LCOV - code coverage report
Current view: top level - sw/source/core/layout - newfrm.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 141 162 87.0 %
Date: 2012-08-25 Functions: 25 33 75.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 112 190 58.9 %

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

Generated by: LCOV version 1.10