summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2018-03-01 05:36:10 +0900
committerTomaž Vajngerl <quikee@gmail.com>2018-03-07 00:23:16 +0100
commit5f618375a5360160e67f6aac4aece90ab218c081 (patch)
tree57b55f9cf59650b73eafd529227650415b7db236 /vcl
parent8fbacaccf41c914bb3e8328980b9981018b187fe (diff)
add GraphicLoader and funct. to load graphic from URL
Change-Id: Ib722ee5bc20908d50642b1371b20c878158204cf Reviewed-on: https://gerrit.libreoffice.org/50538 Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vcl.mk3
-rw-r--r--vcl/source/graphic/GraphicLoader.cxx49
2 files changed, 51 insertions, 1 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 9e292916f843..0aecb5e16a1c 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -300,7 +300,8 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/gdi/wall \
vcl/source/gdi/scrptrun \
vcl/source/gdi/CommonSalLayout \
- vcl/source/bitmap/bitmap \
+ vcl/source/graphic/GraphicLoader \
+ vcl/source/bitmap/bitmap \
vcl/source/bitmap/bitmapfilter \
vcl/source/bitmap/bitmappaint \
vcl/source/bitmap/bitmapscalesuper \
diff --git a/vcl/source/graphic/GraphicLoader.cxx b/vcl/source/graphic/GraphicLoader.cxx
new file mode 100644
index 000000000000..76495e290a9b
--- /dev/null
+++ b/vcl/source/graphic/GraphicLoader.cxx
@@ -0,0 +1,49 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#include <vcl/GraphicLoader.hxx>
+
+#include <comphelper/processfactory.hxx>
+#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;
+
+namespace vcl
+{
+namespace graphic
+{
+Graphic loadFromURL(OUString const& rURL)
+{
+ uno::Reference<css::graphic::XGraphic> xGraphic;
+
+ 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);
+
+ Graphic aGraphic(xGraphic);
+ aGraphic.setOriginURL(rURL);
+ return aGraphic;
+}
+}
+} // end vcl::graphic
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */