LibreOffice Module oox (master) 1
filterbase.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_FILTERBASE_HXX
21#define INCLUDED_OOX_CORE_FILTERBASE_HXX
22
23#include <memory>
24
25#include <com/sun/star/document/XExporter.hpp>
26#include <com/sun/star/document/XFilter.hpp>
27#include <com/sun/star/document/XImporter.hpp>
28#include <com/sun/star/lang/XInitialization.hpp>
29#include <com/sun/star/lang/XServiceInfo.hpp>
30#include <com/sun/star/uno/Any.hxx>
31#include <com/sun/star/uno/Reference.hxx>
32#include <com/sun/star/uno/Sequence.hxx>
34#include <oox/dllapi.h>
37#include <rtl/ustring.hxx>
38#include <sal/types.h>
39
40namespace com::sun::star {
41 namespace beans { struct PropertyValue; }
42 namespace drawing { class XShape; }
43 namespace frame { class XFrame; }
44 namespace frame { class XModel; }
45 namespace io { class XInputStream; }
46 namespace io { class XOutputStream; }
47 namespace io { class XStream; }
48 namespace lang { class XComponent; }
49 namespace lang { class XMultiServiceFactory; }
50 namespace task { class XStatusIndicator; }
51 namespace uno { class XComponentContext; }
52}
53
54namespace comphelper {
55 class SequenceAsHashMap;
56}
57namespace utl {
58 class MediaDescriptor;
59}
60
61namespace oox {
62 class GraphicHelper;
63 class ModelObjectHelper;
64}
65
66namespace oox::ole {
67 class OleObjectHelper;
68 class VbaProject;
69}
70
71namespace oox::core {
72
74{
84};
85
86struct FilterBaseImpl;
87
88typedef ::cppu::WeakImplHelper<
89 css::lang::XServiceInfo,
90 css::lang::XInitialization,
91 css::document::XImporter,
92 css::document::XExporter,
93 css::document::XFilter >
95
97{
98public:
100 explicit FilterBase(
101 const css::uno::Reference< css::uno::XComponentContext >& rxContext );
102
103 virtual ~FilterBase() override;
104
106 bool isImportFilter() const;
108 bool isExportFilter() const;
109
110 OoxmlVersion getVersion() const;
111
113 virtual bool importDocument() = 0;
114
116 virtual bool exportDocument() = 0;
117
118
120 const css::uno::Reference< css::uno::XComponentContext >&
121 getComponentContext() const;
122
124 const css::uno::Reference< css::frame::XModel >&
125 getModel() const;
126
128 const css::uno::Reference< css::lang::XMultiServiceFactory >&
129 getModelFactory() const;
130
132 const css::uno::Reference< css::frame::XFrame >&
133 getTargetFrame() const;
134
136 const css::uno::Reference< css::task::XStatusIndicator >&
137 getStatusIndicator() const;
138
140 ::comphelper::SequenceAsHashMap& getFilterData() const;
141
143 utl::MediaDescriptor& getMediaDescriptor() const;
144
146 const OUString& getFileUrl() const;
147
149 OUString getAbsoluteUrl( const OUString& rUrl ) const;
150
152 StorageRef const & getStorage() const;
153
162 css::uno::Reference< css::io::XInputStream >
163 openInputStream( const OUString& rStreamName ) const;
164
173 css::uno::Reference< css::io::XOutputStream >
174 openOutputStream( const OUString& rStreamName ) const;
175
177 void commitStorage() const;
178
179 // helpers ----------------------------------------------------------------
180
182 GraphicHelper& getGraphicHelper() const;
183
186 ModelObjectHelper& getModelObjectHelper() const;
187
188 ModelObjectHelper& getModelObjectHelperForModel(
189 const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory) const;
190
192 ::oox::ole::OleObjectHelper& getOleObjectHelper() const;
193
195 ::oox::ole::VbaProject& getVbaProject() const;
196
199 bool importBinaryData( StreamDataSequence & orDataSeq, const OUString& rStreamName );
200
201 // com.sun.star.lang.XServiceInfo interface -------------------------------
202
203 virtual sal_Bool SAL_CALL
204 supportsService( const OUString& rServiceName ) override;
205
206 virtual css::uno::Sequence< OUString > SAL_CALL
207 getSupportedServiceNames() override;
208
209 // com.sun.star.lang.XInitialization interface ----------------------------
210
221 virtual void SAL_CALL initialize(
222 const css::uno::Sequence< css::uno::Any >& rArgs ) override;
223
224 // com.sun.star.document.XImporter interface ------------------------------
225
226 virtual void SAL_CALL setTargetDocument(
227 const css::uno::Reference< css::lang::XComponent >& rxDocument ) override;
228
229 // com.sun.star.document.XExporter interface ------------------------------
230
231 virtual void SAL_CALL setSourceDocument(
232 const css::uno::Reference< css::lang::XComponent >& rxDocument ) override;
233
234 // com.sun.star.document.XFilter interface --------------------------------
235
236 virtual sal_Bool SAL_CALL filter(
237 const css::uno::Sequence< css::beans::PropertyValue >& rMediaDescSeq ) override;
238
239 virtual void SAL_CALL cancel() override;
240
241 bool exportVBA() const;
242
243 bool isExportTemplate() const;
244
245protected:
246 virtual css::uno::Reference< css::io::XInputStream >
247 implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const;
248 virtual css::uno::Reference< css::io::XStream >
249 implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const;
250
251 virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor );
252
253 css::uno::Reference< css::io::XStream > const &
254 getMainDocumentStream( ) const;
255
256private:
257 void setMediaDescriptor(
258 const css::uno::Sequence< css::beans::PropertyValue >& rMediaDescSeq );
259
262 virtual GraphicHelper* implCreateGraphicHelper() const;
263
265 virtual ::oox::ole::VbaProject* implCreateVbaProject() const = 0;
266
268 const css::uno::Reference< css::io::XInputStream >& rxInStream ) const = 0;
270 const css::uno::Reference< css::io::XStream >& rxOutStream ) const = 0;
271
272private:
273 std::unique_ptr< FilterBaseImpl > mxImpl;
274};
275
276} // namespace oox::core
277
278#endif
279
280/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
Contains tables for named drawing objects for a document model.
virtual bool importDocument()=0
Derived classes implement import of the entire document.
virtual bool exportDocument()=0
Derived classes implement export of the entire document.
virtual StorageRef implCreateStorage(const css::uno::Reference< css::io::XStream > &rxOutStream) const =0
std::unique_ptr< FilterBaseImpl > mxImpl
Definition: filterbase.hxx:273
virtual ::oox::ole::VbaProject * implCreateVbaProject() const =0
Derived classes create a VBA project manager object.
virtual StorageRef implCreateStorage(const css::uno::Reference< css::io::XInputStream > &rxInStream) const =0
Helper for OLE object handling.
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
css::uno::Sequence< OUString > getSupportedServiceNames()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
@ ISOIEC_29500_2008
Definition: filterbase.hxx:83
@ ECMA_376_1ST_EDITION
There are currently 5 editions of ECMA-376, latest is from 2021.
Definition: filterbase.hxx:82
::cppu::WeakImplHelper< css::lang::XServiceInfo, css::lang::XInitialization, css::document::XImporter, css::document::XExporter, css::document::XFilter > FilterBase_BASE
Definition: filterbase.hxx:86
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
css::uno::Sequence< sal_Int8 > StreamDataSequence
unsigned char sal_Bool