LCOV - code coverage report
Current view: top level - sw/source/filter/basflt - shellio.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 243 452 53.8 %
Date: 2012-08-25 Functions: 21 33 63.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 221 809 27.3 %

           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                 :            : 
      30                 :            : #include <hintids.hxx>
      31                 :            : #include <tools/date.hxx>
      32                 :            : #include <tools/time.hxx>
      33                 :            : #include <svl/urihelper.hxx>
      34                 :            : #include <svl/fstathelper.hxx>
      35                 :            : #include <unotools/moduleoptions.hxx>
      36                 :            : #include <sfx2/docfile.hxx>
      37                 :            : #include <editeng/lrspitem.hxx>
      38                 :            : #include <editeng/ulspitem.hxx>
      39                 :            : #include <editeng/boxitem.hxx>
      40                 :            : #include <editeng/paperinf.hxx>
      41                 :            : #include <node.hxx>
      42                 :            : #include <docary.hxx>
      43                 :            : #include <fmtanchr.hxx>
      44                 :            : #include <fmtfsize.hxx>
      45                 :            : #include <fmtpdsc.hxx>
      46                 :            : #include <swtypes.hxx>
      47                 :            : #include <shellio.hxx>
      48                 :            : #include <doc.hxx>
      49                 :            : #include <IDocumentUndoRedo.hxx>
      50                 :            : #include <pam.hxx>
      51                 :            : #include <editsh.hxx>
      52                 :            : #include <undobj.hxx>           // fuer Undo Insert-Dokument
      53                 :            : #include <swundo.hxx>           // fuer Undo Insert-Dokument
      54                 :            : #include <swtable.hxx>
      55                 :            : #include <tblsel.hxx>
      56                 :            : #include <pagedesc.hxx>
      57                 :            : #include <poolfmt.hxx>
      58                 :            : #include <fltini.hxx>
      59                 :            : #include <docsh.hxx>
      60                 :            : #include <redline.hxx>
      61                 :            : #include <swerror.h>
      62                 :            : #include <paratr.hxx>
      63                 :            : 
      64                 :            : // #i73788#
      65                 :            : #include <pausethreadstarting.hxx>
      66                 :            : 
      67                 :            : using namespace ::com::sun::star;
      68                 :            : 
      69                 :            : //////////////////////////////////////////////////////////////////////////
      70                 :            : 
      71                 :        188 : sal_uLong SwReader::Read( const Reader& rOptions )
      72                 :            : {
      73                 :            :     // Variable uebertragen
      74                 :        188 :     Reader* po = (Reader*) &rOptions;
      75                 :        188 :     po->pStrm = pStrm;
      76         [ +  - ]:        188 :     po->pStg  = pStg;
      77         [ +  - ]:        188 :     po->xStg  = xStg;
      78                 :        188 :     po->bInsertMode = 0 != pCrsr;
      79                 :            : 
      80                 :            :     // ist ein Medium angegeben, dann aus diesem die Streams besorgen
      81 [ +  - ][ -  + ]:        376 :     if( 0 != (po->pMedium = pMedium ) &&
                 [ -  + ]
      82         [ +  - ]:        188 :         !po->SetStrmStgPtr() )
      83                 :            :     {
      84                 :          0 :         po->SetReadUTF8( sal_False );
      85                 :          0 :         po->SetBlockMode( sal_False );
      86                 :          0 :         po->SetOrganizerMode( sal_False );
      87                 :          0 :         po->SetIgnoreHTMLComments( sal_False );
      88                 :          0 :         return ERR_SWG_FILE_FORMAT_ERROR;
      89                 :            :     }
      90                 :            : 
      91                 :        188 :     sal_uLong nError = 0L;
      92                 :            : 
      93         [ +  - ]:        188 :     GetDoc();
      94                 :            : 
      95                 :            :     // waehrend des einlesens kein OLE-Modified rufen
      96                 :        188 :     Link aOLELink( pDoc->GetOle2Link() );
      97         [ +  - ]:        188 :     pDoc->SetOle2Link( Link() );
      98                 :            : 
      99                 :        188 :     pDoc->SetInReading( true );
     100 [ +  + ][ +  - ]:        188 :     pDoc->SetInXMLImport( 0 != dynamic_cast< XMLReader* >(po) );
     101                 :            : 
     102                 :            :     SwPaM *pPam;
     103         [ -  + ]:        188 :     if( pCrsr )
     104                 :          0 :         pPam = pCrsr;
     105                 :            :     else
     106                 :            :     {
     107                 :            :         // Wenn der Reader nicht mit einem Shell konstruiert wurde,
     108                 :            :         // selber einen Pam machen.
     109 [ +  - ][ +  - ]:        188 :         SwNodeIndex nNode( pDoc->GetNodes().GetEndOfContent(), -1 );
     110 [ +  - ][ +  - ]:        188 :         pPam = new SwPaM( nNode );
     111                 :            :         // Bei Web-Dokumenten wird die Default-Vorlage schon im InitNew
     112                 :            :         // gesetzt und braucht deshalb nicht nochmal gesetzt zu werden.
     113                 :            :         // Das gilt natuerlich nicht, wenn der Filter nicht der HTML-Filter
     114                 :            :         // ist oder im ConvertFrom zuvor ein SetTemplateName gerufen
     115                 :            :         // wurde.
     116 [ +  - ][ +  + ]:        188 :         if( !pDoc->get(IDocumentSettingAccess::HTML_MODE) || ReadHTML != po || !po->pTemplate  )
         [ +  - ][ -  + ]
                 [ +  + ]
     117 [ +  - ][ +  - ]:        188 :             po->SetTemplate( *pDoc );
     118                 :            :     }
     119                 :            : 
     120                 :            :     // Pams sind ringfoermig verkettet. Aufhoeren, wenn man wieder beim
     121                 :            :     // ersten ist.
     122                 :        188 :     SwPaM *pEnd = pPam;
     123                 :        188 :     SwUndoInsDoc* pUndo = 0;
     124                 :            : 
     125                 :        188 :     sal_Bool bReadPageDescs = sal_False;
     126 [ +  - ][ +  - ]:        188 :     bool const bDocUndo = pDoc->GetIDocumentUndoRedo().DoesUndo();
     127 [ -  + ][ #  # ]:        188 :     sal_Bool bSaveUndo = bDocUndo && pCrsr;
     128         [ -  + ]:        188 :     if( bSaveUndo )
     129                 :            :     {
     130                 :            :         // das Einlesen von Seitenvorlagen ist nicht Undofaehig!
     131         [ #  # ]:          0 :         if( 0 != ( bReadPageDescs = po->aOpt.IsPageDescs() ) )
     132                 :            :         {
     133                 :          0 :             bSaveUndo = sal_False;
     134 [ #  # ][ #  # ]:          0 :             pDoc->GetIDocumentUndoRedo().DelAllUndoObj();
     135                 :            :         }
     136                 :            :         else
     137                 :            :         {
     138 [ #  # ][ #  # ]:          0 :             pDoc->GetIDocumentUndoRedo().ClearRedo();
     139 [ #  # ][ #  # ]:          0 :             pDoc->GetIDocumentUndoRedo().StartUndo( UNDO_INSDOKUMENT, NULL );
     140                 :            :         }
     141                 :            :     }
     142 [ +  - ][ +  - ]:        188 :     pDoc->GetIDocumentUndoRedo().DoUndo(false);
     143                 :            : 
     144 [ +  - ][ +  - ]:        188 :     SwNodeIndex aSplitIdx( pDoc->GetNodes() );
     145                 :            : 
     146         [ +  - ]:        188 :     RedlineMode_t eOld = pDoc->GetRedlineMode();
     147                 :        188 :     RedlineMode_t ePostReadRedlineMode( nsRedlineMode_t::REDLINE_IGNORE );
     148                 :            : 
     149                 :            :     // Array von FlyFormaten
     150         [ +  - ]:        188 :     SwFrmFmts aFlyFrmArr;
     151                 :            :     // only read templates? then ignore multi selection!
     152                 :        188 :     sal_Bool bFmtsOnly = po->aOpt.IsFmtsOnly();
     153                 :            : 
     154                 :          0 :     while( sal_True )
     155                 :            :     {
     156         [ -  + ]:        188 :         if( bSaveUndo )
     157 [ #  # ][ #  # ]:          0 :             pUndo = new SwUndoInsDoc( *pPam );
     158                 :            : 
     159         [ +  - ]:        188 :         pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE );
     160                 :            : 
     161                 :        188 :         SwPaM* pUndoPam = 0;
     162 [ +  - ][ -  + ]:        188 :         if( bDocUndo || pCrsr )
     163                 :            :         {
     164                 :            :             // Pam auf den Node davor setzen damit er nicht mit verschoben wird
     165                 :          0 :             const SwNodeIndex& rTmp = pPam->GetPoint()->nNode;
     166 [ #  # ][ #  # ]:          0 :             pUndoPam = new SwPaM( rTmp, rTmp, 0, -1 );
     167                 :            :         }
     168                 :            : 
     169                 :            :         // Speicher mal alle Fly's
     170         [ -  + ]:        188 :         if( pCrsr )
     171                 :            :         {
     172                 :          0 :             std::copy(pDoc->GetSpzFrmFmts()->begin(),
     173 [ #  # ][ #  # ]:          0 :                 pDoc->GetSpzFrmFmts()->end(), std::back_inserter(aFlyFrmArr));
     174                 :            :         }
     175                 :            : 
     176                 :        188 :         xub_StrLen nSttCntnt = pPam->GetPoint()->nContent.GetIndex();
     177                 :            : 
     178                 :            :         // damit fuer alle Reader die Ende-Position immer stimmt, hier
     179                 :            :         // pflegen.
     180                 :        188 :         SwCntntNode* pCNd = pPam->GetCntntNode();
     181 [ +  - ][ +  - ]:        188 :         xub_StrLen nEndCntnt = pCNd ? pCNd->Len() - nSttCntnt : 0;
     182         [ +  - ]:        188 :         SwNodeIndex aEndPos( pPam->GetPoint()->nNode, 1 );
     183                 :            : 
     184         [ +  - ]:        188 :         pDoc->SetRedlineMode_intern( eOld );
     185                 :            : 
     186         [ +  - ]:        188 :         nError = po->Read( *pDoc, GetBaseURL(), *pPam, aFileName );
     187                 :            : 
     188                 :            :         // an ODF document may contain redline mode in settings.xml; save it!
     189         [ +  - ]:        188 :         ePostReadRedlineMode = pDoc->GetRedlineMode();
     190                 :            : 
     191         [ +  - ]:        188 :         pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE );
     192                 :            : 
     193         [ +  + ]:        188 :         if( !IsError( nError ))     // dann setzen wir das Ende mal richtig
     194                 :            :         {
     195         [ +  - ]:        176 :             aEndPos--;
     196                 :        176 :             pCNd = aEndPos.GetNode().GetCntntNode();
     197 [ +  - ][ +  - ]:        176 :             if( !pCNd && 0 == ( pCNd = pDoc->GetNodes().GoPrevious( &aEndPos ) ))
         [ -  + ][ -  + ]
                 [ +  + ]
     198 [ #  # ][ #  # ]:          0 :                 pCNd = pDoc->GetNodes().GoNext( &aEndPos );
     199                 :            : 
     200         [ +  - ]:        176 :             pPam->GetPoint()->nNode = aEndPos;
     201         [ +  - ]:        176 :             xub_StrLen nLen = pCNd->Len();
     202         [ -  + ]:        176 :             if( nLen < nEndCntnt )
     203                 :          0 :                 nEndCntnt = 0;
     204                 :            :             else
     205                 :        176 :                 nEndCntnt = nLen - nEndCntnt;
     206 [ +  - ][ +  - ]:        176 :             pPam->GetPoint()->nContent.Assign( pCNd, nEndCntnt );
     207                 :            : 
     208         [ +  - ]:        176 :             const SwStartNode* pTblBoxStart = pCNd->FindTableBoxStartNode();
     209         [ -  + ]:        176 :             if ( pTblBoxStart )
     210                 :            :             {
     211         [ #  # ]:          0 :                 SwTableBox* pBox = pTblBoxStart->GetTblBox();
     212         [ #  # ]:          0 :                 if ( pBox )
     213                 :            :                 {
     214         [ #  # ]:          0 :                     pDoc->ChkBoxNumFmt( *pBox, sal_True );
     215                 :            :                 }
     216                 :            :             }
     217                 :            :         }
     218                 :            : 
     219         [ -  + ]:        188 :         if( pCrsr )
     220                 :            :         {
     221         [ #  # ]:          0 :             *pUndoPam->GetMark() = *pPam->GetPoint();
     222         [ #  # ]:          0 :             pUndoPam->GetPoint()->nNode++;
     223                 :          0 :             SwNode* pNd = pUndoPam->GetNode();
     224         [ #  # ]:          0 :             if( pNd->IsCntntNode() )
     225                 :          0 :                 pUndoPam->GetPoint()->nContent.Assign(
     226 [ #  # ][ #  # ]:          0 :                                     (SwCntntNode*)pNd, nSttCntnt );
         [ #  # ][ #  # ]
     227                 :            :             else
     228         [ #  # ]:          0 :                 pUndoPam->GetPoint()->nContent.Assign( 0, 0 );
     229                 :            : 
     230         [ #  # ]:          0 :             int bChkHeaderFooter = pNd->FindHeaderStartNode() ||
     231 [ #  # ][ #  # ]:          0 :                                    pNd->FindFooterStartNode();
                 [ #  # ]
     232                 :            : 
     233                 :            :             // Suche alle neuen Fly's und speicher sie als einzelne Undo
     234                 :            :             // Objecte
     235         [ #  # ]:          0 :             for( sal_uInt16 n = 0; n < pDoc->GetSpzFrmFmts()->size(); ++n )
     236                 :            :             {
     237                 :          0 :                 SwFrmFmt* pFrmFmt = (*pDoc->GetSpzFrmFmts())[ n ];
     238         [ #  # ]:          0 :                 const SwFmtAnchor& rAnchor = pFrmFmt->GetAnchor();
     239 [ #  # ][ #  # ]:          0 :                 if( USHRT_MAX == aFlyFrmArr.GetPos( pFrmFmt) )
     240                 :            :                 {
     241                 :            :                     SwPosition const*const pFrameAnchor(
     242         [ #  # ]:          0 :                             rAnchor.GetCntntAnchor());
     243 [ #  # ][ #  #  :          0 :                     if  (   (FLY_AT_PAGE == rAnchor.GetAnchorId())
          #  #  #  #  #  
                #  #  # ]
         [ #  # ][ #  # ]
     244                 :            :                         ||  (   pFrameAnchor
     245                 :          0 :                             &&  (   (   (FLY_AT_PARA == rAnchor.GetAnchorId())
     246                 :          0 :                                     &&  (   (pUndoPam->GetPoint()->nNode ==
     247                 :          0 :                                              pFrameAnchor->nNode)
     248                 :          0 :                                         ||  (pUndoPam->GetMark()->nNode ==
     249                 :          0 :                                              pFrameAnchor->nNode)
     250                 :            :                                         )
     251                 :            :                                     )
     252                 :            :                                 // #i97570# also check frames anchored AT char
     253                 :          0 :                                 ||  (   (FLY_AT_CHAR == rAnchor.GetAnchorId())
     254                 :            :                                     &&  !IsDestroyFrameAnchoredAtChar(
     255                 :            :                                               *pFrameAnchor,
     256                 :          0 :                                               *pUndoPam->GetPoint(),
     257         [ #  # ]:          0 :                                               *pUndoPam->GetMark())
     258                 :            :                                     )
     259                 :            :                                 )
     260                 :            :                             )
     261                 :            :                         )
     262                 :            :                     {
     263   [ #  #  #  #  :          0 :                         if( bChkHeaderFooter &&
           #  # ][ #  # ]
     264                 :          0 :                             (FLY_AT_PARA == rAnchor.GetAnchorId()) &&
     265                 :          0 :                             RES_DRAWFRMFMT == pFrmFmt->Which() )
     266                 :            :                         {
     267                 :            :                             // DrawObjecte in Kopf-/Fusszeilen ist nicht
     268                 :            :                             // erlaubt!
     269         [ #  # ]:          0 :                             pFrmFmt->DelFrms();
     270         [ #  # ]:          0 :                             pDoc->DelFrmFmt( pFrmFmt );
     271                 :          0 :                             --n;
     272                 :            :                         }
     273                 :            :                         else
     274                 :            :                         {
     275         [ #  # ]:          0 :                             if( bSaveUndo )
     276                 :            :                             {
     277         [ #  # ]:          0 :                                 pDoc->SetRedlineMode_intern( eOld );
     278                 :            :                                 // UGLY: temp. enable undo
     279 [ #  # ][ #  # ]:          0 :                                 pDoc->GetIDocumentUndoRedo().DoUndo(true);
     280         [ #  # ]:          0 :                                 pDoc->GetIDocumentUndoRedo().AppendUndo(
     281 [ #  # ][ #  # ]:          0 :                                     new SwUndoInsLayFmt( pFrmFmt,0,0 ) );
                 [ #  # ]
     282 [ #  # ][ #  # ]:          0 :                                 pDoc->GetIDocumentUndoRedo().DoUndo(false);
     283         [ #  # ]:          0 :                                 pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE );
     284                 :            :                             }
     285         [ #  # ]:          0 :                             if( pFrmFmt->GetDepends() )
     286                 :            :                             {
     287                 :            :                                 // beim Insert legen Draw-Objecte einen Frame an
     288                 :            :                                 // also weg damit.
     289         [ #  # ]:          0 :                                 pFrmFmt->DelFrms();
     290                 :            :                             }
     291                 :            : 
     292         [ #  # ]:          0 :                             if (FLY_AT_PAGE == rAnchor.GetAnchorId())
     293                 :            :                             {
     294 [ #  # ][ #  # ]:          0 :                                 if( !rAnchor.GetCntntAnchor() )
     295                 :            :                                 {
     296         [ #  # ]:          0 :                                     pFrmFmt->MakeFrms();
     297                 :            :                                 }
     298         [ #  # ]:          0 :                                 else if( pCrsr )
     299                 :            :                                 {
     300                 :            :                                     // seitengebundene Flys eingefuegt, dann schalte
     301                 :            :                                     // die Optimierungs-Flags vom SwDoc ab. Sonst
     302                 :            :                                     // werden die Flys nicht an der Position erzeugt.
     303         [ #  # ]:          0 :                                     pDoc->SetLoaded( sal_False );
     304                 :            :                                 }
     305                 :            :                             }
     306                 :            :                             else
     307         [ #  # ]:          0 :                                 pFrmFmt->MakeFrms();
     308                 :            :                         }
     309                 :            :                     }
     310                 :            :                 }
     311                 :            :             }
     312         [ #  # ]:          0 :             if( !aFlyFrmArr.empty() )
     313                 :          0 :                 aFlyFrmArr.clear();
     314                 :            : 
     315         [ #  # ]:          0 :             pDoc->SetRedlineMode_intern( eOld );
     316 [ #  # ][ #  # ]:          0 :             if( pDoc->IsRedlineOn() )
     317 [ #  # ][ #  # ]:          0 :                 pDoc->AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, *pUndoPam ), true);
                 [ #  # ]
     318                 :            :             else
     319         [ #  # ]:          0 :                 pDoc->SplitRedline( *pUndoPam );
     320         [ #  # ]:          0 :             pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE );
     321                 :            :         }
     322         [ -  + ]:        188 :         if( bSaveUndo )
     323                 :            :         {
     324         [ #  # ]:          0 :             pDoc->SetRedlineMode_intern( eOld );
     325         [ #  # ]:          0 :             pUndo->SetInsertRange( *pUndoPam, sal_False );
     326                 :            :             // UGLY: temp. enable undo
     327 [ #  # ][ #  # ]:          0 :             pDoc->GetIDocumentUndoRedo().DoUndo(true);
     328 [ #  # ][ #  # ]:          0 :             pDoc->GetIDocumentUndoRedo().AppendUndo( pUndo );
     329 [ #  # ][ #  # ]:          0 :             pDoc->GetIDocumentUndoRedo().DoUndo(false);
     330         [ #  # ]:          0 :             pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE );
     331                 :            :         }
     332                 :            : 
     333 [ -  + ][ #  # ]:        188 :         delete pUndoPam;
     334                 :            : 
     335                 :        188 :         pPam = (SwPaM *) pPam->GetNext();
     336         [ +  - ]:        188 :         if( pPam == pEnd )
     337                 :            :             break;
     338                 :            : 
     339                 :            :         // only read templates? then ignore multi selection! Bug 68593
     340         [ #  # ]:          0 :         if( bFmtsOnly )
     341                 :            :             break;
     342                 :            : 
     343                 :            :         /*
     344                 :            :          * !!! man muss selbst den Status vom Stream zuruecksetzen. !!!
     345                 :            :          *     Beim seekg wird der akt. Status, eof- und bad-Bit
     346                 :            :          *     gesetzt, warum weiss keiner
     347                 :            :          */
     348         [ #  # ]:          0 :         if( pStrm )
     349                 :            :         {
     350         [ #  # ]:          0 :             pStrm->Seek(0);
     351         [ #  # ]:          0 :             pStrm->ResetError();
     352                 :            :         }
     353 [ +  - ][ -  + ]:        188 :     }
     354                 :            : 
     355                 :        188 :     pDoc->SetInReading( false );
     356                 :        188 :     pDoc->SetInXMLImport( false );
     357                 :            : 
     358         [ +  - ]:        188 :     pDoc->InvalidateNumRules();
     359         [ +  - ]:        188 :     pDoc->UpdateNumRule();
     360         [ +  - ]:        188 :     pDoc->ChkCondColls();
     361         [ +  - ]:        188 :     pDoc->SetAllUniqueFlyNames();
     362                 :            : 
     363 [ +  - ][ +  - ]:        188 :     pDoc->GetIDocumentUndoRedo().DoUndo(bDocUndo);
     364         [ +  - ]:        188 :     if (!bReadPageDescs)
     365                 :            :     {
     366         [ -  + ]:        188 :         if( bSaveUndo )
     367                 :            :         {
     368         [ #  # ]:          0 :             pDoc->SetRedlineMode_intern( eOld );
     369 [ #  # ][ #  # ]:          0 :             pDoc->GetIDocumentUndoRedo().EndUndo( UNDO_INSDOKUMENT, NULL );
     370         [ #  # ]:          0 :             pDoc->SetRedlineMode_intern( nsRedlineMode_t::REDLINE_IGNORE );
     371                 :            :         }
     372                 :            :     }
     373                 :            : 
     374                 :            :     // Wenn der Pam nur fuers Lesen konstruiert wurde, jetzt zerstoeren.
     375         [ +  - ]:        188 :     if( !pCrsr )
     376                 :            :     {
     377 [ +  - ][ +  - ]:        188 :         delete pPam;          // ein neues aufgemacht.
     378                 :            : 
     379                 :            :         // #i42634# Moved common code of SwReader::Read() and
     380                 :            :         // SwDocShell::UpdateLinks() to new SwDoc::UpdateLinks():
     381                 :            :     // ATM still with Update
     382         [ +  - ]:        188 :         pDoc->UpdateLinks( sal_True );
     383                 :            : 
     384                 :            :         // not insert: set the redline mode read from settings.xml
     385                 :            :         eOld = static_cast<RedlineMode_t>(
     386                 :        188 :                 ePostReadRedlineMode & ~nsRedlineMode_t::REDLINE_IGNORE);
     387                 :            : 
     388         [ +  - ]:        188 :         pDoc->SetFieldsDirty(false, NULL, 0);
     389                 :            :     }
     390                 :            : 
     391         [ +  - ]:        188 :     pDoc->SetRedlineMode_intern( eOld );
     392                 :        188 :     pDoc->SetOle2Link( aOLELink );
     393                 :            : 
     394         [ -  + ]:        188 :     if( pCrsr )                 // das Doc ist jetzt modifiziert
     395         [ #  # ]:          0 :         pDoc->SetModified();
     396                 :            :     // #i38810# - If links have been updated, the document
     397                 :            :     // have to be modified. During update of links the OLE link at the document
     398                 :            :     // isn't set. Thus, the document's modified state has to be set again after
     399                 :            :     // the OLE link is restored - see above <pDoc->SetOle2Link( aOLELink )>.
     400 [ +  - ][ -  + ]:        188 :     if ( pDoc->LinksUpdated() )
     401                 :            :     {
     402         [ #  # ]:          0 :         pDoc->SetModified();
     403                 :            :     }
     404                 :            : 
     405                 :        188 :     po->SetReadUTF8( sal_False );
     406                 :        188 :     po->SetBlockMode( sal_False );
     407                 :        188 :     po->SetOrganizerMode( sal_False );
     408                 :        188 :     po->SetIgnoreHTMLComments( sal_False );
     409                 :            : 
     410 [ +  - ][ +  - ]:        188 :     return nError;
     411                 :            : }
     412                 :            : 
     413                 :            : 
     414                 :            : /*
     415                 :            :  * Konstruktoren, Destruktor
     416                 :            :  */
     417                 :            : 
     418                 :        188 : SwReader::SwReader(SfxMedium& rMedium, const String& rFileName, SwDoc *pDocument)
     419                 :            :     : SwDocFac(pDocument), pStrm(0), pMedium(&rMedium), pCrsr(0),
     420 [ +  - ][ +  - ]:        188 :     aFileName(rFileName)
     421                 :            : {
     422 [ +  - ][ +  - ]:        188 :     SetBaseURL( rMedium.GetBaseURL() );
         [ +  - ][ +  - ]
     423                 :        188 : }
     424                 :            : 
     425                 :            : // In ein existierendes Dokument einlesen
     426                 :            : 
     427                 :          0 : SwReader::SwReader(SvStream& rStrm, const String& rFileName, const String& rBaseURL, SwPaM& rPam)
     428                 :            :     : SwDocFac(rPam.GetDoc()), pStrm(&rStrm), pMedium(0), pCrsr(&rPam),
     429 [ #  # ][ #  # ]:          0 :     aFileName(rFileName)
     430                 :            : {
     431         [ #  # ]:          0 :     SetBaseURL( rBaseURL );
     432                 :          0 : }
     433                 :            : 
     434                 :          0 : SwReader::SwReader(SfxMedium& rMedium, const String& rFileName, SwPaM& rPam)
     435                 :            :     : SwDocFac(rPam.GetDoc()), pStrm(0), pMedium(&rMedium),
     436 [ #  # ][ #  # ]:          0 :     pCrsr(&rPam), aFileName(rFileName)
     437                 :            : {
     438 [ #  # ][ #  # ]:          0 :     SetBaseURL( rMedium.GetBaseURL() );
         [ #  # ][ #  # ]
     439                 :          0 : }
     440                 :            : 
     441                 :          0 : SwReader::SwReader( const uno::Reference < embed::XStorage > &rStg, const String& rFilename, SwPaM &rPam )
     442 [ #  # ][ #  # ]:          0 :     : SwDocFac(rPam.GetDoc()), pStrm(0), xStg( rStg ), pMedium(0), pCrsr(&rPam), aFileName(rFilename)
     443                 :            : {
     444                 :          0 : }
     445                 :            : 
     446                 :        304 : Reader::Reader()
     447                 :            :     : pTemplate(0),
     448                 :            :     aDStamp( Date::EMPTY ),
     449                 :            :     aTStamp( Time::EMPTY ),
     450                 :            :     aChkDateTime( DateTime::EMPTY ),
     451                 :            :     pStrm(0), pMedium(0), bInsertMode(0),
     452                 :            :     bTmplBrowseMode(0), bReadUTF8(0), bBlockMode(0), bOrganizerMode(0),
     453         [ +  - ]:        304 :     bHasAskTemplateName(0), bIgnoreHTMLComments(0)
     454                 :            : {
     455                 :        304 : }
     456                 :            : 
     457 [ +  - ][ +  - ]:        304 : Reader::~Reader()
     458                 :            : {
     459 [ +  + ][ +  - ]:        304 :     delete pTemplate;
     460         [ -  + ]:        304 : }
     461                 :            : 
     462                 :         49 : String Reader::GetTemplateName() const
     463                 :            : {
     464                 :         49 :     return aEmptyStr;
     465                 :            : }
     466                 :            : 
     467                 :            : // Die Filter-Vorlage laden, setzen und wieder freigeben
     468                 :        196 : SwDoc* Reader::GetTemplateDoc()
     469                 :            : {
     470         [ +  + ]:        196 :     if( !bHasAskTemplateName )
     471                 :            :     {
     472         [ +  - ]:         51 :         SetTemplateName( GetTemplateName() );
     473                 :         51 :         bHasAskTemplateName = sal_True;
     474                 :            :     }
     475                 :            : 
     476         [ +  + ]:        196 :     if( !aTemplateNm.Len() )
     477                 :        188 :         ClearTemplate();
     478                 :            :     else
     479                 :            :     {
     480 [ +  - ][ +  - ]:          8 :         INetURLObject aTDir( aTemplateNm );
     481 [ +  - ][ +  - ]:          8 :         String aFileName = aTDir.GetMainURL( INetURLObject::NO_DECODE );
     482                 :            :         OSL_ENSURE( !aTDir.HasError(), "No absolute path for template name!" );
     483         [ +  - ]:          8 :         DateTime aCurrDateTime( DateTime::SYSTEM );
     484                 :          8 :         sal_Bool bLoad = sal_False;
     485                 :            : 
     486                 :            :         // Wenn das Template schon mal geladen wurde, nur einmal pro
     487                 :            :         // Minute nachschauen, ob es geaendert wurde.
     488 [ +  - ][ +  - ]:          8 :         if( !pTemplate || aCurrDateTime >= aChkDateTime )
         [ -  + ][ -  + ]
     489                 :            :         {
     490                 :          0 :             Date aTstDate( Date::EMPTY );
     491                 :          0 :             Time aTstTime( Time::EMPTY );
     492 [ #  # ][ #  #  :          0 :             if( FStatHelper::GetModifiedDateTimeOfFile(
             #  #  #  # ]
                 [ #  # ]
     493                 :            :                             aTDir.GetMainURL( INetURLObject::NO_DECODE ),
     494 [ #  # ][ #  # ]:          0 :                             &aTstDate, &aTstTime ) &&
         [ #  # ][ #  # ]
     495                 :          0 :                 ( !pTemplate || aDStamp != aTstDate || aTStamp != aTstTime ))
     496                 :            :             {
     497                 :          0 :                 bLoad = sal_True;
     498                 :          0 :                 aDStamp = aTstDate;
     499         [ #  # ]:          0 :                 aTStamp = aTstTime;
     500                 :            :             }
     501                 :            : 
     502                 :            :             // Erst in einer Minute wieder mal nachschauen, ob sich die
     503                 :            :             // Vorlage geaendert hat.
     504         [ #  # ]:          0 :             aChkDateTime = aCurrDateTime;
     505 [ #  # ][ #  # ]:          0 :             aChkDateTime += Time( 0L, 1L );
     506                 :            :         }
     507                 :            : 
     508         [ -  + ]:          8 :         if( bLoad )
     509                 :            :         {
     510         [ #  # ]:          0 :             ClearTemplate();
     511                 :            :             OSL_ENSURE( !pTemplate, "Who holds the template doc?" );
     512                 :            : 
     513                 :            :                 // If the writer module is not installed,
     514                 :            :                 // we cannot create a SwDocShell. We could create a
     515                 :            :                 // SwWebDocShell however, because this exists always
     516                 :            :                 // for the help.
     517         [ #  # ]:          0 :                 SvtModuleOptions aModuleOptions;
     518 [ #  # ][ #  # ]:          0 :                 if( aModuleOptions.IsWriter() )
     519                 :            :                 {
     520                 :            :                     SwDocShell *pDocSh =
     521 [ #  # ][ #  # ]:          0 :                         new SwDocShell ( SFX_CREATE_MODE_INTERNAL );
     522         [ #  # ]:          0 :                     SfxObjectShellLock xDocSh = pDocSh;
     523 [ #  # ][ #  # ]:          0 :                     if( pDocSh->DoInitNew( 0 ) )
     524                 :            :                     {
     525                 :          0 :                         pTemplate = pDocSh->GetDoc();
     526         [ #  # ]:          0 :                         pTemplate->SetOle2Link( Link() );
     527                 :            :                         // always FALSE
     528 [ #  # ][ #  # ]:          0 :                         pTemplate->GetIDocumentUndoRedo().DoUndo( false );
     529         [ #  # ]:          0 :                         pTemplate->set(IDocumentSettingAccess::BROWSE_MODE, bTmplBrowseMode );
     530         [ #  # ]:          0 :                         pTemplate->RemoveAllFmtLanguageDependencies();
     531                 :            : 
     532                 :          0 :                         ReadXML->SetOrganizerMode( sal_True );
     533         [ #  # ]:          0 :                         SfxMedium aMedium( aFileName, sal_False );
     534         [ #  # ]:          0 :                         SwReader aRdr( aMedium, aEmptyStr, pTemplate );
     535         [ #  # ]:          0 :                         aRdr.Read( *ReadXML );
     536                 :          0 :                         ReadXML->SetOrganizerMode( sal_False );
     537                 :            : 
     538 [ #  # ][ #  # ]:          0 :                         pTemplate->acquire();
                 [ #  # ]
     539         [ #  # ]:          0 :                     }
     540         [ #  # ]:          0 :                 }
     541                 :            :         }
     542                 :            : 
     543                 :            :         OSL_ENSURE( !pTemplate || FStatHelper::IsDocument( aFileName ) ||
     544                 :            :                 aTemplateNm.EqualsAscii( "$$Dummy$$" ),
     545 [ +  - ][ +  - ]:          8 :                 "TemplatePtr but no template exist!" );
     546                 :            :     }
     547                 :            : 
     548                 :        196 :     return pTemplate;
     549                 :            : }
     550                 :            : 
     551                 :        190 : sal_Bool Reader::SetTemplate( SwDoc& rDoc )
     552                 :            : {
     553                 :        190 :     sal_Bool bRet = sal_False;
     554                 :            : 
     555                 :        190 :     GetTemplateDoc();
     556         [ +  + ]:        190 :     if( pTemplate )
     557                 :            :     {
     558                 :          4 :         rDoc.RemoveAllFmtLanguageDependencies();
     559                 :          4 :         rDoc.ReplaceStyles( *pTemplate );
     560                 :          4 :         rDoc.SetFixFields(false, NULL);
     561                 :          4 :         bRet = sal_True;
     562                 :            :     }
     563                 :            : 
     564                 :        190 :     return bRet;
     565                 :            : }
     566                 :            : 
     567                 :        190 : void Reader::ClearTemplate()
     568                 :            : {
     569         [ -  + ]:        190 :     if( pTemplate )
     570                 :            :     {
     571         [ #  # ]:          0 :         if( 0 == pTemplate->release() )
     572                 :          0 :             delete pTemplate,
     573         [ #  # ]:          0 :         pTemplate = 0;
     574                 :            :     }
     575                 :        190 : }
     576                 :            : 
     577                 :         51 : void Reader::SetTemplateName( const String& rDir )
     578                 :            : {
     579 [ -  + ][ #  # ]:         51 :     if( rDir.Len() && aTemplateNm != rDir )
                 [ -  + ]
     580                 :            :     {
     581                 :          0 :         ClearTemplate();
     582                 :          0 :         aTemplateNm = rDir;
     583                 :            :     }
     584                 :         51 : }
     585                 :            : 
     586                 :          2 : void Reader::MakeHTMLDummyTemplateDoc()
     587                 :            : {
     588                 :          2 :     ClearTemplate();
     589         [ +  - ]:          2 :     pTemplate = new SwDoc;
     590                 :          2 :     pTemplate->acquire();
     591                 :          2 :     pTemplate->set(IDocumentSettingAccess::BROWSE_MODE, bTmplBrowseMode );
     592                 :          2 :     pTemplate->getPrinter( true );
     593                 :          2 :     pTemplate->RemoveAllFmtLanguageDependencies();
     594         [ +  - ]:          2 :     aChkDateTime = Date( 1, 1, 2300 );  // 2300. Jahrtausend sollte reichen
     595                 :          2 :     aTemplateNm.AssignAscii( "$$Dummy$$" );
     596                 :          2 : }
     597                 :            : 
     598                 :            : // alle die die Streams / Storages nicht geoeffnet brauchen,
     599                 :            : // muessen die Methode ueberladen
     600                 :        186 : int Reader::SetStrmStgPtr()
     601                 :            : {
     602                 :            :     OSL_ENSURE( pMedium, "Wo ist das Medium??" );
     603                 :            : 
     604         [ +  + ]:        186 :     if( pMedium->IsStorage() )
     605                 :            :     {
     606         [ +  - ]:         66 :         if( SW_STORAGE_READER & GetReaderType() )
     607                 :            :         {
     608         [ +  - ]:         66 :             xStg = pMedium->GetStorage();
     609                 :         66 :             return sal_True;
     610                 :            :         }
     611                 :            :     }
     612                 :            :     else
     613                 :            :     {
     614                 :        120 :         pStrm = pMedium->GetInStream();
     615 [ +  + ][ +  - ]:        120 :         if ( pStrm && SotStorage::IsStorageFile(pStrm) && (SW_STORAGE_READER & GetReaderType()) )
         [ +  + ][ +  - ]
     616                 :            :         {
     617         [ +  - ]:        108 :             pStg = new SotStorage( *pStrm );
     618                 :        108 :             pStrm = NULL;
     619                 :            :         }
     620         [ -  + ]:         12 :         else if ( !(SW_STREAM_READER & GetReaderType()) )
     621                 :            :         {
     622                 :          0 :             pStrm = NULL;
     623                 :          0 :             return sal_False;
     624                 :            :         }
     625                 :            : 
     626                 :        120 :         return sal_True;
     627                 :            :     }
     628                 :        186 :     return sal_False;
     629                 :            : }
     630                 :            : 
     631                 :            : 
     632                 :         20 : int Reader::GetReaderType()
     633                 :            : {
     634                 :         20 :     return SW_STREAM_READER;
     635                 :            : }
     636                 :            : 
     637                 :            : 
     638                 :         14 : void Reader::SetFltName( const String& )
     639                 :            : {
     640                 :         14 : }
     641                 :            : 
     642                 :            : 
     643                 :          0 : void Reader::ResetFrmFmtAttrs( SfxItemSet &rFrmSet )
     644                 :            : {
     645         [ #  # ]:          0 :     rFrmSet.Put( SvxLRSpaceItem(RES_LR_SPACE) );
     646         [ #  # ]:          0 :     rFrmSet.Put( SvxULSpaceItem(RES_UL_SPACE) );
     647         [ #  # ]:          0 :     rFrmSet.Put( SvxBoxItem(RES_BOX) );
     648                 :          0 : }
     649                 :            : 
     650                 :            : 
     651                 :        110 : void Reader::ResetFrmFmts( SwDoc& rDoc )
     652                 :            : {
     653         [ +  + ]:        440 :     for (sal_uInt16 i=0; i<3; ++i)
     654                 :            :     {
     655                 :            :         sal_uInt16 nPoolId;
     656      [ +  +  + ]:        330 :         switch (i)
     657                 :            :         {
     658                 :            :             default:
     659                 :            :                 OSL_ENSURE(i == 0, "Impossible");
     660                 :            :                 //fallthrough
     661                 :            :             case 0:
     662                 :        110 :                 nPoolId = RES_POOLFRM_FRAME;
     663                 :        110 :                 break;
     664                 :            :             case 1:
     665                 :        110 :                 nPoolId = RES_POOLFRM_GRAPHIC;
     666                 :        110 :                 break;
     667                 :            :             case 2:
     668                 :        110 :                 nPoolId = RES_POOLFRM_OLE;
     669                 :        110 :                 break;
     670                 :            :         }
     671                 :            : 
     672                 :        330 :         SwFrmFmt *pFrmFmt = rDoc.GetFrmFmtFromPool( nPoolId );
     673                 :            : 
     674                 :        330 :         pFrmFmt->ResetFmtAttr( RES_LR_SPACE );
     675                 :        330 :         pFrmFmt->ResetFmtAttr( RES_UL_SPACE );
     676                 :        330 :         pFrmFmt->ResetFmtAttr( RES_BOX );
     677                 :            :     }
     678                 :        110 : }
     679                 :            : 
     680                 :            :     // read the sections of the document, which is equal to the medium.
     681                 :            :     // returns the count of it
     682                 :          0 : size_t Reader::GetSectionList( SfxMedium&, std::vector<String*>& ) const
     683                 :            : {
     684                 :          0 :     return 0;
     685                 :            : }
     686                 :            : 
     687                 :            : // ------------------------------------------------
     688                 :          0 : sal_Bool SwReader::HasGlossaries( const Reader& rOptions )
     689                 :            : {
     690                 :            :     // Variable uebertragen
     691                 :          0 :     Reader* po = (Reader*) &rOptions;
     692                 :          0 :     po->pStrm = pStrm;
     693                 :          0 :     po->pStg  = pStg;
     694                 :          0 :     po->bInsertMode = sal_False;
     695                 :            : 
     696                 :            :     // ist ein Medium angegeben, dann aus diesem die Streams besorgen
     697                 :          0 :     sal_Bool bRet = sal_False;
     698 [ #  # ][ #  # ]:          0 :     if( !( 0 != (po->pMedium = pMedium ) && !po->SetStrmStgPtr() ))
                 [ #  # ]
     699                 :          0 :         bRet = po->HasGlossaries();
     700                 :          0 :     return bRet;
     701                 :            : }
     702                 :            : 
     703                 :          0 : sal_Bool SwReader::ReadGlossaries( const Reader& rOptions,
     704                 :            :                                 SwTextBlocks& rBlocks, sal_Bool bSaveRelFiles )
     705                 :            : {
     706                 :            :     // Variable uebertragen
     707                 :          0 :     Reader* po = (Reader*) &rOptions;
     708                 :          0 :     po->pStrm = pStrm;
     709                 :          0 :     po->pStg  = pStg;
     710                 :          0 :     po->bInsertMode = sal_False;
     711                 :            : 
     712                 :            :     // ist ein Medium angegeben, dann aus diesem die Streams besorgen
     713                 :          0 :     sal_Bool bRet = sal_False;
     714 [ #  # ][ #  # ]:          0 :     if( !( 0 != (po->pMedium = pMedium ) && !po->SetStrmStgPtr() ))
                 [ #  # ]
     715                 :          0 :         bRet = po->ReadGlossaries( rBlocks, bSaveRelFiles );
     716                 :          0 :     return bRet;
     717                 :            : }
     718                 :            : 
     719                 :          0 : sal_Bool Reader::HasGlossaries() const
     720                 :            : {
     721                 :          0 :     return sal_False;
     722                 :            : }
     723                 :            : 
     724                 :          0 : sal_Bool Reader::ReadGlossaries( SwTextBlocks&, sal_Bool ) const
     725                 :            : {
     726                 :          0 :     return sal_False;
     727                 :            : }
     728                 :            : 
     729                 :            : // ------------------------------------------------
     730                 :            : 
     731                 :          0 : int StgReader::GetReaderType()
     732                 :            : {
     733                 :          0 :     return SW_STORAGE_READER;
     734                 :            : }
     735                 :            : 
     736                 :            : 
     737                 :            : 
     738                 :            : 
     739                 :            : /*
     740                 :            :  * Writer
     741                 :            :  */
     742                 :            : 
     743                 :            : /*
     744                 :            :  * Konstruktoren, Destruktoren sind inline (inc/shellio.hxx).
     745                 :            :  */
     746                 :            : 
     747                 :          2 : SwWriter::SwWriter(SvStream& rStrm, SwCrsrShell &rShell, sal_Bool bInWriteAll)
     748                 :            :     : pStrm(&rStrm), pMedium(0), pOutPam(0), pShell(&rShell),
     749                 :          2 :     rDoc(*rShell.GetDoc()), bWriteAll(bInWriteAll)
     750                 :            : {
     751                 :          2 : }
     752                 :            : 
     753                 :          0 : SwWriter::SwWriter(SvStream& rStrm,SwDoc &rDocument)
     754                 :            :     : pStrm(&rStrm), pMedium(0), pOutPam(0), pShell(0), rDoc(rDocument),
     755                 :          0 :     bWriteAll(true)
     756                 :            : {
     757                 :          0 : }
     758                 :            : 
     759                 :      10463 : SwWriter::SwWriter(SvStream& rStrm, SwPaM& rPam, sal_Bool bInWriteAll)
     760                 :            :     : pStrm(&rStrm), pMedium(0), pOutPam(&rPam), pShell(0),
     761                 :      10463 :     rDoc(*rPam.GetDoc()), bWriteAll(bInWriteAll)
     762                 :            : {
     763                 :      10463 : }
     764                 :            : 
     765                 :          2 : SwWriter::SwWriter( const uno::Reference < embed::XStorage >& rStg, SwDoc &rDocument)
     766                 :          2 :     : pStrm(0), xStg( rStg ), pMedium(0), pOutPam(0), pShell(0), rDoc(rDocument), bWriteAll(true)
     767                 :            : {
     768                 :          2 : }
     769                 :            : 
     770                 :         11 : SwWriter::SwWriter(SfxMedium& rMedium, SwCrsrShell &rShell, sal_Bool bInWriteAll)
     771                 :            :     : pStrm(0), pMedium(&rMedium), pOutPam(0), pShell(&rShell),
     772                 :         11 :     rDoc(*rShell.GetDoc()), bWriteAll(bInWriteAll)
     773                 :            : {
     774                 :         11 : }
     775                 :            : 
     776                 :         22 : SwWriter::SwWriter(SfxMedium& rMedium, SwDoc &rDocument)
     777                 :            :     : pStrm(0), pMedium(&rMedium), pOutPam(0), pShell(0), rDoc(rDocument),
     778                 :         22 :     bWriteAll(true)
     779                 :            : {
     780                 :         22 : }
     781                 :            : 
     782                 :      10500 : sal_uLong SwWriter::Write( WriterRef& rxWriter, const String* pRealFileName )
     783                 :            : {
     784                 :            :     // #i73788#
     785         [ +  - ]:      10500 :     SwPauseThreadStarting aPauseThreadStarting;
     786                 :            : 
     787                 :      10500 :     sal_Bool bHasMark = sal_False;
     788                 :            :     SwPaM * pPam;
     789                 :            : 
     790                 :      10500 :     SwDoc *pDoc = 0;
     791                 :            : 
     792 [ +  + ][ +  + ]:      10500 :     if ( pShell && !bWriteAll && pShell->IsTableMode() )
         [ -  + ][ -  + ]
     793                 :            :     {
     794                 :          0 :         bWriteAll = sal_True;
     795 [ #  # ][ #  # ]:          0 :         pDoc = new SwDoc;
     796         [ #  # ]:          0 :         pDoc->acquire();
     797                 :            : 
     798                 :            :         // kopiere Teile aus einer Tabelle: lege eine Tabelle mit der Breite
     799                 :            :         // von der Originalen an und kopiere die selectierten Boxen.
     800                 :            :         // Die Groessen werden prozentual korrigiert.
     801                 :            : 
     802                 :            :         // lasse ueber das Layout die Boxen suchen
     803         [ #  # ]:          0 :         SwSelBoxes aBoxes;
     804         [ #  # ]:          0 :         GetTblSel( *pShell, aBoxes );
     805         [ #  # ]:          0 :         SwTableNode* pTblNd = (SwTableNode*)aBoxes[0]->GetSttNd()->StartOfSectionNode();
     806 [ #  # ][ #  # ]:          0 :         SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfExtras(), 2 );
     807                 :          0 :         SwCntntNode *pNd = aIdx.GetNode().GetCntntNode();
     808                 :            :         OSL_ENSURE( pNd, "Node not found" );
     809 [ #  # ][ #  # ]:          0 :         SwPosition aPos( aIdx, SwIndex( pNd ) );
         [ #  # ][ #  # ]
     810 [ #  # ][ #  # ]:          0 :         pTblNd->GetTable().MakeCopy( pDoc, aPos, aBoxes );
                 [ #  # ]
     811                 :            :     }
     812                 :            : 
     813 [ +  + ][ +  + ]:      10500 :     if( !bWriteAll && ( pShell || pOutPam ))
                 [ +  - ]
     814                 :            :     {
     815         [ +  + ]:      10465 :         if( pShell )
     816         [ +  - ]:          2 :             pPam = pShell->GetCrsr();
     817                 :            :         else
     818                 :      10463 :             pPam = pOutPam;
     819                 :            : 
     820                 :      10465 :         SwPaM *pEnd = pPam;
     821                 :            : 
     822                 :            :         // Erste Runde: Nachsehen, ob eine Selektion besteht.
     823                 :          0 :         while(sal_True)
     824                 :            :         {
     825 [ +  - ][ +  - ]:      10465 :             bHasMark = bHasMark || pPam->HasMark();
     826                 :      10465 :             pPam = (SwPaM *) pPam->GetNext();
     827 [ #  # ][ -  + ]:      10465 :             if(bHasMark || pPam == pEnd)
     828                 :      10465 :                 break;
     829                 :            :         }
     830                 :            : 
     831                 :            :         // Wenn keine Selektion besteht, eine ueber das ganze Dokument aufspannen.
     832         [ -  + ]:      10465 :         if(!bHasMark)
     833                 :            :         {
     834         [ #  # ]:          0 :             if( pShell )
     835                 :            :             {
     836         [ #  # ]:          0 :                 pShell->Push();
     837         [ #  # ]:          0 :                 pShell->SttEndDoc(sal_True);
     838         [ #  # ]:          0 :                 pShell->SetMark();
     839         [ #  # ]:          0 :                 pShell->SttEndDoc(sal_False);
     840                 :            :             }
     841                 :            :             else
     842                 :            :             {
     843 [ #  # ][ #  # ]:          0 :                 pPam = new SwPaM( *pPam );
     844         [ #  # ]:          0 :                 pPam->Move( fnMoveBackward, fnGoDoc );
     845         [ #  # ]:          0 :                 pPam->SetMark();
     846         [ #  # ]:          0 :                 pPam->Move( fnMoveForward, fnGoDoc );
     847                 :            :             }
     848                 :      10465 :         }
     849                 :            :         // pPam ist immer noch der akt. Cursor !!
     850                 :            :     }
     851                 :            :     else
     852                 :            :     {
     853                 :            :         // keine Shell oder alles schreiben -> eigenen Pam erzeugen
     854         [ +  - ]:         35 :         SwDoc* pOutDoc = pDoc ? pDoc : &rDoc;
     855 [ +  - ][ +  - ]:         35 :         pPam = new SwPaM( pOutDoc->GetNodes().GetEndOfContent() );
                 [ +  - ]
     856         [ -  + ]:         35 :         if( pOutDoc->IsClipBoard() )
     857                 :            :         {
     858         [ #  # ]:          0 :             pPam->Move( fnMoveBackward, fnGoDoc );
     859         [ #  # ]:          0 :             pPam->SetMark();
     860         [ #  # ]:          0 :             pPam->Move( fnMoveForward, fnGoDoc );
     861                 :            :         }
     862                 :            :         else
     863                 :            :         {
     864         [ +  - ]:         35 :             pPam->SetMark();
     865         [ +  - ]:         35 :             pPam->Move( fnMoveBackward, fnGoDoc );
     866                 :            :         }
     867                 :            :     }
     868                 :            : 
     869                 :      10500 :     rxWriter->bWriteAll = bWriteAll;
     870         [ +  - ]:      10500 :     SwDoc* pOutDoc = pDoc ? pDoc : &rDoc;
     871                 :            : 
     872                 :            :     // falls der Standart PageDesc. immer noch auf initalen Werten steht
     873                 :            :     // (wenn z.B. kein Drucker gesetzt wurde) dann setze jetzt auf DIN A4
     874                 :            :     // #i37248# - Modifications are only allowed at a new document.
     875                 :            :     // <pOutDoc> contains a new document, if <pDoc> is set - see above.
     876 [ -  + ][ #  # ]:      10500 :     if ( pDoc && !pOutDoc->getPrinter( false ) )
         [ #  # ][ -  + ]
     877                 :            :     {
     878         [ #  # ]:          0 :         const SwPageDesc& rPgDsc = pOutDoc->GetPageDesc( 0 );
     879                 :            :         //const SwPageDesc& rPgDsc = *pOutDoc->GetPageDescFromPool( RES_POOLPAGE_STANDARD );
     880         [ #  # ]:          0 :         const SwFmtFrmSize& rSz = rPgDsc.GetMaster().GetFrmSize();
     881                 :            :         // Clipboard-Dokument wird immer ohne Drucker angelegt, so ist
     882                 :            :         // der Std.PageDesc immer aug LONG_MAX !! Mappe dann auf DIN A4
     883 [ #  # ][ #  # ]:          0 :         if( LONG_MAX == rSz.GetHeight() || LONG_MAX == rSz.GetWidth() )
                 [ #  # ]
     884                 :            :         {
     885         [ #  # ]:          0 :             SwPageDesc aNew( rPgDsc );
     886         [ #  # ]:          0 :             SwFmtFrmSize aNewSz( rSz );
     887         [ #  # ]:          0 :             Size a4(SvxPaperInfo::GetPaperSize( PAPER_A4 ));
     888                 :          0 :             aNewSz.SetHeight( a4.Width() );
     889                 :          0 :             aNewSz.SetWidth( a4.Height() );
     890         [ #  # ]:          0 :             aNew.GetMaster().SetFmtAttr( aNewSz );
     891 [ #  # ][ #  # ]:          0 :             pOutDoc->ChgPageDesc( 0, aNew );
                 [ #  # ]
     892                 :            :         }
     893                 :            :     }
     894                 :            : 
     895                 :      10500 :     sal_Bool bLockedView(sal_False);
     896         [ +  - ]:      10500 :     SwEditShell* pESh = pOutDoc->GetEditShell();
     897         [ +  + ]:      10500 :     if( pESh )
     898                 :            :     {
     899                 :      10459 :         bLockedView = pESh->IsViewLocked();
     900                 :      10459 :         pESh->LockView( sal_True );    //lock visible section
     901         [ +  - ]:      10459 :         pESh->StartAllAction();
     902                 :            :     }
     903                 :            : 
     904         [ +  - ]:      10500 :     sal_Bool bWasPurgeOle = pOutDoc->get(IDocumentSettingAccess::PURGE_OLE);
     905         [ +  - ]:      10500 :     pOutDoc->set(IDocumentSettingAccess::PURGE_OLE, false);
     906                 :            : 
     907                 :      10500 :     sal_uLong nError = 0;
     908         [ +  + ]:      10500 :     if( pMedium )
     909         [ +  - ]:         33 :         nError = rxWriter->Write( *pPam, *pMedium, pRealFileName );
     910         [ -  + ]:      10467 :     else if( pStg )
     911         [ #  # ]:          0 :         nError = rxWriter->Write( *pPam, *pStg, pRealFileName );
     912         [ +  + ]:      10467 :     else if( pStrm )
     913         [ +  - ]:      10465 :         nError = rxWriter->Write( *pPam, *pStrm, pRealFileName );
     914         [ +  - ]:          2 :     else if( xStg.is() )
     915         [ +  - ]:          2 :         nError = rxWriter->Write( *pPam, xStg, pRealFileName );
     916                 :            : 
     917         [ +  - ]:      10500 :     pOutDoc->set(IDocumentSettingAccess::PURGE_OLE, bWasPurgeOle );
     918                 :            : 
     919         [ +  + ]:      10500 :     if( pESh )
     920                 :            :     {
     921         [ +  - ]:      10459 :         pESh->EndAllAction();
     922                 :      10459 :         pESh->LockView( bLockedView );
     923                 :            :     }
     924                 :            : 
     925                 :            :     // Falls nur zum Schreiben eine Selektion aufgespannt wurde, vor der
     926                 :            :     // Rueckkehr den alten Crsr wieder herstellen.
     927 [ +  + ][ +  + ]:      10500 :     if( !bWriteAll && ( pShell || pOutPam ))
                 [ +  - ]
     928                 :            :     {
     929         [ -  + ]:      10465 :         if(!bHasMark)
     930                 :            :         {
     931         [ #  # ]:          0 :             if( pShell )
     932         [ #  # ]:          0 :                 pShell->Pop( sal_False );
     933                 :            :             else
     934 [ #  # ][ #  # ]:          0 :                 delete pPam;
     935                 :            :         }
     936                 :            :     }
     937                 :            :     else
     938                 :            :     {
     939 [ +  - ][ +  - ]:         35 :         delete pPam;            // loesche den hier erzeugten Pam
     940                 :            :         // Alles erfolgreich geschrieben? Sag' das dem Dokument!
     941 [ +  - ][ +  - ]:         35 :         if ( !IsError( nError ) && !pDoc )
                 [ +  - ]
     942                 :            :         {
     943         [ +  - ]:         35 :             rDoc.ResetModified();
     944                 :            :             // #i38810# - reset also flag, that indicates updated links
     945         [ +  - ]:         35 :             rDoc.SetLinksUpdated( sal_False );
     946                 :            :         }
     947                 :            :     }
     948                 :            : 
     949         [ -  + ]:      10500 :     if ( pDoc )
     950                 :            :     {
     951 [ #  # ][ #  # ]:          0 :         if ( !pDoc->release() )
     952 [ #  # ][ #  # ]:          0 :             delete pDoc;
     953                 :          0 :         bWriteAll = sal_False;
     954                 :            :     }
     955                 :            : 
     956         [ +  - ]:      10500 :     return nError;
     957                 :            : }
     958                 :            : 
     959                 :            : 
     960                 :            : 
     961                 :            : // ----------------------------------------------------------------------
     962                 :            : 
     963                 :            : 
     964                 :          4 : sal_Bool SetHTMLTemplate( SwDoc & rDoc )
     965                 :            : {
     966                 :            :     // Vorlagennamen von den Sfx-HTML-Filter besorgen!!!
     967 [ +  - ][ +  + ]:          4 :     if( !ReadHTML->GetTemplateDoc() )
     968         [ +  - ]:          2 :         ReadHTML->MakeHTMLDummyTemplateDoc();
     969                 :            : 
     970         [ +  - ]:          4 :     sal_Bool bRet = ReadHTML->SetTemplate( rDoc );
     971                 :            : 
     972         [ +  - ]:          4 :     SwNodes& rNds = rDoc.GetNodes();
     973         [ +  - ]:          4 :     SwNodeIndex aIdx( rNds.GetEndOfExtras(), 1 );
     974         [ +  - ]:          4 :     SwCntntNode* pCNd = rNds.GoNext( &aIdx );
     975         [ +  - ]:          4 :     if( pCNd )
     976                 :            :     {
     977                 :            :         pCNd->SetAttr
     978 [ +  - ][ +  - ]:          4 :             ( SwFmtPageDesc(rDoc.GetPageDescFromPool(RES_POOLPAGE_HTML, false) ) );
         [ +  - ][ +  - ]
     979 [ +  - ][ +  - ]:          4 :         pCNd->ChgFmtColl( rDoc.GetTxtCollFromPool( RES_POOLCOLL_TEXT, false ));
     980                 :            :     }
     981                 :            : 
     982         [ +  - ]:          4 :     return bRet;
     983                 :            : }
     984                 :            : 
     985                 :            : 
     986                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10