LCOV - code coverage report
Current view: top level - sw/source/core/doc - docnew.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 402 572 70.3 %
Date: 2012-08-25 Functions: 27 36 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 645 1506 42.8 %

           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                 :            : #define ROLBCK_HISTORY_ONLY     // The fight against the CLOOK's
      30                 :            : #include <doc.hxx>
      31                 :            : #include <dcontact.hxx>
      32                 :            : #include <com/sun/star/document/PrinterIndependentLayout.hpp>
      33                 :            : #include <com/sun/star/document/UpdateDocMode.hpp>
      34                 :            : #include <com/sun/star/text/XTextDocument.hpp>
      35                 :            : #include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
      36                 :            : #include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
      37                 :            : 
      38                 :            : #include <comphelper/processfactory.hxx>
      39                 :            : #include <vcl/svapp.hxx>
      40                 :            : #include <vcl/virdev.hxx>
      41                 :            : #include <rtl/logfile.hxx>
      42                 :            : #include <rtl/random.h>
      43                 :            : #include <sfx2/printer.hxx>
      44                 :            : #include <sfx2/docfile.hxx>
      45                 :            : #include <sfx2/frame.hxx>
      46                 :            : #include <sfx2/viewfrm.hxx>
      47                 :            : 
      48                 :            : #include <svl/macitem.hxx>
      49                 :            : #include <svx/svxids.hrc>
      50                 :            : #include <svx/svdogrp.hxx>
      51                 :            : #include <sfx2/linkmgr.hxx>
      52                 :            : #include <editeng/forbiddencharacterstable.hxx>
      53                 :            : #include <svl/zforlist.hxx>
      54                 :            : #include <unotools/compatibility.hxx>
      55                 :            : #include <unotools/lingucfg.hxx>
      56                 :            : #include <svx/svdpage.hxx>
      57                 :            : #include <paratr.hxx>
      58                 :            : #include <fchrfmt.hxx>
      59                 :            : #include <fmtcntnt.hxx>
      60                 :            : #include <fmtanchr.hxx>
      61                 :            : #include <fmtfsize.hxx>
      62                 :            : #include <fmtfordr.hxx>
      63                 :            : #include <fmtpdsc.hxx>
      64                 :            : #include <pvprtdat.hxx>
      65                 :            : #include <rootfrm.hxx>  // So that the RootDtor is being called
      66                 :            : #include <layouter.hxx>
      67                 :            : #include <pagedesc.hxx> // So that the PageDescs can be destroyed
      68                 :            : #include <ndtxt.hxx>
      69                 :            : #include <printdata.hxx>
      70                 :            : #include <docfld.hxx>
      71                 :            : #include <ftninfo.hxx>
      72                 :            : #include <ftnidx.hxx>
      73                 :            : #include <docstat.hxx>
      74                 :            : #include <charfmt.hxx>
      75                 :            : #include <frmfmt.hxx>
      76                 :            : #include <rolbck.hxx>           // Undo attributes, SwHistory
      77                 :            : #include <poolfmt.hxx>          // for the Pool template
      78                 :            : #include <dbmgr.hxx>
      79                 :            : #include <docsh.hxx>
      80                 :            : #include <acorrect.hxx>         // for the automatic adding of exceptions
      81                 :            : #include <visiturl.hxx>         // for the URLChange message
      82                 :            : #include <docary.hxx>
      83                 :            : #include <lineinfo.hxx>
      84                 :            : #include <drawdoc.hxx>
      85                 :            : #include <linkenum.hxx>
      86                 :            : #include <fldupde.hxx>
      87                 :            : #include <extinput.hxx>
      88                 :            : #include <viewsh.hxx>
      89                 :            : #include <doctxm.hxx>
      90                 :            : #include <shellres.hxx>
      91                 :            : #include <breakit.hxx>
      92                 :            : #include <laycache.hxx>
      93                 :            : #include <mvsave.hxx>
      94                 :            : #include <istyleaccess.hxx>
      95                 :            : #include <swstylemanager.hxx>
      96                 :            : #include <IGrammarContact.hxx>
      97                 :            : #include <tblsel.hxx>
      98                 :            : #include <MarkManager.hxx>
      99                 :            : #include <UndoManager.hxx>
     100                 :            : #include <unochart.hxx>
     101                 :            : #include <fldbas.hxx>
     102                 :            : 
     103                 :            : #include <cmdid.h>              // for the default printer in SetJob
     104                 :            : 
     105                 :            : 
     106                 :            : #include <com/sun/star/document/XDocumentInfoSupplier.hpp>
     107                 :            : #include <com/sun/star/beans/XPropertyContainer.hpp>
     108                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
     109                 :            : 
     110                 :            : #include <pausethreadstarting.hxx>
     111                 :            : #include <numrule.hxx>
     112                 :            : #include <list.hxx>
     113                 :            : #include <listfunc.hxx>
     114                 :            : 
     115                 :            : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
     116                 :            : 
     117                 :            : #include <sfx2/Metadatable.hxx>
     118                 :            : #include <fmtmeta.hxx> // MetaFieldManager
     119                 :            : #include <boost/foreach.hpp>
     120                 :            : 
     121                 :            : using namespace ::com::sun::star;
     122                 :            : using namespace ::com::sun::star::document;
     123                 :            : 
     124                 :            : const sal_Char sFrmFmtStr[] = "Frameformat";
     125                 :            : const sal_Char sEmptyPageStr[] = "Empty Page";
     126                 :            : const sal_Char sColumnCntStr[] = "Columncontainer";
     127                 :            : const sal_Char sCharFmtStr[] = "Zeichenformat";
     128                 :            : const sal_Char sTxtCollStr[] = "Textformatvorlage";
     129                 :            : const sal_Char sGrfCollStr[] = "Graphikformatvorlage";
     130                 :            : 
     131                 :            : /*
     132                 :            :  * global functions...
     133                 :            :  */
     134                 :       7180 :  uno::Reference< linguistic2::XProofreadingIterator > SwDoc::GetGCIterator() const
     135                 :            : {
     136 [ +  + ][ +  - ]:       7180 :     if (!m_xGCIterator.is() && SvtLinguConfig().HasGrammarChecker())
         [ +  - ][ +  + ]
                 [ +  + ]
           [ +  +  #  # ]
     137                 :            :     {
     138         [ +  - ]:        705 :         uno::Reference< lang::XMultiServiceFactory >  xMgr( comphelper::getProcessServiceFactory() );
     139         [ +  - ]:        705 :         if (xMgr.is())
     140                 :            :         {
     141                 :            :             try
     142                 :            :             {
     143         [ +  - ]:        705 :                 rtl::OUString aServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.linguistic2.ProofreadingIterator"));
     144                 :            :                 m_xGCIterator = uno::Reference< linguistic2::XProofreadingIterator >
     145 [ +  - ][ +  - ]:        705 :                     ( xMgr->createInstance( aServiceName ), uno::UNO_QUERY_THROW );
         [ +  - ][ +  - ]
                 [ #  # ]
     146                 :            :             }
     147         [ #  # ]:          0 :             catch (uno::Exception &)
     148                 :            :             {
     149                 :            :                 OSL_FAIL( "No GCIterator" );
     150                 :            :             }
     151                 :        705 :         }
     152                 :            :     }
     153                 :            : 
     154                 :       7180 :     return m_xGCIterator;
     155                 :            : }
     156                 :            : 
     157                 :       8558 : void StartGrammarChecking( SwDoc &rDoc )
     158                 :            : {
     159                 :            :     // check for a visible view
     160                 :       8558 :     bool bVisible = false;
     161                 :       8558 :     const SwDocShell *pDocShell = rDoc.GetDocShell();
     162                 :       8558 :     SfxViewFrame    *pFrame = SfxViewFrame::GetFirst( pDocShell, sal_False );
     163 [ +  + ][ +  - ]:      17116 :     while (pFrame && !bVisible)
                 [ +  + ]
     164                 :            :     {
     165         [ +  + ]:       8558 :         if (pFrame->IsVisible())
     166                 :       7180 :             bVisible = true;
     167                 :       8558 :         pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell, sal_False );
     168                 :            :     }
     169                 :            : 
     170                 :            :     //!! only documents with visible views need to be checked
     171                 :            :     //!! (E.g. don't check temporary documents created for printing, see printing of notes and selections.
     172                 :            :     //!! Those get created on the fly and get hard deleted a bit later as well, and no one should have
     173                 :            :     //!! a uno reference to them)
     174         [ +  + ]:       8558 :     if (bVisible)
     175                 :            :     {
     176         [ +  - ]:       7180 :         uno::Reference< linguistic2::XProofreadingIterator > xGCIterator( rDoc.GetGCIterator() );
     177         [ +  + ]:       7180 :         if ( xGCIterator.is() )
     178                 :            :         {
     179 [ +  - ][ +  - ]:       4406 :             uno::Reference< lang::XComponent >  xDoc( rDoc.GetDocShell()->GetBaseModel(), uno::UNO_QUERY );
     180         [ +  - ]:       4406 :             uno::Reference< text::XFlatParagraphIteratorProvider >  xFPIP( xDoc, uno::UNO_QUERY );
     181                 :            : 
     182                 :            :             // start automatic background checking if not active already
     183 [ +  - ][ +  - ]:       4406 :             if ( xFPIP.is() && !xGCIterator->isProofreading( xDoc ) )
         [ +  - ][ +  + ]
                 [ +  + ]
     184 [ +  - ][ +  - ]:       4406 :                 xGCIterator->startProofreading( xDoc, xFPIP );
     185                 :       7180 :         }
     186                 :            :     }
     187                 :       8558 : }
     188                 :            : 
     189                 :            : /*
     190                 :            :  * internal functions
     191                 :            :  */
     192                 :       3505 : static void lcl_DelFmtIndizes( SwFmt* pFmt )
     193                 :            : {
     194                 :       3505 :     SwFmtCntnt &rFmtCntnt = (SwFmtCntnt&)pFmt->GetCntnt();
     195         [ +  + ]:       3505 :     if ( rFmtCntnt.GetCntntIdx() )
     196                 :        655 :         rFmtCntnt.SetNewCntntIdx( 0 );
     197                 :       3505 :     SwFmtAnchor &rFmtAnchor = (SwFmtAnchor&)pFmt->GetAnchor();
     198         [ +  + ]:       3505 :     if ( rFmtAnchor.GetCntntAnchor() )
     199                 :       1167 :         rFmtAnchor.SetAnchor( 0 );
     200                 :       3505 : }
     201                 :            : 
     202                 :            : /*
     203                 :            :  * exported methods
     204                 :            :  */
     205                 :       1549 : SwDoc::SwDoc()
     206         [ +  - ]:       1549 :     : m_pNodes( new SwNodes(this) )
     207                 :            :     ,
     208         [ +  - ]:       1549 :     mpAttrPool(new SwAttrPool(this)),
     209         [ +  - ]:       1549 :     pMarkManager(new ::sw::mark::MarkManager(*this)),
     210                 :          0 :     m_pMetaFieldManager(new ::sw::MetaFieldManager()),
     211                 :            :     m_pUndoManager(new ::sw::UndoManager(
     212 [ +  - ][ +  - ]:       3098 :             ::std::auto_ptr<SwNodes>(new SwNodes(this)), *this, *this, *this)),
     213         [ +  - ]:       1549 :     pDfltFrmFmt( new SwFrmFmt( GetAttrPool(), sFrmFmtStr, 0 ) ),
     214         [ +  - ]:       1549 :     pEmptyPageFmt( new SwFrmFmt( GetAttrPool(), sEmptyPageStr, pDfltFrmFmt ) ),
     215         [ +  - ]:       1549 :     pColumnContFmt( new SwFrmFmt( GetAttrPool(), sColumnCntStr, pDfltFrmFmt ) ),
     216         [ +  - ]:       1549 :     pDfltCharFmt( new SwCharFmt( GetAttrPool(), sCharFmtStr, 0 ) ),
     217         [ +  - ]:       1549 :     pDfltTxtFmtColl( new SwTxtFmtColl( GetAttrPool(), sTxtCollStr ) ),
     218         [ +  - ]:       1549 :     pDfltGrfFmtColl( new SwGrfFmtColl( GetAttrPool(), sGrfCollStr ) ),
     219                 :          0 :     pFrmFmtTbl( new SwFrmFmts() ),
     220                 :          0 :     pCharFmtTbl( new SwCharFmts() ),
     221                 :          0 :     pSpzFrmFmtTbl( new SwFrmFmts() ),
     222                 :          0 :     pSectionFmtTbl( new SwSectionFmts() ),
     223                 :          0 :     pTblFrmFmtTbl( new SwFrmFmts() ),
     224                 :          0 :     pTxtFmtCollTbl( new SwTxtFmtColls() ),
     225                 :          0 :     pGrfFmtCollTbl( new SwGrfFmtColls() ),
     226                 :          0 :     pTOXTypes( new SwTOXTypes() ),
     227                 :            :     pDefTOXBases( new SwDefTOXBase_Impl() ),
     228                 :            :     pCurrentView( 0 ),  //swmod 071225
     229                 :            :     pDrawModel( 0 ),
     230                 :          0 :     pUpdtFlds( new SwDocUpdtFld() ),
     231                 :          0 :     pFldTypes( new SwFldTypes() ),
     232                 :            :     pVirDev( 0 ),
     233                 :            :     pPrt( 0 ),
     234                 :            :     pPrtData( 0 ),
     235                 :            :     pGlossaryDoc( 0 ),
     236                 :            :     pOutlineRule( 0 ),
     237         [ +  - ]:       1549 :     pFtnInfo( new SwFtnInfo ),
     238         [ +  - ]:       1549 :     pEndNoteInfo( new SwEndNoteInfo ),
     239         [ +  - ]:       1549 :     pLineNumberInfo( new SwLineNumberInfo ),
     240         [ +  - ]:       1549 :     pFtnIdxs( new SwFtnIdxs ),
     241         [ +  - ]:       1549 :     pDocStat( new SwDocStat ),
     242                 :            :     pDocShell( 0 ),
     243         [ +  - ]:       1549 :     pLinkMgr( new sfx2::LinkManager( 0 ) ),
     244                 :            :     pACEWord( 0 ),
     245                 :            :     pURLStateChgd( 0 ),
     246                 :            :     pNumberFormatter( 0 ),
     247         [ +  - ]:       1549 :     pNumRuleTbl( new SwNumRuleTbl ),
     248                 :            :     maLists(),
     249                 :            :     maListStyleLists(),
     250         [ +  - ]:       1549 :     pRedlineTbl( new SwRedlineTbl ),
     251                 :            :     pAutoFmtRedlnComment( 0 ),
     252                 :          0 :     pUnoCrsrTbl( new SwUnoCrsrTbl() ),
     253                 :            :     pPgPViewPrtData( 0 ),
     254                 :            :     pExtInputRing( 0 ),
     255                 :            :     pLayouter( 0 ),
     256                 :            :     pStyleAccess( 0 ),
     257                 :            :     pLayoutCache( 0 ),
     258         [ +  - ]:       1549 :     pUnoCallBack(new SwModify(0)),
     259                 :            :     mpGrammarContact( 0 ),
     260                 :            :     aChartDataProviderImplRef(),
     261                 :            :     pChartControllerHelper( 0 ),
     262                 :          0 :     mpListItemsList( new tImplSortedNodeNumList() ), // #i83479#
     263                 :            :     m_pXmlIdRegistry(),
     264                 :            :     nAutoFmtRedlnCommentNo( 0 ),
     265                 :            :     nLinkUpdMode( GLOBALSETTING ),
     266                 :            :      eFldUpdMode( AUTOUPD_GLOBALSETTING ),
     267                 :            :     eRedlineMode((RedlineMode_t)(nsRedlineMode_t::REDLINE_SHOW_INSERT | nsRedlineMode_t::REDLINE_SHOW_DELETE)),
     268                 :            :     eChrCmprType( CHARCOMPRESS_NONE ),
     269                 :            :     mReferenceCount(0),
     270                 :            :     mIdleBlockCount(0),
     271                 :            :     nLockExpFld( 0 ),
     272                 :            :     mbReadlineChecked(false),
     273                 :            :     mbLinksUpdated( sal_False ), //#i38810#
     274                 :            :     mbClipBoard( false ),
     275                 :            :     mbColumnSelection( false ),
     276                 :            :     mbProtectForm(false), // i#78591#
     277                 :            :     mbLastBrowseMode( false ),
     278                 :            :     n32DummyCompatabilityOptions1(0),
     279                 :            :     n32DummyCompatabilityOptions2(0),
     280                 :            :     mbStartIdleTimer(sal_False),
     281 [ +  - ][ +  - ]:      32529 :     mbSetDrawDefaults(false)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     282                 :            : {
     283                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLog, "SW", "JP93722",  "SwDoc::SwDoc" );
     284                 :            : 
     285                 :            :     mbGlossDoc =
     286                 :            :     mbModified =
     287                 :            :     mbDtor =
     288                 :            :     mbPageNums =
     289                 :            :     mbLoaded =
     290                 :            :     mbUpdateExpFld =
     291                 :            :     mbNewDoc =
     292                 :            :     mbCopyIsMove =
     293                 :            :     mbInReading =
     294                 :            :     mbInXMLImport =
     295                 :            :     mbUpdateTOX =
     296                 :            :     mbInLoadAsynchron =
     297                 :            :     mbHTMLMode =
     298                 :            :     mbInCallModified =
     299                 :            :     mbIsGlobalDoc =
     300                 :            :     mbGlblDocSaveLinks =
     301                 :            :     mbIsLabelDoc =
     302                 :            :     mbIsAutoFmtRedline =
     303                 :            :     mbOLEPrtNotifyPending =
     304                 :            :     mbAllOLENotify =
     305                 :            :     mbIsRedlineMove =
     306                 :            :     mbInsOnlyTxtGlssry =
     307                 :            :     mbContains_MSVBasic =
     308                 :            :     mbKernAsianPunctuation =
     309                 :            : #ifdef DBG_UTIL
     310                 :            :     mbXMLExport =
     311                 :            : #endif
     312                 :            :     mbApplyWorkaroundForB6375613 =
     313                 :       1549 :                             false;
     314                 :            : 
     315                 :            :     mbNewFldLst =
     316                 :            :     mbVisibleLinks =
     317                 :            :     mbPurgeOLE =
     318                 :       1549 :                             true;
     319                 :            : 
     320                 :            :     //
     321                 :            :     // COMPATIBILITY FLAGS START
     322                 :            :     //
     323                 :            : 
     324                 :            :     // Note: Any non-hidden compatibility flag should obtain its default
     325                 :            :     // by asking SvtCompatibilityOptions, see below.
     326                 :            :     //
     327         [ +  - ]:       1549 :     const SvtCompatibilityOptions aOptions;
     328         [ +  - ]:       1549 :     mbParaSpaceMax                      = aOptions.IsAddSpacing();
     329         [ +  - ]:       1549 :     mbParaSpaceMaxAtPages               = aOptions.IsAddSpacingAtPages();
     330         [ +  - ]:       1549 :     mbTabCompat                         = !aOptions.IsUseOurTabStops();
     331         [ +  - ]:       1549 :     mbUseVirtualDevice                  = !aOptions.IsUsePrtDevice();
     332         [ +  - ]:       1549 :     mbAddExternalLeading                = !aOptions.IsNoExtLeading();
     333         [ +  - ]:       1549 :     mbOldLineSpacing                    = aOptions.IsUseLineSpacing();
     334         [ +  - ]:       1549 :     mbAddParaSpacingToTableCells        = aOptions.IsAddTableSpacing();
     335         [ +  - ]:       1549 :     mbUseFormerObjectPos                = aOptions.IsUseObjectPositioning();
     336         [ +  - ]:       1549 :     mbUseFormerTextWrapping             = aOptions.IsUseOurTextWrapping();
     337         [ +  - ]:       1549 :     mbConsiderWrapOnObjPos              = aOptions.IsConsiderWrappingStyle();
     338                 :       1549 :     mbMathBaselineAlignment                 = false;        // default for *old* documents is 'off'
     339                 :       1549 :     mbStylesNoDefault                       = false;
     340                 :       1549 :     mbAddFlyOffsets                         = false;        // hidden
     341                 :       1549 :     mbOldNumbering                          = false;        // hidden
     342                 :       1549 :     mbUseHiResolutionVirtualDevice          = true;         // hidden
     343                 :       1549 :     mbIgnoreFirstLineIndentInNumbering      = false;        // hidden
     344         [ +  - ]:       1549 :     mbDoNotJustifyLinesWithManualBreak      = !aOptions.IsExpandWordSpace();
     345                 :       1549 :     mbDoNotResetParaAttrsForNumFont         = false;        // hidden
     346                 :       1549 :     mbOutlineLevelYieldsOutlineRule         = false;        // hidden
     347                 :       1549 :     mbTableRowKeep                          = false;        // hidden
     348                 :       1549 :     mbIgnoreTabsAndBlanksForLineCalculation = false;        // hidden
     349                 :       1549 :     mbDoNotCaptureDrawObjsOnPage            = false;        // hidden
     350                 :       1549 :     mbClipAsCharacterAnchoredWriterFlyFrames= false;        // hidden
     351                 :       1549 :     mbUnixForceZeroExtLeading               = false;        // hidden
     352                 :       1549 :     mbOldPrinterMetrics                     = false;        // hidden
     353                 :       1549 :     mbTabRelativeToIndent                   = true;         // hidden
     354                 :       1549 :     mbTabAtLeftIndentForParagraphsInList    = false;        // hidden #i89181#
     355                 :       1549 :     mbInvertBorderSpacing                   = false;        // hidden
     356                 :       1549 :     mbCollapseEmptyCellPara                 = true;        // hidden
     357                 :       1549 :     mbSmallCapsPercentage66                 = false;        // hidden
     358                 :       1549 :     mbTabOverflow                           = true;
     359                 :       1549 :     mbUnbreakableNumberings                 = false;
     360                 :       1549 :     mbFloattableNomargins                   = false;
     361                 :            : 
     362                 :            :     //
     363                 :            :     // COMPATIBILITY FLAGS END
     364                 :            :     //
     365                 :            : 
     366 [ +  - ][ +  - ]:       1549 :     pMacroTable = new SvxMacroTableDtor;
     367                 :            : 
     368         [ +  - ]:       1549 :     mpGrammarContact = ::createGrammarContact();
     369                 :            : 
     370                 :            :     /*
     371                 :            :      * DefaultFormats and DefaultFormatCollections (FmtColl)
     372                 :            :      * are inserted at position 0 at the respective array.
     373                 :            :      * The formats in the FmtColls are derived from the
     374                 :            :      * DefaultFormats and are also in the list.
     375                 :            :      */
     376                 :            :     /* Formats */
     377         [ +  - ]:       1549 :     pFrmFmtTbl->push_back(pDfltFrmFmt);
     378         [ +  - ]:       1549 :     pCharFmtTbl->push_back(pDfltCharFmt);
     379                 :            : 
     380                 :            :     /* FmtColls */
     381                 :            :     // TXT
     382         [ +  - ]:       1549 :     pTxtFmtCollTbl->push_back(pDfltTxtFmtColl);
     383                 :            :     // GRF
     384         [ +  - ]:       1549 :     pGrfFmtCollTbl->push_back(pDfltGrfFmtColl);
     385                 :            : 
     386                 :            :     // Create PageDesc, EmptyPageFmt and ColumnFmt
     387         [ +  - ]:       1549 :     if ( aPageDescs.empty() )
     388         [ +  - ]:       1549 :         GetPageDescFromPool( RES_POOLPAGE_STANDARD );
     389                 :            : 
     390                 :            :     // Set to "Empty Page"
     391 [ +  - ][ +  - ]:       1549 :     pEmptyPageFmt->SetFmtAttr( SwFmtFrmSize( ATT_FIX_SIZE ) );
                 [ +  - ]
     392                 :            :     // Set BodyFmt for columns
     393 [ +  - ][ +  - ]:       1549 :     pColumnContFmt->SetFmtAttr( SwFmtFillOrder( ATT_LEFT_TO_RIGHT ) );
                 [ +  - ]
     394                 :            : 
     395         [ +  - ]:       1549 :     _InitFieldTypes();
     396                 :            : 
     397                 :            :     // Create a default OutlineNumRule (for Filters)
     398                 :       1549 :     pOutlineRule = new SwNumRule( rtl::OUString::createFromAscii( SwNumRule::GetOutlineRuleName() ),
     399                 :            :                                   // #i89178#
     400                 :            :                                   numfunc::GetDefaultPositionAndSpaceMode(),
     401 [ +  - ][ +  - ]:       1549 :                                   OUTLINE_RULE );
         [ +  - ][ +  - ]
                 [ +  - ]
     402         [ +  - ]:       1549 :     AddNumRule(pOutlineRule);
     403                 :            :     // Counting of phantoms depends on <IsOldNumbering()>
     404 [ +  - ][ +  - ]:       1549 :     pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
     405                 :            : 
     406                 :            :     new SwTxtNode(
     407 [ +  - ][ +  - ]:       1549 :             SwNodeIndex(GetUndoManager().GetUndoNodes().GetEndOfContent()),
     408 [ +  - ][ +  - ]:       1549 :             pDfltTxtFmtColl );
         [ +  - ][ +  - ]
     409         [ +  - ]:       1549 :     new SwTxtNode( SwNodeIndex( GetNodes().GetEndOfContent() ),
     410 [ +  - ][ +  - ]:       1549 :                     GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
         [ +  - ][ +  - ]
                 [ +  - ]
     411                 :            : 
     412                 :            :     // set the own IdleTimer
     413         [ +  - ]:       1549 :     aIdleTimer.SetTimeout( 600 );
     414         [ +  - ]:       1549 :     aIdleTimer.SetTimeoutHdl( LINK(this, SwDoc, DoIdleJobs) );
     415                 :            : 
     416         [ +  - ]:       1549 :     aOLEModifiedTimer.SetTimeout( 1000 );
     417         [ +  - ]:       1549 :     aOLEModifiedTimer.SetTimeoutHdl( LINK( this, SwDoc, DoUpdateModifiedOLE ));
     418                 :            : 
     419                 :            :     // Create DBMgr
     420 [ +  - ][ +  - ]:       1549 :     pNewDBMgr = new SwNewDBMgr;
     421                 :            : 
     422                 :            :     // create TOXTypes
     423         [ +  - ]:       1549 :     InitTOXTypes();
     424                 :            : 
     425                 :            :     // pass empty item set containing the paragraph's list attributes
     426                 :            :     // as ignorable items to the stype manager.
     427                 :            :     {
     428         [ +  - ]:       1549 :         SfxItemSet aIgnorableParagraphItems( GetAttrPool(), RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1);
     429 [ +  - ][ +  - ]:       1549 :         pStyleAccess = createStyleManager( &aIgnorableParagraphItems );
     430                 :            :     }
     431                 :            : 
     432                 :            :     // Initialize the session id of the current document to a random number
     433                 :            :     // smaller than 2^21.
     434 [ +  + ][ +  - ]:       1549 :     static rtlRandomPool aPool = rtl_random_createPool();
     435                 :       1549 :     rtl_random_getBytes( aPool, &nRsid, sizeof ( nRsid ) );
     436                 :       1549 :     nRsid &= ( 1<<21 ) - 1;
     437                 :       1549 :     nRsid++;
     438                 :       1549 :     nRsidRoot = nRsid;
     439                 :            : 
     440 [ +  - ][ +  - ]:       1549 :     ResetModified();
     441                 :       1549 : }
     442                 :            : 
     443                 :       1504 : static void DeleteAndDestroy(SwFrmFmts& rFmts, int aStartIdx, int aEndIdx)
     444                 :            : {
     445         [ -  + ]:       1504 :     if (aEndIdx < aStartIdx)
     446                 :       1504 :         return;
     447 [ +  - ][ +  - ]:       3738 :     for( SwFrmFmts::const_iterator it = rFmts.begin() + aStartIdx;
         [ +  - ][ +  - ]
                 [ +  + ]
     448         [ +  - ]:       1869 :          it != rFmts.begin() + aEndIdx; ++it )
     449 [ +  - ][ +  - ]:        365 :              delete *it;
                 [ +  - ]
     450 [ +  - ][ +  - ]:       1504 :     rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx);
                 [ +  - ]
     451                 :            : }
     452                 :            : 
     453                 :       2960 : static void DeleteAndDestroy(SwTxtFmtColls& rFmts, int aStartIdx, int aEndIdx)
     454                 :            : {
     455         [ -  + ]:       2960 :     if (aEndIdx < aStartIdx)
     456                 :       2960 :         return;
     457 [ +  - ][ +  - ]:      25874 :     for( SwTxtFmtColls::const_iterator it = rFmts.begin() + aStartIdx;
         [ +  - ][ +  - ]
                 [ +  + ]
     458         [ +  - ]:      12937 :          it != rFmts.begin() + aEndIdx; ++it )
     459 [ +  - ][ +  - ]:       9977 :              delete *it;
                 [ +  - ]
     460 [ +  - ][ +  - ]:       2960 :     rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx);
                 [ +  - ]
     461                 :            : }
     462                 :            : 
     463                 :         46 : static void DeleteAndDestroy(SwCharFmts& rFmts, int aStartIdx, int aEndIdx)
     464                 :            : {
     465         [ -  + ]:         46 :     if (aEndIdx < aStartIdx)
     466                 :         46 :         return;
     467 [ +  - ][ +  - ]:         92 :     for( SwCharFmts::const_iterator it = rFmts.begin() + aStartIdx;
         [ #  # ][ +  - ]
                 [ -  + ]
     468         [ +  - ]:         46 :          it != rFmts.begin() + aEndIdx; ++it )
     469 [ #  # ][ #  # ]:          0 :              delete *it;
                 [ #  # ]
     470 [ +  - ][ +  - ]:         46 :     rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx);
                 [ +  - ]
     471                 :            : }
     472                 :            : 
     473                 :       1504 : static void DeleteAndDestroy(SwGrfFmtColls& rFmts, int aStartIdx, int aEndIdx)
     474                 :            : {
     475         [ -  + ]:       1504 :     if (aEndIdx < aStartIdx)
     476                 :       1504 :         return;
     477 [ +  - ][ +  - ]:       3008 :     for( SwGrfFmtColls::const_iterator it = rFmts.begin() + aStartIdx;
         [ +  - ][ -  + ]
     478         [ +  - ]:       1504 :          it != rFmts.begin() + aEndIdx; ++it )
     479 [ #  # ][ #  # ]:          0 :              delete *it;
     480 [ +  - ][ +  - ]:       1504 :     rFmts.erase( rFmts.begin() + aStartIdx, rFmts.begin() + aEndIdx);
                 [ +  - ]
     481                 :            : }
     482                 :            : 
     483                 :            : /*
     484                 :            :  * Speciality: a member of the class SwDoc is located at
     485                 :            :  * position 0 in the array of the Format and GDI objects.
     486                 :            :  * This MUST not be destroyed using 'delete' in any case!
     487                 :            :  */
     488 [ +  - ][ +  - ]:       1458 : SwDoc::~SwDoc()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     489                 :            : {
     490                 :            :     // nothing here should create Undo actions!
     491 [ +  - ][ +  - ]:       1458 :     GetIDocumentUndoRedo().DoUndo(false);
     492                 :            : 
     493         [ +  + ]:       1458 :     if (pDocShell)
     494                 :            :     {
     495         [ +  - ]:         24 :         pDocShell->SetUndoManager(0);
     496                 :            :     }
     497                 :            : 
     498                 :            : 
     499                 :            :     // #i83479#
     500         [ +  - ]:       1458 :     delete mpListItemsList;
     501                 :       1458 :     mpListItemsList = 0;
     502                 :            : 
     503                 :            :     // clean up chart related structures...
     504                 :            :     // Note: the chart data provider gets already diposed in ~SwDocShell
     505                 :            :     // since all UNO API related functionality requires an existing SwDocShell
     506                 :            :     // this assures that dipose gets called if there is need for it.
     507         [ +  - ]:       1458 :     aChartDataProviderImplRef.reset();
     508 [ +  + ][ +  - ]:       1458 :     delete pChartControllerHelper;
     509                 :            : 
     510 [ +  - ][ +  - ]:       1458 :     delete mpGrammarContact;
     511                 :       1458 :     mpGrammarContact = 0;
     512                 :            : 
     513                 :            :     //!! needs to be done to destroy a possible SwFmtDrop format that may
     514                 :            :     //!! be connected to a char format which may not otherwise be removed
     515                 :            :     //!! and thus would leave a unremoved SwFmt object. (TL)
     516                 :            :     //!! (this is case is not possible via UI but via API...)
     517         [ +  - ]:       1458 :     SwFmtDrop aDrop;
     518         [ +  - ]:       1458 :     SetDefault(aDrop);
     519                 :            :     //!! same for SwFmtCharFmt
     520         [ +  - ]:       1458 :     SwFmtCharFmt aCharFmt(NULL);
     521         [ +  - ]:       1458 :     SetDefault(aCharFmt);
     522                 :            : 
     523         [ +  - ]:       1458 :     StopIdling();   // stop idle timer
     524                 :            : 
     525 [ +  - ][ +  - ]:       1458 :     delete pUnoCallBack, pUnoCallBack = 0;
     526 [ +  + ][ +  - ]:       1458 :     delete pURLStateChgd;
     527                 :            : 
     528 [ +  + ][ +  - ]:       1458 :     delete pLayouter;
     529                 :       1458 :     pLayouter = 0L;
     530                 :            : 
     531                 :            :     // Deactivate Undo notification from the Draw
     532         [ +  + ]:       1458 :     if( pDrawModel )
     533                 :            :     {
     534         [ +  - ]:       1297 :         DrawNotifyUndoHdl();
     535         [ +  - ]:       1297 :         ClrContourCache();
     536                 :            :     }
     537                 :            : 
     538                 :       1458 :     delete pPgPViewPrtData;
     539                 :            : 
     540                 :       1458 :     mbDtor = sal_True;
     541                 :            : 
     542 [ +  - ][ +  - ]:       1458 :     delete pRedlineTbl;
     543 [ +  - ][ +  - ]:       1458 :     delete pUnoCrsrTbl;
     544 [ -  + ][ #  # ]:       1458 :     delete pAutoFmtRedlnComment;
     545 [ +  - ][ +  - ]:       1458 :     delete pUpdtFlds;
     546 [ -  + ][ #  # ]:       1458 :     delete pACEWord;
     547                 :            : 
     548                 :            :     // Release the BaseLinks
     549                 :            :     {
     550         [ +  - ]:       1458 :        ::sfx2::SvLinkSources aTemp(pLinkMgr->GetServers());
     551   [ #  #  +  - ]:       2916 :        for( ::sfx2::SvLinkSources::const_iterator it = aTemp.begin();
                 [ -  + ]
     552                 :       1458 :             it != aTemp.end(); ++it )
     553 [ #  # ][ #  # ]:          0 :             (*it)->Closed();
     554                 :            : 
     555         [ +  + ]:       1458 :         if( !pLinkMgr->GetLinks().empty() )
     556         [ +  - ]:       1458 :             pLinkMgr->Remove( 0, pLinkMgr->GetLinks().size() );
     557                 :            :     }
     558                 :            : 
     559                 :            :     // The ChapterNumbers/Numbers need to be deleted before the Templates
     560                 :            :     // or we update all the time!
     561                 :       1458 :     m_pNodes->pOutlineNds->clear();
     562 [ +  - ][ +  - ]:       1458 :     SwNodes & rUndoNodes( GetUndoManager().GetUndoNodes() );
     563                 :       1458 :     rUndoNodes.pOutlineNds->clear();
     564                 :            : 
     565                 :       1458 :     pFtnIdxs->clear();
     566                 :            : 
     567                 :            :     // indices could be registered in attributes
     568         [ +  - ]:       1458 :     m_pUndoManager->DelAllUndoObj();
     569                 :            : 
     570                 :            :     // The BookMarks contain indices to the Content. These must be deleted
     571                 :            :     // before deleting the Nodes.
     572         [ +  - ]:       1458 :     pMarkManager->clearAllMarks();
     573         [ +  - ]:       1458 :     DELETEZ( pMacroTable );
     574                 :            : 
     575         [ -  + ]:       1458 :     if( pExtInputRing )
     576                 :            :     {
     577                 :          0 :         Ring* pTmp = pExtInputRing;
     578                 :          0 :         pExtInputRing = 0;
     579         [ #  # ]:          0 :         while( pTmp->GetNext() != pTmp )
     580 [ #  # ][ #  # ]:          0 :             delete pTmp->GetNext();
     581 [ #  # ][ #  # ]:          0 :         delete pTmp;
     582                 :            :     }
     583                 :            : 
     584                 :            :     // Old - deletion without a Flag is expensive, because we send a Modify
     585                 :            :     // aTOXTypes.DeleteAndDestroy( 0, aTOXTypes.Count() );
     586                 :            :     {
     587         [ +  + ]:      11986 :         for( sal_uInt16 n = pTOXTypes->size(); n; )
     588                 :            :         {
     589                 :      10528 :             (*pTOXTypes)[ --n ]->SetInDocDTOR();
     590 [ +  - ][ +  - ]:      10528 :             delete (*pTOXTypes)[ n ];
     591                 :            :         }
     592                 :       1458 :         pTOXTypes->clear();
     593                 :            :     }
     594 [ +  - ][ +  - ]:       1458 :     delete pDefTOXBases;
     595                 :            : 
     596                 :            :     // Any of the FrmFormats can still have indices registered.
     597                 :            :     // These need to be destroyed now at the latest.
     598 [ +  - ][ +  - ]:       5808 :     BOOST_FOREACH( SwFrmFmt* pFmt, *pFrmFmtTbl )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
     599         [ +  - ]:       2175 :         lcl_DelFmtIndizes( pFmt );
     600 [ +  - ][ +  - ]:       3902 :     BOOST_FOREACH( SwFrmFmt* pFmt, *pSpzFrmFmtTbl )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
     601         [ +  - ]:       1222 :         lcl_DelFmtIndizes( pFmt );
     602 [ +  - ][ +  - ]:       1674 :     BOOST_FOREACH( SwSectionFmt* pFmt, *pSectionFmtTbl )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
     603         [ +  - ]:        108 :         lcl_DelFmtIndizes( pFmt );
     604                 :            : 
     605                 :            :     // The formattings that come hereafter depend on the default formattings.
     606                 :            :     // [Destroy] these only after destroying the FmtIndices, because the content
     607                 :            :     // of headers/footers has to be deleted as well. If in the headers/footers
     608                 :            :     // there are still Flys registered at that point, we have a problem.
     609                 :            :     // (This comment might have been translated incorrectly. Blame the bad
     610                 :            :     // German original)
     611 [ +  - ][ +  - ]:       4796 :     BOOST_FOREACH(SwPageDesc *pPageDesc, aPageDescs)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
     612 [ +  - ][ +  - ]:       1669 :         delete pPageDesc;
     613                 :       1458 :     aPageDescs.clear();
     614                 :            : 
     615                 :            :     // Delete content selections.
     616                 :            :     // Don't wait for the SwNodes dtor to destroy them; so that Formats
     617                 :            :     // do not have any dependencies anymore.
     618 [ +  - ][ +  - ]:       1458 :     m_pNodes->DelNodes( SwNodeIndex(*m_pNodes), m_pNodes->Count() );
                 [ +  - ]
     619 [ +  - ][ +  - ]:       1458 :     rUndoNodes.DelNodes( SwNodeIndex( rUndoNodes ), rUndoNodes.Count() );
                 [ +  - ]
     620                 :            : 
     621                 :            :     // Delete Formats, make it permanent some time in the future
     622                 :            : 
     623                 :            :     // Delete for Collections
     624                 :            :     // So that we get rid of the dependencies
     625         [ +  - ]:       1458 :     pFtnInfo->ReleaseCollection();
     626         [ +  - ]:       1458 :     pEndNoteInfo->ReleaseCollection();
     627                 :            : 
     628                 :            :     OSL_ENSURE( pDfltTxtFmtColl == (*pTxtFmtCollTbl)[0],
     629                 :            :             "Default-Text-Collection must always be at the start" );
     630                 :            : 
     631                 :            :     // Optimization: Based on the fact that Standard is always 2nd in the
     632                 :            :     // array, we should delete it as the last. With this we avoid
     633                 :            :     // remangling the Formats all the time!
     634         [ +  + ]:       1458 :     if( 2 < pTxtFmtCollTbl->size() )
     635         [ +  - ]:       1431 :         DeleteAndDestroy(*pTxtFmtCollTbl, 2, pTxtFmtCollTbl->size());
     636         [ +  - ]:       1458 :     DeleteAndDestroy(*pTxtFmtCollTbl, 1, pTxtFmtCollTbl->size());
     637 [ +  - ][ +  - ]:       1458 :     delete pTxtFmtCollTbl;
     638                 :            : 
     639                 :            :     OSL_ENSURE( pDfltGrfFmtColl == (*pGrfFmtCollTbl)[0],
     640                 :            :             "DefaultGrfCollection must always be at the start" );
     641                 :            : 
     642         [ +  - ]:       1458 :     DeleteAndDestroy(*pGrfFmtCollTbl, 1, pGrfFmtCollTbl->size());
     643                 :            :     // Is the result anyway - no _DEL array!
     644                 :            :     //  pGrfFmtCollTbl->Remove( 0, n );
     645 [ +  - ][ +  - ]:       1458 :     delete pGrfFmtCollTbl;
     646                 :            : 
     647                 :            :     /*
     648                 :            :      * DefaultFormats and DefaultFormatCollections (FmtColl)
     649                 :            :      * are at position 0 of their respective arrays.
     650                 :            :      * In order to not be deleted by the array's dtor, we remove them
     651                 :            :      * now.
     652                 :            :      */
     653         [ +  - ]:       1458 :     pFrmFmtTbl->erase( pFrmFmtTbl->begin() );
     654         [ +  - ]:       1458 :     pCharFmtTbl->erase( pCharFmtTbl->begin() );
     655                 :            : 
     656                 :            :     // Delete for pPrt
     657 [ +  + ][ +  - ]:       1458 :     DELETEZ( pPrt );
     658 [ +  - ][ +  - ]:       1458 :     DELETEZ( pNewDBMgr );
     659                 :            : 
     660                 :            :     // All Flys need to be destroyed before the Drawing Model,
     661                 :            :     // because Flys can still contain DrawContacts, when no
     662                 :            :     // Layout could be constructed due to a read error.
     663         [ +  - ]:       1458 :     DeleteAndDestroy( *pSpzFrmFmtTbl, 0, pSpzFrmFmtTbl->size() );
     664                 :            : 
     665                 :            :     // Only now destroy the Model, the drawing objects - which are also
     666                 :            :     // contained in the Undo - need to remove their attributes from the
     667                 :            :     // Model. Also, DrawContacts could exist before that.
     668         [ +  - ]:       1458 :     ReleaseDrawModel();
     669                 :            :     // Destroy DrawModel before the LinkManager, because it's always set
     670                 :            :     // in the DrawModel.
     671 [ +  - ][ +  - ]:       1458 :     DELETEZ( pLinkMgr );
     672                 :            : 
     673                 :            :     // Clear the Tables before deleting them, or we crash due to
     674                 :            :     // definition dependencies.
     675                 :            :     // We also convert the arrays (due to includes) to pointers.
     676 [ +  - ][ +  - ]:       1458 :     delete pFrmFmtTbl;
     677 [ +  - ][ +  - ]:       1458 :     delete pSpzFrmFmtTbl;
     678                 :            : 
     679 [ +  - ][ +  - ]:       1458 :     delete pStyleAccess;
     680                 :            : 
     681 [ +  - ][ +  - ]:       1458 :     delete pCharFmtTbl;
     682 [ +  - ][ +  - ]:       1458 :     delete pSectionFmtTbl;
     683 [ +  - ][ +  - ]:       1458 :     delete pTblFrmFmtTbl;
     684 [ +  - ][ +  - ]:       1458 :     delete pDfltTxtFmtColl;
     685 [ +  - ][ +  - ]:       1458 :     delete pDfltGrfFmtColl;
     686 [ +  - ][ +  - ]:       1458 :     delete pNumRuleTbl;
     687                 :            : 
     688                 :            :     {
     689         [ +  + ]:       7450 :         for ( boost::unordered_map< String, SwList*, StringHash >::iterator
     690         [ +  - ]:       1458 :                                                     aListIter = maLists.begin();
     691         [ +  - ]:       3725 :               aListIter != maLists.end();
     692                 :            :               ++aListIter )
     693                 :            :         {
     694 [ +  - ][ +  - ]:       2267 :             delete (*aListIter).second;
                 [ +  - ]
     695                 :            :         }
     696         [ +  - ]:       1458 :         maLists.clear();
     697                 :            :     }
     698         [ +  - ]:       1458 :     maListStyleLists.clear();
     699                 :            : 
     700 [ +  + ][ +  - ]:       1458 :     delete pPrtData;
     701 [ +  + ][ +  - ]:       1458 :     delete pNumberFormatter;
     702 [ +  - ][ +  - ]:       1458 :     delete pFtnInfo;
     703 [ +  - ][ +  - ]:       1458 :     delete pEndNoteInfo;
     704 [ +  - ][ +  - ]:       1458 :     delete pLineNumberInfo;
     705         [ +  - ]:       1458 :     delete pFtnIdxs;
     706 [ +  - ][ +  - ]:       1458 :     delete pFldTypes;
     707 [ +  - ][ +  - ]:       1458 :     delete pTOXTypes;
     708                 :       1458 :     delete pDocStat;
     709 [ +  - ][ +  - ]:       1458 :     delete pEmptyPageFmt;
     710 [ +  - ][ +  - ]:       1458 :     delete pColumnContFmt;
     711 [ +  - ][ +  - ]:       1458 :     delete pDfltCharFmt;
     712 [ +  - ][ +  - ]:       1458 :     delete pDfltFrmFmt;
     713 [ +  + ][ +  - ]:       1458 :     delete pLayoutCache;
     714 [ +  + ][ +  - ]:       1458 :     delete pVirDev;
     715                 :            : 
     716 [ +  - ][ +  - ]:       1458 :     SfxItemPool::Free(mpAttrPool);
                 [ +  - ]
     717         [ -  + ]:       2916 : }
     718                 :            : 
     719                 :       1545 : VirtualDevice& SwDoc::CreateVirtualDevice_() const
     720                 :            : {
     721 [ +  - ][ +  - ]:       1545 :     VirtualDevice* pNewVir = new VirtualDevice( 1 );
     722                 :            : 
     723         [ +  - ]:       1545 :     pNewVir->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
     724                 :            : 
     725                 :            :     // #i60945# External leading compatibility for unix systems.
     726 [ +  - ][ -  + ]:       1545 :     if ( get(IDocumentSettingAccess::UNIX_FORCE_ZERO_EXT_LEADING ) )
     727         [ #  # ]:          0 :         pNewVir->Compat_ZeroExtleadBug();
     728                 :            : 
     729         [ +  - ]:       1545 :     MapMode aMapMode( pNewVir->GetMapMode() );
     730         [ +  - ]:       1545 :     aMapMode.SetMapUnit( MAP_TWIP );
     731         [ +  - ]:       1545 :     pNewVir->SetMapMode( aMapMode );
     732                 :            : 
     733         [ +  - ]:       1545 :     const_cast<SwDoc*>(this)->setVirtualDevice( pNewVir, true, true );
     734         [ +  - ]:       1545 :     return *pVirDev;
     735                 :            : }
     736                 :            : 
     737                 :         14 : SfxPrinter& SwDoc::CreatePrinter_() const
     738                 :            : {
     739                 :            :     OSL_ENSURE( ! pPrt, "Do not call CreatePrinter_(), call getPrinter() instead" );
     740                 :            : 
     741                 :            : #if OSL_DEBUG_LEVEL > 1
     742                 :            :     OSL_FAIL( "Printer will be created!" );
     743                 :            : #endif
     744                 :            : 
     745                 :            :     // We create a default SfxPrinter.
     746                 :            :     // The ItemSet is deleted by Sfx!
     747                 :         14 :     SfxItemSet *pSet = new SfxItemSet( ((SwDoc*)this)->GetAttrPool(),
     748                 :            :                     FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
     749                 :            :                     SID_HTML_MODE,  SID_HTML_MODE,
     750                 :            :                     SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
     751                 :            :                     SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
     752         [ +  - ]:         14 :                     0 );
     753                 :            : 
     754         [ +  - ]:         14 :     SfxPrinter* pNewPrt = new SfxPrinter( pSet );
     755                 :         14 :     const_cast<SwDoc*>(this)->setPrinter( pNewPrt, true, true );
     756                 :         14 :     return *pPrt;
     757                 :            : }
     758                 :            : 
     759                 :       3267 : void SwDoc::SetDocShell( SwDocShell* pDSh )
     760                 :            : {
     761         [ +  - ]:       3267 :     if( pDocShell != pDSh )
     762                 :            :     {
     763         [ +  + ]:       3267 :         if (pDocShell)
     764                 :            :         {
     765                 :       1576 :             pDocShell->SetUndoManager(0);
     766                 :            :         }
     767                 :       3267 :         pDocShell = pDSh;
     768         [ +  + ]:       3267 :         if (pDocShell)
     769                 :            :         {
     770         [ +  - ]:       1691 :             pDocShell->SetUndoManager(& GetUndoManager());
     771                 :            :         }
     772                 :            : 
     773                 :       3267 :         pLinkMgr->SetPersist( pDocShell );
     774         [ +  + ]:       3267 :         if( pDrawModel )
     775                 :            :         {
     776                 :       1585 :             ((SwDrawDocument*)pDrawModel)->SetObjectShell( pDocShell );
     777         [ +  + ]:       1585 :             pDrawModel->SetPersist( pDocShell );
     778                 :            :             OSL_ENSURE( pDrawModel->GetPersist() == GetPersist(),
     779                 :            :                     "draw model's persist is out of sync" );
     780                 :            :         }
     781                 :            :     }
     782                 :       3267 : }
     783                 :            : 
     784                 :            : // Convenience method; to avoid excessive includes from docsh.hxx
     785                 :          0 : uno::Reference < embed::XStorage > SwDoc::GetDocStorage()
     786                 :            : {
     787         [ #  # ]:          0 :     if( pDocShell )
     788                 :          0 :         return pDocShell->GetStorage();
     789         [ #  # ]:          0 :     if( pLinkMgr->GetPersist() )
     790                 :          0 :         return pLinkMgr->GetPersist()->GetStorage();
     791                 :          0 :     return NULL;
     792                 :            : }
     793                 :            : 
     794                 :       1020 : SfxObjectShell* SwDoc::GetPersist() const
     795                 :            : {
     796         [ +  - ]:       1020 :     return pDocShell ? pDocShell : pLinkMgr->GetPersist();
     797                 :            : }
     798                 :            : 
     799                 :         46 : void SwDoc::ClearDoc()
     800                 :            : {
     801 [ +  - ][ +  - ]:         46 :     GetIDocumentUndoRedo().DelAllUndoObj();
     802 [ +  - ][ +  - ]:         46 :     ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
     803                 :            : 
     804                 :            :     // Deactivate Undo notification from the Draw
     805         [ -  + ]:         46 :     if( pDrawModel )
     806                 :            :     {
     807         [ #  # ]:          0 :         DrawNotifyUndoHdl();
     808         [ #  # ]:          0 :         ClrContourCache();
     809                 :            :     }
     810                 :            : 
     811                 :            :     // if there are still FlyFrames dangling around, delete them too
     812                 :            :     sal_uInt16 n;
     813         [ -  + ]:         46 :     while ( 0 != (n = GetSpzFrmFmts()->size()) )
     814 [ #  # ][ #  # ]:          0 :         DelLayoutFmt((*pSpzFrmFmtTbl)[n-1]);
     815                 :            :     OSL_ENSURE( !pDrawModel || !pDrawModel->GetPage(0)->GetObjCount(),
     816                 :            :                 "not all DrawObjects removed from the page" );
     817                 :            : 
     818         [ +  - ]:         46 :     pRedlineTbl->DeleteAndDestroyAll();
     819                 :            : 
     820 [ -  + ][ #  # ]:         46 :     delete pACEWord;
     821                 :            : 
     822                 :            :     // The BookMarks contain indices to the Content. These must be deleted
     823                 :            :     // before deleting the Nodes.
     824         [ +  - ]:         46 :     pMarkManager->clearAllMarks();
     825         [ +  - ]:         46 :     InitTOXTypes();
     826                 :            : 
     827                 :            :     // create a dummy pagedesc for the layout
     828 [ +  - ][ +  - ]:         46 :     sal_uInt16 nDummyPgDsc = MakePageDesc(rtl::OUString("?DUMMY?"));
                 [ +  - ]
     829                 :         46 :     SwPageDesc* pDummyPgDsc = aPageDescs[ nDummyPgDsc ];
     830                 :            : 
     831 [ +  - ][ +  - ]:         46 :     SwNodeIndex aSttIdx( *GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
     832                 :            :     // create the first one over and over again (without Attribute/Templates etc.
     833 [ +  - ][ +  - ]:         46 :     SwTxtNode* pFirstNd = GetNodes().MakeTxtNode( aSttIdx, pDfltTxtFmtColl );
     834                 :            : 
     835         [ -  + ]:         46 :     if( pCurrentView )  //swmod 071029//swmod 071225
     836                 :            :     {
     837                 :            :         // set the layout to the dummy pagedesc
     838 [ #  # ][ #  # ]:          0 :         pFirstNd->SetAttr( SwFmtPageDesc( pDummyPgDsc ));
                 [ #  # ]
     839                 :            : 
     840 [ #  # ][ #  # ]:          0 :         SwPosition aPos( *pFirstNd, SwIndex( pFirstNd ));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     841 [ #  # ][ #  # ]:          0 :         SwPaM const tmpPaM(aSttIdx, SwNodeIndex(GetNodes().GetEndOfContent()));
         [ #  # ][ #  # ]
     842 [ #  # ][ #  # ]:          0 :         ::PaMCorrAbs(tmpPaM, aPos);
                 [ #  # ]
     843                 :            :     }
     844                 :            : 
     845         [ +  - ]:         46 :     GetNodes().Delete( aSttIdx,
     846 [ +  - ][ +  - ]:         92 :             GetNodes().GetEndOfContent().GetIndex() - aSttIdx.GetIndex() );
     847                 :            : 
     848                 :            :     // #i62440#
     849                 :            :     // destruction of numbering rules and creation of new outline rule
     850                 :            :     // *after* the document nodes are deleted.
     851                 :         46 :     pOutlineRule = NULL;
     852 [ +  - ][ +  - ]:        138 :     BOOST_FOREACH( SwNumRule* pNumRule, *pNumRuleTbl )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
     853 [ +  - ][ +  - ]:         46 :         delete pNumRule;
     854                 :         46 :     pNumRuleTbl->clear();
     855                 :            :     // creation of new outline numbering rule
     856                 :         46 :     pOutlineRule = new SwNumRule( rtl::OUString::createFromAscii( SwNumRule::GetOutlineRuleName() ),
     857                 :            :                                   // #i89178#
     858                 :            :                                   numfunc::GetDefaultPositionAndSpaceMode(),
     859 [ +  - ][ +  - ]:         46 :                                   OUTLINE_RULE );
         [ +  - ][ +  - ]
                 [ +  - ]
     860         [ +  - ]:         46 :     AddNumRule(pOutlineRule);
     861                 :            :     // Counting of phantoms depends on <IsOldNumbering()>
     862 [ +  - ][ +  - ]:         46 :     pOutlineRule->SetCountPhantoms( !get(IDocumentSettingAccess::OLD_NUMBERING) );
     863                 :            : 
     864                 :            :     // remove the dummy pagedec from the array and delete all the old ones
     865 [ +  - ][ +  - ]:         46 :     aPageDescs.erase( aPageDescs.begin() + nDummyPgDsc );
     866 [ +  - ][ +  - ]:        138 :     BOOST_FOREACH(SwPageDesc *pPageDesc, aPageDescs)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  + ]
                 [ +  + ]
     867 [ +  - ][ +  - ]:         46 :         delete pPageDesc;
     868                 :         46 :     aPageDescs.clear();
     869                 :            : 
     870                 :            :     // Delete for Collections
     871                 :            :     // So that we get rid of the dependencies
     872         [ +  - ]:         46 :     pFtnInfo->ReleaseCollection();
     873         [ +  - ]:         46 :     pEndNoteInfo->ReleaseCollection();
     874                 :            : 
     875                 :            :     // Optimization: Based on the fact that Standard is always 2nd in the
     876                 :            :     // array, we should delete it as the last. With this we avoid
     877                 :            :     // remangling the Formats all the time!
     878         [ +  + ]:         46 :     if( 2 < pTxtFmtCollTbl->size() )
     879         [ +  - ]:         25 :         DeleteAndDestroy(*pTxtFmtCollTbl, 2, pTxtFmtCollTbl->size());
     880         [ +  - ]:         46 :     DeleteAndDestroy(*pTxtFmtCollTbl, 1, pTxtFmtCollTbl->size());
     881         [ +  - ]:         46 :     DeleteAndDestroy(*pGrfFmtCollTbl, 1, pGrfFmtCollTbl->size());
     882         [ +  - ]:         46 :     DeleteAndDestroy(*pCharFmtTbl, 1, pCharFmtTbl->size());
     883                 :            : 
     884         [ -  + ]:         46 :     if( pCurrentView )
     885                 :            :     {
     886                 :            :         // search the FrameFormat of the root frm. This is not allowed to delete
     887 [ #  # ][ #  # ]:          0 :         pFrmFmtTbl->erase( std::find( pFrmFmtTbl->begin(), pFrmFmtTbl->end(), pCurrentView->GetLayout()->GetFmt() ) );
         [ #  # ][ #  # ]
     888         [ #  # ]:          0 :         DeleteAndDestroy(*pFrmFmtTbl, 1, pFrmFmtTbl->size());
     889 [ #  # ][ #  # ]:          0 :         pFrmFmtTbl->push_back( pCurrentView->GetLayout()->GetFmt() );
                 [ #  # ]
     890                 :            :     }
     891                 :            :     else    //swmod 071029//swmod 071225
     892         [ +  - ]:         46 :         DeleteAndDestroy(*pFrmFmtTbl, 1, pFrmFmtTbl->size());
     893                 :            : 
     894         [ +  - ]:         46 :     xForbiddenCharsTable.clear();
     895                 :            : 
     896 [ +  - ][ +  - ]:         92 :     for(SwFldTypes::const_iterator it = pFldTypes->begin() + INIT_FLDTYPES;
         [ +  - ][ -  + ]
     897                 :         46 :         it != pFldTypes->end(); ++it)
     898 [ #  # ][ #  # ]:          0 :         delete *it;
     899 [ +  - ][ +  - ]:         46 :     pFldTypes->erase( pFldTypes->begin() + INIT_FLDTYPES, pFldTypes->end() );
     900                 :            : 
     901 [ -  + ][ #  # ]:         46 :     delete pNumberFormatter, pNumberFormatter = 0;
     902                 :            : 
     903         [ +  - ]:         46 :     GetPageDescFromPool( RES_POOLPAGE_STANDARD );
     904 [ +  - ][ +  - ]:         46 :     pFirstNd->ChgFmtColl( GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
     905                 :         46 :     nDummyPgDsc = aPageDescs.size();
     906         [ +  - ]:         46 :     aPageDescs.push_back( pDummyPgDsc );
     907                 :            :     // set the layout back to the new standard pagedesc
     908         [ +  - ]:         46 :     pFirstNd->ResetAllAttr();
     909                 :            :     // delete now the dummy pagedesc
     910 [ +  - ][ +  - ]:         46 :     DelPageDesc( nDummyPgDsc );
                 [ +  - ]
     911                 :         46 : }
     912                 :            : 
     913                 :          0 : void SwDoc::SetPreViewPrtData( const SwPagePreViewPrtData* pNew )
     914                 :            : {
     915         [ #  # ]:          0 :     if( pNew )
     916                 :            :     {
     917         [ #  # ]:          0 :         if( pPgPViewPrtData )
     918                 :          0 :             *pPgPViewPrtData = *pNew;
     919                 :            :         else
     920                 :          0 :             pPgPViewPrtData = new SwPagePreViewPrtData( *pNew );
     921                 :            :     }
     922         [ #  # ]:          0 :     else if( pPgPViewPrtData )
     923                 :          0 :         DELETEZ( pPgPViewPrtData );
     924                 :          0 :     SetModified();
     925                 :          0 : }
     926                 :            : 
     927                 :        750 : SwModify*   SwDoc::GetUnoCallBack() const
     928                 :            : {
     929                 :        750 :     return pUnoCallBack;
     930                 :            : }
     931                 :            : 
     932                 :            : 
     933                 :            : /** SwDoc:
     934                 :            :  *  Reading and writing of the layout cache.
     935                 :            :  *--------------------------------------------------*/
     936                 :         12 : void SwDoc::ReadLayoutCache( SvStream& rStream )
     937                 :            : {
     938         [ +  - ]:         12 :     if( !pLayoutCache )
     939                 :         12 :         pLayoutCache = new SwLayoutCache();
     940         [ +  - ]:         12 :     if( !pLayoutCache->IsLocked() )
     941                 :            :     {
     942                 :         12 :         pLayoutCache->GetLockCount() |= 0x8000;
     943                 :         12 :         pLayoutCache->Read( rStream );
     944                 :         12 :         pLayoutCache->GetLockCount() &= 0x7fff;
     945                 :            :     }
     946                 :         12 : }
     947                 :            : 
     948                 :          4 : void SwDoc::WriteLayoutCache( SvStream& rStream )
     949                 :            : {
     950                 :          4 :     pLayoutCache->Write( rStream, *this );
     951                 :          4 : }
     952                 :            : 
     953                 :      17035 : IGrammarContact* getGrammarContact( const SwTxtNode& rTxtNode )
     954                 :            : {
     955                 :      17035 :     const SwDoc* pDoc = rTxtNode.GetDoc();
     956 [ -  + ][ -  + ]:      17035 :     if( !pDoc || pDoc->IsInDtor() )
                 [ +  - ]
     957                 :          0 :         return 0;
     958                 :      17035 :     return pDoc->getGrammarContact();
     959                 :            : }
     960                 :            : 
     961                 :            : // #i42634# Moved common code of SwReader::Read() and SwDocShell::UpdateLinks()
     962                 :            : // to new SwDoc::UpdateLinks():
     963                 :        661 : void SwDoc::UpdateLinks( sal_Bool bUI )
     964                 :            : {
     965                 :            :     SfxObjectCreateMode eMode;
     966                 :        661 :     sal_uInt16 nLinkMode = getLinkUpdateMode( true );
     967         [ +  - ]:        661 :     if ( GetDocShell()) {
     968                 :        661 :         sal_uInt16 nUpdateDocMode = GetDocShell()->GetUpdateDocMode();
     969   [ #  #  -  +  :       1322 :         if( (nLinkMode != NEVER ||  document::UpdateDocMode::FULL_UPDATE == nUpdateDocMode) &&
           #  # ][ #  # ]
           [ #  #  #  # ]
         [ -  + ][ -  + ]
     970                 :        661 :             !GetLinkManager().GetLinks().empty() &&
     971                 :            :             SFX_CREATE_MODE_INTERNAL !=
     972                 :          0 :                         ( eMode = GetDocShell()->GetCreateMode()) &&
     973                 :            :             SFX_CREATE_MODE_ORGANIZER != eMode &&
     974                 :            :             SFX_CREATE_MODE_PREVIEW != eMode &&
     975                 :          0 :             !GetDocShell()->IsPreview() )
     976                 :            :         {
     977                 :          0 :             ViewShell* pVSh = 0;
     978                 :          0 :             sal_Bool bAskUpdate = nLinkMode == MANUAL;
     979                 :          0 :             sal_Bool bUpdate = sal_True;
     980   [ #  #  #  # ]:          0 :             switch(nUpdateDocMode)
     981                 :            :             {
     982                 :          0 :                 case document::UpdateDocMode::NO_UPDATE:   bUpdate = sal_False;break;
     983                 :          0 :                 case document::UpdateDocMode::QUIET_UPDATE:bAskUpdate = sal_False; break;
     984                 :          0 :                 case document::UpdateDocMode::FULL_UPDATE: bAskUpdate = sal_True; break;
     985                 :            :             }
     986 [ #  # ][ #  # ]:          0 :             if( bUpdate && (bUI || !bAskUpdate) )
                 [ #  # ]
     987                 :            :             {
     988                 :          0 :                 SfxMedium* pMedium = GetDocShell()->GetMedium();
     989 [ #  # ][ #  # ]:          0 :                 SfxFrame* pFrm = pMedium ? pMedium->GetLoadTargetFrame() : 0;
     990 [ #  # ][ #  # ]:          0 :                 Window* pDlgParent = pFrm ? &pFrm->GetWindow() : 0;
     991 [ #  # ][ #  # ]:          0 :                 if( GetCurrentViewShell() && !GetEditShell( &pVSh ) && !pVSh )  //swmod 071108//swmod 071225
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     992                 :            :                 {
     993         [ #  # ]:          0 :                     ViewShell aVSh( *this, 0, 0 );
     994                 :            : 
     995         [ #  # ]:          0 :                     SET_CURR_SHELL( &aVSh );
     996 [ #  # ][ #  # ]:          0 :                     GetLinkManager().UpdateAllLinks( bAskUpdate , sal_True, sal_False, pDlgParent );
         [ #  # ][ #  # ]
     997                 :            :                 }
     998                 :            :                 else
     999 [ #  # ][ #  # ]:          0 :                     GetLinkManager().UpdateAllLinks( bAskUpdate, sal_True, sal_False, pDlgParent );
    1000                 :            :             }
    1001                 :            :         }
    1002                 :            :     }
    1003                 :            : 
    1004                 :        661 : }
    1005                 :            : 
    1006                 :          8 : void SwDoc::SetApplyWorkaroundForB6375613( bool p_bApplyWorkaroundForB6375613 )
    1007                 :            : {
    1008         [ +  - ]:          8 :     if ( mbApplyWorkaroundForB6375613 != p_bApplyWorkaroundForB6375613 )
    1009                 :            :     {
    1010                 :          8 :         mbApplyWorkaroundForB6375613 = p_bApplyWorkaroundForB6375613;
    1011                 :            : 
    1012                 :            :         uno::Reference< document::XDocumentInfoSupplier > xDoc(
    1013                 :          8 :                                                 GetDocShell()->GetBaseModel(),
    1014 [ +  - ][ +  - ]:          8 :                                                 uno::UNO_QUERY);
    1015         [ +  - ]:          8 :         if ( xDoc.is() )
    1016                 :            :         {
    1017                 :            :             uno::Reference< beans::XPropertyContainer > xDocInfo(
    1018         [ +  - ]:          8 :                                                         xDoc->getDocumentInfo(),
    1019 [ +  - ][ +  - ]:          8 :                                                         uno::UNO_QUERY );
    1020         [ +  - ]:          8 :             if ( xDocInfo.is() )
    1021                 :            :             {
    1022                 :            :                 try
    1023                 :            :                 {
    1024         [ +  + ]:          8 :                     if ( mbApplyWorkaroundForB6375613 )
    1025                 :            :                     {
    1026         [ +  - ]:          4 :                         xDocInfo->addProperty(
    1027                 :            :                             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WorkaroundForB6375613Applied")),
    1028                 :            :                             beans::PropertyAttribute::TRANSIENT | beans::PropertyAttribute::REMOVABLE,
    1029 [ +  - ][ +  - ]:          4 :                             uno::makeAny( false ) );
                 [ +  - ]
    1030                 :            :                     }
    1031                 :            :                     else
    1032                 :            :                     {
    1033 [ +  - ][ +  - ]:          4 :                         xDocInfo->removeProperty( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WorkaroundForB6375613Applied")) );
         [ +  - ][ #  # ]
    1034                 :            :                     }
    1035                 :            :                 }
    1036         [ #  # ]:          0 :                 catch( uno::Exception& )
    1037                 :            :                 {
    1038                 :            :                 }
    1039                 :          8 :             }
    1040                 :          8 :         }
    1041                 :            :     }
    1042                 :          8 : }
    1043                 :            : 
    1044                 :            : ::sfx2::IXmlIdRegistry&
    1045                 :        342 : SwDoc::GetXmlIdRegistry()
    1046                 :            : {
    1047                 :            :     // UGLY: this relies on SetClipBoard being called before GetXmlIdRegistry!
    1048         [ +  + ]:        342 :     if (!m_pXmlIdRegistry.get())
    1049                 :            :     {
    1050                 :         68 :         m_pXmlIdRegistry.reset( ::sfx2::createXmlIdRegistry( IsClipBoard() ) );
    1051                 :            :     }
    1052                 :        342 :     return *m_pXmlIdRegistry;
    1053                 :            : }
    1054                 :            : 
    1055                 :            : ::sw::MetaFieldManager &
    1056                 :        802 : SwDoc::GetMetaFieldManager()
    1057                 :            : {
    1058                 :        802 :     return *m_pMetaFieldManager;
    1059                 :            : }
    1060                 :            : 
    1061                 :            : ::sw::UndoManager &
    1062                 :       5868 : SwDoc::GetUndoManager()
    1063                 :            : {
    1064                 :       5868 :     return *m_pUndoManager;
    1065                 :            : }
    1066                 :            : 
    1067                 :            : ::sw::UndoManager const&
    1068                 :          0 : SwDoc::GetUndoManager() const
    1069                 :            : {
    1070                 :          0 :     return *m_pUndoManager;
    1071                 :            : }
    1072                 :            : 
    1073                 :            : IDocumentUndoRedo &
    1074                 :     450155 : SwDoc::GetIDocumentUndoRedo()
    1075                 :            : {
    1076                 :     450155 :     return *m_pUndoManager;
    1077                 :            : }
    1078                 :            : 
    1079                 :            : IDocumentUndoRedo const&
    1080                 :       2088 : SwDoc::GetIDocumentUndoRedo() const
    1081                 :            : {
    1082                 :       2088 :     return *m_pUndoManager;
    1083                 :            : }
    1084                 :            : 
    1085                 :       1595 : void SwDoc::InitTOXTypes()
    1086                 :            : {
    1087         [ +  - ]:       1595 :    ShellResource* pShellRes = ViewShell::GetShellRes();
    1088 [ +  - ][ +  - ]:       1595 :    SwTOXType * pNew = new SwTOXType(TOX_CONTENT,   pShellRes->aTOXContentName        );
    1089         [ +  - ]:       1595 :    pTOXTypes->push_back( pNew );
    1090 [ +  - ][ +  - ]:       1595 :    pNew = new SwTOXType(TOX_INDEX,                 pShellRes->aTOXIndexName  );
    1091         [ +  - ]:       1595 :    pTOXTypes->push_back( pNew );
    1092 [ +  - ][ +  - ]:       1595 :    pNew = new SwTOXType(TOX_USER,                  pShellRes->aTOXUserName  );
    1093         [ +  - ]:       1595 :    pTOXTypes->push_back( pNew );
    1094 [ +  - ][ +  - ]:       1595 :    pNew = new SwTOXType(TOX_ILLUSTRATIONS,         pShellRes->aTOXIllustrationsName );
    1095         [ +  - ]:       1595 :    pTOXTypes->push_back( pNew );
    1096 [ +  - ][ +  - ]:       1595 :    pNew = new SwTOXType(TOX_OBJECTS,               pShellRes->aTOXObjectsName       );
    1097         [ +  - ]:       1595 :    pTOXTypes->push_back( pNew );
    1098 [ +  - ][ +  - ]:       1595 :    pNew = new SwTOXType(TOX_TABLES,                pShellRes->aTOXTablesName        );
    1099         [ +  - ]:       1595 :    pTOXTypes->push_back( pNew );
    1100 [ +  - ][ +  - ]:       1595 :    pNew = new SwTOXType(TOX_AUTHORITIES,           pShellRes->aTOXAuthoritiesName   );
    1101         [ +  - ]:       1595 :    pTOXTypes->push_back( pNew );
    1102                 :       1595 : }
    1103                 :            : 
    1104                 :          0 : void SwDoc::ReplaceDefaults(const SwDoc& rSource)
    1105                 :            : {
    1106                 :            :     // copy property defaults
    1107                 :            :     const sal_uInt16 aRangeOfDefaults[] =
    1108                 :            :     {
    1109                 :            :         RES_FRMATR_BEGIN, RES_FRMATR_END-1,
    1110                 :            :         RES_CHRATR_BEGIN, RES_CHRATR_END-1,
    1111                 :            :         RES_PARATR_BEGIN, RES_PARATR_END-1,
    1112                 :            :         RES_PARATR_LIST_BEGIN, RES_PARATR_LIST_END-1,
    1113                 :            :         RES_UNKNOWNATR_BEGIN, RES_UNKNOWNATR_END-1,
    1114                 :            :         0
    1115                 :          0 :     };
    1116                 :            : 
    1117         [ #  # ]:          0 :     SfxItemSet aNewDefaults(GetAttrPool(), aRangeOfDefaults);
    1118                 :            : 
    1119                 :          0 :     sal_uInt16 nRange = 0;
    1120         [ #  # ]:          0 :     while (aRangeOfDefaults[nRange] != 0)
    1121                 :            :     {
    1122         [ #  # ]:          0 :         for (sal_uInt16 nWhich = aRangeOfDefaults[nRange];
    1123                 :          0 :              nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich)
    1124                 :            :         {
    1125                 :            :             const SfxPoolItem& rSourceAttr =
    1126         [ #  # ]:          0 :                 rSource.mpAttrPool->GetDefaultItem(nWhich);
    1127 [ #  # ][ #  # ]:          0 :             if (rSourceAttr != mpAttrPool->GetDefaultItem(nWhich))
                 [ #  # ]
    1128         [ #  # ]:          0 :                 aNewDefaults.Put(rSourceAttr);
    1129                 :            :         }
    1130                 :          0 :         nRange += 2;
    1131                 :            :     }
    1132                 :            : 
    1133         [ #  # ]:          0 :     if (aNewDefaults.Count())
    1134 [ #  # ][ #  # ]:          0 :         SetDefault(aNewDefaults);
    1135                 :          0 : }
    1136                 :            : 
    1137                 :          0 : void SwDoc::ReplaceCompatabilityOptions(const SwDoc& rSource)
    1138                 :            : {
    1139                 :          0 :     n32DummyCompatabilityOptions1 = rSource.n32DummyCompatabilityOptions1;
    1140                 :          0 :     n32DummyCompatabilityOptions2 = rSource.n32DummyCompatabilityOptions2;
    1141                 :          0 :     mbParaSpaceMax = rSource.mbParaSpaceMax;
    1142                 :          0 :     mbParaSpaceMaxAtPages = rSource.mbParaSpaceMaxAtPages;
    1143                 :          0 :     mbTabCompat = rSource.mbTabCompat;
    1144                 :          0 :     mbUseVirtualDevice = rSource.mbUseVirtualDevice;
    1145                 :          0 :     mbAddExternalLeading = rSource.mbAddExternalLeading;
    1146                 :          0 :     mbOldLineSpacing = rSource.mbOldLineSpacing;
    1147                 :          0 :     mbAddParaSpacingToTableCells = rSource.mbAddParaSpacingToTableCells;
    1148                 :          0 :     mbUseFormerObjectPos = rSource.mbUseFormerObjectPos;
    1149                 :          0 :     mbUseFormerTextWrapping = rSource.mbUseFormerTextWrapping;
    1150                 :          0 :     mbConsiderWrapOnObjPos = rSource.mbConsiderWrapOnObjPos;
    1151                 :          0 :     mbAddFlyOffsets = rSource.mbAddFlyOffsets;
    1152                 :          0 :     mbOldNumbering = rSource.mbOldNumbering;
    1153                 :          0 :     mbUseHiResolutionVirtualDevice = rSource.mbUseHiResolutionVirtualDevice;
    1154                 :          0 :     mbIgnoreFirstLineIndentInNumbering = rSource.mbIgnoreFirstLineIndentInNumbering;
    1155                 :          0 :     mbDoNotJustifyLinesWithManualBreak = rSource.mbDoNotJustifyLinesWithManualBreak;
    1156                 :          0 :     mbDoNotResetParaAttrsForNumFont = rSource.mbDoNotResetParaAttrsForNumFont;
    1157                 :          0 :     mbOutlineLevelYieldsOutlineRule = rSource.mbOutlineLevelYieldsOutlineRule;
    1158                 :          0 :     mbTableRowKeep = rSource.mbTableRowKeep;
    1159                 :          0 :     mbIgnoreTabsAndBlanksForLineCalculation = rSource.mbIgnoreTabsAndBlanksForLineCalculation;
    1160                 :          0 :     mbDoNotCaptureDrawObjsOnPage = rSource.mbDoNotCaptureDrawObjsOnPage;
    1161                 :          0 :     mbClipAsCharacterAnchoredWriterFlyFrames = rSource.mbClipAsCharacterAnchoredWriterFlyFrames;
    1162                 :          0 :     mbUnixForceZeroExtLeading = rSource.mbUnixForceZeroExtLeading;
    1163                 :          0 :     mbOldPrinterMetrics = rSource.mbOldPrinterMetrics;
    1164                 :          0 :     mbTabRelativeToIndent = rSource.mbTabRelativeToIndent;
    1165                 :          0 :     mbTabAtLeftIndentForParagraphsInList = rSource.mbTabAtLeftIndentForParagraphsInList;
    1166                 :          0 : }
    1167                 :            : 
    1168                 :          0 : SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
    1169                 :            : {
    1170         [ #  # ]:          0 :     SwDoc* pRet = new SwDoc;
    1171                 :            : 
    1172                 :            :     // we have to use pointer here, since the callee has to decide whether
    1173                 :            :     // SfxObjectShellLock or SfxObjectShellRef should be used sometimes the
    1174                 :            :     // object will be returned with refcount set to 0 ( if no DoInitNew is done )
    1175         [ #  # ]:          0 :     SfxObjectShell* pRetShell = new SwDocShell( pRet, SFX_CREATE_MODE_STANDARD );
    1176         [ #  # ]:          0 :     if( bCallInitNew )
    1177                 :            :     {
    1178                 :            :         // it could happen that DoInitNew creates model, that increases the refcount of the object
    1179                 :          0 :         pRetShell->DoInitNew();
    1180                 :            :     }
    1181                 :            : 
    1182                 :          0 :     pRet->acquire();
    1183                 :            : 
    1184                 :          0 :     pRet->ReplaceDefaults(*this);
    1185                 :            : 
    1186                 :          0 :     pRet->ReplaceCompatabilityOptions(*this);
    1187                 :            : 
    1188                 :          0 :     pRet->ReplaceStyles(*this);
    1189                 :            : 
    1190                 :            :     // copy content
    1191                 :          0 :     pRet->Paste( *this );
    1192                 :            : 
    1193                 :            :     // remove the temporary shell if it is there as it was done before
    1194         [ #  # ]:          0 :     pRet->SetTmpDocShell( (SfxObjectShell*)NULL );
    1195                 :            : 
    1196                 :          0 :     pRet->release();
    1197                 :            : 
    1198                 :          0 :     return pRetShell;
    1199                 :            : }
    1200                 :            : 
    1201                 :            : /*-------------------------------------------------------------------------
    1202                 :            :     copy document content - code from SwFEShell::Paste( SwDoc* , sal_Bool  )
    1203                 :            :   -----------------------------------------------------------------------*/
    1204                 :          0 : void SwDoc::Paste( const SwDoc& rSource )
    1205                 :            : {
    1206                 :            :     // this has to be empty const sal_uInt16 nStartPageNumber = GetPhyPageNum();
    1207                 :            :     // until the end of the NodesArray
    1208 [ #  # ][ #  # ]:          0 :     SwNodeIndex aSourceIdx( rSource.GetNodes().GetEndOfExtras(), 2 );
    1209         [ #  # ]:          0 :     SwPaM aCpyPam( aSourceIdx ); //DocStart
    1210 [ #  # ][ #  # ]:          0 :     SwNodeIndex aTargetIdx( GetNodes().GetEndOfExtras(), 2 );
    1211         [ #  # ]:          0 :     SwPaM aInsertPam( aTargetIdx ); //replaces PCURCRSR from SwFEShell::Paste()
    1212                 :            : 
    1213                 :            : 
    1214         [ #  # ]:          0 :     aCpyPam.SetMark();
    1215         [ #  # ]:          0 :     aCpyPam.Move( fnMoveForward, fnGoDoc );
    1216                 :            : 
    1217 [ #  # ][ #  # ]:          0 :     this->GetIDocumentUndoRedo().StartUndo( UNDO_INSGLOSSARY, NULL );
    1218         [ #  # ]:          0 :     this->LockExpFlds();
    1219                 :            : 
    1220                 :            :     {
    1221                 :          0 :         SwPosition& rInsPos = *aInsertPam.GetPoint();
    1222                 :            :         //find out if the clipboard document starts with a table
    1223 [ #  # ][ #  # ]:          0 :         bool bStartWithTable = 0 != aCpyPam.Start()->nNode.GetNode().FindTableNode();
    1224         [ #  # ]:          0 :         SwPosition aInsertPosition( rInsPos );
    1225                 :            : 
    1226                 :            :         {
    1227         [ #  # ]:          0 :             SwNodeIndex aIndexBefore(rInsPos.nNode);
    1228                 :            : 
    1229         [ #  # ]:          0 :             aIndexBefore--;
    1230                 :            : 
    1231         [ #  # ]:          0 :             rSource.CopyRange( aCpyPam, rInsPos, true );
    1232                 :            : 
    1233                 :            :             {
    1234         [ #  # ]:          0 :                 aIndexBefore++;
    1235                 :            :                 SwPaM aPaM(SwPosition(aIndexBefore),
    1236 [ #  # ][ #  # ]:          0 :                            SwPosition(rInsPos.nNode));
         [ #  # ][ #  # ]
                 [ #  # ]
    1237                 :            : 
    1238 [ #  # ][ #  # ]:          0 :                 MakeUniqueNumRules(aPaM);
    1239         [ #  # ]:          0 :             }
    1240                 :            :         }
    1241                 :            : 
    1242                 :            :         //TODO: Is this necessary here? SaveTblBoxCntnt( &rInsPos );
    1243         [ #  # ]:          0 :         if(/*bIncludingPageFrames && */bStartWithTable)
    1244                 :            :         {
    1245                 :            :             //remove the paragraph in front of the table
    1246         [ #  # ]:          0 :             SwPaM aPara(aInsertPosition);
    1247 [ #  # ][ #  # ]:          0 :             this->DelFullPara(aPara);
    1248                 :            :         }
    1249                 :            :         //additionally copy page bound frames
    1250         [ #  # ]:          0 :         if( /*bIncludingPageFrames && */rSource.GetSpzFrmFmts()->size() )
    1251                 :            :         {
    1252         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < rSource.GetSpzFrmFmts()->size(); ++i )
    1253                 :            :             {
    1254                 :          0 :                 sal_Bool bInsWithFmt = sal_True;
    1255         [ #  # ]:          0 :                 const SwFrmFmt& rCpyFmt = *(*rSource.GetSpzFrmFmts())[i];
    1256         [ #  # ]:          0 :                 if( bInsWithFmt  )
    1257                 :            :                 {
    1258 [ #  # ][ #  # ]:          0 :                     SwFmtAnchor aAnchor( rCpyFmt.GetAnchor() );
    1259         [ #  # ]:          0 :                     if (FLY_AT_PAGE == aAnchor.GetAnchorId())
    1260                 :            :                     {
    1261                 :          0 :                         aAnchor.SetPageNum( aAnchor.GetPageNum() /*+ nStartPageNumber - */);
    1262                 :            :                     }
    1263                 :            :                     else
    1264                 :          0 :                         continue;
    1265 [ #  # ][ #  # ]:          0 :                     this->CopyLayoutFmt( rCpyFmt, aAnchor, true, true );
                 [ #  # ]
    1266                 :            :                 }
    1267                 :            :             }
    1268         [ #  # ]:          0 :         }
    1269                 :            :     }
    1270                 :            : 
    1271 [ #  # ][ #  # ]:          0 :     this->GetIDocumentUndoRedo().EndUndo( UNDO_INSGLOSSARY, NULL );
    1272                 :            : 
    1273         [ #  # ]:          0 :     UnlockExpFlds();
    1274 [ #  # ][ #  # ]:          0 :     UpdateFlds(NULL, false);
         [ #  # ][ #  # ]
                 [ #  # ]
    1275                 :          0 : }
    1276                 :            : 
    1277                 :          0 : sal_uInt16 SwTxtFmtColls::GetPos(const SwTxtFmtColl* p) const
    1278                 :            : {
    1279         [ #  # ]:          0 :     const_iterator it = std::find(begin(), end(), p);
    1280 [ #  # ][ #  # ]:          0 :     return it == end() ? USHRT_MAX : it - begin();
         [ #  # ][ #  # ]
                 [ #  # ]
    1281                 :            : }
    1282                 :            : 
    1283                 :          0 : sal_uInt16 SwGrfFmtColls::GetPos(const SwGrfFmtColl* p) const
    1284                 :            : {
    1285         [ #  # ]:          0 :     const_iterator it = std::find(begin(), end(), p);
    1286 [ #  # ][ #  # ]:          0 :     return it == end() ? USHRT_MAX : it - begin();
         [ #  # ][ #  # ]
                 [ #  # ]
    1287                 :            : }
    1288                 :            : 
    1289                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10