[Libreoffice-commits] .: Branch 'libreoffice-4-0' - vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Jan 11 02:17:40 PST 2013


 vcl/inc/vcl/settings.hxx          |   10 +++++-----
 vcl/source/app/settings.cxx       |   38 +++++++++++++++-----------------------
 vcl/source/window/dockingarea.cxx |    8 ++++----
 vcl/source/window/menu.cxx        |   12 ++++++------
 4 files changed, 30 insertions(+), 38 deletions(-)

New commits:
commit 5d1137fce2329ff463d11b46ee31ec210254445c
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Wed Jan 9 11:16:47 2013 +0100

    Personas: As Michael suggested, use BitmapEx instead of BitmapEx*.
    
    Change-Id: Ib1d84b37d452785d12502095c0eedaac4a25fb6b
    (cherry picked from commit 0721b5b83e34de1e2fcb320d6a7deae1ad109d61)
    
    Signed-off-by: Miklos Vajna <vmiklos at suse.cz>

diff --git a/vcl/inc/vcl/settings.hxx b/vcl/inc/vcl/settings.hxx
index d4d4438..8e49b2c 100644
--- a/vcl/inc/vcl/settings.hxx
+++ b/vcl/inc/vcl/settings.hxx
@@ -23,13 +23,13 @@
 #include "tools/solar.h"
 #include "vcl/dllapi.h"
 #include "tools/color.hxx"
+#include "vcl/bitmapex.hxx"
 #include "vcl/font.hxx"
 #include "vcl/accel.hxx"
 #include "vcl/wall.hxx"
 #include <i18npool/languagetag.hxx>
 #include <unotools/syslocale.hxx>
 
-class BitmapEx;
 class CollatorWrapper;
 class LocaleDataWrapper;
 
@@ -351,8 +351,8 @@ private:
 
     OUString                        maPersonaHeaderFooter; ///< Cache the settings to detect changes.
 
-    BitmapEx*                       mpPersonaHeaderBitmap; ///< Cache the header bitmap.
-    BitmapEx*                       mpPersonaFooterBitmap; ///< Cache the footer bitmap.
+    BitmapEx                        mpPersonaHeaderBitmap; ///< Cache the header bitmap.
+    BitmapEx                        mpPersonaFooterBitmap; ///< Cache the footer bitmap.
 };
 
 #define DEFAULT_WORKSPACE_GRADIENT_START_COLOR Color( 0xa3, 0xae, 0xb8 )
@@ -866,8 +866,8 @@ public:
     void                            SetFrameStyle( const FrameStyle& rStyle )
                                         { CopyData(); mpData->maFrameStyle = rStyle; }
 
-    const BitmapEx*                 GetPersonaHeader() const;
-    const BitmapEx*                 GetPersonaFooter() const;
+    const BitmapEx                  GetPersonaHeader() const;
+    const BitmapEx                  GetPersonaFooter() const;
 
     void                            SetStandardStyles();
 
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 17d523d..32366fa 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -34,7 +34,6 @@
 #include "vcl/i18nhelp.hxx"
 #include "vcl/configsettings.hxx"
 #include "vcl/gradient.hxx"
-#include "vcl/bitmapex.hxx"
 
 #include "unotools/fontcfg.hxx"
 #include "unotools/localedatawrapper.hxx"
@@ -204,8 +203,8 @@ sal_Bool MouseSettings::operator ==( const MouseSettings& rSet ) const
 
 ImplStyleData::ImplStyleData() :
     maPersonaHeaderFooter(),
