From a3ca36086bdc69e4e3da41cd1d41e9d5228b06b6 Mon Sep 17 00:00:00 2001 From: Maxim Monastirsky Date: Mon, 7 Sep 2020 23:59:03 +0300 Subject: 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 --- .../source/uiconfiguration/imagemanagerimpl.cxx | 23 +++++++--------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'framework/source') 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(); return false; } + static const o3tl::enumarray 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(); } -- cgit