diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2020-09-07 23:59:03 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2020-09-08 22:25:19 +0200 |
commit | a3ca36086bdc69e4e3da41cd1d41e9d5228b06b6 (patch) | |
tree | d752f243018f9cd7d401f54825793dc304ea7bf3 /framework | |
parent | a1ac10f3acc027fa325fb846f79db6af90dfc223 (diff) |
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@gmail.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/uiconfiguration/imagemanagerimpl.cxx | 23 |
1 files changed, 7 insertions, 16 deletions
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(); } |