LCOV - code coverage report
Current view: top level - sw/source/core/layout - ssfrm.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 221 356 62.1 %
Date: 2014-11-03 Functions: 29 39 74.4 %
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 <pagefrm.hxx>
      21             : #include <rootfrm.hxx>
      22             : #include <dcontact.hxx>
      23             : #include <flyfrm.hxx>
      24             : #include <txtfrm.hxx>
      25             : #include <cellfrm.hxx>
      26             : #include <swtable.hxx>
      27             : #include <fmtfsize.hxx>
      28             : #include <editeng/boxitem.hxx>
      29             : #include <editeng/shaditem.hxx>
      30             : #include <fmtclds.hxx>
      31             : #include <viewimp.hxx>
      32             : #include <sortedobjs.hxx>
      33             : #include <hints.hxx>
      34             : 
      35             :     // No inline cause we need the function pointers
      36        7027 : long SwFrm::GetTopMargin() const
      37        7027 :     { return Prt().Top(); }
      38      156360 : long SwFrm::GetBottomMargin() const
      39      156360 :     { return Frm().Height() -Prt().Height() -Prt().Top(); }
      40         511 : long SwFrm::GetLeftMargin() const
      41         511 :     { return Prt().Left(); }
      42         286 : long SwFrm::GetRightMargin() const
      43         286 :     { return Frm().Width() - Prt().Width() - Prt().Left(); }
      44       35189 : long SwFrm::GetPrtLeft() const
      45       35189 :     { return Frm().Left() + Prt().Left(); }
      46     1047077 : long SwFrm::GetPrtBottom() const
      47     1047077 :     { return Frm().Top() + Prt().Height() + Prt().Top(); }
      48        2416 : long SwFrm::GetPrtRight() const
      49        2416 :     { return Frm().Left() + Prt().Width() + Prt().Left(); }
      50      176515 : long SwFrm::GetPrtTop() const
      51      176515 :     { return Frm().Top() + Prt().Top(); }
      52             : 
      53           0 : bool SwFrm::SetMinLeft( long nDeadline )
      54             : {
      55           0 :     SwTwips nDiff = nDeadline - Frm().Left();
      56           0 :     if( nDiff > 0 )
      57             :     {
      58           0 :         Frm().Left( nDeadline );
      59           0 :         Prt().Width( Prt().Width() - nDiff );
      60           0 :         return true;
      61             :     }
      62           0 :     return false;
      63             : }
      64             : 
      65         616 : bool SwFrm::SetMaxBottom( long nDeadline )
      66             : {
      67         616 :     SwTwips nDiff = Frm().Top() + Frm().Height() - nDeadline;
      68         616 :     if( nDiff > 0 )
      69             :     {
      70           0 :         Frm().Height( Frm().Height() - nDiff );
      71           0 :         Prt().Height( Prt().Height() - nDiff );
      72           0 :         return true;
      73             :     }
      74         616 :     return false;
      75             : }
      76             : 
      77           0 : bool SwFrm::SetMinTop( long nDeadline )
      78             : {
      79           0 :     SwTwips nDiff = nDeadline - Frm().Top();
      80           0 :     if( nDiff > 0 )
      81             :     {
      82           0 :         Frm().Top( nDeadline );
      83           0 :         Prt().Height( Prt().Height() - nDiff );
      84           0 :         return true;
      85             :     }
      86           0 :     return false;
      87             : }
      88             : 
      89           0 : bool SwFrm::SetMaxRight( long nDeadline )
      90             : {
      91           0 :     SwTwips nDiff = Frm().Left() + Frm().Width() - nDeadline;
      92           0 :     if( nDiff > 0 )
      93             :     {
      94           0 :         Frm().Width( Frm().Width() - nDiff );
      95           0 :         Prt().Width( Prt().Width() - nDiff );
      96           0 :         return true;
      97             :     }
      98           0 :     return false;
      99             : }
     100             : 
     101         918 : void SwFrm::MakeBelowPos( const SwFrm* pUp, const SwFrm* pPrv, bool bNotify )
     102             : {
     103         918 :     if( pPrv )
     104             :     {
     105         430 :         maFrm.Pos( pPrv->Frm().Pos() );
     106         430 :         maFrm.Pos().Y() += pPrv->Frm().Height();
     107             :     }
     108             :     else
     109             :     {
     110         488 :         maFrm.Pos( pUp->Frm().Pos() );
     111         488 :         maFrm.Pos() += pUp->Prt().Pos();
     112             :     }
     113         918 :     if( bNotify )
     114         432 :         maFrm.Pos().Y() += 1;
     115         918 : }
     116             : 
     117           0 : void SwFrm::MakeUpperPos( const SwFrm* pUp, const SwFrm* pPrv, bool bNotify )
     118             : {
     119           0 :     if( pPrv )
     120             :     {
     121           0 :         maFrm.Pos( pPrv->Frm().Pos() );
     122           0 :         maFrm.Pos().Y() -= Frm().Height();
     123             :     }
     124             :     else
     125             :     {
     126           0 :         maFrm.Pos( pUp->Frm().Pos() );
     127           0 :         maFrm.Pos() += pUp->Prt().Pos();
     128           0 :         maFrm.Pos().Y() += pUp->Prt().Height() - maFrm.Height();
     129             :     }
     130           0 :     if( bNotify )
     131           0 :         maFrm.Pos().Y() -= 1;
     132           0 : }
     133             : 
     134           0 : void SwFrm::MakeLeftPos( const SwFrm* pUp, const SwFrm* pPrv, bool bNotify )
     135             : {
     136           0 :     if( pPrv )
     137             :     {
     138           0 :         maFrm.Pos( pPrv->Frm().Pos() );
     139           0 :         maFrm.Pos().X() -= Frm().Width();
     140             :     }
     141             :     else
     142             :     {
     143           0 :         maFrm.Pos( pUp->Frm().Pos() );
     144           0 :         maFrm.Pos() += pUp->Prt().Pos();
     145           0 :         maFrm.Pos().X() += pUp->Prt().Width() - maFrm.Width();
     146             :     }
     147           0 :     if( bNotify )
     148           0 :         maFrm.Pos().X() -= 1;
     149           0 : }
     150             : 
     151           0 : void SwFrm::MakeRightPos( const SwFrm* pUp, const SwFrm* pPrv, bool bNotify )
     152             : {
     153           0 :     if( pPrv )
     154             :     {
     155           0 :         maFrm.Pos( pPrv->Frm().Pos() );
     156           0 :         maFrm.Pos().X() += pPrv->Frm().Width();
     157             :     }
     158             :     else
     159             :     {
     160           0 :         maFrm.Pos( pUp->Frm().Pos() );
     161           0 :         maFrm.Pos() += pUp->Prt().Pos();
     162             :     }
     163           0 :     if( bNotify )
     164           0 :         maFrm.Pos().X() += 1;
     165           0 : }
     166             : 
     167       75421 : void SwFrm::SetTopBottomMargins( long nTop, long nBot )
     168             : {
     169       75421 :     Prt().Top( nTop );
     170       75421 :     Prt().Height( Frm().Height() - nTop - nBot );
     171       75421 : }
     172             : 
     173           0 : void SwFrm::SetBottomTopMargins( long nBot, long nTop )
     174             : {
     175           0 :     Prt().Top( nTop );
     176           0 :     Prt().Height( Frm().Height() - nTop - nBot );
     177           0 : }
     178             : 
     179      220112 : void SwFrm::SetLeftRightMargins( long nLeft, long nRight)
     180             : {
     181      220112 :     Prt().Left( nLeft );
     182      220112 :     Prt().Width( Frm().Width() - nLeft - nRight );
     183      220112 : }
     184             : 
     185           4 : void SwFrm::SetRightLeftMargins( long nRight, long nLeft)
     186             : {
     187           4 :     Prt().Left( nLeft );
     188           4 :     Prt().Width( Frm().Width() - nLeft - nRight );
     189           4 : }
     190             : 
     191             : /// checks the layout direction and invalidates the lower frames rekursivly, if necessary.
     192       26370 : void SwFrm::CheckDirChange()
     193             : {
     194       26370 :     bool bOldVert = GetVerticalFlag();
     195       26370 :     bool bOldRev = IsReverse();
     196       26370 :     bool bOldR2L = GetRightToLeftFlag();
     197       26370 :     SetInvalidVert( true );
     198       26370 :     SetInvalidR2L( true );
     199       26370 :     bool bChg = bOldR2L != IsRightToLeft();
     200       26370 :     bool bOldVertL2R = IsVertLR();
     201       26370 :     if( ( IsVertical() != bOldVert ) || bChg || IsReverse() != bOldRev || bOldVertL2R != IsVertLR() )
     202             :     {
     203           0 :         InvalidateAll();
     204           0 :         if( IsLayoutFrm() )
     205             :         {
     206             :             // set minimum row height for vertical cells in horizontal table:
     207           0 :             if ( IsCellFrm() && GetUpper() )
     208             :             {
     209           0 :                 if ( IsVertical() != GetUpper()->IsVertical() &&
     210           0 :                      ((SwCellFrm*)this)->GetTabBox()->getRowSpan() == 1 )
     211             :                 {
     212             :                     enum {
     213             :                         MIN_VERT_CELL_HEIGHT = 1135
     214             :                     };
     215             : 
     216           0 :                     SwTableLine* pLine = (SwTableLine*)((SwCellFrm*)this)->GetTabBox()->GetUpper();
     217           0 :                     SwFrmFmt* pFrmFmt = pLine->GetFrmFmt();
     218           0 :                     SwFmtFrmSize aNew( pFrmFmt->GetFrmSize() );
     219           0 :                     if ( ATT_FIX_SIZE != aNew.GetHeightSizeType() )
     220           0 :                         aNew.SetHeightSizeType( ATT_MIN_SIZE );
     221           0 :                     if ( aNew.GetHeight() < MIN_VERT_CELL_HEIGHT )
     222           0 :                         aNew.SetHeight( MIN_VERT_CELL_HEIGHT );
     223           0 :                     SwDoc* pDoc = pFrmFmt->GetDoc();
     224           0 :                     pDoc->SetAttr( aNew, *pLine->ClaimFrmFmt() );
     225             :                 }
     226             :             }
     227             : 
     228           0 :             SwFrm* pFrm = ((SwLayoutFrm*)this)->Lower();
     229           0 :             const SwFmtCol* pCol = NULL;
     230           0 :             SwLayoutFrm* pBody = 0;
     231           0 :             if( pFrm )
     232             :             {
     233           0 :                 if( IsPageFrm() )
     234             :                 {
     235             :                     // If we're a page frame and we change our layout direction,
     236             :                     // we have to look for columns and rearrange them.
     237           0 :                     pBody = ((SwPageFrm*)this)->FindBodyCont();
     238           0 :                     if(pBody && pBody->Lower() && pBody->Lower()->IsColumnFrm())
     239           0 :                         pCol = &((SwPageFrm*)this)->GetFmt()->GetCol();
     240             :                 }
     241           0 :                 else if( pFrm->IsColumnFrm() )
     242             :                 {
     243           0 :                     pBody = ((SwLayoutFrm*)this);
     244           0 :                     const SwFrmFmt *pFmt = pBody->GetFmt();
     245           0 :                     if( pFmt )
     246           0 :                         pCol = &pFmt->GetCol();
     247             :                 }
     248             :             }
     249           0 :             while( pFrm )
     250             :             {
     251           0 :                 pFrm->CheckDirChange();
     252           0 :                 pFrm = pFrm->GetNext();
     253             :             }
     254           0 :             if( pCol )
     255           0 :                 pBody->AdjustColumns( pCol, true );
     256             :         }
     257           0 :         else if( IsTxtFrm() )
     258           0 :             ((SwTxtFrm*)this)->Prepare( PREP_CLEAR );
     259             : 
     260             :         // #i31698# - notify anchored objects also for page frames.
     261             :         // Remove code above for special handling of page frames
     262           0 :         if ( GetDrawObjs() )
     263             :         {
     264           0 :             const SwSortedObjs *pObjs = GetDrawObjs();
     265           0 :             const size_t nCnt = pObjs->size();
     266           0 :             for ( size_t i = 0; i < nCnt; ++i )
     267             :             {
     268           0 :                 SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
     269           0 :                 if( pAnchoredObj->ISA(SwFlyFrm) )
     270           0 :                     static_cast<SwFlyFrm*>(pAnchoredObj)->CheckDirChange();
     271             :                 else
     272             :                 {
     273             :                     // OD 2004-04-06 #i26791# - direct object
     274             :                     // positioning no longer needed. Instead
     275             :                     // invalidate
     276           0 :                     pAnchoredObj->InvalidateObjPos();
     277             :                 }
     278             :                 // #i31698# - update layout direction of
     279             :                 // anchored object
     280             :                 {
     281           0 :                     ::setContextWritingMode( pAnchoredObj->DrawObj(), pAnchoredObj->GetAnchorFrmContainingAnchPos() );
     282           0 :                     pAnchoredObj->UpdateLayoutDir();
     283             :                 }
     284             :             }
     285             :         }
     286             :     }
     287       26370 : }
     288             : 
     289             : /// returns the position for anchors based on frame direction
     290             : // OD 2004-03-10 #i11860# - consider lower space and line spacing of
     291             : // previous frame according to new option 'Use former object positioning'
     292        3990 : Point SwFrm::GetFrmAnchorPos( bool bIgnoreFlysAnchoredAtThisFrame ) const
     293             : {
     294        3990 :     Point aAnchor = Frm().Pos();
     295             : 
     296        3990 :     if ( ( IsVertical() && !IsVertLR() ) || IsRightToLeft() )
     297           0 :         aAnchor.X() += Frm().Width();
     298             : 
     299        3990 :     if ( IsTxtFrm() )
     300             :     {
     301             :         SwTwips nBaseOfstForFly =
     302        3884 :             ((SwTxtFrm*)this)->GetBaseOfstForFly( bIgnoreFlysAnchoredAtThisFrame );
     303        3884 :         if ( IsVertical() )
     304           0 :             aAnchor.Y() += nBaseOfstForFly;
     305             :         else
     306        3884 :             aAnchor.X() += nBaseOfstForFly;
     307             : 
     308             :         // OD 2004-03-10 #i11860# - if option 'Use former object positioning'
     309             :         // is OFF, consider the lower space and the line spacing of the
     310             :         // previous frame and the spacing considered for the page grid
     311        3884 :         const SwTxtFrm* pThisTxtFrm = static_cast<const SwTxtFrm*>(this);
     312             :         const SwTwips nUpperSpaceAmountConsideredForPrevFrmAndPageGrid =
     313        3884 :                 pThisTxtFrm->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
     314        3884 :         if ( IsVertical() )
     315             :         {
     316           0 :             aAnchor.X() -= nUpperSpaceAmountConsideredForPrevFrmAndPageGrid;
     317             :         }
     318             :         else
     319             :         {
     320        3884 :             aAnchor.Y() += nUpperSpaceAmountConsideredForPrevFrmAndPageGrid;
     321             :         }
     322             :     }
     323             : 
     324        3990 :     return aAnchor;
     325             : }
     326             : 
     327      124604 : void SwFrm::Destroy()
     328             : {
     329      124604 :     mbInDtor = true;
     330             : 
     331             :     // accessible objects for fly and cell frames have been already disposed
     332             :     // by the destructors of the derived classes.
     333      124604 :     if( IsAccessibleFrm() && !(IsFlyFrm() || IsCellFrm()) && GetDep() )
     334             :     {
     335       82098 :         SwRootFrm *pRootFrm = getRootFrm();
     336       82098 :         if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
     337             :         {
     338           0 :             SwViewShell *pVSh = pRootFrm->GetCurrShell();
     339           0 :             if( pVSh && pVSh->Imp() )
     340             :             {
     341             :                 OSL_ENSURE( !GetLower(), "Lowers should be dispose already!" );
     342           0 :                 pVSh->Imp()->DisposeAccessibleFrm( this );
     343             :             }
     344             :         }
     345             :     }
     346             : 
     347      124604 :     if( mpDrawObjs )
     348             :     {
     349         842 :         for ( size_t i = mpDrawObjs->size(); i; )
     350             :         {
     351         310 :             SwAnchoredObject* pAnchoredObj = (*mpDrawObjs)[--i];
     352         310 :             if ( pAnchoredObj->ISA(SwFlyFrm) )
     353         114 :                 delete pAnchoredObj;
     354             :             else
     355             :             {
     356         196 :                 SdrObject* pSdrObj = pAnchoredObj->DrawObj();
     357             :                 SwDrawContact* pContact =
     358         196 :                         static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
     359             :                 OSL_ENSURE( pContact,
     360             :                         "<SwFrm::~SwFrm> - missing contact for drawing object" );
     361         196 :                 if ( pContact )
     362             :                 {
     363         196 :                     pContact->DisconnectObjFromLayout( pSdrObj );
     364             :                 }
     365             :             }
     366             :         }
     367         266 :         delete mpDrawObjs;
     368         266 :         mpDrawObjs = 0;
     369             :     }
     370      124604 : }
     371             : 
     372      249208 : SwFrm::~SwFrm()
     373             : {
     374      124604 :     if (!IsRootFrm()) // ~SwRootFrm already calls Destroy!
     375             :     {
     376      119340 :         Destroy();
     377             :     }
     378             : 
     379             : #if OSL_DEBUG_LEVEL > 0
     380             :     // JP 15.10.2001: for detection of access to deleted frames
     381             :     mpDrawObjs = (SwSortedObjs*)0x33333333;
     382             : #endif
     383      124604 : }
     384             : 
     385     1787072 : const SwFrmFmt * SwLayoutFrm::GetFmt() const
     386             : {
     387     1787072 :     return static_cast< const SwFrmFmt * >( GetDep() );
     388             : }
     389             : 
     390     2316756 : SwFrmFmt * SwLayoutFrm::GetFmt()
     391             : {
     392     2316756 :     return static_cast< SwFrmFmt * >( GetDep() );
     393             : }
     394             : 
     395         200 : void SwLayoutFrm::SetFrmFmt( SwFrmFmt *pNew )
     396             : {
     397         200 :     if ( pNew != GetFmt() )
     398             :     {
     399         200 :         SwFmtChg aOldFmt( GetFmt() );
     400         200 :         pNew->Add( this );
     401         400 :         SwFmtChg aNewFmt( pNew );
     402         400 :         ModifyNotification( &aOldFmt, &aNewFmt );
     403             :     }
     404         200 : }
     405             : 
     406       65842 : SwCntntFrm::SwCntntFrm( SwCntntNode * const pCntnt, SwFrm* pSib ) :
     407             :     SwFrm( pCntnt, pSib ),
     408       65842 :     SwFlowFrm( (SwFrm&)*this )
     409             : {
     410       65842 : }
     411             : 
     412      131532 : SwCntntFrm::~SwCntntFrm()
     413             : {
     414             :     const SwCntntNode* pCNd;
     415      131532 :     if( 0 != ( pCNd = PTR_CAST( SwCntntNode, GetRegisteredIn() )) &&
     416       65766 :         !pCNd->GetDoc()->IsInDtor() )
     417             :     {
     418             :         //Unregister from root if I'm still in turbo there.
     419       65766 :         SwRootFrm *pRoot = getRootFrm();
     420       65766 :         if( pRoot && pRoot->GetTurbo() == this )
     421             :         {
     422           0 :             pRoot->DisallowTurbo();
     423           0 :             pRoot->ResetTurbo();
     424             :         }
     425             :     }
     426       65766 : }
     427             : 
     428         208 : void SwCntntFrm::RegisterToNode( SwCntntNode& rNode )
     429             : {
     430         208 :     rNode.Add( this );
     431         208 : }
     432             : 
     433       58838 : void SwLayoutFrm::Destroy()
     434             : {
     435      117676 :     while (!aVertPosOrientFrmsFor.empty())
     436             :     {
     437           0 :         SwAnchoredObject *pObj = *aVertPosOrientFrmsFor.begin();
     438           0 :         pObj->ClearVertPosOrientFrm();
     439             :     }
     440             : 
     441             :     assert(aVertPosOrientFrmsFor.empty());
     442             : 
     443       58838 :     SwFrm *pFrm = pLower;
     444             : 
     445       58838 :     if( GetFmt() && !GetFmt()->GetDoc()->IsInDtor() )
     446             :     {
     447      136104 :         while ( pFrm )
     448             :         {
     449             :             //First delete the Objs of the Frm because they can't unregister
     450             :             //from the page after remove.
     451             :             //We don't want to create an endless loop only because one couldn't
     452             :             //unregister.
     453             : 
     454      143764 :             while ( pFrm->GetDrawObjs() && pFrm->GetDrawObjs()->size() )
     455             :             {
     456        6492 :                 const size_t nCnt = pFrm->GetDrawObjs()->size();
     457             :                 // #i28701#
     458        6492 :                 SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[0];
     459        6492 :                 if ( pAnchoredObj->ISA(SwFlyFrm) )
     460        3304 :                     delete pAnchoredObj;
     461             :                 else
     462             :                 {
     463        3188 :                     SdrObject* pSdrObj = pAnchoredObj->DrawObj();
     464             :                     SwDrawContact* pContact =
     465        3188 :                             static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
     466             :                     OSL_ENSURE( pContact,
     467             :                             "<SwFrm::~SwFrm> - missing contact for drawing object" );
     468        3188 :                     if ( pContact )
     469             :                     {
     470        3188 :                         pContact->DisconnectObjFromLayout( pSdrObj );
     471             :                     }
     472             :                 }
     473        9382 :                 if ( pFrm->GetDrawObjs() &&
     474        2890 :                      nCnt == pFrm->GetDrawObjs()->size() )
     475             :                 {
     476           0 :                     pFrm->GetDrawObjs()->Remove( *pAnchoredObj );
     477             :                 }
     478             :             }
     479       68636 :             pFrm->Remove();
     480       68636 :             delete pFrm;
     481       68636 :             pFrm = pLower;
     482             :         }
     483             :         //Delete the Flys, the last one also deletes the array.
     484       67510 :         while ( GetDrawObjs() && GetDrawObjs()->size() )
     485             :         {
     486          42 :             const size_t nCnt = GetDrawObjs()->size();
     487             : 
     488             :             // #i28701#
     489          42 :             SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[0];
     490          42 :             if ( pAnchoredObj->ISA(SwFlyFrm) )
     491           0 :                 delete pAnchoredObj;
     492             :             else
     493             :             {
     494          42 :                 SdrObject* pSdrObj = pAnchoredObj->DrawObj();
     495             :                 SwDrawContact* pContact =
     496          42 :                         static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
     497             :                 OSL_ENSURE( pContact,
     498             :                         "<SwFrm::~SwFrm> - missing contact for drawing object" );
     499          42 :                 if ( pContact )
     500             :                 {
     501          42 :                     pContact->DisconnectObjFromLayout( pSdrObj );
     502             :                 }
     503             :             }
     504          42 :             if ( GetDrawObjs() && nCnt == GetDrawObjs()->size() )
     505             :             {
     506           0 :                 GetDrawObjs()->Remove( *pAnchoredObj );
     507             :             }
     508             :         }
     509             :     }
     510             :     else
     511             :     {
     512       89140 :         while( pFrm )
     513             :         {
     514       38932 :             SwFrm *pNxt = pFrm->GetNext();
     515       38932 :             delete pFrm;
     516       38932 :             pFrm = pNxt;
     517             :         }
     518             :     }
     519       58838 : }
     520             : 
     521      117676 : SwLayoutFrm::~SwLayoutFrm()
     522             : {
     523       58838 :     if (!IsRootFrm()) // ~SwRootFrm already calls Destroy!
     524             :     {
     525       53574 :         Destroy();
     526             :     }
     527       58838 : }
     528             : 
     529             : /**
     530             : |*  The paintarea is the area, in which the content of a frame is allowed
     531             : |*  to be displayed. This region could be larger than the printarea (Prt())
     532             : |*  of the upper, it includes e.g. often the margin of the page.
     533             : |*/
     534      221365 : const SwRect SwFrm::PaintArea() const
     535             : {
     536             :     // NEW TABLES
     537             :     // Cell frames may not leave their upper:
     538      221365 :     SwRect aRect = IsRowFrm() ? GetUpper()->Frm() : Frm();
     539      221365 :     const bool bVert = IsVertical();
     540      221365 :     SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
     541      221365 :     long nRight = (aRect.*fnRect->fnGetRight)();
     542      221365 :     long nLeft  = (aRect.*fnRect->fnGetLeft)();
     543      221365 :     const SwFrm* pTmp = this;
     544      221365 :     bool bLeft = true;
     545      221365 :     bool bRight = true;
     546      221365 :     long nRowSpan = 0;
     547      989498 :     while( pTmp )
     548             :     {
     549      837903 :         if( pTmp->IsCellFrm() && pTmp->GetUpper() &&
     550       69770 :             pTmp->GetUpper()->IsVertical() != pTmp->IsVertical() )
     551           0 :             nRowSpan = ((SwCellFrm*)pTmp)->GetTabBox()->getRowSpan();
     552      768133 :         long nTmpRight = (pTmp->Frm().*fnRect->fnGetRight)();
     553      768133 :         long nTmpLeft = (pTmp->Frm().*fnRect->fnGetLeft)();
     554      768133 :         if( pTmp->IsRowFrm() && nRowSpan > 1 )
     555             :         {
     556           0 :             const SwFrm* pNxt = pTmp;
     557           0 :             while( --nRowSpan > 0 && pNxt->GetNext() )
     558           0 :                 pNxt = pNxt->GetNext();
     559           0 :             if( pTmp->IsVertical() )
     560           0 :                 nTmpLeft = (pNxt->Frm().*fnRect->fnGetLeft)();
     561             :             else
     562           0 :                 nTmpRight = (pNxt->Frm().*fnRect->fnGetRight)();
     563             :         }
     564             :         OSL_ENSURE( pTmp, "PaintArea lost in time and space" );
     565     2641353 :         if( pTmp->IsPageFrm() || pTmp->IsFlyFrm() ||
     566     2185016 :             pTmp->IsCellFrm() || pTmp->IsRowFrm() || //nobody leaves a table!
     567      393117 :             pTmp->IsRootFrm() )
     568             :         {
     569      375016 :             if( bLeft || nLeft < nTmpLeft )
     570      221029 :                 nLeft = nTmpLeft;
     571      375016 :             if( bRight || nTmpRight < nRight )
     572      221305 :                 nRight = nTmpRight;
     573      375016 :             if( pTmp->IsPageFrm() || pTmp->IsFlyFrm() || pTmp->IsRootFrm() )
     574      221365 :                 break;
     575      153651 :             bLeft = false;
     576      153651 :             bRight = false;
     577             :         }
     578      393117 :         else if( pTmp->IsColumnFrm() )  // nobody enters neightbour columns
     579             :         {
     580        2126 :             bool bR2L = pTmp->IsRightToLeft();
     581             :             // the first column has _no_ influence to the left range
     582        2126 :             if( bR2L ? pTmp->GetNext() : pTmp->GetPrev() )
     583             :             {
     584         666 :                 if( bLeft || nLeft < nTmpLeft )
     585         666 :                     nLeft = nTmpLeft;
     586         666 :                 bLeft = false;
     587             :             }
     588             :              // the last column has _no_ influence to the right range
     589        2126 :             if( bR2L ? pTmp->GetPrev() : pTmp->GetNext() )
     590             :             {
     591         982 :                 if( bRight || nTmpRight < nRight )
     592         982 :                     nRight = nTmpRight;
     593         982 :                 bRight = false;
     594             :             }
     595             :         }
     596      390991 :         else if( bVert && pTmp->IsBodyFrm() )
     597             :         {
     598             :             // Header and footer frames have always horizontal direction and
     599             :             // limit the body frame.
     600             :             // A previous frame of a body frame must be a header,
     601             :             // the next frame of a body frame may be a footnotecontainer or
     602             :             // a footer. The footnotecontainer has the same direction like
     603             :             // the body frame.
     604           0 :             if( pTmp->GetPrev() && ( bLeft || nLeft < nTmpLeft ) )
     605             :             {
     606           0 :                 nLeft = nTmpLeft;
     607           0 :                 bLeft = false;
     608             :             }
     609           0 :             if( pTmp->GetNext() &&
     610           0 :                 ( pTmp->GetNext()->IsFooterFrm() || pTmp->GetNext()->GetNext() )
     611           0 :                 && ( bRight || nTmpRight < nRight ) )
     612             :             {
     613           0 :                 nRight = nTmpRight;
     614           0 :                 bRight = false;
     615             :             }
     616             :         }
     617      546768 :         pTmp = pTmp->GetUpper();
     618             :     }
     619      221365 :     (aRect.*fnRect->fnSetLeft)( nLeft );
     620      221365 :     (aRect.*fnRect->fnSetRight)( nRight );
     621      221365 :     return aRect;
     622             : }
     623             : 
     624             : /**
     625             : |*  The unionframe is the framearea (Frm()) of a frame expanded by the
     626             : |*  printarea, if there's a negative margin at the left or right side.
     627             : |*/
     628       64575 : const SwRect SwFrm::UnionFrm( bool bBorder ) const
     629             : {
     630       64575 :     bool bVert = IsVertical();
     631       64575 :     SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
     632       64575 :     long nLeft = (Frm().*fnRect->fnGetLeft)();
     633       64575 :     long nWidth = (Frm().*fnRect->fnGetWidth)();
     634       64575 :     long nPrtLeft = (Prt().*fnRect->fnGetLeft)();
     635       64575 :     long nPrtWidth = (Prt().*fnRect->fnGetWidth)();
     636       64575 :     if( nPrtLeft + nPrtWidth > nWidth )
     637           6 :         nWidth = nPrtLeft + nPrtWidth;
     638       64575 :     if( nPrtLeft < 0 )
     639             :     {
     640          76 :         nLeft += nPrtLeft;
     641          76 :         nWidth -= nPrtLeft;
     642             :     }
     643       64575 :     SwTwips nRight = nLeft + nWidth;
     644       64575 :     long nAdd = 0;
     645       64575 :     if( bBorder )
     646             :     {
     647       43433 :         SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
     648       43433 :         const SwBorderAttrs &rAttrs = *aAccess.Get();
     649       43433 :         const SvxBoxItem &rBox = rAttrs.GetBox();
     650       43433 :         if ( rBox.GetLeft() )
     651          34 :             nLeft -= rBox.CalcLineSpace( BOX_LINE_LEFT );
     652       43399 :         else if ( rAttrs.IsBorderDist() )
     653           0 :             nLeft -= rBox.GetDistance( BOX_LINE_LEFT ) + 1;
     654       43433 :         if ( rBox.GetRight() )
     655          34 :             nAdd += rBox.CalcLineSpace( BOX_LINE_RIGHT );
     656       43399 :         else if ( rAttrs.IsBorderDist() )
     657           0 :             nAdd += rBox.GetDistance( BOX_LINE_RIGHT ) + 1;
     658       43433 :         if( rAttrs.GetShadow().GetLocation() != SVX_SHADOW_NONE )
     659             :         {
     660           0 :             const SvxShadowItem &rShadow = rAttrs.GetShadow();
     661           0 :             nLeft -= rShadow.CalcShadowSpace( SHADOW_LEFT );
     662           0 :             nAdd += rShadow.CalcShadowSpace( SHADOW_RIGHT );
     663       43433 :         }
     664             :     }
     665       64575 :     if( IsTxtFrm() && ((SwTxtFrm*)this)->HasPara() )
     666             :     {
     667       44744 :         long nTmp = ((SwTxtFrm*)this)->HangingMargin();
     668       44744 :         if( nTmp > nAdd )
     669           0 :             nAdd = nTmp;
     670             :     }
     671       64575 :     nWidth = nRight + nAdd - nLeft;
     672       64575 :     SwRect aRet( Frm() );
     673       64575 :     (aRet.*fnRect->fnSetPosX)( nLeft );
     674       64575 :     (aRet.*fnRect->fnSetWidth)( nWidth );
     675       64575 :     return aRet;
     676         270 : }
     677             : 
     678             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10