[Libreoffice-commits] .: cui/source vcl/inc vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Dec 12 23:18:39 PST 2012
cui/source/dialogs/about.cxx | 39 ++++++++++++++----------------------
vcl/inc/vcl/svapp.hxx | 1
vcl/inc/vcl/svgdata.hxx | 1
vcl/source/app/brand.cxx | 46 ++++++++-----------------------------------
vcl/source/gdi/svgdata.cxx | 29 +++++++++++++++++++++++++++
5 files changed, 55 insertions(+), 61 deletions(-)
New commits:
commit 634ee953f1d090871834f6bc53faafaa7b96b874
Author: Muthu Subramanian <sumuthu at suse.com>
Date: Thu Dec 13 12:37:18 2012 +0530
fdo#56402: SVG in About Dialog.
diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx
index ddc3b46..cc62e89 100644
--- a/cui/source/dialogs/about.cxx
+++ b/cui/source/dialogs/about.cxx
@@ -207,22 +207,19 @@ void AboutDialog::LayoutControls()
Size aLogoSize( aIdealTextWidth, aIdealTextWidth / 20 );
Point aLogoPos( 0, 0 );
-#ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE
- vcl::RenderGraphicRasterizer aRasterizerLogo = Application::LoadBrandSVG("flat_logo");
- if ( !aRasterizerLogo.GetRenderGraphic().IsEmpty() &&
- aRasterizerLogo.GetDefaultSizePixel().Width() > 0 && aRasterizerLogo.GetDefaultSizePixel().Height() > 0 )
+ if( Application::LoadBrandSVG("flat_logo", aLogoBitmap) &&
+ !aLogoBitmap.IsEmpty() )
{
- 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.Height() = aLogoSize.Width() / aLogoWidthHeightRatio ;
+ aLogoBitmap.Scale(aLogoSize);
- aLogoBitmap = aRasterizerLogo.Rasterize( aLogoSize );
aLogoImage.SetImage( Image( aLogoBitmap ) );
aLogoImage.SetPosSizePixel( aLogoPos, aLogoSize );
aLogoImage.Show();
}
else
-#endif
{
aLogoPos.X() = aDialogBorder;
aLogoPos.Y() = aDialogBorder;
@@ -277,27 +274,21 @@ void AboutDialog::LayoutControls()
// Layout background image
-#ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE
- if ( !(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) ) {
- vcl::RenderGraphicRasterizer aRasterizerBackground = Application::LoadBrandSVG("shell/about");
+ if ( !(Application::GetSettings().GetStyleSettings().GetHighContrastMode()) &&
+ Application::LoadBrandSVG("shell/about", aBackgroundBitmap) &&
+ !aBackgroundBitmap.IsEmpty() )
+ {
+ const float aBackgroundWidthHeightRatio = (float)aBackgroundBitmap.GetSizePixel().Width() /
+ (float)aBackgroundBitmap.GetSizePixel().Height();
+ Size aBackgroundSize (aDialogSize.Width(), aDialogSize.Width() / aBackgroundWidthHeightRatio );
- if ( !aRasterizerBackground.GetRenderGraphic().IsEmpty() &&
- aRasterizerBackground.GetDefaultSizePixel().Width() > 0 && aRasterizerBackground.GetDefaultSizePixel().Height() > 0 )
+ if ( aBackgroundSize.Height() < aDialogSize.Height())
{
- const float aBackgroundWidthHeightRatio = (float)aRasterizerBackground.GetDefaultSizePixel().Width() /
- (float)aRasterizerBackground.GetDefaultSizePixel().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 );
+ aBackgroundSize.Width() = aDialogSize.Height() * aBackgroundWidthHeightRatio ;
+ aBackgroundSize.Height() = aDialogSize.Height();
}
+ aBackgroundBitmap.Scale(aBackgroundSize);
}
-#endif
SetOutputSizePixel( aDialogSize );
diff --git a/vcl/inc/vcl/svapp.hxx b/vcl/inc/vcl/svapp.hxx
index 0a1aa56..48b87d1 100644
--- a/vcl/inc/vcl/svapp.hxx
+++ b/vcl/inc/vcl/svapp.hxx
@@ -267,6 +267,7 @@ public:
static void SetAppName( const String& rUniqueName );
static String GetAppName();
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
static void SetDisplayName( const UniString& rDisplayName );
diff --git a/vcl/inc/vcl/svgdata.hxx b/vcl/inc/vcl/svgdata.hxx
index 488092c..dc4c9e5 100644
--- a/vcl/inc/vcl/svgdata.hxx
+++ b/vcl/inc/vcl/svgdata.hxx
@@ -57,6 +57,7 @@ private:
public:
SvgData(const SvgDataArray& rSvgDataArray, sal_uInt32 nSvgDataArrayLength, const rtl::OUString& rPath);
+ SvgData(const rtl::OUString& rPath);
/// data read
const SvgDataArray& getSvgDataArray() const { return maSvgDataArray; }
diff --git a/vcl/source/app/brand.cxx b/vcl/source/app/brand.cxx
index 33b8bdd..03e999a 100644
--- a/vcl/source/app/brand.cxx
+++ b/vcl/source/app/brand.cxx
@@ -24,6 +24,7 @@
#include <tools/stream.hxx>
#include <vcl/pngread.hxx>
#include <vcl/svapp.hxx>
+#include <vcl/svgdata.hxx>
namespace {
static bool loadPng(const char *pPath, const rtl::OUString &rName, BitmapEx &rBitmap)
@@ -40,27 +41,6 @@ namespace {
else
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)
@@ -86,8 +66,7 @@ bool Application::LoadBrandBitmap (const char* pName, BitmapEx &rBitmap)
loadPng ("$BRAND_BASE_DIR/program", aName, rBitmap) );
}
-#ifdef FIXME_REMOVE_WHEN_RE_BASE_COMPLETE
-vcl::RenderGraphicRasterizer Application::LoadBrandSVG (const char* pName)
+bool Application::LoadBrandSVG (const char *pName, BitmapEx &rBitmap)
{
rtl::OUString aBaseName = ( rtl::OUString("/") +
rtl::OUString::createFromAscii( pName ) );
@@ -101,20 +80,13 @@ vcl::RenderGraphicRasterizer Application::LoadBrandSVG (const char* pName)
rtl::OUString aLocaleName = ( aBaseName + rtl::OUString("-") +
aLanguageTag.getBcp47() +
aSvg );
-
- vcl::RenderGraphicRasterizer aRasterizer = loadSvg ("$BRAND_BASE_DIR/program/edition", aLocaleName);
- if (!aRasterizer.GetRenderGraphic().IsEmpty())
- return aRasterizer;
- aRasterizer = loadSvg ("$BRAND_BASE_DIR/program", aLocaleName);
- if (!aRasterizer.GetRenderGraphic().IsEmpty())
- return aRasterizer;
- aRasterizer = loadSvg ("$BRAND_BASE_DIR/program/edition", aName);
- if (!aRasterizer.GetRenderGraphic().IsEmpty())
- return aRasterizer;
-
- aRasterizer = loadSvg ("$BRAND_BASE_DIR/program", aName);
- return aRasterizer;
+ //rtl::OUString uri = rtl::OUString::createFromAscii( "$BRAND_BASE_DIR/program/edition" ) + aLocaleName;
+ rtl::OUString uri = rtl::OUString::createFromAscii( "$BRAND_BASE_DIR/program" ) + aBaseName+aSvg;
+ rtl::Bootstrap::expandMacros( uri );
+ INetURLObject aObj( uri );
+ SvgData aSvgData(aObj.PathToFileName());
+ rBitmap = aSvgData.getReplacement();
+ return true;
}
-#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/svgdata.cxx b/vcl/source/gdi/svgdata.cxx
index 9efce08..f98abcd 100644
--- a/vcl/source/gdi/svgdata.cxx
+++ b/vcl/source/gdi/svgdata.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <tools/stream.hxx>
#include <vcl/svgdata.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
@@ -164,6 +165,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
{
More information about the Libreoffice-commits
mailing list