LibreOffice Module oox (master)  1
filterbase.cxx
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 #include <sal/config.h>
21 
22 #include <com/sun/star/container/XNameAccess.hpp>
23 #include <com/sun/star/drawing/XShape.hpp>
24 #include <com/sun/star/frame/XModel.hpp>
25 #include <com/sun/star/io/XStream.hpp>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/task/XInteractionHandler.hpp>
28 #include <com/sun/star/task/XStatusIndicator.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
32 #include <comphelper/sequence.hxx>
35 #include <osl/mutex.hxx>
36 #include <osl/diagnose.h>
37 #include <rtl/instance.hxx>
38 #include <rtl/uri.hxx>
39 #include <memory>
40 #include <set>
41 
42 #include <oox/core/filterbase.hxx>
48 #include <oox/ole/vbaproject.hxx>
49 
50 namespace oox::core {
51 
52 using namespace ::com::sun::star::beans;
53 using namespace ::com::sun::star::frame;
54 using namespace ::com::sun::star::graphic;
55 using namespace ::com::sun::star::drawing;
56 using namespace ::com::sun::star::io;
57 using namespace ::com::sun::star::lang;
58 using namespace ::com::sun::star::task;
59 using namespace ::com::sun::star::uno;
60 
61 using ::com::sun::star::container::XNameAccess;
63 using ::comphelper::SequenceAsHashMap;
64 using ::oox::ole::OleObjectHelper;
65 using ::oox::ole::VbaProject;
66 
67 namespace {
68 
69 struct UrlPool
70 {
71  ::osl::Mutex maMutex;
72  ::std::set< OUString > maUrls;
73 };
74 
75 struct StaticUrlPool : public ::rtl::Static< UrlPool, StaticUrlPool > {};
76 
78 class DocumentOpenedGuard
79 {
80 public:
81  explicit DocumentOpenedGuard( const OUString& rUrl );
82  ~DocumentOpenedGuard();
83  DocumentOpenedGuard(const DocumentOpenedGuard&) = delete;
84  DocumentOpenedGuard& operator=(const DocumentOpenedGuard&) = delete;
85 
86  bool isValid() const { return mbValid; }
87 
88 private:
89  OUString maUrl;
90  bool mbValid;
91 };
92 
93 DocumentOpenedGuard::DocumentOpenedGuard( const OUString& rUrl )
94 {
95  UrlPool& rUrlPool = StaticUrlPool::get();
96  ::osl::MutexGuard aGuard( rUrlPool.maMutex );
97  mbValid = rUrl.isEmpty() || (rUrlPool.maUrls.count( rUrl ) == 0);
98  if( mbValid && !rUrl.isEmpty() )
99  {
100  rUrlPool.maUrls.insert( rUrl );
101  maUrl = rUrl;
102  }
103 }
104 
105 DocumentOpenedGuard::~DocumentOpenedGuard()
106 {
107  UrlPool& rUrlPool = StaticUrlPool::get();
108  ::osl::MutexGuard aGuard( rUrlPool.maMutex );
109  if( !maUrl.isEmpty() )
110  rUrlPool.maUrls.erase( maUrl );
111 }
112 
114 enum FilterDirection
115 {
116  FILTERDIRECTION_UNKNOWN,
117  FILTERDIRECTION_IMPORT,
118  FILTERDIRECTION_EXPORT
119 };
120 
121 } // namespace
122 
124 {
125  typedef std::shared_ptr< GraphicHelper > GraphicHelperRef;
126  typedef std::shared_ptr< ModelObjectHelper > ModelObjHelperRef;
127  typedef std::shared_ptr< OleObjectHelper > OleObjHelperRef;
128  typedef std::shared_ptr< VbaProject > VbaProjectRef;
129 
130  FilterDirection meDirection;
131  SequenceAsHashMap maArguments;
132  SequenceAsHashMap maFilterData;
134  OUString maFileUrl;
137 
138  GraphicHelperRef mxGraphicHelper;
139  ModelObjHelperRef mxModelObjHelper;
140  std::map<css::uno::Reference<css::lang::XMultiServiceFactory>, ModelObjHelperRef>
142  OleObjHelperRef mxOleObjHelper;
143  VbaProjectRef mxVbaProject;
144 
146  Reference< XModel > mxModel;
147  Reference< XMultiServiceFactory > mxModelFactory;
150  Reference< XStream > mxOutStream;
151  Reference< XStatusIndicator > mxStatusIndicator;
153  Reference< XShape > mxParentShape;
154 
156 
158 
160  explicit FilterBaseImpl( const Reference< XComponentContext >& rxContext );
161 
163  void setDocumentModel( const Reference< XComponent >& rxComponent );
164 };
165 
167  meDirection( FILTERDIRECTION_UNKNOWN ),
168  meVersion( ECMA_DIALECT ),
169  mxComponentContext( rxContext, UNO_SET_THROW ),
170  mbExportVBA(false),
171  mbExportTemplate(false)
172 {
173 }
174 
175 void FilterBaseImpl::setDocumentModel( const Reference< XComponent >& rxComponent )
176 {
177  try
178  {
179  mxModel.set( rxComponent, UNO_QUERY_THROW );
180  mxModelFactory.set( rxComponent, UNO_QUERY_THROW );
181  }
182  catch( Exception& )
183  {
184  throw IllegalArgumentException();
185  }
186 }
187 
189  mxImpl( new FilterBaseImpl( rxContext ) )
190 {
191 }
192 
194 {
195 }
196 
198 {
199  return mxImpl->meDirection == FILTERDIRECTION_IMPORT;
200 }
201 
203 {
204  return mxImpl->meDirection == FILTERDIRECTION_EXPORT;
205 }
206 
208 {
209  return mxImpl->meVersion;
210 }
211 
213 {
214  return mxImpl->mxComponentContext;
215 }
216 
217 const Reference< XModel >& FilterBase::getModel() const
218 {
219  return mxImpl->mxModel;
220 }
221 
222 const Reference< XMultiServiceFactory >& FilterBase::getModelFactory() const
223 {
224  return mxImpl->mxModelFactory;
225 }
226 
228 {
229  return mxImpl->mxTargetFrame;
230 }
231 
232 const Reference< XStatusIndicator >& FilterBase::getStatusIndicator() const
233 {
234  return mxImpl->mxStatusIndicator;
235 }
236 
238 {
239  return mxImpl->maMediaDesc;
240 }
241 
242 SequenceAsHashMap& FilterBase::getFilterData() const
243 {
244  return mxImpl->maFilterData;
245 }
246 
247 const OUString& FilterBase::getFileUrl() const
248 {
249  return mxImpl->maFileUrl;
250 }
251 
252 namespace {
253 
254 bool lclIsDosDrive( const OUString& rUrl, sal_Int32 nPos = 0 )
255 {
256  return
257  (rUrl.getLength() >= nPos + 3) &&
258  ((('A' <= rUrl[ nPos ]) && (rUrl[ nPos ] <= 'Z')) || (('a' <= rUrl[ nPos ]) && (rUrl[ nPos ] <= 'z'))) &&
259  (rUrl[ nPos + 1 ] == ':') &&
260  (rUrl[ nPos + 2 ] == '/');
261 }
262 
263 } // namespace
264 
265 OUString FilterBase::getAbsoluteUrl( const OUString& rUrl ) const
266 {
267  // handle some special cases before calling ::rtl::Uri::convertRelToAbs()
268 
269  static const OUStringLiteral aFileSchema = u"file:";
270  static const OUStringLiteral aFilePrefix = u"file:///";
271  const sal_Int32 nFilePrefixLen = aFilePrefix.getLength();
272  static const OUStringLiteral aUncPrefix = u"//";
273 
274  /* (1) convert all backslashes to slashes, and check that passed URL is
275  not empty. */
276  OUString aUrl = rUrl.replace( '\\', '/' );
277  if( aUrl.isEmpty() )
278  return aUrl;
279 
280  /* (2) add 'file:///' to absolute Windows paths, e.g. convert
281  'C:/path/file' to 'file:///c:/path/file'. */
282  if( lclIsDosDrive( aUrl ) )
283  return aFilePrefix + aUrl;
284 
285  /* (3) add 'file:' to UNC paths, e.g. convert '//server/path/file' to
286  'file://server/path/file'. */
287  if( aUrl.match( aUncPrefix ) )
288  return aFileSchema + aUrl;
289 
290  /* (4) remove additional slashes from UNC paths, e.g. convert
291  'file://///server/path/file' to 'file://server/path/file'. */
292  if( (aUrl.getLength() >= nFilePrefixLen + 2) &&
293  aUrl.match( aFilePrefix ) &&
294  aUrl.match( aUncPrefix, nFilePrefixLen ) )
295  {
296  return aFileSchema + aUrl.subView( nFilePrefixLen );
297  }
298 
299  /* (5) handle URLs relative to current drive, e.g. the URL '/path1/file1'
300  relative to the base URL 'file:///C:/path2/file2' does not result in
301  the expected 'file:///C:/path1/file1', but in 'file:///path1/file1'. */
302  if( aUrl.startsWith("/") &&
303  mxImpl->maFileUrl.match( aFilePrefix ) &&
304  lclIsDosDrive( mxImpl->maFileUrl, nFilePrefixLen ) )
305  {
306  return OUString::Concat(mxImpl->maFileUrl.subView( 0, nFilePrefixLen + 3 )) + aUrl.subView( 1 );
307  }
308 
309  try
310  {
311  return ::rtl::Uri::convertRelToAbs( mxImpl->maFileUrl, aUrl );
312  }
313  catch( ::rtl::MalformedUriException& )
314  {
315  }
316  return aUrl;
317 }
318 
320 {
321  return mxImpl->mxStorage;
322 }
323 
324 Reference< XInputStream > FilterBase::openInputStream( const OUString& rStreamName ) const
325 {
326  if (!mxImpl->mxStorage)
327  throw RuntimeException();
328  return mxImpl->mxStorage->openInputStream( rStreamName );
329 }
330 
331 Reference< XOutputStream > FilterBase::openOutputStream( const OUString& rStreamName ) const
332 {
333  return mxImpl->mxStorage->openOutputStream( rStreamName );
334 }
335 
337 {
338  mxImpl->mxStorage->commit();
339 }
340 
341 // helpers
342 
344 {
345  if( !mxImpl->mxGraphicHelper )
346  mxImpl->mxGraphicHelper.reset( implCreateGraphicHelper() );
347  return *mxImpl->mxGraphicHelper;
348 }
349 
351 {
352  if( !mxImpl->mxModelObjHelper )
353  mxImpl->mxModelObjHelper = std::make_shared<ModelObjectHelper>( mxImpl->mxModelFactory );
354  return *mxImpl->mxModelObjHelper;
355 }
356 
358  const css::uno::Reference<css::lang::XMultiServiceFactory>& xFactory) const
359 {
360  if (!mxImpl->mxModelObjHelpers.count(xFactory))
361  mxImpl->mxModelObjHelpers[xFactory] = std::make_shared<ModelObjectHelper>(xFactory);
362  return *mxImpl->mxModelObjHelpers[xFactory];
363 }
364 
365 OleObjectHelper& FilterBase::getOleObjectHelper() const
366 {
367  if( !mxImpl->mxOleObjHelper )
368  mxImpl->mxOleObjHelper = std::make_shared<OleObjectHelper>(mxImpl->mxModelFactory, mxImpl->mxModel);
369  return *mxImpl->mxOleObjHelper;
370 }
371 
372 VbaProject& FilterBase::getVbaProject() const
373 {
374  if( !mxImpl->mxVbaProject )
375  mxImpl->mxVbaProject.reset( implCreateVbaProject() );
376  return *mxImpl->mxVbaProject;
377 }
378 
379 bool FilterBase::importBinaryData( StreamDataSequence & orDataSeq, const OUString& rStreamName )
380 {
381  OSL_ENSURE( !rStreamName.isEmpty(), "FilterBase::importBinaryData - empty stream name" );
382  if( rStreamName.isEmpty() )
383  return false;
384 
385  // try to open the stream (this may fail - do not assert)
386  BinaryXInputStream aInStrm( openInputStream( rStreamName ), true );
387  if( aInStrm.isEof() )
388  return false;
389 
390  // copy the entire stream to the passed sequence
391  SequenceOutputStream aOutStrm( orDataSeq );
392  aInStrm.copyToStream( aOutStrm );
393  return true;
394 }
395 
396 // com.sun.star.lang.XServiceInfo interface
397 
398 sal_Bool SAL_CALL FilterBase::supportsService( const OUString& rServiceName )
399 {
400  return cppu::supportsService(this, rServiceName);
401 }
402 
404 {
405  return { "com.sun.star.document.ImportFilter", "com.sun.star.document.ExportFilter" };
406 }
407 
408 // com.sun.star.lang.XInitialization interface
409 
410 void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs )
411 {
412  if( rArgs.getLength() >= 2 ) try
413  {
414  mxImpl->maArguments << rArgs[ 1 ];
415  }
416  catch( Exception& )
417  {
418  }
419 
420  if (!rArgs.hasElements())
421  return;
422 
423  Sequence<css::beans::PropertyValue> aSeq;
424  rArgs[0] >>= aSeq;
425  for (const auto& rVal : std::as_const(aSeq))
426  {
427  if (rVal.Name == "UserData")
428  {
429  css::uno::Sequence<OUString> aUserDataSeq;
430  rVal.Value >>= aUserDataSeq;
431  if (comphelper::findValue(aUserDataSeq, "macro-enabled") != -1)
432  mxImpl->mbExportVBA = true;
433  }
434  else if (rVal.Name == "Flags")
435  {
436  sal_Int32 nFlags(0);
437  rVal.Value >>= nFlags;
438  mxImpl->mbExportTemplate = bool(static_cast<SfxFilterFlags>(nFlags) & SfxFilterFlags::TEMPLATE);
439  }
440  }
441 }
442 
443 // com.sun.star.document.XImporter interface
444 
445 void SAL_CALL FilterBase::setTargetDocument( const Reference< XComponent >& rxDocument )
446 {
447  mxImpl->setDocumentModel( rxDocument );
448  mxImpl->meDirection = FILTERDIRECTION_IMPORT;
449 }
450 
451 // com.sun.star.document.XExporter interface
452 
453 void SAL_CALL FilterBase::setSourceDocument( const Reference< XComponent >& rxDocument )
454 {
455  mxImpl->setDocumentModel( rxDocument );
456  mxImpl->meDirection = FILTERDIRECTION_EXPORT;
457 }
458 
459 // com.sun.star.document.XFilter interface
460 
461 sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDescSeq )
462 {
463  if( !mxImpl->mxModel.is() || !mxImpl->mxModelFactory.is() || (mxImpl->meDirection == FILTERDIRECTION_UNKNOWN) )
464  throw RuntimeException();
465 
466  bool bRet = false;
467  setMediaDescriptor( rMediaDescSeq );
468  DocumentOpenedGuard aOpenedGuard( mxImpl->maFileUrl );
469  if( aOpenedGuard.isValid() || mxImpl->maFileUrl.isEmpty() )
470  {
471  Reference<XModel> xTempModel = mxImpl->mxModel;
472  xTempModel->lockControllers();
473  comphelper::ScopeGuard const lockControllersGuard([xTempModel]() {
474  xTempModel->unlockControllers();
475  });
476 
477  switch( mxImpl->meDirection )
478  {
479  case FILTERDIRECTION_UNKNOWN:
480  break;
481  case FILTERDIRECTION_IMPORT:
482  if( mxImpl->mxInStream.is() )
483  {
484  mxImpl->mxStorage = implCreateStorage( mxImpl->mxInStream );
485  bRet = mxImpl->mxStorage && importDocument();
486  }
487  break;
488  case FILTERDIRECTION_EXPORT:
489  if( mxImpl->mxOutStream.is() )
490  {
491  mxImpl->mxStorage = implCreateStorage( mxImpl->mxOutStream );
492  bRet = mxImpl->mxStorage && exportDocument() && implFinalizeExport( getMediaDescriptor() );
493  }
494  break;
495  }
496  }
497  return bRet;
498 }
499 
500 void SAL_CALL FilterBase::cancel()
501 {
502 }
503 
504 // protected
505 
507 {
508  return rMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INPUTSTREAM(), Reference< XInputStream >() );
509 }
510 
511 Reference< XStream > FilterBase::implGetOutputStream( MediaDescriptor& rMediaDesc ) const
512 {
513  return rMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STREAMFOROUTPUT(), Reference< XStream >() );
514 }
515 
516 bool FilterBase::implFinalizeExport( MediaDescriptor& /*rMediaDescriptor*/ )
517 {
518  return true;
519 }
520 
521 Reference< XStream > const & FilterBase::getMainDocumentStream( ) const
522 {
523  return mxImpl->mxOutStream;
524 }
525 
526 // private
527 
528 void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDescSeq )
529 {
530  mxImpl->maMediaDesc << rMediaDescSeq;
531 
532  switch( mxImpl->meDirection )
533  {
534  case FILTERDIRECTION_UNKNOWN:
535  OSL_FAIL( "FilterBase::setMediaDescriptor - invalid filter direction" );
536  break;
537  case FILTERDIRECTION_IMPORT:
538  mxImpl->maMediaDesc.addInputStream();
539  mxImpl->mxInStream = implGetInputStream( mxImpl->maMediaDesc );
540  OSL_ENSURE( mxImpl->mxInStream.is(), "FilterBase::setMediaDescriptor - missing input stream" );
541  break;
542  case FILTERDIRECTION_EXPORT:
543  mxImpl->mxOutStream = implGetOutputStream( mxImpl->maMediaDesc );
544  OSL_ENSURE( mxImpl->mxOutStream.is(), "FilterBase::setMediaDescriptor - missing output stream" );
545  break;
546  }
547 
548  mxImpl->maFileUrl = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
549  mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FRAME(), Reference< XFrame >() );
550  mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >() );
551  mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() );
552  mxImpl->mxParentShape = mxImpl->maMediaDesc.getUnpackedValueOrDefault( "ParentShape", mxImpl->mxParentShape );
553  mxImpl->maFilterData = mxImpl->maMediaDesc.getUnpackedValueOrDefault( "FilterData", Sequence< PropertyValue >() );
554 
555  // Check for ISO OOXML
556  OUString sFilterName = mxImpl->maMediaDesc.getUnpackedValueOrDefault( "FilterName", OUString() );
557  try
558  {
559  Reference<XMultiServiceFactory> xFactory(getComponentContext()->getServiceManager(), UNO_QUERY_THROW);
560  Reference<XNameAccess> xFilters(xFactory->createInstance("com.sun.star.document.FilterFactory" ), UNO_QUERY_THROW );
561  Any aValues = xFilters->getByName( sFilterName );
562  Sequence<PropertyValue > aPropSeq;
563  aValues >>= aPropSeq;
564  SequenceAsHashMap aProps( aPropSeq );
565 
566  sal_Int32 nVersion = aProps.getUnpackedValueOrDefault( "FileFormatVersion", sal_Int32( 0 ) );
567  mxImpl->meVersion = OoxmlVersion( nVersion );
568  }
569  catch ( const Exception& )
570  {
571  // Not ISO OOXML
572  }
573 }
574 
576 {
577  // default: return base implementation without any special behaviour
578  return new GraphicHelper( mxImpl->mxComponentContext, mxImpl->mxTargetFrame, mxImpl->mxStorage );
579 }
580 
582 {
583  return mxImpl->mbExportVBA;
584 }
585 
587 {
588  return mxImpl->mbExportTemplate;
589 }
590 
591 } // namespace oox::core
592 
593 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool importDocument()=0
Derived classes implement import of the entire document.
Provides helper functions for colors, device measurement conversion, graphics, and graphic objects ha...
StorageRef const & getStorage() const
Returns the base storage of the imported/exported file.
Definition: filterbase.cxx:319
bool exportVBA() const
Definition: filterbase.cxx:581
void setMediaDescriptor(const css::uno::Sequence< css::beans::PropertyValue > &rMediaDescSeq)
Definition: filterbase.cxx:528
std::shared_ptr< GraphicHelper > GraphicHelperRef
Definition: filterbase.cxx:125
virtual css::uno::Reference< css::io::XInputStream > implGetInputStream(utl::MediaDescriptor &rMediaDesc) const
Definition: filterbase.cxx:506
css::uno::Reference< css::io::XStream > const & getMainDocumentStream() const
Definition: filterbase.cxx:521
static const OUString & PROP_STREAMFOROUTPUT()
ModelObjectHelper & getModelObjectHelperForModel(const css::uno::Reference< css::lang::XMultiServiceFactory > &xFactory) const
Definition: filterbase.cxx:357
Wraps a UNO input stream and provides convenient access functions.
const css::uno::Reference< css::frame::XFrame > & getTargetFrame() const
Returns the frame that will contain the document model (may be null).
Definition: filterbase.cxx:227
static const OUString & PROP_STATUSINDICATOR()
Reference< XComponentContext > mxComponentContext
VBA project manager.
Definition: filterbase.cxx:145
SequenceAsHashMap maArguments
Definition: filterbase.cxx:131
SequenceAsHashMap maFilterData
Definition: filterbase.cxx:132
sal_Int32 findValue(const css::uno::Sequence< T1 > &_rList, const T2 &_rValue)
void copyToStream(BinaryOutputStream &rOutStrm)
Copies bytes from the current position to the passed output stream.
OoxmlVersion getVersion() const
Definition: filterbase.cxx:207
virtual void SAL_CALL cancel() override
Definition: filterbase.cxx:500
Reference< XStream > mxOutStream
Definition: filterbase.cxx:150
std::map< css::uno::Reference< css::lang::XMultiServiceFactory >, ModelObjHelperRef > mxModelObjHelpers
Tables to create new named drawing objects.
Definition: filterbase.cxx:141
Reference< XFrame > mxTargetFrame
Definition: filterbase.cxx:148
ModelObjectHelper & getModelObjectHelper() const
Returns a helper with containers for various named drawing objects for the imported document...
Definition: filterbase.cxx:350
virtual GraphicHelper * implCreateGraphicHelper() const
Derived classes may create a specialized graphic helper, e.g.
Definition: filterbase.cxx:575
std::shared_ptr< StorageBase > StorageRef
Definition: storagebase.hxx:42
utl::MediaDescriptor & getMediaDescriptor() const
Returns the media descriptor.
Definition: filterbase.cxx:237
bool isExportTemplate() const
Definition: filterbase.cxx:586
Reference< XMultiServiceFactory > mxModelFactory
Definition: filterbase.cxx:147
GraphicHelper & getGraphicHelper() const
Returns a helper for the handling of graphics and graphic objects.
Definition: filterbase.cxx:343
VbaProjectRef mxVbaProject
OLE object handling.
Definition: filterbase.cxx:143
bool importBinaryData(StreamDataSequence &orDataSeq, const OUString &rStreamName)
Imports the raw binary data from the specified stream.
Definition: filterbase.cxx:379
ModelObjHelperRef mxModelObjHelper
Graphic and graphic object handling.
Definition: filterbase.cxx:139
OUString maUrl
Definition: filterbase.cxx:89
bool isExportFilter() const
Returns true, if filter is an export filter.
Definition: filterbase.cxx:202
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual ~FilterBase() override
Definition: filterbase.cxx:193
::comphelper::SequenceAsHashMap & getFilterData() const
Returns the FilterData.
Definition: filterbase.cxx:242
virtual void SAL_CALL setSourceDocument(const css::uno::Reference< css::lang::XComponent > &rxDocument) override
Definition: filterbase.cxx:453
::oox::ole::VbaProject & getVbaProject() const
Returns the VBA project manager.
Definition: filterbase.cxx:372
static const OUString & PROP_INTERACTIONHANDLER()
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: filterbase.cxx:403
css::uno::Sequence< sal_Int8 > StreamDataSequence
virtual StorageRef implCreateStorage(const css::uno::Reference< css::io::XInputStream > &rxInStream) const =0
Reference< XInputStream > mxInStream
Definition: filterbase.cxx:149
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
static const OUString & PROP_URL()
Contains tables for named drawing objects for a document model.
::oox::ole::OleObjectHelper & getOleObjectHelper() const
Returns a helper for the handling of OLE objects.
Definition: filterbase.cxx:365
std::shared_ptr< OleObjectHelper > OleObjHelperRef
Definition: filterbase.cxx:127
virtual sal_Bool SAL_CALL filter(const css::uno::Sequence< css::beans::PropertyValue > &rMediaDescSeq) override
Definition: filterbase.cxx:461
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &rArgs) override
Receives user defined arguments.
Definition: filterbase.cxx:410
float u
unsigned char sal_Bool
virtual css::uno::Reference< css::io::XStream > implGetOutputStream(utl::MediaDescriptor &rMediaDesc) const
Definition: filterbase.cxx:511
Reference< XInteractionHandler > mxInteractionHandler
Definition: filterbase.cxx:152
const css::uno::Reference< css::uno::XComponentContext > & getComponentContext() const
Returns the component context passed in the filter constructor (always existing). ...
Definition: filterbase.cxx:212
::osl::Mutex maMutex
Definition: filterbase.cxx:71
sal_Int16 nVersion
FilterBase(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Definition: filterbase.cxx:188
Reference< XStatusIndicator > mxStatusIndicator
Definition: filterbase.cxx:151
Reference< XShape > mxParentShape
Definition: filterbase.cxx:153
const css::uno::Reference< css::frame::XModel > & getModel() const
Returns the document model (always existing).
Definition: filterbase.cxx:217
OleObjHelperRef mxOleObjHelper
Definition: filterbase.cxx:142
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: filterbase.cxx:398
Reference< XModel > mxModel
Definition: filterbase.cxx:146
virtual void SAL_CALL setTargetDocument(const css::uno::Reference< css::lang::XComponent > &rxDocument) override
Definition: filterbase.cxx:445
const css::uno::Reference< css::lang::XMultiServiceFactory > & getModelFactory() const
Returns the service factory provided by the document model (always existing).
Definition: filterbase.cxx:222
const OUString & getFileUrl() const
Returns the URL of the imported or exported file.
Definition: filterbase.cxx:247
MediaDescriptor maMediaDesc
Definition: filterbase.cxx:133
css::uno::Reference< css::io::XOutputStream > openOutputStream(const OUString &rStreamName) const
Opens and returns the specified output stream from the base storage.
Definition: filterbase.cxx:331
FilterDirection meDirection
Definition: filterbase.cxx:130
const css::uno::Reference< css::task::XStatusIndicator > & getStatusIndicator() const
Returns the status indicator (may be null).
Definition: filterbase.cxx:232
std::shared_ptr< VbaProject > VbaProjectRef
Definition: filterbase.cxx:128
css::uno::Reference< css::io::XInputStream > openInputStream(const OUString &rStreamName) const
Opens and returns the specified input stream from the base storage.
Definition: filterbase.cxx:324
FilterBaseImpl(const Reference< XComponentContext > &rxContext)
Definition: filterbase.cxx:166
GraphicHelperRef mxGraphicHelper
Definition: filterbase.cxx:138
virtual ::oox::ole::VbaProject * implCreateVbaProject() const =0
Derived classes create a VBA project manager object.
::std::set< OUString > maUrls
Definition: filterbase.cxx:72
Sequence< sal_Int8 > aSeq
void commitStorage() const
Commits changes to base storage (and substorages)
Definition: filterbase.cxx:336
virtual bool exportDocument()=0
Derived classes implement export of the entire document.
OUString getAbsoluteUrl(const OUString &rUrl) const
Returns an absolute URL for the passed relative or absolute URL.
Definition: filterbase.cxx:265
Reference< XSingleServiceFactory > xFactory
bool isEof() const
Returns true, if the stream position is invalid (EOF).
static const OUString & PROP_INPUTSTREAM()
void setDocumentModel(const Reference< XComponent > &rxComponent)
Definition: filterbase.cxx:175
Wraps a StreamDataSequence and provides convenient access functions.
virtual bool implFinalizeExport(utl::MediaDescriptor &rMediaDescriptor)
Definition: filterbase.cxx:516
bool mbValid
Definition: filterbase.cxx:90
sal_uInt16 nPos
bool isImportFilter() const
Returns true, if filter is an import filter.
Definition: filterbase.cxx:197
std::unique_ptr< FilterBaseImpl > mxImpl
Definition: filterbase.hxx:267
std::shared_ptr< ModelObjectHelper > ModelObjHelperRef
Definition: filterbase.cxx:126
static const OUString & PROP_FRAME()