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 
14 #include <vcl/graphicfilter.hxx>
15 #include <vcl/weld.hxx>
16 
17 using namespace css;
18 
19 namespace vcl
20 {
21 namespace graphic
22 {
23 Graphic loadFromURL(OUString const& rURL, weld::Window* pParentWin)
24 {
25  Graphic aGraphic;
26 
27  std::unique_ptr<SvStream> pInputStream = utl::UcbStreamHelper::CreateStream(
28  rURL, StreamMode::READ, pParentWin ? pParentWin->GetXWindow() : nullptr);
29 
30  if (pInputStream)
31  {
33 
34  ErrCode nError
35  = rFilter.ImportGraphic(aGraphic, rURL, *pInputStream, GRFILTER_FORMAT_DONTKNOW,
37  /*pExtHeader*/ static_cast<WmfExternal const*>(nullptr));
38  if (nError != ERRCODE_NONE || aGraphic.GetType() == GraphicType::NONE)
39  return Graphic();
40  }
41 
42  return aGraphic;
43 }
44 }
45 } // end vcl::graphic
46 
47 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
ErrCode ImportGraphic(Graphic &rGraphic, const INetURLObject &rPath, sal_uInt16 nFormat=GRFILTER_FORMAT_DONTKNOW, sal_uInt16 *pDeterminedFormat=nullptr, GraphicFilterImportFlags nImportFlags=GraphicFilterImportFlags::NONE)
Class to import and export graphic formats.
Graphic loadFromURL(OUString const &rURL, weld::Window *pParentWin)
static std::unique_ptr< SvStream > CreateStream(const OUString &rFileName, StreamMode eOpenMode, css::uno::Reference< css::awt::XWindow > xParentWin=nullptr)
GraphicType GetType() const
Definition: graph.cxx:313
#define GRFILTER_FORMAT_DONTKNOW
#define ERRCODE_NONE
Definition: errcode.hxx:198
static GraphicFilter & GetGraphicFilter()