LCOV - code coverage report
Current view: top level - oox/source/core - filterbase.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 166 204 81.4 %
Date: 2014-11-03 Functions: 41 51 80.4 %
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 <sal/config.h>
      21             : 
      22             : #include <boost/noncopyable.hpp>
      23             : #include <com/sun/star/container/XNameAccess.hpp>
      24             : #include <com/sun/star/drawing/XShape.hpp>
      25             : #include <com/sun/star/frame/XModel.hpp>
      26             : #include <com/sun/star/task/XInteractionHandler.hpp>
      27             : #include <com/sun/star/task/XStatusIndicator.hpp>
      28             : #include <com/sun/star/uno/XComponentContext.hpp>
      29             : #include <comphelper/docpasswordhelper.hxx>
      30             : #include <cppuhelper/supportsservice.hxx>
      31             : #include <unotools/mediadescriptor.hxx>
      32             : #include <osl/mutex.hxx>
      33             : #include <rtl/instance.hxx>
      34             : #include <rtl/uri.hxx>
      35             : #include <set>
      36             : 
      37             : #include "oox/core/filterbase.hxx"
      38             : #include "oox/helper/binaryinputstream.hxx"
      39             : #include "oox/helper/binaryoutputstream.hxx"
      40             : #include "oox/helper/graphichelper.hxx"
      41             : #include "oox/helper/modelobjecthelper.hxx"
      42             : #include "oox/ole/oleobjecthelper.hxx"
      43             : #include "oox/ole/vbaproject.hxx"
      44             : 
      45             : namespace oox {
      46             : namespace core {
      47             : 
      48             : using namespace ::com::sun::star::beans;
      49             : using namespace ::com::sun::star::frame;
      50             : using namespace ::com::sun::star::graphic;
      51             : using namespace ::com::sun::star::drawing;
      52             : using namespace ::com::sun::star::io;
      53             : using namespace ::com::sun::star::lang;
      54             : using namespace ::com::sun::star::task;
      55             : using namespace ::com::sun::star::uno;
      56             : 
      57             : using ::com::sun::star::container::XNameAccess;
      58             : using utl::MediaDescriptor;
      59             : using ::comphelper::SequenceAsHashMap;
      60             : using ::oox::ole::OleObjectHelper;
      61             : using ::oox::ole::VbaProject;
      62             : 
      63             : namespace {
      64             : 
      65          84 : struct UrlPool
      66             : {
      67             :     ::osl::Mutex        maMutex;
      68             :     ::std::set< OUString > maUrls;
      69             : };
      70             : 
      71             : struct StaticUrlPool : public ::rtl::Static< UrlPool, StaticUrlPool > {};
      72             : 
      73             : /** This guard prevents recursive loading/saving of the same document. */
      74             : class DocumentOpenedGuard: private boost::noncopyable
      75             : {
      76             : public:
      77             :     explicit            DocumentOpenedGuard( const OUString& rUrl );
      78             :                         ~DocumentOpenedGuard();
      79             : 
      80        4414 :     inline bool         isValid() const { return mbValid; }
      81             : 
      82             : private:
      83             :     OUString            maUrl;
      84             :     bool                mbValid;
      85             : };
      86             : 
      87        4414 : DocumentOpenedGuard::DocumentOpenedGuard( const OUString& rUrl )
      88             : {
      89        4414 :     UrlPool& rUrlPool = StaticUrlPool::get();
      90        4414 :     ::osl::MutexGuard aGuard( rUrlPool.maMutex );
      91        4414 :     mbValid = rUrl.isEmpty() || (rUrlPool.maUrls.count( rUrl ) == 0);
      92        4414 :     if( mbValid && !rUrl.isEmpty() )
      93             :     {
      94        1202 :         rUrlPool.maUrls.insert( rUrl );
      95        1202 :         maUrl = rUrl;
      96        4414 :     }
      97        4414 : }
      98             : 
      99        8828 : DocumentOpenedGuard::~DocumentOpenedGuard()
     100             : {
     101        4414 :     UrlPool& rUrlPool = StaticUrlPool::get();
     102        4414 :     ::osl::MutexGuard aGuard( rUrlPool.maMutex );
     103        4414 :     if( !maUrl.isEmpty() )
     104        1202 :         rUrlPool.maUrls.erase( maUrl );
     105        4414 : }
     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        2712 : 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        2712 : FilterBaseImpl::FilterBaseImpl( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
     156             :     meDirection( FILTERDIRECTION_UNKNOWN ),
     157             :     meVersion( ECMA_DIALECT ),
     158             :     mxComponentContext( rxContext, UNO_SET_THROW ),
     159        2712 :     mxComponentFactory( rxContext->getServiceManager(), UNO_SET_THROW )
     160             : {
     161        2712 : }
     162             : 
     163        4414 : void FilterBaseImpl::setDocumentModel( const Reference< XComponent >& rxComponent ) throw( IllegalArgumentException )
     164             : {
     165             :     try
     166             :     {
     167        4414 :         mxModel.set( rxComponent, UNO_QUERY_THROW );
     168        4414 :         mxModelFactory.set( rxComponent, UNO_QUERY_THROW );
     169             :     }
     170           0 :     catch( Exception& )
     171             :     {
     172           0 :         throw IllegalArgumentException();
     173             :     }
     174        4414 : }
     175             : 
     176        4414 : void FilterBaseImpl::initializeFilter()
     177             : {
     178             :     try
     179             :     {
     180             :         // lock the model controllers
     181        4414 :         mxModel->lockControllers();
     182             :     }
     183           0 :     catch( Exception& )
     184             :     {
     185             :     }
     186        4414 : }
     187             : 
     188        2712 : FilterBase::FilterBase( const Reference< XComponentContext >& rxContext ) throw( RuntimeException ) :
     189        2712 :     mxImpl( new FilterBaseImpl( rxContext ) )
     190             : {
     191        2712 : }
     192             : 
     193        2712 : FilterBase::~FilterBase()
     194             : {
     195        2712 : }
     196             : 
     197         772 : bool FilterBase::isImportFilter() const
     198             : {
     199         772 :     return mxImpl->meDirection == FILTERDIRECTION_IMPORT;
     200             : }
     201             : 
     202          58 : bool FilterBase::isExportFilter() const
     203             : {
     204          58 :     return mxImpl->meDirection == FILTERDIRECTION_EXPORT;
     205             : }
     206             : 
     207       24206 : OoxmlVersion FilterBase::getVersion() const
     208             : {
     209       24206 :     return mxImpl->meVersion;
     210             : }
     211             : 
     212       20938 : const Reference< XComponentContext >& FilterBase::getComponentContext() const
     213             : {
     214       20938 :     return mxImpl->mxComponentContext;
     215             : }
     216             : 
     217        8966 : const Reference< XModel >& FilterBase::getModel() const
     218             : {
     219        8966 :     return mxImpl->mxModel;
     220             : }
     221             : 
     222        3682 : const Reference< XMultiServiceFactory >& FilterBase::getModelFactory() const
     223             : {
     224        3682 :     return mxImpl->mxModelFactory;
     225             : }
     226             : 
     227        1734 : const Reference< XFrame >& FilterBase::getTargetFrame() const
     228             : {
     229        1734 :     return mxImpl->mxTargetFrame;
     230             : }
     231             : 
     232           0 : const Reference< XShape >& FilterBase::getParentShape() const
     233             : {
     234           0 :     return mxImpl->mxParentShape;
     235             : }
     236             : 
     237         284 : const Reference< XStatusIndicator >& FilterBase::getStatusIndicator() const
     238             : {
     239         284 :     return mxImpl->mxStatusIndicator;
     240             : }
     241             : 
     242        1272 : MediaDescriptor& FilterBase::getMediaDescriptor() const
     243             : {
     244        1272 :     return mxImpl->maMediaDesc;
     245             : }
     246             : 
     247          98 : SequenceAsHashMap& FilterBase::getFilterData() const
     248             : {
     249          98 :     return mxImpl->maFilterData;
     250             : }
     251             : 
     252          20 : const OUString& FilterBase::getFileUrl() const
     253             : {
     254          20 :     return mxImpl->maFileUrl;
     255             : }
     256             : 
     257             : namespace {
     258             : 
     259           6 : inline bool lclIsDosDrive( const OUString& rUrl, sal_Int32 nPos = 0 )
     260             : {
     261             :     return
     262          12 :         (rUrl.getLength() >= nPos + 3) &&
     263          18 :         ((('A' <= rUrl[ nPos ]) && (rUrl[ nPos ] <= 'Z')) || (('a' <= rUrl[ nPos ]) && (rUrl[ nPos ] <= 'z'))) &&
     264          12 :         (rUrl[ nPos + 1 ] == ':') &&
     265           6 :         (rUrl[ nPos + 2 ] == '/');
     266             : }
     267             : 
     268             : } // namespace
     269             : 
     270           6 : OUString FilterBase::getAbsoluteUrl( const OUString& rUrl ) const
     271             : {
     272             :     // handle some special cases before calling ::rtl::Uri::convertRelToAbs()
     273             : 
     274           6 :     const OUString aFileSchema = "file:";
     275          12 :     const OUString aFilePrefix = "file:///";
     276           6 :     const sal_Int32 nFilePrefixLen = aFilePrefix.getLength();
     277          12 :     const OUString aUncPrefix = "//";
     278             : 
     279             :     /*  (1) convert all backslashes to slashes, and check that passed URL is
     280             :         not empty. */
     281          12 :     OUString aUrl = rUrl.replace( '\\', '/' );
     282           6 :     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           6 :     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           6 :     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          16 :     if( (aUrl.getLength() >= nFilePrefixLen + 2) &&
     298          10 :         aUrl.match( aFilePrefix ) &&
     299           4 :         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          12 :     if( aUrl.startsWith("/") &&
     308           6 :         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           6 :         return ::rtl::Uri::convertRelToAbs( mxImpl->maFileUrl, aUrl );
     317             :     }
     318           0 :     catch( ::rtl::MalformedUriException& )
     319             :     {
     320             :     }
     321           6 :     return aUrl;
     322             : }
     323             : 
     324        5406 : StorageRef FilterBase::getStorage() const
     325             : {
     326        5406 :     return mxImpl->mxStorage;
     327             : }
     328             : 
     329       10698 : Reference< XInputStream > FilterBase::openInputStream( const OUString& rStreamName ) const
     330             : {
     331       10698 :     return mxImpl->mxStorage->openInputStream( rStreamName );
     332             : }
     333             : 
     334       12678 : Reference< XOutputStream > FilterBase::openOutputStream( const OUString& rStreamName ) const
     335             : {
     336       12678 :     return mxImpl->mxStorage->openOutputStream( rStreamName );
     337             : }
     338             : 
     339         918 : void FilterBase::commitStorage() const
     340             : {
     341         918 :     mxImpl->mxStorage->commit();
     342         918 : }
     343             : 
     344             : // helpers
     345             : 
     346       68228 : GraphicHelper& FilterBase::getGraphicHelper() const
     347             : {
     348       68228 :     if( !mxImpl->mxGraphicHelper )
     349        1734 :         mxImpl->mxGraphicHelper.reset( implCreateGraphicHelper() );
     350       68228 :     return *mxImpl->mxGraphicHelper;
     351             : }
     352             : 
     353        7398 : ModelObjectHelper& FilterBase::getModelObjectHelper() const
     354             : {
     355        7398 :     if( !mxImpl->mxModelObjHelper )
     356        1464 :         mxImpl->mxModelObjHelper.reset( new ModelObjectHelper( mxImpl->mxModelFactory ) );
     357        7398 :     return *mxImpl->mxModelObjHelper;
     358             : }
     359             : 
     360           4 : OleObjectHelper& FilterBase::getOleObjectHelper() const
     361             : {
     362           4 :     if( !mxImpl->mxOleObjHelper )
     363           2 :         mxImpl->mxOleObjHelper.reset( new OleObjectHelper( mxImpl->mxModelFactory ) );
     364           4 :     return *mxImpl->mxOleObjHelper;
     365             : }
     366             : 
     367           4 : VbaProject& FilterBase::getVbaProject() const
     368             : {
     369           4 :     if( !mxImpl->mxVbaProject )
     370           2 :         mxImpl->mxVbaProject.reset( implCreateVbaProject() );
     371           4 :     return *mxImpl->mxVbaProject;
     372             : }
     373             : 
     374         198 : bool FilterBase::importBinaryData( StreamDataSequence& orDataSeq, const OUString& rStreamName )
     375             : {
     376             :     OSL_ENSURE( !rStreamName.isEmpty(), "FilterBase::importBinaryData - empty stream name" );
     377         198 :     if( rStreamName.isEmpty() )
     378           0 :         return false;
     379             : 
     380             :     // try to open the stream (this may fail - do not assert)
     381         198 :     BinaryXInputStream aInStrm( openInputStream( rStreamName ), true );
     382         198 :     if( aInStrm.isEof() )
     383           0 :         return false;
     384             : 
     385             :     // copy the entire stream to the passed sequence
     386         396 :     SequenceOutputStream aOutStrm( orDataSeq );
     387         198 :     aInStrm.copyToStream( aOutStrm );
     388         396 :     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         284 : void SAL_CALL FilterBase::initialize( const Sequence< Any >& rArgs ) throw( Exception, RuntimeException, std::exception )
     414             : {
     415         284 :     if( rArgs.getLength() >= 2 ) try
     416             :     {
     417           0 :         mxImpl->maArguments << rArgs[ 1 ];
     418             :     }
     419           0 :     catch( Exception& )
     420             :     {
     421             :     }
     422         284 : }
     423             : 
     424             : // com.sun.star.document.XImporter interface
     425             : 
     426        3438 : void SAL_CALL FilterBase::setTargetDocument( const Reference< XComponent >& rxDocument ) throw( IllegalArgumentException, RuntimeException, std::exception )
     427             : {
     428        3438 :     mxImpl->setDocumentModel( rxDocument );
     429        3438 :     mxImpl->meDirection = FILTERDIRECTION_IMPORT;
     430        3438 : }
     431             : 
     432             : // com.sun.star.document.XExporter interface
     433             : 
     434         976 : void SAL_CALL FilterBase::setSourceDocument( const Reference< XComponent >& rxDocument ) throw( IllegalArgumentException, RuntimeException, std::exception )
     435             : {
     436         976 :     mxImpl->setDocumentModel( rxDocument );
     437         976 :     mxImpl->meDirection = FILTERDIRECTION_EXPORT;
     438         976 : }
     439             : 
     440             : // com.sun.star.document.XFilter interface
     441             : 
     442        4414 : sal_Bool SAL_CALL FilterBase::filter( const Sequence< PropertyValue >& rMediaDescSeq ) throw( RuntimeException, std::exception )
     443             : {
     444        4414 :     if( !mxImpl->mxModel.is() || !mxImpl->mxModelFactory.is() || (mxImpl->meDirection == FILTERDIRECTION_UNKNOWN) )
     445           0 :         throw RuntimeException();
     446             : 
     447        4414 :     bool bRet = false;
     448        4414 :     setMediaDescriptor( rMediaDescSeq );
     449        4414 :     DocumentOpenedGuard aOpenedGuard( mxImpl->maFileUrl );
     450        4414 :     if( aOpenedGuard.isValid() || mxImpl->maFileUrl.isEmpty() )
     451             :     {
     452        4414 :         mxImpl->initializeFilter();
     453        4414 :         switch( mxImpl->meDirection )
     454             :         {
     455             :             case FILTERDIRECTION_UNKNOWN:
     456           0 :             break;
     457             :             case FILTERDIRECTION_IMPORT:
     458        3438 :                 if( mxImpl->mxInStream.is() )
     459             :                 {
     460        3438 :                     mxImpl->mxStorage = implCreateStorage( mxImpl->mxInStream );
     461        3438 :                     bRet = mxImpl->mxStorage.get() && importDocument();
     462             :                 }
     463        3438 :             break;
     464             :             case FILTERDIRECTION_EXPORT:
     465         976 :                 if( mxImpl->mxOutStream.is() )
     466             :                 {
     467         976 :                     mxImpl->mxStorage = implCreateStorage( mxImpl->mxOutStream );
     468         976 :                     bRet = mxImpl->mxStorage.get() && exportDocument() && implFinalizeExport( getMediaDescriptor() );
     469             :                 }
     470         976 :             break;
     471             :         }
     472        4414 :         mxImpl->mxModel->unlockControllers();
     473             :     }
     474        4414 :     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         976 : Reference< XStream > FilterBase::implGetOutputStream( MediaDescriptor& rMediaDesc ) const
     489             : {
     490         976 :     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        4414 : void FilterBase::setMediaDescriptor( const Sequence< PropertyValue >& rMediaDescSeq )
     506             : {
     507        4414 :     mxImpl->maMediaDesc << rMediaDescSeq;
     508             : 
     509        4414 :     switch( mxImpl->meDirection )
     510             :     {
     511             :         case FILTERDIRECTION_UNKNOWN:
     512             :             OSL_FAIL( "FilterBase::setMediaDescriptor - invalid filter direction" );
     513           0 :         break;
     514             :         case FILTERDIRECTION_IMPORT:
     515        3438 :             mxImpl->maMediaDesc.addInputStream();
     516        3438 :             mxImpl->mxInStream = implGetInputStream( mxImpl->maMediaDesc );
     517             :             OSL_ENSURE( mxImpl->mxInStream.is(), "FilterBase::setMediaDescriptor - missing input stream" );
     518        3438 :         break;
     519             :         case FILTERDIRECTION_EXPORT:
     520         976 :             mxImpl->mxOutStream = implGetOutputStream( mxImpl->maMediaDesc );
     521             :             OSL_ENSURE( mxImpl->mxOutStream.is(), "FilterBase::setMediaDescriptor - missing output stream" );
     522         976 :         break;
     523             :     }
     524             : 
     525        4414 :     mxImpl->maFileUrl = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_URL(), OUString() );
     526        4414 :     mxImpl->mxTargetFrame = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_FRAME(), Reference< XFrame >() );
     527        4414 :     mxImpl->mxStatusIndicator = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STATUSINDICATOR(), Reference< XStatusIndicator >() );
     528        4414 :     mxImpl->mxInteractionHandler = mxImpl->maMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INTERACTIONHANDLER(), Reference< XInteractionHandler >() );
     529        4414 :     mxImpl->mxParentShape = mxImpl->maMediaDesc.getUnpackedValueOrDefault( "ParentShape", mxImpl->mxParentShape );
     530        4414 :     mxImpl->maFilterData = mxImpl->maMediaDesc.getUnpackedValueOrDefault( "FilterData", Sequence< PropertyValue >() );
     531             : 
     532             :     // Check for ISO OOXML
     533        4414 :     OUString sFilterName = mxImpl->maMediaDesc.getUnpackedValueOrDefault( "FilterName", OUString() );
     534             :     try
     535             :     {
     536        4414 :         Reference<XMultiServiceFactory> xFactory(getComponentContext()->getServiceManager(), UNO_QUERY_THROW);
     537        8828 :         Reference<XNameAccess> xFilters(xFactory->createInstance("com.sun.star.document.FilterFactory" ), UNO_QUERY_THROW );
     538        5616 :         Any aValues = xFilters->getByName( sFilterName );
     539        2404 :         Sequence<PropertyValue > aPropSeq;
     540        1202 :         aValues >>= aPropSeq;
     541        2404 :         SequenceAsHashMap aProps( aPropSeq );
     542             : 
     543        1202 :         sal_Int32 nVersion = aProps.getUnpackedValueOrDefault( "FileFormatVersion", sal_Int32( 0 ) );
     544        5616 :         mxImpl->meVersion = OoxmlVersion( nVersion );
     545             :     }
     546        3212 :     catch ( const Exception& )
     547             :     {
     548             :         // Not ISO OOXML
     549        4414 :     }
     550        4414 : }
     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         408 : } // namespace oox
     560             : 
     561             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10