LibreOffice Module svx (master) 1
xmlgrhlp.hxx
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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_SVX_XMLGRHLP_HXX
21#define INCLUDED_SVX_XMLGRHLP_HXX
22
24#include <vcl/graph.hxx>
25#include <rtl/ref.hxx>
26
27#include <string_view>
28#include <vector>
29#include <unordered_map>
30#include <utility>
31#include <com/sun/star/document/XGraphicObjectResolver.hpp>
32#include <com/sun/star/document/XGraphicStorageHandler.hpp>
33#include <com/sun/star/document/XBinaryStreamResolver.hpp>
34#include <com/sun/star/embed/XStorage.hpp>
35#include <svx/svxdllapi.h>
36
38{
39 Read, Write
40};
41
43{
44 css::uno::Reference < css::embed::XStorage > xStorage;
45 css::uno::Reference < css::io::XStream > xStream;
46};
47
49 public comphelper::WeakComponentImplHelper<css::document::XGraphicObjectResolver,
50 css::document::XGraphicStorageHandler,
51 css::document::XBinaryStreamResolver>
52{
53private:
54 css::uno::Reference < css::embed::XStorage > mxRootStorage;
56 std::vector< css::uno::Reference< css::io::XOutputStream > >
58
59 std::unordered_map<OUString, css::uno::Reference<css::graphic::XGraphic>> maGraphicObjects;
60 std::unordered_map<Graphic, std::pair<OUString, OUString>> maExportGraphics;
61
64
65 SVX_DLLPRIVATE static bool ImplGetStreamNames( const OUString& rURLStr,
66 OUString& rPictureStorageName,
67 OUString& rPictureStreamName );
68 SVX_DLLPRIVATE css::uno::Reference < css::embed::XStorage >
69 ImplGetGraphicStorage( const OUString& rPictureStorageName );
71 ImplGetGraphicStream( const OUString& rPictureStorageName,
72 const OUString& rPictureStreamName );
73 SVX_DLLPRIVATE static OUString ImplGetGraphicMimeType( std::u16string_view rFileName );
74 SVX_DLLPRIVATE Graphic ImplReadGraphic( const OUString& rPictureStorageName,
75 const OUString& rPictureStreamName );
76
78 virtual ~SvXMLGraphicHelper() override;
79 void Init( const css::uno::Reference < css::embed::XStorage >& xXMLStorage,
80 SvXMLGraphicHelperMode eCreateMode,
81 const OUString& rGraphicMimeType = OUString() );
82
83 SVX_DLLPRIVATE OUString implSaveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic,
84 OUString & rOutMimeType,
85 std::u16string_view rRequestName);
86
87public:
89
90 static rtl::Reference<SvXMLGraphicHelper> Create( const css::uno::Reference < css::embed::XStorage >& rXMLStorage,
91 SvXMLGraphicHelperMode eCreateMode );
93 const OUString& rMimeType = OUString() );
94
95public:
96
97 // XGraphicObjectResolver
98 virtual OUString SAL_CALL resolveGraphicObjectURL( const OUString& aURL ) override;
99
100 // XGraphicStorageHandler
101 virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
102 loadGraphic(OUString const & aURL) override;
103
104 virtual css::uno::Reference<css::graphic::XGraphic> SAL_CALL
105 loadGraphicFromOutputStream(css::uno::Reference<css::io::XOutputStream> const & rxOutputStream) override;
106
107 virtual OUString SAL_CALL
108 saveGraphic(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
109
110 virtual OUString SAL_CALL
111 saveGraphicByName(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic, OUString & rOutSavedMimeType, OUString const & rRequestName) override;
112
113 virtual css::uno::Reference<css::io::XInputStream> SAL_CALL
114 createInputStream(css::uno::Reference<css::graphic::XGraphic> const & rxGraphic) override;
115
116 // XBinaryStreamResolver
117 virtual css::uno::Reference< css::io::XInputStream > SAL_CALL getInputStream( const OUString& rURL ) override;
118 virtual css::uno::Reference< css::io::XOutputStream > SAL_CALL createOutputStream( ) override;
119 virtual OUString SAL_CALL resolveOutputStream( const css::uno::Reference< css::io::XOutputStream >& rxBinaryStream ) override;
120};
121
122namespace svx {
123 SVXCORE_DLLPUBLIC void DropUnusedNamedItems(css::uno::Reference<css::uno::XInterface> const& xModel);
124}
125
126#endif
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unordered_map< OUString, css::uno::Reference< css::graphic::XGraphic > > maGraphicObjects
Definition: xmlgrhlp.hxx:59
SvXMLGraphicHelperMode meCreateMode
Definition: xmlgrhlp.hxx:62
OUString maCurStorageName
Definition: xmlgrhlp.hxx:55
OUString maOutputMimeType
Definition: xmlgrhlp.hxx:63
std::vector< css::uno::Reference< css::io::XOutputStream > > maGrfStms
Definition: xmlgrhlp.hxx:57
static rtl::Reference< SvXMLGraphicHelper > Create(const css::uno::Reference< css::embed::XStorage > &rXMLStorage, SvXMLGraphicHelperMode eCreateMode)
std::unordered_map< Graphic, std::pair< OUString, OUString > > maExportGraphics
Definition: xmlgrhlp.hxx:60
css::uno::Reference< css::embed::XStorage > mxRootStorage
Definition: xmlgrhlp.hxx:54
void Init()
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
void DropUnusedNamedItems(css::uno::Reference< css::uno::XInterface > const &xModel)
Definition: xmlgrhlp.cxx:1122
Reference< io::XInputStream > createInputStream(std::vector< sal_Int8 > &&rInData)
Reference< io::XOutputStream > createOutputStream(std::vector< sal_Int8 > *pOutData)
css::uno::Reference< css::embed::XStorage > xStorage
Definition: xmlgrhlp.hxx:44
css::uno::Reference< css::io::XStream > xStream
Definition: xmlgrhlp.hxx:45
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
SvXMLGraphicHelperMode
Definition: xmlgrhlp.hxx:38