LCOV - code coverage report
Current view: top level - oox/source/core - filterbase.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 204 0.0 %
Date: 2014-04-14 Functions: 0 51 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10