diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2018-11-26 16:59:42 +0000 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-12-06 10:51:34 +0100 |
commit | ca936bb8b1728f470028e5ae0c55a808210f2b0c (patch) | |
tree | defc6a2d3c3336488b950848304fc3bba39b3361 /vcl | |
parent | 190fad517d66be7891d54d0731cecb148aff357d (diff) |
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)
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/graph.cxx | 14 | ||||
-rw-r--r-- | vcl/source/helper/commandinfoprovider.cxx | 35 | ||||
-rw-r--r-- | vcl/source/image/Image.cxx | 30 |
3 files changed, 46 insertions, 33 deletions
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) |