LCOV - code coverage report
Current view: top level - sw/source/core/layout - newfrm.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 150 170 88.2 %
Date: 2015-06-13 12:38:46 Functions: 29 36 80.6 %
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 <drawdoc.hxx>
      23             : #include <fmtpdsc.hxx>
      24             : #include <swtable.hxx>
      25             : #include <rootfrm.hxx>
      26             : #include <pagefrm.hxx>
      27             : #include <dflyobj.hxx>
      28             : #include <frmtool.hxx>
      29             : #include <virtoutp.hxx>
      30             : #include <blink.hxx>
      31             : #include <sectfrm.hxx>
      32             : #include <notxtfrm.hxx>
      33             : #include <pagedesc.hxx>
      34             : #include "viewimp.hxx"
      35             : #include <hints.hxx>
      36             : #include <viewopt.hxx>
      37             : #include <set>
      38             : #include <IDocumentSettingAccess.hxx>
      39             : #include <IDocumentFieldsAccess.hxx>
      40             : #include <DocumentLayoutManager.hxx>
      41             : 
      42             : SwLayVout     *SwRootFrm::mpVout = 0;
      43             : bool           SwRootFrm::mbInPaint = false;
      44             : bool           SwRootFrm::mbNoVirDev = false;
      45             : 
      46             : SwCache *SwFrm::mpCache = 0;
      47             : 
      48      775544 : long FirstMinusSecond( long nFirst, long nSecond )
      49      775544 :     { return nFirst - nSecond; }
      50          12 : long SecondMinusFirst( long nFirst, long nSecond )
      51          12 :     { return nSecond - nFirst; }
      52       71633 : long SwIncrement( long nA, long nAdd )
      53       71633 :     { return nA + nAdd; }
      54          14 : long SwDecrement( long nA, long nSub )
      55          14 :     { return nA - nSub; }
      56             : 
      57             : static SwRectFnCollection aHorizontal = {
      58             :     /* fnRectGet      */
      59             :     &SwRect::_Top,
      60             :     &SwRect::_Bottom,
      61             :     &SwRect::_Left,
      62             :     &SwRect::_Right,
      63             :     &SwRect::_Width,
      64             :     &SwRect::_Height,
      65             :     &SwRect::TopLeft,
      66             :     &SwRect::_Size,
      67             :     /* fnRectSet      */
      68             :     &SwRect::_Top,
      69             :     &SwRect::_Bottom,
      70             :     &SwRect::_Left,
      71             :     &SwRect::_Right,
      72             :     &SwRect::_Width,
      73             :     &SwRect::_Height,
      74             : 
      75             :     &SwRect::SubTop,
      76             :     &SwRect::AddBottom,
      77             :     &SwRect::SubLeft,
      78             :     &SwRect::AddRight,
      79             :     &SwRect::AddWidth,
      80             :     &SwRect::AddHeight,
      81             : 
      82             :     &SwRect::SetPosX,
      83             :     &SwRect::SetPosY,
      84             : 
      85             :     &SwFrm::GetTopMargin,
      86             :     &SwFrm::GetBottomMargin,
      87             :     &SwFrm::GetLeftMargin,
      88             :     &SwFrm::GetRightMargin,
      89             :     &SwFrm::SetLeftRightMargins,
      90             :     &SwFrm::SetTopBottomMargins,
      91             :     &SwFrm::GetPrtTop,
      92             :     &SwFrm::GetPrtBottom,
      93             :     &SwFrm::GetPrtLeft,
      94             :     &SwFrm::GetPrtRight,
      95             :     &SwRect::GetTopDistance,
      96             :     &SwRect::GetBottomDistance,
      97             :     &SwRect::GetLeftDistance,
      98             :     &SwRect::GetRightDistance,
      99             :     &SwFrm::SetMaxBottom,
     100             :     &SwRect::OverStepBottom,
     101             : 
     102             :     &SwRect::SetUpperLeftCorner,
     103             :     &SwFrm::MakeBelowPos,
     104             :     &FirstMinusSecond,
     105             :     &FirstMinusSecond,
     106             :     &SwIncrement,
     107             :     &SwIncrement,
     108             :     &SwRect::SetLeftAndWidth,
     109             :     &SwRect::SetTopAndHeight
     110             : };
     111             : 
     112             : static SwRectFnCollection aVertical = {
     113             :     /* fnRectGet      */
     114             :     &SwRect::_Right,
     115             :     &SwRect::_Left,
     116             :     &SwRect::_Top,
     117             :     &SwRect::_Bottom,
     118             :     &SwRect::_Height,
     119             :     &SwRect::_Width,
     120             :     &SwRect::TopRight,
     121             :     &SwRect::SwappedSize,
     122             :     /* fnRectSet      */
     123             :     &SwRect::_Right,
     124             :     &SwRect::_Left,
     125             :     &SwRect::_Top,
     126             :     &SwRect::_Bottom,
     127             :     &SwRect::_Height,
     128             :     &SwRect::_Width,
     129             : 
     130             :     &SwRect::AddRight,
     131             :     &SwRect::SubLeft,
     132             :     &SwRect::SubTop,
     133             :     &SwRect::AddBottom,
     134             :     &SwRect::AddHeight,
     135             :     &SwRect::AddWidth,
     136             : 
     137             :     &SwRect::SetPosY,
     138             :     &SwRect::SetPosX,
     139             : 
     140             :     &SwFrm::GetRightMargin,
     141             :     &SwFrm::GetLeftMargin,
     142             :     &SwFrm::GetTopMargin,
     143             :     &SwFrm::GetBottomMargin,
     144             :     &SwFrm::SetTopBottomMargins,
     145             :     &SwFrm::SetRightLeftMargins,
     146             :     &SwFrm::GetPrtRight,
     147             :     &SwFrm::GetPrtLeft,
     148             :     &SwFrm::GetPrtTop,
     149             :     &SwFrm::GetPrtBottom,
     150             :     &SwRect::GetRightDistance,
     151             :     &SwRect::GetLeftDistance,
     152             :     &SwRect::GetTopDistance,
     153             :     &SwRect::GetBottomDistance,
     154             :     &SwFrm::SetMinLeft,
     155             :     &SwRect::OverStepLeft,
     156             : 
     157             :     &SwRect::SetUpperRightCorner,
     158             :     &SwFrm::MakeLeftPos,
     159             :     &FirstMinusSecond,
     160             :     &SecondMinusFirst,
     161             :     &SwIncrement,
     162             :     &SwDecrement,
     163             :     &SwRect::SetTopAndHeight,
     164             :     &SwRect::SetRightAndWidth
     165             : };
     166             : 
     167             : static SwRectFnCollection aBottomToTop = {
     168             :     /* fnRectGet      */
     169             :     &SwRect::_Bottom,
     170             :     &SwRect::_Top,
     171             :     &SwRect::_Left,
     172             :     &SwRect::_Right,
     173             :     &SwRect::_Width,
     174             :     &SwRect::_Height,
     175             :     &SwRect::BottomLeft,
     176             :     &SwRect::_Size,
     177             :     /* fnRectSet      */
     178             :     &SwRect::_Bottom,
     179             :     &SwRect::_Top,
     180             :     &SwRect::_Left,
     181             :     &SwRect::_Right,
     182             :     &SwRect::_Width,
     183             :     &SwRect::_Height,
     184             : 
     185             :     &SwRect::AddBottom,
     186             :     &SwRect::SubTop,
     187             :     &SwRect::SubLeft,
     188             :     &SwRect::AddRight,
     189             :     &SwRect::AddWidth,
     190             :     &SwRect::AddHeight,
     191             : 
     192             :     &SwRect::SetPosX,
     193             :     &SwRect::SetPosY,
     194             : 
     195             :     &SwFrm::GetBottomMargin,
     196             :     &SwFrm::GetTopMargin,
     197             :     &SwFrm::GetLeftMargin,
     198             :     &SwFrm::GetRightMargin,
     199             :     &SwFrm::SetLeftRightMargins,
     200             :     &SwFrm::SetBottomTopMargins,
     201             :     &SwFrm::GetPrtBottom,
     202             :     &SwFrm::GetPrtTop,
     203             :     &SwFrm::GetPrtLeft,
     204             :     &SwFrm::GetPrtRight,
     205             :     &SwRect::GetBottomDistance,
     206             :     &SwRect::GetTopDistance,
     207             :     &SwRect::GetLeftDistance,
     208             :     &SwRect::GetRightDistance,
     209             :     &SwFrm::SetMinTop,
     210             :     &SwRect::OverStepTop,
     211             : 
     212             :     &SwRect::SetLowerLeftCorner,
     213             :     &SwFrm::MakeUpperPos,
     214             :     &FirstMinusSecond,
     215             :     &SecondMinusFirst,
     216             :     &SwIncrement,
     217             :     &SwDecrement,
     218             :     &SwRect::SetLeftAndWidth,
     219             :     &SwRect::SetBottomAndHeight
     220             : };
     221             : 
     222             : static SwRectFnCollection aVerticalRightToLeft = {
     223             :     /* fnRectGet      */
     224             :     &SwRect::_Left,
     225             :     &SwRect::_Right,
     226             :     &SwRect::_Top,
     227             :     &SwRect::_Bottom,
     228             :     &SwRect::_Height,
     229             :     &SwRect::_Width,
     230             :     &SwRect::BottomRight,
     231             :     &SwRect::SwappedSize,
     232             :     /* fnRectSet      */
     233             :     &SwRect::_Left,
     234             :     &SwRect::_Right,
     235             :     &SwRect::_Top,
     236             :     &SwRect::_Bottom,
     237             :     &SwRect::_Height,
     238             :     &SwRect::_Width,
     239             : 
     240             :     &SwRect::SubLeft,
     241             :     &SwRect::AddRight,
     242             :     &SwRect::SubTop,
     243             :     &SwRect::AddBottom,
     244             :     &SwRect::AddHeight,
     245             :     &SwRect::AddWidth,
     246             : 
     247             :     &SwRect::SetPosY,
     248             :     &SwRect::SetPosX,
     249             : 
     250             :     &SwFrm::GetLeftMargin,
     251             :     &SwFrm::GetRightMargin,
     252             :     &SwFrm::GetTopMargin,
     253             :     &SwFrm::GetBottomMargin,
     254             :     &SwFrm::SetTopBottomMargins,
     255             :     &SwFrm::SetLeftRightMargins,
     256             :     &SwFrm::GetPrtLeft,
     257             :     &SwFrm::GetPrtRight,
     258             :     &SwFrm::GetPrtBottom,
     259             :     &SwFrm::GetPrtTop,
     260             :     &SwRect::GetLeftDistance,
     261             :     &SwRect::GetRightDistance,
     262             :     &SwRect::GetBottomDistance,
     263             :     &SwRect::GetTopDistance,
     264             :     &SwFrm::SetMaxRight,
     265             :     &SwRect::OverStepRight,
     266             : 
     267             :     &SwRect::SetLowerLeftCorner,
     268             :     &SwFrm::MakeRightPos,
     269             :     &FirstMinusSecond,
     270             :     &FirstMinusSecond,
     271             :     &SwDecrement,
     272             :     &SwIncrement,
     273             :     &SwRect::SetBottomAndHeight,
     274             :     &SwRect::SetLeftAndWidth
     275             : };
     276             : 
     277             : static SwRectFnCollection aVerticalLeftToRight = {
     278             :     /* fnRectGet      */
     279             :     &SwRect::_Left,
     280             :     &SwRect::_Right,
     281             :     &SwRect::_Top,
     282             :     &SwRect::_Bottom,
     283             :     &SwRect::_Height,
     284             :     &SwRect::_Width,
     285             :     &SwRect::TopLeft,
     286             :     &SwRect::SwappedSize,
     287             :     /* fnRectSet      */
     288             :     &SwRect::_Left,
     289             :     &SwRect::_Right,
     290             :     &SwRect::_Top,
     291             :     &SwRect::_Bottom,
     292             :     &SwRect::_Height,
     293             :     &SwRect::_Width,
     294             : 
     295             :     &SwRect::SubLeft,
     296             :     &SwRect::AddRight,
     297             :     &SwRect::SubTop,
     298             :     &SwRect::AddBottom,
     299             :     &SwRect::AddHeight,
     300             :     &SwRect::AddWidth,
     301             : 
     302             :     &SwRect::SetPosY,
     303             :     &SwRect::SetPosX,
     304             : 
     305             :     &SwFrm::GetLeftMargin,
     306             :     &SwFrm::GetRightMargin,
     307             :     &SwFrm::GetTopMargin,
     308             :     &SwFrm::GetBottomMargin,
     309             :     &SwFrm::SetTopBottomMargins,
     310             :     &SwFrm::SetLeftRightMargins,
     311             :     &SwFrm::GetPrtLeft,
     312             :     &SwFrm::GetPrtRight,
     313             :     &SwFrm::GetPrtTop,
     314             :     &SwFrm::GetPrtBottom,
     315             :     &SwRect::GetLeftDistance,
     316             :     &SwRect::GetRightDistance,
     317             :     &SwRect::GetTopDistance,
     318             :     &SwRect::GetBottomDistance,
     319             :     &SwFrm::SetMaxRight,
     320             :     &SwRect::OverStepRight,
     321             : 
     322             :     &SwRect::SetUpperLeftCorner,
     323             :     &SwFrm::MakeRightPos,
     324             :     &FirstMinusSecond,
     325             :     &FirstMinusSecond,
     326             :     &SwIncrement,
     327             :     &SwIncrement,
     328             :     &SwRect::SetTopAndHeight,
     329             :     &SwRect::SetLeftAndWidth
     330             : };
     331             : 
     332             : SwRectFn fnRectHori = &aHorizontal;
     333             : SwRectFn fnRectVert = &aVertical;
     334             : 
     335             : SwRectFn fnRectVertL2R = &aVerticalLeftToRight;
     336             : 
     337             : SwRectFn fnRectB2T = &aBottomToTop;
     338             : SwRectFn fnRectVL2R = &aVerticalRightToLeft;
     339             : 
     340             : // #i65250#
     341             : sal_uInt32 SwFrm::mnLastFrmId=0;
     342             : 
     343     2227679 : TYPEINIT1(SwFrm,SwClient);      //rtti for SwFrm
     344     1383828 : TYPEINIT1(SwContentFrm,SwFrm);    //rtti for SwContentFrm
     345             : 
     346          59 : void _FrmInit()
     347             : {
     348          59 :     SwRootFrm::mpVout = new SwLayVout();
     349             :     SwCache *pNew = new SwCache( 100
     350             : #ifdef DBG_UTIL
     351             :     , "static SwBorderAttrs::pCache"
     352             : #endif
     353          59 :     );
     354          59 :     SwFrm::SetCache( pNew );
     355          59 : }
     356             : 
     357          59 : void _FrmFinit()
     358             : {
     359             : #if OSL_DEBUG_LEVEL > 0
     360             :     // The cache may only contain null pointers at this time.
     361             :     for( size_t n = SwFrm::GetCachePtr()->size(); n; )
     362             :         if( (*SwFrm::GetCachePtr())[ --n ] )
     363             :         {
     364             :             SwCacheObj* pObj = (*SwFrm::GetCachePtr())[ n ];
     365             :             OSL_ENSURE( !pObj, "Who didn't deregister?");
     366             :         }
     367             : #endif
     368          59 :     delete SwRootFrm::mpVout;
     369          59 :     delete SwFrm::GetCachePtr();
     370          59 : }
     371             : 
     372             : // RootFrm::Everything that belongs to CurrShell
     373             : 
     374        6080 : class SwCurrShells : public std::set<CurrShell*> {};
     375             : 
     376    27199698 : CurrShell::CurrShell( SwViewShell *pNew )
     377             : {
     378             :     OSL_ENSURE( pNew, "insert 0-Shell?" );
     379    27199698 :     pRoot = pNew->GetLayout();
     380    27199698 :     if ( pRoot )
     381             :     {
     382    27199697 :         pPrev = pRoot->mpCurrShell;
     383    27199697 :         pRoot->mpCurrShell = pNew;
     384    27199697 :         pRoot->mpCurrShells->insert( this );
     385             :     }
     386             :     else
     387           1 :         pPrev = 0;
     388    27199698 : }
     389             : 
     390    27199698 : CurrShell::~CurrShell()
     391             : {
     392    27199698 :     if ( pRoot )
     393             :     {
     394    27199697 :         pRoot->mpCurrShells->erase( this );
     395    27199697 :         if ( pPrev )
     396    27199697 :             pRoot->mpCurrShell = pPrev;
     397    27199697 :         if ( pRoot->mpCurrShells->empty() && pRoot->mpWaitingCurrShell )
     398             :         {
     399           0 :             pRoot->mpCurrShell = pRoot->mpWaitingCurrShell;
     400           0 :             pRoot->mpWaitingCurrShell = 0;
     401             :         }
     402             :     }
     403    27199698 : }
     404             : 
     405        2673 : void SetShell( SwViewShell *pSh )
     406             : {
     407        2673 :     SwRootFrm *pRoot = pSh->GetLayout();
     408        2673 :     if ( pRoot->mpCurrShells->empty() )
     409        2673 :         pRoot->mpCurrShell = pSh;
     410             :     else
     411           0 :         pRoot->mpWaitingCurrShell = pSh;
     412        2673 : }
     413             : 
     414        3105 : void SwRootFrm::DeRegisterShell( SwViewShell *pSh )
     415             : {
     416             :     // Activate some shell if possible
     417        3105 :     if ( mpCurrShell == pSh )
     418             :     {
     419        3038 :         mpCurrShell = nullptr;
     420        6076 :         for(SwViewShell& rShell : pSh->GetRingContainer())
     421             :         {
     422        3038 :             if(&rShell != pSh)
     423             :             {
     424           0 :                 mpCurrShell = &rShell;
     425           0 :                 break;
     426             :             }
     427             :         }
     428             :     }
     429             : 
     430             :     // Doesn't matter anymore
     431        3105 :     if ( mpWaitingCurrShell == pSh )
     432           0 :         mpWaitingCurrShell = 0;
     433             : 
     434             :     // Remove references
     435        3105 :     for ( SwCurrShells::iterator it = mpCurrShells->begin(); it != mpCurrShells->end(); ++it )
     436             :     {
     437           0 :         CurrShell *pC = *it;
     438           0 :         if (pC->pPrev == pSh)
     439           0 :             pC->pPrev = 0;
     440             :     }
     441        3105 : }
     442             : 
     443        3042 : void InitCurrShells( SwRootFrm *pRoot )
     444             : {
     445        3042 :     pRoot->mpCurrShells = new SwCurrShells;
     446        3042 : }
     447             : 
     448             : /*
     449             : |*      The RootFrm requests an own FrameFormat from the document, which it is
     450             : |*      going to delete again in the dtor. The own FrameFormat is derived from
     451             : |*      the passed FrameFormat.
     452             : |*/
     453        3042 : SwRootFrm::SwRootFrm( SwFrameFormat *pFormat, SwViewShell * pSh ) :
     454             :     SwLayoutFrm( pFormat->GetDoc()->MakeFrameFormat(
     455             :         OUString("Root"), pFormat ), 0 ),
     456             :     maPagesArea(),
     457             :     mnViewWidth( -1 ),
     458             :     mnColumns( 0 ),
     459             :     mbBookMode( false ),
     460             :     mbSidebarChanged( false ),
     461             :     mbNeedGrammarCheck( false ),
     462             :     mbCheckSuperfluous( false ),
     463             :     mbIdleFormat( true ),
     464             :     mbBrowseWidthValid( false ),
     465             :     mbTurboAllowed( true ),
     466             :     mbAssertFlyPages( true ),
     467             :     mbIsVirtPageNum( false ),
     468             :     mbIsNewLayout( true ),
     469             :     mbCallbackActionEnabled ( false ),
     470             :     mbLayoutFreezed ( false ),
     471             :     mnBrowseWidth( MM50*4 ), //2cm minimum
     472             :     mpTurbo( 0 ),
     473             :     mpLastPage( 0 ),
     474             :     mpCurrShell( pSh ),
     475             :     mpWaitingCurrShell( 0 ),
     476             :     mpCurrShells(NULL),
     477             :     mpDrawPage( 0 ),
     478             :     mpDestroy( 0 ),
     479             :     mnPhyPageNums( 0 ),
     480        3042 :     mnAccessibleShells( 0 )
     481             : {
     482        3042 :     mnFrmType = FRM_ROOT;
     483        3042 :     setRootFrm( this );
     484        3042 : }
     485             : 
     486        3042 : void SwRootFrm::Init( SwFrameFormat* pFormat )
     487             : {
     488        3042 :     InitCurrShells( this );
     489             : 
     490        3042 :     IDocumentTimerAccess *pTimerAccess = pFormat->getIDocumentTimerAccess();
     491        3042 :     IDocumentLayoutAccess *pLayoutAccess = pFormat->getIDocumentLayoutAccess();
     492        3042 :     IDocumentFieldsAccess *pFieldsAccess = pFormat->getIDocumentFieldsAccess();
     493        3042 :     const IDocumentSettingAccess *pSettingAccess = pFormat->getIDocumentSettingAccess();
     494        3042 :     pTimerAccess->StopIdling();
     495             :     // For creating the Flys by MakeFrms()
     496        3042 :     pLayoutAccess->SetCurrentViewShell( this->GetCurrShell() );
     497        3042 :     mbCallbackActionEnabled = false; // needs to be set to true before leaving!
     498             : 
     499        3042 :     SwDrawModel* pMd = pFormat->getIDocumentDrawModelAccess()->GetDrawModel();
     500        3042 :     if ( pMd )
     501             :     {
     502             :         // Disable "multiple layout"
     503        3042 :         mpDrawPage = pMd->GetPage(0);
     504             : 
     505        3042 :         mpDrawPage->SetSize( Frm().SSize() );
     506             :     }
     507             : 
     508             :     // Initialize the layout: create pages, link content with Content etc.
     509             :     // First, initialize some stuff, then get hold of the first
     510             :     // node (which will be needed for the PageDesc).
     511             : 
     512        3042 :     SwDoc* pDoc = pFormat->GetDoc();
     513        3042 :     SwNodeIndex aIndex( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
     514        3042 :     SwContentNode *pNode = pDoc->GetNodes().GoNextSection( &aIndex, true, false );
     515             :     // #123067# pNode = 0 can really happen
     516        3042 :     SwTableNode *pTableNd= pNode ? pNode->FindTableNode() : 0;
     517             : 
     518             :     // Get hold of PageDesc (either via FrameFormat of the first node or the initial one).
     519        3042 :     SwPageDesc *pDesc = 0;
     520        6084 :     ::boost::optional<sal_uInt16> oPgNum;
     521             : 
     522        3042 :     if ( pTableNd )
     523             :     {
     524         198 :         const SwFormatPageDesc &rDesc = pTableNd->GetTable().GetFrameFormat()->GetPageDesc();
     525         198 :         pDesc = const_cast<SwPageDesc*>(rDesc.GetPageDesc());
     526             :         //#19104# respect the page number offset!!
     527         198 :         oPgNum = rDesc.GetNumOffset();
     528         198 :         if (oPgNum)
     529           4 :             mbIsVirtPageNum = true;
     530             :     }
     531        2844 :     else if ( pNode )
     532             :     {
     533        2843 :         const SwFormatPageDesc &rDesc = pNode->GetSwAttrSet().GetPageDesc();
     534        2843 :         pDesc = const_cast<SwPageDesc*>(rDesc.GetPageDesc());
     535             :         //#19104# respect the page number offset!!
     536        2843 :         oPgNum = rDesc.GetNumOffset();
     537        2843 :         if (oPgNum)
     538          93 :             mbIsVirtPageNum = true;
     539             :     }
     540             :     else
     541           1 :         mbIsVirtPageNum = false;
     542        3042 :     if ( !pDesc )
     543         965 :         pDesc = &pDoc->GetPageDesc( 0 );
     544        3042 :     const bool bOdd = !oPgNum || 0 != ( oPgNum.get() % 2 );
     545        3042 :     bool bFirst = !oPgNum || 1 == oPgNum.get();
     546             : 
     547             :     // Create a page and put it in the layout
     548        3042 :     SwPageFrm *pPage = ::InsertNewPage( *pDesc, this, bOdd, bFirst, false, false, 0 );
     549             : 
     550             :     // Find the first page in the Bodytext section.
     551        3042 :     SwLayoutFrm *pLay = pPage->FindBodyCont();
     552        6102 :     while( pLay->Lower() )
     553          18 :         pLay = static_cast<SwLayoutFrm*>(pLay->Lower());
     554             : 
     555        6084 :     SwNodeIndex aTmp( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
     556        3042 :     ::_InsertCnt( pLay, pDoc, aTmp.GetIndex(), true );
     557             :     //Remove masters that haven't been replaced yet from the list.
     558        3042 :     RemoveMasterObjs( mpDrawPage );
     559        3042 :     if( pSettingAccess->get(DocumentSettingId::GLOBAL_DOCUMENT) )
     560           0 :         pFieldsAccess->UpdateRefFields( NULL );
     561             :     //b6433357: Update page fields after loading
     562        3042 :     if ( !mpCurrShell || !mpCurrShell->Imp()->IsUpdateExpFields() )
     563             :     {
     564        3042 :         SwDocPosUpdate aMsgHint( pPage->Frm().Top() );
     565        3042 :         pFieldsAccess->UpdatePageFields( &aMsgHint );
     566             :     }
     567             : 
     568        3042 :     pTimerAccess->StartIdling();
     569        3042 :     mbCallbackActionEnabled = true;
     570             : 
     571        3042 :     SwViewShell *pViewSh  = GetCurrShell();
     572        3042 :     if (pViewSh)
     573        6084 :         mbNeedGrammarCheck = pViewSh->GetViewOptions()->IsOnlineSpell();
     574        3042 : }
     575             : 
     576        3038 : void SwRootFrm::DestroyImpl()
     577             : {
     578        3038 :     mbTurboAllowed = false;
     579        3038 :     mpTurbo = 0;
     580             :     // fdo#39510 crash on document close with footnotes
     581             :     // Object ownership in writer and esp. in layout are a mess: Before the
     582             :     // document/layout split SwDoc and SwRootFrm were essentially one object
     583             :     // and magically/uncleanly worked around their common destruction by call
     584             :     // to SwDoc::IsInDtor() -- even from the layout. As of now destuction of
     585             :     // the layout proceeds forward through the frames. Since SwTextFootnote::DelFrms
     586             :     // also searches backwards to find the master of footnotes, they must be
     587             :     // considered to be owned by the SwRootFrm and also be destroyed here,
     588             :     // before tearing down the (now footnote free) rest of the layout.
     589        3038 :     RemoveFootnotes(0, false, true);
     590             : 
     591        3038 :     if(pBlink)
     592          16 :         pBlink->FrmDelete( this );
     593        3038 :     SwFrameFormat *pRegisteredInNonConst = static_cast<SwFrameFormat*>(GetRegisteredInNonConst());
     594        3038 :     if ( pRegisteredInNonConst )
     595             :     {
     596        3038 :         SwDoc *pDoc = pRegisteredInNonConst->GetDoc();
     597        3038 :         pDoc->DelFrameFormat( pRegisteredInNonConst );
     598        3038 :         pDoc->GetDocumentLayoutManager().ClearSwLayouterEntries();
     599             :     }
     600        3038 :     delete mpDestroy;
     601        3038 :     mpDestroy = 0;
     602             : 
     603             :     // Remove references
     604        3038 :     for ( SwCurrShells::iterator it = mpCurrShells->begin(); it != mpCurrShells->end(); ++it )
     605           0 :         (*it)->pRoot = 0;
     606             : 
     607        3038 :     delete mpCurrShells;
     608        3038 :     mpCurrShells = 0;
     609             : 
     610             :     // Some accessible shells are left => problems on second SwFrm::Destroy call
     611             :     assert(0 == mnAccessibleShells);
     612             : 
     613        3038 :     SwLayoutFrm::DestroyImpl();
     614        3038 : }
     615             : 
     616        6076 : SwRootFrm::~SwRootFrm()
     617             : {
     618        6076 : }
     619             : 
     620        3042 : void SwRootFrm::RemoveMasterObjs( SdrPage *pPg )
     621             : {
     622             :     // Remove all master objects from the Page. But don't delete!
     623        9015 :     for( size_t i = pPg ? pPg->GetObjCount() : 0; i; )
     624             :     {
     625        2931 :         SdrObject* pObj = pPg->GetObj( --i );
     626        2931 :         if( pObj->ISA(SwFlyDrawObj ) )
     627         197 :             pPg->RemoveObject( i );
     628             :     }
     629        3042 : }
     630             : 
     631           8 : void SwRootFrm::AllCheckPageDescs() const
     632             : {
     633           8 :     if ( !IsLayoutFreezed() )
     634           8 :         CheckPageDescs( const_cast<SwPageFrm*>(static_cast<const SwPageFrm*>(this->Lower())) );
     635           8 : }
     636             : 
     637           0 : void SwRootFrm::AllInvalidateAutoCompleteWords() const
     638             : {
     639           0 :     SwPageFrm *pPage = const_cast<SwPageFrm*>(static_cast<const SwPageFrm*>(this->Lower()));
     640           0 :     while ( pPage )
     641             :     {
     642           0 :         pPage->InvalidateAutoCompleteWords();
     643           0 :         pPage = static_cast<SwPageFrm*>(pPage->GetNext());
     644             :     }
     645           0 : }
     646             : 
     647           0 : void SwRootFrm::AllAddPaintRect() const
     648             : {
     649           0 :     GetCurrShell()->AddPaintRect( this->Frm() );
     650           0 : }
     651             : 
     652           1 : void SwRootFrm::AllRemoveFootnotes()
     653             : {
     654           1 :     RemoveFootnotes();
     655           1 : }
     656             : 
     657           5 : void SwRootFrm::AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const
     658             : {
     659           5 :     SwPageFrm *pPage = const_cast<SwPageFrm*>(static_cast<const SwPageFrm*>(this->Lower()));
     660          15 :     while ( pPage )
     661             :     {
     662           5 :         if ( bSmartTags )
     663           4 :             pPage->InvalidateSmartTags();
     664             : 
     665           5 :         pPage->InvalidateSpelling();
     666           5 :         pPage = static_cast<SwPageFrm*>(pPage->GetNext());
     667             :     }
     668         182 : }
     669             : 
     670             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11