LCOV - code coverage report
Current view: top level - sw/source/core/doc - doc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 657 1323 49.7 %
Date: 2012-08-25 Functions: 78 106 73.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 575 2162 26.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <doc.hxx>
      31                 :            : #include <UndoManager.hxx>
      32                 :            : #include <hintids.hxx>
      33                 :            : 
      34                 :            : #include <tools/shl.hxx>
      35                 :            : #include <tools/globname.hxx>
      36                 :            : #include <svx/svxids.hrc>
      37                 :            : #include <rtl/random.h>
      38                 :            : 
      39                 :            : #include <com/sun/star/i18n/WordType.hpp>
      40                 :            : #include <com/sun/star/i18n/ForbiddenCharacters.hpp>
      41                 :            : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      42                 :            : #include <com/sun/star/beans/NamedValue.hpp>
      43                 :            : #include <com/sun/star/beans/XPropertySet.hpp>
      44                 :            : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
      45                 :            : #include <com/sun/star/document/XDocumentProperties.hpp>
      46                 :            : #include <comphelper/processfactory.hxx>
      47                 :            : #include <comphelper/string.hxx>
      48                 :            : #include <tools/urlobj.hxx>
      49                 :            : #include <tools/poly.hxx>
      50                 :            : #include <tools/multisel.hxx>
      51                 :            : #include <rtl/ustring.hxx>
      52                 :            : #include <vcl/virdev.hxx>
      53                 :            : #include <svl/itemiter.hxx>
      54                 :            : #include <svl/poolitem.hxx>
      55                 :            : #include <unotools/syslocale.hxx>
      56                 :            : #include <sfx2/printer.hxx>
      57                 :            : #include <editeng/keepitem.hxx>
      58                 :            : #include <editeng/cscoitem.hxx>
      59                 :            : #include <editeng/brkitem.hxx>
      60                 :            : #include <sfx2/linkmgr.hxx>
      61                 :            : #include <editeng/forbiddencharacterstable.hxx>
      62                 :            : #include <svx/svdmodel.hxx>
      63                 :            : #include <editeng/pbinitem.hxx>
      64                 :            : #include <editeng/rsiditem.hxx>
      65                 :            : #include <unotools/charclass.hxx>
      66                 :            : #include <unotools/localedatawrapper.hxx>
      67                 :            : 
      68                 :            : #include <swatrset.hxx>
      69                 :            : #include <swmodule.hxx>
      70                 :            : #include <fmtpdsc.hxx>
      71                 :            : #include <fmtanchr.hxx>
      72                 :            : #include <fmtrfmrk.hxx>
      73                 :            : #include <fmtinfmt.hxx>
      74                 :            : #include <fmtfld.hxx>
      75                 :            : #include <txtfld.hxx>
      76                 :            : #include <dbfld.hxx>
      77                 :            : #include <txtinet.hxx>
      78                 :            : #include <txtrfmrk.hxx>
      79                 :            : #include <frmatr.hxx>
      80                 :            : #include <linkenum.hxx>
      81                 :            : #include <pagefrm.hxx>
      82                 :            : #include <rootfrm.hxx>
      83                 :            : #include <swtable.hxx>
      84                 :            : #include <pam.hxx>
      85                 :            : #include <ndtxt.hxx>
      86                 :            : #include <swundo.hxx>           // for the  UndoIds
      87                 :            : #include <UndoCore.hxx>
      88                 :            : #include <UndoInsert.hxx>
      89                 :            : #include <UndoSplitMove.hxx>
      90                 :            : #include <UndoTable.hxx>
      91                 :            : #include <pagedesc.hxx>         // DTor
      92                 :            : #include <breakit.hxx>
      93                 :            : #include <ndole.hxx>
      94                 :            : #include <ndgrf.hxx>
      95                 :            : #include <rolbck.hxx>           // Undo attr
      96                 :            : #include <doctxm.hxx>           // for the index stuff
      97                 :            : #include <grfatr.hxx>
      98                 :            : #include <poolfmt.hxx>          // pool template ids
      99                 :            : #include <mvsave.hxx>           // for server functionality
     100                 :            : #include <SwGrammarMarkUp.hxx>
     101                 :            : #include <scriptinfo.hxx>
     102                 :            : #include <acorrect.hxx>         // auto correction
     103                 :            : #include <mdiexp.hxx>           // status indicator
     104                 :            : #include <docstat.hxx>
     105                 :            : #include <docary.hxx>
     106                 :            : #include <redline.hxx>
     107                 :            : #include <fldupde.hxx>
     108                 :            : #include <swbaslnk.hxx>
     109                 :            : #include <printdata.hxx>
     110                 :            : #include <cmdid.h>              // for the dflt printer in SetJob
     111                 :            : #include <statstr.hrc>          // StatLine string
     112                 :            : #include <comcore.hrc>
     113                 :            : #include <SwUndoTOXChange.hxx>
     114                 :            : #include <SwUndoFmt.hxx>
     115                 :            : #include <unocrsr.hxx>
     116                 :            : #include <docsh.hxx>
     117                 :            : #include <viewopt.hxx>
     118                 :            : #include <docfld.hxx>           // _SetGetExpFld
     119                 :            : #include <docufld.hxx>          // SwPostItField
     120                 :            : #include <viewsh.hxx>
     121                 :            : #include <shellres.hxx>
     122                 :            : #include <txtfrm.hxx>
     123                 :            : #include <attrhint.hxx>
     124                 :            : 
     125                 :            : #include <wdocsh.hxx>           // SwWebDocShell
     126                 :            : #include <prtopt.hxx>           // SwPrintOptions
     127                 :            : 
     128                 :            : #include <vector>
     129                 :            : #include <map>
     130                 :            : 
     131                 :            : #include <osl/diagnose.h>
     132                 :            : #include <osl/interlck.h>
     133                 :            : #include <vbahelper/vbaaccesshelper.hxx>
     134                 :            : 
     135                 :            : #include "switerator.hxx"
     136                 :            : 
     137                 :            : /* @@@MAINTAINABILITY-HORROR@@@
     138                 :            :    Probably unwanted dependency on SwDocShell
     139                 :            : */
     140                 :            : #include <layouter.hxx>
     141                 :            : 
     142                 :            : using namespace ::com::sun::star;
     143                 :            : using ::rtl::OUString;
     144                 :            : 
     145                 :            : /* IInterface */
     146                 :       4782 : sal_Int32 SwDoc::acquire()
     147                 :            : {
     148                 :            :     OSL_ENSURE(mReferenceCount >= 0, "Negative reference count detected! This is a sign for unbalanced acquire/release calls.");
     149                 :       4782 :     return osl_incrementInterlockedCount(&mReferenceCount);
     150                 :            : }
     151                 :            : 
     152                 :       4576 : sal_Int32 SwDoc::release()
     153                 :            : {
     154                 :            :     OSL_PRECOND(mReferenceCount >= 1, "Object is already released! Releasing it again leads to a negative reference count.");
     155                 :       4576 :     return osl_decrementInterlockedCount(&mReferenceCount);
     156                 :            : }
     157                 :            : 
     158                 :         60 : sal_Int32 SwDoc::getReferenceCount() const
     159                 :            : {
     160                 :            :     OSL_ENSURE(mReferenceCount >= 0, "Negative reference count detected! This is a sign for unbalanced acquire/release calls.");
     161                 :         60 :     return mReferenceCount;
     162                 :            : }
     163                 :            : 
     164                 :            : /* IDocumentSettingAccess */
     165                 :    2539693 : bool SwDoc::get(/*[in]*/ DocumentSettingId id) const
     166                 :            : {
     167   [ +  +  +  +  :    2539693 :     switch (id)
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
                +  +  - ]
     168                 :            :     {
     169                 :            :         // COMPATIBILITY FLAGS START
     170                 :       4279 :         case PARA_SPACE_MAX: return mbParaSpaceMax; //(n8Dummy1 & DUMMY_PARASPACEMAX);
     171                 :      14018 :         case PARA_SPACE_MAX_AT_PAGES: return mbParaSpaceMaxAtPages; //(n8Dummy1 & DUMMY_PARASPACEMAX_AT_PAGES);
     172                 :      68911 :         case TAB_COMPAT: return mbTabCompat; //(n8Dummy1 & DUMMY_TAB_COMPAT);
     173                 :      19865 :         case ADD_FLY_OFFSETS: return mbAddFlyOffsets; //(n8Dummy2 & DUMMY_ADD_FLY_OFFSETS);
     174                 :     606669 :         case ADD_EXT_LEADING: return mbAddExternalLeading; //(n8Dummy2 & DUMMY_ADD_EXTERNAL_LEADING);
     175                 :    1019508 :         case USE_VIRTUAL_DEVICE: return mbUseVirtualDevice; //(n8Dummy1 & DUMMY_USE_VIRTUAL_DEVICE);
     176                 :         77 :         case USE_HIRES_VIRTUAL_DEVICE: return mbUseHiResolutionVirtualDevice; //(n8Dummy2 & DUMMY_USE_HIRES_VIR_DEV);
     177                 :       1614 :         case OLD_NUMBERING: return mbOldNumbering;
     178                 :      60661 :         case OLD_LINE_SPACING: return mbOldLineSpacing;
     179                 :       7346 :         case ADD_PARA_SPACING_TO_TABLE_CELLS: return mbAddParaSpacingToTableCells;
     180                 :       1840 :         case USE_FORMER_OBJECT_POS: return mbUseFormerObjectPos;
     181                 :       5537 :         case USE_FORMER_TEXT_WRAPPING: return mbUseFormerTextWrapping;
     182                 :      23601 :         case CONSIDER_WRAP_ON_OBJECT_POSITION: return mbConsiderWrapOnObjPos;
     183                 :         48 :         case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK: return mbDoNotJustifyLinesWithManualBreak;
     184                 :     165998 :         case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING: return mbIgnoreFirstLineIndentInNumbering;
     185                 :         19 :         case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE: return mbOutlineLevelYieldsOutlineRule;
     186                 :       1064 :         case TABLE_ROW_KEEP: return mbTableRowKeep;
     187                 :      55354 :         case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION: return mbIgnoreTabsAndBlanksForLineCalculation;
     188                 :       2364 :         case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE: return mbDoNotCaptureDrawObjsOnPage;
     189                 :            :         // #i68949#
     190                 :       1744 :         case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME: return mbClipAsCharacterAnchoredWriterFlyFrames;
     191                 :       1564 :         case UNIX_FORCE_ZERO_EXT_LEADING: return mbUnixForceZeroExtLeading;
     192                 :         26 :         case USE_OLD_PRINTER_METRICS: return mbOldPrinterMetrics;
     193                 :      98718 :         case TABS_RELATIVE_TO_INDENT : return mbTabRelativeToIndent;
     194                 :      49174 :         case PROTECT_FORM: return mbProtectForm;
     195                 :            :         // #i89181#
     196                 :         25 :         case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST: return mbTabAtLeftIndentForParagraphsInList;
     197                 :      76005 :         case INVERT_BORDER_SPACING: return mbInvertBorderSpacing;
     198                 :      24360 :         case COLLAPSE_EMPTY_CELL_PARA: return mbCollapseEmptyCellPara;
     199                 :       6960 :         case SMALL_CAPS_PERCENTAGE_66: return mbSmallCapsPercentage66;
     200                 :        226 :         case TAB_OVERFLOW: return mbTabOverflow;
     201                 :      52300 :         case UNBREAKABLE_NUMBERINGS: return mbUnbreakableNumberings;
     202                 :            : 
     203                 :       6679 :         case BROWSE_MODE: return mbLastBrowseMode; // Attention: normally the ViewShell has to be asked!
     204                 :      92505 :         case HTML_MODE: return mbHTMLMode;
     205                 :       1436 :         case GLOBAL_DOCUMENT: return mbIsGlobalDoc;
     206                 :         23 :         case GLOBAL_DOCUMENT_SAVE_LINKS: return mbGlblDocSaveLinks;
     207                 :       3696 :         case LABEL_DOCUMENT: return mbIsLabelDoc;
     208                 :      10536 :         case PURGE_OLE: return mbPurgeOLE;
     209                 :       5870 :         case KERN_ASIAN_PUNCTUATION: return mbKernAsianPunctuation;
     210                 :        253 :         case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT: return mbDoNotResetParaAttrsForNumFont;
     211                 :         19 :         case MATH_BASELINE_ALIGNMENT: return mbMathBaselineAlignment;
     212                 :      10257 :         case STYLES_NODEFAULT: return mbStylesNoDefault;
     213                 :      38544 :         case FLOATTABLE_NOMARGINS: return mbFloattableNomargins;
     214                 :            :         default:
     215                 :            :             OSL_FAIL("Invalid setting id");
     216                 :            :     }
     217                 :    2539693 :     return false;
     218                 :            : }
     219                 :            : 
     220                 :      34720 : void SwDoc::set(/*[in]*/ DocumentSettingId id, /*[in]*/ bool value)
     221                 :            : {
     222   [ +  +  +  +  :      34720 :     switch (id)
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  +  +  
          +  +  +  -  +  
          +  +  +  +  +  
                +  +  - ]
     223                 :            :     {
     224                 :            :         // COMPATIBILITY FLAGS START
     225                 :            :         case PARA_SPACE_MAX:
     226                 :        640 :             mbParaSpaceMax = value;
     227                 :        640 :             break;
     228                 :            :         case PARA_SPACE_MAX_AT_PAGES:
     229                 :        167 :             mbParaSpaceMaxAtPages = value;
     230                 :        167 :             break;
     231                 :            :         case TAB_COMPAT:
     232                 :        167 :             mbTabCompat = value;
     233                 :        167 :             break;
     234                 :            :         case ADD_FLY_OFFSETS:
     235                 :        165 :             mbAddFlyOffsets = value;
     236                 :        165 :             break;
     237                 :            :         case ADD_EXT_LEADING:
     238                 :        165 :             mbAddExternalLeading = value;
     239                 :        165 :             break;
     240                 :            :         case USE_VIRTUAL_DEVICE:
     241                 :        107 :             mbUseVirtualDevice = value;
     242                 :        107 :             break;
     243                 :            :         case USE_HIRES_VIRTUAL_DEVICE:
     244                 :        107 :             mbUseHiResolutionVirtualDevice = value;
     245                 :        107 :             break;
     246                 :            :         case OLD_NUMBERING:
     247         [ +  + ]:        165 :             if (mbOldNumbering != value)
     248                 :            :             {
     249                 :          2 :                 mbOldNumbering = value;
     250                 :            : 
     251                 :          2 :                 const SwNumRuleTbl& rNmTbl = GetNumRuleTbl();
     252         [ +  + ]:          4 :                 for( sal_uInt16 n = 0; n < rNmTbl.size(); ++n )
     253                 :          2 :                     rNmTbl[n]->SetInvalidRule(sal_True);
     254                 :            : 
     255                 :          2 :                 UpdateNumRule();
     256                 :            : 
     257         [ +  - ]:          2 :                 if (pOutlineRule)
     258                 :            :                 {
     259                 :          2 :                     pOutlineRule->Validate();
     260                 :            :                     // counting of phantoms depends on <IsOldNumbering()>
     261                 :          2 :                     pOutlineRule->SetCountPhantoms( !mbOldNumbering );
     262                 :            :                 }
     263                 :            :             }
     264                 :        165 :             break;
     265                 :            :         case OLD_LINE_SPACING:
     266                 :        167 :             mbOldLineSpacing = value;
     267                 :        167 :             break;
     268                 :            :         case ADD_PARA_SPACING_TO_TABLE_CELLS:
     269                 :        167 :             mbAddParaSpacingToTableCells = value;
     270                 :        167 :             break;
     271                 :            :         case USE_FORMER_OBJECT_POS:
     272                 :        167 :             mbUseFormerObjectPos = value;
     273                 :        167 :             break;
     274                 :            :         case USE_FORMER_TEXT_WRAPPING:
     275                 :        165 :             mbUseFormerTextWrapping = value;
     276                 :        165 :             break;
     277                 :            :         case CONSIDER_WRAP_ON_OBJECT_POSITION:
     278                 :        165 :             mbConsiderWrapOnObjPos = value;
     279                 :        165 :             break;
     280                 :            :         case DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK:
     281                 :        165 :             mbDoNotJustifyLinesWithManualBreak = value;
     282                 :        165 :             break;
     283                 :            :         case IGNORE_FIRST_LINE_INDENT_IN_NUMBERING:
     284                 :        165 :             mbIgnoreFirstLineIndentInNumbering = value;
     285                 :        165 :             break;
     286                 :            : 
     287                 :            :         case OUTLINE_LEVEL_YIELDS_OUTLINE_RULE:
     288                 :        126 :             mbOutlineLevelYieldsOutlineRule = value;
     289                 :        126 :             break;
     290                 :            : 
     291                 :            :         case TABLE_ROW_KEEP:
     292                 :        165 :             mbTableRowKeep = value;
     293                 :        165 :             break;
     294                 :            : 
     295                 :            :         case IGNORE_TABS_AND_BLANKS_FOR_LINE_CALCULATION:
     296                 :        165 :             mbIgnoreTabsAndBlanksForLineCalculation = value;
     297                 :        165 :             break;
     298                 :            : 
     299                 :            :         case DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE:
     300                 :         63 :             mbDoNotCaptureDrawObjsOnPage = value;
     301                 :         63 :             break;
     302                 :            : 
     303                 :            :         // #i68949#
     304                 :            :         case CLIP_AS_CHARACTER_ANCHORED_WRITER_FLY_FRAME:
     305                 :         63 :             mbClipAsCharacterAnchoredWriterFlyFrames = value;
     306                 :         63 :             break;
     307                 :            : 
     308                 :            :         case UNIX_FORCE_ZERO_EXT_LEADING:
     309                 :         63 :             mbUnixForceZeroExtLeading = value;
     310                 :         63 :             break;
     311                 :            : 
     312                 :            :         case PROTECT_FORM:
     313                 :        161 :             mbProtectForm = value;
     314                 :        161 :             break;
     315                 :            : 
     316                 :            :         case USE_OLD_PRINTER_METRICS:
     317                 :         63 :             mbOldPrinterMetrics = value;
     318                 :         63 :             break;
     319                 :            :         case TABS_RELATIVE_TO_INDENT:
     320                 :        636 :             mbTabRelativeToIndent = value;
     321                 :        636 :             break;
     322                 :            :         // #i89181#
     323                 :            :         case TAB_AT_LEFT_INDENT_FOR_PARA_IN_LIST:
     324                 :         61 :             mbTabAtLeftIndentForParagraphsInList = value;
     325                 :         61 :             break;
     326                 :            : 
     327                 :            :         case INVERT_BORDER_SPACING:
     328                 :        150 :             mbInvertBorderSpacing = value;
     329                 :        150 :             break;
     330                 :            : 
     331                 :            :         case COLLAPSE_EMPTY_CELL_PARA:
     332                 :        150 :             mbCollapseEmptyCellPara = value;
     333                 :        150 :             break;
     334                 :            : 
     335                 :            :         case SMALL_CAPS_PERCENTAGE_66:
     336                 :         63 :             mbSmallCapsPercentage66 = value;
     337                 :         63 :             break;
     338                 :            : 
     339                 :            :         case TAB_OVERFLOW:
     340                 :        165 :             mbTabOverflow = value;
     341                 :        165 :             break;
     342                 :            : 
     343                 :            :         case UNBREAKABLE_NUMBERINGS:
     344                 :        356 :             mbUnbreakableNumberings = value;
     345                 :        356 :             break;
     346                 :            :          // COMPATIBILITY FLAGS END
     347                 :            : 
     348                 :            :         case BROWSE_MODE: //can be used temporary (load/save) when no ViewShell is avaiable
     349                 :       1317 :             mbLastBrowseMode = value;
     350                 :       1317 :             break;
     351                 :            : 
     352                 :            :         case HTML_MODE:
     353                 :       3215 :             mbHTMLMode = value;
     354                 :       3215 :             break;
     355                 :            : 
     356                 :            :         case GLOBAL_DOCUMENT:
     357                 :          0 :             mbIsGlobalDoc = value;
     358                 :          0 :             break;
     359                 :            : 
     360                 :            :         case GLOBAL_DOCUMENT_SAVE_LINKS:
     361                 :         65 :             mbGlblDocSaveLinks = value;
     362                 :         65 :             break;
     363                 :            : 
     364                 :            :         case LABEL_DOCUMENT:
     365                 :         65 :             mbIsLabelDoc = value;
     366                 :         65 :             break;
     367                 :            : 
     368                 :            :         case PURGE_OLE:
     369                 :      21000 :             mbPurgeOLE = value;
     370                 :      21000 :             break;
     371                 :            : 
     372                 :            :         case KERN_ASIAN_PUNCTUATION:
     373                 :       1649 :             mbKernAsianPunctuation = value;
     374                 :       1649 :             break;
     375                 :            : 
     376                 :            :         case DO_NOT_RESET_PARA_ATTRS_FOR_NUM_FONT:
     377                 :        165 :             mbDoNotResetParaAttrsForNumFont = value;
     378                 :        165 :             break;
     379                 :            :         case MATH_BASELINE_ALIGNMENT:
     380                 :       1530 :             mbMathBaselineAlignment  = value;
     381                 :       1530 :             break;
     382                 :            :         case STYLES_NODEFAULT:
     383                 :        210 :             mbStylesNoDefault  = value;
     384                 :        210 :             break;
     385                 :            :         case FLOATTABLE_NOMARGINS:
     386                 :        210 :             mbFloattableNomargins = value;
     387                 :        210 :             break;
     388                 :            :         default:
     389                 :            :             OSL_FAIL("Invalid setting id");
     390                 :            :     }
     391                 :      34720 : }
     392                 :            : 
     393                 :            : const i18n::ForbiddenCharacters*
     394                 :      39647 :     SwDoc::getForbiddenCharacters(/*[in]*/ sal_uInt16 nLang, /*[in]*/ bool bLocaleData ) const
     395                 :            : {
     396                 :      39647 :     const i18n::ForbiddenCharacters* pRet = 0;
     397         [ +  - ]:      39647 :     if( xForbiddenCharsTable.is() )
     398                 :      39647 :         pRet = xForbiddenCharsTable->GetForbiddenCharacters( nLang, sal_False );
     399 [ +  + ][ +  - ]:      39647 :     if( bLocaleData && !pRet && pBreakIt )
                 [ +  - ]
     400                 :      39611 :         pRet = &pBreakIt->GetForbidden( (LanguageType)nLang );
     401                 :      39647 :     return pRet;
     402                 :            : }
     403                 :            : 
     404                 :         87 : void SwDoc::setForbiddenCharacters(/*[in]*/ sal_uInt16 nLang,
     405                 :            :                                    /*[in]*/ const com::sun::star::i18n::ForbiddenCharacters& rFChars )
     406                 :            : {
     407         [ +  - ]:         87 :     if( !xForbiddenCharsTable.is() )
     408                 :            :     {
     409                 :            :         uno::Reference<
     410                 :            :             lang::XMultiServiceFactory > xMSF =
     411         [ +  - ]:         87 :                                     ::comphelper::getProcessServiceFactory();
     412 [ +  - ][ +  - ]:         87 :         xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF );
                 [ +  - ]
     413                 :            :     }
     414                 :         87 :     xForbiddenCharsTable->SetForbiddenCharacters( nLang, rFChars );
     415         [ -  + ]:         87 :     if( pDrawModel )
     416                 :            :     {
     417         [ #  # ]:          0 :         pDrawModel->SetForbiddenCharsTable( xForbiddenCharsTable );
     418         [ #  # ]:          0 :         if( !mbInReading )
     419                 :          0 :             pDrawModel->ReformatAllTextObjects();
     420                 :            :     }
     421                 :            : 
     422                 :         87 :     SwRootFrm* pTmpRoot = GetCurrentLayout();
     423 [ #  # ][ -  + ]:         87 :     if( pTmpRoot && !mbInReading )
     424                 :            :     {
     425         [ #  # ]:          0 :         pTmpRoot->StartAllAction();
     426         [ #  # ]:          0 :         std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     427 [ #  # ][ #  # ]:          0 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
                 [ #  # ]
     428         [ #  # ]:          0 :         pTmpRoot->EndAllAction();
     429                 :            :     }//swmod 080310
     430                 :         87 :     SetModified();
     431                 :         87 : }
     432                 :            : 
     433                 :       1466 : rtl::Reference<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable()
     434                 :            : {
     435         [ +  + ]:       1466 :     if( !xForbiddenCharsTable.is() )
     436                 :            :     {
     437                 :            :         uno::Reference<
     438                 :            :             lang::XMultiServiceFactory > xMSF =
     439         [ +  - ]:       1299 :                                     ::comphelper::getProcessServiceFactory();
     440 [ +  - ][ +  - ]:       1299 :         xForbiddenCharsTable = new SvxForbiddenCharactersTable( xMSF );
                 [ +  - ]
     441                 :            :     }
     442                 :       1466 :     return xForbiddenCharsTable;
     443                 :            : }
     444                 :            : 
     445                 :          0 : const rtl::Reference<SvxForbiddenCharactersTable>& SwDoc::getForbiddenCharacterTable() const
     446                 :            : {
     447                 :          0 :     return xForbiddenCharsTable;
     448                 :            : }
     449                 :            : 
     450                 :        682 : sal_uInt16 SwDoc::getLinkUpdateMode( /*[in]*/bool bGlobalSettings ) const
     451                 :            : {
     452                 :        682 :     sal_uInt16 nRet = nLinkUpdMode;
     453 [ +  - ][ +  + ]:        682 :     if( bGlobalSettings && GLOBALSETTING == nRet )
     454                 :        610 :         nRet = SW_MOD()->GetLinkUpdMode(get(IDocumentSettingAccess::HTML_MODE));
     455                 :        682 :     return nRet;
     456                 :            : }
     457                 :            : 
     458                 :       1547 : void SwDoc::setLinkUpdateMode( /*[in]*/sal_uInt16 eMode )
     459                 :            : {
     460                 :       1547 :     nLinkUpdMode = eMode;
     461                 :       1547 : }
     462                 :            : 
     463                 :         38 : sal_uInt32 SwDoc::getRsid() const
     464                 :            : {
     465                 :         38 :     return nRsid;
     466                 :            : }
     467                 :            : 
     468                 :         56 : void SwDoc::setRsid( sal_uInt32 nVal )
     469                 :            : {
     470                 :            :     // Increase the rsid with a random number smaller than 2^17. This way we
     471                 :            :     // expect to be able to edit a document 2^12 times before rsid overflows.
     472                 :         56 :     sal_uInt32 nIncrease = 0;
     473 [ +  + ][ +  - ]:         56 :     static rtlRandomPool aPool = rtl_random_createPool();
     474                 :         56 :     rtl_random_getBytes( aPool, &nIncrease, sizeof ( nIncrease ) );
     475                 :         56 :     nIncrease &= ( 1<<17 ) - 1;
     476                 :         56 :     nIncrease++; // make sure the new rsid is not the same
     477                 :         56 :     nRsid = nVal + nIncrease;
     478                 :         56 : }
     479                 :            : 
     480                 :         19 : sal_uInt32 SwDoc::getRsidRoot() const
     481                 :            : {
     482                 :         19 :     return nRsidRoot;
     483                 :            : }
     484                 :            : 
     485                 :         37 : void SwDoc::setRsidRoot( sal_uInt32 nVal )
     486                 :            : {
     487                 :         37 :     nRsidRoot = nVal;
     488                 :         37 : }
     489                 :            : 
     490                 :       4377 : SwFldUpdateFlags SwDoc::getFieldUpdateFlags( /*[in]*/bool bGlobalSettings ) const
     491                 :            : {
     492                 :       4377 :     SwFldUpdateFlags eRet = eFldUpdMode;
     493 [ +  - ][ +  + ]:       4377 :     if( bGlobalSettings && AUTOUPD_GLOBALSETTING == eRet )
     494                 :       3996 :         eRet = SW_MOD()->GetFldUpdateFlags(get(IDocumentSettingAccess::HTML_MODE));
     495                 :       4377 :     return eRet;
     496                 :            : }
     497                 :            : 
     498                 :       1612 : void SwDoc::setFieldUpdateFlags(/*[in]*/SwFldUpdateFlags eMode )
     499                 :            : {
     500                 :       1612 :     eFldUpdMode = eMode;
     501                 :       1612 : }
     502                 :            : 
     503                 :      15016 : SwCharCompressType SwDoc::getCharacterCompressionType() const
     504                 :            : {
     505                 :      15016 :     return eChrCmprType;
     506                 :            : }
     507                 :            : 
     508                 :       1649 : void SwDoc::setCharacterCompressionType( /*[in]*/SwCharCompressType n )
     509                 :            : {
     510         [ +  + ]:       1649 :     if( eChrCmprType != n )
     511                 :            :     {
     512                 :          3 :         eChrCmprType = n;
     513         [ -  + ]:          3 :         if( pDrawModel )
     514                 :            :         {
     515                 :          0 :             pDrawModel->SetCharCompressType( static_cast<sal_uInt16>(n) );
     516         [ #  # ]:          0 :             if( !mbInReading )
     517                 :          0 :                 pDrawModel->ReformatAllTextObjects();
     518                 :            :         }
     519                 :            : 
     520                 :          3 :         SwRootFrm* pTmpRoot = GetCurrentLayout();
     521 [ #  # ][ -  + ]:          3 :         if( pTmpRoot && !mbInReading )
     522                 :            :         {
     523         [ #  # ]:          0 :             pTmpRoot->StartAllAction();
     524         [ #  # ]:          0 :             std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     525 [ #  # ][ #  # ]:          0 :             std::for_each( aAllLayouts.begin(), aAllLayouts.end(), std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
                 [ #  # ]
     526         [ #  # ]:          0 :             pTmpRoot->EndAllAction();
     527                 :            :         }//swmod 080310
     528                 :          3 :         SetModified();
     529                 :            :     }
     530                 :       1649 : }
     531                 :            : 
     532                 :            : /* IDocumentDeviceAccess */
     533                 :      16338 : SfxPrinter* SwDoc::getPrinter(/*[in]*/ bool bCreate ) const
     534                 :            : {
     535                 :      16338 :     SfxPrinter* pRet = 0;
     536 [ +  + ][ +  + ]:      16338 :     if ( !bCreate || pPrt )
     537                 :      16324 :         pRet = pPrt;
     538                 :            :     else
     539                 :         14 :         pRet = &CreatePrinter_();
     540                 :            : 
     541                 :      16338 :     return pRet;
     542                 :            : }
     543                 :            : 
     544                 :         25 : void SwDoc::setPrinter(/*[in]*/ SfxPrinter *pP,/*[in]*/ bool bDeleteOld,/*[in]*/ bool bCallPrtDataChanged )
     545                 :            : {
     546         [ +  + ]:         25 :     if ( pP != pPrt )
     547                 :            :     {
     548         [ +  - ]:         23 :         if ( bDeleteOld )
     549         [ +  + ]:         23 :             delete pPrt;
     550                 :         23 :         pPrt = pP;
     551                 :            : 
     552                 :            :         // our printer should always use TWIP. Don't rely on this being set in ViewShell::InitPrt, there
     553                 :            :         // are situations where this isn't called.
     554                 :            :         // #i108712# / 2010-02-26 / frank.schoenheit@sun.com
     555         [ +  - ]:         23 :         if ( pPrt )
     556                 :            :         {
     557         [ +  - ]:         23 :             MapMode aMapMode( pPrt->GetMapMode() );
     558         [ +  - ]:         23 :             aMapMode.SetMapUnit( MAP_TWIP );
     559 [ +  - ][ +  - ]:         23 :             pPrt->SetMapMode( aMapMode );
     560                 :            :         }
     561                 :            : 
     562 [ +  + ][ +  + ]:         23 :         if ( pDrawModel && !get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
                 [ +  + ]
     563                 :          9 :             pDrawModel->SetRefDevice( pPrt );
     564                 :            :     }
     565                 :            : 
     566   [ +  -  +  + ]:         50 :     if ( bCallPrtDataChanged &&
                 [ +  + ]
     567                 :            :          // #i41075# Do not call PrtDataChanged() if we do not
     568                 :            :          // use the printer for formatting:
     569                 :         25 :          !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
     570                 :         12 :         PrtDataChanged();
     571                 :         25 : }
     572                 :            : 
     573                 :    1019173 : VirtualDevice* SwDoc::getVirtualDevice(/*[in]*/ bool bCreate ) const
     574                 :            : {
     575                 :    1019173 :     VirtualDevice* pRet = 0;
     576 [ +  + ][ +  + ]:    1019173 :     if ( !bCreate || pVirDev )
     577                 :    1017628 :         pRet = pVirDev;
     578                 :            :     else
     579                 :       1545 :         pRet = &CreateVirtualDevice_();
     580                 :            : 
     581                 :    1019173 :     return pRet;
     582                 :            : }
     583                 :            : 
     584                 :       1545 : void SwDoc::setVirtualDevice(/*[in]*/ VirtualDevice* pVd,/*[in]*/ bool bDeleteOld, /*[in]*/ bool )
     585                 :            : {
     586         [ +  - ]:       1545 :     if ( pVirDev != pVd )
     587                 :            :     {
     588         [ +  - ]:       1545 :         if ( bDeleteOld )
     589         [ -  + ]:       1545 :             delete pVirDev;
     590                 :       1545 :         pVirDev = pVd;
     591                 :            : 
     592 [ +  + ][ +  - ]:       1545 :         if ( pDrawModel && get( IDocumentSettingAccess::USE_VIRTUAL_DEVICE ) )
                 [ +  + ]
     593                 :         58 :             pDrawModel->SetRefDevice( pVirDev );
     594                 :            :     }
     595                 :       1545 : }
     596                 :            : 
     597                 :    1019318 : OutputDevice* SwDoc::getReferenceDevice(/*[in]*/ bool bCreate ) const
     598                 :            : {
     599                 :    1019318 :     OutputDevice* pRet = 0;
     600         [ +  + ]:    1019318 :     if ( !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
     601                 :            :     {
     602                 :        379 :         pRet = getPrinter( bCreate );
     603                 :            : 
     604 [ +  + ][ +  + ]:        379 :         if ( bCreate && !pPrt->IsValid() )
                 [ +  + ]
     605                 :            :         {
     606                 :        234 :             pRet = getVirtualDevice( sal_True );
     607                 :            :         }
     608                 :            :     }
     609                 :            :     else
     610                 :            :     {
     611                 :    1018939 :         pRet = getVirtualDevice( bCreate );
     612                 :            :     }
     613                 :            : 
     614                 :    1019318 :     return pRet;
     615                 :            : }
     616                 :            : 
     617                 :         63 : void SwDoc::setReferenceDeviceType(/*[in]*/ bool bNewVirtual,/*[in]*/ bool bNewHiRes )
     618                 :            : {
     619   [ +  +  -  + ]:        121 :     if ( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) != bNewVirtual ||
                 [ +  + ]
     620                 :         58 :          get(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE) != bNewHiRes )
     621                 :            :     {
     622         [ -  + ]:          5 :         if ( bNewVirtual )
     623                 :            :         {
     624                 :          0 :             VirtualDevice* pMyVirDev = getVirtualDevice( true );
     625         [ #  # ]:          0 :             if ( !bNewHiRes )
     626                 :          0 :                 pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE06 );
     627                 :            :             else
     628                 :          0 :                 pMyVirDev->SetReferenceDevice( VirtualDevice::REFDEV_MODE_MSO1 );
     629                 :            : 
     630         [ #  # ]:          0 :             if( pDrawModel )
     631                 :          0 :                 pDrawModel->SetRefDevice( pMyVirDev );
     632                 :            :         }
     633                 :            :         else
     634                 :            :         {
     635                 :            :             // #i41075#
     636                 :            :             // We have to take care that a printer exists before calling
     637                 :            :             // PrtDataChanged() in order to prevent that PrtDataChanged()
     638                 :            :             // triggers this funny situation:
     639                 :            :             // getReferenceDevice()->getPrinter()->CreatePrinter_()
     640                 :            :             // ->setPrinter()-> PrtDataChanged()
     641                 :          5 :             SfxPrinter* pPrinter = getPrinter( true );
     642         [ -  + ]:          5 :             if( pDrawModel )
     643                 :          0 :                 pDrawModel->SetRefDevice( pPrinter );
     644                 :            :         }
     645                 :            : 
     646                 :          5 :         set(IDocumentSettingAccess::USE_VIRTUAL_DEVICE, bNewVirtual );
     647                 :          5 :         set(IDocumentSettingAccess::USE_HIRES_VIRTUAL_DEVICE, bNewHiRes );
     648                 :          5 :         PrtDataChanged();
     649                 :          5 :         SetModified();
     650                 :            :     }
     651                 :         63 : }
     652                 :            : 
     653                 :        203 : const JobSetup* SwDoc::getJobsetup() const
     654                 :            : {
     655         [ -  + ]:        203 :     return pPrt ? &pPrt->GetJobSetup() : 0;
     656                 :            : }
     657                 :            : 
     658                 :          0 : void SwDoc::setJobsetup(/*[in]*/ const JobSetup &rJobSetup )
     659                 :            : {
     660                 :          0 :     sal_Bool bCheckPageDescs = 0 == pPrt;
     661                 :          0 :     sal_Bool bDataChanged = sal_False;
     662                 :            : 
     663         [ #  # ]:          0 :     if ( pPrt )
     664                 :            :     {
     665         [ #  # ]:          0 :         if ( pPrt->GetName() == rJobSetup.GetPrinterName() )
     666                 :            :         {
     667         [ #  # ]:          0 :             if ( pPrt->GetJobSetup() != rJobSetup )
     668                 :            :             {
     669                 :          0 :                 pPrt->SetJobSetup( rJobSetup );
     670                 :          0 :                 bDataChanged = sal_True;
     671                 :            :             }
     672                 :            :         }
     673                 :            :         else
     674         [ #  # ]:          0 :             delete pPrt, pPrt = 0;
     675                 :            :     }
     676                 :            : 
     677         [ #  # ]:          0 :     if( !pPrt )
     678                 :            :     {
     679                 :            :         //The ItemSet is deleted by Sfx!
     680                 :          0 :         SfxItemSet *pSet = new SfxItemSet( GetAttrPool(),
     681                 :            :                         FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
     682                 :            :                         SID_HTML_MODE,  SID_HTML_MODE,
     683                 :            :                         SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
     684                 :            :                         SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
     685         [ #  # ]:          0 :                         0 );
     686         [ #  # ]:          0 :         SfxPrinter *p = new SfxPrinter( pSet, rJobSetup );
     687         [ #  # ]:          0 :         if ( bCheckPageDescs )
     688                 :          0 :             setPrinter( p, true, true );
     689                 :            :         else
     690                 :            :         {
     691                 :          0 :             pPrt = p;
     692                 :          0 :             bDataChanged = sal_True;
     693                 :            :         }
     694                 :            :     }
     695 [ #  # ][ #  # ]:          0 :     if ( bDataChanged && !get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) )
                 [ #  # ]
     696                 :          0 :         PrtDataChanged();
     697                 :          0 : }
     698                 :            : 
     699                 :       1537 : const SwPrintData & SwDoc::getPrintData() const
     700                 :            : {
     701         [ +  + ]:       1537 :     if(!pPrtData)
     702                 :            :     {
     703                 :         63 :         SwDoc * pThis = const_cast< SwDoc * >(this);
     704         [ +  - ]:         63 :         pThis->pPrtData = new SwPrintData;
     705                 :            : 
     706                 :            :         // SwPrintData should be initialized from the configuration,
     707                 :            :         // the respective config item is implememted by SwPrintOptions which
     708                 :            :         // is also derived from SwPrintData
     709                 :         63 :         const SwDocShell *pDocSh = GetDocShell();
     710                 :            :         OSL_ENSURE( pDocSh, "pDocSh is 0, can't determine if this is a WebDoc or not" );
     711 [ -  + ][ +  - ]:         63 :         bool bWeb = 0 != dynamic_cast< const SwWebDocShell * >(pDocSh);
     712         [ +  - ]:         63 :         SwPrintOptions aPrintOptions( bWeb );
     713         [ +  - ]:         63 :         *pThis->pPrtData = aPrintOptions;
     714                 :            :     }
     715                 :       1537 :     return *pPrtData;
     716                 :            : }
     717                 :            : 
     718                 :       1484 : void SwDoc::setPrintData(/*[in]*/ const SwPrintData& rPrtData )
     719                 :            : {
     720         [ +  - ]:       1484 :     if(!pPrtData)
     721                 :       1484 :         pPrtData = new SwPrintData;
     722                 :       1484 :     *pPrtData = rPrtData;
     723                 :       1484 : }
     724                 :            : 
     725                 :            : /* Implementations the next Interface here */
     726                 :            : 
     727                 :            : /*
     728                 :            :  * Document editing (Doc-SS) to fill the document
     729                 :            :  * by the RTF parser and for the EditShell.
     730                 :            :  */
     731                 :        189 : void SwDoc::ChgDBData(const SwDBData& rNewData)
     732                 :            : {
     733         [ +  + ]:        189 :     if( rNewData != aDBData )
     734                 :            :     {
     735                 :         13 :         aDBData = rNewData;
     736                 :         13 :         SetModified();
     737                 :            :     }
     738                 :        189 :     GetSysFldType(RES_DBNAMEFLD)->UpdateFlds();
     739                 :        189 : }
     740                 :            : 
     741                 :       1268 : bool SwDoc::SplitNode( const SwPosition &rPos, bool bChkTableStart )
     742                 :            : {
     743                 :       1268 :     SwCntntNode *pNode = rPos.nNode.GetNode().GetCntntNode();
     744         [ -  + ]:       1268 :     if(0 == pNode)
     745                 :          0 :         return false;
     746                 :            : 
     747                 :            :     {
     748                 :            :         // BUG 26675: Send DataChanged before deleting, so that we notice which objects are in scope.
     749                 :            :         //            After that they can be before/after the position.
     750 [ +  - ][ +  - ]:       1268 :         SwDataChanged aTmp( this, rPos, 0 );
     751                 :            :     }
     752                 :            : 
     753                 :       1268 :     SwUndoSplitNode* pUndo = 0;
     754 [ +  - ][ +  - ]:       1268 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  + ]
     755                 :            :     {
     756 [ +  - ][ +  - ]:        440 :         GetIDocumentUndoRedo().ClearRedo();
     757                 :            :         // insert the Undo object (currently only for TextNode)
     758         [ +  - ]:        440 :         if( pNode->IsTxtNode() )
     759                 :            :         {
     760 [ +  - ][ +  - ]:        440 :             pUndo = new SwUndoSplitNode( this, rPos, bChkTableStart );
     761 [ +  - ][ +  - ]:        440 :             GetIDocumentUndoRedo().AppendUndo(pUndo);
     762                 :            :         }
     763                 :            :     }
     764                 :            : 
     765                 :            :     // Update the rsid of the old and the new node unless
     766                 :            :     // the old node is split at the beginning or at the end
     767                 :       1268 :     SwTxtNode *pTxtNode =  rPos.nNode.GetNode().GetTxtNode();
     768                 :       1268 :     xub_StrLen nPos = rPos.nContent.GetIndex();
     769 [ +  + ][ +  - ]:       1268 :     if( pTxtNode && nPos && nPos != pTxtNode->Len() )
         [ +  + ][ +  + ]
                 [ +  - ]
     770                 :            :     {
     771         [ +  - ]:         80 :         UpdateParRsid( pTxtNode );
     772                 :            :     }
     773                 :            : 
     774                 :            :     //JP 28.01.97: Special case for SplitNode at table start:
     775                 :            :     //             If it is at the beginning of a Doc/Fly/Footer/... or right at after a table
     776                 :            :     //             then insert a paragraph before it.
     777 [ -  + ][ #  # ]:       1268 :     if( bChkTableStart && !rPos.nContent.GetIndex() && pNode->IsTxtNode() )
         [ #  # ][ -  + ]
     778                 :            :     {
     779                 :          0 :         sal_uLong nPrevPos = rPos.nNode.GetIndex() - 1;
     780                 :            :         const SwTableNode* pTblNd;
     781 [ #  # ][ #  # ]:          0 :         const SwNode* pNd = GetNodes()[ nPrevPos ];
     782   [ #  #  #  # ]:          0 :         if( pNd->IsStartNode() &&
         [ #  # ][ #  #  
          #  #  #  #  #  
             #  #  #  #  
              # ][ #  # ]
     783                 :          0 :             SwTableBoxStartNode == ((SwStartNode*)pNd)->GetStartNodeType() &&
     784 [ #  # ][ #  # ]:          0 :             0 != ( pTblNd = GetNodes()[ --nPrevPos ]->GetTableNode() ) &&
     785         [ #  # ]:          0 :             ((( pNd = GetNodes()[ --nPrevPos ])->IsStartNode() &&
     786                 :          0 :                SwTableBoxStartNode != ((SwStartNode*)pNd)->GetStartNodeType() )
     787                 :          0 :                || ( pNd->IsEndNode() && pNd->StartOfSectionNode()->IsTableNode() )
     788                 :          0 :                || pNd->IsCntntNode() ))
     789                 :            :         {
     790         [ #  # ]:          0 :             if( pNd->IsCntntNode() )
     791                 :            :             {
     792                 :            :                 //JP 30.04.99 Bug 65660:
     793                 :            :                 // There are no page breaks outside of the normal body area,
     794                 :            :                 // so this is not a valid condition to insert a paragraph.
     795 [ #  # ][ #  # ]:          0 :                 if( nPrevPos < GetNodes().GetEndOfExtras().GetIndex() )
     796                 :          0 :                     pNd = 0;
     797                 :            :                 else
     798                 :            :                 {
     799                 :            :                     // Only if the table has page breaks!
     800                 :          0 :                     const SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt();
     801 [ #  # ][ #  # ]:          0 :                     if( SFX_ITEM_SET != pFrmFmt->GetItemState(RES_PAGEDESC, sal_False) &&
         [ #  # ][ #  # ]
     802         [ #  # ]:          0 :                         SFX_ITEM_SET != pFrmFmt->GetItemState( RES_BREAK, sal_False ) )
     803                 :          0 :                         pNd = 0;
     804                 :            :                 }
     805                 :            :             }
     806                 :            : 
     807         [ #  # ]:          0 :             if( pNd )
     808                 :            :             {
     809         [ #  # ]:          0 :                 SwTxtNode* pTxtNd = GetNodes().MakeTxtNode(
     810                 :            :                                         SwNodeIndex( *pTblNd ),
     811 [ #  # ][ #  # ]:          0 :                                         GetTxtCollFromPool( RES_POOLCOLL_TEXT ));
         [ #  # ][ #  # ]
     812         [ #  # ]:          0 :                 if( pTxtNd )
     813                 :            :                 {
     814         [ #  # ]:          0 :                     ((SwPosition&)rPos).nNode = pTblNd->GetIndex()-1;
     815 [ #  # ][ #  # ]:          0 :                     ((SwPosition&)rPos).nContent.Assign( pTxtNd, 0 );
     816                 :            : 
     817                 :            :                     // only add page breaks/styles to the body area
     818 [ #  # ][ #  # ]:          0 :                     if( nPrevPos > GetNodes().GetEndOfExtras().GetIndex() )
     819                 :            :                     {
     820                 :          0 :                         SwFrmFmt* pFrmFmt = pTblNd->GetTable().GetFrmFmt();
     821                 :            :                         const SfxPoolItem *pItem;
     822         [ #  # ]:          0 :                         if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_PAGEDESC,
     823         [ #  # ]:          0 :                             sal_False, &pItem ) )
     824                 :            :                         {
     825         [ #  # ]:          0 :                             pTxtNd->SetAttr( *pItem );
     826         [ #  # ]:          0 :                             pFrmFmt->ResetFmtAttr( RES_PAGEDESC );
     827                 :            :                         }
     828         [ #  # ]:          0 :                         if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_BREAK,
     829         [ #  # ]:          0 :                             sal_False, &pItem ) )
     830                 :            :                         {
     831         [ #  # ]:          0 :                             pTxtNd->SetAttr( *pItem );
     832         [ #  # ]:          0 :                             pFrmFmt->ResetFmtAttr( RES_BREAK );
     833                 :            :                         }
     834                 :            :                     }
     835                 :            : 
     836         [ #  # ]:          0 :                     if( pUndo )
     837                 :          0 :                         pUndo->SetTblFlag();
     838         [ #  # ]:          0 :                     SetModified();
     839                 :          0 :                     return true;
     840                 :            :                 }
     841                 :            :             }
     842                 :            :         }
     843                 :            :     }
     844                 :            : 
     845         [ +  - ]:       1268 :     std::vector<sal_uLong> aBkmkArr;
     846                 :       1268 :     _SaveCntntIdx( this, rPos.nNode.GetIndex(), rPos.nContent.GetIndex(),
     847         [ +  - ]:       1268 :                     aBkmkArr, SAVEFLY_SPLIT );
     848                 :            :     // FIXME: only SwTxtNode has a valid implementation of SplitCntntNode!
     849                 :            :     OSL_ENSURE(pNode->IsTxtNode(), "splitting non-text node?");
     850         [ +  - ]:       1268 :     pNode = pNode->SplitCntntNode( rPos );
     851         [ +  - ]:       1268 :     if (pNode)
     852                 :            :     {
     853                 :            :         // move all bookmarks, TOXMarks, FlyAtCnt
     854         [ +  + ]:       1268 :         if( !aBkmkArr.empty() )
     855         [ +  - ]:         58 :             _RestoreCntntIdx( this, aBkmkArr, rPos.nNode.GetIndex()-1, 0, sal_True );
     856                 :            : 
     857 [ +  - ][ +  - ]:       1268 :         if( IsRedlineOn() || (!IsIgnoreRedline() && !pRedlineTbl->empty() ))
         [ +  - ][ +  + ]
         [ -  + ][ -  + ]
     858                 :            :         {
     859         [ #  # ]:          0 :             SwPaM aPam( rPos );
     860         [ #  # ]:          0 :             aPam.SetMark();
     861         [ #  # ]:          0 :             aPam.Move( fnMoveBackward );
     862 [ #  # ][ #  # ]:          0 :             if( IsRedlineOn() )
     863 [ #  # ][ #  # ]:          0 :                 AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
                 [ #  # ]
     864                 :            :             else
     865 [ #  # ][ #  # ]:          0 :                 SplitRedline( aPam );
     866                 :            :         }
     867                 :            :     }
     868                 :            : 
     869         [ +  - ]:       1268 :     SetModified();
     870                 :       1268 :     return true;
     871                 :            : }
     872                 :            : 
     873                 :       7947 : bool SwDoc::AppendTxtNode( SwPosition& rPos )
     874                 :            : {
     875                 :            :     // create new node before EndOfContent
     876                 :       7947 :     SwTxtNode * pCurNode = rPos.nNode.GetNode().GetTxtNode();
     877         [ +  + ]:       7947 :     if( !pCurNode )
     878                 :            :     {
     879                 :            :         // so then one can be created!
     880         [ +  - ]:         20 :         SwNodeIndex aIdx( rPos.nNode, 1 );
     881         [ +  - ]:         20 :         pCurNode = GetNodes().MakeTxtNode( aIdx,
     882 [ +  - ][ +  - ]:         40 :                         GetTxtCollFromPool( RES_POOLCOLL_STANDARD ));
                 [ +  - ]
     883                 :            :     }
     884                 :            :     else
     885                 :       7927 :         pCurNode = (SwTxtNode*)pCurNode->AppendNode( rPos );
     886                 :            : 
     887                 :       7947 :     rPos.nNode++;
     888         [ +  - ]:       7947 :     rPos.nContent.Assign( pCurNode, 0 );
     889                 :            : 
     890         [ +  + ]:       7947 :     if (GetIDocumentUndoRedo().DoesUndo())
     891                 :            :     {
     892         [ +  - ]:         22 :         GetIDocumentUndoRedo().AppendUndo( new SwUndoInsert( rPos.nNode ) );
     893                 :            :     }
     894                 :            : 
     895 [ +  - ][ +  - ]:       7947 :     if( IsRedlineOn() || (!IsIgnoreRedline() && !pRedlineTbl->empty() ))
         [ -  + ][ -  + ]
     896                 :            :     {
     897         [ #  # ]:          0 :         SwPaM aPam( rPos );
     898         [ #  # ]:          0 :         aPam.SetMark();
     899         [ #  # ]:          0 :         aPam.Move( fnMoveBackward );
     900 [ #  # ][ #  # ]:          0 :         if( IsRedlineOn() )
     901 [ #  # ][ #  # ]:          0 :             AppendRedline( new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
                 [ #  # ]
     902                 :            :         else
     903 [ #  # ][ #  # ]:          0 :             SplitRedline( aPam );
     904                 :            :     }
     905                 :            : 
     906                 :       7947 :     SetModified();
     907                 :       7947 :     return sal_True;
     908                 :            : }
     909                 :            : 
     910                 :     138881 : bool SwDoc::InsertString( const SwPaM &rRg, const String &rStr,
     911                 :            :         const enum InsertFlags nInsertMode )
     912                 :            : {
     913                 :            :     // fetching DoesUndo is surprisingly expensive
     914 [ +  - ][ +  - ]:     138881 :     bool bDoesUndo = GetIDocumentUndoRedo().DoesUndo();
     915         [ +  + ]:     138881 :     if (bDoesUndo)
     916 [ +  - ][ +  - ]:       7280 :         GetIDocumentUndoRedo().ClearRedo(); // AppendUndo not always called!
     917                 :            : 
     918                 :     138881 :     const SwPosition& rPos = *rRg.GetPoint();
     919                 :            : 
     920         [ -  + ]:     138881 :     if( pACEWord )                  // add to auto correction
     921                 :            :     {
     922 [ #  # ][ #  # ]:          0 :         if( 1 == rStr.Len() && pACEWord->IsDeleted() )
                 [ #  # ]
     923                 :            :         {
     924         [ #  # ]:          0 :             pACEWord->CheckChar( rPos, rStr.GetChar( 0 ) );
     925                 :            :         }
     926 [ #  # ][ #  # ]:          0 :         delete pACEWord, pACEWord = 0;
     927                 :            :     }
     928                 :            : 
     929                 :     138881 :     SwTxtNode *const pNode = rPos.nNode.GetNode().GetTxtNode();
     930         [ +  + ]:     138881 :     if(!pNode)
     931                 :       4069 :         return false;
     932                 :            : 
     933         [ +  - ]:     134812 :     SwDataChanged aTmp( rRg, 0 );
     934                 :            : 
     935 [ +  + ][ +  - ]:     134812 :     if (!bDoesUndo || !GetIDocumentUndoRedo().DoesGroupUndo())
         [ +  - ][ +  + ]
                 [ +  + ]
     936                 :            :     {
     937         [ +  - ]:     134650 :         pNode->InsertText( rStr, rPos.nContent, nInsertMode );
     938                 :            : 
     939         [ +  + ]:     134650 :         if (bDoesUndo)
     940                 :            :         {
     941                 :            :             SwUndoInsert * const pUndo( new SwUndoInsert(
     942 [ +  - ][ +  - ]:       7118 :                 rPos.nNode, rPos.nContent.GetIndex(), rStr.Len(), nInsertMode));
     943 [ +  - ][ +  - ]:       7118 :             GetIDocumentUndoRedo().AppendUndo(pUndo);
     944                 :            :         }
     945                 :            :     }
     946                 :            :     else
     947                 :            :     {   // if Undo and grouping is enabled, everything changes!
     948                 :        162 :         SwUndoInsert * pUndo = NULL;
     949                 :            : 
     950                 :            :         // don't group the start if hints at the start should be expanded
     951         [ +  + ]:        162 :         if (!(nInsertMode & IDocumentContentOperations::INS_FORCEHINTEXPAND))
     952                 :            :         {
     953 [ +  - ][ +  - ]:        160 :             SwUndo *const pLastUndo = GetUndoManager().GetLastUndo();
     954                 :            :             SwUndoInsert *const pUndoInsert(
     955         [ +  + ]:        160 :                 dynamic_cast<SwUndoInsert *>(pLastUndo) );
     956 [ +  + ][ +  - ]:        160 :             if (pUndoInsert && pUndoInsert->CanGrouping(rPos))
         [ +  + ][ +  + ]
     957                 :            :             {
     958                 :         92 :                 pUndo = pUndoInsert;
     959                 :            :             }
     960                 :            :         }
     961                 :            : 
     962         [ +  - ]:        162 :         CharClass const& rCC = GetAppCharClass();
     963                 :        162 :         xub_StrLen nInsPos = rPos.nContent.GetIndex();
     964                 :            : 
     965         [ +  + ]:        162 :         if (!pUndo)
     966                 :            :         {
     967                 :            :             pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 0, nInsertMode,
     968 [ +  - ][ +  - ]:         70 :                             !rCC.isLetterNumeric( rStr, 0 ) );
                 [ +  - ]
     969 [ +  - ][ +  - ]:         70 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
     970                 :            :         }
     971                 :            : 
     972         [ +  - ]:        162 :         pNode->InsertText( rStr, rPos.nContent, nInsertMode );
     973                 :            : 
     974         [ +  + ]:        428 :         for( xub_StrLen i = 0; i < rStr.Len(); ++i )
     975                 :            :         {
     976                 :        266 :             nInsPos++;
     977                 :            :             // if CanGrouping() returns sal_True, everything has already been done
     978 [ +  - ][ +  + ]:        266 :             if( !pUndo->CanGrouping( rStr.GetChar( i ) ))
     979                 :            :             {
     980                 :            :                 pUndo = new SwUndoInsert( rPos.nNode, nInsPos, 1, nInsertMode,
     981 [ +  - ][ +  - ]:          6 :                             !rCC.isLetterNumeric( rStr, i ) );
                 [ +  - ]
     982 [ +  - ][ +  - ]:          6 :                 GetIDocumentUndoRedo().AppendUndo( pUndo );
     983                 :            :             }
     984                 :            :         }
     985                 :            :     }
     986                 :            : 
     987 [ +  - ][ +  + ]:     134812 :     if( IsRedlineOn() || (!IsIgnoreRedline() && !pRedlineTbl->empty() ))
         [ +  - ][ +  + ]
         [ -  + ][ +  + ]
     988                 :            :     {
     989                 :       2050 :         SwPaM aPam( rPos.nNode, aTmp.GetCntnt(),
     990         [ +  - ]:       4100 :                     rPos.nNode, rPos.nContent.GetIndex());
     991 [ +  - ][ +  - ]:       2050 :         if( IsRedlineOn() )
     992                 :            :         {
     993                 :            :             AppendRedline(
     994 [ +  - ][ +  - ]:       2050 :                 new SwRedline( nsRedlineType_t::REDLINE_INSERT, aPam ), true);
                 [ +  - ]
     995                 :            :         }
     996                 :            :         else
     997                 :            :         {
     998         [ #  # ]:          0 :             SplitRedline( aPam );
     999         [ +  - ]:       2050 :         }
    1000                 :            :     }
    1001                 :            : 
    1002         [ +  - ]:     134812 :     SetModified();
    1003         [ +  - ]:     138881 :     return true;
    1004                 :            : }
    1005                 :            : 
    1006                 :        523 : SwFlyFrmFmt* SwDoc::_InsNoTxtNode( const SwPosition& rPos, SwNoTxtNode* pNode,
    1007                 :            :                                     const SfxItemSet* pFlyAttrSet,
    1008                 :            :                                     const SfxItemSet* pGrfAttrSet,
    1009                 :            :                                     SwFrmFmt* pFrmFmt)
    1010                 :            : {
    1011                 :        523 :     SwFlyFrmFmt *pFmt = 0;
    1012         [ +  - ]:        523 :     if( pNode )
    1013                 :            :     {
    1014                 :            :         pFmt = _MakeFlySection( rPos, *pNode, FLY_AT_PARA,
    1015                 :        523 :                                 pFlyAttrSet, pFrmFmt );
    1016         [ +  + ]:        523 :         if( pGrfAttrSet )
    1017                 :         86 :             pNode->SetAttr( *pGrfAttrSet );
    1018                 :            :     }
    1019                 :        523 :     return pFmt;
    1020                 :            : }
    1021                 :            : 
    1022                 :         87 : SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg,
    1023                 :            :                             const String& rGrfName,
    1024                 :            :                             const String& rFltName,
    1025                 :            :                             const Graphic* pGraphic,
    1026                 :            :                             const SfxItemSet* pFlyAttrSet,
    1027                 :            :                             const SfxItemSet* pGrfAttrSet,
    1028                 :            :                             SwFrmFmt* pFrmFmt )
    1029                 :            : {
    1030         [ +  - ]:         87 :     if( !pFrmFmt )
    1031                 :         87 :         pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
    1032         [ +  - ]:        174 :     return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeGrfNode(
    1033                 :         87 :                             SwNodeIndex( GetNodes().GetEndOfAutotext() ),
    1034                 :            :                             rGrfName, rFltName, pGraphic,
    1035         [ +  - ]:        261 :                             pDfltGrfFmtColl ),
    1036         [ +  - ]:        174 :                             pFlyAttrSet, pGrfAttrSet, pFrmFmt );
    1037                 :            : }
    1038                 :            : 
    1039                 :          2 : SwFlyFrmFmt* SwDoc::Insert( const SwPaM &rRg, const GraphicObject& rGrfObj,
    1040                 :            :                             const SfxItemSet* pFlyAttrSet,
    1041                 :            :                             const SfxItemSet* pGrfAttrSet,
    1042                 :            :                             SwFrmFmt* pFrmFmt )
    1043                 :            : {
    1044         [ -  + ]:          2 :     if( !pFrmFmt )
    1045                 :          0 :         pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC );
    1046         [ +  - ]:          4 :     return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeGrfNode(
    1047                 :          2 :                             SwNodeIndex( GetNodes().GetEndOfAutotext() ),
    1048         [ +  - ]:          6 :                             rGrfObj, pDfltGrfFmtColl ),
    1049         [ +  - ]:          4 :                             pFlyAttrSet, pGrfAttrSet, pFrmFmt );
    1050                 :            : }
    1051                 :            : 
    1052                 :        432 : SwFlyFrmFmt* SwDoc::Insert(const SwPaM &rRg, const svt::EmbeddedObjectRef& xObj,
    1053                 :            :                         const SfxItemSet* pFlyAttrSet,
    1054                 :            :                         const SfxItemSet* pGrfAttrSet,
    1055                 :            :                         SwFrmFmt* pFrmFmt )
    1056                 :            : {
    1057         [ +  - ]:        432 :     if( !pFrmFmt )
    1058                 :            :     {
    1059                 :        432 :         sal_uInt16 nId = RES_POOLFRM_OLE;
    1060 [ +  - ][ +  - ]:        432 :         SvGlobalName aClassName( xObj->getClassID() );
         [ +  - ][ +  - ]
    1061 [ +  - ][ +  + ]:        432 :         if (SotExchange::IsMath(aClassName))
    1062                 :        426 :             nId = RES_POOLFRM_FORMEL;
    1063                 :            : 
    1064 [ +  - ][ +  - ]:        432 :         pFrmFmt = GetFrmFmtFromPool( nId );
    1065                 :            :     }
    1066         [ +  - ]:        864 :     return _InsNoTxtNode( *rRg.GetPoint(), GetNodes().MakeOLENode(
    1067                 :        432 :                             SwNodeIndex( GetNodes().GetEndOfAutotext() ),
    1068                 :            :                             xObj,
    1069         [ +  - ]:       1296 :                             pDfltGrfFmtColl ),
    1070                 :            :                             pFlyAttrSet, pGrfAttrSet,
    1071         [ +  - ]:        864 :                             pFrmFmt );
    1072                 :            : }
    1073                 :            : 
    1074                 :          2 : SwFlyFrmFmt* SwDoc::InsertOLE(const SwPaM &rRg, const String& rObjName,
    1075                 :            :                         sal_Int64 nAspect,
    1076                 :            :                         const SfxItemSet* pFlyAttrSet,
    1077                 :            :                         const SfxItemSet* pGrfAttrSet,
    1078                 :            :                         SwFrmFmt* pFrmFmt )
    1079                 :            : {
    1080         [ +  - ]:          2 :     if( !pFrmFmt )
    1081                 :          2 :         pFrmFmt = GetFrmFmtFromPool( RES_POOLFRM_OLE );
    1082                 :            : 
    1083                 :          2 :     return _InsNoTxtNode( *rRg.GetPoint(),
    1084         [ +  - ]:          2 :                             GetNodes().MakeOLENode(
    1085                 :          2 :                                 SwNodeIndex( GetNodes().GetEndOfAutotext() ),
    1086                 :            :                                 rObjName,
    1087                 :            :                                 nAspect,
    1088                 :            :                                 pDfltGrfFmtColl,
    1089         [ +  - ]:          6 :                                 0 ),
    1090                 :            :                             pFlyAttrSet, pGrfAttrSet,
    1091         [ +  - ]:          4 :                             pFrmFmt );
    1092                 :            : }
    1093                 :            : 
    1094                 :            : /*************************************************************************
    1095                 :            : |*  SwDoc::GetFldType()
    1096                 :            : |*  Description: returns the field type of the Doc
    1097                 :            : *************************************************************************/
    1098                 :      20614 : SwFieldType *SwDoc::GetSysFldType( const sal_uInt16 eWhich ) const
    1099                 :            : {
    1100         [ +  - ]:     182923 :     for( sal_uInt16 i = 0; i < INIT_FLDTYPES; ++i )
    1101         [ +  + ]:     182923 :         if( eWhich == (*pFldTypes)[i]->Which() )
    1102                 :      20614 :             return (*pFldTypes)[i];
    1103                 :      20614 :     return 0;
    1104                 :            : }
    1105                 :            : 
    1106                 :            : // Set the rsid from nStt to nEnd of pTxtNode to the current session number
    1107                 :        841 : bool SwDoc::UpdateRsid( SwTxtNode *pTxtNode, xub_StrLen nStt, xub_StrLen nEnd )
    1108                 :            : {
    1109         [ -  + ]:        841 :     if ( !pTxtNode )
    1110                 :            :     {
    1111                 :          0 :         return false;
    1112                 :            :     }
    1113                 :            : 
    1114         [ +  - ]:        841 :     SvxRsidItem aRsid( nRsid, RES_CHRATR_RSID );
    1115         [ +  - ]:        841 :     SwTxtAttr* pAttr = MakeTxtAttr( *this, aRsid, nStt, nEnd );
    1116 [ +  - ][ +  - ]:        841 :     return pTxtNode->InsertHint( pAttr, INS_DEFAULT );
    1117                 :            : }
    1118                 :            : 
    1119                 :            : // Set the rsid of the next nLen symbols of rRg to the current session number
    1120                 :        841 : bool SwDoc::UpdateRsid( const SwPaM &rRg, const xub_StrLen nLen )
    1121                 :            : {
    1122                 :        841 :     const SwPosition* pPos = rRg.GetPoint();
    1123                 :        841 :     SwTxtNode *pTxtNode = pPos->nNode.GetNode().GetTxtNode();
    1124                 :        841 :     xub_StrLen nInsPos = pPos->nContent.GetIndex();
    1125                 :            : 
    1126                 :        841 :     return UpdateRsid( pTxtNode, nInsPos - nLen, nInsPos );
    1127                 :            : }
    1128                 :            : 
    1129                 :        911 : bool SwDoc::UpdateParRsid( SwTxtNode *pTxtNode, sal_uInt32 nVal )
    1130                 :            : {
    1131         [ -  + ]:        911 :     if ( !pTxtNode )
    1132                 :            :     {
    1133                 :          0 :         return false;
    1134                 :            :     }
    1135                 :            : 
    1136 [ +  - ][ +  - ]:        911 :     SvxRsidItem aRsid( nVal ? nVal : nRsid, RES_PARATR_RSID );
    1137 [ +  - ][ +  - ]:        911 :     return pTxtNode->SetAttr( aRsid );
    1138                 :            : }
    1139                 :            : 
    1140                 :            : 
    1141                 :            : /*************************************************************************
    1142                 :            :  *             void SetDocStat( const SwDocStat& rStat );
    1143                 :            :  *************************************************************************/
    1144                 :         63 : void SwDoc::SetDocStat( const SwDocStat& rStat )
    1145                 :            : {
    1146                 :         63 :     *pDocStat = rStat;
    1147                 :         63 : }
    1148                 :            : 
    1149                 :      11597 : const SwDocStat& SwDoc::GetDocStat() const
    1150                 :            : {
    1151                 :      11597 :     return *pDocStat;
    1152                 :            : }
    1153                 :            : 
    1154                 :       1396 : const SwDocStat& SwDoc::GetUpdatedDocStat()
    1155                 :            : {
    1156         [ +  + ]:       1396 :     if (pDocStat->bModified)
    1157                 :            :     {
    1158                 :       1376 :         UpdateDocStat();
    1159                 :            :     }
    1160                 :       1396 :     return *pDocStat;
    1161                 :            : }
    1162                 :            : 
    1163                 :            : struct _PostItFld : public _SetGetExpFld
    1164                 :            : {
    1165                 :          0 :     _PostItFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld,  const SwIndex* pIdx = 0 )
    1166                 :          0 :         : _SetGetExpFld( rNdIdx, pFld, pIdx ) {}
    1167                 :            : 
    1168                 :            :     sal_uInt16 GetPageNo( const StringRangeEnumerator &rRangeEnum,
    1169                 :            :             const std::set< sal_Int32 > &rPossiblePages,
    1170                 :            :             sal_uInt16& rVirtPgNo, sal_uInt16& rLineNo );
    1171                 :            : 
    1172                 :          0 :     SwPostItField* GetPostIt() const
    1173                 :            :     {
    1174                 :          0 :         return (SwPostItField*) GetFld()->GetFld().GetFld();
    1175                 :            :     }
    1176                 :            : };
    1177                 :            : 
    1178                 :          0 : sal_uInt16 _PostItFld::GetPageNo(
    1179                 :            :     const StringRangeEnumerator &rRangeEnum,
    1180                 :            :     const std::set< sal_Int32 > &rPossiblePages,
    1181                 :            :     /* out */ sal_uInt16& rVirtPgNo, /* out */ sal_uInt16& rLineNo )
    1182                 :            : {
    1183                 :            :     //Problem: If a PostItFld is contained in a Node that is represented
    1184                 :            :     //by more than one layout instance,
    1185                 :            :     //we have to decide whether it should be printed once or n-times.
    1186                 :            :     //Probably only once. For the page number we don't select a random one,
    1187                 :            :     //but the PostIt's first occurence in the selected area.
    1188                 :          0 :     rVirtPgNo = 0;
    1189                 :          0 :     sal_uInt16 nPos = GetCntnt();
    1190         [ #  # ]:          0 :     SwIterator<SwTxtFrm,SwTxtNode> aIter( GetFld()->GetTxtNode() );
    1191 [ #  # ][ #  # ]:          0 :     for( SwTxtFrm* pFrm = aIter.First(); pFrm;  pFrm = aIter.Next() )
                 [ #  # ]
    1192                 :            :     {
    1193   [ #  #  #  #  :          0 :         if( pFrm->GetOfst() > nPos ||
           #  # ][ #  # ]
    1194                 :          0 :             (pFrm->HasFollow() && pFrm->GetFollow()->GetOfst() <= nPos) )
    1195                 :          0 :             continue;
    1196         [ #  # ]:          0 :         sal_uInt16 nPgNo = pFrm->GetPhyPageNum();
    1197 [ #  # ][ #  # ]:          0 :         if( rRangeEnum.hasValue( nPgNo, &rPossiblePages ))
    1198                 :            :         {
    1199         [ #  # ]:          0 :             rLineNo = (sal_uInt16)(pFrm->GetLineCount( nPos ) +
    1200                 :          0 :                       pFrm->GetAllLines() - pFrm->GetThisLines());
    1201         [ #  # ]:          0 :             rVirtPgNo = pFrm->GetVirtPageNum();
    1202                 :          0 :             return nPgNo;
    1203                 :            :         }
    1204                 :            :     }
    1205         [ #  # ]:          0 :     return 0;
    1206                 :            : }
    1207                 :            : 
    1208                 :          0 : bool lcl_GetPostIts(
    1209                 :            :     IDocumentFieldsAccess* pIDFA,
    1210                 :            :     _SetGetExpFlds * pSrtLst )
    1211                 :            : {
    1212                 :          0 :     bool bHasPostIts = false;
    1213                 :            : 
    1214                 :          0 :     SwFieldType* pFldType = pIDFA->GetSysFldType( RES_POSTITFLD );
    1215                 :            :     OSL_ENSURE( pFldType, "kein PostItType ? ");
    1216                 :            : 
    1217         [ #  # ]:          0 :     if( pFldType->GetDepends() )
    1218                 :            :     {
    1219                 :            :         // Found modify object; insert all fields into the array
    1220         [ #  # ]:          0 :         SwIterator<SwFmtFld,SwFieldType> aIter( *pFldType );
    1221                 :            :         const SwTxtFld* pTxtFld;
    1222 [ #  # ][ #  # ]:          0 :         for( SwFmtFld* pFld = aIter.First(); pFld;  pFld = aIter.Next() )
                 [ #  # ]
    1223                 :            :         {
    1224 [ #  # ][ #  # ]:          0 :             if( 0 != ( pTxtFld = pFld->GetTxtFld() ) &&
                 [ #  # ]
    1225         [ #  # ]:          0 :                 pTxtFld->GetTxtNode().GetNodes().IsDocNodes() )
    1226                 :            :             {
    1227                 :          0 :                 bHasPostIts = true;
    1228         [ #  # ]:          0 :                 if (pSrtLst)
    1229                 :            :                 {
    1230         [ #  # ]:          0 :                     SwNodeIndex aIdx( pTxtFld->GetTxtNode() );
    1231 [ #  # ][ #  # ]:          0 :                     _PostItFld* pNew = new _PostItFld( aIdx, pTxtFld );
    1232 [ #  # ][ #  # ]:          0 :                     pSrtLst->insert( pNew );
    1233                 :            :                 }
    1234                 :            :                 else
    1235                 :          0 :                     break;  // we just wanted to check for the existence of postits ...
    1236                 :            :             }
    1237         [ #  # ]:          0 :         }
    1238                 :            :     }
    1239                 :            : 
    1240                 :          0 :     return bHasPostIts;
    1241                 :            : }
    1242                 :            : 
    1243                 :          0 : static void lcl_FormatPostIt(
    1244                 :            :     IDocumentContentOperations* pIDCO,
    1245                 :            :     SwPaM& aPam,
    1246                 :            :     SwPostItField* pField,
    1247                 :            :     bool bNewPage, bool bIsFirstPostIt,
    1248                 :            :     sal_uInt16 nPageNo, sal_uInt16 nLineNo )
    1249                 :            : {
    1250                 :            :     static char const sTmp[] = " : ";
    1251                 :            : 
    1252                 :            :     OSL_ENSURE( ViewShell::GetShellRes(), "missing ShellRes" );
    1253                 :            : 
    1254         [ #  # ]:          0 :     if (bNewPage)
    1255                 :            :     {
    1256 [ #  # ][ #  # ]:          0 :         pIDCO->InsertPoolItem( aPam, SvxFmtBreakItem( SVX_BREAK_PAGE_AFTER, RES_BREAK ), 0 );
                 [ #  # ]
    1257         [ #  # ]:          0 :         pIDCO->SplitNode( *aPam.GetPoint(), false );
    1258                 :            :     }
    1259         [ #  # ]:          0 :     else if (!bIsFirstPostIt)
    1260                 :            :     {
    1261                 :            :         // add an empty line between different notes
    1262         [ #  # ]:          0 :         pIDCO->SplitNode( *aPam.GetPoint(), false );
    1263         [ #  # ]:          0 :         pIDCO->SplitNode( *aPam.GetPoint(), false );
    1264                 :            :     }
    1265                 :            : 
    1266 [ #  # ][ #  # ]:          0 :     String aStr( ViewShell::GetShellRes()->aPostItPage );
    1267         [ #  # ]:          0 :     aStr.AppendAscii(sTmp);
    1268                 :            : 
    1269 [ #  # ][ #  # ]:          0 :     aStr += XubString::CreateFromInt32( nPageNo );
                 [ #  # ]
    1270         [ #  # ]:          0 :     aStr += ' ';
    1271         [ #  # ]:          0 :     if( nLineNo )
    1272                 :            :     {
    1273 [ #  # ][ #  # ]:          0 :         aStr += ViewShell::GetShellRes()->aPostItLine;
    1274         [ #  # ]:          0 :         aStr.AppendAscii(sTmp);
    1275 [ #  # ][ #  # ]:          0 :         aStr += XubString::CreateFromInt32( nLineNo );
                 [ #  # ]
    1276         [ #  # ]:          0 :         aStr += ' ';
    1277                 :            :     }
    1278 [ #  # ][ #  # ]:          0 :     aStr += ViewShell::GetShellRes()->aPostItAuthor;
    1279         [ #  # ]:          0 :     aStr.AppendAscii(sTmp);
    1280 [ #  # ][ #  # ]:          0 :     aStr += pField->GetPar1();
    1281         [ #  # ]:          0 :     aStr += ' ';
    1282         [ #  # ]:          0 :     SvtSysLocale aSysLocale;
    1283 [ #  # ][ #  # ]:          0 :     aStr += /*(LocaleDataWrapper&)*/aSysLocale.GetLocaleData().getDate( pField->GetDate() );
                 [ #  # ]
    1284         [ #  # ]:          0 :     pIDCO->InsertString( aPam, aStr );
    1285                 :            : 
    1286         [ #  # ]:          0 :     pIDCO->SplitNode( *aPam.GetPoint(), false );
    1287 [ #  # ][ #  # ]:          0 :     aStr = pField->GetPar2();
    1288                 :            : #if defined( WNT )
    1289                 :            :     // Throw out all CR in Windows
    1290                 :            :     aStr = comphelper::string::remove(aStr, '\r');
    1291                 :            : #endif
    1292 [ #  # ][ #  # ]:          0 :     pIDCO->InsertString( aPam, aStr );
                 [ #  # ]
    1293                 :          0 : }
    1294                 :            : 
    1295                 :            : // provide the paper tray to use according to the page style in use,
    1296                 :            : // but do that only if the respective item is NOT just the default item
    1297                 :          0 : static sal_Int32 lcl_GetPaperBin( const SwPageFrm *pStartFrm )
    1298                 :            : {
    1299                 :          0 :     sal_Int32 nRes = -1;
    1300                 :            : 
    1301                 :          0 :     const SwFrmFmt &rFmt = pStartFrm->GetPageDesc()->GetMaster();
    1302                 :          0 :     const SfxPoolItem *pItem = NULL;
    1303         [ #  # ]:          0 :     SfxItemState eState = rFmt.GetItemState( RES_PAPER_BIN, sal_False, &pItem );
    1304         [ #  # ]:          0 :     const SvxPaperBinItem *pPaperBinItem = dynamic_cast< const SvxPaperBinItem * >(pItem);
    1305 [ #  # ][ #  # ]:          0 :     if (eState > SFX_ITEM_DEFAULT && pPaperBinItem)
    1306                 :          0 :         nRes = pPaperBinItem->GetValue();
    1307                 :            : 
    1308                 :          0 :     return nRes;
    1309                 :            : }
    1310                 :            : 
    1311                 :          0 : void SwDoc::CalculatePagesForPrinting(
    1312                 :            :     const SwRootFrm& rLayout,
    1313                 :            :     /* out */ SwRenderData &rData,
    1314                 :            :     const SwPrintUIOptions &rOptions,
    1315                 :            :     bool bIsPDFExport,
    1316                 :            :     sal_Int32 nDocPageCount )
    1317                 :            : {
    1318         [ #  # ]:          0 :     const sal_Int32 nContent = rOptions.getIntValue( "PrintContent", 0 );
    1319                 :          0 :     const bool bPrintSelection = nContent == 2;
    1320                 :            : 
    1321                 :            :     // properties to take into account when calcualting the set of pages
    1322                 :            :     // (PDF export UI does not allow for selecting left or right pages only)
    1323 [ #  # ][ #  # ]:          0 :     bool bPrintLeftPages    = bIsPDFExport ? true : rOptions.IsPrintLeftPages();
    1324 [ #  # ][ #  # ]:          0 :     bool bPrintRightPages   = bIsPDFExport ? true : rOptions.IsPrintRightPages();
    1325                 :            :     // #i103700# printing selections should not allow for automatic inserting empty pages
    1326 [ #  # ][ #  # ]:          0 :     bool bPrintEmptyPages   = bPrintSelection ? false : rOptions.IsPrintEmptyPages( bIsPDFExport );
    1327                 :            : 
    1328                 :          0 :     std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
    1329                 :          0 :     std::set< sal_Int32 > &rValidPages = rData.GetValidPagesSet();
    1330                 :          0 :     rValidPages.clear();
    1331                 :            : 
    1332                 :          0 :     sal_Int32 nPageNum = 1;
    1333         [ #  # ]:          0 :     const SwPageFrm *pStPage = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
    1334 [ #  # ][ #  # ]:          0 :     while (pStPage && nPageNum <= nDocPageCount)
                 [ #  # ]
    1335                 :            :     {
    1336                 :            :         const bool bPrintThisPage =
    1337         [ #  # ]:          0 :             ( (bPrintRightPages && pStPage->OnRightPage()) ||
    1338         [ #  # ]:          0 :               (bPrintLeftPages && !pStPage->OnRightPage()) ) &&
    1339 [ #  # ][ #  # ]:          0 :             ( bPrintEmptyPages || pStPage->Frm().Height() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1340                 :            : 
    1341         [ #  # ]:          0 :         if (bPrintThisPage)
    1342                 :            :         {
    1343         [ #  # ]:          0 :             rValidPages.insert( nPageNum );
    1344 [ #  # ][ #  # ]:          0 :             rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
    1345                 :            :         }
    1346                 :            : 
    1347                 :          0 :         ++nPageNum;
    1348                 :          0 :         pStPage = (SwPageFrm*)pStPage->GetNext();
    1349                 :            :     }
    1350                 :            : 
    1351                 :            : 
    1352                 :            :     //
    1353                 :            :     // now that we have identified the valid pages for printing according
    1354                 :            :     // to the print settings we need to get the PageRange to use and
    1355                 :            :     // use both results to get the actual pages to be printed
    1356                 :            :     // (post-it settings need to be taken into account later on!)
    1357                 :            :     //
    1358                 :            : 
    1359                 :            :     // get PageRange value to use
    1360                 :          0 :     OUString aPageRange;
    1361                 :            :     // #i116085# - adjusting fix for i113919
    1362         [ #  # ]:          0 :     if ( !bIsPDFExport )
    1363                 :            :     {
    1364                 :            :         // PageContent :
    1365                 :            :         // 0 -> print all pages (default if aPageRange is empty)
    1366                 :            :         // 1 -> print range according to PageRange
    1367                 :            :         // 2 -> print selection
    1368         [ #  # ]:          0 :         if (1 == nContent)
    1369         [ #  # ]:          0 :             aPageRange = rOptions.getStringValue( "PageRange", OUString() );
    1370                 :            :         if (2 == nContent)
    1371                 :            :         {
    1372                 :            :             // note that printing selections is actually implemented by copying
    1373                 :            :             // the selection to a new temporary document and printing all of that one.
    1374                 :            :             // Thus for Writer "PrintContent" must never be 2.
    1375                 :            :             // See SwXTextDocument::GetRenderDoc for evaluating if a selection is to be
    1376                 :            :             // printed and for creating the temporary document.
    1377                 :            :         }
    1378                 :            : 
    1379                 :            :         // please note
    1380                 :            :     }
    1381         [ #  # ]:          0 :     if (aPageRange.isEmpty())    // empty string -> print all
    1382                 :            :     {
    1383                 :            :         // set page range to print to 'all pages'
    1384                 :          0 :         aPageRange = OUString::valueOf( (sal_Int32)1 );
    1385                 :          0 :         aPageRange += OUString::valueOf( (sal_Unicode)'-');
    1386                 :          0 :         aPageRange += OUString::valueOf( nDocPageCount );
    1387                 :            :     }
    1388                 :          0 :     rData.SetPageRange( aPageRange );
    1389                 :            : 
    1390                 :            :     // get vector of pages to print according to PageRange and valid pages set from above
    1391                 :            :     // (result may be an empty vector, for example if the range string is not correct)
    1392                 :            :     StringRangeEnumerator::getRangesFromString(
    1393                 :          0 :             aPageRange, rData.GetPagesToPrint(),
    1394         [ #  # ]:          0 :             1, nDocPageCount, 0, &rData.GetValidPagesSet() );
    1395                 :          0 : }
    1396                 :            : 
    1397                 :          0 : void SwDoc::UpdatePagesForPrintingWithPostItData(
    1398                 :            :     /* out */ SwRenderData &rData,
    1399                 :            :     const SwPrintUIOptions &rOptions,
    1400                 :            :     bool /*bIsPDFExport*/,
    1401                 :            :     sal_Int32 nDocPageCount )
    1402                 :            : {
    1403                 :            : 
    1404                 :          0 :     sal_Int16 nPostItMode = (sal_Int16) rOptions.getIntValue( "PrintAnnotationMode", 0 );
    1405                 :            :     OSL_ENSURE(nPostItMode == POSTITS_NONE || rData.HasPostItData(),
    1406                 :            :             "print post-its without post-it data?" );
    1407         [ #  # ]:          0 :     const sal_uInt16 nPostItCount = rData.HasPostItData() ? rData.m_pPostItFields->size() : 0;
    1408 [ #  # ][ #  # ]:          0 :     if (nPostItMode != POSTITS_NONE && nPostItCount > 0)
    1409                 :            :     {
    1410         [ #  # ]:          0 :         SET_CURR_SHELL( rData.m_pPostItShell.get() );
    1411                 :            : 
    1412                 :            :         // clear document and move to end of it
    1413                 :          0 :         SwDoc & rPostItDoc(*rData.m_pPostItShell->GetDoc());
    1414 [ #  # ][ #  # ]:          0 :         SwPaM aPam(rPostItDoc.GetNodes().GetEndOfContent());
    1415         [ #  # ]:          0 :         aPam.Move( fnMoveBackward, fnGoDoc );
    1416         [ #  # ]:          0 :         aPam.SetMark();
    1417         [ #  # ]:          0 :         aPam.Move( fnMoveForward, fnGoDoc );
    1418         [ #  # ]:          0 :         rPostItDoc.DeleteRange( aPam );
    1419                 :            : 
    1420         [ #  # ]:          0 :         const StringRangeEnumerator aRangeEnum( rData.GetPageRange(), 1, nDocPageCount, 0 );
    1421                 :            : 
    1422                 :            :         // For mode POSTITS_ENDPAGE:
    1423                 :            :         // maps a physical page number to the page number in post-it document that holds
    1424                 :            :         // the first post-it for that physical page . Needed to relate the correct start frames
    1425                 :            :         // from the post-it doc to the physical page of the document
    1426         [ #  # ]:          0 :         std::map< sal_Int32, sal_Int32 >  aPostItLastStartPageNum;
    1427                 :            : 
    1428                 :            :         // add all post-its on valid pages within the the page range to the
    1429                 :            :         // temporary post-it document.
    1430                 :            :         // Since the array of post-it fileds is sorted by page and line number we will
    1431                 :            :         // already get them in the correct order
    1432                 :          0 :         sal_uInt16 nVirtPg = 0, nLineNo = 0, nLastPageNum = 0, nPhyPageNum = 0;
    1433                 :          0 :         bool bIsFirstPostIt = true;
    1434         [ #  # ]:          0 :         for (sal_uInt16 i = 0; i < nPostItCount; ++i)
    1435                 :            :         {
    1436         [ #  # ]:          0 :             _PostItFld& rPostIt = (_PostItFld&)*(*rData.m_pPostItFields)[ i ];
    1437                 :          0 :             nLastPageNum = nPhyPageNum;
    1438                 :            :             nPhyPageNum = rPostIt.GetPageNo(
    1439         [ #  # ]:          0 :                     aRangeEnum, rData.GetValidPagesSet(), nVirtPg, nLineNo );
    1440         [ #  # ]:          0 :             if (nPhyPageNum)
    1441                 :            :             {
    1442                 :            :                 // need to insert a page break?
    1443                 :            :                 // In POSTITS_ENDPAGE mode for each document page the following
    1444                 :            :                 // post-it page needs to start on a new page
    1445                 :            :                 const bool bNewPage = nPostItMode == POSTITS_ENDPAGE &&
    1446 [ #  # ][ #  # ]:          0 :                         !bIsFirstPostIt && nPhyPageNum != nLastPageNum;
                 [ #  # ]
    1447                 :            : 
    1448                 :          0 :                 lcl_FormatPostIt( rData.m_pPostItShell->GetDoc(), aPam,
    1449 [ #  # ][ #  # ]:          0 :                         rPostIt.GetPostIt(), bNewPage, bIsFirstPostIt, nVirtPg, nLineNo );
    1450                 :          0 :                 bIsFirstPostIt = false;
    1451                 :            : 
    1452         [ #  # ]:          0 :                 if (nPostItMode == POSTITS_ENDPAGE)
    1453                 :            :                 {
    1454                 :            :                     // get the correct number of current pages for the post-it document
    1455         [ #  # ]:          0 :                     rData.m_pPostItShell->CalcLayout();
    1456         [ #  # ]:          0 :                     const sal_Int32 nPages = rData.m_pPostItShell->GetPageCount();
    1457         [ #  # ]:          0 :                     aPostItLastStartPageNum[ nPhyPageNum ] = nPages;
    1458                 :            :                 }
    1459                 :            :             }
    1460                 :            :         }
    1461                 :            : 
    1462                 :            :         // format post-it doc to get correct number of pages
    1463         [ #  # ]:          0 :         rData.m_pPostItShell->CalcLayout();
    1464         [ #  # ]:          0 :         const sal_Int32 nPostItDocPageCount = rData.m_pPostItShell->GetPageCount();
    1465                 :            : 
    1466 [ #  # ][ #  # ]:          0 :         if (nPostItMode == POSTITS_ONLY || nPostItMode == POSTITS_ENDDOC)
    1467                 :            :         {
    1468                 :            :             // now add those post-it pages to the vector of pages to print
    1469                 :            :             // or replace them if only post-its should be printed
    1470                 :            : 
    1471         [ #  # ]:          0 :             if (nPostItMode == POSTITS_ONLY)
    1472                 :            :             {
    1473                 :            :                 // no document page to be printed
    1474                 :          0 :                 rData.GetPagesToPrint().clear();
    1475                 :            :             }
    1476                 :            : 
    1477                 :            :             // now we just need to add the post-it pages to be printed to the
    1478                 :            :             // end of the vector of pages to print
    1479                 :          0 :             sal_Int32 nPageNum = 0;
    1480         [ #  # ]:          0 :             const SwPageFrm * pPageFrm = (SwPageFrm*)rData.m_pPostItShell->GetLayout()->Lower();
    1481 [ #  # ][ #  # ]:          0 :             while( pPageFrm && nPageNum < nPostItDocPageCount )
                 [ #  # ]
    1482                 :            :             {
    1483                 :            :                 OSL_ENSURE( pPageFrm, "Empty page frame. How are we going to print this?" );
    1484                 :          0 :                 ++nPageNum;
    1485                 :            :                 // negative page number indicates page is from the post-it doc
    1486         [ #  # ]:          0 :                 rData.GetPagesToPrint().push_back( -nPageNum );
    1487                 :            :                 OSL_ENSURE( pPageFrm, "pPageFrm is NULL!" );
    1488                 :          0 :                 pPageFrm = (SwPageFrm*)pPageFrm->GetNext();
    1489                 :            :             }
    1490                 :          0 :             OSL_ENSURE( nPageNum == nPostItDocPageCount, "unexpected number of pages" );
    1491                 :            :         }
    1492         [ #  # ]:          0 :         else if (nPostItMode == POSTITS_ENDPAGE)
    1493                 :            :         {
    1494                 :            :             // the next step is to find all the pages from the post-it
    1495                 :            :             // document that should be printed for a given physical page
    1496                 :            :             // of the document
    1497                 :            : 
    1498         [ #  # ]:          0 :             std::vector< sal_Int32 >            aTmpPagesToPrint;
    1499                 :          0 :             sal_Int32 nLastPostItPage(0);
    1500                 :          0 :             const size_t nNum = rData.GetPagesToPrint().size();
    1501         [ #  # ]:          0 :             for (size_t i = 0 ;  i < nNum;  ++i)
    1502                 :            :             {
    1503                 :            :                 // add the physical page to print from the document
    1504         [ #  # ]:          0 :                 const sal_Int32 nPhysPage = rData.GetPagesToPrint()[i];
    1505         [ #  # ]:          0 :                 aTmpPagesToPrint.push_back( nPhysPage );
    1506                 :            : 
    1507                 :            :                 // add the post-it document pages to print, i.e those
    1508                 :            :                 // post-it pages that have the data for the above physical page
    1509                 :            :                 ::std::map<sal_Int32, sal_Int32>::const_iterator const iter(
    1510 [ #  # ][ #  # ]:          0 :                         aPostItLastStartPageNum.find(nPhysPage));
    1511 [ #  # ][ #  # ]:          0 :                 if (iter != aPostItLastStartPageNum.end())
                 [ #  # ]
    1512                 :            :                 {
    1513         [ #  # ]:          0 :                     for (sal_Int32 j = nLastPostItPage + 1;
    1514         [ #  # ]:          0 :                             j <= iter->second; ++j)
    1515                 :            :                     {
    1516                 :            :                         // negative page number indicates page is from the
    1517         [ #  # ]:          0 :                         aTmpPagesToPrint.push_back(-j); // post-it document
    1518                 :            :                     }
    1519         [ #  # ]:          0 :                     nLastPostItPage = iter->second;
    1520                 :            :                 }
    1521                 :            :             }
    1522                 :            : 
    1523                 :            :             // finally we need to assign those vectors to the resulting ones.
    1524                 :            :             // swapping the data should be more efficient than assigning since
    1525                 :            :             // we won't need the temporary vectors anymore
    1526                 :          0 :             rData.GetPagesToPrint().swap( aTmpPagesToPrint );
    1527 [ #  # ][ #  # ]:          0 :         }
    1528                 :            :     }
    1529                 :          0 : }
    1530                 :            : 
    1531                 :          0 : void SwDoc::CalculatePagePairsForProspectPrinting(
    1532                 :            :     const SwRootFrm& rLayout,
    1533                 :            :     /* out */ SwRenderData &rData,
    1534                 :            :     const SwPrintUIOptions &rOptions,
    1535                 :            :     sal_Int32 nDocPageCount )
    1536                 :            : {
    1537                 :          0 :     std::map< sal_Int32, sal_Int32 > &rPrinterPaperTrays = rData.GetPrinterPaperTrays();
    1538                 :          0 :     std::set< sal_Int32 > &rValidPagesSet = rData.GetValidPagesSet();
    1539                 :          0 :     std::vector< std::pair< sal_Int32, sal_Int32 > > &rPagePairs = rData.GetPagePairsForProspectPrinting();
    1540         [ #  # ]:          0 :     std::map< sal_Int32, const SwPageFrm * > validStartFrms;
    1541                 :            : 
    1542                 :          0 :     rPagePairs.clear();
    1543                 :          0 :     rValidPagesSet.clear();
    1544                 :            : 
    1545                 :          0 :     rtl::OUString aPageRange;
    1546                 :            :     // PageContent :
    1547                 :            :     // 0 -> print all pages (default if aPageRange is empty)
    1548                 :            :     // 1 -> print range according to PageRange
    1549                 :            :     // 2 -> print selection
    1550         [ #  # ]:          0 :     const sal_Int32 nContent = rOptions.getIntValue( "PrintContent", 0 );
    1551         [ #  # ]:          0 :     if (nContent == 1)
    1552         [ #  # ]:          0 :         aPageRange = rOptions.getStringValue( "PageRange", rtl::OUString() );
    1553         [ #  # ]:          0 :     if (aPageRange.isEmpty())    // empty string -> print all
    1554                 :            :     {
    1555                 :            :         // set page range to print to 'all pages'
    1556                 :          0 :         aPageRange = OUString::valueOf( (sal_Int32)1 );
    1557                 :          0 :         aPageRange += OUString::valueOf( (sal_Unicode)'-');
    1558                 :          0 :         aPageRange += OUString::valueOf( nDocPageCount );
    1559                 :            :     }
    1560         [ #  # ]:          0 :     StringRangeEnumerator aRange( aPageRange, 1, nDocPageCount, 0 );
    1561                 :            : 
    1562         [ #  # ]:          0 :     if ( aRange.size() <= 0)
    1563                 :            :         return;
    1564                 :            : 
    1565         [ #  # ]:          0 :     const SwPageFrm *pStPage  = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
    1566                 :          0 :     sal_Int32 i = 0;
    1567 [ #  # ][ #  # ]:          0 :     for ( i = 1; pStPage && i < nDocPageCount; ++i )
                 [ #  # ]
    1568                 :          0 :         pStPage = (SwPageFrm*)pStPage->GetNext();
    1569         [ #  # ]:          0 :     if ( !pStPage )          // dann wars das
    1570                 :            :         return;
    1571                 :            : 
    1572                 :            :     // currently for prospect printing all pages are valid to be printed
    1573                 :            :     // thus we add them all to the respective map and set for later use
    1574                 :          0 :     sal_Int32 nPageNum = 0;
    1575         [ #  # ]:          0 :     const SwPageFrm *pPageFrm  = dynamic_cast<const SwPageFrm*>( rLayout.Lower() );
    1576 [ #  # ][ #  # ]:          0 :     while( pPageFrm && nPageNum < nDocPageCount )
                 [ #  # ]
    1577                 :            :     {
    1578                 :            :         OSL_ENSURE( pPageFrm, "Empty page frame. How are we going to print this?" );
    1579                 :          0 :         ++nPageNum;
    1580         [ #  # ]:          0 :         rValidPagesSet.insert( nPageNum );
    1581         [ #  # ]:          0 :         validStartFrms[ nPageNum ] = pPageFrm;
    1582                 :          0 :         pPageFrm = (SwPageFrm*)pPageFrm->GetNext();
    1583                 :            : 
    1584 [ #  # ][ #  # ]:          0 :         rPrinterPaperTrays[ nPageNum ] = lcl_GetPaperBin( pStPage );
    1585                 :            :     }
    1586                 :            :     OSL_ENSURE( nPageNum == nDocPageCount, "unexpected number of pages" );
    1587                 :            : 
    1588                 :            :     // properties to take into account when calcualting the set of pages
    1589                 :            :     // Note: here bPrintLeftPages and bPrintRightPages refer to the (virtual) resulting pages
    1590                 :            :     //      of the prospect!
    1591         [ #  # ]:          0 :     bool bPrintLeftPages     = rOptions.IsPrintLeftPages();
    1592         [ #  # ]:          0 :     bool bPrintRightPages    = rOptions.IsPrintRightPages();
    1593         [ #  # ]:          0 :     bool bPrintProspectRTL = rOptions.getIntValue( "PrintProspectRTL",  0 ) ? true : false;
    1594                 :            : 
    1595                 :            :     // get pages for prospect printing according to the 'PageRange'
    1596                 :            :     // (duplicates and any order allowed!)
    1597         [ #  # ]:          0 :     std::vector< sal_Int32 > aPagesToPrint;
    1598                 :            :     StringRangeEnumerator::getRangesFromString(
    1599         [ #  # ]:          0 :             aPageRange, aPagesToPrint, 1, nDocPageCount, 0 );
    1600                 :            : 
    1601         [ #  # ]:          0 :     if (aPagesToPrint.empty())
    1602                 :            :         return;
    1603                 :            : 
    1604                 :            :     // now fill the vector for calculating the page pairs with the start frames
    1605                 :            :     // from the above obtained vector
    1606         [ #  # ]:          0 :     std::vector< const SwPageFrm * > aVec;
    1607         [ #  # ]:          0 :     for ( i = 0; i < sal_Int32(aPagesToPrint.size()); ++i)
    1608                 :            :     {
    1609         [ #  # ]:          0 :         const sal_Int32 nPage = aPagesToPrint[i];
    1610         [ #  # ]:          0 :         const SwPageFrm *pFrm = validStartFrms[ nPage ];
    1611         [ #  # ]:          0 :         aVec.push_back( pFrm );
    1612                 :            :     }
    1613                 :            : 
    1614                 :            :     // just one page is special ...
    1615         [ #  # ]:          0 :     if ( 1 == aVec.size() )
    1616 [ #  # ][ #  # ]:          0 :         aVec.insert( aVec.begin() + 1, 0 ); // insert a second empty page
    1617                 :            :     else
    1618                 :            :     {
    1619                 :            :         // now extend the number of pages to fit a multiple of 4
    1620                 :            :         // (4 'normal' pages are needed for a single prospect paper
    1621                 :            :         //  with back and front)
    1622         [ #  # ]:          0 :         while( aVec.size() & 3 )
    1623         [ #  # ]:          0 :             aVec.push_back( 0 );
    1624                 :            :     }
    1625                 :            : 
    1626                 :            :     // make sure that all pages are in correct order
    1627                 :          0 :     sal_uInt16 nSPg = 0, nEPg = aVec.size(), nStep = 1;
    1628         [ #  # ]:          0 :     if ( 0 == (nEPg & 1 ))      // there are no uneven ones!
    1629                 :          0 :         --nEPg;
    1630                 :            : 
    1631         [ #  # ]:          0 :     if ( !bPrintLeftPages )
    1632                 :          0 :         ++nStep;
    1633         [ #  # ]:          0 :     else if ( !bPrintRightPages )
    1634                 :            :     {
    1635                 :          0 :         ++nStep;
    1636                 :          0 :         ++nSPg, --nEPg;
    1637                 :            :     }
    1638                 :            : 
    1639                 :            :     // the number of 'virtual' pages to be printed
    1640                 :          0 :     sal_Int32 nCntPage = (( nEPg - nSPg ) / ( 2 * nStep )) + 1;
    1641                 :            : 
    1642 [ #  # ][ #  # ]:          0 :     for ( sal_uInt16 nPrintCount = 0; nSPg < nEPg &&
                 [ #  # ]
    1643                 :            :             nPrintCount < nCntPage; ++nPrintCount )
    1644                 :            :     {
    1645                 :          0 :         pStPage = aVec[ nSPg ];
    1646         [ #  # ]:          0 :         const SwPageFrm* pNxtPage = nEPg < aVec.size() ? aVec[ nEPg ] : 0;
    1647                 :            : 
    1648         [ #  # ]:          0 :         short nRtlOfs = bPrintProspectRTL ? 1 : 0;
    1649         [ #  # ]:          0 :         if ( 0 == (( nSPg + nRtlOfs) & 1 ) )     // switch for odd number in LTR, even number in RTL
    1650                 :            :         {
    1651                 :          0 :             const SwPageFrm* pTmp = pStPage;
    1652                 :          0 :             pStPage = pNxtPage;
    1653                 :          0 :             pNxtPage = pTmp;
    1654                 :            :         }
    1655                 :            : 
    1656                 :          0 :         sal_Int32 nFirst = -1, nSecond = -1;
    1657         [ #  # ]:          0 :         for ( int nC = 0; nC < 2; ++nC )
    1658                 :            :         {
    1659                 :          0 :             sal_Int32 nPage = -1;
    1660         [ #  # ]:          0 :             if ( pStPage )
    1661                 :          0 :                 nPage = pStPage->GetPhyPageNum();
    1662         [ #  # ]:          0 :             if (nC == 0)
    1663                 :          0 :                 nFirst  = nPage;
    1664                 :            :             else
    1665                 :          0 :                 nSecond = nPage;
    1666                 :            : 
    1667                 :          0 :             pStPage = pNxtPage;
    1668                 :            :         }
    1669 [ #  # ][ #  # ]:          0 :         rPagePairs.push_back( std::pair< sal_Int32, sal_Int32 >(nFirst, nSecond) );
    1670                 :            : 
    1671                 :          0 :         nSPg = nSPg + nStep;
    1672                 :          0 :         nEPg = nEPg - nStep;
    1673                 :            :     }
    1674 [ #  # ][ #  # ]:          0 :     OSL_ENSURE( size_t(nCntPage) == rPagePairs.size(), "size mismatch for number of page pairs" );
         [ #  # ][ #  # ]
    1675                 :            : 
    1676                 :            :     // luckily prospect printing does not make use of post-its so far,
    1677                 :            :     // thus we are done here.
    1678                 :            : }
    1679                 :            : 
    1680                 :            : /*************************************************************************
    1681                 :            :  *            void UpdateDocStat();
    1682                 :            :  *************************************************************************/
    1683                 :       1456 : void SwDoc::UpdateDocStat()
    1684                 :            : {
    1685         [ +  + ]:       1456 :     if( pDocStat->bModified )
    1686                 :            :     {
    1687         [ +  - ]:       1447 :         pDocStat->Reset();
    1688                 :       1447 :         pDocStat->nPara = 0;        // default is 1!
    1689                 :            :         SwNode* pNd;
    1690                 :            : 
    1691 [ +  - ][ +  + ]:      22932 :         for( sal_uLong i = GetNodes().Count(); i; )
    1692                 :            :         {
    1693 [ +  - ][ +  - ]:      21485 :             switch( ( pNd = GetNodes()[ --i ])->GetNodeType() )
           [ +  +  +  +  
                   +  + ]
    1694                 :            :             {
    1695                 :            :             case ND_TEXTNODE:
    1696 [ +  - ][ +  - ]:       4622 :                 ((SwTxtNode*)pNd)->CountWords( *pDocStat, 0, ((SwTxtNode*)pNd)->GetTxt().Len() );
                 [ +  - ]
    1697                 :       4622 :                 break;
    1698                 :         61 :             case ND_TABLENODE:      ++pDocStat->nTbl;   break;
    1699                 :         36 :             case ND_GRFNODE:        ++pDocStat->nGrf;   break;
    1700                 :         11 :             case ND_OLENODE:        ++pDocStat->nOLE;   break;
    1701                 :        113 :             case ND_SECTIONNODE:    break;
    1702                 :            :             }
    1703                 :            :         }
    1704                 :            : 
    1705                 :            :         // #i93174#: notes contain paragraphs that are not nodes
    1706                 :            :         {
    1707         [ +  - ]:       1447 :             SwFieldType * const pPostits( GetSysFldType(RES_POSTITFLD) );
    1708         [ +  - ]:       1447 :             SwIterator<SwFmtFld,SwFieldType> aIter( *pPostits );
    1709 [ +  - ][ +  - ]:       1450 :             for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld;  pFmtFld = aIter.Next() )
                 [ +  + ]
    1710                 :            :             {
    1711 [ +  - ][ +  - ]:          3 :                 if (pFmtFld->IsFldInDoc())
    1712                 :            :                 {
    1713                 :            :                     SwPostItField const * const pField(
    1714                 :          3 :                         static_cast<SwPostItField const*>(pFmtFld->GetFld()));
    1715         [ +  - ]:          3 :                     pDocStat->nAllPara += pField->GetNumberOfParagraphs();
    1716                 :            :                 }
    1717         [ +  - ]:       1447 :             }
    1718                 :            :         }
    1719                 :            : 
    1720 [ +  - ][ +  + ]:       1447 :         pDocStat->nPage     = GetCurrentLayout() ? GetCurrentLayout()->GetPageNum() : 0;    //swmod 080218
                 [ +  - ]
    1721                 :       1447 :         pDocStat->bModified = sal_False;
    1722                 :            : 
    1723 [ +  + ][ +  - ]:       1447 :         com::sun::star::uno::Sequence < com::sun::star::beans::NamedValue > aStat( pDocStat->nPage ? 8 : 7);
    1724                 :       1447 :         sal_Int32 n=0;
    1725 [ +  - ][ +  - ]:       1447 :         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TableCount"));
    1726 [ +  - ][ +  - ]:       1447 :         aStat[n++].Value <<= (sal_Int32)pDocStat->nTbl;
    1727 [ +  - ][ +  - ]:       1447 :         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImageCount"));
    1728 [ +  - ][ +  - ]:       1447 :         aStat[n++].Value <<= (sal_Int32)pDocStat->nGrf;
    1729 [ +  - ][ +  - ]:       1447 :         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ObjectCount"));
    1730 [ +  - ][ +  - ]:       1447 :         aStat[n++].Value <<= (sal_Int32)pDocStat->nOLE;
    1731         [ +  + ]:       1447 :         if ( pDocStat->nPage )
    1732                 :            :         {
    1733 [ +  - ][ +  - ]:       1439 :             aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PageCount"));
    1734 [ +  - ][ +  - ]:       1439 :             aStat[n++].Value <<= (sal_Int32)pDocStat->nPage;
    1735                 :            :         }
    1736 [ +  - ][ +  - ]:       1447 :         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParagraphCount"));
    1737 [ +  - ][ +  - ]:       1447 :         aStat[n++].Value <<= (sal_Int32)pDocStat->nPara;
    1738 [ +  - ][ +  - ]:       1447 :         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("WordCount"));
    1739 [ +  - ][ +  - ]:       1447 :         aStat[n++].Value <<= (sal_Int32)pDocStat->nWord;
    1740 [ +  - ][ +  - ]:       1447 :         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharacterCount"));
    1741 [ +  - ][ +  - ]:       1447 :         aStat[n++].Value <<= (sal_Int32)pDocStat->nChar;
    1742 [ +  - ][ +  - ]:       1447 :         aStat[n].Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NonWhitespaceCharacterCount"));
    1743 [ +  - ][ +  - ]:       1447 :         aStat[n++].Value <<= (sal_Int32)pDocStat->nCharExcludingSpaces;
    1744                 :            : 
    1745                 :            :         // For e.g. autotext documents there is no pSwgInfo (#i79945)
    1746                 :       1447 :         SfxObjectShell * const pObjShell( GetDocShell() );
    1747         [ +  - ]:       1447 :         if (pObjShell)
    1748                 :            :         {
    1749                 :            :             const uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
    1750 [ +  - ][ +  - ]:       1447 :                 pObjShell->GetModel(), uno::UNO_QUERY_THROW);
    1751                 :            :             const uno::Reference<document::XDocumentProperties> xDocProps(
    1752 [ +  - ][ +  - ]:       1447 :                 xDPS->getDocumentProperties());
    1753                 :            :             // #i96786#: do not set modified flag when updating statistics
    1754         [ +  - ]:       1447 :             const bool bDocWasModified( IsModified() );
    1755         [ +  - ]:       1447 :             const ModifyBlocker_Impl b(pObjShell);
    1756 [ +  - ][ +  - ]:       1447 :             xDocProps->setDocumentStatistics(aStat);
    1757         [ +  + ]:       1447 :             if (!bDocWasModified)
    1758                 :            :             {
    1759         [ +  - ]:        774 :                 ResetModified();
    1760         [ +  - ]:       1447 :             }
    1761                 :            :         }
    1762                 :            : 
    1763                 :            :         // optionally update stat. fields
    1764         [ +  - ]:       1447 :         SwFieldType *pType = GetSysFldType(RES_DOCSTATFLD);
    1765 [ +  - ][ +  - ]:       1447 :         pType->UpdateFlds();
    1766                 :            :     }
    1767                 :       1456 : }
    1768                 :            : 
    1769                 :            : // Document - info
    1770                 :       2933 : void SwDoc::DocInfoChgd( )
    1771                 :            : {
    1772                 :       2933 :     GetSysFldType( RES_DOCINFOFLD )->UpdateFlds();
    1773                 :       2933 :     GetSysFldType( RES_TEMPLNAMEFLD )->UpdateFlds();
    1774                 :       2933 :     SetModified();
    1775                 :       2933 : }
    1776                 :            : 
    1777                 :            : // Return the reference in the doc for the name
    1778                 :        124 : const SwFmtRefMark* SwDoc::GetRefMark( const String& rName ) const
    1779                 :            : {
    1780                 :            :     const SfxPoolItem* pItem;
    1781                 :        124 :     sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK );
    1782         [ +  + ]:        902 :     for( sal_uInt32 n = 0; n < nMaxItems; ++n )
    1783                 :            :     {
    1784         [ +  + ]:        894 :         if( 0 == (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n ) ))
    1785                 :        234 :             continue;
    1786                 :            : 
    1787                 :        660 :         const SwFmtRefMark* pFmtRef = (SwFmtRefMark*)pItem;
    1788                 :        660 :         const SwTxtRefMark* pTxtRef = pFmtRef->GetTxtRefMark();
    1789 [ +  - ][ +  - ]:       1558 :         if( pTxtRef && &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() &&
         [ +  + ][ +  + ]
                 [ +  + ]
    1790 [ +  - ][ +  - ]:        898 :             rName.Equals( pFmtRef->GetRefName() ) )
         [ +  + ][ #  # ]
    1791                 :        116 :             return pFmtRef;
    1792                 :            :     }
    1793                 :        124 :     return 0;
    1794                 :            : }
    1795                 :            : 
    1796                 :            : // Return the RefMark per index - for Uno
    1797                 :          8 : const SwFmtRefMark* SwDoc::GetRefMark( sal_uInt16 nIndex ) const
    1798                 :            : {
    1799                 :            :     const SfxPoolItem* pItem;
    1800                 :            :     const SwTxtRefMark* pTxtRef;
    1801                 :          8 :     const SwFmtRefMark* pRet = 0;
    1802                 :            : 
    1803                 :          8 :     sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK );
    1804                 :          8 :     sal_uInt32 nCount = 0;
    1805         [ +  + ]:         48 :     for( sal_uInt32 n = 0; n < nMaxItems; ++n )
    1806         [ +  + ]:         60 :         if( 0 != (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n )) &&
           [ +  +  +  - ]
                 [ +  + ]
    1807                 :            :             0 != (pTxtRef = ((SwFmtRefMark*)pItem)->GetTxtRefMark()) &&
    1808                 :         14 :             &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() )
    1809                 :            :         {
    1810         [ +  + ]:         14 :             if(nCount == nIndex)
    1811                 :            :             {
    1812                 :          6 :                 pRet = (SwFmtRefMark*)pItem;
    1813                 :          6 :                 break;
    1814                 :            :             }
    1815                 :          8 :             nCount++;
    1816                 :            :         }
    1817                 :          8 :    return pRet;
    1818                 :            : }
    1819                 :            : 
    1820                 :            : // Return the names of all set references in the Doc
    1821                 :            : //JP 24.06.96: If the array pointer is 0, then just return whether a RefMark is set in the Doc
    1822                 :            : // OS 25.06.96: From now on we always return the reference count
    1823                 :          6 : sal_uInt16 SwDoc::GetRefMarks( std::vector<rtl::OUString>* pNames ) const
    1824                 :            : {
    1825                 :            :     const SfxPoolItem* pItem;
    1826                 :            :     const SwTxtRefMark* pTxtRef;
    1827                 :            : 
    1828                 :          6 :     sal_uInt32 nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_REFMARK );
    1829                 :          6 :     sal_uInt32 nCount = 0;
    1830         [ +  + ]:         42 :     for( sal_uInt32 n = 0; n < nMaxItems; ++n )
    1831         [ +  + ]:         48 :         if( 0 != (pItem = GetAttrPool().GetItem2( RES_TXTATR_REFMARK, n )) &&
           [ +  +  +  - ]
                 [ +  + ]
    1832                 :            :             0 != (pTxtRef = ((SwFmtRefMark*)pItem)->GetTxtRefMark()) &&
    1833                 :         12 :             &pTxtRef->GetTxtNode().GetNodes() == &GetNodes() )
    1834                 :            :         {
    1835         [ +  + ]:         12 :             if( pNames )
    1836                 :            :             {
    1837         [ +  - ]:          4 :                 String pTmp(((SwFmtRefMark*)pItem)->GetRefName());
    1838 [ +  - ][ +  - ]:          4 :                 pNames->insert(pNames->begin() + nCount, pTmp);
         [ +  - ][ +  - ]
    1839                 :            :             }
    1840                 :         12 :             nCount ++;
    1841                 :            :         }
    1842                 :            : 
    1843                 :          6 :     return nCount;
    1844                 :            : }
    1845                 :            : 
    1846                 :        990 : bool SwDoc::IsLoaded() const
    1847                 :            : {
    1848                 :        990 :     return mbLoaded;
    1849                 :            : }
    1850                 :            : 
    1851                 :       2183 : bool SwDoc::IsUpdateExpFld() const
    1852                 :            : {
    1853                 :       2183 :     return mbUpdateExpFld;
    1854                 :            : }
    1855                 :            : 
    1856                 :        935 : bool SwDoc::IsNewDoc() const
    1857                 :            : {
    1858                 :        935 :     return mbNewDoc;
    1859                 :            : }
    1860                 :            : 
    1861                 :          0 : bool SwDoc::IsPageNums() const
    1862                 :            : {
    1863                 :          0 :   return mbPageNums;
    1864                 :            : }
    1865                 :            : 
    1866                 :          0 : void SwDoc::SetPageNums(bool b)
    1867                 :            : {
    1868                 :          0 :     mbPageNums = b;
    1869                 :          0 : }
    1870                 :            : 
    1871                 :          0 : void SwDoc::SetNewDoc(bool b)
    1872                 :            : {
    1873                 :          0 :     mbNewDoc = b;
    1874                 :          0 : }
    1875                 :            : 
    1876                 :        138 : void SwDoc::SetUpdateExpFldStat(bool b)
    1877                 :            : {
    1878                 :        138 :     mbUpdateExpFld = b;
    1879                 :        138 : }
    1880                 :            : 
    1881                 :        154 : void SwDoc::SetLoaded(bool b)
    1882                 :            : {
    1883                 :        154 :     mbLoaded = b;
    1884                 :        154 : }
    1885                 :            : 
    1886                 :      26215 : bool SwDoc::IsModified() const
    1887                 :            : {
    1888                 :      26215 :     return mbModified;
    1889                 :            : }
    1890                 :            : 
    1891                 :            : //Load document from fdo#42534 under valgrind, drag the scrollbar down so full
    1892                 :            : //document layout is triggered. Close document before layout has completed, and
    1893                 :            : //SwAnchoredObject objects deleted by the deletion of layout remain referenced
    1894                 :            : //by the SwLayouter
    1895                 :     252639 : void SwDoc::ClearSwLayouterEntries()
    1896                 :            : {
    1897                 :     252639 :     SwLayouter::ClearMovedFwdFrms( *this );
    1898                 :     252639 :     SwLayouter::ClearObjsTmpConsiderWrapInfluence( *this );
    1899                 :            :     // #i65250#
    1900                 :     252639 :     SwLayouter::ClearMoveBwdLayoutInfo( *this );
    1901                 :     252639 : }
    1902                 :            : 
    1903                 :     251408 : void SwDoc::SetModified()
    1904                 :            : {
    1905                 :     251408 :     ClearSwLayouterEntries();
    1906                 :            :     // give the old and new modified state to the link
    1907                 :            :     //  Bit 0:  -> old state
    1908                 :            :     //  Bit 1:  -> new state
    1909         [ +  + ]:     251408 :     long nCall = mbModified ? 3 : 2;
    1910                 :     251408 :     mbModified = sal_True;
    1911                 :     251408 :     pDocStat->bModified = sal_True;
    1912         [ +  + ]:     251408 :     if( aOle2Link.IsSet() )
    1913                 :            :     {
    1914                 :      84526 :         mbInCallModified = sal_True;
    1915                 :      84526 :         aOle2Link.Call( (void*)nCall );
    1916                 :      84526 :         mbInCallModified = sal_False;
    1917                 :            :     }
    1918                 :            : 
    1919 [ -  + ][ #  # ]:     251408 :     if( pACEWord && !pACEWord->IsDeleted() )
                 [ -  + ]
    1920         [ #  # ]:          0 :         delete pACEWord, pACEWord = 0;
    1921                 :     251408 : }
    1922                 :            : 
    1923                 :      13418 : void SwDoc::ResetModified()
    1924                 :            : {
    1925                 :            :     // give the old and new modified state to the link
    1926                 :            :     //  Bit 0:  -> old state
    1927                 :            :     //  Bit 1:  -> new state
    1928         [ +  + ]:      13418 :     long nCall = mbModified ? 1 : 0;
    1929                 :      13418 :     mbModified = sal_False;
    1930                 :            :     // If there is already a document statistic, we assume that
    1931                 :            :     // it is correct. In this case we reset the modified flag.
    1932         [ +  + ]:      13418 :     if ( 0 != pDocStat->nCharExcludingSpaces )
    1933                 :        400 :         pDocStat->bModified = sal_False;
    1934                 :      13418 :     GetIDocumentUndoRedo().SetUndoNoModifiedPosition();
    1935 [ +  + ][ +  + ]:      13418 :     if( nCall && aOle2Link.IsSet() )
                 [ +  + ]
    1936                 :            :     {
    1937                 :       7174 :         mbInCallModified = sal_True;
    1938                 :       7174 :         aOle2Link.Call( (void*)nCall );
    1939                 :       7174 :         mbInCallModified = sal_False;
    1940                 :            :     }
    1941                 :      13418 : }
    1942                 :            : 
    1943                 :         12 : void SwDoc::ReRead( SwPaM& rPam, const String& rGrfName,
    1944                 :            :                     const String& rFltName, const Graphic* pGraphic,
    1945                 :            :                     const GraphicObject* pGrafObj )
    1946                 :            : {
    1947                 :            :     SwGrfNode *pGrfNd;
    1948   [ -  +  #  #  :         24 :     if( ( !rPam.HasMark()
           +  - ][ +  - ]
    1949                 :          0 :          || rPam.GetPoint()->nNode.GetIndex() == rPam.GetMark()->nNode.GetIndex() )
    1950                 :         12 :          && 0 != ( pGrfNd = rPam.GetPoint()->nNode.GetNode().GetGrfNode() ) )
    1951                 :            :     {
    1952         [ +  - ]:         12 :         if (GetIDocumentUndoRedo().DoesUndo())
    1953                 :            :         {
    1954         [ +  - ]:         12 :             GetIDocumentUndoRedo().AppendUndo(new SwUndoReRead(rPam, *pGrfNd));
    1955                 :            :         }
    1956                 :            : 
    1957                 :            :         // Because we don't know if we can mirror the graphic, the mirror attribute is always reset
    1958         [ +  + ]:         24 :         if( RES_MIRROR_GRAPH_DONT != pGrfNd->GetSwAttrSet().
    1959                 :         12 :                                                 GetMirrorGrf().GetValue() )
    1960         [ +  - ]:          2 :             pGrfNd->SetAttr( SwMirrorGrf() );
    1961                 :            : 
    1962                 :         12 :         pGrfNd->ReRead( rGrfName, rFltName, pGraphic, pGrafObj, sal_True );
    1963                 :         12 :         SetModified();
    1964                 :            :     }
    1965                 :         12 : }
    1966                 :            : 
    1967                 :         88 : sal_Bool lcl_SpellAndGrammarAgain( const SwNodePtr& rpNd, void* pArgs )
    1968                 :            : {
    1969                 :         88 :     SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
    1970                 :         88 :     sal_Bool bOnlyWrong = *(sal_Bool*)pArgs;
    1971         [ +  + ]:         88 :     if( pTxtNode )
    1972                 :            :     {
    1973         [ -  + ]:          8 :         if( bOnlyWrong )
    1974                 :            :         {
    1975   [ #  #  #  # ]:          0 :             if( pTxtNode->GetWrong() &&
                 [ #  # ]
    1976                 :          0 :                 pTxtNode->GetWrong()->InvalidateWrong() )
    1977                 :          0 :                 pTxtNode->SetWrongDirty( true );
    1978   [ #  #  #  # ]:          0 :             if( pTxtNode->GetGrammarCheck() &&
                 [ #  # ]
    1979                 :          0 :                 pTxtNode->GetGrammarCheck()->InvalidateWrong() )
    1980                 :          0 :                 pTxtNode->SetGrammarCheckDirty( true );
    1981                 :            :         }
    1982                 :            :         else
    1983                 :            :         {
    1984                 :          8 :             pTxtNode->SetWrongDirty( true );
    1985         [ -  + ]:          8 :             if( pTxtNode->GetWrong() )
    1986                 :          0 :                 pTxtNode->GetWrong()->SetInvalid( 0, STRING_LEN );
    1987                 :          8 :             pTxtNode->SetGrammarCheckDirty( true );
    1988         [ -  + ]:          8 :             if( pTxtNode->GetGrammarCheck() )
    1989                 :          0 :                 pTxtNode->GetGrammarCheck()->SetInvalid( 0, STRING_LEN );
    1990                 :            :         }
    1991                 :            :     }
    1992                 :         88 :     return sal_True;
    1993                 :            : }
    1994                 :            : 
    1995                 :         88 : sal_Bool lcl_CheckSmartTagsAgain( const SwNodePtr& rpNd, void*  )
    1996                 :            : {
    1997                 :         88 :     SwTxtNode *pTxtNode = (SwTxtNode*)rpNd->GetTxtNode();
    1998                 :            : //  sal_Bool bOnlyWrong = *(sal_Bool*)pArgs;
    1999         [ +  + ]:         88 :     if( pTxtNode )
    2000                 :            :     {
    2001                 :          8 :         pTxtNode->SetSmartTagDirty( true );
    2002         [ -  + ]:          8 :         if( pTxtNode->GetSmartTags() )
    2003                 :            :         {
    2004                 :            : //            if ( bOnlyWrong ) // only some smart tag types have been enabled or disabled
    2005                 :            : //              pTxtNode->GetSmartTags()->SetInvalid( 0, STRING_LEN );
    2006                 :            : //            else // smart tags all have been enabled or disabled
    2007                 :          0 :                 pTxtNode->SetSmartTags( NULL );
    2008                 :            :         }
    2009                 :            :     }
    2010                 :         88 :     return sal_True;
    2011                 :            : }
    2012                 :            : 
    2013                 :            : /*************************************************************************
    2014                 :            :  * SwDoc::SpellItAgainSam( sal_Bool bInvalid, sal_Bool bOnlyWrong )
    2015                 :            :  *
    2016                 :            :  * Re-triggers spelling in the idle handler.
    2017                 :            :  * If bInvalid is passed with sal_True, the WrongLists in all nodes are invalidated
    2018                 :            :  * and the SpellInvalid flag is set on all pages.
    2019                 :            :  * bOnlyWrong controls whether only the areas with wrong words are checked or the whole area.
    2020                 :            :  ************************************************************************/
    2021                 :          8 : void SwDoc::SpellItAgainSam( sal_Bool bInvalid, sal_Bool bOnlyWrong, sal_Bool bSmartTags )
    2022                 :            : {
    2023         [ +  - ]:          8 :     std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();//swmod 080307
    2024                 :            :     OSL_ENSURE( GetCurrentLayout(), "SpellAgain: Where's my RootFrm?" );
    2025         [ +  - ]:          8 :     if( bInvalid )
    2026                 :            :     {
    2027 [ +  - ][ +  - ]:          8 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::AllInvalidateSmartTagsOrSpelling),bSmartTags));//swmod 080305
                 [ +  - ]
    2028 [ +  - ][ +  - ]:          8 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::SetNeedGrammarCheck), true) );
                 [ +  - ]
    2029         [ +  - ]:          8 :         if ( bSmartTags )
    2030 [ +  - ][ +  - ]:          8 :             GetNodes().ForEach( lcl_CheckSmartTagsAgain, &bOnlyWrong );
    2031 [ +  - ][ +  - ]:          8 :         GetNodes().ForEach( lcl_SpellAndGrammarAgain, &bOnlyWrong );
    2032                 :            :     }
    2033                 :            : 
    2034 [ +  - ][ +  - ]:          8 :     std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::SetIdleFlags));//swmod 080307
    2035                 :          8 : }
    2036                 :            : 
    2037                 :          0 : void SwDoc::InvalidateAutoCompleteFlag()
    2038                 :            : {
    2039                 :          0 :     SwRootFrm* pTmpRoot = GetCurrentLayout();
    2040         [ #  # ]:          0 :     if( pTmpRoot )
    2041                 :            :     {
    2042         [ #  # ]:          0 :         std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
    2043 [ #  # ][ #  # ]:          0 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllInvalidateAutoCompleteWords));//swmod 080305
    2044 [ #  # ][ #  # ]:          0 :         for( sal_uLong nNd = 1, nCnt = GetNodes().Count(); nNd < nCnt; ++nNd )
    2045                 :            :         {
    2046 [ #  # ][ #  # ]:          0 :             SwTxtNode* pTxtNode = GetNodes()[ nNd ]->GetTxtNode();
    2047 [ #  # ][ #  # ]:          0 :             if ( pTxtNode ) pTxtNode->SetAutoCompleteWordDirty( true );
    2048                 :            :         }
    2049                 :            : 
    2050 [ #  # ][ #  # ]:          0 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::SetIdleFlags));//swmod 080228
    2051                 :            :     }   //swmod 080219
    2052                 :          0 : }
    2053                 :            : 
    2054                 :          0 : const SwFmtINetFmt* SwDoc::FindINetAttr( const String& rName ) const
    2055                 :            : {
    2056                 :            :     const SwFmtINetFmt* pItem;
    2057                 :            :     const SwTxtINetFmt* pTxtAttr;
    2058                 :            :     const SwTxtNode* pTxtNd;
    2059                 :          0 :     sal_uInt32 n, nMaxItems = GetAttrPool().GetItemCount2( RES_TXTATR_INETFMT );
    2060         [ #  # ]:          0 :     for( n = 0; n < nMaxItems; ++n )
    2061   [ #  #  #  # ]:          0 :         if( 0 != (pItem = (SwFmtINetFmt*)GetAttrPool().GetItem2(
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    2062                 :          0 :             RES_TXTATR_INETFMT, n ) ) &&
    2063                 :          0 :             pItem->GetName().Equals( rName ) &&
    2064                 :            :             0 != ( pTxtAttr = pItem->GetTxtINetFmt()) &&
    2065                 :            :             0 != ( pTxtNd = pTxtAttr->GetpTxtNode() ) &&
    2066                 :          0 :             &pTxtNd->GetNodes() == &GetNodes() )
    2067                 :            :         {
    2068                 :          0 :             return pItem;
    2069                 :            :         }
    2070                 :            : 
    2071                 :          0 :     return 0;
    2072                 :            : }
    2073                 :            : 
    2074                 :          0 : void SwDoc::Summary( SwDoc* pExtDoc, sal_uInt8 nLevel, sal_uInt8 nPara, sal_Bool bImpress )
    2075                 :            : {
    2076                 :          0 :     const SwOutlineNodes& rOutNds = GetNodes().GetOutLineNds();
    2077 [ #  # ][ #  # ]:          0 :     if( pExtDoc && !rOutNds.empty() )
                 [ #  # ]
    2078                 :            :     {
    2079                 :            :         sal_uInt16 i;
    2080         [ #  # ]:          0 :         ::StartProgress( STR_STATSTR_SUMMARY, 0, rOutNds.size(), GetDocShell() );
    2081 [ #  # ][ #  # ]:          0 :         SwNodeIndex aEndOfDoc( pExtDoc->GetNodes().GetEndOfContent(), -1 );
    2082         [ #  # ]:          0 :         for( i = 0; i < rOutNds.size(); ++i )
    2083                 :            :         {
    2084         [ #  # ]:          0 :             ::SetProgressState( i, GetDocShell() );
    2085         [ #  # ]:          0 :             const sal_uLong nIndex = rOutNds[ i ]->GetIndex();
    2086                 :            : 
    2087 [ #  # ][ #  # ]:          0 :             const int nLvl = ((SwTxtNode*)GetNodes()[ nIndex ])->GetAttrOutlineLevel()-1;//<-end,zhaojianwei
         [ #  # ][ #  # ]
    2088         [ #  # ]:          0 :             if( nLvl > nLevel )
    2089                 :          0 :                 continue;
    2090                 :          0 :             sal_uInt16 nEndOfs = 1;
    2091                 :          0 :             sal_uInt8 nWish = nPara;
    2092                 :          0 :             sal_uLong nNextOutNd = i + 1 < (sal_uInt16)rOutNds.size() ?
    2093 [ #  # ][ #  # ]:          0 :                 rOutNds[ i + 1 ]->GetIndex() : GetNodes().Count();
                 [ #  # ]
    2094                 :          0 :             sal_Bool bKeep = sal_False;
    2095 [ #  # ][ #  # ]:          0 :             while( ( nWish || bKeep ) && nIndex + nEndOfs < nNextOutNd &&
           [ #  #  #  # ]
                 [ #  # ]
    2096 [ #  # ][ #  # ]:          0 :                    GetNodes()[ nIndex + nEndOfs ]->IsTxtNode() )
    2097                 :            :             {
    2098 [ #  # ][ #  # ]:          0 :                 SwTxtNode* pTxtNode = (SwTxtNode*)GetNodes()[ nIndex+nEndOfs ];
                 [ #  # ]
    2099 [ #  # ][ #  # ]:          0 :                 if( pTxtNode->GetTxt().Len() && nWish )
                 [ #  # ]
    2100                 :          0 :                     --nWish;
    2101 [ #  # ][ #  # ]:          0 :                 bKeep = pTxtNode->GetSwAttrSet().GetKeep().GetValue();
    2102                 :          0 :                 ++nEndOfs;
    2103                 :            :             }
    2104                 :            : 
    2105 [ #  # ][ #  # ]:          0 :             SwNodeRange aRange( *rOutNds[ i ], 0, *rOutNds[ i ], nEndOfs );
                 [ #  # ]
    2106 [ #  # ][ #  # ]:          0 :             GetNodes()._Copy( aRange, aEndOfDoc );
    2107         [ #  # ]:          0 :         }
    2108                 :          0 :         const SwTxtFmtColls *pColl = pExtDoc->GetTxtFmtColls();
    2109         [ #  # ]:          0 :         for( i = 0; i < pColl->size(); ++i )
    2110 [ #  # ][ #  # ]:          0 :             (*pColl)[ i ]->ResetFmtAttr( RES_PAGEDESC, RES_BREAK );
    2111 [ #  # ][ #  # ]:          0 :         SwNodeIndex aIndx( pExtDoc->GetNodes().GetEndOfExtras() );
    2112         [ #  # ]:          0 :         ++aEndOfDoc;
    2113         [ #  # ]:          0 :         while( aIndx < aEndOfDoc )
    2114                 :            :         {
    2115                 :            :             SwNode *pNode;
    2116                 :          0 :             sal_Bool bDelete = sal_False;
    2117         [ #  # ]:          0 :             if( (pNode = &aIndx.GetNode())->IsTxtNode() )
    2118                 :            :             {
    2119         [ #  # ]:          0 :                 SwTxtNode *pNd = (SwTxtNode*)pNode;
    2120 [ #  # ][ #  # ]:          0 :                 if( pNd->HasSwAttrSet() )
    2121         [ #  # ]:          0 :                     pNd->ResetAttr( RES_PAGEDESC, RES_BREAK );
    2122         [ #  # ]:          0 :                 if( bImpress )
    2123                 :            :                 {
    2124                 :          0 :                     SwTxtFmtColl* pMyColl = pNd->GetTxtColl();
    2125                 :            : 
    2126                 :            :                     const sal_uInt16 nHeadLine = static_cast<sal_uInt16>(
    2127                 :          0 :                                 !pMyColl->IsAssignedToListLevelOfOutlineStyle() //<-end,zhaojianwei
    2128                 :            :                                 ? RES_POOLCOLL_HEADLINE2
    2129         [ #  # ]:          0 :                                 : RES_POOLCOLL_HEADLINE1 );
    2130         [ #  # ]:          0 :                     pMyColl = pExtDoc->GetTxtCollFromPool( nHeadLine );
    2131         [ #  # ]:          0 :                     pNd->ChgFmtColl( pMyColl );
    2132                 :            :                 }
    2133         [ #  # ]:          0 :                 if( !pNd->Len() &&
           [ #  #  #  # ]
                 [ #  # ]
    2134                 :          0 :                     pNd->StartOfSectionIndex()+2 < pNd->EndOfSectionIndex() )
    2135                 :            :                 {
    2136                 :          0 :                     bDelete = sal_True;
    2137 [ #  # ][ #  # ]:          0 :                     pExtDoc->GetNodes().Delete( aIndx );
    2138                 :            :                 }
    2139                 :            :             }
    2140         [ #  # ]:          0 :             if( !bDelete )
    2141         [ #  # ]:          0 :                 ++aIndx;
    2142                 :            :         }
    2143 [ #  # ][ #  # ]:          0 :         ::EndProgress( GetDocShell() );
                 [ #  # ]
    2144                 :            :     }
    2145                 :          0 : }
    2146                 :            : 
    2147                 :            : // Remove the invisible content from the document e.g. hidden areas, hidden paragraphs
    2148                 :          0 : bool SwDoc::RemoveInvisibleContent()
    2149                 :            : {
    2150                 :          0 :     sal_Bool bRet = sal_False;
    2151                 :          0 :     GetIDocumentUndoRedo().StartUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL );
    2152                 :            : 
    2153                 :            :     {
    2154                 :            :         SwTxtNode* pTxtNd;
    2155 [ #  # ][ #  # ]:          0 :         SwIterator<SwFmtFld,SwFieldType> aIter( *GetSysFldType( RES_HIDDENPARAFLD )  );
    2156 [ #  # ][ #  # ]:          0 :         for( SwFmtFld* pFmtFld = aIter.First(); pFmtFld;  pFmtFld = aIter.Next() )
                 [ #  # ]
    2157                 :            :         {
    2158   [ #  #  #  #  :          0 :             if( pFmtFld->GetTxtFld() &&
           #  # ][ #  # ]
         [ #  # ][ #  # ]
    2159                 :          0 :                 0 != ( pTxtNd = (SwTxtNode*)pFmtFld->GetTxtFld()->GetpTxtNode() ) &&
    2160         [ #  # ]:          0 :                 pTxtNd->GetpSwpHints() && pTxtNd->HasHiddenParaField() &&
    2161         [ #  # ]:          0 :                 &pTxtNd->GetNodes() == &GetNodes() )
    2162                 :            :             {
    2163                 :          0 :                 bRet = sal_True;
    2164         [ #  # ]:          0 :                 SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() );
    2165                 :            : 
    2166                 :            :                 // Remove hidden paragraph or delete contents:
    2167                 :            :                 // Delete contents if
    2168                 :            :                 // 1. removing the paragraph would result in an empty section or
    2169                 :            :                 // 2. if the paragraph is the last paragraph in the section and
    2170                 :            :                 //    there is no paragraph in front of the paragraph:
    2171   [ #  #  #  #  :          0 :                 if ( ( 2 == pTxtNd->EndOfSectionIndex() - pTxtNd->StartOfSectionIndex() ) ||
           #  # ][ #  # ]
    2172                 :          0 :                      ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() &&
    2173 [ #  # ][ #  # ]:          0 :                        !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) )
    2174                 :            :                 {
    2175         [ #  # ]:          0 :                     DeleteRange( aPam );
    2176                 :            :                 }
    2177                 :            :                 else
    2178                 :            :                 {
    2179         [ #  # ]:          0 :                     aPam.DeleteMark();
    2180         [ #  # ]:          0 :                     DelFullPara( aPam );
    2181         [ #  # ]:          0 :                 }
    2182                 :            :             }
    2183         [ #  # ]:          0 :         }
    2184                 :            :     }
    2185                 :            : 
    2186                 :            :     //
    2187                 :            :     // Remove any hidden paragraph (hidden text attribute)
    2188                 :            :     //
    2189         [ #  # ]:          0 :     for( sal_uLong n = GetNodes().Count(); n; )
    2190                 :            :     {
    2191                 :          0 :         SwTxtNode* pTxtNd = GetNodes()[ --n ]->GetTxtNode();
    2192         [ #  # ]:          0 :         if ( pTxtNd )
    2193                 :            :         {
    2194                 :          0 :             bool bRemoved = false;
    2195         [ #  # ]:          0 :             SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() );
    2196 [ #  # ][ #  # ]:          0 :             if ( pTxtNd->HasHiddenCharAttribute( true ) )
    2197                 :            :             {
    2198                 :          0 :                 bRemoved = sal_True;
    2199                 :          0 :                 bRet = sal_True;
    2200                 :            : 
    2201                 :            :                 // Remove hidden paragraph or delete contents:
    2202                 :            :                 // Delete contents if
    2203                 :            :                 // 1. removing the paragraph would result in an empty section or
    2204                 :            :                 // 2. if the paragraph is the last paragraph in the section and
    2205                 :            :                 //    there is no paragraph in front of the paragraph:
    2206                 :            : 
    2207   [ #  #  #  #  :          0 :                 if ( ( 2 == pTxtNd->EndOfSectionIndex() - pTxtNd->StartOfSectionIndex() ) ||
           #  # ][ #  # ]
    2208                 :          0 :                      ( 1 == pTxtNd->EndOfSectionIndex() - pTxtNd->GetIndex() &&
    2209 [ #  # ][ #  # ]:          0 :                        !GetNodes()[ pTxtNd->GetIndex() - 1 ]->GetTxtNode() ) )
    2210                 :            :                 {
    2211         [ #  # ]:          0 :                     DeleteRange( aPam );
    2212                 :            :                 }
    2213                 :            :                 else
    2214                 :            :                 {
    2215         [ #  # ]:          0 :                     aPam.DeleteMark();
    2216         [ #  # ]:          0 :                     DelFullPara( aPam );
    2217                 :            :                 }
    2218                 :            :             }
    2219 [ #  # ][ #  # ]:          0 :             else if ( pTxtNd->HasHiddenCharAttribute( false ) )
    2220                 :            :             {
    2221                 :          0 :                 bRemoved = sal_True;
    2222                 :          0 :                 bRet = sal_True;
    2223         [ #  # ]:          0 :                 SwScriptInfo::DeleteHiddenRanges( *pTxtNd );
    2224                 :            :             }
    2225                 :            : 
    2226                 :            :             // Footnotes/Frames may have been removed, therefore we have
    2227                 :            :             // to reset n:
    2228         [ #  # ]:          0 :             if ( bRemoved )
    2229         [ #  # ]:          0 :                 n = aPam.GetPoint()->nNode.GetIndex();
    2230                 :            :         }
    2231                 :            :     }
    2232                 :            : 
    2233                 :            :     {
    2234                 :            :         // Delete/empty all hidden areas
    2235         [ #  # ]:          0 :         SwSectionFmts aSectFmts;
    2236                 :          0 :         SwSectionFmts& rSectFmts = GetSections();
    2237                 :            :         sal_uInt16 n;
    2238                 :            : 
    2239         [ #  # ]:          0 :         for( n = rSectFmts.size(); n; )
    2240                 :            :         {
    2241         [ #  # ]:          0 :             SwSectionFmt* pSectFmt = rSectFmts[ --n ];
    2242                 :            :             // don't add sections in Undo/Redo
    2243 [ #  # ][ #  # ]:          0 :             if( !pSectFmt->IsInNodesArr())
    2244                 :          0 :                 continue;
    2245         [ #  # ]:          0 :             SwSection* pSect = pSectFmt->GetSection();
    2246 [ #  # ][ #  # ]:          0 :             if( pSect->CalcHiddenFlag() )
    2247                 :            :             {
    2248                 :          0 :                 SwSection* pParent = pSect, *pTmp;
    2249 [ #  # ][ #  # ]:          0 :                 while( 0 != (pTmp = pParent->GetParent() ))
    2250                 :            :                 {
    2251         [ #  # ]:          0 :                     if( pTmp->IsHiddenFlag() )
    2252                 :          0 :                         pSect = pTmp;
    2253                 :          0 :                     pParent = pTmp;
    2254                 :            :                 }
    2255                 :            : 
    2256                 :            :                 SwSectionFmts::iterator it = std::find(
    2257         [ #  # ]:          0 :                         aSectFmts.begin(), aSectFmts.end(), pSect->GetFmt() );
    2258 [ #  # ][ #  # ]:          0 :                 if (it == aSectFmts.end())
    2259         [ #  # ]:          0 :                     aSectFmts.insert( aSectFmts.begin(), pSect->GetFmt() );
    2260                 :            :             }
    2261         [ #  # ]:          0 :             if( pSect->GetCondition().Len() )
    2262                 :            :             {
    2263         [ #  # ]:          0 :                 SwSectionData aSectionData( *pSect );
    2264         [ #  # ]:          0 :                 aSectionData.SetCondition( aEmptyStr );
    2265                 :          0 :                 aSectionData.SetHidden( false );
    2266 [ #  # ][ #  # ]:          0 :                 UpdateSection( n, aSectionData );
    2267                 :            :             }
    2268                 :            :         }
    2269                 :            : 
    2270         [ #  # ]:          0 :         if( 0 != ( n = aSectFmts.size() ))
    2271                 :            :         {
    2272         [ #  # ]:          0 :             while( n )
    2273                 :            :             {
    2274         [ #  # ]:          0 :                 SwSectionFmt* pSectFmt = aSectFmts[ --n ];
    2275         [ #  # ]:          0 :                 SwSectionNode* pSectNd = pSectFmt->GetSectionNode();
    2276         [ #  # ]:          0 :                 if( pSectNd )
    2277                 :            :                 {
    2278                 :          0 :                     bRet = sal_True;
    2279         [ #  # ]:          0 :                     SwPaM aPam( *pSectNd );
    2280                 :            : 
    2281   [ #  #  #  # ]:          0 :                     if( pSectNd->StartOfSectionNode()->StartOfSectionIndex() ==
                 [ #  # ]
    2282                 :          0 :                         pSectNd->GetIndex() - 1 &&
    2283                 :          0 :                         pSectNd->StartOfSectionNode()->EndOfSectionIndex() ==
    2284                 :          0 :                         pSectNd->EndOfSectionIndex() + 1 )
    2285                 :            :                     {
    2286                 :            :                         // only delete the content
    2287         [ #  # ]:          0 :                         SwCntntNode* pCNd = GetNodes().GoNext(
    2288         [ #  # ]:          0 :                                                 &aPam.GetPoint()->nNode );
    2289 [ #  # ][ #  # ]:          0 :                         aPam.GetPoint()->nContent.Assign( pCNd, 0 );
    2290         [ #  # ]:          0 :                         aPam.SetMark();
    2291         [ #  # ]:          0 :                         aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode();
    2292         [ #  # ]:          0 :                         pCNd = GetNodes().GoPrevious(
    2293         [ #  # ]:          0 :                                                 &aPam.GetPoint()->nNode );
    2294 [ #  # ][ #  # ]:          0 :                         aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
                 [ #  # ]
    2295                 :            : 
    2296         [ #  # ]:          0 :                         DeleteRange( aPam );
    2297                 :            :                     }
    2298                 :            :                     else
    2299                 :            :                     {
    2300                 :            :                         // delete the whole section
    2301         [ #  # ]:          0 :                         aPam.SetMark();
    2302         [ #  # ]:          0 :                         aPam.GetPoint()->nNode = *pSectNd->EndOfSectionNode();
    2303         [ #  # ]:          0 :                         DelFullPara( aPam );
    2304         [ #  # ]:          0 :                     }
    2305                 :            : 
    2306                 :            :                 }
    2307                 :            :             }
    2308                 :          0 :             aSectFmts.clear();
    2309         [ #  # ]:          0 :         }
    2310                 :            :     }
    2311                 :            : 
    2312         [ #  # ]:          0 :     if( bRet )
    2313                 :          0 :         SetModified();
    2314                 :          0 :     GetIDocumentUndoRedo().EndUndo( UNDO_UI_DELETE_INVISIBLECNTNT, NULL );
    2315                 :          0 :     return bRet;
    2316                 :            : }
    2317                 :            : 
    2318                 :          0 : bool SwDoc::HasInvisibleContent() const
    2319                 :            : {
    2320                 :          0 :     sal_Bool bRet = sal_False;
    2321                 :            : 
    2322 [ #  # ][ #  # ]:          0 :     SwClientIter aIter( *GetSysFldType( RES_HIDDENPARAFLD ) );
    2323 [ #  # ][ #  # ]:          0 :     if( aIter.First( TYPE( SwFmtFld ) ) )
                 [ #  # ]
    2324                 :          0 :         bRet = sal_True;
    2325                 :            : 
    2326                 :            :     //
    2327                 :            :     // Search for any hidden paragraph (hidden text attribute)
    2328                 :            :     //
    2329         [ #  # ]:          0 :     if( ! bRet )
    2330                 :            :     {
    2331 [ #  # ][ #  # ]:          0 :         for( sal_uLong n = GetNodes().Count(); !bRet && (n > 0); )
         [ #  # ][ #  # ]
    2332                 :            :         {
    2333 [ #  # ][ #  # ]:          0 :             SwTxtNode* pTxtNd = GetNodes()[ --n ]->GetTxtNode();
    2334         [ #  # ]:          0 :             if ( pTxtNd )
    2335                 :            :             {
    2336         [ #  # ]:          0 :                 SwPaM aPam( *pTxtNd, 0, *pTxtNd, pTxtNd->GetTxt().Len() );
    2337 [ #  # ][ #  # ]:          0 :                 if( pTxtNd->HasHiddenCharAttribute( true ) ||  ( pTxtNd->HasHiddenCharAttribute( false ) ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    2338                 :            :                 {
    2339                 :          0 :                     bRet = sal_True;
    2340         [ #  # ]:          0 :                 }
    2341                 :            :             }
    2342                 :            :         }
    2343                 :            :     }
    2344                 :            : 
    2345         [ #  # ]:          0 :     if( ! bRet )
    2346                 :            :     {
    2347                 :          0 :         const SwSectionFmts& rSectFmts = GetSections();
    2348                 :            :         sal_uInt16 n;
    2349                 :            : 
    2350 [ #  # ][ #  # ]:          0 :         for( n = rSectFmts.size(); !bRet && (n > 0); )
                 [ #  # ]
    2351                 :            :         {
    2352         [ #  # ]:          0 :             SwSectionFmt* pSectFmt = rSectFmts[ --n ];
    2353                 :            :             // don't add sections in Undo/Redo
    2354 [ #  # ][ #  # ]:          0 :             if( !pSectFmt->IsInNodesArr())
    2355                 :          0 :                 continue;
    2356         [ #  # ]:          0 :             SwSection* pSect = pSectFmt->GetSection();
    2357         [ #  # ]:          0 :             if( pSect->IsHidden() )
    2358                 :          0 :                 bRet = sal_True;
    2359                 :            :         }
    2360                 :            :     }
    2361         [ #  # ]:          0 :     return bRet;
    2362                 :            : }
    2363                 :            : 
    2364                 :          0 : bool SwDoc::RestoreInvisibleContent()
    2365                 :            : {
    2366                 :          0 :     bool bRet = false;
    2367                 :          0 :     SwUndoId nLastUndoId(UNDO_EMPTY);
    2368 [ #  # ][ #  # ]:          0 :     if (GetIDocumentUndoRedo().GetLastUndoInfo(0, & nLastUndoId)
         [ #  # ][ #  # ]
                 [ #  # ]
    2369                 :            :         && (UNDO_UI_DELETE_INVISIBLECNTNT == nLastUndoId))
    2370                 :            :     {
    2371 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().Undo();
    2372 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().ClearRedo();
    2373                 :          0 :         bRet = true;
    2374                 :            :     }
    2375                 :          0 :     return bRet;
    2376                 :            : }
    2377                 :            : 
    2378                 :            : 
    2379                 :          0 : sal_Bool SwDoc::ConvertFieldsToText()
    2380                 :            : {
    2381                 :          0 :     sal_Bool bRet = sal_False;
    2382                 :          0 :     LockExpFlds();
    2383                 :          0 :     GetIDocumentUndoRedo().StartUndo( UNDO_UI_REPLACE, NULL );
    2384                 :            : 
    2385                 :          0 :     const SwFldTypes* pMyFldTypes = GetFldTypes();
    2386                 :          0 :     sal_uInt16 nCount = pMyFldTypes->size();
    2387                 :            :     //go backward, field types are removed
    2388         [ #  # ]:          0 :     for(sal_uInt16 nType = nCount;  nType > 0;  --nType)
    2389                 :            :     {
    2390         [ #  # ]:          0 :         const SwFieldType *pCurType = (*pMyFldTypes)[nType - 1];
    2391                 :            : 
    2392         [ #  # ]:          0 :         if ( RES_POSTITFLD == pCurType->Which() )
    2393                 :          0 :             continue;
    2394                 :            : 
    2395         [ #  # ]:          0 :         SwIterator<SwFmtFld,SwFieldType> aIter( *pCurType );
    2396         [ #  # ]:          0 :         ::std::vector<const SwFmtFld*> aFieldFmts;
    2397 [ #  # ][ #  # ]:          0 :         for( SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next() )
                 [ #  # ]
    2398         [ #  # ]:          0 :             aFieldFmts.push_back(pCurFldFmt);
    2399                 :            : 
    2400                 :          0 :         ::std::vector<const SwFmtFld*>::iterator aBegin = aFieldFmts.begin();
    2401                 :          0 :         ::std::vector<const SwFmtFld*>::iterator aEnd = aFieldFmts.end();
    2402 [ #  # ][ #  # ]:          0 :         while(aBegin != aEnd)
    2403                 :            :         {
    2404         [ #  # ]:          0 :             const SwTxtFld *pTxtFld = (*aBegin)->GetTxtFld();
    2405                 :            :             // skip fields that are currently not in the document
    2406                 :            :             // e.g. fields in undo or redo array
    2407                 :            : 
    2408                 :            :             sal_Bool bSkip = !pTxtFld ||
    2409 [ #  # ][ #  # ]:          0 :                          !pTxtFld->GetpTxtNode()->GetNodes().IsDocNodes();
                 [ #  # ]
    2410                 :            : 
    2411         [ #  # ]:          0 :             if (!bSkip)
    2412                 :            :             {
    2413 [ #  # ][ #  # ]:          0 :                 sal_Bool bInHeaderFooter = IsInHeaderFooter(SwNodeIndex(*pTxtFld->GetpTxtNode()));
                 [ #  # ]
    2414                 :          0 :                 const SwFmtFld& rFmtFld = pTxtFld->GetFld();
    2415                 :          0 :                 const SwField*  pField = rFmtFld.GetFld();
    2416                 :            : 
    2417                 :            :                 //#i55595# some fields have to be excluded in headers/footers
    2418                 :          0 :                 sal_uInt16 nWhich = pField->GetTyp()->Which();
    2419 [ #  # ][ #  # ]:          0 :                 if(!bInHeaderFooter ||
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2420                 :            :                         (nWhich != RES_PAGENUMBERFLD &&
    2421                 :            :                         nWhich != RES_CHAPTERFLD &&
    2422                 :            :                         nWhich != RES_GETEXPFLD&&
    2423                 :            :                         nWhich != RES_SETEXPFLD&&
    2424                 :            :                         nWhich != RES_INPUTFLD&&
    2425                 :            :                         nWhich != RES_REFPAGEGETFLD&&
    2426                 :            :                         nWhich != RES_REFPAGESETFLD))
    2427                 :            :                 {
    2428         [ #  # ]:          0 :                     String sText = pField->ExpandField(true);
    2429                 :            :                     //database fields should not convert their command into text
    2430 [ #  # ][ #  # ]:          0 :                     if( RES_DBFLD == pCurType->Which() && !static_cast<const SwDBField*>(pField)->IsInitialized())
                 [ #  # ]
    2431         [ #  # ]:          0 :                         sText.Erase();
    2432                 :            : 
    2433                 :            :                     //now remove the field and insert the string
    2434         [ #  # ]:          0 :                     SwPaM aPam1(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
    2435         [ #  # ]:          0 :                     aPam1.Move();
    2436                 :            :                     //insert first to keep the field's attributes
    2437         [ #  # ]:          0 :                     InsertString( aPam1, sText );
    2438         [ #  # ]:          0 :                     SwPaM aPam2(*pTxtFld->GetpTxtNode(), *pTxtFld->GetStart());
    2439         [ #  # ]:          0 :                     aPam2.SetMark();
    2440         [ #  # ]:          0 :                     aPam2.Move();
    2441 [ #  # ][ #  # ]:          0 :                     DeleteAndJoin(aPam2);//remove the field
         [ #  # ][ #  # ]
    2442                 :            :                 }
    2443                 :            :             }
    2444         [ #  # ]:          0 :             ++aBegin;
    2445                 :            :         }
    2446         [ #  # ]:          0 :     }
    2447                 :            : 
    2448         [ #  # ]:          0 :     if( bRet )
    2449                 :          0 :         SetModified();
    2450                 :          0 :     GetIDocumentUndoRedo().EndUndo( UNDO_UI_REPLACE, NULL );
    2451                 :          0 :     UnlockExpFlds();
    2452                 :          0 :     return bRet;
    2453                 :            : 
    2454                 :            : }
    2455                 :            : 
    2456                 :         49 : bool SwDoc::IsVisibleLinks() const
    2457                 :            : {
    2458                 :         49 :     return mbVisibleLinks;
    2459                 :            : }
    2460                 :            : 
    2461                 :         36 : void SwDoc::SetVisibleLinks(bool bFlag)
    2462                 :            : {
    2463                 :         36 :     mbVisibleLinks = bFlag;
    2464                 :         36 : }
    2465                 :            : 
    2466                 :      17819 : sfx2::LinkManager& SwDoc::GetLinkManager()
    2467                 :            : {
    2468                 :      17819 :     return *pLinkMgr;
    2469                 :            : }
    2470                 :            : 
    2471                 :         17 : const sfx2::LinkManager& SwDoc::GetLinkManager() const
    2472                 :            : {
    2473                 :         17 :     return *pLinkMgr;
    2474                 :            : }
    2475                 :            : 
    2476                 :         53 : void SwDoc::SetLinksUpdated(const bool bNewLinksUpdated)
    2477                 :            : {
    2478                 :         53 :     mbLinksUpdated = bNewLinksUpdated;
    2479                 :         53 : }
    2480                 :            : 
    2481                 :        364 : bool SwDoc::LinksUpdated() const
    2482                 :            : {
    2483                 :        364 :     return mbLinksUpdated;
    2484                 :            : }
    2485                 :            : 
    2486                 :            : // embedded alle lokalen Links (Bereiche/Grafiken)
    2487                 :          0 : ::sfx2::SvBaseLink* lcl_FindNextRemovableLink( const ::sfx2::SvBaseLinks& rLinks, sfx2::LinkManager& rLnkMgr )
    2488                 :            : {
    2489         [ #  # ]:          0 :     for( sal_uInt16 n = 0; n < rLinks.size(); ++n )
    2490                 :            :     {
    2491                 :          0 :         ::sfx2::SvBaseLink* pLnk = &(*rLinks[ n ]);
    2492 [ #  # ][ #  #  :          0 :         if( pLnk &&
          #  #  #  #  #  
                      # ]
    2493                 :          0 :             ( OBJECT_CLIENT_GRF == pLnk->GetObjType() ||
    2494                 :          0 :               OBJECT_CLIENT_FILE == pLnk->GetObjType() ) &&
    2495                 :          0 :             pLnk->ISA( SwBaseLink ) )
    2496                 :            :         {
    2497                 :          0 :                 ::sfx2::SvBaseLinkRef xLink = pLnk;
    2498                 :            : 
    2499         [ #  # ]:          0 :                 String sFName;
    2500         [ #  # ]:          0 :                 rLnkMgr.GetDisplayNames( xLink, 0, &sFName, 0, 0 );
    2501                 :            : 
    2502 [ #  # ][ #  # ]:          0 :                 INetURLObject aURL( sFName );
    2503         [ #  # ]:          0 :                 if( INET_PROT_FILE == aURL.GetProtocol() ||
           [ #  #  #  # ]
    2504                 :          0 :                     INET_PROT_CID == aURL.GetProtocol() )
    2505 [ #  # ][ #  # ]:          0 :                     return pLnk;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2506                 :            :         }
    2507                 :            :     }
    2508                 :          0 :     return 0;
    2509                 :            : }
    2510                 :          0 : bool SwDoc::EmbedAllLinks()
    2511                 :            : {
    2512                 :          0 :     sal_Bool bRet = sal_False;
    2513                 :          0 :     sfx2::LinkManager& rLnkMgr = GetLinkManager();
    2514                 :          0 :     const ::sfx2::SvBaseLinks& rLinks = rLnkMgr.GetLinks();
    2515         [ #  # ]:          0 :     if( !rLinks.empty() )
    2516                 :            :     {
    2517 [ #  # ][ #  # ]:          0 :         ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
    2518                 :            : 
    2519                 :          0 :         ::sfx2::SvBaseLink* pLnk = 0;
    2520 [ #  # ][ #  # ]:          0 :         while( 0 != (pLnk = lcl_FindNextRemovableLink( rLinks, rLnkMgr ) ) )
    2521                 :            :         {
    2522                 :          0 :             ::sfx2::SvBaseLinkRef xLink = pLnk;
    2523                 :            :             // Tell the link that it's being destroyed!
    2524         [ #  # ]:          0 :             xLink->Closed();
    2525                 :            : 
    2526                 :            :             // if one forgot to remove itself
    2527         [ #  # ]:          0 :             if( xLink.Is() )
    2528         [ #  # ]:          0 :                 rLnkMgr.Remove( xLink );
    2529                 :            : 
    2530                 :          0 :             bRet = sal_True;
    2531         [ #  # ]:          0 :         }
    2532                 :            : 
    2533 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().DelAllUndoObj();
    2534 [ #  # ][ #  # ]:          0 :         SetModified();
    2535                 :            :     }
    2536                 :          0 :     return bRet;
    2537                 :            : }
    2538                 :            : 
    2539                 :          0 : sal_Bool SwDoc::IsInsTblFormatNum() const
    2540                 :            : {
    2541                 :          0 :     return SW_MOD()->IsInsTblFormatNum(get(IDocumentSettingAccess::HTML_MODE));
    2542                 :            : }
    2543                 :            : 
    2544                 :          0 : sal_Bool SwDoc::IsInsTblChangeNumFormat() const
    2545                 :            : {
    2546                 :          0 :     return SW_MOD()->IsInsTblChangeNumFormat(get(IDocumentSettingAccess::HTML_MODE));
    2547                 :            : }
    2548                 :            : 
    2549                 :        154 : sal_Bool SwDoc::IsInsTblAlignNum() const
    2550                 :            : {
    2551                 :        154 :     return SW_MOD()->IsInsTblAlignNum(get(IDocumentSettingAccess::HTML_MODE));
    2552                 :            : }
    2553                 :            : 
    2554                 :            : // Set up the InsertDB as Undo table
    2555                 :          0 : void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, sal_Bool bIsTable )
    2556                 :            : {
    2557         [ #  # ]:          0 :     if( bIsTable )
    2558                 :            :     {
    2559                 :          0 :         const SwTableNode* pTblNd = rPam.GetPoint()->nNode.GetNode().FindTableNode();
    2560         [ #  # ]:          0 :         if( pTblNd )
    2561                 :            :         {
    2562         [ #  # ]:          0 :             SwUndoCpyTbl* pUndo = new SwUndoCpyTbl;
    2563                 :          0 :             pUndo->SetTableSttIdx( pTblNd->GetIndex() );
    2564                 :          0 :             GetIDocumentUndoRedo().AppendUndo( pUndo );
    2565                 :            :         }
    2566                 :            :     }
    2567         [ #  # ]:          0 :     else if( rPam.HasMark() )
    2568                 :            :     {
    2569         [ #  # ]:          0 :         SwUndoCpyDoc* pUndo = new SwUndoCpyDoc( rPam );
    2570                 :          0 :         pUndo->SetInsertRange( rPam, sal_False );
    2571                 :          0 :         GetIDocumentUndoRedo().AppendUndo( pUndo );
    2572                 :            :     }
    2573                 :          0 : }
    2574                 :            : 
    2575                 :          0 : void SwDoc::ChgTOX(SwTOXBase & rTOX, const SwTOXBase & rNew)
    2576                 :            : {
    2577         [ #  # ]:          0 :     if (GetIDocumentUndoRedo().DoesUndo())
    2578                 :            :     {
    2579                 :          0 :         GetIDocumentUndoRedo().DelAllUndoObj();
    2580                 :            : 
    2581         [ #  # ]:          0 :         SwUndo * pUndo = new SwUndoTOXChange(&rTOX, rNew);
    2582                 :            : 
    2583                 :          0 :         GetIDocumentUndoRedo().AppendUndo(pUndo);
    2584                 :            :     }
    2585                 :            : 
    2586                 :          0 :     rTOX = rNew;
    2587                 :            : 
    2588         [ #  # ]:          0 :     if (rTOX.ISA(SwTOXBaseSection))
    2589                 :            :     {
    2590                 :          0 :         static_cast<SwTOXBaseSection &>(rTOX).Update();
    2591                 :          0 :         static_cast<SwTOXBaseSection &>(rTOX).UpdatePageNum();
    2592                 :            :     }
    2593                 :          0 : }
    2594                 :            : 
    2595                 :          0 : String SwDoc::GetPaMDescr(const SwPaM & rPam) const
    2596                 :            : {
    2597                 :          0 :     String aResult;
    2598                 :          0 :     bool bOK = false;
    2599                 :            : 
    2600         [ #  # ]:          0 :     if (rPam.GetNode(sal_True) == rPam.GetNode(sal_False))
    2601                 :            :     {
    2602                 :          0 :         SwTxtNode * pTxtNode = rPam.GetNode(sal_True)->GetTxtNode();
    2603                 :            : 
    2604         [ #  # ]:          0 :         if (0 != pTxtNode)
    2605                 :            :         {
    2606         [ #  # ]:          0 :             xub_StrLen nStart = rPam.Start()->nContent.GetIndex();
    2607         [ #  # ]:          0 :             xub_StrLen nEnd = rPam.End()->nContent.GetIndex();
    2608                 :            : 
    2609 [ #  # ][ #  # ]:          0 :             aResult += String(SW_RES(STR_START_QUOTE));
                 [ #  # ]
    2610                 :          0 :             aResult += ShortenString(pTxtNode->GetTxt().
    2611                 :            :                                      Copy(nStart, nEnd - nStart),
    2612                 :            :                                      nUndoStringLength,
    2613   [ #  #  #  # ]:          0 :                                      String(SW_RES(STR_LDOTS)));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    2614 [ #  # ][ #  # ]:          0 :             aResult += String(SW_RES(STR_END_QUOTE));
                 [ #  # ]
    2615                 :            : 
    2616                 :          0 :             bOK = true;
    2617                 :            :         }
    2618                 :            :     }
    2619         [ #  # ]:          0 :     else if (0 != rPam.GetNode(sal_True))
    2620                 :            :     {
    2621         [ #  # ]:          0 :         if (0 != rPam.GetNode(sal_False))
    2622 [ #  # ][ #  # ]:          0 :             aResult += String(SW_RES(STR_PARAGRAPHS));
                 [ #  # ]
    2623                 :            : 
    2624                 :          0 :         bOK = true;
    2625                 :            :     }
    2626                 :            : 
    2627         [ #  # ]:          0 :     if (! bOK)
    2628 [ #  # ][ #  # ]:          0 :         aResult += String("??", RTL_TEXTENCODING_ASCII_US);
                 [ #  # ]
    2629                 :            : 
    2630                 :          0 :     return aResult;
    2631                 :            : }
    2632                 :            : 
    2633                 :         62 : SwField * SwDoc::GetField(const SwPosition & rPos)
    2634                 :            : {
    2635                 :         62 :     SwTxtFld * const pAttr = GetTxtFld(rPos);
    2636                 :            : 
    2637         [ +  - ]:         62 :     return (pAttr) ? const_cast<SwField *>( pAttr->GetFld().GetFld() ) : 0;
    2638                 :            : }
    2639                 :            : 
    2640                 :         62 : SwTxtFld * SwDoc::GetTxtFld(const SwPosition & rPos)
    2641                 :            : {
    2642                 :         62 :     SwTxtNode * const pNode = rPos.nNode.GetNode().GetTxtNode();
    2643                 :            : 
    2644                 :            :     return (pNode)
    2645                 :            :         ? static_cast<SwTxtFld*>( pNode->GetTxtAttrForCharAt(
    2646                 :         62 :                     rPos.nContent.GetIndex(), RES_TXTATR_FIELD) )
    2647         [ +  - ]:        124 :         : 0;
    2648                 :            : }
    2649                 :            : 
    2650                 :          4 : bool SwDoc::ContainsHiddenChars() const
    2651                 :            : {
    2652         [ +  + ]:         48 :     for( sal_uLong n = GetNodes().Count(); n; )
    2653                 :            :     {
    2654                 :         44 :         SwNode* pNd = GetNodes()[ --n ];
    2655         [ -  + ]:         48 :         if ( pNd->IsTxtNode() &&
           [ +  +  -  + ]
    2656         [ +  - ]:          4 :              ((SwTxtNode*)pNd)->HasHiddenCharAttribute( false ) )
    2657                 :          0 :             return true;
    2658                 :            :     }
    2659                 :            : 
    2660                 :          4 :     return false;
    2661                 :            : }
    2662                 :            : 
    2663                 :      38328 : SwUnoCrsr* SwDoc::CreateUnoCrsr( const SwPosition& rPos, sal_Bool bTblCrsr )
    2664                 :            : {
    2665                 :            :     SwUnoCrsr* pNew;
    2666         [ +  + ]:      38328 :     if( bTblCrsr )
    2667 [ +  - ][ +  - ]:         47 :         pNew = new SwUnoTableCrsr( rPos );
                 [ +  - ]
    2668                 :            :     else
    2669 [ +  - ][ +  - ]:      38281 :         pNew = new SwUnoCrsr( rPos );
    2670                 :            : 
    2671         [ +  - ]:      38328 :     pUnoCrsrTbl->insert( pNew );
    2672                 :      38328 :     return pNew;
    2673                 :            : }
    2674                 :            : 
    2675                 :        188 : void SwDoc::ChkCondColls()
    2676                 :            : {
    2677         [ +  + ]:       2367 :      for (sal_uInt16 n = 0; n < pTxtFmtCollTbl->size(); n++)
    2678                 :            :      {
    2679                 :       2179 :         SwTxtFmtColl *pColl = (*pTxtFmtCollTbl)[n];
    2680         [ +  + ]:       2179 :         if (RES_CONDTXTFMTCOLL == pColl->Which())
    2681         [ +  - ]:        188 :             pColl->CallSwClientNotify( SwAttrHint(RES_CONDTXTFMTCOLL) );
    2682                 :            :      }
    2683                 :        188 : }
    2684                 :            : 
    2685                 :            : uno::Reference< script::vba::XVBAEventProcessor >
    2686                 :      85702 : SwDoc::GetVbaEventProcessor()
    2687                 :            : {
    2688                 :            : #ifndef DISABLE_SCRIPTING
    2689 [ +  - ][ +  - ]:      85702 :     if( !mxVbaEvents.is() && pDocShell && ooo::vba::isAlienWordDoc( *pDocShell ) )
         [ +  + ][ +  + ]
    2690                 :            :     {
    2691                 :            :         try
    2692                 :            :         {
    2693 [ +  - ][ +  - ]:       4608 :             uno::Reference< frame::XModel > xModel( pDocShell->GetModel(), uno::UNO_SET_THROW );
    2694         [ +  - ]:       4608 :             uno::Sequence< uno::Any > aArgs(1);
    2695 [ +  - ][ +  - ]:       4608 :             aArgs[0] <<= xModel;
    2696 [ +  + ][ -  + ]:       4608 :             mxVbaEvents.set( ooo::vba::createVBAUnoAPIServiceWithArgs( pDocShell, "com.sun.star.script.vba.VBATextEventProcessor" , aArgs ), uno::UNO_QUERY_THROW );
         [ #  # ][ -  + ]
    2697                 :            :         }
    2698                 :       4608 :         catch( uno::Exception& )
    2699                 :            :         {
    2700                 :            :         }
    2701                 :            :     }
    2702                 :            : #endif
    2703                 :      85702 :     return mxVbaEvents;
    2704                 :            : }
    2705                 :            : 
    2706                 :        204 : void SwDoc::setExternalData(::sw::tExternalDataType eType,
    2707                 :            :                             ::sw::tExternalDataPointer pPayload)
    2708                 :            : {
    2709                 :        204 :     m_externalData[eType] = pPayload;
    2710                 :        204 : }
    2711                 :            : 
    2712                 :         18 : ::sw::tExternalDataPointer SwDoc::getExternalData(::sw::tExternalDataType eType)
    2713                 :            : {
    2714                 :         18 :     return m_externalData[eType];
    2715                 :            : }
    2716                 :            : 
    2717                 :         18 : sal_uInt16 SwNumRuleTbl::GetPos(const SwNumRule* pRule) const
    2718                 :            : {
    2719         [ +  - ]:         18 :     const_iterator it = std::find(begin(), end(), pRule);
    2720 [ +  - ][ -  + ]:         18 :     return it == end() ? USHRT_MAX : it - begin();
         [ +  - ][ +  - ]
                 [ #  # ]
    2721                 :            : }
    2722                 :            : 
    2723                 :       1563 : SwNumRuleTbl::~SwNumRuleTbl()
    2724                 :            : {
    2725 [ +  - ][ +  - ]:       3830 :     for(const_iterator it = begin(); it != end(); ++it)
                 [ +  + ]
    2726 [ +  - ][ +  - ]:       2267 :         delete *it;
    2727                 :       1563 : }
    2728                 :            : 
    2729                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10