LCOV - code coverage report
Current view: top level - sw/source/filter/xml - swxml.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 244 406 60.1 %
Date: 2014-11-03 Functions: 9 11 81.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <rsc/rscsfx.hxx>
      21             : #include <com/sun/star/embed/XStorage.hpp>
      22             : #include <com/sun/star/embed/ElementModes.hpp>
      23             : #include <comphelper/processfactory.hxx>
      24             : #include <com/sun/star/xml/sax/InputSource.hpp>
      25             : #include <com/sun/star/xml/sax/Parser.hpp>
      26             : #include <com/sun/star/io/XActiveDataControl.hpp>
      27             : #include <com/sun/star/text/XTextRange.hpp>
      28             : #include <com/sun/star/container/XChild.hpp>
      29             : #include <com/sun/star/document/NamedPropertyValues.hpp>
      30             : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      31             : #include <com/sun/star/beans/PropertyValue.hpp>
      32             : #include <com/sun/star/beans/NamedValue.hpp>
      33             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      34             : #include <com/sun/star/task/XStatusIndicatorFactory.hpp>
      35             : #include <com/sun/star/io/XActiveDataSource.hpp>
      36             : #include <com/sun/star/packages/zip/ZipIOException.hpp>
      37             : #include <com/sun/star/packages/WrongPasswordException.hpp>
      38             : #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
      39             : #include <sfx2/docfile.hxx>
      40             : #include <svtools/sfxecode.hxx>
      41             : #include <svl/stritem.hxx>
      42             : #include <unotools/streamwrap.hxx>
      43             : #include <svx/xmlgrhlp.hxx>
      44             : #include <svx/xmleohlp.hxx>
      45             : #include <comphelper/genericpropertyset.hxx>
      46             : #include <rtl/strbuf.hxx>
      47             : #include <sfx2/frame.hxx>
      48             : #include <unotools/ucbstreamhelper.hxx>
      49             : #include <swerror.h>
      50             : #include <fltini.hxx>
      51             : #include <drawdoc.hxx>
      52             : #include <doc.hxx>
      53             : #include <IDocumentSettingAccess.hxx>
      54             : #include <IDocumentDrawModelAccess.hxx>
      55             : #include <IDocumentRedlineAccess.hxx>
      56             : #include <docary.hxx>
      57             : #include <docsh.hxx>
      58             : #include <unotextrange.hxx>
      59             : #include <swmodule.hxx>
      60             : #include <SwXMLSectionList.hxx>
      61             : #include <statstr.hrc>
      62             : 
      63             : #include <SwStyleNameMapper.hxx>
      64             : #include <poolfmt.hxx>
      65             : #include <numrule.hxx>
      66             : #include <paratr.hxx>
      67             : 
      68             : #include <svx/svdmodel.hxx>
      69             : #include <svx/svdpage.hxx>
      70             : #include <svx/svditer.hxx>
      71             : #include <svx/svdoole2.hxx>
      72             : #include <svx/svdograf.hxx>
      73             : #include <sfx2/docfilt.hxx>
      74             : #include <istyleaccess.hxx>
      75             : 
      76             : #include <sfx2/DocumentMetadataAccess.hxx>
      77             : 
      78             : using namespace ::com::sun::star;
      79             : using namespace ::com::sun::star::uno;
      80             : using namespace ::com::sun::star::text;
      81             : using namespace ::com::sun::star::container;
      82             : using namespace ::com::sun::star::document;
      83             : using namespace ::com::sun::star::lang;
      84             : 
      85         318 : static void lcl_EnsureValidPam( SwPaM& rPam )
      86             : {
      87         318 :     if( rPam.GetCntntNode() != NULL )
      88             :     {
      89             :         // set proper point content
      90         318 :         if( rPam.GetCntntNode() != rPam.GetPoint()->nContent.GetIdxReg() )
      91             :         {
      92         318 :             rPam.GetPoint()->nContent.Assign( rPam.GetCntntNode(), 0 );
      93             :         }
      94             :         // else: point was already valid
      95             : 
      96             :         // if mark is invalid, we delete it
      97         636 :         if( ( rPam.GetCntntNode( false ) == NULL ) ||
      98         318 :             ( rPam.GetCntntNode( false ) != rPam.GetMark()->nContent.GetIdxReg() ) )
      99             :         {
     100           0 :             rPam.DeleteMark();
     101             :         }
     102             :     }
     103             :     else
     104             :     {
     105             :         // point is not valid, so move it into the first content
     106           0 :         rPam.DeleteMark();
     107           0 :         rPam.GetPoint()->nNode =
     108           0 :             *rPam.GetDoc()->GetNodes().GetEndOfContent().StartOfSectionNode();
     109           0 :         ++ rPam.GetPoint()->nNode;
     110           0 :         rPam.Move( fnMoveForward, fnGoCntnt ); // go into content
     111             :     }
     112         318 : }
     113             : 
     114          90 : XMLReader::XMLReader()
     115             : {
     116          90 : }
     117             : 
     118         318 : int XMLReader::GetReaderType()
     119             : {
     120         318 :     return SW_STORAGE_READER;
     121             : }
     122             : 
     123             : namespace
     124             : {
     125             : 
     126             : /// read a component (file + filter version)
     127        1256 : sal_Int32 ReadThroughComponent(
     128             :     uno::Reference<io::XInputStream> xInputStream,
     129             :     uno::Reference<XComponent> xModelComponent,
     130             :     const OUString& rStreamName,
     131             :     uno::Reference<uno::XComponentContext> & rxContext,
     132             :     const sal_Char* pFilterName,
     133             :     const Sequence<Any>& rFilterArguments,
     134             :     const OUString& rName,
     135             :     bool bMustBeSuccessfull,
     136             :     bool bEncrypted )
     137             : {
     138             :     OSL_ENSURE(xInputStream.is(), "input stream missing");
     139             :     OSL_ENSURE(xModelComponent.is(), "document missing");
     140             :     OSL_ENSURE(rxContext.is(), "factory missing");
     141             :     OSL_ENSURE(NULL != pFilterName,"I need a service name for the component!");
     142             : 
     143             :     // prepare ParserInputSrouce
     144        1256 :     xml::sax::InputSource aParserInput;
     145        1256 :     aParserInput.sSystemId = rName;
     146        1256 :     aParserInput.aInputStream = xInputStream;
     147             : 
     148             :     // get parser
     149        2512 :     uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(rxContext);
     150             :     SAL_INFO( "sw.filter", "parser created" );
     151             :     // get filter
     152        2512 :     const OUString aFilterName(OUString::createFromAscii(pFilterName));
     153             :     uno::Reference< xml::sax::XDocumentHandler > xFilter(
     154        2512 :         rxContext->getServiceManager()->createInstanceWithArgumentsAndContext(aFilterName, rFilterArguments, rxContext),
     155        2512 :         UNO_QUERY);
     156             :     SAL_WARN_IF(!xFilter.is(), "sw", "Can't instantiate filter component: " << aFilterName);
     157        1256 :     if( !xFilter.is() )
     158           4 :         return ERR_SWG_READ_ERROR;
     159             :     SAL_INFO( "sw.filter", "" << pFilterName << " created" );
     160             :     // connect parser and filter
     161        1252 :     xParser->setDocumentHandler( xFilter );
     162             : 
     163             :     // connect model and filter
     164        2504 :     uno::Reference < XImporter > xImporter( xFilter, UNO_QUERY );
     165        1252 :     xImporter->setTargetDocument( xModelComponent );
     166             : 
     167             :     // finally, parser the stream
     168             :     try
     169             :     {
     170        1252 :         xParser->parseStream( aParserInput );
     171             :     }
     172           0 :     catch( xml::sax::SAXParseException& r )
     173             :     {
     174             :         // sax parser sends wrapped exceptions,
     175             :         // try to find the original one
     176           0 :         xml::sax::SAXException aSaxEx = *(xml::sax::SAXException*)(&r);
     177           0 :         bool bTryChild = true;
     178             : 
     179           0 :         while( bTryChild )
     180             :         {
     181           0 :             xml::sax::SAXException aTmp;
     182           0 :             if ( aSaxEx.WrappedException >>= aTmp )
     183           0 :                 aSaxEx = aTmp;
     184             :             else
     185           0 :                 bTryChild = false;
     186           0 :         }
     187             : 
     188           0 :         packages::zip::ZipIOException aBrokenPackage;
     189           0 :         if ( aSaxEx.WrappedException >>= aBrokenPackage )
     190           0 :             return ERRCODE_IO_BROKENPACKAGE;
     191             : 
     192           0 :         if( bEncrypted )
     193           0 :             return ERRCODE_SFX_WRONGPASSWORD;
     194             : 
     195             : #if OSL_DEBUG_LEVEL > 0
     196             :         OStringBuffer aError("SAX parse exception caught while importing:\n");
     197             :         aError.append(OUStringToOString(r.Message,
     198             :             RTL_TEXTENCODING_ASCII_US));
     199             :         OSL_FAIL(aError.getStr());
     200             : #endif
     201             : 
     202             :         const OUString sErr( OUString::number( r.LineNumber )
     203           0 :             + ","
     204           0 :             + OUString::number( r.ColumnNumber ) );
     205             : 
     206           0 :         if( !rStreamName.isEmpty() )
     207             :         {
     208             :             return *new TwoStringErrorInfo(
     209             :                             (bMustBeSuccessfull ? ERR_FORMAT_FILE_ROWCOL
     210             :                                                     : WARN_FORMAT_FILE_ROWCOL),
     211             :                             rStreamName, sErr,
     212           0 :                             ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
     213             :         }
     214             :         else
     215             :         {
     216             :             OSL_ENSURE( bMustBeSuccessfull, "Warnings are not supported" );
     217             :             return *new StringErrorInfo( ERR_FORMAT_ROWCOL, sErr,
     218           0 :                              ERRCODE_BUTTON_OK | ERRCODE_MSG_ERROR );
     219           0 :         }
     220             :     }
     221           0 :     catch(const xml::sax::SAXException& r)
     222             :     {
     223           0 :         packages::zip::ZipIOException aBrokenPackage;
     224           0 :         if ( r.WrappedException >>= aBrokenPackage )
     225           0 :             return ERRCODE_IO_BROKENPACKAGE;
     226             : 
     227           0 :         if( bEncrypted )
     228           0 :             return ERRCODE_SFX_WRONGPASSWORD;
     229             : 
     230             : #if OSL_DEBUG_LEVEL > 0
     231             :         OStringBuffer aError("SAX exception caught while importing:\n");
     232             :         aError.append(OUStringToOString(r.Message,
     233             :             RTL_TEXTENCODING_ASCII_US));
     234             :         OSL_FAIL(aError.getStr());
     235             : #endif
     236             : 
     237           0 :         return ERR_SWG_READ_ERROR;
     238             :     }
     239           0 :     catch(const packages::zip::ZipIOException& r)
     240             :     {
     241             :         (void)r;
     242             : #if OSL_DEBUG_LEVEL > 0
     243             :         OStringBuffer aError("Zip exception caught while importing:\n");
     244             :         aError.append(OUStringToOString(r.Message,
     245             :             RTL_TEXTENCODING_ASCII_US));
     246             :         OSL_FAIL(aError.getStr());
     247             : #endif
     248           0 :         return ERRCODE_IO_BROKENPACKAGE;
     249             :     }
     250           0 :     catch(const io::IOException& r)
     251             :     {
     252             :         (void)r;
     253             : #if OSL_DEBUG_LEVEL > 0
     254             :         OStringBuffer aError("IO exception caught while importing:\n");
     255             :         aError.append(OUStringToOString(r.Message,
     256             :             RTL_TEXTENCODING_ASCII_US));
     257             :         OSL_FAIL(aError.getStr());
     258             : #endif
     259           0 :         return ERR_SWG_READ_ERROR;
     260             :     }
     261           0 :     catch(const uno::Exception& r)
     262             :     {
     263             :         (void)r;
     264             : #if OSL_DEBUG_LEVEL > 0
     265             :         OStringBuffer aError("uno exception caught while importing:\n");
     266             :         aError.append(OUStringToOString(r.Message,
     267             :             RTL_TEXTENCODING_ASCII_US));
     268             :         OSL_FAIL(aError.getStr());
     269             : #endif
     270           0 :         return ERR_SWG_READ_ERROR;
     271             :     }
     272             : 
     273             :     // success!
     274        2508 :     return 0;
     275             : }
     276             : 
     277             : // read a component (storage version)
     278        1256 : sal_Int32 ReadThroughComponent(
     279             :     uno::Reference<embed::XStorage> xStorage,
     280             :     uno::Reference<XComponent> xModelComponent,
     281             :     const sal_Char* pStreamName,
     282             :     const sal_Char* pCompatibilityStreamName,
     283             :     uno::Reference<uno::XComponentContext> & rxContext,
     284             :     const sal_Char* pFilterName,
     285             :     const Sequence<Any>& rFilterArguments,
     286             :     const OUString& rName,
     287             :     bool bMustBeSuccessfull)
     288             : {
     289             :     OSL_ENSURE(xStorage.is(), "Need storage!");
     290             :     OSL_ENSURE(NULL != pStreamName, "Please, please, give me a name!");
     291             : 
     292             :     // open stream (and set parser input)
     293        1256 :     OUString sStreamName = OUString::createFromAscii(pStreamName);
     294        1256 :     bool bContainsStream = false;
     295             :     try
     296             :     {
     297        1256 :         bContainsStream = xStorage->isStreamElement(sStreamName);
     298             :     }
     299           0 :     catch( container::NoSuchElementException& )
     300             :     {
     301             :     }
     302             : 
     303        1256 :     if (!bContainsStream )
     304             :     {
     305             :         // stream name not found! Then try the compatibility name.
     306             :         // if no stream can be opened, return immediately with OK signal
     307             : 
     308             :         // do we even have an alternative name?
     309           0 :         if ( NULL == pCompatibilityStreamName )
     310           0 :             return 0;
     311             : 
     312             :         // if so, does the stream exist?
     313           0 :         sStreamName = OUString::createFromAscii(pCompatibilityStreamName);
     314             :         try
     315             :         {
     316           0 :             bContainsStream = xStorage->isStreamElement(sStreamName);
     317             :         }
     318           0 :         catch( container::NoSuchElementException& )
     319             :         {
     320             :         }
     321             : 
     322           0 :         if (! bContainsStream )
     323           0 :             return 0;
     324             :     }
     325             : 
     326             :     // set Base URL
     327        2512 :     uno::Reference< beans::XPropertySet > xInfoSet;
     328        1256 :     if( rFilterArguments.getLength() > 0 )
     329        1256 :         rFilterArguments.getConstArray()[0] >>= xInfoSet;
     330             :     OSL_ENSURE( xInfoSet.is(), "missing property set" );
     331        1256 :     if( xInfoSet.is() )
     332             :     {
     333        1256 :         xInfoSet->setPropertyValue( "StreamName", makeAny( sStreamName ) );
     334             :     }
     335             : 
     336             :     try
     337             :     {
     338             :         // get input stream
     339        1256 :         uno::Reference <io::XStream> xStream = xStorage->openStreamElement( sStreamName, embed::ElementModes::READ );
     340        2512 :         uno::Reference <beans::XPropertySet > xProps( xStream, uno::UNO_QUERY );
     341             : 
     342        2512 :         Any aAny = xProps->getPropertyValue("Encrypted");
     343             : 
     344        2512 :         bool bEncrypted = aAny.getValueType() == ::getBooleanCppuType() &&
     345        2512 :                 *(sal_Bool *)aAny.getValue();
     346             : 
     347        2512 :         uno::Reference <io::XInputStream> xInputStream = xStream->getInputStream();
     348             : 
     349             :         // read from the stream
     350             :         return ReadThroughComponent(
     351             :             xInputStream, xModelComponent, sStreamName, rxContext,
     352             :             pFilterName, rFilterArguments,
     353        2512 :             rName, bMustBeSuccessfull, bEncrypted );
     354             :     }
     355           0 :     catch ( packages::WrongPasswordException& )
     356             :     {
     357           0 :         return ERRCODE_SFX_WRONGPASSWORD;
     358             :     }
     359           0 :     catch( packages::zip::ZipIOException& )
     360             :     {
     361           0 :         return ERRCODE_IO_BROKENPACKAGE;
     362             :     }
     363           0 :     catch ( uno::Exception& )
     364             :     {
     365             :         OSL_FAIL( "Error on import!\n" );
     366             :         // TODO/LATER: error handling
     367             :     }
     368             : 
     369        1256 :     return ERR_SWG_READ_ERROR;
     370             : }
     371             : 
     372             : }
     373             : 
     374             : // #i44177#
     375           0 : static void lcl_AdjustOutlineStylesForOOo(SwDoc& _rDoc)
     376             : {
     377             :     // array containing the names of the default outline styles ('Heading 1',
     378             :     // 'Heading 2', ..., 'Heading 10')
     379           0 :     OUString aDefOutlStyleNames[ MAXLEVEL ];
     380             :     {
     381           0 :         OUString sStyleName;
     382           0 :         for ( sal_uInt8 i = 0; i < MAXLEVEL; ++i )
     383             :         {
     384             :             sStyleName =
     385             :                 SwStyleNameMapper::GetProgName( static_cast< sal_uInt16 >(RES_POOLCOLL_HEADLINE1 + i),
     386           0 :                                                 sStyleName );
     387           0 :             aDefOutlStyleNames[i] = sStyleName;
     388           0 :         }
     389             :     }
     390             : 
     391             :     // array indicating, which outline level already has a style assigned.
     392             :     bool aOutlineLevelAssigned[ MAXLEVEL ];
     393             :     // array of the default outline styles, which are created for the document.
     394             :     SwTxtFmtColl* aCreatedDefaultOutlineStyles[ MAXLEVEL ];
     395             : 
     396             :     {
     397           0 :         for ( sal_uInt8 i = 0; i < MAXLEVEL; ++i )
     398             :         {
     399           0 :             aOutlineLevelAssigned[ i ] = false;
     400           0 :             aCreatedDefaultOutlineStyles[ i ] = 0L;
     401             :         }
     402             :     }
     403             : 
     404             :     // determine, which outline level has already a style assigned and
     405             :     // which of the default outline styles is created.
     406           0 :     const SwTxtFmtColls& rColls = *(_rDoc.GetTxtFmtColls());
     407           0 :     for ( size_t n = 1; n < rColls.size(); ++n )
     408             :     {
     409           0 :         SwTxtFmtColl* pColl = rColls[ n ];
     410           0 :         if ( pColl->IsAssignedToListLevelOfOutlineStyle() )
     411             :         {
     412           0 :             aOutlineLevelAssigned[ pColl->GetAssignedOutlineStyleLevel() ] = true;
     413             :         }
     414             : 
     415           0 :         for ( sal_uInt8 i = 0; i < MAXLEVEL; ++i )
     416             :         {
     417           0 :             if ( aCreatedDefaultOutlineStyles[ i ] == 0L &&
     418           0 :                  pColl->GetName() == aDefOutlStyleNames[i] )
     419             :             {
     420           0 :                 aCreatedDefaultOutlineStyles[ i ] = pColl;
     421           0 :                 break;
     422             :             }
     423             :         }
     424             :     }
     425             : 
     426             :     // assign already created default outline style to outline level, which
     427             :     // doesn't have a style assigned to it.
     428           0 :     const SwNumRule* pOutlineRule = _rDoc.GetOutlineNumRule();
     429           0 :     for ( sal_uInt8 i = 0; i < MAXLEVEL; ++i )
     430             :     {
     431             :         // #i73361#
     432             :         // Do not change assignment of already created default outline style
     433             :         // to a certain outline level.
     434           0 :         if ( !aOutlineLevelAssigned[ i ] &&
     435           0 :              aCreatedDefaultOutlineStyles[ i ] != 0 &&
     436           0 :              ! aCreatedDefaultOutlineStyles[ i ]->IsAssignedToListLevelOfOutlineStyle() )
     437             :         {
     438             :             // apply outline level at created default outline style
     439           0 :             aCreatedDefaultOutlineStyles[ i ]->AssignToListLevelOfOutlineStyle(i);
     440             : 
     441             :             // apply outline numbering rule, if none is set.
     442             :             const SfxPoolItem& rItem =
     443           0 :                 aCreatedDefaultOutlineStyles[ i ]->GetFmtAttr( RES_PARATR_NUMRULE, false );
     444           0 :             if ( static_cast<const SwNumRuleItem&>(rItem).GetValue().isEmpty() )
     445             :             {
     446           0 :                 SwNumRuleItem aItem( pOutlineRule->GetName() );
     447           0 :                 aCreatedDefaultOutlineStyles[ i ]->SetFmtAttr( aItem );
     448             :             }
     449             :         }
     450           0 :     }
     451           0 : }
     452             : 
     453         318 : static void lcl_ConvertSdrOle2ObjsToSdrGrafObjs(SwDoc& _rDoc)
     454             : {
     455         636 :     if ( _rDoc.getIDocumentDrawModelAccess().GetDrawModel() &&
     456         318 :          _rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 ) )
     457             :     {
     458         318 :         const SdrPage& rSdrPage( *(_rDoc.getIDocumentDrawModelAccess().GetDrawModel()->GetPage( 0 )) );
     459             : 
     460             :         // iterate recursive with group objects over all shapes on the draw page
     461         318 :         SdrObjListIter aIter( rSdrPage );
     462        1058 :         while( aIter.IsMore() )
     463             :         {
     464         422 :             SdrOle2Obj* pOle2Obj = dynamic_cast< SdrOle2Obj* >( aIter.Next() );
     465         422 :             if( pOle2Obj )
     466             :             {
     467             :                 // found an ole2 shape
     468           0 :                 SdrObjList* pObjList = pOle2Obj->GetObjList();
     469             : 
     470             :                 // get its graphic
     471           0 :                 Graphic aGraphic;
     472           0 :                 pOle2Obj->Connect();
     473           0 :                 const Graphic* pGraphic = pOle2Obj->GetGraphic();
     474           0 :                 if( pGraphic )
     475           0 :                     aGraphic = *pGraphic;
     476           0 :                 pOle2Obj->Disconnect();
     477             : 
     478             :                 // create new graphic shape with the ole graphic and shape size
     479           0 :                 SdrGrafObj* pGraphicObj = new SdrGrafObj( aGraphic, pOle2Obj->GetCurrentBoundRect() );
     480             :                 // apply layer of ole2 shape at graphic shape
     481           0 :                 pGraphicObj->SetLayer( pOle2Obj->GetLayer() );
     482             : 
     483             :                 // replace ole2 shape with the new graphic object and delete the ol2 shape
     484           0 :                 SdrObject* pReplaced = pObjList->ReplaceObject( pGraphicObj, pOle2Obj->GetOrdNum() );
     485           0 :                 SdrObject::Free( pReplaced );
     486             :             }
     487         318 :         }
     488             :     }
     489         318 : }
     490             : 
     491         318 : sal_uLong XMLReader::Read( SwDoc &rDoc, const OUString& rBaseURL, SwPaM &rPaM, const OUString & rName )
     492             : {
     493             :     // Get service factory
     494             :     uno::Reference< uno::XComponentContext > xContext =
     495         318 :             comphelper::getProcessComponentContext();
     496             : 
     497         636 :     uno::Reference< io::XActiveDataSource > xSource;
     498         636 :     uno::Reference< XInterface > xPipe;
     499         636 :     uno::Reference< document::XGraphicObjectResolver > xGraphicResolver;
     500         318 :     SvXMLGraphicHelper *pGraphicHelper = 0;
     501         636 :     uno::Reference< document::XEmbeddedObjectResolver > xObjectResolver;
     502         318 :     SvXMLEmbeddedObjectHelper *pObjectHelper = 0;
     503             : 
     504             :     // get the input stream (storage or stream)
     505         636 :     uno::Reference<io::XInputStream> xInputStream;
     506         636 :     uno::Reference<embed::XStorage> xStorage;
     507         318 :     if( pMedium )
     508         318 :         xStorage = pMedium->GetStorage();
     509             :     else
     510           0 :         xStorage = xStg;
     511             : 
     512         318 :     if( !xStorage.is() )
     513           0 :         return ERR_SWG_READ_ERROR;
     514             : 
     515             :     pGraphicHelper = SvXMLGraphicHelper::Create( xStorage,
     516             :                                                  GRAPHICHELPER_MODE_READ,
     517         318 :                                                  false );
     518         318 :     xGraphicResolver = pGraphicHelper;
     519         318 :     SfxObjectShell *pPersist = rDoc.GetPersist();
     520         318 :     if( pPersist )
     521             :     {
     522             :         pObjectHelper = SvXMLEmbeddedObjectHelper::Create(
     523             :                                         xStorage, *pPersist,
     524             :                                         EMBEDDEDOBJECTHELPER_MODE_READ,
     525         318 :                                         false );
     526         318 :         xObjectResolver = pObjectHelper;
     527             :     }
     528             : 
     529             :     // Get the docshell, the model, and finally the model's component
     530         318 :     SwDocShell *pDocSh = rDoc.GetDocShell();
     531             :     OSL_ENSURE( pDocSh, "XMLReader::Read: got no doc shell" );
     532         318 :     if( !pDocSh )
     533           0 :         return ERR_SWG_READ_ERROR;
     534         636 :     uno::Reference< lang::XComponent > xModelComp( pDocSh->GetModel(), UNO_QUERY );
     535             :     OSL_ENSURE( xModelComp.is(),
     536             :             "XMLReader::Read: got no model" );
     537         318 :     if( !xModelComp.is() )
     538           0 :         return ERR_SWG_READ_ERROR;
     539             : 
     540             :     // create and prepare the XPropertySet that gets passed through
     541             :     // the components, and the XStatusIndicator that shows progress to
     542             :     // the user.
     543             : 
     544             :     // create XPropertySet with three properties for status indicator
     545             :     comphelper::PropertyMapEntry const aInfoMap[] =
     546             :     {
     547             :         { OUString("ProgressRange"), 0,
     548         318 :               ::cppu::UnoType<sal_Int32>::get(),
     549             :               beans::PropertyAttribute::MAYBEVOID, 0},
     550             :         { OUString("ProgressMax"), 0,
     551         318 :               ::cppu::UnoType<sal_Int32>::get(),
     552             :               beans::PropertyAttribute::MAYBEVOID, 0},
     553             :         { OUString("ProgressCurrent"), 0,
     554         318 :               ::cppu::UnoType<sal_Int32>::get(),
     555             :               beans::PropertyAttribute::MAYBEVOID, 0},
     556             :         { OUString("NumberStyles"), 0,
     557         318 :               cppu::UnoType<container::XNameContainer>::get(),
     558             :               beans::PropertyAttribute::MAYBEVOID, 0},
     559             :         { OUString("RecordChanges"), 0,
     560         318 :               ::getBooleanCppuType(),
     561             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     562             :         { OUString("ShowChanges"), 0,
     563         318 :               ::getBooleanCppuType(),
     564             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     565             :         { OUString("RedlineProtectionKey"), 0,
     566         318 :               ::getCppuType((Sequence<sal_Int8>*)0),
     567             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     568             :         { OUString("PrivateData"), 0,
     569         318 :               cppu::UnoType<XInterface>::get(),
     570             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     571             :         { OUString("BaseURI"), 0,
     572         318 :               ::cppu::UnoType<OUString>::get(),
     573             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     574             :         { OUString("StreamRelPath"), 0,
     575         318 :               ::cppu::UnoType<OUString>::get(),
     576             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     577             :         { OUString("StreamName"), 0,
     578         318 :               ::cppu::UnoType<OUString>::get(),
     579             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     580             :         // properties for insert modes
     581             :         { OUString("StyleInsertModeFamilies"), 0,
     582         318 :               ::getCppuType((Sequence<OUString>*)0),
     583             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     584             :         { OUString("StyleInsertModeOverwrite"), 0,
     585         318 :               ::getBooleanCppuType(),
     586             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     587             :         { OUString("TextInsertModeRange"), 0,
     588         318 :               cppu::UnoType<text::XTextRange>::get(),
     589             :               beans::PropertyAttribute::MAYBEVOID, 0},
     590             :         { OUString("AutoTextMode"), 0,
     591         318 :               ::getBooleanCppuType(),
     592             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     593             :         { OUString("OrganizerMode"), 0,
     594         318 :               ::getBooleanCppuType(),
     595             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     596             : 
     597             :         // #i28749# - Add property, which indicates, if the
     598             :         // shape position attributes are given in horizontal left-to-right layout.
     599             :         // This is the case for the OpenOffice.org file format.
     600             :         { OUString("ShapePositionInHoriL2R"), 0,
     601         318 :               ::getBooleanCppuType(),
     602             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     603             : 
     604             :         { OUString("BuildId"), 0,
     605         318 :               ::cppu::UnoType<OUString>::get(),
     606             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     607             : 
     608             :         // Add property, which indicates, if a text document in OpenOffice.org
     609             :         // file format is read.
     610             :         // Note: Text documents read via the binary filter are also finally
     611             :         //       read using the OpenOffice.org file format. Thus, e.g. for text
     612             :         //       documents in StarOffice 5.2 binary file format this property
     613             :         //       will be sal_True.
     614             :         { OUString("TextDocInOOoFileFormat"), 0,
     615         318 :               ::getBooleanCppuType(),
     616             :               beans::PropertyAttribute::MAYBEVOID, 0 },
     617         318 :         { OUString("SourceStorage"), 0, cppu::UnoType<embed::XStorage>::get(),
     618             :           ::com::sun::star::beans::PropertyAttribute::MAYBEVOID, 0 },
     619             :         { OUString(), 0, css::uno::Type(), 0, 0 }
     620        6996 :     };
     621             :     uno::Reference< beans::XPropertySet > xInfoSet(
     622             :                 comphelper::GenericPropertySet_CreateInstance(
     623         636 :                             new comphelper::PropertySetInfo( aInfoMap ) ) );
     624             : 
     625             :     // get BuildId from parent container if available
     626         636 :     uno::Reference< container::XChild > xChild( xModelComp, uno::UNO_QUERY );
     627         318 :     if( xChild.is() )
     628             :     {
     629         318 :         uno::Reference< beans::XPropertySet > xParentSet( xChild->getParent(), uno::UNO_QUERY );
     630         318 :         if( xParentSet.is() )
     631             :         {
     632           0 :             uno::Reference< beans::XPropertySetInfo > xPropSetInfo( xParentSet->getPropertySetInfo() );
     633           0 :             const OUString sPropName("BuildId" );
     634           0 :             if( xPropSetInfo.is() && xPropSetInfo->hasPropertyByName(sPropName) )
     635             :             {
     636           0 :                 xInfoSet->setPropertyValue( sPropName, xParentSet->getPropertyValue(sPropName) );
     637           0 :             }
     638         318 :         }
     639             :     }
     640             : 
     641             :     // try to get an XStatusIndicator from the Medium
     642         636 :     uno::Reference<task::XStatusIndicator> xStatusIndicator;
     643             : 
     644         318 :     if (pDocSh->GetMedium())
     645             :     {
     646         318 :         SfxItemSet* pSet = pDocSh->GetMedium()->GetItemSet();
     647         318 :         if (pSet)
     648             :         {
     649             :             const SfxUnoAnyItem* pItem = static_cast<const SfxUnoAnyItem*>(
     650         318 :                 pSet->GetItem(SID_PROGRESS_STATUSBAR_CONTROL) );
     651         318 :             if (pItem)
     652             :             {
     653         276 :                 pItem->GetValue() >>= xStatusIndicator;
     654             :             }
     655             :         }
     656             :     }
     657             : 
     658             :     // set progress range and start status indicator
     659         318 :     sal_Int32 nProgressRange(1000000);
     660         318 :     if (xStatusIndicator.is())
     661             :     {
     662         276 :         xStatusIndicator->start(SW_RESSTR(STR_STATSTR_SWGREAD), nProgressRange);
     663             :     }
     664         636 :     uno::Any aProgRange;
     665         318 :     aProgRange <<= nProgressRange;
     666         318 :     xInfoSet->setPropertyValue("ProgressRange", aProgRange);
     667             : 
     668         636 :     Reference< container::XNameAccess > xLateInitSettings( document::NamedPropertyValues::create(xContext), UNO_QUERY_THROW );
     669         636 :     beans::NamedValue aLateInitSettings( "LateInitSettings", makeAny( xLateInitSettings ) );
     670             : 
     671         318 :     xInfoSet->setPropertyValue( "SourceStorage", Any( xStorage ) );
     672             : 
     673             :     // prepare filter arguments, WARNING: the order is important!
     674         636 :     Sequence<Any> aFilterArgs( 5 );
     675         318 :     Any *pArgs = aFilterArgs.getArray();
     676         318 :     *pArgs++ <<= xInfoSet;
     677         318 :     *pArgs++ <<= xStatusIndicator;
     678         318 :     *pArgs++ <<= xGraphicResolver;
     679         318 :     *pArgs++ <<= xObjectResolver;
     680         318 :     *pArgs++ <<= aLateInitSettings;
     681             : 
     682         636 :     Sequence<Any> aEmptyArgs( 3 );
     683             :     // cppcheck-suppress redundantAssignment
     684         318 :     pArgs = aEmptyArgs.getArray();
     685         318 :     *pArgs++ <<= xInfoSet;
     686         318 :     *pArgs++ <<= xStatusIndicator;
     687             : 
     688             :     // prepare for special modes
     689         318 :     if( aOpt.IsFmtsOnly() )
     690             :     {
     691             :         sal_Int32 nCount =
     692           0 :             (aOpt.IsFrmFmts() ? 1 : 0) +
     693           0 :             (aOpt.IsPageDescs() ? 1 : 0) +
     694           0 :             (aOpt.IsTxtFmts() ? 2 : 0) +
     695           0 :             (aOpt.IsNumRules() ? 1 : 0);
     696             : 
     697           0 :         Sequence< OUString> aFamiliesSeq( nCount );
     698           0 :         OUString *pSeq = aFamiliesSeq.getArray();
     699           0 :         if( aOpt.IsFrmFmts() )
     700             :             // SFX_STYLE_FAMILY_FRAME;
     701           0 :             *pSeq++ = "FrameStyles";
     702           0 :         if( aOpt.IsPageDescs() )
     703             :             // SFX_STYLE_FAMILY_PAGE;
     704           0 :             *pSeq++ = "PageStyles";
     705           0 :         if( aOpt.IsTxtFmts() )
     706             :         {
     707             :             // (SFX_STYLE_FAMILY_CHAR|SFX_STYLE_FAMILY_PARA);
     708           0 :             *pSeq++ = "CharacterStyles";
     709           0 :             *pSeq++ = "ParagraphStyles";
     710             :         }
     711           0 :         if( aOpt.IsNumRules() )
     712             :             // SFX_STYLE_FAMILY_PSEUDO;
     713           0 :             *pSeq++ = "NumberingStyles";
     714             : 
     715           0 :         xInfoSet->setPropertyValue( "StyleInsertModeFamilies",
     716           0 :                                     makeAny(aFamiliesSeq) );
     717             : 
     718           0 :         sal_Bool bTmp = !aOpt.IsMerge();
     719           0 :         Any aAny;
     720           0 :         aAny.setValue( &bTmp, ::getBooleanCppuType() );
     721           0 :         xInfoSet->setPropertyValue( "StyleInsertModeOverwrite", aAny );
     722             :     }
     723         318 :     else if( bInsertMode )
     724             :     {
     725             :         const uno::Reference<text::XTextRange> xInsertTextRange =
     726           0 :             SwXTextRange::CreateXTextRange(rDoc, *rPaM.GetPoint(), 0);
     727           0 :         xInfoSet->setPropertyValue( "TextInsertModeRange",
     728           0 :                                     makeAny(xInsertTextRange) );
     729             :     }
     730             :     else
     731             :     {
     732         318 :         rPaM.GetBound(true).nContent.Assign(0, 0);
     733         318 :         rPaM.GetBound(false).nContent.Assign(0, 0);
     734             :     }
     735             : 
     736         318 :     if( IsBlockMode() )
     737             :     {
     738           0 :         sal_Bool bTmp = sal_True;
     739           0 :         Any aAny;
     740           0 :         aAny.setValue( &bTmp, ::getBooleanCppuType() );
     741           0 :         xInfoSet->setPropertyValue( "AutoTextMode", aAny );
     742             :     }
     743         318 :     if( IsOrganizerMode() )
     744             :     {
     745           8 :         sal_Bool bTmp = sal_True;
     746           8 :         Any aAny;
     747           8 :         aAny.setValue( &bTmp, ::getBooleanCppuType() );
     748           8 :         xInfoSet->setPropertyValue( "OrganizerMode", aAny );
     749             :     }
     750             : 
     751             :     // Set base URI
     752             :     // there is ambiguity which medium should be used here
     753             :     // for now the own medium has a preference
     754         318 :     SfxMedium* pMedDescrMedium = pMedium ? pMedium : pDocSh->GetMedium();
     755             :     OSL_ENSURE( pMedDescrMedium, "There is no medium to get MediaDescriptor from!\n" );
     756             : 
     757         318 :     xInfoSet->setPropertyValue( "BaseURI", makeAny( rBaseURL ) );
     758             : 
     759             :     // TODO/LATER: separate links from usual embedded objects
     760         636 :     OUString StreamPath;
     761         318 :     if( SFX_CREATE_MODE_EMBEDDED == rDoc.GetDocShell()->GetCreateMode() )
     762             :     {
     763          14 :         if ( pMedDescrMedium && pMedDescrMedium->GetItemSet() )
     764             :         {
     765             :             const SfxStringItem* pDocHierarchItem = static_cast<const SfxStringItem*>(
     766          14 :                 pMedDescrMedium->GetItemSet()->GetItem(SID_DOC_HIERARCHICALNAME) );
     767          14 :             if ( pDocHierarchItem )
     768           0 :                 StreamPath = pDocHierarchItem->GetValue();
     769             :         }
     770             :         else
     771             :         {
     772           0 :             StreamPath = "dummyObjectName";
     773             :         }
     774             : 
     775          14 :         if( !StreamPath.isEmpty() )
     776             :         {
     777           0 :             xInfoSet->setPropertyValue( "StreamRelPath", makeAny( StreamPath ) );
     778             :         }
     779             :     }
     780             : 
     781         318 :     (void)rDoc.acquire(); // prevent deletion
     782         318 :     sal_uInt32 nRet = 0;
     783             : 
     784             :     // save redline mode into import info property set
     785         636 :     Any aAny;
     786             :     sal_Bool bTmp;
     787         636 :     const OUString sShowChanges("ShowChanges");
     788         636 :     const OUString sRecordChanges("RecordChanges");
     789         636 :     const OUString sRedlineProtectionKey("RedlineProtectionKey");
     790         318 :     bTmp = IDocumentRedlineAccess::IsShowChanges( rDoc.getIDocumentRedlineAccess().GetRedlineMode() );
     791         318 :     aAny.setValue( &bTmp, ::getBooleanCppuType() );
     792         318 :     xInfoSet->setPropertyValue( sShowChanges, aAny );
     793         318 :     bTmp = IDocumentRedlineAccess::IsRedlineOn(rDoc.getIDocumentRedlineAccess().GetRedlineMode());
     794         318 :     aAny.setValue( &bTmp, ::getBooleanCppuType() );
     795         318 :     xInfoSet->setPropertyValue( sRecordChanges, aAny );
     796         318 :     aAny <<= rDoc.getIDocumentRedlineAccess().GetRedlinePassword();
     797         318 :     xInfoSet->setPropertyValue( sRedlineProtectionKey, aAny );
     798             : 
     799             :     // force redline mode to "none"
     800         318 :     rDoc.getIDocumentRedlineAccess().SetRedlineMode_intern( nsRedlineMode_t::REDLINE_NONE );
     801             : 
     802         318 :     const bool bOASIS = ( SotStorage::GetVersion( xStorage ) > SOFFICE_FILEFORMAT_60 );
     803             :     // #i28749# - set property <ShapePositionInHoriL2R>
     804             :     {
     805         318 :         const bool bShapePositionInHoriL2R = !bOASIS;
     806         318 :         xInfoSet->setPropertyValue(
     807             :                 "ShapePositionInHoriL2R",
     808         318 :                 makeAny( bShapePositionInHoriL2R ) );
     809             :     }
     810             :     {
     811         318 :         const bool bTextDocInOOoFileFormat = !bOASIS;
     812         318 :         xInfoSet->setPropertyValue(
     813             :                 "TextDocInOOoFileFormat",
     814         318 :                 makeAny( bTextDocInOOoFileFormat ) );
     815             :     }
     816             : 
     817         318 :     sal_uInt32 nWarnRDF = 0;
     818         946 :     if ( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() ||
     819         628 :            bInsertMode) )
     820             :     {
     821             :         // RDF metadata - must be read before styles/content
     822             :         // N.B.: embedded documents have their own manifest.rdf!
     823             :         try
     824             :         {
     825             :             const uno::Reference<rdf::XDocumentMetadataAccess> xDMA(xModelComp,
     826         310 :                 uno::UNO_QUERY_THROW);
     827             :             const uno::Reference<rdf::XURI> xBaseURI( ::sfx2::createBaseURI(
     828         354 :                 xContext, xStorage, rBaseURL, StreamPath) );
     829             :             const uno::Reference<task::XInteractionHandler> xHandler(
     830          88 :                 pDocSh->GetMedium()->GetInteractionHandler() );
     831         354 :             xDMA->loadMetadataFromStorage(xStorage, xBaseURI, xHandler);
     832             :         }
     833           0 :         catch (const lang::WrappedTargetException & e)
     834             :         {
     835           0 :             ucb::InteractiveAugmentedIOException iaioe;
     836           0 :             if (e.TargetException >>= iaioe)
     837             :             {
     838             :                 // import error that was not ignored by InteractionHandler!
     839           0 :                 nWarnRDF = ERR_SWG_READ_ERROR;
     840             :             }
     841             :             else
     842             :             {
     843           0 :                 nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something wrong?
     844           0 :             }
     845             :         }
     846         532 :         catch (uno::Exception &)
     847             :         {
     848         266 :             nWarnRDF = WARN_SWG_FEATURES_LOST; // uhh... something went wrong?
     849             :         }
     850             :     }
     851             : 
     852             :     // read storage streams
     853             : 
     854             :     // #i103539#: always read meta.xml for generator
     855             :     sal_uInt32 const nWarn = ReadThroughComponent(
     856             :         xStorage, xModelComp, "meta.xml", "Meta.xml", xContext,
     857             :         (bOASIS ? "com.sun.star.comp.Writer.XMLOasisMetaImporter"
     858             :                 : "com.sun.star.comp.Writer.XMLMetaImporter"),
     859         318 :         aEmptyArgs, rName, false );
     860             : 
     861         318 :     sal_uInt32 nWarn2 = 0;
     862         946 :     if( !(IsOrganizerMode() || IsBlockMode() || aOpt.IsFmtsOnly() ||
     863         628 :           bInsertMode) )
     864             :     {
     865             :         nWarn2 = ReadThroughComponent(
     866             :             xStorage, xModelComp, "settings.xml", NULL, xContext,
     867             :             (bOASIS ? "com.sun.star.comp.Writer.XMLOasisSettingsImporter"
     868             :                     : "com.sun.star.comp.Writer.XMLSettingsImporter"),
     869         310 :             aFilterArgs, rName, false );
     870             :     }
     871             : 
     872             :     nRet = ReadThroughComponent(
     873             :         xStorage, xModelComp, "styles.xml", NULL, xContext,
     874             :         (bOASIS ? "com.sun.star.comp.Writer.XMLOasisStylesImporter"
     875             :                 : "com.sun.star.comp.Writer.XMLStylesImporter"),
     876         318 :         aFilterArgs, rName, true );
     877             : 
     878         318 :     if( !nRet && !(IsOrganizerMode() || aOpt.IsFmtsOnly()) )
     879             :         nRet = ReadThroughComponent(
     880             :            xStorage, xModelComp, "content.xml", "Content.xml", xContext,
     881             :             (bOASIS ? "com.sun.star.comp.Writer.XMLOasisContentImporter"
     882             :                     : "com.sun.star.comp.Writer.XMLContentImporter"),
     883         310 :            aFilterArgs, rName, true );
     884             : 
     885         946 :     if( !(IsOrganizerMode() || IsBlockMode() || bInsertMode ||
     886         628 :           aOpt.IsFmtsOnly() ) )
     887             :     {
     888             :         try
     889             :         {
     890         588 :             uno::Reference < io::XStream > xStm = xStorage->openStreamElement( "layout-cache", embed::ElementModes::READ );
     891          32 :             SvStream* pStrm2 = utl::UcbStreamHelper::CreateStream( xStm );
     892          32 :             if( !pStrm2->GetError() )
     893          32 :                 rDoc.ReadLayoutCache( *pStrm2 );
     894          32 :             delete pStrm2;
     895             :         }
     896         278 :         catch (const uno::Exception&)
     897             :         {
     898             :         }
     899             :     }
     900             : 
     901             :     // Notify math objects
     902         318 :     if( bInsertMode )
     903           0 :         rDoc.PrtOLENotify( false );
     904         318 :     else if ( rDoc.IsOLEPrtNotifyPending() )
     905          16 :         rDoc.PrtOLENotify( true );
     906             : 
     907         318 :     nRet = nRet ? nRet : (nWarn ? nWarn : (nWarn2 ? nWarn2 : nWarnRDF ) );
     908             : 
     909         318 :     aOpt.ResetAllFmtsOnly();
     910             : 
     911             :     // redline password
     912         318 :     aAny = xInfoSet->getPropertyValue( sRedlineProtectionKey );
     913         636 :     Sequence<sal_Int8> aKey;
     914         318 :     aAny >>= aKey;
     915         318 :     rDoc.getIDocumentRedlineAccess().SetRedlinePassword( aKey );
     916             : 
     917             :     // restore redline mode from import info property set
     918         318 :     sal_Int16 nRedlineMode = nsRedlineMode_t::REDLINE_SHOW_INSERT;
     919         318 :     aAny = xInfoSet->getPropertyValue( sShowChanges );
     920         318 :     if ( *(sal_Bool*)aAny.getValue() )
     921         316 :         nRedlineMode |= nsRedlineMode_t::REDLINE_SHOW_DELETE;
     922         318 :     aAny = xInfoSet->getPropertyValue( sRecordChanges );
     923         318 :     if ( *(sal_Bool*)aAny.getValue() || (aKey.getLength() > 0) )
     924           0 :         nRedlineMode |= nsRedlineMode_t::REDLINE_ON;
     925             :     else
     926         318 :         nRedlineMode |= nsRedlineMode_t::REDLINE_NONE;
     927             : 
     928             :     // ... restore redline mode
     929             :     // (First set bogus mode to make sure the mode in getIDocumentRedlineAccess().SetRedlineMode()
     930             :     //  is different from it's previous mode.)
     931         318 :     rDoc.getIDocumentRedlineAccess().SetRedlineMode_intern((RedlineMode_t)( ~nRedlineMode ));
     932         318 :     rDoc.getIDocumentRedlineAccess().SetRedlineMode( (RedlineMode_t)( nRedlineMode ));
     933             : 
     934         318 :     lcl_EnsureValidPam( rPaM ); // move Pam into valid content
     935             : 
     936         318 :     if( pGraphicHelper )
     937         318 :         SvXMLGraphicHelper::Destroy( pGraphicHelper );
     938         318 :     xGraphicResolver = 0;
     939         318 :     if( pObjectHelper )
     940         318 :         SvXMLEmbeddedObjectHelper::Destroy( pObjectHelper );
     941         318 :     xObjectResolver = 0;
     942         318 :     (void)rDoc.release();
     943             : 
     944         318 :     if ( !bOASIS )
     945             :     {
     946             :         // #i44177# - assure that for documents in OpenOffice.org
     947             :         // file format the relation between outline numbering rule and styles is
     948             :         // filled-up accordingly.
     949             :         // Note: The OpenOffice.org file format, which has no content that applys
     950             :         //       a certain style, which is related to the outline numbering rule,
     951             :         //       has lost the information, that this certain style is related to
     952             :         //       the outline numbering rule.
     953             :         // #i70748# - only for templates
     954          12 :         if ( pMedium && pMedium->GetFilter() &&
     955           2 :              pMedium->GetFilter()->IsOwnTemplateFormat() )
     956             :         {
     957           0 :             lcl_AdjustOutlineStylesForOOo( rDoc );
     958             :         }
     959             :         // Fix #i58251#: Unfortunately is the static default different to SO7 behaviour,
     960             :         // so we have to set a dynamic default after importing SO7
     961          10 :         rDoc.SetDefault( SfxBoolItem( RES_ROW_SPLIT, false ) );
     962             :     }
     963             : 
     964         318 :     rDoc.PropagateOutlineRule();
     965             : 
     966             :     // #i62875#
     967         318 :     if ( rDoc.getIDocumentSettingAccess().get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE) && !docfunc::ExistsDrawObjs( rDoc ) )
     968             :     {
     969           2 :         rDoc.getIDocumentSettingAccess().set(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE, false);
     970             :     }
     971             : 
     972             :     // Convert all instances of <SdrOle2Obj> into <SdrGrafObj>, because the
     973             :     // Writer doesn't support such objects.
     974         318 :     lcl_ConvertSdrOle2ObjsToSdrGrafObjs( rDoc );
     975             : 
     976             :     // set BuildId on XModel for later OLE object loading
     977         318 :     if( xInfoSet.is() )
     978             :     {
     979         318 :         uno::Reference< beans::XPropertySet > xModelSet( xModelComp, uno::UNO_QUERY );
     980         318 :         if( xModelSet.is() )
     981             :         {
     982         318 :             uno::Reference< beans::XPropertySetInfo > xModelSetInfo( xModelSet->getPropertySetInfo() );
     983         636 :             const OUString sName("BuildId" );
     984         318 :             if( xModelSetInfo.is() && xModelSetInfo->hasPropertyByName(sName) )
     985             :             {
     986         318 :                 xModelSet->setPropertyValue( sName, xInfoSet->getPropertyValue(sName) );
     987         318 :             }
     988         318 :         }
     989             :     }
     990             : 
     991         318 :     if (xStatusIndicator.is())
     992             :     {
     993         276 :         xStatusIndicator->end();
     994             :     }
     995             : 
     996         318 :     rDoc.GetIStyleAccess().clearCaches(); // Clear Automatic-Style-Caches(shared_pointer!)
     997         636 :     return nRet;
     998             : }
     999             : 
    1000             :     // read the sections of the document, which is equal to the medium.
    1001             :     // returns the count of it
    1002           0 : size_t XMLReader::GetSectionList( SfxMedium& rMedium,
    1003             :                                   std::vector<OUString*>& rStrings ) const
    1004             : {
    1005             :     uno::Reference< uno::XComponentContext > xContext =
    1006           0 :             comphelper::getProcessComponentContext();
    1007           0 :     uno::Reference < embed::XStorage > xStg2;
    1008           0 :     if( ( xStg2 = rMedium.GetStorage() ).is() )
    1009             :     {
    1010             :         try
    1011             :         {
    1012           0 :             xml::sax::InputSource aParserInput;
    1013           0 :             const OUString sDocName( "content.xml" );
    1014           0 :             aParserInput.sSystemId = sDocName;
    1015             : 
    1016           0 :             uno::Reference < io::XStream > xStm = xStg2->openStreamElement( sDocName, embed::ElementModes::READ );
    1017           0 :             aParserInput.aInputStream = xStm->getInputStream();
    1018             : 
    1019             :             // get filter
    1020           0 :             uno::Reference< xml::sax::XDocumentHandler > xFilter = new SwXMLSectionList( xContext, rStrings );
    1021             : 
    1022             :             // connect parser and filter
    1023           0 :             uno::Reference< xml::sax::XParser > xParser = xml::sax::Parser::create(xContext);
    1024           0 :             xParser->setDocumentHandler( xFilter );
    1025             : 
    1026             :             // parse
    1027           0 :             xParser->parseStream( aParserInput );
    1028             :         }
    1029           0 :         catch( xml::sax::SAXParseException&  )
    1030             :         {
    1031             :             // re throw ?
    1032             :         }
    1033           0 :         catch( xml::sax::SAXException&  )
    1034             :         {
    1035             :             // re throw ?
    1036             :         }
    1037           0 :         catch( io::IOException& )
    1038             :         {
    1039             :             // re throw ?
    1040             :         }
    1041           0 :         catch( packages::WrongPasswordException& )
    1042             :         {
    1043             :             // re throw ?
    1044             :         }
    1045             :     }
    1046           0 :     return rStrings.size();
    1047         270 : }
    1048             : 
    1049             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10