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
228 void exportDocumentProperties( const css::uno::Reference< css::document::XDocumentProperties >& xProperties, bool bSecurityOptOpenReadOnly );
229
231 void exportCustomFragments();
232
234 void importDocumentProperties();
235
236 static void putPropertiesToDocumentGrabBag(const css::uno::Reference<css::lang::XComponent>& xDstDoc,
237 const comphelper::SequenceAsHashMap& rProperties);
238
239 static FastParser* createParser();
240
241 bool isMSO2007Document() const;
242 bool isMSODocument() const;
243
246 void setMissingExtDrawing();
247
248 void setDiagramFontHeights(NamedShapePairs* pDiagramFontHeights);
249 NamedShapePairs* getDiagramFontHeights();
250
251 void checkDocumentProperties(
252 const css::uno::Reference<css::document::XDocumentProperties>& xDocProps);
253
254 OUString getNamespaceURL(sal_Int32 nNSID) const;
255
256protected:
257 virtual css::uno::Reference< css::io::XInputStream >
258 implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const override;
259
260 virtual css::uno::Reference< css::io::XStream >
261 implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const override;
262
263 virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor ) override;
264
265private:
267 const css::uno::Reference< css::io::XInputStream >& rxInStream ) const override;
269 const css::uno::Reference< css::io::XStream >& rxOutStream ) const override;
270
271 void importCustomFragments(css::uno::Reference<css::embed::XStorage> const & xDocumentStorage);
272
273private:
274 ::std::unique_ptr< XmlFilterBaseImpl > mxImpl;
275 sal_Int32 mnRelId;
276 sal_Int32 mnMaxDocId;
278 bool mbMSO;
279protected:
281};
282
283} // namespace oox::core
284
285#endif
286
287/* 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,...
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