LCOV - code coverage report
Current view: top level - sw/source/core/layout - pagechg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 792 1144 69.2 %
Date: 2012-08-25 Functions: 37 44 84.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 721 1452 49.7 %

           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 <com/sun/star/embed/EmbedStates.hpp>
      31                 :            : #include <ndole.hxx>
      32                 :            : #include <docary.hxx>
      33                 :            : #include <svl/itemiter.hxx>
      34                 :            : #include <fmtfsize.hxx>
      35                 :            : #include <fmthdft.hxx>
      36                 :            : #include <fmtclds.hxx>
      37                 :            : #include <fmtanchr.hxx>
      38                 :            : #include <fmtpdsc.hxx>
      39                 :            : #include <fmtfordr.hxx>
      40                 :            : #include <fmtfld.hxx>
      41                 :            : #include <fmtornt.hxx>
      42                 :            : #include <fmtsrnd.hxx>
      43                 :            : #include <ftninfo.hxx>
      44                 :            : #include <tgrditem.hxx>
      45                 :            : #include <viewopt.hxx>
      46                 :            : #include <docsh.hxx>
      47                 :            : #include <wrtsh.hxx>
      48                 :            : #include <view.hxx>
      49                 :            : #include <edtwin.hxx>
      50                 :            : 
      51                 :            : #include "viewimp.hxx"
      52                 :            : #include "viewopt.hxx"
      53                 :            : #include "pagefrm.hxx"
      54                 :            : #include "rootfrm.hxx"
      55                 :            : #include "cntfrm.hxx"
      56                 :            : #include "flyfrm.hxx"
      57                 :            : #include "doc.hxx"
      58                 :            : #include "fesh.hxx"
      59                 :            : #include "dview.hxx"
      60                 :            : #include "dflyobj.hxx"
      61                 :            : #include "dcontact.hxx"
      62                 :            : #include "frmtool.hxx"
      63                 :            : #include "fldbas.hxx"
      64                 :            : #include "hints.hxx"
      65                 :            : #include "swtable.hxx"
      66                 :            : 
      67                 :            : #include "ftnidx.hxx"
      68                 :            : #include "bodyfrm.hxx"
      69                 :            : #include "ftnfrm.hxx"
      70                 :            : #include "tabfrm.hxx"
      71                 :            : #include "txtfrm.hxx"
      72                 :            : #include "layact.hxx"
      73                 :            : #include "flyfrms.hxx"
      74                 :            : #include "htmltbl.hxx"
      75                 :            : #include "pagedesc.hxx"
      76                 :            : #include "poolfmt.hxx"
      77                 :            : #include <editeng/frmdiritem.hxx>
      78                 :            : #include <swfntcch.hxx> // SwFontAccess
      79                 :            : #include <sortedobjs.hxx>
      80                 :            : #include <switerator.hxx>
      81                 :            : #include <vcl/svapp.hxx>
      82                 :            : 
      83                 :            : using namespace ::com::sun::star;
      84                 :            : 
      85                 :            : 
      86                 :            : /*************************************************************************
      87                 :            : |*
      88                 :            : |*  SwBodyFrm::SwBodyFrm()
      89                 :            : |*
      90                 :            : |*************************************************************************/
      91                 :       1540 : SwBodyFrm::SwBodyFrm( SwFrmFmt *pFmt, SwFrm* pSib ):
      92                 :       1540 :     SwLayoutFrm( pFmt, pSib )
      93                 :            : {
      94                 :       1540 :     nType = FRMC_BODY;
      95                 :       1540 : }
      96                 :            : 
      97                 :            : /*************************************************************************
      98                 :            : |*
      99                 :            : |*  SwBodyFrm::Format()
     100                 :            : |*
     101                 :            : |*************************************************************************/
     102                 :       2111 : void SwBodyFrm::Format( const SwBorderAttrs * )
     103                 :            : {
     104                 :            :     //Formatieren des Body ist zu einfach, deshalb bekommt er ein eigenes
     105                 :            :     //Format; Umrandungen und dergl. sind hier nicht zu beruecksichtigen.
     106                 :            :     //Breite ist die der PrtArea des Uppers, Hoehe ist die Hoehe der PrtArea
     107                 :            :     //des Uppers abzueglich der Nachbarn (Wird eigentlich eingestellt aber
     108                 :            :     //Vorsicht ist die Mutter der Robustheit).
     109                 :            :     //Die PrtArea ist stets so gross wie der Frm itself.
     110                 :            : 
     111         [ +  + ]:       2111 :     if ( !bValidSize )
     112                 :            :     {
     113                 :       1888 :         SwTwips nHeight = GetUpper()->Prt().Height();
     114                 :       1888 :         SwTwips nWidth = GetUpper()->Prt().Width();
     115                 :       1888 :         const SwFrm *pFrm = GetUpper()->Lower();
     116         [ +  + ]:       1898 :         do
     117                 :            :         {
     118         [ +  + ]:       1898 :             if ( pFrm != this )
     119                 :            :             {
     120         [ -  + ]:         10 :                 if( pFrm->IsVertical() )
     121                 :          0 :                     nWidth -= pFrm->Frm().Width();
     122                 :            :                 else
     123                 :         10 :                     nHeight -= pFrm->Frm().Height();
     124                 :            :             }
     125                 :       1898 :             pFrm = pFrm->GetNext();
     126                 :            :         } while ( pFrm );
     127         [ +  + ]:       1888 :         if ( nHeight < 0 )
     128                 :          6 :             nHeight = 0;
     129                 :       1888 :         Frm().Height( nHeight );
     130                 :            :         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     131 [ +  - ][ +  - ]:       1888 :         if( IsVertical() && !IsVertLR() && !IsReverse() && nWidth != Frm().Width() )
         [ -  + ][ -  + ]
                 [ +  + ]
     132                 :          0 :             Frm().Pos().X() += Frm().Width() - nWidth;
     133                 :       1888 :         Frm().Width( nWidth );
     134                 :            :     }
     135                 :            : 
     136                 :       2111 :     sal_Bool bNoGrid = sal_True;
     137 [ +  + ][ -  + ]:       2111 :     if( GetUpper()->IsPageFrm() && ((SwPageFrm*)GetUpper())->HasGrid() )
                 [ -  + ]
     138                 :            :     {
     139 [ #  # ][ #  # ]:          0 :         GETGRID( ((SwPageFrm*)GetUpper()) )
         [ #  # ][ #  # ]
     140         [ #  # ]:          0 :         if( pGrid )
     141                 :            :         {
     142                 :          0 :             bNoGrid = sal_False;
     143                 :          0 :             long nSum = pGrid->GetBaseHeight() + pGrid->GetRubyHeight();
     144 [ #  # ][ #  # ]:          0 :             SWRECTFN( this )
         [ #  # ][ #  # ]
     145         [ #  # ]:          0 :             long nSize = (Frm().*fnRect->fnGetWidth)();
     146                 :          0 :             long nBorder = 0;
     147         [ #  # ]:          0 :             if( GRID_LINES_CHARS == pGrid->GetGridType() )
     148                 :            :             {
     149                 :            :                 //for textgrid refactor
     150                 :          0 :                 SwDoc *pDoc = GetFmt()->GetDoc();
     151         [ #  # ]:          0 :                 nBorder = nSize % (GETGRIDWIDTH(pGrid, pDoc));
     152                 :          0 :                 nSize -= nBorder;
     153                 :          0 :                 nBorder /= 2;
     154                 :            :             }
     155         [ #  # ]:          0 :             (Prt().*fnRect->fnSetPosX)( nBorder );
     156         [ #  # ]:          0 :             (Prt().*fnRect->fnSetWidth)( nSize );
     157                 :            : 
     158                 :            :             // Height of body frame:
     159         [ #  # ]:          0 :             nBorder = (Frm().*fnRect->fnGetHeight)();
     160                 :            : 
     161                 :            :             // Number of possible lines in area of body frame:
     162                 :          0 :             long nNumberOfLines = nBorder / nSum;
     163         [ #  # ]:          0 :             if( nNumberOfLines > pGrid->GetLines() )
     164                 :          0 :                 nNumberOfLines = pGrid->GetLines();
     165                 :            : 
     166                 :            :             // Space required for nNumberOfLines lines:
     167                 :          0 :             nSize = nNumberOfLines * nSum;
     168                 :          0 :             nBorder -= nSize;
     169                 :          0 :             nBorder /= 2;
     170                 :            : 
     171                 :            :             // #i21774# Footnotes and centering the grid does not work together:
     172                 :          0 :             const bool bAdjust = ((SwPageFrm*)GetUpper())->GetFmt()->GetDoc()->
     173                 :          0 :                                         GetFtnIdxs().empty();
     174                 :            : 
     175 [ #  # ][ #  # ]:          0 :             (Prt().*fnRect->fnSetPosY)( bAdjust ? nBorder : 0 );
     176         [ #  # ]:          0 :             (Prt().*fnRect->fnSetHeight)( nSize );
     177                 :            :         }
     178                 :            :     }
     179         [ +  - ]:       2111 :     if( bNoGrid )
     180                 :            :     {
     181                 :       2111 :         Prt().Pos().X() = Prt().Pos().Y() = 0;
     182                 :       2111 :         Prt().Height( Frm().Height() );
     183                 :       2111 :         Prt().Width( Frm().Width() );
     184                 :            :     }
     185                 :       2111 :     bValidSize = bValidPrtArea = sal_True;
     186                 :       2111 : }
     187                 :            : 
     188                 :      12288 : void SwBodyFrm::Paint( const SwRect& rRect, const SwPrintData* ) const
     189                 :            : {
     190                 :            : #if OSL_DEBUG_LAYOUT > 1
     191                 :            :     // Paint a red border around the SwBodyFrm in debug mode
     192                 :            :     ViewShell *pSh = GetShell();
     193                 :            :     OutputDevice* pOut =  pSh->GetOut();
     194                 :            :     pOut->Push();
     195                 :            :     pOut->SetLineColor(Color(255, 0, 0));
     196                 :            :     pOut->SetFillColor(COL_TRANSPARENT);
     197                 :            :     SwRect aRect = Frm();
     198                 :            :     pOut->DrawRect(aRect.SVRect());
     199                 :            :     pOut->Pop();
     200                 :            : #endif
     201                 :      12288 :     SwLayoutFrm::Paint(rRect);
     202                 :      12288 : }
     203                 :            : 
     204                 :            : /*************************************************************************
     205                 :            : |*
     206                 :            : |*  SwPageFrm::SwPageFrm(), ~SwPageFrm()
     207                 :            : |*
     208                 :            : |*************************************************************************/
     209                 :       1419 : SwPageFrm::SwPageFrm( SwFrmFmt *pFmt, SwFrm* pSib, SwPageDesc *pPgDsc ) :
     210                 :            :     SwFtnBossFrm( pFmt, pSib ),
     211                 :            :     pSortedObjs( 0 ),
     212                 :            :     pDesc( pPgDsc ),
     213                 :            :     nPhyPageNum( 0 ),
     214                 :            :     // OD 2004-05-17 #i28701#
     215                 :       1419 :     mbLayoutInProgress( false )
     216                 :            : {
     217                 :       1419 :     SetDerivedVert( sal_False );
     218                 :       1419 :     SetDerivedR2L( sal_False );
     219         [ +  - ]:       1419 :     if( pDesc )
     220                 :            :     {
     221                 :       1419 :         bHasGrid = sal_True;
     222 [ +  - ][ +  - ]:       1419 :         GETGRID( this )
         [ +  - ][ +  - ]
                 [ +  - ]
     223         [ +  - ]:       1419 :         if( !pGrid )
     224                 :       1419 :             bHasGrid = sal_False;
     225                 :            :     }
     226                 :            :     else
     227                 :          0 :         bHasGrid = sal_False;
     228                 :       1419 :     SetMaxFtnHeight( pPgDsc->GetFtnInfo().GetHeight() ?
     229         [ -  + ]:       1419 :                      pPgDsc->GetFtnInfo().GetHeight() : LONG_MAX ),
     230                 :       1419 :     nType = FRMC_PAGE;
     231                 :       1419 :     bInvalidLayout = bInvalidCntnt = bInvalidSpelling = bInvalidSmartTags = bInvalidAutoCmplWrds = bInvalidWordCount = sal_True;
     232                 :       1419 :     bInvalidFlyLayout = bInvalidFlyCntnt = bInvalidFlyInCnt = bFtnPage = bEndNotePage = sal_False;
     233                 :            : 
     234                 :       1419 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
     235 [ +  + ][ +  - ]:       1419 :     const bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
     236         [ +  + ]:       1419 :     if ( bBrowseMode )
     237                 :            :     {
     238                 :          4 :         Frm().Height( 0 );
     239                 :          4 :         long nWidth = pSh->VisArea().Width();
     240         [ +  - ]:          4 :         if ( !nWidth )
     241                 :          4 :             nWidth = 5000L;     //aendert sich sowieso
     242                 :          4 :         Frm().Width ( nWidth );
     243                 :            :     }
     244                 :            :     else
     245         [ +  - ]:       1415 :         Frm().SSize( pFmt->GetFrmSize().GetSize() );
     246                 :            : 
     247                 :            :     //Body-Bereich erzeugen und einsetzen, aber nur wenn ich nicht gerade
     248                 :            :     //eine Leerseite bin.
     249                 :       1419 :     SwDoc *pDoc = pFmt->GetDoc();
     250         [ +  + ]:       1419 :     if ( sal_False == (bEmptyPage = (pFmt == pDoc->GetEmptyPageFmt())) )
     251                 :            :     {
     252                 :       1416 :         bEmptyPage = sal_False;
     253         [ +  - ]:       1416 :         Calc();                             //Damit die PrtArea stimmt.
     254 [ +  - ][ +  - ]:       1416 :         SwBodyFrm *pBodyFrm = new SwBodyFrm( pDoc->GetDfltFrmFmt(), this );
     255         [ +  - ]:       1416 :         pBodyFrm->ChgSize( Prt().SSize() );
     256         [ +  - ]:       1416 :         pBodyFrm->Paste( this );
     257         [ +  - ]:       1416 :         pBodyFrm->Calc();                   //Damit die Spalten korrekt
     258                 :            :                                             //eingesetzt werden koennen.
     259         [ +  - ]:       1416 :         pBodyFrm->InvalidatePos();
     260                 :            : 
     261         [ +  + ]:       1416 :         if ( bBrowseMode )
     262         [ +  - ]:          4 :             _InvalidateSize();      //Alles nur gelogen
     263                 :            : 
     264                 :            :         //Header/Footer einsetzen, nur rufen wenn aktiv.
     265 [ +  - ][ +  + ]:       1416 :         if ( pFmt->GetHeader().IsActive() )
     266         [ +  - ]:         36 :             PrepareHeader();
     267 [ +  - ][ +  + ]:       1416 :         if ( pFmt->GetFooter().IsActive() )
     268         [ +  - ]:         28 :             PrepareFooter();
     269                 :            : 
     270         [ +  - ]:       1416 :         const SwFmtCol &rCol = pFmt->GetCol();
     271 [ +  - ][ +  + ]:       1416 :         if ( rCol.GetNumCols() > 1 )
     272                 :            :         {
     273         [ +  - ]:          6 :             const SwFmtCol aOld; //ChgColumns() verlaesst sich darauf, dass ein
     274                 :            :                                  //Old-Wert hereingereicht wird.
     275 [ +  - ][ +  - ]:          6 :             pBodyFrm->ChgColumns( aOld, rCol );
     276                 :            :         }
     277                 :            :     }
     278                 :       1419 : }
     279                 :            : 
     280                 :       1326 : SwPageFrm::~SwPageFrm()
     281                 :            : {
     282                 :            :     // Cleanup the header-footer controls in the SwEditWin
     283                 :       1326 :     ViewShell* pSh = getRootFrm()->GetCurrShell();
     284         [ +  + ]:       1326 :     SwWrtShell* pWrtSh = dynamic_cast< SwWrtShell* >( pSh );
     285         [ +  + ]:       1326 :     if ( pWrtSh )
     286                 :            :     {
     287                 :         16 :         SwEditWin& rEditWin = pWrtSh->GetView().GetEditWin();
     288         [ +  - ]:         16 :         rEditWin.GetFrameControlsManager( ).RemoveControls( this );
     289                 :            :     }
     290                 :            : 
     291                 :            :     //FlyContainer entleeren, delete der Flys uebernimmt der Anchor
     292                 :            :     //(Basisklasse SwFrm)
     293         [ +  + ]:       1326 :     if ( pSortedObjs )
     294                 :            :     {
     295                 :            :         //Objekte koennen (warum auch immer) auch an Seiten verankert sein,
     296                 :            :         //die vor Ihren Ankern stehen. Dann wuerde auf bereits freigegebenen
     297                 :            :         //Speicher zugegriffen.
     298 [ +  - ][ +  + ]:        272 :         for ( sal_uInt16 i = 0; i < pSortedObjs->Count(); ++i )
     299                 :            :         {
     300         [ +  - ]:        172 :             SwAnchoredObject* pAnchoredObj = (*pSortedObjs)[i];
     301         [ +  - ]:        172 :             pAnchoredObj->SetPageFrm( 0L );
     302                 :            :         }
     303 [ +  - ][ +  - ]:        100 :         delete pSortedObjs;
     304                 :        100 :         pSortedObjs = 0;        //Auf 0 setzen, sonst rauchts beim Abmdelden von Flys!
     305                 :            :     }
     306                 :            : 
     307                 :            :     //Damit der Zugriff auf zerstoerte Seiten verhindert werden kann.
     308         [ +  + ]:       1326 :     if ( !IsEmptyPage() ) //#59184# sollte fuer Leerseiten unnoetig sein.
     309                 :            :     {
     310 [ +  - ][ +  - ]:       1323 :         SwDoc *pDoc = GetFmt() ? GetFmt()->GetDoc() : NULL;
                 [ +  - ]
     311 [ +  - ][ +  - ]:       1323 :         if( pDoc && !pDoc->IsInDtor() )
                 [ +  - ]
     312                 :            :         {
     313         [ +  + ]:       1323 :             if ( pSh )
     314                 :            :             {
     315                 :         16 :                 SwViewImp *pImp = pSh->Imp();
     316                 :         16 :                 pImp->SetFirstVisPageInvalid();
     317         [ +  - ]:         16 :                 if ( pImp->IsAction() )
     318                 :         16 :                     pImp->GetLayAction().SetAgain();
     319                 :            :                 // OD 12.02.2003 #i9719#, #105645# - retouche area of page
     320                 :            :                 // including border and shadow area.
     321         [ +  - ]:         16 :                 const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
     322                 :         16 :                 SwRect aRetoucheRect;
     323 [ +  - ][ +  - ]:         16 :                 SwPageFrm::GetBorderAndShadowBoundRect( Frm(), pSh, aRetoucheRect, IsLeftShadowNeeded(), IsRightShadowNeeded(), bRightSidebar );
                 [ +  - ]
     324         [ +  - ]:         16 :                 pSh->AddPaintRect( aRetoucheRect );
     325                 :            :             }
     326                 :            :         }
     327                 :            :     }
     328         [ -  + ]:       2652 : }
     329                 :            : 
     330                 :            : 
     331                 :          0 : void SwPageFrm::CheckGrid( sal_Bool bInvalidate )
     332                 :            : {
     333                 :          0 :     sal_Bool bOld = bHasGrid;
     334                 :          0 :     bHasGrid = sal_True;
     335 [ #  # ][ #  # ]:          0 :     GETGRID( this )
         [ #  # ][ #  # ]
     336                 :          0 :     bHasGrid = 0 != pGrid;
     337 [ #  # ][ #  # ]:          0 :     if( bInvalidate || bOld != bHasGrid )
     338                 :            :     {
     339                 :          0 :         SwLayoutFrm* pBody = FindBodyCont();
     340         [ #  # ]:          0 :         if( pBody )
     341                 :            :         {
     342                 :          0 :             pBody->InvalidatePrt();
     343                 :          0 :             SwCntntFrm* pFrm = pBody->ContainsCntnt();
     344         [ #  # ]:          0 :             while( pBody->IsAnLower( pFrm ) )
     345                 :            :             {
     346                 :          0 :                 ((SwTxtFrm*)pFrm)->Prepare( PREP_CLEAR );
     347                 :          0 :                 pFrm = pFrm->GetNextCntntFrm();
     348                 :            :             }
     349                 :            :         }
     350                 :          0 :         SetCompletePaint();
     351                 :            :     }
     352                 :          0 : }
     353                 :            : 
     354                 :            : 
     355                 :       2927 : void SwPageFrm::CheckDirection( sal_Bool bVert )
     356                 :            : {
     357                 :            :     sal_uInt16 nDir =
     358                 :       2927 :             ((SvxFrameDirectionItem&)GetFmt()->GetFmtAttr( RES_FRAMEDIR )).GetValue();
     359         [ +  + ]:       2927 :     if( bVert )
     360                 :            :     {
     361 [ +  + ][ -  + ]:       1480 :         if( FRMDIR_HORI_LEFT_TOP == nDir || FRMDIR_HORI_RIGHT_TOP == nDir )
     362                 :            :         {
     363                 :            :             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     364                 :       1475 :             bVertLR = 0;
     365                 :       1475 :             bVertical = 0;
     366                 :            :         }
     367                 :            :         else
     368                 :            :         {
     369                 :          5 :             const ViewShell *pSh = getRootFrm()->GetCurrShell();
     370 [ -  + ][ -  + ]:          5 :             if( pSh && pSh->GetViewOptions()->getBrowseMode() )
                 [ +  - ]
     371                 :            :             {
     372                 :            :                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     373                 :          0 :                 bVertLR = 0;
     374                 :          0 :                 bVertical = 0;
     375                 :            :             }
     376                 :            :             else
     377                 :            :             {
     378                 :          5 :                 bVertical = 1;
     379                 :            :                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     380         [ -  + ]:          5 :                 if(FRMDIR_VERT_TOP_RIGHT == nDir)
     381                 :          0 :                     bVertLR = 0;
     382         [ -  + ]:          5 :                     else if(FRMDIR_VERT_TOP_LEFT==nDir)
     383                 :          0 :                        bVertLR = 1;
     384                 :            :             }
     385                 :            :         }
     386                 :            : 
     387                 :       1480 :         bReverse = 0;
     388                 :       1480 :         bInvalidVert = 0;
     389                 :            :     }
     390                 :            :     else
     391                 :            :     {
     392         [ -  + ]:       1447 :         if( FRMDIR_HORI_RIGHT_TOP == nDir )
     393                 :          0 :             bRightToLeft = 1;
     394                 :            :         else
     395                 :       1447 :             bRightToLeft = 0;
     396                 :       1447 :         bInvalidR2L = 0;
     397                 :            :     }
     398                 :       2927 : }
     399                 :            : 
     400                 :            : /*************************************************************************
     401                 :            : |*
     402                 :            : |*  SwPageFrm::PreparePage()
     403                 :            : |*
     404                 :            : |*  Beschreibung        Erzeugt die Spezifischen Flys zur Seite und formatiert
     405                 :            : |*      generischen Cntnt
     406                 :            : |*
     407                 :            : |*************************************************************************/
     408                 :       2920 : void lcl_FormatLay( SwLayoutFrm *pLay )
     409                 :            : {
     410                 :            :     //Alle LayoutFrms - nicht aber Tables, Flys o.ae. - formatieren.
     411                 :            : 
     412                 :       2920 :     SwFrm *pTmp = pLay->Lower();
     413                 :            :     //Erst die untergeordneten
     414         [ +  + ]:       4507 :     while ( pTmp )
     415                 :            :     {
     416         [ +  + ]:       1587 :         if ( pTmp->GetType() & 0x00FF )
     417                 :       1504 :             ::lcl_FormatLay( (SwLayoutFrm*)pTmp );
     418                 :       1587 :         pTmp = pTmp->GetNext();
     419                 :            :     }
     420                 :       2920 :     pLay->Calc();
     421                 :       2920 : }
     422                 :            : 
     423                 :       1409 : void lcl_MakeObjs( const SwFrmFmts &rTbl, SwPageFrm *pPage )
     424                 :            : {
     425                 :            :     //Anlegen bzw. registrieren von Flys und Drawobjekten.
     426                 :            :     //Die Formate stehen in der SpzTbl (vom Dokument).
     427                 :            :     //Flys werden angelegt, DrawObjekte werden bei der Seite angemeldet.
     428                 :            : 
     429         [ +  + ]:       2069 :     for ( sal_uInt16 i = 0; i < rTbl.size(); ++i )
     430                 :            :     {
     431                 :            :         SdrObject *pSdrObj;
     432                 :        660 :         SwFrmFmt *pFmt = rTbl[i];
     433                 :        660 :         const SwFmtAnchor &rAnch = pFmt->GetAnchor();
     434         [ +  + ]:        660 :         if ( rAnch.GetPageNum() == pPage->GetPhyPageNum() )
     435                 :            :         {
     436         [ -  + ]:         16 :             if( rAnch.GetCntntAnchor() )
     437                 :            :             {
     438         [ #  # ]:          0 :                 if (FLY_AT_PAGE == rAnch.GetAnchorId())
     439                 :            :                 {
     440         [ #  # ]:          0 :                     SwFmtAnchor aAnch( rAnch );
     441         [ #  # ]:          0 :                     aAnch.SetAnchor( 0 );
     442 [ #  # ][ #  # ]:          0 :                     pFmt->SetFmtAttr( aAnch );
     443                 :            :                 }
     444                 :            :                 else
     445                 :          0 :                     continue;
     446                 :            :             }
     447                 :            : 
     448                 :            :             //Wird ein Rahmen oder ein SdrObject beschrieben?
     449                 :         16 :             sal_Bool bSdrObj = RES_DRAWFRMFMT == pFmt->Which();
     450                 :         16 :             pSdrObj = 0;
     451 [ -  + ][ -  + ]:         16 :             if ( bSdrObj  && 0 == (pSdrObj = pFmt->FindSdrObject()) )
                 [ +  + ]
     452                 :            :             {
     453                 :            :                 OSL_FAIL( "DrawObject not found." );
     454                 :          0 :                 pFmt->GetDoc()->DelFrmFmt( pFmt );
     455                 :          0 :                 --i;
     456                 :          0 :                 continue;
     457                 :            :             }
     458                 :            :             //Das Objekt kann noch an einer anderen Seite verankert sein.
     459                 :            :             //Z.B. beim Einfuegen einer neuen Seite aufgrund eines
     460                 :            :             //Pagedescriptor-Wechsels. Das Objekt muss dann umgehaengt
     461                 :            :             //werden.
     462                 :            :             //Fuer bestimmte Faelle ist das Objekt bereits an der richtigen
     463                 :            :             //Seite verankert. Das wird hier automatisch erledigt und braucht
     464                 :            :             //- wenngleich performater machbar - nicht extra codiert werden.
     465         [ -  + ]:         16 :             SwPageFrm *pPg = pPage->IsEmptyPage() ? (SwPageFrm*)pPage->GetNext() : pPage;
     466         [ +  + ]:         16 :             if ( bSdrObj )
     467                 :            :             {
     468                 :            :                 // OD 23.06.2003 #108784# - consider 'virtual' drawing objects
     469                 :            :                 SwDrawContact *pContact =
     470                 :         14 :                             static_cast<SwDrawContact*>(::GetUserCall(pSdrObj));
     471         [ -  + ]:         14 :                 if ( pSdrObj->ISA(SwDrawVirtObj) )
     472                 :            :                 {
     473                 :          0 :                     SwDrawVirtObj* pDrawVirtObj = static_cast<SwDrawVirtObj*>(pSdrObj);
     474         [ #  # ]:          0 :                     if ( pContact )
     475                 :            :                     {
     476                 :          0 :                         pDrawVirtObj->RemoveFromWriterLayout();
     477                 :          0 :                         pDrawVirtObj->RemoveFromDrawingPage();
     478                 :          0 :                         pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pDrawVirtObj )) );
     479                 :            :                     }
     480                 :            :                 }
     481                 :            :                 else
     482                 :            :                 {
     483         [ -  + ]:         14 :                     if ( pContact->GetAnchorFrm() )
     484                 :          0 :                         pContact->DisconnectFromLayout( false );
     485                 :         14 :                     pPg->AppendDrawObj( *(pContact->GetAnchoredObj( pSdrObj )) );
     486                 :            :                 }
     487                 :            :             }
     488                 :            :             else
     489                 :            :             {
     490         [ +  - ]:          2 :                 SwIterator<SwFlyFrm,SwFmt> aIter( *pFmt );
     491         [ +  - ]:          2 :                 SwFlyFrm *pFly = aIter.First();
     492         [ -  + ]:          2 :                 if ( pFly)
     493                 :            :                 {
     494 [ #  # ][ #  # ]:          0 :                     if( pFly->GetAnchorFrm() )
     495 [ #  # ][ #  # ]:          0 :                         pFly->AnchorFrm()->RemoveFly( pFly );
     496                 :            :                 }
     497                 :            :                 else
     498 [ +  - ][ +  - ]:          2 :                     pFly = new SwFlyLayFrm( (SwFlyFrmFmt*)pFmt, pPg, pPg );
     499         [ +  - ]:          2 :                 pPg->AppendFly( pFly );
     500 [ +  - ][ +  - ]:          2 :                 ::RegistFlys( pPg, pFly );
     501                 :            :             }
     502                 :            :         }
     503                 :            :     }
     504                 :       1409 : }
     505                 :            : 
     506                 :       1419 : void SwPageFrm::PreparePage( sal_Bool bFtn )
     507                 :            : {
     508                 :       1419 :     SetFtnPage( bFtn );
     509                 :            : 
     510                 :            :     // #i82258#
     511                 :            :     // Due to made change on OOo 2.0 code line, method <::lcl_FormatLay(..)> has
     512                 :            :     // the side effect, that the content of page header and footer are formatted.
     513                 :            :     // For this formatting it is needed that the anchored objects are registered
     514                 :            :     // at the <SwPageFrm> instance.
     515                 :            :     // Thus, first calling <::RegistFlys(..)>, then call <::lcl_FormatLay(..)>
     516                 :       1419 :     ::RegistFlys( this, this );
     517                 :            : 
     518         [ +  + ]:       1419 :         if ( Lower() )
     519                 :            :     {
     520                 :       1416 :                 ::lcl_FormatLay( this );
     521                 :            :     }
     522                 :            : 
     523                 :            :     //Flys und DrawObjekte die noch am Dokument bereitstehen.
     524                 :            :     //Fussnotenseiten tragen keine Seitengebundenen Flys!
     525                 :            :     //Es kann Flys und Objekte geben, die auf Leerseiten (Seitennummernmaessig)
     526                 :            :     //stehen wollen, diese werden jedoch von den Leerseiten ignoriert;
     527                 :            :     //sie werden von den Folgeseiten aufgenommen.
     528 [ +  + ][ +  + ]:       1419 :     if ( !bFtn && !IsEmptyPage() )
                 [ +  + ]
     529                 :            :     {
     530                 :       1406 :         SwDoc *pDoc = GetFmt()->GetDoc();
     531                 :            : 
     532 [ +  + ][ +  + ]:       1406 :         if ( GetPrev() && ((SwPageFrm*)GetPrev())->IsEmptyPage() )
                 [ +  + ]
     533                 :          3 :             lcl_MakeObjs( *pDoc->GetSpzFrmFmts(), (SwPageFrm*)GetPrev() );
     534                 :       1406 :         lcl_MakeObjs( *pDoc->GetSpzFrmFmts(), this );
     535                 :            : 
     536                 :            :         //Kopf-/Fusszeilen) formatieren.
     537                 :       1406 :         SwLayoutFrm *pLow = (SwLayoutFrm*)Lower();
     538         [ +  + ]:       2876 :         while ( pLow )
     539                 :            :         {
     540         [ -  + ]:       1470 :             if ( pLow->GetType() & (FRMTYPE_HEADER|FRMTYPE_FOOTER) )
     541                 :            :             {
     542                 :          0 :                 SwCntntFrm *pCntnt = pLow->ContainsCntnt();
     543 [ #  # ][ #  # ]:          0 :                 while ( pCntnt && pLow->IsAnLower( pCntnt ) )
                 [ #  # ]
     544                 :            :                 {
     545                 :          0 :                     pCntnt->OptCalc();  //Nicht die Vorgaenger
     546                 :          0 :                     pCntnt = pCntnt->GetNextCntntFrm();
     547                 :            :                 }
     548                 :            :             }
     549                 :       1470 :             pLow = (SwLayoutFrm*)pLow->GetNext();
     550                 :            :         }
     551                 :            :     }
     552                 :       1419 : }
     553                 :            : 
     554                 :            : /*************************************************************************
     555                 :            : |*
     556                 :            : |*  SwPageFrm::Modify()
     557                 :            : |*
     558                 :            : |*************************************************************************/
     559                 :         93 : void SwPageFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
     560                 :            : {
     561                 :         93 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
     562         [ +  - ]:         93 :     if ( pSh )
     563         [ +  - ]:         93 :         pSh->SetFirstVisPageInvalid();
     564                 :         93 :     sal_uInt8 nInvFlags = 0;
     565                 :            : 
     566 [ +  - ][ +  + ]:         93 :     if( pNew && RES_ATTRSET_CHG == pNew->Which() )
                 [ +  + ]
     567                 :            :     {
     568         [ +  - ]:         40 :         SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
     569         [ +  - ]:         40 :         SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
     570         [ +  - ]:         40 :         SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
     571         [ +  - ]:         40 :         SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
     572                 :          8 :         while( sal_True )
     573                 :            :         {
     574                 :            :             _UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
     575                 :            :                          (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
     576         [ +  - ]:         48 :                          &aOldSet, &aNewSet );
     577         [ +  + ]:         48 :             if( aNIter.IsAtEnd() )
     578                 :         40 :                 break;
     579         [ +  - ]:          8 :             aNIter.NextItem();
     580         [ +  - ]:          8 :             aOIter.NextItem();
     581                 :            :         }
     582 [ +  + ][ -  + ]:         40 :         if ( aOldSet.Count() || aNewSet.Count() )
                 [ +  + ]
     583 [ +  - ][ +  - ]:         40 :             SwLayoutFrm::Modify( &aOldSet, &aNewSet );
         [ +  - ][ +  - ]
                 [ +  - ]
     584                 :            :     }
     585                 :            :     else
     586         [ +  - ]:         53 :         _UpdateAttr( pOld, pNew, nInvFlags );
     587                 :            : 
     588         [ +  + ]:         93 :     if ( nInvFlags != 0 )
     589                 :            :     {
     590         [ +  - ]:         75 :         InvalidatePage( this );
     591         [ +  + ]:         75 :         if ( nInvFlags & 0x01 )
     592         [ +  - ]:         57 :             _InvalidatePrt();
     593         [ +  + ]:         75 :         if ( nInvFlags & 0x02 )
     594                 :         57 :             SetCompletePaint();
     595 [ +  + ][ -  + ]:         75 :         if ( nInvFlags & 0x04 && GetNext() )
                 [ -  + ]
     596         [ #  # ]:          0 :             GetNext()->InvalidatePos();
     597         [ +  + ]:         75 :         if ( nInvFlags & 0x08 )
     598         [ +  - ]:         10 :             PrepareHeader();
     599         [ +  + ]:         75 :         if ( nInvFlags & 0x10 )
     600         [ +  - ]:         12 :             PrepareFooter();
     601         [ -  + ]:         75 :         if ( nInvFlags & 0x20 )
     602         [ #  # ]:          0 :             CheckGrid( nInvFlags & 0x40 );
     603                 :            :     }
     604                 :         93 : }
     605                 :            : 
     606                 :        101 : void SwPageFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
     607                 :            :                              sal_uInt8 &rInvFlags,
     608                 :            :                              SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
     609                 :            : {
     610                 :        101 :     sal_Bool bClear = sal_True;
     611 [ +  - ][ #  # ]:        101 :     const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
     612   [ +  +  -  +  :        101 :     switch( nWhich )
             +  -  -  +  
                      + ]
     613                 :            :     {
     614                 :            :         case RES_FMT_CHG:
     615                 :            :         {
     616                 :            :             //Wenn sich das FrmFmt aendert kann hier einiges passieren.
     617                 :            :             //Abgesehen von den Grossenverhaeltnissen sind noch andere
     618                 :            :             //Dinge betroffen.
     619                 :            :             //1. Spaltigkeit.
     620                 :            :             OSL_ENSURE( pOld && pNew, "FMT_CHG Missing Format." );
     621                 :         53 :             const SwFmt* pOldFmt = ((SwFmtChg*)pOld)->pChangedFmt;
     622                 :         53 :             const SwFmt* pNewFmt = ((SwFmtChg*)pNew)->pChangedFmt;
     623                 :            :             OSL_ENSURE( pOldFmt && pNewFmt, "FMT_CHG Missing Format." );
     624                 :            : 
     625                 :         53 :             const SwFmtCol &rOldCol = pOldFmt->GetCol();
     626                 :         53 :             const SwFmtCol &rNewCol = pNewFmt->GetCol();
     627         [ -  + ]:         53 :             if( rOldCol != rNewCol )
     628                 :            :             {
     629                 :          0 :                 SwLayoutFrm *pB = FindBodyCont();
     630                 :            :                 OSL_ENSURE( pB, "Seite ohne Body." );
     631                 :          0 :                 pB->ChgColumns( rOldCol, rNewCol );
     632                 :          0 :                 rInvFlags |= 0x20;
     633                 :            :             }
     634                 :            : 
     635                 :            :             //2. Kopf- und Fusszeilen.
     636                 :         53 :             const SwFmtHeader &rOldH = pOldFmt->GetHeader();
     637                 :         53 :             const SwFmtHeader &rNewH = pNewFmt->GetHeader();
     638         [ -  + ]:         53 :             if( rOldH != rNewH )
     639                 :          0 :                 rInvFlags |= 0x08;
     640                 :            : 
     641                 :         53 :             const SwFmtFooter &rOldF = pOldFmt->GetFooter();
     642                 :         53 :             const SwFmtFooter &rNewF = pNewFmt->GetFooter();
     643         [ -  + ]:         53 :             if( rOldF != rNewF )
     644                 :          0 :                 rInvFlags |= 0x10;
     645                 :         53 :             CheckDirChange();
     646                 :            :         }
     647                 :            :             /* kein break hier */
     648                 :            :         case RES_FRM_SIZE:
     649                 :            :         {
     650                 :         57 :             const SwRect aOldPageFrmRect( Frm() );
     651                 :         57 :             ViewShell *pSh = getRootFrm()->GetCurrShell();
     652 [ +  + ][ +  + ]:         57 :             if( pSh && pSh->GetViewOptions()->getBrowseMode() )
                 [ +  - ]
     653                 :            :             {
     654                 :          6 :                 bValidSize = sal_False;
     655                 :            :                 // OD 28.10.2002 #97265# - Don't call <SwPageFrm::MakeAll()>
     656                 :            :                 // Calculation of the page is not necessary, because its size is
     657                 :            :                 // is invalidated here and further invalidation is done in the
     658                 :            :                 // calling method <SwPageFrm::Modify(..)> and probably by calling
     659                 :            :                 // <SwLayoutFrm::Modify(..)> at the end.
     660                 :            :                 // It can also causes inconsistences, because the lowers are
     661                 :            :                 // adjusted, but not calculated, and a <SwPageFrm::MakeAll()> of
     662                 :            :                 // a next page is called. This is performed on the switch to the
     663                 :            :                 // online layout.
     664                 :            :                 //MakeAll();
     665                 :            :             }
     666                 :            :             else
     667                 :            :             {
     668                 :            :                 const SwFmtFrmSize &rSz = nWhich == RES_FMT_CHG ?
     669                 :         47 :                         ((SwFmtChg*)pNew)->pChangedFmt->GetFrmSize() :
     670 [ +  + ][ +  - ]:         51 :                         (const SwFmtFrmSize&)*pNew;
     671                 :            : 
     672                 :         51 :                 Frm().Height( Max( rSz.GetHeight(), long(MINLAY) ) );
     673                 :         51 :                 Frm().Width ( Max( rSz.GetWidth(),  long(MINLAY) ) );
     674                 :            : 
     675                 :            :                 // PAGES01
     676         [ +  - ]:         51 :                 if ( GetUpper() )
     677         [ +  - ]:         51 :                     static_cast<SwRootFrm*>(GetUpper())->CheckViewLayout( 0, 0 );
     678                 :            :             }
     679                 :            :             //Window aufraeumen.
     680 [ +  - ][ +  - ]:         57 :             if( pSh && pSh->GetWin() && aOldPageFrmRect.HasArea() )
         [ +  - ][ +  + ]
                 [ +  + ]
     681                 :            :             {
     682                 :            :                 // OD 12.02.2003 #i9719#, #105645# - consider border and shadow of
     683                 :            :                 // page frame for determine 'old' rectangle - it's used for invalidating.
     684         [ +  - ]:         55 :                 const bool bRightSidebar = (SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
     685                 :         55 :                 SwRect aOldRectWithBorderAndShadow;
     686                 :            :                 SwPageFrm::GetBorderAndShadowBoundRect( aOldPageFrmRect, pSh, aOldRectWithBorderAndShadow,
     687 [ +  - ][ +  - ]:         55 :                     IsLeftShadowNeeded(), IsRightShadowNeeded(), bRightSidebar );
                 [ +  - ]
     688         [ +  - ]:         55 :                 pSh->InvalidateWindows( aOldRectWithBorderAndShadow );
     689                 :            :             }
     690                 :         57 :             rInvFlags |= 0x03;
     691         [ +  + ]:         57 :             if ( aOldPageFrmRect.Height() != Frm().Height() )
     692                 :          4 :                 rInvFlags |= 0x04;
     693                 :            :         }
     694                 :         57 :         break;
     695                 :            : 
     696                 :            :         case RES_COL:
     697                 :            :         {
     698                 :          0 :             SwLayoutFrm *pB = FindBodyCont();
     699                 :            :             OSL_ENSURE( pB, "Seite ohne Body." );
     700                 :          0 :             pB->ChgColumns( *(const SwFmtCol*)pOld, *(const SwFmtCol*)pNew );
     701                 :          0 :             rInvFlags |= 0x22;
     702                 :            :         }
     703                 :          0 :         break;
     704                 :            : 
     705                 :            :         case RES_HEADER:
     706                 :         10 :             rInvFlags |= 0x08;
     707                 :         10 :             break;
     708                 :            : 
     709                 :            :         case RES_FOOTER:
     710                 :         12 :             rInvFlags |= 0x10;
     711                 :         12 :             break;
     712                 :            :         case RES_TEXTGRID:
     713                 :          0 :             rInvFlags |= 0x60;
     714                 :          0 :             break;
     715                 :            : 
     716                 :            :         case RES_PAGEDESC_FTNINFO:
     717                 :            :             //Die derzeit einzig sichere Methode:
     718                 :          0 :             ((SwRootFrm*)GetUpper())->SetSuperfluous();
     719                 :          0 :             SetMaxFtnHeight( pDesc->GetFtnInfo().GetHeight() );
     720         [ #  # ]:          0 :             if ( !GetMaxFtnHeight() )
     721                 :          0 :                 SetMaxFtnHeight( LONG_MAX );
     722                 :          0 :             SetColMaxFtnHeight();
     723                 :            :             //Hier wird die Seite ggf. zerstoert!
     724                 :          0 :             ((SwRootFrm*)GetUpper())->RemoveFtns( 0, sal_False, sal_True );
     725                 :          0 :             break;
     726                 :            :         case RES_FRAMEDIR :
     727                 :          4 :             CheckDirChange();
     728                 :          4 :             break;
     729                 :            : 
     730                 :            :         default:
     731                 :         18 :             bClear = sal_False;
     732                 :            :     }
     733         [ +  + ]:        101 :     if ( bClear )
     734                 :            :     {
     735 [ +  + ][ -  + ]:         83 :         if ( pOldSet || pNewSet )
     736                 :            :         {
     737         [ +  - ]:         30 :             if ( pOldSet )
     738                 :         30 :                 pOldSet->ClearItem( nWhich );
     739         [ +  - ]:         60 :             if ( pNewSet )
     740                 :         30 :                 pNewSet->ClearItem( nWhich );
     741                 :            :         }
     742                 :            :         else
     743                 :         83 :             SwLayoutFrm::Modify( pOld, pNew );
     744                 :            :     }
     745                 :        101 : }
     746                 :            : 
     747                 :            : /*************************************************************************
     748                 :            : |*
     749                 :            : |*                SwPageFrm::GetInfo()
     750                 :            : |*
     751                 :            : |*    Beschreibung      erfragt Informationen
     752                 :            : |*
     753                 :            : *************************************************************************/
     754                 :            :     // erfrage vom Modify Informationen
     755                 :          0 : sal_Bool SwPageFrm::GetInfo( SfxPoolItem & rInfo ) const
     756                 :            : {
     757         [ #  # ]:          0 :     if( RES_AUTOFMT_DOCNODE == rInfo.Which() )
     758                 :            :     {
     759                 :            :         // es gibt einen PageFrm also wird er benutzt
     760                 :          0 :         return sal_False;
     761                 :            :     }
     762                 :          0 :     return sal_True;        // weiter suchen
     763                 :            : }
     764                 :            : 
     765                 :            : /*************************************************************************
     766                 :            : |*
     767                 :            : |*  SwPageFrm::SetPageDesc()
     768                 :            : |*
     769                 :            : |*************************************************************************/
     770                 :          8 : void  SwPageFrm::SetPageDesc( SwPageDesc *pNew, SwFrmFmt *pFmt )
     771                 :            : {
     772                 :          8 :     pDesc = pNew;
     773         [ +  - ]:          8 :     if ( pFmt )
     774                 :          8 :         SetFrmFmt( pFmt );
     775                 :          8 : }
     776                 :            : 
     777                 :            : /*************************************************************************
     778                 :            : |*
     779                 :            : |*  SwPageFrm::FindPageDesc()
     780                 :            : |*
     781                 :            : |*  Beschreibung        Der richtige PageDesc wird bestimmt:
     782                 :            : |*      0.  Vom Dokument bei Fussnotenseiten und Endnotenseiten
     783                 :            : |*      1.  vom ersten BodyCntnt unterhalb der Seite.
     784                 :            : |*      2.  vom PageDesc der vorstehenden Seite.
     785                 :            : |*      3.  bei Leerseiten vom PageDesc der vorigen Seite.
     786                 :            : |*      3.1 vom PageDesc der folgenden Seite wenn es keinen Vorgaenger gibt.
     787                 :            : |*      4.  es ist der Default-PageDesc sonst.
     788                 :            : |*      5.  Im BrowseMode ist der Pagedesc immer der vom ersten Absatz im
     789                 :            : |*          Dokument oder Standard (der 0-te) wenn der erste Absatz keinen
     790                 :            : |*          wuenscht.
     791                 :            : |*     (6.  Im HTML-Mode ist der Pagedesc immer die HTML-Seitenvorlage.)
     792                 :            : |*
     793                 :            : |*************************************************************************/
     794                 :        286 : SwPageDesc *SwPageFrm::FindPageDesc()
     795                 :            : {
     796                 :            :     //0.
     797         [ +  + ]:        286 :     if ( IsFtnPage() )
     798                 :            :     {
     799                 :          6 :         SwDoc *pDoc = GetFmt()->GetDoc();
     800         [ +  - ]:          6 :         if ( IsEndNotePage() )
     801                 :          6 :             return pDoc->GetEndNoteInfo().GetPageDesc( *pDoc );
     802                 :            :         else
     803                 :          0 :             return pDoc->GetFtnInfo().GetPageDesc( *pDoc );
     804                 :            :     }
     805                 :            : 
     806                 :            :     //6.
     807                 :            :     //if ( GetFmt()->GetDoc()->IsHTMLMode() )
     808                 :            :     //  return GetFmt()->GetDoc()->GetPageDescFromPool( RES_POOLPAGE_HTML );
     809                 :            : 
     810                 :        280 :     SwPageDesc *pRet = 0;
     811                 :            : 
     812                 :            :     //5.
     813                 :        280 :     const ViewShell *pSh = getRootFrm()->GetCurrShell();
     814 [ +  + ][ +  + ]:        280 :     if( pSh && pSh->GetViewOptions()->getBrowseMode() )
                 [ +  - ]
     815                 :            :     {
     816                 :         28 :         SwCntntFrm *pFrm = GetUpper()->ContainsCntnt();
     817         [ -  + ]:         28 :         while ( !pFrm->IsInDocBody() )
     818                 :          0 :             pFrm = pFrm->GetNextCntntFrm();
     819                 :         28 :         SwFrm *pFlow = pFrm;
     820         [ -  + ]:         28 :         if ( pFlow->IsInTab() )
     821                 :          0 :             pFlow = pFlow->FindTabFrm();
     822                 :         28 :         pRet = (SwPageDesc*)pFlow->GetAttrSet()->GetPageDesc().GetPageDesc();
     823         [ +  + ]:         28 :         if ( !pRet )
     824                 :         20 :             pRet = &GetFmt()->GetDoc()->GetPageDesc( 0 );
     825                 :         28 :         return pRet;
     826                 :            :     }
     827                 :            : 
     828                 :        252 :     SwFrm *pFlow = FindFirstBodyCntnt();
     829 [ +  + ][ +  + ]:        252 :     if ( pFlow && pFlow->IsInTab() )
                 [ +  + ]
     830                 :         32 :         pFlow = pFlow->FindTabFrm();
     831                 :            : 
     832                 :            :     //1.
     833         [ +  + ]:        252 :     if ( pFlow )
     834                 :            :     {
     835                 :        223 :         SwFlowFrm *pTmp = SwFlowFrm::CastFlowFrm( pFlow );
     836         [ +  + ]:        223 :         if ( !pTmp->IsFollow() )
     837                 :        192 :             pRet = (SwPageDesc*)pFlow->GetAttrSet()->GetPageDesc().GetPageDesc();
     838                 :            :     }
     839                 :            : 
     840                 :            :     //3. und 3.1
     841 [ +  + ][ -  + ]:        252 :     if ( !pRet && IsEmptyPage() )
                 [ -  + ]
     842                 :            :             // FME 2008-03-03 #i81544# lijian/fme: an empty page should have
     843                 :            :             // the same page description as its prev, just like after construction
     844                 :            :             // of the empty page.
     845                 :          0 :         pRet = GetPrev() ? ((SwPageFrm*)GetPrev())->GetPageDesc() :
     846 [ #  # ][ #  # ]:          0 :                GetNext() ? ((SwPageFrm*)GetNext())->GetPageDesc() : 0;
     847                 :            : 
     848                 :            :     //2.
     849         [ +  + ]:        252 :     if ( !pRet )
     850                 :        216 :         pRet = GetPrev() ?
     851         [ +  + ]:        216 :                     ((SwPageFrm*)GetPrev())->GetPageDesc()->GetFollow() : 0;
     852                 :            : 
     853                 :            :     //4.
     854         [ +  + ]:        252 :     if ( !pRet )
     855                 :        102 :         pRet = &GetFmt()->GetDoc()->GetPageDesc( 0 );
     856                 :            : 
     857                 :            : 
     858                 :            :     OSL_ENSURE( pRet, "Kein Descriptor gefunden." );
     859                 :        286 :     return pRet;
     860                 :            : }
     861                 :            : 
     862                 :            : //Wenn der RootFrm seine Groesse aendert muss benachrichtigt werden.
     863                 :       1552 : void AdjustSizeChgNotify( SwRootFrm *pRoot )
     864                 :            : {
     865                 :       1552 :     const sal_Bool bOld = pRoot->IsSuperfluous();
     866                 :       1552 :     pRoot->bCheckSuperfluous = sal_False;
     867                 :       1552 :     ViewShell *pSh = pRoot->GetCurrShell();
     868         [ +  + ]:       1552 :     if ( pSh )
     869                 :            :     {
     870         [ -  + ]:       1542 :         do
     871                 :            :         {
     872         [ +  - ]:       1542 :             if( pRoot == pSh->GetLayout() )
     873                 :            :             {
     874                 :       1542 :                 pSh->SizeChgNotify();
     875         [ +  - ]:       1542 :                 if ( pSh->Imp() )
     876                 :       1542 :                     pSh->Imp()->NotifySizeChg( pRoot->Frm().SSize() );
     877                 :            :             }
     878                 :       1542 :             pSh = (ViewShell*)pSh->GetNext();
     879                 :       1542 :         } while ( pSh != pRoot->GetCurrShell() );
     880                 :            :     }
     881                 :       1552 :     pRoot->bCheckSuperfluous = bOld;
     882                 :       1552 : }
     883                 :            : 
     884                 :            : 
     885                 :       1442 : inline void SetLastPage( SwPageFrm *pPage )
     886                 :            : {
     887                 :       1442 :     ((SwRootFrm*)pPage->GetUpper())->pLastPage = pPage;
     888                 :       1442 : }
     889                 :            : 
     890                 :            : /*************************************************************************
     891                 :            : |*
     892                 :            : |*  SwPageFrm::Cut()
     893                 :            : |*
     894                 :            : |*************************************************************************/
     895                 :         26 : void SwPageFrm::Cut()
     896                 :            : {
     897                 :            :     // PAGES01
     898                 :            :     //AdjustRootSize( CHG_CUTPAGE, 0 );
     899                 :            : 
     900                 :         26 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
     901         [ +  - ]:         26 :     if ( !IsEmptyPage() )
     902                 :            :     {
     903         [ -  + ]:         26 :         if ( GetNext() )
     904                 :          0 :             GetNext()->InvalidatePos();
     905                 :            : 
     906                 :            :         //Flys deren Anker auf anderen Seiten stehen umhaengen.
     907                 :            :         //DrawObjecte spielen hier keine Rolle.
     908         [ -  + ]:         26 :         if ( GetSortedObjs() )
     909                 :            :         {
     910   [ #  #  #  # ]:          0 :             for ( int i = 0; GetSortedObjs() &&
                 [ #  # ]
     911                 :          0 :                              (sal_uInt16)i < GetSortedObjs()->Count(); ++i )
     912                 :            :             {
     913                 :            :                 // #i28701#
     914                 :          0 :                 SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
     915                 :            : 
     916         [ #  # ]:          0 :                 if ( pAnchoredObj->ISA(SwFlyAtCntFrm) )
     917                 :            :                 {
     918         [ #  # ]:          0 :                     SwFlyFrm* pFly = static_cast<SwFlyAtCntFrm*>(pAnchoredObj);
     919                 :          0 :                     SwPageFrm *pAnchPage = pFly->GetAnchorFrm() ?
     920         [ #  # ]:          0 :                                 pFly->AnchorFrm()->FindPageFrm() : 0;
     921 [ #  # ][ #  # ]:          0 :                     if ( pAnchPage && (pAnchPage != this) )
     922                 :            :                     {
     923                 :          0 :                         MoveFly( pFly, pAnchPage );
     924                 :          0 :                         --i;
     925                 :          0 :                         pFly->InvalidateSize();
     926                 :          0 :                         pFly->_InvalidatePos();
     927                 :            :                     }
     928                 :            :                 }
     929                 :            :             }
     930                 :            :         }
     931                 :            :         //Window aufraeumen
     932 [ +  + ][ +  - ]:         26 :         if ( pSh && pSh->GetWin() )
                 [ +  + ]
     933                 :         16 :             pSh->InvalidateWindows( Frm() );
     934                 :            :     }
     935                 :            : 
     936                 :            :     // die Seitennummer der Root runterzaehlen.
     937                 :         26 :     ((SwRootFrm*)GetUpper())->DecrPhyPageNums();
     938                 :         26 :     SwPageFrm *pPg = (SwPageFrm*)GetNext();
     939         [ -  + ]:         26 :     if ( pPg )
     940                 :            :     {
     941         [ #  # ]:          0 :         while ( pPg )
     942                 :            :         {
     943                 :          0 :             pPg->DecrPhyPageNum();  //inline --nPhyPageNum
     944                 :          0 :             pPg = (SwPageFrm*)pPg->GetNext();
     945                 :            :         }
     946                 :            :     }
     947                 :            :     else
     948                 :         26 :         ::SetLastPage( (SwPageFrm*)GetPrev() );
     949                 :            : 
     950                 :         26 :     SwFrm* pRootFrm = GetUpper();
     951                 :            : 
     952                 :            :     // Alle Verbindungen kappen.
     953                 :         26 :     Remove();
     954                 :            : 
     955                 :            :     // PAGES01
     956         [ +  - ]:         26 :     if ( pRootFrm )
     957                 :         26 :         static_cast<SwRootFrm*>(pRootFrm)->CheckViewLayout( 0, 0 );
     958                 :         26 : }
     959                 :            : 
     960                 :            : /*************************************************************************
     961                 :            : |*
     962                 :            : |*  SwPageFrm::Paste()
     963                 :            : |*
     964                 :            : |*************************************************************************/
     965                 :       1419 : void SwPageFrm::Paste( SwFrm* pParent, SwFrm* pSibling )
     966                 :            : {
     967                 :            :     OSL_ENSURE( pParent->IsRootFrm(), "Parent ist keine Root." );
     968                 :            :     OSL_ENSURE( pParent, "Kein Parent fuer Paste." );
     969                 :            :     OSL_ENSURE( pParent != this, "Bin selbst der Parent." );
     970                 :            :     OSL_ENSURE( pSibling != this, "Bin mein eigener Nachbar." );
     971                 :            :     OSL_ENSURE( !GetPrev() && !GetNext() && !GetUpper(),
     972                 :            :             "Bin noch irgendwo angemeldet." );
     973                 :            : 
     974                 :            :     //In den Baum einhaengen.
     975                 :       1419 :     InsertBefore( (SwLayoutFrm*)pParent, pSibling );
     976                 :            : 
     977                 :            :     // die Seitennummer am Root hochzaehlen.
     978                 :       1419 :     ((SwRootFrm*)GetUpper())->IncrPhyPageNums();
     979         [ +  + ]:       1419 :     if( GetPrev() )
     980                 :        101 :         SetPhyPageNum( ((SwPageFrm*)GetPrev())->GetPhyPageNum() + 1 );
     981                 :            :     else
     982                 :       1318 :         SetPhyPageNum( 1 );
     983                 :       1419 :     SwPageFrm *pPg = (SwPageFrm*)GetNext();
     984         [ +  + ]:       1419 :     if ( pPg )
     985                 :            :     {
     986         [ +  + ]:          6 :         while ( pPg )
     987                 :            :         {
     988                 :          3 :             pPg->IncrPhyPageNum();  //inline ++nPhyPageNum
     989                 :          3 :             pPg->_InvalidatePos();
     990                 :          3 :             pPg->InvalidateLayout();
     991                 :          3 :             pPg = (SwPageFrm*)pPg->GetNext();
     992                 :            :         }
     993                 :            :     }
     994                 :            :     else
     995                 :       1416 :         ::SetLastPage( this );
     996                 :            : 
     997         [ +  + ]:       1419 :     if( Frm().Width() != pParent->Prt().Width() )
     998                 :       1321 :         _InvalidateSize();
     999                 :            : 
    1000                 :       1419 :     InvalidatePos();
    1001                 :            : 
    1002                 :       1419 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
    1003         [ +  - ]:       1419 :     if ( pSh )
    1004                 :       1419 :         pSh->SetFirstVisPageInvalid();
    1005                 :            :     // PAGES01
    1006                 :       1419 :     getRootFrm()->CheckViewLayout( 0, 0 );
    1007                 :       1419 : }
    1008                 :            : 
    1009                 :            : /*************************************************************************
    1010                 :            : |*
    1011                 :            : |*  SwPageFrm::PrepareRegisterChg()
    1012                 :            : |*
    1013                 :            : |*************************************************************************/
    1014                 :          0 : void lcl_PrepFlyInCntRegister( SwCntntFrm *pFrm )
    1015                 :            : {
    1016                 :          0 :     pFrm->Prepare( PREP_REGISTER );
    1017         [ #  # ]:          0 :     if( pFrm->GetDrawObjs() )
    1018                 :            :     {
    1019         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < pFrm->GetDrawObjs()->Count(); ++i )
    1020                 :            :         {
    1021                 :            :             // #i28701#
    1022                 :          0 :             SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
    1023         [ #  # ]:          0 :             if ( pAnchoredObj->ISA(SwFlyInCntFrm) )
    1024                 :            :             {
    1025         [ #  # ]:          0 :                 SwFlyFrm* pFly = static_cast<SwFlyInCntFrm*>(pAnchoredObj);
    1026                 :          0 :                 SwCntntFrm *pCnt = pFly->ContainsCntnt();
    1027         [ #  # ]:          0 :                 while ( pCnt )
    1028                 :            :                 {
    1029                 :          0 :                     lcl_PrepFlyInCntRegister( pCnt );
    1030                 :          0 :                     pCnt = pCnt->GetNextCntntFrm();
    1031                 :            :                 }
    1032                 :            :             }
    1033                 :            :         }
    1034                 :            :     }
    1035                 :          0 : }
    1036                 :            : 
    1037                 :          0 : void SwPageFrm::PrepareRegisterChg()
    1038                 :            : {
    1039                 :          0 :     SwCntntFrm *pFrm = FindFirstBodyCntnt();
    1040         [ #  # ]:          0 :     while( pFrm )
    1041                 :            :     {
    1042                 :          0 :         lcl_PrepFlyInCntRegister( pFrm );
    1043                 :          0 :         pFrm = pFrm->GetNextCntntFrm();
    1044         [ #  # ]:          0 :         if( !IsAnLower( pFrm ) )
    1045                 :          0 :             break;
    1046                 :            :     }
    1047         [ #  # ]:          0 :     if( GetSortedObjs() )
    1048                 :            :     {
    1049         [ #  # ]:          0 :         for( sal_uInt16 i = 0; i < GetSortedObjs()->Count(); ++i )
    1050                 :            :         {
    1051                 :            :             // #i28701#
    1052                 :          0 :             SwAnchoredObject* pAnchoredObj = (*GetSortedObjs())[i];
    1053         [ #  # ]:          0 :             if ( pAnchoredObj->ISA(SwFlyFrm) )
    1054                 :            :             {
    1055         [ #  # ]:          0 :                 SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
    1056                 :          0 :                 pFrm = pFly->ContainsCntnt();
    1057         [ #  # ]:          0 :                 while ( pFrm )
    1058                 :            :                 {
    1059                 :          0 :                     ::lcl_PrepFlyInCntRegister( pFrm );
    1060                 :          0 :                     pFrm = pFrm->GetNextCntntFrm();
    1061                 :            :                 }
    1062                 :            :             }
    1063                 :            :         }
    1064                 :            :     }
    1065                 :          0 : }
    1066                 :            : 
    1067                 :            : /*************************************************************************
    1068                 :            : |*
    1069                 :            : |*  SwFrm::CheckPageDescs()
    1070                 :            : |*
    1071                 :            : |*  Beschreibung        Prueft alle Seiten ab der uebergebenen, daraufhin,
    1072                 :            : |*      ob sie das richtige FrmFmt verwenden. Wenn 'falsche' Seiten
    1073                 :            : |*      aufgespuehrt werden, so wird versucht die Situation moeglichst
    1074                 :            : |*      einfache zu bereinigen.
    1075                 :            : |*
    1076                 :            : |*************************************************************************/
    1077                 :        165 : void SwFrm::CheckPageDescs( SwPageFrm *pStart, sal_Bool bNotifyFields )
    1078                 :            : {
    1079                 :            :     OSL_ENSURE( pStart, "Keine Startpage." );
    1080                 :            : 
    1081                 :        165 :     ViewShell *pSh   = pStart->getRootFrm()->GetCurrShell();
    1082         [ +  - ]:        165 :     SwViewImp *pImp  = pSh ? pSh->Imp() : 0;
    1083                 :            : 
    1084 [ +  - ][ +  + ]:        165 :     if ( pImp && pImp->IsAction() && !pImp->GetLayAction().IsCheckPages() )
         [ -  + ][ -  + ]
    1085                 :            :     {
    1086                 :          0 :         pImp->GetLayAction().SetCheckPageNum( pStart->GetPhyPageNum() );
    1087                 :        165 :         return;
    1088                 :            :     }
    1089                 :            : 
    1090                 :            :     //Fuer das Aktualisieren der Seitennummern-Felder gibt nDocPos
    1091                 :            :     //die Seitenposition an, _ab_ der invalidiert werden soll.
    1092                 :        165 :     SwTwips nDocPos  = LONG_MAX;
    1093                 :            : 
    1094                 :        165 :     SwRootFrm *pRoot = (SwRootFrm*)pStart->GetUpper();
    1095                 :        165 :     SwDoc* pDoc      = pStart->GetFmt()->GetDoc();
    1096                 :        165 :     const bool bFtns = !pDoc->GetFtnIdxs().empty();
    1097                 :            : 
    1098                 :        165 :     SwPageFrm *pPage = pStart;
    1099 [ -  + ][ -  + ]:        165 :     if( pPage->GetPrev() && ((SwPageFrm*)pPage->GetPrev())->IsEmptyPage() )
                 [ +  + ]
    1100                 :          0 :         pPage = (SwPageFrm*)pPage->GetPrev();
    1101         [ +  + ]:        334 :     while ( pPage )
    1102                 :            :     {
    1103                 :            :         //gewuenschten PageDesc und FrmFmt festellen.
    1104                 :        169 :         SwPageDesc *pDesc = pPage->FindPageDesc();
    1105                 :        169 :         sal_Bool bCheckEmpty = pPage->IsEmptyPage();
    1106                 :        169 :         sal_Bool bActOdd = pPage->OnRightPage();
    1107                 :        169 :         sal_Bool bOdd = pPage->WannaRightPage();
    1108                 :        169 :         bool bFirst = pPage->OnFirstPage();
    1109                 :        169 :         SwFrmFmt *pFmtWish = 0;
    1110         [ +  + ]:        169 :         if (bFirst)
    1111                 :          6 :             pFmtWish = pDesc->GetFirstFmt();
    1112                 :            :         else
    1113         [ +  - ]:        163 :             pFmtWish = bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
    1114                 :            : 
    1115   [ +  -  +  +  :        544 :         if ( bActOdd != bOdd ||
             +  +  -  + ]
         [ #  # ][ +  + ]
    1116                 :        169 :              pDesc != pPage->GetPageDesc() ||       //falscher Desc
    1117                 :        161 :              ( pFmtWish != pPage->GetFmt()  &&      //falsches Format und
    1118                 :         45 :                ( !pPage->IsEmptyPage() || pFmtWish ) //nicht Leerseite
    1119                 :            :              )
    1120                 :            :            )
    1121                 :            :         {
    1122                 :            :             //Wenn wir schon ein Seite veraendern muessen kann das eine
    1123                 :            :             //Weile dauern, deshalb hier den WaitCrsr pruefen.
    1124         [ +  - ]:         53 :             if( pImp )
    1125                 :         53 :                 pImp->CheckWaitCrsr();
    1126                 :            : 
    1127                 :            :             //Ab hier muessen die Felder invalidiert werden!
    1128         [ +  - ]:         53 :             if ( nDocPos == LONG_MAX )
    1129                 :         53 :                 nDocPos = pPage->GetPrev() ?
    1130         [ +  + ]:         53 :                             pPage->GetPrev()->Frm().Top() : pPage->Frm().Top();
    1131                 :            : 
    1132                 :            :             //Faelle:
    1133                 :            :             //1. Wir haben eine EmptyPage und wollen eine "Normalseite".
    1134                 :            :             //      ->EmptyPage wegwerfen und weiter mit der naechsten.
    1135                 :            :             //2. Wir haben eine EmptyPage und wollen eine EmptyPage mit
    1136                 :            :             //   anderem Descriptor.
    1137                 :            :             //      ->Descriptor austauschen.
    1138                 :            :             //3. Wir haben eine "Normalseite" und wollen eine EmptyPage.
    1139                 :            :             //      ->Emptypage einfuegen, nicht aber wenn die Vorseite
    1140                 :            :             //                             bereits eine EmptyPage ist -> 6.
    1141                 :            :             //4. Wir haben eine "Normalseite" und wollen eine "Normalseite"
    1142                 :            :             //   mit anderem Descriptor
    1143                 :            :             //      ->Descriptor und Format austauschen
    1144                 :            :             //5. Wir haben eine "Normalseite" und wollen eine "Normalseite"
    1145                 :            :             //   mit anderem Format
    1146                 :            :             //      ->Format austauschen.
    1147                 :            :             //6. Wir haben kein Wunschformat erhalten, also nehmen wir das
    1148                 :            :             //   'andere' Format (rechts/links) des PageDesc.
    1149                 :            : 
    1150 [ -  + ][ #  # ]:         53 :             if ( pPage->IsEmptyPage() && ( pFmtWish ||          //1.
           [ #  #  #  # ]
                 [ -  + ]
    1151                 :          0 :                  ( !bOdd && !pPage->GetPrev() ) ) )
    1152                 :            :             {
    1153                 :          0 :                 SwPageFrm *pTmp = (SwPageFrm*)pPage->GetNext();
    1154                 :          0 :                 pPage->Cut();
    1155         [ #  # ]:          0 :                 delete pPage;
    1156         [ #  # ]:          0 :                 if ( pStart == pPage )
    1157                 :          0 :                     pStart = pTmp;
    1158                 :          0 :                 pPage = pTmp;
    1159                 :          0 :                 continue;
    1160                 :            :             }
    1161         [ -  + ]:         53 :             else if ( pPage->IsEmptyPage() && !pFmtWish &&  //2.
           [ #  #  #  # ]
                 [ -  + ]
    1162                 :          0 :                       pDesc != pPage->GetPageDesc() )
    1163                 :            :             {
    1164                 :          0 :                 pPage->SetPageDesc( pDesc, 0 );
    1165                 :            :             }
    1166         [ +  - ]:         53 :             else if ( !pPage->IsEmptyPage() &&      //3.
           [ -  +  #  # ]
           [ #  #  #  #  
           #  # ][ -  + ]
    1167                 :            :                       bActOdd != bOdd &&
    1168                 :          0 :                       ( ( !pPage->GetPrev() && !bOdd ) ||
    1169                 :          0 :                         ( pPage->GetPrev() &&
    1170                 :          0 :                           !((SwPageFrm*)pPage->GetPrev())->IsEmptyPage() )
    1171                 :            :                       )
    1172                 :            :                     )
    1173                 :            :             {
    1174         [ #  # ]:          0 :                 if ( pPage->GetPrev() )
    1175                 :          0 :                     pDesc = ((SwPageFrm*)pPage->GetPrev())->GetPageDesc();
    1176         [ #  # ]:          0 :                 SwPageFrm *pTmp = new SwPageFrm( pDoc->GetEmptyPageFmt(),pRoot,pDesc);
    1177                 :          0 :                 pTmp->Paste( pRoot, pPage );
    1178                 :          0 :                 pTmp->PreparePage( sal_False );
    1179                 :          0 :                 pPage = pTmp;
    1180                 :            :             }
    1181         [ +  + ]:         53 :             else if ( pPage->GetPageDesc() != pDesc )           //4.
    1182                 :            :             {
    1183                 :          8 :                 SwPageDesc *pOld = pPage->GetPageDesc();
    1184                 :          8 :                 pPage->SetPageDesc( pDesc, pFmtWish );
    1185         [ +  + ]:          8 :                 if ( bFtns )
    1186                 :            :                 {
    1187                 :            :                     //Wenn sich bestimmte Werte der FtnInfo veraendert haben
    1188                 :            :                     //muss etwas passieren. Wir versuchen den Schaden zu
    1189                 :            :                     //begrenzen.
    1190                 :            :                     //Wenn die Seiten keinen FtnCont hat, ist zwar theoretisches
    1191                 :            :                     //ein Problem denkbar, aber das ignorieren wir mit aller Kraft.
    1192                 :            :                     //Bei Aenderungen hoffen wir mal, dass eine Invalidierung
    1193                 :            :                     //ausreicht, denn alles andere wuerde viel Kraft kosten.
    1194                 :          2 :                     SwFtnContFrm *pCont = pPage->FindFtnCont();
    1195 [ +  - ][ +  - ]:          2 :                     if ( pCont && !(pOld->GetFtnInfo() == pDesc->GetFtnInfo()) )
                 [ +  - ]
    1196                 :          2 :                         pCont->_InvalidateAll();
    1197                 :            :                 }
    1198                 :            :             }
    1199 [ +  - ][ +  - ]:         45 :             else if ( pFmtWish && pPage->GetFmt() != pFmtWish )         //5.
                 [ +  - ]
    1200                 :            :             {
    1201                 :         45 :                 pPage->SetFrmFmt( pFmtWish );
    1202                 :            :             }
    1203         [ #  # ]:          0 :             else if ( !pFmtWish )                                       //6.
    1204                 :            :             {
    1205                 :            :                 //Format mit verdrehter Logic besorgen.
    1206         [ #  # ]:          0 :                 pFmtWish = bOdd ? pDesc->GetLeftFmt() : pDesc->GetRightFmt();
    1207         [ #  # ]:          0 :                 if ( pPage->GetFmt() != pFmtWish )
    1208                 :          0 :                     pPage->SetFrmFmt( pFmtWish );
    1209                 :            :             }
    1210                 :            : #if OSL_DEBUG_LEVEL > 0
    1211                 :            :             else
    1212                 :            :             {
    1213                 :            :                 OSL_FAIL( "CheckPageDescs, missing solution" );
    1214                 :            :             }
    1215                 :            : #endif
    1216                 :            :         }
    1217         [ -  + ]:        169 :         if ( bCheckEmpty )
    1218                 :            :         {
    1219                 :            :             //Es kann noch sein, dass die Leerseite schlicht  ueberflussig ist.
    1220                 :            :             //Obiger Algorithmus kann dies leider nicht feststellen.
    1221                 :            :             //Eigentlich muesste die Leerseite einfach praeventiv entfernt
    1222                 :            :             //werden; sie wuerde ja ggf. wieder eingefuegt.
    1223                 :            :             //Die EmptyPage ist genau dann ueberfluessig, wenn die Folgeseite
    1224                 :            :             //auch ohne sie auskommt. Dazu muessen wir uns die Verhaeltnisse
    1225                 :            :             //genauer ansehen. Wir bestimmen den PageDesc und die virtuelle
    1226                 :            :             //Seitennummer manuell.
    1227                 :          0 :             SwPageFrm *pPg = (SwPageFrm*)pPage->GetNext();
    1228 [ #  # ][ #  # ]:          0 :             if( !pPg || pPage->OnRightPage() == pPg->WannaRightPage() )
                 [ #  # ]
    1229                 :            :             {
    1230                 :            :                 //Die Folgeseite hat kein Problem ein FrmFmt zu finden oder keinen
    1231                 :            :                 //Nachfolger, also ist die Leerseite ueberfluessig.
    1232                 :          0 :                 SwPageFrm *pTmp = (SwPageFrm*)pPage->GetNext();
    1233                 :          0 :                 pPage->Cut();
    1234         [ #  # ]:          0 :                 delete pPage;
    1235         [ #  # ]:          0 :                 if ( pStart == pPage )
    1236                 :          0 :                     pStart = pTmp;
    1237                 :          0 :                 pPage = pTmp;
    1238                 :          0 :                 continue;
    1239                 :            :             }
    1240                 :            :         }
    1241                 :        169 :         pPage = (SwPageFrm*)pPage->GetNext();
    1242                 :            :     }
    1243                 :            : 
    1244                 :        165 :     pRoot->SetAssertFlyPages();
    1245                 :        165 :     pRoot->AssertPageFlys( pStart );
    1246                 :            : 
    1247 [ +  - ][ +  - ]:        165 :     if ( bNotifyFields && (!pImp || !pImp->IsUpdateExpFlds()) )
         [ +  + ][ +  + ]
    1248                 :            :     {
    1249         [ +  - ]:        114 :         SwDocPosUpdate aMsgHnt( nDocPos );
    1250 [ +  - ][ +  - ]:        114 :         pDoc->UpdatePageFlds( &aMsgHnt );
    1251                 :            :     }
    1252                 :            : 
    1253                 :            : #if OSL_DEBUG_LEVEL > 0
    1254                 :            :     //Ein paar Pruefungen muessen schon erlaubt sein.
    1255                 :            : 
    1256                 :            :     //1. Keine zwei EmptyPages hintereinander.
    1257                 :            :     //2. Alle PageDescs richtig?
    1258                 :            :     sal_Bool bEmpty = sal_False;
    1259                 :            :     SwPageFrm *pPg = pStart;
    1260                 :            :     while ( pPg )
    1261                 :            :     {
    1262                 :            :         if ( pPg->IsEmptyPage() )
    1263                 :            :         {
    1264                 :            :             if ( bEmpty )
    1265                 :            :             {
    1266                 :            :                 OSL_FAIL( "Doppelte Leerseiten." );
    1267                 :            :                 break;  //Einmal reicht.
    1268                 :            :             }
    1269                 :            :             bEmpty = sal_True;
    1270                 :            :         }
    1271                 :            :         else
    1272                 :            :             bEmpty = sal_False;
    1273                 :            : 
    1274                 :            : //MA 21. Jun. 95: Kann zu testzwecken 'rein, ist aber bei zyklen durchaus
    1275                 :            : //moeglich: Ein paar Seiten, auf der ersten 'erste Seite' anwenden,
    1276                 :            : //rechte als folge der ersten, linke als folge der rechten, rechte als
    1277                 :            : //folge der linken.
    1278                 :            : //   OSL_ENSURE( pPg->GetPageDesc() == pPg->FindPageDesc(),
    1279                 :            : //              "Seite mit falschem Descriptor." );
    1280                 :            : 
    1281                 :            :         pPg = (SwPageFrm*)pPg->GetNext();
    1282                 :            :     }
    1283                 :            : #endif
    1284                 :            : }
    1285                 :            : 
    1286                 :            : /*************************************************************************
    1287                 :            : |*
    1288                 :            : |*  SwFrm::InsertPage()
    1289                 :            : |*
    1290                 :            : |*************************************************************************/
    1291                 :         27 : SwPageFrm *SwFrm::InsertPage( SwPageFrm *pPrevPage, sal_Bool bFtn )
    1292                 :            : {
    1293                 :         27 :     SwRootFrm *pRoot = (SwRootFrm*)pPrevPage->GetUpper();
    1294                 :         27 :     SwPageFrm *pSibling = (SwPageFrm*)pRoot->GetLower();
    1295                 :         27 :     SwPageDesc *pDesc = pSibling->GetPageDesc();
    1296                 :            : 
    1297                 :         27 :     pSibling = (SwPageFrm*)pPrevPage->GetNext();
    1298                 :            :         //Rechte (ungerade) oder linke (gerade) Seite einfuegen?
    1299                 :         27 :     sal_Bool bNextOdd = !pPrevPage->OnRightPage();
    1300                 :         27 :     sal_Bool bWishedOdd = bNextOdd;
    1301                 :            : 
    1302                 :            :     //Welcher PageDesc gilt?
    1303                 :            :     //Bei CntntFrm der aus dem Format wenn einer angegeben ist,
    1304                 :            :     //der Follow vom bereits in der PrevPage gueltigen sonst.
    1305                 :         27 :     pDesc = 0;
    1306 [ +  + ][ +  + ]:         27 :     if ( IsFlowFrm() && !SwFlowFrm::CastFlowFrm( this )->IsFollow() )
                 [ +  - ]
    1307                 :          5 :     {   SwFmtPageDesc &rDesc = (SwFmtPageDesc&)GetAttrSet()->GetPageDesc();
    1308                 :          5 :         pDesc = rDesc.GetPageDesc();
    1309         [ -  + ]:          5 :         if ( rDesc.GetNumOffset() )
    1310                 :            :         {
    1311                 :          0 :             bWishedOdd = rDesc.GetNumOffset() % 2 ? sal_True : sal_False;
    1312                 :            :             //Die Gelegenheit nutzen wir um das Flag an der Root zu pflegen.
    1313                 :          0 :             pRoot->SetVirtPageNum( sal_True );
    1314                 :            :         }
    1315                 :            :     }
    1316         [ +  - ]:         27 :     if ( !pDesc )
    1317                 :         27 :         pDesc = pPrevPage->GetPageDesc()->GetFollow();
    1318                 :            : 
    1319                 :            :     OSL_ENSURE( pDesc, "Missing PageDesc" );
    1320 [ +  + ][ -  + ]:         27 :     if( !(bWishedOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt()) )
    1321                 :          0 :         bWishedOdd = !bWishedOdd;
    1322                 :         27 :     bool bWishedFirst = pDesc != pPrevPage->GetPageDesc();
    1323 [ -  + ][ -  + ]:         27 :     if (bWishedFirst && !pDesc->GetFirstFmt())
                 [ +  + ]
    1324                 :          0 :         bWishedFirst = false;
    1325                 :            : 
    1326                 :         27 :     SwDoc *pDoc = pPrevPage->GetFmt()->GetDoc();
    1327                 :            :     SwFrmFmt *pFmt;
    1328                 :         27 :     sal_Bool bCheckPages = sal_False;
    1329                 :            :     //Wenn ich kein FrmFmt fuer die Seite gefunden habe, muss ich eben eine
    1330                 :            :     //Leerseite einfuegen.
    1331         [ -  + ]:         27 :     if( bWishedOdd != bNextOdd )
    1332                 :          0 :     {   pFmt = pDoc->GetEmptyPageFmt();
    1333                 :          0 :         SwPageDesc *pTmpDesc = pPrevPage->GetPageDesc();
    1334         [ #  # ]:          0 :         SwPageFrm *pPage = new SwPageFrm( pFmt, pRoot, pTmpDesc );
    1335                 :          0 :         pPage->Paste( pRoot, pSibling );
    1336                 :          0 :         pPage->PreparePage( bFtn );
    1337                 :            :         //Wenn der Sibling keinen Bodytext enthaelt kann ich ihn vernichten
    1338                 :            :         //Es sei denn, es ist eine Fussnotenseite
    1339   [ #  #  #  # ]:          0 :         if ( pSibling && !pSibling->IsFtnPage() &&
         [ #  # ][ #  # ]
    1340                 :          0 :              !pSibling->FindFirstBodyCntnt() )
    1341                 :            :         {
    1342                 :          0 :             SwPageFrm *pDel = pSibling;
    1343                 :          0 :             pSibling = (SwPageFrm*)pSibling->GetNext();
    1344         [ #  # ]:          0 :             if ( !pDoc->GetFtnIdxs().empty() )
    1345                 :          0 :                 pRoot->RemoveFtns( pDel, sal_True );
    1346                 :          0 :             pDel->Cut();
    1347         [ #  # ]:          0 :             delete pDel;
    1348                 :            :         }
    1349                 :            :         else
    1350                 :          0 :             bCheckPages = sal_True;
    1351                 :            :     }
    1352 [ +  + ][ +  - ]:         27 :     if (bWishedFirst && !pDesc->IsFirstShared())
                 [ +  + ]
    1353                 :          3 :         pFmt = pDesc->GetFirstFmt();
    1354                 :            :     else
    1355         [ +  + ]:         24 :         pFmt = bWishedOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt();
    1356                 :            :     OSL_ENSURE( pFmt, "Descriptor without format." );
    1357         [ +  - ]:         27 :     SwPageFrm *pPage = new SwPageFrm( pFmt, pRoot, pDesc );
    1358                 :         27 :     pPage->Paste( pRoot, pSibling );
    1359                 :         27 :     pPage->PreparePage( bFtn );
    1360                 :            :     //Wenn der Sibling keinen Bodytext enthaelt kann ich ihn vernichten
    1361                 :            :     //Es sei denn es ist eine Fussnotenseite.
    1362   [ +  -  -  + ]:         30 :     if ( pSibling && !pSibling->IsFtnPage() &&
         [ -  + ][ +  + ]
    1363                 :          3 :          !pSibling->FindFirstBodyCntnt() )
    1364                 :            :     {
    1365                 :          0 :         SwPageFrm *pDel = pSibling;
    1366                 :          0 :         pSibling = (SwPageFrm*)pSibling->GetNext();
    1367         [ #  # ]:          0 :         if ( !pDoc->GetFtnIdxs().empty() )
    1368                 :          0 :             pRoot->RemoveFtns( pDel, sal_True );
    1369                 :          0 :         pDel->Cut();
    1370         [ #  # ]:          0 :         delete pDel;
    1371                 :            :     }
    1372                 :            :     else
    1373                 :         27 :         bCheckPages = sal_True;
    1374                 :            : 
    1375         [ +  + ]:         27 :     if ( pSibling )
    1376                 :            :     {
    1377         [ +  - ]:          3 :         if ( bCheckPages )
    1378                 :            :         {
    1379                 :          3 :             CheckPageDescs( pSibling, sal_False );
    1380                 :          3 :             ViewShell *pSh = getRootFrm()->GetCurrShell();
    1381         [ +  - ]:          3 :             SwViewImp *pImp = pSh ? pSh->Imp() : 0;
    1382 [ +  - ][ +  - ]:          3 :             if ( pImp && pImp->IsAction() && !pImp->GetLayAction().IsCheckPages() )
         [ -  + ][ -  + ]
    1383                 :            :             {
    1384                 :          0 :                 const sal_uInt16 nNum = pImp->GetLayAction().GetCheckPageNum();
    1385         [ #  # ]:          0 :                 if ( nNum == pPrevPage->GetPhyPageNum() + 1 )
    1386                 :          0 :                     pImp->GetLayAction().SetCheckPageNumDirect(
    1387                 :          0 :                                                     pSibling->GetPhyPageNum() );
    1388                 :          0 :                 return pPage;
    1389                 :            :             }
    1390                 :            :         }
    1391                 :            :         else
    1392                 :          0 :             pRoot->AssertPageFlys( pSibling );
    1393                 :            :     }
    1394                 :            : 
    1395                 :            :     //Fuer das Aktualisieren der Seitennummern-Felder gibt nDocPos
    1396                 :            :     //die Seitenposition an, _ab_ der invalidiert werden soll.
    1397                 :         27 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
    1398 [ +  - ][ +  - ]:         27 :     if ( !pSh || !pSh->Imp()->IsUpdateExpFlds() )
                 [ +  - ]
    1399                 :            :     {
    1400         [ +  - ]:         27 :         SwDocPosUpdate aMsgHnt( pPrevPage->Frm().Top() );
    1401 [ +  - ][ +  - ]:         27 :         pDoc->UpdatePageFlds( &aMsgHnt );
    1402                 :            :     }
    1403                 :         27 :     return pPage;
    1404                 :            : }
    1405                 :            : 
    1406                 :      35596 : sw::sidebarwindows::SidebarPosition SwPageFrm::SidebarPosition() const
    1407                 :            : {
    1408                 :      35596 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
    1409 [ +  + ][ +  + ]:      35596 :     if( !pSh || pSh->GetViewOptions()->getBrowseMode() )
                 [ +  + ]
    1410                 :            :     {
    1411                 :        919 :         return sw::sidebarwindows::SIDEBAR_RIGHT;
    1412                 :            :     }
    1413                 :            :     else
    1414                 :            :     {
    1415                 :      34677 :         const bool bLTR = getRootFrm()->IsLeftToRightViewLayout();
    1416                 :      34677 :         const bool bBookMode = pSh->GetViewOptions()->IsViewLayoutBookMode();
    1417 [ -  + ][ #  # ]:      34677 :         const bool bRightSidebar = bLTR ? (!bBookMode || OnRightPage()) : (bBookMode && !OnRightPage());
         [ -  + ][ #  # ]
                 [ +  + ]
    1418                 :            : 
    1419                 :            :         return bRightSidebar
    1420                 :            :                ? sw::sidebarwindows::SIDEBAR_RIGHT
    1421         [ +  + ]:      35596 :                : sw::sidebarwindows::SIDEBAR_LEFT;
    1422                 :            :     }
    1423                 :            : }
    1424                 :            : 
    1425                 :            : /*************************************************************************
    1426                 :            : |*
    1427                 :            : |*  SwRootFrm::GrowFrm()
    1428                 :            : |*
    1429                 :            : |*************************************************************************/
    1430                 :            : 
    1431                 :          0 : SwTwips SwRootFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool )
    1432                 :            : {
    1433         [ #  # ]:          0 :     if ( !bTst )
    1434                 :          0 :         Frm().SSize().Height() += nDist;
    1435                 :          0 :     return nDist;
    1436                 :            : }
    1437                 :            : /*************************************************************************
    1438                 :            : |*
    1439                 :            : |*  SwRootFrm::ShrinkFrm()
    1440                 :            : |*
    1441                 :            : |*************************************************************************/
    1442                 :          0 : SwTwips SwRootFrm::ShrinkFrm( SwTwips nDist, sal_Bool bTst, sal_Bool )
    1443                 :            : {
    1444                 :            :     OSL_ENSURE( nDist >= 0, "nDist < 0." );
    1445                 :            :     OSL_ENSURE( nDist <= Frm().Height(), "nDist > als aktuelle Groesse." );
    1446                 :            : 
    1447         [ #  # ]:          0 :     if ( !bTst )
    1448                 :          0 :         Frm().SSize().Height() -= nDist;
    1449                 :          0 :     return nDist;
    1450                 :            : }
    1451                 :            : 
    1452                 :            : /*************************************************************************
    1453                 :            : |*
    1454                 :            : |*  SwRootFrm::RemoveSuperfluous()
    1455                 :            : |*
    1456                 :            : |*  Beschreibung:       Entfernung von ueberfluessigen Seiten.
    1457                 :            : |*          Arbeitet nur wenn das Flag bCheckSuperfluous gesetzt ist.
    1458                 :            : |*          Definition: Eine Seite ist genau dann leer, wenn der
    1459                 :            : |*          Body-Textbereich keinen CntntFrm enthaelt, aber nicht, wenn noch
    1460                 :            : |*          mindestens ein Fly an der Seite klebt.
    1461                 :            : |*          Die Seite ist auch dann nicht leer, wenn sie noch eine
    1462                 :            : |*          Fussnote enthaelt.
    1463                 :            : |*          Es muss zweimal angesetzt werden um leeren Seiten aufzuspueren:
    1464                 :            : |*              - einmal fuer die Endnotenseiten.
    1465                 :            : |*              - und einmal fuer die Seiten des Bodytextes.
    1466                 :            : |*
    1467                 :            : |*************************************************************************/
    1468                 :         29 : void SwRootFrm::RemoveSuperfluous()
    1469                 :            : {
    1470         [ -  + ]:         29 :     if ( !IsSuperfluous() )
    1471                 :         29 :         return;
    1472                 :         29 :     bCheckSuperfluous = sal_False;
    1473                 :            : 
    1474                 :         29 :     SwPageFrm *pPage = GetLastPage();
    1475                 :         29 :     long nDocPos = LONG_MAX;
    1476                 :            : 
    1477                 :            :     //Jetzt wird fuer die jeweils letzte Seite geprueft ob sie leer ist
    1478                 :            :     //bei der ersten nicht leeren Seite wird die Schleife beendet.
    1479         [ +  + ]:         45 :     do
    1480                 :            :     {
    1481                 :         45 :         bool bExistEssentialObjs = ( 0 != pPage->GetSortedObjs() );
    1482         [ +  + ]:         45 :         if ( bExistEssentialObjs )
    1483                 :            :         {
    1484                 :            :             //Nur weil die Seite Flys hat sind wir noch lange nicht fertig,
    1485                 :            :             //denn wenn alle Flys an generischem Inhalt haengen, so ist sie
    1486                 :            :             //trotzdem ueberfluessig (Ueberpruefung auf DocBody sollte reichen).
    1487                 :            :             // OD 19.06.2003 #108784# - consider that drawing objects in
    1488                 :            :             // header/footer are supported now.
    1489                 :         15 :             bool bOnlySuperfluosObjs = true;
    1490                 :         15 :             SwSortedObjs &rObjs = *pPage->GetSortedObjs();
    1491 [ +  + ][ +  + ]:         30 :             for ( sal_uInt16 i = 0; bOnlySuperfluosObjs && i < rObjs.Count(); ++i )
                 [ +  + ]
    1492                 :            :             {
    1493                 :            :                 // #i28701#
    1494                 :         15 :                 SwAnchoredObject* pAnchoredObj = rObjs[i];
    1495                 :            :                 // OD 2004-01-19 #110582# - do not consider hidden objects
    1496 [ +  - ][ +  + ]:         60 :                 if ( pPage->GetFmt()->GetDoc()->IsVisibleLayerId(
         [ +  + ][ +  - ]
    1497 [ +  - ][ +  - ]:         30 :                                     pAnchoredObj->GetDrawObj()->GetLayer() ) &&
         [ +  - ][ #  # ]
                 [ +  - ]
    1498 [ +  - ][ +  - ]:         15 :                      !pAnchoredObj->GetAnchorFrm()->FindFooterOrHeader() )
    1499                 :            :                 {
    1500                 :         12 :                     bOnlySuperfluosObjs = false;
    1501                 :            :                 }
    1502                 :            :             }
    1503                 :         15 :             bExistEssentialObjs = !bOnlySuperfluosObjs;
    1504                 :            :         }
    1505                 :            : 
    1506                 :            :         // OD 19.06.2003 #108784# - optimization: check first, if essential objects
    1507                 :            :         // exists.
    1508                 :         45 :         const SwLayoutFrm* pBody = 0;
    1509   [ +  +  +  + ]:        125 :         if ( bExistEssentialObjs ||
           [ +  -  +  +  
             -  +  #  # ]
                 [ +  + ]
    1510                 :         33 :              pPage->FindFtnCont() ||
    1511                 :         31 :              ( 0 != ( pBody = pPage->FindBodyCont() ) &&
    1512                 :         31 :                 ( pBody->ContainsCntnt() ||
    1513                 :            :                     // #i47580#
    1514                 :            :                     // Do not delete page if there's an empty tabframe
    1515                 :            :                     // left. I think it might be correct to use ContainsAny()
    1516                 :            :                     // instead of ContainsCntnt() to cover the empty-table-case,
    1517                 :            :                     // but I'm not fully sure, since ContainsAny() also returns
    1518                 :            :                     // SectionFrames. Therefore I prefer to do it the safe way:
    1519                 :         16 :                   ( pBody->Lower() && pBody->Lower()->IsTabFrm() ) ) ) )
    1520                 :            :         {
    1521         [ -  + ]:         29 :             if ( pPage->IsFtnPage() )
    1522                 :            :             {
    1523         [ #  # ]:          0 :                 while ( pPage->IsFtnPage() )
    1524                 :            :                 {
    1525                 :          0 :                     pPage = (SwPageFrm*)pPage->GetPrev();
    1526                 :            :                     OSL_ENSURE( pPage, "Nur noch Endnotenseiten uebrig." );
    1527                 :            :                 }
    1528                 :          0 :                 continue;
    1529                 :            :             }
    1530                 :            :             else
    1531                 :         29 :                 pPage = 0;
    1532                 :            :         }
    1533                 :            : 
    1534         [ +  + ]:         45 :         if ( pPage )
    1535                 :            :         {
    1536                 :         16 :             SwPageFrm *pEmpty = pPage;
    1537                 :         16 :             pPage = (SwPageFrm*)pPage->GetPrev();
    1538         [ -  + ]:         16 :             if ( !GetFmt()->GetDoc()->GetFtnIdxs().empty() )
    1539                 :          0 :                 RemoveFtns( pEmpty, sal_True );
    1540                 :         16 :             pEmpty->Cut();
    1541         [ +  - ]:         16 :             delete pEmpty;
    1542         [ +  - ]:         16 :             nDocPos = pPage ? pPage->Frm().Top() : 0;
    1543                 :            :         }
    1544                 :            :     } while ( pPage );
    1545                 :            : 
    1546                 :         29 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
    1547   [ +  -  +  - ]:         41 :     if ( nDocPos != LONG_MAX &&
         [ +  + ][ +  + ]
    1548                 :         12 :          (!pSh || !pSh->Imp()->IsUpdateExpFlds()) )
    1549                 :            :     {
    1550         [ +  - ]:         12 :         SwDocPosUpdate aMsgHnt( nDocPos );
    1551 [ +  - ][ +  - ]:         12 :         GetFmt()->GetDoc()->UpdatePageFlds( &aMsgHnt );
                 [ +  - ]
    1552                 :            :     }
    1553                 :            : }
    1554                 :            : 
    1555                 :            : /*************************************************************************
    1556                 :            : |*
    1557                 :            : |*  SwRootFrm::AssertFlyPages()
    1558                 :            : |*
    1559                 :            : |*  Beschreibung        Stellt sicher, dass genuegend Seiten vorhanden
    1560                 :            : |*      sind, damit alle Seitengebundenen Rahmen und DrawObject
    1561                 :            : |*      untergebracht sind.
    1562                 :            : |*
    1563                 :            : |*************************************************************************/
    1564                 :       1424 : void SwRootFrm::AssertFlyPages()
    1565                 :            : {
    1566         [ -  + ]:       1424 :     if ( !IsAssertFlyPages() )
    1567                 :       1424 :         return;
    1568                 :       1424 :     bAssertFlyPages = sal_False;
    1569                 :            : 
    1570                 :       1424 :     SwDoc *pDoc = GetFmt()->GetDoc();
    1571                 :       1424 :     const SwFrmFmts *pTbl = pDoc->GetSpzFrmFmts();
    1572                 :            : 
    1573                 :            :     //Auf welche Seite will der 'letzte' Fly?
    1574                 :       1424 :     sal_uInt16 nMaxPg = 0;
    1575                 :            :     sal_uInt16 i;
    1576                 :            : 
    1577         [ +  + ]:       2050 :     for ( i = 0; i < pTbl->size(); ++i )
    1578                 :            :     {
    1579                 :        626 :         const SwFmtAnchor &rAnch = (*pTbl)[i]->GetAnchor();
    1580 [ +  + ][ +  + ]:        626 :         if ( !rAnch.GetCntntAnchor() && nMaxPg < rAnch.GetPageNum() )
                 [ +  + ]
    1581                 :          6 :             nMaxPg = rAnch.GetPageNum();
    1582                 :            :     }
    1583                 :            :     //Wieviele Seiten haben wir derzeit?
    1584                 :       1424 :     SwPageFrm *pPage = (SwPageFrm*)Lower();
    1585         [ +  - ]:       1564 :     while ( pPage && pPage->GetNext() &&
           [ +  +  +  + ]
                 [ +  + ]
    1586                 :         73 :             !((SwPageFrm*)pPage->GetNext())->IsFtnPage() )
    1587                 :            :     {
    1588                 :         67 :         pPage = (SwPageFrm*)pPage->GetNext();
    1589                 :            :     }
    1590                 :            : 
    1591         [ -  + ]:       1424 :     if ( nMaxPg > pPage->GetPhyPageNum() )
    1592                 :            :     {
    1593                 :            :         //Die Seiten werden ausgehend von der letzten Seite konsequent
    1594                 :            :         //nach den Regeln der PageDescs weitergefuehrt.
    1595                 :          0 :         sal_Bool bOdd = pPage->GetPhyPageNum() % 2 ? sal_True : sal_False;
    1596                 :          0 :         SwPageDesc *pDesc = pPage->GetPageDesc();
    1597                 :          0 :         SwFrm *pSibling = pPage->GetNext();
    1598         [ #  # ]:          0 :         for ( i = pPage->GetPhyPageNum(); i < nMaxPg; ++i  )
    1599                 :            :         {
    1600 [ #  # ][ #  # ]:          0 :             if ( !(bOdd ? pDesc->GetRightFmt() : pDesc->GetLeftFmt()) )
    1601                 :            :             {
    1602                 :            :                 //Leerseite einfuegen, die Flys werden aber erst von
    1603                 :            :                 //der naechsten Seite aufgenommen!
    1604         [ #  # ]:          0 :                 pPage = new SwPageFrm( pDoc->GetEmptyPageFmt(), this, pDesc );
    1605                 :          0 :                 pPage->Paste( this, pSibling );
    1606                 :          0 :                 pPage->PreparePage( sal_False );
    1607                 :          0 :                 bOdd = bOdd ? sal_False : sal_True;
    1608                 :          0 :                 ++i;
    1609                 :            :             }
    1610                 :            :             pPage = new
    1611                 :            :                     SwPageFrm( (bOdd ? pDesc->GetRightFmt() :
    1612 [ #  # ][ #  # ]:          0 :                                        pDesc->GetLeftFmt()), this, pDesc );
    1613                 :          0 :             pPage->Paste( this, pSibling );
    1614                 :          0 :             pPage->PreparePage( sal_False );
    1615                 :          0 :             bOdd = bOdd ? sal_False : sal_True;
    1616                 :          0 :             pDesc = pDesc->GetFollow();
    1617                 :            :         }
    1618                 :            :         //Jetzt koennen die Endnotenseiten natuerlich wieder krumm sein;
    1619                 :            :         //in diesem Fall werden sie vernichtet.
    1620         [ #  # ]:          0 :         if ( !pDoc->GetFtnIdxs().empty() )
    1621                 :            :         {
    1622                 :          0 :             pPage = (SwPageFrm*)Lower();
    1623 [ #  # ][ #  # ]:          0 :             while ( pPage && !pPage->IsFtnPage() )
                 [ #  # ]
    1624                 :          0 :                 pPage = (SwPageFrm*)pPage->GetNext();
    1625                 :            : 
    1626         [ #  # ]:          0 :             if ( pPage )
    1627                 :            :             {
    1628                 :          0 :                 SwPageDesc *pTmpDesc = pPage->FindPageDesc();
    1629                 :          0 :                 bOdd = pPage->OnRightPage();
    1630 [ #  # ][ #  # ]:          0 :                 if ( pPage->GetFmt() !=
    1631                 :            :                      (bOdd ? pTmpDesc->GetRightFmt() : pTmpDesc->GetLeftFmt()) )
    1632                 :          0 :                     RemoveFtns( pPage, sal_False, sal_True );
    1633                 :            :             }
    1634                 :            :         }
    1635                 :            :     }
    1636                 :            : }
    1637                 :            : 
    1638                 :            : /*************************************************************************
    1639                 :            : |*
    1640                 :            : |*  SwRootFrm::AssertPageFlys()
    1641                 :            : |*
    1642                 :            : |*  Beschreibung        Stellt sicher, dass ab der uebergebenen Seite
    1643                 :            : |*      auf allen Seiten die Seitengebunden Objecte auf der richtigen
    1644                 :            : |*      Seite (Seitennummer stehen).
    1645                 :            : |*
    1646                 :            : |*************************************************************************/
    1647                 :        165 : void SwRootFrm::AssertPageFlys( SwPageFrm *pPage )
    1648                 :            : {
    1649         [ +  + ]:        334 :     while ( pPage )
    1650                 :            :     {
    1651         [ +  + ]:        169 :         if ( pPage->GetSortedObjs() )
    1652                 :            :         {
    1653                 :          4 :             pPage->GetSortedObjs();
    1654   [ +  -  +  + ]:         24 :             for ( int i = 0;
                 [ +  + ]
    1655                 :         16 :                   pPage->GetSortedObjs() && sal_uInt16(i) < pPage->GetSortedObjs()->Count();
    1656                 :            :                   ++i)
    1657                 :            :             {
    1658                 :            :                 // #i28701#
    1659                 :          4 :                 SwFrmFmt& rFmt = (*pPage->GetSortedObjs())[i]->GetFrmFmt();
    1660                 :          4 :                 const SwFmtAnchor &rAnch = rFmt.GetAnchor();
    1661                 :          4 :                 const sal_uInt16 nPg = rAnch.GetPageNum();
    1662         [ -  + ]:          4 :                 if ((rAnch.GetAnchorId() == FLY_AT_PAGE) &&
           [ -  +  #  # ]
    1663                 :          0 :                      nPg != pPage->GetPhyPageNum() )
    1664                 :            :                 {
    1665                 :            :                     //Das er auf der falschen Seite steht muss noch nichts
    1666                 :            :                     //heissen, wenn er eigentlich auf der Vorseite
    1667                 :            :                     //stehen will und diese eine EmptyPage ist.
    1668 [ #  # ][ #  # ]:          0 :                     if( nPg && !(pPage->GetPhyPageNum()-1 == nPg &&
                 [ #  # ]
    1669         [ #  # ]:          0 :                         ((SwPageFrm*)pPage->GetPrev())->IsEmptyPage()) )
    1670                 :            :                     {
    1671                 :            :                         //Umhaengen kann er sich selbst, indem wir ihm
    1672                 :            :                         //einfach ein Modify mit seinem AnkerAttr schicken.
    1673                 :            : #if OSL_DEBUG_LEVEL > 1
    1674                 :            :                         const sal_uInt32 nCnt = pPage->GetSortedObjs()->Count();
    1675                 :            :                         rFmt.NotifyClients( 0, (SwFmtAnchor*)&rAnch );
    1676                 :            :                         OSL_ENSURE( !pPage->GetSortedObjs() ||
    1677                 :            :                                 nCnt != pPage->GetSortedObjs()->Count(),
    1678                 :            :                                 "Object couldn't be reattached!" );
    1679                 :            : #else
    1680                 :          0 :                         rFmt.NotifyClients( 0, (SwFmtAnchor*)&rAnch );
    1681                 :            : #endif
    1682                 :          0 :                         --i;
    1683                 :            :                     }
    1684                 :            :                 }
    1685                 :            :             }
    1686                 :            :         }
    1687                 :        169 :         pPage = (SwPageFrm*)pPage->GetNext();
    1688                 :            :     }
    1689                 :        165 : }
    1690                 :            : 
    1691                 :            : /*************************************************************************
    1692                 :            : |*
    1693                 :            : |*  SwRootFrm::ChgSize()
    1694                 :            : |*
    1695                 :            : |*************************************************************************/
    1696                 :       1552 : Size SwRootFrm::ChgSize( const Size& aNewSize )
    1697                 :            : {
    1698                 :       1552 :     Frm().SSize() = aNewSize;
    1699                 :       1552 :     _InvalidatePrt();
    1700                 :       1552 :     bFixSize = sal_False;
    1701                 :       1552 :     return Frm().SSize();
    1702                 :            : }
    1703                 :            : 
    1704                 :            : /*************************************************************************
    1705                 :            : |*
    1706                 :            : |*  SwRootFrm::MakeAll()
    1707                 :            : |*
    1708                 :            : |*************************************************************************/
    1709                 :       2870 : void SwRootFrm::MakeAll()
    1710                 :            : {
    1711         [ +  + ]:       2870 :     if ( !bValidPos )
    1712                 :       1318 :     {   bValidPos = sal_True;
    1713                 :       1318 :         aFrm.Pos().X() = aFrm.Pos().Y() = DOCUMENTBORDER;
    1714                 :            :     }
    1715         [ +  - ]:       2870 :     if ( !bValidPrtArea )
    1716                 :       2870 :     {   bValidPrtArea = sal_True;
    1717                 :       2870 :         aPrt.Pos().X() = aPrt.Pos().Y() = 0;
    1718                 :       2870 :         aPrt.SSize( aFrm.SSize() );
    1719                 :            :     }
    1720         [ +  + ]:       2870 :     if ( !bValidSize )
    1721                 :            :         //SSize wird von den Seiten (Cut/Paste) eingestellt.
    1722                 :       1318 :         bValidSize = sal_True;
    1723                 :       2870 : }
    1724                 :            : 
    1725                 :            : /*************************************************************************
    1726                 :            : |*
    1727                 :            : |*  SwRootFrm::ImplInvalidateBrowseWidth()
    1728                 :            : |*
    1729                 :            : |*************************************************************************/
    1730                 :        146 : void SwRootFrm::ImplInvalidateBrowseWidth()
    1731                 :            : {
    1732                 :        146 :     bBrowseWidthValid = sal_False;
    1733                 :        146 :     SwFrm *pPg = Lower();
    1734         [ +  + ]:        292 :     while ( pPg )
    1735                 :            :     {
    1736                 :        146 :         pPg->InvalidateSize();
    1737                 :        146 :         pPg = pPg->GetNext();
    1738                 :            :     }
    1739                 :        146 : }
    1740                 :            : 
    1741                 :            : /*************************************************************************
    1742                 :            : |*
    1743                 :            : |*  SwRootFrm::ImplCalcBrowseWidth()
    1744                 :            : |*
    1745                 :            : |*************************************************************************/
    1746                 :        156 : void SwRootFrm::ImplCalcBrowseWidth()
    1747                 :            : {
    1748                 :            :     OSL_ENSURE( GetCurrShell() && GetCurrShell()->GetViewOptions()->getBrowseMode(),
    1749                 :            :             "CalcBrowseWidth and not in BrowseView" );
    1750                 :            : 
    1751                 :            :     //Die (minimale) Breite wird von Rahmen, Tabellen und Zeichenobjekten
    1752                 :            :     //bestimmt. Die Breite wird nicht anhand ihrer aktuellen Groessen bestimmt,
    1753                 :            :     //sondern anhand der Attribute. Es interessiert also nicht wie breit sie
    1754                 :            :     //sind, sondern wie breit sie sein wollen.
    1755                 :            :     //Rahmen und Zeichenobjekte innerhalb ander Objekte (Rahmen, Tabellen)
    1756                 :            :     //Zaehlen nicht.
    1757                 :            :     //Seitenraender und Spalten werden hier nicht beruecksichtigt.
    1758                 :            : 
    1759                 :        156 :     SwFrm *pFrm = ContainsCntnt();
    1760 [ +  + ][ -  + ]:        156 :     while ( pFrm && !pFrm->IsInDocBody() )
                 [ -  + ]
    1761                 :          0 :         pFrm = ((SwCntntFrm*)pFrm)->GetNextCntntFrm();
    1762         [ +  + ]:        156 :     if ( !pFrm )
    1763                 :        156 :         return;
    1764                 :            : 
    1765                 :        152 :     bBrowseWidthValid = sal_True;
    1766                 :        152 :     ViewShell *pSh = getRootFrm()->GetCurrShell();
    1767                 :            :     nBrowseWidth = pSh
    1768                 :            :                     ? MINLAY + 2 * pSh->GetOut()->
    1769 [ +  - ][ +  - ]:        304 :                                 PixelToLogic( pSh->GetBrowseBorder() ).Width()
         [ +  - ][ #  # ]
    1770         [ +  - ]:        304 :                     : 5000;
    1771         [ -  + ]:        152 :     do
    1772                 :            :     {
    1773         [ -  + ]:        152 :         if ( pFrm->IsInTab() )
    1774                 :          0 :             pFrm = pFrm->FindTabFrm();
    1775                 :            : 
    1776   [ -  +  #  # ]:        152 :         if ( pFrm->IsTabFrm() &&
                 [ -  + ]
    1777                 :          0 :              !((SwLayoutFrm*)pFrm)->GetFmt()->GetFrmSize().GetWidthPercent() )
    1778                 :            :         {
    1779         [ #  # ]:          0 :             SwBorderAttrAccess aAccess( SwFrm::GetCache(), pFrm );
    1780         [ #  # ]:          0 :             const SwBorderAttrs &rAttrs = *aAccess.Get();
    1781         [ #  # ]:          0 :             const SwFmtHoriOrient &rHori = rAttrs.GetAttrSet().GetHoriOrient();
    1782                 :          0 :             long nWidth = rAttrs.GetSize().Width();
    1783         [ #  # ]:          0 :             if ( nWidth < USHRT_MAX-2000 && //-2000, weil bei Randeinstellung per
           [ #  #  #  # ]
    1784                 :            :                                             //Zuppeln das USHRT_MAX verlorengeht!
    1785                 :          0 :                  text::HoriOrientation::FULL != rHori.GetHoriOrient() )
    1786                 :            :             {
    1787                 :            :                 const SwHTMLTableLayout *pLayoutInfo =
    1788                 :            :                     ((const SwTabFrm *)pFrm)->GetTable()
    1789                 :          0 :                                             ->GetHTMLTableLayout();
    1790         [ #  # ]:          0 :                 if ( pLayoutInfo )
    1791                 :          0 :                     nWidth = Min( nWidth, pLayoutInfo->GetBrowseWidthMin() );
    1792                 :            : 
    1793      [ #  #  # ]:          0 :                 switch ( rHori.GetHoriOrient() )
    1794                 :            :                 {
    1795                 :            :                     case text::HoriOrientation::NONE:
    1796                 :            :                         // OD 23.01.2003 #106895# - add 1st param to <SwBorderAttrs::CalcRight(..)>
    1797 [ #  # ][ #  # ]:          0 :                         nWidth += rAttrs.CalcLeft( pFrm ) + rAttrs.CalcRight( pFrm );
    1798                 :          0 :                         break;
    1799                 :            :                     case text::HoriOrientation::LEFT_AND_WIDTH:
    1800         [ #  # ]:          0 :                         nWidth += rAttrs.CalcLeft( pFrm );
    1801                 :          0 :                         break;
    1802                 :            :                     default:
    1803                 :          0 :                         break;
    1804                 :            : 
    1805                 :            :                 }
    1806                 :          0 :                 nBrowseWidth = Max( nBrowseWidth, nWidth );
    1807         [ #  # ]:          0 :             }
    1808                 :            :         }
    1809         [ -  + ]:        152 :         else if ( pFrm->GetDrawObjs() )
    1810                 :            :         {
    1811         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < pFrm->GetDrawObjs()->Count(); ++i )
    1812                 :            :             {
    1813                 :            :                 // #i28701#
    1814                 :          0 :                 SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
    1815                 :          0 :                 const SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
    1816                 :          0 :                 const sal_Bool bFly = pAnchoredObj->ISA(SwFlyFrm);
    1817         [ #  # ]:          0 :                 if ((bFly && (FAR_AWAY == pAnchoredObj->GetObjRect().Width()))
           [ #  #  #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1818         [ #  # ]:          0 :                     || rFmt.GetFrmSize().GetWidthPercent())
    1819                 :            :                 {
    1820                 :          0 :                     continue;
    1821                 :            :                 }
    1822                 :            : 
    1823                 :          0 :                 long nWidth = 0;
    1824      [ #  #  # ]:          0 :                 switch ( rFmt.GetAnchor().GetAnchorId() )
    1825                 :            :                 {
    1826                 :            :                     case FLY_AS_CHAR:
    1827         [ #  # ]:          0 :                         nWidth = bFly ? rFmt.GetFrmSize().GetWidth() :
    1828 [ #  # ][ #  # ]:          0 :                                         pAnchoredObj->GetObjRect().Width();
         [ #  # ][ #  # ]
    1829                 :          0 :                         break;
    1830                 :            :                     case FLY_AT_PARA:
    1831                 :            :                         {
    1832                 :            :                             // #i33170#
    1833                 :            :                             // Reactivated old code because
    1834                 :            :                             // nWidth = pAnchoredObj->GetObjRect().Right()
    1835                 :            :                             // gives wrong results for objects that are still
    1836                 :            :                             // at position FAR_AWAY.
    1837         [ #  # ]:          0 :                             if ( bFly )
    1838                 :            :                             {
    1839                 :          0 :                                 nWidth = rFmt.GetFrmSize().GetWidth();
    1840                 :          0 :                                 const SwFmtHoriOrient &rHori = rFmt.GetHoriOrient();
    1841      [ #  #  # ]:          0 :                                 switch ( rHori.GetHoriOrient() )
    1842                 :            :                                 {
    1843                 :            :                                     case text::HoriOrientation::NONE:
    1844                 :          0 :                                         nWidth += rHori.GetPos();
    1845                 :          0 :                                         break;
    1846                 :            :                                     case text::HoriOrientation::INSIDE:
    1847                 :            :                                     case text::HoriOrientation::LEFT:
    1848         [ #  # ]:          0 :                                         if ( text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() )
    1849                 :          0 :                                             nWidth += pFrm->Prt().Left();
    1850                 :          0 :                                         break;
    1851                 :            :                                     default:
    1852                 :          0 :                                         break;
    1853                 :            :                                 }
    1854                 :            :                             }
    1855                 :            :                             else
    1856                 :            :                                 //Fuer Zeichenobjekte ist die Auswahl sehr klein,
    1857                 :            :                                 //weil sie keine Attribute haben, also durch ihre
    1858                 :            :                                 //aktuelle Groesse bestimmt werden.
    1859                 :          0 :                                 nWidth = pAnchoredObj->GetObjRect().Right() -
    1860 [ #  # ][ #  # ]:          0 :                                          pAnchoredObj->GetDrawObj()->GetAnchorPos().X();
    1861                 :            :                         }
    1862                 :          0 :                         break;
    1863                 :            :                     default:    /* do nothing */;
    1864                 :            :                 }
    1865                 :          0 :                 nBrowseWidth = Max( nBrowseWidth, nWidth );
    1866                 :            :             }
    1867                 :            :         }
    1868                 :        152 :         pFrm = pFrm->FindNextCnt();
    1869                 :            :     } while ( pFrm );
    1870                 :            : }
    1871                 :            : 
    1872                 :            : /*************************************************************************
    1873                 :            : |*
    1874                 :            : |*  SwRootFrm::StartAllAction()
    1875                 :            : |*
    1876                 :            : |*************************************************************************/
    1877                 :            : 
    1878                 :      13074 : void SwRootFrm::StartAllAction()
    1879                 :            : {
    1880                 :      13074 :     ViewShell *pSh = GetCurrShell();
    1881         [ +  - ]:      13074 :     if ( pSh )
    1882         [ -  + ]:      13074 :         do
    1883         [ +  - ]:      13074 :         {   if ( pSh->ISA( SwCrsrShell ) )
    1884                 :      13074 :                 ((SwCrsrShell*)pSh)->StartAction();
    1885                 :            :             else
    1886                 :          0 :                 pSh->StartAction();
    1887                 :      13074 :             pSh = (ViewShell*)pSh->GetNext();
    1888                 :            : 
    1889                 :      13074 :         } while ( pSh != GetCurrShell() );
    1890                 :      13074 : }
    1891                 :            : 
    1892                 :      13074 : void SwRootFrm::EndAllAction( sal_Bool bVirDev )
    1893                 :            : {
    1894                 :      13074 :     ViewShell *pSh = GetCurrShell();
    1895         [ +  - ]:      13074 :     if ( pSh )
    1896         [ -  + ]:      13074 :         do
    1897                 :            :         {
    1898                 :      13074 :             const sal_Bool bOldEndActionByVirDev = pSh->IsEndActionByVirDev();
    1899                 :      13074 :             pSh->SetEndActionByVirDev( bVirDev );
    1900         [ +  - ]:      13074 :             if ( pSh->ISA( SwCrsrShell ) )
    1901                 :            :             {
    1902                 :      13074 :                 ((SwCrsrShell*)pSh)->EndAction();
    1903                 :      13074 :                 ((SwCrsrShell*)pSh)->CallChgLnk();
    1904         [ +  - ]:      13074 :                 if ( pSh->ISA( SwFEShell ) )
    1905                 :      13074 :                     ((SwFEShell*)pSh)->SetChainMarker();
    1906                 :            :             }
    1907                 :            :             else
    1908                 :          0 :                 pSh->EndAction();
    1909                 :      13074 :             pSh->SetEndActionByVirDev( bOldEndActionByVirDev );
    1910                 :      13074 :             pSh = (ViewShell*)pSh->GetNext();
    1911                 :            : 
    1912                 :      13074 :         } while ( pSh != GetCurrShell() );
    1913                 :      13074 : }
    1914                 :            : 
    1915                 :        309 : void SwRootFrm::UnoRemoveAllActions()
    1916                 :            : {
    1917                 :        309 :     ViewShell *pSh = GetCurrShell();
    1918         [ +  - ]:        309 :     if ( pSh )
    1919         [ -  + ]:        309 :         do
    1920                 :            :         {
    1921                 :            :             // #i84729#
    1922                 :            :             // No end action, if <ViewShell> instance is currently in its end action.
    1923                 :            :             // Recursives calls to <::EndAction()> are not allowed.
    1924         [ +  - ]:        309 :             if ( !pSh->IsInEndAction() )
    1925                 :            :             {
    1926                 :            :                 OSL_ENSURE(!pSh->GetRestoreActions(), "Restore action count is already set!");
    1927                 :        309 :                 sal_Bool bCrsr = pSh->ISA( SwCrsrShell );
    1928                 :        309 :                 sal_Bool bFE = pSh->ISA( SwFEShell );
    1929                 :        309 :                 sal_uInt16 nRestore = 0;
    1930         [ +  + ]:        433 :                 while( pSh->ActionCount() )
    1931                 :            :                 {
    1932         [ +  - ]:        124 :                     if( bCrsr )
    1933                 :            :                     {
    1934                 :        124 :                         ((SwCrsrShell*)pSh)->EndAction();
    1935                 :        124 :                         ((SwCrsrShell*)pSh)->CallChgLnk();
    1936         [ +  - ]:        124 :                         if ( bFE )
    1937                 :        124 :                             ((SwFEShell*)pSh)->SetChainMarker();
    1938                 :            :                     }
    1939                 :            :                     else
    1940                 :          0 :                         pSh->EndAction();
    1941                 :        124 :                     nRestore++;
    1942                 :            :                 }
    1943                 :        309 :                 pSh->SetRestoreActions(nRestore);
    1944                 :            :             }
    1945                 :        309 :             pSh->LockView(sal_True);
    1946                 :        309 :             pSh = (ViewShell*)pSh->GetNext();
    1947                 :            : 
    1948                 :        309 :         } while ( pSh != GetCurrShell() );
    1949                 :        309 : }
    1950                 :            : 
    1951                 :        309 : void SwRootFrm::UnoRestoreAllActions()
    1952                 :            : {
    1953                 :        309 :     ViewShell *pSh = GetCurrShell();
    1954         [ +  - ]:        309 :     if ( pSh )
    1955         [ -  + ]:        309 :         do
    1956                 :            :         {
    1957                 :        309 :             sal_uInt16 nActions = pSh->GetRestoreActions();
    1958         [ +  + ]:        433 :             while( nActions-- )
    1959                 :            :             {
    1960         [ +  - ]:        124 :                 if ( pSh->ISA( SwCrsrShell ) )
    1961                 :        124 :                     ((SwCrsrShell*)pSh)->StartAction();
    1962                 :            :                 else
    1963                 :          0 :                     pSh->StartAction();
    1964                 :            :             }
    1965                 :        309 :             pSh->SetRestoreActions(0);
    1966                 :        309 :             pSh->LockView(sal_False);
    1967                 :        309 :             pSh = (ViewShell*)pSh->GetNext();
    1968                 :            : 
    1969                 :        309 :         } while ( pSh != GetCurrShell() );
    1970                 :        309 : }
    1971                 :            : 
    1972                 :            : // PAGES01: Helper functions for SwRootFrm::CheckViewLayout
    1973                 :            : void lcl_MoveAllLowers( SwFrm* pFrm, const Point& rOffset );
    1974                 :            : 
    1975                 :       3361 : void lcl_MoveAllLowerObjs( SwFrm* pFrm, const Point& rOffset )
    1976                 :            : {
    1977                 :       3361 :     SwSortedObjs* pSortedObj = 0;
    1978                 :       3361 :     const bool bPage = pFrm->IsPageFrm();
    1979                 :            : 
    1980         [ +  + ]:       3361 :     if ( bPage )
    1981                 :       1501 :         pSortedObj = static_cast<SwPageFrm*>(pFrm)->GetSortedObjs();
    1982                 :            :     else
    1983                 :       1860 :         pSortedObj = pFrm->GetDrawObjs();
    1984                 :            : 
    1985 [ +  + ][ +  + ]:       3394 :     for ( sal_uInt16 i = 0; pSortedObj && i < pSortedObj->Count(); ++i)
                 [ +  + ]
    1986                 :            :     {
    1987         [ +  - ]:         33 :         SwAnchoredObject* pAnchoredObj = (*pSortedObj)[i];
    1988                 :            : 
    1989         [ +  - ]:         33 :         const SwFrmFmt& rObjFmt = pAnchoredObj->GetFrmFmt();
    1990         [ +  - ]:         33 :         const SwFmtAnchor& rAnchor = rObjFmt.GetAnchor();
    1991                 :            : 
    1992                 :            :         // all except from the as character anchored objects are moved
    1993                 :            :         // when processing the page frame:
    1994                 :         33 :         const bool bAsChar = (rAnchor.GetAnchorId() == FLY_AS_CHAR);
    1995 [ +  - ][ +  + ]:         33 :         if ( !bPage && !bAsChar )
    1996                 :         21 :             continue;
    1997                 :            : 
    1998         [ +  - ]:         12 :         SwObjPositioningInProgress aPosInProgress( *pAnchoredObj );
    1999                 :            : 
    2000 [ +  - ][ +  - ]:         12 :         if ( pAnchoredObj->ISA(SwFlyFrm) )
                 [ +  - ]
    2001                 :            :         {
    2002         [ +  - ]:         12 :             SwFlyFrm* pFlyFrm( static_cast<SwFlyFrm*>(pAnchoredObj) );
    2003         [ +  - ]:         12 :             lcl_MoveAllLowers( pFlyFrm, rOffset );
    2004         [ +  - ]:         12 :             pFlyFrm->NotifyDrawObj();
    2005                 :            :             // --> let the active embedded object be moved
    2006         [ +  - ]:         12 :             if ( pFlyFrm->Lower() )
    2007                 :            :             {
    2008         [ +  - ]:         12 :                 if ( pFlyFrm->Lower()->IsNoTxtFrm() )
    2009                 :            :                 {
    2010                 :         12 :                     SwCntntFrm* pCntntFrm = static_cast<SwCntntFrm*>(pFlyFrm->Lower());
    2011                 :         12 :                     SwRootFrm* pRoot = pFlyFrm->Lower()->getRootFrm();
    2012         [ +  - ]:         12 :                     ViewShell *pSh = pRoot ? pRoot->GetCurrShell() : 0;
    2013         [ +  - ]:         12 :                     if ( pSh )
    2014                 :            :                     {
    2015                 :         12 :                         SwOLENode* pNode = pCntntFrm->GetNode()->GetOLENode();
    2016         [ -  + ]:         12 :                         if ( pNode )
    2017                 :            :                         {
    2018         [ #  # ]:          0 :                             svt::EmbeddedObjectRef& xObj = pNode->GetOLEObj().GetObject();
    2019         [ #  # ]:          0 :                             if ( xObj.is() )
    2020                 :            :                             {
    2021                 :          0 :                                 ViewShell* pTmp = pSh;
    2022         [ #  # ]:          0 :                                 do
    2023                 :            :                                 {
    2024         [ #  # ]:          0 :                                     SwFEShell* pFEShell = dynamic_cast< SwFEShell* >( pTmp );
    2025         [ #  # ]:          0 :                                     if ( pFEShell )
    2026         [ #  # ]:          0 :                                         pFEShell->MoveObjectIfActive( xObj, rOffset );
    2027                 :          0 :                                     pTmp = static_cast<ViewShell*>( pTmp->GetNext() );
    2028                 :            :                                 } while( pTmp != pSh );
    2029                 :            :                             }
    2030                 :            :                         }
    2031                 :            :                     }
    2032                 :            :                 }
    2033                 :            :             }
    2034                 :            :         }
    2035 [ #  # ][ #  # ]:          0 :         else if ( pAnchoredObj->ISA(SwAnchoredDrawObject) )
                 [ #  # ]
    2036                 :            :         {
    2037                 :          0 :             SwAnchoredDrawObject* pAnchoredDrawObj( static_cast<SwAnchoredDrawObject*>(pAnchoredObj) );
    2038                 :            : 
    2039                 :            :             // don't touch objects that are not yet positioned:
    2040                 :          0 :             const bool bNotYetPositioned = pAnchoredDrawObj->NotYetPositioned();
    2041         [ #  # ]:          0 :             if ( bNotYetPositioned )
    2042                 :          0 :                 continue;
    2043                 :            : 
    2044 [ #  # ][ #  # ]:          0 :             const Point aCurrAnchorPos = pAnchoredDrawObj->GetDrawObj()->GetAnchorPos();
    2045                 :          0 :             const Point aNewAnchorPos( ( aCurrAnchorPos + rOffset ) );
    2046 [ #  # ][ #  # ]:          0 :             pAnchoredDrawObj->DrawObj()->SetAnchorPos( aNewAnchorPos );
    2047 [ #  # ][ #  # ]:          0 :             pAnchoredDrawObj->SetLastObjRect( pAnchoredDrawObj->GetObjRect().SVRect() );
                 [ #  # ]
    2048                 :            : 
    2049                 :            :             // clear contour cache
    2050 [ #  # ][ #  # ]:          0 :             if ( pAnchoredDrawObj->GetFrmFmt().GetSurround().IsContour() )
                 [ #  # ]
    2051 [ #  # ][ #  # ]:          0 :                 ClrContourCache( pAnchoredDrawObj->GetDrawObj() );
    2052                 :            :         }
    2053                 :            :         // #i92511#
    2054                 :            :         // cache for object rectangle inclusive spaces has to be invalidated.
    2055         [ +  - ]:         45 :         pAnchoredObj->InvalidateObjRectWithSpaces();
    2056         [ +  - ]:         12 :     }
    2057                 :       3361 : }
    2058                 :            : 
    2059                 :       3361 : void lcl_MoveAllLowers( SwFrm* pFrm, const Point& rOffset )
    2060                 :            : {
    2061                 :       3361 :     const SwRect aFrm( pFrm->Frm() );
    2062                 :            : 
    2063                 :            :     // first move the current frame
    2064                 :       3361 :     pFrm->Frm().Pos() += rOffset;
    2065                 :            : 
    2066                 :            :     // Don't forget accessibility:
    2067         [ +  + ]:       3361 :     if( pFrm->IsAccessibleFrm() )
    2068                 :            :     {
    2069                 :       1798 :         SwRootFrm *pRootFrm = pFrm->getRootFrm();
    2070   [ +  +  +  - ]:       1914 :         if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
         [ +  + ][ +  - ]
    2071                 :        116 :             pRootFrm->GetCurrShell() )
    2072                 :            :         {
    2073         [ +  - ]:        116 :             pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( pFrm, aFrm );
    2074                 :            :         }
    2075                 :            :     }
    2076                 :            : 
    2077                 :            :     // the move any objects
    2078         [ +  - ]:       3361 :     lcl_MoveAllLowerObjs( pFrm, rOffset );
    2079                 :            : 
    2080                 :            :     // finally, for layout frames we have to call this function recursively:
    2081 [ +  - ][ +  - ]:       3361 :     if ( pFrm->ISA(SwLayoutFrm) )
                 [ +  + ]
    2082                 :            :     {
    2083         [ +  - ]:       3169 :         SwFrm* pLowerFrm = pFrm->GetLower();
    2084         [ +  + ]:       5017 :         while ( pLowerFrm )
    2085                 :            :         {
    2086         [ +  - ]:       1848 :             lcl_MoveAllLowers( pLowerFrm, rOffset );
    2087                 :       1848 :             pLowerFrm = pLowerFrm->GetNext();
    2088                 :            :         }
    2089                 :            :     }
    2090                 :       3361 : }
    2091                 :            : 
    2092                 :            : // PAGES01: Calculate how the pages have to be positioned
    2093                 :      37288 : void SwRootFrm::CheckViewLayout( const SwViewOption* pViewOpt, const SwRect* pVisArea )
    2094                 :            : {
    2095                 :            :     // #i91432#
    2096                 :            :     // No calculation of page positions, if only an empty page is present.
    2097                 :            :     // This situation occurs when <SwRootFrm> instance is in construction
    2098                 :            :     // and the document contains only left pages.
    2099   [ +  +  -  + ]:      57439 :     if ( Lower()->GetNext() == 0 &&
                 [ +  - ]
    2100                 :      20151 :          static_cast<SwPageFrm*>(Lower())->IsEmptyPage() )
    2101                 :            :     {
    2102                 :            :         return;
    2103                 :            :     }
    2104                 :            : 
    2105         [ +  + ]:      37288 :     if ( !pVisArea )
    2106                 :            :     {
    2107                 :            :         // no early return for bNewPage
    2108         [ +  + ]:       1528 :         if ( mnViewWidth < 0 )
    2109                 :       1318 :             mnViewWidth = 0;
    2110                 :            :     }
    2111                 :            :     else
    2112                 :            :     {
    2113                 :            :         OSL_ENSURE( pViewOpt, "CheckViewLayout required ViewOptions" );
    2114                 :            : 
    2115                 :      35760 :         const sal_uInt16 nColumns =  pViewOpt->GetViewLayoutColumns();
    2116                 :      35760 :         const bool   bBookMode = pViewOpt->IsViewLayoutBookMode();
    2117                 :            : 
    2118 [ +  - ][ +  + ]:      35760 :         if ( nColumns == mnColumns && bBookMode == mbBookMode && pVisArea->Width() == mnViewWidth && !mbSidebarChanged )
         [ +  + ][ +  + ]
                 [ +  + ]
    2119                 :            :             return;
    2120                 :            : 
    2121                 :       2046 :         mnColumns = nColumns;
    2122                 :       2046 :         mbBookMode = bBookMode;
    2123                 :       2046 :         mnViewWidth = pVisArea->Width();
    2124                 :       2046 :         mbSidebarChanged = false;
    2125                 :            :     }
    2126                 :            : 
    2127 [ +  - ][ +  - ]:       3574 :     if( GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::BROWSE_MODE ) )
         [ +  - ][ +  + ]
    2128                 :            :     {
    2129                 :        561 :         mnColumns = 1;
    2130                 :        561 :         mbBookMode = false;
    2131                 :            :     }
    2132                 :            : 
    2133         [ +  - ]:       3574 :     Calc();
    2134                 :            : 
    2135                 :       3574 :     const sal_Bool bOldCallbackActionEnabled = IsCallbackActionEnabled();
    2136                 :       3574 :     SetCallbackActionEnabled( sal_False );
    2137                 :            : 
    2138                 :       3574 :     maPageRects.clear();
    2139                 :            : 
    2140                 :       3574 :     const long nBorder = Frm().Pos().X();
    2141                 :       3574 :     const long nVisWidth = mnViewWidth - 2 * nBorder;
    2142                 :       3574 :     const long nGapBetweenPages = GAPBETWEENPAGES;
    2143                 :            : 
    2144                 :            :     // check how many pages fit into the first page layout row:
    2145                 :       3574 :     SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(Lower());
    2146                 :            : 
    2147                 :            :     // will contain the number of pages per row. 0 means that
    2148                 :            :     // the page does not fit.
    2149                 :       3574 :     long nWidthRemain = nVisWidth;
    2150                 :            : 
    2151                 :            :     // after one row has been processed, these variables contain
    2152                 :            :     // the width of the row and the maxium of the page heights
    2153                 :       3574 :     long nCurrentRowHeight = 0;
    2154                 :       3574 :     long nCurrentRowWidth = 0;
    2155                 :            : 
    2156                 :            :     // these variables are used to finally set the size of the
    2157                 :            :     // root frame
    2158                 :       3574 :     long nSumRowHeight = 0;
    2159                 :       3574 :     SwTwips nMinPageLeft = TWIPS_MAX;
    2160                 :       3574 :     SwTwips nMaxPageRight = 0;
    2161                 :       3574 :     SwPageFrm* pStartOfRow = pPageFrm;
    2162         [ -  + ]:       3574 :     sal_uInt16 nNumberOfPagesInRow = mbBookMode ? 1 : 0; // in book view, start with right page
    2163                 :       3574 :     bool bFirstRow = true;
    2164                 :            : 
    2165                 :       3574 :     bool bPageChanged = false;
    2166         [ +  - ]:       3574 :     const bool bRTL = !IsLeftToRightViewLayout();
    2167         [ +  - ]:       3574 :     const SwTwips nSidebarWidth = SwPageFrm::GetSidebarBorderWidth( GetCurrShell() );
    2168                 :            : 
    2169         [ +  + ]:       7446 :     while ( pPageFrm )
    2170                 :            :     {
    2171                 :            :         // we consider the current page to be "start of row" if
    2172                 :            :         // 1. it is the first page in the current row or
    2173                 :            :         // 2. it is the second page in the row and the first page is an empty page in non-book view:
    2174                 :            :         const bool bStartOfRow = pPageFrm == pStartOfRow ||
    2175 [ +  + ][ +  + ]:       3872 :                                              ( pStartOfRow->IsEmptyPage() && pPageFrm == pStartOfRow->GetNext() && !mbBookMode );
         [ +  - ][ +  - ]
    2176                 :            : 
    2177 [ +  + ][ +  - ]:       3872 :         const bool bEmptyPage = pPageFrm->IsEmptyPage() && !mbBookMode;
    2178                 :            : 
    2179                 :            :         // no half doc border space for first page in each row and
    2180                 :       3872 :         long nPageWidth = 0;
    2181                 :       3872 :         long nPageHeight = 0;
    2182                 :            : 
    2183         [ -  + ]:       3872 :         if ( mbBookMode )
    2184                 :            :         {
    2185         [ #  # ]:          0 :             const SwFrm& rFormatPage = pPageFrm->GetFormatPage();
    2186                 :            : 
    2187 [ #  # ][ #  # ]:          0 :             nPageWidth  = rFormatPage.Frm().Width()  + nSidebarWidth + ((bStartOfRow || 1 == (pPageFrm->GetPhyPageNum()%2)) ? 0 : nGapBetweenPages);
    2188                 :          0 :             nPageHeight = rFormatPage.Frm().Height() + nGapBetweenPages;
    2189                 :            :         }
    2190                 :            :         else
    2191                 :            :         {
    2192                 :       3872 :             SwRect aPageFrm;
    2193         [ +  + ]:       3872 :             if ( !pPageFrm->IsEmptyPage() )
    2194                 :            :             {
    2195         [ +  + ]:       3857 :                 nPageWidth  = pPageFrm->Frm().Width() + nSidebarWidth + (bStartOfRow ? 0 : nGapBetweenPages);
    2196                 :       3872 :                 nPageHeight = pPageFrm->Frm().Height() + nGapBetweenPages;
    2197                 :            :             }
    2198                 :            :         }
    2199                 :            : 
    2200         [ +  + ]:       3872 :         if ( !bEmptyPage )
    2201                 :       3857 :             ++nNumberOfPagesInRow;
    2202                 :            : 
    2203                 :            :         // finish current row if
    2204                 :            :         // 1. in dynamic mode the current page does not fit anymore or
    2205                 :            :         // 2. the current page exceeds the maximum number of columns
    2206                 :            :         bool bRowFinished = (0 == mnColumns && nWidthRemain < nPageWidth ) ||
    2207 [ +  + ][ +  + ]:       3872 :                             (0 != mnColumns && mnColumns < nNumberOfPagesInRow);
         [ +  + ][ -  + ]
    2208                 :            : 
    2209                 :            :         // make sure that at least one page goes to the current row:
    2210 [ +  + ][ +  - ]:       3872 :         if ( !bRowFinished || bStartOfRow )
    2211                 :            :         {
    2212                 :            :             // current page is allowed to be in current row
    2213                 :       3872 :             nWidthRemain = nWidthRemain - nPageWidth;
    2214                 :            : 
    2215                 :       3872 :             nCurrentRowWidth = nCurrentRowWidth + nPageWidth;
    2216                 :       3872 :             nCurrentRowHeight = Max( nCurrentRowHeight, nPageHeight );
    2217                 :            : 
    2218                 :       3872 :             pPageFrm = static_cast<SwPageFrm*>(pPageFrm->GetNext());
    2219                 :            : 
    2220         [ +  + ]:       3872 :             if ( !pPageFrm )
    2221                 :       3574 :                 bRowFinished = true;
    2222                 :            :         }
    2223                 :            : 
    2224         [ +  + ]:       3872 :         if ( bRowFinished )
    2225                 :            :         {
    2226                 :            :             // pPageFrm now points to the first page in the new row or null
    2227                 :            :             // pStartOfRow points to the first page in the current row
    2228                 :            : 
    2229                 :            :             // special centering for last row. pretend to fill the last row with virtual copies of the last page before centering:
    2230 [ +  + ][ +  + ]:       3839 :             if ( !pPageFrm && nWidthRemain > 0 )
    2231                 :            :             {
    2232                 :            :                 // find last page in current row:
    2233                 :         73 :                 const SwPageFrm* pLastPageInCurrentRow = pStartOfRow;
    2234         [ +  + ]:        103 :                 while( pLastPageInCurrentRow->GetNext() )
    2235                 :         30 :                     pLastPageInCurrentRow = static_cast<const SwPageFrm*>(pLastPageInCurrentRow->GetNext());
    2236                 :            : 
    2237         [ -  + ]:         73 :                 if ( pLastPageInCurrentRow->IsEmptyPage() )
    2238                 :          0 :                     pLastPageInCurrentRow = static_cast<const SwPageFrm*>(pLastPageInCurrentRow->GetPrev());
    2239                 :            : 
    2240                 :            :                 // check how many times the last page would still fit into the remaining space:
    2241                 :         73 :                 sal_uInt16 nNumberOfVirtualPages = 0;
    2242         [ -  + ]:         73 :                 const sal_uInt16 nMaxNumberOfVirtualPages = mnColumns > 0 ? mnColumns - nNumberOfPagesInRow : USHRT_MAX;
    2243                 :         73 :                 SwTwips nRemain = nWidthRemain;
    2244                 :         73 :                 SwTwips nVirtualPagesWidth = 0;
    2245                 :         73 :                 SwTwips nLastPageWidth = pLastPageInCurrentRow->Frm().Width() + nSidebarWidth;
    2246                 :            : 
    2247 [ +  - ][ +  + ]:        581 :                 while ( ( mnColumns > 0 || nRemain > 0 ) && nNumberOfVirtualPages < nMaxNumberOfVirtualPages )
         [ +  - ][ +  + ]
    2248                 :            :                 {
    2249                 :        508 :                     SwTwips nLastPageWidthWithGap = nLastPageWidth;
    2250 [ -  + ][ #  # ]:        508 :                     if ( !mbBookMode || ( 0 == (nNumberOfVirtualPages + nNumberOfPagesInRow) %2) )
    2251                 :        508 :                         nLastPageWidthWithGap += nGapBetweenPages;
    2252                 :            : 
    2253 [ +  - ][ +  + ]:        508 :                     if ( mnColumns > 0 || nLastPageWidthWithGap < nRemain )
    2254                 :            :                     {
    2255                 :        435 :                         ++nNumberOfVirtualPages;
    2256                 :        435 :                         nVirtualPagesWidth += nLastPageWidthWithGap;
    2257                 :            :                     }
    2258                 :        508 :                     nRemain = nRemain - nLastPageWidthWithGap;
    2259                 :            :                 }
    2260                 :            : 
    2261                 :         73 :                 nCurrentRowWidth = nCurrentRowWidth + nVirtualPagesWidth;
    2262                 :            :             }
    2263                 :            : 
    2264                 :            :             // first page in book mode is always special:
    2265 [ +  + ][ -  + ]:       3839 :             if ( bFirstRow && mbBookMode )
    2266                 :            :             {
    2267                 :            :                 // #i88036#
    2268                 :            :                 nCurrentRowWidth +=
    2269         [ #  # ]:          0 :                     pStartOfRow->GetFormatPage().Frm().Width() + nSidebarWidth;
    2270                 :            :             }
    2271                 :            : 
    2272                 :            :             // center page if possible
    2273                 :            :             const long nSizeDiff = nVisWidth > nCurrentRowWidth ?
    2274                 :            :                                    ( nVisWidth - nCurrentRowWidth ) / 2 :
    2275         [ +  + ]:       3839 :                                    0;
    2276                 :            : 
    2277                 :            :             // adjust positions of pages in current row
    2278                 :       3839 :             long nX = nSizeDiff;
    2279                 :            : 
    2280                 :       3839 :             const long nRowStart = nBorder + nSizeDiff;
    2281                 :       3839 :             const long nRowEnd   = nRowStart + nCurrentRowWidth;
    2282                 :            : 
    2283 [ +  + ][ -  + ]:       3839 :             if ( bFirstRow && mbBookMode )
    2284                 :            :             {
    2285                 :            :                 // #i88036#
    2286         [ #  # ]:          0 :                 nX += pStartOfRow->GetFormatPage().Frm().Width() + nSidebarWidth;
    2287                 :            :             }
    2288                 :            : 
    2289                 :       3839 :             SwPageFrm* pEndOfRow = pPageFrm;
    2290                 :       3839 :             SwPageFrm* pPageToAdjust = pStartOfRow;
    2291                 :            : 
    2292         [ +  + ]:       3872 :             do
    2293                 :            :             {
    2294                 :       3872 :                 const SwPageFrm* pFormatPage = pPageToAdjust;
    2295         [ -  + ]:       3872 :                 if ( mbBookMode )
    2296         [ #  # ]:          0 :                     pFormatPage = &pPageToAdjust->GetFormatPage();
    2297                 :            : 
    2298         [ +  + ]:       3872 :                 const SwTwips nCurrentPageWidth = pFormatPage->Frm().Width() + (pFormatPage->IsEmptyPage() ? 0 : nSidebarWidth);
    2299                 :       3872 :                 const Point aOldPagePos = pPageToAdjust->Frm().Pos();
    2300         [ +  - ]:       3872 :                 const bool bLeftSidebar = pPageToAdjust->SidebarPosition() == sw::sidebarwindows::SIDEBAR_LEFT;
    2301                 :            :                 const SwTwips nLeftPageAddOffset = bLeftSidebar ?
    2302                 :            :                                                    nSidebarWidth :
    2303         [ +  + ]:       3872 :                                                    0;
    2304                 :            : 
    2305                 :       3872 :                 Point aNewPagePos( nBorder + nX, nBorder + nSumRowHeight );
    2306                 :       3872 :                 Point aNewPagePosWithLeftOffset( nBorder + nX + nLeftPageAddOffset, nBorder + nSumRowHeight );
    2307                 :            : 
    2308                 :            :                 // RTL view layout: Calculate mirrored page position
    2309         [ +  + ]:       3872 :                 if ( bRTL )
    2310                 :            :                 {
    2311                 :          6 :                     const long nXOffsetInRow = aNewPagePos.X() - nRowStart;
    2312                 :          6 :                     aNewPagePos.X() = nRowEnd - nXOffsetInRow - nCurrentPageWidth;
    2313                 :          6 :                     aNewPagePosWithLeftOffset = aNewPagePos;
    2314                 :          6 :                     aNewPagePosWithLeftOffset.X() += nLeftPageAddOffset;
    2315                 :            :                 }
    2316                 :            : 
    2317         [ +  + ]:       3872 :                 if ( aNewPagePosWithLeftOffset != aOldPagePos )
    2318                 :            :                 {
    2319         [ +  - ]:       1501 :                     lcl_MoveAllLowers( pPageToAdjust, aNewPagePosWithLeftOffset - aOldPagePos );
    2320                 :       1501 :                     pPageToAdjust->SetCompletePaint();
    2321                 :       1501 :                     bPageChanged = true;
    2322                 :            :                 }
    2323                 :            : 
    2324                 :            :                 // calculate area covered by the current page and store to
    2325                 :            :                 // maPageRects. This is used e.g., for cursor setting
    2326                 :       3872 :                 const bool bFirstColumn = pPageToAdjust == pStartOfRow;
    2327                 :       3872 :                 const bool bLastColumn = pPageToAdjust->GetNext() == pEndOfRow;
    2328                 :       3872 :                 const bool bLastRow = !pEndOfRow;
    2329                 :            : 
    2330                 :       3872 :                 nMinPageLeft  = Min( nMinPageLeft, aNewPagePos.X() );
    2331                 :       3872 :                 nMaxPageRight = Max( nMaxPageRight, aNewPagePos.X() + nCurrentPageWidth);
    2332                 :            : 
    2333                 :            :                 // border of nGapBetweenPages around the current page:
    2334                 :       3872 :                 SwRect aPageRectWithBorders( aNewPagePos.X() - nGapBetweenPages,
    2335                 :       3872 :                                              aNewPagePos.Y(),
    2336                 :       3872 :                                              pPageToAdjust->Frm().SSize().Width() + nGapBetweenPages + nSidebarWidth,
    2337                 :       3872 :                                              nCurrentRowHeight );
    2338                 :            : 
    2339                 :            :                 static const long nOuterClickDiff = 1000000;
    2340                 :            : 
    2341                 :            :                 // adjust borders for these special cases:
    2342 [ +  + ][ +  - ]:       3872 :                 if ( (bFirstColumn && !bRTL) || (bLastColumn && bRTL) )
         [ +  + ][ +  + ]
    2343         [ +  - ]:       3839 :                     aPageRectWithBorders.SubLeft( nOuterClickDiff );
    2344 [ +  + ][ +  + ]:       3872 :                 if ( (bLastColumn && !bRTL) || (bFirstColumn && bRTL) )
         [ +  - ][ +  + ]
    2345         [ +  - ]:       3839 :                     aPageRectWithBorders.AddRight( nOuterClickDiff );
    2346         [ +  + ]:       3872 :                 if ( bFirstRow )
    2347         [ +  - ]:       3604 :                     aPageRectWithBorders.SubTop( nOuterClickDiff );
    2348         [ +  + ]:       3872 :                 if ( bLastRow )
    2349         [ +  - ]:       3604 :                     aPageRectWithBorders.AddBottom( nOuterClickDiff );
    2350                 :            : 
    2351         [ +  - ]:       3872 :                 maPageRects.push_back( aPageRectWithBorders );
    2352                 :            : 
    2353                 :       3872 :                 nX = nX + nCurrentPageWidth;
    2354                 :       3872 :                 pPageToAdjust = static_cast<SwPageFrm*>(pPageToAdjust->GetNext());
    2355                 :            : 
    2356                 :            :                 // distance to next page
    2357 [ +  + ][ +  + ]:       3872 :                 if ( pPageToAdjust && pPageToAdjust != pEndOfRow )
    2358                 :            :                 {
    2359                 :            :                     // in book view, we add the x gap before left (even) pages:
    2360         [ -  + ]:         33 :                     if ( mbBookMode )
    2361                 :            :                     {
    2362         [ #  # ]:          0 :                         if ( 0 == (pPageToAdjust->GetPhyPageNum()%2) )
    2363                 :          0 :                             nX = nX + nGapBetweenPages;
    2364                 :            :                     }
    2365                 :            :                     else
    2366                 :            :                     {
    2367                 :            :                         // in non-book view, dont add x gap before
    2368                 :            :                         // 1. the last empty page in a row
    2369                 :            :                         // 2. after an empty page
    2370                 :         33 :                         const bool bDontAddGap = ( pPageToAdjust->IsEmptyPage() && pPageToAdjust->GetNext() == pEndOfRow ) ||
    2371         [ +  + ]:         33 :                                                  ( static_cast<SwPageFrm*>(pPageToAdjust->GetPrev())->IsEmptyPage() );
           [ -  +  #  # ]
    2372                 :            : 
    2373         [ +  + ]:         33 :                         if  ( !bDontAddGap )
    2374                 :         30 :                             nX = nX + nGapBetweenPages;
    2375                 :            :                     }
    2376                 :            :                 }
    2377                 :            :             }
    2378                 :            :             while ( pPageToAdjust != pEndOfRow );
    2379                 :            : 
    2380                 :            :             // adjust values for root frame size
    2381                 :       3839 :             nSumRowHeight = nSumRowHeight + nCurrentRowHeight;
    2382                 :            : 
    2383                 :            :             // start new row:
    2384                 :       3839 :             nCurrentRowHeight = 0;
    2385                 :       3839 :             nCurrentRowWidth = 0;
    2386                 :       3839 :             pStartOfRow = pEndOfRow;
    2387                 :       3839 :             nWidthRemain = nVisWidth;
    2388                 :       3839 :             nNumberOfPagesInRow = 0;
    2389                 :       3839 :             bFirstRow = false;
    2390                 :            :         } // end row finished
    2391                 :            :     } // end while
    2392                 :            : 
    2393                 :            :     // set size of root frame:
    2394                 :       3574 :     const Size aOldSize( Frm().SSize() );
    2395                 :       3574 :     const Size aNewSize( nMaxPageRight - nBorder, nSumRowHeight - nGapBetweenPages );
    2396                 :            : 
    2397 [ +  + ][ +  + ]:       3574 :     if ( bPageChanged || aNewSize != aOldSize )
                 [ +  + ]
    2398                 :            :     {
    2399         [ +  - ]:       1552 :         ChgSize( aNewSize );
    2400         [ +  - ]:       1552 :         ::AdjustSizeChgNotify( this );
    2401         [ +  - ]:       1552 :         Calc();
    2402                 :            : 
    2403                 :       1552 :         ViewShell* pSh = GetCurrShell();
    2404                 :            : 
    2405 [ +  - ][ +  + ]:       1552 :         if ( pSh && pSh->GetDoc()->GetDocShell() )
                 [ +  + ]
    2406                 :            :         {
    2407         [ +  - ]:       1542 :             pSh->SetFirstVisPageInvalid();
    2408         [ +  + ]:       1542 :             if (bOldCallbackActionEnabled)
    2409                 :            :             {
    2410         [ +  - ]:        152 :                 pSh->InvalidateWindows( SwRect( 0, 0, LONG_MAX, LONG_MAX ) );
    2411 [ +  - ][ +  - ]:        152 :                 pSh->GetDoc()->GetDocShell()->Broadcast(SfxSimpleHint(SFX_HINT_DOCCHANGED));
                 [ +  - ]
    2412                 :            :             }
    2413                 :            :         }
    2414                 :            :     }
    2415                 :            : 
    2416                 :       3574 :     maPagesArea.Pos( Frm().Pos() );
    2417                 :       3574 :     maPagesArea.SSize( aNewSize );
    2418         [ +  - ]:       3574 :     if ( TWIPS_MAX != nMinPageLeft )
    2419         [ +  - ]:       3574 :         maPagesArea._Left( nMinPageLeft );
    2420                 :            : 
    2421                 :      37288 :     SetCallbackActionEnabled( bOldCallbackActionEnabled );
    2422                 :            : }
    2423                 :            : 
    2424                 :      85070 : bool SwRootFrm::IsLeftToRightViewLayout() const
    2425                 :            : {
    2426                 :            :     // Layout direction determined by layout direction of the first page.
    2427                 :            :     // #i88036#
    2428                 :            :     // Only ask a non-empty page frame for its layout direction
    2429                 :            : //    const SwPageFrm* pPage = dynamic_cast<const SwPageFrm*>(Lower());
    2430                 :            : //    return !pPage->IsRightToLeft() && !pPage->IsVertical();
    2431                 :            :     const SwPageFrm& rPage =
    2432         [ -  + ]:      85070 :                     dynamic_cast<const SwPageFrm*>(Lower())->GetFormatPage();
    2433 [ +  + ][ +  - ]:      85070 :     return !rPage.IsRightToLeft() && !rPage.IsVertical();
    2434                 :            : }
    2435                 :            : 
    2436                 :      85070 : const SwPageFrm& SwPageFrm::GetFormatPage() const
    2437                 :            : {
    2438                 :      85070 :     const SwPageFrm* pRet = this;
    2439         [ -  + ]:      85070 :     if ( IsEmptyPage() )
    2440                 :            :     {
    2441         [ #  # ]:          0 :         pRet = static_cast<const SwPageFrm*>( OnRightPage() ? GetNext() : GetPrev() );
    2442                 :            :         // #i88035#
    2443                 :            :         // Typically a right empty page frame has a next non-empty page frame and
    2444                 :            :         // a left empty page frame has a previous non-empty page frame.
    2445                 :            :         // But under certain cirsumstances this assumption is not true -
    2446                 :            :         // e.g. during insertion of a left page at the end of the document right
    2447                 :            :         // after a left page in an intermediate state a right empty page does not
    2448                 :            :         // have a next page frame.
    2449         [ #  # ]:          0 :         if ( pRet == 0 )
    2450                 :            :         {
    2451         [ #  # ]:          0 :             if ( OnRightPage() )
    2452                 :            :             {
    2453                 :          0 :                 pRet = static_cast<const SwPageFrm*>( GetPrev() );
    2454                 :            :             }
    2455                 :            :             else
    2456                 :            :             {
    2457                 :          0 :                 pRet = static_cast<const SwPageFrm*>( GetNext() );
    2458                 :            :             }
    2459                 :            :         }
    2460                 :            :         OSL_ENSURE( pRet,
    2461                 :            :                 "<SwPageFrm::GetFormatPage()> - inconsistent layout: empty page without previous and next page frame --> crash." );
    2462                 :            :     }
    2463                 :      85070 :     return *pRet;
    2464                 :            : }
    2465                 :            : 
    2466                 :          0 : bool SwPageFrm::IsOverHeaderFooterArea( const Point& rPt, FrameControlType &rControl ) const
    2467                 :            : {
    2468                 :          0 :     long nUpperLimit = 0;
    2469                 :          0 :     long nLowerLimit = 0;
    2470                 :          0 :     const SwFrm* pFrm = Lower();
    2471         [ #  # ]:          0 :     while ( pFrm )
    2472                 :            :     {
    2473         [ #  # ]:          0 :         if ( pFrm->IsBodyFrm() )
    2474                 :            :         {
    2475                 :          0 :             nUpperLimit = pFrm->Frm().Top();
    2476                 :          0 :             nLowerLimit = pFrm->Frm().Bottom();
    2477                 :            :         }
    2478         [ #  # ]:          0 :         else if ( pFrm->IsFtnContFrm() )
    2479                 :          0 :             nLowerLimit = pFrm->Frm().Bottom();
    2480                 :            : 
    2481                 :          0 :         pFrm = pFrm->GetNext();
    2482                 :            :     }
    2483                 :            : 
    2484                 :          0 :     SwRect aHeaderArea( Frm().TopLeft(),
    2485         [ #  # ]:          0 :            Size( Frm().Width(), nUpperLimit - Frm().Top() ) );
    2486                 :            : 
    2487 [ #  # ][ #  # ]:          0 :     if ( aHeaderArea.IsInside( rPt ) )
    2488                 :            :     {
    2489                 :          0 :         rControl = Header;
    2490                 :          0 :         return true;
    2491                 :            :     }
    2492                 :            :     else
    2493                 :            :     {
    2494                 :          0 :         SwRect aFooterArea( Point( Frm().Left(), nLowerLimit ),
    2495                 :          0 :                 Size( Frm().Width(), Frm().Bottom() - nLowerLimit ) );
    2496                 :            : 
    2497 [ #  # ][ #  # ]:          0 :         if ( aFooterArea.IsInside( rPt ) )
    2498                 :            :         {
    2499                 :          0 :             rControl = Footer;
    2500                 :          0 :             return true;
    2501                 :            :         }
    2502                 :            :     }
    2503                 :            : 
    2504                 :          0 :     return false;
    2505                 :            : }
    2506                 :            : 
    2507                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10