[Libreoffice-commits] core.git: framework/source include/framework sfx2/source

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Fri Jun 26 14:49:41 UTC 2020


 framework/source/fwe/classes/addonsoptions.cxx              |   50 +++++-------
 framework/source/fwe/helper/actiontriggerhelper.cxx         |    2 
 framework/source/uielement/FixedImageToolbarController.cxx  |    2 
 framework/source/uielement/addonstoolbarmanager.cxx         |    6 -
 framework/source/uielement/imagebuttontoolbarcontroller.cxx |    2 
 framework/source/uielement/menubarmanager.cxx               |    2 
 framework/source/uielement/toolbarmanager.cxx               |    4 
 include/framework/addonsoptions.hxx                         |    4 
 sfx2/source/notebookbar/SfxNotebookBar.cxx                  |    4 
 9 files changed, 36 insertions(+), 40 deletions(-)

New commits:
commit 8f1569568a2816dd4c6e4d9f015557d451ccfadf
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Fri Jun 26 14:38:44 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Fri Jun 26 16:49:07 2020 +0200

    use underlying BitmapEx
    
    Change-Id: I1ddc5a50a54bb230af1c76a8098c68fdb0495df0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97234
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx
index 725bec2f5405..faa8ffdc5713 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -227,7 +227,7 @@ class AddonsOptions_Impl : public ConfigItem
         OUString                                        GetAddonsToolbarResourceName( sal_uInt32 nIndex ) const;
         OUString                                        GetAddonsNotebookBarResourceName( sal_uInt32 nIndex ) const;
         const Sequence< Sequence< PropertyValue > >&    GetAddonsHelpMenu    () const { return m_aCachedHelpMenuProperties;}
-        Image                                           GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale );
+        BitmapEx                                        GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale );
         const MergeMenuInstructionContainer&            GetMergeMenuInstructions() const { return m_aCachedMergeMenuInsContainer;}
         bool                                            GetMergeToolbarInstructions( const OUString& rToolbarName, MergeToolbarInstructionContainer& rToolbarInstructions ) const;
         bool                                            GetMergeNotebookBarInstructions( const OUString& rNotebookBarName, MergeNotebookBarInstructionContainer& rNotebookBarInstructions ) const;
@@ -243,8 +243,8 @@ class AddonsOptions_Impl : public ConfigItem
 
         struct OneImageEntry
         {
-            Image    aScaled;   ///< cached scaled image
-            Image    aImage;    ///< original un-scaled image
+            BitmapEx aScaled;   ///< cached scaled image
+            BitmapEx aImage;    ///< original un-scaled image
             OUString aURL;      ///< URL in case it is not loaded yet
         };
 
@@ -256,7 +256,7 @@ class AddonsOptions_Impl : public ConfigItem
             // accessed in this order
             OneImageEntry aSizeEntry[2];
             ImageEntry() {}
-            void addImage(ImageSize eSize, const Image &rImage, const OUString &rURL);
+            void addImage(ImageSize eSize, const BitmapEx &rImage, const OUString &rURL);
         };
 
         typedef std::unordered_map< OUString, ImageEntry > ImageManager;
@@ -301,7 +301,7 @@ class AddonsOptions_Impl : public ConfigItem
         bool                 ReadStatusBarItem( const OUString& aStatusbarItemNodeName, Sequence< PropertyValue >& aStatusbarItem );
         std::unique_ptr<ImageEntry> ReadImageData( const OUString& aImagesNodeName );
         void                 ReadAndAssociateImages( const OUString& aURL, const OUString& aImageId );
-        Image                ReadImageFromURL( const OUString& aURL );
+        BitmapEx             ReadImageFromURL( const OUString& aURL );
         bool                 HasAssociatedImages( const OUString& aURL );
         void                 SubstituteVariables( OUString& aURL );
 
@@ -315,7 +315,7 @@ class AddonsOptions_Impl : public ConfigItem
 
         Sequence< OUString > GetPropertyNamesStatusbarItem( const OUString& aPropertyRootNode ) const;
         Sequence< OUString > GetPropertyNamesImages( const OUString& aPropertyRootNode ) const;
-        bool                 CreateImageFromSequence( Image& rImage, Sequence< sal_Int8 >& rBitmapDataSeq ) const;
+        bool                 CreateImageFromSequence( BitmapEx& rImage, Sequence< sal_Int8 >& rBitmapDataSeq ) const;
 
         DECL_LINK(NotifyEvent, void*, void);
 
