LCOV - code coverage report
Current view: top level - sd/source/filter/xml - sdxmlwrp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 324 426 76.1 %
Date: 2012-08-25 Functions: 9 10 90.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 396 986 40.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <rtl/logfile.hxx>
      30                 :            : #include <rtl/strbuf.hxx>
      31                 :            : #include <com/sun/star/container/XChild.hpp>
      32                 :            : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      33                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      34                 :            : #include <com/sun/star/xml/sax/SAXParseException.hpp>
      35                 :            : #include <comphelper/processfactory.hxx>
      36                 :            : #include <sfx2/docfile.hxx>
      37                 :            : #include <sfx2/docfilt.hxx>
      38                 :            : #include "drawdoc.hxx"
      39                 :            : #include <unotools/streamwrap.hxx>
      40                 :            : #include <svx/xmlgrhlp.hxx>
      41                 :            : 
      42                 :            : #include "../../ui/inc/DrawDocShell.hxx"
      43                 :            : 
      44                 :            : #include "sdxmlwrp.hxx"
      45                 :            : #include "strmname.h"
      46                 :            : #include <svx/xmleohlp.hxx>
      47                 :            : #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
      48                 :            : #include <com/sun/star/document/XFilter.hpp>
      49                 :            : #include <com/sun/star/document/XImporter.hpp>
      50                 :            : #include <com/sun/star/document/XExporter.hpp>
      51                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      52                 :            : #include <com/sun/star/document/XGraphicObjectResolver.hpp>
      53                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      54                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      55                 :            : #include <com/sun/star/packages/zip/ZipIOException.hpp>
      56                 :            : 
      57                 :            : #include <com/sun/star/xml/sax/XErrorHandler.hpp>
      58                 :            : #include <com/sun/star/xml/sax/XEntityResolver.hpp>
      59                 :            : #include <com/sun/star/xml/sax/InputSource.hpp>
      60                 :            : #include <com/sun/star/xml/sax/XDTDHandler.hpp>
      61                 :            : #include <com/sun/star/xml/sax/XParser.hpp>
      62                 :            : #include <com/sun/star/io/XActiveDataSource.hpp>
      63                 :            : #include <com/sun/star/io/XActiveDataControl.hpp>
      64                 :            : #include <comphelper/genericpropertyset.hxx>
      65                 :            : #include <comphelper/propertysetinfo.hxx>
      66                 :            : #include <unotools/saveopt.hxx>
      67                 :            : 
      68                 :            : // include necessary for XML progress bar at load time
      69                 :            : #include <svl/itemset.hxx>
      70                 :            : #include <svl/stritem.hxx>
      71                 :            : #include <svtools/sfxecode.hxx>
      72                 :            : 
      73                 :            : #include "sderror.hxx"
      74                 :            : #include "sdresid.hxx"
      75                 :            : #include "glob.hrc"
      76                 :            : 
      77                 :            : #include <sfx2/frame.hxx>
      78                 :            : 
      79                 :            : using rtl::OUString;
      80                 :            : using namespace com::sun::star;
      81                 :            : using namespace com::sun::star::uno;
      82                 :            : using namespace com::sun::star::lang;
      83                 :            : using namespace com::sun::star::document;
      84                 :            : using namespace comphelper;
      85                 :            : 
      86                 :            : #define SD_XML_READERROR 1234
      87                 :            : 
      88                 :            : extern void TransformOOo2xDocument( SdDrawDocument* pDocument );
      89                 :            : 
      90                 :            : //////////////////////////////////////////////////////////////////////////////
      91                 :            : 
      92                 :            : #ifndef SEQTYPE
      93                 :            :  #if defined(__SUNPRO_CC) && (__SUNPRO_CC == 0x500)
      94                 :            :   #define SEQTYPE(x) (new ::com::sun::star::uno::Type( x ))
      95                 :            :  #else
      96                 :            :   #define SEQTYPE(x) &(x)
      97                 :            :  #endif
      98                 :            : #endif
      99                 :            : 
     100                 :            : #define MAP_LEN(x) x, sizeof(x) - 1
     101                 :            : 
     102                 :            : #define XML_STRING(i, x) sal_Char const i[sizeof(x)] = x
     103                 :            : 
     104                 :            : XML_STRING( sXML_metaStreamName, "meta.xml");
     105                 :            : XML_STRING( sXML_styleStreamName, "styles.xml" );
     106                 :            : XML_STRING( sXML_contentStreamName, "content.xml" );
     107                 :            : XML_STRING( sXML_oldContentStreamName, "Content.xml" );
     108                 :            : XML_STRING( sXML_settingsStreamName, "settings.xml" );
     109                 :            : 
     110                 :            : XML_STRING( sXML_export_impress_oasis_service, "com.sun.star.comp.Impress.XMLOasisExporter" );
     111                 :            : XML_STRING( sXML_export_impress_meta_oasis_service, "com.sun.star.comp.Impress.XMLOasisMetaExporter" );
     112                 :            : XML_STRING( sXML_export_impress_styles_oasis_service, "com.sun.star.comp.Impress.XMLOasisStylesExporter" );
     113                 :            : XML_STRING( sXML_export_impress_content_oasis_service, "com.sun.star.comp.Impress.XMLOasisContentExporter" );
     114                 :            : XML_STRING( sXML_export_impress_settings_oasis_service, "com.sun.star.comp.Impress.XMLOasisSettingsExporter" );
     115                 :            : 
     116                 :            : XML_STRING( sXML_export_draw_oasis_service, "com.sun.star.comp.Draw.XMLOasisExporter" );
     117                 :            : XML_STRING( sXML_export_draw_meta_oasis_service, "com.sun.star.comp.Draw.XMLOasisMetaExporter" );
     118                 :            : XML_STRING( sXML_export_draw_styles_oasis_service, "com.sun.star.comp.Draw.XMLOasisStylesExporter" );
     119                 :            : XML_STRING( sXML_export_draw_content_oasis_service, "com.sun.star.comp.Draw.XMLOasisContentExporter" );
     120                 :            : XML_STRING( sXML_export_draw_settings_oasis_service, "com.sun.star.comp.Draw.XMLOasisSettingsExporter" );
     121                 :            : 
     122                 :            : XML_STRING( sXML_import_impress_oasis_service, "com.sun.star.comp.Impress.XMLOasisImporter" );
     123                 :            : XML_STRING( sXML_import_impress_meta_oasis_service, "com.sun.star.comp.Impress.XMLOasisMetaImporter" );
     124                 :            : XML_STRING( sXML_import_impress_styles_oasis_service, "com.sun.star.comp.Impress.XMLOasisStylesImporter" );
     125                 :            : XML_STRING( sXML_import_impress_content_oasis_service, "com.sun.star.comp.Impress.XMLOasisContentImporter" );
     126                 :            : XML_STRING( sXML_import_impress_settings_oasis_service, "com.sun.star.comp.Impress.XMLOasisSettingsImporter" );
     127                 :            : 
     128                 :            : XML_STRING( sXML_import_draw_oasis_service, "com.sun.star.comp.Draw.XMLOasisImporter" );
     129                 :            : XML_STRING( sXML_import_draw_meta_oasis_service, "com.sun.star.comp.Draw.XMLOasisMetaImporter" );
     130                 :            : XML_STRING( sXML_import_draw_styles_oasis_service, "com.sun.star.comp.Draw.XMLOasisStylesImporter" );
     131                 :            : XML_STRING( sXML_import_draw_content_oasis_service, "com.sun.star.comp.Draw.XMLOasisContentImporter" );
     132                 :            : XML_STRING( sXML_import_draw_settings_oasis_service, "com.sun.star.comp.Draw.XMLOasisSettingsImporter" );
     133                 :            : 
     134                 :            : // OOo
     135                 :            : XML_STRING( sXML_export_impress_ooo_service, "com.sun.star.comp.Impress.XMLExporter" );
     136                 :            : XML_STRING( sXML_export_impress_meta_ooo_service, "com.sun.star.comp.Impress.XMLMetaExporter" );
     137                 :            : XML_STRING( sXML_export_impress_styles_ooo_service, "com.sun.star.comp.Impress.XMLStylesExporter" );
     138                 :            : XML_STRING( sXML_export_impress_content_ooo_service, "com.sun.star.comp.Impress.XMLContentExporter" );
     139                 :            : XML_STRING( sXML_export_impress_settings_ooo_service, "com.sun.star.comp.Impress.XMLSettingsExporter" );
     140                 :            : 
     141                 :            : XML_STRING( sXML_export_draw_ooo_service, "com.sun.star.comp.Draw.XMLExporter" );
     142                 :            : XML_STRING( sXML_export_draw_meta_ooo_service, "com.sun.star.comp.Draw.XMLMetaExporter" );
     143                 :            : XML_STRING( sXML_export_draw_styles_ooo_service, "com.sun.star.comp.Draw.XMLStylesExporter" );
     144                 :            : XML_STRING( sXML_export_draw_content_ooo_service, "com.sun.star.comp.Draw.XMLContentExporter" );
     145                 :            : XML_STRING( sXML_export_draw_settings_ooo_service, "com.sun.star.comp.Draw.XMLSettingsExporter" );
     146                 :            : 
     147                 :            : XML_STRING( sXML_import_impress_ooo_service, "com.sun.star.comp.Impress.XMLImporter" );
     148                 :            : XML_STRING( sXML_import_impress_meta_ooo_service, "com.sun.star.comp.Impress.XMLMetaImporter" );
     149                 :            : XML_STRING( sXML_import_impress_styles_ooo_service, "com.sun.star.comp.Impress.XMLStylesImporter" );
     150                 :            : XML_STRING( sXML_import_impress_content_ooo_service, "com.sun.star.comp.Impress.XMLContentImporter" );
     151                 :            : XML_STRING( sXML_import_impress_settings_ooo_service, "com.sun.star.comp.Impress.XMLSettingsImporter" );
     152                 :            : 
     153                 :            : XML_STRING( sXML_import_draw_ooo_service, "com.sun.star.comp.Draw.XMLImporter" );
     154                 :            : XML_STRING( sXML_import_draw_meta_ooo_service, "com.sun.star.comp.Draw.XMLMetaImporter" );
     155                 :            : XML_STRING( sXML_import_draw_styles_ooo_service, "com.sun.star.comp.Draw.XMLStylesImporter" );
     156                 :            : XML_STRING( sXML_import_draw_content_ooo_service, "com.sun.star.comp.Draw.XMLContentImporter" );
     157                 :            : XML_STRING( sXML_import_draw_settings_ooo_service, "com.sun.star.comp.Draw.XMLSettingsImporter" );
     158                 :            : 
     159                 :            : struct XML_SERVICEMAP
     160                 :            : {
     161                 :            :     const sal_Char* mpService;
     162                 :            :     const sal_Char* mpStream;
     163                 :            :     sal_Bool mbPlain;
     164                 :            : };
     165                 :            : 
     166                 :            : struct XML_SERVICES
     167                 :            : {
     168                 :            :     const sal_Char* mpAll;
     169                 :            :     const sal_Char* mpMeta;
     170                 :            :     const sal_Char* mpStyles;
     171                 :            :     const sal_Char* mpContent;
     172                 :            :     const sal_Char* mpSettings;
     173                 :            : };
     174                 :            : 
     175                 :         19 : XML_SERVICES* getServices( bool bImport, bool bDraw, sal_uLong nStoreVer )
     176                 :            : {
     177                 :            :     static XML_SERVICES gServices[] =
     178                 :            :     {
     179                 :            :         { sXML_export_impress_oasis_service, sXML_export_impress_meta_oasis_service, sXML_export_impress_styles_oasis_service, sXML_export_impress_content_oasis_service, sXML_export_impress_settings_oasis_service },
     180                 :            :         { sXML_export_draw_oasis_service, sXML_export_draw_meta_oasis_service, sXML_export_draw_styles_oasis_service, sXML_export_draw_content_oasis_service, sXML_export_draw_settings_oasis_service },
     181                 :            :         { sXML_import_impress_oasis_service, sXML_import_impress_meta_oasis_service, sXML_import_impress_styles_oasis_service, sXML_import_impress_content_oasis_service, sXML_import_impress_settings_oasis_service },
     182                 :            :         { sXML_import_draw_oasis_service, sXML_import_draw_meta_oasis_service, sXML_import_draw_styles_oasis_service, sXML_import_draw_content_oasis_service, sXML_import_draw_settings_oasis_service },
     183                 :            : 
     184                 :            :         { sXML_export_impress_ooo_service, sXML_export_impress_meta_ooo_service, sXML_export_impress_styles_ooo_service, sXML_export_impress_content_ooo_service, sXML_export_impress_settings_ooo_service },
     185                 :            :         { sXML_export_draw_ooo_service, sXML_export_draw_meta_ooo_service, sXML_export_draw_styles_ooo_service, sXML_export_draw_content_ooo_service, sXML_export_draw_settings_ooo_service },
     186                 :            :         { sXML_import_impress_ooo_service, sXML_import_impress_meta_ooo_service, sXML_import_impress_styles_ooo_service, sXML_import_impress_content_ooo_service, sXML_import_impress_settings_ooo_service },
     187                 :            :         { sXML_import_draw_ooo_service, sXML_import_draw_meta_ooo_service, sXML_import_draw_styles_ooo_service, sXML_import_draw_content_ooo_service, sXML_import_draw_settings_ooo_service },
     188                 :            :     };
     189                 :            : 
     190 [ +  + ][ +  + ]:         19 :     return &gServices[ (bImport ? 2 : 0) + ((nStoreVer == SOFFICE_FILEFORMAT_60) ? 4 : 0) + (bDraw ? 1 : 0 ) ];
                 [ +  + ]
     191                 :            : }
     192                 :            : 
     193                 :            : 
     194                 :            : // ----------------
     195                 :            : // - SdXMLWrapper -
     196                 :            : // ----------------
     197                 :            : 
     198                 :         19 : SdXMLFilter::SdXMLFilter( SfxMedium& rMedium, ::sd::DrawDocShell& rDocShell, sal_Bool bShowProgress, SdXMLFilterMode eFilterMode, sal_uLong nStoreVer ) :
     199                 :         19 :     SdFilter( rMedium, rDocShell, bShowProgress ), meFilterMode( eFilterMode ), mnStoreVer( nStoreVer )
     200                 :            : {
     201                 :         19 : }
     202                 :            : 
     203                 :         19 : SdXMLFilter::~SdXMLFilter(void)
     204                 :            : {
     205         [ -  + ]:         19 : }
     206                 :            : 
     207                 :         44 : sal_Int32 ReadThroughComponent(
     208                 :            :     Reference<io::XInputStream> xInputStream,
     209                 :            :     Reference<XComponent> xModelComponent,
     210                 :            :     const String& rStreamName,
     211                 :            :     Reference<lang::XMultiServiceFactory> & rFactory,
     212                 :            :     const sal_Char* pFilterName,
     213                 :            :     Sequence<Any> rFilterArguments,
     214                 :            :     const OUString& rName,
     215                 :            :     sal_Bool bMustBeSuccessfull,
     216                 :            :     sal_Bool bEncrypted )
     217                 :            : {
     218                 :            :     DBG_ASSERT(xInputStream.is(), "input stream missing");
     219                 :            :     DBG_ASSERT(xModelComponent.is(), "document missing");
     220                 :            :     DBG_ASSERT(rFactory.is(), "factory missing");
     221                 :            :     DBG_ASSERT(NULL != pFilterName,"I need a service name for the component!");
     222                 :            : 
     223                 :            :     RTL_LOGFILE_CONTEXT( aLog, "ReadThroughComponent" );
     224                 :            : 
     225                 :            :     // prepare ParserInputSrouce
     226         [ +  - ]:         44 :     xml::sax::InputSource aParserInput;
     227                 :         44 :     aParserInput.sSystemId = rName;
     228         [ +  - ]:         44 :     aParserInput.aInputStream = xInputStream;
     229                 :            : 
     230                 :            :     // get parser
     231                 :            :     Reference< xml::sax::XParser > xParser(
     232         [ +  - ]:         44 :         rFactory->createInstance("com.sun.star.xml.sax.Parser" ),
     233 [ +  - ][ +  - ]:         44 :         UNO_QUERY );
     234                 :            :     DBG_ASSERT( xParser.is(), "Can't create parser" );
     235         [ -  + ]:         44 :     if( !xParser.is() )
     236                 :          0 :         return SD_XML_READERROR;
     237                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "parser created" );
     238                 :            : 
     239                 :            :     // get filter
     240                 :            :     Reference< xml::sax::XDocumentHandler > xFilter(
     241         [ +  - ]:         44 :         rFactory->createInstanceWithArguments(
     242                 :         44 :             OUString::createFromAscii(pFilterName), rFilterArguments),
     243 [ +  - ][ +  - ]:         44 :         UNO_QUERY );
     244                 :            :     DBG_ASSERT( xFilter.is(), "Can't instantiate filter component." );
     245         [ -  + ]:         44 :     if( !xFilter.is() )
     246                 :          0 :         return SD_XML_READERROR;
     247                 :            :     RTL_LOGFILE_CONTEXT_TRACE1( aLog, "%s created", pFilterName );
     248                 :            : 
     249                 :            :     // connect parser and filter
     250 [ +  - ][ +  - ]:         44 :     xParser->setDocumentHandler( xFilter );
     251                 :            : 
     252                 :            :     // connect model and filter
     253         [ +  - ]:         44 :     Reference < XImporter > xImporter( xFilter, UNO_QUERY );
     254 [ +  - ][ +  - ]:         44 :     xImporter->setTargetDocument( xModelComponent );
     255                 :            :     // finally, parser the stream
     256                 :            :     RTL_LOGFILE_CONTEXT_TRACE( aLog, "parsing stream" );
     257                 :            :     try
     258                 :            :     {
     259 [ +  - ][ +  - ]:         44 :         xParser->parseStream( aParserInput );
     260                 :            :     }
     261         [ #  # ]:          0 :     catch (const xml::sax::SAXParseException& r)
     262                 :            :     {
     263                 :            :         // sax parser sends wrapped exceptions,
     264                 :            :         // try to find the original one
     265         [ #  # ]:          0 :         xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r);
     266                 :          0 :         sal_Bool bTryChild = sal_True;
     267                 :            : 
     268         [ #  # ]:          0 :         while( bTryChild )
     269                 :            :         {
     270         [ #  # ]:          0 :             xml::sax::SAXException aTmp;
     271   [ #  #  #  # ]:          0 :             if ( aSaxEx.WrappedException >>= aTmp )
     272         [ #  # ]:          0 :                 aSaxEx = aTmp;
     273                 :            :             else
     274                 :          0 :                 bTryChild = sal_False;
     275         [ #  # ]:          0 :         }
     276                 :            : 
     277         [ #  # ]:          0 :         packages::zip::ZipIOException aBrokenPackage;
     278   [ #  #  #  # ]:          0 :         if ( aSaxEx.WrappedException >>= aBrokenPackage )
     279                 :          0 :             return ERRCODE_IO_BROKENPACKAGE;
     280                 :            : 
     281         [ #  # ]:          0 :         if( bEncrypted )
     282                 :          0 :             return ERRCODE_SFX_WRONGPASSWORD;
     283                 :            : 
     284                 :            : #if OSL_DEBUG_LEVEL > 1
     285                 :            :         rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM(
     286                 :            :             "SAX parse exception caught while importing:\n"));
     287                 :            :         aError.append(rtl::OUStringToOString(r.Message,
     288                 :            :             RTL_TEXTENCODING_ASCII_US));
     289                 :            :         OSL_FAIL(aError.getStr());
     290                 :            : #endif
     291                 :            : 
     292         [ #  # ]:          0 :         String sErr( String::CreateFromInt32( r.LineNumber ));
     293         [ #  # ]:          0 :         sErr += ',';
     294   [ #  #  #  #  :          0 :         sErr += String::CreateFromInt32( r.ColumnNumber );
                   #  # ]
     295                 :            : 
     296         [ #  # ]:          0 :         if( rStreamName.Len() )
     297                 :            :         {
     298                 :            :             return *new TwoStringErrorInfo(
     299                 :            :                             (bMustBeSuccessfull ? ERR_FORMAT_FILE_ROWCOL
     300                 :            :                                                     : WARN_FORMAT_FILE_ROWCOL),
     301                 :            :                             rStreamName, sErr,
     302   [ #  #  #  #  :          0 :                             ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
             #  #  #  # ]
     303                 :            :         }
     304                 :            :         else
     305                 :            :         {
     306                 :            :             DBG_ASSERT( bMustBeSuccessfull, "Warnings are not supported" );
     307                 :            :             return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
     308   [ #  #  #  #  :          0 :                              ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
                   #  # ]
     309   [ #  #  #  #  :          0 :         }
                   #  # ]
     310                 :            :     }
     311   [ #  #  #  #  :          0 :     catch (const xml::sax::SAXException& r)
             #  #  #  # ]
     312                 :            :     {
     313         [ #  # ]:          0 :         packages::zip::ZipIOException aBrokenPackage;
     314   [ #  #  #  # ]:          0 :         if ( r.WrappedException >>= aBrokenPackage )
     315                 :          0 :             return ERRCODE_IO_BROKENPACKAGE;
     316                 :            : 
     317         [ #  # ]:          0 :         if( bEncrypted )
     318                 :          0 :             return ERRCODE_SFX_WRONGPASSWORD;
     319                 :            : 
     320                 :            : #if OSL_DEBUG_LEVEL > 1
     321                 :            :         rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM(
     322                 :            :             "SAX exception caught while importing:\n"));
     323                 :            :         aError.append(rtl::OUStringToOString(r.Message,
     324                 :            :             RTL_TEXTENCODING_ASCII_US));
     325                 :            :         OSL_FAIL(aError.getStr());
     326                 :            : #endif
     327         [ #  # ]:          0 :         return SD_XML_READERROR;
     328                 :            :     }
     329         [ #  # ]:          0 :     catch (const packages::zip::ZipIOException& r)
     330                 :            :     {
     331                 :            : #if OSL_DEBUG_LEVEL > 1
     332                 :            :         rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM(
     333                 :            :             "Zip exception caught while importing:\n"));
     334                 :            :         aError.append(rtl::OUStringToOString(r.Message,
     335                 :            :             RTL_TEXTENCODING_ASCII_US));
     336                 :            :         OSL_FAIL(aError.getStr());
     337                 :            : #else
     338                 :            :         (void)r;
     339                 :            : #endif
     340                 :          0 :         return ERRCODE_IO_BROKENPACKAGE;
     341                 :            :     }
     342         [ #  # ]:          0 :     catch (const io::IOException& r)
     343                 :            :     {
     344                 :            : #if OSL_DEBUG_LEVEL > 1
     345                 :            :         rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM(
     346                 :            :             "IO exception caught while importing:\n"));
     347                 :            :         aError.append(rtl::OUStringToOString(r.Message,
     348                 :            :             RTL_TEXTENCODING_ASCII_US));
     349                 :            :         OSL_FAIL(aError.getStr());
     350                 :            : #else
     351                 :            :         (void)r;
     352                 :            : #endif
     353                 :          0 :         return SD_XML_READERROR;
     354                 :            :     }
     355         [ #  # ]:          0 :     catch (const uno::Exception& r)
     356                 :            :     {
     357                 :            : #if OSL_DEBUG_LEVEL > 1
     358                 :            :         rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM(
     359                 :            :             "uno exception caught while importing:\n"));
     360                 :            :         aError.append(rtl::OUStringToOString(r.Message,
     361                 :            :             RTL_TEXTENCODING_ASCII_US));
     362                 :            :         OSL_FAIL(aError.getStr());
     363                 :            : #else
     364                 :            :         (void)r;
     365                 :            : #endif
     366                 :          0 :         return SD_XML_READERROR;
     367                 :            :     }
     368                 :            : 
     369                 :            :     // success!
     370         [ +  - ]:         44 :     return 0;
     371                 :            : }
     372                 :            : 
     373                 :         44 : sal_Int32 ReadThroughComponent(
     374                 :            :     const uno::Reference < embed::XStorage >& xStorage,
     375                 :            :     Reference<XComponent> xModelComponent,
     376                 :            :     const sal_Char* pStreamName,
     377                 :            :     const sal_Char* pCompatibilityStreamName,
     378                 :            :     Reference<lang::XMultiServiceFactory> & rFactory,
     379                 :            :     const sal_Char* pFilterName,
     380                 :            :     Sequence<Any> rFilterArguments,
     381                 :            :     const OUString& rName,
     382                 :            :     sal_Bool bMustBeSuccessfull )
     383                 :            : {
     384                 :            :     DBG_ASSERT(xStorage.is(), "Need storage!");
     385                 :            :     DBG_ASSERT(NULL != pStreamName, "Please, please, give me a name!");
     386                 :            : 
     387                 :            :     // open stream (and set parser input)
     388                 :         44 :     OUString sStreamName = OUString::createFromAscii(pStreamName);
     389                 :         44 :     sal_Bool bContainsStream = sal_False;
     390                 :            :     try
     391                 :            :     {
     392 [ +  - ][ +  - ]:         44 :         bContainsStream = xStorage->isStreamElement(sStreamName);
     393                 :            :     }
     394   [ #  #  #  # ]:          0 :     catch (const container::NoSuchElementException&)
     395                 :            :     {
     396                 :            :     }
     397                 :            : 
     398         [ -  + ]:         44 :     if (!bContainsStream )
     399                 :            :     {
     400                 :            :         // stream name not found! Then try the compatibility name.
     401                 :            :         // if no stream can be opened, return immediatly with OK signal
     402                 :            : 
     403                 :            :         // do we even have an alternative name?
     404         [ #  # ]:          0 :         if ( NULL == pCompatibilityStreamName )
     405                 :          0 :             return 0;
     406                 :            : 
     407                 :            :         // if so, does the stream exist?
     408                 :          0 :         sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
     409                 :            :         try
     410                 :            :         {
     411 [ #  # ][ #  # ]:          0 :             bContainsStream = xStorage->isStreamElement(sStreamName);
     412                 :            :         }
     413         [ #  # ]:          0 :         catch (const container::NoSuchElementException&)
     414                 :            :         {
     415                 :            :         }
     416                 :            : 
     417         [ #  # ]:          0 :         if (! bContainsStream )
     418                 :          0 :             return 0;
     419                 :            :     }
     420                 :            : 
     421                 :            :     // set Base URL
     422                 :         44 :     uno::Reference< beans::XPropertySet > xInfoSet;
     423         [ +  - ]:         44 :     if( rFilterArguments.getLength() > 0 )
     424         [ +  - ]:         44 :         rFilterArguments.getConstArray()[0] >>= xInfoSet;
     425                 :            :     DBG_ASSERT( xInfoSet.is(), "missing property set" );
     426         [ +  - ]:         44 :     if( xInfoSet.is() )
     427                 :            :     {
     428                 :         44 :         OUString sPropName( "StreamName" );
     429 [ +  - ][ +  - ]:         44 :         xInfoSet->setPropertyValue( sPropName, makeAny( sStreamName ) );
                 [ +  - ]
     430                 :            :     }
     431                 :            : 
     432                 :            :     try
     433                 :            :     {
     434                 :            :         // get input stream
     435                 :            :         Reference <io::XStream> xStream =
     436 [ +  - ][ +  - ]:         44 :                 xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
     437         [ +  - ]:         44 :         Reference <beans::XPropertySet > xProps( xStream, uno::UNO_QUERY );
     438 [ +  - ][ -  + ]:         44 :         if ( !xStream.is() || ! xProps.is() )
                 [ -  + ]
     439                 :          0 :             return SD_XML_READERROR;
     440                 :            : 
     441 [ +  - ][ +  - ]:         44 :         Any aAny = xProps->getPropertyValue( "Encrypted" );
     442                 :            : 
     443         [ +  - ]:         44 :         sal_Bool bEncrypted = aAny.getValueType() == ::getBooleanCppuType() &&
     444 [ -  + ][ +  - ]:         44 :                 *(sal_Bool *)aAny.getValue();
     445                 :            : 
     446 [ +  - ][ +  - ]:         44 :         Reference <io::XInputStream> xInputStream = xStream->getInputStream();
     447                 :            : 
     448                 :            :         // read from the stream
     449                 :            :         return ReadThroughComponent(
     450                 :            :             xInputStream, xModelComponent, sStreamName, rFactory,
     451                 :            :             pFilterName, rFilterArguments,
     452 [ +  - ][ +  - ]:         44 :             rName, bMustBeSuccessfull, bEncrypted );
         [ +  - ][ +  - ]
                 [ +  - ]
           [ #  #  #  # ]
     453                 :            :     }
     454         [ #  # ]:          0 :     catch (const packages::WrongPasswordException&)
     455                 :            :     {
     456                 :          0 :         return ERRCODE_SFX_WRONGPASSWORD;
     457                 :            :     }
     458         [ #  # ]:          0 :     catch (const packages::zip::ZipIOException&)
     459                 :            :     {
     460                 :          0 :         return ERRCODE_IO_BROKENPACKAGE;
     461                 :            :     }
     462         [ #  # ]:          0 :     catch (const uno::Exception&)
     463                 :            :     {}
     464                 :            : 
     465         [ #  # ]:         44 :     return SD_XML_READERROR;
     466                 :            : }
     467                 :            : 
     468                 :            : // -----------------------------------------------------------------------------
     469                 :            : 
     470                 :         11 : sal_Bool SdXMLFilter::Import( ErrCode& nError )
     471                 :            : {
     472                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sd", "cl93746", "SdXMLFilter::Import" );
     473                 :            : #ifdef TIMELOG
     474                 :            :     rtl::OString aFile(rtl::OUStringToOString(mrMedium.GetName(), RTL_TEXTENCODING_ASCII_US));
     475                 :            :     RTL_LOGFILE_CONTEXT_TRACE1( aLog, "importing %s", aFile.getStr() );
     476                 :            : #endif
     477                 :            : 
     478                 :         11 :     sal_uInt32  nRet = 0;
     479                 :            : 
     480                 :            :     // Get service factory
     481                 :            :     Reference< lang::XMultiServiceFactory > xServiceFactory =
     482         [ +  - ]:         11 :             comphelper::getProcessServiceFactory();
     483                 :            :     DBG_ASSERT( xServiceFactory.is(),
     484                 :            :             "XMLReader::Read: got no service manager" );
     485         [ -  + ]:         11 :     if( !xServiceFactory.is() )
     486                 :          0 :         return sal_False;
     487                 :            : 
     488                 :            :     // -------------------------------------
     489                 :            : 
     490         [ +  - ]:         11 :     SdDrawDocument* pDoc = mrDocShell.GetDoc();
     491         [ +  - ]:         11 :     pDoc->EnableUndo(false);
     492         [ +  - ]:         11 :     pDoc->NewOrLoadCompleted( NEW_DOC );
     493         [ +  - ]:         11 :     pDoc->CreateFirstPages();
     494         [ +  - ]:         11 :     pDoc->StopWorkStartupDelay();
     495                 :            : 
     496                 :            :     // -------------------------------------
     497                 :            : 
     498 [ +  - ][ +  - ]:         11 :     mxModel->lockControllers();
     499                 :            : 
     500                 :            :     // -------------------------------------
     501                 :            : 
     502                 :            :     /** property map for import info set */
     503                 :            :     PropertyMapEntry aImportInfoMap[] =
     504                 :            :     {
     505                 :            :         // necessary properties for XML progress bar at load time
     506         [ +  - ]:         11 :         { MAP_LEN( "ProgressRange" ),   0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     507         [ +  - ]:         11 :         { MAP_LEN( "ProgressMax" ),     0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     508         [ +  - ]:         11 :         { MAP_LEN( "ProgressCurrent" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     509         [ +  - ]:         11 :         { MAP_LEN( "Preview" ),         0, &::getCppuType((const sal_Bool*)0),  ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     510         [ +  - ]:         11 :         { MAP_LEN( "PageLayouts" ), 0, SEQTYPE(::getCppuType((const uno::Reference< container::XNameAccess >*)0)),  ::com::sun::star::beans::PropertyAttribute::MAYBEVOID,     0},
     511                 :            :         { MAP_LEN( "PrivateData" ), 0,
     512         [ +  - ]:         11 :               &::getCppuType( (Reference<XInterface> *)0 ),
     513                 :            :               ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     514                 :            :         { MAP_LEN( "BaseURI" ), 0,
     515         [ +  - ]:         11 :               &::getCppuType( (OUString *)0 ),
     516                 :            :               ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     517                 :            :         { MAP_LEN( "StreamRelPath" ), 0,
     518         [ +  - ]:         11 :               &::getCppuType( (OUString *)0 ),
     519                 :            :               ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     520                 :            :         { MAP_LEN( "StreamName" ), 0,
     521         [ +  - ]:         11 :               &::getCppuType( (OUString *)0 ),
     522                 :            :               ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     523                 :            :         { MAP_LEN( "BuildId" ), 0,
     524         [ +  - ]:         11 :               &::getCppuType( (OUString *)0 ),
     525                 :            :               ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     526                 :            :         { MAP_LEN( "OrganizerMode" ), 0,
     527         [ +  - ]:         11 :               &::getBooleanCppuType(),
     528                 :            :               ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     529         [ +  - ]:         11 :         { MAP_LEN( "SourceStorage" ), 0, &embed::XStorage::static_type(),
     530                 :            :           ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     531                 :            :         { NULL, 0, 0, NULL, 0, 0 }
     532                 :        143 :     };
     533                 :            : 
     534         [ +  - ]:         11 :     uno::Reference< beans::XPropertySet > xInfoSet( GenericPropertySet_CreateInstance( new PropertySetInfo( aImportInfoMap ) ) );
     535 [ +  - ][ +  - ]:         11 :     xInfoSet->setPropertyValue( "Preview" , uno::makeAny( mrDocShell.GetDoc()->IsStarDrawPreviewMode() ) );
         [ +  - ][ +  - ]
     536                 :            : 
     537                 :            :     // ---- get BuildId from parent container if available
     538                 :            : 
     539         [ +  - ]:         11 :     uno::Reference< container::XChild > xChild( mxModel, uno::UNO_QUERY );
     540         [ +  - ]:         11 :     if( xChild.is() )
     541                 :            :     {
     542 [ +  - ][ +  - ]:         11 :         uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
                 [ +  - ]
     543         [ -  + ]:         11 :         if( xParentSet.is() )
     544                 :            :         {
     545 [ #  # ][ #  # ]:          0 :             uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
     546                 :          0 :             OUString sPropName( "BuildId" );
     547 [ #  # ][ #  # ]:          0 :             if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(sPropName) )
         [ #  # ][ #  # ]
                 [ #  # ]
     548                 :            :             {
     549 [ #  # ][ #  # ]:          0 :                 xInfoSet->setPropertyValue( sPropName, xParentSet->getPropertyValue(sPropName) );
         [ #  # ][ #  # ]
     550                 :          0 :             }
     551                 :         11 :         }
     552                 :            :     }
     553                 :            : 
     554                 :            :     // -------------------------------------
     555                 :            : 
     556                 :         11 :     Reference< io::XActiveDataSource > xSource;
     557                 :         11 :     Reference< XInterface > xPipe;
     558                 :         11 :     Reference< document::XGraphicObjectResolver > xGraphicResolver;
     559                 :         11 :     SvXMLGraphicHelper *pGraphicHelper = 0;
     560                 :         11 :     Reference< document::XEmbeddedObjectResolver > xObjectResolver;
     561                 :         11 :     SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
     562                 :            : 
     563         [ +  - ]:         11 :     Reference< lang::XComponent > xModelComp( mxModel, uno::UNO_QUERY );
     564                 :            : 
     565                 :            :     // -------------------------------------
     566                 :            : 
     567                 :            :     // try to get an XStatusIndicator from the Medium
     568         [ +  - ]:         11 :     if( mbShowProgress )
     569                 :            :     {
     570         [ +  - ]:         11 :         SfxItemSet* pSet = mrMedium.GetItemSet();
     571         [ +  - ]:         11 :         if(pSet)
     572                 :            :         {
     573                 :            :             const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
     574         [ +  - ]:         11 :                 pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
     575         [ +  + ]:         11 :             if (pItem)
     576                 :            :             {
     577         [ +  - ]:          8 :                 pItem->GetValue() >>= mxStatusIndicator;
     578                 :            :             }
     579                 :            :         }
     580                 :            : 
     581         [ +  + ]:         11 :         if(mxStatusIndicator.is())
     582                 :            :         {
     583                 :          8 :             sal_Int32 nProgressRange(1000000);
     584                 :          8 :             sal_Int32 nProgressCurrent(0);
     585 [ +  - ][ +  - ]:          8 :             OUString aMsg = String( SdResId( STR_LOAD_DOC ) );
         [ +  - ][ +  - ]
     586 [ +  - ][ +  - ]:          8 :             mxStatusIndicator->start(aMsg, nProgressRange);
     587                 :            : 
     588                 :            :             // set ProgressRange
     589                 :          8 :             uno::Any aProgRange;
     590         [ +  - ]:          8 :             aProgRange <<= nProgressRange;
     591 [ +  - ][ +  - ]:          8 :             xInfoSet->setPropertyValue( "ProgressRange" , aProgRange);
     592                 :            : 
     593                 :            :             // set ProgressCurrent
     594                 :          8 :             uno::Any aProgCurrent;
     595         [ +  - ]:          8 :             aProgCurrent <<= nProgressCurrent;
     596 [ +  - ][ +  - ]:          8 :             xInfoSet->setPropertyValue( "ProgressCurrent" , aProgCurrent);
     597                 :            :         }
     598                 :            :     }
     599                 :            : 
     600                 :            :     // -------------------------------------
     601                 :            :     // get the input stream (storage or stream)
     602                 :            :     // -------------------------------------
     603                 :            : 
     604                 :         11 :     SvStorageStreamRef xDocStream;
     605                 :         11 :     Reference<io::XInputStream> xInputStream;
     606         [ +  - ]:         11 :     uno::Reference < embed::XStorage > xStorage = mrMedium.GetStorage();
     607                 :            : 
     608                 :         11 :     OUString sSourceStorage( "SourceStorage");
     609 [ +  - ][ +  - ]:         11 :     xInfoSet->setPropertyValue( sSourceStorage, Any( xStorage ) );
                 [ +  - ]
     610                 :            : 
     611         [ -  + ]:         11 :     if( !xStorage.is() )
     612                 :          0 :         nRet = SD_XML_READERROR;
     613                 :            : 
     614         [ +  - ]:         11 :     if( 0 == nRet )
     615                 :            :     {
     616                 :            :         pGraphicHelper = SvXMLGraphicHelper::Create( xStorage,
     617                 :            :                                                      GRAPHICHELPER_MODE_READ,
     618         [ +  - ]:         11 :                                                      sal_False );
     619 [ +  - ][ +  - ]:         11 :         xGraphicResolver = pGraphicHelper;
     620                 :            :         pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
     621                 :         11 :                                     xStorage, *pDoc->GetPersist(),
     622                 :            :                                     EMBEDDEDOBJECTHELPER_MODE_READ,
     623         [ +  - ]:         11 :                                     sal_False );
     624 [ +  - ][ +  - ]:         11 :         xObjectResolver = pObjectHelper;
     625                 :            :     }
     626                 :            : 
     627                 :            :     // Set base URI
     628 [ +  - ][ +  - ]:         11 :     xInfoSet->setPropertyValue( "BaseURI" , makeAny( mrMedium.GetBaseURL() ) );
         [ +  - ][ +  - ]
     629                 :            : 
     630 [ +  + ][ +  + ]:         11 :     if( 0 == nRet && SFX_CREATE_MODE_EMBEDDED == mrDocShell.GetCreateMode() )
                 [ +  - ]
     631                 :            :     {
     632                 :          3 :         OUString aName;
     633 [ +  - ][ +  - ]:          3 :         if ( mrMedium.GetItemSet() )
     634                 :            :         {
     635                 :            :             const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
     636 [ +  - ][ +  - ]:          3 :                 mrMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
     637         [ -  + ]:          3 :             if ( pDocHierarchItem )
     638         [ #  # ]:          0 :                 aName = pDocHierarchItem->GetValue();
     639                 :            :         }
     640                 :            :         else
     641                 :          0 :             aName = "dummyObjectName" ;
     642                 :            : 
     643         [ -  + ]:          3 :         if( !aName.isEmpty() )
     644 [ #  # ][ #  # ]:          3 :             xInfoSet->setPropertyValue( "StreamRelPath", Any( aName ) );
                 [ #  # ]
     645                 :            :     }
     646                 :            : 
     647         [ -  + ]:         11 :     if (SDXMLMODE_Organizer == meFilterMode)
     648 [ #  # ][ #  # ]:          0 :         xInfoSet->setPropertyValue("OrganizerMode", uno::makeAny(sal_True));
                 [ #  # ]
     649                 :            : 
     650                 :            :     // -------------------------------------
     651                 :            : 
     652         [ +  - ]:         11 :     if( 0 == nRet )
     653                 :            :     {
     654                 :            : 
     655                 :            :         // prepare filter arguments
     656         [ +  - ]:         11 :         Sequence<Any> aFilterArgs( 4 );
     657         [ +  - ]:         11 :         Any *pArgs = aFilterArgs.getArray();
     658         [ +  - ]:         11 :         *pArgs++ <<= xInfoSet;
     659         [ +  - ]:         11 :         *pArgs++ <<= xGraphicResolver;
     660         [ +  - ]:         11 :         *pArgs++ <<= xObjectResolver;
     661         [ +  - ]:         11 :         *pArgs++ <<= mxStatusIndicator;
     662                 :            : 
     663         [ +  - ]:         11 :         Sequence<Any> aEmptyArgs( 2 );
     664         [ +  - ]:         11 :         pArgs = aEmptyArgs.getArray();
     665         [ +  - ]:         11 :         *pArgs++ <<= xInfoSet;
     666         [ +  - ]:         11 :         *pArgs++ <<= mxStatusIndicator;
     667                 :            : 
     668         [ +  - ]:         11 :         const OUString aName( mrMedium.GetName() );
     669                 :            : 
     670                 :         11 :         XML_SERVICES* pServices = getServices( true, IsDraw(), mnStoreVer );
     671                 :            : 
     672                 :         11 :         sal_uInt32 nWarn = 0;
     673                 :         11 :         sal_uInt32 nWarn2 = 0;
     674                 :            :         // read storage streams
     675                 :            :         // #i103539#: always read meta.xml for generator
     676                 :            :         nWarn = ReadThroughComponent(
     677                 :            :             xStorage, xModelComp, "meta.xml", "Meta.xml", xServiceFactory,
     678                 :            :             pServices->mpMeta,
     679 [ +  - ][ +  - ]:         11 :             aEmptyArgs, aName, sal_False );
                 [ +  - ]
     680                 :            : 
     681         [ +  - ]:         11 :         if( meFilterMode != SDXMLMODE_Organizer )
     682                 :            :         {
     683                 :            :             nWarn2 = ReadThroughComponent(
     684                 :            :                 xStorage, xModelComp, "settings.xml", NULL, xServiceFactory,
     685                 :            :                 pServices->mpSettings,
     686 [ +  - ][ +  - ]:         11 :                 aFilterArgs, aName, sal_False );
                 [ +  - ]
     687                 :            :         }
     688                 :            : 
     689                 :            :         nRet = ReadThroughComponent(
     690                 :            :             xStorage, xModelComp, "styles.xml", NULL, xServiceFactory,
     691                 :            :             pServices->mpStyles,
     692 [ +  - ][ +  - ]:         11 :             aFilterArgs, aName, sal_True );
                 [ +  - ]
     693                 :            : 
     694 [ +  - ][ +  - ]:         11 :         if( !nRet && (meFilterMode != SDXMLMODE_Organizer) )
     695                 :            :             nRet = ReadThroughComponent(
     696                 :            :                xStorage, xModelComp, "content.xml", "Content.xml", xServiceFactory,
     697                 :            :                pServices->mpContent,
     698 [ +  - ][ +  - ]:         11 :                aFilterArgs, aName, sal_True );
                 [ +  - ]
     699                 :            : 
     700         [ +  - ]:         11 :         if( !nRet )
     701                 :            :         {
     702         [ -  + ]:         11 :             if( nWarn )
     703                 :          0 :                 nRet = nWarn;
     704         [ -  + ]:         11 :             else if( nWarn2 )
     705                 :          0 :                 nRet = nWarn2;
     706 [ +  - ][ +  - ]:         11 :         }
     707                 :            :     }
     708                 :            : 
     709                 :            :     // -------------------------------------
     710         [ +  - ]:         11 :     if( pGraphicHelper )
     711         [ +  - ]:         11 :         SvXMLGraphicHelper::Destroy( pGraphicHelper );
     712         [ +  - ]:         11 :     xGraphicResolver = 0;
     713         [ +  - ]:         11 :     if( pObjectHelper )
     714         [ +  - ]:         11 :         SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
     715         [ +  - ]:         11 :     xObjectResolver = 0;
     716                 :            : 
     717         [ +  + ]:         11 :     if( mxStatusIndicator.is() )
     718 [ +  - ][ +  - ]:          8 :         mxStatusIndicator->end();
     719                 :            : 
     720         [ +  - ]:         11 :     if( mxModel.is() )
     721 [ +  - ][ +  - ]:         11 :         mxModel->unlockControllers();
     722                 :            : 
     723         [ +  - ]:         11 :     if( nRet == 0 )
     724         [ +  - ]:         11 :         pDoc->UpdateAllLinks();
     725                 :            : 
     726   [ +  -  -  - ]:         11 :     switch( nRet )
     727                 :            :     {
     728                 :         11 :     case 0: break;
     729                 :          0 :     case SD_XML_READERROR: break;
     730                 :            :     case ERRCODE_IO_BROKENPACKAGE:
     731         [ #  # ]:          0 :         if( xStorage.is() )
     732                 :            :         {
     733                 :          0 :             nError = ERRCODE_IO_BROKENPACKAGE;
     734                 :          0 :             break;
     735                 :            :         }
     736                 :            :         // fall through intented
     737                 :            :     default:
     738                 :            :         {
     739                 :            :             // TODO/LATER: this is completely wrong! Filter code should never call ErrorHandler directly!
     740         [ #  # ]:          0 :             ErrorHandler::HandleError( nRet );
     741         [ #  # ]:          0 :             if( IsWarning( nRet ) )
     742                 :          0 :                 nRet = 0;
     743                 :            :         }
     744                 :            :     }
     745                 :            : 
     746                 :            : 
     747                 :            :     // clear unused named items from item pool
     748                 :            : 
     749         [ +  - ]:         11 :     uno::Reference< lang::XMultiServiceFactory> xModelFactory( mxModel, uno::UNO_QUERY );
     750         [ +  - ]:         11 :     if( xModelFactory.is() )
     751                 :            :     {
     752                 :            :         try
     753                 :            :         {
     754                 :         11 :             const OUString aName("~clear~" );
     755 [ +  - ][ +  - ]:         11 :             uno::Reference< container::XNameContainer > xGradient( xModelFactory->createInstance( "com.sun.star.drawing.GradientTable" ), uno::UNO_QUERY );
                 [ +  - ]
     756         [ +  - ]:         11 :             if( xGradient.is() )
     757 [ +  - ][ +  - ]:         11 :                 xGradient->removeByName( aName );
     758                 :            : 
     759 [ +  - ][ +  - ]:         11 :             uno::Reference< container::XNameContainer > xHatch( xModelFactory->createInstance( "com.sun.star.drawing.HatchTable" ), uno::UNO_QUERY );
                 [ +  - ]
     760         [ +  - ]:         11 :             if( xHatch.is() )
     761 [ +  - ][ +  - ]:         11 :                 xHatch->removeByName( aName );
     762                 :            : 
     763 [ +  - ][ +  - ]:         11 :             uno::Reference< container::XNameContainer > xBitmap( xModelFactory->createInstance( "com.sun.star.drawing.BitmapTable" ), uno::UNO_QUERY );
                 [ +  - ]
     764         [ +  - ]:         11 :             if( xBitmap.is() )
     765 [ +  - ][ +  - ]:         11 :                 xBitmap->removeByName( aName );
     766                 :            : 
     767 [ +  - ][ +  - ]:         11 :             uno::Reference< container::XNameContainer > xTransGradient( xModelFactory->createInstance( "com.sun.star.drawing.TransparencyGradientTable" ), uno::UNO_QUERY );
                 [ +  - ]
     768         [ +  - ]:         11 :             if( xTransGradient.is() )
     769 [ +  - ][ +  - ]:         11 :                 xTransGradient->removeByName( aName );
     770                 :            : 
     771 [ +  - ][ +  - ]:         11 :             uno::Reference< container::XNameContainer > xMarker( xModelFactory->createInstance( "com.sun.star.drawing.MarkerTable" ), uno::UNO_QUERY );
                 [ +  - ]
     772         [ +  - ]:         11 :             if( xMarker.is() )
     773 [ +  - ][ +  - ]:         11 :                 xMarker->removeByName( aName );
     774                 :            : 
     775 [ +  - ][ +  - ]:         11 :             uno::Reference< container::XNameContainer > xDashes( xModelFactory->createInstance( "com.sun.star.drawing.DashTable" ), uno::UNO_QUERY );
                 [ +  - ]
     776         [ +  - ]:         11 :             if( xDashes.is() )
     777 [ +  - ][ +  - ]:         11 :                 xDashes->removeByName( aName );
                 [ #  # ]
     778                 :            :         }
     779         [ #  # ]:          0 :         catch (const Exception&)
     780                 :            :         {
     781                 :            :             OSL_FAIL("sd::SdXMLFilter::Import(), exception during clearing of unused named items");
     782                 :            :         }
     783                 :            :     }
     784                 :            : 
     785                 :            :     // set BuildId on XModel for later OLE object loading
     786         [ +  - ]:         11 :     if( xInfoSet.is() )
     787                 :            :     {
     788         [ +  - ]:         11 :         uno::Reference< beans::XPropertySet > xModelSet( mxModel, uno::UNO_QUERY );
     789         [ +  - ]:         11 :         if( xModelSet.is() )
     790                 :            :         {
     791 [ +  - ][ +  - ]:         11 :             uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
     792                 :         11 :             const OUString sPropName( "BuildId" );
     793                 :            : 
     794                 :         11 :             OUString sBuildId;
     795 [ +  - ][ +  - ]:         11 :             xInfoSet->getPropertyValue(sPropName) >>= sBuildId;
     796                 :            : 
     797 [ +  - ][ +  - ]:         11 :             if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sPropName) )
         [ +  - ][ +  - ]
                 [ +  - ]
     798                 :            :             {
     799 [ +  - ][ +  - ]:         11 :                 xModelSet->setPropertyValue( sPropName, Any( sBuildId ) );
                 [ +  - ]
     800                 :            :             }
     801                 :            : 
     802                 :         11 :             bool bTransform = false;
     803                 :            : 
     804         [ +  - ]:         11 :             if( nRet == 0 )
     805                 :            :             {
     806         [ +  + ]:         11 :                 if( !sBuildId.isEmpty() )
     807                 :            :                 {
     808                 :          3 :                     sal_Int32 nIndex = sBuildId.indexOf('$');
     809         [ +  - ]:          3 :                     if( nIndex != -1 )
     810                 :            :                     {
     811                 :          3 :                         sal_Int32 nUPD = sBuildId.copy( 0, nIndex ).toInt32();
     812                 :            : 
     813         [ -  + ]:          3 :                         if( nUPD == 300 )
     814                 :            :                         {
     815                 :          0 :                             sal_Int32 nBuildId = sBuildId.copy( nIndex+1 ).toInt32();
     816 [ #  # ][ #  # ]:          0 :                             if( (nBuildId > 0) && (nBuildId < 9316) )
     817                 :          0 :                                 bTransform = true; // treat OOo 3.0 beta1 as OOo 2.x
     818                 :            :                         }
     819 [ +  - ][ -  + ]:          3 :                         else if( (nUPD == 680) || ( nUPD >= 640 && nUPD <= 645 ) )
                 [ #  # ]
     820                 :          0 :                             bTransform = true;
     821                 :            :                     }
     822                 :            :                 }
     823                 :            :                 else
     824                 :            :                 {
     825                 :            :                     // check for binary formats
     826         [ +  - ]:          8 :                      const SfxFilter * pFilter = mrMedium.GetFilter();
     827         [ +  - ]:          8 :                     if( pFilter )
     828                 :            :                     {
     829                 :          8 :                         const String& rTypeName = pFilter->GetRealTypeName();
     830                 :            : 
     831 [ +  - ][ -  + ]:         16 :                         if( (rTypeName.CompareToAscii( RTL_CONSTASCII_STRINGPARAM("impress_StarImpress" ) ) == 0) ||
         [ -  + ][ +  - ]
     832         [ +  - ]:          8 :                             (rTypeName.CompareToAscii( RTL_CONSTASCII_STRINGPARAM("draw_StarDraw" ) ) == 0) )
     833                 :            :                         {
     834                 :          0 :                             bTransform = true;
     835                 :            :                         }
     836                 :            :                     }
     837                 :            :                 }
     838                 :            :             }
     839                 :            : 
     840         [ -  + ]:         11 :             if( bTransform )
     841         [ #  # ]:         11 :                 TransformOOo2xDocument( pDoc );
     842                 :         11 :         }
     843                 :            :     }
     844                 :            : 
     845         [ +  - ]:         11 :     pDoc->EnableUndo(true);
     846         [ +  - ]:         11 :     mrDocShell.ClearUndoBuffer();
     847         [ +  - ]:         11 :     return nRet == 0;
     848                 :            : }
     849                 :            : 
     850                 :            : // -----------------------------------------------------------------------------
     851                 :            : 
     852                 :          8 : sal_Bool SdXMLFilter::Export()
     853                 :            : {
     854                 :            : #ifdef TIMELOG
     855                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sd", "cl93746", "SdXMLFilter::Export" );
     856                 :            :     rtl::OString aFile(rtl::OUStringToOString(mrMedium.GetName(), RTL_TEXTENCODING_ASCII_US));
     857                 :            :     RTL_LOGFILE_CONTEXT_TRACE1( aLog, "exporting %s", aFile.getStr() );
     858                 :            : #endif
     859                 :            : 
     860                 :          8 :     SvXMLEmbeddedObjectHelper*  pObjectHelper = NULL;
     861                 :          8 :     SvXMLGraphicHelper*         pGraphicHelper = NULL;
     862                 :          8 :     sal_Bool                    bDocRet = sal_False;
     863                 :            : 
     864         [ -  + ]:          8 :     if( !mxModel.is() )
     865                 :            :     {
     866                 :            :         OSL_FAIL("Got NO Model in XMLExport");
     867                 :          0 :         return sal_False;
     868                 :            :     }
     869                 :            : 
     870                 :          8 :     sal_Bool bLocked = mxModel->hasControllersLocked();
     871                 :            : 
     872                 :            :     try
     873                 :            :     {
     874 [ +  - ][ +  - ]:          8 :         mxModel->lockControllers();
     875                 :            : 
     876         [ +  - ]:          8 :         uno::Reference< lang::XServiceInfo > xServiceInfo( mxModel, uno::UNO_QUERY );
     877                 :            : 
     878 [ +  - ][ +  - ]:          8 :         if( !xServiceInfo.is() || !xServiceInfo->supportsService( "com.sun.star.drawing.GenericDrawingDocument" ) )
         [ +  - ][ -  + ]
         [ +  - ][ +  - ]
           [ -  +  #  #  
                   #  # ]
     879                 :            :         {
     880                 :            :             OSL_FAIL( "Model is no DrawingDocument in XMLExport" );
     881                 :          0 :             return sal_False;
     882                 :            :         }
     883                 :            : 
     884         [ +  - ]:          8 :         uno::Reference< lang::XMultiServiceFactory> xServiceFactory( ::comphelper::getProcessServiceFactory() );
     885                 :            : 
     886         [ -  + ]:          8 :         if( !xServiceFactory.is() )
     887                 :            :         {
     888                 :            :             OSL_FAIL( "got no service manager" );
     889                 :          0 :             return sal_False;
     890                 :            :         }
     891                 :            : 
     892 [ +  - ][ +  - ]:          8 :         uno::Reference< uno::XInterface > xWriter( xServiceFactory->createInstance( "com.sun.star.xml.sax.Writer" ) );
     893                 :            : 
     894         [ -  + ]:          8 :         if( !xWriter.is() )
     895                 :            :         {
     896                 :            :             OSL_FAIL( "com.sun.star.xml.sax.Writer service missing" );
     897                 :          0 :             return sal_False;
     898                 :            :         }
     899         [ +  - ]:          8 :         uno::Reference<xml::sax::XDocumentHandler>  xHandler( xWriter, uno::UNO_QUERY );
     900                 :            : 
     901                 :            :         /** property map for export info set */
     902                 :            :         PropertyMapEntry aExportInfoMap[] =
     903                 :            :         {
     904         [ +  - ]:          8 :             { MAP_LEN( "ProgressRange" ),   0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     905         [ +  - ]:          8 :             { MAP_LEN( "ProgressMax" ),     0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     906         [ +  - ]:          8 :             { MAP_LEN( "ProgressCurrent" ), 0, &::getCppuType((const sal_Int32*)0), ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     907         [ +  - ]:          8 :             { MAP_LEN( "UsePrettyPrinting"),0, &::getBooleanCppuType(),             ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0},
     908                 :            : 
     909         [ +  - ]:          8 :             { MAP_LEN( "PageLayoutNames" ), 0, SEQTYPE(::getCppuType((const OUString*)0)),  ::com::sun::star::beans::PropertyAttribute::MAYBEVOID,     0},
     910                 :            :             { MAP_LEN( "BaseURI" ), 0,
     911         [ +  - ]:          8 :                   &::getCppuType( (OUString *)0 ),
     912                 :            :                   ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     913                 :            :             { MAP_LEN( "StreamRelPath" ), 0,
     914         [ +  - ]:          8 :                   &::getCppuType( (OUString *)0 ),
     915                 :            :                   ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     916                 :            :             { MAP_LEN( "StreamName" ), 0,
     917         [ +  - ]:          8 :                   &::getCppuType( (OUString *)0 ),
     918                 :            :                   ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     919                 :            :             { MAP_LEN( "StyleNames" ), 0,
     920         [ +  - ]:          8 :                   &::getCppuType( (Sequence<OUString>*)0 ),
     921                 :            :                   ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     922                 :            :             { MAP_LEN( "StyleFamilies" ), 0,
     923         [ +  - ]:          8 :                   &::getCppuType( (Sequence<sal_Int32>*)0 ),
     924                 :            :                   ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     925         [ +  - ]:          8 :             { MAP_LEN( "TargetStorage" ), 0, &embed::XStorage::static_type(),
     926                 :            :                   ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     927                 :            : 
     928                 :            :             { NULL, 0, 0, NULL, 0, 0 }
     929                 :         96 :         };
     930                 :            : 
     931         [ +  - ]:          8 :         uno::Reference< beans::XPropertySet > xInfoSet( GenericPropertySet_CreateInstance( new PropertySetInfo( aExportInfoMap ) ) );
     932                 :            : 
     933                 :            : 
     934         [ +  - ]:          8 :         SvtSaveOptions aSaveOpt;
     935                 :          8 :         OUString sUsePrettyPrinting("UsePrettyPrinting");
     936         [ +  - ]:          8 :         sal_Bool bUsePrettyPrinting( aSaveOpt.IsPrettyPrinting() );
     937 [ +  - ][ +  - ]:          8 :         xInfoSet->setPropertyValue( sUsePrettyPrinting, makeAny( bUsePrettyPrinting ) );
                 [ +  - ]
     938                 :            : 
     939         [ +  - ]:          8 :         const uno::Reference < embed::XStorage >& xStorage = mrMedium.GetOutputStorage();
     940                 :            : 
     941                 :            :         // Set base URI
     942                 :          8 :         OUString sPropName( "BaseURI" );
     943 [ +  - ][ +  - ]:          8 :         xInfoSet->setPropertyValue( sPropName, makeAny( mrMedium.GetBaseURL( true ) ) );
         [ +  - ][ +  - ]
     944                 :            : 
     945                 :          8 :         OUString sTargetStorage( "TargetStorage" );
     946 [ +  - ][ +  - ]:          8 :         xInfoSet->setPropertyValue( sTargetStorage, Any( xStorage ) );
                 [ +  - ]
     947                 :            : 
     948         [ -  + ]:          8 :         if( SFX_CREATE_MODE_EMBEDDED == mrDocShell.GetCreateMode() )
     949                 :            :         {
     950                 :          0 :             OUString aName;
     951 [ #  # ][ #  # ]:          0 :             if ( mrMedium.GetItemSet() )
     952                 :            :             {
     953                 :            :                 const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
     954 [ #  # ][ #  # ]:          0 :                     mrMedium.GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
     955         [ #  # ]:          0 :                 if ( pDocHierarchItem )
     956         [ #  # ]:          0 :                     aName = pDocHierarchItem->GetValue();
     957                 :            :             }
     958                 :            : 
     959         [ #  # ]:          0 :             if( !aName.isEmpty() )
     960                 :            :             {
     961                 :          0 :                 sPropName = OUString( "StreamRelPath" );
     962 [ #  # ][ #  # ]:          0 :                 xInfoSet->setPropertyValue( sPropName, makeAny( aName ) );
                 [ #  # ]
     963                 :          0 :             }
     964                 :            :         }
     965                 :            : 
     966                 :            :         // initialize descriptor
     967         [ +  - ]:          8 :         uno::Sequence< beans::PropertyValue > aDescriptor( 1 );
     968         [ +  - ]:          8 :         beans::PropertyValue* pProps = aDescriptor.getArray();
     969                 :            : 
     970                 :          8 :         pProps[0].Name = "FileName";
     971 [ +  - ][ +  - ]:          8 :         pProps[0].Value <<= OUString( mrMedium.GetName() );
     972                 :            : 
     973                 :            :         {
     974                 :          8 :             uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
     975                 :          8 :             uno::Reference< document::XGraphicObjectResolver >  xGrfResolver;
     976                 :            : 
     977                 :            :             // create helper for graphic and ole export if we have a storage
     978         [ +  - ]:          8 :             if( xStorage.is() )
     979                 :            :             {
     980 [ +  - ][ +  - ]:          8 :                 pObjectHelper = SvXMLEmbeddedObjectHelper::Create( xStorage, *mrDocShell.GetDoc()->GetPersist(), EMBEDDEDOBJECTHELPER_MODE_WRITE, sal_False );
     981 [ +  - ][ +  - ]:          8 :                 xObjectResolver = pObjectHelper;
     982                 :            : 
     983         [ +  - ]:          8 :                 pGraphicHelper = SvXMLGraphicHelper::Create( xStorage, GRAPHICHELPER_MODE_WRITE, sal_False );
     984 [ +  - ][ +  - ]:          8 :                 xGrfResolver = pGraphicHelper;
     985                 :            :             }
     986                 :            : 
     987         [ +  - ]:          8 :             if(mbShowProgress)
     988                 :            :             {
     989         [ +  - ]:          8 :                 CreateStatusIndicator();
     990         [ -  + ]:          8 :                 if(mxStatusIndicator.is())
     991                 :            :                 {
     992                 :          0 :                     sal_Int32 nProgressRange(1000000);
     993                 :          0 :                     sal_Int32 nProgressCurrent(0);
     994 [ #  # ][ #  # ]:          0 :                     OUString aMsg = String( SdResId( STR_SAVE_DOC ) );
         [ #  # ][ #  # ]
     995 [ #  # ][ #  # ]:          0 :                     mxStatusIndicator->start(aMsg, nProgressRange);
     996                 :            : 
     997                 :            :                     // set ProgressRange
     998                 :          0 :                     uno::Any aProgRange;
     999         [ #  # ]:          0 :                     aProgRange <<= nProgressRange;
    1000 [ #  # ][ #  # ]:          0 :                     xInfoSet->setPropertyValue( "ProgressRange" , aProgRange);
    1001                 :            : 
    1002                 :            :                     // set ProgressCurrent
    1003                 :          0 :                     uno::Any aProgCurrent;
    1004         [ #  # ]:          0 :                     aProgCurrent <<= nProgressCurrent;
    1005 [ #  # ][ #  # ]:          0 :                     xInfoSet->setPropertyValue( "ProgressCurrent" , aProgCurrent);
    1006                 :            :                 }
    1007                 :            :             }
    1008                 :            : 
    1009         [ +  - ]:          8 :             uno::Reference< lang::XComponent > xComponent( mxModel, uno::UNO_QUERY );
    1010                 :            : 
    1011                 :          8 :             XML_SERVICES* pServiceNames = getServices( false, IsDraw(), mnStoreVer );
    1012                 :            : 
    1013                 :          8 :             XML_SERVICEMAP aServices[5]; sal_uInt16 i = 0;
    1014                 :          8 :             aServices[i  ].mpService = pServiceNames->mpStyles;
    1015                 :          8 :             aServices[i  ].mpStream  = sXML_styleStreamName;
    1016                 :          8 :             aServices[i++].mbPlain = sal_False;
    1017                 :            : 
    1018                 :          8 :             aServices[i  ].mpService = pServiceNames->mpContent;
    1019                 :          8 :             aServices[i  ].mpStream  = sXML_contentStreamName;
    1020                 :          8 :             aServices[i++].mbPlain = sal_False;
    1021                 :            : 
    1022                 :          8 :             aServices[i  ].mpService = pServiceNames->mpSettings;
    1023                 :          8 :             aServices[i  ].mpStream  = sXML_settingsStreamName;
    1024                 :          8 :             aServices[i++].mbPlain = sal_False;
    1025                 :            : 
    1026         [ +  - ]:          8 :             if( mrDocShell.GetCreateMode() != SFX_CREATE_MODE_EMBEDDED )
    1027                 :            :             {
    1028                 :          8 :                 aServices[i  ].mpService = pServiceNames->mpMeta;
    1029                 :          8 :                 aServices[i  ].mpStream  = sXML_metaStreamName;
    1030                 :          8 :                 aServices[i++].mbPlain = sal_True;
    1031                 :            :             };
    1032                 :            : 
    1033                 :          8 :             aServices[i].mpService = NULL;
    1034                 :          8 :             aServices[i].mpStream  = NULL;
    1035                 :            : 
    1036                 :          8 :             XML_SERVICEMAP* pServices = aServices;
    1037                 :            : 
    1038                 :            :             // doc export
    1039 [ +  - ][ +  + ]:         32 :             do
                 [ +  + ]
    1040                 :            :             {
    1041                 :            :                 RTL_LOGFILE_CONTEXT_TRACE1( aLog, "exporting substream %s", pServices->mpStream );
    1042                 :            : 
    1043                 :         32 :                 uno::Reference<io::XOutputStream> xDocOut;
    1044         [ +  - ]:         32 :                 if( xStorage.is() )
    1045                 :            :                 {
    1046                 :         32 :                     const OUString sDocName( OUString::createFromAscii( pServices->mpStream ) );
    1047                 :            :                     uno::Reference<io::XStream> xStream =
    1048         [ +  - ]:         32 :                             xStorage->openStreamElement( sDocName,
    1049         [ +  - ]:         32 :                             embed::ElementModes::READWRITE | embed::ElementModes::TRUNCATE );
    1050                 :            : 
    1051                 :            :                     DBG_ASSERT(xStream.is(), "Can't create output stream in package!");
    1052         [ -  + ]:         32 :                     if( !xStream.is() )
    1053                 :          0 :                         return sal_False;
    1054                 :            : 
    1055 [ +  - ][ +  - ]:         32 :                     xDocOut = xStream->getOutputStream();
                 [ +  - ]
    1056         [ +  - ]:         32 :                     Reference <beans::XPropertySet > xProps( xStream, uno::UNO_QUERY );
    1057 [ +  - ][ -  + ]:         32 :                     if( !xDocOut.is() || !xProps.is() )
                 [ -  + ]
    1058                 :          0 :                         return sal_False;
    1059                 :            : 
    1060         [ +  - ]:         32 :                     uno::Any aAny; aAny <<= OUString( "text/xml");
    1061 [ +  - ][ +  - ]:         32 :                     xProps->setPropertyValue( "MediaType" , aAny);
    1062                 :            : 
    1063                 :         32 :                     OUString aUseCommonPassPropName( "UseCommonStoragePasswordEncryption");
    1064         [ +  + ]:         32 :                     if( pServices->mbPlain )
    1065 [ +  - ][ +  - ]:          8 :                         xProps->setPropertyValue( "Compressed" , uno::makeAny( (sal_Bool) sal_False ) );
                 [ +  - ]
    1066                 :            :                     // if the document is encrypted even the plain streams should be encrypted
    1067 [ +  - ][ +  - ]:         32 :                     xProps->setPropertyValue( aUseCommonPassPropName, uno::makeAny( (sal_Bool)sal_True ) );
                 [ +  - ]
    1068                 :            : 
    1069                 :         32 :                     const OUString sStreamName( "StreamName");
    1070 [ +  - ][ +  - ]:         32 :                     xInfoSet->setPropertyValue( sStreamName, Any( sDocName ) );
         [ -  + ][ -  + ]
         [ +  - ][ +  - ]
    1071                 :            :                 }
    1072                 :            : 
    1073         [ +  - ]:         32 :                 uno::Reference< io::XActiveDataSource > xDocSrc( xWriter, uno::UNO_QUERY );
    1074 [ +  - ][ +  - ]:         32 :                 xDocSrc->setOutputStream( xDocOut );
    1075                 :            : 
    1076 [ -  + ][ +  - ]:         32 :                 uno::Sequence< uno::Any > aArgs( 2 + ( mxStatusIndicator.is() ? 1 : 0 ) + ( xGrfResolver.is() ? 1 : 0 ) + ( xObjectResolver.is() ? 1 : 0 ) );
         [ +  - ][ +  - ]
    1077         [ +  - ]:         32 :                 uno::Any* pArgs = aArgs.getArray();
    1078         [ +  - ]:         32 :                 *pArgs++ <<= xInfoSet;
    1079 [ +  - ][ +  - ]:         32 :                 if( xGrfResolver.is() )         *pArgs++ <<= xGrfResolver;
    1080 [ +  - ][ +  - ]:         32 :                 if( xObjectResolver.is() )      *pArgs++ <<= xObjectResolver;
    1081 [ -  + ][ #  # ]:         32 :                 if( mxStatusIndicator.is() )    *pArgs++ <<= mxStatusIndicator;
    1082                 :            : 
    1083         [ +  - ]:         32 :                 *pArgs   <<= xHandler;
    1084                 :            : 
    1085 [ +  - ][ +  - ]:         32 :                 uno::Reference< document::XFilter > xFilter( xServiceFactory->createInstanceWithArguments( OUString::createFromAscii( pServices->mpService ), aArgs ), uno::UNO_QUERY );
                 [ +  - ]
    1086         [ +  - ]:         32 :                 if( xFilter.is() )
    1087                 :            :                 {
    1088         [ +  - ]:         32 :                     uno::Reference< document::XExporter > xExporter( xFilter, uno::UNO_QUERY );
    1089         [ +  - ]:         32 :                     if( xExporter.is() )
    1090                 :            :                     {
    1091 [ +  - ][ +  - ]:         32 :                         xExporter->setSourceDocument( xComponent );
    1092                 :            :                         // outputstream will be closed by SAX parser
    1093 [ +  - ][ +  - ]:         32 :                         bDocRet = xFilter->filter( aDescriptor );
    1094                 :         32 :                     }
    1095                 :            :                 }
    1096                 :            : 
    1097 [ +  - ][ +  - ]:         32 :                 pServices++;
    1098                 :            :             }
    1099                 :            :             while( bDocRet && pServices->mpService );
    1100                 :            : 
    1101         [ +  - ]:          8 :             if(mbShowProgress)
    1102                 :            :             {
    1103         [ -  + ]:          8 :                 if(mxStatusIndicator.is())
    1104 [ #  # ][ #  # ]:          8 :                     mxStatusIndicator->end();
    1105 [ -  + ][ -  + ]:          8 :             }
                 [ +  - ]
    1106 [ +  - ][ -  + ]:          8 :         }
         [ -  + ][ -  + ]
         [ -  + ][ -  + ]
         [ +  - ][ -  + ]
         [ -  + ][ -  + ]
         [ -  + ][ -  + ]
         [ +  - ][ #  # ]
    1107                 :            :     }
    1108                 :          0 :     catch (const uno::Exception &e)
    1109                 :            :     {
    1110                 :            : #if OSL_DEBUG_LEVEL > 1
    1111                 :            :         rtl::OStringBuffer aError(RTL_CONSTASCII_STRINGPARAM(
    1112                 :            :             "uno Exception caught while exporting:\n"));
    1113                 :            :         aError.append(rtl::OUStringToOString(e.Message,
    1114                 :            :             RTL_TEXTENCODING_ASCII_US));
    1115                 :            :         OSL_FAIL(aError.getStr());
    1116                 :            : #else
    1117                 :            :         (void)e;
    1118                 :            : #endif
    1119                 :          0 :         bDocRet = sal_False;
    1120                 :            :     }
    1121         [ +  - ]:          8 :     if ( !bLocked )
    1122                 :          8 :         mxModel->unlockControllers();
    1123                 :            : 
    1124         [ +  - ]:          8 :     if( pGraphicHelper )
    1125                 :          8 :         SvXMLGraphicHelper::Destroy( pGraphicHelper );
    1126                 :            : 
    1127         [ +  - ]:          8 :     if( pObjectHelper )
    1128                 :          8 :         SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
    1129                 :            : 
    1130                 :          8 :     return bDocRet;
    1131 [ +  - ][ +  - ]:         75 : }
    1132                 :            : 
    1133                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10