LibreOffice Module oox (master) 1
xmlfilterbase.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_OOX_CORE_XMLFILTERBASE_HXX
21#define INCLUDED_OOX_CORE_XMLFILTERBASE_HXX
22
23#include <memory>
24#include <string_view>
25#include <vector>
26
27#include <com/sun/star/uno/Reference.hxx>
30#include <oox/dllapi.h>
32#include <rtl/ustring.hxx>
33#include <sal/types.h>
34
35namespace com::sun::star {
36 namespace document { class XDocumentProperties; }
37 namespace io { class XInputStream; }
38 namespace io { class XOutputStream; }
39 namespace io { class XStream; }
40 namespace text { class XText; }
41 namespace text { class XTextCursor; }
42 namespace text { class XTextField; }
43 namespace uno { class XComponentContext; }
44 namespace xml::dom { class XDocument; }
45 namespace xml::sax { class XFastSAXSerializable; }
46}
47
48namespace oox {
49 namespace drawingml { class Theme; }
50 namespace drawingml::chart { class ChartConverter; }
51 namespace drawingml::table {
52 class TableStyleList;
53 typedef std::shared_ptr< TableStyleList > TableStyleListPtr;
54 }
55 namespace vml { class Drawing; }
56}
57
58namespace rtl { template <class reference_type> class Reference; }
59
60namespace sax_fastparser {
61 class FastSerializerHelper;
62
63 typedef std::shared_ptr< FastSerializerHelper > FSHelperPtr;
64}
65
66namespace utl { class MediaDescriptor; }
67
68namespace oox::drawingml
69{
70class Shape;
71}
72
73namespace oox::core {
74
75class FragmentHandler;
76class FastParser;
77
78struct XmlFilterBaseImpl;
79
81 = std::map<std::shared_ptr<drawingml::Shape>, css::uno::Reference<css::drawing::XShape>>;
82using NamedShapePairs = std::map<OUString, ShapePairs>;
83
85{
86public:
88 explicit XmlFilterBase(
89 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
90
91 virtual ~XmlFilterBase() override;
92
94 virtual const ::oox::drawingml::Theme* getCurrentTheme() const = 0;
95
97 virtual std::shared_ptr<::oox::drawingml::Theme> getCurrentThemePtr() const;
98
100 virtual ::oox::vml::Drawing* getVmlDrawing() = 0;
101
104 virtual ::oox::drawingml::chart::ChartConverter* getChartConverter() = 0;
105
107 virtual void useInternalChartDataTable( bool /*bInternal*/ ) { }
108
111
112
113 OUString getFragmentPathFromFirstTypeFromOfficeDoc( std::u16string_view rPart );
114
120 bool importFragment( const rtl::Reference<FragmentHandler>& rxHandler );
121 bool importFragment( const rtl::Reference<FragmentHandler>& rxHandler, FastParser& rParser );
122
130 css::uno::Reference< css::xml::dom::XDocument> importFragment( const OUString& rFragmentPath );
131
143 bool importFragment( const ::rtl::Reference< FragmentHandler >& rxHandler,
144 const css::uno::Reference< css::xml::sax::XFastSAXSerializable >& rxSerializer );
145
150 RelationsRef importRelations( const OUString& rFragmentPath );
151
162 OUString addRelation( const OUString& rType, std::u16string_view rTarget );
163
177 OUString addRelation( const css::uno::Reference< css::io::XOutputStream >& rOutputStream, const OUString& rType, std::u16string_view rTarget, bool bExternal = false );
178
193 css::uno::Reference< css::io::XOutputStream >
194 openFragmentStream(
195 const OUString& rStreamName,
196 const OUString& rMediaType );
197
214 openFragmentStreamWithSerializer(
215 const OUString& rStreamName,
216 const OUString& rMediaType );
217
222 sal_Int32 GetUniqueId() { return mnMaxDocId++; }
223
224 sal_Int32 GetMaxDocId() { return mnMaxDocId; }
225
226 void SetMaxDocId(sal_Int32 maxDocId) { mnMaxDocId = maxDocId; }
227
232 void exportDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xProperties, bool bSecurityOptOpenReadOnly );
233
235 void exportCustomFragments();
236
238 void importDocumentProperties();
239
240 static void putPropertiesToDocumentGrabBag(const css::uno::Reference<css::lang::XComponent>& xDstDoc,
241 const comphelper::SequenceAsHashMap& rProperties);
242
243 static FastParser* createParser();
244
245 bool isMSO2007Document() const;
246 bool isMSODocument() const;
247
250 void setMissingExtDrawing();
251
252 void setDiagramFontHeights(NamedShapePairs* pDiagramFontHeights);
253 NamedShapePairs* getDiagramFontHeights();
254
255 void checkDocumentProperties(
256 const css::uno::Reference<css::document::XDocumentProperties>& xDocProps);
257
258 OUString getNamespaceURL(sal_Int32 nNSID) const;
259
260protected:
261 virtual css::uno::Reference< css::io::XInputStream >
262 implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const override;
263
264 virtual css::uno::Reference< css::io::XStream >
265 implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const override;
266
267 virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor ) override;
268
269private:
271 const css::uno::Reference< css::io::XInputStream >& rxInStream ) const override;
273 const css::uno::Reference< css::io::XStream >& rxOutStream ) const override;
274
275 void importCustomFragments(css::uno::Reference<css::embed::XStorage> const & xDocumentStorage);
276
277private:
278 ::std::unique_ptr< XmlFilterBaseImpl > mxImpl;
279 sal_Int32 mnRelId;
280 sal_Int32 mnMaxDocId;
282 bool mbMSO;
283protected:
285};
286
287} // namespace oox::core
288
289#endif
290
291/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Wrapper for a fast SAX parser that works on automatically generated OOXML token and namespace identif...
Definition: fastparser.hxx:54
virtual ::oox::vml::Drawing * getVmlDrawing()=0
Has to be implemented by each filter to return the collection of VML shapes.
sal_Int32 GetUniqueId()
Returns new unique ID for exported document.
virtual ::oox::drawingml::table::TableStyleListPtr getTableStyles()=0
Has to be implemented by each filter to return the table style list.
virtual ::oox::drawingml::chart::ChartConverter * getChartConverter()=0
Has to be implemented by each filter, returns a filter-specific chart converter object,...
void SetMaxDocId(sal_Int32 maxDocId)
bool importFragment(const ::rtl::Reference< FragmentHandler > &rxHandler, const css::uno::Reference< css::xml::sax::XFastSAXSerializable > &rxSerializer)
Imports a fragment from an xml::dom::XDocument using the passed fragment handler.
virtual StorageRef implCreateStorage(const css::uno::Reference< css::io::XStream > &rxOutStream) const override
OUString addRelation(const css::uno::Reference< css::io::XOutputStream > &rOutputStream, const OUString &rType, std::u16string_view rTarget, bool bExternal=false)
Adds new relation to part's relations.
::std::unique_ptr< XmlFilterBaseImpl > mxImpl
virtual void useInternalChartDataTable(bool)
Helper to switch chart data table - specifically for xlsx imports.
virtual StorageRef implCreateStorage(const css::uno::Reference< css::io::XInputStream > &rxInStream) const override
virtual const ::oox::drawingml::Theme * getCurrentTheme() const =0
Has to be implemented by each filter, returns the current theme.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
def text(shape, orig_st)
Reference
std::shared_ptr< Relations > RelationsRef
Definition: relations.hxx:63
std::map< std::shared_ptr< drawingml::Shape >, css::uno::Reference< css::drawing::XShape > > ShapePairs
std::map< OUString, ShapePairs > NamedShapePairs
std::shared_ptr< TableStyleList > TableStyleListPtr
static void importFragment(core::XmlFilterBase &rFilter, const uno::Reference< xml::dom::XDocument > &rXDom, const OUString &rDocName, const DiagramPtr &pDiagram, const rtl::Reference< core::FragmentHandler > &rxHandler)
Definition: diagram.cxx:238
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
std::shared_ptr< FastSerializerHelper > FSHelperPtr
Shape