xref: /aoo41x/main/sw/source/core/layout/ssfrm.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <ftnfrm.hxx>
28cdf0e10cSrcweir #include <pagefrm.hxx>
29cdf0e10cSrcweir #include <rootfrm.hxx>
30cdf0e10cSrcweir #include <cntfrm.hxx>
31cdf0e10cSrcweir #include <doc.hxx>
32cdf0e10cSrcweir #include <node.hxx>
33cdf0e10cSrcweir #include <dview.hxx>
34cdf0e10cSrcweir #include <dcontact.hxx>
35cdf0e10cSrcweir #include <dflyobj.hxx>
36cdf0e10cSrcweir #include <flyfrm.hxx>
37cdf0e10cSrcweir #include <txtfrm.hxx>		// ClearPara()
38cdf0e10cSrcweir #include <cellfrm.hxx>
39cdf0e10cSrcweir #include <swtable.hxx>
40cdf0e10cSrcweir #include <fmtfsize.hxx>
41cdf0e10cSrcweir #include <ftnidx.hxx>
42cdf0e10cSrcweir #include <txtftn.hxx>
43cdf0e10cSrcweir #include <ndtxt.hxx>
44cdf0e10cSrcweir #include <ndindex.hxx>
45cdf0e10cSrcweir #include <frmtool.hxx>
46cdf0e10cSrcweir #include <pagedesc.hxx>
47cdf0e10cSrcweir #include <editeng/boxitem.hxx>
48cdf0e10cSrcweir #include <editeng/shaditem.hxx>
49cdf0e10cSrcweir #include <fmtclds.hxx>
50cdf0e10cSrcweir #include <viewsh.hxx>
51cdf0e10cSrcweir #include <viewimp.hxx>
52cdf0e10cSrcweir #include <sortedobjs.hxx>
53cdf0e10cSrcweir #include <hints.hxx>
54cdf0e10cSrcweir #include <switerator.hxx>
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     // No inline cause we need the function pointers
GetTopMargin() const57cdf0e10cSrcweir long SwFrm::GetTopMargin() const
58cdf0e10cSrcweir     { return Prt().Top(); }
GetBottomMargin() const59cdf0e10cSrcweir long SwFrm::GetBottomMargin() const
60cdf0e10cSrcweir     { return Frm().Height() -Prt().Height() -Prt().Top(); }
GetLeftMargin() const61cdf0e10cSrcweir long SwFrm::GetLeftMargin() const
62cdf0e10cSrcweir     { return Prt().Left(); }
GetRightMargin() const63cdf0e10cSrcweir long SwFrm::GetRightMargin() const
64cdf0e10cSrcweir     { return Frm().Width() - Prt().Width() - Prt().Left(); }
GetPrtLeft() const65cdf0e10cSrcweir long SwFrm::GetPrtLeft() const
66cdf0e10cSrcweir     { return Frm().Left() + Prt().Left(); }
GetPrtBottom() const67cdf0e10cSrcweir long SwFrm::GetPrtBottom() const
68cdf0e10cSrcweir     { return Frm().Top() + Prt().Height() + Prt().Top(); }
GetPrtRight() const69cdf0e10cSrcweir long SwFrm::GetPrtRight() const
70cdf0e10cSrcweir     { return Frm().Left() + Prt().Width() + Prt().Left(); }
GetPrtTop() const71cdf0e10cSrcweir long SwFrm::GetPrtTop() const
72cdf0e10cSrcweir     { return Frm().Top() + Prt().Top(); }
73cdf0e10cSrcweir 
SetMinLeft(long nDeadline)74cdf0e10cSrcweir sal_Bool SwFrm::SetMinLeft( long nDeadline )
75cdf0e10cSrcweir {
76cdf0e10cSrcweir     SwTwips nDiff = nDeadline - Frm().Left();
77cdf0e10cSrcweir     if( nDiff > 0 )
78cdf0e10cSrcweir     {
79cdf0e10cSrcweir         Frm().Left( nDeadline );
80cdf0e10cSrcweir         Prt().Width( Prt().Width() - nDiff );
81cdf0e10cSrcweir         return sal_True;
82cdf0e10cSrcweir     }
83cdf0e10cSrcweir     return sal_False;
84cdf0e10cSrcweir }
85cdf0e10cSrcweir 
SetMaxBottom(long nDeadline)86cdf0e10cSrcweir sal_Bool SwFrm::SetMaxBottom( long nDeadline )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir     SwTwips nDiff = Frm().Top() + Frm().Height() - nDeadline;
89cdf0e10cSrcweir     if( nDiff > 0 )
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir         Frm().Height( Frm().Height() - nDiff );
92cdf0e10cSrcweir         Prt().Height( Prt().Height() - nDiff );
93cdf0e10cSrcweir         return sal_True;
94cdf0e10cSrcweir     }
95cdf0e10cSrcweir     return sal_False;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
SetMinTop(long nDeadline)98cdf0e10cSrcweir sal_Bool SwFrm::SetMinTop( long nDeadline )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir     SwTwips nDiff = nDeadline - Frm().Top();
101cdf0e10cSrcweir     if( nDiff > 0 )
102cdf0e10cSrcweir     {
103cdf0e10cSrcweir         Frm().Top( nDeadline );
104cdf0e10cSrcweir         Prt().Height( Prt().Height() - nDiff );
105cdf0e10cSrcweir         return sal_True;
106cdf0e10cSrcweir     }
107cdf0e10cSrcweir     return sal_False;
108cdf0e10cSrcweir }
109cdf0e10cSrcweir 
SetMaxRight(long nDeadline)110cdf0e10cSrcweir sal_Bool SwFrm::SetMaxRight( long nDeadline )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir     SwTwips nDiff = Frm().Left() + Frm().Width() - nDeadline;
113cdf0e10cSrcweir     if( nDiff > 0 )
114cdf0e10cSrcweir     {
115cdf0e10cSrcweir         Frm().Width( Frm().Width() - nDiff );
116cdf0e10cSrcweir         Prt().Width( Prt().Width() - nDiff );
117cdf0e10cSrcweir         return sal_True;
118cdf0e10cSrcweir     }
119cdf0e10cSrcweir     return sal_False;
120cdf0e10cSrcweir }
121cdf0e10cSrcweir 
MakeBelowPos(const SwFrm * pUp,const SwFrm * pPrv,sal_Bool bNotify)122cdf0e10cSrcweir void SwFrm::MakeBelowPos( const SwFrm* pUp, const SwFrm* pPrv, sal_Bool bNotify )
123cdf0e10cSrcweir {
124cdf0e10cSrcweir     if( pPrv )
125cdf0e10cSrcweir     {
126cdf0e10cSrcweir         aFrm.Pos( pPrv->Frm().Pos() );
127cdf0e10cSrcweir         aFrm.Pos().Y() += pPrv->Frm().Height();
128cdf0e10cSrcweir     }
129cdf0e10cSrcweir     else
130cdf0e10cSrcweir     {
131cdf0e10cSrcweir         aFrm.Pos( pUp->Frm().Pos() );
132cdf0e10cSrcweir         aFrm.Pos() += pUp->Prt().Pos();
133cdf0e10cSrcweir     }
134cdf0e10cSrcweir     if( bNotify )
135cdf0e10cSrcweir         aFrm.Pos().Y() += 1;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
MakeUpperPos(const SwFrm * pUp,const SwFrm * pPrv,sal_Bool bNotify)138cdf0e10cSrcweir void SwFrm::MakeUpperPos( const SwFrm* pUp, const SwFrm* pPrv, sal_Bool bNotify )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir     if( pPrv )
141cdf0e10cSrcweir     {
142cdf0e10cSrcweir         aFrm.Pos( pPrv->Frm().Pos() );
143cdf0e10cSrcweir         aFrm.Pos().Y() -= Frm().Height();
144cdf0e10cSrcweir     }
145cdf0e10cSrcweir     else
146cdf0e10cSrcweir     {
147cdf0e10cSrcweir         aFrm.Pos( pUp->Frm().Pos() );
148cdf0e10cSrcweir         aFrm.Pos() += pUp->Prt().Pos();
149cdf0e10cSrcweir         aFrm.Pos().Y() += pUp->Prt().Height() - aFrm.Height();
150cdf0e10cSrcweir     }
151cdf0e10cSrcweir     if( bNotify )
152cdf0e10cSrcweir         aFrm.Pos().Y() -= 1;
153cdf0e10cSrcweir }
154cdf0e10cSrcweir 
MakeLeftPos(const SwFrm * pUp,const SwFrm * pPrv,sal_Bool bNotify)155cdf0e10cSrcweir void SwFrm::MakeLeftPos( const SwFrm* pUp, const SwFrm* pPrv, sal_Bool bNotify )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     if( pPrv )
158cdf0e10cSrcweir     {
159cdf0e10cSrcweir         aFrm.Pos( pPrv->Frm().Pos() );
160cdf0e10cSrcweir         aFrm.Pos().X() -= Frm().Width();
161cdf0e10cSrcweir     }
162cdf0e10cSrcweir     else
163cdf0e10cSrcweir     {
164cdf0e10cSrcweir         aFrm.Pos( pUp->Frm().Pos() );
165cdf0e10cSrcweir         aFrm.Pos() += pUp->Prt().Pos();
166cdf0e10cSrcweir         aFrm.Pos().X() += pUp->Prt().Width() - aFrm.Width();
167cdf0e10cSrcweir     }
168cdf0e10cSrcweir     if( bNotify )
169cdf0e10cSrcweir         aFrm.Pos().X() -= 1;
170cdf0e10cSrcweir }
171cdf0e10cSrcweir 
MakeRightPos(const SwFrm * pUp,const SwFrm * pPrv,sal_Bool bNotify)172cdf0e10cSrcweir void SwFrm::MakeRightPos( const SwFrm* pUp, const SwFrm* pPrv, sal_Bool bNotify )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir     if( pPrv )
175cdf0e10cSrcweir     {
176cdf0e10cSrcweir         aFrm.Pos( pPrv->Frm().Pos() );
177cdf0e10cSrcweir         aFrm.Pos().X() += pPrv->Frm().Width();
178cdf0e10cSrcweir     }
179cdf0e10cSrcweir     else
180cdf0e10cSrcweir     {
181cdf0e10cSrcweir         aFrm.Pos( pUp->Frm().Pos() );
182cdf0e10cSrcweir         aFrm.Pos() += pUp->Prt().Pos();
183cdf0e10cSrcweir     }
184cdf0e10cSrcweir     if( bNotify )
185cdf0e10cSrcweir         aFrm.Pos().X() += 1;
186cdf0e10cSrcweir }
187cdf0e10cSrcweir 
SetTopBottomMargins(long nTop,long nBot)188cdf0e10cSrcweir void SwFrm::SetTopBottomMargins( long nTop, long nBot )
189cdf0e10cSrcweir {
190cdf0e10cSrcweir     Prt().Top( nTop );
191cdf0e10cSrcweir     Prt().Height( Frm().Height() - nTop - nBot );
192cdf0e10cSrcweir }
193cdf0e10cSrcweir 
SetBottomTopMargins(long nBot,long nTop)194cdf0e10cSrcweir void SwFrm::SetBottomTopMargins( long nBot, long nTop )
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     Prt().Top( nTop );
197cdf0e10cSrcweir     Prt().Height( Frm().Height() - nTop - nBot );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
SetLeftRightMargins(long nLeft,long nRight)200cdf0e10cSrcweir void SwFrm::SetLeftRightMargins( long nLeft, long nRight)
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     Prt().Left( nLeft );
203cdf0e10cSrcweir     Prt().Width( Frm().Width() - nLeft - nRight );
204cdf0e10cSrcweir }
205cdf0e10cSrcweir 
SetRightLeftMargins(long nRight,long nLeft)206cdf0e10cSrcweir void SwFrm::SetRightLeftMargins( long nRight, long nLeft)
207cdf0e10cSrcweir {
208cdf0e10cSrcweir     Prt().Left( nLeft );
209cdf0e10cSrcweir     Prt().Width( Frm().Width() - nLeft - nRight );
210cdf0e10cSrcweir }
211cdf0e10cSrcweir 
212cdf0e10cSrcweir const sal_uInt16 nMinVertCellHeight = 1135;
213cdf0e10cSrcweir 
214cdf0e10cSrcweir /*-----------------------------------
215cdf0e10cSrcweir  * SwFrm::CheckDirChange(..)
216cdf0e10cSrcweir  * checks the layout direction and
217cdf0e10cSrcweir  * invalidates the lower frames rekursivly, if necessary.
218cdf0e10cSrcweir  * --------------------------------------------------*/
219cdf0e10cSrcweir 
CheckDirChange()220cdf0e10cSrcweir void SwFrm::CheckDirChange()
221cdf0e10cSrcweir {
222cdf0e10cSrcweir     sal_Bool bOldVert = GetVerticalFlag();
223cdf0e10cSrcweir     sal_Bool bOldRev = IsReverse();
224cdf0e10cSrcweir     sal_Bool bOldR2L = GetRightToLeftFlag();
225cdf0e10cSrcweir     SetInvalidVert( sal_True );
226cdf0e10cSrcweir     SetInvalidR2L( sal_True );
227cdf0e10cSrcweir     sal_Bool bChg = bOldR2L != IsRightToLeft();
228cdf0e10cSrcweir     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
229cdf0e10cSrcweir     sal_Bool bOldVertL2R = IsVertLR();
230cdf0e10cSrcweir     if( ( IsVertical() != bOldVert ) || bChg || IsReverse() != bOldRev || bOldVertL2R != IsVertLR() )
231cdf0e10cSrcweir     {
232cdf0e10cSrcweir         InvalidateAll();
233cdf0e10cSrcweir         if( IsLayoutFrm() )
234cdf0e10cSrcweir         {
235cdf0e10cSrcweir             // set minimum row height for vertical cells in horizontal table:
236cdf0e10cSrcweir             if ( IsCellFrm() && GetUpper() )
237cdf0e10cSrcweir             {
238cdf0e10cSrcweir                 if ( IsVertical() != GetUpper()->IsVertical() &&
239cdf0e10cSrcweir                      ((SwCellFrm*)this)->GetTabBox()->getRowSpan() == 1 )
240cdf0e10cSrcweir                 {
241cdf0e10cSrcweir                     SwTableLine* pLine = (SwTableLine*)((SwCellFrm*)this)->GetTabBox()->GetUpper();
242cdf0e10cSrcweir                     SwFrmFmt* pFrmFmt = pLine->GetFrmFmt();
243cdf0e10cSrcweir                     SwFmtFrmSize aNew( pFrmFmt->GetFrmSize() );
244cdf0e10cSrcweir                     if ( ATT_FIX_SIZE != aNew.GetHeightSizeType() )
245cdf0e10cSrcweir                         aNew.SetHeightSizeType( ATT_MIN_SIZE );
246cdf0e10cSrcweir                     if ( aNew.GetHeight() < nMinVertCellHeight )
247cdf0e10cSrcweir                         aNew.SetHeight( nMinVertCellHeight );
248cdf0e10cSrcweir                     SwDoc* pDoc = pFrmFmt->GetDoc();
249cdf0e10cSrcweir                     pDoc->SetAttr( aNew, *pLine->ClaimFrmFmt() );
250cdf0e10cSrcweir                 }
251cdf0e10cSrcweir             }
252cdf0e10cSrcweir 
253cdf0e10cSrcweir             SwFrm* pFrm = ((SwLayoutFrm*)this)->Lower();
254cdf0e10cSrcweir             const SwFmtCol* pCol = NULL;
255cdf0e10cSrcweir             SwLayoutFrm* pBody = 0;
256cdf0e10cSrcweir             if( pFrm )
257cdf0e10cSrcweir             {
258cdf0e10cSrcweir                 if( IsPageFrm() )
259cdf0e10cSrcweir                 {
260cdf0e10cSrcweir                     // If we're a page frame and we change our layout direction,
261cdf0e10cSrcweir                     // we have to look for columns and rearrange them.
262cdf0e10cSrcweir                     pBody = ((SwPageFrm*)this)->FindBodyCont();
263cdf0e10cSrcweir                     if(pBody && pBody->Lower() && pBody->Lower()->IsColumnFrm())
264cdf0e10cSrcweir                         pCol = &((SwPageFrm*)this)->GetFmt()->GetCol();
265cdf0e10cSrcweir                 }
266cdf0e10cSrcweir                 else if( pFrm->IsColumnFrm() )
267cdf0e10cSrcweir                 {
268cdf0e10cSrcweir                     pBody = ((SwLayoutFrm*)this);
269cdf0e10cSrcweir                     const SwFrmFmt *pFmt = pBody->GetFmt();
270cdf0e10cSrcweir                     if( pFmt )
271cdf0e10cSrcweir                         pCol = &pFmt->GetCol();
272cdf0e10cSrcweir                 }
273cdf0e10cSrcweir             }
274cdf0e10cSrcweir             while( pFrm )
275cdf0e10cSrcweir             {
276cdf0e10cSrcweir                 pFrm->CheckDirChange();
277cdf0e10cSrcweir                 pFrm = pFrm->GetNext();
278cdf0e10cSrcweir             }
279cdf0e10cSrcweir             if( pCol )
280cdf0e10cSrcweir                 pBody->AdjustColumns( pCol, sal_True );
281cdf0e10cSrcweir         }
282cdf0e10cSrcweir         else if( IsTxtFrm() )
283cdf0e10cSrcweir             ((SwTxtFrm*)this)->Prepare( PREP_CLEAR );
284cdf0e10cSrcweir 
285cdf0e10cSrcweir         // --> OD 2004-07-27 #i31698# - notify anchored objects also for page frames.
286cdf0e10cSrcweir         // Remove code above for special handling of page frames
287cdf0e10cSrcweir         if ( GetDrawObjs() )
288cdf0e10cSrcweir         {
289cdf0e10cSrcweir             const SwSortedObjs *pObjs = GetDrawObjs();
290cdf0e10cSrcweir             sal_uInt32 nCnt = pObjs->Count();
291cdf0e10cSrcweir             for ( sal_uInt32 i = 0; i < nCnt; ++i )
292cdf0e10cSrcweir             {
293cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
294cdf0e10cSrcweir                 if( pAnchoredObj->ISA(SwFlyFrm) )
295cdf0e10cSrcweir                     static_cast<SwFlyFrm*>(pAnchoredObj)->CheckDirChange();
296cdf0e10cSrcweir                 else
297cdf0e10cSrcweir                 {
298cdf0e10cSrcweir                     // OD 2004-04-06 #i26791# - direct object
299cdf0e10cSrcweir                     // positioning no longer needed. Instead
300cdf0e10cSrcweir                     // invalidate
301cdf0e10cSrcweir                     pAnchoredObj->InvalidateObjPos();
302cdf0e10cSrcweir                 }
303cdf0e10cSrcweir                 // --> OD 2004-07-27 #i31698# - update layout direction of
304cdf0e10cSrcweir                 // anchored object
305cdf0e10cSrcweir                 {
306cdf0e10cSrcweir                     ::setContextWritingMode( pAnchoredObj->DrawObj(), pAnchoredObj->GetAnchorFrmContainingAnchPos() );
307cdf0e10cSrcweir                     pAnchoredObj->UpdateLayoutDir();
308cdf0e10cSrcweir                 }
309cdf0e10cSrcweir                 // <--
310cdf0e10cSrcweir             }
311cdf0e10cSrcweir         }
312cdf0e10cSrcweir     }
313cdf0e10cSrcweir }
314cdf0e10cSrcweir 
315cdf0e10cSrcweir /*-----------------------------------
316cdf0e10cSrcweir  * SwFrm::GetFrmAnchorPos(..)
317cdf0e10cSrcweir  * returns the position for anchors based on frame direction
318cdf0e10cSrcweir  * --------------------------------------------------*/
319cdf0e10cSrcweir // OD 2004-03-10 #i11860# - consider lower space and line spacing of
320cdf0e10cSrcweir // previous frame according to new option 'Use former object positioning'
GetFrmAnchorPos(sal_Bool bIgnoreFlysAnchoredAtThisFrame) const321cdf0e10cSrcweir Point SwFrm::GetFrmAnchorPos( sal_Bool bIgnoreFlysAnchoredAtThisFrame ) const
322cdf0e10cSrcweir {
323cdf0e10cSrcweir     Point aAnchor = Frm().Pos();
324cdf0e10cSrcweir     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
325cdf0e10cSrcweir     if ( ( IsVertical() && !IsVertLR() ) || IsRightToLeft() )
326cdf0e10cSrcweir 		aAnchor.X() += Frm().Width();
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     if ( IsTxtFrm() )
329cdf0e10cSrcweir     {
330cdf0e10cSrcweir         SwTwips nBaseOfstForFly =
331cdf0e10cSrcweir             ((SwTxtFrm*)this)->GetBaseOfstForFly( bIgnoreFlysAnchoredAtThisFrame );
332cdf0e10cSrcweir         if ( IsVertical() )
333cdf0e10cSrcweir             aAnchor.Y() += nBaseOfstForFly;
334cdf0e10cSrcweir         else
335cdf0e10cSrcweir             aAnchor.X() += nBaseOfstForFly;
336cdf0e10cSrcweir 
337cdf0e10cSrcweir         // OD 2004-03-10 #i11860# - if option 'Use former object positioning'
338cdf0e10cSrcweir         // is OFF, consider the lower space and the line spacing of the
339cdf0e10cSrcweir         // previous frame and the spacing considered for the page grid
340cdf0e10cSrcweir         const SwTxtFrm* pThisTxtFrm = static_cast<const SwTxtFrm*>(this);
341cdf0e10cSrcweir         const SwTwips nUpperSpaceAmountConsideredForPrevFrmAndPageGrid =
342cdf0e10cSrcweir                 pThisTxtFrm->GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
343cdf0e10cSrcweir         if ( IsVertical() )
344cdf0e10cSrcweir         {
345cdf0e10cSrcweir             aAnchor.X() -= nUpperSpaceAmountConsideredForPrevFrmAndPageGrid;
346cdf0e10cSrcweir         }
347cdf0e10cSrcweir         else
348cdf0e10cSrcweir         {
349cdf0e10cSrcweir             aAnchor.Y() += nUpperSpaceAmountConsideredForPrevFrmAndPageGrid;
350cdf0e10cSrcweir         }
351cdf0e10cSrcweir     }
352cdf0e10cSrcweir 
353cdf0e10cSrcweir     return aAnchor;
354cdf0e10cSrcweir }
355cdf0e10cSrcweir 
356cdf0e10cSrcweir 
357cdf0e10cSrcweir /*************************************************************************
358cdf0e10cSrcweir |*
359cdf0e10cSrcweir |*	SwFrm::~SwFrm()
360cdf0e10cSrcweir |*
361cdf0e10cSrcweir |*************************************************************************/
362cdf0e10cSrcweir 
~SwFrm()363cdf0e10cSrcweir SwFrm::~SwFrm()
364cdf0e10cSrcweir {
365cdf0e10cSrcweir 	// accessible objects for fly and cell frames have been already disposed
366cdf0e10cSrcweir 	// by the destructors of the derived classes.
367cdf0e10cSrcweir 	if( IsAccessibleFrm() && !(IsFlyFrm() || IsCellFrm()) && GetDep() )
368cdf0e10cSrcweir 	{
369cdf0e10cSrcweir 		SwRootFrm *pRootFrm = getRootFrm();
370cdf0e10cSrcweir 		if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
371cdf0e10cSrcweir 		{
372cdf0e10cSrcweir 			ViewShell *pVSh = pRootFrm->GetCurrShell();
373cdf0e10cSrcweir 			if( pVSh && pVSh->Imp() )
374cdf0e10cSrcweir 			{
375cdf0e10cSrcweir 				ASSERT( !GetLower(), "Lowers should be dispose already!" );
376cdf0e10cSrcweir 				pVSh->Imp()->DisposeAccessibleFrm( this );
377cdf0e10cSrcweir 			}
378cdf0e10cSrcweir 		}
379cdf0e10cSrcweir 	}
380cdf0e10cSrcweir 
381cdf0e10cSrcweir 	if( pDrawObjs )
382cdf0e10cSrcweir 	{
383cdf0e10cSrcweir         for ( sal_uInt32 i = pDrawObjs->Count(); i; )
384cdf0e10cSrcweir 		{
385cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pDrawObjs)[--i];
386cdf0e10cSrcweir             if ( pAnchoredObj->ISA(SwFlyFrm) )
387cdf0e10cSrcweir                 delete pAnchoredObj;
388cdf0e10cSrcweir             else
389cdf0e10cSrcweir             {
390cdf0e10cSrcweir                 SdrObject* pSdrObj = pAnchoredObj->DrawObj();
391cdf0e10cSrcweir                 SwDrawContact* pContact =
392cdf0e10cSrcweir                         static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
393cdf0e10cSrcweir                 ASSERT( pContact,
394cdf0e10cSrcweir                         "<SwFrm::~SwFrm> - missing contact for drawing object" );
395cdf0e10cSrcweir                 if ( pContact )
396cdf0e10cSrcweir                 {
397cdf0e10cSrcweir                     pContact->DisconnectObjFromLayout( pSdrObj );
398cdf0e10cSrcweir                 }
399cdf0e10cSrcweir             }
400cdf0e10cSrcweir 		}
401cdf0e10cSrcweir 		if ( pDrawObjs )
402cdf0e10cSrcweir 			delete pDrawObjs;
403cdf0e10cSrcweir 	}
404cdf0e10cSrcweir 
405cdf0e10cSrcweir #ifdef DBG_UTIL
406cdf0e10cSrcweir 	// JP 15.10.2001: for detection of access to deleted frames
407cdf0e10cSrcweir     pDrawObjs = (SwSortedObjs*)0x33333333;
408cdf0e10cSrcweir #endif
409cdf0e10cSrcweir }
410cdf0e10cSrcweir 
411cdf0e10cSrcweir /*************************************************************************/
412cdf0e10cSrcweir 
GetFmt() const413cdf0e10cSrcweir const SwFrmFmt * SwLayoutFrm::GetFmt() const
414cdf0e10cSrcweir {
415cdf0e10cSrcweir     return static_cast< const SwFlyFrmFmt * >( GetDep() );
416cdf0e10cSrcweir }
417cdf0e10cSrcweir 
GetFmt()418cdf0e10cSrcweir SwFrmFmt * SwLayoutFrm::GetFmt()
419cdf0e10cSrcweir {
420cdf0e10cSrcweir     return static_cast< SwFlyFrmFmt * >( GetDep() );
421cdf0e10cSrcweir }
422cdf0e10cSrcweir 
423cdf0e10cSrcweir 
424cdf0e10cSrcweir /*************************************************************************
425cdf0e10cSrcweir |*
426cdf0e10cSrcweir |*	  SwLayoutFrm::SetFrmFmt()
427cdf0e10cSrcweir |*
428cdf0e10cSrcweir |*************************************************************************/
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 
SetFrmFmt(SwFrmFmt * pNew)431cdf0e10cSrcweir void SwLayoutFrm::SetFrmFmt( SwFrmFmt *pNew )
432cdf0e10cSrcweir {
433cdf0e10cSrcweir 	if ( pNew != GetFmt() )
434cdf0e10cSrcweir 	{
435cdf0e10cSrcweir 		SwFmtChg aOldFmt( GetFmt() );
436cdf0e10cSrcweir 		pNew->Add( this );
437cdf0e10cSrcweir 		SwFmtChg aNewFmt( pNew );
438cdf0e10cSrcweir 		ModifyNotification( &aOldFmt, &aNewFmt );
439cdf0e10cSrcweir 	}
440cdf0e10cSrcweir }
441cdf0e10cSrcweir 
442cdf0e10cSrcweir /*************************************************************************
443cdf0e10cSrcweir |*                  SwCntntFrm::SwCntntFrm()
444cdf0e10cSrcweir |*************************************************************************/
SwCntntFrm(SwCntntNode * const pCntnt,SwFrm * pSib)445cdf0e10cSrcweir SwCntntFrm::SwCntntFrm( SwCntntNode * const pCntnt, SwFrm* pSib ) :
446cdf0e10cSrcweir 	SwFrm( pCntnt, pSib ),
447cdf0e10cSrcweir 	SwFlowFrm( (SwFrm&)*this )
448cdf0e10cSrcweir {
449cdf0e10cSrcweir }
450cdf0e10cSrcweir 
451cdf0e10cSrcweir /*************************************************************************
452cdf0e10cSrcweir |*                  SwCntntFrm::~SwCntntFrm()
453cdf0e10cSrcweir |*************************************************************************/
~SwCntntFrm()454cdf0e10cSrcweir SwCntntFrm::~SwCntntFrm()
455cdf0e10cSrcweir {
456cdf0e10cSrcweir 	SwCntntNode* pCNd;
457cdf0e10cSrcweir 	if( 0 != ( pCNd = PTR_CAST( SwCntntNode, GetRegisteredIn() )) &&
458cdf0e10cSrcweir 		!pCNd->GetDoc()->IsInDtor() )
459cdf0e10cSrcweir 	{
460cdf0e10cSrcweir 		//Bei der Root abmelden wenn ich dort noch im Turbo stehe.
461cdf0e10cSrcweir 		SwRootFrm *pRoot = getRootFrm();
462cdf0e10cSrcweir 		if( pRoot && pRoot->GetTurbo() == this )
463cdf0e10cSrcweir 		{
464cdf0e10cSrcweir 			pRoot->DisallowTurbo();
465cdf0e10cSrcweir 			pRoot->ResetTurbo();
466cdf0e10cSrcweir 		}
467cdf0e10cSrcweir         if( IsTxtFrm() && ((SwTxtFrm*)this)->HasFtn() )
468cdf0e10cSrcweir         {
469cdf0e10cSrcweir             SwTxtNode *pTxtNd = ((SwTxtFrm*)this)->GetTxtNode();
470cdf0e10cSrcweir             const SwFtnIdxs &rFtnIdxs = pCNd->GetDoc()->GetFtnIdxs();
471cdf0e10cSrcweir             sal_uInt16 nPos;
472cdf0e10cSrcweir             sal_uLong nIndex = pCNd->GetIndex();
473cdf0e10cSrcweir             rFtnIdxs.SeekEntry( *pTxtNd, &nPos );
474cdf0e10cSrcweir             SwTxtFtn* pTxtFtn;
475cdf0e10cSrcweir             if( nPos < rFtnIdxs.Count() )
476cdf0e10cSrcweir             {
477cdf0e10cSrcweir                 while( nPos && pTxtNd == &(rFtnIdxs[ nPos ]->GetTxtNode()) )
478cdf0e10cSrcweir                     --nPos;
479cdf0e10cSrcweir                 if( nPos || pTxtNd != &(rFtnIdxs[ nPos ]->GetTxtNode()) )
480cdf0e10cSrcweir                     ++nPos;
481cdf0e10cSrcweir             }
482cdf0e10cSrcweir             while( nPos < rFtnIdxs.Count() )
483cdf0e10cSrcweir             {
484cdf0e10cSrcweir                 pTxtFtn = rFtnIdxs[ nPos ];
485cdf0e10cSrcweir                 if( pTxtFtn->GetTxtNode().GetIndex() > nIndex )
486cdf0e10cSrcweir                     break;
487cdf0e10cSrcweir                 pTxtFtn->DelFrms( this );
488cdf0e10cSrcweir                 ++nPos;
489cdf0e10cSrcweir             }
490cdf0e10cSrcweir         }
491cdf0e10cSrcweir 	}
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
RegisterToNode(SwCntntNode & rNode)494cdf0e10cSrcweir void SwCntntFrm::RegisterToNode( SwCntntNode& rNode )
495cdf0e10cSrcweir {
496cdf0e10cSrcweir     rNode.Add( this );
497cdf0e10cSrcweir }
498cdf0e10cSrcweir 
DelFrms(const SwCntntNode & rNode)499cdf0e10cSrcweir void SwCntntFrm::DelFrms( const SwCntntNode& rNode )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir 	SwIterator<SwCntntFrm,SwCntntNode> aIter( rNode );
502cdf0e10cSrcweir 	for( SwCntntFrm* pFrm = aIter.First(); pFrm; pFrm = aIter.Next() )
503cdf0e10cSrcweir 	{
504cdf0e10cSrcweir         // --> OD 2005-12-01 #i27138#
505cdf0e10cSrcweir         // notify accessibility paragraphs objects about changed
506cdf0e10cSrcweir         // CONTENT_FLOWS_FROM/_TO relation.
507cdf0e10cSrcweir         // Relation CONTENT_FLOWS_FROM for current next paragraph will change
508cdf0e10cSrcweir         // and relation CONTENT_FLOWS_TO for current previous paragraph will change.
509cdf0e10cSrcweir         if ( pFrm->IsTxtFrm() )
510cdf0e10cSrcweir         {
511cdf0e10cSrcweir             ViewShell* pViewShell( pFrm->getRootFrm()->GetCurrShell() );
512cdf0e10cSrcweir             if ( pViewShell && pViewShell->GetLayout() &&
513cdf0e10cSrcweir                  pViewShell->GetLayout()->IsAnyShellAccessible() )
514cdf0e10cSrcweir             {
515cdf0e10cSrcweir                 pViewShell->InvalidateAccessibleParaFlowRelation(
516cdf0e10cSrcweir                             dynamic_cast<SwTxtFrm*>(pFrm->FindNextCnt( true )),
517cdf0e10cSrcweir                             dynamic_cast<SwTxtFrm*>(pFrm->FindPrevCnt( true )) );
518cdf0e10cSrcweir             }
519cdf0e10cSrcweir         }
520cdf0e10cSrcweir         // <--
521cdf0e10cSrcweir         if( pFrm->HasFollow() )
522cdf0e10cSrcweir             pFrm->GetFollow()->_SetIsFollow( pFrm->IsFollow() );
523cdf0e10cSrcweir         if( pFrm->IsFollow() )
524cdf0e10cSrcweir         {
525cdf0e10cSrcweir             SwCntntFrm* pMaster = (SwTxtFrm*)pFrm->FindMaster();
526cdf0e10cSrcweir             pMaster->SetFollow( pFrm->GetFollow() );
527cdf0e10cSrcweir             pFrm->_SetIsFollow( sal_False );
528cdf0e10cSrcweir         }
529cdf0e10cSrcweir 		pFrm->SetFollow( 0 );//Damit er nicht auf dumme Gedanken kommt.
530cdf0e10cSrcweir 								//Andernfalls kann es sein, dass ein Follow
531cdf0e10cSrcweir 								//vor seinem Master zerstoert wird, der Master
532cdf0e10cSrcweir 								//greift dann ueber den ungueltigen
533cdf0e10cSrcweir 								//Follow-Pointer auf fremdes Memory zu.
534cdf0e10cSrcweir 								//Die Kette darf hier zerknauscht werden, weil
535cdf0e10cSrcweir 								//sowieso alle zerstoert werden.
536cdf0e10cSrcweir 		if( pFrm->GetUpper() && pFrm->IsInFtn() && !pFrm->GetIndNext() &&
537cdf0e10cSrcweir 			!pFrm->GetIndPrev() )
538cdf0e10cSrcweir 		{
539cdf0e10cSrcweir 			SwFtnFrm *pFtn = pFrm->FindFtnFrm();
540cdf0e10cSrcweir 			ASSERT( pFtn, "You promised a FtnFrm?" );
541cdf0e10cSrcweir 			SwCntntFrm* pCFrm;
542cdf0e10cSrcweir 			if( !pFtn->GetFollow() && !pFtn->GetMaster() &&
543cdf0e10cSrcweir 				0 != ( pCFrm = pFtn->GetRefFromAttr()) && pCFrm->IsFollow() )
544cdf0e10cSrcweir 			{
545cdf0e10cSrcweir 				ASSERT( pCFrm->IsTxtFrm(), "NoTxtFrm has Footnote?" );
546cdf0e10cSrcweir 				((SwTxtFrm*)pCFrm->FindMaster())->Prepare( PREP_FTN_GONE );
547cdf0e10cSrcweir 			}
548cdf0e10cSrcweir 		}
549cdf0e10cSrcweir 		pFrm->Cut();
550cdf0e10cSrcweir 		delete pFrm;
551cdf0e10cSrcweir 	}
552cdf0e10cSrcweir }
553cdf0e10cSrcweir 
554cdf0e10cSrcweir /*************************************************************************
555cdf0e10cSrcweir |*
556cdf0e10cSrcweir |*	SwLayoutFrm::~SwLayoutFrm
557cdf0e10cSrcweir |*
558cdf0e10cSrcweir |*************************************************************************/
559cdf0e10cSrcweir 
560cdf0e10cSrcweir 
~SwLayoutFrm()561cdf0e10cSrcweir SwLayoutFrm::~SwLayoutFrm()
562cdf0e10cSrcweir {
563cdf0e10cSrcweir 	SwFrm *pFrm = pLower;
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 	if( GetFmt() && !GetFmt()->GetDoc()->IsInDtor() )
566cdf0e10cSrcweir 	{
567cdf0e10cSrcweir         while ( pFrm )
568cdf0e10cSrcweir 		{
569cdf0e10cSrcweir 			//Erst die Objs des Frm vernichten, denn diese koennen sich sonst nach
570cdf0e10cSrcweir 			//dem Remove nicht mehr bei der Seite abmelden.
571cdf0e10cSrcweir 			//Falls sich einer nicht abmeldet wollen wir nicht gleich
572cdf0e10cSrcweir 			//endlos schleifen.
573cdf0e10cSrcweir 
574cdf0e10cSrcweir             sal_uInt32 nCnt;
575cdf0e10cSrcweir 			while ( pFrm->GetDrawObjs() && pFrm->GetDrawObjs()->Count() )
576cdf0e10cSrcweir 			{
577cdf0e10cSrcweir 				nCnt = pFrm->GetDrawObjs()->Count();
578cdf0e10cSrcweir                 // --> OD 2004-06-30 #i28701#
579cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[0];
580cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyFrm) )
581cdf0e10cSrcweir                     delete pAnchoredObj;
582cdf0e10cSrcweir                 else
583cdf0e10cSrcweir                 {
584cdf0e10cSrcweir                     SdrObject* pSdrObj = pAnchoredObj->DrawObj();
585cdf0e10cSrcweir                     SwDrawContact* pContact =
586cdf0e10cSrcweir                             static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
587cdf0e10cSrcweir                     ASSERT( pContact,
588cdf0e10cSrcweir                             "<SwFrm::~SwFrm> - missing contact for drawing object" );
589cdf0e10cSrcweir                     if ( pContact )
590cdf0e10cSrcweir                     {
591cdf0e10cSrcweir                         pContact->DisconnectObjFromLayout( pSdrObj );
592cdf0e10cSrcweir                     }
593cdf0e10cSrcweir                 }
594cdf0e10cSrcweir 				if ( pFrm->GetDrawObjs() &&
595cdf0e10cSrcweir 					 nCnt == pFrm->GetDrawObjs()->Count() )
596cdf0e10cSrcweir                 {
597cdf0e10cSrcweir                     pFrm->GetDrawObjs()->Remove( *pAnchoredObj );
598cdf0e10cSrcweir                 }
599cdf0e10cSrcweir                 // <--
600cdf0e10cSrcweir 			}
601cdf0e10cSrcweir 			pFrm->Remove();
602cdf0e10cSrcweir 			delete pFrm;
603cdf0e10cSrcweir 			pFrm = pLower;
604cdf0e10cSrcweir 		}
605cdf0e10cSrcweir 		//Fly's vernichten. Der letzte loescht gleich das Array.
606cdf0e10cSrcweir         sal_uInt32 nCnt;
607cdf0e10cSrcweir 		while ( GetDrawObjs() && GetDrawObjs()->Count() )
608cdf0e10cSrcweir 		{
609cdf0e10cSrcweir 			nCnt = GetDrawObjs()->Count();
610cdf0e10cSrcweir 
611cdf0e10cSrcweir             // --> OD 2004-06-30 #i28701#
612cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[0];
613cdf0e10cSrcweir             if ( pAnchoredObj->ISA(SwFlyFrm) )
614cdf0e10cSrcweir                 delete pAnchoredObj;
615cdf0e10cSrcweir             else
616cdf0e10cSrcweir             {
617cdf0e10cSrcweir                 SdrObject* pSdrObj = pAnchoredObj->DrawObj();
618cdf0e10cSrcweir                 SwDrawContact* pContact =
619cdf0e10cSrcweir                         static_cast<SwDrawContact*>(pSdrObj->GetUserCall());
620cdf0e10cSrcweir                 ASSERT( pContact,
621cdf0e10cSrcweir                         "<SwFrm::~SwFrm> - missing contact for drawing object" );
622cdf0e10cSrcweir                 if ( pContact )
623cdf0e10cSrcweir                 {
624cdf0e10cSrcweir                     pContact->DisconnectObjFromLayout( pSdrObj );
625cdf0e10cSrcweir                 }
626cdf0e10cSrcweir             }
627cdf0e10cSrcweir             if ( GetDrawObjs() && nCnt == GetDrawObjs()->Count() )
628cdf0e10cSrcweir             {
629cdf0e10cSrcweir                 GetDrawObjs()->Remove( *pAnchoredObj );
630cdf0e10cSrcweir             }
631cdf0e10cSrcweir             // <--
632cdf0e10cSrcweir 		}
633cdf0e10cSrcweir 	}
634cdf0e10cSrcweir 	else
635cdf0e10cSrcweir 	{
636cdf0e10cSrcweir 		while( pFrm )
637cdf0e10cSrcweir 		{
638cdf0e10cSrcweir 			SwFrm *pNxt = pFrm->GetNext();
639cdf0e10cSrcweir 			delete pFrm;
640cdf0e10cSrcweir 			pFrm = pNxt;
641cdf0e10cSrcweir 		}
642cdf0e10cSrcweir 	}
643cdf0e10cSrcweir }
644cdf0e10cSrcweir 
645cdf0e10cSrcweir /*************************************************************************
646cdf0e10cSrcweir |*
647cdf0e10cSrcweir |*	SwFrm::PaintArea()
648cdf0e10cSrcweir |*
649cdf0e10cSrcweir |*  The paintarea is the area, in which the content of a frame is allowed
650cdf0e10cSrcweir |*  to be displayed. This region could be larger than the printarea (Prt())
651cdf0e10cSrcweir |*  of the upper, it includes e.g. often the margin of the page.
652cdf0e10cSrcweir |*
653cdf0e10cSrcweir |*************************************************************************/
654cdf0e10cSrcweir 
PaintArea() const655cdf0e10cSrcweir const SwRect SwFrm::PaintArea() const
656cdf0e10cSrcweir {
657cdf0e10cSrcweir     // NEW TABLES
658cdf0e10cSrcweir     // Cell frames may not leave their upper:
659cdf0e10cSrcweir     SwRect aRect = IsRowFrm() ? GetUpper()->Frm() : Frm();
660cdf0e10cSrcweir     const sal_Bool bVert = IsVertical();
661cdf0e10cSrcweir     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
662cdf0e10cSrcweir     SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
663cdf0e10cSrcweir     long nRight = (aRect.*fnRect->fnGetRight)();
664cdf0e10cSrcweir     long nLeft  = (aRect.*fnRect->fnGetLeft)();
665cdf0e10cSrcweir 	const SwFrm* pTmp = this;
666cdf0e10cSrcweir 	sal_Bool bLeft = sal_True;
667cdf0e10cSrcweir 	sal_Bool bRight = sal_True;
668cdf0e10cSrcweir     long nRowSpan = 0;
669cdf0e10cSrcweir 	while( pTmp )
670cdf0e10cSrcweir 	{
671cdf0e10cSrcweir         if( pTmp->IsCellFrm() && pTmp->GetUpper() &&
672cdf0e10cSrcweir             pTmp->GetUpper()->IsVertical() != pTmp->IsVertical() )
673cdf0e10cSrcweir             nRowSpan = ((SwCellFrm*)pTmp)->GetTabBox()->getRowSpan();
674cdf0e10cSrcweir         long nTmpRight = (pTmp->Frm().*fnRect->fnGetRight)();
675cdf0e10cSrcweir         long nTmpLeft = (pTmp->Frm().*fnRect->fnGetLeft)();
676cdf0e10cSrcweir         if( pTmp->IsRowFrm() && nRowSpan > 1 )
677cdf0e10cSrcweir         {
678cdf0e10cSrcweir             const SwFrm* pNxt = pTmp;
679cdf0e10cSrcweir             while( --nRowSpan > 0 && pNxt->GetNext() )
680cdf0e10cSrcweir                 pNxt = pNxt->GetNext();
681cdf0e10cSrcweir             if( pTmp->IsVertical() )
682cdf0e10cSrcweir                 nTmpLeft = (pNxt->Frm().*fnRect->fnGetLeft)();
683cdf0e10cSrcweir             else
684cdf0e10cSrcweir                 nTmpRight = (pNxt->Frm().*fnRect->fnGetRight)();
685cdf0e10cSrcweir         }
686cdf0e10cSrcweir 		ASSERT( pTmp, "PaintArea lost in time and space" );
687cdf0e10cSrcweir 		if( pTmp->IsPageFrm() || pTmp->IsFlyFrm() ||
688cdf0e10cSrcweir 			pTmp->IsCellFrm() || pTmp->IsRowFrm() || //nobody leaves a table!
689cdf0e10cSrcweir 			pTmp->IsRootFrm() )
690cdf0e10cSrcweir 		{
691cdf0e10cSrcweir             if( bLeft || nLeft < nTmpLeft )
692cdf0e10cSrcweir                 nLeft = nTmpLeft;
693cdf0e10cSrcweir             if( bRight || nTmpRight < nRight )
694cdf0e10cSrcweir 				nRight = nTmpRight;
695cdf0e10cSrcweir 			if( pTmp->IsPageFrm() || pTmp->IsFlyFrm() || pTmp->IsRootFrm() )
696cdf0e10cSrcweir 				break;
697cdf0e10cSrcweir 			bLeft = sal_False;
698cdf0e10cSrcweir 			bRight = sal_False;
699cdf0e10cSrcweir 		}
700cdf0e10cSrcweir 		else if( pTmp->IsColumnFrm() )  // nobody enters neightbour columns
701cdf0e10cSrcweir 		{
702cdf0e10cSrcweir             sal_Bool bR2L = pTmp->IsRightToLeft();
703cdf0e10cSrcweir             // the first column has _no_ influence to the left range
704cdf0e10cSrcweir             if( bR2L ? pTmp->GetNext() : pTmp->GetPrev() )
705cdf0e10cSrcweir             {
706cdf0e10cSrcweir                 if( bLeft || nLeft < nTmpLeft )
707cdf0e10cSrcweir                     nLeft = nTmpLeft;
708cdf0e10cSrcweir 				bLeft = sal_False;
709cdf0e10cSrcweir 			}
710cdf0e10cSrcweir              // the last column has _no_ influence to the right range
711cdf0e10cSrcweir             if( bR2L ? pTmp->GetPrev() : pTmp->GetNext() )
712cdf0e10cSrcweir             {
713cdf0e10cSrcweir 				if( bRight || nTmpRight < nRight )
714cdf0e10cSrcweir                     nRight = nTmpRight;
715cdf0e10cSrcweir 				bRight = sal_False;
716cdf0e10cSrcweir 			}
717cdf0e10cSrcweir 		}
718cdf0e10cSrcweir         else if( bVert && pTmp->IsBodyFrm() )
719cdf0e10cSrcweir         {
720cdf0e10cSrcweir             // Header and footer frames have always horizontal direction and
721cdf0e10cSrcweir             // limit the body frame.
722cdf0e10cSrcweir             // A previous frame of a body frame must be a header,
723cdf0e10cSrcweir             // the next frame of a body frame may be a footnotecontainer or
724cdf0e10cSrcweir             // a footer. The footnotecontainer has the same direction like
725cdf0e10cSrcweir             // the body frame.
726cdf0e10cSrcweir             if( pTmp->GetPrev() && ( bLeft || nLeft < nTmpLeft ) )
727cdf0e10cSrcweir             {
728cdf0e10cSrcweir                 nLeft = nTmpLeft;
729cdf0e10cSrcweir                 bLeft = sal_False;
730cdf0e10cSrcweir             }
731cdf0e10cSrcweir             if( pTmp->GetNext() &&
732cdf0e10cSrcweir                 ( pTmp->GetNext()->IsFooterFrm() || pTmp->GetNext()->GetNext() )
733cdf0e10cSrcweir                 && ( bRight || nTmpRight < nRight ) )
734cdf0e10cSrcweir             {
735cdf0e10cSrcweir                 nRight = nTmpRight;
736cdf0e10cSrcweir                 bRight = sal_False;
737cdf0e10cSrcweir 			}
738cdf0e10cSrcweir         }
739cdf0e10cSrcweir 		pTmp = pTmp->GetUpper();
740cdf0e10cSrcweir 	}
741cdf0e10cSrcweir     (aRect.*fnRect->fnSetLeft)( nLeft );
742cdf0e10cSrcweir     (aRect.*fnRect->fnSetRight)( nRight );
743cdf0e10cSrcweir 	return aRect;
744cdf0e10cSrcweir }
745cdf0e10cSrcweir 
746cdf0e10cSrcweir /*************************************************************************
747cdf0e10cSrcweir |*
748cdf0e10cSrcweir |*	SwFrm::UnionFrm()
749cdf0e10cSrcweir |*
750cdf0e10cSrcweir |*  The unionframe is the framearea (Frm()) of a frame expanded by the
751cdf0e10cSrcweir |*  printarea, if there's a negative margin at the left or right side.
752cdf0e10cSrcweir |*
753cdf0e10cSrcweir |*************************************************************************/
754cdf0e10cSrcweir 
UnionFrm(sal_Bool bBorder) const755cdf0e10cSrcweir const SwRect SwFrm::UnionFrm( sal_Bool bBorder ) const
756cdf0e10cSrcweir {
757cdf0e10cSrcweir     sal_Bool bVert = IsVertical();
758cdf0e10cSrcweir     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
759cdf0e10cSrcweir     SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
760cdf0e10cSrcweir     long nLeft = (Frm().*fnRect->fnGetLeft)();
761cdf0e10cSrcweir     long nWidth = (Frm().*fnRect->fnGetWidth)();
762cdf0e10cSrcweir     long nPrtLeft = (Prt().*fnRect->fnGetLeft)();
763cdf0e10cSrcweir     long nPrtWidth = (Prt().*fnRect->fnGetWidth)();
764cdf0e10cSrcweir     if( nPrtLeft + nPrtWidth > nWidth )
765cdf0e10cSrcweir         nWidth = nPrtLeft + nPrtWidth;
766cdf0e10cSrcweir     if( nPrtLeft < 0 )
767cdf0e10cSrcweir     {
768cdf0e10cSrcweir         nLeft += nPrtLeft;
769cdf0e10cSrcweir         nWidth -= nPrtLeft;
770cdf0e10cSrcweir     }
771cdf0e10cSrcweir     SwTwips nRight = nLeft + nWidth;
772cdf0e10cSrcweir     long nAdd = 0;
773cdf0e10cSrcweir 	if( bBorder )
774cdf0e10cSrcweir 	{
775cdf0e10cSrcweir 		SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
776cdf0e10cSrcweir 		const SwBorderAttrs &rAttrs = *aAccess.Get();
777cdf0e10cSrcweir 		const SvxBoxItem &rBox = rAttrs.GetBox();
778cdf0e10cSrcweir 		if ( rBox.GetLeft() )
779cdf0e10cSrcweir             nLeft -= rBox.CalcLineSpace( BOX_LINE_LEFT );
780cdf0e10cSrcweir 		else if ( rAttrs.IsBorderDist() )
781cdf0e10cSrcweir             nLeft -= rBox.GetDistance( BOX_LINE_LEFT ) + 1;
782cdf0e10cSrcweir 		if ( rBox.GetRight() )
783cdf0e10cSrcweir             nAdd += rBox.CalcLineSpace( BOX_LINE_RIGHT );
784cdf0e10cSrcweir 		else if ( rAttrs.IsBorderDist() )
785cdf0e10cSrcweir             nAdd += rBox.GetDistance( BOX_LINE_RIGHT ) + 1;
786cdf0e10cSrcweir 		if( rAttrs.GetShadow().GetLocation() != SVX_SHADOW_NONE )
787cdf0e10cSrcweir 		{
788cdf0e10cSrcweir 			const SvxShadowItem &rShadow = rAttrs.GetShadow();
789cdf0e10cSrcweir             nLeft -= rShadow.CalcShadowSpace( SHADOW_LEFT );
790cdf0e10cSrcweir             nAdd += rShadow.CalcShadowSpace( SHADOW_RIGHT );
791cdf0e10cSrcweir 		}
792cdf0e10cSrcweir 	}
793cdf0e10cSrcweir     if( IsTxtFrm() && ((SwTxtFrm*)this)->HasPara() )
794cdf0e10cSrcweir     {
795cdf0e10cSrcweir         long nTmp = ((SwTxtFrm*)this)->HangingMargin();
796cdf0e10cSrcweir         if( nTmp > nAdd )
797cdf0e10cSrcweir             nAdd = nTmp;
798cdf0e10cSrcweir     }
799cdf0e10cSrcweir     nWidth = nRight + nAdd - nLeft;
800cdf0e10cSrcweir 	SwRect aRet( Frm() );
801cdf0e10cSrcweir     (aRet.*fnRect->fnSetPosX)( nLeft );
802cdf0e10cSrcweir     (aRet.*fnRect->fnSetWidth)( nWidth );
803cdf0e10cSrcweir 	return aRet;
804cdf0e10cSrcweir }
805cdf0e10cSrcweir 
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 
808cdf0e10cSrcweir 
809