LibreOffice Module vcl (master) 1
GraphicLoader.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 */
10
11#include <vcl/GraphicLoader.hxx>
12
13#include <com/sun/star/awt/XWindow.hpp>
15#include <vcl/graphicfilter.hxx>
16#include <vcl/weld.hxx>
17
18using namespace css;
19
20namespace vcl::graphic
21{
22Graphic loadFromURL(OUString const& rURL, weld::Window* pParentWin)
23{
24 Graphic aGraphic;
25
26 std::unique_ptr<SvStream> pInputStream = utl::UcbStreamHelper::CreateStream(
27 rURL, StreamMode::READ, pParentWin ? pParentWin->GetXWindow() : nullptr);
28
29 if (pInputStream)
30 {
32
33 ErrCode nError
34 = rFilter.ImportGraphic(aGraphic, rURL, *pInputStream, GRFILTER_FORMAT_DONTKNOW,
36 if (nError != ERRCODE_NONE || aGraphic.GetType() == GraphicType::NONE)
37 return Graphic();
38 }
39
40 return aGraphic;
41}
42} // end vcl::graphic
43
44/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Class to import and export graphic formats.
static GraphicFilter & GetGraphicFilter()
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
GraphicType GetType() const
Definition: graph.cxx:294
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
#define ERRCODE_NONE
#define GRFILTER_FORMAT_DONTKNOW
Graphic loadFromURL(OUString const &rURL, weld::Window *pParentWin)