diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2018-03-01 05:36:10 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-03-07 00:23:16 +0100 |
commit | 5f618375a5360160e67f6aac4aece90ab218c081 (patch) | |
tree | 57b55f9cf59650b73eafd529227650415b7db236 /vcl/source/graphic/GraphicLoader.cxx | |
parent | 8fbacaccf41c914bb3e8328980b9981018b187fe (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/source/graphic/GraphicLoader.cxx')
-rw-r--r-- | vcl/source/graphic/GraphicLoader.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
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: */ |