[Libreoffice-commits] core.git: include/vcl vcl/Library_vcl.mk vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.co.uk
Tue Mar 6 23:23:39 UTC 2018
include/vcl/GraphicLoader.hxx | 25 +++++++++++++++++
vcl/Library_vcl.mk | 3 +-
vcl/source/graphic/GraphicLoader.cxx | 49 +++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 1 deletion(-)
New commits:
commit 5f618375a5360160e67f6aac4aece90ab218c081
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date: Thu Mar 1 05:36:10 2018 +0900
add GraphicLoader and funct. to load graphic from URL
Change-Id: Ib722ee5bc20908d50642b1371b20c878158204cf
Reviewed-on: https://gerrit.libreoffice.org/50538
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
diff --git a/include/vcl/GraphicLoader.hxx b/include/vcl/GraphicLoader.hxx
new file mode 100644
index 000000000000..9b96ec13b8a2
--- /dev/null
+++ b/include/vcl/GraphicLoader.hxx
@@ -0,0 +1,25 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_VCL_GRAPHIC_LOADER_HXX
+#define INCLUDED_VCL_GRAPHIC_LOADER_HXX
+
+#include <vcl/graph.hxx>
+
+namespace vcl
+{
+namespace graphic
+{
+Graphic VCL_DLLPUBLIC loadFromURL(OUString const& rURL);
+}
+} // end vcl::graphic
+
+#endif // INCLUDED_VCL_GRAPHIC_TOOLS_HXX
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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: */
More information about the Libreoffice-commits
mailing list