LCOV - code coverage report
Current view: top level - sw/source/core/doc - docdesc.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 256 409 62.6 %
Date: 2012-08-25 Functions: 16 21 76.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 261 746 35.0 %

           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 <svx/svdmodel.hxx>
      31                 :            : #include <editeng/ulspitem.hxx>
      32                 :            : #include <editeng/paperinf.hxx>
      33                 :            : #include "editeng/frmdiritem.hxx"
      34                 :            : #include <sfx2/printer.hxx>
      35                 :            : #include <fmtfsize.hxx>
      36                 :            : #include <fmthdft.hxx>
      37                 :            : #include <fmtcntnt.hxx>
      38                 :            : #include <ftninfo.hxx>
      39                 :            : #include <fesh.hxx>
      40                 :            : #include <ndole.hxx>
      41                 :            : #include <mdiexp.hxx>
      42                 :            : #include <doc.hxx>
      43                 :            : #include <IDocumentUndoRedo.hxx>
      44                 :            : #include <docary.hxx>
      45                 :            : #include <rootfrm.hxx>  //For DelPageDesc
      46                 :            : #include <frmtool.hxx>
      47                 :            : #include <poolfmt.hxx>
      48                 :            : #include <docsh.hxx>
      49                 :            : #include <ftnidx.hxx>
      50                 :            : #include <fmtftn.hxx>
      51                 :            : #include <txtftn.hxx>
      52                 :            : #include <fntcache.hxx>
      53                 :            : #include <viewopt.hxx>
      54                 :            : #include <fldbas.hxx>
      55                 :            : #include <swwait.hxx>
      56                 :            : #include <GetMetricVal.hxx>
      57                 :            : #include <statstr.hrc>
      58                 :            : #include <hints.hxx>
      59                 :            : #include <SwUndoPageDesc.hxx>
      60                 :            : #include <pagedeschint.hxx>
      61                 :            : #include <tgrditem.hxx>
      62                 :            : 
      63                 :            : using namespace com::sun::star;
      64                 :            : 
      65                 :       1891 : static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId,
      66                 :            :                                 SwFrmFmt &rFmt1,
      67                 :            :                                 SwFrmFmt &rFmt2,
      68                 :            :                                 SwFrmFmt &rFmt3 )
      69                 :            : {
      70                 :            :     // --> #i41075# Printer on demand
      71                 :            :     // This function does not require a printer anymore.
      72                 :            :     // The default page size is obtained from the application
      73                 :            :     //locale
      74                 :            : 
      75         [ +  - ]:       1891 :     SwFmtFrmSize aFrmSize( ATT_FIX_SIZE );
      76         [ +  - ]:       1891 :     const Size aPhysSize = SvxPaperInfo::GetDefaultPaperSize();
      77                 :       1891 :     aFrmSize.SetSize( aPhysSize );
      78                 :            : 
      79                 :            :     // Prepare for default margins.
      80                 :            :     // Margins have a default minimum size.
      81                 :            :     // If the printer forces a larger margins, that's ok too.
      82                 :            :     // The HTML page desc had A4 as page size always.
      83                 :            :     // This has been changed to take the page size from the printer.
      84                 :            :     // Unfortunately, the margins of the HTML page desc are smaller than
      85                 :            :     // the margins used here in general, so one extra case is required.
      86                 :            :     // In the long term, this needs to be changed to always keep the
      87                 :            :     // margins from the page desc.
      88                 :            :     sal_Int32 nMinTop, nMinBottom, nMinLeft, nMinRight;
      89         [ -  + ]:       1891 :     if( RES_POOLPAGE_HTML == nPoolFmtId )
      90                 :            :     {
      91                 :          0 :         nMinRight = nMinTop = nMinBottom = GetMetricVal( CM_1 );
      92                 :          0 :         nMinLeft = nMinRight * 2;
      93                 :            :     }
      94 [ +  - ][ +  - ]:       1891 :     else if( MEASURE_METRIC == SvtSysLocale().GetLocaleData().getMeasurementSystemEnum() )
         [ +  - ][ +  - ]
                 [ -  + ]
      95                 :            :     {
      96                 :          0 :         nMinTop = nMinBottom = nMinLeft = nMinRight = 1134; // 2 centimetres
      97                 :            :     }
      98                 :            :     else
      99                 :            :     {
     100                 :       1891 :         nMinTop = nMinBottom = 1440;    // as in MS Word: 1 Inch
     101                 :       1891 :         nMinLeft = nMinRight = 1800;    //                1,25 Inch
     102                 :            :     }
     103                 :            : 
     104                 :            :     // set margins
     105         [ +  - ]:       1891 :     SvxLRSpaceItem aLR( RES_LR_SPACE );
     106         [ +  - ]:       1891 :     SvxULSpaceItem aUL( RES_UL_SPACE );
     107                 :            : 
     108                 :       1891 :     aUL.SetUpper( (sal_uInt16)nMinTop );
     109                 :       1891 :     aUL.SetLower( (sal_uInt16)nMinBottom );
     110                 :       1891 :     aLR.SetRight( nMinRight );
     111                 :       1891 :     aLR.SetLeft( nMinLeft );
     112                 :            : 
     113         [ +  - ]:       1891 :     rFmt1.SetFmtAttr( aFrmSize );
     114         [ +  - ]:       1891 :     rFmt1.SetFmtAttr( aLR );
     115         [ +  - ]:       1891 :     rFmt1.SetFmtAttr( aUL );
     116                 :            : 
     117         [ +  - ]:       1891 :     rFmt2.SetFmtAttr( aFrmSize );
     118         [ +  - ]:       1891 :     rFmt2.SetFmtAttr( aLR );
     119         [ +  - ]:       1891 :     rFmt2.SetFmtAttr( aUL );
     120                 :            : 
     121         [ +  - ]:       1891 :     rFmt3.SetFmtAttr( aFrmSize );
     122         [ +  - ]:       1891 :     rFmt3.SetFmtAttr( aLR );
     123 [ +  - ][ +  - ]:       1891 :     rFmt3.SetFmtAttr( aUL );
         [ +  - ][ +  - ]
     124                 :       1891 : }
     125                 :            : 
     126                 :            : /*************************************************************************
     127                 :            : |*
     128                 :            : |*  SwDoc::ChgPageDesc()
     129                 :            : |*
     130                 :            : |*************************************************************************/
     131                 :            : 
     132                 :       6524 : void lcl_DescSetAttr( const SwFrmFmt &rSource, SwFrmFmt &rDest,
     133                 :            :                          const sal_Bool bPage = sal_True )
     134                 :            : {
     135                 :            :     // We should actually use ItemSet's Intersect here, but that doesn't work
     136                 :            :     // correctly if we have different WhichRanges.
     137                 :            : 
     138                 :            :     // Take over the attributes which are of interest.
     139                 :            :     sal_uInt16 const aIdArr[] = { RES_FRM_SIZE, RES_UL_SPACE,
     140                 :            :                                         RES_BACKGROUND, RES_SHADOW,
     141                 :            :                                         RES_COL, RES_COL,
     142                 :            :                                         RES_FRAMEDIR, RES_FRAMEDIR,
     143                 :            :                                         RES_TEXTGRID, RES_TEXTGRID,
     144                 :            :                                         // #i45539#
     145                 :            :                                         RES_HEADER_FOOTER_EAT_SPACING,
     146                 :            :                                         RES_HEADER_FOOTER_EAT_SPACING,
     147                 :            :                                         RES_UNKNOWNATR_CONTAINER,
     148                 :            :                                         RES_UNKNOWNATR_CONTAINER,
     149                 :       6524 :                                         0 };
     150                 :            : 
     151                 :            :     const SfxPoolItem* pItem;
     152         [ +  + ]:      52192 :     for( sal_uInt16 n = 0; aIdArr[ n ]; n += 2 )
     153                 :            :     {
     154         [ +  + ]:     123956 :         for( sal_uInt16 nId = aIdArr[ n ]; nId <= aIdArr[ n+1]; ++nId )
     155                 :            :         {
     156                 :            :             // #i45539#
     157                 :            :             // bPage == true:
     158                 :            :             // All in aIdArr except from RES_HEADER_FOOTER_EAT_SPACING
     159                 :            :             // bPage == false:
     160                 :            :             // All in aIdArr except from RES_COL and RES_PAPER_BIN:
     161 [ +  + ][ +  + ]:      78288 :             if( (  bPage && RES_HEADER_FOOTER_EAT_SPACING != nId ) ||
         [ +  + ][ +  + ]
                 [ +  + ]
     162                 :            :                 ( !bPage && RES_COL != nId && RES_PAPER_BIN != nId ))
     163                 :            :             {
     164 [ +  - ][ +  + ]:      71760 :                 if( SFX_ITEM_SET == rSource.GetItemState( nId, sal_False, &pItem ))
     165         [ +  - ]:      31372 :                     rDest.SetFmtAttr( *pItem );
     166                 :            :                 else
     167         [ +  - ]:      40388 :                     rDest.ResetFmtAttr( nId );
     168                 :            :             }
     169                 :            :         }
     170                 :            :     }
     171                 :            : 
     172                 :            :     // Transmit pool and help IDs too
     173                 :       6524 :     rDest.SetPoolFmtId( rSource.GetPoolFmtId() );
     174                 :       6524 :     rDest.SetPoolHelpId( rSource.GetPoolHelpId() );
     175                 :       6524 :     rDest.SetPoolHlpFileId( rSource.GetPoolHlpFileId() );
     176                 :       6524 : }
     177                 :            : 
     178                 :       2608 : void SwDoc::CopyMasterHeader(const SwPageDesc &rChged, const SwFmtHeader &rHead, SwPageDesc *pDesc, bool bLeft)
     179                 :            : {
     180         [ +  + ]:       2608 :     SwFrmFmt& rDescFrmFmt = (bLeft ? pDesc->GetLeft() : pDesc->GetFirst());
     181 [ +  + ][ -  + ]:       2608 :     if ( (bLeft ? rChged.IsHeaderShared() : rChged.IsFirstShared() ) || !rHead.IsActive() )
         [ +  + ][ +  - ]
                 [ +  - ]
     182                 :            :     {
     183                 :            :         // Left or first shares the header with the Master.
     184                 :       2608 :         rDescFrmFmt.SetFmtAttr( pDesc->GetMaster().GetHeader() );
     185                 :            :     }
     186         [ #  # ]:          0 :     else if ( rHead.IsActive() )
     187                 :            :     {   // Left or first gets its own header if the Format doesn't alrady have one.
     188                 :            :         // If it already has one and it points to the same Section as the
     189                 :            :         // Right one, it needs to get an own Header.
     190                 :            :         // The content is evidently copied.
     191                 :          0 :         const SwFmtHeader &rFmtHead = rDescFrmFmt.GetHeader();
     192         [ #  # ]:          0 :         if ( !rFmtHead.IsActive() )
     193                 :            :         {
     194 [ #  # ][ #  # ]:          0 :             SwFmtHeader aHead( MakeLayoutFmt( RND_STD_HEADERL, 0 ) );
     195         [ #  # ]:          0 :             rDescFrmFmt.SetFmtAttr( aHead );
     196                 :            :             // take over additional attributes (margins, borders ...)
     197 [ #  # ][ #  # ]:          0 :             ::lcl_DescSetAttr( *rHead.GetHeaderFmt(), *aHead.GetHeaderFmt(), sal_False);
     198                 :            :         }
     199                 :            :         else
     200                 :            :         {
     201                 :          0 :             const SwFrmFmt *pRight = rHead.GetHeaderFmt();
     202                 :          0 :             const SwFmtCntnt &aRCnt = pRight->GetCntnt();
     203                 :          0 :             const SwFmtCntnt &aCnt = rFmtHead.GetHeaderFmt()->GetCntnt();
     204         [ #  # ]:          0 :             if( !aCnt.GetCntntIdx() )
     205                 :            :             {
     206         [ #  # ]:          0 :                 const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
     207                 :          0 :                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetHeader() );
     208                 :            :             }
     209         [ #  # ]:          0 :             else if( (*aRCnt.GetCntntIdx()) == (*aCnt.GetCntntIdx()) )
     210                 :            :             {
     211                 :            :                 SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left header" : "First header"),
     212 [ #  # ][ #  # ]:          0 :                                                 GetDfltFrmFmt() );
                 [ #  # ]
     213         [ #  # ]:          0 :                 ::lcl_DescSetAttr( *pRight, *pFmt, sal_False );
     214                 :            :                 // The section which the right header attribute is pointing
     215                 :            :                 // is copied, and the Index to the StartNode is set to
     216                 :            :                 // the left or first header attribute.
     217 [ #  # ][ #  # ]:          0 :                 SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() );
     218 [ #  # ][ #  # ]:          0 :                 SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmp, SwHeaderStartNode );
     219                 :          0 :                 SwNodeRange aRange( aRCnt.GetCntntIdx()->GetNode(), 0,
     220         [ #  # ]:          0 :                             *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() );
     221         [ #  # ]:          0 :                 aTmp = *pSttNd->EndOfSectionNode();
     222 [ #  # ][ #  # ]:          0 :                 GetNodes()._Copy( aRange, aTmp, sal_False );
     223                 :            : 
     224 [ #  # ][ #  # ]:          0 :                 pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
                 [ #  # ]
     225 [ #  # ][ #  # ]:          0 :                 rDescFrmFmt.SetFmtAttr( SwFmtHeader( pFmt ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     226                 :            :             }
     227                 :            :             else
     228                 :            :                 ::lcl_DescSetAttr( *pRight,
     229                 :          0 :                                *(SwFrmFmt*)rFmtHead.GetHeaderFmt(), sal_False );
     230                 :            : 
     231                 :            :         }
     232                 :            :     }
     233                 :       2608 : }
     234                 :            : 
     235                 :       2608 : void SwDoc::CopyMasterFooter(const SwPageDesc &rChged, const SwFmtFooter &rFoot, SwPageDesc *pDesc, bool bLeft)
     236                 :            : {
     237         [ +  + ]:       2608 :     SwFrmFmt& rDescFrmFmt = (bLeft ? pDesc->GetLeft() : pDesc->GetFirst());
     238 [ +  + ][ -  + ]:       2608 :     if ( (bLeft ? rChged.IsFooterShared() : rChged.IsFirstShared() ) || !rFoot.IsActive() )
         [ +  + ][ +  + ]
                 [ +  + ]
     239                 :            :         // Left or first shares the Header with the Master.
     240                 :       2604 :         rDescFrmFmt.SetFmtAttr( pDesc->GetMaster().GetFooter() );
     241         [ +  - ]:          4 :     else if ( rFoot.IsActive() )
     242                 :            :     {   // Left or first gets its own Footer if the Format does not already have one.
     243                 :            :         // If the Format already has a Footer and it points to the same section as the Right one,
     244                 :            :         // it needs to get an own one.
     245                 :            :         // The content is evidently copied.
     246                 :          4 :         const SwFmtFooter &rFmtFoot = rDescFrmFmt.GetFooter();
     247         [ +  + ]:          4 :         if ( !rFmtFoot.IsActive() )
     248                 :            :         {
     249 [ +  - ][ +  - ]:          2 :             SwFmtFooter aFoot( MakeLayoutFmt( RND_STD_FOOTER, 0 ) );
     250         [ +  - ]:          2 :             rDescFrmFmt.SetFmtAttr( aFoot );
     251                 :            :             // Take over additional attributes (margins, borders ...).
     252 [ +  - ][ +  - ]:          2 :             ::lcl_DescSetAttr( *rFoot.GetFooterFmt(), *aFoot.GetFooterFmt(), sal_False);
     253                 :            :         }
     254                 :            :         else
     255                 :            :         {
     256                 :          2 :             const SwFrmFmt *pRight = rFoot.GetFooterFmt();
     257                 :          2 :             const SwFmtCntnt &aRCnt = pRight->GetCntnt();
     258                 :          2 :             const SwFmtCntnt &aLCnt = rFmtFoot.GetFooterFmt()->GetCntnt();
     259         [ -  + ]:          2 :             if( !aLCnt.GetCntntIdx() )
     260                 :            :             {
     261         [ #  # ]:          0 :                 const SwFrmFmt& rChgedFrmFmt = (bLeft ? rChged.GetLeft() : rChged.GetFirst());
     262                 :          0 :                 rDescFrmFmt.SetFmtAttr( rChgedFrmFmt.GetFooter() );
     263                 :            :             }
     264         [ -  + ]:          2 :             else if( (*aRCnt.GetCntntIdx()) == (*aLCnt.GetCntntIdx()) )
     265                 :            :             {
     266                 :            :                 SwFrmFmt *pFmt = new SwFrmFmt( GetAttrPool(), (bLeft ? "Left footer" : "First footer"),
     267 [ #  # ][ #  # ]:          0 :                                                 GetDfltFrmFmt() );
                 [ #  # ]
     268         [ #  # ]:          0 :                 ::lcl_DescSetAttr( *pRight, *pFmt, sal_False );
     269                 :            :                 // The section to which the right footer attribute is pointing
     270                 :            :                 // is copied, and the Index to the StartNode is set to
     271                 :            :                 // the left footer attribute.
     272 [ #  # ][ #  # ]:          0 :                 SwNodeIndex aTmp( GetNodes().GetEndOfAutotext() );
     273 [ #  # ][ #  # ]:          0 :                 SwStartNode* pSttNd = GetNodes().MakeEmptySection( aTmp, SwFooterStartNode );
     274                 :          0 :                 SwNodeRange aRange( aRCnt.GetCntntIdx()->GetNode(), 0,
     275         [ #  # ]:          0 :                             *aRCnt.GetCntntIdx()->GetNode().EndOfSectionNode() );
     276         [ #  # ]:          0 :                 aTmp = *pSttNd->EndOfSectionNode();
     277 [ #  # ][ #  # ]:          0 :                 GetNodes()._Copy( aRange, aTmp, sal_False );
     278                 :            : 
     279 [ #  # ][ #  # ]:          0 :                 pFmt->SetFmtAttr( SwFmtCntnt( pSttNd ) );
                 [ #  # ]
     280 [ #  # ][ #  # ]:          0 :                 rDescFrmFmt.SetFmtAttr( SwFmtFooter( pFmt ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     281                 :            :             }
     282                 :            :             else
     283                 :            :                 ::lcl_DescSetAttr( *pRight,
     284                 :          2 :                                *(SwFrmFmt*)rFmtFoot.GetFooterFmt(), sal_False );
     285                 :            :         }
     286                 :            :     }
     287                 :       2608 : }
     288                 :            : 
     289                 :       1304 : void SwDoc::ChgPageDesc( sal_uInt16 i, const SwPageDesc &rChged )
     290                 :            : {
     291                 :            :     OSL_ENSURE( i < aPageDescs.size(), "PageDescs is out of range." );
     292                 :            : 
     293                 :       1304 :     SwPageDesc *pDesc = aPageDescs[i];
     294         [ +  - ]:       1304 :     SwRootFrm* pTmpRoot = GetCurrentLayout();
     295                 :            : 
     296 [ +  - ][ +  - ]:       1304 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  + ]
     297                 :            :     {
     298 [ +  - ][ +  - ]:          8 :         SwUndo *const pUndo(new SwUndoPageDesc(*pDesc, rChged, this));
     299 [ +  - ][ +  - ]:          8 :         GetIDocumentUndoRedo().AppendUndo(pUndo);
     300                 :            :     }
     301 [ +  - ][ +  - ]:       1304 :     ::sw::UndoGuard const undoGuard(GetIDocumentUndoRedo());
     302                 :            : 
     303                 :            :     // Mirror at first if needed.
     304         [ -  + ]:       1304 :     if ( rChged.GetUseOn() == nsUseOnPage::PD_MIRROR )
     305         [ #  # ]:          0 :         ((SwPageDesc&)rChged).Mirror();
     306                 :            :     else
     307                 :            :     {
     308                 :            :         // Or else transfer values from Master to Left and First.
     309                 :       1304 :         ::lcl_DescSetAttr( ((SwPageDesc&)rChged).GetMaster(),
     310         [ +  - ]:       2608 :                        ((SwPageDesc&)rChged).GetLeft() );
     311                 :       1304 :         ::lcl_DescSetAttr( ((SwPageDesc&)rChged).GetMaster(),
     312         [ +  - ]:       2608 :                        ((SwPageDesc&)rChged).GetFirst() );
     313                 :            :     }
     314                 :            : 
     315                 :            :     // Take over NumType.
     316         [ -  + ]:       1304 :     if( rChged.GetNumType().GetNumberingType() != pDesc->GetNumType().GetNumberingType() )
     317                 :            :     {
     318                 :          0 :         pDesc->SetNumType( rChged.GetNumType() );
     319                 :            :         // Notify page number fields that NumFormat has changed
     320 [ #  # ][ #  # ]:          0 :         GetSysFldType( RES_PAGENUMBERFLD )->UpdateFlds();
     321 [ #  # ][ #  # ]:          0 :         GetSysFldType( RES_REFPAGEGETFLD )->UpdateFlds();
     322                 :            : 
     323                 :            :         // If the numbering scheme has changed we could have QuoVadis/ErgoSum texts
     324                 :            :         // that refer to a changed page, so we invalidate foot notes.
     325                 :          0 :         SwFtnIdxs& rFtnIdxs = GetFtnIdxs();
     326         [ #  # ]:          0 :         for( sal_uInt16 nPos = 0; nPos < rFtnIdxs.size(); ++nPos )
     327                 :            :         {
     328         [ #  # ]:          0 :             SwTxtFtn *pTxtFtn = rFtnIdxs[ nPos ];
     329                 :          0 :             const SwFmtFtn &rFtn = pTxtFtn->GetFtn();
     330         [ #  # ]:          0 :             pTxtFtn->SetNumber( rFtn.GetNumber(), &rFtn.GetNumStr());
     331                 :            :         }
     332                 :            :     }
     333                 :            : 
     334                 :            :     // Take over orientation
     335                 :       1304 :     pDesc->SetLandscape( rChged.GetLandscape() );
     336 [ +  - ][ +  - ]:       1304 :     pDesc->ChgFirstShare( rChged.IsFirstShared() );
     337                 :            : 
     338                 :            :     // #i46909# no undo if header or footer changed
     339                 :       1304 :     bool bHeaderFooterChanged = false;
     340                 :            : 
     341                 :            :     // Synch header.
     342         [ +  - ]:       1304 :     const SwFmtHeader &rHead = rChged.GetMaster().GetHeader();
     343         [ +  + ]:       1304 :     if (undoGuard.UndoWasEnabled())
     344                 :            :     {
     345                 :            :         // #i46909# no undo if header or footer changed
     346                 :            :         // Did something change in the nodes?
     347         [ +  - ]:          8 :         const SwFmtHeader &rOldHead = pDesc->GetMaster().GetHeader();
     348                 :            :         bHeaderFooterChanged |=
     349                 :          8 :             ( rHead.IsActive() != rOldHead.IsActive() ||
     350                 :          8 :               rChged.IsHeaderShared() != pDesc->IsHeaderShared() ||
     351 [ +  - ][ +  - ]:         16 :               rChged.IsFirstShared() != pDesc->IsFirstShared() );
                 [ -  + ]
           [ +  -  +  - ]
     352                 :            :     }
     353         [ +  - ]:       1304 :     pDesc->GetMaster().SetFmtAttr( rHead );
     354         [ +  - ]:       1304 :     CopyMasterHeader(rChged, rHead, pDesc, true); // Copy left header
     355         [ +  - ]:       1304 :     CopyMasterHeader(rChged, rHead, pDesc, false); // Copy first header
     356                 :       1304 :     pDesc->ChgHeaderShare( rChged.IsHeaderShared() );
     357                 :            : 
     358                 :            :     // Synch Footer.
     359         [ +  - ]:       1304 :     const SwFmtFooter &rFoot = rChged.GetMaster().GetFooter();
     360         [ +  + ]:       1304 :     if (undoGuard.UndoWasEnabled())
     361                 :            :     {
     362                 :            :         // #i46909# no undo if header or footer changed
     363                 :            :         // Did something change in the Nodes?
     364         [ +  - ]:          8 :         const SwFmtFooter &rOldFoot = pDesc->GetMaster().GetFooter();
     365                 :            :         bHeaderFooterChanged |=
     366                 :          8 :             ( rFoot.IsActive() != rOldFoot.IsActive() ||
     367                 :          8 :               rChged.IsFooterShared() != pDesc->IsFooterShared() ||
     368 [ +  - ][ +  - ]:         16 :               rChged.IsFirstShared() != pDesc->IsFirstShared() );
                 [ -  + ]
           [ +  -  +  - ]
     369                 :            :     }
     370         [ +  - ]:       1304 :     pDesc->GetMaster().SetFmtAttr( rFoot );
     371         [ +  - ]:       1304 :     CopyMasterFooter(rChged, rFoot, pDesc, true); // Copy left footer
     372         [ +  - ]:       1304 :     CopyMasterFooter(rChged, rFoot, pDesc, false); // Copy first footer
     373                 :       1304 :     pDesc->ChgFooterShare( rChged.IsFooterShared() );
     374                 :            : 
     375 [ +  + ][ +  - ]:       1304 :     if ( pDesc->GetName() != rChged.GetName() )
     376         [ +  - ]:          4 :         pDesc->SetName( rChged.GetName() );
     377                 :            : 
     378                 :            :     // A RegisterChange is triggered, if necessary
     379 [ +  - ][ +  - ]:       1304 :     pDesc->SetRegisterFmtColl( rChged.GetRegisterFmtColl() );
     380                 :            : 
     381                 :            :     // If UseOn or the Follow change, the paragraphs need to know about it.
     382                 :       1304 :     sal_Bool bUseOn  = sal_False;
     383                 :       1304 :     sal_Bool bFollow = sal_False;
     384         [ +  + ]:       1304 :     if ( pDesc->GetUseOn() != rChged.GetUseOn() )
     385                 :         12 :     {   pDesc->SetUseOn( rChged.GetUseOn() );
     386                 :         12 :         bUseOn = sal_True;
     387                 :            :     }
     388         [ +  + ]:       1304 :     if ( pDesc->GetFollow() != rChged.GetFollow() )
     389         [ -  + ]:         14 :     {   if ( rChged.GetFollow() == &rChged )
     390         [ #  # ]:          0 :         {   if ( pDesc->GetFollow() != pDesc )
     391                 :          0 :             {   pDesc->SetFollow( pDesc );
     392                 :          0 :                 bFollow = sal_True;
     393                 :            :             }
     394                 :            :         }
     395                 :            :         else
     396                 :         14 :         {   pDesc->SetFollow( rChged.pFollow );
     397                 :         14 :             bFollow = sal_True;
     398                 :            :         }
     399                 :            :     }
     400                 :            : 
     401 [ +  + ][ +  + ]:       1304 :     if ( (bUseOn || bFollow) && pTmpRoot)
                 [ +  + ]
     402                 :            :         // Inform layout!
     403                 :            :     {
     404         [ +  - ]:          2 :         std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     405 [ +  - ][ +  - ]:          2 :         std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));
     406                 :            :     }
     407                 :            : 
     408                 :            :     // Take over the page attributes.
     409         [ +  - ]:       1304 :     ::lcl_DescSetAttr( rChged.GetMaster(), pDesc->GetMaster() );
     410         [ +  - ]:       1304 :     ::lcl_DescSetAttr( rChged.GetLeft(), pDesc->GetLeft() );
     411         [ +  - ]:       1304 :     ::lcl_DescSetAttr( rChged.GetFirst(), pDesc->GetFirst() );
     412                 :            : 
     413                 :            :     // If the FootnoteInfo changes, the pages are triggered.
     414 [ +  - ][ +  + ]:       1304 :     if( !(pDesc->GetFtnInfo() == rChged.GetFtnInfo()) )
     415                 :            :     {
     416         [ +  - ]:         58 :         pDesc->SetFtnInfo( rChged.GetFtnInfo() );
     417         [ +  - ]:         58 :         SwMsgPoolItem  aInfo( RES_PAGEDESC_FTNINFO );
     418                 :            :         {
     419 [ +  - ][ +  - ]:         58 :             pDesc->GetMaster().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
     420                 :            :         }
     421                 :            :         {
     422 [ +  - ][ +  - ]:         58 :             pDesc->GetLeft().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
     423                 :            :         }
     424                 :            :         {
     425 [ +  - ][ +  - ]:         58 :             pDesc->GetFirst().ModifyBroadcast( &aInfo, 0, TYPE(SwFrm) );
     426         [ +  - ]:         58 :         }
     427                 :            :     }
     428         [ +  - ]:       1304 :     SetModified();
     429                 :            : 
     430                 :            :     // #i46909# no undo if header or footer changed
     431         [ -  + ]:       1304 :     if( bHeaderFooterChanged )
     432                 :            :     {
     433 [ #  # ][ #  # ]:          0 :         GetIDocumentUndoRedo().DelAllUndoObj();
     434         [ +  - ]:       1304 :     }
     435                 :       1304 : }
     436                 :            : 
     437                 :            : /*************************************************************************
     438                 :            : |*
     439                 :            : |*  SwDoc::DelPageDesc()
     440                 :            : |*
     441                 :            : |*  Description: All descriptors whose Follow point to the to-be-deleted
     442                 :            : |*  have to be adapted.
     443                 :            : |*
     444                 :            : |*************************************************************************/
     445                 :            : 
     446                 :            : // #i7983#
     447                 :        993 : void SwDoc::PreDelPageDesc(SwPageDesc * pDel)
     448                 :            : {
     449         [ +  - ]:        993 :     if (0 == pDel)
     450                 :        993 :         return;
     451                 :            : 
     452                 :            :     // mba: test iteration as clients are removed while iteration
     453         [ +  - ]:        993 :     SwPageDescHint aHint( aPageDescs[0] );
     454         [ +  - ]:        993 :     pDel->CallSwClientNotify( aHint );
     455                 :            : 
     456         [ +  - ]:        993 :     bool bHasLayout = HasLayout();
     457 [ +  - ][ -  + ]:        993 :     if ( pFtnInfo->DependsOn( pDel ) )
     458                 :            :     {
     459         [ #  # ]:          0 :         pFtnInfo->ChgPageDesc( aPageDescs[0] );
     460         [ #  # ]:          0 :         if ( bHasLayout )
     461                 :            :         {
     462         [ #  # ]:          0 :             std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     463 [ #  # ][ #  # ]:          0 :             std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFtnPageDescs), false));
                 [ #  # ]
     464                 :            :         }
     465                 :            :     }
     466 [ +  - ][ -  + ]:        993 :     else if ( pEndNoteInfo->DependsOn( pDel ) )
     467                 :            :     {
     468         [ #  # ]:          0 :         pEndNoteInfo->ChgPageDesc( aPageDescs[0] );
     469         [ #  # ]:          0 :         if ( bHasLayout )
     470                 :            :         {
     471         [ #  # ]:          0 :             std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     472 [ #  # ][ #  # ]:          0 :             std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::CheckFtnPageDescs), true));
                 [ #  # ]
     473                 :            :         }
     474                 :            :     }
     475                 :            : 
     476         [ +  + ]:       3102 :     for ( sal_uInt16 j = 0; j < aPageDescs.size(); ++j )
     477                 :            :     {
     478         [ +  + ]:       2109 :         if ( aPageDescs[j]->GetFollow() == pDel )
     479                 :            :         {
     480                 :         46 :             aPageDescs[j]->SetFollow( 0 );
     481         [ -  + ]:         46 :             if( bHasLayout )
     482                 :            :             {
     483         [ #  # ]:          0 :                 std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     484 [ #  # ][ #  # ]:          0 :                 std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::mem_fun(&SwRootFrm::AllCheckPageDescs));
     485                 :            :             }
     486                 :            :         }
     487         [ +  - ]:        993 :     }
     488                 :            : }
     489                 :            : 
     490                 :          0 : void SwDoc::BroadcastStyleOperation(String rName, SfxStyleFamily eFamily,
     491                 :            :                                     sal_uInt16 nOp)
     492                 :            : {
     493         [ #  # ]:          0 :     if (pDocShell)
     494                 :            :     {
     495                 :          0 :         SfxStyleSheetBasePool * pPool = pDocShell->GetStyleSheetPool();
     496                 :            : 
     497         [ #  # ]:          0 :         if (pPool)
     498                 :            :         {
     499                 :          0 :             pPool->SetSearchMask(eFamily, SFXSTYLEBIT_ALL );
     500                 :          0 :             SfxStyleSheetBase * pBase = pPool->Find(rName);
     501                 :            : 
     502         [ #  # ]:          0 :             if (pBase != NULL)
     503         [ #  # ]:          0 :                 pPool->Broadcast(SfxStyleSheetHint( nOp, *pBase ));
     504                 :            :         }
     505                 :            :     }
     506                 :          0 : }
     507                 :            : 
     508                 :         46 : void SwDoc::DelPageDesc( sal_uInt16 i, sal_Bool bBroadcast )
     509                 :            : {
     510                 :            :     OSL_ENSURE( i < aPageDescs.size(), "PageDescs is out of range." );
     511                 :            :     OSL_ENSURE( i != 0, "You cannot delete the default Pagedesc.");
     512         [ -  + ]:         46 :     if ( i == 0 )
     513                 :         46 :         return;
     514                 :            : 
     515                 :         46 :     SwPageDesc *pDel = aPageDescs[i];
     516                 :            : 
     517         [ -  + ]:         46 :     if (bBroadcast)
     518                 :          0 :         BroadcastStyleOperation(pDel->GetName(), SFX_STYLE_FAMILY_PAGE,
     519         [ #  # ]:          0 :                                 SFX_STYLESHEET_ERASED);
     520                 :            : 
     521         [ -  + ]:         46 :     if (GetIDocumentUndoRedo().DoesUndo())
     522                 :            :     {
     523         [ #  # ]:          0 :         SwUndo *const pUndo(new SwUndoPageDescDelete(*pDel, this));
     524                 :          0 :         GetIDocumentUndoRedo().AppendUndo(pUndo);
     525                 :            :     }
     526                 :            : 
     527                 :         46 :     PreDelPageDesc(pDel); // #i7983#
     528                 :            : 
     529 [ +  - ][ +  - ]:         46 :     aPageDescs.erase( aPageDescs.begin() + i );
     530         [ +  - ]:         46 :     delete pDel;
     531                 :         46 :     SetModified();
     532                 :            : }
     533                 :            : 
     534                 :            : 
     535                 :            : 
     536                 :            : /*************************************************************************
     537                 :            : |*
     538                 :            : |*  SwDoc::MakePageDesc()
     539                 :            : |*
     540                 :            : |*************************************************************************/
     541                 :            : 
     542                 :       1897 : sal_uInt16 SwDoc::MakePageDesc( const String &rName, const SwPageDesc *pCpy,
     543                 :            :                             sal_Bool bRegardLanguage, sal_Bool bBroadcast)
     544                 :            : {
     545                 :            :     SwPageDesc *pNew;
     546         [ +  + ]:       1897 :     if( pCpy )
     547                 :            :     {
     548 [ +  - ][ +  - ]:          6 :         pNew = new SwPageDesc( *pCpy );
     549         [ +  - ]:          6 :         pNew->SetName( rName );
     550 [ +  - ][ +  - ]:          6 :         if( rName != pCpy->GetName() )
     551                 :            :         {
     552                 :          6 :             pNew->SetPoolFmtId( USHRT_MAX );
     553                 :          6 :             pNew->SetPoolHelpId( USHRT_MAX );
     554                 :          6 :             pNew->SetPoolHlpFileId( UCHAR_MAX );
     555                 :            :         }
     556                 :            :     }
     557                 :            :     else
     558                 :            :     {
     559 [ +  - ][ +  - ]:       1891 :         pNew = new SwPageDesc( rName, GetDfltFrmFmt(), this );
     560                 :            :         // Set the default page format.
     561         [ +  - ]:       1891 :         lcl_DefaultPageFmt( USHRT_MAX, pNew->GetMaster(), pNew->GetLeft(), pNew->GetFirst() );
     562                 :            : 
     563                 :            :         SvxFrameDirection aFrameDirection = bRegardLanguage ?
     564         [ +  - ]:       1881 :             GetDefaultFrameDirection(GetAppLanguage())
     565 [ +  + ][ +  - ]:       3772 :             : FRMDIR_HORI_LEFT_TOP;
     566                 :            : 
     567 [ +  - ][ +  - ]:       1891 :         pNew->GetMaster().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
                 [ +  - ]
     568 [ +  - ][ +  - ]:       1891 :         pNew->GetLeft().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
                 [ +  - ]
     569 [ +  - ][ +  - ]:       1891 :         pNew->GetFirst().SetFmtAttr( SvxFrameDirectionItem(aFrameDirection, RES_FRAMEDIR) );
                 [ +  - ]
     570                 :            :     }
     571         [ +  - ]:       1897 :     aPageDescs.push_back( pNew );
     572                 :            : 
     573         [ -  + ]:       1897 :     if (bBroadcast)
     574                 :            :         BroadcastStyleOperation(rName, SFX_STYLE_FAMILY_PAGE,
     575 [ #  # ][ #  # ]:          0 :                                 SFX_STYLESHEET_CREATED);
                 [ #  # ]
     576                 :            : 
     577 [ +  - ][ +  - ]:       1897 :     if (GetIDocumentUndoRedo().DoesUndo())
                 [ +  + ]
     578                 :            :     {
     579 [ +  - ][ +  - ]:          4 :         GetIDocumentUndoRedo().AppendUndo(new SwUndoPageDescCreate(pNew, this));
         [ +  - ][ +  - ]
     580                 :            :     }
     581                 :            : 
     582         [ +  - ]:       1897 :     SetModified();
     583                 :       1897 :     return (aPageDescs.size()-1);
     584                 :            : }
     585                 :            : 
     586                 :       9216 : SwPageDesc* SwDoc::FindPageDescByName( const String& rName, sal_uInt16* pPos ) const
     587                 :            : {
     588                 :       9216 :     SwPageDesc* pRet = 0;
     589         [ +  + ]:       9216 :     if( pPos ) *pPos = USHRT_MAX;
     590                 :            : 
     591         [ +  + ]:      16060 :     for( sal_uInt16 n = 0, nEnd = aPageDescs.size(); n < nEnd; ++n )
     592         [ +  + ]:      13765 :         if( aPageDescs[ n ]->GetName() == rName )
     593                 :            :         {
     594                 :       6921 :             pRet = aPageDescs[ n ];
     595         [ +  + ]:       6921 :             if( pPos )
     596                 :       1159 :                 *pPos = n;
     597                 :       6921 :             break;
     598                 :            :         }
     599                 :       9216 :     return pRet;
     600                 :            : }
     601                 :            : 
     602                 :            : /******************************************************************************
     603                 :            :  *  Method      :   void SwDoc::PrtDataChanged()
     604                 :            :  *  Description :
     605                 :            :  ******************************************************************************/
     606                 :            : 
     607                 :         17 : void SwDoc::PrtDataChanged()
     608                 :            : {
     609                 :            : // If you change this, also modify InJobSetup in Sw3io if appropriate.
     610                 :            : 
     611                 :            :     // #i41075#
     612                 :            :     OSL_ENSURE( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) ||
     613                 :            :             0 != getPrinter( sal_False ), "PrtDataChanged will be called recursively!" );
     614                 :         17 :     SwRootFrm* pTmpRoot = GetCurrentLayout();
     615                 :         17 :     SwWait *pWait = 0;
     616                 :         17 :     sal_Bool bEndAction = sal_False;
     617                 :            : 
     618         [ +  - ]:         17 :     if( GetDocShell() )
     619                 :         17 :         GetDocShell()->UpdateFontList();
     620                 :            : 
     621                 :         17 :     sal_Bool bDraw = sal_True;
     622         [ -  + ]:         17 :     if ( pTmpRoot )
     623                 :            :     {
     624                 :          0 :         ViewShell *pSh = GetCurrentViewShell();
     625 [ #  # ][ #  #  :          0 :         if( pSh &&
             #  #  #  # ]
     626                 :          0 :             (!pSh->GetViewOptions()->getBrowseMode() ||
     627                 :          0 :              pSh->GetViewOptions()->IsPrtFormat()) )
     628                 :            :         {
     629         [ #  # ]:          0 :             if ( GetDocShell() )
     630 [ #  # ][ #  # ]:          0 :                 pWait = new SwWait( *GetDocShell(), sal_True );
     631                 :            : 
     632         [ #  # ]:          0 :             pTmpRoot->StartAllAction();
     633                 :          0 :             bEndAction = sal_True;
     634                 :            : 
     635                 :          0 :             bDraw = sal_False;
     636         [ #  # ]:          0 :             if( pDrawModel )
     637                 :            :             {
     638 [ #  # ][ #  # ]:          0 :                 pDrawModel->SetAddExtLeading( get(IDocumentSettingAccess::ADD_EXT_LEADING) );
     639 [ #  # ][ #  # ]:          0 :                 pDrawModel->SetRefDevice( getReferenceDevice( false ) );
     640                 :            :             }
     641                 :            : 
     642         [ #  # ]:          0 :             pFntCache->Flush();
     643                 :            : 
     644         [ #  # ]:          0 :             std::set<SwRootFrm*> aAllLayouts = GetAllLayouts();
     645 [ #  # ][ #  # ]:          0 :             std::for_each( aAllLayouts.begin(), aAllLayouts.end(),std::bind2nd(std::mem_fun(&SwRootFrm::InvalidateAllCntnt), INV_SIZE));
                 [ #  # ]
     646                 :            : 
     647         [ #  # ]:          0 :             do
     648                 :            :             {
     649         [ #  # ]:          0 :                 pSh->InitPrt( pPrt );
     650                 :          0 :                 pSh = (ViewShell*)pSh->GetNext();
     651                 :            :             }
     652         [ #  # ]:          0 :             while ( pSh != GetCurrentViewShell() );
     653                 :            :         }
     654                 :            :     }
     655 [ +  - ][ +  + ]:         17 :     if ( bDraw && pDrawModel )
     656                 :            :     {
     657                 :          9 :         const sal_Bool bTmpAddExtLeading = get(IDocumentSettingAccess::ADD_EXT_LEADING);
     658         [ -  + ]:          9 :         if ( bTmpAddExtLeading != pDrawModel->IsAddExtLeading() )
     659                 :          0 :             pDrawModel->SetAddExtLeading( bTmpAddExtLeading );
     660                 :            : 
     661                 :          9 :         OutputDevice* pOutDev = getReferenceDevice( false );
     662         [ -  + ]:          9 :         if ( pOutDev != pDrawModel->GetRefDevice() )
     663                 :          0 :             pDrawModel->SetRefDevice( pOutDev );
     664                 :            :     }
     665                 :            : 
     666                 :         17 :     PrtOLENotify( sal_True );
     667                 :            : 
     668         [ -  + ]:         17 :     if ( bEndAction )
     669                 :          0 :         pTmpRoot->EndAllAction();
     670         [ -  + ]:         17 :     delete pWait;
     671                 :         17 : }
     672                 :            : 
     673                 :            : // We collect the GlobalNames of the servers at runtime, who don't want to be notified
     674                 :            : // about printer changes. Thereby saving loading a lot of objects (luckily all foreign
     675                 :            : // objects are mapped to one ID).
     676                 :            : // Initialisation and deinitialisation can be found in init.cxx
     677                 :            : extern std::vector<SvGlobalName*> *pGlobalOLEExcludeList;
     678                 :            : 
     679                 :         33 : void SwDoc::PrtOLENotify( sal_Bool bAll )
     680                 :            : {
     681                 :         33 :     SwFEShell *pShell = 0;
     682         [ +  + ]:         33 :     if ( GetCurrentViewShell() )
     683                 :            :     {
     684                 :          9 :         ViewShell *pSh = GetCurrentViewShell();
     685         [ -  + ]:          9 :         if ( !pSh->ISA(SwFEShell) )
     686         [ #  # ]:          0 :             do
           [ #  #  #  # ]
     687                 :          0 :             {   pSh = (ViewShell*)pSh->GetNext();
     688                 :          0 :             } while ( !pSh->ISA(SwFEShell) &&
     689                 :          0 :                       pSh != GetCurrentViewShell() );
     690                 :            : 
     691         [ +  - ]:          9 :         if ( pSh->ISA(SwFEShell) )
     692                 :          9 :             pShell = (SwFEShell*)pSh;
     693                 :            :     }
     694         [ +  + ]:         33 :     if ( !pShell )
     695                 :            :     {
     696                 :            :         // This doesn't make sense without a Shell and thus without a client, because
     697                 :            :         // the communication about size changes is implemented by these components.
     698                 :            :         // Because we don't have a Shell we remember this unfortunate situation
     699                 :            :         // in the document,
     700                 :            :         // which is made up for later on when creating the first Shell.
     701                 :         24 :         mbOLEPrtNotifyPending = sal_True;
     702         [ +  - ]:         24 :         if ( bAll )
     703                 :         24 :             mbAllOLENotify = sal_True;
     704                 :            :     }
     705                 :            :     else
     706                 :            :     {
     707         [ +  + ]:          9 :         if ( mbAllOLENotify )
     708                 :          7 :             bAll = sal_True;
     709                 :            : 
     710                 :          9 :         mbOLEPrtNotifyPending = mbAllOLENotify = sal_False;
     711                 :            : 
     712                 :          9 :         SwOLENodes *pNodes = SwCntntNode::CreateOLENodesArray( *GetDfltGrfFmtColl(), !bAll );
     713         [ -  + ]:          9 :         if ( pNodes )
     714                 :            :         {
     715                 :            :             ::StartProgress( STR_STATSTR_SWGPRTOLENOTIFY,
     716                 :          0 :                              0, pNodes->size(), GetDocShell());
     717                 :          0 :             GetCurrentLayout()->StartAllAction();
     718                 :            : 
     719         [ #  # ]:          0 :             for( sal_uInt16 i = 0; i < pNodes->size(); ++i )
     720                 :            :             {
     721         [ #  # ]:          0 :                 ::SetProgressState( i, GetDocShell() );
     722                 :            : 
     723         [ #  # ]:          0 :                 SwOLENode* pOLENd = (*pNodes)[i];
     724                 :          0 :                 pOLENd->SetOLESizeInvalid( sal_False );
     725                 :            : 
     726                 :            :                 // At first load the Infos and see if it's not already in the exclude list.
     727         [ #  # ]:          0 :                 SvGlobalName aName;
     728                 :            : 
     729         [ #  # ]:          0 :                 svt::EmbeddedObjectRef& xObj = pOLENd->GetOLEObj().GetObject();
     730         [ #  # ]:          0 :                 if ( xObj.is() )
     731 [ #  # ][ #  # ]:          0 :                     aName = SvGlobalName( xObj->getClassID() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     732                 :            :                 else  // Not yet loaded
     733                 :            :                 {
     734                 :            :                         // TODO/LATER: retrieve ClassID of an unloaded object
     735                 :            :                         // aName = ????
     736                 :            :                 }
     737                 :            : 
     738                 :          0 :                 sal_Bool bFound = sal_False;
     739 [ #  # ][ #  # ]:          0 :                 for ( sal_uInt16 j = 0;
                 [ #  # ]
     740                 :          0 :                       j < pGlobalOLEExcludeList->size() && !bFound;
     741                 :            :                       ++j )
     742                 :            :                 {
     743 [ #  # ][ #  # ]:          0 :                     bFound = *(*pGlobalOLEExcludeList)[j] == aName;
     744                 :            :                 }
     745         [ #  # ]:          0 :                 if ( bFound )
     746                 :          0 :                     continue;
     747                 :            : 
     748                 :            :                 // We don't know it, so the object has to be loaded.
     749                 :            :                 // If it doesn't want to be informed
     750         [ #  # ]:          0 :                 if ( xObj.is() )
     751                 :            :                 {
     752 [ #  # ][ #  # ]:          0 :                         pGlobalOLEExcludeList->push_back( new SvGlobalName( aName ) );
     753                 :            :                 }
     754 [ #  # ][ #  # ]:          0 :             }
     755         [ #  # ]:          0 :             delete pNodes;
     756                 :          0 :             GetCurrentLayout()->EndAllAction();
     757                 :          0 :             ::EndProgress( GetDocShell() );
     758                 :            :         }
     759                 :            :     }
     760                 :         33 : }
     761                 :            : 
     762                 :          0 : IMPL_LINK( SwDoc, DoUpdateModifiedOLE, Timer *, )
     763                 :            : {
     764                 :          0 :     SwFEShell* pSh = (SwFEShell*)GetEditShell();
     765         [ #  # ]:          0 :     if( pSh )
     766                 :            :     {
     767                 :          0 :         mbOLEPrtNotifyPending = mbAllOLENotify = sal_False;
     768                 :            : 
     769                 :          0 :         SwOLENodes *pNodes = SwCntntNode::CreateOLENodesArray( *GetDfltGrfFmtColl(), true );
     770         [ #  # ]:          0 :         if( pNodes )
     771                 :            :         {
     772                 :            :             ::StartProgress( STR_STATSTR_SWGPRTOLENOTIFY,
     773         [ #  # ]:          0 :                              0, pNodes->size(), GetDocShell());
     774 [ #  # ][ #  # ]:          0 :             GetCurrentLayout()->StartAllAction();
     775         [ #  # ]:          0 :             SwMsgPoolItem aMsgHint( RES_UPDATE_ATTR );
     776                 :            : 
     777         [ #  # ]:          0 :             for( sal_uInt16 i = 0; i < pNodes->size(); ++i )
     778                 :            :             {
     779         [ #  # ]:          0 :                 ::SetProgressState( i, GetDocShell() );
     780                 :            : 
     781         [ #  # ]:          0 :                 SwOLENode* pOLENd = (*pNodes)[i];
     782                 :          0 :                 pOLENd->SetOLESizeInvalid( sal_False );
     783                 :            : 
     784                 :            :                 // We don't know it, so the object has to be loaded.
     785                 :            :                 // If it doesn't want to be informed
     786 [ #  # ][ #  # ]:          0 :                 if( pOLENd->GetOLEObj().GetOleRef().is() ) // Broken?
     787                 :            :                 {
     788         [ #  # ]:          0 :                     pOLENd->ModifyNotification( &aMsgHint, &aMsgHint );
     789                 :            :                 }
     790                 :            :             }
     791 [ #  # ][ #  # ]:          0 :             GetCurrentLayout()->EndAllAction();
     792         [ #  # ]:          0 :             ::EndProgress( GetDocShell() );
     793 [ #  # ][ #  # ]:          0 :             delete pNodes;
     794                 :            :         }
     795                 :            :     }
     796                 :          0 :     return 0;
     797                 :            : }
     798                 :            : 
     799                 :          4 : sal_Bool SwDoc::FindPageDesc( const String & rName, sal_uInt16 * pFound)
     800                 :            : {
     801                 :          4 :     sal_Bool bResult = sal_False;
     802                 :            :     sal_uInt16 nI;
     803         [ +  - ]:          8 :     for (nI = 0; nI < aPageDescs.size(); nI++)
     804                 :            :     {
     805         [ +  + ]:          8 :         if (aPageDescs[nI]->GetName() == rName)
     806                 :            :         {
     807                 :          4 :             *pFound = nI;
     808                 :          4 :             bResult = sal_True;
     809                 :          4 :             break;
     810                 :            :         }
     811                 :            :     }
     812                 :            : 
     813                 :          4 :     return bResult;
     814                 :            : }
     815                 :            : 
     816                 :          0 : SwPageDesc * SwDoc::GetPageDesc( const String & rName )
     817                 :            : {
     818                 :          0 :     SwPageDesc * aResult = NULL;
     819                 :            : 
     820                 :            :     sal_uInt16 nI;
     821                 :            : 
     822 [ #  # ][ #  # ]:          0 :     if (FindPageDesc(rName, &nI))
     823                 :          0 :         aResult = aPageDescs[nI];
     824                 :            : 
     825                 :          0 :     return aResult;
     826                 :            : }
     827                 :            : 
     828                 :          0 : void SwDoc::DelPageDesc( const String & rName, sal_Bool bBroadcast )
     829                 :            : {
     830                 :            :     sal_uInt16 nI;
     831                 :            : 
     832 [ #  # ][ #  # ]:          0 :     if (FindPageDesc(rName, &nI))
     833         [ #  # ]:          0 :         DelPageDesc(nI, bBroadcast);
     834                 :          0 : }
     835                 :            : 
     836                 :          4 : void SwDoc::ChgPageDesc( const String & rName, const SwPageDesc & rDesc)
     837                 :            : {
     838                 :            :     sal_uInt16 nI;
     839                 :            : 
     840 [ +  - ][ +  - ]:          4 :     if (FindPageDesc(rName, &nI))
     841         [ +  - ]:          4 :         ChgPageDesc(nI, rDesc);
     842                 :          4 : }
     843                 :            : 
     844                 :            : /*
     845                 :            :  * The HTML import cannot resist changing the page descriptions, I don't
     846                 :            :  * know why. This function is meant to check the page descriptors for invalid
     847                 :            :  * values.
     848                 :            :  */
     849                 :       1337 : void SwDoc::CheckDefaultPageFmt()
     850                 :            : {
     851         [ +  + ]:       2845 :     for ( sal_uInt16 i = 0; i < GetPageDescCnt(); ++i )
     852                 :            :     {
     853                 :       1508 :         SwPageDesc& rDesc = GetPageDesc( i );
     854                 :            : 
     855                 :       1508 :         SwFrmFmt& rMaster = rDesc.GetMaster();
     856                 :       1508 :         SwFrmFmt& rLeft   = rDesc.GetLeft();
     857                 :            : 
     858                 :       1508 :         const SwFmtFrmSize& rMasterSize  = rMaster.GetFrmSize();
     859                 :       1508 :         const SwFmtFrmSize& rLeftSize    = rLeft.GetFrmSize();
     860                 :            : 
     861                 :       1508 :         const bool bSetSize = LONG_MAX == rMasterSize.GetWidth() ||
     862                 :       1508 :                               LONG_MAX == rMasterSize.GetHeight() ||
     863                 :       1508 :                               LONG_MAX == rLeftSize.GetWidth() ||
     864 [ -  + ][ +  -  :       4524 :                               LONG_MAX == rLeftSize.GetHeight();
             +  -  +  - ]
     865                 :            : 
     866         [ -  + ]:       1508 :         if ( bSetSize )
     867                 :          0 :             lcl_DefaultPageFmt( rDesc.GetPoolFmtId(), rDesc.GetMaster(), rDesc.GetLeft(), rDesc.GetFirst() );
     868                 :            :     }
     869                 :       1337 : }
     870                 :            : 
     871                 :       1804 : void SwDoc::SetDefaultPageMode(bool bSquaredPageMode)
     872                 :            : {
     873 [ +  - ][ +  + ]:       1804 :     if( !bSquaredPageMode == !IsSquaredPageMode() )
     874                 :       1804 :         return;
     875                 :            : 
     876                 :            :     const SwTextGridItem& rGrid =
     877         [ +  - ]:        102 :                     (const SwTextGridItem&)GetDefault( RES_TEXTGRID );
     878         [ +  - ]:        102 :     SwTextGridItem aNewGrid = rGrid;
     879                 :        102 :     aNewGrid.SetSquaredMode(bSquaredPageMode);
     880         [ +  - ]:        102 :     aNewGrid.Init();
     881         [ +  - ]:        102 :     SetDefault(aNewGrid);
     882                 :            : 
     883         [ +  + ]:        306 :     for ( sal_uInt16 i = 0; i < GetPageDescCnt(); ++i )
     884                 :            :     {
     885         [ +  - ]:        204 :         SwPageDesc& rDesc = GetPageDesc( i );
     886                 :            : 
     887                 :        204 :         SwFrmFmt& rMaster = rDesc.GetMaster();
     888                 :        204 :         SwFrmFmt& rLeft = rDesc.GetLeft();
     889                 :            : 
     890 [ +  - ][ +  - ]:        204 :         SwTextGridItem aGrid((SwTextGridItem&)rMaster.GetFmtAttr(RES_TEXTGRID));
     891         [ +  - ]:        204 :         aGrid.SwitchPaperMode( bSquaredPageMode );
     892         [ +  - ]:        204 :         rMaster.SetFmtAttr(aGrid);
     893         [ +  - ]:        204 :         rLeft.SetFmtAttr(aGrid);
     894 [ +  - ][ +  - ]:       2008 :     }
     895                 :            : }
     896                 :            : 
     897                 :      18226 : sal_Bool SwDoc::IsSquaredPageMode() const
     898                 :            : {
     899                 :            :     const SwTextGridItem& rGrid =
     900                 :      18226 :                         (const SwTextGridItem&)GetDefault( RES_TEXTGRID );
     901                 :      18226 :     return rGrid.IsSquaredMode();
     902                 :            : }
     903                 :            : 
     904                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10