@@ -350,7 +350,7 @@ class AddonsOptions_Impl : public ConfigItem
 };
 
 void AddonsOptions_Impl::ImageEntry::addImage(ImageSize eSize,
-                                              const Image &rImage,
+                                              const BitmapEx& rImage,
                                               const OUString &rURL)
 {
     aSizeEntry[static_cast<int>(eSize)].aImage = rImage;
@@ -577,19 +577,19 @@ bool AddonsOptions_Impl::GetMergeNotebookBarInstructions(
 
 //  public method
 
-static Image ScaleImage( const Image &rImage, bool bBig )
+static BitmapEx ScaleImage( const BitmapEx &rImage, bool bBig )
 {
     Size aSize = ToolBox::GetDefaultImageSize(bBig ? ToolBoxButtonSize::Large : ToolBoxButtonSize::Small);
-    BitmapEx aScaleBmp(rImage.GetBitmapEx());
+    BitmapEx aScaleBmp(rImage);
     SAL_INFO("fwk", "Addons: expensive scale image from "
              << aScaleBmp.GetSizePixel() << " to " << aSize);
     aScaleBmp.Scale(aSize, BmpScaleFlag::BestQuality);
-    return Image(aScaleBmp);
+    return aScaleBmp;
 }
 
-Image AddonsOptions_Impl::GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale )
+BitmapEx AddonsOptions_Impl::GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale )
 {
-    Image aImage;
+    BitmapEx aImage;
 
     SAL_INFO("fwk", "Expensive: Addons GetImageFromURL " << aURL <<
              " big " << (bBig?"big":"little") <<
@@ -1561,9 +1561,9 @@ void AddonsOptions_Impl::SubstituteVariables( OUString& aURL )
         comphelper::getProcessComponentContext(), aURL);
 }
 
-Image AddonsOptions_Impl::ReadImageFromURL(const OUString& aImageURL)
+BitmapEx AddonsOptions_Impl::ReadImageFromURL(const OUString& aImageURL)
 {
-    Image aImage;
+    BitmapEx aImage;
 
     std::unique_ptr<SvStream> pStream = UcbStreamHelper::CreateStream( aImageURL, StreamMode::STD_READ );
     if ( pStream && ( pStream->GetErrorCode() == ERRCODE_NONE ))
@@ -1583,7 +1583,7 @@ Image AddonsOptions_Impl::ReadImageFromURL(const OUString& aImageURL)
             if( !aBitmapEx.IsTransparent() )
                 aBitmapEx = BitmapEx( aBitmapEx.GetBitmap(), COL_LIGHTMAGENTA );
 
-            aImage = Image(aBitmapEx);
+            aImage = aBitmapEx;
         }
     }
 
@@ -1609,7 +1609,7 @@ void AddonsOptions_Impl::ReadAndAssociateImages( const OUString& aURL, const OUS
         aFileURL.append( ".bmp" );
 
         aImageEntry.addImage( !i ? IMGSIZE_SMALL : IMGSIZE_BIG,
-                              Image(), aFileURL.makeStringAndClear() );
+                              BitmapEx(), aFileURL.makeStringAndClear() );
     }
 
     m_aImageManager.emplace( aURL, aImageEntry );
@@ -1632,7 +1632,7 @@ std::unique_ptr<AddonsOptions_Impl::ImageEntry> AddonsOptions_Impl::ReadImageDat
         if ( i < PROPERTYCOUNT_EMBEDDED_IMAGES )
         {
             // Extract image data from the embedded hex binary sequence
-            Image aImage;
+            BitmapEx aImage;
             if (( aPropertyData[i] >>= aImageDataSeq ) &&
                 aImageDataSeq.hasElements() &&
                 ( CreateImageFromSequence( aImage, aImageDataSeq ) ) )
@@ -1653,31 +1653,29 @@ std::unique_ptr<AddonsOptions_Impl::ImageEntry> AddonsOptions_Impl::ReadImageDat
 
             SubstituteVariables( aImageURL );
 
-            pEntry->addImage(IMGSIZE_BIG, Image(), aImageURL);
+            pEntry->addImage(IMGSIZE_BIG, BitmapEx(), aImageURL);
         }
     }
 
     return pEntry;
 }
 
