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

Generated by: LCOV version 1.10