[Libreoffice-commits] core.git: vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Fri Mar 16 00:55:12 UTC 2018
vcl/source/graphic/GraphicLoader.cxx | 42 ++++++++++++++++-------------------
1 file changed, 20 insertions(+), 22 deletions(-)
New commits:
commit e4db2bcaef12877258f691febab1a1260dcf9916
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu Mar 15 20:09:41 2018 +0900
more robust method to load a Graphic from URL, +clean up
Change-Id: Ib7fb107a56a3cc9fffb6cfaa9bbc2117434902df
Reviewed-on: https://gerrit.libreoffice.org/51329
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/vcl/source/graphic/GraphicLoader.cxx b/vcl/source/graphic/GraphicLoader.cxx
index 03ca2a6f56a3..b07b345cb982 100644
--- a/vcl/source/graphic/GraphicLoader.cxx
+++ b/vcl/source/graphic/GraphicLoader.cxx
@@ -14,10 +14,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/graphic/GraphicProvider.hpp>
#include <com/sun/star/graphic/XGraphicProvider.hpp>
-//#include <com/sun/star/lang/XUnoTunnel.hpp>
-//#include <com/sun/star/lang/XTypeProvider.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
-//#include <cppuhelper/typeprovider.hxx>
using namespace css;
@@ -27,31 +24,32 @@ namespace graphic
{
Graphic loadFromURL(OUString const& rURL)
{
- uno::Reference<css::graphic::XGraphic> xGraphic;
+ Graphic aGraphic;
- uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
- uno::Reference<css::graphic::XGraphicProvider> xProv(
- css::graphic::GraphicProvider::create(xContext));
-
- uno::Sequence<beans::PropertyValue> aLoadProps(1);
- aLoadProps[0].Name = "URL";
- aLoadProps[0].Value <<= rURL;
-
- xGraphic = xProv->queryGraphic(aLoadProps);
-
- std::unique_ptr<Graphic> pGraphic;
- if (xGraphic.is())
+ try
{
- pGraphic.reset(new Graphic(xGraphic));
+ uno::Reference<css::graphic::XGraphic> xGraphic;
+ uno::Reference<uno::XComponentContext> xContext(comphelper::getProcessComponentContext());
+ uno::Reference<css::graphic::XGraphicProvider> xProvider;
+ xProvider.set(css::graphic::GraphicProvider::create(xContext));
+
+ uno::Sequence<beans::PropertyValue> aLoadProps(1);
+ aLoadProps[0].Name = "URL";
+ aLoadProps[0].Value <<= rURL;
+
+ xGraphic = xProvider->queryGraphic(aLoadProps);
+
+ if (xGraphic.is())
+ aGraphic = Graphic(xGraphic);
+ else
+ aGraphic.SetDefaultType();
+ aGraphic.setOriginURL(rURL);
}
- else
+ catch (uno::Exception const&)
{
- pGraphic.reset(new Graphic);
- pGraphic->SetDefaultType();
}
- pGraphic->setOriginURL(rURL);
- return *pGraphic.get();
+ return aGraphic;
}
}
} // end vcl::graphic
More information about the Libreoffice-commits
mailing list