-    mpPersonaHeaderBitmap( NULL ),
-    mpPersonaFooterBitmap( NULL )
+    mpPersonaHeaderBitmap(),
+    mpPersonaFooterBitmap()
 {
     mnRefCount                  = 1;
     mnScrollBarSize             = 16;
@@ -305,8 +304,8 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
     maDialogStyle( rData.maDialogStyle ),
     maFrameStyle( rData.maFrameStyle ),
     maPersonaHeaderFooter( rData.maPersonaHeaderFooter ),
-    mpPersonaHeaderBitmap( rData.mpPersonaHeaderBitmap? new BitmapEx( *rData.mpPersonaHeaderBitmap ): NULL ),
-    mpPersonaFooterBitmap( rData.mpPersonaFooterBitmap? new BitmapEx( *rData.mpPersonaFooterBitmap ): NULL )
+    mpPersonaHeaderBitmap( rData.mpPersonaHeaderBitmap ),
+    mpPersonaFooterBitmap( rData.mpPersonaFooterBitmap )
 {
     mnRefCount                  = 1;
     mnBorderSize                = rData.mnBorderSize;
@@ -687,7 +686,7 @@ sal_Bool StyleSettings::GetUseImagesInMenus() const
 
 // -----------------------------------------------------------------------
 
-static BitmapEx* readBitmapEx( const OUString& rPath )
+static BitmapEx readBitmapEx( const OUString& rPath )
 {
     OUString aPath( rPath );
     rtl::Bootstrap::expandMacros( aPath );
@@ -695,19 +694,15 @@ static BitmapEx* readBitmapEx( const OUString& rPath )
     // import the image
     Graphic aGraphic;
     if ( GraphicFilter::LoadGraphic( aPath, String(), aGraphic ) != GRFILTER_OK )
-        return NULL;
+        return BitmapEx();
 
-    const BitmapEx& rBitmap( aGraphic.GetBitmapEx() );
-    if ( rBitmap.IsEmpty() )
-        return NULL;
-
-    return new BitmapEx( rBitmap );
+    return aGraphic.GetBitmapEx();
 }
 
 enum WhichPersona { PERSONA_HEADER, PERSONA_FOOTER };
 
 /** Update the setting of the Persona header / footer in ImplStyleData */
-static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFooter, BitmapEx*& pHeaderFooterBitmap )
+static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFooter, BitmapEx& rHeaderFooterBitmap )
 {
     uno::Reference< uno::XComponentContext > xContext( comphelper::getProcessComponentContext() );
     if ( !xContext.is() )
@@ -745,9 +740,6 @@ static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFoot
         case PERSONA_FOOTER: aName = aFooter; break;
     }
 
-    delete pHeaderFooterBitmap;
-    pHeaderFooterBitmap = NULL;
-
     if ( !aName.isEmpty() )
     {
         // try the gallery first, then edition, and the program path if
@@ -757,23 +749,23 @@ static void setupPersonaHeaderFooter( WhichPersona eWhich, OUString& rHeaderFoot
         gallery += "/user/gallery/personas/";
 
         if ( aPersona == "own" )
-            pHeaderFooterBitmap = readBitmapEx( gallery + aName );
+            rHeaderFooterBitmap = readBitmapEx( gallery + aName );
 
-        if ( !pHeaderFooterBitmap )
-            pHeaderFooterBitmap = readBitmapEx( "$BRAND_BASE_DIR/program/edition/" + aName );
+        if ( rHeaderFooterBitmap.IsEmpty() )
+            rHeaderFooterBitmap = readBitmapEx( "$BRAND_BASE_DIR/program/edition/" + aName );
 
-        if ( !pHeaderFooterBitmap )
-            pHeaderFooterBitmap = readBitmapEx( "$BRAND_BASE_DIR/program/" + aName );
+        if ( rHeaderFooterBitmap.IsEmpty() )
+            rHeaderFooterBitmap = readBitmapEx( "$BRAND_BASE_DIR/program/" + aName );
     }
 }
 
-const BitmapEx* StyleSettings::GetPersonaHeader() const
+const BitmapEx StyleSettings::GetPersonaHeader() const
 {
     setupPersonaHeaderFooter( PERSONA_HEADER, mpData->maPersonaHeaderFooter, mpData->mpPersonaHeaderBitmap );
     return mpData->mpPersonaHeaderBitmap;
 }
 
