LCOV - code coverage report
Current view: top level - sw/source/core/layout - layact.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 977 1186 82.4 %
Date: 2012-08-25 Functions: 33 35 94.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1347 2204 61.1 %

           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 <time.h>
      31                 :            : #include "rootfrm.hxx"
      32                 :            : #include "pagefrm.hxx"
      33                 :            : #include "cntfrm.hxx"
      34                 :            : #include "doc.hxx"
      35                 :            : #include "IDocumentDrawModelAccess.hxx"
      36                 :            : #include "IDocumentSettingAccess.hxx"
      37                 :            : #include "IDocumentLayoutAccess.hxx"
      38                 :            : #include "IDocumentStatistics.hxx"
      39                 :            : #include "IDocumentTimerAccess.hxx"
      40                 :            : #include "viewimp.hxx"
      41                 :            : #include "crsrsh.hxx"
      42                 :            : #include "dflyobj.hxx"
      43                 :            : #include "flyfrm.hxx"
      44                 :            : #include "frmtool.hxx"
      45                 :            : #include "dcontact.hxx"
      46                 :            : #include "ndtxt.hxx"    // OnlineSpelling
      47                 :            : #include "frmfmt.hxx"
      48                 :            : #include "swregion.hxx"
      49                 :            : #include "viewopt.hxx"  // test OnlineSpelling using internal TabPage
      50                 :            : #include "pam.hxx"      // OnlineSpelling needed because of the current cursor position
      51                 :            : #include "dbg_lay.hxx"
      52                 :            : #include "layouter.hxx" // LoopControlling
      53                 :            : #include "docstat.hxx"
      54                 :            : #include "swevent.hxx"
      55                 :            : 
      56                 :            : #include <sfx2/event.hxx>
      57                 :            : 
      58                 :            : #include <ftnidx.hxx>
      59                 :            : #include <vcl/window.hxx>
      60                 :            : #include <vcl/svapp.hxx>
      61                 :            : #include <editeng/opaqitem.hxx>
      62                 :            : #include <editeng/brshitem.hxx>
      63                 :            : #include <SwSmartTagMgr.hxx>
      64                 :            : 
      65                 :            : #define _LAYACT_CXX
      66                 :            : #include "layact.hxx"
      67                 :            : #include <swwait.hxx>
      68                 :            : #include <fmtsrnd.hxx>
      69                 :            : #include <fmtanchr.hxx>
      70                 :            : #include <tools/shl.hxx>
      71                 :            : #include <sfx2/progress.hxx>
      72                 :            : #include <docsh.hxx>
      73                 :            : 
      74                 :            : #include "swmodule.hxx"
      75                 :            : #include "fmtline.hxx"
      76                 :            : #include "tabfrm.hxx"
      77                 :            : #include "ftnfrm.hxx"
      78                 :            : #include "txtfrm.hxx"
      79                 :            : #include "notxtfrm.hxx"
      80                 :            : #include "flyfrms.hxx"
      81                 :            : #include "mdiexp.hxx"
      82                 :            : #include "fmtornt.hxx"
      83                 :            : #include "sectfrm.hxx"
      84                 :            : #include "lineinfo.hxx"
      85                 :            : #include <acmplwrd.hxx>
      86                 :            : // #i28701#
      87                 :            : #include <sortedobjs.hxx>
      88                 :            : #include <objectformatter.hxx>
      89                 :            : #include <PostItMgr.hxx>
      90                 :            : #include <vector>
      91                 :            : 
      92                 :            : //#pragma optimize("ity",on)
      93                 :            : 
      94                 :            : /*************************************************************************
      95                 :            : |*
      96                 :            : |*  SwLayAction static stuff
      97                 :            : |*
      98                 :            : |*************************************************************************/
      99                 :            : 
     100                 :            : #define IS_FLYS (pPage->GetSortedObjs())
     101                 :            : #define IS_INVAFLY (pPage->IsInvalidFly())
     102                 :            : 
     103                 :            : 
     104                 :            : // Save some typing work to avoid accessing destroyed pages.
     105                 :            : #if OSL_DEBUG_LEVEL > 1
     106                 :            : 
     107                 :            : static void BreakPoint()
     108                 :            : {
     109                 :            :     return;
     110                 :            : }
     111                 :            : 
     112                 :            : #define CHECKPAGE \
     113                 :            :             {   if ( IsAgain() ) \
     114                 :            :                 {   BreakPoint(); \
     115                 :            :                     return; \
     116                 :            :                 } \
     117                 :            :             }
     118                 :            : 
     119                 :            : #define XCHECKPAGE \
     120                 :            :             {   if ( IsAgain() ) \
     121                 :            :                 {   BreakPoint(); \
     122                 :            :                     if( bNoLoop ) \
     123                 :            :                         pLayoutAccess->GetLayouter()->EndLoopControl(); \
     124                 :            :                     return; \
     125                 :            :                 } \
     126                 :            :             }
     127                 :            : #else
     128                 :            : #define CHECKPAGE \
     129                 :            :             {   if ( IsAgain() ) \
     130                 :            :                     return; \
     131                 :            :             }
     132                 :            : 
     133                 :            : #define XCHECKPAGE \
     134                 :            :             {   if ( IsAgain() ) \
     135                 :            :                 { \
     136                 :            :                     if( bNoLoop ) \
     137                 :            :                         pLayoutAccess->GetLayouter()->EndLoopControl(); \
     138                 :            :                     return; \
     139                 :            :                 } \
     140                 :            :             }
     141                 :            : #endif
     142                 :            : 
     143                 :            : #define RESCHEDULE \
     144                 :            :     { \
     145                 :            :         if ( IsReschedule() )  \
     146                 :            :         { \
     147                 :            :             if (pProgress) pProgress->Reschedule(); \
     148                 :            :             ::RescheduleProgress( pImp->GetShell()->GetDoc()->GetDocShell() ); \
     149                 :            :         } \
     150                 :            :     }
     151                 :            : 
     152                 :      52419 : inline sal_uLong Ticks()
     153                 :            : {
     154                 :      52419 :     return 1000 * clock() / CLOCKS_PER_SEC;
     155                 :            : }
     156                 :            : 
     157                 :      21166 : void SwLayAction::CheckWaitCrsr()
     158                 :            : {
     159 [ +  + ][ -  + ]:      21166 :     RESCHEDULE
     160 [ +  + ][ +  + ]:      34391 :     if ( !IsWait() && IsWaitAllowed() && IsPaint() &&
           [ +  +  +  + ]
                 [ +  + ]
     161                 :      13225 :          ((Ticks() - GetStartTicks()) >= CLOCKS_PER_SEC/2) )
     162                 :            :     {
     163         [ +  - ]:          8 :         pWait = new SwWait( *pRoot->GetFmt()->GetDoc()->GetDocShell(), sal_True );
     164                 :            :     }
     165                 :      21166 : }
     166                 :            : 
     167                 :            : /*************************************************************************
     168                 :            : |*
     169                 :            : |*  SwLayAction::CheckIdleEnd()
     170                 :            : |*
     171                 :            : |*************************************************************************/
     172                 :            : // Time over already?
     173                 :      16096 : inline void SwLayAction::CheckIdleEnd()
     174                 :            : {
     175         [ +  + ]:      16096 :     if ( !IsInput() )
     176 [ +  + ][ +  + ]:      15761 :         bInput = GetInputType() && Application::AnyInput( GetInputType() );
     177                 :      16096 : }
     178                 :            : 
     179                 :            : /*************************************************************************
     180                 :            : |*
     181                 :            : |*  SwLayAction::SetStatBar()
     182                 :            : |*
     183                 :            : |*************************************************************************/
     184                 :        148 : void SwLayAction::SetStatBar( sal_Bool bNew )
     185                 :            : {
     186         [ +  - ]:        148 :     if ( bNew )
     187                 :            :     {
     188                 :        148 :         nEndPage = pRoot->GetPageNum();
     189                 :        148 :         nEndPage += nEndPage * 10 / 100;
     190                 :            :     }
     191                 :            :     else
     192                 :          0 :         nEndPage = USHRT_MAX;
     193                 :        148 : }
     194                 :            : 
     195                 :            : /*************************************************************************
     196                 :            : |*
     197                 :            : |*  SwLayAction::PaintCntnt()
     198                 :            : |*
     199                 :            : |*  Description        Depending of the type, the Cntnt is output
     200                 :            : |*      according to it's changes, or the area to be outputted is
     201                 :            : |*      registered with the region, respectively.
     202                 :            : |*      PaintCntnt: fills the region
     203                 :            : |*
     204                 :            : |*************************************************************************/
     205                 :       1613 : sal_Bool SwLayAction::PaintWithoutFlys( const SwRect &rRect, const SwCntntFrm *pCnt,
     206                 :            :                                     const SwPageFrm *pPage )
     207                 :            : {
     208         [ +  - ]:       1613 :     SwRegionRects aTmp( rRect );
     209                 :       1613 :     const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
     210         [ +  - ]:       1613 :     const SwFlyFrm *pSelfFly = pCnt->FindFlyFrm();
     211                 :            :     sal_uInt16 i;
     212                 :            : 
     213 [ +  - ][ +  + ]:       4014 :     for ( i = 0; i < rObjs.Count() && !aTmp.empty(); ++i )
         [ +  + ][ +  + ]
     214                 :            :     {
     215 [ +  - ][ +  - ]:       2401 :         SdrObject *pO = rObjs[i]->DrawObj();
     216 [ +  - ][ +  - ]:       2401 :         if ( !pO->ISA(SwVirtFlyDrawObj) )
                 [ +  + ]
     217                 :        208 :             continue;
     218                 :            : 
     219                 :            :         // OD 2004-01-15 #110582# - do not consider invisible objects
     220 [ +  - ][ +  - ]:       2193 :         const IDocumentDrawModelAccess* pIDDMA = pPage->GetFmt()->getIDocumentDrawModelAccess();
     221 [ +  - ][ +  - ]:       2193 :         if ( !pIDDMA->IsVisibleLayerId( pO->GetLayer() ) )
                 [ -  + ]
     222                 :            :         {
     223                 :          0 :             continue;
     224                 :            :         }
     225                 :            : 
     226                 :       2193 :         SwFlyFrm *pFly = ((SwVirtFlyDrawObj*)pO)->GetFlyFrm();
     227                 :            : 
     228 [ +  - ][ +  + ]:       2193 :         if ( pFly == pSelfFly || !rRect.IsOver( pFly->Frm() ) )
         [ +  + ][ +  + ]
     229                 :       1545 :             continue;
     230                 :            : 
     231 [ +  + ][ +  - ]:        648 :         if ( pSelfFly && pSelfFly->IsLowerOf( pFly ) )
         [ -  + ][ -  + ]
     232                 :          0 :             continue;
     233                 :            : 
     234 [ +  - ][ +  - ]:        648 :         if ( pFly->GetVirtDrawObj()->GetLayer() == pIDDMA->GetHellId() )
         [ +  - ][ -  + ]
     235                 :          0 :             continue;
     236                 :            : 
     237         [ +  + ]:        648 :         if ( pSelfFly )
     238                 :            :         {
     239         [ +  - ]:        256 :             const SdrObject *pTmp = pSelfFly->GetVirtDrawObj();
     240 [ +  - ][ +  - ]:        256 :             if ( pO->GetLayer() == pTmp->GetLayer() )
                 [ +  - ]
     241                 :            :             {
     242 [ +  - ][ +  - ]:        256 :                 if ( pO->GetOrdNumDirect() < pTmp->GetOrdNumDirect() )
                 [ +  + ]
     243                 :            :                     // Only look at things above us, if inside the same layer
     244                 :        219 :                     continue;
     245                 :            :             }
     246                 :            :             else
     247                 :            :             {
     248         [ #  # ]:          0 :                 const sal_Bool bLowerOfSelf = pFly->IsLowerOf( pSelfFly );
     249 [ #  # ][ #  # ]:          0 :                 if ( !bLowerOfSelf && !pFly->GetFmt()->GetOpaque().GetValue() )
         [ #  # ][ #  # ]
                 [ #  # ]
     250                 :            :                     // Things from other layers are only interesting to us if
     251                 :            :                     // they're not transparent or lie inwards
     252                 :          0 :                     continue;
     253                 :            :             }
     254                 :            :         }
     255                 :            : 
     256                 :            :         /// OD 19.08.2002 #99657#
     257                 :            :         ///     Fly frame without a lower have to be subtracted from paint region.
     258                 :            :         ///     For checking, if fly frame contains transparent graphic or
     259                 :            :         ///     has surrounded contour, assure that fly frame has a lower
     260   [ +  -  +  + ]:       1081 :         if ( pFly->Lower() &&
           [ -  +  #  # ]
                 [ +  + ]
     261                 :        429 :              pFly->Lower()->IsNoTxtFrm() &&
     262         [ +  - ]:        223 :              ( ((SwNoTxtFrm*)pFly->Lower())->IsTransparent() ||
     263 [ #  # ][ #  # ]:          0 :                pFly->GetFmt()->GetSurround().IsContour() )
     264                 :            :            )
     265                 :            :         {
     266                 :        223 :             continue;
     267                 :            :         }
     268                 :            : 
     269                 :            :         /// OD 19.08.2002 #99657#
     270                 :            :         ///     Region of a fly frame with transparent background or a transparent
     271                 :            :         ///     shadow have not to be subtracted from paint region
     272 [ +  - ][ +  - ]:        412 :         if ( pFly->IsBackgroundTransparent() ||
         [ -  + ][ -  + ]
     273         [ +  - ]:        206 :              pFly->IsShadowTransparent() )
     274                 :            :         {
     275                 :          0 :             continue;
     276                 :            :         }
     277                 :            : 
     278         [ +  - ]:        206 :         aTmp -= pFly->Frm();
     279                 :            :     }
     280                 :            : 
     281                 :       1613 :     sal_Bool bRetPaint = sal_False;
     282 [ +  - ][ +  - ]:       3516 :     for ( SwRects::const_iterator it = aTmp.begin(); it != aTmp.end(); ++it )
                 [ +  + ]
     283         [ +  - ]:       1903 :         bRetPaint |= pImp->GetShell()->AddPaintRect( *it );
     284                 :       1613 :     return bRetPaint;
     285                 :            : }
     286                 :            : 
     287                 :      24631 : inline sal_Bool SwLayAction::_PaintCntnt( const SwCntntFrm *pCntnt,
     288                 :            :                                       const SwPageFrm *pPage,
     289                 :            :                                       const SwRect &rRect )
     290                 :            : {
     291         [ +  + ]:      24631 :     if ( rRect.HasArea() )
     292                 :            :     {
     293         [ +  + ]:      23651 :         if ( pPage->GetSortedObjs() )
     294                 :       1613 :             return PaintWithoutFlys( rRect, pCntnt, pPage );
     295                 :            :         else
     296                 :      22038 :             return pImp->GetShell()->AddPaintRect( rRect );
     297                 :            :     }
     298                 :      24631 :     return sal_False;
     299                 :            : }
     300                 :            : 
     301                 :      20394 : void SwLayAction::PaintCntnt( const SwCntntFrm *pCnt,
     302                 :            :                               const SwPageFrm *pPage,
     303                 :            :                               const SwRect &rOldRect,
     304                 :            :                               long nOldBottom )
     305                 :            : {
     306 [ -  + ][ #  # ]:      20394 :     SWRECTFN( pCnt )
         [ #  # ][ -  + ]
     307                 :            : 
     308 [ +  + ][ +  + ]:      20394 :     if ( pCnt->IsCompletePaint() || !pCnt->IsTxtFrm() )
                 [ +  + ]
     309                 :            :     {
     310         [ +  - ]:       7470 :         SwRect aPaint( pCnt->PaintArea() );
     311 [ +  - ][ +  + ]:       7470 :         if ( !_PaintCntnt( pCnt, pPage, aPaint ) )
     312                 :       7470 :             pCnt->ResetCompletePaint();
     313                 :            :     }
     314                 :            :     else
     315                 :            :     {
     316                 :            :         // paint the area between printing bottom and frame bottom and
     317                 :            :         // the area left and right beside the frame, if its height changed.
     318 [ +  - ][ +  - ]:      12924 :         long nOldHeight = (rOldRect.*fnRect->fnGetHeight)();
     319 [ +  - ][ +  - ]:      12924 :         long nNewHeight = (pCnt->Frm().*fnRect->fnGetHeight)();
     320                 :      12924 :         const bool bHeightDiff = nOldHeight != nNewHeight;
     321         [ +  + ]:      12924 :         if( bHeightDiff )
     322                 :            :         {
     323                 :            :             // OD 05.11.2002 #94454# - consider whole potential paint area.
     324                 :            :             //SwRect aDrawRect( pCnt->UnionFrm( sal_True ) );
     325         [ +  - ]:       1615 :             SwRect aDrawRect( pCnt->PaintArea() );
     326         [ +  + ]:       1615 :             if( nOldHeight > nNewHeight )
     327 [ +  - ][ +  - ]:        145 :                 nOldBottom = (pCnt->*fnRect->fnGetPrtBottom)();
     328 [ +  - ][ +  - ]:       1615 :             (aDrawRect.*fnRect->fnSetTop)( nOldBottom );
     329         [ +  - ]:       1615 :             _PaintCntnt( pCnt, pPage, aDrawRect );
     330                 :            :         }
     331                 :            :         // paint content area
     332         [ +  - ]:      12924 :         SwRect aPaintRect = static_cast<SwTxtFrm*>(const_cast<SwCntntFrm*>(pCnt))->Paint();
     333         [ +  - ]:      12924 :         _PaintCntnt( pCnt, pPage, aPaintRect );
     334                 :            :     }
     335                 :            : 
     336 [ +  + ][ +  + ]:      20394 :     if ( pCnt->IsRetouche() && !pCnt->GetNext() )
                 [ +  + ]
     337                 :            :     {
     338                 :       2622 :         const SwFrm *pTmp = pCnt;
     339 [ +  - ][ +  + ]:       2622 :         if( pCnt->IsInSct() )
     340                 :            :         {
     341         [ +  - ]:        102 :             const SwSectionFrm* pSct = pCnt->FindSctFrm();
     342 [ +  + ][ +  + ]:        102 :             if( pSct->IsRetouche() && !pSct->GetNext() )
                 [ +  + ]
     343                 :         10 :                 pTmp = pSct;
     344                 :            :         }
     345         [ +  - ]:       2622 :         SwRect aRect( pTmp->GetUpper()->PaintArea() );
     346 [ +  - ][ +  - ]:       2622 :         (aRect.*fnRect->fnSetTop)( (pTmp->*fnRect->fnGetPrtBottom)() );
         [ +  - ][ +  - ]
     347 [ +  - ][ +  + ]:       2622 :         if ( !_PaintCntnt( pCnt, pPage, aRect ) )
     348                 :       2622 :             pCnt->ResetRetouche();
     349                 :            :     }
     350                 :      20394 : }
     351                 :            : 
     352                 :            : /*************************************************************************
     353                 :            : |*
     354                 :            : |*  SwLayAction::SwLayAction()
     355                 :            : |*
     356                 :            : |*************************************************************************/
     357                 :      39194 : SwLayAction::SwLayAction( SwRootFrm *pRt, SwViewImp *pI ) :
     358                 :            :     pRoot( pRt ),
     359                 :            :     pImp( pI ),
     360                 :            :     pOptTab( 0 ),
     361                 :            :     pWait( 0 ),
     362                 :            :     pProgress(NULL),
     363                 :            :     nPreInvaPage( USHRT_MAX ),
     364                 :      39194 :     nStartTicks( Ticks() ),
     365                 :            :     nInputType( 0 ),
     366                 :            :     nEndPage( USHRT_MAX ),
     367                 :      78388 :     nCheckPageNum( USHRT_MAX )
     368                 :            : {
     369                 :      39194 :     bPaintExtraData = ::IsExtraData( pImp->GetShell()->GetDoc() );
     370                 :      39194 :     bPaint = bComplete = bWaitAllowed = bCheckPages = sal_True;
     371                 :            :     bInput = bAgain = bNextCycle = bCalcLayout = bIdle = bReschedule =
     372                 :      39194 :     bUpdateExpFlds = bBrowseActionStop = bActionInProgress = sal_False;
     373                 :            :     // OD 14.04.2003 #106346# - init new flag <mbFormatCntntOnInterrupt>.
     374                 :      39194 :     mbFormatCntntOnInterrupt = sal_False;
     375                 :            : 
     376                 :      39194 :     pImp->pLayAct = this;   // register there
     377                 :      39194 : }
     378                 :            : 
     379                 :      39194 : SwLayAction::~SwLayAction()
     380                 :            : {
     381                 :            :     OSL_ENSURE( !pWait, "Wait object not destroyed" );
     382                 :      39194 :     pImp->pLayAct = 0;      // unregister
     383                 :      39194 : }
     384                 :            : 
     385                 :            : /*************************************************************************
     386                 :            : |*
     387                 :            : |*  SwLayAction::Reset()
     388                 :            : |*
     389                 :            : |*************************************************************************/
     390                 :          0 : void SwLayAction::Reset()
     391                 :            : {
     392                 :          0 :     pOptTab = 0;
     393                 :          0 :     nStartTicks = Ticks();
     394                 :          0 :     nInputType = 0;
     395                 :          0 :     nEndPage = nPreInvaPage = nCheckPageNum = USHRT_MAX;
     396                 :          0 :     bPaint = bComplete = bWaitAllowed = bCheckPages = sal_True;
     397                 :            :     bInput = bAgain = bNextCycle = bCalcLayout = bIdle = bReschedule =
     398                 :          0 :     bUpdateExpFlds = bBrowseActionStop = sal_False;
     399                 :          0 : }
     400                 :            : 
     401                 :            : /*************************************************************************
     402                 :            : |*
     403                 :            : |*  SwLayAction::RemoveEmptyBrowserPages()
     404                 :            : |*
     405                 :            : |*************************************************************************/
     406                 :            : 
     407                 :      31321 : sal_Bool SwLayAction::RemoveEmptyBrowserPages()
     408                 :            : {
     409                 :            :     // switching from the normal to the browser mode, empty pages may be
     410                 :            :     // retained for an annoyingly long time, so delete them here
     411                 :      31321 :     sal_Bool bRet = sal_False;
     412                 :      31321 :     const ViewShell *pSh = pRoot->GetCurrShell();
     413 [ +  + ][ +  + ]:      31321 :     if( pSh && pSh->GetViewOptions()->getBrowseMode() )
                 [ +  - ]
     414                 :            :     {
     415                 :        655 :         SwPageFrm *pPage = (SwPageFrm*)pRoot->Lower();
     416         [ -  + ]:        655 :         do
     417                 :            :         {
     418         [ -  + ]:       1310 :             if ( (pPage->GetSortedObjs() && pPage->GetSortedObjs()->Count()) ||
           [ #  #  +  - ]
                 [ +  - ]
     419                 :        655 :                  pPage->ContainsCntnt() )
     420                 :        655 :                 pPage = (SwPageFrm*)pPage->GetNext();
     421                 :            :             else
     422                 :            :             {
     423                 :          0 :                 bRet = sal_True;
     424                 :          0 :                 SwPageFrm *pDel = pPage;
     425                 :          0 :                 pPage = (SwPageFrm*)pPage->GetNext();
     426                 :          0 :                 pDel->Cut();
     427         [ #  # ]:          0 :                 delete pDel;
     428                 :            :             }
     429                 :            :         } while ( pPage );
     430                 :            :     }
     431                 :      31321 :     return bRet;
     432                 :            : }
     433                 :            : 
     434                 :            : 
     435                 :            : /*************************************************************************
     436                 :            : |*
     437                 :            : |*  SwLayAction::Action()
     438                 :            : |*
     439                 :            : |*************************************************************************/
     440                 :      39194 : void SwLayAction::Action()
     441                 :            : {
     442                 :      39194 :     bActionInProgress = sal_True;
     443                 :            : 
     444                 :            :     //TurboMode? Hands-off during idle-format
     445 [ +  + ][ +  + ]:      39194 :     if ( IsPaint() && !IsIdle() && TurboAction() )
         [ +  + ][ +  + ]
     446                 :            :     {
     447         [ -  + ]:       7873 :         delete pWait, pWait = 0;
     448                 :       7873 :         pRoot->ResetTurboFlag();
     449                 :       7873 :         bActionInProgress = sal_False;
     450                 :       7873 :         pRoot->DeleteEmptySct();
     451                 :      39194 :         return;
     452                 :            :     }
     453         [ +  + ]:      31321 :     else if ( pRoot->GetTurbo() )
     454                 :            :     {
     455                 :          7 :         pRoot->DisallowTurbo();
     456                 :          7 :         const SwFrm *pFrm = pRoot->GetTurbo();
     457                 :          7 :         pRoot->ResetTurbo();
     458                 :          7 :         pFrm->InvalidatePage();
     459                 :            :     }
     460                 :      31321 :     pRoot->DisallowTurbo();
     461                 :            : 
     462         [ +  + ]:      31321 :     if ( IsCalcLayout() )
     463                 :        148 :         SetCheckPages( sal_False );
     464                 :            : 
     465                 :      31321 :     InternalAction();
     466                 :      31321 :     bAgain |= RemoveEmptyBrowserPages();
     467         [ -  + ]:      31321 :     while ( IsAgain() )
     468                 :            :     {
     469                 :          0 :         bAgain = bNextCycle = sal_False;
     470                 :          0 :         InternalAction();
     471                 :          0 :         bAgain |= RemoveEmptyBrowserPages();
     472                 :            :     }
     473                 :      31321 :     pRoot->DeleteEmptySct();
     474                 :            : 
     475         [ +  + ]:      31321 :     delete pWait, pWait = 0;
     476                 :            : 
     477                 :            :     //Turbo-Action permitted again for all cases.
     478                 :      31321 :     pRoot->ResetTurboFlag();
     479                 :      31321 :     pRoot->ResetTurbo();
     480                 :            : 
     481                 :      31321 :     SetCheckPages( sal_True );
     482                 :            : 
     483                 :      31321 :     bActionInProgress = sal_False;
     484                 :            : }
     485                 :            : 
     486                 :      26685 : SwPageFrm* SwLayAction::CheckFirstVisPage( SwPageFrm *pPage )
     487                 :            : {
     488                 :      26685 :     SwCntntFrm *pCnt = pPage->FindFirstBodyCntnt();
     489                 :      26685 :     SwCntntFrm *pChk = pCnt;
     490                 :      26685 :     sal_Bool bPageChgd = sal_False;
     491 [ +  + ][ +  + ]:      39375 :     while ( pCnt && pCnt->IsFollow() )
                 [ +  + ]
     492                 :      12690 :         pCnt = static_cast<SwCntntFrm*>(pCnt)->FindMaster();
     493 [ +  + ][ +  + ]:      26685 :     if ( pCnt && pChk != pCnt )
     494                 :      10262 :     {   bPageChgd = sal_True;
     495                 :      10262 :         pPage = pCnt->FindPageFrm();
     496                 :            :     }
     497                 :            : 
     498         [ +  + ]:      26685 :     if ( !pPage->GetFmt()->GetDoc()->GetFtnIdxs().empty() )
     499                 :            :     {
     500                 :        372 :         SwFtnContFrm *pCont = pPage->FindFtnCont();
     501         [ +  + ]:        372 :         if ( pCont )
     502                 :            :         {
     503                 :        207 :             pCnt = pCont->ContainsCntnt();
     504                 :        207 :             pChk = pCnt;
     505 [ +  - ][ -  + ]:        207 :             while ( pCnt && pCnt->IsFollow() )
                 [ -  + ]
     506                 :          0 :                 pCnt = (SwCntntFrm*)pCnt->FindPrev();
     507 [ +  - ][ -  + ]:        207 :             if ( pCnt && pCnt != pChk )
     508                 :            :             {
     509         [ #  # ]:          0 :                 if ( bPageChgd )
     510                 :            :                 {
     511                 :            :                     // Use the 'topmost' page
     512                 :          0 :                     SwPageFrm *pTmp = pCnt->FindPageFrm();
     513         [ #  # ]:          0 :                     if ( pPage->GetPhyPageNum() > pTmp->GetPhyPageNum() )
     514                 :          0 :                         pPage = pTmp;
     515                 :            :                 }
     516                 :            :                 else
     517                 :          0 :                     pPage = pCnt->FindPageFrm();
     518                 :            :             }
     519                 :            :         }
     520                 :            :     }
     521                 :      26685 :     return pPage;
     522                 :            : }
     523                 :            : 
     524                 :            : // OD 2004-05-12 #i28701#
     525                 :            : // #i114798# - unlock position on start and end of page
     526                 :            : // layout process.
     527                 :            : class NotifyLayoutOfPageInProgress
     528                 :            : {
     529                 :            :     private:
     530                 :            :         SwPageFrm& mrPageFrm;
     531                 :            : 
     532                 :       8176 :         void _UnlockPositionOfObjs()
     533                 :            :         {
     534                 :       8176 :             SwSortedObjs* pObjs = mrPageFrm.GetSortedObjs();
     535         [ +  + ]:       8176 :             if ( pObjs )
     536                 :            :             {
     537                 :        530 :                 sal_uInt32 i = 0;
     538         [ +  + ]:       1376 :                 for ( ; i < pObjs->Count(); ++i )
     539                 :            :                 {
     540                 :        846 :                     SwAnchoredObject* pObj = (*pObjs)[i];
     541                 :        846 :                     pObj->UnlockPosition();
     542                 :            :                 }
     543                 :            :             }
     544                 :       8176 :         }
     545                 :            :     public:
     546                 :       4088 :         NotifyLayoutOfPageInProgress( SwPageFrm& _rPageFrm )
     547                 :       4088 :             : mrPageFrm( _rPageFrm )
     548                 :            :         {
     549                 :       4088 :             _UnlockPositionOfObjs();
     550                 :       4088 :             _rPageFrm.SetLayoutInProgress( true );
     551                 :       4088 :         }
     552                 :       4088 :         ~NotifyLayoutOfPageInProgress()
     553                 :            :         {
     554                 :       4088 :             mrPageFrm.SetLayoutInProgress( false );
     555                 :       4088 :             _UnlockPositionOfObjs();
     556                 :       4088 :         }
     557                 :            : };
     558                 :            : 
     559                 :      31321 : void SwLayAction::InternalAction()
     560                 :            : {
     561                 :            :     OSL_ENSURE( pRoot->Lower()->IsPageFrm(), ":-( No page below the root.");
     562                 :            : 
     563         [ +  - ]:      31321 :     pRoot->Calc();
     564                 :            : 
     565                 :            :     // Figure out the first invalid page or the first one to be formatted,
     566                 :            :     // respectively. A complete-action means the first invalid page.
     567                 :            :     // However, the first page to be formatted might be the one having the
     568                 :            :     // number 1.  If we're doing a fake formatting, the number of the first
     569                 :            :     // page is the number of the first visible page.
     570                 :      31321 :     SwPageFrm *pPage = IsComplete() ? (SwPageFrm*)pRoot->Lower() :
     571 [ +  - ][ +  + ]:      31321 :                 pImp->GetFirstVisPage();
     572         [ -  + ]:      31321 :     if ( !pPage )
     573                 :          0 :         pPage = (SwPageFrm*)pRoot->Lower();
     574                 :            : 
     575                 :            :     // If there's a first-flow-Cntnt in the first visible page that's also a Follow,
     576                 :            :     // we switch the page back to the original master of that Cntnt.
     577         [ +  + ]:      31321 :     if ( !IsComplete() )
     578         [ +  - ]:      26685 :         pPage = CheckFirstVisPage( pPage );
     579                 :      31321 :     sal_uInt16 nFirstPageNum = pPage->GetPhyPageNum();
     580                 :            : 
     581 [ +  + ][ +  + ]:      77703 :     while ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
         [ +  + ][ +  + ]
     582                 :      46382 :         pPage = (SwPageFrm*)pPage->GetNext();
     583                 :            : 
     584 [ +  - ][ +  - ]:      31321 :     IDocumentLayoutAccess *pLayoutAccess = pRoot->GetFmt()->getIDocumentLayoutAccess();
     585 [ +  + ][ +  - ]:      31321 :     sal_Bool bNoLoop = pPage ? SwLayouter::StartLoopControl( pRoot->GetFmt()->GetDoc(), pPage ) : sal_False;
                 [ +  - ]
     586                 :      31321 :     sal_uInt16 nPercentPageNum = 0;
     587 [ +  + ][ +  - ]:      36309 :     while ( (pPage && !IsInterrupt()) || nCheckPageNum != USHRT_MAX )
         [ +  + ][ -  + ]
                 [ +  + ]
     588                 :            :     {
     589 [ -  + ][ #  # ]:       8965 :         if ( !pPage && nCheckPageNum != USHRT_MAX &&
           [ #  #  #  # ]
                 [ -  + ]
     590                 :          0 :              (!pPage || pPage->GetPhyPageNum() >= nCheckPageNum) )
     591                 :            :         {
     592 [ #  # ][ #  # ]:          0 :             if ( !pPage || pPage->GetPhyPageNum() > nCheckPageNum )
                 [ #  # ]
     593                 :            :             {
     594                 :          0 :                 SwPageFrm *pPg = (SwPageFrm*)pRoot->Lower();
     595 [ #  # ][ #  # ]:          0 :                 while ( pPg && pPg->GetPhyPageNum() < nCheckPageNum )
                 [ #  # ]
     596                 :          0 :                     pPg = (SwPageFrm*)pPg->GetNext();
     597         [ #  # ]:          0 :                 if ( pPg )
     598                 :          0 :                     pPage = pPg;
     599         [ #  # ]:          0 :                 if ( !pPage )
     600                 :          0 :                     break;
     601                 :            :             }
     602                 :          0 :             SwPageFrm *pTmp = pPage->GetPrev() ?
     603         [ #  # ]:          0 :                                         (SwPageFrm*)pPage->GetPrev() : pPage;
     604                 :          0 :             SetCheckPages( sal_True );
     605         [ #  # ]:          0 :             SwFrm::CheckPageDescs( pPage );
     606                 :          0 :             SetCheckPages( sal_False );
     607                 :          0 :             nCheckPageNum = USHRT_MAX;
     608                 :          0 :             pPage = pTmp;
     609                 :          0 :             continue;
     610                 :            :         }
     611                 :            : 
     612 [ +  + ][ +  - ]:       8965 :         if ( nEndPage != USHRT_MAX && pPage->GetPhyPageNum() > nPercentPageNum )
                 [ +  + ]
     613                 :            :         {
     614                 :          9 :             nPercentPageNum = pPage->GetPhyPageNum();
     615         [ +  - ]:          9 :             ::SetProgressState( nPercentPageNum, pImp->GetShell()->GetDoc()->GetDocShell());
     616                 :            :         }
     617                 :       8965 :         pOptTab = 0;
     618                 :            :              // No Shortcut for Idle or CalcLayout
     619 [ +  + ][ +  + ]:       8965 :         if ( !IsIdle() && !IsComplete() && IsShortCut( pPage ) )
         [ +  - ][ +  + ]
                 [ +  + ]
     620                 :            :         {
     621         [ +  - ]:       4974 :             pRoot->DeleteEmptySct();
     622 [ -  + ][ #  # ]:       4974 :             XCHECKPAGE;
         [ #  # ][ #  # ]
     623 [ +  - ][ +  -  :      14913 :             if ( !IsInterrupt() &&
             +  +  +  + ]
                 [ +  + ]
     624                 :       9939 :                  (pRoot->IsSuperfluous() || pRoot->IsAssertFlyPages()) )
     625                 :            :             {
     626         [ +  + ]:        997 :                 if ( pRoot->IsAssertFlyPages() )
     627         [ +  - ]:        993 :                     pRoot->AssertFlyPages();
     628         [ +  + ]:        997 :                 if ( pRoot->IsSuperfluous() )
     629                 :            :                 {
     630                 :          9 :                     sal_Bool bOld = IsAgain();
     631         [ +  - ]:          9 :                     pRoot->RemoveSuperfluous();
     632                 :          9 :                     bAgain = bOld;
     633                 :            :                 }
     634         [ -  + ]:        997 :                 if ( IsAgain() )
     635                 :            :                 {
     636         [ #  # ]:          0 :                     if( bNoLoop )
     637 [ #  # ][ #  # ]:          0 :                         pLayoutAccess->GetLayouter()->EndLoopControl();
     638                 :            :                     return;
     639                 :            :                 }
     640                 :        997 :                 pPage = (SwPageFrm*)pRoot->Lower();
     641 [ +  + ][ +  + ]:       1031 :                 while ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
         [ +  - ][ +  + ]
     642                 :         34 :                     pPage = (SwPageFrm*)pPage->GetNext();
     643         [ +  + ]:       1024 :                 while ( pPage && pPage->GetNext() &&
           [ +  +  -  + ]
                 [ -  + ]
     644                 :         27 :                         pPage->GetPhyPageNum() < nFirstPageNum )
     645                 :          0 :                     pPage = (SwPageFrm*)pPage->GetNext();
     646                 :        997 :                 continue;
     647                 :            :             }
     648                 :       3977 :             break;
     649                 :            :         }
     650                 :            :         else
     651                 :            :         {
     652         [ +  - ]:       3991 :             pRoot->DeleteEmptySct();
     653 [ -  + ][ #  # ]:       3991 :             XCHECKPAGE;
         [ #  # ][ #  # ]
     654                 :            : 
     655                 :            :             // #i28701# - scope for instance of class <NotifyLayoutOfPageInProgress>
     656                 :            :             {
     657         [ +  - ]:       3991 :                 NotifyLayoutOfPageInProgress aLayoutOfPageInProgress( *pPage );
     658                 :            : 
     659 [ +  - ][ +  + ]:      24038 :                 while ( !IsInterrupt() && !IsNextCycle() &&
           [ +  -  +  +  
             +  +  +  + ]
                 [ +  + ]
     660                 :      16058 :                         ((IS_FLYS && IS_INVAFLY) || pPage->IsInvalid()) )
     661                 :            :                 {
     662                 :            :                     // #i28701#
     663         [ +  - ]:       3989 :                     SwObjectFormatter::FormatObjsAtFrm( *pPage, *pPage, this );
     664         [ +  + ]:       3989 :                     if ( !IS_FLYS )
     665                 :            :                     {
     666                 :            :                         // If there are no (more) Flys, the flags are superfluous.
     667                 :       3731 :                         pPage->ValidateFlyLayout();
     668                 :       3731 :                         pPage->ValidateFlyCntnt();
     669                 :            :                     }
     670                 :            :                     // #i28701# - change condition
     671 [ +  - ][ +  + ]:      22566 :                     while ( !IsInterrupt() && !IsNextCycle() &&
           [ +  -  +  +  
             +  +  +  + ]
                 [ +  + ]
     672                 :       9059 :                             ( pPage->IsInvalid() ||
     673                 :       4356 :                               (IS_FLYS && IS_INVAFLY) ) )
     674                 :            :                     {
     675                 :            :                         PROTOCOL( pPage, PROT_FILE_INIT, 0, 0)
     676 [ -  + ][ #  # ]:       5162 :                         XCHECKPAGE;
         [ #  # ][ #  # ]
     677                 :            : 
     678                 :            :                         // #i81146# new loop control
     679                 :       5162 :                         sal_uInt16 nLoopControlRuns_1 = 0;
     680                 :       5162 :                         const sal_uInt16 nLoopControlMax = 20;
     681                 :            : 
     682 [ +  - ][ +  + ]:       7412 :                         while ( !IsNextCycle() && pPage->IsInvalidLayout() )
                 [ +  + ]
     683                 :            :                         {
     684                 :       2250 :                             pPage->ValidateLayout();
     685                 :            : 
     686         [ -  + ]:       2250 :                             if ( ++nLoopControlRuns_1 > nLoopControlMax )
     687                 :            :                             {
     688                 :            :                                 OSL_FAIL( "LoopControl_1 in SwLayAction::InternalAction" );
     689                 :          0 :                                 break;
     690                 :            :                             }
     691                 :            : 
     692         [ +  - ]:       2250 :                             FormatLayout( pPage );
     693 [ -  + ][ #  # ]:       2250 :                             XCHECKPAGE;
         [ #  # ][ #  # ]
     694                 :            :                         }
     695                 :            :                         // #i28701# - change condition
     696   [ +  -  +  +  :      10586 :                         if ( !IsNextCycle() &&
             +  +  +  - ]
                 [ +  + ]
     697                 :       5162 :                              ( pPage->IsInvalidCntnt() ||
     698                 :        262 :                                (IS_FLYS && IS_INVAFLY) ) )
     699                 :            :                         {
     700                 :       5108 :                             pPage->ValidateFlyInCnt();
     701                 :       5108 :                             pPage->ValidateCntnt();
     702                 :            :                             // #i28701#
     703                 :       5108 :                             pPage->ValidateFlyLayout();
     704                 :       5108 :                             pPage->ValidateFlyCntnt();
     705 [ +  + ][ +  - ]:       5108 :                             if ( !FormatCntnt( pPage ) )
     706                 :            :                             {
     707 [ -  + ][ #  # ]:        349 :                                 XCHECKPAGE;
         [ #  # ][ #  # ]
     708                 :        349 :                                 pPage->InvalidateCntnt();
     709                 :        349 :                                 pPage->InvalidateFlyInCnt();
     710                 :            :                                 // #i28701#
     711                 :        349 :                                 pPage->InvalidateFlyLayout();
     712                 :        349 :                                 pPage->InvalidateFlyCntnt();
     713         [ -  + ]:        349 :                                 if ( IsBrowseActionStop() )
     714                 :          0 :                                     bInput = sal_True;
     715                 :            :                             }
     716                 :            :                         }
     717         [ +  - ]:       5162 :                         if( bNoLoop )
     718 [ +  - ][ +  - ]:       5162 :                             pLayoutAccess->GetLayouter()->LoopControl( pPage, LOOP_PAGE );
     719                 :            :                     }
     720 [ +  - ][ +  - ]:       3991 :                 }
     721                 :            :             } // end of scope for instance of class <NotifyLayoutOfPageInProgress>
     722                 :            : 
     723                 :            : 
     724                 :            :             // A previous page may be invalid again.
     725 [ -  + ][ #  # ]:       3991 :             XCHECKPAGE;
         [ #  # ][ #  # ]
     726         [ +  + ]:       3991 :             if ( !IS_FLYS )
     727                 :            :             {
     728                 :            :                 // If there are no (more) Flys, the flags are superfluous.
     729                 :       3733 :                 pPage->ValidateFlyLayout();
     730                 :       3733 :                 pPage->ValidateFlyCntnt();
     731                 :            :             }
     732 [ +  - ][ +  + ]:       3991 :             if ( !IsInterrupt() )
     733                 :            :             {
     734                 :       3899 :                 SetNextCycle( sal_False );
     735                 :            : 
     736         [ +  + ]:       3899 :                 if ( nPreInvaPage != USHRT_MAX )
     737                 :            :                 {
     738 [ +  + ][ -  + ]:          4 :                     if( !IsComplete() && nPreInvaPage + 2 < nFirstPageNum )
                 [ -  + ]
     739                 :            :                     {
     740                 :          0 :                         pImp->SetFirstVisPageInvalid();
     741         [ #  # ]:          0 :                         SwPageFrm *pTmpPage = pImp->GetFirstVisPage();
     742                 :          0 :                         nFirstPageNum = pTmpPage->GetPhyPageNum();
     743         [ #  # ]:          0 :                         if( nPreInvaPage < nFirstPageNum )
     744                 :            :                         {
     745                 :          0 :                             nPreInvaPage = nFirstPageNum;
     746                 :          0 :                             pPage = pTmpPage;
     747                 :            :                         }
     748                 :            :                     }
     749 [ +  - ][ +  + ]:          8 :                     while ( pPage->GetPrev() && pPage->GetPhyPageNum() > nPreInvaPage )
                 [ +  + ]
     750                 :          4 :                         pPage = (SwPageFrm*)pPage->GetPrev();
     751                 :          4 :                     nPreInvaPage = USHRT_MAX;
     752                 :            :                 }
     753                 :            : 
     754   [ +  +  +  +  :       6020 :                 while ( pPage->GetPrev() &&
          +  +  -  +  -  
              + ][ -  + ]
     755                 :       1060 :                         ( ((SwPageFrm*)pPage->GetPrev())->IsInvalid() ||
     756                 :       1000 :                           ( ((SwPageFrm*)pPage->GetPrev())->GetSortedObjs() &&
     757                 :          1 :                             ((SwPageFrm*)pPage->GetPrev())->IsInvalidFly())) &&
     758                 :         60 :                         (((SwPageFrm*)pPage->GetPrev())->GetPhyPageNum() >=
     759                 :            :                             nFirstPageNum) )
     760                 :            :                 {
     761                 :          0 :                     pPage = (SwPageFrm*)pPage->GetPrev();
     762                 :            :                 }
     763                 :            : 
     764                 :            :                 // Continue to the next invalid page
     765 [ +  + ][ +  +  :      12204 :                 while ( pPage && !pPage->IsInvalid() &&
             +  +  +  - ]
                 [ +  + ]
     766                 :       4278 :                         (!IS_FLYS || !IS_INVAFLY) )
     767                 :            :                 {
     768                 :       4027 :                     pPage = (SwPageFrm*)pPage->GetNext();
     769                 :            :                 }
     770         [ +  - ]:       3899 :                 if( bNoLoop )
     771 [ +  - ][ +  - ]:       3899 :                     pLayoutAccess->GetLayouter()->LoopControl( pPage, LOOP_PAGE );
     772                 :            :             }
     773         [ +  - ]:       3991 :             CheckIdleEnd();
     774                 :            :         }
     775 [ +  + ][ +  - ]:      10229 :         if ( !pPage && !IsInterrupt() &&
           [ +  +  +  +  
           +  + ][ +  + ]
     776                 :       6238 :              (pRoot->IsSuperfluous() || pRoot->IsAssertFlyPages()) )
     777                 :            :         {
     778         [ +  + ]:        451 :             if ( pRoot->IsAssertFlyPages() )
     779         [ +  - ]:        431 :                 pRoot->AssertFlyPages();
     780         [ +  + ]:        451 :             if ( pRoot->IsSuperfluous() )
     781                 :            :             {
     782                 :         20 :                 sal_Bool bOld = IsAgain();
     783         [ +  - ]:         20 :                 pRoot->RemoveSuperfluous();
     784                 :         20 :                 bAgain = bOld;
     785                 :            :             }
     786         [ -  + ]:        451 :             if ( IsAgain() )
     787                 :            :             {
     788         [ #  # ]:          0 :                 if( bNoLoop )
     789 [ #  # ][ #  # ]:          0 :                     pLayoutAccess->GetLayouter()->EndLoopControl();
     790                 :            :                 return;
     791                 :            :             }
     792                 :        451 :             pPage = (SwPageFrm*)pRoot->Lower();
     793 [ +  + ][ +  + ]:        906 :             while ( pPage && !pPage->IsInvalid() && !pPage->IsInvalidFly() )
         [ +  - ][ +  + ]
     794                 :        455 :                 pPage = (SwPageFrm*)pPage->GetNext();
     795         [ +  + ]:        465 :             while ( pPage && pPage->GetNext() &&
           [ +  +  +  + ]
                 [ +  + ]
     796                 :          8 :                     pPage->GetPhyPageNum() < nFirstPageNum )
     797                 :          6 :                 pPage = (SwPageFrm*)pPage->GetNext();
     798                 :            :         }
     799                 :            :     }
     800 [ +  - ][ +  + ]:      31321 :     if ( IsInterrupt() && pPage )
         [ +  + ][ +  + ]
     801                 :            :     {
     802                 :            :         // If we have input, we don't want to format content anymore, but
     803                 :            :         // we still should clean the layout.
     804                 :            :         // Otherwise, the following situation might arise:
     805                 :            :         // The user enters some text at the end of the paragraph of the last
     806                 :            :         // page, causing the paragraph to create a Follow for the next page.
     807                 :            :         // Meanwhile the user continues typing, so we have input while
     808                 :            :         // still formatting.
     809                 :            :         // The paragraph on the new page has already been partially formatted,
     810                 :            :         // and the new page has been fully formatted and is set to CompletePaint,
     811                 :            :         // but hasn't added itself to the area to be output. Then we paint,
     812                 :            :         // the CompletePaint of the page is reset because the new paragraph
     813                 :            :         // already added itself, but the borders of the page haven't been painted
     814                 :            :         // yet.
     815                 :            :         // Oh well, with the inevitable following LayAction, the page doesn't
     816                 :            :         // register itself, because it's (LayoutFrm) flags have been reset
     817                 :            :         // already - the border of the page will never be painted.
     818                 :         92 :         SwPageFrm *pPg = pPage;
     819 [ -  + ][ #  # ]:         92 :         XCHECKPAGE;
         [ #  # ][ #  # ]
     820                 :         92 :         const SwRect &rVis = pImp->GetShell()->VisArea();
     821                 :            : 
     822 [ +  - ][ +  + ]:        100 :         while( pPg && pPg->Frm().Bottom() < rVis.Top() )
                 [ +  + ]
     823                 :          8 :             pPg = (SwPageFrm*)pPg->GetNext();
     824         [ +  + ]:         92 :         if( pPg != pPage )
     825         [ +  - ]:          5 :             pPg = pPg ? (SwPageFrm*)pPg->GetPrev() : pPage;
     826                 :            : 
     827                 :            :         // set flag for interrupt content formatting
     828 [ +  - ][ +  - ]:         92 :         mbFormatCntntOnInterrupt = IsInput() && !IsStopPrt();
     829                 :         92 :         long nBottom = rVis.Bottom();
     830                 :            :         // #i42586# - format current page, if idle action is active
     831                 :            :         // This is an optimization for the case that the interrupt is created by
     832                 :            :         // the move of a form control object, which is represented by a window.
     833         [ +  + ]:        264 :         while ( pPg && ( pPg->Frm().Top() < nBottom ||
           [ +  +  +  - ]
         [ +  + ][ +  + ]
     834                 :         75 :                          ( IsIdle() && pPg == pPage ) ) )
     835                 :            :         {
     836                 :            :             // #i26945# - follow-up of #i28701#
     837         [ +  - ]:         97 :             NotifyLayoutOfPageInProgress aLayoutOfPageInProgress( *pPg );
     838                 :            : 
     839 [ -  + ][ #  # ]:         97 :             XCHECKPAGE;
         [ #  # ][ #  # ]
     840                 :            : 
     841                 :            :             // #i81146# new loop control
     842                 :         97 :             sal_uInt16 nLoopControlRuns_2 = 0;
     843                 :         97 :             const sal_uInt16 nLoopControlMax = 20;
     844                 :            : 
     845                 :            :             // special case: interrupt content formatting
     846                 :            :             // #i28701# - conditions are incorrect (macros IS_FLYS and IS_INVAFLY only
     847                 :            :             //            works for <pPage>) and are too strict.
     848                 :            :             // #i50432# - adjust interrupt formatting to normal page formatting - see above.
     849   [ +  -  +  +  :        200 :             while ( ( mbFormatCntntOnInterrupt &&
             +  +  -  + ]
           [ -  +  #  # ]
                 [ +  + ]
     850                 :         97 :                       ( pPg->IsInvalid() ||
     851                 :          6 :                         ( pPg->GetSortedObjs() && pPg->IsInvalidFly() ) ) ) ||
     852                 :          0 :                     ( !mbFormatCntntOnInterrupt && pPg->IsInvalidLayout() ) )
     853                 :            :             {
     854 [ -  + ][ #  # ]:         95 :                 XCHECKPAGE;
         [ #  # ][ #  # ]
     855                 :            :                 // #i50432# - format also at-page anchored objects
     856         [ +  - ]:         95 :                 SwObjectFormatter::FormatObjsAtFrm( *pPg, *pPg, this );
     857         [ +  + ]:         95 :                 if ( !pPg->GetSortedObjs() )
     858                 :            :                 {
     859                 :         88 :                     pPg->ValidateFlyLayout();
     860                 :         88 :                     pPg->ValidateFlyCntnt();
     861                 :            :                 }
     862                 :            : 
     863                 :            :                 // #i81146# new loop control
     864                 :         95 :                 sal_uInt16 nLoopControlRuns_3 = 0;
     865                 :            : 
     866         [ +  + ]:         97 :                 while ( pPg->IsInvalidLayout() )
     867                 :            :                 {
     868                 :          2 :                     pPg->ValidateLayout();
     869                 :            : 
     870         [ -  + ]:          2 :                     if ( ++nLoopControlRuns_3 > nLoopControlMax )
     871                 :            :                     {
     872                 :            :                         OSL_FAIL( "LoopControl_3 in Interrupt formatting in SwLayAction::InternalAction" );
     873                 :          0 :                         break;
     874                 :            :                     }
     875                 :            : 
     876         [ +  - ]:          2 :                     FormatLayout( pPg );
     877 [ -  + ][ #  # ]:          2 :                     XCHECKPAGE;
         [ #  # ][ #  # ]
     878                 :            :                 }
     879                 :            : 
     880                 :            :                 // #i50432#
     881   [ +  -  +  +  :        194 :                 if ( mbFormatCntntOnInterrupt &&
             +  -  +  - ]
                 [ +  - ]
     882                 :         95 :                      ( pPg->IsInvalidCntnt() ||
     883                 :          4 :                        ( pPg->GetSortedObjs() && pPg->IsInvalidFly() ) ) )
     884                 :            :                 {
     885                 :         95 :                     pPg->ValidateFlyInCnt();
     886                 :         95 :                     pPg->ValidateCntnt();
     887                 :            :                     // #i26945#
     888                 :         95 :                     pPg->ValidateFlyLayout();
     889                 :         95 :                     pPg->ValidateFlyCntnt();
     890                 :            : 
     891         [ -  + ]:         95 :                     if ( ++nLoopControlRuns_2 > nLoopControlMax )
     892                 :            :                     {
     893                 :            :                         OSL_FAIL( "LoopControl_2 in Interrupt formatting in SwLayAction::InternalAction" );
     894                 :          0 :                         break;
     895                 :            :                     }
     896                 :            : 
     897 [ +  - ][ -  + ]:         95 :                     if ( !FormatCntnt( pPg ) )
     898                 :            :                     {
     899 [ #  # ][ #  # ]:          0 :                         XCHECKPAGE;
         [ #  # ][ #  # ]
     900                 :          0 :                         pPg->InvalidateCntnt();
     901                 :          0 :                         pPg->InvalidateFlyInCnt();
     902                 :            :                         // #i26945#
     903                 :          0 :                         pPg->InvalidateFlyLayout();
     904                 :          0 :                         pPg->InvalidateFlyCntnt();
     905                 :            :                     }
     906                 :            :                     // #i46807# - we are statisfied, if the content is formatted once complete.
     907                 :            :                     else
     908                 :            :                     {
     909                 :         95 :                         break;
     910                 :            :                     }
     911                 :            :                 }
     912                 :            :             }
     913         [ +  - ]:        194 :             pPg = (SwPageFrm*)pPg->GetNext();
     914         [ +  - ]:         97 :         }
     915                 :            :         // reset flag for special interrupt content formatting.
     916                 :         92 :         mbFormatCntntOnInterrupt = sal_False;
     917                 :            :     }
     918                 :      31321 :     pOptTab = 0;
     919         [ +  + ]:      31321 :     if( bNoLoop )
     920 [ +  - ][ +  - ]:      31321 :         pLayoutAccess->GetLayouter()->EndLoopControl();
     921                 :            : }
     922                 :            : /*************************************************************************
     923                 :            : |*
     924                 :            : |*  SwLayAction::TurboAction(), _TurboAction()
     925                 :            : |*
     926                 :            : |*************************************************************************/
     927                 :       9357 : sal_Bool SwLayAction::_TurboAction( const SwCntntFrm *pCnt )
     928                 :            : {
     929                 :            : 
     930                 :       9357 :     const SwPageFrm *pPage = 0;
     931 [ +  + ][ +  + ]:       9357 :     if ( !pCnt->IsValid() || pCnt->IsCompletePaint() || pCnt->IsRetouche() )
         [ -  + ][ +  + ]
     932                 :            :     {
     933         [ +  - ]:       9353 :         const SwRect aOldRect( pCnt->UnionFrm( sal_True ) );
     934                 :       9353 :         const long   nOldBottom = pCnt->Frm().Top() + pCnt->Prt().Bottom();
     935         [ +  - ]:       9353 :         pCnt->Calc();
     936         [ +  + ]:       9353 :         if ( pCnt->Frm().Bottom() < aOldRect.Bottom() )
     937                 :         84 :             pCnt->SetRetouche();
     938                 :            : 
     939         [ +  - ]:       9353 :         pPage = pCnt->FindPageFrm();
     940         [ +  - ]:       9353 :         PaintCntnt( pCnt, pPage, aOldRect, nOldBottom );
     941                 :            : 
     942 [ +  + ][ +  + ]:       9353 :         if ( !pCnt->GetValidLineNumFlag() && pCnt->IsTxtFrm() )
                 [ +  + ]
     943                 :            :         {
     944                 :        333 :             const sal_uLong nAllLines = ((SwTxtFrm*)pCnt)->GetAllLines();
     945         [ +  - ]:        333 :             ((SwTxtFrm*)pCnt)->RecalcAllLines();
     946         [ +  + ]:        333 :             if ( nAllLines != ((SwTxtFrm*)pCnt)->GetAllLines() )
     947                 :            :             {
     948         [ -  + ]:         20 :                 if ( IsPaintExtraData() )
     949         [ #  # ]:          0 :                     pImp->GetShell()->AddPaintRect( pCnt->Frm() );
     950                 :            :                 // This is to calculate the remaining LineNums on the page,
     951                 :            :                 // and we don't stop processing here. To perform this inside RecalcAllLines
     952                 :            :                 // would be expensive, because we would have to notify the page even
     953                 :            :                 // in unnecessary cases (normal actions).
     954         [ +  - ]:         20 :                 const SwCntntFrm *pNxt = pCnt->GetNextCntntFrm();
     955 [ +  + ][ +  - ]:         50 :                 while ( pNxt &&
         [ -  + ][ -  + ]
     956 [ +  - ][ +  - ]:         30 :                         (pNxt->IsInTab() || pNxt->IsInDocBody() != pCnt->IsInDocBody()) )
                 [ +  - ]
     957         [ #  # ]:          0 :                     pNxt = pNxt->GetNextCntntFrm();
     958         [ +  + ]:         20 :                 if ( pNxt )
     959         [ +  - ]:         15 :                     pNxt->InvalidatePage();
     960                 :            :             }
     961                 :        333 :             return sal_False;
     962                 :            :         }
     963                 :            : 
     964 [ +  + ][ +  + ]:       9020 :         if ( pPage->IsInvalidLayout() || (IS_FLYS && IS_INVAFLY) )
         [ +  + ][ +  + ]
     965                 :       9353 :             return sal_False;
     966                 :            :     }
     967         [ +  + ]:       8946 :     if ( !pPage )
     968                 :          4 :         pPage = pCnt->FindPageFrm();
     969                 :            : 
     970                 :            :     // OD 2004-05-10 #i28701# - format floating screen objects at content frame.
     971   [ +  +  -  + ]:      17885 :     if ( pCnt->IsTxtFrm() &&
                 [ -  + ]
     972                 :            :          !SwObjectFormatter::FormatObjsAtFrm( *(const_cast<SwCntntFrm*>(pCnt)),
     973                 :       8939 :                                               *pPage, this ) )
     974                 :            :     {
     975                 :          0 :         return sal_False;
     976                 :            :     }
     977                 :            : 
     978         [ +  + ]:       8946 :     if ( pPage->IsInvalidCntnt() )
     979                 :       1073 :         return sal_False;
     980                 :       9357 :     return sal_True;
     981                 :            : }
     982                 :            : 
     983                 :      31585 : sal_Bool SwLayAction::TurboAction()
     984                 :            : {
     985                 :      31585 :     sal_Bool bRet = sal_True;
     986                 :            : 
     987         [ +  + ]:      31585 :     if ( pRoot->GetTurbo() )
     988                 :            :     {
     989         [ +  + ]:       9357 :         if ( !_TurboAction( pRoot->GetTurbo() ) )
     990                 :            :         {
     991                 :       1484 :             CheckIdleEnd();
     992                 :       1484 :             bRet = sal_False;
     993                 :            :         }
     994                 :       9357 :         pRoot->ResetTurbo();
     995                 :            :     }
     996                 :            :     else
     997                 :      22228 :         bRet = sal_False;
     998                 :      31585 :     return bRet;
     999                 :            : }
    1000                 :            : /*************************************************************************
    1001                 :            : |*
    1002                 :            : |*  SwLayAction::IsShortCut()
    1003                 :            : |*
    1004                 :            : |*  Description:       Returns True if the page lies directly below or
    1005                 :            : |*      right of the visible area.
    1006                 :            : |*      It's possible for things to change in such a way that the processing
    1007                 :            : |*      (of the caller!) has to continue with the predecessor of the passed
    1008                 :            : |*      page. The parameter might therefore get modified!
    1009                 :            : |*      For BrowseMode, you may even activate the ShortCut if the invalid
    1010                 :            : |*      content of the page lies below the visible area.
    1011                 :            : |*
    1012                 :            : |*************************************************************************/
    1013                 :       1473 : static bool lcl_IsInvaLay( const SwFrm *pFrm, long nBottom )
    1014                 :            : {
    1015 [ +  + ][ +  -  :       2952 :     if (
             +  +  +  - ]
    1016                 :       1473 :          !pFrm->IsValid() ||
    1017                 :       1479 :          (pFrm->IsCompletePaint() && ( pFrm->Frm().Top() < nBottom ) )
    1018                 :            :        )
    1019                 :            :     {
    1020                 :          6 :         return true;
    1021                 :            :     }
    1022                 :       1473 :     return false;
    1023                 :            : }
    1024                 :            : 
    1025                 :        984 : static const SwFrm *lcl_FindFirstInvaLay( const SwFrm *pFrm, long nBottom )
    1026                 :            : {
    1027                 :            :     OSL_ENSURE( pFrm->IsLayoutFrm(), "FindFirstInvaLay, no LayFrm" );
    1028                 :            : 
    1029         [ +  + ]:        984 :     if (lcl_IsInvaLay(pFrm, nBottom))
    1030                 :          6 :         return pFrm;
    1031                 :        978 :     pFrm = ((SwLayoutFrm*)pFrm)->Lower();
    1032         [ +  + ]:       1956 :     while ( pFrm )
    1033                 :            :     {
    1034         [ +  + ]:        978 :         if ( pFrm->IsLayoutFrm() )
    1035                 :            :         {
    1036         [ -  + ]:        489 :             if (lcl_IsInvaLay(pFrm, nBottom))
    1037                 :          0 :                 return pFrm;
    1038                 :            :             const SwFrm *pTmp;
    1039         [ -  + ]:        489 :             if ( 0 != (pTmp = lcl_FindFirstInvaLay( pFrm, nBottom )) )
    1040                 :          0 :                 return pTmp;
    1041                 :            :         }
    1042                 :        978 :         pFrm = pFrm->GetNext();
    1043                 :            :     }
    1044                 :        984 :     return 0;
    1045                 :            : }
    1046                 :            : 
    1047                 :         40 : static const SwFrm *lcl_FindFirstInvaCntnt( const SwLayoutFrm *pLay, long nBottom,
    1048                 :            :                                      const SwCntntFrm *pFirst )
    1049                 :            : {
    1050                 :            :     const SwCntntFrm *pCnt = pFirst ? pFirst->GetNextCntntFrm() :
    1051         [ -  + ]:         40 :                                       pLay->ContainsCntnt();
    1052         [ +  - ]:         40 :     while ( pCnt )
    1053                 :            :     {
    1054 [ -  + ][ #  # ]:         40 :         if ( !pCnt->IsValid() || pCnt->IsCompletePaint() )
                 [ +  - ]
    1055                 :            :         {
    1056         [ +  - ]:         40 :             if ( pCnt->Frm().Top() <= nBottom )
    1057                 :         40 :                 return pCnt;
    1058                 :            :         }
    1059                 :            : 
    1060         [ #  # ]:          0 :         if ( pCnt->GetDrawObjs() )
    1061                 :            :         {
    1062                 :          0 :             const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
    1063         [ #  # ]:          0 :             for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
    1064                 :            :             {
    1065                 :          0 :                 const SwAnchoredObject* pObj = rObjs[i];
    1066         [ #  # ]:          0 :                 if ( pObj->ISA(SwFlyFrm) )
    1067                 :            :                 {
    1068         [ #  # ]:          0 :                     const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>(pObj);
    1069         [ #  # ]:          0 :                     if ( pFly->IsFlyInCntFrm() )
    1070                 :            :                     {
    1071   [ #  #  #  # ]:          0 :                         if ( ((SwFlyInCntFrm*)pFly)->IsInvalid() ||
                 [ #  # ]
    1072                 :          0 :                              pFly->IsCompletePaint() )
    1073                 :            :                         {
    1074         [ #  # ]:          0 :                             if ( pFly->Frm().Top() <= nBottom )
    1075                 :          0 :                                 return pFly;
    1076                 :            :                         }
    1077                 :          0 :                         const SwFrm *pFrm = lcl_FindFirstInvaCntnt( pFly, nBottom, 0 );
    1078 [ #  # ][ #  # ]:          0 :                         if ( pFrm && pFrm->Frm().Bottom() <= nBottom )
                 [ #  # ]
    1079                 :          0 :                             return pFrm;
    1080                 :            :                     }
    1081                 :            :                 }
    1082                 :            :             }
    1083                 :            :         }
    1084 [ #  # ][ #  # ]:          0 :         if ( pCnt->Frm().Top() > nBottom && !pCnt->IsInTab() )
                 [ #  # ]
    1085                 :          0 :             return 0;
    1086                 :          0 :         pCnt = pCnt->GetNextCntntFrm();
    1087         [ #  # ]:          0 :         if ( !pLay->IsAnLower( pCnt ) )
    1088                 :          0 :             break;
    1089                 :            :     }
    1090                 :         40 :     return 0;
    1091                 :            : }
    1092                 :            : 
    1093                 :            : // #i37877# - consider drawing objects
    1094                 :          0 : static const SwAnchoredObject* lcl_FindFirstInvaObj( const SwPageFrm* _pPage,
    1095                 :            :                                               long _nBottom )
    1096                 :            : {
    1097                 :            :     OSL_ENSURE( _pPage->GetSortedObjs(), "FindFirstInvaObj, no Objs" );
    1098                 :            : 
    1099         [ #  # ]:          0 :     for ( sal_uInt16 i = 0; i < _pPage->GetSortedObjs()->Count(); ++i )
    1100                 :            :     {
    1101                 :          0 :         const SwAnchoredObject* pObj = (*_pPage->GetSortedObjs())[i];
    1102         [ #  # ]:          0 :         if ( pObj->ISA(SwFlyFrm) )
    1103                 :            :         {
    1104         [ #  # ]:          0 :             const SwFlyFrm* pFly = static_cast<const SwFlyFrm*>(pObj);
    1105         [ #  # ]:          0 :             if ( pFly->Frm().Top() <= _nBottom )
    1106                 :            :             {
    1107 [ #  # ][ #  # ]:          0 :                 if ( pFly->IsInvalid() || pFly->IsCompletePaint() )
                 [ #  # ]
    1108         [ #  # ]:          0 :                     return pFly;
    1109                 :            : 
    1110                 :            :                 const SwFrm* pTmp;
    1111   [ #  #  #  # ]:          0 :                 if ( 0 != (pTmp = lcl_FindFirstInvaCntnt( pFly, _nBottom, 0 )) &&
                 [ #  # ]
    1112                 :          0 :                      pTmp->Frm().Top() <= _nBottom )
    1113         [ #  # ]:          0 :                     return pFly;
    1114                 :            :             }
    1115                 :            :         }
    1116         [ #  # ]:          0 :         else if ( pObj->ISA(SwAnchoredDrawObject) )
    1117                 :            :         {
    1118         [ #  # ]:          0 :             if ( !static_cast<const SwAnchoredDrawObject*>(pObj)->IsValidPos() )
    1119                 :            :             {
    1120                 :          0 :                 return pObj;
    1121                 :            :             }
    1122                 :            :         }
    1123                 :            :     }
    1124                 :          0 :     return 0;
    1125                 :            : }
    1126                 :            : 
    1127                 :       8706 : sal_Bool SwLayAction::IsShortCut( SwPageFrm *&prPage )
    1128                 :            : {
    1129                 :       8706 :     sal_Bool bRet = sal_False;
    1130                 :       8706 :     const ViewShell *pSh = pRoot->GetCurrShell();
    1131 [ +  + ][ +  - ]:       8706 :     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
    1132                 :            : 
    1133                 :            :     // If the page is not valid, we quickly format it, otherwise
    1134                 :            :     // there's gonna be no end of trouble
    1135         [ +  + ]:       8706 :     if ( !prPage->IsValid() )
    1136                 :            :     {
    1137         [ +  + ]:        223 :         if ( bBrowse )
    1138                 :            :         {
    1139                 :            :             /// OD 15.10.2002 #103517# - format complete page
    1140                 :            :             /// Thus, loop on all lowers of the page <prPage>, instead of only
    1141                 :            :             /// format its first lower.
    1142                 :            :             /// NOTE: In online layout (bBrowse == sal_True) a page can contain
    1143                 :            :             ///     a header frame and/or a footer frame beside the body frame.
    1144                 :        174 :             prPage->Calc();
    1145                 :        174 :             SwFrm* pPageLowerFrm = prPage->Lower();
    1146         [ +  + ]:        348 :             while ( pPageLowerFrm )
    1147                 :            :             {
    1148                 :        174 :                 pPageLowerFrm->Calc();
    1149                 :        174 :                 pPageLowerFrm = pPageLowerFrm->GetNext();
    1150                 :            :             }
    1151                 :            :         }
    1152                 :            :         else
    1153                 :         49 :             FormatLayout( prPage );
    1154         [ -  + ]:        223 :         if ( IsAgain() )
    1155                 :          0 :             return sal_False;
    1156                 :            :     }
    1157                 :            : 
    1158                 :            : 
    1159                 :       8706 :     const SwRect &rVis = pImp->GetShell()->VisArea();
    1160         [ +  + ]:      12861 :     if ( (prPage->Frm().Top() >= rVis.Bottom()) ||
           [ +  +  -  + ]
    1161                 :       4155 :          (prPage->Frm().Left()>= rVis.Right()) )
    1162                 :            :     {
    1163                 :       4551 :         bRet = sal_True;
    1164                 :            : 
    1165                 :            :         // This is going to be a bit nasty: The first CntntFrm of this
    1166                 :            :         // page in the Body text needs formatting; if it changes the page during
    1167                 :            :         // that process, I need to start over a page further back, because we
    1168                 :            :         // have been processing a PageBreak.
    1169                 :            :         // Even more uncomfortable: The next CntntFrm must be formatted,
    1170                 :            :         // because it's possible for empty pages to exist temporarily (for example
    1171                 :            :         // a paragraph across multiple pages gets deleted or reduced in size).
    1172                 :            : 
    1173                 :            :         // This is irrelevant for the browser, if the last Cnt above it
    1174                 :            :         // isn't visible anymore.
    1175                 :            : 
    1176                 :       4551 :         const SwPageFrm *p2ndPage = prPage;
    1177                 :            :         const SwCntntFrm *pCntnt;
    1178                 :       4551 :         const SwLayoutFrm* pBody = p2ndPage->FindBodyCont();
    1179 [ +  - ][ +  + ]:       4551 :         if( p2ndPage->IsFtnPage() && pBody )
                 [ +  + ]
    1180                 :         49 :             pBody = (SwLayoutFrm*)pBody->GetNext();
    1181         [ +  - ]:       4551 :         pCntnt = pBody ? pBody->ContainsCntnt() : 0;
    1182 [ +  + ][ +  + ]:       4559 :         while ( p2ndPage && !pCntnt )
                 [ +  + ]
    1183                 :            :         {
    1184                 :          8 :             p2ndPage = (SwPageFrm*)p2ndPage->GetNext();
    1185         [ +  + ]:          8 :             if( p2ndPage )
    1186                 :            :             {
    1187                 :          2 :                 pBody = p2ndPage->FindBodyCont();
    1188 [ #  # ][ -  + ]:          2 :                 if( p2ndPage->IsFtnPage() && pBody )
                 [ -  + ]
    1189                 :          0 :                     pBody = (SwLayoutFrm*)pBody->GetNext();
    1190         [ +  - ]:          2 :                 pCntnt = pBody ? pBody->ContainsCntnt() : 0;
    1191                 :            :             }
    1192                 :            :         }
    1193         [ +  + ]:       4551 :         if ( pCntnt )
    1194                 :            :         {
    1195                 :       4545 :             sal_Bool bTstCnt = sal_True;
    1196         [ +  + ]:       4545 :             if ( bBrowse )
    1197                 :            :             {
    1198                 :            :                 // Is the Cnt before already invisible?
    1199                 :         12 :                 const SwFrm *pLst = pCntnt;
    1200         [ -  + ]:         12 :                 if ( pLst->IsInTab() )
    1201                 :          0 :                     pLst = pCntnt->FindTabFrm();
    1202         [ -  + ]:         12 :                 if ( pLst->IsInSct() )
    1203                 :          0 :                     pLst = pCntnt->FindSctFrm();
    1204                 :         12 :                 pLst = pLst->FindPrev();
    1205 [ -  + ][ -  +  :         12 :                 if ( pLst &&
             #  #  #  # ]
    1206                 :          0 :                      (pLst->Frm().Top() >= rVis.Bottom() ||
    1207                 :          0 :                       pLst->Frm().Left()>= rVis.Right()) )
    1208                 :            :                 {
    1209                 :          0 :                     bTstCnt = sal_False;
    1210                 :            :                 }
    1211                 :            :             }
    1212                 :            : 
    1213         [ +  - ]:       4545 :             if ( bTstCnt )
    1214                 :            :             {
    1215                 :            :                 // #i27756# - check after each frame calculation,
    1216                 :            :                 // if the content frame has changed the page. If yes, no other
    1217                 :            :                 // frame calculation is performed
    1218                 :       4545 :                 bool bPageChg = false;
    1219                 :            : 
    1220         [ +  + ]:       4545 :                 if ( pCntnt->IsInSct() )
    1221                 :            :                 {
    1222                 :         37 :                     const SwSectionFrm *pSct = ((SwFrm*)pCntnt)->ImplFindSctFrm();
    1223         [ +  + ]:         37 :                     if ( !pSct->IsValid() )
    1224                 :            :                     {
    1225                 :         16 :                         pSct->Calc();
    1226                 :         16 :                         pSct->SetCompletePaint();
    1227         [ -  + ]:         16 :                         if ( IsAgain() )
    1228                 :          0 :                             return sal_False;
    1229                 :            :                         // #i27756#
    1230                 :         16 :                         bPageChg = pCntnt->FindPageFrm() != p2ndPage &&
    1231 [ +  - ][ +  + ]:         16 :                                    prPage->GetPrev();
    1232                 :            :                     }
    1233                 :            :                 }
    1234                 :            : 
    1235 [ +  + ][ +  + ]:       4545 :                 if ( !bPageChg && !pCntnt->IsValid() )
                 [ +  + ]
    1236                 :            :                 {
    1237                 :        858 :                     pCntnt->Calc();
    1238                 :        858 :                     pCntnt->SetCompletePaint();
    1239         [ -  + ]:        858 :                     if ( IsAgain() )
    1240                 :          0 :                         return sal_False;
    1241                 :            :                     // #i27756#
    1242                 :        858 :                     bPageChg = pCntnt->FindPageFrm() != p2ndPage &&
    1243 [ +  - ][ +  + ]:        858 :                                prPage->GetPrev();
    1244                 :            :                 }
    1245                 :            : 
    1246 [ +  + ][ +  + ]:       4545 :                 if ( !bPageChg && pCntnt->IsInTab() )
                 [ +  + ]
    1247                 :            :                 {
    1248                 :         10 :                     const SwTabFrm *pTab = ((SwFrm*)pCntnt)->ImplFindTabFrm();
    1249         [ +  + ]:         10 :                     if ( !pTab->IsValid() )
    1250                 :            :                     {
    1251                 :          2 :                         pTab->Calc();
    1252                 :          2 :                         pTab->SetCompletePaint();
    1253         [ -  + ]:          2 :                         if ( IsAgain() )
    1254                 :          0 :                             return sal_False;
    1255                 :            :                         // #i27756#
    1256                 :          2 :                         bPageChg = pCntnt->FindPageFrm() != p2ndPage &&
    1257 [ #  # ][ -  + ]:          2 :                                    prPage->GetPrev();
    1258                 :            :                     }
    1259                 :            :                 }
    1260                 :            : 
    1261 [ +  + ][ +  + ]:       4545 :                 if ( !bPageChg && pCntnt->IsInSct() )
                 [ +  + ]
    1262                 :            :                 {
    1263                 :         21 :                     const SwSectionFrm *pSct = ((SwFrm*)pCntnt)->ImplFindSctFrm();
    1264         [ -  + ]:         21 :                     if ( !pSct->IsValid() )
    1265                 :            :                     {
    1266                 :          0 :                         pSct->Calc();
    1267                 :          0 :                         pSct->SetCompletePaint();
    1268         [ #  # ]:          0 :                         if ( IsAgain() )
    1269                 :          0 :                             return sal_False;
    1270                 :            :                         // #i27756#
    1271                 :          0 :                         bPageChg = pCntnt->FindPageFrm() != p2ndPage &&
    1272 [ #  # ][ #  # ]:          0 :                                    prPage->GetPrev();
    1273                 :            :                     }
    1274                 :            :                 }
    1275                 :            : 
    1276                 :            :                 // #i27756#
    1277         [ +  + ]:       4545 :                 if ( bPageChg )
    1278                 :            :                 {
    1279                 :         26 :                     bRet = sal_False;
    1280                 :         26 :                     const SwPageFrm* pTmp = pCntnt->FindPageFrm();
    1281         [ +  - ]:         52 :                     if ( pTmp->GetPhyPageNum() < prPage->GetPhyPageNum() &&
           [ +  -  +  - ]
    1282                 :         26 :                          pTmp->IsInvalid() )
    1283                 :            :                     {
    1284                 :         26 :                         prPage = (SwPageFrm*)pTmp;
    1285                 :            :                     }
    1286                 :            :                     else
    1287                 :            :                     {
    1288                 :          0 :                         prPage = (SwPageFrm*)prPage->GetPrev();
    1289                 :            :                     }
    1290                 :            :                 }
    1291                 :            :                 // #121980# - no shortcut, if at previous page
    1292                 :            :                 // an anchored object is registered, whose anchor is <pCntnt>.
    1293   [ +  +  +  + ]:       4774 :                 else if ( prPage->GetPrev() &&
                 [ +  + ]
    1294                 :        255 :                           static_cast<SwPageFrm*>(prPage->GetPrev())->GetSortedObjs() )
    1295                 :            :                 {
    1296                 :            :                     SwSortedObjs* pObjs =
    1297                 :         58 :                         static_cast<SwPageFrm*>(prPage->GetPrev())->GetSortedObjs();
    1298         [ +  - ]:         58 :                     if ( pObjs )
    1299                 :            :                     {
    1300                 :         58 :                         sal_uInt32 i = 0;
    1301         [ +  + ]:        162 :                         for ( ; i < pObjs->Count(); ++i )
    1302                 :            :                         {
    1303                 :        104 :                             SwAnchoredObject* pObj = (*pObjs)[i];
    1304         [ -  + ]:        104 :                             if ( pObj->GetAnchorFrmContainingAnchPos() == pCntnt )
    1305                 :            :                             {
    1306                 :          0 :                                 bRet = sal_False;
    1307                 :          0 :                                 break;
    1308                 :            :                             }
    1309                 :            :                         }
    1310                 :            :                     }
    1311                 :            :                 }
    1312                 :            :             }
    1313                 :            :         }
    1314                 :            :     }
    1315                 :            : 
    1316 [ +  + ][ +  + ]:       8706 :     if ( !bRet && bBrowse )
    1317                 :            :     {
    1318                 :        495 :         const long nBottom = rVis.Bottom();
    1319                 :        495 :         const SwAnchoredObject* pObj( 0L );
    1320         [ #  # ]:        990 :         if ( prPage->GetSortedObjs() &&
           [ #  #  #  # ]
         [ -  + ][ -  +  
             #  #  #  # ]
    1321                 :          0 :              (prPage->IsInvalidFlyLayout() || prPage->IsInvalidFlyCntnt()) &&
    1322                 :          0 :              0 != (pObj = lcl_FindFirstInvaObj( prPage, nBottom )) &&
    1323 [ #  # ][ -  + ]:        495 :              pObj->GetObjRect().Top() <= nBottom )
                 [ #  # ]
    1324                 :            :         {
    1325                 :          0 :             return sal_False;
    1326                 :            :         }
    1327                 :        495 :         const SwFrm* pFrm( 0L );
    1328         [ +  - ]:        501 :         if ( prPage->IsInvalidLayout() &&
           [ +  +  +  - ]
                 [ +  + ]
    1329                 :        495 :              0 != (pFrm = lcl_FindFirstInvaLay( prPage, nBottom )) &&
    1330                 :          6 :              pFrm->Frm().Top() <= nBottom )
    1331                 :            :         {
    1332                 :          6 :             return sal_False;
    1333                 :            :         }
    1334 [ +  + ][ -  + ]:        529 :         if ( (prPage->IsInvalidCntnt() || prPage->IsInvalidFlyInCnt()) &&
           [ +  -  +  - ]
                 [ +  + ]
    1335                 :         40 :              0 != (pFrm = lcl_FindFirstInvaCntnt( prPage, nBottom, 0 )) &&
    1336                 :         40 :              pFrm->Frm().Top() <= nBottom )
    1337                 :            :         {
    1338                 :         40 :             return sal_False;
    1339                 :            :         }
    1340                 :        449 :         bRet = sal_True;
    1341                 :            :     }
    1342                 :       8706 :     return bRet;
    1343                 :            : }
    1344                 :            : 
    1345                 :            : /*************************************************************************
    1346                 :            : |*
    1347                 :            : |*  SwLayAction::FormatLayout(), FormatLayoutFly, FormatLayoutTab()
    1348                 :            : |*
    1349                 :            : |*************************************************************************/
    1350                 :            : // OD 15.11.2002 #105155# - introduce support for vertical layout
    1351                 :      14389 : sal_Bool SwLayAction::FormatLayout( SwLayoutFrm *pLay, sal_Bool bAddRect )
    1352                 :            : {
    1353                 :            :     OSL_ENSURE( !IsAgain(), "Attention to the invalid page." );
    1354         [ -  + ]:      14389 :     if ( IsAgain() )
    1355                 :          0 :         return sal_False;
    1356                 :            : 
    1357                 :      14389 :     sal_Bool bChanged = sal_False;
    1358                 :      14389 :     sal_Bool bAlreadyPainted = sal_False;
    1359                 :            :     // OD 11.11.2002 #104414# - remember frame at complete paint
    1360                 :      14389 :     SwRect aFrmAtCompletePaint;
    1361                 :            : 
    1362 [ +  + ][ +  + ]:      14389 :     if ( !pLay->IsValid() || pLay->IsCompletePaint() )
                 [ +  + ]
    1363                 :            :     {
    1364 [ +  + ][ +  + ]:       7775 :         if ( pLay->GetPrev() && !pLay->GetPrev()->IsValid() )
                 [ +  + ]
    1365                 :        319 :             pLay->GetPrev()->SetCompletePaint();
    1366                 :            : 
    1367                 :       7775 :         SwRect aOldFrame( pLay->Frm() );
    1368                 :       7775 :         SwRect aOldRect( aOldFrame );
    1369         [ +  + ]:       7775 :         if( pLay->IsPageFrm() )
    1370                 :            :         {
    1371         [ +  - ]:       1419 :             aOldRect = static_cast<SwPageFrm*>(pLay)->GetBoundRect();
    1372                 :            :         }
    1373                 :            : 
    1374         [ +  - ]:       7775 :         pLay->Calc();
    1375         [ +  + ]:       7775 :         if ( aOldFrame != pLay->Frm() )
    1376                 :       2166 :             bChanged = sal_True;
    1377                 :            : 
    1378                 :       7775 :         sal_Bool bNoPaint = sal_False;
    1379   [ +  +  +  +  :      10772 :         if ( pLay->IsPageBodyFrm() &&
           +  + ][ +  + ]
    1380                 :       1532 :              pLay->Frm().Pos() == aOldRect.Pos() &&
    1381                 :       1465 :              pLay->Lower() )
    1382                 :            :         {
    1383                 :       1451 :             const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
    1384                 :            :             // Limitations because of headers / footers
    1385   [ +  +  +  - ]:       1463 :             if( pSh && pSh->GetViewOptions()->getBrowseMode() &&
         [ +  + ][ +  - ]
    1386 [ +  - ][ +  - ]:         12 :                 !( pLay->IsCompletePaint() && pLay->FindPageFrm()->FindFtnCont() ) )
                 [ +  - ]
    1387                 :          6 :                 bNoPaint = sal_True;
    1388                 :            :         }
    1389                 :            : 
    1390 [ +  + ][ +  + ]:       7775 :         if ( !bNoPaint && IsPaint() && bAddRect && (pLay->IsCompletePaint() || bChanged) )
         [ +  + ][ +  + ]
         [ -  + ][ +  + ]
    1391                 :            :         {
    1392                 :        751 :             SwRect aPaint( pLay->Frm() );
    1393                 :            :             // OD 13.02.2003 #i9719#, #105645# - consider border and shadow for
    1394                 :            :             // page frames -> enlarge paint rectangle correspondingly.
    1395         [ +  + ]:        751 :             if ( pLay->IsPageFrm() )
    1396                 :            :             {
    1397                 :        143 :                 SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(pLay);
    1398         [ +  - ]:        143 :                 aPaint = pPageFrm->GetBoundRect();
    1399                 :            :             }
    1400                 :            : 
    1401                 :        751 :             sal_Bool bPageInBrowseMode = pLay->IsPageFrm();
    1402         [ +  + ]:        751 :             if( bPageInBrowseMode )
    1403                 :            :             {
    1404                 :        143 :                 const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
    1405 [ +  + ][ +  + ]:        143 :                 if( !pSh || !pSh->GetViewOptions()->getBrowseMode() )
                 [ +  - ]
    1406                 :        135 :                     bPageInBrowseMode = sal_False;
    1407                 :            :             }
    1408         [ +  + ]:        751 :             if( bPageInBrowseMode )
    1409                 :            :             {
    1410                 :            :                 // NOTE: no vertical layout in online layout
    1411                 :            :                 // Is the change even visible?
    1412         [ +  - ]:          8 :                 if ( pLay->IsCompletePaint() )
    1413                 :            :                 {
    1414         [ +  - ]:          8 :                     pImp->GetShell()->AddPaintRect( aPaint );
    1415                 :          8 :                     bAddRect = sal_False;
    1416                 :            :                 }
    1417                 :            :                 else
    1418                 :            :                 {
    1419                 :            :                     sal_uInt16 i;
    1420                 :            : 
    1421         [ #  # ]:          0 :                     SwRegionRects aRegion( aOldRect );
    1422         [ #  # ]:          0 :                     aRegion -= aPaint;
    1423         [ #  # ]:          0 :                     for ( i = 0; i < aRegion.size(); ++i )
    1424         [ #  # ]:          0 :                         pImp->GetShell()->AddPaintRect( aRegion[i] );
    1425                 :          0 :                     aRegion.ChangeOrigin( aPaint );
    1426                 :          0 :                     aRegion.clear();
    1427         [ #  # ]:          0 :                     aRegion.push_back( aPaint );
    1428         [ #  # ]:          0 :                     aRegion -= aOldRect;
    1429         [ #  # ]:          0 :                     for ( i = 0; i < aRegion.size(); ++i )
    1430         [ #  # ]:          0 :                         pImp->GetShell()->AddPaintRect( aRegion[i] );
    1431                 :            :                 }
    1432                 :            : 
    1433                 :            :             }
    1434                 :            :             else
    1435                 :            :             {
    1436         [ +  - ]:        743 :                 pImp->GetShell()->AddPaintRect( aPaint );
    1437                 :        743 :                 bAlreadyPainted = sal_True;
    1438                 :            :                 // OD 11.11.2002 #104414# - remember frame at complete paint
    1439                 :        743 :                 aFrmAtCompletePaint = pLay->Frm();
    1440                 :            :             }
    1441                 :            : 
    1442                 :            :             // OD 13.02.2003 #i9719#, #105645# - provide paint of spacing
    1443                 :            :             // between pages (not only for in online mode).
    1444         [ +  + ]:        751 :             if ( pLay->IsPageFrm() )
    1445                 :            :             {
    1446                 :        143 :                 const SwTwips nHalfDocBorder = GAPBETWEENPAGES;
    1447         [ +  - ]:        143 :                 const bool bLeftToRightViewLayout = pRoot->IsLeftToRightViewLayout();
    1448         [ +  - ]:        143 :                 const bool bPrev = bLeftToRightViewLayout ? pLay->GetPrev() : pLay->GetNext();
    1449         [ +  - ]:        143 :                 const bool bNext = bLeftToRightViewLayout ? pLay->GetNext() : pLay->GetPrev();
    1450                 :        143 :                 SwPageFrm* pPageFrm = static_cast<SwPageFrm*>(pLay);
    1451                 :        143 :                 const ViewShell *pSh = pLay->getRootFrm()->GetCurrShell();
    1452                 :        143 :                 SwRect aPageRect( pLay->Frm() );
    1453                 :            : 
    1454         [ +  - ]:        143 :                 if(pSh)
    1455                 :            :                 {
    1456                 :            :                     SwPageFrm::GetBorderAndShadowBoundRect(aPageRect, pSh,
    1457 [ +  - ][ +  - ]:        143 :                         aPageRect, pPageFrm->IsLeftShadowNeeded(), pPageFrm->IsRightShadowNeeded(),
    1458 [ +  - ][ +  - ]:        286 :                         pPageFrm->SidebarPosition() == sw::sidebarwindows::SIDEBAR_RIGHT);
    1459                 :            :                 }
    1460                 :            : 
    1461         [ +  + ]:        143 :                 if ( bPrev )
    1462                 :            :                 {
    1463                 :            :                     // top
    1464                 :         50 :                     SwRect aSpaceToPrevPage( aPageRect );
    1465                 :         50 :                     aSpaceToPrevPage.Top( aSpaceToPrevPage.Top() - nHalfDocBorder );
    1466                 :         50 :                     aSpaceToPrevPage.Bottom( pLay->Frm().Top() );
    1467 [ +  - ][ +  - ]:         50 :                     if(aSpaceToPrevPage.Height() > 0 && aSpaceToPrevPage.Width() > 0)
                 [ +  - ]
    1468         [ +  - ]:         50 :                         pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
    1469                 :            : 
    1470 [ +  - ][ +  - ]:         50 :                     pSh->GetOut()->DrawRect( aSpaceToPrevPage.SVRect() );
    1471                 :            : 
    1472                 :            :                     // left
    1473                 :         50 :                     aSpaceToPrevPage = aPageRect;
    1474                 :         50 :                     aSpaceToPrevPage.Left( aSpaceToPrevPage.Left() - nHalfDocBorder );
    1475                 :         50 :                     aSpaceToPrevPage.Right( pLay->Frm().Left() );
    1476 [ +  - ][ +  - ]:         50 :                     if(aSpaceToPrevPage.Height() > 0 && aSpaceToPrevPage.Width() > 0)
                 [ +  - ]
    1477         [ +  - ]:         50 :                         pImp->GetShell()->AddPaintRect( aSpaceToPrevPage );
    1478                 :            :                 }
    1479         [ +  + ]:        143 :                 if ( bNext )
    1480                 :            :                 {
    1481                 :            :                     // bottom
    1482                 :         11 :                     SwRect aSpaceToNextPage( aPageRect );
    1483                 :         11 :                     aSpaceToNextPage.Bottom( aSpaceToNextPage.Bottom() + nHalfDocBorder );
    1484                 :         11 :                     aSpaceToNextPage.Top( pLay->Frm().Bottom() );
    1485 [ +  - ][ +  - ]:         11 :                     if(aSpaceToNextPage.Height() > 0 && aSpaceToNextPage.Width() > 0)
                 [ +  - ]
    1486         [ +  - ]:         11 :                         pImp->GetShell()->AddPaintRect( aSpaceToNextPage );
    1487                 :            : 
    1488                 :            :                     // right
    1489                 :         11 :                     aSpaceToNextPage = aPageRect;
    1490                 :         11 :                     aSpaceToNextPage.Right( aSpaceToNextPage.Right() + nHalfDocBorder );
    1491                 :         11 :                     aSpaceToNextPage.Left( pLay->Frm().Right() );
    1492 [ +  - ][ +  - ]:         11 :                     if(aSpaceToNextPage.Height() > 0 && aSpaceToNextPage.Width() > 0)
                 [ +  - ]
    1493         [ +  - ]:        751 :                         pImp->GetShell()->AddPaintRect( aSpaceToNextPage );
    1494                 :            :                 }
    1495                 :            :             }
    1496                 :            :         }
    1497                 :       7775 :         pLay->ResetCompletePaint();
    1498                 :            :     }
    1499                 :            : 
    1500 [ +  + ][ +  +  :      23919 :     if ( IsPaint() && bAddRect &&
          +  +  +  +  +  
              + ][ +  + ]
    1501                 :       9530 :          !pLay->GetNext() && pLay->IsRetoucheFrm() && pLay->IsRetouche() )
    1502                 :            :     {
    1503                 :            :         // OD 15.11.2002 #105155# - vertical layout support
    1504 [ +  - ][ -  + ]:         27 :         SWRECTFN( pLay );
         [ #  # ][ #  # ]
                 [ -  + ]
    1505         [ +  - ]:         27 :         SwRect aRect( pLay->GetUpper()->PaintArea() );
    1506 [ +  - ][ +  - ]:         27 :         (aRect.*fnRect->fnSetTop)( (pLay->*fnRect->fnGetPrtBottom)() );
         [ +  - ][ +  - ]
    1507 [ +  - ][ +  + ]:         27 :         if ( !pImp->GetShell()->AddPaintRect( aRect ) )
    1508                 :         27 :             pLay->ResetRetouche();
    1509                 :            :     }
    1510                 :            : 
    1511         [ +  + ]:      14389 :     if( bAlreadyPainted )
    1512                 :        743 :         bAddRect = sal_False;
    1513                 :            : 
    1514         [ +  - ]:      14389 :     CheckWaitCrsr();
    1515                 :            : 
    1516         [ -  + ]:      14389 :     if ( IsAgain() )
    1517                 :          0 :         return sal_False;
    1518                 :            : 
    1519                 :            :     // Now, deal with the lowers that are LayoutFrms
    1520                 :            : 
    1521         [ +  + ]:      14389 :     if ( pLay->IsFtnFrm() ) // no LayFrms as Lower
    1522                 :        147 :         return bChanged;
    1523                 :            : 
    1524                 :      14242 :     SwFrm *pLow = pLay->Lower();
    1525                 :      14242 :     sal_Bool bTabChanged = sal_False;
    1526 [ +  + ][ +  + ]:      36324 :     while ( pLow && pLow->GetUpper() == pLay )
                 [ +  + ]
    1527                 :            :     {
    1528         [ +  + ]:      22082 :         if ( pLow->IsLayoutFrm() )
    1529                 :            :         {
    1530         [ +  + ]:      10827 :             if ( pLow->IsTabFrm() )
    1531         [ +  - ]:        652 :                 bTabChanged |= FormatLayoutTab( (SwTabFrm*)pLow, bAddRect );
    1532                 :            :             // Skip the ones already registered for deletion
    1533 [ +  + ][ +  - ]:      10175 :             else if( !pLow->IsSctFrm() || ((SwSectionFrm*)pLow)->GetSection() )
                 [ +  - ]
    1534         [ +  - ]:      10175 :                 bChanged |= FormatLayout( (SwLayoutFrm*)pLow, bAddRect );
    1535                 :            :         }
    1536         [ +  + ]:      11255 :         else if ( pImp->GetShell()->IsPaintLocked() )
    1537                 :            :             // Shortcut to minimize the cycles. With Lock, the
    1538                 :            :             // paint is coming either way (primarily for browse)
    1539         [ +  - ]:       4103 :             pLow->OptCalc();
    1540                 :            : 
    1541         [ -  + ]:      22082 :         if ( IsAgain() )
    1542                 :          0 :             return sal_False;
    1543                 :      22082 :         pLow = pLow->GetNext();
    1544                 :            :     }
    1545                 :            :     // OD 11.11.2002 #104414# - add complete frame area as paint area, if frame
    1546                 :            :     // area has been already added and after formating its lowers the frame area
    1547                 :            :     // is enlarged.
    1548 [ +  + ][ +  - ]:      14242 :     SwRect aBoundRect(pLay->IsPageFrm() ? static_cast<SwPageFrm*>(pLay)->GetBoundRect() : pLay->Frm() );
    1549                 :            : 
    1550   [ +  +  +  +  :      15593 :     if ( bAlreadyPainted &&
           -  + ][ +  + ]
    1551                 :        743 :          ( aBoundRect.Width() > aFrmAtCompletePaint.Width() ||
    1552                 :        608 :            aBoundRect.Height() > aFrmAtCompletePaint.Height() )
    1553                 :            :        )
    1554                 :            :     {
    1555         [ +  - ]:        135 :         pImp->GetShell()->AddPaintRect( aBoundRect );
    1556                 :            :     }
    1557 [ +  + ][ +  + ]:      14389 :     return bChanged || bTabChanged;
    1558                 :            : }
    1559                 :            : 
    1560                 :       1169 : sal_Bool SwLayAction::FormatLayoutFly( SwFlyFrm* pFly )
    1561                 :            : {
    1562                 :            :     OSL_ENSURE( !IsAgain(), "Attention to the invalid page." );
    1563         [ -  + ]:       1169 :     if ( IsAgain() )
    1564                 :          0 :         return sal_False;
    1565                 :            : 
    1566                 :       1169 :     sal_Bool bChanged = false;
    1567                 :       1169 :     sal_Bool bAddRect = true;
    1568                 :            : 
    1569 [ +  + ][ +  + ]:       1169 :     if ( !pFly->IsValid() || pFly->IsCompletePaint() || pFly->IsInvalid() )
         [ +  + ][ +  + ]
    1570                 :            :     {
    1571                 :            :         // The Frame has changed, now it's getting formatted.
    1572                 :        858 :         const SwRect aOldRect( pFly->Frm() );
    1573         [ +  - ]:        858 :         pFly->Calc();
    1574                 :        858 :         bChanged = aOldRect != pFly->Frm();
    1575                 :            : 
    1576 [ +  + ][ -  +  :       1352 :         if ( IsPaint() && (pFly->IsCompletePaint() || bChanged) &&
             +  +  +  - ]
         [ +  + ][ +  + ]
    1577                 :        494 :                     pFly->Frm().Top() > 0 && pFly->Frm().Left() > 0 )
    1578         [ +  - ]:        235 :             pImp->GetShell()->AddPaintRect( pFly->Frm() );
    1579                 :            : 
    1580         [ +  + ]:        858 :         if ( bChanged )
    1581                 :        157 :             pFly->Invalidate();
    1582                 :            :         else
    1583                 :        701 :             pFly->Validate();
    1584                 :            : /*
    1585                 :            :         //mba: it's unclear why we should invalidate always, so I remove it
    1586                 :            :         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
    1587                 :            :         if ( IsPaint() && bAddRect && pFly->Frm().Top() > 0 && pFly->Frm().Left() > 0 )
    1588                 :            :             pImp->GetShell()->AddPaintRect( pFly->Frm() );
    1589                 :            : 
    1590                 :            :         pFly->Invalidate();
    1591                 :            : */
    1592                 :        858 :         bAddRect = false;
    1593                 :        858 :         pFly->ResetCompletePaint();
    1594                 :            :     }
    1595                 :            : 
    1596         [ -  + ]:       1169 :     if ( IsAgain() )
    1597                 :          0 :         return sal_False;
    1598                 :            : 
    1599                 :            :     // Now, deal with the lowers that are LayoutFrms
    1600                 :       1169 :     sal_Bool bTabChanged = false;
    1601                 :       1169 :     SwFrm *pLow = pFly->Lower();
    1602         [ +  + ]:       2376 :     while ( pLow )
    1603                 :            :     {
    1604         [ +  + ]:       1207 :         if ( pLow->IsLayoutFrm() )
    1605                 :            :         {
    1606         [ +  - ]:          6 :             if ( pLow->IsTabFrm() )
    1607                 :          6 :                 bTabChanged |= FormatLayoutTab( (SwTabFrm*)pLow, bAddRect );
    1608                 :            :             else
    1609                 :          0 :                 bChanged |= FormatLayout( (SwLayoutFrm*)pLow, bAddRect );
    1610                 :            :         }
    1611                 :       1207 :         pLow = pLow->GetNext();
    1612                 :            :     }
    1613 [ +  + ][ +  + ]:       1169 :     return bChanged || bTabChanged;
    1614                 :            : }
    1615                 :            : 
    1616                 :            : // OD 31.10.2002 #104100#
    1617                 :            : // Implement vertical layout support
    1618                 :        658 : sal_Bool SwLayAction::FormatLayoutTab( SwTabFrm *pTab, sal_Bool bAddRect )
    1619                 :            : {
    1620                 :            :     OSL_ENSURE( !IsAgain(), "8-) Attention to the invalid page." );
    1621 [ +  - ][ -  + ]:        658 :     if ( IsAgain() || !pTab->Lower() )
                 [ -  + ]
    1622                 :          0 :         return sal_False;
    1623                 :            : 
    1624                 :        658 :     IDocumentTimerAccess *pTimerAccess = pRoot->GetFmt()->getIDocumentTimerAccess();
    1625                 :        658 :     pTimerAccess->BlockIdling();
    1626                 :            : 
    1627                 :        658 :     sal_Bool bChanged = sal_False;
    1628                 :        658 :     sal_Bool bPainted = sal_False;
    1629                 :            : 
    1630                 :        658 :     const SwPageFrm *pOldPage = pTab->FindPageFrm();
    1631                 :            : 
    1632                 :            :     // OD 31.10.2002 #104100# - vertical layout support
    1633                 :            :     // use macro to declare and init <sal_Bool bVert>, <sal_Bool bRev> and
    1634                 :            :     // <SwRectFn fnRect> for table frame <pTab>.
    1635 [ #  # ][ #  # ]:        658 :     SWRECTFN( pTab );
         [ -  + ][ -  + ]
    1636                 :            : 
    1637 [ +  + ][ +  + ]:        658 :     if ( !pTab->IsValid() || pTab->IsCompletePaint() || pTab->IsComplete() )
         [ +  + ][ +  + ]
    1638                 :            :     {
    1639 [ +  + ][ +  + ]:        458 :         if ( pTab->GetPrev() && !pTab->GetPrev()->IsValid() )
                 [ +  + ]
    1640                 :            :         {
    1641                 :          6 :             pTab->GetPrev()->SetCompletePaint();
    1642                 :            :         }
    1643                 :            : 
    1644                 :        458 :         const SwRect aOldRect( pTab->Frm() );
    1645                 :        458 :         pTab->SetLowersFormatted( sal_False );
    1646         [ +  - ]:        458 :         pTab->Calc();
    1647         [ +  + ]:        458 :         if ( aOldRect != pTab->Frm() )
    1648                 :            :         {
    1649                 :        136 :             bChanged = sal_True;
    1650                 :            :         }
    1651         [ +  - ]:        458 :         const SwRect aPaintFrm = pTab->PaintArea();
    1652                 :            : 
    1653 [ +  + ][ +  + ]:        458 :         if ( IsPaint() && bAddRect )
                 [ +  + ]
    1654                 :            :         {
    1655                 :            :             // OD 01.11.2002 #104100# - add condition <pTab->Frm().HasArea()>
    1656   [ +  +  +  +  :        673 :             if ( !pTab->IsCompletePaint() &&
           -  + ][ #  # ]
         [ +  - ][ +  + ]
    1657                 :        149 :                  pTab->IsComplete() &&
    1658                 :        140 :                  ( pTab->Frm().SSize() != pTab->Prt().SSize() ||
    1659                 :            :                    // OD 31.10.2002 #104100# - vertical layout support
    1660 [ #  # ][ #  # ]:          0 :                    (pTab->*fnRect->fnGetLeftMargin)() ) &&
    1661         [ +  - ]:        140 :                  pTab->Frm().HasArea()
    1662                 :            :                )
    1663                 :            :             {
    1664                 :            :                 // OD 01.11.2002 #104100# - re-implement calculation of margin rectangles.
    1665                 :        140 :                 SwRect aMarginRect;
    1666                 :            : 
    1667 [ +  - ][ +  - ]:        140 :                 SwTwips nLeftMargin = (pTab->*fnRect->fnGetLeftMargin)();
    1668         [ +  + ]:        140 :                 if ( nLeftMargin > 0)
    1669                 :            :                 {
    1670                 :          4 :                     aMarginRect = pTab->Frm();
    1671 [ +  - ][ +  - ]:          4 :                     (aMarginRect.*fnRect->fnSetWidth)( nLeftMargin );
    1672         [ +  - ]:          4 :                     pImp->GetShell()->AddPaintRect( aMarginRect );
    1673                 :            :                 }
    1674                 :            : 
    1675 [ +  - ][ +  - ]:        140 :                 if ( (pTab->*fnRect->fnGetRightMargin)() > 0)
                 [ +  + ]
    1676                 :            :                 {
    1677                 :          6 :                     aMarginRect = pTab->Frm();
    1678 [ +  - ][ +  - ]:          6 :                     (aMarginRect.*fnRect->fnSetLeft)( (pTab->*fnRect->fnGetPrtRight)() );
         [ +  - ][ +  - ]
    1679         [ +  - ]:          6 :                     pImp->GetShell()->AddPaintRect( aMarginRect );
    1680                 :            :                 }
    1681                 :            : 
    1682 [ +  - ][ +  - ]:        140 :                 SwTwips nTopMargin = (pTab->*fnRect->fnGetTopMargin)();
    1683         [ +  + ]:        140 :                 if ( nTopMargin > 0)
    1684                 :            :                 {
    1685                 :          4 :                     aMarginRect = pTab->Frm();
    1686 [ +  - ][ +  - ]:          4 :                     (aMarginRect.*fnRect->fnSetHeight)( nTopMargin );
    1687         [ +  - ]:          4 :                     pImp->GetShell()->AddPaintRect( aMarginRect );
    1688                 :            :                 }
    1689                 :            : 
    1690 [ +  - ][ +  - ]:        140 :                 if ( (pTab->*fnRect->fnGetBottomMargin)() > 0)
                 [ +  - ]
    1691                 :            :                 {
    1692                 :        140 :                     aMarginRect = pTab->Frm();
    1693 [ +  - ][ +  - ]:        140 :                     (aMarginRect.*fnRect->fnSetTop)( (pTab->*fnRect->fnGetPrtBottom)() );
         [ +  - ][ +  - ]
    1694         [ +  - ]:        140 :                     pImp->GetShell()->AddPaintRect( aMarginRect );
    1695                 :            :                 }
    1696                 :            :             }
    1697         [ +  + ]:        104 :             else if ( pTab->IsCompletePaint() )
    1698                 :            :             {
    1699         [ +  - ]:         95 :                 pImp->GetShell()->AddPaintRect( aPaintFrm );
    1700                 :         95 :                 bAddRect = sal_False;
    1701                 :         95 :                 bPainted = sal_True;
    1702                 :            :             }
    1703                 :            : 
    1704 [ -  + ][ #  # ]:        244 :             if ( pTab->IsRetouche() && !pTab->GetNext() )
                 [ -  + ]
    1705                 :            :             {
    1706         [ #  # ]:          0 :                 SwRect aRect( pTab->GetUpper()->PaintArea() );
    1707                 :            :                 // OD 04.11.2002 #104100# - vertical layout support
    1708 [ #  # ][ #  # ]:          0 :                 (aRect.*fnRect->fnSetTop)( (pTab->*fnRect->fnGetPrtBottom)() );
         [ #  # ][ #  # ]
    1709 [ #  # ][ #  # ]:          0 :                 if ( !pImp->GetShell()->AddPaintRect( aRect ) )
    1710                 :          0 :                     pTab->ResetRetouche();
    1711                 :            :             }
    1712                 :            :         }
    1713                 :            :         else
    1714                 :        214 :             bAddRect = sal_False;
    1715                 :            : 
    1716 [ +  + ][ +  + ]:        458 :         if ( pTab->IsCompletePaint() && !pOptTab )
                 [ +  + ]
    1717                 :        131 :             pOptTab = pTab;
    1718                 :        458 :         pTab->ResetCompletePaint();
    1719                 :            :     }
    1720 [ +  + ][ +  + ]:        658 :     if ( IsPaint() && bAddRect && pTab->IsRetouche() && !pTab->GetNext() )
         [ -  + ][ #  # ]
                 [ -  + ]
    1721                 :            :     {
    1722                 :            :         // OD 04.10.2002 #102779#
    1723                 :            :         // set correct rectangle for retouche: area between bottom of table frame
    1724                 :            :         // and bottom of paint area of the upper frame.
    1725         [ #  # ]:          0 :         SwRect aRect( pTab->GetUpper()->PaintArea() );
    1726                 :            :         // OD 04.11.2002 #104100# - vertical layout support
    1727 [ #  # ][ #  # ]:          0 :         (aRect.*fnRect->fnSetTop)( (pTab->*fnRect->fnGetPrtBottom)() );
         [ #  # ][ #  # ]
    1728 [ #  # ][ #  # ]:          0 :         if ( !pImp->GetShell()->AddPaintRect( aRect ) )
    1729                 :          0 :             pTab->ResetRetouche();
    1730                 :            :     }
    1731                 :            : 
    1732                 :        658 :     CheckWaitCrsr();
    1733                 :            : 
    1734                 :        658 :     pTimerAccess->UnblockIdling();
    1735                 :            : 
    1736                 :            :     // Ugly shortcut!
    1737   [ -  +  #  # ]:        658 :     if ( pTab->IsLowersFormatted() &&
         [ +  + ][ +  + ]
    1738                 :          0 :          (bPainted || !pImp->GetShell()->VisArea().IsOver( pTab->Frm())) )
    1739                 :          8 :         return sal_False;
    1740                 :            : 
    1741                 :            :     // Now, deal with the lowers
    1742         [ -  + ]:        650 :     if ( IsAgain() )
    1743                 :          0 :         return sal_False;
    1744                 :            : 
    1745                 :            :     // OD 20.10.2003 #112464# - for savety reasons:
    1746                 :            :     // check page number before formatting lowers.
    1747         [ -  + ]:        650 :     if ( pOldPage->GetPhyPageNum() > (pTab->FindPageFrm()->GetPhyPageNum() + 1) )
    1748                 :          0 :         SetNextCycle( sal_True );
    1749                 :            : 
    1750                 :            :     // OD 20.10.2003 #112464# - format lowers, only if table frame is valid
    1751         [ +  - ]:        650 :     if ( pTab->IsValid() )
    1752                 :            :     {
    1753                 :        650 :         SwLayoutFrm *pLow = (SwLayoutFrm*)pTab->Lower();
    1754         [ +  + ]:       2563 :         while ( pLow )
    1755                 :            :         {
    1756                 :       1913 :             bChanged |= FormatLayout( (SwLayoutFrm*)pLow, bAddRect );
    1757         [ -  + ]:       1913 :             if ( IsAgain() )
    1758                 :          0 :                 return sal_False;
    1759                 :       1913 :             pLow = (SwLayoutFrm*)pLow->GetNext();
    1760                 :            :         }
    1761                 :            :     }
    1762                 :            : 
    1763                 :        658 :     return bChanged;
    1764                 :            : }
    1765                 :            : 
    1766                 :            : /*************************************************************************
    1767                 :            : |*
    1768                 :            : |*  SwLayAction::FormatCntnt()
    1769                 :            : |*
    1770                 :            : |*************************************************************************/
    1771                 :       5203 : sal_Bool SwLayAction::FormatCntnt( const SwPageFrm *pPage )
    1772                 :            : {
    1773                 :       5203 :     const SwCntntFrm *pCntnt = pPage->ContainsCntnt();
    1774                 :       5203 :     const ViewShell *pSh = pRoot->GetCurrShell();
    1775 [ +  + ][ +  - ]:       5203 :     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
    1776                 :            : 
    1777 [ +  + ][ +  + ]:      27349 :     while ( pCntnt && pPage->IsAnLower( pCntnt ) )
                 [ +  + ]
    1778                 :            :     {
    1779                 :            :         // If the Cntnt didn't change, we can use a few shortcuts.
    1780                 :      37830 :         const sal_Bool bFull = !pCntnt->IsValid() || pCntnt->IsCompletePaint() ||
    1781 [ +  + ][ +  + ]:      37830 :                            pCntnt->IsRetouche() || pCntnt->GetDrawObjs();
           [ +  +  +  + ]
    1782         [ +  + ]:      22495 :         if ( bFull )
    1783                 :            :         {
    1784                 :            :             // We do this so we don't have to search later on.
    1785 [ +  + ][ +  - ]:      15418 :             const sal_Bool bNxtCnt = IsCalcLayout() && !pCntnt->GetFollow();
    1786         [ +  + ]:      15418 :             const SwCntntFrm *pCntntNext = bNxtCnt ? pCntnt->GetNextCntntFrm() : 0;
    1787         [ +  + ]:      15418 :             const SwCntntFrm *pCntntPrev = pCntnt->GetPrev() ? pCntnt->GetPrevCntntFrm() : 0;
    1788                 :            : 
    1789                 :      15418 :             const SwLayoutFrm*pOldUpper  = pCntnt->GetUpper();
    1790                 :      15418 :             const SwTabFrm *pTab = pCntnt->FindTabFrm();
    1791 [ +  + ][ +  + ]:      15418 :             const sal_Bool bInValid = !pCntnt->IsValid() || pCntnt->IsCompletePaint();
    1792                 :      15418 :             const sal_Bool bOldPaint = IsPaint();
    1793 [ +  + ][ +  + ]:      15418 :             bPaint = bOldPaint && !(pTab && pTab == pOptTab);
                 [ +  + ]
    1794                 :      15418 :             _FormatCntnt( pCntnt, pPage );
    1795                 :            :             // #i26945# - reset <bPaint> before format objects
    1796                 :      15418 :             bPaint = bOldPaint;
    1797                 :            : 
    1798                 :            :             // OD 2004-05-10 #i28701# - format floating screen object at content frame.
    1799                 :            :             // No format, if action flag <bAgain> is set or action is interrupted.
    1800                 :            :             // OD 2004-08-30 #117736# - allow format on interruption of action, if
    1801                 :            :             // it's the format for this interrupt
    1802                 :            :             // #i23129#, #i36347# - pass correct page frame
    1803                 :            :             // to the object formatter.
    1804   [ +  -  +  -  :      61672 :             if ( !IsAgain() &&
           +  + ][ +  + ]
           [ +  -  +  + ]
    1805                 :      15418 :                  ( !IsInterrupt() || mbFormatCntntOnInterrupt ) &&
    1806                 :      15418 :                  pCntnt->IsTxtFrm() &&
    1807                 :            :                  !SwObjectFormatter::FormatObjsAtFrm( *(const_cast<SwCntntFrm*>(pCntnt)),
    1808                 :      15418 :                                                       *(pCntnt->FindPageFrm()), this ) )
    1809                 :            :             {
    1810                 :          9 :                 return sal_False;
    1811                 :            :             }
    1812                 :            : 
    1813 [ +  + ][ +  - ]:      15409 :             if ( !pCntnt->GetValidLineNumFlag() && pCntnt->IsTxtFrm() )
                 [ +  + ]
    1814                 :            :             {
    1815                 :       9757 :                 const sal_uLong nAllLines = ((SwTxtFrm*)pCntnt)->GetAllLines();
    1816                 :       9757 :                 ((SwTxtFrm*)pCntnt)->RecalcAllLines();
    1817   [ +  -  -  + ]:       9769 :                 if ( IsPaintExtraData() && IsPaint() &&
         [ -  + ][ +  + ]
    1818                 :         12 :                      nAllLines != ((SwTxtFrm*)pCntnt)->GetAllLines() )
    1819                 :          0 :                     pImp->GetShell()->AddPaintRect( pCntnt->Frm() );
    1820                 :            :             }
    1821                 :            : 
    1822         [ -  + ]:      15409 :             if ( IsAgain() )
    1823                 :          0 :                 return sal_False;
    1824                 :            : 
    1825                 :            :             // Temporarily interrupt processing if layout or Flys become invalid again.
    1826                 :            :             // However not for the BrowseView: The layout is getting invalid
    1827                 :            :             // all the time because the page height gets adjusted.
    1828                 :            :             // The same applies if the user wants to continue working and at least one
    1829                 :            :             // paragraph has been processed.
    1830 [ +  + ][ +  - ]:      15409 :             if ( (!pTab || (pTab && !bInValid)) )
                 [ +  + ]
    1831                 :            :             {
    1832                 :       9573 :                 CheckIdleEnd();
    1833                 :            :                 // OD 14.04.2003 #106346# - consider interrupt formatting.
    1834 [ +  + ][ +  +  :      29620 :                 if ( ( IsInterrupt() && !mbFormatCntntOnInterrupt ) ||
          +  +  +  +  +  
              + ][ +  + ]
         [ +  + ][ +  + ]
    1835                 :       9458 :                      ( !bBrowse && pPage->IsInvalidLayout() ) ||
    1836                 :            :                      // OD 07.05.2003 #109435# - consider interrupt formatting
    1837                 :      10589 :                      ( IS_FLYS && IS_INVAFLY && !mbFormatCntntOnInterrupt )
    1838                 :            :                    )
    1839                 :        326 :                     return sal_False;
    1840                 :            :             }
    1841         [ +  + ]:      15083 :             if ( pOldUpper != pCntnt->GetUpper() )
    1842                 :            :             {
    1843                 :         26 :                 const sal_uInt16 nCurNum = pCntnt->FindPageFrm()->GetPhyPageNum();
    1844         [ +  + ]:         26 :                 if (  nCurNum < pPage->GetPhyPageNum() )
    1845                 :          4 :                     nPreInvaPage = nCurNum;
    1846                 :            : 
    1847                 :            :                 // If the Frm flowed backwards more than one page, we need to
    1848                 :            :                 // start over again from the beginning, so nothing gets left out.
    1849 [ +  - ][ -  + ]:         26 :                 if ( !IsCalcLayout() && pPage->GetPhyPageNum() > nCurNum+1 )
                 [ -  + ]
    1850                 :            :                 {
    1851                 :          0 :                     SetNextCycle( sal_True );
    1852                 :            :                     // OD 07.05.2003 #109435# - consider interrupt formatting
    1853         [ #  # ]:          0 :                     if ( !mbFormatCntntOnInterrupt )
    1854                 :            :                     {
    1855                 :          0 :                         return sal_False;
    1856                 :            :                     }
    1857                 :            :                 }
    1858                 :            :             }
    1859                 :            :             // If the Frame moved forwards to the next page, we re-run through
    1860                 :            :             // the predecessor.
    1861                 :            :             // This way, we catch predecessors which are now responsible for
    1862                 :            :             // retouching, but the footers will be touched also.
    1863                 :      15083 :             sal_Bool bSetCntnt = sal_True;
    1864         [ +  + ]:      15083 :             if ( pCntntPrev )
    1865                 :            :             {
    1866 [ +  + ][ +  - ]:       5609 :                 if ( !pCntntPrev->IsValid() && pPage->IsAnLower( pCntntPrev ) )
                 [ +  + ]
    1867                 :         22 :                     pPage->InvalidateCntnt();
    1868   [ +  +  +  - ]:       5631 :                 if ( pOldUpper != pCntnt->GetUpper() &&
                 [ +  + ]
    1869                 :         22 :                      pPage->GetPhyPageNum() < pCntnt->FindPageFrm()->GetPhyPageNum() )
    1870                 :            :                 {
    1871                 :         22 :                     pCntnt = pCntntPrev;
    1872                 :         22 :                     bSetCntnt = sal_False;
    1873                 :            :                 }
    1874                 :            :             }
    1875         [ +  + ]:      15083 :             if ( bSetCntnt )
    1876                 :            :             {
    1877 [ +  + ][ +  - ]:      15101 :                 if ( bBrowse && !IsIdle() && !IsCalcLayout() && !IsComplete() &&
                 [ +  - ]
           [ +  -  -  + ]
                 [ -  + ]
    1878                 :         40 :                      pCntnt->Frm().Top() > pImp->GetShell()->VisArea().Bottom())
    1879                 :            :                 {
    1880                 :          0 :                     const long nBottom = pImp->GetShell()->VisArea().Bottom();
    1881                 :            :                     const SwFrm *pTmp = lcl_FindFirstInvaCntnt( pPage,
    1882                 :          0 :                                                             nBottom, pCntnt );
    1883         [ #  # ]:          0 :                     if ( !pTmp )
    1884                 :            :                     {
    1885 [ #  # ][ #  #  :          0 :                         if ( (!(IS_FLYS && IS_INVAFLY) ||
          #  #  #  #  #  
              # ][ #  # ]
    1886                 :          0 :                               !lcl_FindFirstInvaObj( pPage, nBottom )) &&
    1887                 :          0 :                               (!pPage->IsInvalidLayout() ||
    1888                 :          0 :                                !lcl_FindFirstInvaLay( pPage, nBottom )))
    1889                 :          0 :                             SetBrowseActionStop( sal_True );
    1890                 :            :                         // OD 14.04.2003 #106346# - consider interrupt formatting.
    1891         [ #  # ]:          0 :                         if ( !mbFormatCntntOnInterrupt )
    1892                 :            :                         {
    1893                 :          0 :                             return sal_False;
    1894                 :            :                         }
    1895                 :            :                     }
    1896                 :            :                 }
    1897         [ +  + ]:      15061 :                 pCntnt = bNxtCnt ? pCntntNext : pCntnt->GetNextCntntFrm();
    1898                 :            :             }
    1899                 :            : 
    1900 [ +  + ][ -  + ]:      15083 :             RESCHEDULE;
    1901                 :            :         }
    1902                 :            :         else
    1903                 :            :         {
    1904 [ +  + ][ +  - ]:       7077 :             if ( !pCntnt->GetValidLineNumFlag() && pCntnt->IsTxtFrm() )
                 [ +  + ]
    1905                 :            :             {
    1906                 :         12 :                 const sal_uLong nAllLines = ((SwTxtFrm*)pCntnt)->GetAllLines();
    1907                 :         12 :                 ((SwTxtFrm*)pCntnt)->RecalcAllLines();
    1908   [ #  #  #  # ]:         12 :                 if ( IsPaintExtraData() && IsPaint() &&
         [ -  + ][ -  + ]
    1909                 :          0 :                      nAllLines != ((SwTxtFrm*)pCntnt)->GetAllLines() )
    1910                 :          0 :                     pImp->GetShell()->AddPaintRect( pCntnt->Frm() );
    1911                 :            :             }
    1912                 :            : 
    1913                 :            :             // Do this if the Frm has been formatted before.
    1914         [ +  - ]:       7313 :             if ( pCntnt->IsTxtFrm() && ((SwTxtFrm*)pCntnt)->HasRepaint() &&
           [ +  +  +  + ]
                 [ +  + ]
    1915                 :        236 :                   IsPaint() )
    1916                 :        232 :                 PaintCntnt( pCntnt, pPage, pCntnt->Frm(), pCntnt->Frm().Bottom());
    1917         [ +  + ]:       7077 :             if ( IsIdle() )
    1918                 :            :             {
    1919                 :        282 :                 CheckIdleEnd();
    1920                 :            :                 // OD 14.04.2003 #106346# - consider interrupt formatting.
    1921 [ +  + ][ +  + ]:        282 :                 if ( IsInterrupt() && !mbFormatCntntOnInterrupt )
                 [ +  + ]
    1922                 :         14 :                     return sal_False;
    1923                 :            :             }
    1924 [ +  + ][ +  - ]:       7077 :             if ( bBrowse && !IsIdle() && !IsCalcLayout() && !IsComplete() &&
                 [ +  - ]
           [ +  -  -  + ]
                 [ -  + ]
    1925                 :         14 :                  pCntnt->Frm().Top() > pImp->GetShell()->VisArea().Bottom())
    1926                 :            :             {
    1927                 :          0 :                 const long nBottom = pImp->GetShell()->VisArea().Bottom();
    1928                 :            :                 const SwFrm *pTmp = lcl_FindFirstInvaCntnt( pPage,
    1929                 :          0 :                                                     nBottom, pCntnt );
    1930         [ #  # ]:          0 :                 if ( !pTmp )
    1931                 :            :                 {
    1932 [ #  # ][ #  #  :          0 :                     if ( (!(IS_FLYS && IS_INVAFLY) ||
          #  #  #  #  #  
              # ][ #  # ]
    1933                 :          0 :                             !lcl_FindFirstInvaObj( pPage, nBottom )) &&
    1934                 :          0 :                             (!pPage->IsInvalidLayout() ||
    1935                 :          0 :                             !lcl_FindFirstInvaLay( pPage, nBottom )))
    1936                 :          0 :                         SetBrowseActionStop( sal_True );
    1937                 :            :                     // OD 14.04.2003 #106346# - consider interrupt formatting.
    1938         [ #  # ]:          0 :                     if ( !mbFormatCntntOnInterrupt )
    1939                 :            :                     {
    1940                 :          0 :                         return sal_False;
    1941                 :            :                     }
    1942                 :            :                 }
    1943                 :            :             }
    1944                 :       7063 :             pCntnt = pCntnt->GetNextCntntFrm();
    1945                 :            :         }
    1946                 :            :     }
    1947                 :       4854 :     CheckWaitCrsr();
    1948                 :            :     // OD 14.04.2003 #106346# - consider interrupt formatting.
    1949 [ +  - ][ +  + ]:       5203 :     return !IsInterrupt() || mbFormatCntntOnInterrupt;
    1950                 :            : }
    1951                 :            : /*************************************************************************
    1952                 :            : |*
    1953                 :            : |*  SwLayAction::_FormatCntnt()
    1954                 :            : |*
    1955                 :            : |*  Description         Returns sal_True if the paragraph has been processed,
    1956                 :            : |*                      sal_False if there wasn't anything to be processed.
    1957                 :            : |*
    1958                 :            : |*************************************************************************/
    1959                 :      16763 : void SwLayAction::_FormatCntnt( const SwCntntFrm *pCntnt,
    1960                 :            :                                 const SwPageFrm  *pPage )
    1961                 :            : {
    1962                 :            :     // We probably only ended up here because the Cntnt holds DrawObjects.
    1963                 :      25601 :     const bool bDrawObjsOnly = pCntnt->IsValid() && !pCntnt->IsCompletePaint() &&
    1964         [ +  + ]:      25601 :                          !pCntnt->IsRetouche();
           [ +  +  +  + ]
    1965 [ +  + ][ +  - ]:      16763 :     SWRECTFN( pCntnt )
         [ -  + ][ -  + ]
    1966 [ +  + ][ +  + ]:      16763 :     if ( !bDrawObjsOnly && IsPaint() )
                 [ +  + ]
    1967                 :            :     {
    1968         [ +  - ]:      10794 :         const SwRect aOldRect( pCntnt->UnionFrm() );
    1969 [ +  - ][ +  - ]:      10794 :         const long nOldBottom = (pCntnt->*fnRect->fnGetPrtBottom)();
    1970         [ +  - ]:      10794 :         pCntnt->OptCalc();
    1971         [ +  - ]:      10794 :         if( IsAgain() )
    1972                 :      16763 :             return;
    1973         [ +  + ]:      21588 :         if( (*fnRect->fnYDiff)( (pCntnt->Frm().*fnRect->fnGetBottom)(),
    1974         [ +  - ]:      21588 :                                 (aOldRect.*fnRect->fnGetBottom)() ) < 0 )
           [ +  -  +  - ]
         [ +  - ][ +  - ]
    1975                 :            :         {
    1976                 :        302 :             pCntnt->SetRetouche();
    1977                 :            :         }
    1978 [ +  - ][ +  - ]:      10794 :         PaintCntnt( pCntnt, pCntnt->FindPageFrm(), aOldRect, nOldBottom);
    1979                 :            :     }
    1980                 :            :     else
    1981                 :            :     {
    1982 [ +  + ][ +  + ]:       5969 :         if ( IsPaint() && pCntnt->IsTxtFrm() && ((SwTxtFrm*)pCntnt)->HasRepaint() )
         [ +  + ][ +  + ]
    1983                 :         15 :             PaintCntnt( pCntnt, pPage, pCntnt->Frm(),
    1984         [ +  - ]:         30 :                         (pCntnt->Frm().*fnRect->fnGetBottom)() );
    1985                 :       5969 :         pCntnt->OptCalc();
    1986                 :            :     }
    1987                 :            : }
    1988                 :            : 
    1989                 :            : /*************************************************************************
    1990                 :            : |*
    1991                 :            : |*  SwLayAction::_FormatFlyCntnt()
    1992                 :            : |*
    1993                 :            : |*  Description:
    1994                 :            : |*      - Returns sal_True if all Cntnts of the Fly have been processed completely.
    1995                 :            : |*        Returns sal_False if processing has been interrupted prematurely.
    1996                 :            : |*
    1997                 :            : |*************************************************************************/
    1998                 :       1169 : sal_Bool SwLayAction::_FormatFlyCntnt( const SwFlyFrm *pFly )
    1999                 :            : {
    2000                 :       1169 :     const SwCntntFrm *pCntnt = pFly->ContainsCntnt();
    2001                 :            : 
    2002         [ +  + ]:       2511 :     while ( pCntnt )
    2003                 :            :     {
    2004                 :            :         // OD 2004-05-10 #i28701#
    2005                 :       1345 :         _FormatCntnt( pCntnt, pCntnt->FindPageFrm() );
    2006                 :            : 
    2007                 :            :         // #i28701# - format floating screen objects
    2008                 :            :         // at content text frame
    2009                 :            :         // #i23129#, #i36347# - pass correct page frame
    2010                 :            :         // to the object formatter.
    2011         [ -  + ]:       2059 :         if ( pCntnt->IsTxtFrm() &&
           [ +  +  -  + ]
    2012                 :            :              !SwObjectFormatter::FormatObjsAtFrm(
    2013                 :            :                                             *(const_cast<SwCntntFrm*>(pCntnt)),
    2014                 :        714 :                                             *(pCntnt->FindPageFrm()), this ) )
    2015                 :            :         {
    2016                 :            :             // restart format with first content
    2017                 :          0 :             pCntnt = pFly->ContainsCntnt();
    2018                 :          0 :             continue;
    2019                 :            :         }
    2020                 :            : 
    2021 [ +  + ][ +  + ]:       1345 :         if ( !pCntnt->GetValidLineNumFlag() && pCntnt->IsTxtFrm() )
                 [ +  + ]
    2022                 :            :         {
    2023                 :        244 :             const sal_uLong nAllLines = ((SwTxtFrm*)pCntnt)->GetAllLines();
    2024                 :        244 :             ((SwTxtFrm*)pCntnt)->RecalcAllLines();
    2025   [ #  #  #  # ]:        244 :             if ( IsPaintExtraData() && IsPaint() &&
         [ -  + ][ -  + ]
    2026                 :          0 :                  nAllLines != ((SwTxtFrm*)pCntnt)->GetAllLines() )
    2027                 :          0 :                 pImp->GetShell()->AddPaintRect( pCntnt->Frm() );
    2028                 :            :         }
    2029                 :            : 
    2030         [ -  + ]:       1345 :         if ( IsAgain() )
    2031                 :          0 :             return sal_False;
    2032                 :            : 
    2033                 :            :         // If there's input, we interrupt processing.
    2034         [ +  + ]:       1345 :         if ( !pFly->IsFlyInCntFrm() )
    2035                 :            :         {
    2036                 :        766 :             CheckIdleEnd();
    2037                 :            :             // OD 14.04.2003 #106346# - consider interrupt formatting.
    2038 [ +  + ][ +  + ]:        766 :             if ( IsInterrupt() && !mbFormatCntntOnInterrupt )
                 [ +  + ]
    2039                 :          3 :                 return sal_False;
    2040                 :            :         }
    2041                 :       1342 :         pCntnt = pCntnt->GetNextCntntFrm();
    2042                 :            :     }
    2043                 :       1166 :     CheckWaitCrsr();
    2044                 :            :     // OD 14.04.2003 #106346# - consider interrupt formatting.
    2045 [ +  - ][ +  + ]:       1169 :     return !(IsInterrupt() && !mbFormatCntntOnInterrupt);
    2046                 :            : }
    2047                 :            : 
    2048                 :     105069 : sal_Bool SwLayAction::IsStopPrt() const
    2049                 :            : {
    2050                 :     105069 :     sal_Bool bResult = sal_False;
    2051                 :            : 
    2052 [ +  - ][ -  + ]:     105069 :     if (pImp != NULL && pProgress != NULL)
    2053                 :          0 :         bResult = pImp->IsStopPrt();
    2054                 :            : 
    2055                 :     105069 :     return bResult;
    2056                 :            : }
    2057                 :            : 
    2058                 :            : /*************************************************************************
    2059                 :            : |*
    2060                 :            : |*  SwLayAction::FormatSpelling(), _FormatSpelling()
    2061                 :            : |*
    2062                 :            : |*************************************************************************/
    2063                 :      44634 : sal_Bool SwLayIdle::_DoIdleJob( const SwCntntFrm *pCnt, IdleJobType eJob )
    2064                 :            : {
    2065                 :            :     OSL_ENSURE( pCnt->IsTxtFrm(), "NoTxt neighbour of Txt" );
    2066                 :            :     // robust against misuse by e.g. #i52542#
    2067         [ -  + ]:      44634 :     if( !pCnt->IsTxtFrm() )
    2068                 :          0 :         return sal_False;
    2069                 :            : 
    2070                 :      44634 :     const SwTxtNode* pTxtNode = pCnt->GetNode()->GetTxtNode();
    2071                 :            : 
    2072                 :      44634 :     bool bProcess = false;
    2073   [ +  +  +  -  :      44634 :     switch ( eJob )
                      - ]
    2074                 :            :     {
    2075                 :            :         case ONLINE_SPELLING :
    2076                 :      16951 :             bProcess = pTxtNode->IsWrongDirty(); break;
    2077                 :            :         case AUTOCOMPLETE_WORDS :
    2078                 :      16965 :             bProcess = pTxtNode->IsAutoCompleteWordDirty(); break;
    2079                 :            :         case WORD_COUNT :
    2080                 :      10718 :             bProcess = pTxtNode->IsWordCountDirty(); break;
    2081                 :            :         case SMART_TAGS :   // SMARTTAGS
    2082                 :          0 :             bProcess = pTxtNode->IsSmartTagDirty(); break;
    2083                 :            :     }
    2084                 :            : 
    2085         [ +  + ]:      44634 :     if( bProcess )
    2086                 :            :     {
    2087                 :      10865 :         ViewShell *pSh = pImp->GetShell();
    2088         [ +  + ]:      10865 :         if( STRING_LEN == nTxtPos )
    2089                 :            :         {
    2090                 :       8055 :             --nTxtPos;
    2091 [ +  - ][ +  + ]:       8055 :             if( pSh->ISA(SwCrsrShell) && !((SwCrsrShell*)pSh)->IsTableMode() )
                 [ +  + ]
    2092                 :            :             {
    2093                 :       8054 :                 SwPaM *pCrsr = ((SwCrsrShell*)pSh)->GetCrsr();
    2094 [ +  - ][ +  + ]:       8054 :                 if( !pCrsr->HasMark() && pCrsr == pCrsr->GetNext() )
                 [ +  + ]
    2095                 :            :                 {
    2096                 :       8021 :                     pCntntNode = pCrsr->GetCntntNode();
    2097                 :       8021 :                     nTxtPos =  pCrsr->GetPoint()->nContent.GetIndex();
    2098                 :            :                 }
    2099                 :            :             }
    2100                 :            :         }
    2101                 :            : 
    2102   [ +  +  +  -  :      10865 :         switch ( eJob )
                      - ]
    2103                 :            :         {
    2104                 :            :             case ONLINE_SPELLING :
    2105                 :            :             {
    2106         [ +  - ]:       6641 :                 SwRect aRepaint( ((SwTxtFrm*)pCnt)->_AutoSpell( pCntntNode,  *pSh->GetViewOptions(), nTxtPos ) );
    2107 [ +  + ][ +  - ]:       6641 :                 bPageValid = bPageValid && !pTxtNode->IsWrongDirty();
                 [ +  + ]
    2108         [ +  + ]:       6641 :                 if( !bPageValid )
    2109                 :       2951 :                     bAllValid = sal_False;
    2110 [ +  - ][ +  + ]:       6641 :                 if ( aRepaint.HasArea() )
    2111         [ +  - ]:        246 :                     pImp->GetShell()->InvalidateWindows( aRepaint );
    2112 [ +  - ][ -  + ]:       6641 :                 if ( Application::AnyInput( VCL_INPUT_MOUSEANDKEYBOARD|VCL_INPUT_OTHER|VCL_INPUT_PAINT ) )
    2113                 :       6641 :                     return sal_True;
    2114                 :            :                 break;
    2115                 :            :             }
    2116                 :            :             case AUTOCOMPLETE_WORDS :
    2117                 :         14 :                 ((SwTxtFrm*)pCnt)->CollectAutoCmplWrds( pCntntNode, nTxtPos );
    2118         [ +  + ]:         14 :                 if ( Application::AnyInput( VCL_INPUT_ANY ) )
    2119                 :          2 :                     return sal_True;
    2120                 :         12 :                 break;
    2121                 :            :             case WORD_COUNT :
    2122                 :            :             {
    2123                 :       4210 :                 const xub_StrLen nEnd = pTxtNode->GetTxt().Len();
    2124         [ +  - ]:       4210 :                 SwDocStat aStat;
    2125         [ +  - ]:       4210 :                 pTxtNode->CountWords( aStat, 0, nEnd );
    2126 [ +  - ][ +  + ]:       4210 :                 if ( Application::AnyInput( VCL_INPUT_ANY ) )
    2127                 :       4210 :                     return sal_True;
    2128                 :            :                 break;
    2129                 :            :             }
    2130                 :            :             case SMART_TAGS : // SMARTTAGS
    2131                 :            :             {
    2132         [ #  # ]:          0 :                 const SwRect aRepaint( ((SwTxtFrm*)pCnt)->SmartTagScan( pCntntNode, nTxtPos ) );
    2133 [ #  # ][ #  # ]:          0 :                 bPageValid = bPageValid && !pTxtNode->IsSmartTagDirty();
                 [ #  # ]
    2134         [ #  # ]:          0 :                 if( !bPageValid )
    2135                 :          0 :                     bAllValid = sal_False;
    2136 [ #  # ][ #  # ]:          0 :                 if ( aRepaint.HasArea() )
    2137         [ #  # ]:          0 :                     pImp->GetShell()->InvalidateWindows( aRepaint );
    2138 [ #  # ][ #  # ]:          0 :                 if ( Application::AnyInput( VCL_INPUT_MOUSEANDKEYBOARD|VCL_INPUT_OTHER|VCL_INPUT_PAINT ) )
    2139                 :       9412 :                     return sal_True;
    2140                 :            :                 break;
    2141                 :            :             }
    2142                 :            :         }
    2143                 :            :     }
    2144                 :            : 
    2145                 :            :     // The Flys that are anchored to the paragraph need to be considered too.
    2146         [ +  + ]:      43181 :     if ( pCnt->GetDrawObjs() )
    2147                 :            :     {
    2148                 :       3176 :         const SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
    2149         [ +  + ]:       7472 :         for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
    2150                 :            :         {
    2151                 :       4296 :             SwAnchoredObject* pObj = rObjs[i];
    2152         [ +  + ]:       4296 :             if ( pObj->ISA(SwFlyFrm) )
    2153                 :            :             {
    2154         [ +  - ]:        841 :                 SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pObj);
    2155         [ +  + ]:        841 :                 if ( pFly->IsFlyInCntFrm() )
    2156                 :            :                 {
    2157                 :        660 :                     const SwCntntFrm *pC = pFly->ContainsCntnt();
    2158         [ +  + ]:       1320 :                     while( pC )
    2159                 :            :                     {
    2160         [ +  + ]:        660 :                         if ( pC->IsTxtFrm() )
    2161                 :            :                         {
    2162         [ -  + ]:          2 :                             if ( _DoIdleJob( pC, eJob ) )
    2163                 :          0 :                                 return sal_True;
    2164                 :            :                         }
    2165                 :        660 :                         pC = pC->GetNextCntntFrm();
    2166                 :            :                     }
    2167                 :            :                 }
    2168                 :            :             }
    2169                 :            :         }
    2170                 :            :     }
    2171                 :      44634 :     return sal_False;
    2172                 :            : }
    2173                 :            : 
    2174                 :      26597 : sal_Bool SwLayIdle::DoIdleJob( IdleJobType eJob, sal_Bool bVisAreaOnly )
    2175                 :            : {
    2176                 :            :     // Spellcheck all contents of the pages. Either only the
    2177                 :            :     // visible ones or all of them.
    2178                 :      26597 :     const ViewShell* pViewShell = pImp->GetShell();
    2179                 :      26597 :     const SwViewOption* pViewOptions = pViewShell->GetViewOptions();
    2180                 :      26597 :     const SwDoc* pDoc = pViewShell->GetDoc();
    2181                 :            : 
    2182   [ +  +  +  +  :      26597 :     switch ( eJob )
                      - ]
    2183                 :            :     {
    2184                 :            :         case ONLINE_SPELLING :
    2185         [ +  + ]:       7409 :             if( !pViewOptions->IsOnlineSpell() )
    2186                 :         14 :                 return sal_False;
    2187                 :       7395 :             break;
    2188                 :            :         case AUTOCOMPLETE_WORDS :
    2189   [ +  -  -  + ]:      14818 :             if( !pViewOptions->IsAutoCompleteWords() ||
                 [ -  + ]
    2190                 :       7409 :                  pDoc->GetAutoCompleteWords().IsLockWordLstLocked())
    2191                 :          0 :                 return sal_False;
    2192                 :       7409 :             break;
    2193                 :            :         case WORD_COUNT :
    2194         [ +  + ]:       4370 :             if ( !pViewShell->getIDocumentStatistics()->GetDocStat().bModified )
    2195                 :         27 :                 return sal_False;
    2196                 :       4343 :             break;
    2197                 :            :         case SMART_TAGS :
    2198   [ +  -  +  -  :      22227 :             if ( pDoc->GetDocShell()->IsHelpDocument() ||
           +  - ][ +  - ]
    2199                 :       7409 :                  pDoc->isXForms() ||
    2200                 :       7409 :                 !SwSmartTagMgr::Get().IsSmartTagsEnabled() )
    2201                 :       7409 :                 return sal_False;
    2202                 :          0 :             break;
    2203                 :            :         default: OSL_FAIL( "Unknown idle job type" );
    2204                 :            :     }
    2205                 :            : 
    2206                 :            :     SwPageFrm *pPage;
    2207         [ +  + ]:      19147 :     if ( bVisAreaOnly )
    2208                 :       8972 :         pPage = pImp->GetFirstVisPage();
    2209                 :            :     else
    2210                 :      10175 :         pPage = (SwPageFrm*)pRoot->Lower();
    2211                 :            : 
    2212                 :      19147 :     pCntntNode = NULL;
    2213                 :      19147 :     nTxtPos = STRING_LEN;
    2214                 :            : 
    2215         [ +  + ]:      40277 :     while ( pPage )
    2216                 :            :     {
    2217                 :      22665 :         bPageValid = sal_True;
    2218                 :      22665 :         const SwCntntFrm *pCnt = pPage->ContainsCntnt();
    2219 [ +  + ][ +  + ]:      65710 :         while( pCnt && pPage->IsAnLower( pCnt ) )
                 [ +  + ]
    2220                 :            :         {
    2221         [ +  + ]:      44498 :             if ( _DoIdleJob( pCnt, eJob ) )
    2222                 :       1453 :                 return sal_True;
    2223                 :      43045 :             pCnt = pCnt->GetNextCntntFrm();
    2224                 :            :         }
    2225         [ +  + ]:      21212 :         if ( pPage->GetSortedObjs() )
    2226                 :            :         {
    2227   [ +  -  +  + ]:       1398 :             for ( sal_uInt16 i = 0; pPage->GetSortedObjs() &&
                 [ +  + ]
    2228                 :        699 :                                 i < pPage->GetSortedObjs()->Count(); ++i )
    2229                 :            :             {
    2230                 :        454 :                 const SwAnchoredObject* pObj = (*pPage->GetSortedObjs())[i];
    2231         [ +  + ]:        454 :                 if ( pObj->ISA(SwFlyFrm) )
    2232                 :            :                 {
    2233         [ +  - ]:        268 :                     const SwFlyFrm *pFly = static_cast<const SwFlyFrm*>(pObj);
    2234                 :        268 :                     const SwCntntFrm *pC = pFly->ContainsCntnt();
    2235         [ +  + ]:        536 :                     while( pC )
    2236                 :            :                     {
    2237         [ +  + ]:        268 :                         if ( pC->IsTxtFrm() )
    2238                 :            :                         {
    2239         [ -  + ]:        134 :                             if ( _DoIdleJob( pC, eJob ) )
    2240                 :          0 :                                 return sal_True;
    2241                 :            :                         }
    2242                 :        268 :                         pC = pC->GetNextCntntFrm();
    2243                 :            :                     }
    2244                 :            :                 }
    2245                 :            :             }
    2246                 :            :         }
    2247                 :            : 
    2248         [ +  + ]:      21212 :         if( bPageValid )
    2249                 :            :         {
    2250   [ +  +  +  -  :      18273 :             switch ( eJob )
                      - ]
    2251                 :            :             {
    2252                 :       5571 :                 case ONLINE_SPELLING : pPage->ValidateSpelling(); break;
    2253                 :       8522 :                 case AUTOCOMPLETE_WORDS : pPage->ValidateAutoCompleteWords(); break;
    2254                 :       4180 :                 case WORD_COUNT : pPage->ValidateWordCount(); break;
    2255                 :      18273 :                 case SMART_TAGS : pPage->ValidateSmartTags(); break; // SMARTTAGS
    2256                 :            :             }
    2257                 :            :         }
    2258                 :            : 
    2259                 :      21212 :         pPage = (SwPageFrm*)pPage->GetNext();
    2260   [ +  +  +  + ]:      21572 :         if ( pPage && bVisAreaOnly &&
         [ +  + ][ +  + ]
    2261                 :        360 :              !pPage->Frm().IsOver( pImp->GetShell()->VisArea()))
    2262                 :         82 :              break;
    2263                 :            :     }
    2264                 :      26597 :     return sal_False;
    2265                 :            : }
    2266                 :            : 
    2267                 :            : #ifdef DBG_UTIL
    2268                 :            : /*************************************************************************
    2269                 :            : |*
    2270                 :            : |*  void SwLayIdle::SwLayIdle()
    2271                 :            : |*
    2272                 :            : |*************************************************************************/
    2273                 :            : void SwLayIdle::ShowIdle( ColorData eColorData )
    2274                 :            : {
    2275                 :            :     if ( !m_bIndicator )
    2276                 :            :     {
    2277                 :            :         m_bIndicator = true;
    2278                 :            :         Window *pWin = pImp->GetShell()->GetWin();
    2279                 :            :         if ( pWin )
    2280                 :            :         {
    2281                 :            :             Rectangle aRect( 0, 0, 5, 5 );
    2282                 :            :             aRect = pWin->PixelToLogic( aRect );
    2283                 :            :             // OD 2004-04-23 #116347#
    2284                 :            :             pWin->Push( PUSH_FILLCOLOR|PUSH_LINECOLOR );
    2285                 :            :             pWin->SetFillColor( eColorData );
    2286                 :            :             pWin->SetLineColor();
    2287                 :            :             pWin->DrawRect( aRect );
    2288                 :            :             pWin->Pop();
    2289                 :            :         }
    2290                 :            :     }
    2291                 :            : }
    2292                 :            : #define SHOW_IDLE( ColorData ) ShowIdle( ColorData )
    2293                 :            : #else
    2294                 :            : #define SHOW_IDLE( ColorData )
    2295                 :            : #endif // DBG_UTIL
    2296                 :            : 
    2297                 :            : /*************************************************************************
    2298                 :            : |*
    2299                 :            : |*  void SwLayIdle::SwLayIdle()
    2300                 :            : |*
    2301                 :            : |*************************************************************************/
    2302                 :       4490 : SwLayIdle::SwLayIdle( SwRootFrm *pRt, SwViewImp *pI ) :
    2303                 :            :     pRoot( pRt ),
    2304                 :       4490 :     pImp( pI )
    2305                 :            : #ifdef DBG_UTIL
    2306                 :            :     , m_bIndicator( false )
    2307                 :            : #endif
    2308                 :            : {
    2309                 :       4490 :     pImp->pIdleAct = this;
    2310                 :            : 
    2311                 :            :     SHOW_IDLE( COL_LIGHTRED );
    2312                 :            : 
    2313                 :       4490 :     pImp->GetShell()->EnableSmooth( sal_False );
    2314                 :            : 
    2315                 :            :     // First, spellcheck the visible area. Only if there's nothing
    2316                 :            :     // to do there, we trigger the IdleFormat.
    2317 [ +  + ][ +  -  :      13470 :     if ( !DoIdleJob( SMART_TAGS, sal_True ) &&
             +  -  +  + ]
    2318                 :       4490 :          !DoIdleJob( ONLINE_SPELLING, sal_True ) &&
    2319                 :       4490 :          !DoIdleJob( AUTOCOMPLETE_WORDS, sal_True ) ) // SMARTTAGS
    2320                 :            :     {
    2321                 :            :         // Format, then register repaint rectangles with the ViewShell if necessary.
    2322                 :            :         // This requires running artificial actions, so we don't get undesired
    2323                 :            :         // effects when for instance the page count gets changed.
    2324                 :            :         // We remember the shells where the cursor is visible, so we can make
    2325                 :            :         // it visible again if needed after a document change.
    2326         [ +  - ]:       4488 :         std::vector<bool> aBools;
    2327                 :       4488 :         ViewShell *pSh = pImp->GetShell();
    2328         [ -  + ]:       4488 :         do
    2329                 :       4488 :         {   ++pSh->nStartAction;
    2330                 :       4488 :             sal_Bool bVis = sal_False;
    2331 [ +  - ][ +  - ]:       4488 :             if ( pSh->ISA(SwCrsrShell) )
                 [ +  - ]
    2332                 :            :             {
    2333                 :            : #ifdef SW_CRSR_TIMER
    2334                 :            :                 ((SwCrsrShell*)pSh)->ChgCrsrTimerFlag( sal_False );
    2335                 :            : #endif
    2336         [ +  - ]:       4488 :                 bVis = ((SwCrsrShell*)pSh)->GetCharRect().IsOver(pSh->VisArea());
    2337                 :            :             }
    2338         [ +  - ]:       4488 :             aBools.push_back( bVis );
    2339                 :       4488 :             pSh = (ViewShell*)pSh->GetNext();
    2340                 :       4488 :         } while ( pSh != pImp->GetShell() );
    2341                 :            : 
    2342         [ +  - ]:       4488 :         SwLayAction aAction( pRoot, pImp );
    2343                 :       4488 :         aAction.SetInputType( VCL_INPUT_ANY );
    2344                 :       4488 :         aAction.SetIdle( sal_True );
    2345                 :       4488 :         aAction.SetWaitAllowed( sal_False );
    2346         [ +  - ]:       4488 :         aAction.Action();
    2347                 :            : 
    2348                 :            :         // Further start/end actions only happen if there were paints started
    2349                 :            :         // somewhere or if the visibility of the CharRects has changed.
    2350                 :       4488 :         sal_Bool bActions = sal_False;
    2351                 :       4488 :         sal_uInt16 nBoolIdx = 0;
    2352         [ -  + ]:       4488 :         do
    2353                 :            :         {
    2354                 :       4488 :             --pSh->nStartAction;
    2355                 :            : 
    2356         [ +  + ]:       4488 :             if ( pSh->Imp()->GetRegion() )
    2357                 :         58 :                 bActions = sal_True;
    2358                 :            :             else
    2359                 :            :             {
    2360                 :       4430 :                 SwRect aTmp( pSh->VisArea() );
    2361         [ +  - ]:       4430 :                 pSh->UISizeNotify();
    2362                 :            : 
    2363                 :            :                 // #137134#
    2364                 :            :                 // Are we supposed to crash if pSh isn't a cursor shell?!
    2365                 :            :                 // bActions |= aTmp != pSh->VisArea() ||
    2366                 :            :                 //             aBools[nBoolIdx] != ((SwCrsrShell*)pSh)->GetCharRect().IsOver( pSh->VisArea() );
    2367                 :            : 
    2368                 :            :                 // aBools[ i ] is true, if the i-th shell is a cursor shell (!!!)
    2369                 :            :                 // and the cursor is visible.
    2370                 :       4430 :                 bActions |= aTmp != pSh->VisArea();
    2371 [ +  - ][ +  - ]:       4430 :                 if ( aTmp == pSh->VisArea() && pSh->ISA(SwCrsrShell) )
         [ +  - ][ +  - ]
                 [ +  - ]
    2372                 :            :                 {
    2373         [ +  - ]:       8860 :                     bActions |= ((sal_Bool) aBools[nBoolIdx]) !=
    2374         [ +  - ]:       4430 :                                 static_cast<SwCrsrShell*>(pSh)->GetCharRect().IsOver( pSh->VisArea() );
    2375                 :            :                 }
    2376                 :            :             }
    2377                 :            : 
    2378                 :       4488 :             pSh = (ViewShell*)pSh->GetNext();
    2379                 :       4488 :             ++nBoolIdx;
    2380                 :       4488 :         } while ( pSh != pImp->GetShell() );
    2381                 :            : 
    2382         [ +  + ]:       4488 :         if ( bActions )
    2383                 :            :         {
    2384                 :            :             // Prepare start/end actions via CrsrShell, so the cursor, selection
    2385                 :            :             // and VisArea can be set correctly.
    2386                 :         58 :             nBoolIdx = 0;
    2387         [ -  + ]:         58 :             do
    2388                 :            :             {
    2389 [ +  - ][ +  - ]:         58 :                 sal_Bool bCrsrShell = pSh->IsA( TYPE(SwCrsrShell) );
    2390                 :            : 
    2391         [ +  - ]:         58 :                 if ( bCrsrShell )
    2392         [ +  - ]:         58 :                     ((SwCrsrShell*)pSh)->SttCrsrMove();
    2393                 :            : //              else
    2394                 :            : //                  pSh->StartAction();
    2395                 :            : 
    2396                 :            :                 // If there are accrued paints, it's best to simply invalidate
    2397                 :            :                 // the whole window. Otherwise there would arise paint problems whose
    2398                 :            :                 // solution would be disproportionally expensive.
    2399                 :            :                 //fix(18176):
    2400                 :         58 :                 SwViewImp *pViewImp = pSh->Imp();
    2401                 :         58 :                 sal_Bool bUnlock = sal_False;
    2402         [ +  - ]:         58 :                 if ( pViewImp->GetRegion() )
    2403                 :            :                 {
    2404         [ +  - ]:         58 :                     pViewImp->DelRegion();
    2405                 :            : 
    2406                 :            :                     // Cause a repaint with virtual device.
    2407         [ +  - ]:         58 :                     pSh->LockPaint();
    2408                 :         58 :                     bUnlock = sal_True;
    2409                 :            :                 }
    2410                 :            : 
    2411         [ +  - ]:         58 :                 if ( bCrsrShell )
    2412                 :            :                     // If the Crsr was visible, we need to make it visible again.
    2413                 :            :                     // Otherwise, EndCrsrMove with sal_True for IdleEnd
    2414 [ +  - ][ +  - ]:         58 :                     ((SwCrsrShell*)pSh)->EndCrsrMove( sal_True^aBools[nBoolIdx] );
    2415                 :            : //              else
    2416                 :            : //                  pSh->EndAction();
    2417         [ +  - ]:         58 :                 if( bUnlock )
    2418                 :            :                 {
    2419         [ +  - ]:         58 :                     if( bCrsrShell )
    2420                 :            :                     {
    2421                 :            :                         // UnlockPaint overwrite the selection from the
    2422                 :            :                         // CrsrShell and calls the virtual method paint
    2423                 :            :                         // to fill the virtual device. This fill dont have
    2424                 :            :                         // paint the selection! -> Set the focus flag at
    2425                 :            :                         // CrsrShell and it dont paint the selection.
    2426         [ +  - ]:         58 :                         ((SwCrsrShell*)pSh)->ShLooseFcs();
    2427         [ +  - ]:         58 :                         pSh->UnlockPaint( sal_True );
    2428         [ +  - ]:         58 :                         ((SwCrsrShell*)pSh)->ShGetFcs( sal_False );
    2429                 :            :                     }
    2430                 :            :                     else
    2431         [ #  # ]:          0 :                         pSh->UnlockPaint( sal_True );
    2432                 :            :                 }
    2433                 :            : 
    2434                 :         58 :                 pSh = (ViewShell*)pSh->GetNext();
    2435                 :         58 :                 ++nBoolIdx;
    2436                 :            : 
    2437                 :         58 :             } while ( pSh != pImp->GetShell() );
    2438                 :            :         }
    2439                 :            : 
    2440 [ +  - ][ +  + ]:       4488 :         if ( !aAction.IsInterrupt() )
    2441                 :            :         {
    2442 [ +  - ][ +  + ]:       4370 :             if ( !DoIdleJob( WORD_COUNT, sal_False ) )
    2443 [ +  - ][ +  - ]:       2919 :                 if ( !DoIdleJob( SMART_TAGS, sal_False ) )
    2444 [ +  - ][ +  - ]:       2919 :                     if ( !DoIdleJob( ONLINE_SPELLING, sal_False ) )
    2445         [ +  - ]:       2919 :                         DoIdleJob( AUTOCOMPLETE_WORDS, sal_False ); // SMARTTAGS
    2446                 :            :         }
    2447                 :            : 
    2448                 :       4488 :         bool bInValid = false;
    2449                 :       4488 :         const SwViewOption& rVOpt = *pImp->GetShell()->GetViewOptions();
    2450                 :       4488 :         const ViewShell* pViewShell = pImp->GetShell();
    2451                 :            :         // See conditions in DoIdleJob()
    2452                 :       4488 :         const sal_Bool bSpell     = rVOpt.IsOnlineSpell();
    2453         [ +  - ]:       4488 :         const sal_Bool bACmplWrd  = rVOpt.IsAutoCompleteWords();
    2454 [ +  - ][ +  - ]:       4488 :         const sal_Bool bWordCount = pViewShell->getIDocumentStatistics()->GetDocStat().bModified;
    2455         [ +  - ]:       4488 :         const sal_Bool bSmartTags = !pViewShell->GetDoc()->GetDocShell()->IsHelpDocument() &&
    2456         [ +  - ]:       4488 :                                 !pViewShell->GetDoc()->isXForms() &&
    2457 [ +  - ][ +  - ]:       8976 :                                 SwSmartTagMgr::Get().IsSmartTagsEnabled(); // SMARTTAGS
         [ +  - ][ -  + ]
    2458                 :            : 
    2459                 :       4488 :         SwPageFrm *pPg = (SwPageFrm*)pRoot->Lower();
    2460 [ +  + ][ +  + ]:       5835 :         do
                 [ +  + ]
    2461                 :            :         {
    2462                 :      11664 :             bInValid = pPg->IsInvalidCntnt()    || pPg->IsInvalidLayout() ||
    2463                 :      11658 :                        pPg->IsInvalidFlyCntnt() || pPg->IsInvalidFlyLayout() ||
    2464                 :       5829 :                        pPg->IsInvalidFlyInCnt() ||
    2465                 :       5823 :                        (bSpell && pPg->IsInvalidSpelling()) ||
    2466                 :       4182 :                        (bACmplWrd && pPg->IsInvalidAutoCompleteWords()) ||
    2467                 :       4124 :                        (bWordCount && pPg->IsInvalidWordCount()) ||
    2468   [ +  +  +  + ]:      43280 :                        (bSmartTags && pPg->IsInvalidSmartTags()); // SMARTTAGS
           [ +  -  +  + ]
           [ +  +  +  + ]
         [ -  + ][ #  # ]
           [ +  +  +  -  
          +  -  +  -  +  
                      - ]
    2469                 :            : 
    2470                 :       5835 :             pPg = (SwPageFrm*)pPg->GetNext();
    2471                 :            : 
    2472                 :       1547 :         } while ( pPg && !bInValid );
    2473                 :            : 
    2474         [ +  + ]:       4488 :         if ( !bInValid )
    2475                 :            :         {
    2476                 :       1528 :             pRoot->ResetIdleFormat();
    2477                 :       1528 :             SfxObjectShell* pDocShell = pImp->GetShell()->GetDoc()->GetDocShell();
    2478 [ +  - ][ +  - ]:       1528 :             pDocShell->Broadcast( SfxEventHint( SW_EVENT_LAYOUT_FINISHED, SwDocShell::GetEventName(STR_SW_EVENT_LAYOUT_FINISHED), pDocShell ) );
         [ +  - ][ +  - ]
    2479                 :       4488 :         }
    2480                 :            :     }
    2481                 :            : 
    2482                 :       4490 :     pImp->GetShell()->EnableSmooth( sal_True );
    2483                 :            : 
    2484         [ +  + ]:       4490 :     if( pImp->IsAccessible() )
    2485                 :         16 :         pImp->FireAccessibleEvents();
    2486                 :            : 
    2487                 :            : #ifdef DBG_UTIL
    2488                 :            :     if ( m_bIndicator && pImp->GetShell()->GetWin() )
    2489                 :            :     {
    2490                 :            :         // #i75172# Do not invalidate indicator, this may cause a endless loop. Instead, just repaint it
    2491                 :            :         // This should be replaced by an overlay object in the future, anyways. Since it's only for debug
    2492                 :            :         // purposes, it is not urgent.
    2493                 :            :             m_bIndicator = false; SHOW_IDLE( COL_LIGHTGREEN );
    2494                 :            :     }
    2495                 :            : #endif
    2496                 :       4490 : }
    2497                 :            : 
    2498                 :       4490 : SwLayIdle::~SwLayIdle()
    2499                 :            : {
    2500                 :       4490 :     pImp->pIdleAct = 0;
    2501                 :       4490 : }
    2502                 :            : 
    2503                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10