LCOV - code coverage report
Current view: top level - libreoffice/sw/source/core/layout - newfrm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 127 162 78.4 %
Date: 2012-12-27 Functions: 21 33 63.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 <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::pCache = 0;
      55             : 
      56        8972 : long FirstMinusSecond( long nFirst, long nSecond )
      57        8972 :     { return nFirst - nSecond; }
      58           0 : long SecondMinusFirst( long nFirst, long nSecond )
      59           0 :     { return nSecond - nFirst; }
      60         486 : long SwIncrement( long nA, long nAdd )
      61         486 :     { return nA + nAdd; }
      62           0 : long SwDecrement( long nA, long nSub )
      63           0 :     { 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      107972 : TYPEINIT1(SwFrm,SwClient);      //rtti for SwFrm
     352       68788 : TYPEINIT1(SwCntntFrm,SwFrm);    //rtti for SwCntntFrm
     353             : 
     354             : 
     355          10 : void _FrmInit()
     356             : {
     357          10 :     SwRootFrm::pVout = new SwLayVout();
     358             :     SwCache *pNew = new SwCache( 100
     359             : #ifdef DBG_UTIL
     360             :     , "static SwBorderAttrs::pCache"
     361             : #endif
     362          10 :     );
     363          10 :     SwFrm::SetCache( pNew );
     364          10 : }
     365             : 
     366             : 
     367             : 
     368          10 : 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          10 :     delete SwRootFrm::pVout;
     380          10 :     delete SwFrm::GetCachePtr();
     381          10 : }
     382             : 
     383             : /*************************************************************************
     384             : |*
     385             : |*  RootFrm::Everything that belongs to CurrShell
     386             : |*
     387             : |*************************************************************************/
     388             : 
     389         299 : class SwCurrShells : public std::set<CurrShell*> {};
     390             : 
     391       15093 : CurrShell::CurrShell( ViewShell *pNew )
     392             : {
     393             :     OSL_ENSURE( pNew, "insert 0-Shell?" );
     394       15093 :     pRoot = pNew->GetLayout();
     395       15093 :     if ( pRoot )
     396             :     {
     397       15093 :         pPrev = pRoot->pCurrShell;
     398       15093 :         pRoot->pCurrShell = pNew;
     399       15093 :         pRoot->pCurrShells->insert( this );
     400             :     }
     401             :     else
     402           0 :         pPrev = 0;
     403       15093 : }
     404             : 
     405       15093 : CurrShell::~CurrShell()
     406             : {
     407       15093 :     if ( pRoot )
     408             :     {
     409       15093 :         pRoot->pCurrShells->erase( this );
     410       15093 :         if ( pPrev )
     411       15093 :             pRoot->pCurrShell = pPrev;
     412       15093 :         if ( pRoot->pCurrShells->empty() && pRoot->pWaitingCurrShell )
     413             :         {
     414           0 :             pRoot->pCurrShell = pRoot->pWaitingCurrShell;
     415           0 :             pRoot->pWaitingCurrShell = 0;
     416             :         }
     417             :     }
     418       15093 : }
     419             : 
     420         236 : void SetShell( ViewShell *pSh )
     421             : {
     422         236 :     SwRootFrm *pRoot = pSh->GetLayout();
     423         236 :     if ( pRoot->pCurrShells->empty() )
     424         236 :         pRoot->pCurrShell = pSh;
     425             :     else
     426           0 :         pRoot->pWaitingCurrShell = pSh;
     427         236 : }
     428             : 
     429          65 : void SwRootFrm::DeRegisterShell( ViewShell *pSh )
     430             : {
     431             :     // Activate some shell if possible
     432          65 :     if ( pCurrShell == pSh )
     433          63 :         pCurrShell = pSh->GetNext() != pSh ? (ViewShell*)pSh->GetNext() : 0;
     434             : 
     435             :     // Doesn't matter anymore
     436          65 :     if ( pWaitingCurrShell == pSh )
     437           0 :         pWaitingCurrShell = 0;
     438             : 
     439             :     // Remove references
     440          65 :     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          65 : }
     447             : 
     448         236 : void InitCurrShells( SwRootFrm *pRoot )
     449             : {
     450         236 :     pRoot->pCurrShells = new SwCurrShells;
     451         236 : }
     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         236 : SwRootFrm::SwRootFrm( SwFrmFmt *pFmt, ViewShell * pSh ) :
     467             :     SwLayoutFrm( pFmt->GetDoc()->MakeFrmFmt(
     468             :         rtl::OUString("Root"), pFmt ), 0 ),
     469             :     // --> PAGES01
     470             :     maPagesArea(),
     471             :     mnViewWidth( -1 ),
     472             :     mnColumns( 0 ),
     473             :     mbBookMode( false ),
     474             :     mbSidebarChanged( false ),
     475             :     mbNeedGrammarCheck( false ),
     476             :     nBrowseWidth( MM50*4 ), //2cm minimum
     477             :     pTurbo( 0 ),
     478             :     pLastPage( 0 ),
     479             :     pCurrShell( pSh ),
     480             :     pWaitingCurrShell( 0 ),
     481             :     pDrawPage( 0 ),
     482             :     pDestroy( 0 ),
     483             :     nPhyPageNums( 0 ),
     484         236 :     nAccessibleShells( 0 )
     485             : {
     486         236 :     nType = FRMC_ROOT;
     487         236 :     bIdleFormat = bTurboAllowed = bAssertFlyPages = bIsNewLayout = sal_True;
     488         236 :     bCheckSuperfluous = bBrowseWidthValid = sal_False;
     489         236 :     setRootFrm( this );
     490         236 : }
     491             : 
     492         236 : void SwRootFrm::Init( SwFrmFmt* pFmt )
     493             : {
     494         236 :     InitCurrShells( this );
     495             : 
     496         236 :     IDocumentTimerAccess *pTimerAccess = pFmt->getIDocumentTimerAccess();
     497         236 :     IDocumentLayoutAccess *pLayoutAccess = pFmt->getIDocumentLayoutAccess();
     498         236 :     IDocumentFieldsAccess *pFieldsAccess = pFmt->getIDocumentFieldsAccess();
     499         236 :     const IDocumentSettingAccess *pSettingAccess = pFmt->getIDocumentSettingAccess();
     500         236 :     pTimerAccess->StopIdling();
     501             :     // For creating the Flys by MakeFrms()
     502         236 :     pLayoutAccess->SetCurrentViewShell( this->GetCurrShell() );
     503         236 :     bCallbackActionEnabled = sal_False; // needs to be set to sal_True before leaving!
     504             : 
     505         236 :     SdrModel *pMd = pFmt->getIDocumentDrawModelAccess()->GetDrawModel();
     506         236 :     if ( pMd )
     507             :     {
     508             :         // Disable "multiple layout"
     509         236 :         pDrawPage = pMd->GetPage(0); //pMd->AllocPage( FALSE );
     510             :         //pMd->InsertPage( pDrawPage );
     511             :         // end of disabling
     512             : 
     513         236 :         pDrawPage->SetSize( Frm().SSize() );
     514             :     }
     515             : 
     516             :     // Initialize the layout: create pages, link content with Cntnt etc.
     517             :     // First, initialize some stuff, then get hold of the first
     518             :     // node (which will be needed for the PageDesc).
     519             : 
     520         236 :     SwDoc* pDoc = pFmt->GetDoc();
     521         236 :     SwNodeIndex aIndex( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode() );
     522         236 :     SwCntntNode *pNode = pDoc->GetNodes().GoNextSection( &aIndex, sal_True, sal_False );
     523             :     // #123067# pNode = 0 can really happen
     524         236 :     SwTableNode *pTblNd= pNode ? pNode->FindTableNode() : 0;
     525             : 
     526             :     // Get hold of PageDesc (either via FrmFmt of the first node or the initial one).
     527         236 :     SwPageDesc *pDesc = 0;
     528         236 :     sal_uInt16 nPgNum = 1;
     529             : 
     530         236 :     if ( pTblNd )
     531             :     {
     532          13 :         const SwFmtPageDesc &rDesc = pTblNd->GetTable().GetFrmFmt()->GetPageDesc();
     533          13 :         pDesc = (SwPageDesc*)rDesc.GetPageDesc();
     534             :         //#19104# respect the page number offset!!
     535          13 :         bIsVirtPageNum = 0 != ( nPgNum = rDesc.GetNumOffset() );
     536             :     }
     537         223 :     else if ( pNode )
     538             :     {
     539         222 :         const SwFmtPageDesc &rDesc = pNode->GetSwAttrSet().GetPageDesc();
     540         222 :         pDesc = (SwPageDesc*)rDesc.GetPageDesc();
     541             :         //#19104# respect the page number offset!!
     542         222 :         bIsVirtPageNum = 0 != ( nPgNum = rDesc.GetNumOffset() );
     543             :     }
     544             :     else
     545           1 :         bIsVirtPageNum = sal_False;
     546         236 :     if ( !pDesc )
     547          16 :         pDesc = &pDoc->GetPageDesc( 0 );
     548         236 :     const bool bOdd = !nPgNum || 0 != ( nPgNum % 2 );
     549         236 :     bool bFirst = !nPgNum || 1 == nPgNum;
     550             : 
     551             :     // Create a page and put it in the layout
     552         236 :     SwPageFrm *pPage = ::InsertNewPage( *pDesc, this, bOdd, bFirst, false, sal_False, 0 );
     553             : 
     554             :     // Find the first page in the Bodytext section.
     555         236 :     SwLayoutFrm *pLay = pPage->FindBodyCont();
     556         476 :     while( pLay->Lower() )
     557           4 :         pLay = (SwLayoutFrm*)pLay->Lower();
     558             : 
     559         236 :     SwNodeIndex aTmp( *pDoc->GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
     560         236 :     ::_InsertCnt( pLay, pDoc, aTmp.GetIndex(), sal_True );
     561             :     //Remove masters that haven't been replaced yet from the list.
     562         236 :     RemoveMasterObjs( pDrawPage );
     563         236 :     if( pSettingAccess->get(IDocumentSettingAccess::GLOBAL_DOCUMENT) )
     564           0 :         pFieldsAccess->UpdateRefFlds( NULL );
     565             :     //b6433357: Update page fields after loading
     566             :     // --->
     567         236 :     if ( !pCurrShell || !pCurrShell->Imp()->IsUpdateExpFlds() )
     568             :     {
     569         236 :         SwDocPosUpdate aMsgHnt( pPage->Frm().Top() );
     570         236 :         pFieldsAccess->UpdatePageFlds( &aMsgHnt );
     571             :     }
     572             : 
     573         236 :     pTimerAccess->StartIdling();
     574         236 :     bCallbackActionEnabled = sal_True;
     575             : 
     576         236 :     ViewShell *pViewSh  = GetCurrShell();
     577         236 :     if (pViewSh)
     578         236 :         mbNeedGrammarCheck = pViewSh->GetViewOptions()->IsOnlineSpell();
     579         236 : }
     580             : 
     581             : /*************************************************************************
     582             : |*
     583             : |*  SwRootFrm::~SwRootFrm()
     584             : |*
     585             : |*************************************************************************/
     586             : 
     587             : 
     588             : 
     589         189 : SwRootFrm::~SwRootFrm()
     590             : {
     591          63 :     bTurboAllowed = sal_False;
     592          63 :     pTurbo = 0;
     593             :     // fdo#39510 crash on document close with footnotes
     594             :     // Object ownership in writer and esp. in layout are a mess: Before the
     595             :     // document/layout split SwDoc and SwRootFrm were essentially one object
     596             :     // and magically/uncleanly worked around their common destruction by call
     597             :     // to SwDoc::IsInDtor() -- even from the layout. As of now destuction of
     598             :     // the layout proceeds forward through the frames. Since SwTxtFtn::DelFrms
     599             :     // also searches backwards to find the master of footnotes, they must be
     600             :     // considered to be owned by the SwRootFrm and also be destroyed here,
     601             :     // before tearing down the (now footnote free) rest of the layout.
     602          63 :     RemoveFtns(0, false, true);
     603             : 
     604          63 :     if(pBlink)
     605           0 :         pBlink->FrmDelete( this );
     606          63 :     SwFrmFmt *pRegisteredInNonConst = static_cast<SwFrmFmt*>(GetRegisteredInNonConst());
     607          63 :     if ( pRegisteredInNonConst )
     608             :     {
     609          63 :         SwDoc *pDoc = pRegisteredInNonConst->GetDoc();
     610          63 :         pDoc->DelFrmFmt( pRegisteredInNonConst );
     611          63 :         pDoc->ClearSwLayouterEntries();
     612             :     }
     613          63 :     delete pDestroy;
     614          63 :     pDestroy = 0;
     615             : 
     616             :     // Remove references
     617          63 :     for ( SwCurrShells::iterator it = pCurrShells->begin(); it != pCurrShells->end(); ++it )
     618           0 :         (*it)->pRoot = 0;
     619             : 
     620          63 :     delete pCurrShells;
     621          63 :     pCurrShells = 0;
     622             : 
     623             :     // Some accessible shells are left => problems on second SwFrm::Destroy call
     624             :     assert(0 == nAccessibleShells);
     625             : 
     626             :     // manually call base classes Destroy because it could call stuff
     627             :     // that accesses members of this
     628          63 :     SwLayoutFrm::Destroy();
     629          63 :     SwFrm::Destroy();
     630         126 : }
     631             : 
     632             : /*************************************************************************
     633             : |*
     634             : |*  SwRootFrm::RemoveMasterObjs()
     635             : |*
     636             : |*************************************************************************/
     637             : 
     638             : 
     639         236 : void SwRootFrm::RemoveMasterObjs( SdrPage *pPg )
     640             : {
     641             :     // Remove all master objects from the Page. But don't delete!
     642         562 :     for( sal_uLong i = pPg ? pPg->GetObjCount() : 0; i; )
     643             :     {
     644          90 :         SdrObject* pObj = pPg->GetObj( --i );
     645          90 :         if( pObj->ISA(SwFlyDrawObj ) )
     646          15 :             pPg->RemoveObject( i );
     647             :     }
     648         236 : }
     649             : 
     650             : 
     651           1 : void SwRootFrm::AllCheckPageDescs() const
     652             : {
     653           1 :     CheckPageDescs( (SwPageFrm*)this->Lower() );
     654           1 : }
     655             : //swmod 080226
     656           0 : void SwRootFrm::AllInvalidateAutoCompleteWords() const
     657             : {
     658           0 :     SwPageFrm *pPage = (SwPageFrm*)this->Lower();
     659           0 :     while ( pPage )
     660             :     {
     661           0 :         pPage->InvalidateAutoCompleteWords();
     662           0 :         pPage = (SwPageFrm*)pPage->GetNext();
     663             :     }
     664           0 : }//swmod 080305
     665           0 : void SwRootFrm::AllAddPaintRect() const
     666             : {
     667           0 :     GetCurrShell()->AddPaintRect( this->Frm() );
     668           0 : }//swmod 080305
     669           0 : void SwRootFrm::AllRemoveFtns()
     670             : {
     671           0 :     RemoveFtns();
     672           0 : }
     673           0 : void SwRootFrm::AllInvalidateSmartTagsOrSpelling(bool bSmartTags) const
     674             : {
     675           0 :     SwPageFrm *pPage = (SwPageFrm*)this->Lower();
     676           0 :     while ( pPage )
     677             :     {
     678           0 :         if ( bSmartTags )
     679           0 :             pPage->InvalidateSmartTags();
     680             : 
     681           0 :         pPage->InvalidateSpelling();
     682           0 :         pPage = (SwPageFrm*)pPage->GetNext();
     683             :     }   //swmod 080218
     684           0 : }
     685             : 
     686             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10