LCOV - code coverage report
Current view: top level - sw/source/core/layout - newfrm.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 165 0.0 %
Date: 2014-04-14 Functions: 0 33 0.0 %
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           0 : long FirstMinusSecond( long nFirst, long nSecond )
      45           0 :     { return nFirst - nSecond; }
      46           0 : long SecondMinusFirst( long nFirst, long nSecond )
      47           0 :     { return nSecond - nFirst; }
      48           0 : long SwIncrement( long nA, long nAdd )
      49           0 :     { return nA + nAdd; }
      50           0 : long SwDecrement( long nA, long nSub )
      51           0 :     { 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           0 : TYPEINIT1(SwFrm,SwClient);      //rtti for SwFrm
     340           0 : TYPEINIT1(SwCntntFrm,SwFrm);    //rtti for SwCntntFrm
     341             : 
     342           0 : void _FrmInit()
     343             : {
     344           0 :     SwRootFrm::pVout = new SwLayVout();
     345             :     SwCache *pNew = new SwCache( 100
     346             : #ifdef DBG_UTIL
     347             :     , "static SwBorderAttrs::pCache"
     348             : #endif
     349           0 :     );
     350           0 :     SwFrm::SetCache( pNew );
     351           0 : }
     352             : 
     353           0 : 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           0 :     delete SwRootFrm::pVout;
     365           0 :     delete SwFrm::GetCachePtr();
     366           0 : }
     367             : 
     368             : // RootFrm::Everything that belongs to CurrShell
     369             : 
     370           0 : class SwCurrShells : public std::set<CurrShell*> {};
     371             : 
     372           0 : CurrShell::CurrShell( SwViewShell *pNew )
     373             : {
     374             :     OSL_ENSURE( pNew, "insert 0-Shell?" );
     375           0 :     pRoot = pNew->GetLayout();
     376           0 :     if ( pRoot )
     377             :     {
     378           0 :         pPrev = pRoot->pCurrShell;
     379           0 :         pRoot->pCurrShell = pNew;
     380           0 :         pRoot->pCurrShells->insert( this );
     381             :     }
     382             :     else
     383           0 :         pPrev = 0;
     384           0 : }
     385             : 
     386           0 : CurrShell::~CurrShell()
     387             : {
     388           0 :     if ( pRoot )
     389             :     {
     390           0 :         pRoot->pCurrShells->erase( this );
     391           0 :         if ( pPrev )
     392           0 :             pRoot->pCurrShell = pPrev;
     393           0 :         if ( pRoot->pCurrShells->empty() && pRoot->pWaitingCurrShell )
     394             :         {
     395           0 :             pRoot->pCurrShell = pRoot->pWaitingCurrShell;
     396           0 :             pRoot->pWaitingCurrShell = 0;
     397             :         }
     398             :     }
     399           0 : }
     400             : 
     401           0 : void SetShell( SwViewShell *pSh )
     402             : {
     403           0 :     SwRootFrm *pRoot = pSh->GetLayout();
     404           0 :     if ( pRoot->pCurrShells->empty() )
     405           0 :         pRoot->pCurrShell = pSh;
     406             :     else
     407           0 :         pRoot->pWaitingCurrShell = pSh;
     408           0 : }
     409             : 
     410           0 : void SwRootFrm::DeRegisterShell( SwViewShell *pSh )
     411             : {
     412             :     // Activate some shell if possible
     413           0 :     if ( pCurrShell == pSh )
     414           0 :         pCurrShell = pSh->GetNext() != pSh ? (SwViewShell*)pSh->GetNext() : 0;
     415             : 
     416             :     // Doesn't matter anymore
     417           0 :     if ( pWaitingCurrShell == pSh )
     418           0 :         pWaitingCurrShell = 0;
     419             : 
     420             :     // Remove references
     421           0 :     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           0 : }
     428             : 
     429           0 : void InitCurrShells( SwRootFrm *pRoot )
     430             : {
     431           0 :     pRoot->pCurrShells = new SwCurrShells;
     432           0 : }
     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           0 : 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           0 :     nAccessibleShells( 0 )
     467             : {
     468           0 :     mnType = FRMC_ROOT;
     469           0 :     setRootFrm( this );
     470           0 : }
     471             : 
     472           0 : void SwRootFrm::Init( SwFrmFmt* pFmt )
     473             : {
     474           0 :     InitCurrShells( this );
     475             : 
     476           0 :     IDocumentTimerAccess *pTimerAccess = pFmt->getIDocumentTimerAccess();
     477           0 :     IDocumentLayoutAccess *pLayoutAccess = pFmt->getIDocumentLayoutAccess();
     478           0 :     IDocumentFieldsAccess *pFieldsAccess = pFmt->getIDocumentFieldsAccess();
     479           0 :     const IDocumentSettingAccess *pSettingAccess = pFmt->getIDocumentSettingAccess();
     480           0 :     pTimerAccess->StopIdling();
     481             :     // For creating the Flys by MakeFrms()
     482           0 :     pLayoutAccess->SetCurrentViewShell( this->GetCurrShell() );
     483           0 :     bCallbackActionEnabled = sal_False; // needs to be set to sal_True before leaving!
     484             : 
     485           0 :     SdrModel *pMd = pFmt->getIDocumentDrawModelAccess()->GetDrawModel();
     486           0 :     if ( pMd )
     487             :     {
     488             :         // Disable "multiple layout"
     489           0 :         pDrawPage = pMd->GetPage(0);
     490             : 
     491           0 :         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           0 :     SwDoc* pDoc = pFmt->GetDoc();
     499           0 :     SwNodeIndex aIndex( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
     500           0 :     SwCntntNode *pNode = pDoc->GetNodes().GoNextSection( &aIndex, true, false );
     501             :     // #123067# pNode = 0 can really happen
     502           0 :     SwTableNode *pTblNd= pNode ? pNode->FindTableNode() : 0;
     503             : 
     504             :     // Get hold of PageDesc (either via FrmFmt of the first node or the initial one).
     505           0 :     SwPageDesc *pDesc = 0;
     506           0 :     ::boost::optional<sal_uInt16> oPgNum;
     507             : 
     508           0 :     if ( pTblNd )
     509             :     {
     510           0 :         const SwFmtPageDesc &rDesc = pTblNd->GetTable().GetFrmFmt()->GetPageDesc();
     511           0 :         pDesc = (SwPageDesc*)rDesc.GetPageDesc();
     512             :         //#19104# respect the page number offset!!
     513           0 :         oPgNum = rDesc.GetNumOffset();
     514           0 :         if (oPgNum)
     515           0 :             bIsVirtPageNum = true;
     516             :     }
     517           0 :     else if ( pNode )
     518             :     {
     519           0 :         const SwFmtPageDesc &rDesc = pNode->GetSwAttrSet().GetPageDesc();
     520           0 :         pDesc = (SwPageDesc*)rDesc.GetPageDesc();
     521             :         //#19104# respect the page number offset!!
     522           0 :         oPgNum = rDesc.GetNumOffset();
     523           0 :         if (oPgNum)
     524           0 :             bIsVirtPageNum = true;
     525             :     }
     526             :     else
     527           0 :         bIsVirtPageNum = sal_False;
     528           0 :     if ( !pDesc )
     529           0 :         pDesc = &pDoc->GetPageDesc( 0 );
     530           0 :     const bool bOdd = !oPgNum || 0 != ( oPgNum.get() % 2 );
     531           0 :     bool bFirst = !oPgNum || 1 == oPgNum.get();
     532             : 
     533             :     // Create a page and put it in the layout
     534           0 :     SwPageFrm *pPage = ::InsertNewPage( *pDesc, this, bOdd, bFirst, false, sal_False, 0 );
     535             : 
     536             :     // Find the first page in the Bodytext section.
     537           0 :     SwLayoutFrm *pLay = pPage->FindBodyCont();
     538           0 :     while( pLay->Lower() )
     539           0 :         pLay = (SwLayoutFrm*)pLay->Lower();
     540             : 
     541           0 :     SwNodeIndex aTmp( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
     542           0 :     ::_InsertCnt( pLay, pDoc, aTmp.GetIndex(), sal_True );
     543             :     //Remove masters that haven't been replaced yet from the list.
     544           0 :     RemoveMasterObjs( pDrawPage );
     545           0 :     if( pSettingAccess->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) )
     546           0 :         pFieldsAccess->UpdateRefFlds( NULL );
     547             :     //b6433357: Update page fields after loading
     548           0 :     if ( !pCurrShell || !pCurrShell->Imp()->IsUpdateExpFlds() )
     549             :     {
     550           0 :         SwDocPosUpdate aMsgHnt( pPage->Frm().Top() );
     551           0 :         pFieldsAccess->UpdatePageFlds( &aMsgHnt );
     552             :     }
     553             : 
     554           0 :     pTimerAccess->StartIdling();
     555           0 :     bCallbackActionEnabled = sal_True;
     556             : 
     557           0 :     SwViewShell *pViewSh  = GetCurrShell();
     558           0 :     if (pViewSh)
     559           0 :         mbNeedGrammarCheck = pViewSh->GetViewOptions()->IsOnlineSpell();
     560           0 : }
     561             : 
     562           0 : SwRootFrm::~SwRootFrm()
     563             : {
     564           0 :     bTurboAllowed = sal_False;
     565           0 :     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           0 :     RemoveFtns(0, false, true);
     576             : 
     577           0 :     if(pBlink)
     578           0 :         pBlink->FrmDelete( this );
     579           0 :     SwFrmFmt *pRegisteredInNonConst = static_cast<SwFrmFmt*>(GetRegisteredInNonConst());
     580           0 :     if ( pRegisteredInNonConst )
     581             :     {
     582           0 :         SwDoc *pDoc = pRegisteredInNonConst->GetDoc();
     583           0 :         pDoc->DelFrmFmt( pRegisteredInNonConst );
     584           0 :         pDoc->ClearSwLayouterEntries();
     585             :     }
     586           0 :     delete pDestroy;
     587           0 :     pDestroy = 0;
     588             : 
     589             :     // Remove references
     590           0 :     for ( SwCurrShells::iterator it = pCurrShells->begin(); it != pCurrShells->end(); ++it )
     591           0 :         (*it)->pRoot = 0;
     592             : 
     593           0 :     delete pCurrShells;
     594           0 :     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           0 :     SwLayoutFrm::Destroy();
     602           0 :     SwFrm::Destroy();
     603           0 : }
     604             : 
     605           0 : void SwRootFrm::RemoveMasterObjs( SdrPage *pPg )
     606             : {
     607             :     // Remove all master objects from the Page. But don't delete!
     608           0 :     for( sal_uLong i = pPg ? pPg->GetObjCount() : 0; i; )
     609             :     {
     610           0 :         SdrObject* pObj = pPg->GetObj( --i );
     611           0 :         if( pObj->ISA(SwFlyDrawObj ) )
     612           0 :             pPg->RemoveObject( i );
     613             :     }
     614           0 : }
     615             : 
     616           0 : void SwRootFrm::AllCheckPageDescs() const
     617             : {
     618           0 :     if ( !IsLayoutFreezed() )
     619           0 :         CheckPageDescs( (SwPageFrm*)this->Lower() );
     620           0 : }
     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           0 : void SwRootFrm::AllRemoveFtns()
     638             : {
     639           0 :     RemoveFtns();
     640           0 : }
     641             : 
     642           0 : void SwRootFrm::AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const
     643             : {
     644           0 :     SwPageFrm *pPage = (SwPageFrm*)this->Lower();
     645           0 :     while ( pPage )
     646             :     {
     647           0 :         if ( bSmartTags )
     648           0 :             pPage->InvalidateSmartTags();
     649             : 
     650           0 :         pPage->InvalidateSpelling();
     651           0 :         pPage = (SwPageFrm*)pPage->GetNext();
     652             :     }
     653           0 : }
     654             : 
     655             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10