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

Generated by: LCOV version 1.10