-const BitmapEx* StyleSettings::GetPersonaFooter() const
+const BitmapEx StyleSettings::GetPersonaFooter() const
 {
     setupPersonaHeaderFooter( PERSONA_FOOTER, mpData->maPersonaHeaderFooter, mpData->mpPersonaFooterBitmap );
     return mpData->mpPersonaFooterBitmap;
diff --git a/vcl/source/window/dockingarea.cxx b/vcl/source/window/dockingarea.cxx
index 8269c5e..e20265d 100644
--- a/vcl/source/window/dockingarea.cxx
+++ b/vcl/source/window/dockingarea.cxx
@@ -50,10 +50,10 @@ DockingAreaWindow::ImplData::~ImplData()
 
 static void ImplInitBackground( DockingAreaWindow* pThis )
 {
-    const BitmapEx* pPersonaBitmap = Application::GetSettings().GetStyleSettings().GetPersonaHeader();
-    if ( pPersonaBitmap != NULL && pThis->GetAlign() == WINDOWALIGN_TOP )
+    const BitmapEx& rPersonaBitmap = Application::GetSettings().GetStyleSettings().GetPersonaHeader();
+    if ( !rPersonaBitmap.IsEmpty() && pThis->GetAlign() == WINDOWALIGN_TOP )
     {
-        Wallpaper aWallpaper( *pPersonaBitmap );
+        Wallpaper aWallpaper( rPersonaBitmap );
         aWallpaper.SetStyle( WALLPAPER_TOPRIGHT );
 
         // we need to shift the bitmap vertically so that it spans over the
@@ -175,7 +175,7 @@ void DockingAreaWindow::Paint( const Rectangle& )
         }
         ControlState        nState = CTRL_STATE_ENABLED;
 
-        if ( GetAlign() == WINDOWALIGN_TOP && Application::GetSettings().GetStyleSettings().GetPersonaHeader() )
+        if ( GetAlign() == WINDOWALIGN_TOP && !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
             Erase();
         else if ( !ImplGetSVData()->maNWFData.mbDockingAreaSeparateTB )
         {
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 5fe08d1..ec35098 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -3856,10 +3856,10 @@ static void ImplInitMenuWindow( Window* pWin, sal_Bool bFont, sal_Bool bMenuBar
         pWin->SetPointFont( rStyleSettings.GetMenuFont() );
     if( bMenuBar )
     {
-        const BitmapEx* pPersonaBitmap = Application::GetSettings().GetStyleSettings().GetPersonaHeader();
-        if ( pPersonaBitmap != NULL )
+        const BitmapEx& rPersonaBitmap = Application::GetSettings().GetStyleSettings().GetPersonaHeader();
+        if ( !rPersonaBitmap.IsEmpty() )
         {
-            Wallpaper aWallpaper( *pPersonaBitmap );
+            Wallpaper aWallpaper( rPersonaBitmap );
             aWallpaper.SetStyle( WALLPAPER_TOPRIGHT );
             pWin->SetBackground( aWallpaper );
             pWin->SetPaintTransparent( sal_False );
@@ -5503,7 +5503,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, sal_Bool bHighlight )
                         MenubarValue aControlValue;
                         aControlValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
 
-                        if ( Application::GetSettings().GetStyleSettings().GetPersonaHeader() )
+                        if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
                             Erase();
                         else
                         {
@@ -5539,7 +5539,7 @@ void MenuBarWindow::HighlightItem( sal_uInt16 nPos, sal_Bool bHighlight )
                         MenubarValue aMenubarValue;
                         aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
 
-                        if ( Application::GetSettings().GetStyleSettings().GetPersonaHeader() )
+                        if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
                             Erase( aRect );
                         else
                         {
@@ -5775,7 +5775,7 @@ void MenuBarWindow::Paint( const Rectangle& )
         MenubarValue aMenubarValue;
         aMenubarValue.maTopDockingAreaHeight = ImplGetTopDockingAreaHeight( this );
 
-        if ( Application::GetSettings().GetStyleSettings().GetPersonaHeader() )
+        if ( !Application::GetSettings().GetStyleSettings().GetPersonaHeader().IsEmpty() )
             Erase();
         else
         {


More information about the Libreoffice-commits mailing list