LCOV - code coverage report
Current view: top level - sw/source/core/layout - newfrm.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 145 165 87.9 %
Date: 2014-04-11 Functions: 26 33 78.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svx/svdmodel.hxx>
      21             : #include <svx/svdpage.hxx>
      22             : #include <fmtpdsc.hxx>
      23             : #include <swtable.hxx>
      24             : #include <rootfrm.hxx>
      25             : #include <pagefrm.hxx>
      26             : #include <dflyobj.hxx>
      27             : #include <frmtool.hxx>
      28             : #include <virtoutp.hxx>
      29             : #include <blink.hxx>
      30             : #include <sectfrm.hxx>
      31             : #include <notxtfrm.hxx>
      32             : #include <pagedesc.hxx>
      33             : #include "viewimp.hxx"
      34             : #include <hints.hxx>
      35             : #include <viewopt.hxx>
      36             : #include <set>
      37             : 
      38             : SwLayVout     *SwRootFrm::pVout = 0;
      39             : bool           SwRootFrm::bInPaint = false;
      40             : sal_Bool           SwRootFrm::bNoVirDev = sal_False;
      41             : 
      42             : SwCache *SwFrm::mpCache = 0;
      43             : 
      44      431317 : long FirstMinusSecond( long nFirst, long nSecond )
      45      431317 :     { return nFirst - nSecond; }
      46           1 : long SecondMinusFirst( long nFirst, long nSecond )
      47           1 :     { return nSecond - nFirst; }
      48       48364 : long SwIncrement( long nA, long nAdd )
      49       48364 :     { return nA + nAdd; }
      50           1 : long SwDecrement( long nA, long nSub )
      51           1 :     { return nA - nSub; }
      52             : 
      53             : static SwRectFnCollection aHorizontal = {
      54             :     /* fnRectGet      */
      55             :     &SwRect::_Top,
      56             :     &SwRect::_Bottom,
      57             :     &SwRect::_Left,
      58             :     &SwRect::_Right,
      59             :     &SwRect::_Width,
      60             :     &SwRect::_Height,
      61             :     &SwRect::TopLeft,
      62             :     &SwRect::_Size,
      63             :     /* fnRectSet      */
      64             :     &SwRect::_Top,
      65             :     &SwRect::_Bottom,
      66             :     &SwRect::_Left,
      67             :     &SwRect::_Right,
      68             :     &SwRect::_Width,
      69             :     &SwRect::_Height,
      70             : 
      71             :     &SwRect::SubTop,
      72             :     &SwRect::AddBottom,
      73             :     &SwRect::SubLeft,
      74             :     &SwRect::AddRight,
      75             :     &SwRect::AddWidth,
      76             :     &SwRect::AddHeight,
      77             : 
      78             :     &SwRect::SetPosX,
      79             :     &SwRect::SetPosY,
      80             : 
      81             :     &SwFrm::GetTopMargin,
      82             :     &SwFrm::GetBottomMargin,
      83             :     &SwFrm::GetLeftMargin,
      84             :     &SwFrm::GetRightMargin,
      85             :     &SwFrm::SetLeftRightMargins,
      86             :     &SwFrm::SetTopBottomMargins,
      87             :     &SwFrm::GetPrtTop,
      88             :     &SwFrm::GetPrtBottom,
      89             :     &SwFrm::GetPrtLeft,
      90             :     &SwFrm::GetPrtRight,
      91             :     &SwRect::GetTopDistance,
      92             :     &SwRect::GetBottomDistance,
      93             :     &SwRect::GetLeftDistance,
      94             :     &SwRect::GetRightDistance,
      95             :     &SwFrm::SetMaxBottom,
      96             :     &SwRect::OverStepBottom,
      97             : 
      98             :     &SwRect::SetUpperLeftCorner,
      99             :     &SwFrm::MakeBelowPos,
     100             :     &FirstMinusSecond,
     101             :     &FirstMinusSecond,
     102             :     &SwIncrement,
     103             :     &SwIncrement,
     104             :     &SwRect::SetLeftAndWidth,
     105             :     &SwRect::SetTopAndHeight
     106             : };
     107             : 
     108             : static SwRectFnCollection aVertical = {
     109             :     /* fnRectGet      */
     110             :     &SwRect::_Right,
     111             :     &SwRect::_Left,
     112             :     &SwRect::_Top,
     113             :     &SwRect::_Bottom,
     114             :     &SwRect::_Height,
     115             :     &SwRect::_Width,
     116             :     &SwRect::TopRight,
     117             :     &SwRect::SwappedSize,
     118             :     /* fnRectSet      */
     119             :     &SwRect::_Right,
     120             :     &SwRect::_Left,
     121             :     &SwRect::_Top,
     122             :     &SwRect::_Bottom,
     123             :     &SwRect::_Height,
     124             :     &SwRect::_Width,
     125             : 
     126             :     &SwRect::AddRight,
     127             :     &SwRect::SubLeft,
     128             :     &SwRect::SubTop,
     129             :     &SwRect::AddBottom,
     130             :     &SwRect::AddHeight,
     131             :     &SwRect::AddWidth,
     132             : 
     133             :     &SwRect::SetPosY,
     134             :     &SwRect::SetPosX,
     135             : 
     136             :     &SwFrm::GetRightMargin,
     137             :     &SwFrm::GetLeftMargin,
     138             :     &SwFrm::GetTopMargin,
     139             :     &SwFrm::GetBottomMargin,
     140             :     &SwFrm::SetTopBottomMargins,
     141             :     &SwFrm::SetRightLeftMargins,
     142             :     &SwFrm::GetPrtRight,
     143             :     &SwFrm::GetPrtLeft,
     144             :     &SwFrm::GetPrtTop,
     145             :     &SwFrm::GetPrtBottom,
     146             :     &SwRect::GetRightDistance,
     147             :     &SwRect::GetLeftDistance,
     148             :     &SwRect::GetTopDistance,
     149             :     &SwRect::GetBottomDistance,
     150             :     &SwFrm::SetMinLeft,
     151             :     &SwRect::OverStepLeft,
     152             : 
     153             :     &SwRect::SetUpperRightCorner,
     154             :     &SwFrm::MakeLeftPos,
     155             :     &FirstMinusSecond,
     156             :     &SecondMinusFirst,
     157             :     &SwIncrement,
     158             :     &SwDecrement,
     159             :     &SwRect::SetTopAndHeight,
     160             :     &SwRect::SetRightAndWidth
     161             : };
     162             : 
     163             : static SwRectFnCollection aBottomToTop = {
     164             :     /* fnRectGet      */
     165             :     &SwRect::_Bottom,
     166             :     &SwRect::_Top,
     167             :     &SwRect::_Left,
     168             :     &SwRect::_Right,
     169             :     &SwRect::_Width,
     170             :     &SwRect::_Height,
     171             :     &SwRect::BottomLeft,
     172             :     &SwRect::_Size,
     173             :     /* fnRectSet      */
     174             :     &SwRect::_Bottom,
     175             :     &SwRect::_Top,
     176             :     &SwRect::_Left,
     177             :     &SwRect::_Right,
     178             :     &SwRect::_Width,
     179             :     &SwRect::_Height,
     180             : 
     181             :     &SwRect::AddBottom,
     182             :     &SwRect::SubTop,
     183             :     &SwRect::SubLeft,
     184             :     &SwRect::AddRight,
     185             :     &SwRect::AddWidth,
     186             :     &SwRect::AddHeight,
     187             : 
     188             :     &SwRect::SetPosX,
     189             :     &SwRect::SetPosY,
     190             : 
     191             :     &SwFrm::GetBottomMargin,
     192             :     &SwFrm::GetTopMargin,
     193             :     &SwFrm::GetLeftMargin,
     194             :     &SwFrm::GetRightMargin,
     195             :     &SwFrm::SetLeftRightMargins,
     196             :     &SwFrm::SetBottomTopMargins,
     197             :     &SwFrm::GetPrtBottom,
     198             :     &SwFrm::GetPrtTop,
     199             :     &SwFrm::GetPrtLeft,
     200             :     &SwFrm::GetPrtRight,
     201             :     &SwRect::GetBottomDistance,
     202             :     &SwRect::GetTopDistance,
     203             :     &SwRect::GetLeftDistance,
     204             :     &SwRect::GetRightDistance,
     205             :     &SwFrm::SetMinTop,
     206             :     &SwRect::OverStepTop,
     207             : 
     208             :     &SwRect::SetLowerLeftCorner,
     209             :     &SwFrm::MakeUpperPos,
     210             :     &FirstMinusSecond,
     211             :     &SecondMinusFirst,
     212             :     &SwIncrement,
     213             :     &SwDecrement,
     214             :     &SwRect::SetLeftAndWidth,
     215             :     &SwRect::SetBottomAndHeight
     216             : };
     217             : 
     218             : static SwRectFnCollection aVerticalRightToLeft = {
     219             :     /* fnRectGet      */
     220             :     &SwRect::_Left,
     221             :     &SwRect::_Right,
     222             :     &SwRect::_Top,
     223             :     &SwRect::_Bottom,
     224             :     &SwRect::_Height,
     225             :     &SwRect::_Width,
     226             :     &SwRect::BottomRight,
     227             :     &SwRect::SwappedSize,
     228             :     /* fnRectSet      */
     229             :     &SwRect::_Left,
     230             :     &SwRect::_Right,
     231             :     &SwRect::_Top,
     232             :     &SwRect::_Bottom,
     233             :     &SwRect::_Height,
     234             :     &SwRect::_Width,
     235             : 
     236             :     &SwRect::SubLeft,
     237             :     &SwRect::AddRight,
     238             :     &SwRect::SubTop,
     239             :     &SwRect::AddBottom,
     240             :     &SwRect::AddHeight,
     241             :     &SwRect::AddWidth,
     242             : 
     243             :     &SwRect::SetPosY,
     244             :     &SwRect::SetPosX,
     245             : 
     246             :     &SwFrm::GetLeftMargin,
     247             :     &SwFrm::GetRightMargin,
     248             :     &SwFrm::GetTopMargin,
     249             :     &SwFrm::GetBottomMargin,
     250             :     &SwFrm::SetTopBottomMargins,
     251             :     &SwFrm::SetLeftRightMargins,
     252             :     &SwFrm::GetPrtLeft,
     253             :     &SwFrm::GetPrtRight,
     254             :     &SwFrm::GetPrtBottom,
     255             :     &SwFrm::GetPrtTop,
     256             :     &SwRect::GetLeftDistance,
     257             :     &SwRect::GetRightDistance,
     258             :     &SwRect::GetBottomDistance,
     259             :     &SwRect::GetTopDistance,
     260             :     &SwFrm::SetMaxRight,
     261             :     &SwRect::OverStepRight,
     262             : 
     263             :     &SwRect::SetLowerLeftCorner,
     264             :     &SwFrm::MakeRightPos,
     265             :     &FirstMinusSecond,
     266             :     &FirstMinusSecond,
     267             :     &SwDecrement,
     268             :     &SwIncrement,
     269             :     &SwRect::SetBottomAndHeight,
     270             :     &SwRect::SetLeftAndWidth
     271             : };
     272             : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     273             : static SwRectFnCollection aVerticalLeftToRight = {
     274             :     /* fnRectGet      */
     275             :     &SwRect::_Left,
     276             :     &SwRect::_Right,
     277             :     &SwRect::_Top,
     278             :     &SwRect::_Bottom,
     279             :     &SwRect::_Height,
     280             :     &SwRect::_Width,
     281             :     &SwRect::TopLeft,
     282             :     &SwRect::SwappedSize,
     283             :     /* fnRectSet      */
     284             :     &SwRect::_Left,
     285             :     &SwRect::_Right,
     286             :     &SwRect::_Top,
     287             :     &SwRect::_Bottom,
     288             :     &SwRect::_Height,
     289             :     &SwRect::_Width,
     290             : 
     291             :     &SwRect::SubLeft,
     292             :     &SwRect::AddRight,
     293             :     &SwRect::SubTop,
     294             :     &SwRect::AddBottom,
     295             :     &SwRect::AddHeight,
     296             :     &SwRect::AddWidth,
     297             : 
     298             :     &SwRect::SetPosY,
     299             :     &SwRect::SetPosX,
     300             : 
     301             :     &SwFrm::GetLeftMargin,
     302             :     &SwFrm::GetRightMargin,
     303             :     &SwFrm::GetTopMargin,
     304             :     &SwFrm::GetBottomMargin,
     305             :     &SwFrm::SetTopBottomMargins,
     306             :     &SwFrm::SetLeftRightMargins,
     307             :     &SwFrm::GetPrtLeft,
     308             :     &SwFrm::GetPrtRight,
     309             :     &SwFrm::GetPrtTop,
     310             :     &SwFrm::GetPrtBottom,
     311             :     &SwRect::GetLeftDistance,
     312             :     &SwRect::GetRightDistance,
     313             :     &SwRect::GetTopDistance,
     314             :     &SwRect::GetBottomDistance,
     315             :     &SwFrm::SetMaxRight,
     316             :     &SwRect::OverStepRight,
     317             : 
     318             :     &SwRect::SetUpperLeftCorner,
     319             :     &SwFrm::MakeRightPos,
     320             :     &FirstMinusSecond,
     321             :     &FirstMinusSecond,
     322             :     &SwIncrement,
     323             :     &SwIncrement,
     324             :     &SwRect::SetTopAndHeight,
     325             :     &SwRect::SetLeftAndWidth
     326             : };
     327             : //End of SCMS
     328             : SwRectFn fnRectHori = &aHorizontal;
     329             : SwRectFn fnRectVert = &aVertical;
     330             : //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
     331             : SwRectFn fnRectVertL2R = &aVerticalLeftToRight;
     332             : //End of SCMS
     333             : SwRectFn fnRectB2T = &aBottomToTop;
     334             : SwRectFn fnRectVL2R = &aVerticalRightToLeft;
     335             : 
     336             : // #i65250#
     337             : sal_uInt32 SwFrm::mnLastFrmId=0;
     338             : 
     339     2719052 : TYPEINIT1(SwFrm,SwClient);      //rtti for SwFrm
     340     1801861 : TYPEINIT1(SwCntntFrm,SwFrm);    //rtti for SwCntntFrm
     341             : 
     342          37 : void _FrmInit()
     343             : {
     344          37 :     SwRootFrm::pVout = new SwLayVout();
     345             :     SwCache *pNew = new SwCache( 100
     346             : #ifdef DBG_UTIL
     347             :     , "static SwBorderAttrs::pCache"
     348             : #endif
     349          37 :     );
     350          37 :     SwFrm::SetCache( pNew );
     351          37 : }
     352             : 
     353          37 : void _FrmFinit()
     354             : {
     355             : #if OSL_DEBUG_LEVEL > 0
     356             :     // The cache may only contain null pointers at this time.
     357             :     for( sal_uInt16 n = SwFrm::GetCachePtr()->size(); n; )
     358             :         if( (*SwFrm::GetCachePtr())[ --n ] )
     359             :         {
     360             :             SwCacheObj* pObj = (*SwFrm::GetCachePtr())[ n ];
     361             :             OSL_ENSURE( !pObj, "Who didn't deregister?");
     362             :         }
     363             : #endif
     364          37 :     delete SwRootFrm::pVout;
     365          37 :     delete SwFrm::GetCachePtr();
     366          37 : }
     367             : 
     368             : // RootFrm::Everything that belongs to CurrShell
     369             : 
     370        3463 : class SwCurrShells : public std::set<CurrShell*> {};
     371             : 
     372      254276 : CurrShell::CurrShell( SwViewShell *pNew )
     373             : {
     374             :     OSL_ENSURE( pNew, "insert 0-Shell?" );
     375      254276 :     pRoot = pNew->GetLayout();
     376      254276 :     if ( pRoot )
     377             :     {
     378      254276 :         pPrev = pRoot->pCurrShell;
     379      254276 :         pRoot->pCurrShell = pNew;
     380      254276 :         pRoot->pCurrShells->insert( this );
     381             :     }
     382             :     else
     383           0 :         pPrev = 0;
     384      254276 : }
     385             : 
     386      254276 : CurrShell::~CurrShell()
     387             : {
     388      254276 :     if ( pRoot )
     389             :     {
     390      254276 :         pRoot->pCurrShells->erase( this );
     391      254276 :         if ( pPrev )
     392      254276 :             pRoot->pCurrShell = pPrev;
     393      254276 :         if ( pRoot->pCurrShells->empty() && pRoot->pWaitingCurrShell )
     394             :         {
     395           0 :             pRoot->pCurrShell = pRoot->pWaitingCurrShell;
     396           0 :             pRoot->pWaitingCurrShell = 0;
     397             :         }
     398             :     }
     399      254276 : }
     400             : 
     401        1714 : void SetShell( SwViewShell *pSh )
     402             : {
     403        1714 :     SwRootFrm *pRoot = pSh->GetLayout();
     404        1714 :     if ( pRoot->pCurrShells->empty() )
     405        1714 :         pRoot->pCurrShell = pSh;
     406             :     else
     407           0 :         pRoot->pWaitingCurrShell = pSh;
     408        1714 : }
     409             : 
     410        1751 : void SwRootFrm::DeRegisterShell( SwViewShell *pSh )
     411             : {
     412             :     // Activate some shell if possible
     413        1751 :     if ( pCurrShell == pSh )
     414        1731 :         pCurrShell = pSh->GetNext() != pSh ? (SwViewShell*)pSh->GetNext() : 0;
     415             : 
     416             :     // Doesn't matter anymore
     417        1751 :     if ( pWaitingCurrShell == pSh )
     418           0 :         pWaitingCurrShell = 0;
     419             : 
     420             :     // Remove references
     421        1751 :     for ( SwCurrShells::iterator it = pCurrShells->begin(); it != pCurrShells->end(); ++it )
     422             :     {
     423           0 :         CurrShell *pC = *it;
     424           0 :         if (pC->pPrev == pSh)
     425           0 :             pC->pPrev = 0;
     426             :     }
     427        1751 : }
     428             : 
     429        1732 : void InitCurrShells( SwRootFrm *pRoot )
     430             : {
     431        1732 :     pRoot->pCurrShells = new SwCurrShells;
     432        1732 : }
     433             : 
     434             : /*
     435             : |*      The RootFrm requests an own FrmFmt from the document, which it is
     436             : |*      going to delete again in the dtor. The own FrmFmt is derived from
     437             : |*      the passed FrmFmt.
     438             : |*/
     439        1732 : SwRootFrm::SwRootFrm( SwFrmFmt *pFmt, SwViewShell * pSh ) :
     440             :     SwLayoutFrm( pFmt->GetDoc()->MakeFrmFmt(
     441             :         OUString("Root"), pFmt ), 0 ),
     442             :     maPagesArea(),
     443             :     mnViewWidth( -1 ),
     444             :     mnColumns( 0 ),
     445             :     mbBookMode( false ),
     446             :     mbSidebarChanged( false ),
     447             :     mbNeedGrammarCheck( false ),
     448             :     bCheckSuperfluous( false ),
     449             :     bIdleFormat( true ),
     450             :     bBrowseWidthValid( false ),
     451             :     bTurboAllowed( true ),
     452             :     bAssertFlyPages( true ),
     453             :     bIsVirtPageNum( false ),
     454             :     bIsNewLayout( true ),
     455             :     bCallbackActionEnabled ( false ),
     456             :     bLayoutFreezed ( false ),
     457             :     nBrowseWidth( MM50*4 ), //2cm minimum
     458             :     pTurbo( 0 ),
     459             :     pLastPage( 0 ),
     460             :     pCurrShell( pSh ),
     461             :     pWaitingCurrShell( 0 ),
     462             :     pCurrShells(NULL),
     463             :     pDrawPage( 0 ),
     464             :     pDestroy( 0 ),
     465             :     nPhyPageNums( 0 ),
     466        1732 :     nAccessibleShells( 0 )
     467             : {
     468        1732 :     mnType = FRMC_ROOT;
     469        1732 :     setRootFrm( this );
     470        1732 : }
     471             : 
     472        1732 : void SwRootFrm::Init( SwFrmFmt* pFmt )
     473             : {
     474        1732 :     InitCurrShells( this );
     475             : 
     476        1732 :     IDocumentTimerAccess *pTimerAccess = pFmt->getIDocumentTimerAccess();
     477        1732 :     IDocumentLayoutAccess *pLayoutAccess = pFmt->getIDocumentLayoutAccess();
     478        1732 :     IDocumentFieldsAccess *pFieldsAccess = pFmt->getIDocumentFieldsAccess();
     479        1732 :     const IDocumentSettingAccess *pSettingAccess = pFmt->getIDocumentSettingAccess();
     480        1732 :     pTimerAccess->StopIdling();
     481             :     // For creating the Flys by MakeFrms()
     482        1732 :     pLayoutAccess->SetCurrentViewShell( this->GetCurrShell() );
     483        1732 :     bCallbackActionEnabled = sal_False; // needs to be set to sal_True before leaving!
     484             : 
     485        1732 :     SdrModel *pMd = pFmt->getIDocumentDrawModelAccess()->GetDrawModel();
     486        1732 :     if ( pMd )
     487             :     {
     488             :         // Disable "multiple layout"
     489        1317 :         pDrawPage = pMd->GetPage(0);
     490             : 
     491        1317 :         pDrawPage->SetSize( Frm().SSize() );
     492             :     }
     493             : 
     494             :     // Initialize the layout: create pages, link content with Cntnt etc.
     495             :     // First, initialize some stuff, then get hold of the first
     496             :     // node (which will be needed for the PageDesc).
     497             : 
     498        1732 :     SwDoc* pDoc = pFmt->GetDoc();
     499        1732 :     SwNodeIndex aIndex( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
     500        1732 :     SwCntntNode *pNode = pDoc->GetNodes().GoNextSection( &aIndex, true, false );
     501             :     // #123067# pNode = 0 can really happen
     502        1732 :     SwTableNode *pTblNd= pNode ? pNode->FindTableNode() : 0;
     503             : 
     504             :     // Get hold of PageDesc (either via FrmFmt of the first node or the initial one).
     505        1732 :     SwPageDesc *pDesc = 0;
     506        3464 :     ::boost::optional<sal_uInt16> oPgNum;
     507             : 
     508        1732 :     if ( pTblNd )
     509             :     {
     510         135 :         const SwFmtPageDesc &rDesc = pTblNd->GetTable().GetFrmFmt()->GetPageDesc();
     511         135 :         pDesc = (SwPageDesc*)rDesc.GetPageDesc();
     512             :         //#19104# respect the page number offset!!
     513         135 :         oPgNum = rDesc.GetNumOffset();
     514         135 :         if (oPgNum)
     515           0 :             bIsVirtPageNum = true;
     516             :     }
     517        1597 :     else if ( pNode )
     518             :     {
     519        1596 :         const SwFmtPageDesc &rDesc = pNode->GetSwAttrSet().GetPageDesc();
     520        1596 :         pDesc = (SwPageDesc*)rDesc.GetPageDesc();
     521             :         //#19104# respect the page number offset!!
     522        1596 :         oPgNum = rDesc.GetNumOffset();
     523        1596 :         if (oPgNum)
     524          67 :             bIsVirtPageNum = true;
     525             :     }
     526             :     else
     527           1 :         bIsVirtPageNum = sal_False;
     528        1732 :     if ( !pDesc )
     529         497 :         pDesc = &pDoc->GetPageDesc( 0 );
     530        1732 :     const bool bOdd = !oPgNum || 0 != ( oPgNum.get() % 2 );
     531        1732 :     bool bFirst = !oPgNum || 1 == oPgNum.get();
     532             : 
     533             :     // Create a page and put it in the layout
     534        1732 :     SwPageFrm *pPage = ::InsertNewPage( *pDesc, this, bOdd, bFirst, false, sal_False, 0 );
     535             : 
     536             :     // Find the first page in the Bodytext section.
     537        1732 :     SwLayoutFrm *pLay = pPage->FindBodyCont();
     538        3472 :     while( pLay->Lower() )
     539           8 :         pLay = (SwLayoutFrm*)pLay->Lower();
     540             : 
     541        3464 :     SwNodeIndex aTmp( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
     542        1732 :     ::_InsertCnt( pLay, pDoc, aTmp.GetIndex(), sal_True );
     543             :     //Remove masters that haven't been replaced yet from the list.
     544        1732 :     RemoveMasterObjs( pDrawPage );
     545        1732 :     if( pSettingAccess->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) )
     546           0 :         pFieldsAccess->UpdateRefFlds( NULL );
     547             :     //b6433357: Update page fields after loading
     548        1732 :     if ( !pCurrShell || !pCurrShell->Imp()->IsUpdateExpFlds() )
     549             :     {
     550        1732 :         SwDocPosUpdate aMsgHnt( pPage->Frm().Top() );
     551        1732 :         pFieldsAccess->UpdatePageFlds( &aMsgHnt );
     552             :     }
     553             : 
     554        1732 :     pTimerAccess->StartIdling();
     555        1732 :     bCallbackActionEnabled = sal_True;
     556             : 
     557        1732 :     SwViewShell *pViewSh  = GetCurrShell();
     558        1732 :     if (pViewSh)
     559        3464 :         mbNeedGrammarCheck = pViewSh->GetViewOptions()->IsOnlineSpell();
     560        1732 : }
     561             : 
     562        5193 : SwRootFrm::~SwRootFrm()
     563             : {
     564        1731 :     bTurboAllowed = sal_False;
     565        1731 :     pTurbo = 0;
     566             :     // fdo#39510 crash on document close with footnotes
     567             :     // Object ownership in writer and esp. in layout are a mess: Before the
     568             :     // document/layout split SwDoc and SwRootFrm were essentially one object
     569             :     // and magically/uncleanly worked around their common destruction by call
     570             :     // to SwDoc::IsInDtor() -- even from the layout. As of now destuction of
     571             :     // the layout proceeds forward through the frames. Since SwTxtFtn::DelFrms
     572             :     // also searches backwards to find the master of footnotes, they must be
     573             :     // considered to be owned by the SwRootFrm and also be destroyed here,
     574             :     // before tearing down the (now footnote free) rest of the layout.
     575        1731 :     RemoveFtns(0, false, true);
     576             : 
     577        1731 :     if(pBlink)
     578          36 :         pBlink->FrmDelete( this );
     579        1731 :     SwFrmFmt *pRegisteredInNonConst = static_cast<SwFrmFmt*>(GetRegisteredInNonConst());
     580        1731 :     if ( pRegisteredInNonConst )
     581             :     {
     582        1731 :         SwDoc *pDoc = pRegisteredInNonConst->GetDoc();
     583        1731 :         pDoc->DelFrmFmt( pRegisteredInNonConst );
     584        1731 :         pDoc->ClearSwLayouterEntries();
     585             :     }
     586        1731 :     delete pDestroy;
     587        1731 :     pDestroy = 0;
     588             : 
     589             :     // Remove references
     590        1731 :     for ( SwCurrShells::iterator it = pCurrShells->begin(); it != pCurrShells->end(); ++it )
     591           0 :         (*it)->pRoot = 0;
     592             : 
     593        1731 :     delete pCurrShells;
     594        1731 :     pCurrShells = 0;
     595             : 
     596             :     // Some accessible shells are left => problems on second SwFrm::Destroy call
     597             :     assert(0 == nAccessibleShells);
     598             : 
     599             :     // manually call base classes Destroy because it could call stuff
     600             :     // that accesses members of this
     601        1731 :     SwLayoutFrm::Destroy();
     602        1731 :     SwFrm::Destroy();
     603        3462 : }
     604             : 
     605        1732 : void SwRootFrm::RemoveMasterObjs( SdrPage *pPg )
     606             : {
     607             :     // Remove all master objects from the Page. But don't delete!
     608        4922 :     for( sal_uLong i = pPg ? pPg->GetObjCount() : 0; i; )
     609             :     {
     610        1458 :         SdrObject* pObj = pPg->GetObj( --i );
     611        1458 :         if( pObj->ISA(SwFlyDrawObj ) )
     612         182 :             pPg->RemoveObject( i );
     613             :     }
     614        1732 : }
     615             : 
     616          24 : void SwRootFrm::AllCheckPageDescs() const
     617             : {
     618          24 :     if ( !IsLayoutFreezed() )
     619          24 :         CheckPageDescs( (SwPageFrm*)this->Lower() );
     620          24 : }
     621             : 
     622           0 : void SwRootFrm::AllInvalidateAutoCompleteWords() const
     623             : {
     624           0 :     SwPageFrm *pPage = (SwPageFrm*)this->Lower();
     625           0 :     while ( pPage )
     626             :     {
     627           0 :         pPage->InvalidateAutoCompleteWords();
     628           0 :         pPage = (SwPageFrm*)pPage->GetNext();
     629             :     }
     630           0 : }
     631             : 
     632           0 : void SwRootFrm::AllAddPaintRect() const
     633             : {
     634           0 :     GetCurrShell()->AddPaintRect( this->Frm() );
     635           0 : }
     636             : 
     637           1 : void SwRootFrm::AllRemoveFtns()
     638             : {
     639           1 :     RemoveFtns();
     640           1 : }
     641             : 
     642           5 : void SwRootFrm::AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const
     643             : {
     644           5 :     SwPageFrm *pPage = (SwPageFrm*)this->Lower();
     645          15 :     while ( pPage )
     646             :     {
     647           5 :         if ( bSmartTags )
     648           4 :             pPage->InvalidateSmartTags();
     649             : 
     650           5 :         pPage->InvalidateSpelling();
     651           5 :         pPage = (SwPageFrm*)pPage->GetNext();
     652             :     }
     653           5 : }
     654             : 
     655             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10