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>
33 #include <cppuhelper/basemutex.hxx>
34 #include <cppuhelper/implbase.hxx>
35 #include <oox/dllapi.h>
38 #include <rtl/ustring.hxx>
39 #include <sal/types.h>
40 
41 namespace com::sun::star {
42  namespace beans { struct PropertyValue; }
43  namespace drawing { class XShape; }
44  namespace frame { class XFrame; }
45  namespace frame { class XModel; }
46  namespace io { class XInputStream; }
47  namespace io { class XOutputStream; }
48  namespace io { class XStream; }
49  namespace lang { class XComponent; }
50  namespace lang { class XMultiServiceFactory; }
51  namespace task { class XStatusIndicator; }
52  namespace uno { class XComponentContext; }
53 }
54 
55 namespace comphelper {
56  class SequenceAsHashMap;
57 }
58 namespace utl {
59  class MediaDescriptor;
60 }
61 
62 namespace oox {
63  class GraphicHelper;
64  class ModelObjectHelper;
65 }
66 
67 namespace oox::ole {
68  class OleObjectHelper;
69  class VbaProject;
70 }
71 
72 namespace oox::core {
73 
75 {
78 };
79 
81 
82 typedef ::cppu::WeakImplHelper<
83  css::lang::XServiceInfo,
84  css::lang::XInitialization,
85  css::document::XImporter,
86  css::document::XExporter,
87  css::document::XFilter >
89 
90 class OOX_DLLPUBLIC FilterBase : public FilterBase_BASE, public ::cppu::BaseMutex
91 {
92 public:
94  explicit FilterBase(
95  const css::uno::Reference< css::uno::XComponentContext >& rxContext );
96 
97  virtual ~FilterBase() override;
98 
100  bool isImportFilter() const;
102  bool isExportFilter() const;
103 
104  OoxmlVersion getVersion() const;
105 
107  virtual bool importDocument() = 0;
108 
110  virtual bool exportDocument() = 0;
111 
112 
114  const css::uno::Reference< css::uno::XComponentContext >&
115  getComponentContext() const;
116 
118  const css::uno::Reference< css::frame::XModel >&
119  getModel() const;
120 
122  const css::uno::Reference< css::lang::XMultiServiceFactory >&
123  getModelFactory() const;
124 
126  const css::uno::Reference< css::frame::XFrame >&
127  getTargetFrame() const;
128 
130  const css::uno::Reference< css::task::XStatusIndicator >&
131  getStatusIndicator() const;
132 
134  ::comphelper::SequenceAsHashMap& getFilterData() const;
135 
137  utl::MediaDescriptor& getMediaDescriptor() const;
138 
140  const OUString& getFileUrl() const;
141 
143  OUString getAbsoluteUrl( const OUString& rUrl ) const;
144 
146  StorageRef const & getStorage() const;
147 
156  css::uno::Reference< css::io::XInputStream >
157  openInputStream( const OUString& rStreamName ) const;
158 
167  css::uno::Reference< css::io::XOutputStream >
168  openOutputStream( const OUString& rStreamName ) const;
169 
171  void commitStorage() const;
172 
173  // helpers ----------------------------------------------------------------
174 
176  GraphicHelper& getGraphicHelper() const;
177 
180  ModelObjectHelper& getModelObjectHelper() const;
181 
182  ModelObjectHelper& getModelObjectHelperForModel(
183  const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory) const;
184 
186  ::oox::ole::OleObjectHelper& getOleObjectHelper() const;
187 
189  ::oox::ole::VbaProject& getVbaProject() const;
190 
193  bool importBinaryData( StreamDataSequence & orDataSeq, const OUString& rStreamName );
194 
195  // com.sun.star.lang.XServiceInfo interface -------------------------------
196 
197  virtual sal_Bool SAL_CALL
198  supportsService( const OUString& rServiceName ) override;
199 
200  virtual css::uno::Sequence< OUString > SAL_CALL
201  getSupportedServiceNames() override;
202 
203  // com.sun.star.lang.XInitialization interface ----------------------------
204 
215  virtual void SAL_CALL initialize(
216  const css::uno::Sequence< css::uno::Any >& rArgs ) override;
217 
218  // com.sun.star.document.XImporter interface ------------------------------
219 
220  virtual void SAL_CALL setTargetDocument(
221  const css::uno::Reference< css::lang::XComponent >& rxDocument ) override;
222 
223  // com.sun.star.document.XExporter interface ------------------------------
224 
225  virtual void SAL_CALL setSourceDocument(
226  const css::uno::Reference< css::lang::XComponent >& rxDocument ) override;
227 
228  // com.sun.star.document.XFilter interface --------------------------------
229 
230  virtual sal_Bool SAL_CALL filter(
231  const css::uno::Sequence< css::beans::PropertyValue >& rMediaDescSeq ) override;
232 
233  virtual void SAL_CALL cancel() override;
234 
235  bool exportVBA() const;
236 
237  bool isExportTemplate() const;
238 
239 protected:
240  virtual css::uno::Reference< css::io::XInputStream >
241  implGetInputStream( utl::MediaDescriptor& rMediaDesc ) const;
242  virtual css::uno::Reference< css::io::XStream >
243  implGetOutputStream( utl::MediaDescriptor& rMediaDesc ) const;
244 
245  virtual bool implFinalizeExport( utl::MediaDescriptor& rMediaDescriptor );
246 
247  css::uno::Reference< css::io::XStream > const &
248  getMainDocumentStream( ) const;
249 
250 private:
251  void setMediaDescriptor(
252  const css::uno::Sequence< css::beans::PropertyValue >& rMediaDescSeq );
253 
256  virtual GraphicHelper* implCreateGraphicHelper() const;
257 
259  virtual ::oox::ole::VbaProject* implCreateVbaProject() const = 0;
260 
261  virtual StorageRef implCreateStorage(
262  const css::uno::Reference< css::io::XInputStream >& rxInStream ) const = 0;
263  virtual StorageRef implCreateStorage(
264  const css::uno::Reference< css::io::XStream >& rxOutStream ) const = 0;
265 
266 private:
267  std::unique_ptr< FilterBaseImpl > mxImpl;
268 };
269 
270 } // namespace oox::core
271 
272 #endif
273 
274 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
exports com.sun.star. io
css::uno::Sequence< OUString > getSupportedServiceNames()
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
exports com.sun.star. frame
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
exports com.sun.star. drawing
css::uno::Sequence< sal_Int8 > StreamDataSequence
Contains tables for named drawing objects for a document model.
unsigned char sal_Bool
Helper for OLE object handling.
exports com.sun.star. task
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
exports com.sun.star. beans
::cppu::WeakImplHelper< css::lang::XServiceInfo, css::lang::XInitialization, css::document::XImporter, css::document::XExporter, css::document::XFilter > FilterBase_BASE
Definition: filterbase.hxx:80
exports com.sun.star. lang
#define OOX_DLLPUBLIC
Definition: dllapi.h:28
Reference< XSingleServiceFactory > xFactory
std::unique_ptr< FilterBaseImpl > mxImpl
Definition: filterbase.hxx:267