Kaydet (Commit) 634ee953 authored tarafından Muthu Subramanian's avatar Muthu Subramanian

fdo#56402: SVG in About Dialog.

üst 6b5059c7
...@@ -207,22 +207,19 @@ void AboutDialog::LayoutControls() ...@@ -207,22 +207,19 @@ void AboutDialog::LayoutControls()
Size aLogoSize( aIdealTextWidth, aIdealTextWidth / 20 ); Size aLogoSize( aIdealTextWidth, aIdealTextWidth / 20 );
Point aLogoPos( 0, 0 ); Point aLogoPos( 0, 0 );
#ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE if( Application::LoadBrandSVG("flat_logo", aLogoBitmap) &&
vcl::RenderGraphicRasterizer aRasterizerLogo = Application::LoadBrandSVG("flat_logo"); !aLogoBitmap.IsEmpty() )
if ( !aRasterizerLogo.GetRenderGraphic().IsEmpty() &&
aRasterizerLogo.GetDefaultSizePixel().Width() > 0 && aRasterizerLogo.GetDefaultSizePixel().Height() > 0 )
{ {
const float aLogoWidthHeightRatio = (float)aRasterizerLogo.GetDefaultSizePixel().Width() / (float)aRasterizerLogo.GetDefaultSizePixel().Height(); const float aLogoWidthHeightRatio = (float)aLogoBitmap.GetSizePixel().Width() / (float)aLogoBitmap.GetSizePixel().Height();
aLogoSize.Width() = aDialogSize.Width() ; aLogoSize.Width() = aDialogSize.Width() ;
aLogoSize.Height() = aLogoSize.Width() / aLogoWidthHeightRatio ; aLogoSize.Height() = aLogoSize.Width() / aLogoWidthHeightRatio ;
aLogoBitmap.Scale(aLogoSize);
aLogoBitmap = aRasterizerLogo.Rasterize( aLogoSize );
aLogoImage.SetImage( Image( aLogoBitmap ) ); aLogoImage.SetImage( Image( aLogoBitmap ) );
aLogoImage.SetPosSizePixel( aLogoPos, aLogoSize ); aLogoImage.SetPosSizePixel( aLogoPos, aLogoSize );
aLogoImage.Show(); aLogoImage.Show();
} }
else else
#endif
{ {
aLogoPos.X() = aDialogBorder; aLogoPos.X() = aDialogBorder;
aLogoPos.Y() = aDialogBorder; aLogoPos.Y() = aDialogBorder;
...@@ -277,27 +274,21 @@ void AboutDialog::LayoutControls() ...@@ -277,27 +274,21 @@ void AboutDialog::LayoutControls()
// Layout background image // Layout background image
#ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE if ( !(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) &&
if ( !(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) ) { Application::LoadBrandSVG("shell/about", aBackgroundBitmap) &&
vcl::RenderGraphicRasterizer aRasterizerBackground = Application::LoadBrandSVG("shell/about"); !aBackgroundBitmap.IsEmpty() )
{
const float aBackgroundWidthHeightRatio = (float)aBackgroundBitmap.GetSizePixel().Width() /
(float)aBackgroundBitmap.GetSizePixel().Height();
Size aBackgroundSize (aDialogSize.Width(), aDialogSize.Width() / aBackgroundWidthHeightRatio );
if ( !aRasterizerBackground.GetRenderGraphic().IsEmpty() && if ( aBackgroundSize.Height() < aDialogSize.Height())
aRasterizerBackground.GetDefaultSizePixel().Width() > 0 && aRasterizerBackground.GetDefaultSizePixel().Height() > 0 )
{ {
const float aBackgroundWidthHeightRatio = (float)aRasterizerBackground.GetDefaultSizePixel().Width() / aBackgroundSize.Width() = aDialogSize.Height() * aBackgroundWidthHeightRatio ;
(float)aRasterizerBackground.GetDefaultSizePixel().Height(); aBackgroundSize.Height() = aDialogSize.Height();
Size aBackgroundSize (aDialogSize.Width(), aDialogSize.Width() / aBackgroundWidthHeightRatio );
if ( aBackgroundSize.Height() < aDialogSize.Height())
{
aBackgroundSize.Width() = aDialogSize.Height() * aBackgroundWidthHeightRatio ;
aBackgroundSize.Height() = aDialogSize.Height();
}
aBackgroundBitmap = aRasterizerBackground.Rasterize( aBackgroundSize );
} }
aBackgroundBitmap.Scale(aBackgroundSize);
} }
#endif
SetOutputSizePixel( aDialogSize ); SetOutputSizePixel( aDialogSize );
......
...@@ -267,6 +267,7 @@ public: ...@@ -267,6 +267,7 @@ public:
static void SetAppName( const String& rUniqueName ); static void SetAppName( const String& rUniqueName );
static String GetAppName(); static String GetAppName();
static bool LoadBrandBitmap (const char* pName, BitmapEx &rBitmap); static bool LoadBrandBitmap (const char* pName, BitmapEx &rBitmap);
static bool LoadBrandSVG( const char *pName, BitmapEx &rBitmap );
// default name of the application for message dialogs and printing // default name of the application for message dialogs and printing
static void SetDisplayName( const UniString& rDisplayName ); static void SetDisplayName( const UniString& rDisplayName );
......
...@@ -57,6 +57,7 @@ private: ...@@ -57,6 +57,7 @@ private:
public: public:
SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const rtl::OUString& rPath); SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const rtl::OUString& rPath);
SvgData(const rtl::OUString& rPath);
/// data read /// data read
const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; } const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <vcl/pngread.hxx> #include <vcl/pngread.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/svgdata.hxx>
namespace { namespace {
static bool loadPng(const char *pPath, const rtl::OUString &rName, BitmapEx &rBitmap) static bool loadPng(const char *pPath, const rtl::OUString &rName, BitmapEx &rBitmap)
...@@ -40,27 +41,6 @@ namespace { ...@@ -40,27 +41,6 @@ namespace {
else else
return false; return false;
} }
#ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE
static vcl::RenderGraphicRasterizer loadSvg(const char *pPath, const rtl::OUString &rName)
{
rtl::OUString uri = rtl::OUString::createFromAscii( pPath ) + rName;
rtl::Bootstrap::expandMacros( uri );
INetURLObject aObj( uri );
SvFileStream aStrm( aObj.PathToFileName(), STREAM_STD_READ );
vcl::RenderGraphic aRenderGraphic;
vcl::RenderGraphic aRasterizer ( aRenderGraphic );
if ( !aStrm.GetError() ) {
vcl::SVGReader aSVGReader( aStrm );
aRenderGraphic = aSVGReader.GetRenderGraphic();
vcl::RenderGraphic aNewRasterizer ( aRenderGraphic );
aRasterizer = aNewRasterizer;
}
return aRasterizer;
}
#endif
} }
bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap) bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap)
...@@ -86,8 +66,7 @@ bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap) ...@@ -86,8 +66,7 @@ bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap)
loadPng ("$BRAND_BASE_DIR/program", aName, rBitmap) ); loadPng ("$BRAND_BASE_DIR/program", aName, rBitmap) );
} }
#ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE bool Application::LoadBrandSVG (const char *pName, BitmapEx &rBitmap)
vcl::RenderGraphicRasterizer Application::LoadBrandSVG (const char* pName)
{ {
rtl::OUString aBaseName = ( rtl::OUString("/") + rtl::OUString aBaseName = ( rtl::OUString("/") +
rtl::OUString::createFromAscii( pName ) ); rtl::OUString::createFromAscii( pName ) );
...@@ -101,20 +80,13 @@ vcl::RenderGraphicRasterizer Application::LoadBrandSVG (const char* pName) ...@@ -101,20 +80,13 @@ vcl::RenderGraphicRasterizer Application::LoadBrandSVG (const char* pName)
rtl::OUString aLocaleName = ( aBaseName + rtl::OUString("-") + rtl::OUString aLocaleName = ( aBaseName + rtl::OUString("-") +
aLanguageTag.getBcp47() + aLanguageTag.getBcp47() +
aSvg ); aSvg );
//rtl::OUString uri = rtl::OUString::createFromAscii( "$BRAND_BASE_DIR/program/edition" ) + aLocaleName;
vcl::RenderGraphicRasterizer aRasterizer = loadSvg ("$BRAND_BASE_DIR/program/edition", aLocaleName); rtl::OUString uri = rtl::OUString::createFromAscii( "$BRAND_BASE_DIR/program" ) + aBaseName+aSvg;
if (!aRasterizer.GetRenderGraphic().IsEmpty()) rtl::Bootstrap::expandMacros( uri );
return aRasterizer; INetURLObject aObj( uri );
aRasterizer = loadSvg ("$BRAND_BASE_DIR/program", aLocaleName); SvgData aSvgData(aObj.PathToFileName());
if (!aRasterizer.GetRenderGraphic().IsEmpty()) rBitmap = aSvgData.getReplacement();
return aRasterizer; return true;
aRasterizer = loadSvg ("$BRAND_BASE_DIR/program/edition", aName);
if (!aRasterizer.GetRenderGraphic().IsEmpty())
return aRasterizer;
aRasterizer = loadSvg ("$BRAND_BASE_DIR/program", aName);
return aRasterizer;
} }
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <tools/stream.hxx>
#include <vcl/svgdata.hxx> #include <vcl/svgdata.hxx>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
...@@ -163,6 +164,34 @@ SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLeng ...@@ -163,6 +164,34 @@ SvgData::SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLeng
{ {
} }
//////////////////////////////////////////////////////////////////////////////
SvgData::SvgData(const OUString& rPath):
maSvgDataArray(NULL),
mnSvgDataArrayLength(0),
maPath(rPath),
maRange(),
maSequence(),
maReplacement()
{
SvFileStream rIStm(rPath, STREAM_STD_READ);
if(rIStm.GetError())
return;
const sal_uInt32 nStmPos(rIStm.Tell());
const sal_uInt32 nStmLen(rIStm.Seek(STREAM_SEEK_TO_END) - nStmPos);
if(nStmLen)
{
SvgDataArray aNewData(new sal_uInt8[nStmLen]);
rIStm.Seek(nStmPos);
rIStm.Read(aNewData.get(), nStmLen);
if(!rIStm.GetError())
{
maSvgDataArray = aNewData;
mnSvgDataArrayLength = nStmLen;
}
}
}
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
const basegfx::B2DRange& SvgData::getRange() const const basegfx::B2DRange& SvgData::getRange() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment