[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 6 commits - framework/source include/vcl sd/source sfx2/source vcl/inc vcl/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Dec 6 10:07:18 UTC 2018


 framework/source/uiconfiguration/ImageArrayData.cxx   |   22 ---
 framework/source/uiconfiguration/ImageList.cxx        |   37 +----
 framework/source/uiconfiguration/ImplImageList.cxx    |    9 -
 framework/source/uiconfiguration/image.h              |   11 -
 framework/source/uiconfiguration/imagemanagerimpl.cxx |    2 
 include/vcl/ImageTree.hxx                             |    7 
 include/vcl/graph.hxx                                 |    2 
 include/vcl/image.hxx                                 |    3 
 sd/source/ui/controller/slidelayoutcontroller.cxx     |   10 -
 sd/source/ui/sidebar/LayoutMenu.cxx                   |   10 -
 sfx2/source/sidebar/Tools.cxx                         |   14 +
 vcl/inc/image.h                                       |   19 ++
 vcl/inc/implimagetree.hxx                             |   15 +-
 vcl/source/control/fixed.cxx                          |    3 
 vcl/source/gdi/graph.cxx                              |   14 +
 vcl/source/helper/commandinfoprovider.cxx             |   35 +---
 vcl/source/image/Image.cxx                            |  127 ++++++++----------
 vcl/source/image/ImageTree.cxx                        |   10 +
 vcl/source/image/ImplImage.cxx                        |   93 +++++++++++++
 vcl/source/image/ImplImageTree.cxx                    |   37 +++--
 vcl/source/window/builder.cxx                         |    4 
 vcl/source/window/msgbox.cxx                          |   11 -
 vcl/source/window/toolbox.cxx                         |   47 ++----
 23 files changed, 327 insertions(+), 215 deletions(-)

New commits:
commit 5b7dd9231b5cfa775f35c3ba8d542b6f5b080af3
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Nov 26 19:50:38 2018 +0000
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Dec 6 10:51:45 2018 +0100

    Propagate stock info through slide layouts.
    
    Change-Id: If717db82fe6ab14bbf32225c1f1c95f44954f011
    (cherry picked from commit f107161bbd0eb4ee5766f5f983d18b32b929b15c)

diff --git a/sd/source/ui/controller/slidelayoutcontroller.cxx b/sd/source/ui/controller/slidelayoutcontroller.cxx
index 82cc5ae0f06a..4ba598f10809 100644
--- a/sd/source/ui/controller/slidelayoutcontroller.cxx
+++ b/sd/source/ui/controller/slidelayoutcontroller.cxx
@@ -135,13 +135,11 @@ static void fillLayoutValueSet( ValueSet* pValue, const snewfoil_value_info_layo
     for( ; pInfo->mpStrResId; pInfo++ )
     {
         OUString aText(SdResId(pInfo->mpStrResId));
-        BitmapEx aBmp(OUString::createFromAscii(pInfo->msBmpResId));
+        Image aImg("private:graphicrepository/" + OUString::createFromAscii(pInfo->msBmpResId));
+        pValue->InsertItem(static_cast<sal_uInt16>(pInfo->maAutoLayout)+1, aImg, aText);
 
-        pValue->InsertItem(static_cast<sal_uInt16>(pInfo->maAutoLayout)+1,
-                Image(aBmp), aText);
-
-        aLayoutItemSize.Width()  = std::max( aLayoutItemSize.Width(),  aBmp.GetSizePixel().Width()  );
-        aLayoutItemSize.Height() = std::max( aLayoutItemSize.Height(), aBmp.GetSizePixel().Height() );
+        aLayoutItemSize.Width()  = std::max( aLayoutItemSize.Width(),  aImg.GetSizePixel().Width()  );
+        aLayoutItemSize.Height() = std::max( aLayoutItemSize.Height(), aImg.GetSizePixel().Height() );
     }
 
     aLayoutItemSize = pValue->CalcItemSizePixel( aLayoutItemSize );
diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx
index 5a975ec80c49..2ba0c51e3484 100644
--- a/sd/source/ui/sidebar/LayoutMenu.cxx
+++ b/sd/source/ui/sidebar/LayoutMenu.cxx
@@ -530,12 +530,16 @@ void LayoutMenu::Fill()
     {
         if ((WritingMode_TB_RL != pInfo->meWritingMode) || bVertical)
         {
-            BitmapEx aBmp(OUString::createFromAscii(pInfo->msBmpResId));
+            Image aImg("private:graphicrepository/" + OUString::createFromAscii(pInfo->msBmpResId));
 
             if (bRightToLeft && (WritingMode_TB_RL != pInfo->meWritingMode))
-                aBmp.Mirror (BmpMirrorFlags::Horizontal);
+            { // FIXME: avoid interpolating RTL layouts.
+                BitmapEx aRTL = aImg.GetBitmapEx();
+                aRTL.Mirror(BmpMirrorFlags::Horizontal);
+                aImg = Image(aRTL);
+            }
 
-            InsertItem(i, Image(aBmp), SdResId(pInfo->mpStrResId));
+            InsertItem(i, aImg, SdResId(pInfo->mpStrResId));
             SetItemData (i, new AutoLayout(pInfo->maAutoLayout));
         }
     }
commit ca936bb8b1728f470028e5ae0c55a808210f2b0c
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Nov 26 16:59:42 2018 +0000
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Dec 6 10:51:34 2018 +0100

    Use lazy-loading stock Image to simplify framework image lists.
    
    Project stock names through XGraphic via origin URL.
    
    Change-Id: Ib445694f7c142a163ef7e7bc0beea39b88b99e14
    (cherry picked from commit 77b88eebaadebb626108172e4f2de36c60960051)

diff --git a/framework/source/uiconfiguration/ImageArrayData.cxx b/framework/source/uiconfiguration/ImageArrayData.cxx
index 508f79105d98..076cbcefb6dd 100644
--- a/framework/source/uiconfiguration/ImageArrayData.cxx
+++ b/framework/source/uiconfiguration/ImageArrayData.cxx
@@ -38,13 +38,13 @@
 ImageAryData::ImageAryData( const ImageAryData& rData ) :
     maName( rData.maName ),
     mnId( rData.mnId ),
-    maBitmapEx( rData.maBitmapEx )
+    maImage( rData.maImage )
 {
 }
 
 ImageAryData::ImageAryData( const OUString &aName,
-                            sal_uInt16 nId, const BitmapEx &aBitmap )
-        : maName( aName ), mnId( nId ), maBitmapEx( aBitmap )
+                            sal_uInt16 nId, const Image &aImage )
+        : maName( aName ), mnId( nId ), maImage( aImage )
 {
 }
 
@@ -56,23 +56,9 @@ ImageAryData& ImageAryData::operator=( const ImageAryData& rData )
 {
     maName = rData.maName;
     mnId = rData.mnId;
-    maBitmapEx = rData.maBitmapEx;
+    maImage = rData.maImage;
 
     return *this;
 }
 
-void ImageAryData::Load(const OUString &rPrefix)
-{
-    OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
-
-    OUString aFileName = rPrefix;
-    aFileName += maName;
-
-    bool bSuccess = ImageTree::get().loadImage(aFileName, aIconTheme, maBitmapEx, true);
-
-    SAL_WARN_IF(!bSuccess, "fwk.uiconfiguration", "Failed to load image '" << aFileName
-              << "' from icon theme '" << aIconTheme << "'");
-}
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/source/uiconfiguration/ImageList.cxx b/framework/source/uiconfiguration/ImageList.cxx
index dbdb9459440f..57cbe28b10e7 100644
--- a/framework/source/uiconfiguration/ImageList.cxx
+++ b/framework/source/uiconfiguration/ImageList.cxx
@@ -44,9 +44,7 @@ ImageList::ImageList(const std::vector< OUString >& rNameVector,
 
     mpImplData->maPrefix = rPrefix;
     for( size_t i = 0; i < rNameVector.size(); ++i )
-    {
-        mpImplData->AddImage( rNameVector[ i ], static_cast< sal_uInt16 >( i ) + 1, BitmapEx() );
-    }
+        mpImplData->AddImage( rPrefix, rNameVector[ i ], static_cast< sal_uInt16 >( i ) + 1, Image() );
 }
 
 void ImageList::ImplInit( sal_uInt16 nItems, const Size &rSize )
@@ -65,15 +63,7 @@ BitmapEx ImageList::GetAsHorizontalStrip() const
         return BitmapEx();
     aSize.Width() *= nCount;
 
-    // Load any stragglers
-    for (sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++)
-    {
-        ImageAryData *pData = mpImplData->maImages[ nIdx ];
-        if( pData->IsLoadable() )
-            pData->Load( mpImplData->maPrefix );
-    }
-
-    BitmapEx aTempl = mpImplData->maImages[ 0 ]->maBitmapEx;
+    BitmapEx aTempl = mpImplData->maImages[ 0 ]->maImage.GetBitmapEx();
     BitmapEx aResult;
     Bitmap aPixels( aSize, aTempl.GetBitmap().GetBitCount() );
     if( aTempl.IsAlpha() )
@@ -87,9 +77,10 @@ BitmapEx ImageList::GetAsHorizontalStrip() const
     for (sal_uInt16 nIdx = 0; nIdx < nCount; nIdx++)
     {
         tools::Rectangle aDestRect( Point( nIdx * mpImplData->maImageSize.Width(), 0 ),
-                             mpImplData->maImageSize );
+                                    mpImplData->maImageSize );
         ImageAryData *pData = mpImplData->maImages[ nIdx ];
-        aResult.CopyPixel( aDestRect, aSrcRect, &pData->maBitmapEx);
+        BitmapEx aTmp = pData->maImage.GetBitmapEx();
+        aResult.CopyPixel( aDestRect, aSrcRect, &aTmp );
     }
 
     return aResult;
@@ -112,7 +103,7 @@ void ImageList::InsertFromHorizontalStrip( const BitmapEx &rBitmapEx,
     for (sal_uInt16 nIdx = 0; nIdx < nItems; nIdx++)
     {
         BitmapEx aBitmap( rBitmapEx, Point( nIdx * aSize.Width(), 0 ), aSize );
-        mpImplData->AddImage( rNameVector[ nIdx ], nIdx + 1, aBitmap );
+        mpImplData->AddImage( mpImplData->maPrefix, rNameVector[ nIdx ], nIdx + 1, Image( aBitmap ) );
     }
 }
 
@@ -132,8 +123,7 @@ void ImageList::AddImage( const OUString& rImageName, const Image& rImage )
     if( !mpImplData )
         ImplInit( 0, rImage.GetSizePixel() );
 
-    mpImplData->AddImage( rImageName, GetImageCount() + 1,
-                          rImage.GetBitmapEx() );
+    mpImplData->AddImage( mpImplData->maPrefix, rImageName, GetImageCount() + 1, rImage );
 }
 
 void ImageList::ReplaceImage( const OUString& rImageName, const Image& rImage )
@@ -142,10 +132,10 @@ void ImageList::ReplaceImage( const OUString& rImageName, const Image& rImage )
 
     if( nId )
     {
-        //Just replace the bitmap rather than doing RemoveImage / AddImage
-        //which breaks index-based iteration.
+        // Just replace the bitmap rather than doing RemoveImage / AddImage
+        // which breaks index-based iteration.
         ImageAryData *pImg = mpImplData->maNameHash[ rImageName ];
-        pImg->maBitmapEx = rImage.GetBitmapEx();
+        pImg->maImage = rImage;
     }
 }
 
@@ -166,13 +156,8 @@ Image ImageList::GetImage( const OUString& rImageName ) const
     if( mpImplData )
     {
         ImageAryData *pImg = mpImplData->maNameHash[ rImageName ];
-
         if( pImg )
-        {
-            if( pImg->IsLoadable() )
-                pImg->Load( mpImplData->maPrefix );
-            return Image( pImg->maBitmapEx );
-        }
+            return pImg->maImage;
     }
 
     return Image();
diff --git a/framework/source/uiconfiguration/ImplImageList.cxx b/framework/source/uiconfiguration/ImplImageList.cxx
index 19bb1e8a1266..a349a865bcde 100644
--- a/framework/source/uiconfiguration/ImplImageList.cxx
+++ b/framework/source/uiconfiguration/ImplImageList.cxx
@@ -53,10 +53,13 @@ ImplImageList::~ImplImageList()
         delete *aIt;
 }
 
-void ImplImageList::AddImage( const OUString &aName,
-                              sal_uInt16 nId, const BitmapEx &aBitmapEx )
+void ImplImageList::AddImage( const OUString &aPrefix, const OUString &aName,
+                              sal_uInt16 nId, const Image &aImage )
 {
-    ImageAryData *pImg = new ImageAryData( aName, nId, aBitmapEx );
+    Image aInsert = aImage;
+    if (!aInsert)
+        aInsert = Image( "private:graphicrepository/" + aPrefix + aName );
+    ImageAryData *pImg = new ImageAryData( aName, nId, aInsert );
     maImages.push_back( pImg );
     if( !aName.isEmpty() )
         maNameHash [ aName ] = pImg;
diff --git a/framework/source/uiconfiguration/image.h b/framework/source/uiconfiguration/image.h
index 1005fc39cdf1..4e903cc9b743 100644
--- a/framework/source/uiconfiguration/image.h
+++ b/framework/source/uiconfiguration/image.h
@@ -30,16 +30,13 @@ struct ImageAryData
     OUString maName;
     // Images identified by either name, or by id
     sal_uInt16              mnId;
-    BitmapEx                maBitmapEx;
+    Image                   maImage;
 
     ImageAryData( const OUString &aName,
-                  sal_uInt16 nId, const BitmapEx &aBitmap );
+                  sal_uInt16 nId, const Image &aImage );
     ImageAryData( const ImageAryData& rData );
     ~ImageAryData();
 
-    bool IsLoadable() { return maBitmapEx.IsEmpty() && !maName.isEmpty(); }
-    void Load(const OUString &rPrefix);
-
     ImageAryData&   operator=( const ImageAryData& rData );
 };
 
@@ -57,8 +54,8 @@ struct ImplImageList
     ImplImageList( const ImplImageList &aSrc );
     ~ImplImageList();
 
-    void AddImage( const OUString &aName,
-                   sal_uInt16 nId, const BitmapEx &aBitmapEx );
+    void AddImage( const OUString &aPrefix, const OUString &aName,
+                   sal_uInt16 nId, const Image &aImage );
     void RemoveImage( sal_uInt16 nPos );
 };
 
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index ded9db11ee2e..6c5a627bbe94 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -722,7 +722,7 @@ namespace
 {
     css::uno::Reference< css::graphic::XGraphic > GetXGraphic(const Image &rImage)
     {
-        return Graphic(rImage.GetBitmapEx()).GetXGraphic();
+        return Graphic(rImage).GetXGraphic();
     }
 }
 
diff --git a/include/vcl/graph.hxx b/include/vcl/graph.hxx
index b232dc4b0990..72032931704b 100644
--- a/include/vcl/graph.hxx
+++ b/include/vcl/graph.hxx
@@ -101,6 +101,7 @@ public:
     bool            getSnapHorVerLines() const { return mbSnapHorVerLines; }
 };
 
+class Image;
 class VCL_DLLPUBLIC Graphic
 {
 private:
@@ -117,6 +118,7 @@ public:
                     Graphic( const Graphic& rGraphic );
                     Graphic( Graphic&& rGraphic );
                     Graphic( const Bitmap& rBmp );
+                    Graphic( const Image& rImage );
                     Graphic( const BitmapEx& rBmpEx );
                     Graphic( const VectorGraphicDataPtr& rVectorGraphicDataPtr );
                     Graphic( const Animation& rAnimation );
diff --git a/include/vcl/image.hxx b/include/vcl/image.hxx
index 4577bd8fbed1..058a985e237d 100644
--- a/include/vcl/image.hxx
+++ b/include/vcl/image.hxx
@@ -52,7 +52,6 @@ namespace vcl
 class SAL_WARN_UNUSED VCL_DLLPUBLIC Image
 {
     friend class ::OutputDevice;
-
 public:
                     Image();
                     explicit Image( const BitmapEx& rBitmapEx );
@@ -67,6 +66,8 @@ public:
     bool            operator==( const Image& rImage ) const;
     bool            operator!=( const Image& rImage ) const { return !(Image::operator==( rImage )); }
 
+    SAL_DLLPRIVATE  OUString GetStock() const;
+
     void Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle, const Size* pSize = nullptr);
 
 private:
diff --git a/sfx2/source/sidebar/Tools.cxx b/sfx2/source/sidebar/Tools.cxx
index e246599fd9c0..f0b0c3021b56 100644
--- a/sfx2/source/sidebar/Tools.cxx
+++ b/sfx2/source/sidebar/Tools.cxx
@@ -55,11 +55,14 @@ Image Tools::GetImage (
 {
     if (rsURL.getLength() > 0)
     {
+        OUString sPath;
+
         if (rsURL.startsWith(".uno:"))
-        {
-            const Image aPanelImage(vcl::CommandInfoProvider::GetImageForCommand(rsURL, rxFrame));
-            return aPanelImage;
-        }
+            return vcl::CommandInfoProvider::GetImageForCommand(rsURL, rxFrame);
+
+        else if (rsURL.startsWith("private:graphicrepository/", &sPath))
+            return Image(rsURL);
+
         else
         {
             const Reference<XComponentContext> xContext (::comphelper::getProcessComponentContext());
@@ -70,8 +73,7 @@ Image Tools::GetImage (
             const Reference<graphic::XGraphic> xGraphic (
                 xGraphicProvider->queryGraphic(aMediaProperties.getPropertyValues()),
                 UNO_QUERY);
-            if (xGraphic.is())
-                return Image(xGraphic);
+            return Image(xGraphic);
         }
     }
     return Image();
diff --git a/vcl/source/gdi/graph.cxx b/vcl/source/gdi/graph.cxx
index c0e9bb444a4b..73f623071a74 100644
--- a/vcl/source/gdi/graph.cxx
+++ b/vcl/source/gdi/graph.cxx
@@ -21,6 +21,7 @@
 #include <vcl/outdev.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/graph.hxx>
+#include <vcl/image.hxx>
 #include <vcl/metaact.hxx>
 #include <impgraph.hxx>
 #include <comphelper/processfactory.hxx>
@@ -32,6 +33,8 @@
 #include <com/sun/star/graphic/XGraphic.hpp>
 #include <cppuhelper/typeprovider.hxx>
 
+#include "image.h"
+
 using namespace ::com::sun::star;
 
 namespace
@@ -209,6 +212,17 @@ Graphic::Graphic(const BitmapEx& rBmpEx)
 {
 }
 
+// We use XGraphic for passing toolbar images across app UNO aps
+// and we need to be able to see and preserve 'stock' images too.
+Graphic::Graphic(const Image& rImage)
+    // FIXME: should really defer the BitmapEx load.
+    : mxImpGraphic(new ImpGraphic(rImage.GetBitmapEx()))
+{
+    OUString aStock = rImage.GetStock();
+    if (aStock.getLength())
+        mxImpGraphic->setOriginURL("private:graphicrepository/" + aStock);
+}
+
 Graphic::Graphic(const VectorGraphicDataPtr& rVectorGraphicDataPtr)
     : mxImpGraphic(new ImpGraphic(rVectorGraphicDataPtr))
 {
diff --git a/vcl/source/helper/commandinfoprovider.cxx b/vcl/source/helper/commandinfoprovider.cxx
index 931900ad2abe..fb0df8071c73 100644
--- a/vcl/source/helper/commandinfoprovider.cxx
+++ b/vcl/source/helper/commandinfoprovider.cxx
@@ -293,13 +293,13 @@ OUString GetRealCommandForCommand(const OUString& rCommandName,
     return GetCommandProperty("TargetURL", rCommandName, rsModuleName);
 }
 
-BitmapEx GetBitmapForCommand(const OUString& rsCommandName,
-                             const Reference<frame::XFrame>& rxFrame,
-                             vcl::ImageType eImageType)
+Image GetImageForCommand(const OUString& rsCommandName,
+                         const Reference<frame::XFrame>& rxFrame,
+                         vcl::ImageType eImageType)
 {
 
     if (rsCommandName.isEmpty())
-        return BitmapEx();
+        return Image();
 
     sal_Int16 nImageType(ui::ImageType::COLOR_NORMAL | ui::ImageType::SIZE_DEFAULT);
 
@@ -308,6 +308,8 @@ BitmapEx GetBitmapForCommand(const OUString& rsCommandName,
     else if (eImageType == vcl::ImageType::Size32)
         nImageType |= ui::ImageType::SIZE_32;
 
+    Image aRet;
+
     try
     {
         Reference<frame::XController> xController(rxFrame->getController(), UNO_SET_THROW);
@@ -321,12 +323,11 @@ BitmapEx GetBitmapForCommand(const OUString& rsCommandName,
             Sequence<OUString> aImageCmdSeq { rsCommandName };
 
             aGraphicSeq = xDocImgMgr->getImages( nImageType, aImageCmdSeq );
-            Reference<graphic::XGraphic> xGraphic = aGraphicSeq[0];
-            const Graphic aGraphic(xGraphic);
-            BitmapEx aBitmap(aGraphic.GetBitmapEx());
 
-            if (!!aBitmap)
-                return aBitmap;
+            aRet = Image( aGraphicSeq[0] );
+
+            if (!!aRet)
+                return aRet;
         }
     }
     catch (Exception&)
@@ -344,31 +345,19 @@ BitmapEx GetBitmapForCommand(const OUString& rsCommandName,
 
         aGraphicSeq = xModuleImageManager->getImages(nImageType, aImageCmdSeq);
 
-        Reference<graphic::XGraphic> xGraphic(aGraphicSeq[0]);
-
-        const Graphic aGraphic(xGraphic);
-
-        return aGraphic.GetBitmapEx();
+        aRet = Image(aGraphicSeq[0]);
     }
     catch (Exception&)
     {
     }
 
-    return BitmapEx();
-}
-
-Image GetImageForCommand(const OUString& rsCommandName,
-                         const Reference<frame::XFrame>& rxFrame,
-                         vcl::ImageType eImageType)
-{
-    return Image(GetBitmapForCommand(rsCommandName, rxFrame, eImageType));
+    return aRet;
 }
 
 sal_Int32 GetPropertiesForCommand (
     const OUString& rsCommandName,
     const OUString& rsModuleName)
 {
-
     sal_Int32 nValue = 0;
     const Sequence<beans::PropertyValue> aProperties (GetCommandProperties(rsCommandName, rsModuleName));
     for (sal_Int32 nIndex=0; nIndex<aProperties.getLength(); ++nIndex)
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index 4232173f80d6..106e9e21ec4d 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -48,21 +48,24 @@ Image::Image(const BitmapEx& rBitmapEx)
 
 Image::Image(const css::uno::Reference< css::graphic::XGraphic >& rxGraphic)
 {
-    const Graphic aGraphic(rxGraphic);
-    ImplInit(aGraphic.GetBitmapEx());
+    if (rxGraphic.is())
+    {
+        const Graphic aGraphic(rxGraphic);
+
+        OUString aPath;
+        if (aGraphic.getOriginURL().startsWith("private:graphicrepository/", &aPath))
+            mpImplData.reset(new ImplImage(aPath));
+        else
+            ImplInit(aGraphic.GetBitmapEx());
+    }
 }
 
 Image::Image(const OUString & rFileUrl)
 {
     OUString aPath;
-    sal_Int32 nIndex = 0;
-    if (rFileUrl.getToken( 0, '/', nIndex ) == "private:graphicrepository")
-    {
-        OUString sPathName(rFileUrl.copy(nIndex));
-        BitmapEx aBitmapEx;
-        if (vcl::ImageRepository::loadImage(sPathName, aBitmapEx))
-            mpImplData.reset(new ImplImage(rFileUrl.copy(nIndex)));
-    }
+    if (rFileUrl.startsWith("private:graphicrepository/", &aPath))
+        mpImplData.reset(new ImplImage(aPath));
+
     else
     {
         osl::FileBase::getSystemPathFromFileURL(rFileUrl, aPath);
@@ -79,6 +82,13 @@ void Image::ImplInit(const BitmapEx& rBitmapEx)
         mpImplData.reset(new ImplImage(rBitmapEx));
 }
 
+OUString Image::GetStock() const
+{
+    if (mpImplData)
+        return mpImplData->maStockName;
+    return OUString();
+}
+
 Size Image::GetSizePixel() const
 {
     if (mpImplData)
commit 190fad517d66be7891d54d0731cecb148aff357d
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Nov 26 14:45:50 2018 +0000
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Dec 6 10:51:23 2018 +0100

    Use HiDPI scaling to load scaled images.
    
    We render these at apparently the same pixel size as normal images,
    but the underlying canvas is larger so these then end up pixel-matching
    the true underlying grid.
    
    Change-Id: Ic4b749127e9c81da78d06b34d9f88c5635dc64b9
    (cherry picked from commit 1799b122ef79432c9ce4e419bce660797c01efa4)

diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index fdda197f2654..4232173f80d6 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -119,7 +119,7 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle
 
     Size aOutSize = pSize ? *pSize : pOutDev->PixelToLogic(aBitmapSizePixel);
 
-    BitmapEx aRenderBmp = mpImplData->getBitmapEx(!!(nStyle & DrawImageFlags::Disable));
+    BitmapEx aRenderBmp = mpImplData->getBitmapExForHiDPI(!!(nStyle & DrawImageFlags::Disable));
 
     if (!(nStyle & DrawImageFlags::Disable) &&
         (nStyle & (DrawImageFlags::ColorTransform | DrawImageFlags::Highlight |
@@ -156,7 +156,7 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle
         aRenderBmp = aTempBitmapEx;
     }
 
-    pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, aBitmapSizePixel, aRenderBmp);
+    pOutDev->DrawBitmapEx(rPos, aOutSize, aRenderBmp);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/image/ImplImage.cxx b/vcl/source/image/ImplImage.cxx
index e9024229f482..5f75c82845a1 100644
--- a/vcl/source/image/ImplImage.cxx
+++ b/vcl/source/image/ImplImage.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <sal/log.hxx>
+#include <vcl/svapp.hxx>
 #include <vcl/outdev.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/alpha.hxx>
@@ -26,7 +27,8 @@
 #include <vcl/virdev.hxx>
 #include <vcl/image.hxx>
 #include <vcl/settings.hxx>
-#include <vcl/imagerepository.hxx>
+#include <vcl/ImageTree.hxx>
+#include <comphelper/lok.hxx>
 #include <BitmapProcessor.hxx>
 
 #include <image.h>
@@ -46,6 +48,21 @@ ImplImage::ImplImage(const OUString &aStockName)
 {
 }
 
+bool ImplImage::loadStockAtScale(double fScale, BitmapEx &rBitmapEx)
+{
+    BitmapEx aBitmapEx;
+    OUString aIconTheme = Application::GetSettings().GetStyleSettings().DetermineIconTheme();
+    if (!ImageTree::get().loadImage(maStockName, aIconTheme, aBitmapEx, true,
+                                    fScale * 100.0,
+                                    ImageLoadFlags::IgnoreScalingFactor))
+    {
+        SAL_WARN("vcl", "Failed to load scaled image from " << maStockName << " at " << fScale);
+        return false;
+    }
+    rBitmapEx = aBitmapEx;
+    return true;
+}
+
 Size ImplImage::getSizePixel()
 {
     Size aRet;
@@ -53,13 +70,11 @@ Size ImplImage::getSizePixel()
         aRet = maSizePixel;
     else if (isStock())
     {
-        BitmapEx aBitmapEx;
-        if (vcl::ImageRepository::loadImage(maStockName, aBitmapEx))
+        if (loadStockAtScale(1.0, maBitmapEx))
         {
             assert(!maDisabledBitmapEx);
             assert(maBitmapChecksum == 0);
-            maBitmapEx = aBitmapEx;
-            maSizePixel = aBitmapEx.GetSizePixel();
+            maSizePixel = maBitmapEx.GetSizePixel();
             aRet = maSizePixel;
         }
         else
@@ -98,4 +113,18 @@ bool ImplImage::isEqual(const ImplImage &ref) const
         return maBitmapEx == ref.maBitmapEx;
 }
 
+BitmapEx ImplImage::getBitmapExForHiDPI(bool bDisabled)
+{
+    if (isStock())
+    {   // check we have the right bitmap cached.
+        // FIXME: DPI scaling should be tied to the outdev really ...
+        double fScale = comphelper::LibreOfficeKit::getDPIScale();
+        Size aTarget(maSizePixel.Width()*fScale,
+                     maSizePixel.Height()*fScale);
+        if (maBitmapEx.GetSizePixel() != aTarget)
+            loadStockAtScale(fScale, maBitmapEx);
+    }
+    return getBitmapEx(bDisabled);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 6dca7a2411c96f955c768b425bc4ac62bafacd0b
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Nov 26 14:13:29 2018 +0000
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Dec 6 10:51:13 2018 +0100

    Add explicit API scaling via ImageTree API.
    
    Also add image scale to in-memory cache lookup.
    
    Change-Id: I1e84b922d4a9ab2f1723c5cb8a72f295c6940504
    (cherry picked from commit 59b3cdbc27b65fb3e72dd0b3b2565851bc8f772c)

diff --git a/include/vcl/ImageTree.hxx b/include/vcl/ImageTree.hxx
index 5de137128d58..6d5946159022 100644
--- a/include/vcl/ImageTree.hxx
+++ b/include/vcl/ImageTree.hxx
@@ -60,8 +60,13 @@ public:
         BitmapEx & bitmap, bool localized,
         const ImageLoadFlags eFlags = ImageLoadFlags::NONE);
 
-    VCL_DLLPUBLIC css::uno::Reference<css::container::XNameAccess> getNameAccess();
+    VCL_DLLPUBLIC bool loadImage(
+        OUString const & name, OUString const & style,
+        BitmapEx & bitmap, bool localized,
+        sal_Int32 nScalePercentage,
+        const ImageLoadFlags eFlags = ImageLoadFlags::NONE);
 
+    VCL_DLLPUBLIC css::uno::Reference<css::container::XNameAccess> getNameAccess();
 
     /** a crude form of life cycle control (called from DeInitVCL; otherwise,
      *  if the ImplImageTree singleton were destroyed during exit that would
diff --git a/vcl/inc/implimagetree.hxx b/vcl/inc/implimagetree.hxx
index 98954704f2a7..31afc0663564 100644
--- a/vcl/inc/implimagetree.hxx
+++ b/vcl/inc/implimagetree.hxx
@@ -46,14 +46,17 @@ struct ImageRequestParameters
     bool mbLocalized;
     ImageLoadFlags meFlags;
     bool mbWriteImageToCache;
+    sal_Int32 mnScalePercentage;
 
-    ImageRequestParameters(const OUString & rName, const OUString & rStyle, BitmapEx& rBitmap, bool bLocalized, ImageLoadFlags eFlags)
+    ImageRequestParameters(const OUString & rName, const OUString & rStyle, BitmapEx& rBitmap, bool bLocalized,
+                           ImageLoadFlags eFlags, sal_Int32 nScalePercentage)
         : msName(rName)
         , msStyle(rStyle)
         , mrBitmap(rBitmap)
         , mbLocalized(bLocalized)
         , meFlags(eFlags)
         , mbWriteImageToCache(false)
+        , mnScalePercentage(nScalePercentage)
     {}
 
     bool convertToDarkTheme();
@@ -72,7 +75,8 @@ public:
     bool loadImage(
         OUString const & name, OUString const & style,
         BitmapEx & bitmap, bool localized,
-        const ImageLoadFlags eFlags);
+        const ImageLoadFlags eFlags,
+        sal_Int32 nScalePercentage = -1);
 
     /** a crude form of life cycle control (called from DeInitVCL; otherwise,
      *  if the ImplImageTree singleton were destroyed during exit that would
@@ -85,14 +89,15 @@ private:
     ImplImageTree(const ImplImageTree&) = delete;
     ImplImageTree& operator=(const ImplImageTree&) = delete;
 
-    typedef std::unordered_map<OUString, std::pair<bool, BitmapEx>> IconCache;
+    typedef std::unordered_map<OUString, std::pair<bool,BitmapEx>> IconCache;
+    typedef std::unordered_map<sal_Int32, std::unique_ptr<IconCache>> ScaledIconCache;
     typedef std::unordered_map<OUString, OUString> IconLinkHash;
 
     struct IconSet
     {
         OUString maURL;
         css::uno::Reference<css::container::XNameAccess> maNameAccess;
-        IconCache maIconCache;
+        ScaledIconCache maScaledIconCaches;
         IconLinkHash maLinkHash;
 
         IconSet()
@@ -127,6 +132,8 @@ private:
 
     void createStyle();
 
+    IconCache &getIconCache(ImageRequestParameters& rParameters);
+
     bool iconCacheLookup(ImageRequestParameters& rParameters);
 
     bool findImage(std::vector<OUString> const & rPaths, ImageRequestParameters& rParameters);
diff --git a/vcl/source/image/ImageTree.cxx b/vcl/source/image/ImageTree.cxx
index bbce46b0f280..7978e5d0cdd7 100644
--- a/vcl/source/image/ImageTree.cxx
+++ b/vcl/source/image/ImageTree.cxx
@@ -32,9 +32,17 @@ OUString ImageTree::getImageUrl(OUString const & rName, OUString const & rStyle,
 
 bool ImageTree::loadImage(OUString const & rName, OUString const & rStyle,
                           BitmapEx & rBitmap, bool bLocalized,
+                          sal_Int32 nScalePercentage,
                           const ImageLoadFlags eFlags)
 {
-    return mpImplImageTree->loadImage(rName, rStyle, rBitmap, bLocalized, eFlags);
+    return mpImplImageTree->loadImage(rName, rStyle, rBitmap, bLocalized, eFlags, nScalePercentage);
+}
+
+bool ImageTree::loadImage(OUString const & rName, OUString const & rStyle,
+                          BitmapEx & rBitmap, bool bLocalized,
+                          const ImageLoadFlags eFlags)
+{
+    return loadImage(rName, rStyle, rBitmap, bLocalized, -1, eFlags);
 }
 
 css::uno::Reference<css::container::XNameAccess> ImageTree::getNameAccess()
diff --git a/vcl/source/image/ImplImageTree.cxx b/vcl/source/image/ImplImageTree.cxx
index a21700cc8501..30d9d9d38b7d 100644
--- a/vcl/source/image/ImplImageTree.cxx
+++ b/vcl/source/image/ImplImageTree.cxx
@@ -66,6 +66,8 @@ sal_Int32 ImageRequestParameters::scalePercentage()
     sal_Int32 aScalePercentage = 100;
     if (!(meFlags & ImageLoadFlags::IgnoreScalingFactor))
         aScalePercentage = Application::GetDefaultDevice()->GetDPIScalePercentage();
+    else if (mnScalePercentage > 0)
+        aScalePercentage = mnScalePercentage;
     return aScalePercentage;
 }
 
@@ -93,17 +95,17 @@ OUString createPath(OUString const & name, sal_Int32 pos, OUString const & local
     return name.copy(0, pos + 1) + locale + name.copy(pos);
 }
 
-OUString getIconCacheUrl(OUString const & sStyle, OUString const & sVariant, OUString const & sName)
+OUString getIconCacheUrl(OUString const & sVariant, ImageRequestParameters const & rParameters)
 {
     OUString sUrl("${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("bootstrap") ":UserInstallation}/cache/");
-    sUrl += sStyle + "/" + sVariant + "/" + sName;
+    sUrl += rParameters.msStyle + "/" + sVariant + "/" + rParameters.msName;
     rtl::Bootstrap::expandMacros(sUrl);
     return sUrl;
 }
 
-OUString createIconCacheUrl(OUString const & sStyle, OUString const & sVariant, OUString const & sName)
+OUString createIconCacheUrl(OUString const & sVariant, ImageRequestParameters const & rParameters)
 {
-    OUString sUrl(getIconCacheUrl(sStyle, sVariant, sName));
+    OUString sUrl(getIconCacheUrl(sVariant, rParameters));
     OUString sDir = sUrl.copy(0, sUrl.lastIndexOf('/'));
     osl::Directory::createPath(sDir);
     return sUrl;
@@ -272,14 +274,15 @@ OUString ImplImageTree::fallbackStyle(const OUString& rsStyle)
     return sResult;
 }
 
-bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, BitmapEx & rBitmap, bool localized, const ImageLoadFlags eFlags)
+bool ImplImageTree::loadImage(OUString const & rName, OUString const & rStyle, BitmapEx & rBitmap, bool localized,
+                              const ImageLoadFlags eFlags, sal_Int32 nScalePercentage)
 {
     OUString aCurrentStyle(rStyle);
     while (!aCurrentStyle.isEmpty())
     {
         try
         {
-            ImageRequestParameters aParameters(rName, aCurrentStyle, rBitmap, localized, eFlags);
+            ImageRequestParameters aParameters(rName, aCurrentStyle, rBitmap, localized, eFlags, nScalePercentage);
             if (doLoadImage(aParameters))
                 return true;
         }
@@ -306,7 +309,7 @@ OUString createVariant(ImageRequestParameters& rParameters)
 
 bool loadDiskCachedVersion(OUString const & sVariant, ImageRequestParameters& rParameters)
 {
-    OUString sUrl(getIconCacheUrl(rParameters.msStyle, sVariant, rParameters.msName));
+    OUString sUrl(getIconCacheUrl(sVariant, rParameters));
     if (!urlExists(sUrl))
         return false;
     SvFileStream aFileStream(sUrl, StreamMode::READ);
@@ -318,7 +321,7 @@ bool loadDiskCachedVersion(OUString const & sVariant, ImageRequestParameters& rP
 
 void cacheBitmapToDisk(OUString const & sVariant, ImageRequestParameters const & rParameters)
 {
-    OUString sUrl(createIconCacheUrl(rParameters.msStyle, sVariant, rParameters.msName));
+    OUString sUrl(createIconCacheUrl(sVariant, rParameters));
     vcl::PNGWriter aWriter(rParameters.mrBitmap);
     try
     {
@@ -339,9 +342,7 @@ bool ImplImageTree::doLoadImage(ImageRequestParameters& rParameters)
 
     OUString aVariant = createVariant(rParameters);
     if (loadDiskCachedVersion(aVariant, rParameters))
-    {
         return true;
-    }
 
     if (!rParameters.mrBitmap.IsEmpty())
         rParameters.mrBitmap.SetEmpty();
@@ -371,7 +372,7 @@ bool ImplImageTree::doLoadImage(ImageRequestParameters& rParameters)
         {
             cacheBitmapToDisk(aVariant, rParameters);
         }
-        getCurrentIconSet().maIconCache[rParameters.msName] = std::make_pair(rParameters.mbLocalized, rParameters.mrBitmap);
+        getIconCache(rParameters)[rParameters.msName] = std::make_pair(rParameters.mbLocalized, rParameters.mrBitmap);
     }
 
     return bFound;
@@ -439,9 +440,20 @@ void ImplImageTree::createStyle()
     loadImageLinks();
 }
 
+/// Find an icon cache for the right scale factor
+ImplImageTree::IconCache &ImplImageTree::getIconCache(ImageRequestParameters& rParameters)
+{
+    IconSet &rSet = getCurrentIconSet();
+    auto it = rSet.maScaledIconCaches.find(rParameters.mnScalePercentage);
+    if ( it != rSet.maScaledIconCaches.end() )
+        return *it->second.get();
+    rSet.maScaledIconCaches[rParameters.mnScalePercentage] = std::unique_ptr<IconCache>(new IconCache);
+    return *rSet.maScaledIconCaches[rParameters.mnScalePercentage].get();
+}
+
 bool ImplImageTree::iconCacheLookup(ImageRequestParameters& rParameters)
 {
-    IconCache& rIconCache = getCurrentIconSet().maIconCache;
+    IconCache& rIconCache = getIconCache(rParameters);
 
     IconCache::iterator i(rIconCache.find(getRealImageName(rParameters.msName)));
     if (i != rIconCache.end() && i->second.first == rParameters.mbLocalized)
@@ -470,6 +482,7 @@ bool ImplImageTree::findImage(std::vector<OUString> const & rPaths, ImageRequest
             (void)ok; // prevent unused warning in release build
 
             loadImageFromStream(wrapStream(aStream), rPath, rParameters);
+
             return true;
         }
     }
commit 244df39479a161ce6865cc3dde7629af15d5fa8f
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Mon Nov 26 14:08:13 2018 +0000
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Dec 6 10:51:04 2018 +0100

    Preserve stock images until render time.
    
    This allows us to choose to render HiDPI images at the right time,
    when we have the DPI of the device to render to.
    
    The first step in a better, and more industry standard way of
    improving our UI for HiDPI via rendering level scaling that should
    retain a consistent look across the app with many fewer changes.
    
    Change-Id: I36681f3242cb650de4f0b2d0fcdffbe5618e30fc
    (cherry picked from commit e42c6d6903ab804235671d51ae3a05d1627e2574)

diff --git a/vcl/inc/image.h b/vcl/inc/image.h
index 873fc98432dd..c9fb5393191a 100644
--- a/vcl/inc/image.h
+++ b/vcl/inc/image.h
@@ -28,10 +28,29 @@
 struct ImplImage
 {
     BitmapChecksum maBitmapChecksum;
+    /// if non-empty: cached original size of maStockName else Size of maBitmap
+    Size     maSizePixel;
+    /// If set - defines the bitmap via images.zip*
+    OUString maStockName;
+
+    /// Original bitmap - or cache of a potentially scaled bitmap
     BitmapEx maBitmapEx;
     BitmapEx maDisabledBitmapEx;
 
     ImplImage(const BitmapEx& rBitmapEx);
+    ImplImage(const OUString &aStockName);
+
+    bool isStock() const { return maStockName.getLength() > 0; }
+
+    /// get size in co-ordinates not scaled for HiDPI
+    Size getSizePixel();
+    /// Legacy - the original bitmap
+    BitmapEx getBitmapEx(bool bDisabled = false);
+    /// Taking account of HiDPI scaling
+    BitmapEx getBitmapExForHiDPI(bool bDisabled = false);
+    bool isEqual(const ImplImage &ref) const;
+    bool isSizeEmpty() const { return maSizePixel == Size(0, 0); }
+    bool loadStockAtScale(double fScale, BitmapEx &rBitmapEx);
 };
 
 #endif // INCLUDED_VCL_INC_IMAGE_H
diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx
index b927cb2054a1..e990752ebc22 100644
--- a/vcl/source/control/fixed.cxx
+++ b/vcl/source/control/fixed.cxx
@@ -967,8 +967,7 @@ bool FixedImage::SetModeImage( const Image& rImage )
 
 Image FixedImage::loadThemeImage(const OUString &rFileName)
 {
-    BitmapEx aBitmap(rFileName);
-    return Image(aBitmap);
+    return Image("private:graphicrepository/" + rFileName);
 }
 
 bool FixedImage::set_property(const OString &rKey, const OUString &rValue)
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index e99cccd0f256..fdda197f2654 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -55,45 +55,44 @@ Image::Image(const css::uno::Reference< css::graphic::XGraphic >& rxGraphic)
 Image::Image(const OUString & rFileUrl)
 {
     OUString aPath;
-    osl::FileBase::getSystemPathFromFileURL(rFileUrl, aPath);
-    Graphic aGraphic;
-    const OUString aFilterName(IMP_PNG);
-    if (ERRCODE_NONE == GraphicFilter::LoadGraphic(aPath, aFilterName, aGraphic))
+    sal_Int32 nIndex = 0;
+    if (rFileUrl.getToken( 0, '/', nIndex ) == "private:graphicrepository")
     {
-        ImplInit(aGraphic.GetBitmapEx());
+        OUString sPathName(rFileUrl.copy(nIndex));
+        BitmapEx aBitmapEx;
+        if (vcl::ImageRepository::loadImage(sPathName, aBitmapEx))
+            mpImplData.reset(new ImplImage(rFileUrl.copy(nIndex)));
+    }
+    else
+    {
+        osl::FileBase::getSystemPathFromFileURL(rFileUrl, aPath);
+        Graphic aGraphic;
+        const OUString aFilterName(IMP_PNG);
+        if (ERRCODE_NONE == GraphicFilter::LoadGraphic(aPath, aFilterName, aGraphic))
+            ImplInit(aGraphic.GetBitmapEx());
     }
 }
 
 void Image::ImplInit(const BitmapEx& rBitmapEx)
 {
     if (!rBitmapEx.IsEmpty())
-    {
         mpImplData.reset(new ImplImage(rBitmapEx));
-    }
 }
 
 Size Image::GetSizePixel() const
 {
-    Size aRet;
-
     if (mpImplData)
-    {
-        aRet = mpImplData->maBitmapEx.GetSizePixel();
-    }
-
-    return aRet;
+        return mpImplData->getSizePixel();
+    else
+        return Size();
 }
 
 BitmapEx Image::GetBitmapEx() const
 {
-    BitmapEx aRet;
-
     if (mpImplData)
-    {
-        aRet = mpImplData->maBitmapEx;
-    }
-
-    return aRet;
+        return mpImplData->getBitmapEx();
+    else
+        return BitmapEx();
 }
 
 bool Image::operator==(const Image& rImage) const
@@ -105,7 +104,7 @@ bool Image::operator==(const Image& rImage) const
     else if (!rImage.mpImplData || !mpImplData)
         bRet = false;
     else
-        bRet = rImage.mpImplData->maBitmapEx == mpImplData->maBitmapEx;
+        bRet = rImage.mpImplData->isEqual(*mpImplData);
 
     return bRet;
 }
@@ -116,60 +115,48 @@ void Image::Draw(OutputDevice* pOutDev, const Point& rPos, DrawImageFlags nStyle
         return;
 
     const Point aSrcPos(0, 0);
-    Size aBitmapSizePixel = mpImplData->maBitmapEx.GetSizePixel();
+    Size aBitmapSizePixel = mpImplData->getSizePixel();
 
     Size aOutSize = pSize ? *pSize : pOutDev->PixelToLogic(aBitmapSizePixel);
 
-    if (nStyle & DrawImageFlags::Disable)
+    BitmapEx aRenderBmp = mpImplData->getBitmapEx(!!(nStyle & DrawImageFlags::Disable));
+
+    if (!(nStyle & DrawImageFlags::Disable) &&
+        (nStyle & (DrawImageFlags::ColorTransform | DrawImageFlags::Highlight |
+                   DrawImageFlags::Deactive | DrawImageFlags::SemiTransparent)))
     {
-        BitmapChecksum aChecksum = mpImplData->maBitmapEx.GetChecksum();
-        if (mpImplData->maBitmapChecksum != aChecksum)
+        BitmapEx aTempBitmapEx(aRenderBmp);
+
+        if (nStyle & (DrawImageFlags::Highlight | DrawImageFlags::Deactive))
         {
-            mpImplData->maBitmapChecksum = aChecksum;
-            mpImplData->maDisabledBitmapEx = BitmapProcessor::createDisabledImage(mpImplData->maBitmapEx);
+            const StyleSettings& rSettings = pOutDev->GetSettings().GetStyleSettings();
+            Color aColor;
+            if (nStyle & DrawImageFlags::Highlight)
+                aColor = rSettings.GetHighlightColor();
+            else
+                aColor = rSettings.GetDeactiveColor();
+
+            BitmapProcessor::colorizeImage(aTempBitmapEx, aColor);
         }
-        pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, aBitmapSizePixel, mpImplData->maDisabledBitmapEx);
-    }
-    else
-    {
-        if (nStyle & (DrawImageFlags::ColorTransform | DrawImageFlags::Highlight |
-                      DrawImageFlags::Deactive | DrawImageFlags::SemiTransparent))
-        {
-            BitmapEx aTempBitmapEx(mpImplData->maBitmapEx);
 
-            if (nStyle & (DrawImageFlags::Highlight | DrawImageFlags::Deactive))
+        if (nStyle & DrawImageFlags::SemiTransparent)
+        {
+            if (aTempBitmapEx.IsTransparent())
             {
-                const StyleSettings& rSettings = pOutDev->GetSettings().GetStyleSettings();
-                Color aColor;
-                if (nStyle & DrawImageFlags::Highlight)
-                    aColor = rSettings.GetHighlightColor();
-                else
-                    aColor = rSettings.GetDeactiveColor();
-
-                BitmapProcessor::colorizeImage(aTempBitmapEx, aColor);
+                Bitmap aAlphaBmp(aTempBitmapEx.GetAlpha().GetBitmap());
+                aAlphaBmp.Adjust(50);
+                aTempBitmapEx = BitmapEx(aTempBitmapEx.GetBitmap(), AlphaMask(aAlphaBmp));
             }
-
-            if (nStyle & DrawImageFlags::SemiTransparent)
+            else
             {
-                if (aTempBitmapEx.IsTransparent())
-                {
-                    Bitmap aAlphaBmp(aTempBitmapEx.GetAlpha().GetBitmap());
-                    aAlphaBmp.Adjust(50);
-                    aTempBitmapEx = BitmapEx(aTempBitmapEx.GetBitmap(), AlphaMask(aAlphaBmp));
-                }
-                else
-                {
-                    sal_uInt8 cErase = 128;
-                    aTempBitmapEx = BitmapEx(aTempBitmapEx.GetBitmap(), AlphaMask(aTempBitmapEx.GetSizePixel(), &cErase));
-                }
+                sal_uInt8 cErase = 128;
+                aTempBitmapEx = BitmapEx(aTempBitmapEx.GetBitmap(), AlphaMask(aTempBitmapEx.GetSizePixel(), &cErase));
             }
-            pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, aTempBitmapEx.GetSizePixel(), aTempBitmapEx);
-        }
-        else
-        {
-            pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, mpImplData->maBitmapEx.GetSizePixel(), mpImplData->maBitmapEx);
         }
+        aRenderBmp = aTempBitmapEx;
     }
+
+    pOutDev->DrawBitmapEx(rPos, aOutSize, aSrcPos, aBitmapSizePixel, aRenderBmp);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/image/ImplImage.cxx b/vcl/source/image/ImplImage.cxx
index 82a2099e8813..e9024229f482 100644
--- a/vcl/source/image/ImplImage.cxx
+++ b/vcl/source/image/ImplImage.cxx
@@ -17,6 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/log.hxx>
 #include <vcl/outdev.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/alpha.hxx>
@@ -25,15 +26,76 @@
 #include <vcl/virdev.hxx>
 #include <vcl/image.hxx>
 #include <vcl/settings.hxx>
+#include <vcl/imagerepository.hxx>
+#include <BitmapProcessor.hxx>
 
 #include <image.h>
 #include <memory>
 
 ImplImage::ImplImage(const BitmapEx &rBitmapEx)
     : maBitmapChecksum(0)
+    , maSizePixel(rBitmapEx.GetSizePixel())
     , maBitmapEx(rBitmapEx)
-    , maDisabledBitmapEx()
 {
 }
 
+ImplImage::ImplImage(const OUString &aStockName)
+    : maBitmapChecksum(0)
+    , maSizePixel(0,0) // defer size lookup
+    , maStockName( aStockName )
+{
+}
+
+Size ImplImage::getSizePixel()
+{
+    Size aRet;
+    if (!isSizeEmpty())
+        aRet = maSizePixel;
+    else if (isStock())
+    {
+        BitmapEx aBitmapEx;
+        if (vcl::ImageRepository::loadImage(maStockName, aBitmapEx))
+        {
+            assert(!maDisabledBitmapEx);
+            assert(maBitmapChecksum == 0);
+            maBitmapEx = aBitmapEx;
+            maSizePixel = aBitmapEx.GetSizePixel();
+            aRet = maSizePixel;
+        }
+        else
+            SAL_WARN("vcl", "Failed to load stock icon " << maStockName);
+    }
+    return aRet;
+}
+
+/// non-HiDPI compatibility method.
+BitmapEx ImplImage::getBitmapEx(bool bDisabled)
+{
+    getSizePixel(); // force load, and at unity scale.
+    if (bDisabled)
+    {
+        // Changed since we last generated this.
+        BitmapChecksum aChecksum = maBitmapEx.GetChecksum();
+        if (maBitmapChecksum != aChecksum ||
+            maDisabledBitmapEx.GetSizePixel() != maBitmapEx.GetSizePixel())
+        {
+            maDisabledBitmapEx = BitmapProcessor::createDisabledImage(maBitmapEx);
+            maBitmapChecksum = aChecksum;
+        }
+        return maDisabledBitmapEx;
+    }
+
+    return maBitmapEx;
+}
+
+bool ImplImage::isEqual(const ImplImage &ref) const
+{
+    if (isStock() != ref.isStock())
+        return false;
+    if (isStock())
+        return maStockName == ref.maStockName;
+    else
+        return maBitmapEx == ref.maBitmapEx;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 8af60681afb1..60e968771d78 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -365,8 +365,8 @@ VclBuilder::VclBuilder(vcl::Window *pParent, const OUString& sUIDir, const OUStr
                 SAL_WARN_IF(eType != SymbolType::IMAGE, "vcl.layout", "inimplemented symbol type for radiobuttons");
             if (eType == SymbolType::IMAGE)
             {
-                BitmapEx aBitmap(mapStockToImageResource(rImageInfo.m_sStock));
-                Image const aImage(aBitmap);
+                Image const aImage("private:graphicrepository/" +
+                                   mapStockToImageResource(rImageInfo.m_sStock));
                 if (!aI->m_bRadio)
                     pTargetButton->SetModeImage(aImage);
                 else
diff --git a/vcl/source/window/msgbox.cxx b/vcl/source/window/msgbox.cxx
index 2a99d25ac2ee..40a120e0508a 100644
--- a/vcl/source/window/msgbox.cxx
+++ b/vcl/source/window/msgbox.cxx
@@ -37,12 +37,13 @@
 static void ImplInitMsgBoxImageList()
 {
     ImplSVData* pSVData = ImplGetSVData();
-    if (pSVData->maWinData.maMsgBoxImgList.empty())
+    std::vector<Image> &rImages = pSVData->maWinData.maMsgBoxImgList;
+    if (rImages.empty())
     {
-        pSVData->maWinData.maMsgBoxImgList.emplace_back(BitmapEx(SV_RESID_BITMAP_ERRORBOX));
-        pSVData->maWinData.maMsgBoxImgList.emplace_back(BitmapEx(SV_RESID_BITMAP_QUERYBOX));
-        pSVData->maWinData.maMsgBoxImgList.emplace_back(BitmapEx(SV_RESID_BITMAP_WARNINGBOX));
-        pSVData->maWinData.maMsgBoxImgList.emplace_back(BitmapEx(SV_RESID_BITMAP_INFOBOX));
+        rImages.emplace_back(Image("private:graphicrepository/" SV_RESID_BITMAP_ERRORBOX));
+        rImages.emplace_back(Image("private:graphicrepository/" SV_RESID_BITMAP_QUERYBOX));
+        rImages.emplace_back(Image("private:graphicrepository/" SV_RESID_BITMAP_WARNINGBOX));
+        rImages.emplace_back(Image("private:graphicrepository/" SV_RESID_BITMAP_INFOBOX));
     }
 }
 
commit 1a3e67dc574c8e7053a693d47921233c08f9ecb2
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Fri Nov 23 02:14:00 2018 +0000
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Dec 6 10:50:20 2018 +0100

    Anti-alias toolbar button drop-downs.
    
    Change-Id: Id4eed12f3d4a32b71d00b99e6e82ca7cefb3f8ec
    (cherry picked from commit 121a30224bbbe85b559b0e4559c14e145101511f)

diff --git a/vcl/source/window/toolbox.cxx b/vcl/source/window/toolbox.cxx
index 5d569aa5f50e..bbc4ddf7c9a1 100644
--- a/vcl/source/window/toolbox.cxx
+++ b/vcl/source/window/toolbox.cxx
@@ -2532,36 +2532,27 @@ static void ImplDrawDropdownArrow(vcl::RenderContext& rRenderContext, const tool
 
     float fScaleFactor = rRenderContext.GetDPIScaleFactor();
 
-    if( !bRotate )
-    {
-        long width = 5 * fScaleFactor;
-        long height = 3 * fScaleFactor;
+    tools::Polygon aPoly(4);
 
-        long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2;
-        long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2;
-        while( width >= 1)
-        {
-            rRenderContext.DrawRect( tools::Rectangle( x, y, x+width-1, y ) );
-            y++;
-            x++;
-            width -= 2;
-        }
-    }
-    else
-    {
-        long width = 3 * fScaleFactor;
-        long height = 5 * fScaleFactor;
+    long width = 7 * fScaleFactor;
+    long height = 4 * fScaleFactor;
 
-        long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2;
-        long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2;
-        while( height >= 1)
-        {
-            rRenderContext.DrawRect( tools::Rectangle( x, y, x, y+height-1 ) );
-            y++;
-            x++;
-            height -= 2;
-        }
-    }
+    long x = rDropDownRect.Left() + (rDropDownRect.getWidth() - width)/2;
+    long y = rDropDownRect.Top() + (rDropDownRect.getHeight() - height)/2;
+
+    long halfwidth = (width+1)>>1;
+    aPoly.SetPoint(Point(x, y), 0);
+    aPoly.SetPoint(Point(x + halfwidth, y + height), 1);
+    aPoly.SetPoint(Point(x + halfwidth*2, y), 2);
+    aPoly.SetPoint(Point(x, y), 3);
+
+    if (bRotate) // TESTME: harder ...
+        aPoly.Rotate(Point(x,y+height/2),-900);
+
+    auto aaflags = rRenderContext.GetAntialiasing();
+    rRenderContext.SetAntialiasing(AntialiasingFlags::EnableB2dDraw);
+    rRenderContext.DrawPolygon( aPoly );
+    rRenderContext.SetAntialiasing(aaflags);
 
     if( bFillColor )
         rRenderContext.SetFillColor(aOldFillColor);


More information about the Libreoffice-commits mailing list