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

Maxim Monastirsky (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 8 20:26:02 UTC 2020


 framework/source/uiconfiguration/imagemanagerimpl.cxx |   23 +++++-------------
 1 file changed, 7 insertions(+), 16 deletions(-)

New commits:
commit a3ca36086bdc69e4e3da41cd1d41e9d5228b06b6
Author:     Maxim Monastirsky <momonasmon at gmail.com>
AuthorDate: Mon Sep 7 23:59:03 2020 +0300
Commit:     Maxim Monastirsky <momonasmon at gmail.com>
CommitDate: Tue Sep 8 22:25:19 2020 +0200

    Related: tdf#130445 Fix custom icon scale check
    
    There were two problems here:
    
    - For large size 26x26 was specified, but this was the case
    only for Galaxy. All other themes have 24x24, and that's the
    size specified also in the icon selection dialog (See
    SvxIconSelectorDialog::SvxIconSelectorDialog).
    
    - When a wrong size detected, the image was always scaled to
    16x16, instead of to the current image size.
    
    Change-Id: I586abfd01441d6b1cdbf1dd011b0e12a31f02dd4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102225
    Tested-by: Jenkins
    Reviewed-by: Maxim Monastirsky <momonasmon at gmail.com>

diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index e17649ca8176..ae3aafef0113 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -214,32 +214,23 @@ bool GlobalImageList::hasImage( vcl::ImageType nImageType, const OUString& rComm
 
 static bool implts_checkAndScaleGraphic( uno::Reference< XGraphic >& rOutGraphic, const uno::Reference< XGraphic >& rInGraphic, vcl::ImageType nImageType )
 {
-    static Size aNormSize(16, 16);
-    static Size aLargeSize(26, 26);
-    static Size aSize32(32, 32);
-
     if ( !rInGraphic.is() )
     {
         rOutGraphic = uno::Reference<graphic::XGraphic>();
         return false;
     }
 
+    static const o3tl::enumarray<vcl::ImageType, Size> BITMAP_SIZE =
+    {
+        Size(16, 16), Size(24, 24), Size(32, 32)
+    };
+
     // Check size and scale it
     Graphic aImage(rInGraphic);
-    Size   aSize = aImage.GetSizePixel();
-    bool   bMustScale( false );
-
-    if (nImageType == vcl::ImageType::Size26)
-        bMustScale = (aSize != aLargeSize);
-    else if (nImageType == vcl::ImageType::Size32)
-        bMustScale = (aSize != aSize32);
-    else
-        bMustScale = (aSize != aNormSize);
-
-    if (bMustScale)
+    if (BITMAP_SIZE[nImageType] != aImage.GetSizePixel())
     {
         BitmapEx aBitmap = aImage.GetBitmapEx();
-        aBitmap.Scale( aNormSize );
+        aBitmap.Scale(BITMAP_SIZE[nImageType]);
         aImage = Graphic(aBitmap);
         rOutGraphic = aImage.GetXGraphic();
     }


More information about the Libreoffice-commits mailing list