summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-04-12 14:46:49 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-04-13 10:03:07 +0200
commitf8072cc8e43b42e2bfa227bb33aa06be69233e46 (patch)
tree24fd566c607433c9d2cccf5d7912981055967e7f
parent2b2fe50f33f7d677098f3ebafa8357aea848c0ea (diff)
Don't abuse loading of a Graphic to actually load an Image
Change-Id: I816c46542088f36ef69b127cc13080e3bc8cdfc2 Reviewed-on: https://gerrit.libreoffice.org/52806 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
-rw-r--r--sfx2/source/sidebar/Tools.cxx15
-rw-r--r--vcl/source/image/Image.cxx24
2 files changed, 21 insertions, 18 deletions
diff --git a/sfx2/source/sidebar/Tools.cxx b/sfx2/source/sidebar/Tools.cxx
index 727cd6f24bec..47c27adb2520 100644
--- a/sfx2/source/sidebar/Tools.cxx
+++ b/sfx2/source/sidebar/Tools.cxx
@@ -27,7 +27,6 @@
#include <vcl/gradient.hxx>
#include <com/sun/star/frame/XDispatchProvider.hpp>
-#include <com/sun/star/graphic/GraphicProvider.hpp>
#include <com/sun/star/util/URLTransformer.hpp>
#include <com/sun/star/frame/ModuleManager.hpp>
@@ -60,18 +59,10 @@ Image Tools::GetImage (
const Image aPanelImage(vcl::CommandInfoProvider::GetImageForCommand(rsURL, rxFrame));
return aPanelImage;
}
- else
+ else if (rsURL.startsWith("private:graphicrepository"))
{
- const Reference<XComponentContext> xContext (::comphelper::getProcessComponentContext());
- const Reference<graphic::XGraphicProvider> xGraphicProvider =
- graphic::GraphicProvider::create( xContext );
- ::comphelper::NamedValueCollection aMediaProperties;
- aMediaProperties.put("URL", rsURL);
- const Reference<graphic::XGraphic> xGraphic (
- xGraphicProvider->queryGraphic(aMediaProperties.getPropertyValues()),
- UNO_QUERY);
- if (xGraphic.is())
- return Image(xGraphic);
+ const Image aPanelImage(rsURL);
+ return aPanelImage;
}
}
return Image();
diff --git a/vcl/source/image/Image.cxx b/vcl/source/image/Image.cxx
index e99cccd0f256..e9e105c10bf0 100644
--- a/vcl/source/image/Image.cxx
+++ b/vcl/source/image/Image.cxx
@@ -54,13 +54,25 @@ 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))
+ {
+ ImplInit(aBitmapEx);
+ }
+ }
+ else
+ {
+ OUString aPath;
+ osl::FileBase::getSystemPathFromFileURL(rFileUrl, aPath);
+ Graphic aGraphic;
+ if (ERRCODE_NONE == GraphicFilter::LoadGraphic(aPath, IMP_PNG, aGraphic))
+ {
+ ImplInit(aGraphic.GetBitmapEx());
+ }
}
}