-bool AddonsOptions_Impl::CreateImageFromSequence( Image& rImage, Sequence< sal_Int8 >& rBitmapDataSeq ) const
+bool AddonsOptions_Impl::CreateImageFromSequence( BitmapEx& rImage, Sequence< sal_Int8 >& rBitmapDataSeq ) const
 {
     bool bResult = false;
 
     if ( rBitmapDataSeq.hasElements() )
     {
         SvMemoryStream  aMemStream( rBitmapDataSeq.getArray(), rBitmapDataSeq.getLength(), StreamMode::STD_READ );
-        BitmapEx        aBitmapEx;
 
-        ReadDIBBitmapEx(aBitmapEx, aMemStream);
+        ReadDIBBitmapEx(rImage, aMemStream);
 
-        if( !aBitmapEx.IsTransparent() )
+        if( !rImage.IsTransparent() )
         {
             // Support non-transparent bitmaps to be downward compatible with OOo 1.1.x addons
-            aBitmapEx = BitmapEx( aBitmapEx.GetBitmap(), COL_LIGHTMAGENTA );
+            rImage = BitmapEx( rImage.GetBitmap(), COL_LIGHTMAGENTA );
         }
 
-        rImage = Image( aBitmapEx );
         bResult = true;
     }
 
@@ -1925,7 +1923,7 @@ const MergeStatusbarInstructionContainer& AddonsOptions::GetMergeStatusbarInstru
 
 //  public method
 
-Image AddonsOptions::GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale ) const
+BitmapEx AddonsOptions::GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale ) const
 {
     MutexGuard aGuard( GetOwnStaticMutex() );
     return m_pImpl->GetImageFromURL( aURL, bBig, bNoScale );
@@ -1933,7 +1931,7 @@ Image AddonsOptions::GetImageFromURL( const OUString& aURL, bool bBig, bool bNoS
 
 //  public method
 
-Image AddonsOptions::GetImageFromURL( const OUString& aURL, bool bBig ) const
+BitmapEx AddonsOptions::GetImageFromURL( const OUString& aURL, bool bBig ) const
 {
     return GetImageFromURL( aURL, bBig, false );
 }
diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx
index deb14f0e1e2e..a8fe71861116 100644
--- a/framework/source/fwe/helper/actiontriggerhelper.cxx
+++ b/framework/source/fwe/helper/actiontriggerhelper.cxx
@@ -201,7 +201,7 @@ static void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, const Refer
                         else
                         {
                             // Support add-on images for context menu interceptors
-                            Image aImage = aAddonOptions.GetImageFromURL( aCommandURL, false, true );
+                            Image aImage(aAddonOptions.GetImageFromURL(aCommandURL, false, true));
                             if ( !!aImage )
                                 pSubMenu->SetItemImage( nNewItemId, aImage );
                         }
diff --git a/framework/source/uielement/FixedImageToolbarController.cxx b/framework/source/uielement/FixedImageToolbarController.cxx
index c42bb518a8e7..cfc987d97d3f 100644
--- a/framework/source/uielement/FixedImageToolbarController.cxx
+++ b/framework/source/uielement/FixedImageToolbarController.cxx
@@ -47,7 +47,7 @@ FixedImageToolbarController::FixedImageToolbarController(
 
     bool bBigImages(SvtMiscOptions().AreCurrentSymbolsLarge());
 
-    Image aImage = AddonsOptions().GetImageFromURL(aCommand, bBigImages, true);
+    Image aImage(AddonsOptions().GetImageFromURL(aCommand, bBigImages, true));
     m_pFixedImageControl->SetImage(aImage);
     m_pFixedImageControl->SetSizePixel(m_pFixedImageControl->GetOptimalSize());
 
diff --git a/framework/source/uielement/addonstoolbarmanager.cxx b/framework/source/uielement/addonstoolbarmanager.cxx
index e2d61259943f..9a850e0bc39e 100644
--- a/framework/source/uielement/addonstoolbarmanager.cxx
+++ b/framework/source/uielement/addonstoolbarmanager.cxx
@@ -96,11 +96,9 @@ static Image RetrieveImage( Reference< css::frame::XFrame > const & rFrame,
     if (bBigImage)
         eImageType = vcl::ImageType::Size26;
 
-    Image aImage;
-
     if ( !aImageId.isEmpty() )
     {
-        aImage = framework::AddonsOptions().GetImageFromURL( aImageId, bBigImage );
+        Image aImage(framework::AddonsOptions().GetImageFromURL(aImageId, bBigImage));
         if ( !!aImage )
             return aImage;
         else
@@ -109,7 +107,7 @@ static Image RetrieveImage( Reference< css::frame::XFrame > const & rFrame,
             return aImage;
     }
 
-    aImage = framework::AddonsOptions().GetImageFromURL( aURL, bBigImage );
+    Image aImage(framework::AddonsOptions().GetImageFromURL(aURL, bBigImage));
     if ( !aImage )
         aImage = vcl::CommandInfoProvider::GetImageForCommand(aImageId, rFrame, eImageType);
 
diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
index 5c0cbeba873f..c14606db0000 100644
--- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx
+++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx
@@ -63,7 +63,7 @@ ImageButtonToolbarController::ImageButtonToolbarController(
 {
     bool bBigImages( SvtMiscOptions().AreCurrentSymbolsLarge() );
 
-    Image aImage = AddonsOptions().GetImageFromURL( aCommand, bBigImages, true );
+    Image aImage(AddonsOptions().GetImageFromURL(aCommand, bBigImages, true));
 
     // Height will be controlled by scaling according to button height
     m_xToolbar->SetItemImage( m_nID, aImage );
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index 29bc7f3e4643..21a4c82b731b 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -1873,7 +1873,7 @@ void MenuBarManager::FillMenuImages(Reference< XFrame > const & _xFrame, Menu* _
                     OUString aMenuItemCommand = _pMenu->GetItemCommand( nId );
                     Image aImage = vcl::CommandInfoProvider::GetImageForCommand(aMenuItemCommand, _xFrame);
                     if ( !aImage )
-                        aImage = aAddonOptions.GetImageFromURL( aMenuItemCommand, false );
+                        aImage = Image(aAddonOptions.GetImageFromURL(aMenuItemCommand, false));
 
                     _pMenu->SetItemImage( nId, aImage );
                 }
diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx
index 670b30873233..07e5fd1b1a83 100644
--- a/framework/source/uielement/toolbarmanager.cxx
+++ b/framework/source/uielement/toolbarmanager.cxx
@@ -321,7 +321,7 @@ void ToolBarManager::RefreshImages()
             // empty image.
             bool bBigImages = eImageType != vcl::ImageType::Size16;
             if ( !aImage )
-                aImage = framework::AddonsOptions().GetImageFromURL(aCommandURL, bBigImages);
+                aImage = Image(framework::AddonsOptions().GetImageFromURL(aCommandURL, bBigImages));
             m_pToolBar->SetItemImage( it.first, aImage );
         }
     }
@@ -1263,7 +1263,7 @@ void ToolBarManager::RequestImages()
             // Try also to query for add-on images before giving up and use an
             // empty image.
             if ( !aImage )
-                aImage = framework::AddonsOptions().GetImageFromURL( aCmdURLSeq[i], aMiscOptions.AreCurrentSymbolsLarge());
+                aImage = Image(framework::AddonsOptions().GetImageFromURL(aCmdURLSeq[i], aMiscOptions.AreCurrentSymbolsLarge()));
 
             pIter->second.nImageInfo = 1; // mark image as module based
         }
diff --git a/include/framework/addonsoptions.hxx b/include/framework/addonsoptions.hxx
index deb53e2a1e7e..0f14b8e2323a 100644
--- a/include/framework/addonsoptions.hxx
+++ b/include/framework/addonsoptions.hxx
@@ -238,8 +238,8 @@ class UNLESS_MERGELIBS(FWE_DLLPUBLIC) AddonsOptions
             @onerror    An empty image
         *//*-*****************************************************************************************************/
 
-        Image GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale ) const;
-        Image GetImageFromURL( const OUString& aURL, bool bBig ) const;
+        BitmapEx GetImageFromURL( const OUString& aURL, bool bBig, bool bNoScale ) const;
+        BitmapEx GetImageFromURL( const OUString& aURL, bool bBig ) const;
 
     //  private methods
 
diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx
index 674caf4b0bb0..3a2cbae0d596 100644
--- a/sfx2/source/notebookbar/SfxNotebookBar.cxx
+++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx
@@ -63,7 +63,7 @@ static void NotebookbarAddonValues(
                 if (rProp.Name == MERGE_NOTEBOOKBAR_IMAGEID)
                 {
                     rProp.Value >>= sImage;
-                    aImage = framework::AddonsOptions().GetImageFromURL(sImage, isBigImage);
+                    aImage = Image(framework::AddonsOptions().GetImageFromURL(sImage, isBigImage));
                 }
             }
             if(!aImage)
@@ -74,7 +74,7 @@ static void NotebookbarAddonValues(
                     if (rProp.Name == MERGE_NOTEBOOKBAR_URL)
                     {
                         rProp.Value >>= sImage;
-                        aImage = framework::AddonsOptions().GetImageFromURL(sImage, isBigImage);
+                        aImage = Image(framework::AddonsOptions().GetImageFromURL(sImage, isBigImage));
                     }
                 }
             }


More information about the Libreoffice-commits mailing list