LCOV - code coverage report
Current view: top level - chart2/source/model/filter - XMLFilter.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 227 335 67.8 %
Date: 2012-08-25 Functions: 16 22 72.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 294 880 33.4 %

           Branch data     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                 :            : 
      21                 :            : #include "XMLFilter.hxx"
      22                 :            : #include "macros.hxx"
      23                 :            : #include "MediaDescriptorHelper.hxx"
      24                 :            : #include "ContainerHelper.hxx"
      25                 :            : #include <comphelper/mediadescriptor.hxx>
      26                 :            : 
      27                 :            : // for ERRCODE_SFX_GENERAL etc.
      28                 :            : // header contains only macros
      29                 :            : #include <svtools/sfxecode.hxx>
      30                 :            : // header for class SvtSaveOptions
      31                 :            : #include <unotools/saveopt.hxx>
      32                 :            : #include <comphelper/genericpropertyset.hxx>
      33                 :            : // header for struct PropertyMapEntry
      34                 :            : #include <comphelper/propertysetinfo.hxx>
      35                 :            : #include <comphelper/documentconstants.hxx>
      36                 :            : 
      37                 :            : // header for class SotStorage
      38                 :            : #include <sot/storage.hxx>
      39                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      40                 :            : #include <com/sun/star/xml/sax/InputSource.hpp>
      41                 :            : #include <com/sun/star/lang/XMultiComponentFactory.hpp>
      42                 :            : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
      43                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      44                 :            : #include <com/sun/star/embed/XStorage.hpp>
      45                 :            : #include <com/sun/star/embed/XTransactedObject.hpp>
      46                 :            : #include <com/sun/star/frame/XModel.hpp>
      47                 :            : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      48                 :            : #include <com/sun/star/xml/sax/XParser.hpp>
      49                 :            : #include <com/sun/star/xml/sax/SAXParseException.hpp>
      50                 :            : #include <com/sun/star/packages/zip/ZipIOException.hpp>
      51                 :            : #include <com/sun/star/document/XGraphicObjectResolver.hpp>
      52                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      53                 :            : 
      54                 :            : using namespace ::com::sun::star;
      55                 :            : 
      56                 :            : using ::com::sun::star::uno::Reference;
      57                 :            : using ::com::sun::star::uno::Sequence;
      58                 :            : using ::rtl::OUString;
      59                 :            : using ::osl::MutexGuard;
      60                 :            : 
      61                 :            : // ----------------------------------------
      62                 :            : namespace
      63                 :            : {
      64                 :            : #define LOCAL_CONST_STR(i, x) sal_Char const i[sizeof(x)] = x
      65                 :            : #define MAP_LEN(x) x, sizeof(x) - 1
      66                 :            : 
      67                 :            : LOCAL_CONST_STR( sXML_metaStreamName,       "meta.xml");
      68                 :            : LOCAL_CONST_STR( sXML_styleStreamName,      "styles.xml" );
      69                 :            : LOCAL_CONST_STR( sXML_contentStreamName,    "content.xml" );
      70                 :            : LOCAL_CONST_STR( sXML_oldContentStreamName, "Content.xml" );
      71                 :            : 
      72                 :            : // soffice 6/7
      73                 :            : LOCAL_CONST_STR( sXML_export_chart_styles_service,          "com.sun.star.comp.Chart.XMLStylesExporter" );
      74                 :            : LOCAL_CONST_STR( sXML_export_chart_content_service,         "com.sun.star.comp.Chart.XMLContentExporter" );
      75                 :            : 
      76                 :            : LOCAL_CONST_STR( sXML_import_chart_styles_service,          "com.sun.star.comp.Chart.XMLStylesImporter" );
      77                 :            : LOCAL_CONST_STR( sXML_import_chart_content_service,         "com.sun.star.comp.Chart.XMLContentImporter" );
      78                 :            : LOCAL_CONST_STR( sXML_import_chart_old_content_service,     "com.sun.star.office.sax.importer.Chart" );
      79                 :            : 
      80                 :            : // Oasis
      81                 :            : LOCAL_CONST_STR( sXML_export_chart_oasis_styles_service,    "com.sun.star.comp.Chart.XMLOasisStylesExporter" );
      82                 :            : LOCAL_CONST_STR( sXML_export_chart_oasis_content_service,   "com.sun.star.comp.Chart.XMLOasisContentExporter" );
      83                 :            : LOCAL_CONST_STR( sXML_export_chart_oasis_meta_service,      "com.sun.star.comp.Chart.XMLOasisMetaExporter" );
      84                 :            : 
      85                 :            : LOCAL_CONST_STR( sXML_import_chart_oasis_styles_service,    "com.sun.star.comp.Chart.XMLOasisStylesImporter" );
      86                 :            : LOCAL_CONST_STR( sXML_import_chart_oasis_content_service,   "com.sun.star.comp.Chart.XMLOasisContentImporter" );
      87                 :            : LOCAL_CONST_STR( sXML_import_chart_oasis_meta_service,      "com.sun.star.comp.Chart.XMLOasisMetaImporter" );
      88                 :            : 
      89                 :         15 : uno::Reference< embed::XStorage > lcl_getWriteStorage(
      90                 :            :     const Sequence< beans::PropertyValue >& rMediaDescriptor,
      91                 :            :     const uno::Reference< uno::XComponentContext >& xContext,const ::rtl::OUString& _sMediaType)
      92                 :            : {
      93                 :         15 :     uno::Reference< embed::XStorage > xStorage;
      94                 :            :     try
      95                 :            :     {
      96         [ +  - ]:         15 :         apphelper::MediaDescriptorHelper aMDHelper( rMediaDescriptor );
      97         [ +  - ]:         15 :         if( aMDHelper.ISSET_Storage )
      98                 :            :         {
      99         [ +  - ]:         15 :             xStorage = aMDHelper.Storage;
     100                 :            :         }
     101                 :            :         else
     102                 :            :         {
     103                 :            :             Reference< lang::XSingleServiceFactory > xStorageFact(
     104 [ #  # ][ #  # ]:          0 :                 xContext->getServiceManager()->createInstanceWithContext(
                 [ #  # ]
     105                 :            :                     C2U("com.sun.star.embed.StorageFactory"),
     106 [ #  # ][ #  # ]:          0 :                     xContext ), uno::UNO_QUERY_THROW );
                 [ #  # ]
     107                 :            : 
     108         [ #  # ]:          0 :             ::std::vector< beans::PropertyValue > aPropertiesForStorage;
     109                 :            : 
     110         [ #  # ]:          0 :             for( sal_Int32 i=rMediaDescriptor.getLength(); i--; )
     111                 :            :             {
     112                 :            :                 // properties understood by storage factory
     113                 :            :                 // (see package/source/xstor/xfactory.cxx for details)
     114 [ #  # ][ #  # ]:          0 :                 if ( rMediaDescriptor[i].Name == "InteractionHandler" || rMediaDescriptor[i].Name == "Password" || rMediaDescriptor[i].Name == "RepairPackage" )
         [ #  # ][ #  # ]
     115                 :            :                 {
     116         [ #  # ]:          0 :                     aPropertiesForStorage.push_back( rMediaDescriptor[i] );
     117                 :            :                 }
     118                 :            :             }
     119                 :            : 
     120         [ #  # ]:          0 :             if( aMDHelper.ISSET_Storage )
     121         [ #  # ]:          0 :                 xStorage.set( aMDHelper.Storage );
     122                 :            :             else
     123                 :            :             {
     124         [ #  # ]:          0 :                 Sequence< uno::Any > aStorageArgs( 3 );
     125         [ #  # ]:          0 :                 if( aMDHelper.ISSET_OutputStream  )
     126 [ #  # ][ #  # ]:          0 :                     aStorageArgs[0] <<= aMDHelper.OutputStream;
     127                 :            :                 else
     128 [ #  # ][ #  # ]:          0 :                     aStorageArgs[0] <<= aMDHelper.URL;
     129 [ #  # ][ #  # ]:          0 :                 aStorageArgs[1] <<= (embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE);
     130 [ #  # ][ #  # ]:          0 :                 aStorageArgs[2] <<= ::chart::ContainerHelper::ContainerToSequence( aPropertiesForStorage );
         [ #  # ][ #  # ]
     131                 :            : 
     132                 :            :                 xStorage.set(
     133         [ #  # ]:          0 :                     xStorageFact->createInstanceWithArguments( aStorageArgs ),
     134 [ #  # ][ #  # ]:          0 :                     uno::UNO_QUERY_THROW );
                 [ #  # ]
     135                 :          0 :             }
     136                 :            :         }
     137                 :            : 
     138                 :            :         // set correct media type at storage
     139         [ +  - ]:         15 :         uno::Reference<beans::XPropertySet> xProp(xStorage,uno::UNO_QUERY);
     140                 :         15 :         OUString aMediaType;
     141 [ +  - ][ +  -  :         60 :         if ( ! xProp.is() ||
             +  -  +  - ]
     142 [ +  - ][ +  - ]:         30 :              ! ( xProp->getPropertyValue( C2U("MediaType")) >>= aMediaType ) ||
         [ +  - ][ +  - ]
                 [ +  - ]
           [ #  #  #  # ]
     143                 :         15 :              ( aMediaType.isEmpty() ))
     144                 :            :         {
     145 [ +  - ][ +  - ]:         15 :             xProp->setPropertyValue( C2U("MediaType"), uno::makeAny( _sMediaType ));
         [ +  - ][ +  - ]
     146 [ +  - ][ #  # ]:         15 :         }
     147                 :            :     }
     148         [ #  # ]:          0 :     catch (const uno::Exception& ex)
     149                 :            :     {
     150                 :            :         ASSERT_EXCEPTION( ex );
     151                 :            :     }
     152                 :         15 :     return xStorage;
     153                 :            : }
     154                 :            : 
     155                 :          6 : uno::Reference< embed::XStorage > lcl_getReadStorage(
     156                 :            :     const Sequence< beans::PropertyValue >& rMediaDescriptor,
     157                 :            :     const uno::Reference< uno::XComponentContext >& xContext)
     158                 :            : {
     159                 :          6 :     uno::Reference< embed::XStorage > xStorage;
     160                 :            : 
     161                 :            :     try
     162                 :            :     {
     163         [ +  - ]:          6 :         apphelper::MediaDescriptorHelper aMDHelper( rMediaDescriptor );
     164         [ +  - ]:          6 :         if( aMDHelper.ISSET_Storage )
     165                 :            :         {
     166         [ +  - ]:          6 :             xStorage = aMDHelper.Storage;
     167                 :            :         }
     168                 :            :         else
     169                 :            :         {
     170                 :            :             // get XStream from MediaDescriptor
     171                 :          0 :             uno::Reference< io::XInputStream > xStream;
     172         [ #  # ]:          0 :             ::std::vector< beans::PropertyValue > aPropertiesForStorage;
     173         [ #  # ]:          0 :             for( sal_Int32 i=rMediaDescriptor.getLength(); i--; )
     174                 :            :             {
     175         [ #  # ]:          0 :                 if( rMediaDescriptor[i].Name == "InputStream" )
     176         [ #  # ]:          0 :                     xStream.set( rMediaDescriptor[i].Value, uno::UNO_QUERY );
     177                 :            : 
     178                 :            :                 // properties understood by storage factory
     179                 :            :                 // (see package/source/xstor/xfactory.cxx for details)
     180 [ #  # ][ #  # ]:          0 :                 if ( rMediaDescriptor[i].Name == "InteractionHandler" || rMediaDescriptor[i].Name == "Password" || rMediaDescriptor[i].Name == "RepairPackage" )
         [ #  # ][ #  # ]
     181                 :            :                 {
     182         [ #  # ]:          0 :                     aPropertiesForStorage.push_back( rMediaDescriptor[i] );
     183                 :            :                 }
     184                 :            :             }
     185                 :            :             OSL_ENSURE( xStream.is(), "No Stream" );
     186         [ #  # ]:          0 :             if( ! xStream.is())
     187                 :            :                 return xStorage;
     188                 :            : 
     189                 :            :             // convert XInputStream to XStorage via the storage factory
     190                 :            :             Reference< lang::XSingleServiceFactory > xStorageFact(
     191 [ #  # ][ #  # ]:          0 :                 xContext->getServiceManager()->createInstanceWithContext(
                 [ #  # ]
     192                 :            :                     C2U("com.sun.star.embed.StorageFactory"),
     193                 :          0 :                     xContext ),
     194 [ #  # ][ #  # ]:          0 :                 uno::UNO_QUERY_THROW );
                 [ #  # ]
     195         [ #  # ]:          0 :             Sequence< uno::Any > aStorageArgs( 3 );
     196 [ #  # ][ #  # ]:          0 :             aStorageArgs[0] <<= xStream;
     197 [ #  # ][ #  # ]:          0 :             aStorageArgs[1] <<= (embed::ElementModes::READ | embed::ElementModes::NOCREATE);
     198 [ #  # ][ #  # ]:          0 :             aStorageArgs[2] <<= ::chart::ContainerHelper::ContainerToSequence( aPropertiesForStorage );
         [ #  # ][ #  # ]
     199                 :            :             xStorage.set(
     200 [ #  # ][ #  # ]:          6 :                 xStorageFact->createInstanceWithArguments( aStorageArgs ), uno::UNO_QUERY_THROW );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     201                 :            :         }
     202                 :            : 
     203 [ +  - ][ +  - ]:          6 :         OSL_ENSURE( xStorage.is(), "No Storage" );
                 [ #  # ]
     204                 :            :     }
     205         [ #  # ]:          0 :     catch (const uno::Exception& ex)
     206                 :            :     {
     207                 :            :         ASSERT_EXCEPTION( ex );
     208                 :            :     }
     209                 :            : 
     210                 :          6 :     return xStorage;
     211                 :            : }
     212                 :            : 
     213                 :            : 
     214                 :            : } // anonymous namespace
     215                 :            : 
     216                 :            : // ----------------------------------------
     217                 :            : 
     218                 :            : namespace chart
     219                 :            : {
     220                 :            : 
     221                 :         21 : XMLFilter::XMLFilter( Reference< uno::XComponentContext > const & xContext ) :
     222                 :            :         m_xContext( xContext ),
     223         [ +  - ]:         21 :         m_bCancelOperation( false )
     224                 :         21 : {}
     225                 :            : 
     226         [ +  - ]:         21 : XMLFilter::~XMLFilter()
     227         [ -  + ]:         42 : {}
     228                 :            : 
     229                 :            : // ____ XFilter ____
     230                 :         21 : sal_Bool SAL_CALL XMLFilter::filter(
     231                 :            :     const Sequence< beans::PropertyValue >& aDescriptor )
     232                 :            :     throw (uno::RuntimeException)
     233                 :            : {
     234                 :         21 :     bool bResult = false;
     235                 :            : 
     236         [ +  - ]:         21 :     MutexGuard aGuard( m_aMutex );
     237                 :            : 
     238                 :            :     // ignore cancel flag at start of function
     239                 :            :     // note: is currently ignored during import/export
     240         [ -  + ]:         21 :     if( m_bCancelOperation )
     241                 :          0 :         m_bCancelOperation = false;
     242                 :            : 
     243         [ +  + ]:         21 :     if( m_xSourceDoc.is())
     244                 :            :     {
     245                 :            :         OSL_ENSURE( ! m_xTargetDoc.is(), "source doc is set -> target document should not be set" );
     246         [ +  + ]:         15 :         if( impl_Export( m_xSourceDoc,
     247         [ +  - ]:         15 :                          aDescriptor ) == 0 )
     248                 :            :         {
     249         [ +  - ]:          9 :             m_xSourceDoc = NULL;
     250                 :          9 :             bResult = true;
     251                 :            :         }
     252                 :            :     }
     253         [ +  - ]:          6 :     else if( m_xTargetDoc.is())
     254                 :            :     {
     255         [ +  - ]:          6 :         if( impl_Import( m_xTargetDoc,
     256         [ +  - ]:          6 :                          aDescriptor ) == 0 )
     257                 :            :         {
     258         [ +  - ]:          6 :             m_xTargetDoc = NULL;
     259                 :          6 :             bResult = true;
     260                 :            :         }
     261                 :            :     }
     262                 :            :     else
     263                 :            :     {
     264                 :            :         OSL_FAIL( "filter() called with no document set" );
     265                 :            :     }
     266                 :            : 
     267         [ +  - ]:         21 :     return bResult;
     268                 :            : }
     269                 :            : 
     270                 :          0 : void SAL_CALL XMLFilter::cancel()
     271                 :            :     throw (uno::RuntimeException)
     272                 :            : {
     273                 :            :     // if mutex is locked set "cancel state"
     274                 :            :     // note: is currently ignored in filter-method
     275         [ #  # ]:          0 :     if( ! m_aMutex.tryToAcquire())
     276                 :            :     {
     277                 :          0 :         m_bCancelOperation = true;
     278                 :            :     }
     279                 :          0 : }
     280                 :            : 
     281                 :            : // ____ XImporter ____
     282                 :          6 : void SAL_CALL XMLFilter::setTargetDocument(
     283                 :            :     const Reference< lang::XComponent >& Document )
     284                 :            :     throw (lang::IllegalArgumentException,
     285                 :            :            uno::RuntimeException)
     286                 :            : {
     287         [ +  - ]:          6 :     MutexGuard aGuard( m_aMutex );
     288                 :            :     OSL_ENSURE( ! m_xSourceDoc.is(), "Setting target doc while source doc is set" );
     289                 :            : 
     290 [ +  - ][ +  - ]:          6 :     m_xTargetDoc = Document;
     291                 :          6 : }
     292                 :            : 
     293                 :            : 
     294                 :            : // ____ XExporter ____
     295                 :         15 : void SAL_CALL XMLFilter::setSourceDocument(
     296                 :            :     const Reference< lang::XComponent >& Document )
     297                 :            :     throw (lang::IllegalArgumentException,
     298                 :            :            uno::RuntimeException)
     299                 :            : {
     300         [ +  - ]:         15 :     MutexGuard aGuard( m_aMutex );
     301                 :            :     OSL_ENSURE( ! m_xTargetDoc.is(), "Setting source doc while target doc is set" );
     302                 :            : 
     303 [ +  - ][ +  - ]:         15 :     m_xSourceDoc = Document;
     304                 :         15 : }
     305                 :            : 
     306                 :            : 
     307                 :          6 : sal_Int32 XMLFilter::impl_Import(
     308                 :            :     const Reference< lang::XComponent > & xDocumentComp,
     309                 :            :     const Sequence< beans::PropertyValue > & rMediaDescriptor )
     310                 :            : {
     311                 :          6 :     sal_Int32 nWarning = 0;
     312                 :            : 
     313                 :            :     OSL_ENSURE( xDocumentComp.is(), "Import: No Model" );
     314                 :            :     OSL_ENSURE( m_xContext.is(), "Import: No ComponentContext" );
     315                 :            : 
     316         [ -  + ]:         12 :     if( ! (xDocumentComp.is() &&
     317 [ -  + ][ +  - ]:          6 :            m_xContext.is()))
     318                 :          0 :         return nWarning;
     319                 :            : 
     320                 :            :     try
     321                 :            :     {
     322         [ +  - ]:          6 :         Reference< lang::XServiceInfo > xServInfo( xDocumentComp, uno::UNO_QUERY_THROW );
     323 [ +  - ][ +  - ]:          6 :         if( ! xServInfo->supportsService( C2U( "com.sun.star.chart2.ChartDocument" )))
         [ +  - ][ -  + ]
     324                 :            :         {
     325                 :            :             OSL_FAIL( "Import: No ChartDocument" );
     326                 :          0 :             return ERRCODE_SFX_GENERAL;
     327                 :            :         }
     328                 :            : 
     329 [ +  - ][ +  - ]:          6 :         Reference< lang::XMultiComponentFactory > xFactory( m_xContext->getServiceManager());
     330                 :            :         OSL_ENSURE( xFactory.is(), "Import: No Factory" );
     331         [ -  + ]:          6 :         if( ! xFactory.is())
     332                 :          0 :             return ERRCODE_SFX_GENERAL;
     333                 :            : 
     334                 :            :         // create a sax parser
     335                 :            :         Reference< xml::sax::XParser > xSaxParser(
     336         [ +  - ]:          6 :             xFactory->createInstanceWithContext( C2U( "com.sun.star.xml.sax.Parser" ), m_xContext ),
     337 [ +  - ][ +  - ]:          6 :             uno::UNO_QUERY_THROW );
                 [ +  - ]
     338                 :            : 
     339                 :          6 :         bool bOasis = true;
     340         [ +  - ]:          6 :         isOasisFormat( rMediaDescriptor, bOasis );
     341         [ +  - ]:          6 :         Reference< embed::XStorage > xStorage( lcl_getReadStorage( rMediaDescriptor, m_xContext));
     342         [ -  + ]:          6 :         if( ! xStorage.is())
     343                 :          0 :             return ERRCODE_SFX_GENERAL;
     344                 :            : 
     345                 :          6 :         Reference< document::XGraphicObjectResolver > xGraphicObjectResolver;
     346         [ +  - ]:          6 :         uno::Reference< lang::XMultiServiceFactory > xServiceFactory( xFactory, uno::UNO_QUERY);
     347         [ +  - ]:          6 :         if( xServiceFactory.is())
     348                 :            :         {
     349         [ +  - ]:          6 :             uno::Sequence< uno::Any > aArgs(1);
     350 [ +  - ][ +  - ]:          6 :             aArgs[0] <<= xStorage;
     351                 :            :             xGraphicObjectResolver.set(
     352         [ +  - ]:          6 :                 xServiceFactory->createInstanceWithArguments(
     353 [ +  - ][ +  - ]:          6 :                     C2U("com.sun.star.comp.Svx.GraphicImportHelper"), aArgs ), uno::UNO_QUERY );
         [ +  - ][ +  - ]
     354                 :            :         }
     355                 :            : 
     356                 :            :         // create XPropertySet with extra informatio for the filter
     357                 :            :         /** property map for import info set */
     358                 :            :         comphelper::PropertyMapEntry aImportInfoMap[] =
     359                 :            :         {
     360                 :            :             // necessary properties for XML progress bar at load time
     361         [ +  - ]:          6 :             { MAP_LEN( "ProgressRange" ),   0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     362         [ +  - ]:          6 :             { MAP_LEN( "ProgressMax" ),     0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     363         [ +  - ]:          6 :             { MAP_LEN( "ProgressCurrent" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     364                 :            :             { MAP_LEN( "PrivateData" ), 0,
     365         [ +  - ]:          6 :                 &::getCppuType( (Reference<XInterface> *)0 ),
     366                 :            :                 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     367                 :            :             { MAP_LEN( "BaseURI" ), 0,
     368         [ +  - ]:          6 :                 &::getCppuType( (OUString *)0 ),
     369                 :            :                 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     370                 :            :             { MAP_LEN( "StreamRelPath" ), 0,
     371         [ +  - ]:          6 :                 &::getCppuType( (OUString *)0 ),
     372                 :            :                 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     373                 :            :             { MAP_LEN( "StreamName" ), 0,
     374         [ +  - ]:          6 :                 &::getCppuType( (OUString *)0 ),
     375                 :            :                 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     376                 :            :             { MAP_LEN( "BuildId" ), 0,
     377         [ +  - ]:          6 :                 &::getCppuType( (OUString *)0 ),
     378                 :            :                 ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     379                 :            :             { NULL, 0, 0, NULL, 0, 0 }
     380                 :         54 :         };
     381                 :            :         uno::Reference< beans::XPropertySet > xImportInfo(
     382                 :            :                     comphelper::GenericPropertySet_CreateInstance(
     383         [ +  - ]:          6 :                                 new comphelper::PropertySetInfo( aImportInfoMap ) ) );
     384                 :            : 
     385                 :            :         // Set base URI and Hierarchical Name
     386                 :          6 :         OUString aHierarchName, aBaseUri;
     387         [ +  - ]:          6 :         uno::Reference< frame::XModel > xModel( m_xSourceDoc, uno::UNO_QUERY );
     388         [ -  + ]:          6 :         if( xModel.is() )
     389                 :            :         {
     390 [ #  # ][ #  # ]:          0 :             uno::Sequence< beans::PropertyValue > aModProps = xModel->getArgs();
     391         [ #  # ]:          0 :             for( sal_Int32 nInd = 0; nInd < aModProps.getLength(); nInd++ )
     392                 :            :             {
     393 [ #  # ][ #  # ]:          0 :                 if( aModProps[nInd].Name.equals( C2U( "HierarchicalDocumentName" ) ) )
                 [ #  # ]
     394                 :            :                 {
     395                 :            :                     // Actually this argument only has meaning for embedded documents
     396         [ #  # ]:          0 :                     aModProps[nInd].Value >>= aHierarchName;
     397                 :            :                 }
     398 [ #  # ][ #  # ]:          0 :                 else if( aModProps[nInd].Name.equals( C2U( "DocumentBaseURL" ) ) )
                 [ #  # ]
     399                 :            :                 {
     400         [ #  # ]:          0 :                     aModProps[nInd].Value >>= aBaseUri;
     401                 :            :                 }
     402         [ #  # ]:          0 :             }
     403                 :            :         }
     404                 :            : 
     405         [ -  + ]:          6 :         if( !aBaseUri.isEmpty() )
     406 [ #  # ][ #  # ]:          0 :             xImportInfo->setPropertyValue( C2U("BaseURI"), uno::makeAny( aBaseUri ) );
         [ #  # ][ #  # ]
     407                 :            : 
     408         [ -  + ]:          6 :         if( !aHierarchName.isEmpty() )
     409 [ #  # ][ #  # ]:          0 :             xImportInfo->setPropertyValue( C2U("StreamRelPath"), uno::makeAny( aHierarchName ) );
         [ #  # ][ #  # ]
     410                 :            : 
     411                 :            :         // import meta information
     412         [ -  + ]:          6 :         if( bOasis )
     413                 :            :             nWarning |= impl_ImportStream(
     414                 :            :                 C2U( sXML_metaStreamName ),
     415                 :            :                 C2U( sXML_import_chart_oasis_meta_service ),
     416 [ #  # ][ #  # ]:          0 :                 xStorage, xSaxParser, xFactory, xGraphicObjectResolver, xImportInfo );
                 [ #  # ]
     417                 :            : 
     418                 :            :         // import styles
     419                 :            :         nWarning |= impl_ImportStream(
     420                 :            :             C2U( sXML_styleStreamName ),
     421                 :            :             bOasis
     422                 :            :             ? C2U( sXML_import_chart_oasis_styles_service )
     423                 :            :             : C2U( sXML_import_chart_styles_service ),
     424 [ -  + ][ #  # ]:          6 :             xStorage, xSaxParser, xFactory, xGraphicObjectResolver, xImportInfo );
         [ +  - ][ +  - ]
                 [ +  - ]
     425                 :            : 
     426                 :            :         // import content
     427                 :            :         sal_Int32 nContentWarning = impl_ImportStream(
     428                 :            :             C2U( sXML_contentStreamName ),
     429                 :            :             bOasis
     430                 :            :             ? C2U( sXML_import_chart_oasis_content_service )
     431                 :            :             : C2U( sXML_import_chart_content_service ),
     432 [ #  # ][ +  - ]:          6 :             xStorage, xSaxParser, xFactory, xGraphicObjectResolver, xImportInfo );
         [ +  - ][ +  - ]
                 [ -  + ]
     433                 :          6 :         nWarning |= nContentWarning;
     434                 :            : 
     435                 :            :         // import of "content.xml" didn't work - try old "Content.xml" stream
     436         [ -  + ]:          6 :         if( nContentWarning != 0 )
     437                 :            :         {
     438                 :            :             nWarning = impl_ImportStream(
     439                 :            :                 C2U( sXML_oldContentStreamName ),
     440                 :            :                 C2U( sXML_import_chart_old_content_service ),
     441 [ #  # ][ #  # ]:          0 :                 xStorage, xSaxParser, xFactory, xGraphicObjectResolver, xImportInfo );
                 [ #  # ]
     442 [ -  + ][ -  + ]:          6 :         }
         [ -  + ][ +  - ]
                 [ #  # ]
     443                 :            :     }
     444                 :          0 :     catch (const uno::Exception& ex)
     445                 :            :     {
     446                 :            :         ASSERT_EXCEPTION( ex );
     447                 :            : 
     448                 :            :         // something went awry
     449                 :          0 :         nWarning = ERRCODE_SFX_GENERAL;
     450                 :            :     }
     451                 :            : 
     452                 :          6 :     return nWarning;
     453                 :            : }
     454                 :            : 
     455                 :         12 : sal_Int32 XMLFilter::impl_ImportStream(
     456                 :            :     const OUString & rStreamName,
     457                 :            :     const OUString & rServiceName,
     458                 :            :     const Reference< embed::XStorage > & xStorage,
     459                 :            :     const Reference< xml::sax::XParser > & xParser,
     460                 :            :     const Reference< lang::XMultiComponentFactory > & xFactory,
     461                 :            :     const Reference< document::XGraphicObjectResolver > & xGraphicObjectResolver,
     462                 :            :     uno::Reference< beans::XPropertySet >& xImportInfo )
     463                 :            : {
     464                 :         12 :     sal_Int32 nWarning = ERRCODE_SFX_GENERAL;
     465                 :            : 
     466         [ +  - ]:         12 :     Reference< container::XNameAccess > xNameAcc( xStorage, uno::UNO_QUERY );
     467         [ -  + ]:         24 :     if( ! (xNameAcc.is() &&
     468 [ +  - ][ +  - ]:         12 :            xNameAcc->hasByName( rStreamName )))
         [ -  + ][ +  - ]
     469                 :          0 :         return 0;
     470                 :            : 
     471         [ +  - ]:         12 :     if( xImportInfo.is() )
     472 [ +  - ][ +  - ]:         12 :         xImportInfo->setPropertyValue( C2U("StreamName"), uno::makeAny( rStreamName ) );
         [ +  - ][ +  - ]
     473                 :            : 
     474 [ +  - ][ +  - ]:         24 :     if( xStorage.is() &&
                 [ +  - ]
     475 [ +  - ][ +  - ]:         12 :         xStorage->isStreamElement( rStreamName ) )
     476                 :            :     {
     477                 :            :         try
     478                 :            :         {
     479         [ +  - ]:         12 :             xml::sax::InputSource aParserInput;
     480                 :            :             aParserInput.aInputStream.set(
     481         [ +  - ]:         12 :                 xStorage->openStreamElement(
     482                 :            :                     rStreamName,
     483                 :         12 :                     embed::ElementModes::READ | embed::ElementModes::NOCREATE ),
     484 [ +  - ][ +  - ]:         12 :                 uno::UNO_QUERY );
     485                 :            : 
     486                 :            :             // todo: encryption
     487                 :            : 
     488         [ +  - ]:         12 :             if( aParserInput.aInputStream.is())
     489                 :            :             {
     490                 :         12 :                 sal_Int32 nArgs = 0;
     491         [ +  - ]:         12 :                 if( xGraphicObjectResolver.is())
     492                 :         12 :                     nArgs++;
     493         [ +  - ]:         12 :                 if( xImportInfo.is())
     494                 :         12 :                     nArgs++;
     495                 :            : 
     496         [ +  - ]:         12 :                 uno::Sequence< uno::Any > aFilterCompArgs( nArgs );
     497                 :            : 
     498                 :         12 :                 nArgs = 0;
     499         [ +  - ]:         12 :                 if( xGraphicObjectResolver.is())
     500 [ +  - ][ +  - ]:         12 :                     aFilterCompArgs[nArgs++] <<= xGraphicObjectResolver;
     501         [ +  - ]:         12 :                 if( xImportInfo.is())
     502 [ +  - ][ +  - ]:         12 :                     aFilterCompArgs[ nArgs++ ] <<= xImportInfo;
     503                 :            : 
     504                 :            :                 Reference< xml::sax::XDocumentHandler > xDocHandler(
     505         [ +  - ]:         12 :                     xFactory->createInstanceWithArgumentsAndContext( rServiceName, aFilterCompArgs, m_xContext ),
     506 [ +  - ][ +  - ]:         12 :                     uno::UNO_QUERY_THROW );
     507                 :            : 
     508                 :            : 
     509         [ +  - ]:         12 :                 Reference< document::XImporter > xImporter( xDocHandler, uno::UNO_QUERY_THROW );
     510 [ +  - ][ +  - ]:         12 :                 xImporter->setTargetDocument( Reference< lang::XComponent >( m_xTargetDoc, uno::UNO_QUERY_THROW ));
                 [ +  - ]
     511                 :            : 
     512         [ -  + ]:         12 :                 if ( !m_sDocumentHandler.isEmpty() )
     513                 :            :                 {
     514                 :            :                     try
     515                 :            :                     {
     516         [ #  # ]:          0 :                         uno::Sequence< uno::Any > aArgs(2);
     517                 :          0 :                         beans::NamedValue aValue;
     518         [ #  # ]:          0 :                         aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentHandler"));
     519         [ #  # ]:          0 :                         aValue.Value <<= xDocHandler;
     520 [ #  # ][ #  # ]:          0 :                         aArgs[0] <<= aValue;
     521         [ #  # ]:          0 :                         aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model"));
     522         [ #  # ]:          0 :                         aValue.Value <<= m_xTargetDoc;
     523 [ #  # ][ #  # ]:          0 :                         aArgs[1] <<= aValue;
     524                 :            : 
     525 [ #  # ][ #  # ]:          0 :                         xDocHandler.set(xFactory->createInstanceWithArgumentsAndContext(m_sDocumentHandler,aArgs,m_xContext), uno::UNO_QUERY );
                 [ #  # ]
     526 [ #  # ][ #  # ]:          0 :                         xImporter.set(xDocHandler,uno::UNO_QUERY);
                 [ #  # ]
     527                 :            :                     }
     528         [ #  # ]:          0 :                     catch (const uno::Exception&)
     529                 :            :                     {
     530                 :            :                         OSL_FAIL("Exception caught!");
     531                 :            :                     }
     532                 :            :                 }
     533 [ +  - ][ +  - ]:         12 :                 xParser->setDocumentHandler( xDocHandler );
     534 [ +  - ][ +  - ]:         12 :                 xParser->parseStream( aParserInput );
                 [ +  - ]
     535                 :            :             }
     536                 :            : 
     537                 :            :             // load was successful
     538 [ +  - ][ #  #  :         12 :             nWarning = 0;
             #  #  #  # ]
     539                 :            :         }
     540         [ #  # ]:          0 :         catch (const xml::sax::SAXParseException&)
     541                 :            :         {
     542                 :            :             // todo: if encrypted: ERRCODE_SFX_WRONGPASSWORD
     543                 :            :         }
     544         [ #  # ]:          0 :         catch (const xml::sax::SAXException&)
     545                 :            :         {
     546                 :            :             // todo: if encrypted: ERRCODE_SFX_WRONGPASSWORD
     547                 :            :         }
     548         [ #  # ]:          0 :         catch (const packages::zip::ZipIOException&)
     549                 :            :         {
     550                 :          0 :             nWarning = ERRCODE_IO_BROKENPACKAGE;
     551                 :            :         }
     552         [ #  # ]:          0 :         catch (const io::IOException&)
     553                 :            :         {
     554                 :            :         }
     555         [ #  # ]:          0 :         catch (const uno::Exception& rEx)
     556                 :            :         {
     557                 :            :             ASSERT_EXCEPTION(rEx);
     558                 :            :         }
     559                 :            :     }
     560                 :            : 
     561                 :         12 :     return nWarning;
     562                 :            : }
     563                 :            : 
     564                 :         15 : sal_Int32 XMLFilter::impl_Export(
     565                 :            :     const Reference< lang::XComponent > & xDocumentComp,
     566                 :            :     const Sequence< beans::PropertyValue > & rMediaDescriptor )
     567                 :            : {
     568                 :            :     //save
     569                 :            : 
     570                 :         15 :     sal_Int32 nWarning = 0;
     571                 :            : 
     572                 :            :     OSL_ENSURE( xDocumentComp.is(), "Export: No Model" );
     573                 :            :     OSL_ENSURE( m_xContext.is(), "Export: No ComponentContext" );
     574                 :            : 
     575 [ +  - ][ -  + ]:         15 :     if( !xDocumentComp.is() || !m_xContext.is() )
                 [ -  + ]
     576                 :          0 :         return nWarning;
     577                 :            : 
     578                 :            :     try
     579                 :            :     {
     580         [ +  - ]:         15 :         Reference< lang::XServiceInfo > xServInfo( xDocumentComp, uno::UNO_QUERY_THROW );
     581 [ +  - ][ +  - ]:         15 :         if( ! xServInfo->supportsService( C2U( "com.sun.star.chart2.ChartDocument" )))
         [ +  - ][ -  + ]
     582                 :            :         {
     583                 :            :             OSL_FAIL( "Export: No ChartDocument" );
     584                 :          0 :             return ERRCODE_SFX_GENERAL;
     585                 :            :         }
     586                 :            : 
     587 [ +  - ][ +  - ]:         15 :         Reference< lang::XMultiComponentFactory > xFactory( m_xContext->getServiceManager());
     588                 :            :         OSL_ENSURE( xFactory.is(), "Export: No Factory" );
     589         [ -  + ]:         15 :         if( ! xFactory.is())
     590                 :          0 :             return ERRCODE_SFX_GENERAL;
     591 [ +  - ][ +  - ]:         15 :         uno::Reference< lang::XMultiServiceFactory > xServiceFactory( m_xContext->getServiceManager(), uno::UNO_QUERY);
                 [ +  - ]
     592         [ -  + ]:         15 :         if( ! xServiceFactory.is())
     593                 :          0 :             return ERRCODE_SFX_GENERAL;
     594                 :            : 
     595         [ +  - ]:         15 :         uno::Reference< io::XActiveDataSource > xSaxWriter( xServiceFactory->createInstance(
     596 [ +  - ][ +  - ]:         15 :                 C2U("com.sun.star.xml.sax.Writer")), uno::UNO_QUERY );
                 [ +  - ]
     597         [ -  + ]:         15 :         if ( !xSaxWriter.is() )
     598                 :          0 :             return ERRCODE_SFX_GENERAL;
     599                 :            : 
     600                 :         15 :         bool bOasis = true;
     601         [ +  - ]:         15 :         isOasisFormat( rMediaDescriptor, bOasis );
     602                 :            : 
     603 [ +  - ][ +  - ]:         15 :         uno::Reference< embed::XStorage > xStorage( lcl_getWriteStorage( rMediaDescriptor, m_xContext, getMediaType(bOasis) ) );
     604                 :            :         OSL_ENSURE( xStorage.is(), "No Storage" );
     605         [ -  + ]:         15 :         if( ! xStorage.is())
     606                 :          0 :             return ERRCODE_SFX_GENERAL;
     607                 :            : 
     608         [ +  - ]:         15 :         uno::Reference< xml::sax::XDocumentHandler> xDocHandler( xSaxWriter, uno::UNO_QUERY );
     609                 :            : 
     610         [ -  + ]:         15 :         if ( !m_sDocumentHandler.isEmpty() )
     611                 :            :         {
     612                 :            :             try
     613                 :            :             {
     614         [ #  # ]:          0 :                 uno::Sequence< uno::Any > aArgs(2);
     615                 :          0 :                 beans::NamedValue aValue;
     616         [ #  # ]:          0 :                 aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DocumentHandler"));
     617         [ #  # ]:          0 :                 aValue.Value <<= xDocHandler;
     618 [ #  # ][ #  # ]:          0 :                 aArgs[0] <<= aValue;
     619         [ #  # ]:          0 :                 aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Model"));
     620         [ #  # ]:          0 :                 aValue.Value <<= xDocumentComp;
     621 [ #  # ][ #  # ]:          0 :                 aArgs[1] <<= aValue;
     622                 :            : 
     623 [ #  # ][ #  # ]:          0 :                 xDocHandler.set(xServiceFactory->createInstanceWithArguments(m_sDocumentHandler,aArgs), uno::UNO_QUERY );
                 [ #  # ]
     624 [ #  # ][ #  # ]:          0 :                 xSaxWriter.set(xDocHandler,uno::UNO_QUERY);
                 [ #  # ]
     625                 :            :             }
     626         [ #  # ]:          0 :             catch (const uno::Exception&)
     627                 :            :             {
     628                 :            :                 OSL_FAIL("Exception caught!");
     629                 :            :             }
     630                 :            :         }
     631                 :            : 
     632         [ +  - ]:         15 :         uno::Sequence< uno::Any > aGraphicResolverArgs(1);
     633 [ +  - ][ +  - ]:         15 :         aGraphicResolverArgs[0] <<= xStorage;
     634                 :            :         Reference< document::XGraphicObjectResolver > xGraphicObjectResolver(
     635         [ +  - ]:         15 :             xServiceFactory->createInstanceWithArguments(
     636 [ +  - ][ +  - ]:         15 :                 C2U("com.sun.star.comp.Svx.GraphicExportHelper"), aGraphicResolverArgs ), uno::UNO_QUERY );
                 [ +  - ]
     637                 :            : 
     638                 :         15 :         uno::Reference< beans::XPropertySet > xInfoSet;
     639                 :            :         {
     640                 :            :             // property map for export info set
     641                 :            :             comphelper::PropertyMapEntry aExportInfoMap[] =
     642                 :            :             {
     643         [ +  - ]:         15 :                 { MAP_LEN("UsePrettyPrinting"), 0, &::getBooleanCppuType(), beans::PropertyAttribute::MAYBEVOID, 0},
     644         [ +  - ]:         15 :                 { MAP_LEN("BaseURI"), 0, &::getCppuType( (OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 },
     645         [ +  - ]:         15 :                 { MAP_LEN("StreamRelPath"), 0, &::getCppuType( (OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 },
     646         [ +  - ]:         15 :                 { MAP_LEN("StreamName"), 0, &::getCppuType( (OUString *)0 ), beans::PropertyAttribute::MAYBEVOID, 0 },
     647         [ +  - ]:         15 :                 { MAP_LEN("ExportTableNumberList"), 0, &::getBooleanCppuType(), beans::PropertyAttribute::MAYBEVOID, 0 },
     648                 :            :                 { NULL, 0, 0, NULL, 0, 0 }
     649                 :         90 :             };
     650                 :            : 
     651 [ +  - ][ +  - ]:         15 :             xInfoSet = comphelper::GenericPropertySet_CreateInstance( new comphelper::PropertySetInfo( aExportInfoMap ) );
     652                 :            : 
     653         [ +  - ]:         15 :             SvtSaveOptions aSaveOpt;
     654         [ +  - ]:         15 :             OUString sUsePrettyPrinting(RTL_CONSTASCII_USTRINGPARAM("UsePrettyPrinting"));
     655         [ +  - ]:         15 :             sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() );
     656 [ +  - ][ +  - ]:         15 :             xInfoSet->setPropertyValue( sUsePrettyPrinting, uno::makeAny( bUsePrettyPrinting ) );
                 [ +  - ]
     657         [ -  + ]:         15 :             if( ! bOasis )
     658 [ #  # ][ #  # ]:         15 :                 xInfoSet->setPropertyValue( C2U("ExportTableNumberList"), uno::makeAny( true ));
         [ #  # ][ #  # ]
                 [ +  - ]
     659                 :            :         }
     660                 :            : 
     661                 :         15 :         sal_Int32 nArgs = 2;
     662         [ +  + ]:         15 :         if( xGraphicObjectResolver.is())
     663                 :          9 :             nArgs++;
     664                 :            : 
     665         [ +  - ]:         15 :         uno::Sequence< uno::Any > aFilterProperties( nArgs );
     666                 :            :         {
     667                 :         15 :             nArgs = 0;
     668 [ +  - ][ +  - ]:         15 :             aFilterProperties[ nArgs++ ] <<= xInfoSet;
     669 [ +  - ][ +  - ]:         15 :             aFilterProperties[ nArgs++ ] <<= xDocHandler;
     670         [ +  + ]:         15 :             if( xGraphicObjectResolver.is())
     671 [ +  - ][ +  - ]:          9 :                 aFilterProperties[ nArgs++ ] <<= xGraphicObjectResolver;
     672                 :            :         }
     673                 :            : 
     674                 :            :         // export meta information
     675         [ +  - ]:         15 :         if( bOasis )
     676                 :            :             nWarning |= impl_ExportStream(
     677                 :            :                 C2U( sXML_metaStreamName ),
     678                 :            :                 C2U( sXML_export_chart_oasis_meta_service ),
     679 [ +  - ][ +  - ]:         15 :                 xStorage, xSaxWriter, xServiceFactory, aFilterProperties );
                 [ +  - ]
     680                 :            : 
     681                 :            :         // export styles
     682                 :            :         nWarning |= impl_ExportStream(
     683                 :            :             C2U( sXML_styleStreamName ),
     684                 :            :             bOasis
     685                 :            :             ? C2U( sXML_export_chart_oasis_styles_service )
     686                 :            :             : C2U( sXML_export_chart_styles_service ),
     687 [ +  - ][ +  - ]:         15 :             xStorage, xSaxWriter, xServiceFactory, aFilterProperties );
         [ #  # ][ +  - ]
                 [ +  - ]
     688                 :            : 
     689                 :            :         // export content
     690                 :            :         sal_Int32 nContentWarning = impl_ExportStream(
     691                 :            :             C2U( sXML_contentStreamName ),
     692                 :            :             bOasis
     693                 :            :             ? C2U( sXML_export_chart_oasis_content_service )
     694                 :            :             : C2U( sXML_export_chart_content_service ),
     695 [ +  - ][ #  # ]:         15 :             xStorage, xSaxWriter, xServiceFactory, aFilterProperties );
         [ +  - ][ +  - ]
                 [ +  - ]
     696                 :         15 :         nWarning |= nContentWarning;
     697                 :            : 
     698         [ +  - ]:         15 :         Reference< lang::XComponent > xComp( xGraphicObjectResolver, uno::UNO_QUERY );
     699         [ +  + ]:         15 :         if( xComp.is())
     700 [ +  - ][ +  - ]:          9 :             xComp->dispose();
     701                 :            : 
     702         [ +  - ]:         15 :         uno::Reference<embed::XTransactedObject> xTransact( xStorage ,uno::UNO_QUERY);
     703         [ +  - ]:         15 :         if ( xTransact.is() )
     704 [ +  - ][ +  - ]:         15 :             xTransact->commit();
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
         [ -  + ][ -  + ]
         [ +  - ][ #  # ]
     705                 :            :     }
     706                 :          0 :     catch (const uno::Exception& ex)
     707                 :            :     {
     708                 :            :         ASSERT_EXCEPTION( ex );
     709                 :            : 
     710                 :            :         // something went awry
     711                 :          0 :         nWarning = ERRCODE_SFX_GENERAL;
     712                 :            :     }
     713                 :            : 
     714                 :         15 :     return nWarning;
     715                 :            : }
     716                 :            : 
     717                 :         45 : sal_Int32 XMLFilter::impl_ExportStream(
     718                 :            :     const OUString & rStreamName,
     719                 :            :     const OUString & rServiceName,
     720                 :            :     const Reference< embed::XStorage > & xStorage,
     721                 :            :     const uno::Reference< io::XActiveDataSource >& xActiveDataSource,
     722                 :            :     const Reference< lang::XMultiServiceFactory >& xServiceFactory,
     723                 :            :     const Sequence< uno::Any > & rFilterProperties )
     724                 :            : {
     725                 :         45 :     sal_Int32 nWarning = 0;
     726                 :            : 
     727                 :            :     try
     728                 :            :     {
     729         [ -  + ]:         45 :         if( !xServiceFactory.is() )
     730                 :          0 :             return ERRCODE_SFX_GENERAL;
     731         [ -  + ]:         45 :         if( !xStorage.is() )
     732                 :          0 :             return ERRCODE_SFX_GENERAL;
     733         [ -  + ]:         45 :         if ( !xActiveDataSource.is() )
     734                 :          0 :             return ERRCODE_SFX_GENERAL;
     735                 :            : 
     736         [ +  - ]:         45 :         uno::Reference< io::XStream > xStream( xStorage->openStreamElement(
     737         [ +  - ]:         45 :             rStreamName, embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE ) );
     738         [ -  + ]:         45 :         if ( !xStream.is() )
     739                 :          0 :             return ERRCODE_SFX_GENERAL;
     740 [ +  - ][ +  - ]:         45 :         uno::Reference< io::XOutputStream > xOutputStream( xStream->getOutputStream() );
     741         [ -  + ]:         45 :         if ( !xOutputStream.is() )
     742                 :          0 :             return ERRCODE_SFX_GENERAL;
     743                 :            : 
     744         [ +  - ]:         45 :         uno::Reference< beans::XPropertySet > xStreamProp( xOutputStream, uno::UNO_QUERY );
     745         [ +  - ]:         45 :         if(xStreamProp.is()) try
     746                 :            :         {
     747 [ +  - ][ +  - ]:         45 :             xStreamProp->setPropertyValue( C2U("MediaType"), uno::makeAny( C2U("text/xml") ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     748 [ +  - ][ +  - ]:         45 :             xStreamProp->setPropertyValue( C2U("Compressed"), uno::makeAny( sal_True ) );//@todo?
         [ +  - ][ +  - ]
     749 [ +  - ][ +  - ]:         45 :             xStreamProp->setPropertyValue( C2U("UseCommonStoragePasswordEncryption"), uno::makeAny( sal_True ) );
         [ +  - ][ #  # ]
                 [ +  - ]
     750                 :            :         }
     751         [ #  # ]:          0 :         catch (const uno::Exception& rEx)
     752                 :            :         {
     753                 :            :             ASSERT_EXCEPTION( rEx );
     754                 :            :         }
     755                 :            : 
     756 [ +  - ][ +  - ]:         45 :         xActiveDataSource->setOutputStream(xOutputStream);
     757                 :            : 
     758                 :            :         // set Base URL
     759                 :            :         {
     760                 :         45 :             uno::Reference< beans::XPropertySet > xInfoSet;
     761         [ +  - ]:         45 :             if( rFilterProperties.getLength() > 0 )
     762         [ +  - ]:         45 :                 rFilterProperties.getConstArray()[0] >>= xInfoSet;
     763                 :            :             OSL_ENSURE( xInfoSet.is(), "missing infoset for export" );
     764         [ +  - ]:         45 :             if( xInfoSet.is() )
     765 [ +  - ][ +  - ]:         45 :                 xInfoSet->setPropertyValue( C2U("StreamName"), uno::makeAny( rStreamName ) );
         [ +  - ][ +  - ]
     766                 :            :         }
     767                 :            : 
     768         [ +  - ]:         45 :         Reference< XExporter > xExporter( xServiceFactory->createInstanceWithArguments(
     769 [ +  - ][ +  - ]:         45 :             rServiceName, rFilterProperties ), uno::UNO_QUERY);
     770         [ +  + ]:         45 :         if ( !xExporter.is() )
     771                 :         18 :             return ERRCODE_SFX_GENERAL;
     772                 :            : 
     773 [ +  - ][ +  - ]:         27 :         xExporter->setSourceDocument( m_xSourceDoc );
     774                 :            : 
     775         [ +  - ]:         27 :         uno::Reference< document::XFilter > xFilter( xExporter, uno::UNO_QUERY );
     776         [ -  + ]:         27 :         if ( !xFilter.is() )
     777                 :          0 :             return ERRCODE_SFX_GENERAL;
     778                 :            : 
     779         [ +  - ]:         27 :         uno::Sequence < beans::PropertyValue > aMediaDesc(0);
     780                 :            :         //@todo? filter properties? ... url? ...
     781 [ +  - ][ +  - ]:         45 :         xFilter->filter( aMediaDesc );
         [ +  - ][ -  + ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
                 [ #  # ]
     782                 :            :     }
     783                 :          0 :     catch (const uno::Exception& rEx)
     784                 :            :     {
     785                 :            :         ASSERT_EXCEPTION( rEx );
     786                 :            :     }
     787                 :         45 :     return nWarning;
     788                 :            : }
     789                 :            : 
     790                 :            : // --------------------------------------------------------------------------------
     791                 :            : 
     792                 :         10 : Sequence< OUString > XMLFilter::getSupportedServiceNames_Static()
     793                 :            : {
     794                 :         10 :     Sequence< OUString > aServices( 2 );
     795 [ +  - ][ +  - ]:         10 :     aServices[ 0 ] = C2U( "com.sun.star.document.ImportFilter" );
     796 [ +  - ][ +  - ]:         10 :     aServices[ 1 ] = C2U( "com.sun.star.document.ExportFilter" );
     797                 :            : 
     798                 :            :     // todo: services are incomplete.  Missing:
     799                 :            :     // XInitialization, XNamed
     800                 :         10 :     return aServices;
     801                 :            : }
     802                 :            : // -----------------------------------------------------------------------------
     803                 :            : 
     804                 :         21 : void XMLFilter::isOasisFormat(const Sequence< beans::PropertyValue >& _rMediaDescriptor, bool & rOutOASIS )
     805                 :            : {
     806         [ +  - ]:         21 :     apphelper::MediaDescriptorHelper aMDHelper( _rMediaDescriptor );
     807         [ +  - ]:         21 :     if( aMDHelper.ISSET_FilterName )
     808         [ +  - ]:         21 :         rOutOASIS = aMDHelper.FilterName == "chart8";
     809                 :         21 : }
     810                 :            : // -----------------------------------------------------------------------------
     811                 :         15 : ::rtl::OUString XMLFilter::getMediaType(bool _bOasis)
     812                 :            : {
     813         [ +  - ]:         15 :     return _bOasis ? MIMETYPE_OASIS_OPENDOCUMENT_CHART : MIMETYPE_VND_SUN_XML_CHART;
     814                 :            : }
     815                 :            : // -----------------------------------------------------------------------------
     816                 :            : 
     817 [ #  # ][ #  # ]:        173 : APPHELPER_XSERVICEINFO_IMPL( XMLFilter, C2U( "com.sun.star.comp.chart2.XMLFilter" ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     818                 :            : // -----------------------------------------------------------------------------
     819                 :            : 
     820                 :          0 : void XMLReportFilterHelper::isOasisFormat(const Sequence< beans::PropertyValue >& _rMediaDescriptor, bool & rOutOASIS )
     821                 :            : {
     822         [ #  # ]:          0 :     apphelper::MediaDescriptorHelper aMDHelper( _rMediaDescriptor );
     823         [ #  # ]:          0 :     if( aMDHelper.ISSET_FilterName )
     824         [ #  # ]:          0 :         rOutOASIS = aMDHelper.FilterName == "StarOffice XML (Base) Report Chart";
     825                 :          0 : }
     826                 :            : // -----------------------------------------------------------------------------
     827                 :          0 : ::rtl::OUString XMLReportFilterHelper::getMediaType(bool )
     828                 :            : {
     829                 :          0 :     return MIMETYPE_OASIS_OPENDOCUMENT_REPORT_CHART;
     830                 :            : }
     831                 :            : 
     832                 :            : } //  namespace chart
     833                 :            : 
     834                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10