xref: /trunk/main/sw/source/core/layout/wsfrm.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include <hintids.hxx>
29cdf0e10cSrcweir #include <hints.hxx>
30cdf0e10cSrcweir #include <tools/pstm.hxx>
31cdf0e10cSrcweir #include <vcl/outdev.hxx>
32cdf0e10cSrcweir #include <svl/itemiter.hxx>
33cdf0e10cSrcweir #include <editeng/brshitem.hxx>
34cdf0e10cSrcweir #include <editeng/keepitem.hxx>
35cdf0e10cSrcweir #include <editeng/brkitem.hxx>
36cdf0e10cSrcweir #include <fmtornt.hxx>
37cdf0e10cSrcweir #include <pagefrm.hxx>
38cdf0e10cSrcweir #include <section.hxx>
39cdf0e10cSrcweir #include <rootfrm.hxx>
40cdf0e10cSrcweir #include <cntfrm.hxx>
41cdf0e10cSrcweir #include <dcontact.hxx>
42cdf0e10cSrcweir #include <anchoreddrawobject.hxx>
43cdf0e10cSrcweir #include <fmtanchr.hxx>
44cdf0e10cSrcweir #include <viewsh.hxx>
45cdf0e10cSrcweir #include <viewimp.hxx>
46cdf0e10cSrcweir #include "viewopt.hxx"
47cdf0e10cSrcweir #include <doc.hxx>
48cdf0e10cSrcweir #include <fesh.hxx>
49cdf0e10cSrcweir #include <docsh.hxx>
50cdf0e10cSrcweir #include <flyfrm.hxx>
51cdf0e10cSrcweir #include <frmtool.hxx>
52cdf0e10cSrcweir #include <ftninfo.hxx>
53cdf0e10cSrcweir #include <dflyobj.hxx>
54cdf0e10cSrcweir #include <fmtclbl.hxx>
55cdf0e10cSrcweir #include <fmtfordr.hxx>
56cdf0e10cSrcweir #include <fmtfsize.hxx>
57cdf0e10cSrcweir #include <fmtpdsc.hxx>
58cdf0e10cSrcweir #include <txtftn.hxx>
59cdf0e10cSrcweir #include <fmtftn.hxx>
60cdf0e10cSrcweir #include <fmtsrnd.hxx>
61cdf0e10cSrcweir #include <ftnfrm.hxx>
62cdf0e10cSrcweir #include <tabfrm.hxx>
63cdf0e10cSrcweir #include <htmltbl.hxx>
64cdf0e10cSrcweir #include <flyfrms.hxx>
65cdf0e10cSrcweir #include <sectfrm.hxx>
66cdf0e10cSrcweir #include <fmtclds.hxx>
67cdf0e10cSrcweir #include <txtfrm.hxx>
68cdf0e10cSrcweir #include <ndtxt.hxx>
69cdf0e10cSrcweir #include <bodyfrm.hxx>
70cdf0e10cSrcweir #include <cellfrm.hxx>
71cdf0e10cSrcweir #include <dbg_lay.hxx>
72cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
73cdf0e10cSrcweir #include <sortedobjs.hxx>
743f09c2ceSJürgen Schmidt #include <svx/xdef.hxx>
75cdf0e10cSrcweir 
76cdf0e10cSrcweir 
77cdf0e10cSrcweir using namespace ::com::sun::star;
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir /*************************************************************************
81cdf0e10cSrcweir |*
82cdf0e10cSrcweir |*  SwFrm::SwFrm()
83cdf0e10cSrcweir |*
84cdf0e10cSrcweir |*  Ersterstellung      AK 12-Feb-1991
85cdf0e10cSrcweir |*  Letzte Aenderung    MA 05. Apr. 94
86cdf0e10cSrcweir |*
87cdf0e10cSrcweir |*************************************************************************/
88cdf0e10cSrcweir 
SwFrm(SwModify * pMod,SwFrm * pSib)89cdf0e10cSrcweir SwFrm::SwFrm( SwModify *pMod, SwFrm* pSib ) :
90cdf0e10cSrcweir     SwClient( pMod ),
91f686a0e7SPavel Janík     //Solution:Add a member to identify if the acc table should dispose
92f686a0e7SPavel Janík     bIfAccTableShouldDisposing( sal_False ),
93cdf0e10cSrcweir     // --> OD 2006-05-10 #i65250#
94cdf0e10cSrcweir     mnFrmId( SwFrm::mnLastFrmId++ ),
95cdf0e10cSrcweir     // <--
96cdf0e10cSrcweir     mpRoot( pSib ? pSib->getRootFrm() : 0 ),
97cdf0e10cSrcweir     pUpper( 0 ),
98cdf0e10cSrcweir     pNext( 0 ),
99cdf0e10cSrcweir     pPrev( 0 ),
100cdf0e10cSrcweir     pDrawObjs( 0 )
101cdf0e10cSrcweir     , bInfBody( sal_False )
102cdf0e10cSrcweir     , bInfTab ( sal_False )
103cdf0e10cSrcweir     , bInfFly ( sal_False )
104cdf0e10cSrcweir     , bInfFtn ( sal_False )
105cdf0e10cSrcweir     , bInfSct ( sal_False )
106cdf0e10cSrcweir {
107cdf0e10cSrcweir #ifdef DBG_UTIL
108cdf0e10cSrcweir     bFlag01 = bFlag02 = bFlag03 = bFlag04 = bFlag05 = 0;
109cdf0e10cSrcweir #endif
110cdf0e10cSrcweir 
111cdf0e10cSrcweir     ASSERT( pMod, "Kein Frameformat uebergeben." );
112cdf0e10cSrcweir     bInvalidR2L = bInvalidVert = 1;
113cdf0e10cSrcweir     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
114cdf0e10cSrcweir     bDerivedR2L = bDerivedVert = bRightToLeft = bVertical = bReverse = bVertLR = 0;
115cdf0e10cSrcweir 
116cdf0e10cSrcweir     bValidPos = bValidPrtArea = bValidSize = bValidLineNum = bRetouche =
117cdf0e10cSrcweir     bFixSize = bColLocked = sal_False;
118cdf0e10cSrcweir     bCompletePaint = bInfInvalid = sal_True;
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
KnowsFormat(const SwFmt & rFmt) const121cdf0e10cSrcweir bool SwFrm::KnowsFormat( const SwFmt& rFmt ) const
122cdf0e10cSrcweir {
123cdf0e10cSrcweir     return GetRegisteredIn() == &rFmt;
124cdf0e10cSrcweir }
125cdf0e10cSrcweir 
RegisterToFormat(SwFmt & rFmt)126cdf0e10cSrcweir void SwFrm::RegisterToFormat( SwFmt& rFmt )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir     rFmt.Add( this );
129cdf0e10cSrcweir }
130cdf0e10cSrcweir 
CheckDir(sal_uInt16 nDir,sal_Bool bVert,sal_Bool bOnlyBiDi,sal_Bool bBrowse)131cdf0e10cSrcweir void SwFrm::CheckDir( sal_uInt16 nDir, sal_Bool bVert, sal_Bool bOnlyBiDi, sal_Bool bBrowse )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     if( FRMDIR_ENVIRONMENT == nDir || ( bVert && bOnlyBiDi ) )
134cdf0e10cSrcweir     {
135cdf0e10cSrcweir         bDerivedVert = 1;
136cdf0e10cSrcweir         if( FRMDIR_ENVIRONMENT == nDir )
137cdf0e10cSrcweir             bDerivedR2L = 1;
138cdf0e10cSrcweir         SetDirFlags( bVert );
139cdf0e10cSrcweir     }
140cdf0e10cSrcweir     else if( bVert )
141cdf0e10cSrcweir     {
142cdf0e10cSrcweir         bInvalidVert = 0;
143cdf0e10cSrcweir         if( FRMDIR_HORI_LEFT_TOP == nDir || FRMDIR_HORI_RIGHT_TOP == nDir
144cdf0e10cSrcweir             || bBrowse )
145cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
146cdf0e10cSrcweir         {
147cdf0e10cSrcweir             bVertical = 0;
148cdf0e10cSrcweir             bVertLR = 0;
149cdf0e10cSrcweir         }
150cdf0e10cSrcweir         else
151cdf0e10cSrcweir         {
152cdf0e10cSrcweir             bVertical = 1;
153cdf0e10cSrcweir             if(FRMDIR_VERT_TOP_RIGHT == nDir)
154cdf0e10cSrcweir                 bVertLR = 0;
155cdf0e10cSrcweir             else if(FRMDIR_VERT_TOP_LEFT==nDir)
156cdf0e10cSrcweir                     bVertLR = 1;
157cdf0e10cSrcweir         }
158cdf0e10cSrcweir     }
159cdf0e10cSrcweir     else
160cdf0e10cSrcweir     {
161cdf0e10cSrcweir         bInvalidR2L = 0;
162cdf0e10cSrcweir         if( FRMDIR_HORI_RIGHT_TOP == nDir )
163cdf0e10cSrcweir             bRightToLeft = 1;
164cdf0e10cSrcweir         else
165cdf0e10cSrcweir             bRightToLeft = 0;
166cdf0e10cSrcweir     }
167cdf0e10cSrcweir }
168cdf0e10cSrcweir 
CheckDirection(sal_Bool bVert)169cdf0e10cSrcweir void SwFrm::CheckDirection( sal_Bool bVert )
170cdf0e10cSrcweir {
171cdf0e10cSrcweir     if( bVert )
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         if( !IsHeaderFrm() && !IsFooterFrm() )
174cdf0e10cSrcweir         {
175cdf0e10cSrcweir             bDerivedVert = 1;
176cdf0e10cSrcweir             SetDirFlags( bVert );
177cdf0e10cSrcweir         }
178cdf0e10cSrcweir     }
179cdf0e10cSrcweir     else
180cdf0e10cSrcweir     {
181cdf0e10cSrcweir         bDerivedR2L = 1;
182cdf0e10cSrcweir         SetDirFlags( bVert );
183cdf0e10cSrcweir     }
184cdf0e10cSrcweir }
185cdf0e10cSrcweir 
CheckDirection(sal_Bool bVert)186cdf0e10cSrcweir void SwSectionFrm::CheckDirection( sal_Bool bVert )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir     const SwFrmFmt* pFmt = GetFmt();
189cdf0e10cSrcweir     if( pFmt )
190cdf0e10cSrcweir     {
191cdf0e10cSrcweir         const ViewShell *pSh = getRootFrm()->GetCurrShell();
192cdf0e10cSrcweir         const sal_Bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
193cdf0e10cSrcweir         CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(),
194cdf0e10cSrcweir                     bVert, sal_True, bBrowseMode );
195cdf0e10cSrcweir     }
196cdf0e10cSrcweir     else
197cdf0e10cSrcweir         SwFrm::CheckDirection( bVert );
198cdf0e10cSrcweir }
199cdf0e10cSrcweir 
CheckDirection(sal_Bool bVert)200cdf0e10cSrcweir void SwFlyFrm::CheckDirection( sal_Bool bVert )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir     const SwFrmFmt* pFmt = GetFmt();
203cdf0e10cSrcweir     if( pFmt )
204cdf0e10cSrcweir     {
205cdf0e10cSrcweir         const ViewShell *pSh = getRootFrm()->GetCurrShell();
206cdf0e10cSrcweir         const sal_Bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
207cdf0e10cSrcweir         CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(),
208cdf0e10cSrcweir                     bVert, sal_False, bBrowseMode );
209cdf0e10cSrcweir     }
210cdf0e10cSrcweir     else
211cdf0e10cSrcweir         SwFrm::CheckDirection( bVert );
212cdf0e10cSrcweir }
213cdf0e10cSrcweir 
CheckDirection(sal_Bool bVert)214cdf0e10cSrcweir void SwTabFrm::CheckDirection( sal_Bool bVert )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir     const SwFrmFmt* pFmt = GetFmt();
217cdf0e10cSrcweir     if( pFmt )
218cdf0e10cSrcweir     {
219cdf0e10cSrcweir         const ViewShell *pSh = getRootFrm()->GetCurrShell();
220cdf0e10cSrcweir         const sal_Bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
221cdf0e10cSrcweir         CheckDir(((SvxFrameDirectionItem&)pFmt->GetFmtAttr(RES_FRAMEDIR)).GetValue(),
222cdf0e10cSrcweir                     bVert, sal_True, bBrowseMode );
223cdf0e10cSrcweir     }
224cdf0e10cSrcweir     else
225cdf0e10cSrcweir         SwFrm::CheckDirection( bVert );
226cdf0e10cSrcweir }
227cdf0e10cSrcweir 
CheckDirection(sal_Bool bVert)228cdf0e10cSrcweir void SwCellFrm::CheckDirection( sal_Bool bVert )
229cdf0e10cSrcweir {
230cdf0e10cSrcweir     const SwFrmFmt* pFmt = GetFmt();
231cdf0e10cSrcweir     const SfxPoolItem* pItem;
232cdf0e10cSrcweir     // --> FME 2006-03-30 #b6402837# Check if the item is set, before actually
233cdf0e10cSrcweir     // using it. Otherwise the dynamic pool default is used, which may be set
234cdf0e10cSrcweir     // to LTR in case of OOo 1.0 documents.
235cdf0e10cSrcweir     // <--
236cdf0e10cSrcweir     if( pFmt && SFX_ITEM_SET == pFmt->GetItemState( RES_FRAMEDIR, sal_True, &pItem ) )
237cdf0e10cSrcweir     {
238cdf0e10cSrcweir         const SvxFrameDirectionItem* pFrmDirItem = static_cast<const SvxFrameDirectionItem*>(pItem);
239cdf0e10cSrcweir         const ViewShell *pSh = getRootFrm()->GetCurrShell();
240cdf0e10cSrcweir         const sal_Bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
241cdf0e10cSrcweir         CheckDir( pFrmDirItem->GetValue(), bVert, sal_False, bBrowseMode );
242cdf0e10cSrcweir     }
243cdf0e10cSrcweir     else
244cdf0e10cSrcweir         SwFrm::CheckDirection( bVert );
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
CheckDirection(sal_Bool bVert)247cdf0e10cSrcweir void SwTxtFrm::CheckDirection( sal_Bool bVert )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir     const ViewShell *pSh = getRootFrm()->GetCurrShell();
250cdf0e10cSrcweir     const sal_Bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
251cdf0e10cSrcweir     CheckDir( GetTxtNode()->GetSwAttrSet().GetFrmDir().GetValue(), bVert,
252cdf0e10cSrcweir               sal_True, bBrowseMode );
253cdf0e10cSrcweir }
254cdf0e10cSrcweir 
255cdf0e10cSrcweir /*************************************************************************/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)256cdf0e10cSrcweir void SwFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir     sal_uInt8 nInvFlags = 0;
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     if( pNew && RES_ATTRSET_CHG == pNew->Which() )
261cdf0e10cSrcweir     {
262cdf0e10cSrcweir         SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
263cdf0e10cSrcweir         SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
264cdf0e10cSrcweir         while( sal_True )
265cdf0e10cSrcweir         {
266cdf0e10cSrcweir             _UpdateAttrFrm( (SfxPoolItem*)aOIter.GetCurItem(),
267cdf0e10cSrcweir                          (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags );
268cdf0e10cSrcweir             if( aNIter.IsAtEnd() )
269cdf0e10cSrcweir                 break;
270cdf0e10cSrcweir             aNIter.NextItem();
271cdf0e10cSrcweir             aOIter.NextItem();
272cdf0e10cSrcweir         }
273cdf0e10cSrcweir     }
274cdf0e10cSrcweir     else
275cdf0e10cSrcweir         _UpdateAttrFrm( pOld, pNew, nInvFlags );
276cdf0e10cSrcweir 
277cdf0e10cSrcweir     if ( nInvFlags != 0 )
278cdf0e10cSrcweir     {
279cdf0e10cSrcweir         SwPageFrm *pPage = FindPageFrm();
280cdf0e10cSrcweir         InvalidatePage( pPage );
281cdf0e10cSrcweir         if ( nInvFlags & 0x01 )
282cdf0e10cSrcweir         {
283cdf0e10cSrcweir             _InvalidatePrt();
284cdf0e10cSrcweir             if( !GetPrev() && IsTabFrm() && IsInSct() )
285cdf0e10cSrcweir                 FindSctFrm()->_InvalidatePrt();
286cdf0e10cSrcweir         }
287cdf0e10cSrcweir         if ( nInvFlags & 0x02 )
288cdf0e10cSrcweir             _InvalidateSize();
289cdf0e10cSrcweir         if ( nInvFlags & 0x04 )
290cdf0e10cSrcweir             _InvalidatePos();
291cdf0e10cSrcweir         if ( nInvFlags & 0x08 )
292cdf0e10cSrcweir             SetCompletePaint();
293cdf0e10cSrcweir         SwFrm *pNxt;
294cdf0e10cSrcweir         if ( nInvFlags & 0x30 && 0 != (pNxt = GetNext()) )
295cdf0e10cSrcweir         {
296cdf0e10cSrcweir             pNxt->InvalidatePage( pPage );
297cdf0e10cSrcweir             if ( nInvFlags & 0x10 )
298cdf0e10cSrcweir                 pNxt->_InvalidatePos();
299cdf0e10cSrcweir             if ( nInvFlags & 0x20 )
300cdf0e10cSrcweir                 pNxt->SetCompletePaint();
301cdf0e10cSrcweir         }
302cdf0e10cSrcweir     }
303cdf0e10cSrcweir }
304cdf0e10cSrcweir 
_UpdateAttrFrm(const SfxPoolItem * pOld,const SfxPoolItem * pNew,sal_uInt8 & rInvFlags)305cdf0e10cSrcweir void SwFrm::_UpdateAttrFrm( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
306cdf0e10cSrcweir                          sal_uInt8 &rInvFlags )
307cdf0e10cSrcweir {
308cdf0e10cSrcweir     sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
309cdf0e10cSrcweir     switch( nWhich )
310cdf0e10cSrcweir     {
311cdf0e10cSrcweir         case RES_BOX:
312cdf0e10cSrcweir         case RES_SHADOW:
313cdf0e10cSrcweir             Prepare( PREP_FIXSIZE_CHG );
314cdf0e10cSrcweir             // hier kein break !
315cdf0e10cSrcweir         case RES_LR_SPACE:
316cdf0e10cSrcweir         case RES_UL_SPACE:
317cdf0e10cSrcweir             rInvFlags |= 0x0B;
318cdf0e10cSrcweir             break;
319cdf0e10cSrcweir 
320cdf0e10cSrcweir         case RES_HEADER_FOOTER_EAT_SPACING:
321cdf0e10cSrcweir             rInvFlags |= 0x03;
322cdf0e10cSrcweir             break;
323cdf0e10cSrcweir 
324cdf0e10cSrcweir         case RES_BACKGROUND:
325cdf0e10cSrcweir             rInvFlags |= 0x28;
326cdf0e10cSrcweir             break;
327cdf0e10cSrcweir 
328cdf0e10cSrcweir         case RES_KEEP:
329cdf0e10cSrcweir             rInvFlags |= 0x04;
330cdf0e10cSrcweir             break;
331cdf0e10cSrcweir 
332cdf0e10cSrcweir         case RES_FRM_SIZE:
333cdf0e10cSrcweir             ReinitializeFrmSizeAttrFlags();
334cdf0e10cSrcweir             rInvFlags |= 0x13;
335cdf0e10cSrcweir             break;
336cdf0e10cSrcweir 
337cdf0e10cSrcweir         case RES_FMT_CHG:
338cdf0e10cSrcweir             rInvFlags |= 0x0F;
339cdf0e10cSrcweir             break;
340cdf0e10cSrcweir 
341cdf0e10cSrcweir         case RES_ROW_SPLIT:
342cdf0e10cSrcweir         {
343cdf0e10cSrcweir             if ( IsRowFrm() )
344cdf0e10cSrcweir             {
345cdf0e10cSrcweir                 sal_Bool bInFollowFlowRow = 0 != IsInFollowFlowRow();
346cdf0e10cSrcweir                 if ( bInFollowFlowRow || 0 != IsInSplitTableRow() )
347cdf0e10cSrcweir                 {
348cdf0e10cSrcweir                     SwTabFrm* pTab = FindTabFrm();
349cdf0e10cSrcweir                     if ( bInFollowFlowRow )
350cdf0e10cSrcweir                         pTab = pTab->FindMaster();
351cdf0e10cSrcweir                     pTab->SetRemoveFollowFlowLinePending( sal_True );
352cdf0e10cSrcweir                 }
353cdf0e10cSrcweir             }
354cdf0e10cSrcweir             break;
355cdf0e10cSrcweir         }
356cdf0e10cSrcweir         case RES_COL:
357cdf0e10cSrcweir             ASSERT( sal_False, "Spalten fuer neuen FrmTyp?" );
358cdf0e10cSrcweir             break;
359cdf0e10cSrcweir 
360cdf0e10cSrcweir         default:
36164b14621SArmin Le Grand             //UUUU the new FillStyle has to do the same as previous RES_BACKGROUND
36264b14621SArmin Le Grand             if(nWhich >= XATTR_FILL_FIRST && nWhich <= XATTR_FILL_LAST)
36364b14621SArmin Le Grand             {
36464b14621SArmin Le Grand                 rInvFlags |= 0x28;
36564b14621SArmin Le Grand             }
366cdf0e10cSrcweir             /* do Nothing */;
367cdf0e10cSrcweir     }
368cdf0e10cSrcweir }
369cdf0e10cSrcweir 
370cdf0e10cSrcweir /*************************************************************************
371cdf0e10cSrcweir |*
372cdf0e10cSrcweir |*    SwFrm::Prepare()
373cdf0e10cSrcweir |*    Ersterstellung    MA 13. Apr. 93
374cdf0e10cSrcweir |*    Letzte Aenderung  MA 26. Jun. 96
375cdf0e10cSrcweir |*
376cdf0e10cSrcweir |*************************************************************************/
Prepare(const PrepareHint,const void *,sal_Bool)377cdf0e10cSrcweir void SwFrm::Prepare( const PrepareHint, const void *, sal_Bool )
378cdf0e10cSrcweir {
379cdf0e10cSrcweir     /* Do nothing */
380cdf0e10cSrcweir }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir /*************************************************************************
383cdf0e10cSrcweir |*
384cdf0e10cSrcweir |*    SwFrm::InvalidatePage()
385cdf0e10cSrcweir |*    Beschreibung:     Invalidiert die Seite, in der der Frm gerade steht.
386cdf0e10cSrcweir |*      Je nachdem ob es ein Layout, Cntnt oder FlyFrm ist wird die Seite
387cdf0e10cSrcweir |*      entsprechend Invalidiert.
388cdf0e10cSrcweir |*    Ersterstellung    MA 22. Jul. 92
389cdf0e10cSrcweir |*    Letzte Aenderung  MA 14. Oct. 94
390cdf0e10cSrcweir |*
391cdf0e10cSrcweir |*************************************************************************/
InvalidatePage(const SwPageFrm * pPage) const392cdf0e10cSrcweir void SwFrm::InvalidatePage( const SwPageFrm *pPage ) const
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     if ( !pPage )
395cdf0e10cSrcweir     {
396cdf0e10cSrcweir         pPage = FindPageFrm();
397cdf0e10cSrcweir         // --> OD 2004-07-02 #i28701# - for at-character and as-character
398cdf0e10cSrcweir         // anchored Writer fly frames additionally invalidate also page frame
399cdf0e10cSrcweir         // its 'anchor character' is on.
400cdf0e10cSrcweir         if ( pPage && pPage->GetUpper() && IsFlyFrm() )
401cdf0e10cSrcweir         {
402cdf0e10cSrcweir             const SwFlyFrm* pFlyFrm = static_cast<const SwFlyFrm*>(this);
403cdf0e10cSrcweir             if ( pFlyFrm->IsAutoPos() || pFlyFrm->IsFlyInCntFrm() )
404cdf0e10cSrcweir             {
405cdf0e10cSrcweir                 // --> OD 2004-09-23 #i33751#, #i34060# - method <GetPageFrmOfAnchor()>
406cdf0e10cSrcweir                 // is replaced by method <FindPageFrmOfAnchor()>. It's return value
407cdf0e10cSrcweir                 // have to be checked.
408cdf0e10cSrcweir                 SwPageFrm* pPageFrmOfAnchor =
409cdf0e10cSrcweir                         const_cast<SwFlyFrm*>(pFlyFrm)->FindPageFrmOfAnchor();
410cdf0e10cSrcweir                 if ( pPageFrmOfAnchor && pPageFrmOfAnchor != pPage )
411cdf0e10cSrcweir                 // <--
412cdf0e10cSrcweir                 {
413cdf0e10cSrcweir                     InvalidatePage( pPageFrmOfAnchor );
414cdf0e10cSrcweir                 }
415cdf0e10cSrcweir             }
416cdf0e10cSrcweir         }
417cdf0e10cSrcweir         // <--
418cdf0e10cSrcweir     }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir     if ( pPage && pPage->GetUpper() )
421cdf0e10cSrcweir     {
422cdf0e10cSrcweir         if ( pPage->GetFmt()->GetDoc()->IsInDtor() )
423cdf0e10cSrcweir             return;
424cdf0e10cSrcweir 
425cdf0e10cSrcweir         SwRootFrm *pRoot = (SwRootFrm*)pPage->GetUpper();
426cdf0e10cSrcweir         const SwFlyFrm *pFly = FindFlyFrm();
427cdf0e10cSrcweir         if ( IsCntntFrm() )
428cdf0e10cSrcweir         {
429cdf0e10cSrcweir             if ( pRoot->IsTurboAllowed() )
430cdf0e10cSrcweir             {
431cdf0e10cSrcweir                 // JP 21.09.95: wenn sich der ContentFrame 2 mal eintragen
432cdf0e10cSrcweir                 //              will, kann es doch eine TurboAction bleiben.
433cdf0e10cSrcweir                 //  ODER????
434cdf0e10cSrcweir                 if ( !pRoot->GetTurbo() || this == pRoot->GetTurbo() )
435cdf0e10cSrcweir                     pRoot->SetTurbo( (const SwCntntFrm*)this );
436cdf0e10cSrcweir                 else
437cdf0e10cSrcweir                 {
438cdf0e10cSrcweir                     pRoot->DisallowTurbo();
439cdf0e10cSrcweir                     //Die Seite des Turbo koennte eine andere als die meinige
440cdf0e10cSrcweir                     //sein, deshalb muss sie invalidiert werden.
441cdf0e10cSrcweir                     const SwFrm *pTmp = pRoot->GetTurbo();
442cdf0e10cSrcweir                     pRoot->ResetTurbo();
443cdf0e10cSrcweir                     pTmp->InvalidatePage();
444cdf0e10cSrcweir                 }
445cdf0e10cSrcweir             }
446cdf0e10cSrcweir             if ( !pRoot->GetTurbo() )
447cdf0e10cSrcweir             {
448cdf0e10cSrcweir                 if ( pFly )
449cdf0e10cSrcweir                 {   if( !pFly->IsLocked() )
450cdf0e10cSrcweir                     {
451cdf0e10cSrcweir                         if ( pFly->IsFlyInCntFrm() )
452cdf0e10cSrcweir                         {   pPage->InvalidateFlyInCnt();
453cdf0e10cSrcweir                             ((SwFlyInCntFrm*)pFly)->InvalidateCntnt();
454cdf0e10cSrcweir                             pFly->GetAnchorFrm()->InvalidatePage();
455cdf0e10cSrcweir                         }
456cdf0e10cSrcweir                         else
457cdf0e10cSrcweir                             pPage->InvalidateFlyCntnt();
458cdf0e10cSrcweir                     }
459cdf0e10cSrcweir                 }
460cdf0e10cSrcweir                 else
461cdf0e10cSrcweir                     pPage->InvalidateCntnt();
462cdf0e10cSrcweir             }
463cdf0e10cSrcweir         }
464cdf0e10cSrcweir         else
465cdf0e10cSrcweir         {
466cdf0e10cSrcweir             pRoot->DisallowTurbo();
467cdf0e10cSrcweir             if ( pFly )
468cdf0e10cSrcweir             {
469cdf0e10cSrcweir                 if ( !pFly->IsLocked() )
470cdf0e10cSrcweir                 {
471cdf0e10cSrcweir                     if ( pFly->IsFlyInCntFrm() )
472cdf0e10cSrcweir                     {
473cdf0e10cSrcweir                         pPage->InvalidateFlyInCnt();
474cdf0e10cSrcweir                         ((SwFlyInCntFrm*)pFly)->InvalidateLayout();
475cdf0e10cSrcweir                         pFly->GetAnchorFrm()->InvalidatePage();
476cdf0e10cSrcweir                     }
477cdf0e10cSrcweir                     else
478cdf0e10cSrcweir                         pPage->InvalidateFlyLayout();
479cdf0e10cSrcweir                 }
480cdf0e10cSrcweir             }
481cdf0e10cSrcweir             else
482cdf0e10cSrcweir                 pPage->InvalidateLayout();
483cdf0e10cSrcweir 
484cdf0e10cSrcweir             if ( pRoot->GetTurbo() )
485cdf0e10cSrcweir             {   const SwFrm *pTmp = pRoot->GetTurbo();
486cdf0e10cSrcweir                 pRoot->ResetTurbo();
487cdf0e10cSrcweir                 pTmp->InvalidatePage();
488cdf0e10cSrcweir             }
489cdf0e10cSrcweir         }
490cdf0e10cSrcweir         pRoot->SetIdleFlags();
491cdf0e10cSrcweir 
492cdf0e10cSrcweir         const SwTxtFrm *pTxtFrm = dynamic_cast< const SwTxtFrm * >(this);
493cdf0e10cSrcweir         if (pTxtFrm)
494cdf0e10cSrcweir         {
495cdf0e10cSrcweir             const SwTxtNode *pTxtNode = pTxtFrm->GetTxtNode();
496cdf0e10cSrcweir             if (pTxtNode && pTxtNode->IsGrammarCheckDirty())
497cdf0e10cSrcweir                 pRoot->SetNeedGrammarCheck( sal_True );
498cdf0e10cSrcweir         }
499cdf0e10cSrcweir     }
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir /*************************************************************************
503cdf0e10cSrcweir |*
504cdf0e10cSrcweir |*  SwFrm::ChgSize()
505cdf0e10cSrcweir |*
506cdf0e10cSrcweir |*  Ersterstellung      AK 15-Feb-1991
507cdf0e10cSrcweir |*  Letzte Aenderung    MA 18. Nov. 98
508cdf0e10cSrcweir |*
509cdf0e10cSrcweir |*************************************************************************/
ChgSize(const Size & aNewSize)510cdf0e10cSrcweir Size SwFrm::ChgSize( const Size& aNewSize )
511cdf0e10cSrcweir {
512cdf0e10cSrcweir     bFixSize = sal_True;
513cdf0e10cSrcweir     const Size aOldSize( Frm().SSize() );
514cdf0e10cSrcweir     if ( aNewSize == aOldSize )
515cdf0e10cSrcweir         return aOldSize;
516cdf0e10cSrcweir 
517cdf0e10cSrcweir     if ( GetUpper() )
518cdf0e10cSrcweir     {
519cdf0e10cSrcweir         SWRECTFN2( this )
520cdf0e10cSrcweir         SwRect aNew( Point(0,0), aNewSize );
521cdf0e10cSrcweir         (aFrm.*fnRect->fnSetWidth)( (aNew.*fnRect->fnGetWidth)() );
522cdf0e10cSrcweir         long nNew = (aNew.*fnRect->fnGetHeight)();
523cdf0e10cSrcweir         long nDiff = nNew - (aFrm.*fnRect->fnGetHeight)();
524cdf0e10cSrcweir         if( nDiff )
525cdf0e10cSrcweir         {
526cdf0e10cSrcweir             if ( GetUpper()->IsFtnBossFrm() && HasFixSize() &&
527cdf0e10cSrcweir                  NA_GROW_SHRINK !=
528cdf0e10cSrcweir                  ((SwFtnBossFrm*)GetUpper())->NeighbourhoodAdjustment( this ) )
529cdf0e10cSrcweir             {
530cdf0e10cSrcweir                 (aFrm.*fnRect->fnSetHeight)( nNew );
531cdf0e10cSrcweir                 SwTwips nReal = ((SwLayoutFrm*)this)->AdjustNeighbourhood(nDiff);
532cdf0e10cSrcweir                 if ( nReal != nDiff )
533cdf0e10cSrcweir                     (aFrm.*fnRect->fnSetHeight)( nNew - nDiff + nReal );
534cdf0e10cSrcweir             }
535cdf0e10cSrcweir             else
536cdf0e10cSrcweir             {
537cdf0e10cSrcweir                 // OD 24.10.2002 #97265# - grow/shrink not for neighbour frames
538cdf0e10cSrcweir                 // NOTE: neighbour frames are cell and column frames.
539cdf0e10cSrcweir                 if ( !bNeighb )
540cdf0e10cSrcweir                 {
541cdf0e10cSrcweir                     if ( nDiff > 0 )
542cdf0e10cSrcweir                         Grow( nDiff );
543cdf0e10cSrcweir                     else
544cdf0e10cSrcweir                         Shrink( -nDiff );
545cdf0e10cSrcweir 
546cdf0e10cSrcweir                     if ( GetUpper() && (aFrm.*fnRect->fnGetHeight)() != nNew )
547cdf0e10cSrcweir                         GetUpper()->_InvalidateSize();
548cdf0e10cSrcweir                 }
549cdf0e10cSrcweir 
550cdf0e10cSrcweir                 // Auch wenn das Grow/Shrink noch nicht die gewuenschte Breite eingestellt hat,
551cdf0e10cSrcweir                 // wie z.B. beim Aufruf durch ChgColumns, um die Spaltenbreiten einzustellen,
552cdf0e10cSrcweir                 // wird die Breite jetzt gesetzt.
553cdf0e10cSrcweir                 (aFrm.*fnRect->fnSetHeight)( nNew );
554cdf0e10cSrcweir             }
555cdf0e10cSrcweir         }
556cdf0e10cSrcweir     }
557cdf0e10cSrcweir     else
558cdf0e10cSrcweir         aFrm.SSize( aNewSize );
559cdf0e10cSrcweir 
560cdf0e10cSrcweir     if ( Frm().SSize() != aOldSize )
561cdf0e10cSrcweir     {
562cdf0e10cSrcweir         SwPageFrm *pPage = FindPageFrm();
563cdf0e10cSrcweir         if ( GetNext() )
564cdf0e10cSrcweir         {
565cdf0e10cSrcweir             GetNext()->_InvalidatePos();
566cdf0e10cSrcweir             GetNext()->InvalidatePage( pPage );
567cdf0e10cSrcweir         }
568cdf0e10cSrcweir         if( IsLayoutFrm() )
569cdf0e10cSrcweir         {
570cdf0e10cSrcweir             if( IsRightToLeft() )
571cdf0e10cSrcweir                 _InvalidatePos();
572cdf0e10cSrcweir             if( ((SwLayoutFrm*)this)->Lower() )
573cdf0e10cSrcweir                 ((SwLayoutFrm*)this)->Lower()->_InvalidateSize();
574cdf0e10cSrcweir         }
575cdf0e10cSrcweir         _InvalidatePrt();
576cdf0e10cSrcweir         _InvalidateSize();
577cdf0e10cSrcweir         InvalidatePage( pPage );
578cdf0e10cSrcweir     }
579cdf0e10cSrcweir 
580cdf0e10cSrcweir     return aFrm.SSize();
581cdf0e10cSrcweir }
582cdf0e10cSrcweir 
583cdf0e10cSrcweir /*************************************************************************
584cdf0e10cSrcweir |*
585cdf0e10cSrcweir |*  SwFrm::InsertBefore()
586cdf0e10cSrcweir |*
587cdf0e10cSrcweir |*  Beschreibung        SwFrm wird in eine bestehende Struktur eingefuegt
588cdf0e10cSrcweir |*                      Eingefuegt wird unterhalb des Parent und entweder
589cdf0e10cSrcweir |*                      vor pBehind oder am Ende der Kette wenn pBehind
590cdf0e10cSrcweir |*                      leer ist.
591cdf0e10cSrcweir |*  Letzte Aenderung    MA 06. Aug. 99
592cdf0e10cSrcweir |*
593cdf0e10cSrcweir |*************************************************************************/
InsertBefore(SwLayoutFrm * pParent,SwFrm * pBehind)594cdf0e10cSrcweir void SwFrm::InsertBefore( SwLayoutFrm* pParent, SwFrm* pBehind )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir     ASSERT( pParent, "Kein Parent fuer Insert." );
597cdf0e10cSrcweir     ASSERT( (!pBehind || (pBehind && pParent == pBehind->GetUpper())),
598cdf0e10cSrcweir             "Framebaum inkonsistent." );
599cdf0e10cSrcweir 
600cdf0e10cSrcweir     pUpper = pParent;
601cdf0e10cSrcweir     pNext = pBehind;
602cdf0e10cSrcweir     if( pBehind )
603cdf0e10cSrcweir     {   //Einfuegen vor pBehind.
604cdf0e10cSrcweir         if( 0 != (pPrev = pBehind->pPrev) )
605cdf0e10cSrcweir             pPrev->pNext = this;
606cdf0e10cSrcweir         else
607cdf0e10cSrcweir             pUpper->pLower = this;
608cdf0e10cSrcweir         pBehind->pPrev = this;
609cdf0e10cSrcweir     }
610cdf0e10cSrcweir     else
611cdf0e10cSrcweir     {   //Einfuegen am Ende, oder als ersten Node im Unterbaum
612cdf0e10cSrcweir         pPrev = pUpper->Lower();
613cdf0e10cSrcweir         if ( pPrev )
614cdf0e10cSrcweir         {
615cdf0e10cSrcweir             while( pPrev->pNext )
616cdf0e10cSrcweir                 pPrev = pPrev->pNext;
617cdf0e10cSrcweir             pPrev->pNext = this;
618cdf0e10cSrcweir         }
619cdf0e10cSrcweir         else
620cdf0e10cSrcweir             pUpper->pLower = this;
621cdf0e10cSrcweir     }
622cdf0e10cSrcweir }
623cdf0e10cSrcweir 
624cdf0e10cSrcweir /*************************************************************************
625cdf0e10cSrcweir |*
626cdf0e10cSrcweir |*  SwFrm::InsertBehind()
627cdf0e10cSrcweir |*
628cdf0e10cSrcweir |*  Beschreibung        SwFrm wird in eine bestehende Struktur eingefuegt
629cdf0e10cSrcweir |*                      Eingefuegt wird unterhalb des Parent und entweder
630cdf0e10cSrcweir |*                      hinter pBefore oder am Anfang der Kette wenn pBefore
631cdf0e10cSrcweir |*                      leer ist.
632cdf0e10cSrcweir |*  Letzte Aenderung    MA 06. Aug. 99
633cdf0e10cSrcweir |*
634cdf0e10cSrcweir |*************************************************************************/
InsertBehind(SwLayoutFrm * pParent,SwFrm * pBefore)635cdf0e10cSrcweir void SwFrm::InsertBehind( SwLayoutFrm *pParent, SwFrm *pBefore )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir     ASSERT( pParent, "Kein Parent fuer Insert." );
638cdf0e10cSrcweir     ASSERT( (!pBefore || (pBefore && pParent == pBefore->GetUpper())),
639cdf0e10cSrcweir             "Framebaum inkonsistent." );
640cdf0e10cSrcweir 
641cdf0e10cSrcweir     pUpper = pParent;
642cdf0e10cSrcweir     pPrev = pBefore;
643cdf0e10cSrcweir     if ( pBefore )
644cdf0e10cSrcweir     {
645cdf0e10cSrcweir         //Einfuegen hinter pBefore
646cdf0e10cSrcweir         if ( 0 != (pNext = pBefore->pNext) )
647cdf0e10cSrcweir             pNext->pPrev = this;
648cdf0e10cSrcweir         pBefore->pNext = this;
649cdf0e10cSrcweir     }
650cdf0e10cSrcweir     else
651cdf0e10cSrcweir     {
652cdf0e10cSrcweir         //Einfuegen am Anfang der Kette
653cdf0e10cSrcweir         pNext = pParent->Lower();
654cdf0e10cSrcweir         if ( pParent->Lower() )
655cdf0e10cSrcweir             pParent->Lower()->pPrev = this;
656cdf0e10cSrcweir         pParent->pLower = this;
657cdf0e10cSrcweir     }
658cdf0e10cSrcweir }
659cdf0e10cSrcweir 
660cdf0e10cSrcweir /*************************************************************************
661cdf0e10cSrcweir |*
662cdf0e10cSrcweir |*  SwFrm::InsertGroup()
663cdf0e10cSrcweir |*
664cdf0e10cSrcweir |*  Beschreibung        Eine Kette von SwFrms wird in eine bestehende Struktur
665cdf0e10cSrcweir |*                      eingefuegt
666cdf0e10cSrcweir |*  Letzte Aenderung    AMA 9. Dec. 97
667cdf0e10cSrcweir |*
668cdf0e10cSrcweir |*  Bisher wird dies genutzt, um einen SectionFrame, der ggf. schon Geschwister
669cdf0e10cSrcweir |*  mit sich bringt, in eine bestehende Struktur einzufuegen.
670cdf0e10cSrcweir |*
671cdf0e10cSrcweir |*  Wenn man den dritten Parameter als NULL uebergibt, entspricht
672cdf0e10cSrcweir |*  diese Methode dem SwFrm::InsertBefore(..), nur eben mit Geschwistern.
673cdf0e10cSrcweir |*
674cdf0e10cSrcweir |*  Wenn man einen dritten Parameter uebergibt, passiert folgendes:
675cdf0e10cSrcweir |*  this wird pNext von pParent,
676cdf0e10cSrcweir |*  pSct wird pNext vom Letzten der this-Kette,
677cdf0e10cSrcweir |*  pBehind wird vom pParent an den pSct umgehaengt.
678cdf0e10cSrcweir |*  Dies dient dazu: ein SectionFrm (this) wird nicht als
679cdf0e10cSrcweir |*  Kind an einen anderen SectionFrm (pParent) gehaengt, sondern pParent
680cdf0e10cSrcweir |*  wird in zwei Geschwister aufgespalten (pParent+pSct) und this dazwischen
681cdf0e10cSrcweir |*  eingebaut.
682cdf0e10cSrcweir |*
683cdf0e10cSrcweir |*************************************************************************/
InsertGroupBefore(SwFrm * pParent,SwFrm * pBehind,SwFrm * pSct)684cdf0e10cSrcweir void SwFrm::InsertGroupBefore( SwFrm* pParent, SwFrm* pBehind, SwFrm* pSct )
685cdf0e10cSrcweir {
686cdf0e10cSrcweir     ASSERT( pParent, "Kein Parent fuer Insert." );
687cdf0e10cSrcweir     ASSERT( (!pBehind || (pBehind && ( pParent == pBehind->GetUpper())
688cdf0e10cSrcweir             || ( pParent->IsSctFrm() && pBehind->GetUpper()->IsColBodyFrm() ) ) ),
689cdf0e10cSrcweir             "Framebaum inkonsistent." );
690cdf0e10cSrcweir     if( pSct )
691cdf0e10cSrcweir     {
692cdf0e10cSrcweir         pUpper = pParent->GetUpper();
693cdf0e10cSrcweir         SwFrm *pLast = this;
694cdf0e10cSrcweir         while( pLast->GetNext() )
695cdf0e10cSrcweir         {
696cdf0e10cSrcweir             pLast = pLast->GetNext();
697cdf0e10cSrcweir             pLast->pUpper = GetUpper();
698cdf0e10cSrcweir         }
699cdf0e10cSrcweir         if( pBehind )
700cdf0e10cSrcweir         {
701cdf0e10cSrcweir             pLast->pNext = pSct;
702cdf0e10cSrcweir             pSct->pPrev = pLast;
703cdf0e10cSrcweir             pSct->pNext = pParent->GetNext();
704cdf0e10cSrcweir         }
705cdf0e10cSrcweir         else
706cdf0e10cSrcweir         {
707cdf0e10cSrcweir             pLast->pNext = pParent->GetNext();
708cdf0e10cSrcweir             if( pLast->GetNext() )
709cdf0e10cSrcweir                 pLast->GetNext()->pPrev = pLast;
710cdf0e10cSrcweir         }
711cdf0e10cSrcweir         pParent->pNext = this;
712cdf0e10cSrcweir         pPrev = pParent;
713cdf0e10cSrcweir         if( pSct->GetNext() )
714cdf0e10cSrcweir             pSct->GetNext()->pPrev = pSct;
715cdf0e10cSrcweir         while( pLast->GetNext() )
716cdf0e10cSrcweir         {
717cdf0e10cSrcweir             pLast = pLast->GetNext();
718cdf0e10cSrcweir             pLast->pUpper = GetUpper();
719cdf0e10cSrcweir         }
720cdf0e10cSrcweir         if( pBehind )
721cdf0e10cSrcweir         {   //Einfuegen vor pBehind.
722cdf0e10cSrcweir             if( pBehind->GetPrev() )
723cdf0e10cSrcweir                 pBehind->GetPrev()->pNext = NULL;
724cdf0e10cSrcweir             else
725cdf0e10cSrcweir                 pBehind->GetUpper()->pLower = NULL;
726cdf0e10cSrcweir             pBehind->pPrev = NULL;
727cdf0e10cSrcweir             SwLayoutFrm* pTmp = (SwLayoutFrm*)pSct;
728cdf0e10cSrcweir             if( pTmp->Lower() )
729cdf0e10cSrcweir             {
730cdf0e10cSrcweir                 ASSERT( pTmp->Lower()->IsColumnFrm(), "InsertGrp: Used SectionFrm" );
731cdf0e10cSrcweir                 pTmp = (SwLayoutFrm*)((SwLayoutFrm*)pTmp->Lower())->Lower();
732cdf0e10cSrcweir                 ASSERT( pTmp, "InsertGrp: Missing ColBody" );
733cdf0e10cSrcweir             }
734cdf0e10cSrcweir             pBehind->pUpper = pTmp;
735cdf0e10cSrcweir             pBehind->GetUpper()->pLower = pBehind;
736cdf0e10cSrcweir             pLast = pBehind->GetNext();
737cdf0e10cSrcweir             while ( pLast )
738cdf0e10cSrcweir             {
739cdf0e10cSrcweir                 pLast->pUpper = pBehind->GetUpper();
740cdf0e10cSrcweir                 pLast = pLast->GetNext();
741cdf0e10cSrcweir             };
742cdf0e10cSrcweir         }
743cdf0e10cSrcweir         else
744cdf0e10cSrcweir         {
745cdf0e10cSrcweir             ASSERT( pSct->IsSctFrm(), "InsertGroup: For SectionFrms only" );
746cdf0e10cSrcweir             delete ((SwSectionFrm*)pSct);
747cdf0e10cSrcweir         }
748cdf0e10cSrcweir     }
749cdf0e10cSrcweir     else
750cdf0e10cSrcweir     {
751cdf0e10cSrcweir         pUpper = (SwLayoutFrm*)pParent;
752cdf0e10cSrcweir         SwFrm *pLast = this;
753cdf0e10cSrcweir         while( pLast->GetNext() )
754cdf0e10cSrcweir         {
755cdf0e10cSrcweir             pLast = pLast->GetNext();
756cdf0e10cSrcweir             pLast->pUpper = GetUpper();
757cdf0e10cSrcweir         }
758cdf0e10cSrcweir         pLast->pNext = pBehind;
759cdf0e10cSrcweir         if( pBehind )
760cdf0e10cSrcweir         {   //Einfuegen vor pBehind.
761cdf0e10cSrcweir             if( 0 != (pPrev = pBehind->pPrev) )
762cdf0e10cSrcweir                 pPrev->pNext = this;
763cdf0e10cSrcweir             else
764cdf0e10cSrcweir                 pUpper->pLower = this;
765cdf0e10cSrcweir             pBehind->pPrev = pLast;
766cdf0e10cSrcweir         }
767cdf0e10cSrcweir         else
768cdf0e10cSrcweir         {   //Einfuegen am Ende, oder des ersten Nodes im Unterbaum
769cdf0e10cSrcweir             pPrev = pUpper->Lower();
770cdf0e10cSrcweir             if ( pPrev )
771cdf0e10cSrcweir             {
772cdf0e10cSrcweir                 while( pPrev->pNext )
773cdf0e10cSrcweir                     pPrev = pPrev->pNext;
774cdf0e10cSrcweir                 pPrev->pNext = this;
775cdf0e10cSrcweir             }
776cdf0e10cSrcweir             else
777cdf0e10cSrcweir                 pUpper->pLower = this;
778cdf0e10cSrcweir         }
779cdf0e10cSrcweir     }
780cdf0e10cSrcweir }
781cdf0e10cSrcweir 
782cdf0e10cSrcweir /*************************************************************************
783cdf0e10cSrcweir |*
784cdf0e10cSrcweir |*  SwFrm::Remove()
785cdf0e10cSrcweir |*
786cdf0e10cSrcweir |*  Ersterstellung      AK 01-Mar-1991
787cdf0e10cSrcweir |*  Letzte Aenderung    MA 07. Dec. 95
788cdf0e10cSrcweir |*
789cdf0e10cSrcweir |*************************************************************************/
Remove()790cdf0e10cSrcweir void SwFrm::Remove()
791cdf0e10cSrcweir {
792cdf0e10cSrcweir     ASSERT( pUpper, "Removen ohne Upper?" );
793cdf0e10cSrcweir 
794cdf0e10cSrcweir     if( pPrev )
795cdf0e10cSrcweir         // einer aus der Mitte wird removed
796cdf0e10cSrcweir         pPrev->pNext = pNext;
797cdf0e10cSrcweir     else
798cdf0e10cSrcweir     {   // der erste in einer Folge wird removed
799cdf0e10cSrcweir         ASSERT( pUpper->pLower == this, "Layout inkonsistent." );
800cdf0e10cSrcweir         pUpper->pLower = pNext;
801cdf0e10cSrcweir     }
802cdf0e10cSrcweir     if( pNext )
803cdf0e10cSrcweir         pNext->pPrev = pPrev;
804cdf0e10cSrcweir 
805cdf0e10cSrcweir     // Verbindung kappen.
806cdf0e10cSrcweir     pNext  = pPrev  = 0;
807cdf0e10cSrcweir     pUpper = 0;
808cdf0e10cSrcweir }
809cdf0e10cSrcweir /*************************************************************************
810cdf0e10cSrcweir |*
811cdf0e10cSrcweir |*  SwCntntFrm::Paste()
812cdf0e10cSrcweir |*
813cdf0e10cSrcweir |*  Ersterstellung      MA 23. Feb. 94
814cdf0e10cSrcweir |*  Letzte Aenderung    MA 09. Sep. 98
815cdf0e10cSrcweir |*
816cdf0e10cSrcweir |*************************************************************************/
Paste(SwFrm * pParent,SwFrm * pSibling)817cdf0e10cSrcweir void SwCntntFrm::Paste( SwFrm* pParent, SwFrm* pSibling)
818cdf0e10cSrcweir {
819cdf0e10cSrcweir     ASSERT( pParent, "Kein Parent fuer Paste." );
820cdf0e10cSrcweir     ASSERT( pParent->IsLayoutFrm(), "Parent ist CntntFrm." );
821cdf0e10cSrcweir     ASSERT( pParent != this, "Bin selbst der Parent." );
822cdf0e10cSrcweir     ASSERT( pSibling != this, "Bin mein eigener Nachbar." );
823cdf0e10cSrcweir     ASSERT( !GetPrev() && !GetNext() && !GetUpper(),
824cdf0e10cSrcweir             "Bin noch irgendwo angemeldet." );
825cdf0e10cSrcweir     ASSERT( !pSibling || pSibling->IsFlowFrm(),
826cdf0e10cSrcweir             "<SwCntntFrm::Paste(..)> - sibling not of expected type." )
827cdf0e10cSrcweir 
828cdf0e10cSrcweir     //In den Baum einhaengen.
829cdf0e10cSrcweir     InsertBefore( (SwLayoutFrm*)pParent, pSibling );
830cdf0e10cSrcweir 
831cdf0e10cSrcweir     SwPageFrm *pPage = FindPageFrm();
832cdf0e10cSrcweir     _InvalidateAll();
833cdf0e10cSrcweir     InvalidatePage( pPage );
834cdf0e10cSrcweir 
835cdf0e10cSrcweir     if( pPage )
836cdf0e10cSrcweir     {
837cdf0e10cSrcweir         pPage->InvalidateSpelling();
838cdf0e10cSrcweir         pPage->InvalidateSmartTags();   // SMARTTAGS
839cdf0e10cSrcweir         pPage->InvalidateAutoCompleteWords();
840cdf0e10cSrcweir         pPage->InvalidateWordCount();
841cdf0e10cSrcweir     }
842cdf0e10cSrcweir 
843cdf0e10cSrcweir     if ( GetNext() )
844cdf0e10cSrcweir     {
845cdf0e10cSrcweir         SwFrm* pNxt = GetNext();
846cdf0e10cSrcweir         pNxt->_InvalidatePrt();
847cdf0e10cSrcweir         pNxt->_InvalidatePos();
848cdf0e10cSrcweir         pNxt->InvalidatePage( pPage );
849cdf0e10cSrcweir         if( pNxt->IsSctFrm() )
850cdf0e10cSrcweir             pNxt = ((SwSectionFrm*)pNxt)->ContainsCntnt();
851cdf0e10cSrcweir         if( pNxt && pNxt->IsTxtFrm() && pNxt->IsInFtn() )
852cdf0e10cSrcweir             pNxt->Prepare( PREP_FTN, 0, sal_False );
853cdf0e10cSrcweir     }
854cdf0e10cSrcweir 
855cdf0e10cSrcweir     if ( Frm().Height() )
856cdf0e10cSrcweir         pParent->Grow( Frm().Height() );
857cdf0e10cSrcweir 
858cdf0e10cSrcweir     if ( Frm().Width() != pParent->Prt().Width() )
859cdf0e10cSrcweir         Prepare( PREP_FIXSIZE_CHG );
860cdf0e10cSrcweir 
861cdf0e10cSrcweir     if ( GetPrev() )
862cdf0e10cSrcweir     {
863cdf0e10cSrcweir         if ( IsFollow() )
864cdf0e10cSrcweir             //Ich bin jetzt direkter Nachfolger meines Masters geworden
865cdf0e10cSrcweir             ((SwCntntFrm*)GetPrev())->Prepare( PREP_FOLLOW_FOLLOWS );
866cdf0e10cSrcweir         else
867cdf0e10cSrcweir         {
868cdf0e10cSrcweir             if ( GetPrev()->Frm().Height() !=
869cdf0e10cSrcweir                  GetPrev()->Prt().Height() + GetPrev()->Prt().Top() )
870cdf0e10cSrcweir                 //Umrandung zu beruecksichtigen?
871cdf0e10cSrcweir                 GetPrev()->_InvalidatePrt();
872cdf0e10cSrcweir             // OD 18.02.2003 #104989# - force complete paint of previous frame,
873cdf0e10cSrcweir             // if frame is inserted at the end of a section frame, in order to
874cdf0e10cSrcweir             // get subsidiary lines repainted for the section.
875cdf0e10cSrcweir             if ( pParent->IsSctFrm() && !GetNext() )
876cdf0e10cSrcweir             {
877cdf0e10cSrcweir                 // force complete paint of previous frame, if new inserted frame
878cdf0e10cSrcweir                 // in the section is the last one.
879cdf0e10cSrcweir                 GetPrev()->SetCompletePaint();
880cdf0e10cSrcweir             }
881cdf0e10cSrcweir             GetPrev()->InvalidatePage( pPage );
882cdf0e10cSrcweir         }
883cdf0e10cSrcweir     }
884cdf0e10cSrcweir     if ( IsInFtn() )
885cdf0e10cSrcweir     {
886cdf0e10cSrcweir         SwFrm* pFrm = GetIndPrev();
887cdf0e10cSrcweir         if( pFrm && pFrm->IsSctFrm() )
888cdf0e10cSrcweir             pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
889cdf0e10cSrcweir         if( pFrm )
890cdf0e10cSrcweir             pFrm->Prepare( PREP_QUOVADIS, 0, sal_False );
891cdf0e10cSrcweir         if( !GetNext() )
892cdf0e10cSrcweir         {
893cdf0e10cSrcweir             pFrm = FindFtnFrm()->GetNext();
894cdf0e10cSrcweir             if( pFrm && 0 != (pFrm=((SwLayoutFrm*)pFrm)->ContainsAny()) )
895cdf0e10cSrcweir                 pFrm->_InvalidatePrt();
896cdf0e10cSrcweir         }
897cdf0e10cSrcweir     }
898cdf0e10cSrcweir 
899cdf0e10cSrcweir     _InvalidateLineNum();
900cdf0e10cSrcweir     SwFrm *pNxt = FindNextCnt();
901cdf0e10cSrcweir     if ( pNxt  )
902cdf0e10cSrcweir     {
903cdf0e10cSrcweir         while ( pNxt && pNxt->IsInTab() )
904cdf0e10cSrcweir         {
905cdf0e10cSrcweir             if( 0 != (pNxt = pNxt->FindTabFrm()) )
906cdf0e10cSrcweir                 pNxt = pNxt->FindNextCnt();
907cdf0e10cSrcweir         }
908cdf0e10cSrcweir         if ( pNxt )
909cdf0e10cSrcweir         {
910cdf0e10cSrcweir             pNxt->_InvalidateLineNum();
911cdf0e10cSrcweir             if ( pNxt != GetNext() )
912cdf0e10cSrcweir                 pNxt->InvalidatePage();
913cdf0e10cSrcweir         }
914cdf0e10cSrcweir     }
915cdf0e10cSrcweir }
916cdf0e10cSrcweir 
917cdf0e10cSrcweir /*************************************************************************
918cdf0e10cSrcweir |*
919cdf0e10cSrcweir |*  SwCntntFrm::Cut()
920cdf0e10cSrcweir |*
921cdf0e10cSrcweir |*  Ersterstellung      AK 14-Feb-1991
922cdf0e10cSrcweir |*  Letzte Aenderung    MA 09. Sep. 98
923cdf0e10cSrcweir |*
924cdf0e10cSrcweir |*************************************************************************/
Cut()925cdf0e10cSrcweir void SwCntntFrm::Cut()
926cdf0e10cSrcweir {
927cdf0e10cSrcweir     ASSERT( GetUpper(), "Cut ohne Upper()." );
928cdf0e10cSrcweir 
929cdf0e10cSrcweir     SwPageFrm *pPage = FindPageFrm();
930cdf0e10cSrcweir     InvalidatePage( pPage );
931cdf0e10cSrcweir     SwFrm *pFrm = GetIndPrev();
932cdf0e10cSrcweir     if( pFrm )
933cdf0e10cSrcweir     {
934cdf0e10cSrcweir         if( pFrm->IsSctFrm() )
935cdf0e10cSrcweir             pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
936cdf0e10cSrcweir         if ( pFrm && pFrm->IsCntntFrm() )
937cdf0e10cSrcweir         {
938cdf0e10cSrcweir             pFrm->_InvalidatePrt();
939cdf0e10cSrcweir             if( IsInFtn() )
940cdf0e10cSrcweir                 pFrm->Prepare( PREP_QUOVADIS, 0, sal_False );
941cdf0e10cSrcweir         }
942cdf0e10cSrcweir         // --> OD 2004-07-15 #i26250# - invalidate printing area of previous
943cdf0e10cSrcweir         // table frame.
944cdf0e10cSrcweir         else if ( pFrm && pFrm->IsTabFrm() )
945cdf0e10cSrcweir         {
946cdf0e10cSrcweir             pFrm->InvalidatePrt();
947cdf0e10cSrcweir         }
948cdf0e10cSrcweir         // <--
949cdf0e10cSrcweir     }
950cdf0e10cSrcweir 
951cdf0e10cSrcweir     SwFrm *pNxt = FindNextCnt();
952cdf0e10cSrcweir     if ( pNxt )
953cdf0e10cSrcweir     {
954cdf0e10cSrcweir         while ( pNxt && pNxt->IsInTab() )
955cdf0e10cSrcweir         {
956cdf0e10cSrcweir             if( 0 != (pNxt = pNxt->FindTabFrm()) )
957cdf0e10cSrcweir                 pNxt = pNxt->FindNextCnt();
958cdf0e10cSrcweir         }
959cdf0e10cSrcweir         if ( pNxt )
960cdf0e10cSrcweir         {
961cdf0e10cSrcweir             pNxt->_InvalidateLineNum();
962cdf0e10cSrcweir             if ( pNxt != GetNext() )
963cdf0e10cSrcweir                 pNxt->InvalidatePage();
964cdf0e10cSrcweir         }
965cdf0e10cSrcweir     }
966cdf0e10cSrcweir 
967cdf0e10cSrcweir     if( 0 != (pFrm = GetIndNext()) )
968cdf0e10cSrcweir     {   //Der alte Nachfolger hat evtl. einen Abstand zum Vorgaenger
969cdf0e10cSrcweir         //berechnet, der ist jetzt, wo er der erste wird obsolet bzw. anders.
970cdf0e10cSrcweir         pFrm->_InvalidatePrt();
971cdf0e10cSrcweir         pFrm->_InvalidatePos();
972cdf0e10cSrcweir         pFrm->InvalidatePage( pPage );
973cdf0e10cSrcweir         if( pFrm->IsSctFrm() )
974cdf0e10cSrcweir         {
975cdf0e10cSrcweir             pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
976cdf0e10cSrcweir             if( pFrm )
977cdf0e10cSrcweir             {
978cdf0e10cSrcweir                 pFrm->_InvalidatePrt();
979cdf0e10cSrcweir                 pFrm->_InvalidatePos();
980cdf0e10cSrcweir                 pFrm->InvalidatePage( pPage );
981cdf0e10cSrcweir             }
982cdf0e10cSrcweir         }
983cdf0e10cSrcweir         if( pFrm && IsInFtn() )
984cdf0e10cSrcweir             pFrm->Prepare( PREP_ERGOSUM, 0, sal_False );
985cdf0e10cSrcweir         if( IsInSct() && !GetPrev() )
986cdf0e10cSrcweir         {
987cdf0e10cSrcweir             SwSectionFrm* pSct = FindSctFrm();
988cdf0e10cSrcweir             if( !pSct->IsFollow() )
989cdf0e10cSrcweir             {
990cdf0e10cSrcweir                 pSct->_InvalidatePrt();
991cdf0e10cSrcweir                 pSct->InvalidatePage( pPage );
992cdf0e10cSrcweir             }
993cdf0e10cSrcweir         }
994cdf0e10cSrcweir     }
995cdf0e10cSrcweir     else
996cdf0e10cSrcweir     {
997cdf0e10cSrcweir         InvalidateNextPos();
998cdf0e10cSrcweir         //Einer muss die Retusche uebernehmen: Vorgaenger oder Upper
999cdf0e10cSrcweir         if ( 0 != (pFrm = GetPrev()) )
1000cdf0e10cSrcweir         {   pFrm->SetRetouche();
1001cdf0e10cSrcweir             pFrm->Prepare( PREP_WIDOWS_ORPHANS );
1002cdf0e10cSrcweir             pFrm->_InvalidatePos();
1003cdf0e10cSrcweir             pFrm->InvalidatePage( pPage );
1004cdf0e10cSrcweir         }
1005cdf0e10cSrcweir         //Wenn ich der einzige CntntFrm in meinem Upper bin (war), so muss
1006cdf0e10cSrcweir         //er die Retouche uebernehmen.
1007cdf0e10cSrcweir         //Ausserdem kann eine Leerseite entstanden sein.
1008cdf0e10cSrcweir         else
1009cdf0e10cSrcweir         {   SwRootFrm *pRoot = getRootFrm();
1010cdf0e10cSrcweir             if ( pRoot )
1011cdf0e10cSrcweir             {
1012cdf0e10cSrcweir                 pRoot->SetSuperfluous();
1013cdf0e10cSrcweir                 GetUpper()->SetCompletePaint();
1014cdf0e10cSrcweir                 GetUpper()->InvalidatePage( pPage );
1015cdf0e10cSrcweir             }
1016cdf0e10cSrcweir             if( IsInSct() )
1017cdf0e10cSrcweir             {
1018cdf0e10cSrcweir                 SwSectionFrm* pSct = FindSctFrm();
1019cdf0e10cSrcweir                 if( !pSct->IsFollow() )
1020cdf0e10cSrcweir                 {
1021cdf0e10cSrcweir                     pSct->_InvalidatePrt();
1022cdf0e10cSrcweir                     pSct->InvalidatePage( pPage );
1023cdf0e10cSrcweir                 }
1024cdf0e10cSrcweir             }
1025cdf0e10cSrcweir             // --> FME 2005-08-03 #i52253# The master table should take care
1026cdf0e10cSrcweir             // of removing the follow flow line.
1027cdf0e10cSrcweir             if ( IsInTab() )
1028cdf0e10cSrcweir             {
1029cdf0e10cSrcweir                 SwTabFrm* pThisTab = FindTabFrm();
1030cdf0e10cSrcweir                 SwTabFrm* pMasterTab = pThisTab && pThisTab->IsFollow() ? pThisTab->FindMaster() : 0;
1031cdf0e10cSrcweir                 if ( pMasterTab )
1032cdf0e10cSrcweir                 {
1033cdf0e10cSrcweir                     pMasterTab->_InvalidatePos();
1034cdf0e10cSrcweir                     pMasterTab->SetRemoveFollowFlowLinePending( sal_True );
1035cdf0e10cSrcweir                 }
1036cdf0e10cSrcweir             }
1037cdf0e10cSrcweir             // <--
1038cdf0e10cSrcweir         }
1039cdf0e10cSrcweir     }
1040cdf0e10cSrcweir     //Erst removen, dann Upper Shrinken.
1041cdf0e10cSrcweir     SwLayoutFrm *pUp = GetUpper();
1042cdf0e10cSrcweir     Remove();
1043cdf0e10cSrcweir     if ( pUp )
1044cdf0e10cSrcweir     {
1045cdf0e10cSrcweir         SwSectionFrm *pSct = 0;
1046cdf0e10cSrcweir         if ( !pUp->Lower() &&
1047cdf0e10cSrcweir              ( ( pUp->IsFtnFrm() && !pUp->IsColLocked() ) ||
1048cdf0e10cSrcweir                ( pUp->IsInSct() &&
1049cdf0e10cSrcweir                  // -->  FME 2004-06-03 #i29438#
1050cdf0e10cSrcweir                  // We have to consider the case that the section may be "empty"
1051cdf0e10cSrcweir                  // except from a temporary empty table frame.
1052cdf0e10cSrcweir                  // This can happen due to the new cell split feature.
1053cdf0e10cSrcweir                  !pUp->IsCellFrm() &&
1054cdf0e10cSrcweir                  // <--
1055cdf0e10cSrcweir                  // --> OD 2006-01-04 #126020# - adjust check for empty section
1056cdf0e10cSrcweir                  // --> OD 2006-02-01 #130797# - correct fix #126020#
1057cdf0e10cSrcweir                  !(pSct = pUp->FindSctFrm())->ContainsCntnt() &&
1058cdf0e10cSrcweir                  !pSct->ContainsAny( true ) ) ) )
1059cdf0e10cSrcweir                  // <--
1060cdf0e10cSrcweir         {
1061cdf0e10cSrcweir             if ( pUp->GetUpper() )
1062cdf0e10cSrcweir             {
1063cdf0e10cSrcweir                 // --> OD 2006-09-25 #b6448963#
1064cdf0e10cSrcweir                 // prevent delete of <ColLocked> footnote frame
1065cdf0e10cSrcweir //                if( pUp->IsFtnFrm() )
1066cdf0e10cSrcweir                 if ( pUp->IsFtnFrm() && !pUp->IsColLocked())
1067cdf0e10cSrcweir                 // <--
1068cdf0e10cSrcweir                 {
1069cdf0e10cSrcweir                     if( pUp->GetNext() && !pUp->GetPrev() )
1070cdf0e10cSrcweir                     {
1071cdf0e10cSrcweir                         SwFrm* pTmp = ((SwLayoutFrm*)pUp->GetNext())->ContainsAny();
1072cdf0e10cSrcweir                         if( pTmp )
1073cdf0e10cSrcweir                             pTmp->_InvalidatePrt();
1074cdf0e10cSrcweir                     }
1075cdf0e10cSrcweir                     pUp->Cut();
1076cdf0e10cSrcweir                     delete pUp;
1077cdf0e10cSrcweir                 }
1078cdf0e10cSrcweir                 else
1079cdf0e10cSrcweir                 {
1080cdf0e10cSrcweir                     // --> OD 2006-09-25 #b6448963#
1081cdf0e10cSrcweir //                    if ( pSct->IsColLocked() || !pSct->IsInFtn() )
1082cdf0e10cSrcweir                     if ( pSct->IsColLocked() || !pSct->IsInFtn() ||
1083cdf0e10cSrcweir                          ( pUp->IsFtnFrm() && pUp->IsColLocked() ) )
1084cdf0e10cSrcweir                     // <--
1085cdf0e10cSrcweir                     {
1086cdf0e10cSrcweir                         pSct->DelEmpty( sal_False );
1087cdf0e10cSrcweir                         // Wenn ein gelockter Bereich nicht geloescht werden darf,
1088cdf0e10cSrcweir                         // so ist zumindest seine Groesse durch das Entfernen seines
1089cdf0e10cSrcweir                         // letzten Contents ungueltig geworden.
1090cdf0e10cSrcweir                         pSct->_InvalidateSize();
1091cdf0e10cSrcweir                     }
1092cdf0e10cSrcweir                     else
1093cdf0e10cSrcweir                     {
1094cdf0e10cSrcweir                         pSct->DelEmpty( sal_True );
1095cdf0e10cSrcweir                         delete pSct;
1096cdf0e10cSrcweir                     }
1097cdf0e10cSrcweir                 }
1098cdf0e10cSrcweir             }
1099cdf0e10cSrcweir         }
1100cdf0e10cSrcweir         else
1101cdf0e10cSrcweir         {
1102cdf0e10cSrcweir             SWRECTFN( this )
1103cdf0e10cSrcweir             long nFrmHeight = (Frm().*fnRect->fnGetHeight)();
1104cdf0e10cSrcweir             if( nFrmHeight )
1105cdf0e10cSrcweir                 pUp->Shrink( nFrmHeight );
1106cdf0e10cSrcweir         }
1107cdf0e10cSrcweir     }
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir 
1110cdf0e10cSrcweir /*************************************************************************
1111cdf0e10cSrcweir |*
1112cdf0e10cSrcweir |*  SwLayoutFrm::Paste()
1113cdf0e10cSrcweir |*
1114cdf0e10cSrcweir |*  Ersterstellung      MA 23. Feb. 94
1115cdf0e10cSrcweir |*  Letzte Aenderung    MA 23. Feb. 94
1116cdf0e10cSrcweir |*
1117cdf0e10cSrcweir |*************************************************************************/
Paste(SwFrm * pParent,SwFrm * pSibling)1118cdf0e10cSrcweir void SwLayoutFrm::Paste( SwFrm* pParent, SwFrm* pSibling)
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir     ASSERT( pParent, "Kein Parent fuer Paste." );
1121cdf0e10cSrcweir     ASSERT( pParent->IsLayoutFrm(), "Parent ist CntntFrm." );
1122cdf0e10cSrcweir     ASSERT( pParent != this, "Bin selbst der Parent." );
1123cdf0e10cSrcweir     ASSERT( pSibling != this, "Bin mein eigener Nachbar." );
1124cdf0e10cSrcweir     ASSERT( !GetPrev() && !GetNext() && !GetUpper(),
1125cdf0e10cSrcweir             "Bin noch irgendwo angemeldet." );
1126cdf0e10cSrcweir 
1127cdf0e10cSrcweir     //In den Baum einhaengen.
1128cdf0e10cSrcweir     InsertBefore( (SwLayoutFrm*)pParent, pSibling );
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir     // OD 24.10.2002 #103517# - correct setting of variable <fnRect>
1131cdf0e10cSrcweir     // <fnRect> is used for the following:
1132cdf0e10cSrcweir     // (1) To invalidate the frame's size, if its size, which has to be the
1133cdf0e10cSrcweir     //      same as its upper/parent, differs from its upper's/parent's.
1134cdf0e10cSrcweir     // (2) To adjust/grow the frame's upper/parent, if it has a dimension in its
1135cdf0e10cSrcweir     //      size, which is not determined by its upper/parent.
1136cdf0e10cSrcweir     // Which size is which depends on the frame type and the layout direction
1137cdf0e10cSrcweir     // (vertical or horizontal).
1138cdf0e10cSrcweir     // There are the following cases:
1139cdf0e10cSrcweir     // (A) Header and footer frames both in vertical and in horizontal layout
1140cdf0e10cSrcweir     //      have to size the width to the upper/parent. A dimension in the height
1141cdf0e10cSrcweir     //      has to cause a adjustment/grow of the upper/parent.
1142cdf0e10cSrcweir     //      --> <fnRect> = fnRectHori
1143cdf0e10cSrcweir     // (B) Cell and column frames in vertical layout, the width has to be the
1144cdf0e10cSrcweir     //          same as upper/parent and a dimension in height causes adjustment/grow
1145cdf0e10cSrcweir     //          of the upper/parent.
1146cdf0e10cSrcweir     //          --> <fnRect> = fnRectHori
1147cdf0e10cSrcweir     //      in horizontal layout the other way around
1148cdf0e10cSrcweir     //          --> <fnRect> = fnRectVert
1149cdf0e10cSrcweir     // (C) Other frames in vertical layout, the height has to be the
1150cdf0e10cSrcweir     //          same as upper/parent and a dimension in width causes adjustment/grow
1151cdf0e10cSrcweir     //          of the upper/parent.
1152cdf0e10cSrcweir     //          --> <fnRect> = fnRectVert
1153cdf0e10cSrcweir     //      in horizontal layout the other way around
1154cdf0e10cSrcweir     //          --> <fnRect> = fnRectHori
1155cdf0e10cSrcweir     //SwRectFn fnRect = IsVertical() ? fnRectHori : fnRectVert;
1156cdf0e10cSrcweir     SwRectFn fnRect;
1157cdf0e10cSrcweir     if ( IsHeaderFrm() || IsFooterFrm() )
1158cdf0e10cSrcweir         fnRect = fnRectHori;
1159cdf0e10cSrcweir     else if ( IsCellFrm() || IsColumnFrm() )
1160cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
1161cdf0e10cSrcweir         fnRect = GetUpper()->IsVertical() ? fnRectHori : ( GetUpper()->IsVertLR() ? fnRectVertL2R : fnRectVert );
1162cdf0e10cSrcweir     else
1163cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
1164cdf0e10cSrcweir         fnRect = GetUpper()->IsVertical() ? ( GetUpper()->IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
1165cdf0e10cSrcweir 
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir     if( (Frm().*fnRect->fnGetWidth)() != (pParent->Prt().*fnRect->fnGetWidth)())
1168cdf0e10cSrcweir         _InvalidateSize();
1169cdf0e10cSrcweir     _InvalidatePos();
1170cdf0e10cSrcweir     const SwPageFrm *pPage = FindPageFrm();
1171cdf0e10cSrcweir     InvalidatePage( pPage );
1172cdf0e10cSrcweir     SwFrm *pFrm;
1173cdf0e10cSrcweir     if( !IsColumnFrm() )
1174cdf0e10cSrcweir     {
1175cdf0e10cSrcweir         if( 0 != ( pFrm = GetIndNext() ) )
1176cdf0e10cSrcweir         {
1177cdf0e10cSrcweir             pFrm->_InvalidatePos();
1178cdf0e10cSrcweir             if( IsInFtn() )
1179cdf0e10cSrcweir             {
1180cdf0e10cSrcweir                 if( pFrm->IsSctFrm() )
1181cdf0e10cSrcweir                     pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
1182cdf0e10cSrcweir                 if( pFrm )
1183cdf0e10cSrcweir                     pFrm->Prepare( PREP_ERGOSUM, 0, sal_False );
1184cdf0e10cSrcweir             }
1185cdf0e10cSrcweir         }
1186cdf0e10cSrcweir         if ( IsInFtn() && 0 != ( pFrm = GetIndPrev() ) )
1187cdf0e10cSrcweir         {
1188cdf0e10cSrcweir             if( pFrm->IsSctFrm() )
1189cdf0e10cSrcweir                 pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
1190cdf0e10cSrcweir             if( pFrm )
1191cdf0e10cSrcweir                 pFrm->Prepare( PREP_QUOVADIS, 0, sal_False );
1192cdf0e10cSrcweir         }
1193cdf0e10cSrcweir     }
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir     if( (Frm().*fnRect->fnGetHeight)() )
1196cdf0e10cSrcweir     {
1197cdf0e10cSrcweir         // AdjustNeighbourhood wird jetzt auch in Spalten aufgerufen,
1198cdf0e10cSrcweir         // die sich nicht in Rahmen befinden
1199cdf0e10cSrcweir         sal_uInt8 nAdjust = GetUpper()->IsFtnBossFrm() ?
1200cdf0e10cSrcweir                 ((SwFtnBossFrm*)GetUpper())->NeighbourhoodAdjustment( this )
1201cdf0e10cSrcweir                 : NA_GROW_SHRINK;
1202cdf0e10cSrcweir         SwTwips nGrow = (Frm().*fnRect->fnGetHeight)();
1203cdf0e10cSrcweir         if( NA_ONLY_ADJUST == nAdjust )
1204cdf0e10cSrcweir             AdjustNeighbourhood( nGrow );
1205cdf0e10cSrcweir         else
1206cdf0e10cSrcweir         {
1207cdf0e10cSrcweir             SwTwips nReal = 0;
1208cdf0e10cSrcweir             if( NA_ADJUST_GROW == nAdjust )
1209cdf0e10cSrcweir                 nReal = AdjustNeighbourhood( nGrow );
1210cdf0e10cSrcweir             if( nReal < nGrow )
1211cdf0e10cSrcweir                 nReal += pParent->Grow( nGrow - nReal );
1212cdf0e10cSrcweir             if( NA_GROW_ADJUST == nAdjust && nReal < nGrow )
1213cdf0e10cSrcweir                 AdjustNeighbourhood( nGrow - nReal );
1214cdf0e10cSrcweir         }
1215cdf0e10cSrcweir     }
1216cdf0e10cSrcweir }
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir /*************************************************************************
1219cdf0e10cSrcweir |*
1220cdf0e10cSrcweir |*  SwLayoutFrm::Cut()
1221cdf0e10cSrcweir |*
1222cdf0e10cSrcweir |*  Ersterstellung      MA 23. Feb. 94
1223cdf0e10cSrcweir |*  Letzte Aenderung    MA 23. Feb. 94
1224cdf0e10cSrcweir |*
1225cdf0e10cSrcweir |*************************************************************************/
Cut()1226cdf0e10cSrcweir void SwLayoutFrm::Cut()
1227cdf0e10cSrcweir {
1228cdf0e10cSrcweir     if ( GetNext() )
1229cdf0e10cSrcweir         GetNext()->_InvalidatePos();
1230cdf0e10cSrcweir 
1231cdf0e10cSrcweir     SWRECTFN( this )
1232cdf0e10cSrcweir     SwTwips nShrink = (Frm().*fnRect->fnGetHeight)();
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir     //Erst removen, dann Upper Shrinken.
1235cdf0e10cSrcweir     SwLayoutFrm *pUp = GetUpper();
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir     // AdjustNeighbourhood wird jetzt auch in Spalten aufgerufen,
1238cdf0e10cSrcweir     // die sich nicht in Rahmen befinden
1239cdf0e10cSrcweir 
1240cdf0e10cSrcweir     // Remove must not be called before a AdjustNeighbourhood, but it has to
1241cdf0e10cSrcweir     // be called before the upper-shrink-call, if the upper-shrink takes care
1242cdf0e10cSrcweir     // of his content
1243cdf0e10cSrcweir     if ( pUp && nShrink )
1244cdf0e10cSrcweir     {
1245cdf0e10cSrcweir         if( pUp->IsFtnBossFrm() )
1246cdf0e10cSrcweir         {
1247cdf0e10cSrcweir             sal_uInt8 nAdjust= ((SwFtnBossFrm*)pUp)->NeighbourhoodAdjustment( this );
1248cdf0e10cSrcweir             if( NA_ONLY_ADJUST == nAdjust )
1249cdf0e10cSrcweir                 AdjustNeighbourhood( -nShrink );
1250cdf0e10cSrcweir             else
1251cdf0e10cSrcweir             {
1252cdf0e10cSrcweir                 SwTwips nReal = 0;
1253cdf0e10cSrcweir                 if( NA_ADJUST_GROW == nAdjust )
1254cdf0e10cSrcweir                     nReal = -AdjustNeighbourhood( -nShrink );
1255cdf0e10cSrcweir                 if( nReal < nShrink )
1256cdf0e10cSrcweir                 {
1257cdf0e10cSrcweir                     SwTwips nOldHeight = (Frm().*fnRect->fnGetHeight)();
1258cdf0e10cSrcweir                     (Frm().*fnRect->fnSetHeight)( 0 );
1259cdf0e10cSrcweir                     nReal += pUp->Shrink( nShrink - nReal );
1260cdf0e10cSrcweir                     (Frm().*fnRect->fnSetHeight)( nOldHeight );
1261cdf0e10cSrcweir                 }
1262cdf0e10cSrcweir                 if( NA_GROW_ADJUST == nAdjust && nReal < nShrink )
1263cdf0e10cSrcweir                     AdjustNeighbourhood( nReal - nShrink );
1264cdf0e10cSrcweir             }
1265cdf0e10cSrcweir             Remove();
1266cdf0e10cSrcweir         }
1267cdf0e10cSrcweir         else
1268cdf0e10cSrcweir         {
1269cdf0e10cSrcweir             Remove();
1270cdf0e10cSrcweir             pUp->Shrink( nShrink );
1271cdf0e10cSrcweir         }
1272cdf0e10cSrcweir     }
1273cdf0e10cSrcweir     else
1274cdf0e10cSrcweir         Remove();
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir     if( pUp && !pUp->Lower() )
1277cdf0e10cSrcweir     {
1278cdf0e10cSrcweir         pUp->SetCompletePaint();
1279cdf0e10cSrcweir         pUp->InvalidatePage();
1280cdf0e10cSrcweir     }
1281cdf0e10cSrcweir }
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir /*************************************************************************
1284cdf0e10cSrcweir |*
1285cdf0e10cSrcweir |*  SwFrm::Grow()
1286cdf0e10cSrcweir |*
1287cdf0e10cSrcweir |*  Ersterstellung      AK 19-Feb-1991
1288cdf0e10cSrcweir |*  Letzte Aenderung    MA 05. May. 94
1289cdf0e10cSrcweir |*
1290cdf0e10cSrcweir |*************************************************************************/
Grow(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)1291cdf0e10cSrcweir SwTwips SwFrm::Grow( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
1292cdf0e10cSrcweir {
1293cdf0e10cSrcweir     ASSERT( nDist >= 0, "Negatives Wachstum?" );
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir     PROTOCOL_ENTER( this, bTst ? PROT_GROW_TST : PROT_GROW, 0, &nDist )
1296cdf0e10cSrcweir 
1297cdf0e10cSrcweir     if ( nDist )
1298cdf0e10cSrcweir     {
1299cdf0e10cSrcweir         SWRECTFN( this )
1300cdf0e10cSrcweir 
1301cdf0e10cSrcweir         SwTwips nPrtHeight = (Prt().*fnRect->fnGetHeight)();
1302cdf0e10cSrcweir         if( nPrtHeight > 0 && nDist > (LONG_MAX - nPrtHeight) )
1303cdf0e10cSrcweir             nDist = LONG_MAX - nPrtHeight;
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir         if ( IsFlyFrm() )
1306cdf0e10cSrcweir             return ((SwFlyFrm*)this)->_Grow( nDist, bTst );
1307cdf0e10cSrcweir         else if( IsSctFrm() )
1308cdf0e10cSrcweir             return ((SwSectionFrm*)this)->_Grow( nDist, bTst );
1309cdf0e10cSrcweir         else
1310cdf0e10cSrcweir         {
1311cdf0e10cSrcweir             const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
1312cdf0e10cSrcweir             if ( pThisCell )
1313cdf0e10cSrcweir             {
1314cdf0e10cSrcweir                 const SwTabFrm* pTab = FindTabFrm();
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir                 // NEW TABLES
1317cdf0e10cSrcweir                 if ( ( 0 != pTab->IsVertical() ) != ( 0 != IsVertical() ) ||
1318cdf0e10cSrcweir                      pThisCell->GetLayoutRowSpan() < 1 )
1319cdf0e10cSrcweir                     return 0;
1320cdf0e10cSrcweir             }
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir             const SwTwips nReal = GrowFrm( nDist, bTst, bInfo );
1323cdf0e10cSrcweir             if( !bTst )
1324cdf0e10cSrcweir             {
1325cdf0e10cSrcweir                 nPrtHeight = (Prt().*fnRect->fnGetHeight)();
1326cdf0e10cSrcweir                 (Prt().*fnRect->fnSetHeight)( nPrtHeight +
1327cdf0e10cSrcweir                         ( IsCntntFrm() ? nDist : nReal ) );
1328cdf0e10cSrcweir             }
1329cdf0e10cSrcweir             return nReal;
1330cdf0e10cSrcweir         }
1331cdf0e10cSrcweir     }
1332cdf0e10cSrcweir     return 0L;
1333cdf0e10cSrcweir }
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir /*************************************************************************
1336cdf0e10cSrcweir |*
1337cdf0e10cSrcweir |*  SwFrm::Shrink()
1338cdf0e10cSrcweir |*
1339cdf0e10cSrcweir |*  Ersterstellung      AK 14-Feb-1991
1340cdf0e10cSrcweir |*  Letzte Aenderung    MA 05. May. 94
1341cdf0e10cSrcweir |*
1342cdf0e10cSrcweir |*************************************************************************/
Shrink(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)1343cdf0e10cSrcweir SwTwips SwFrm::Shrink( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
1344cdf0e10cSrcweir {
1345cdf0e10cSrcweir     ASSERT( nDist >= 0, "Negative Verkleinerung?" );
1346cdf0e10cSrcweir 
1347cdf0e10cSrcweir     PROTOCOL_ENTER( this, bTst ? PROT_SHRINK_TST : PROT_SHRINK, 0, &nDist )
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir     if ( nDist )
1350cdf0e10cSrcweir     {
1351cdf0e10cSrcweir         if ( IsFlyFrm() )
1352cdf0e10cSrcweir             return ((SwFlyFrm*)this)->_Shrink( nDist, bTst );
1353cdf0e10cSrcweir         else if( IsSctFrm() )
1354cdf0e10cSrcweir             return ((SwSectionFrm*)this)->_Shrink( nDist, bTst );
1355cdf0e10cSrcweir         else
1356cdf0e10cSrcweir         {
1357cdf0e10cSrcweir             const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
1358cdf0e10cSrcweir             if ( pThisCell )
1359cdf0e10cSrcweir             {
1360cdf0e10cSrcweir                 const SwTabFrm* pTab = FindTabFrm();
1361cdf0e10cSrcweir 
1362cdf0e10cSrcweir                 // NEW TABLES
1363cdf0e10cSrcweir                 if ( ( 0 != pTab->IsVertical() ) != ( 0 != IsVertical() ) ||
1364cdf0e10cSrcweir                      pThisCell->GetLayoutRowSpan() < 1 )
1365cdf0e10cSrcweir                     return 0;
1366cdf0e10cSrcweir             }
1367cdf0e10cSrcweir 
1368cdf0e10cSrcweir             SWRECTFN( this )
1369cdf0e10cSrcweir             SwTwips nReal = (Frm().*fnRect->fnGetHeight)();
1370cdf0e10cSrcweir             ShrinkFrm( nDist, bTst, bInfo );
1371cdf0e10cSrcweir             nReal -= (Frm().*fnRect->fnGetHeight)();
1372cdf0e10cSrcweir             if( !bTst )
1373cdf0e10cSrcweir             {
1374cdf0e10cSrcweir                 const SwTwips nPrtHeight = (Prt().*fnRect->fnGetHeight)();
1375cdf0e10cSrcweir                 (Prt().*fnRect->fnSetHeight)( nPrtHeight -
1376cdf0e10cSrcweir                         ( IsCntntFrm() ? nDist : nReal ) );
1377cdf0e10cSrcweir             }
1378cdf0e10cSrcweir             return nReal;
1379cdf0e10cSrcweir         }
1380cdf0e10cSrcweir     }
1381cdf0e10cSrcweir     return 0L;
1382cdf0e10cSrcweir }
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir /*************************************************************************
1385cdf0e10cSrcweir |*
1386cdf0e10cSrcweir |*  SwFrm::AdjustNeighbourhood()
1387cdf0e10cSrcweir |*
1388cdf0e10cSrcweir |*  Beschreibung        Wenn sich die Groesse eines Frm's direkt unterhalb
1389cdf0e10cSrcweir |*      eines Fussnotenbosses (Seite/Spalte) veraendert hat, so muss dieser
1390cdf0e10cSrcweir |*      "Normalisiert" werden.
1391cdf0e10cSrcweir |*      Es gibt dort immer einen Frame, der den "maximal moeglichen" Raum
1392cdf0e10cSrcweir |*      einnimmt (der Frame, der den Body.Text enhaelt) und keinen oder
1393cdf0e10cSrcweir |*      mehrere Frames die den Platz einnehmen den sie halt brauchen
1394cdf0e10cSrcweir |*      (Kopf-/Fussbereich, Fussnoten).
1395cdf0e10cSrcweir |*      Hat sich einer der Frames veraendert, so muss der Body-Text-Frame
1396cdf0e10cSrcweir |*      entsprechen wachsen oder schrumpfen; unabhaegig davon, dass er fix ist.
1397cdf0e10cSrcweir |*      !! Ist es moeglich dies allgemeiner zu loesen, also nicht auf die
1398cdf0e10cSrcweir |*      Seite beschraenkt und nicht auf einen Speziellen Frame, der den
1399cdf0e10cSrcweir |*      maximalen Platz einnimmt (gesteuert ueber Attribut FrmSize)? Probleme:
1400cdf0e10cSrcweir |*      Was ist wenn mehrere Frames nebeneinander stehen, die den maximalen
1401cdf0e10cSrcweir |*      Platz einnehmen?
1402cdf0e10cSrcweir |*      Wie wird der Maximale Platz berechnet?
1403cdf0e10cSrcweir |*      Wie klein duerfen diese Frames werden?
1404cdf0e10cSrcweir |*
1405cdf0e10cSrcweir |*      Es wird auf jeden Fall nur so viel Platz genehmigt, dass ein
1406cdf0e10cSrcweir |*      Minimalwert fuer die Hoehe des Bodys nicht unterschritten wird.
1407cdf0e10cSrcweir |*
1408cdf0e10cSrcweir |*  Parameter: nDiff ist der Betrag, um den Platz geschaffen werden muss
1409cdf0e10cSrcweir |*
1410cdf0e10cSrcweir |*  Ersterstellung      MA 07. May. 92
1411cdf0e10cSrcweir |*  Letzte Aenderung    AMA 02. Nov. 98
1412cdf0e10cSrcweir |*
1413cdf0e10cSrcweir |*************************************************************************/
AdjustNeighbourhood(SwTwips nDiff,sal_Bool bTst)1414cdf0e10cSrcweir SwTwips SwFrm::AdjustNeighbourhood( SwTwips nDiff, sal_Bool bTst )
1415cdf0e10cSrcweir {
1416cdf0e10cSrcweir     PROTOCOL_ENTER( this, PROT_ADJUSTN, 0, &nDiff );
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir     if ( !nDiff || !GetUpper()->IsFtnBossFrm() ) // nur innerhalb von Seiten/Spalten
1419cdf0e10cSrcweir         return 0L;
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir     const ViewShell *pSh = getRootFrm()->GetCurrShell();
1422cdf0e10cSrcweir     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
1423cdf0e10cSrcweir 
1424cdf0e10cSrcweir     //Der (Page)Body veraendert sich nur im BrowseMode, aber nicht wenn er
1425cdf0e10cSrcweir     //Spalten enthaelt.
1426cdf0e10cSrcweir     if ( IsPageBodyFrm() && (!bBrowse ||
1427cdf0e10cSrcweir           (((SwLayoutFrm*)this)->Lower() &&
1428cdf0e10cSrcweir            ((SwLayoutFrm*)this)->Lower()->IsColumnFrm())) )
1429cdf0e10cSrcweir         return 0L;
1430cdf0e10cSrcweir 
1431cdf0e10cSrcweir     //In der BrowseView kann der PageFrm selbst ersteinmal einiges von den
1432cdf0e10cSrcweir     //Wuenschen abfangen.
1433cdf0e10cSrcweir     long nBrowseAdd = 0;
1434cdf0e10cSrcweir     if ( bBrowse && GetUpper()->IsPageFrm() ) // nur (Page)BodyFrms
1435cdf0e10cSrcweir     {
1436cdf0e10cSrcweir         ViewShell *pViewShell = getRootFrm()->GetCurrShell();
1437cdf0e10cSrcweir         SwLayoutFrm *pUp = GetUpper();
1438cdf0e10cSrcweir         long nChg;
1439cdf0e10cSrcweir         const long nUpPrtBottom = pUp->Frm().Height() -
1440cdf0e10cSrcweir                                   pUp->Prt().Height() - pUp->Prt().Top();
1441cdf0e10cSrcweir         SwRect aInva( pUp->Frm() );
1442cdf0e10cSrcweir         if ( pViewShell )
1443cdf0e10cSrcweir         {
1444cdf0e10cSrcweir             aInva.Pos().X() = pViewShell->VisArea().Left();
1445cdf0e10cSrcweir             aInva.Width( pViewShell->VisArea().Width() );
1446cdf0e10cSrcweir         }
1447cdf0e10cSrcweir         if ( nDiff > 0 )
1448cdf0e10cSrcweir         {
1449cdf0e10cSrcweir             nChg = BROWSE_HEIGHT - pUp->Frm().Height();
1450cdf0e10cSrcweir             nChg = Min( nDiff, nChg );
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir             if ( !IsBodyFrm() )
1453cdf0e10cSrcweir             {
1454cdf0e10cSrcweir                 SetCompletePaint();
1455cdf0e10cSrcweir                 if ( !pViewShell || pViewShell->VisArea().Height() >= pUp->Frm().Height() )
1456cdf0e10cSrcweir                 {
1457cdf0e10cSrcweir                     //Ersteinmal den Body verkleinern. Der waechst dann schon
1458cdf0e10cSrcweir                     //wieder.
1459cdf0e10cSrcweir                     SwFrm *pBody = ((SwFtnBossFrm*)pUp)->FindBodyCont();
1460cdf0e10cSrcweir                     const long nTmp = nChg - pBody->Prt().Height();
1461cdf0e10cSrcweir                     if ( !bTst )
1462cdf0e10cSrcweir                     {
1463cdf0e10cSrcweir                         pBody->Frm().Height(Max( 0L, pBody->Frm().Height() - nChg ));
1464cdf0e10cSrcweir                         pBody->_InvalidatePrt();
1465cdf0e10cSrcweir                         pBody->_InvalidateSize();
1466cdf0e10cSrcweir                         if ( pBody->GetNext() )
1467cdf0e10cSrcweir                             pBody->GetNext()->_InvalidatePos();
1468cdf0e10cSrcweir                         if ( !IsHeaderFrm() )
1469cdf0e10cSrcweir                             pBody->SetCompletePaint();
1470cdf0e10cSrcweir                     }
1471cdf0e10cSrcweir                     nChg = nTmp <= 0 ? 0 : nTmp;
1472cdf0e10cSrcweir                 }
1473cdf0e10cSrcweir             }
1474cdf0e10cSrcweir 
1475cdf0e10cSrcweir             const long nTmp = nUpPrtBottom + 20;
1476cdf0e10cSrcweir             aInva.Top( aInva.Bottom() - nTmp );
1477cdf0e10cSrcweir             aInva.Height( nChg + nTmp );
1478cdf0e10cSrcweir         }
1479cdf0e10cSrcweir         else
1480cdf0e10cSrcweir         {
1481cdf0e10cSrcweir             //Die Seite kann bis auf 0 schrumpfen. Die erste Seite bleibt
1482cdf0e10cSrcweir             //mindestens so gross wie die VisArea.
1483cdf0e10cSrcweir             nChg = nDiff;
1484cdf0e10cSrcweir             long nInvaAdd = 0;
1485cdf0e10cSrcweir             if ( pViewShell && !pUp->GetPrev() &&
1486cdf0e10cSrcweir                  pUp->Frm().Height() + nDiff < pViewShell->VisArea().Height() )
1487cdf0e10cSrcweir             {
1488cdf0e10cSrcweir                 //Das heisst aber wiederum trotzdem, das wir geeignet invalidieren
1489cdf0e10cSrcweir                 //muessen.
1490cdf0e10cSrcweir                 nChg = pViewShell->VisArea().Height() - pUp->Frm().Height();
1491cdf0e10cSrcweir                 nInvaAdd = -(nDiff - nChg);
1492cdf0e10cSrcweir             }
1493cdf0e10cSrcweir 
1494cdf0e10cSrcweir             //Invalidieren inklusive unterem Rand.
1495cdf0e10cSrcweir             long nBorder = nUpPrtBottom + 20;
1496cdf0e10cSrcweir             nBorder -= nChg;
1497cdf0e10cSrcweir             aInva.Top( aInva.Bottom() - (nBorder+nInvaAdd) );
1498cdf0e10cSrcweir             if ( !IsBodyFrm() )
1499cdf0e10cSrcweir             {
1500cdf0e10cSrcweir                 SetCompletePaint();
1501cdf0e10cSrcweir                 if ( !IsHeaderFrm() )
1502cdf0e10cSrcweir                     ((SwFtnBossFrm*)pUp)->FindBodyCont()->SetCompletePaint();
1503cdf0e10cSrcweir             }
1504cdf0e10cSrcweir             //Wegen der Rahmen die Seite invalidieren. Dadurch wird die Seite
1505cdf0e10cSrcweir             //wieder entsprechend gross wenn ein Rahmen nicht passt. Das
1506cdf0e10cSrcweir             //funktioniert anderfalls nur zufaellig fuer absatzgebundene Rahmen
1507cdf0e10cSrcweir             //(NotifyFlys).
1508cdf0e10cSrcweir             pUp->InvalidateSize();
1509cdf0e10cSrcweir         }
1510cdf0e10cSrcweir         if ( !bTst )
1511cdf0e10cSrcweir         {
1512cdf0e10cSrcweir             //Unabhaengig von nChg
1513cdf0e10cSrcweir             if ( pViewShell && aInva.HasArea() && pUp->GetUpper() )
1514cdf0e10cSrcweir                 pViewShell->InvalidateWindows( aInva );
1515cdf0e10cSrcweir         }
1516cdf0e10cSrcweir         if ( !bTst && nChg )
1517cdf0e10cSrcweir         {
1518cdf0e10cSrcweir             const SwRect aOldRect( pUp->Frm() );
1519cdf0e10cSrcweir             pUp->Frm().SSize().Height() += nChg;
1520cdf0e10cSrcweir             pUp->Prt().SSize().Height() += nChg;
1521cdf0e10cSrcweir             if ( pViewShell )
1522cdf0e10cSrcweir                 pViewShell->Imp()->SetFirstVisPageInvalid();
1523cdf0e10cSrcweir 
1524cdf0e10cSrcweir             if ( GetNext() )
1525cdf0e10cSrcweir                 GetNext()->_InvalidatePos();
1526cdf0e10cSrcweir 
1527cdf0e10cSrcweir             //Ggf. noch ein Repaint ausloesen.
1528cdf0e10cSrcweir             const SvxGraphicPosition ePos = pUp->GetFmt()->GetBackground().GetGraphicPos();
1529cdf0e10cSrcweir             if ( ePos != GPOS_NONE && ePos != GPOS_TILED )
1530cdf0e10cSrcweir                 pViewShell->InvalidateWindows( pUp->Frm() );
1531cdf0e10cSrcweir 
1532cdf0e10cSrcweir             if ( pUp->GetUpper() )
1533cdf0e10cSrcweir             {
1534cdf0e10cSrcweir                 if ( pUp->GetNext() )
1535cdf0e10cSrcweir                     pUp->GetNext()->InvalidatePos();
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir                 //Mies aber wahr: im Notify am ViewImp wird evtl. ein Calc
1538cdf0e10cSrcweir                 //auf die Seite und deren Lower gerufen. Die Werte sollten
1539cdf0e10cSrcweir                 //unverandert bleiben, weil der Aufrufer bereits fuer die
1540cdf0e10cSrcweir                 //Anpassung von Frm und Prt sorgen wird.
1541cdf0e10cSrcweir                 const long nOldFrmHeight = Frm().Height();
1542cdf0e10cSrcweir                 const long nOldPrtHeight = Prt().Height();
1543cdf0e10cSrcweir                 const sal_Bool bOldComplete = IsCompletePaint();
1544cdf0e10cSrcweir                 if ( IsBodyFrm() )
1545cdf0e10cSrcweir                     Prt().SSize().Height() = nOldFrmHeight;
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir                 // PAGES01
1548cdf0e10cSrcweir                 if ( pUp->GetUpper() )
1549cdf0e10cSrcweir                     static_cast<SwRootFrm*>(pUp->GetUpper())->CheckViewLayout( 0, 0 );
1550cdf0e10cSrcweir                 //((SwPageFrm*)pUp)->AdjustRootSize( CHG_CHGPAGE, &aOldRect );
1551cdf0e10cSrcweir 
1552cdf0e10cSrcweir                 Frm().SSize().Height() = nOldFrmHeight;
1553cdf0e10cSrcweir                 Prt().SSize().Height() = nOldPrtHeight;
1554cdf0e10cSrcweir                 bCompletePaint = bOldComplete;
1555cdf0e10cSrcweir             }
1556cdf0e10cSrcweir             if ( !IsBodyFrm() )
1557cdf0e10cSrcweir                 pUp->_InvalidateSize();
1558cdf0e10cSrcweir             InvalidatePage( (SwPageFrm*)pUp );
1559cdf0e10cSrcweir         }
1560cdf0e10cSrcweir         nDiff -= nChg;
1561cdf0e10cSrcweir         if ( !nDiff )
1562cdf0e10cSrcweir             return nChg;
1563cdf0e10cSrcweir         else
1564cdf0e10cSrcweir             nBrowseAdd = nChg;
1565cdf0e10cSrcweir     }
1566cdf0e10cSrcweir 
1567cdf0e10cSrcweir     const SwFtnBossFrm *pBoss = (SwFtnBossFrm*)GetUpper();
1568cdf0e10cSrcweir 
1569cdf0e10cSrcweir     SwTwips nReal = 0,
1570cdf0e10cSrcweir             nAdd  = 0;
1571cdf0e10cSrcweir     SwFrm *pFrm = 0;
1572cdf0e10cSrcweir     SWRECTFN( this )
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir     if( IsBodyFrm() )
1575cdf0e10cSrcweir     {
1576cdf0e10cSrcweir         if( IsInSct() )
1577cdf0e10cSrcweir         {
1578cdf0e10cSrcweir             SwSectionFrm *pSect = FindSctFrm();
1579cdf0e10cSrcweir             if( nDiff > 0 && pSect->IsEndnAtEnd() && GetNext() &&
1580cdf0e10cSrcweir                 GetNext()->IsFtnContFrm() )
1581cdf0e10cSrcweir             {
1582cdf0e10cSrcweir                 SwFtnContFrm* pCont = (SwFtnContFrm*)GetNext();
1583cdf0e10cSrcweir                 SwTwips nMinH = 0;
1584cdf0e10cSrcweir                 SwFtnFrm* pFtn = (SwFtnFrm*)pCont->Lower();
1585cdf0e10cSrcweir                 sal_Bool bFtn = sal_False;
1586cdf0e10cSrcweir                 while( pFtn )
1587cdf0e10cSrcweir                 {
1588cdf0e10cSrcweir                     if( !pFtn->GetAttr()->GetFtn().IsEndNote() )
1589cdf0e10cSrcweir                     {
1590cdf0e10cSrcweir                         nMinH += (pFtn->Frm().*fnRect->fnGetHeight)();
1591cdf0e10cSrcweir                         bFtn = sal_True;
1592cdf0e10cSrcweir                     }
1593cdf0e10cSrcweir                     pFtn = (SwFtnFrm*)pFtn->GetNext();
1594cdf0e10cSrcweir                 }
1595cdf0e10cSrcweir                 if( bFtn )
1596cdf0e10cSrcweir                     nMinH += (pCont->Prt().*fnRect->fnGetTop)();
1597cdf0e10cSrcweir                 nReal = (pCont->Frm().*fnRect->fnGetHeight)() - nMinH;
1598cdf0e10cSrcweir                 if( nReal > nDiff )
1599cdf0e10cSrcweir                     nReal = nDiff;
1600cdf0e10cSrcweir                 if( nReal > 0 )
1601cdf0e10cSrcweir                     pFrm = GetNext();
1602cdf0e10cSrcweir                 else
1603cdf0e10cSrcweir                     nReal = 0;
1604cdf0e10cSrcweir             }
1605cdf0e10cSrcweir             if( !bTst && !pSect->IsColLocked() )
1606cdf0e10cSrcweir                 pSect->InvalidateSize();
1607cdf0e10cSrcweir         }
1608cdf0e10cSrcweir         if( !pFrm )
1609cdf0e10cSrcweir             return nBrowseAdd;
1610cdf0e10cSrcweir     }
1611cdf0e10cSrcweir     else
1612cdf0e10cSrcweir     {
1613cdf0e10cSrcweir         const sal_Bool bFtnPage = pBoss->IsPageFrm() && ((SwPageFrm*)pBoss)->IsFtnPage();
1614cdf0e10cSrcweir         if ( bFtnPage && !IsFtnContFrm() )
1615cdf0e10cSrcweir             pFrm = (SwFrm*)pBoss->FindFtnCont();
1616cdf0e10cSrcweir         if ( !pFrm )
1617cdf0e10cSrcweir             pFrm = (SwFrm*)pBoss->FindBodyCont();
1618cdf0e10cSrcweir 
1619cdf0e10cSrcweir         if ( !pFrm )
1620cdf0e10cSrcweir             return 0;
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir         //Wenn ich keinen finde eruebrigt sich alles weitere.
1623cdf0e10cSrcweir         nReal = (pFrm->Frm().*fnRect->fnGetHeight)();
1624cdf0e10cSrcweir         if( nReal > nDiff )
1625cdf0e10cSrcweir             nReal = nDiff;
1626cdf0e10cSrcweir         if( !bFtnPage )
1627cdf0e10cSrcweir         {
1628cdf0e10cSrcweir             //Minimalgrenze beachten!
1629cdf0e10cSrcweir             if( nReal )
1630cdf0e10cSrcweir             {
1631cdf0e10cSrcweir                 const SwTwips nMax = pBoss->GetVarSpace();
1632cdf0e10cSrcweir                 if ( nReal > nMax )
1633cdf0e10cSrcweir                     nReal = nMax;
1634cdf0e10cSrcweir             }
1635cdf0e10cSrcweir             if( !IsFtnContFrm() && nDiff > nReal &&
1636cdf0e10cSrcweir                 pFrm->GetNext() && pFrm->GetNext()->IsFtnContFrm()
1637cdf0e10cSrcweir                 && ( pFrm->GetNext()->IsVertical() == IsVertical() )
1638cdf0e10cSrcweir                 )
1639cdf0e10cSrcweir             {
1640cdf0e10cSrcweir                 //Wenn der Body nicht genuegend her gibt, kann ich noch mal
1641cdf0e10cSrcweir                 //schauen ob es eine Fussnote gibt, falls ja kann dieser
1642cdf0e10cSrcweir                 //entsprechend viel gemopst werden.
1643cdf0e10cSrcweir                 const SwTwips nAddMax = (pFrm->GetNext()->Frm().*fnRect->
1644cdf0e10cSrcweir                                         fnGetHeight)();
1645cdf0e10cSrcweir                 nAdd = nDiff - nReal;
1646cdf0e10cSrcweir                 if ( nAdd > nAddMax )
1647cdf0e10cSrcweir                     nAdd = nAddMax;
1648cdf0e10cSrcweir                 if ( !bTst )
1649cdf0e10cSrcweir                 {
1650cdf0e10cSrcweir                     (pFrm->GetNext()->Frm().*fnRect->fnSetHeight)(nAddMax-nAdd);
1651cdf0e10cSrcweir                     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
1652cdf0e10cSrcweir                     if( bVert && !bVertL2R && !bRev )
1653cdf0e10cSrcweir                         pFrm->GetNext()->Frm().Pos().X() += nAdd;
1654cdf0e10cSrcweir                     pFrm->GetNext()->InvalidatePrt();
1655cdf0e10cSrcweir                     if ( pFrm->GetNext()->GetNext() )
1656cdf0e10cSrcweir                         pFrm->GetNext()->GetNext()->_InvalidatePos();
1657cdf0e10cSrcweir                 }
1658cdf0e10cSrcweir             }
1659cdf0e10cSrcweir         }
1660cdf0e10cSrcweir     }
1661cdf0e10cSrcweir 
1662cdf0e10cSrcweir     if ( !bTst && nReal )
1663cdf0e10cSrcweir     {
1664cdf0e10cSrcweir         SwTwips nTmp = (pFrm->Frm().*fnRect->fnGetHeight)();
1665cdf0e10cSrcweir         (pFrm->Frm().*fnRect->fnSetHeight)( nTmp - nReal );
1666cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
1667cdf0e10cSrcweir         if( bVert && !bVertL2R && !bRev )
1668cdf0e10cSrcweir             pFrm->Frm().Pos().X() += nReal;
1669cdf0e10cSrcweir         pFrm->InvalidatePrt();
1670cdf0e10cSrcweir         if ( pFrm->GetNext() )
1671cdf0e10cSrcweir             pFrm->GetNext()->_InvalidatePos();
1672cdf0e10cSrcweir         if( nReal < 0 && pFrm->IsInSct() )
1673cdf0e10cSrcweir         {
1674cdf0e10cSrcweir             SwLayoutFrm* pUp = pFrm->GetUpper();
1675cdf0e10cSrcweir             if( pUp && 0 != ( pUp = pUp->GetUpper() ) && pUp->IsSctFrm() &&
1676cdf0e10cSrcweir                 !pUp->IsColLocked() )
1677cdf0e10cSrcweir                 pUp->InvalidateSize();
1678cdf0e10cSrcweir         }
1679cdf0e10cSrcweir         if( ( IsHeaderFrm() || IsFooterFrm() ) && pBoss->GetDrawObjs() )
1680cdf0e10cSrcweir         {
1681cdf0e10cSrcweir             const SwSortedObjs &rObjs = *pBoss->GetDrawObjs();
1682cdf0e10cSrcweir             ASSERT( pBoss->IsPageFrm(), "Header/Footer out of page?" );
1683cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
1684cdf0e10cSrcweir             {
1685cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = rObjs[i];
1686cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyFrm) )
1687cdf0e10cSrcweir                 {
1688cdf0e10cSrcweir                     SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
1689cdf0e10cSrcweir                     ASSERT( !pFly->IsFlyInCntFrm(), "FlyInCnt at Page?" );
1690cdf0e10cSrcweir                     const SwFmtVertOrient &rVert =
1691cdf0e10cSrcweir                                         pFly->GetFmt()->GetVertOrient();
1692cdf0e10cSrcweir                    // Wann muss invalidiert werden?
1693cdf0e10cSrcweir                    // Wenn ein Rahmen am SeitenTextBereich ausgerichtet ist,
1694cdf0e10cSrcweir                    // muss bei Aenderung des Headers ein TOP, MIDDLE oder NONE,
1695cdf0e10cSrcweir                    // bei Aenderung des Footers ein BOTTOM oder MIDDLE
1696cdf0e10cSrcweir                    // ausgerichteter Rahmen seine Position neu berechnen.
1697cdf0e10cSrcweir                     if( ( rVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ||
1698cdf0e10cSrcweir                           rVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA )    &&
1699cdf0e10cSrcweir                         ((IsHeaderFrm() && rVert.GetVertOrient()!=text::VertOrientation::BOTTOM) ||
1700cdf0e10cSrcweir                          (IsFooterFrm() && rVert.GetVertOrient()!=text::VertOrientation::NONE &&
1701cdf0e10cSrcweir                           rVert.GetVertOrient() != text::VertOrientation::TOP)) )
1702cdf0e10cSrcweir                     {
1703cdf0e10cSrcweir                         pFly->_InvalidatePos();
1704cdf0e10cSrcweir                         pFly->_Invalidate();
1705cdf0e10cSrcweir                     }
1706cdf0e10cSrcweir                 }
1707cdf0e10cSrcweir             }
1708cdf0e10cSrcweir         }
1709cdf0e10cSrcweir     }
1710cdf0e10cSrcweir     return (nBrowseAdd + nReal + nAdd);
1711cdf0e10cSrcweir }
1712cdf0e10cSrcweir 
1713cdf0e10cSrcweir /*************************************************************************
1714cdf0e10cSrcweir |*
1715cdf0e10cSrcweir |*  SwFrm::ImplInvalidateSize(), ImplInvalidatePrt(), ImplInvalidatePos(),
1716cdf0e10cSrcweir |*         ImplInvalidateLineNum()
1717cdf0e10cSrcweir |*
1718cdf0e10cSrcweir |*  Ersterstellung      MA 15. Oct. 92
1719cdf0e10cSrcweir |*  Letzte Aenderung    MA 24. Mar. 94
1720cdf0e10cSrcweir |*
1721cdf0e10cSrcweir |*************************************************************************/
1722cdf0e10cSrcweir /** method to perform additional actions on an invalidation
1723cdf0e10cSrcweir 
1724cdf0e10cSrcweir     OD 2004-05-19 #i28701#
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir     @author OD
1727cdf0e10cSrcweir */
_ActionOnInvalidation(const InvalidationType)1728cdf0e10cSrcweir void SwFrm::_ActionOnInvalidation( const InvalidationType )
1729cdf0e10cSrcweir {
1730cdf0e10cSrcweir     // default behaviour is to perform no additional action
1731cdf0e10cSrcweir }
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir /** method to determine, if an invalidation is allowed.
1734cdf0e10cSrcweir 
1735cdf0e10cSrcweir     OD 2004-05-19 #i28701#
1736cdf0e10cSrcweir 
1737cdf0e10cSrcweir     @author OD
1738cdf0e10cSrcweir */
_InvalidationAllowed(const InvalidationType) const1739cdf0e10cSrcweir bool SwFrm::_InvalidationAllowed( const InvalidationType ) const
1740cdf0e10cSrcweir {
1741cdf0e10cSrcweir     // default behaviour is to allow invalidation
1742cdf0e10cSrcweir     return true;
1743cdf0e10cSrcweir }
1744cdf0e10cSrcweir 
ImplInvalidateSize()1745cdf0e10cSrcweir void SwFrm::ImplInvalidateSize()
1746cdf0e10cSrcweir {
1747cdf0e10cSrcweir     if ( _InvalidationAllowed( INVALID_SIZE ) )
1748cdf0e10cSrcweir     {
1749cdf0e10cSrcweir         bValidSize = sal_False;
1750cdf0e10cSrcweir         if ( IsFlyFrm() )
1751cdf0e10cSrcweir             ((SwFlyFrm*)this)->_Invalidate();
1752cdf0e10cSrcweir         else
1753cdf0e10cSrcweir             InvalidatePage();
1754cdf0e10cSrcweir 
1755cdf0e10cSrcweir         // OD 2004-05-19 #i28701#
1756cdf0e10cSrcweir         _ActionOnInvalidation( INVALID_SIZE );
1757cdf0e10cSrcweir     }
1758cdf0e10cSrcweir }
1759cdf0e10cSrcweir 
ImplInvalidatePrt()1760cdf0e10cSrcweir void SwFrm::ImplInvalidatePrt()
1761cdf0e10cSrcweir {
1762cdf0e10cSrcweir     if ( _InvalidationAllowed( INVALID_PRTAREA ) )
1763cdf0e10cSrcweir     {
1764cdf0e10cSrcweir         bValidPrtArea = sal_False;
1765cdf0e10cSrcweir         if ( IsFlyFrm() )
1766cdf0e10cSrcweir             ((SwFlyFrm*)this)->_Invalidate();
1767cdf0e10cSrcweir         else
1768cdf0e10cSrcweir             InvalidatePage();
1769cdf0e10cSrcweir 
1770cdf0e10cSrcweir         // OD 2004-05-19 #i28701#
1771cdf0e10cSrcweir         _ActionOnInvalidation( INVALID_PRTAREA );
1772cdf0e10cSrcweir     }
1773cdf0e10cSrcweir }
1774cdf0e10cSrcweir 
ImplInvalidatePos()1775cdf0e10cSrcweir void SwFrm::ImplInvalidatePos()
1776cdf0e10cSrcweir {
1777cdf0e10cSrcweir     if ( _InvalidationAllowed( INVALID_POS ) )
1778cdf0e10cSrcweir     {
1779cdf0e10cSrcweir         bValidPos = sal_False;
1780cdf0e10cSrcweir         if ( IsFlyFrm() )
1781cdf0e10cSrcweir         {
1782cdf0e10cSrcweir             ((SwFlyFrm*)this)->_Invalidate();
1783cdf0e10cSrcweir         }
1784cdf0e10cSrcweir         else
1785cdf0e10cSrcweir         {
1786cdf0e10cSrcweir             InvalidatePage();
1787cdf0e10cSrcweir         }
1788cdf0e10cSrcweir 
1789cdf0e10cSrcweir         // OD 2004-05-19 #i28701#
1790cdf0e10cSrcweir         _ActionOnInvalidation( INVALID_POS );
1791cdf0e10cSrcweir     }
1792cdf0e10cSrcweir }
1793cdf0e10cSrcweir 
ImplInvalidateLineNum()1794cdf0e10cSrcweir void SwFrm::ImplInvalidateLineNum()
1795cdf0e10cSrcweir {
1796cdf0e10cSrcweir     if ( _InvalidationAllowed( INVALID_LINENUM ) )
1797cdf0e10cSrcweir     {
1798cdf0e10cSrcweir         bValidLineNum = sal_False;
1799cdf0e10cSrcweir         ASSERT( IsTxtFrm(), "line numbers are implemented for text only" );
1800cdf0e10cSrcweir         InvalidatePage();
1801cdf0e10cSrcweir 
1802cdf0e10cSrcweir         // OD 2004-05-19 #i28701#
1803cdf0e10cSrcweir         _ActionOnInvalidation( INVALID_LINENUM );
1804cdf0e10cSrcweir     }
1805cdf0e10cSrcweir }
1806cdf0e10cSrcweir 
1807cdf0e10cSrcweir /*************************************************************************
1808cdf0e10cSrcweir |*
1809cdf0e10cSrcweir |*  SwFrm::ReinitializeFrmSizeAttrFlags
1810cdf0e10cSrcweir |*
1811cdf0e10cSrcweir |*  Ersterstellung      MA 15. Oct. 96
1812cdf0e10cSrcweir |*  Letzte Aenderung    MA 15. Oct. 96
1813cdf0e10cSrcweir |*
1814cdf0e10cSrcweir |*************************************************************************/
ReinitializeFrmSizeAttrFlags()1815cdf0e10cSrcweir void SwFrm::ReinitializeFrmSizeAttrFlags()
1816cdf0e10cSrcweir {
1817cdf0e10cSrcweir     const SwFmtFrmSize &rFmtSize = GetAttrSet()->GetFrmSize();
1818cdf0e10cSrcweir     if ( ATT_VAR_SIZE == rFmtSize.GetHeightSizeType() ||
1819cdf0e10cSrcweir          ATT_MIN_SIZE == rFmtSize.GetHeightSizeType())
1820cdf0e10cSrcweir     {
1821cdf0e10cSrcweir         bFixSize = sal_False;
1822cdf0e10cSrcweir         if ( GetType() & (FRM_HEADER | FRM_FOOTER | FRM_ROW) )
1823cdf0e10cSrcweir         {
1824cdf0e10cSrcweir             SwFrm *pFrm = ((SwLayoutFrm*)this)->Lower();
1825cdf0e10cSrcweir             while ( pFrm )
1826cdf0e10cSrcweir             {   pFrm->_InvalidateSize();
1827cdf0e10cSrcweir                 pFrm->_InvalidatePrt();
1828cdf0e10cSrcweir                 pFrm = pFrm->GetNext();
1829cdf0e10cSrcweir             }
1830cdf0e10cSrcweir             SwCntntFrm *pCnt = ((SwLayoutFrm*)this)->ContainsCntnt();
1831cdf0e10cSrcweir             // --> OD 2004-12-20 #i36991# - be save.
1832cdf0e10cSrcweir             // E.g., a row can contain *no* content.
1833cdf0e10cSrcweir             if ( pCnt )
1834cdf0e10cSrcweir             {
1835cdf0e10cSrcweir                 pCnt->InvalidatePage();
1836cdf0e10cSrcweir                 do
1837cdf0e10cSrcweir                 {
1838cdf0e10cSrcweir                     pCnt->Prepare( PREP_ADJUST_FRM );
1839cdf0e10cSrcweir                     pCnt->_InvalidateSize();
1840cdf0e10cSrcweir                     pCnt = pCnt->GetNextCntntFrm();
1841cdf0e10cSrcweir                 } while ( ((SwLayoutFrm*)this)->IsAnLower( pCnt ) );
1842cdf0e10cSrcweir             }
1843cdf0e10cSrcweir             // <--
1844cdf0e10cSrcweir         }
1845cdf0e10cSrcweir     }
1846cdf0e10cSrcweir     else if ( rFmtSize.GetHeightSizeType() == ATT_FIX_SIZE )
1847cdf0e10cSrcweir     {
1848cdf0e10cSrcweir         if( IsVertical() )
1849cdf0e10cSrcweir             ChgSize( Size( rFmtSize.GetWidth(), Frm().Height()));
1850cdf0e10cSrcweir         else
1851cdf0e10cSrcweir             ChgSize( Size( Frm().Width(), rFmtSize.GetHeight()));
1852cdf0e10cSrcweir     }
1853cdf0e10cSrcweir }
1854cdf0e10cSrcweir 
1855cdf0e10cSrcweir /*************************************************************************
1856cdf0e10cSrcweir |*  SwFrm::ValidateThisAndAllLowers()
1857cdf0e10cSrcweir  *
1858cdf0e10cSrcweir  * FME 2007-08-30 #i81146# new loop control
1859cdf0e10cSrcweir |*************************************************************************/
ValidateThisAndAllLowers(const sal_uInt16 nStage)1860cdf0e10cSrcweir void SwFrm::ValidateThisAndAllLowers( const sal_uInt16 nStage )
1861cdf0e10cSrcweir {
1862cdf0e10cSrcweir     // Stage 0: Only validate frames. Do not process any objects.
1863cdf0e10cSrcweir     // Stage 1: Only validate fly frames and all of their contents.
1864cdf0e10cSrcweir     // Stage 2: Validate all.
1865cdf0e10cSrcweir 
1866cdf0e10cSrcweir     const bool bOnlyObject = 1 == nStage;
1867cdf0e10cSrcweir     const bool bIncludeObjects = 1 <= nStage;
1868cdf0e10cSrcweir 
1869cdf0e10cSrcweir     if ( !bOnlyObject || ISA(SwFlyFrm) )
1870cdf0e10cSrcweir     {
1871cdf0e10cSrcweir         bValidSize = sal_True;
1872cdf0e10cSrcweir         bValidPrtArea = sal_True;
1873cdf0e10cSrcweir         bValidPos = sal_True;
1874cdf0e10cSrcweir     }
1875cdf0e10cSrcweir 
1876cdf0e10cSrcweir     if ( bIncludeObjects )
1877cdf0e10cSrcweir     {
1878cdf0e10cSrcweir         const SwSortedObjs* pObjs = GetDrawObjs();
1879cdf0e10cSrcweir         if ( pObjs )
1880cdf0e10cSrcweir         {
1881cdf0e10cSrcweir             const sal_uInt32 nCnt = pObjs->Count();
1882cdf0e10cSrcweir             for ( sal_uInt32 i = 0; i < nCnt; ++i )
1883cdf0e10cSrcweir             {
1884cdf0e10cSrcweir                 SwAnchoredObject* pAnchObj = (*pObjs)[i];
1885cdf0e10cSrcweir                 if ( pAnchObj->ISA(SwFlyFrm) )
1886cdf0e10cSrcweir                     static_cast<SwFlyFrm*>(pAnchObj)->ValidateThisAndAllLowers( 2 );
1887cdf0e10cSrcweir                 else if ( pAnchObj->ISA(SwAnchoredDrawObject) )
1888cdf0e10cSrcweir                     static_cast<SwAnchoredDrawObject*>(pAnchObj)->ValidateThis();
1889cdf0e10cSrcweir             }
1890cdf0e10cSrcweir         }
1891cdf0e10cSrcweir     }
1892cdf0e10cSrcweir 
1893cdf0e10cSrcweir     if ( IsLayoutFrm() )
1894cdf0e10cSrcweir     {
1895cdf0e10cSrcweir         SwFrm* pLower = static_cast<SwLayoutFrm*>(this)->Lower();
1896cdf0e10cSrcweir         while ( pLower )
1897cdf0e10cSrcweir         {
1898cdf0e10cSrcweir             pLower->ValidateThisAndAllLowers( nStage );
1899cdf0e10cSrcweir             pLower = pLower->GetNext();
1900cdf0e10cSrcweir         }
1901cdf0e10cSrcweir     }
1902cdf0e10cSrcweir }
1903cdf0e10cSrcweir 
1904cdf0e10cSrcweir /*************************************************************************
1905cdf0e10cSrcweir |*
1906cdf0e10cSrcweir |*  SwCntntFrm::GrowFrm()
1907cdf0e10cSrcweir |*
1908cdf0e10cSrcweir |*  Ersterstellung      MA 30. Jul. 92
1909cdf0e10cSrcweir |*  Letzte Aenderung    MA 25. Mar. 99
1910cdf0e10cSrcweir |*
1911cdf0e10cSrcweir |*************************************************************************/
GrowFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)1912cdf0e10cSrcweir SwTwips SwCntntFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
1913cdf0e10cSrcweir {
1914cdf0e10cSrcweir     SWRECTFN( this )
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir     SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
1917cdf0e10cSrcweir     if( nFrmHeight > 0 &&
1918cdf0e10cSrcweir          nDist > (LONG_MAX - nFrmHeight ) )
1919cdf0e10cSrcweir         nDist = LONG_MAX - nFrmHeight;
1920cdf0e10cSrcweir 
1921cdf0e10cSrcweir     const ViewShell *pSh = getRootFrm()->GetCurrShell();
1922cdf0e10cSrcweir     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
1923cdf0e10cSrcweir     const sal_uInt16 nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse mit Body
1924cdf0e10cSrcweir     if( !(GetUpper()->GetType() & nTmpType) && GetUpper()->HasFixSize() )
1925cdf0e10cSrcweir     {
1926cdf0e10cSrcweir         if ( !bTst )
1927cdf0e10cSrcweir         {
1928cdf0e10cSrcweir             (Frm().*fnRect->fnSetHeight)( nFrmHeight + nDist );
1929cdf0e10cSrcweir             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
1930cdf0e10cSrcweir             if( IsVertical() && !IsVertLR() && !IsReverse() )
1931cdf0e10cSrcweir                 Frm().Pos().X() -= nDist;
1932cdf0e10cSrcweir             if ( GetNext() )
1933cdf0e10cSrcweir             {
1934cdf0e10cSrcweir                 GetNext()->InvalidatePos();
1935cdf0e10cSrcweir             }
1936cdf0e10cSrcweir             // --> OD 2004-07-05 #i28701# - Due to the new object positioning the
1937cdf0e10cSrcweir             // frame on the next page/column can flow backward (e.g. it was moved forward
1938cdf0e10cSrcweir             // due to the positioning of its objects ). Thus, invalivate this next frame,
1939cdf0e10cSrcweir             // if document compatibility option 'Consider wrapping style influence on
1940cdf0e10cSrcweir             // object positioning' is ON.
1941cdf0e10cSrcweir             else if ( GetUpper()->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
1942cdf0e10cSrcweir             {
1943cdf0e10cSrcweir                 InvalidateNextPos();
1944cdf0e10cSrcweir             }
1945cdf0e10cSrcweir             // <--
1946cdf0e10cSrcweir         }
1947cdf0e10cSrcweir         return 0;
1948cdf0e10cSrcweir     }
1949cdf0e10cSrcweir 
1950cdf0e10cSrcweir     SwTwips nReal = (GetUpper()->Prt().*fnRect->fnGetHeight)();
1951cdf0e10cSrcweir     SwFrm *pFrm = GetUpper()->Lower();
1952cdf0e10cSrcweir     while( pFrm && nReal > 0 )
1953cdf0e10cSrcweir     {   nReal -= (pFrm->Frm().*fnRect->fnGetHeight)();
1954cdf0e10cSrcweir         pFrm = pFrm->GetNext();
1955cdf0e10cSrcweir     }
1956cdf0e10cSrcweir 
1957cdf0e10cSrcweir     if ( !bTst )
1958cdf0e10cSrcweir     {
1959cdf0e10cSrcweir         //Cntnts werden immer auf den gewuenschten Wert gebracht.
1960cdf0e10cSrcweir         long nOld = (Frm().*fnRect->fnGetHeight)();
1961cdf0e10cSrcweir         (Frm().*fnRect->fnSetHeight)( nOld + nDist );
1962cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
1963cdf0e10cSrcweir         if( IsVertical()&& !IsVertLR() && !IsReverse() )
1964cdf0e10cSrcweir             Frm().Pos().X() -= nDist;
1965cdf0e10cSrcweir         if ( nOld && IsInTab() )
1966cdf0e10cSrcweir         {
1967cdf0e10cSrcweir             SwTabFrm *pTab = FindTabFrm();
1968cdf0e10cSrcweir             if ( pTab->GetTable()->GetHTMLTableLayout() &&
1969cdf0e10cSrcweir                  !pTab->IsJoinLocked() &&
1970cdf0e10cSrcweir                  !pTab->GetFmt()->GetDoc()->GetDocShell()->IsReadOnly() )
1971cdf0e10cSrcweir             {
1972cdf0e10cSrcweir                 pTab->InvalidatePos();
1973cdf0e10cSrcweir                 pTab->SetResizeHTMLTable();
1974cdf0e10cSrcweir             }
1975cdf0e10cSrcweir         }
1976cdf0e10cSrcweir     }
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir     //Upper nur growen wenn notwendig.
1979cdf0e10cSrcweir     if ( nReal < nDist )
1980cdf0e10cSrcweir     {
1981cdf0e10cSrcweir         if( GetUpper() )
1982cdf0e10cSrcweir         {
1983cdf0e10cSrcweir             if( bTst || !GetUpper()->IsFooterFrm() )
1984cdf0e10cSrcweir                 nReal = GetUpper()->Grow( nDist - (nReal > 0 ? nReal : 0),
1985cdf0e10cSrcweir                                           bTst, bInfo );
1986cdf0e10cSrcweir             else
1987cdf0e10cSrcweir             {
1988cdf0e10cSrcweir                 nReal = 0;
1989cdf0e10cSrcweir                 GetUpper()->InvalidateSize();
1990cdf0e10cSrcweir             }
1991cdf0e10cSrcweir         }
1992cdf0e10cSrcweir         else
1993cdf0e10cSrcweir             nReal = 0;
1994cdf0e10cSrcweir     }
1995cdf0e10cSrcweir     else
1996cdf0e10cSrcweir         nReal = nDist;
1997cdf0e10cSrcweir 
1998cdf0e10cSrcweir     // --> OD 2004-07-05 #i28701# - Due to the new object positioning the
1999cdf0e10cSrcweir     // frame on the next page/column can flow backward (e.g. it was moved forward
2000cdf0e10cSrcweir     // due to the positioning of its objects ). Thus, invalivate this next frame,
2001cdf0e10cSrcweir     // if document compatibility option 'Consider wrapping style influence on
2002cdf0e10cSrcweir     // object positioning' is ON.
2003cdf0e10cSrcweir     if ( !bTst )
2004cdf0e10cSrcweir     {
2005cdf0e10cSrcweir         if ( GetNext() )
2006cdf0e10cSrcweir         {
2007cdf0e10cSrcweir             GetNext()->InvalidatePos();
2008cdf0e10cSrcweir         }
2009cdf0e10cSrcweir         else if ( GetUpper()->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
2010cdf0e10cSrcweir         {
2011cdf0e10cSrcweir             InvalidateNextPos();
2012cdf0e10cSrcweir         }
2013cdf0e10cSrcweir     }
2014cdf0e10cSrcweir     // <--
2015cdf0e10cSrcweir 
2016cdf0e10cSrcweir     return nReal;
2017cdf0e10cSrcweir }
2018cdf0e10cSrcweir 
2019cdf0e10cSrcweir /*************************************************************************
2020cdf0e10cSrcweir |*
2021cdf0e10cSrcweir |*  SwCntntFrm::ShrinkFrm()
2022cdf0e10cSrcweir |*
2023cdf0e10cSrcweir |*  Ersterstellung      MA 30. Jul. 92
2024cdf0e10cSrcweir |*  Letzte Aenderung    MA 05. May. 94
2025cdf0e10cSrcweir |*
2026cdf0e10cSrcweir |*************************************************************************/
ShrinkFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)2027cdf0e10cSrcweir SwTwips SwCntntFrm::ShrinkFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
2028cdf0e10cSrcweir {
2029cdf0e10cSrcweir     SWRECTFN( this )
2030cdf0e10cSrcweir     ASSERT( nDist >= 0, "nDist < 0" );
2031cdf0e10cSrcweir     ASSERT( nDist <= (Frm().*fnRect->fnGetHeight)(),
2032cdf0e10cSrcweir             "nDist > als aktuelle Grosse." );
2033cdf0e10cSrcweir 
2034cdf0e10cSrcweir     if ( !bTst )
2035cdf0e10cSrcweir     {
2036cdf0e10cSrcweir         SwTwips nRstHeight;
2037cdf0e10cSrcweir         if( GetUpper() )
2038cdf0e10cSrcweir             nRstHeight = (Frm().*fnRect->fnBottomDist)
2039cdf0e10cSrcweir                          ( (GetUpper()->*fnRect->fnGetPrtBottom)() );
2040cdf0e10cSrcweir         else
2041cdf0e10cSrcweir             nRstHeight = 0;
2042cdf0e10cSrcweir         if( nRstHeight < 0 )
2043cdf0e10cSrcweir         {
2044cdf0e10cSrcweir             SwTwips nNextHeight = 0;
2045cdf0e10cSrcweir             if( GetUpper()->IsSctFrm() && nDist > LONG_MAX/2 )
2046cdf0e10cSrcweir             {
2047cdf0e10cSrcweir                 SwFrm *pNxt = GetNext();
2048cdf0e10cSrcweir                 while( pNxt )
2049cdf0e10cSrcweir                 {
2050cdf0e10cSrcweir                     nNextHeight += (pNxt->Frm().*fnRect->fnGetHeight)();
2051cdf0e10cSrcweir                     pNxt = pNxt->GetNext();
2052cdf0e10cSrcweir                 }
2053cdf0e10cSrcweir             }
2054cdf0e10cSrcweir             nRstHeight = nDist + nRstHeight - nNextHeight;
2055cdf0e10cSrcweir         }
2056cdf0e10cSrcweir         else
2057cdf0e10cSrcweir             nRstHeight = nDist;
2058cdf0e10cSrcweir         (Frm().*fnRect->fnSetHeight)( (Frm().*fnRect->fnGetHeight)() - nDist );
2059cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
2060cdf0e10cSrcweir         if( IsVertical() && !IsVertLR() )
2061cdf0e10cSrcweir             Frm().Pos().X() += nDist;
2062cdf0e10cSrcweir         nDist = nRstHeight;
2063cdf0e10cSrcweir         if ( IsInTab() )
2064cdf0e10cSrcweir         {
2065cdf0e10cSrcweir             SwTabFrm *pTab = FindTabFrm();
2066cdf0e10cSrcweir             if ( pTab->GetTable()->GetHTMLTableLayout() &&
2067cdf0e10cSrcweir                  !pTab->IsJoinLocked() &&
2068cdf0e10cSrcweir                  !pTab->GetFmt()->GetDoc()->GetDocShell()->IsReadOnly() )
2069cdf0e10cSrcweir             {
2070cdf0e10cSrcweir                 pTab->InvalidatePos();
2071cdf0e10cSrcweir                 pTab->SetResizeHTMLTable();
2072cdf0e10cSrcweir             }
2073cdf0e10cSrcweir         }
2074cdf0e10cSrcweir     }
2075cdf0e10cSrcweir 
2076cdf0e10cSrcweir     SwTwips nReal;
2077cdf0e10cSrcweir     if( GetUpper() && nDist > 0 )
2078cdf0e10cSrcweir     {
2079cdf0e10cSrcweir         if( bTst || !GetUpper()->IsFooterFrm() )
2080cdf0e10cSrcweir             nReal = GetUpper()->Shrink( nDist, bTst, bInfo );
2081cdf0e10cSrcweir         else
2082cdf0e10cSrcweir         {
2083cdf0e10cSrcweir             nReal = 0;
2084cdf0e10cSrcweir 
2085cdf0e10cSrcweir             // #108745# Sorry, dear old footer friend, I'm not gonna invalidate you,
2086cdf0e10cSrcweir             // if there are any objects anchored inside your content, which
2087cdf0e10cSrcweir             // overlap with the shrinking frame.
2088cdf0e10cSrcweir             // This may lead to a footer frame that is too big, but this is better
2089cdf0e10cSrcweir             // than looping.
2090cdf0e10cSrcweir             // #109722# : The fix for #108745# was too strict.
2091cdf0e10cSrcweir 
2092cdf0e10cSrcweir             bool bInvalidate = true;
2093cdf0e10cSrcweir             const SwRect aRect( Frm() );
2094cdf0e10cSrcweir             const SwPageFrm* pPage = FindPageFrm();
2095cdf0e10cSrcweir             const SwSortedObjs* pSorted = pPage ? pPage->GetSortedObjs() : 0;
2096cdf0e10cSrcweir             if( pSorted )
2097cdf0e10cSrcweir             {
2098cdf0e10cSrcweir                 for ( sal_uInt16 i = 0; i < pSorted->Count(); ++i )
2099cdf0e10cSrcweir                 {
2100cdf0e10cSrcweir                     const SwAnchoredObject* pAnchoredObj = (*pSorted)[i];
2101cdf0e10cSrcweir                     const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
2102cdf0e10cSrcweir 
2103cdf0e10cSrcweir                     if( aBound.Left() > aRect.Right() )
2104cdf0e10cSrcweir                         continue;
2105cdf0e10cSrcweir 
2106cdf0e10cSrcweir                     if( aBound.IsOver( aRect ) )
2107cdf0e10cSrcweir                     {
2108cdf0e10cSrcweir                         const SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
2109cdf0e10cSrcweir                         if( SURROUND_THROUGHT != rFmt.GetSurround().GetSurround() )
2110cdf0e10cSrcweir                         {
2111cdf0e10cSrcweir                             const SwFrm* pAnchor = pAnchoredObj->GetAnchorFrm();
2112cdf0e10cSrcweir                             if ( pAnchor && pAnchor->FindFooterOrHeader() == GetUpper() )
2113cdf0e10cSrcweir                             {
2114cdf0e10cSrcweir                                 bInvalidate = false;
2115cdf0e10cSrcweir                                 break;
2116cdf0e10cSrcweir                             }
2117cdf0e10cSrcweir                         }
2118cdf0e10cSrcweir                     }
2119cdf0e10cSrcweir                 }
2120cdf0e10cSrcweir             }
2121cdf0e10cSrcweir 
2122cdf0e10cSrcweir             if ( bInvalidate )
2123cdf0e10cSrcweir                 GetUpper()->InvalidateSize();
2124cdf0e10cSrcweir         }
2125cdf0e10cSrcweir     }
2126cdf0e10cSrcweir     else
2127cdf0e10cSrcweir         nReal = 0;
2128cdf0e10cSrcweir 
2129cdf0e10cSrcweir     if ( !bTst )
2130cdf0e10cSrcweir     {
2131cdf0e10cSrcweir         //Die Position des naechsten Frm's veraendert sich auf jeden Fall.
2132cdf0e10cSrcweir         InvalidateNextPos();
2133cdf0e10cSrcweir 
2134cdf0e10cSrcweir         //Wenn ich keinen Nachfolger habe, so muss ich mich eben selbst um
2135cdf0e10cSrcweir         //die Retusche kuemmern.
2136cdf0e10cSrcweir         if ( !GetNext() )
2137cdf0e10cSrcweir             SetRetouche();
2138cdf0e10cSrcweir     }
2139cdf0e10cSrcweir     return nReal;
2140cdf0e10cSrcweir }
2141cdf0e10cSrcweir 
2142cdf0e10cSrcweir /*************************************************************************
2143cdf0e10cSrcweir |*
2144cdf0e10cSrcweir |*    SwCntntFrm::Modify()
2145cdf0e10cSrcweir |*
2146cdf0e10cSrcweir |*    Beschreibung
2147cdf0e10cSrcweir |*    Ersterstellung    AK 05-Mar-1991
2148cdf0e10cSrcweir |*    Letzte Aenderung  MA 13. Oct. 95
2149cdf0e10cSrcweir |*
2150cdf0e10cSrcweir |*************************************************************************/
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)2151cdf0e10cSrcweir void SwCntntFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
2152cdf0e10cSrcweir {
2153cdf0e10cSrcweir     sal_uInt8 nInvFlags = 0;
2154cdf0e10cSrcweir 
2155cdf0e10cSrcweir     if( pNew && RES_ATTRSET_CHG == pNew->Which() )
2156cdf0e10cSrcweir     {
2157cdf0e10cSrcweir         SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
2158cdf0e10cSrcweir         SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
2159cdf0e10cSrcweir         SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
2160cdf0e10cSrcweir         SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
2161cdf0e10cSrcweir         while( sal_True )
2162cdf0e10cSrcweir         {
2163cdf0e10cSrcweir             _UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
2164cdf0e10cSrcweir                          (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
2165cdf0e10cSrcweir                          &aOldSet, &aNewSet );
2166cdf0e10cSrcweir             if( aNIter.IsAtEnd() )
2167cdf0e10cSrcweir                 break;
2168cdf0e10cSrcweir             aNIter.NextItem();
2169cdf0e10cSrcweir             aOIter.NextItem();
2170cdf0e10cSrcweir         }
2171cdf0e10cSrcweir         if ( aOldSet.Count() || aNewSet.Count() )
2172cdf0e10cSrcweir             SwFrm::Modify( &aOldSet, &aNewSet );
2173cdf0e10cSrcweir     }
2174cdf0e10cSrcweir     else
2175cdf0e10cSrcweir         _UpdateAttr( pOld, pNew, nInvFlags );
2176cdf0e10cSrcweir 
2177cdf0e10cSrcweir     if ( nInvFlags != 0 )
2178cdf0e10cSrcweir     {
2179cdf0e10cSrcweir         SwPageFrm *pPage = FindPageFrm();
2180cdf0e10cSrcweir         InvalidatePage( pPage );
2181cdf0e10cSrcweir         if ( nInvFlags & 0x01 )
2182cdf0e10cSrcweir             SetCompletePaint();
2183cdf0e10cSrcweir         if ( nInvFlags & 0x02 )
2184cdf0e10cSrcweir             _InvalidatePos();
2185cdf0e10cSrcweir         if ( nInvFlags & 0x04 )
2186cdf0e10cSrcweir             _InvalidateSize();
2187cdf0e10cSrcweir         if ( nInvFlags & 0x88 )
2188cdf0e10cSrcweir         {
2189cdf0e10cSrcweir             if( IsInSct() && !GetPrev() )
2190cdf0e10cSrcweir             {
2191cdf0e10cSrcweir                 SwSectionFrm *pSect = FindSctFrm();
2192cdf0e10cSrcweir                 if( pSect->ContainsAny() == this )
2193cdf0e10cSrcweir                 {
2194cdf0e10cSrcweir                     pSect->_InvalidatePrt();
2195cdf0e10cSrcweir                     pSect->InvalidatePage( pPage );
2196cdf0e10cSrcweir                 }
2197cdf0e10cSrcweir             }
2198cdf0e10cSrcweir             _InvalidatePrt();
2199cdf0e10cSrcweir         }
2200cdf0e10cSrcweir         SwFrm* pNextFrm = GetIndNext();
2201cdf0e10cSrcweir         if ( pNextFrm && nInvFlags & 0x10)
2202cdf0e10cSrcweir         {
2203cdf0e10cSrcweir             pNextFrm->_InvalidatePrt();
2204cdf0e10cSrcweir             pNextFrm->InvalidatePage( pPage );
2205cdf0e10cSrcweir         }
2206cdf0e10cSrcweir         if ( pNextFrm && nInvFlags & 0x80 )
2207cdf0e10cSrcweir         {
2208cdf0e10cSrcweir             pNextFrm->SetCompletePaint();
2209cdf0e10cSrcweir         }
2210cdf0e10cSrcweir         if ( nInvFlags & 0x20 )
2211cdf0e10cSrcweir         {
2212cdf0e10cSrcweir             SwFrm* pPrevFrm = GetPrev();
2213cdf0e10cSrcweir             if ( pPrevFrm )
2214cdf0e10cSrcweir             {
2215cdf0e10cSrcweir                 pPrevFrm->_InvalidatePrt();
2216cdf0e10cSrcweir                 pPrevFrm->InvalidatePage( pPage );
2217cdf0e10cSrcweir             }
2218cdf0e10cSrcweir         }
2219cdf0e10cSrcweir         if ( nInvFlags & 0x40 )
2220cdf0e10cSrcweir             InvalidateNextPos();
2221cdf0e10cSrcweir     }
2222cdf0e10cSrcweir }
2223cdf0e10cSrcweir 
_UpdateAttr(const SfxPoolItem * pOld,const SfxPoolItem * pNew,sal_uInt8 & rInvFlags,SwAttrSetChg * pOldSet,SwAttrSetChg * pNewSet)2224cdf0e10cSrcweir void SwCntntFrm::_UpdateAttr( const SfxPoolItem* pOld, const SfxPoolItem* pNew,
2225cdf0e10cSrcweir                               sal_uInt8 &rInvFlags,
2226cdf0e10cSrcweir                             SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
2227cdf0e10cSrcweir {
2228cdf0e10cSrcweir     sal_Bool bClear = sal_True;
2229cdf0e10cSrcweir     sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
2230cdf0e10cSrcweir     switch ( nWhich )
2231cdf0e10cSrcweir     {
2232cdf0e10cSrcweir         case RES_FMT_CHG:
2233cdf0e10cSrcweir             rInvFlags = 0xFF;
2234cdf0e10cSrcweir             /* kein break hier */
2235cdf0e10cSrcweir 
2236cdf0e10cSrcweir         case RES_PAGEDESC:                      //Attributaenderung (an/aus)
2237cdf0e10cSrcweir             if ( IsInDocBody() && !IsInTab() )
2238cdf0e10cSrcweir             {
2239cdf0e10cSrcweir                 rInvFlags |= 0x02;
2240cdf0e10cSrcweir                 SwPageFrm *pPage = FindPageFrm();
2241cdf0e10cSrcweir                 if ( !GetPrev() )
2242cdf0e10cSrcweir                     CheckPageDescs( pPage );
2243cdf0e10cSrcweir                 if ( pPage && GetAttrSet()->GetPageDesc().GetNumOffset() )
2244cdf0e10cSrcweir                     ((SwRootFrm*)pPage->GetUpper())->SetVirtPageNum( sal_True );
2245cdf0e10cSrcweir                 SwDocPosUpdate aMsgHnt( pPage->Frm().Top() );
2246cdf0e10cSrcweir                 pPage->GetFmt()->GetDoc()->UpdatePageFlds( &aMsgHnt );
2247cdf0e10cSrcweir             }
2248cdf0e10cSrcweir             break;
2249cdf0e10cSrcweir 
2250cdf0e10cSrcweir         case RES_UL_SPACE:
2251cdf0e10cSrcweir             {
2252cdf0e10cSrcweir                 // OD 2004-02-18 #106629# - correction
2253cdf0e10cSrcweir                 // Invalidation of the printing area of next frame, not only
2254cdf0e10cSrcweir                 // for footnote content.
2255cdf0e10cSrcweir                 if ( !GetIndNext() )
2256cdf0e10cSrcweir                 {
2257cdf0e10cSrcweir                     SwFrm* pNxt = FindNext();
2258cdf0e10cSrcweir                     if ( pNxt )
2259cdf0e10cSrcweir                     {
2260cdf0e10cSrcweir                         SwPageFrm* pPg = pNxt->FindPageFrm();
2261cdf0e10cSrcweir                         pNxt->InvalidatePage( pPg );
2262cdf0e10cSrcweir                         pNxt->_InvalidatePrt();
2263cdf0e10cSrcweir                         if( pNxt->IsSctFrm() )
2264cdf0e10cSrcweir                         {
2265cdf0e10cSrcweir                             SwFrm* pCnt = ((SwSectionFrm*)pNxt)->ContainsAny();
2266cdf0e10cSrcweir                             if( pCnt )
2267cdf0e10cSrcweir                             {
2268cdf0e10cSrcweir                                 pCnt->_InvalidatePrt();
2269cdf0e10cSrcweir                                 pCnt->InvalidatePage( pPg );
2270cdf0e10cSrcweir                             }
2271cdf0e10cSrcweir                         }
2272cdf0e10cSrcweir                         pNxt->SetCompletePaint();
2273cdf0e10cSrcweir                     }
2274cdf0e10cSrcweir                 }
2275cdf0e10cSrcweir                 // OD 2004-03-17 #i11860#
2276cdf0e10cSrcweir                 if ( GetIndNext() &&
2277cdf0e10cSrcweir                      !GetUpper()->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::USE_FORMER_OBJECT_POS) )
2278cdf0e10cSrcweir                 {
2279cdf0e10cSrcweir                     // OD 2004-07-01 #i28701# - use new method <InvalidateObjs(..)>
2280cdf0e10cSrcweir                     GetIndNext()->InvalidateObjs( true );
2281cdf0e10cSrcweir                 }
2282cdf0e10cSrcweir                 Prepare( PREP_UL_SPACE );   //TxtFrm muss Zeilenabst. korrigieren.
2283cdf0e10cSrcweir                 rInvFlags |= 0x80;
2284cdf0e10cSrcweir                 /* kein Break hier */
2285cdf0e10cSrcweir             }
2286cdf0e10cSrcweir         case RES_LR_SPACE:
2287cdf0e10cSrcweir         case RES_BOX:
2288cdf0e10cSrcweir         case RES_SHADOW:
2289cdf0e10cSrcweir             Prepare( PREP_FIXSIZE_CHG );
2290cdf0e10cSrcweir             SwFrm::Modify( pOld, pNew );
2291cdf0e10cSrcweir             rInvFlags |= 0x30;
2292cdf0e10cSrcweir             break;
2293cdf0e10cSrcweir 
2294cdf0e10cSrcweir         case RES_BREAK:
2295cdf0e10cSrcweir             {
2296cdf0e10cSrcweir                 rInvFlags |= 0x42;
2297cdf0e10cSrcweir                 const IDocumentSettingAccess* pIDSA = GetUpper()->GetFmt()->getIDocumentSettingAccess();
2298cdf0e10cSrcweir                 if( pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX) ||
2299cdf0e10cSrcweir                     pIDSA->get(IDocumentSettingAccess::PARA_SPACE_MAX_AT_PAGES) )
2300cdf0e10cSrcweir                 {
2301cdf0e10cSrcweir                     rInvFlags |= 0x1;
2302cdf0e10cSrcweir                     SwFrm* pNxt = FindNext();
2303cdf0e10cSrcweir                     if( pNxt )
2304cdf0e10cSrcweir                     {
2305cdf0e10cSrcweir                         SwPageFrm* pPg = pNxt->FindPageFrm();
2306cdf0e10cSrcweir                         pNxt->InvalidatePage( pPg );
2307cdf0e10cSrcweir                         pNxt->_InvalidatePrt();
2308cdf0e10cSrcweir                         if( pNxt->IsSctFrm() )
2309cdf0e10cSrcweir                         {
2310cdf0e10cSrcweir                             SwFrm* pCnt = ((SwSectionFrm*)pNxt)->ContainsAny();
2311cdf0e10cSrcweir                             if( pCnt )
2312cdf0e10cSrcweir                             {
2313cdf0e10cSrcweir                                 pCnt->_InvalidatePrt();
2314cdf0e10cSrcweir                                 pCnt->InvalidatePage( pPg );
2315cdf0e10cSrcweir                             }
2316cdf0e10cSrcweir                         }
2317cdf0e10cSrcweir                         pNxt->SetCompletePaint();
2318cdf0e10cSrcweir                     }
2319cdf0e10cSrcweir                 }
2320cdf0e10cSrcweir             }
2321cdf0e10cSrcweir             break;
2322cdf0e10cSrcweir 
2323cdf0e10cSrcweir         // OD 2004-02-26 #i25029#
2324cdf0e10cSrcweir         case RES_PARATR_CONNECT_BORDER:
2325cdf0e10cSrcweir         {
2326cdf0e10cSrcweir             rInvFlags |= 0x01;
2327cdf0e10cSrcweir             if ( IsTxtFrm() )
2328cdf0e10cSrcweir             {
2329cdf0e10cSrcweir                 InvalidateNextPrtArea();
2330cdf0e10cSrcweir             }
2331cdf0e10cSrcweir             if ( !GetIndNext() && IsInTab() && IsInSplitTableRow() )
2332cdf0e10cSrcweir             {
2333cdf0e10cSrcweir                 FindTabFrm()->InvalidateSize();
2334cdf0e10cSrcweir             }
2335cdf0e10cSrcweir         }
2336cdf0e10cSrcweir         break;
2337cdf0e10cSrcweir 
2338cdf0e10cSrcweir         case RES_PARATR_TABSTOP:
2339cdf0e10cSrcweir         case RES_CHRATR_PROPORTIONALFONTSIZE:
2340cdf0e10cSrcweir         case RES_CHRATR_SHADOWED:
2341cdf0e10cSrcweir         case RES_CHRATR_AUTOKERN:
2342cdf0e10cSrcweir         case RES_CHRATR_UNDERLINE:
2343cdf0e10cSrcweir         case RES_CHRATR_OVERLINE:
2344cdf0e10cSrcweir         case RES_CHRATR_KERNING:
2345cdf0e10cSrcweir         case RES_CHRATR_FONT:
2346cdf0e10cSrcweir         case RES_CHRATR_FONTSIZE:
2347cdf0e10cSrcweir         case RES_CHRATR_ESCAPEMENT:
2348cdf0e10cSrcweir         case RES_CHRATR_CONTOUR:
2349cdf0e10cSrcweir         case RES_PARATR_NUMRULE:
2350cdf0e10cSrcweir             rInvFlags |= 0x01;
2351cdf0e10cSrcweir             break;
2352cdf0e10cSrcweir 
2353cdf0e10cSrcweir 
2354cdf0e10cSrcweir         case RES_FRM_SIZE:
2355cdf0e10cSrcweir             rInvFlags |= 0x01;
2356cdf0e10cSrcweir             /* no break here */
2357cdf0e10cSrcweir 
2358cdf0e10cSrcweir         default:
2359cdf0e10cSrcweir             bClear = sal_False;
2360cdf0e10cSrcweir     }
2361cdf0e10cSrcweir     if ( bClear )
2362cdf0e10cSrcweir     {
2363cdf0e10cSrcweir         if ( pOldSet || pNewSet )
2364cdf0e10cSrcweir         {
2365cdf0e10cSrcweir             if ( pOldSet )
2366cdf0e10cSrcweir                 pOldSet->ClearItem( nWhich );
2367cdf0e10cSrcweir             if ( pNewSet )
2368cdf0e10cSrcweir                 pNewSet->ClearItem( nWhich );
2369cdf0e10cSrcweir         }
2370cdf0e10cSrcweir         else
2371cdf0e10cSrcweir             SwFrm::Modify( pOld, pNew );
2372cdf0e10cSrcweir     }
2373cdf0e10cSrcweir }
2374cdf0e10cSrcweir 
2375cdf0e10cSrcweir /*************************************************************************
2376cdf0e10cSrcweir |*
2377cdf0e10cSrcweir |*  SwLayoutFrm::SwLayoutFrm()
2378cdf0e10cSrcweir |*
2379cdf0e10cSrcweir |*  Ersterstellung      AK 14-Feb-1991
2380cdf0e10cSrcweir |*  Letzte Aenderung    MA 12. May. 95
2381cdf0e10cSrcweir |*
2382cdf0e10cSrcweir |*************************************************************************/
SwLayoutFrm(SwFrmFmt * pFmt,SwFrm * pSib)2383cdf0e10cSrcweir SwLayoutFrm::SwLayoutFrm( SwFrmFmt* pFmt, SwFrm* pSib ):
2384cdf0e10cSrcweir     SwFrm( pFmt, pSib ),
2385cdf0e10cSrcweir     pLower( 0 )
2386cdf0e10cSrcweir {
2387cdf0e10cSrcweir     const SwFmtFrmSize &rFmtSize = pFmt->GetFrmSize();
2388cdf0e10cSrcweir     if ( rFmtSize.GetHeightSizeType() == ATT_FIX_SIZE )
2389cdf0e10cSrcweir         bFixSize = sal_True;
2390cdf0e10cSrcweir }
2391cdf0e10cSrcweir 
2392cdf0e10cSrcweir // --> OD 2004-06-29 #i28701#
2393cdf0e10cSrcweir TYPEINIT1(SwLayoutFrm,SwFrm);
2394cdf0e10cSrcweir // <--
2395cdf0e10cSrcweir /*-----------------10.06.99 09:42-------------------
2396cdf0e10cSrcweir  * SwLayoutFrm::InnerHeight()
2397cdf0e10cSrcweir  * --------------------------------------------------*/
2398cdf0e10cSrcweir 
InnerHeight() const2399cdf0e10cSrcweir SwTwips SwLayoutFrm::InnerHeight() const
2400cdf0e10cSrcweir {
2401cdf0e10cSrcweir     if( !Lower() )
2402cdf0e10cSrcweir         return 0;
2403cdf0e10cSrcweir     SwTwips nRet = 0;
2404cdf0e10cSrcweir     const SwFrm* pCnt = Lower();
2405cdf0e10cSrcweir     SWRECTFN( this )
2406cdf0e10cSrcweir     if( pCnt->IsColumnFrm() || pCnt->IsCellFrm() )
2407cdf0e10cSrcweir     {
2408cdf0e10cSrcweir         do
2409cdf0e10cSrcweir         {
2410cdf0e10cSrcweir             SwTwips nTmp = ((SwLayoutFrm*)pCnt)->InnerHeight();
2411cdf0e10cSrcweir             if( pCnt->GetValidPrtAreaFlag() )
2412cdf0e10cSrcweir                 nTmp += (pCnt->Frm().*fnRect->fnGetHeight)() -
2413cdf0e10cSrcweir                         (pCnt->Prt().*fnRect->fnGetHeight)();
2414cdf0e10cSrcweir             if( nRet < nTmp )
2415cdf0e10cSrcweir                 nRet = nTmp;
2416cdf0e10cSrcweir             pCnt = pCnt->GetNext();
2417cdf0e10cSrcweir         } while ( pCnt );
2418cdf0e10cSrcweir     }
2419cdf0e10cSrcweir     else
2420cdf0e10cSrcweir     {
2421cdf0e10cSrcweir         do
2422cdf0e10cSrcweir         {
2423cdf0e10cSrcweir             nRet += (pCnt->Frm().*fnRect->fnGetHeight)();
2424cdf0e10cSrcweir             if( pCnt->IsCntntFrm() && ((SwTxtFrm*)pCnt)->IsUndersized() )
2425cdf0e10cSrcweir                 nRet += ((SwTxtFrm*)pCnt)->GetParHeight() -
2426cdf0e10cSrcweir                         (pCnt->Prt().*fnRect->fnGetHeight)();
2427cdf0e10cSrcweir             if( pCnt->IsLayoutFrm() && !pCnt->IsTabFrm() )
2428cdf0e10cSrcweir                 nRet += ((SwLayoutFrm*)pCnt)->InnerHeight() -
2429cdf0e10cSrcweir                         (pCnt->Prt().*fnRect->fnGetHeight)();
2430cdf0e10cSrcweir             pCnt = pCnt->GetNext();
2431cdf0e10cSrcweir         } while( pCnt );
2432cdf0e10cSrcweir 
2433cdf0e10cSrcweir     }
2434cdf0e10cSrcweir     return nRet;
2435cdf0e10cSrcweir }
2436cdf0e10cSrcweir 
2437cdf0e10cSrcweir /*************************************************************************
2438cdf0e10cSrcweir |*
2439cdf0e10cSrcweir |*  SwLayoutFrm::GrowFrm()
2440cdf0e10cSrcweir |*
2441cdf0e10cSrcweir |*  Ersterstellung      MA 30. Jul. 92
2442cdf0e10cSrcweir |*  Letzte Aenderung    MA 23. Sep. 96
2443cdf0e10cSrcweir |*
2444cdf0e10cSrcweir |*************************************************************************/
GrowFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)2445cdf0e10cSrcweir SwTwips SwLayoutFrm::GrowFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
2446cdf0e10cSrcweir {
2447cdf0e10cSrcweir     const ViewShell *pSh = getRootFrm()->GetCurrShell();
2448cdf0e10cSrcweir     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
2449cdf0e10cSrcweir     const sal_uInt16 nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse mit Body
2450cdf0e10cSrcweir     if( !(GetType() & nTmpType) && HasFixSize() )
2451cdf0e10cSrcweir         return 0;
2452cdf0e10cSrcweir 
2453cdf0e10cSrcweir     SWRECTFN( this )
2454cdf0e10cSrcweir     const SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
2455cdf0e10cSrcweir     const SwTwips nFrmPos = Frm().Pos().X();
2456cdf0e10cSrcweir 
2457cdf0e10cSrcweir     if ( nFrmHeight > 0 && nDist > (LONG_MAX - nFrmHeight) )
2458cdf0e10cSrcweir         nDist = LONG_MAX - nFrmHeight;
2459cdf0e10cSrcweir 
2460cdf0e10cSrcweir     SwTwips nMin = 0;
2461cdf0e10cSrcweir     if ( GetUpper() && !IsCellFrm() )
2462cdf0e10cSrcweir     {
2463cdf0e10cSrcweir         SwFrm *pFrm = GetUpper()->Lower();
2464cdf0e10cSrcweir         while( pFrm )
2465cdf0e10cSrcweir         {   nMin += (pFrm->Frm().*fnRect->fnGetHeight)();
2466cdf0e10cSrcweir             pFrm = pFrm->GetNext();
2467cdf0e10cSrcweir         }
2468cdf0e10cSrcweir         nMin = (GetUpper()->Prt().*fnRect->fnGetHeight)() - nMin;
2469cdf0e10cSrcweir         if ( nMin < 0 )
2470cdf0e10cSrcweir             nMin = 0;
2471cdf0e10cSrcweir     }
2472cdf0e10cSrcweir 
2473cdf0e10cSrcweir     SwRect aOldFrm( Frm() );
2474cdf0e10cSrcweir     sal_Bool bMoveAccFrm = sal_False;
2475cdf0e10cSrcweir 
2476cdf0e10cSrcweir     sal_Bool bChgPos = IsVertical() && !IsReverse();
2477cdf0e10cSrcweir     if ( !bTst )
2478cdf0e10cSrcweir     {
2479cdf0e10cSrcweir         (Frm().*fnRect->fnSetHeight)( nFrmHeight + nDist );
2480cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
2481cdf0e10cSrcweir         if( bChgPos && !IsVertLR() )
2482cdf0e10cSrcweir             Frm().Pos().X() -= nDist;
2483cdf0e10cSrcweir         bMoveAccFrm = sal_True;
2484cdf0e10cSrcweir     }
2485cdf0e10cSrcweir 
2486cdf0e10cSrcweir     SwTwips nReal = nDist - nMin;
2487cdf0e10cSrcweir     if ( nReal > 0 )
2488cdf0e10cSrcweir     {
2489cdf0e10cSrcweir         if ( GetUpper() )
2490cdf0e10cSrcweir         {   // AdjustNeighbourhood jetzt auch in Spalten (aber nicht in Rahmen)
2491cdf0e10cSrcweir             sal_uInt8 nAdjust = GetUpper()->IsFtnBossFrm() ?
2492cdf0e10cSrcweir                 ((SwFtnBossFrm*)GetUpper())->NeighbourhoodAdjustment( this )
2493cdf0e10cSrcweir                 : NA_GROW_SHRINK;
2494cdf0e10cSrcweir             if( NA_ONLY_ADJUST == nAdjust )
2495cdf0e10cSrcweir                 nReal = AdjustNeighbourhood( nReal, bTst );
2496cdf0e10cSrcweir             else
2497cdf0e10cSrcweir             {
2498cdf0e10cSrcweir                 if( NA_ADJUST_GROW == nAdjust )
2499cdf0e10cSrcweir                     nReal += AdjustNeighbourhood( nReal, bTst );
2500cdf0e10cSrcweir 
2501cdf0e10cSrcweir                 SwTwips nGrow = 0;
2502cdf0e10cSrcweir                 if( 0 < nReal )
2503cdf0e10cSrcweir                 {
2504cdf0e10cSrcweir                     SwFrm* pToGrow = GetUpper();
2505cdf0e10cSrcweir                     // NEW TABLES
2506cdf0e10cSrcweir                     // A cell with a row span of > 1 is allowed to grow the
2507cdf0e10cSrcweir                     // line containing the end of the row span if it is
2508cdf0e10cSrcweir                     // located in the same table frame:
2509cdf0e10cSrcweir                     const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
2510cdf0e10cSrcweir                     if ( pThisCell && pThisCell->GetLayoutRowSpan() > 1 )
2511cdf0e10cSrcweir                     {
2512cdf0e10cSrcweir                         SwCellFrm& rEndCell = const_cast<SwCellFrm&>(pThisCell->FindStartEndOfRowSpanCell( false, true ));
2513cdf0e10cSrcweir                         if ( -1 == rEndCell.GetTabBox()->getRowSpan() )
2514cdf0e10cSrcweir                             pToGrow = rEndCell.GetUpper();
2515cdf0e10cSrcweir                         else
2516cdf0e10cSrcweir                             pToGrow = 0;
2517cdf0e10cSrcweir                     }
2518cdf0e10cSrcweir 
2519cdf0e10cSrcweir                     nGrow = pToGrow ? pToGrow->Grow( nReal, bTst, bInfo ) : 0;
2520cdf0e10cSrcweir                 }
2521cdf0e10cSrcweir 
2522cdf0e10cSrcweir                 if( NA_GROW_ADJUST == nAdjust && nGrow < nReal )
2523cdf0e10cSrcweir                     nReal += AdjustNeighbourhood( nReal - nGrow, bTst );
2524cdf0e10cSrcweir 
2525cdf0e10cSrcweir                 if ( IsFtnFrm() && (nGrow != nReal) && GetNext() )
2526cdf0e10cSrcweir                 {
2527cdf0e10cSrcweir                     //Fussnoten koennen ihre Nachfolger verdraengen.
2528cdf0e10cSrcweir                     SwTwips nSpace = bTst ? 0 : -nDist;
2529cdf0e10cSrcweir                     const SwFrm *pFrm = GetUpper()->Lower();
2530cdf0e10cSrcweir                     do
2531cdf0e10cSrcweir                     {   nSpace += (pFrm->Frm().*fnRect->fnGetHeight)();
2532cdf0e10cSrcweir                         pFrm = pFrm->GetNext();
2533cdf0e10cSrcweir                     } while ( pFrm != GetNext() );
2534cdf0e10cSrcweir                     nSpace = (GetUpper()->Prt().*fnRect->fnGetHeight)() -nSpace;
2535cdf0e10cSrcweir                     if ( nSpace < 0 )
2536cdf0e10cSrcweir                         nSpace = 0;
2537cdf0e10cSrcweir                     nSpace += nGrow;
2538cdf0e10cSrcweir                     if ( nReal > nSpace )
2539cdf0e10cSrcweir                         nReal = nSpace;
2540cdf0e10cSrcweir                     if ( nReal && !bTst )
2541cdf0e10cSrcweir                         ((SwFtnFrm*)this)->InvalidateNxtFtnCnts( FindPageFrm() );
2542cdf0e10cSrcweir                 }
2543cdf0e10cSrcweir                 else
2544cdf0e10cSrcweir                     nReal = nGrow;
2545cdf0e10cSrcweir             }
2546cdf0e10cSrcweir         }
2547cdf0e10cSrcweir         else
2548cdf0e10cSrcweir             nReal = 0;
2549cdf0e10cSrcweir 
2550cdf0e10cSrcweir         nReal += nMin;
2551cdf0e10cSrcweir     }
2552cdf0e10cSrcweir     else
2553cdf0e10cSrcweir         nReal = nDist;
2554cdf0e10cSrcweir 
2555cdf0e10cSrcweir     if ( !bTst )
2556cdf0e10cSrcweir     {
2557cdf0e10cSrcweir         if( nReal != nDist &&
2558cdf0e10cSrcweir             // NEW TABLES
2559cdf0e10cSrcweir             ( !IsCellFrm() || static_cast<SwCellFrm*>(this)->GetLayoutRowSpan() > 1 ) )
2560cdf0e10cSrcweir         {
2561cdf0e10cSrcweir             (Frm().*fnRect->fnSetHeight)( nFrmHeight + nReal );
2562cdf0e10cSrcweir             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
2563cdf0e10cSrcweir             if( bChgPos && !IsVertLR() )
2564cdf0e10cSrcweir                 Frm().Pos().X() = nFrmPos - nReal;
2565cdf0e10cSrcweir             bMoveAccFrm = sal_True;
2566cdf0e10cSrcweir         }
2567cdf0e10cSrcweir 
2568cdf0e10cSrcweir         if ( nReal )
2569cdf0e10cSrcweir         {
2570cdf0e10cSrcweir             SwPageFrm *pPage = FindPageFrm();
2571cdf0e10cSrcweir             if ( GetNext() )
2572cdf0e10cSrcweir             {
2573cdf0e10cSrcweir                 GetNext()->_InvalidatePos();
2574cdf0e10cSrcweir                 if ( GetNext()->IsCntntFrm() )
2575cdf0e10cSrcweir                     GetNext()->InvalidatePage( pPage );
2576cdf0e10cSrcweir             }
2577cdf0e10cSrcweir             if ( !IsPageBodyFrm() )
2578cdf0e10cSrcweir             {
2579cdf0e10cSrcweir                 _InvalidateAll();
2580cdf0e10cSrcweir                 InvalidatePage( pPage );
2581cdf0e10cSrcweir             }
2582cdf0e10cSrcweir             if ( !(GetType() & 0x1823) ) //Tab, Row, FtnCont, Root, Page
2583cdf0e10cSrcweir                 NotifyLowerObjs();
2584cdf0e10cSrcweir 
2585cdf0e10cSrcweir             if( IsCellFrm() )
2586cdf0e10cSrcweir                 InvaPercentLowers( nReal );
2587cdf0e10cSrcweir 
2588cdf0e10cSrcweir             const SvxGraphicPosition ePos = GetFmt()->GetBackground().GetGraphicPos();
2589cdf0e10cSrcweir             if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
2590cdf0e10cSrcweir                 SetCompletePaint();
2591cdf0e10cSrcweir         }
2592cdf0e10cSrcweir     }
2593cdf0e10cSrcweir 
2594cdf0e10cSrcweir     if( bMoveAccFrm && IsAccessibleFrm() )
2595cdf0e10cSrcweir     {
2596cdf0e10cSrcweir         SwRootFrm *pRootFrm = getRootFrm();
2597cdf0e10cSrcweir         if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
2598cdf0e10cSrcweir             pRootFrm->GetCurrShell() )
2599cdf0e10cSrcweir         {
2600cdf0e10cSrcweir             pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( this, aOldFrm );
2601cdf0e10cSrcweir         }
2602cdf0e10cSrcweir     }
2603cdf0e10cSrcweir     return nReal;
2604cdf0e10cSrcweir }
2605cdf0e10cSrcweir 
2606cdf0e10cSrcweir /*************************************************************************
2607cdf0e10cSrcweir |*
2608cdf0e10cSrcweir |*  SwLayoutFrm::ShrinkFrm()
2609cdf0e10cSrcweir |*
2610cdf0e10cSrcweir |*  Ersterstellung      MA 30. Jul. 92
2611cdf0e10cSrcweir |*  Letzte Aenderung    MA 25. Mar. 99
2612cdf0e10cSrcweir |*
2613cdf0e10cSrcweir |*************************************************************************/
ShrinkFrm(SwTwips nDist,sal_Bool bTst,sal_Bool bInfo)2614cdf0e10cSrcweir SwTwips SwLayoutFrm::ShrinkFrm( SwTwips nDist, sal_Bool bTst, sal_Bool bInfo )
2615cdf0e10cSrcweir {
2616cdf0e10cSrcweir     const ViewShell *pSh = getRootFrm()->GetCurrShell();
2617cdf0e10cSrcweir     const sal_Bool bBrowse = pSh && pSh->GetViewOptions()->getBrowseMode();
2618cdf0e10cSrcweir     const sal_uInt16 nTmpType = bBrowse ? 0x2084: 0x2004; //Row+Cell, Browse mit Body
2619cdf0e10cSrcweir     if( !(GetType() & nTmpType) && HasFixSize() )
2620cdf0e10cSrcweir         return 0;
2621cdf0e10cSrcweir 
2622cdf0e10cSrcweir     ASSERT( nDist >= 0, "nDist < 0" );
2623cdf0e10cSrcweir     SWRECTFN( this )
2624cdf0e10cSrcweir     SwTwips nFrmHeight = (Frm().*fnRect->fnGetHeight)();
2625cdf0e10cSrcweir     if ( nDist > nFrmHeight )
2626cdf0e10cSrcweir         nDist = nFrmHeight;
2627cdf0e10cSrcweir 
2628cdf0e10cSrcweir     SwTwips nMin = 0;
2629cdf0e10cSrcweir     sal_Bool bChgPos = IsVertical() && !IsReverse();
2630cdf0e10cSrcweir     if ( Lower() )
2631cdf0e10cSrcweir     {
2632cdf0e10cSrcweir         if( !Lower()->IsNeighbourFrm() )
2633cdf0e10cSrcweir         {   const SwFrm *pFrm = Lower();
2634cdf0e10cSrcweir             const long nTmp = (Prt().*fnRect->fnGetHeight)();
2635cdf0e10cSrcweir             while( pFrm && nMin < nTmp )
2636cdf0e10cSrcweir             {   nMin += (pFrm->Frm().*fnRect->fnGetHeight)();
2637cdf0e10cSrcweir                 pFrm = pFrm->GetNext();
2638cdf0e10cSrcweir             }
2639cdf0e10cSrcweir         }
2640cdf0e10cSrcweir     }
2641cdf0e10cSrcweir     SwTwips nReal = nDist;
2642cdf0e10cSrcweir     SwTwips nMinDiff = (Prt().*fnRect->fnGetHeight)() - nMin;
2643cdf0e10cSrcweir     if( nReal > nMinDiff )
2644cdf0e10cSrcweir         nReal = nMinDiff;
2645cdf0e10cSrcweir     if( nReal <= 0 )
2646cdf0e10cSrcweir         return nDist;
2647cdf0e10cSrcweir 
2648cdf0e10cSrcweir     SwRect aOldFrm( Frm() );
2649cdf0e10cSrcweir     sal_Bool bMoveAccFrm = sal_False;
2650cdf0e10cSrcweir 
2651cdf0e10cSrcweir     SwTwips nRealDist = nReal;
2652cdf0e10cSrcweir     if ( !bTst )
2653cdf0e10cSrcweir     {
2654cdf0e10cSrcweir         (Frm().*fnRect->fnSetHeight)( nFrmHeight - nReal );
2655cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
2656cdf0e10cSrcweir         if( bChgPos && !IsVertLR() )
2657cdf0e10cSrcweir             Frm().Pos().X() += nReal;
2658cdf0e10cSrcweir         bMoveAccFrm = sal_True;
2659cdf0e10cSrcweir     }
2660cdf0e10cSrcweir 
2661cdf0e10cSrcweir     sal_uInt8 nAdjust = GetUpper() && GetUpper()->IsFtnBossFrm() ?
2662cdf0e10cSrcweir                    ((SwFtnBossFrm*)GetUpper())->NeighbourhoodAdjustment( this )
2663cdf0e10cSrcweir                    : NA_GROW_SHRINK;
2664cdf0e10cSrcweir 
2665cdf0e10cSrcweir     // AdjustNeighbourhood auch in Spalten (aber nicht in Rahmen)
2666cdf0e10cSrcweir     if( NA_ONLY_ADJUST == nAdjust )
2667cdf0e10cSrcweir     {
2668cdf0e10cSrcweir         if ( IsPageBodyFrm() && !bBrowse )
2669cdf0e10cSrcweir             nReal = nDist;
2670cdf0e10cSrcweir         else
2671cdf0e10cSrcweir         {   nReal = AdjustNeighbourhood( -nReal, bTst );
2672cdf0e10cSrcweir             nReal *= -1;
2673cdf0e10cSrcweir             if ( !bTst && IsBodyFrm() && nReal < nRealDist )
2674cdf0e10cSrcweir             {
2675cdf0e10cSrcweir                 (Frm().*fnRect->fnSetHeight)( (Frm().*fnRect->fnGetHeight)()
2676cdf0e10cSrcweir                                             + nRealDist - nReal );
2677cdf0e10cSrcweir                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
2678cdf0e10cSrcweir                 if( bChgPos && !IsVertLR() )
2679cdf0e10cSrcweir                     Frm().Pos().X() += nRealDist - nReal;
2680cdf0e10cSrcweir                 ASSERT( !IsAccessibleFrm(), "bMoveAccFrm has to be set!" );
2681cdf0e10cSrcweir             }
2682cdf0e10cSrcweir         }
2683cdf0e10cSrcweir     }
2684cdf0e10cSrcweir     else if( IsColumnFrm() || IsColBodyFrm() )
2685cdf0e10cSrcweir     {
2686cdf0e10cSrcweir         SwTwips nTmp = GetUpper()->Shrink( nReal, bTst, bInfo );
2687cdf0e10cSrcweir         if ( nTmp != nReal )
2688cdf0e10cSrcweir         {
2689cdf0e10cSrcweir             (Frm().*fnRect->fnSetHeight)( (Frm().*fnRect->fnGetHeight)()
2690cdf0e10cSrcweir                                           + nReal - nTmp );
2691cdf0e10cSrcweir             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
2692cdf0e10cSrcweir             if( bChgPos && !IsVertLR() )
2693cdf0e10cSrcweir                 Frm().Pos().X() += nTmp - nReal;
2694cdf0e10cSrcweir             ASSERT( !IsAccessibleFrm(), "bMoveAccFrm has to be set!" );
2695cdf0e10cSrcweir             nReal = nTmp;
2696cdf0e10cSrcweir         }
2697cdf0e10cSrcweir     }
2698cdf0e10cSrcweir     else
2699cdf0e10cSrcweir     {
2700cdf0e10cSrcweir         SwTwips nShrink = nReal;
2701cdf0e10cSrcweir         SwFrm* pToShrink = GetUpper();
2702cdf0e10cSrcweir         const SwCellFrm* pThisCell = dynamic_cast<const SwCellFrm*>(this);
2703cdf0e10cSrcweir         // NEW TABLES
2704cdf0e10cSrcweir         if ( pThisCell && pThisCell->GetLayoutRowSpan() > 1 )
2705cdf0e10cSrcweir         {
2706cdf0e10cSrcweir             SwCellFrm& rEndCell = const_cast<SwCellFrm&>(pThisCell->FindStartEndOfRowSpanCell( false, true ));
2707cdf0e10cSrcweir             pToShrink = rEndCell.GetUpper();
2708cdf0e10cSrcweir         }
2709cdf0e10cSrcweir 
2710cdf0e10cSrcweir         nReal = pToShrink ? pToShrink->Shrink( nShrink, bTst, bInfo ) : 0;
2711cdf0e10cSrcweir         if( ( NA_GROW_ADJUST == nAdjust || NA_ADJUST_GROW == nAdjust )
2712cdf0e10cSrcweir             && nReal < nShrink )
2713cdf0e10cSrcweir             AdjustNeighbourhood( nReal - nShrink );
2714cdf0e10cSrcweir     }
2715cdf0e10cSrcweir 
2716cdf0e10cSrcweir     if( bMoveAccFrm && IsAccessibleFrm() )
2717cdf0e10cSrcweir     {
2718cdf0e10cSrcweir         SwRootFrm *pRootFrm = getRootFrm();
2719cdf0e10cSrcweir         if( pRootFrm && pRootFrm->IsAnyShellAccessible() &&
2720cdf0e10cSrcweir             pRootFrm->GetCurrShell() )
2721cdf0e10cSrcweir         {
2722cdf0e10cSrcweir             pRootFrm->GetCurrShell()->Imp()->MoveAccessibleFrm( this, aOldFrm );
2723cdf0e10cSrcweir         }
2724cdf0e10cSrcweir     }
2725cdf0e10cSrcweir     if ( !bTst && (IsCellFrm() || IsColumnFrm() ? nReal : nRealDist) )
2726cdf0e10cSrcweir     {
2727cdf0e10cSrcweir         SwPageFrm *pPage = FindPageFrm();
2728cdf0e10cSrcweir         if ( GetNext() )
2729cdf0e10cSrcweir         {
2730cdf0e10cSrcweir             GetNext()->_InvalidatePos();
2731cdf0e10cSrcweir             if ( GetNext()->IsCntntFrm() )
2732cdf0e10cSrcweir                 GetNext()->InvalidatePage( pPage );
2733cdf0e10cSrcweir             if ( IsTabFrm() )
2734cdf0e10cSrcweir                 ((SwTabFrm*)this)->SetComplete();
2735cdf0e10cSrcweir         }
2736cdf0e10cSrcweir         else
2737cdf0e10cSrcweir         {   if ( IsRetoucheFrm() )
2738cdf0e10cSrcweir                 SetRetouche();
2739cdf0e10cSrcweir             if ( IsTabFrm() )
2740cdf0e10cSrcweir             {
2741cdf0e10cSrcweir                 if( IsTabFrm() )
2742cdf0e10cSrcweir                     ((SwTabFrm*)this)->SetComplete();
2743cdf0e10cSrcweir                 if ( Lower() )  //Kann auch im Join stehen und leer sein!
2744cdf0e10cSrcweir                     InvalidateNextPos();
2745cdf0e10cSrcweir             }
2746cdf0e10cSrcweir         }
2747cdf0e10cSrcweir         if ( !IsBodyFrm() )
2748cdf0e10cSrcweir         {
2749cdf0e10cSrcweir             _InvalidateAll();
2750cdf0e10cSrcweir             InvalidatePage( pPage );
2751cdf0e10cSrcweir             const SvxGraphicPosition ePos = GetFmt()->GetBackground().GetGraphicPos();
2752cdf0e10cSrcweir             if ( GPOS_NONE != ePos && GPOS_TILED != ePos )
2753cdf0e10cSrcweir                 SetCompletePaint();
2754cdf0e10cSrcweir         }
2755cdf0e10cSrcweir 
2756cdf0e10cSrcweir         if ( !(GetType() & 0x1823) ) //Tab, Row, FtnCont, Root, Page
2757cdf0e10cSrcweir             NotifyLowerObjs();
2758cdf0e10cSrcweir 
2759cdf0e10cSrcweir         if( IsCellFrm() )
2760cdf0e10cSrcweir             InvaPercentLowers( nReal );
2761cdf0e10cSrcweir 
2762cdf0e10cSrcweir         SwCntntFrm *pCnt;
2763cdf0e10cSrcweir         if( IsFtnFrm() && !((SwFtnFrm*)this)->GetAttr()->GetFtn().IsEndNote() &&
2764cdf0e10cSrcweir             ( GetFmt()->GetDoc()->GetFtnInfo().ePos != FTNPOS_CHAPTER ||
2765cdf0e10cSrcweir               ( IsInSct() && FindSctFrm()->IsFtnAtEnd() ) ) &&
2766cdf0e10cSrcweir               0 != (pCnt = ((SwFtnFrm*)this)->GetRefFromAttr() ) )
2767cdf0e10cSrcweir         {
2768cdf0e10cSrcweir             if ( pCnt->IsFollow() )
2769cdf0e10cSrcweir             {   // Wenn wir sowieso schon in einer anderen Spalte/Seite sitzen
2770cdf0e10cSrcweir                 // als der Frame mit der Referenz, dann brauchen wir nicht
2771cdf0e10cSrcweir                 // auch noch seinen Master zu invalidieren.
2772cdf0e10cSrcweir                 SwFrm *pTmp = pCnt->FindFtnBossFrm(sal_True) == FindFtnBossFrm(sal_True)
2773cdf0e10cSrcweir                               ?  pCnt->FindMaster()->GetFrm() : pCnt;
2774cdf0e10cSrcweir                 pTmp->Prepare( PREP_ADJUST_FRM );
2775cdf0e10cSrcweir                 pTmp->InvalidateSize();
2776cdf0e10cSrcweir             }
2777cdf0e10cSrcweir             else
2778cdf0e10cSrcweir                 pCnt->InvalidatePos();
2779cdf0e10cSrcweir         }
2780cdf0e10cSrcweir     }
2781cdf0e10cSrcweir     return nReal;
2782cdf0e10cSrcweir }
2783cdf0e10cSrcweir /*************************************************************************
2784cdf0e10cSrcweir |*
2785cdf0e10cSrcweir |*  SwLayoutFrm::ChgLowersProp()
2786cdf0e10cSrcweir |*
2787cdf0e10cSrcweir |*  Beschreibung        Aendert die Grosse der direkt untergeordneten Frm's
2788cdf0e10cSrcweir |*      die eine Fixe Groesse haben, proportional zur Groessenaenderung der
2789cdf0e10cSrcweir |*      PrtArea des Frm's.
2790cdf0e10cSrcweir |*      Die Variablen Frm's werden auch proportional angepasst; sie werden
2791cdf0e10cSrcweir |*      sich schon wieder zurechtwachsen/-schrumpfen.
2792cdf0e10cSrcweir |*  Ersterstellung      MA 11.03.92
2793cdf0e10cSrcweir |*  Letzte Aenderung    AMA 2. Nov. 98
2794cdf0e10cSrcweir |*
2795cdf0e10cSrcweir |*************************************************************************/
ChgLowersProp(const Size & rOldSize)2796cdf0e10cSrcweir void SwLayoutFrm::ChgLowersProp( const Size& rOldSize )
2797cdf0e10cSrcweir {
2798cdf0e10cSrcweir     // no change of lower properties for root frame or if no lower exists.
2799cdf0e10cSrcweir     if ( IsRootFrm() || !Lower() )
2800cdf0e10cSrcweir         return;
2801cdf0e10cSrcweir 
2802cdf0e10cSrcweir     // declare and init <SwFrm* pLowerFrm> with first lower
2803cdf0e10cSrcweir     SwFrm *pLowerFrm = Lower();
2804cdf0e10cSrcweir 
2805cdf0e10cSrcweir     // declare and init const booleans <bHeightChgd> and <bWidthChg>
2806cdf0e10cSrcweir     const bool bHeightChgd = rOldSize.Height() != Prt().Height();
2807cdf0e10cSrcweir     const bool bWidthChgd  = rOldSize.Width()  != Prt().Width();
2808cdf0e10cSrcweir 
2809cdf0e10cSrcweir     // declare and init variables <bVert>, <bRev> and <fnRect>
2810cdf0e10cSrcweir     SWRECTFN( this )
2811cdf0e10cSrcweir 
2812cdf0e10cSrcweir     // This shortcut basically tries to handle only lower frames that
2813cdf0e10cSrcweir     // are affected by the size change. Otherwise much more lower frames
2814cdf0e10cSrcweir     // are invalidated.
2815cdf0e10cSrcweir     if ( !( bVert ? bHeightChgd : bWidthChgd ) &&
2816cdf0e10cSrcweir          ! Lower()->IsColumnFrm() &&
2817cdf0e10cSrcweir            ( ( IsBodyFrm() && IsInDocBody() && ( !IsInSct() || !FindSctFrm()->IsColLocked() ) ) ||
2818cdf0e10cSrcweir                 // --> FME 2004-07-21 #i10826# Section frames without columns should not
2819cdf0e10cSrcweir                 // invalidate all lowers!
2820cdf0e10cSrcweir                IsSctFrm() ) )
2821cdf0e10cSrcweir                // <--
2822cdf0e10cSrcweir     {
2823cdf0e10cSrcweir         // Determine page frame the body frame resp. the section frame belongs to.
2824cdf0e10cSrcweir         SwPageFrm *pPage = FindPageFrm();
2825cdf0e10cSrcweir         // Determine last lower by traveling through them using <GetNext()>.
2826cdf0e10cSrcweir         // During travel check each section frame, if it will be sized to
2827cdf0e10cSrcweir         // maximum. If Yes, invalidate size of section frame and set
2828cdf0e10cSrcweir         // corresponding flags at the page.
2829cdf0e10cSrcweir         do
2830cdf0e10cSrcweir         {
2831cdf0e10cSrcweir             if( pLowerFrm->IsSctFrm() &&((SwSectionFrm*)pLowerFrm)->_ToMaximize() )
2832cdf0e10cSrcweir             {
2833cdf0e10cSrcweir                 pLowerFrm->_InvalidateSize();
2834cdf0e10cSrcweir                 pLowerFrm->InvalidatePage( pPage );
2835cdf0e10cSrcweir             }
2836cdf0e10cSrcweir             if( pLowerFrm->GetNext() )
2837cdf0e10cSrcweir                 pLowerFrm = pLowerFrm->GetNext();
2838cdf0e10cSrcweir             else
2839cdf0e10cSrcweir                 break;
2840cdf0e10cSrcweir         } while( sal_True );
2841cdf0e10cSrcweir         // If found last lower is a section frame containing no section
2842cdf0e10cSrcweir         // (section frame isn't valid and will be deleted in the future),
2843cdf0e10cSrcweir         // travel backwards.
2844cdf0e10cSrcweir         while( pLowerFrm->IsSctFrm() && !((SwSectionFrm*)pLowerFrm)->GetSection() &&
2845cdf0e10cSrcweir                pLowerFrm->GetPrev() )
2846cdf0e10cSrcweir             pLowerFrm = pLowerFrm->GetPrev();
2847cdf0e10cSrcweir         // If found last lower is a section frame, set <pLowerFrm> to its last
2848cdf0e10cSrcweir         // content, if the section frame is valid and is not sized to maximum.
2849cdf0e10cSrcweir         // Otherwise set <pLowerFrm> to NULL - In this case body frame only
2850cdf0e10cSrcweir         //      contains invalid section frames.
2851cdf0e10cSrcweir         if( pLowerFrm->IsSctFrm() )
2852cdf0e10cSrcweir             pLowerFrm = ((SwSectionFrm*)pLowerFrm)->GetSection() &&
2853cdf0e10cSrcweir                    !((SwSectionFrm*)pLowerFrm)->ToMaximize( sal_False ) ?
2854cdf0e10cSrcweir                    ((SwSectionFrm*)pLowerFrm)->FindLastCntnt() : NULL;
2855cdf0e10cSrcweir 
2856cdf0e10cSrcweir         // continue with found last lower, probably the last content of a section
2857cdf0e10cSrcweir         if ( pLowerFrm )
2858cdf0e10cSrcweir         {
2859cdf0e10cSrcweir             // If <pLowerFrm> is in a table frame, set <pLowerFrm> to this table
2860cdf0e10cSrcweir             // frame and continue.
2861cdf0e10cSrcweir             if ( pLowerFrm->IsInTab() )
2862cdf0e10cSrcweir             {
2863cdf0e10cSrcweir                 // OD 28.10.2002 #97265# - safeguard for setting <pLowerFrm> to
2864cdf0e10cSrcweir                 // its table frame - check, if the table frame is also a lower
2865cdf0e10cSrcweir                 // of the body frame, in order to assure that <pLowerFrm> is not
2866cdf0e10cSrcweir                 // set to a frame, which is an *upper* of the body frame.
2867cdf0e10cSrcweir                 SwFrm* pTableFrm = pLowerFrm->FindTabFrm();
2868cdf0e10cSrcweir                 if ( IsAnLower( pTableFrm ) )
2869cdf0e10cSrcweir                 {
2870cdf0e10cSrcweir                     pLowerFrm = pTableFrm;
2871cdf0e10cSrcweir                 }
2872cdf0e10cSrcweir             }
2873cdf0e10cSrcweir             // Check, if variable size of body frame resp. section frame has grown
2874cdf0e10cSrcweir             // OD 28.10.2002 #97265# - correct check, if variable size has grown.
2875cdf0e10cSrcweir             SwTwips nOldHeight = bVert ? rOldSize.Width() : rOldSize.Height();
2876cdf0e10cSrcweir             if( nOldHeight < (Prt().*fnRect->fnGetHeight)() )
2877cdf0e10cSrcweir             {
2878cdf0e10cSrcweir                 // If variable size of body|section frame has grown, only found
2879cdf0e10cSrcweir                 // last lower and the position of the its next have to be invalidated.
2880cdf0e10cSrcweir                 pLowerFrm->_InvalidateAll();
2881cdf0e10cSrcweir                 pLowerFrm->InvalidatePage( pPage );
2882cdf0e10cSrcweir                 if( !pLowerFrm->IsFlowFrm() ||
2883cdf0e10cSrcweir                     !SwFlowFrm::CastFlowFrm( pLowerFrm )->HasFollow() )
2884cdf0e10cSrcweir                     pLowerFrm->InvalidateNextPos( sal_True );
2885cdf0e10cSrcweir                 if ( pLowerFrm->IsTxtFrm() )
2886cdf0e10cSrcweir                     ((SwCntntFrm*)pLowerFrm)->Prepare( PREP_ADJUST_FRM );
2887cdf0e10cSrcweir             }
2888cdf0e10cSrcweir             else
2889cdf0e10cSrcweir             {
289086e1cf34SPedro Giffuni                 // variable size of body|section frame has shrunk. Thus,
2891cdf0e10cSrcweir                 // invalidate all lowers not matching the new body|section size
2892cdf0e10cSrcweir                 // and the dedicated new last lower.
2893cdf0e10cSrcweir                 if( bVert )
2894cdf0e10cSrcweir                 {
2895cdf0e10cSrcweir                     SwTwips nBot = Frm().Left() + Prt().Left();
2896cdf0e10cSrcweir                     while ( pLowerFrm->GetPrev() && pLowerFrm->Frm().Left() < nBot )
2897cdf0e10cSrcweir                     {
2898cdf0e10cSrcweir                         pLowerFrm->_InvalidateAll();
2899cdf0e10cSrcweir                         pLowerFrm->InvalidatePage( pPage );
2900cdf0e10cSrcweir                         pLowerFrm = pLowerFrm->GetPrev();
2901cdf0e10cSrcweir                     }
2902cdf0e10cSrcweir                 }
2903cdf0e10cSrcweir                 else
2904cdf0e10cSrcweir                 {
2905cdf0e10cSrcweir                     SwTwips nBot = Frm().Top() + Prt().Bottom();
2906cdf0e10cSrcweir                     while ( pLowerFrm->GetPrev() && pLowerFrm->Frm().Top() > nBot )
2907cdf0e10cSrcweir                     {
2908cdf0e10cSrcweir                         pLowerFrm->_InvalidateAll();
2909cdf0e10cSrcweir                         pLowerFrm->InvalidatePage( pPage );
2910cdf0e10cSrcweir                         pLowerFrm = pLowerFrm->GetPrev();
2911cdf0e10cSrcweir                     }
2912cdf0e10cSrcweir                 }
2913cdf0e10cSrcweir                 if ( pLowerFrm )
2914cdf0e10cSrcweir                 {
2915cdf0e10cSrcweir                     pLowerFrm->_InvalidateSize();
2916cdf0e10cSrcweir                     pLowerFrm->InvalidatePage( pPage );
2917cdf0e10cSrcweir                     if ( pLowerFrm->IsTxtFrm() )
2918cdf0e10cSrcweir                         ((SwCntntFrm*)pLowerFrm)->Prepare( PREP_ADJUST_FRM );
2919cdf0e10cSrcweir                 }
2920cdf0e10cSrcweir             }
2921cdf0e10cSrcweir             // --> OD 2005-01-31 #i41694# - improvement by removing duplicates
2922cdf0e10cSrcweir             if ( pLowerFrm )
2923cdf0e10cSrcweir             {
2924cdf0e10cSrcweir                 if ( pLowerFrm->IsInSct() )
2925cdf0e10cSrcweir                 {
2926cdf0e10cSrcweir                     // --> OD 2005-01-31 #i41694# - follow-up of issue #i10826#:
2927cdf0e10cSrcweir                     // No invalidation of section frame, if it's the this.
2928cdf0e10cSrcweir                     SwFrm* pSectFrm = pLowerFrm->FindSctFrm();
2929cdf0e10cSrcweir                     if( pSectFrm != this && IsAnLower( pSectFrm ) )
2930cdf0e10cSrcweir                     {
2931cdf0e10cSrcweir                         pSectFrm->_InvalidateSize();
2932cdf0e10cSrcweir                         pSectFrm->InvalidatePage( pPage );
2933cdf0e10cSrcweir                     }
2934cdf0e10cSrcweir                     // <--
2935cdf0e10cSrcweir                 }
2936cdf0e10cSrcweir             }
2937cdf0e10cSrcweir             // <--
2938cdf0e10cSrcweir         }
2939cdf0e10cSrcweir         return;
2940cdf0e10cSrcweir     } // end of { special case }
2941cdf0e10cSrcweir 
2942cdf0e10cSrcweir 
2943cdf0e10cSrcweir     // Invalidate page for content only once.
2944cdf0e10cSrcweir     bool bInvaPageForCntnt = true;
2945cdf0e10cSrcweir 
2946cdf0e10cSrcweir     // Declare booleans <bFixChgd> and <bVarChgd>, indicating for text frame
2947cdf0e10cSrcweir     // adjustment, if fixed/variable size has changed.
2948cdf0e10cSrcweir     bool bFixChgd, bVarChgd;
2949cdf0e10cSrcweir     if( bVert == pLowerFrm->IsNeighbourFrm() )
2950cdf0e10cSrcweir     {
2951cdf0e10cSrcweir         bFixChgd = bWidthChgd;
2952cdf0e10cSrcweir         bVarChgd = bHeightChgd;
2953cdf0e10cSrcweir     }
2954cdf0e10cSrcweir     else
2955cdf0e10cSrcweir     {
2956cdf0e10cSrcweir         bFixChgd = bHeightChgd;
2957cdf0e10cSrcweir         bVarChgd = bWidthChgd;
2958cdf0e10cSrcweir     }
2959cdf0e10cSrcweir 
2960cdf0e10cSrcweir     // Declare const unsigned short <nFixWidth> and init it this frame types
2961cdf0e10cSrcweir     // which has fixed width in vertical respectively horizontal layout.
2962cdf0e10cSrcweir     // In vertical layout these are neighbour frames (cell and column frames),
2963cdf0e10cSrcweir     //      header frames and footer frames.
2964cdf0e10cSrcweir     // In horizontal layout these are all frames, which aren't neighbour frames.
2965cdf0e10cSrcweir     const sal_uInt16 nFixWidth = bVert ? (FRM_NEIGHBOUR | FRM_HEADFOOT)
2966cdf0e10cSrcweir                                    : ~FRM_NEIGHBOUR;
2967cdf0e10cSrcweir 
2968cdf0e10cSrcweir     // Declare const unsigned short <nFixHeight> and init it this frame types
2969cdf0e10cSrcweir     // which has fixed height in vertical respectively horizontal layout.
2970cdf0e10cSrcweir     // In vertical layout these are all frames, which aren't neighbour frames,
2971cdf0e10cSrcweir     //      header frames, footer frames, body frames or foot note container frames.
2972cdf0e10cSrcweir     // In horizontal layout these are neighbour frames.
2973cdf0e10cSrcweir     const sal_uInt16 nFixHeight= bVert ? ~(FRM_NEIGHBOUR | FRM_HEADFOOT | FRM_BODYFTNC)
2974cdf0e10cSrcweir                                    : FRM_NEIGHBOUR;
2975cdf0e10cSrcweir 
2976cdf0e10cSrcweir     // Travel through all lowers using <GetNext()>
2977cdf0e10cSrcweir     while ( pLowerFrm )
2978cdf0e10cSrcweir     {
2979cdf0e10cSrcweir         if ( pLowerFrm->IsTxtFrm() )
2980cdf0e10cSrcweir         {
2981cdf0e10cSrcweir             // Text frames will only be invalidated - prepare invalidation
2982cdf0e10cSrcweir             if ( bFixChgd )
2983cdf0e10cSrcweir                 static_cast<SwCntntFrm*>(pLowerFrm)->Prepare( PREP_FIXSIZE_CHG );
2984cdf0e10cSrcweir             if ( bVarChgd )
2985cdf0e10cSrcweir                 static_cast<SwCntntFrm*>(pLowerFrm)->Prepare( PREP_ADJUST_FRM );
2986cdf0e10cSrcweir         }
2987cdf0e10cSrcweir         else
2988cdf0e10cSrcweir         {
2989cdf0e10cSrcweir             // If lower isn't a table, row, cell or section frame, adjust its
2990cdf0e10cSrcweir             // frame size.
2991cdf0e10cSrcweir             const sal_uInt16 nLowerType = pLowerFrm->GetType();
2992cdf0e10cSrcweir             if ( !(nLowerType & (FRM_TAB|FRM_ROW|FRM_CELL|FRM_SECTION)) )
2993cdf0e10cSrcweir             {
2994cdf0e10cSrcweir                 if ( bWidthChgd )
2995cdf0e10cSrcweir                 {
2996cdf0e10cSrcweir                     if( nLowerType & nFixWidth )
2997cdf0e10cSrcweir                     {
2998cdf0e10cSrcweir                         // Considering previous conditions:
2999cdf0e10cSrcweir                         // In vertical layout set width of column, header and
3000cdf0e10cSrcweir                         // footer frames to its upper width.
3001cdf0e10cSrcweir                         // In horizontal layout set width of header, footer,
3002cdf0e10cSrcweir                         // foot note container, foot note, body and no-text
3003cdf0e10cSrcweir                         // frames to its upper width.
3004cdf0e10cSrcweir                         pLowerFrm->Frm().Width( Prt().Width() );
3005cdf0e10cSrcweir                     }
3006cdf0e10cSrcweir                     else if( rOldSize.Width() && !pLowerFrm->IsFtnFrm() )
3007cdf0e10cSrcweir                     {
3008cdf0e10cSrcweir                         // Adjust frame width proportional, if lower isn't a
3009cdf0e10cSrcweir                         // foot note frame and condition <nLowerType & nFixWidth>
3010cdf0e10cSrcweir                         // isn't true.
3011cdf0e10cSrcweir                         // Considering previous conditions:
3012cdf0e10cSrcweir                         // In vertical layout these are foot note container,
3013cdf0e10cSrcweir                         // body and no-text frames.
3014cdf0e10cSrcweir                         // In horizontal layout these are column and no-text frames.
3015cdf0e10cSrcweir                         // OD 24.10.2002 #97265# - <double> calculation
3016cdf0e10cSrcweir                         // Perform <double> calculation of new width, if
3017cdf0e10cSrcweir                         // one of the coefficients is greater than 50000
3018cdf0e10cSrcweir                         SwTwips nNewWidth;
3019cdf0e10cSrcweir                         if ( (pLowerFrm->Frm().Width() > 50000) ||
3020cdf0e10cSrcweir                              (Prt().Width() > 50000) )
3021cdf0e10cSrcweir                         {
3022cdf0e10cSrcweir                             double nNewWidthTmp =
3023cdf0e10cSrcweir                                 ( double(pLowerFrm->Frm().Width())
3024cdf0e10cSrcweir                                   * double(Prt().Width()) )
3025cdf0e10cSrcweir                                 / double(rOldSize.Width());
3026cdf0e10cSrcweir                             nNewWidth = SwTwips(nNewWidthTmp);
3027cdf0e10cSrcweir                         }
3028cdf0e10cSrcweir                         else
3029cdf0e10cSrcweir                         {
3030cdf0e10cSrcweir                             nNewWidth =
3031cdf0e10cSrcweir                                 (pLowerFrm->Frm().Width() * Prt().Width()) / rOldSize.Width();
3032cdf0e10cSrcweir                         }
3033cdf0e10cSrcweir                         pLowerFrm->Frm().Width( nNewWidth );
3034cdf0e10cSrcweir                     }
3035cdf0e10cSrcweir                 }
3036cdf0e10cSrcweir                 if ( bHeightChgd )
3037cdf0e10cSrcweir                 {
3038cdf0e10cSrcweir                     if( nLowerType & nFixHeight )
3039cdf0e10cSrcweir                     {
3040cdf0e10cSrcweir                         // Considering previous conditions:
3041cdf0e10cSrcweir                         // In vertical layout set height of foot note and
3042cdf0e10cSrcweir                         // no-text frames to its upper height.
3043cdf0e10cSrcweir                         // In horizontal layout set height of column frames
3044cdf0e10cSrcweir                         // to its upper height.
3045cdf0e10cSrcweir                         pLowerFrm->Frm().Height( Prt().Height() );
3046cdf0e10cSrcweir                     }
3047cdf0e10cSrcweir                     // OD 01.10.2002 #102211#
3048cdf0e10cSrcweir                     // add conditions <!pLowerFrm->IsHeaderFrm()> and
3049cdf0e10cSrcweir                     // <!pLowerFrm->IsFooterFrm()> in order to avoid that
3050cdf0e10cSrcweir                     // the <Grow> of header or footer are overwritten.
3051cdf0e10cSrcweir                     // NOTE: Height of header/footer frame is determined by contents.
3052cdf0e10cSrcweir                     else if ( rOldSize.Height() &&
3053cdf0e10cSrcweir                               !pLowerFrm->IsFtnFrm() &&
3054cdf0e10cSrcweir                               !pLowerFrm->IsHeaderFrm() &&
3055cdf0e10cSrcweir                               !pLowerFrm->IsFooterFrm()
3056cdf0e10cSrcweir                             )
3057cdf0e10cSrcweir                     {
3058cdf0e10cSrcweir                         // Adjust frame height proportional, if lower isn't a
3059cdf0e10cSrcweir                         // foot note, a header or a footer frame and
3060cdf0e10cSrcweir                         // condition <nLowerType & nFixHeight> isn't true.
3061cdf0e10cSrcweir                         // Considering previous conditions:
3062cdf0e10cSrcweir                         // In vertical layout these are column, foot note container,
3063cdf0e10cSrcweir                         // body and no-text frames.
3064cdf0e10cSrcweir                         // In horizontal layout these are column, foot note
3065cdf0e10cSrcweir                         // container, body and no-text frames.
3066cdf0e10cSrcweir 
3067cdf0e10cSrcweir                         // OD 29.10.2002 #97265# - special case for page lowers
3068cdf0e10cSrcweir                         // The page lowers that have to be adjusted on page height
3069cdf0e10cSrcweir                         // change are the body frame and the foot note container
3070cdf0e10cSrcweir                         // frame.
3071cdf0e10cSrcweir                         // In vertical layout the height of both is directly
3072cdf0e10cSrcweir                         // adjusted to the page height change.
3073cdf0e10cSrcweir                         // In horizontal layout the height of the body frame is
30749cf3e4aaSJohn Bampton                         // directly adjusted to the page height change and the
3075cdf0e10cSrcweir                         // foot note frame height isn't touched, because its
3076cdf0e10cSrcweir                         // determined by its content.
3077cdf0e10cSrcweir                         // OD 31.03.2003 #108446# - apply special case for page
3078cdf0e10cSrcweir                         // lowers - see description above - also for section columns.
3079cdf0e10cSrcweir                         if ( IsPageFrm() ||
3080cdf0e10cSrcweir                              ( IsColumnFrm() && IsInSct() )
3081cdf0e10cSrcweir                            )
3082cdf0e10cSrcweir                         {
3083cdf0e10cSrcweir                             ASSERT( pLowerFrm->IsBodyFrm() || pLowerFrm->IsFtnContFrm(),
3084cdf0e10cSrcweir                                     "ChgLowersProp - only for body or foot note container" );
3085cdf0e10cSrcweir                             if ( pLowerFrm->IsBodyFrm() || pLowerFrm->IsFtnContFrm() )
3086cdf0e10cSrcweir                             {
3087cdf0e10cSrcweir                                 if ( IsVertical() || pLowerFrm->IsBodyFrm() )
3088cdf0e10cSrcweir                                 {
3089cdf0e10cSrcweir                                     SwTwips nNewHeight =
3090cdf0e10cSrcweir                                             pLowerFrm->Frm().Height() +
3091cdf0e10cSrcweir                                             ( Prt().Height() - rOldSize.Height() );
3092cdf0e10cSrcweir                                     if ( nNewHeight < 0)
3093cdf0e10cSrcweir                                     {
3094cdf0e10cSrcweir                                         // OD 01.04.2003 #108446# - adjust assertion condition and text
3095cdf0e10cSrcweir                                         ASSERT( !( IsPageFrm() &&
3096cdf0e10cSrcweir                                                    (pLowerFrm->Frm().Height()>0) &&
3097cdf0e10cSrcweir                                                    (pLowerFrm->IsValid()) ),
3098cdf0e10cSrcweir                                                     "ChgLowersProg - negative height for lower.");
3099cdf0e10cSrcweir                                         nNewHeight = 0;
3100cdf0e10cSrcweir                                     }
3101cdf0e10cSrcweir                                     pLowerFrm->Frm().Height( nNewHeight );
3102cdf0e10cSrcweir                                 }
3103cdf0e10cSrcweir                             }
3104cdf0e10cSrcweir                         }
3105cdf0e10cSrcweir                         else
3106cdf0e10cSrcweir                         {
3107cdf0e10cSrcweir                             SwTwips nNewHeight;
3108cdf0e10cSrcweir                             // OD 24.10.2002 #97265# - <double> calculation
3109cdf0e10cSrcweir                             // Perform <double> calculation of new height, if
3110cdf0e10cSrcweir                             // one of the coefficients is greater than 50000
3111cdf0e10cSrcweir                             if ( (pLowerFrm->Frm().Height() > 50000) ||
3112cdf0e10cSrcweir                                  (Prt().Height() > 50000) )
3113cdf0e10cSrcweir                             {
3114cdf0e10cSrcweir                                 double nNewHeightTmp =
3115cdf0e10cSrcweir                                     ( double(pLowerFrm->Frm().Height())
3116cdf0e10cSrcweir                                       * double(Prt().Height()) )
3117cdf0e10cSrcweir                                     / double(rOldSize.Height());
3118cdf0e10cSrcweir                                 nNewHeight = SwTwips(nNewHeightTmp);
3119cdf0e10cSrcweir                             }
3120cdf0e10cSrcweir                             else
3121cdf0e10cSrcweir                             {
3122cdf0e10cSrcweir                                 nNewHeight = ( pLowerFrm->Frm().Height()
3123cdf0e10cSrcweir                                              * Prt().Height() ) / rOldSize.Height();
3124cdf0e10cSrcweir                             }
3125cdf0e10cSrcweir                             if( !pLowerFrm->GetNext() )
3126cdf0e10cSrcweir                             {
3127cdf0e10cSrcweir                                 SwTwips nSum = Prt().Height();
3128cdf0e10cSrcweir                                 SwFrm* pTmp = Lower();
3129cdf0e10cSrcweir                                 while( pTmp->GetNext() )
3130cdf0e10cSrcweir                                 {
3131cdf0e10cSrcweir                                     if( !pTmp->IsFtnContFrm() || !pTmp->IsVertical() )
3132cdf0e10cSrcweir                                         nSum -= pTmp->Frm().Height();
3133cdf0e10cSrcweir                                     pTmp = pTmp->GetNext();
3134cdf0e10cSrcweir                                 }
3135cdf0e10cSrcweir                                 if( nSum - nNewHeight == 1 &&
3136cdf0e10cSrcweir                                     nSum == pLowerFrm->Frm().Height() )
3137cdf0e10cSrcweir                                     nNewHeight = nSum;
3138cdf0e10cSrcweir                             }
3139cdf0e10cSrcweir                             pLowerFrm->Frm().Height( nNewHeight );
3140cdf0e10cSrcweir                         }
3141cdf0e10cSrcweir                     }
3142cdf0e10cSrcweir                 }
3143cdf0e10cSrcweir             }
3144cdf0e10cSrcweir         } // end of else { NOT text frame }
3145cdf0e10cSrcweir 
3146cdf0e10cSrcweir         pLowerFrm->_InvalidateAll();
3147cdf0e10cSrcweir         if ( bInvaPageForCntnt && pLowerFrm->IsCntntFrm() )
3148cdf0e10cSrcweir         {
3149cdf0e10cSrcweir             pLowerFrm->InvalidatePage();
3150cdf0e10cSrcweir             bInvaPageForCntnt = false;
3151cdf0e10cSrcweir         }
3152cdf0e10cSrcweir 
3153cdf0e10cSrcweir         if ( !pLowerFrm->GetNext() && pLowerFrm->IsRetoucheFrm() )
3154cdf0e10cSrcweir         {
3155cdf0e10cSrcweir             //Wenn ein Wachstum stattgefunden hat, und die untergeordneten
3156cdf0e10cSrcweir             //zur Retouche faehig sind (derzeit Tab, Section und Cntnt), so
3157cdf0e10cSrcweir             //trigger ich sie an.
3158cdf0e10cSrcweir             if ( rOldSize.Height() < Prt().SSize().Height() ||
3159cdf0e10cSrcweir                  rOldSize.Width() < Prt().SSize().Width() )
3160cdf0e10cSrcweir                 pLowerFrm->SetRetouche();
3161cdf0e10cSrcweir         }
3162cdf0e10cSrcweir         pLowerFrm = pLowerFrm->GetNext();
3163cdf0e10cSrcweir     }
3164cdf0e10cSrcweir 
3165cdf0e10cSrcweir     // Finally adjust the columns if width is set to auto
3166cdf0e10cSrcweir     // Possible optimisation: execute this code earlier in this function and
3167cdf0e10cSrcweir     // return???
3168cdf0e10cSrcweir     if ( ( (bVert && bHeightChgd) || (! bVert && bWidthChgd) ) &&
3169cdf0e10cSrcweir            Lower()->IsColumnFrm() )
3170cdf0e10cSrcweir     {
3171cdf0e10cSrcweir         // get column attribute
3172cdf0e10cSrcweir         const SwFmtCol* pColAttr = NULL;
3173cdf0e10cSrcweir         if ( IsPageBodyFrm() )
3174cdf0e10cSrcweir         {
3175cdf0e10cSrcweir             ASSERT( GetUpper()->IsPageFrm(), "Upper is not page frame" )
3176cdf0e10cSrcweir             pColAttr = &GetUpper()->GetFmt()->GetCol();
3177cdf0e10cSrcweir         }
3178cdf0e10cSrcweir         else
3179cdf0e10cSrcweir         {
3180cdf0e10cSrcweir             ASSERT( IsFlyFrm() || IsSctFrm(), "Columns not in fly or section" )
3181cdf0e10cSrcweir             pColAttr = &GetFmt()->GetCol();
3182cdf0e10cSrcweir         }
3183cdf0e10cSrcweir 
3184cdf0e10cSrcweir         if ( pColAttr->IsOrtho() && pColAttr->GetNumCols() > 1 )
3185cdf0e10cSrcweir             AdjustColumns( pColAttr, sal_False );
3186cdf0e10cSrcweir     }
3187cdf0e10cSrcweir }
3188cdf0e10cSrcweir 
3189cdf0e10cSrcweir /*************************************************************************
3190cdf0e10cSrcweir |*
3191cdf0e10cSrcweir |*  SwLayoutFrm::Format()
3192cdf0e10cSrcweir |*
3193cdf0e10cSrcweir |*  Beschreibung:       "Formatiert" den Frame; Frm und PrtArea.
3194cdf0e10cSrcweir |*                      Die Fixsize wird hier nicht eingestellt.
3195cdf0e10cSrcweir |*  Ersterstellung      MA 28. Jul. 92
3196cdf0e10cSrcweir |*  Letzte Aenderung    MA 21. Mar. 95
3197cdf0e10cSrcweir |*
3198cdf0e10cSrcweir |*************************************************************************/
Format(const SwBorderAttrs * pAttrs)3199cdf0e10cSrcweir void SwLayoutFrm::Format( const SwBorderAttrs *pAttrs )
3200cdf0e10cSrcweir {
3201cdf0e10cSrcweir     ASSERT( pAttrs, "LayoutFrm::Format, pAttrs ist 0." );
3202cdf0e10cSrcweir 
3203cdf0e10cSrcweir     if ( bValidPrtArea && bValidSize )
3204cdf0e10cSrcweir         return;
3205cdf0e10cSrcweir 
3206cdf0e10cSrcweir     const sal_uInt16 nLeft = (sal_uInt16)pAttrs->CalcLeft( this );
3207cdf0e10cSrcweir     const sal_uInt16 nUpper = pAttrs->CalcTop();
3208cdf0e10cSrcweir 
3209cdf0e10cSrcweir     const sal_uInt16 nRight = (sal_uInt16)((SwBorderAttrs*)pAttrs)->CalcRight( this );
3210cdf0e10cSrcweir     const sal_uInt16 nLower = pAttrs->CalcBottom();
3211cdf0e10cSrcweir     sal_Bool bVert = IsVertical() && !IsPageFrm();
3212cdf0e10cSrcweir     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
3213cdf0e10cSrcweir     SwRectFn fnRect = bVert ? ( IsVertLR() ? fnRectVertL2R : fnRectVert ) : fnRectHori;
3214cdf0e10cSrcweir     if ( !bValidPrtArea )
3215cdf0e10cSrcweir     {
3216cdf0e10cSrcweir         bValidPrtArea = sal_True;
3217cdf0e10cSrcweir         (this->*fnRect->fnSetXMargins)( nLeft, nRight );
3218cdf0e10cSrcweir         (this->*fnRect->fnSetYMargins)( nUpper, nLower );
3219cdf0e10cSrcweir     }
3220cdf0e10cSrcweir 
3221cdf0e10cSrcweir     if ( !bValidSize )
3222cdf0e10cSrcweir     {
3223cdf0e10cSrcweir         if ( !HasFixSize() )
3224cdf0e10cSrcweir         {
3225cdf0e10cSrcweir             const SwTwips nBorder = nUpper + nLower;
3226cdf0e10cSrcweir             const SwFmtFrmSize &rSz = GetFmt()->GetFrmSize();
3227cdf0e10cSrcweir             SwTwips nMinHeight = rSz.GetHeightSizeType() == ATT_MIN_SIZE ? rSz.GetHeight() : 0;
3228cdf0e10cSrcweir             do
3229cdf0e10cSrcweir             {   bValidSize = sal_True;
3230cdf0e10cSrcweir 
3231cdf0e10cSrcweir                 //Die Groesse in der VarSize wird durch den Inhalt plus den
3232cdf0e10cSrcweir                 //Raendern bestimmt.
3233cdf0e10cSrcweir                 SwTwips nRemaining = 0;
3234cdf0e10cSrcweir                 SwFrm *pFrm = Lower();
3235cdf0e10cSrcweir                 while ( pFrm )
3236cdf0e10cSrcweir                 {   nRemaining += (pFrm->Frm().*fnRect->fnGetHeight)();
3237cdf0e10cSrcweir                     if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
3238cdf0e10cSrcweir                     // Dieser TxtFrm waere gern ein bisschen groesser
3239cdf0e10cSrcweir                         nRemaining += ((SwTxtFrm*)pFrm)->GetParHeight()
3240cdf0e10cSrcweir                                       - (pFrm->Prt().*fnRect->fnGetHeight)();
3241cdf0e10cSrcweir                     else if( pFrm->IsSctFrm() && ((SwSectionFrm*)pFrm)->IsUndersized() )
3242cdf0e10cSrcweir                         nRemaining += ((SwSectionFrm*)pFrm)->Undersize();
3243cdf0e10cSrcweir                     pFrm = pFrm->GetNext();
3244cdf0e10cSrcweir                 }
3245cdf0e10cSrcweir                 nRemaining += nBorder;
3246cdf0e10cSrcweir                 nRemaining = Max( nRemaining, nMinHeight );
3247cdf0e10cSrcweir                 const SwTwips nDiff = nRemaining-(Frm().*fnRect->fnGetHeight)();
3248cdf0e10cSrcweir                 const long nOldLeft = (Frm().*fnRect->fnGetLeft)();
3249cdf0e10cSrcweir                 const long nOldTop = (Frm().*fnRect->fnGetTop)();
3250cdf0e10cSrcweir                 if ( nDiff )
3251cdf0e10cSrcweir                 {
3252cdf0e10cSrcweir                     if ( nDiff > 0 )
3253cdf0e10cSrcweir                         Grow( nDiff );
3254cdf0e10cSrcweir                     else
3255cdf0e10cSrcweir                         Shrink( -nDiff );
3256cdf0e10cSrcweir                     //Schnell auf dem kurzen Dienstweg die Position updaten.
3257cdf0e10cSrcweir                     MakePos();
3258cdf0e10cSrcweir                 }
3259cdf0e10cSrcweir                 //Unterkante des Uppers nicht ueberschreiten.
3260cdf0e10cSrcweir                 if ( GetUpper() && (Frm().*fnRect->fnGetHeight)() )
3261cdf0e10cSrcweir                 {
3262cdf0e10cSrcweir                     const SwTwips nLimit = (GetUpper()->*fnRect->fnGetPrtBottom)();
3263cdf0e10cSrcweir                     if( (this->*fnRect->fnSetLimit)( nLimit ) &&
3264cdf0e10cSrcweir                         nOldLeft == (Frm().*fnRect->fnGetLeft)() &&
3265cdf0e10cSrcweir                         nOldTop  == (Frm().*fnRect->fnGetTop)() )
3266cdf0e10cSrcweir                         bValidSize = bValidPrtArea = sal_True;
3267cdf0e10cSrcweir                 }
3268cdf0e10cSrcweir             } while ( !bValidSize );
3269cdf0e10cSrcweir         }
3270cdf0e10cSrcweir         else if ( GetType() & 0x0018 )
3271cdf0e10cSrcweir         {
3272cdf0e10cSrcweir             do
3273cdf0e10cSrcweir             {   if ( Frm().Height() != pAttrs->GetSize().Height() )
3274cdf0e10cSrcweir                     ChgSize( Size( Frm().Width(), pAttrs->GetSize().Height()));
3275cdf0e10cSrcweir                 bValidSize = sal_True;
3276cdf0e10cSrcweir                 MakePos();
3277cdf0e10cSrcweir             } while ( !bValidSize );
3278cdf0e10cSrcweir         }
3279cdf0e10cSrcweir         else
3280cdf0e10cSrcweir             bValidSize = sal_True;
3281cdf0e10cSrcweir     }
3282cdf0e10cSrcweir }
3283cdf0e10cSrcweir 
3284cdf0e10cSrcweir /*************************************************************************
3285cdf0e10cSrcweir |*
3286cdf0e10cSrcweir |*  SwLayoutFrm::InvalidatePercentLowers()
3287cdf0e10cSrcweir |*
3288cdf0e10cSrcweir |*  Ersterstellung      MA 13. Jun. 96
3289cdf0e10cSrcweir |*  Letzte Aenderung    MA 13. Jun. 96
3290cdf0e10cSrcweir |*
3291cdf0e10cSrcweir |*************************************************************************/
InvaPercentFlys(SwFrm * pFrm,SwTwips nDiff)3292cdf0e10cSrcweir static void InvaPercentFlys( SwFrm *pFrm, SwTwips nDiff )
3293cdf0e10cSrcweir {
3294cdf0e10cSrcweir     ASSERT( pFrm->GetDrawObjs(), "Can't find any Objects" );
3295cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < pFrm->GetDrawObjs()->Count(); ++i )
3296cdf0e10cSrcweir     {
3297cdf0e10cSrcweir         SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
3298cdf0e10cSrcweir         if ( pAnchoredObj->ISA(SwFlyFrm) )
3299cdf0e10cSrcweir         {
3300cdf0e10cSrcweir             SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3301cdf0e10cSrcweir             const SwFmtFrmSize &rSz = pFly->GetFmt()->GetFrmSize();
3302cdf0e10cSrcweir             if ( rSz.GetWidthPercent() || rSz.GetHeightPercent() )
3303cdf0e10cSrcweir             {
3304cdf0e10cSrcweir                 sal_Bool bNotify = sal_True;
3305cdf0e10cSrcweir                 // If we've a fly with more than 90% relative height...
3306cdf0e10cSrcweir                 if( rSz.GetHeightPercent() > 90 && pFly->GetAnchorFrm() &&
3307cdf0e10cSrcweir                     rSz.GetHeightPercent() != 0xFF && nDiff )
3308cdf0e10cSrcweir                 {
3309cdf0e10cSrcweir                     const SwFrm *pRel = pFly->IsFlyLayFrm() ? pFly->GetAnchorFrm():
3310cdf0e10cSrcweir                                         pFly->GetAnchorFrm()->GetUpper();
3311cdf0e10cSrcweir                     // ... and we have already more than 90% height and we
3312cdf0e10cSrcweir                     // not allow the text to go through...
3313ad1df53dSJohn Bampton                     // then a notification could cause an endless loop, e.g.
3314cdf0e10cSrcweir                     // 100% height and no text wrap inside a cell of a table.
3315cdf0e10cSrcweir                     if( pFly->Frm().Height()*10 >
3316cdf0e10cSrcweir                         ( nDiff + pRel->Prt().Height() )*9 &&
3317cdf0e10cSrcweir                         pFly->GetFmt()->GetSurround().GetSurround() !=
3318cdf0e10cSrcweir                         SURROUND_THROUGHT )
3319cdf0e10cSrcweir                        bNotify = sal_False;
3320cdf0e10cSrcweir                 }
3321cdf0e10cSrcweir                 if( bNotify )
3322cdf0e10cSrcweir                     pFly->InvalidateSize();
3323cdf0e10cSrcweir             }
3324cdf0e10cSrcweir         }
3325cdf0e10cSrcweir     }
3326cdf0e10cSrcweir }
3327cdf0e10cSrcweir 
InvaPercentLowers(SwTwips nDiff)3328cdf0e10cSrcweir void SwLayoutFrm::InvaPercentLowers( SwTwips nDiff )
3329cdf0e10cSrcweir {
3330cdf0e10cSrcweir     if ( GetDrawObjs() )
3331cdf0e10cSrcweir         ::InvaPercentFlys( this, nDiff );
3332cdf0e10cSrcweir 
3333cdf0e10cSrcweir     SwFrm *pFrm = ContainsCntnt();
3334cdf0e10cSrcweir     if ( pFrm )
3335cdf0e10cSrcweir         do
3336cdf0e10cSrcweir         {
3337cdf0e10cSrcweir             if ( pFrm->IsInTab() && !IsTabFrm() )
3338cdf0e10cSrcweir             {
3339cdf0e10cSrcweir                 SwFrm *pTmp = pFrm->FindTabFrm();
3340cdf0e10cSrcweir                 ASSERT( pTmp, "Where's my TabFrm?" );
3341cdf0e10cSrcweir                 if( IsAnLower( pTmp ) )
3342cdf0e10cSrcweir                     pFrm = pTmp;
3343cdf0e10cSrcweir             }
3344cdf0e10cSrcweir 
3345cdf0e10cSrcweir             if ( pFrm->IsTabFrm() )
3346cdf0e10cSrcweir             {
3347cdf0e10cSrcweir                 const SwFmtFrmSize &rSz = ((SwLayoutFrm*)pFrm)->GetFmt()->GetFrmSize();
3348cdf0e10cSrcweir                 if ( rSz.GetWidthPercent() || rSz.GetHeightPercent() )
3349cdf0e10cSrcweir                     pFrm->InvalidatePrt();
3350cdf0e10cSrcweir             }
3351cdf0e10cSrcweir             else if ( pFrm->GetDrawObjs() )
3352cdf0e10cSrcweir                 ::InvaPercentFlys( pFrm, nDiff );
3353cdf0e10cSrcweir             pFrm = pFrm->FindNextCnt();
3354cdf0e10cSrcweir         } while ( pFrm && IsAnLower( pFrm ) ) ;
3355cdf0e10cSrcweir }
3356cdf0e10cSrcweir 
3357cdf0e10cSrcweir /*************************************************************************
3358cdf0e10cSrcweir |*
3359cdf0e10cSrcweir |*  SwLayoutFrm::CalcRel()
3360cdf0e10cSrcweir |*
3361cdf0e10cSrcweir |*  Ersterstellung      MA 13. Jun. 96
3362cdf0e10cSrcweir |*  Letzte Aenderung    MA 10. Oct. 96
3363cdf0e10cSrcweir |*
3364cdf0e10cSrcweir |*************************************************************************/
CalcRel(const SwFmtFrmSize & rSz,sal_Bool) const3365cdf0e10cSrcweir long SwLayoutFrm::CalcRel( const SwFmtFrmSize &rSz, sal_Bool ) const
3366cdf0e10cSrcweir {
3367cdf0e10cSrcweir     long nRet     = rSz.GetWidth(),
3368cdf0e10cSrcweir          nPercent = rSz.GetWidthPercent();
3369cdf0e10cSrcweir 
3370cdf0e10cSrcweir     if ( nPercent )
3371cdf0e10cSrcweir     {
3372cdf0e10cSrcweir         const SwFrm *pRel = GetUpper();
3373cdf0e10cSrcweir         long nRel = LONG_MAX;
3374cdf0e10cSrcweir         const ViewShell *pSh = getRootFrm()->GetCurrShell();
3375cdf0e10cSrcweir         const sal_Bool bBrowseMode = pSh && pSh->GetViewOptions()->getBrowseMode();
3376cdf0e10cSrcweir         if( pRel->IsPageBodyFrm() && pSh && bBrowseMode && pSh->VisArea().Width() )
3377cdf0e10cSrcweir         {
3378cdf0e10cSrcweir             nRel = pSh->GetBrowseWidth();
3379cdf0e10cSrcweir             long nDiff = nRel - pRel->Prt().Width();
3380cdf0e10cSrcweir             if ( nDiff > 0 )
3381cdf0e10cSrcweir                 nRel -= nDiff;
3382cdf0e10cSrcweir         }
3383cdf0e10cSrcweir         nRel = Min( nRel, pRel->Prt().Width() );
3384cdf0e10cSrcweir         nRet = nRel * nPercent / 100;
3385cdf0e10cSrcweir     }
3386cdf0e10cSrcweir     return nRet;
3387cdf0e10cSrcweir }
3388cdf0e10cSrcweir 
3389cdf0e10cSrcweir /*************************************************************************
3390cdf0e10cSrcweir |*  Local helpers for SwLayoutFrm::FormatWidthCols()
3391cdf0e10cSrcweir |*************************************************************************/
lcl_CalcMinColDiff(SwLayoutFrm * pLayFrm)3392cdf0e10cSrcweir long MA_FASTCALL lcl_CalcMinColDiff( SwLayoutFrm *pLayFrm )
3393cdf0e10cSrcweir {
3394cdf0e10cSrcweir     long nDiff = 0, nFirstDiff = 0;
3395cdf0e10cSrcweir     SwLayoutFrm *pCol = (SwLayoutFrm*)pLayFrm->Lower();
3396cdf0e10cSrcweir     ASSERT( pCol, "Where's the columnframe?" );
3397cdf0e10cSrcweir     SwFrm *pFrm = pCol->Lower();
3398cdf0e10cSrcweir     do
3399cdf0e10cSrcweir     {
3400cdf0e10cSrcweir         if( pFrm && pFrm->IsBodyFrm() )
3401cdf0e10cSrcweir             pFrm = ((SwBodyFrm*)pFrm)->Lower();
3402cdf0e10cSrcweir         if ( pFrm && pFrm->IsTxtFrm() )
3403cdf0e10cSrcweir         {
3404cdf0e10cSrcweir             const long nTmp = ((SwTxtFrm*)pFrm)->FirstLineHeight();
3405cdf0e10cSrcweir             if ( nTmp != USHRT_MAX )
3406cdf0e10cSrcweir             {
3407cdf0e10cSrcweir                 if ( pCol == pLayFrm->Lower() )
3408cdf0e10cSrcweir                     nFirstDiff = nTmp;
3409cdf0e10cSrcweir                 else
3410cdf0e10cSrcweir                     nDiff = nDiff ? Min( nDiff, nTmp ) : nTmp;
3411cdf0e10cSrcweir             }
3412cdf0e10cSrcweir         }
3413cdf0e10cSrcweir         //Leere Spalten ueberspringen!
3414cdf0e10cSrcweir         pCol = (SwLayoutFrm*)pCol->GetNext();
3415cdf0e10cSrcweir         while ( pCol && 0 == (pFrm = pCol->Lower()) )
3416cdf0e10cSrcweir             pCol = (SwLayoutFrm*)pCol->GetNext();
3417cdf0e10cSrcweir 
3418cdf0e10cSrcweir     } while ( pFrm && pCol );
3419cdf0e10cSrcweir 
3420cdf0e10cSrcweir     return nDiff ? nDiff : nFirstDiff ? nFirstDiff : 240;
3421cdf0e10cSrcweir }
3422cdf0e10cSrcweir 
lcl_IsFlyHeightClipped(SwLayoutFrm * pLay)3423cdf0e10cSrcweir sal_Bool lcl_IsFlyHeightClipped( SwLayoutFrm *pLay )
3424cdf0e10cSrcweir {
3425cdf0e10cSrcweir     SwFrm *pFrm = pLay->ContainsCntnt();
3426cdf0e10cSrcweir     while ( pFrm )
3427cdf0e10cSrcweir     {
3428cdf0e10cSrcweir         if ( pFrm->IsInTab() )
3429cdf0e10cSrcweir             pFrm = pFrm->FindTabFrm();
3430cdf0e10cSrcweir 
3431cdf0e10cSrcweir         if ( pFrm->GetDrawObjs() )
3432cdf0e10cSrcweir         {
3433cdf0e10cSrcweir             sal_uInt32 nCnt = pFrm->GetDrawObjs()->Count();
3434cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < nCnt; ++i )
3435cdf0e10cSrcweir             {
3436cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
3437cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyFrm) )
3438cdf0e10cSrcweir                 {
3439cdf0e10cSrcweir                     SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3440cdf0e10cSrcweir                     if ( pFly->IsHeightClipped() &&
3441cdf0e10cSrcweir                          ( !pFly->IsFlyFreeFrm() || pFly->GetPageFrm() ) )
3442cdf0e10cSrcweir                         return sal_True;
3443cdf0e10cSrcweir                 }
3444cdf0e10cSrcweir             }
3445cdf0e10cSrcweir         }
3446cdf0e10cSrcweir         pFrm = pFrm->FindNextCnt();
3447cdf0e10cSrcweir     }
3448cdf0e10cSrcweir     return sal_False;
3449cdf0e10cSrcweir }
3450cdf0e10cSrcweir 
3451cdf0e10cSrcweir /*************************************************************************
3452cdf0e10cSrcweir |*  SwLayoutFrm::FormatWidthCols()
3453cdf0e10cSrcweir |*************************************************************************/
FormatWidthCols(const SwBorderAttrs & rAttrs,const SwTwips nBorder,const SwTwips nMinHeight)3454cdf0e10cSrcweir void SwLayoutFrm::FormatWidthCols( const SwBorderAttrs &rAttrs,
3455cdf0e10cSrcweir                                    const SwTwips nBorder, const SwTwips nMinHeight )
3456cdf0e10cSrcweir {
3457cdf0e10cSrcweir     //Wenn Spalten im Spiel sind, so wird die Groesse an der
3458cdf0e10cSrcweir     //letzten Spalte ausgerichtet.
3459cdf0e10cSrcweir     //1. Inhalt formatieren.
3460cdf0e10cSrcweir     //2. Hoehe der letzten Spalte ermitteln, wenn diese zu
3461cdf0e10cSrcweir     //   zu gross ist muss der Fly wachsen.
3462cdf0e10cSrcweir     //   Der Betrag um den der Fly waechst ist aber nicht etwa
3463cdf0e10cSrcweir     //   der Betrag des Ueberhangs, denn wir muessen davon
3464cdf0e10cSrcweir     //   ausgehen, dass etwas Masse zurueckfliesst und so
3465cdf0e10cSrcweir     //   zusaetzlicher Platz geschaffen wird.
3466cdf0e10cSrcweir     //   Im Ersten Ansatz ist der Betrag um den gewachsen wird
3467cdf0e10cSrcweir     //   der Ueberhang geteilt durch die Spaltenanzahl oder
3468cdf0e10cSrcweir     //   der Ueberhang selbst wenn er kleiner als die Spalten-
3469cdf0e10cSrcweir     //   anzahl ist.
3470cdf0e10cSrcweir     //3. Weiter mit 1. bis zur Stabilitaet.
3471cdf0e10cSrcweir 
3472cdf0e10cSrcweir     const SwFmtCol &rCol = rAttrs.GetAttrSet().GetCol();
3473cdf0e10cSrcweir     const sal_uInt16 nNumCols = rCol.GetNumCols();
3474cdf0e10cSrcweir 
3475cdf0e10cSrcweir     sal_Bool bEnd = sal_False;
3476cdf0e10cSrcweir     sal_Bool bBackLock = sal_False;
3477cdf0e10cSrcweir     ViewShell *pSh = getRootFrm()->GetCurrShell();
3478cdf0e10cSrcweir     SwViewImp *pImp = pSh ? pSh->Imp() : 0;
3479cdf0e10cSrcweir     {
3480cdf0e10cSrcweir         // Zugrunde liegender Algorithmus
3481cdf0e10cSrcweir         // Es wird versucht, eine optimale Hoehe fuer die Spalten zu finden.
3482cdf0e10cSrcweir         // nMinimum beginnt mit der uebergebenen Mindesthoehe und wird dann als
3483cdf0e10cSrcweir         // Maximum der Hoehen gepflegt, bei denen noch Spalteninhalt aus einer
3484cdf0e10cSrcweir         // Spalte herausragt.
3485cdf0e10cSrcweir         // nMaximum beginnt bei LONG_MAX und wird als Minimum der Hoehen gepflegt,
3486cdf0e10cSrcweir         // bei denen der Inhalt gepasst hat.
3487cdf0e10cSrcweir         // Bei spaltigen Bereichen beginnt nMaximum bei dem maximalen Wert, den
3488cdf0e10cSrcweir         // die Umgebung vorgibt, dies kann natuerlich ein Wert sein, bei dem noch
3489cdf0e10cSrcweir         // Inhalt heraushaengt.
3490cdf0e10cSrcweir         // Es werden die Spalten formatiert, wenn Inhalt heraushaengt, wird nMinimum
3491cdf0e10cSrcweir         // ggf. angepasst, dann wird gewachsen, mindestens um nMinDiff, aber nicht ueber
3492cdf0e10cSrcweir         // ein groesseres nMaximum hinaus. Wenn kein Inhalt heraushaengt, sondern
3493cdf0e10cSrcweir         // noch Luft in einer Spalte ist, schrumpfen wir entsprechend, mindestens um
3494cdf0e10cSrcweir         // nMinDiff, aber nicht unter das nMinimum.
3495cdf0e10cSrcweir         // Abgebrochen wird, wenn kein Inhalt mehr heraushaengt und das Minimum sich auf
3496cdf0e10cSrcweir         // weniger als ein MinDiff dem Maximum angenaehert hat oder das von der
3497cdf0e10cSrcweir         // Umgebung vorgegebene Maximum erreicht ist und trotzdem Inhalt heraus-
3498cdf0e10cSrcweir         // haengt.
3499cdf0e10cSrcweir 
3500cdf0e10cSrcweir         // Kritik an der Implementation
3501cdf0e10cSrcweir         // 1. Es kann theoretisch Situationen geben, in denen der Inhalt in einer geringeren
3502cdf0e10cSrcweir         // Hoehe passt und in einer groesseren Hoehe nicht passt. Damit der Code robust
3503cdf0e10cSrcweir         // gegen solche Verhaeltnisse ist, sind ein paar Abfragen bezgl. Minimum und Maximum
3504cdf0e10cSrcweir         // drin, die wahrscheinlich niemals zuschlagen koennen.
3505cdf0e10cSrcweir         // 2. Es wird fuer das Schrumpfen das gleiche nMinDiff benutzt wie fuer das Wachstum,
3506cdf0e10cSrcweir         // das nMinDiff ist allerdings mehr oder weniger die kleinste erste Zeilenhoehe und
3507cdf0e10cSrcweir         // als Mindestwert fuer das Schrumpfen nicht unbedingt optimal.
3508cdf0e10cSrcweir 
3509cdf0e10cSrcweir         long nMinimum = nMinHeight;
3510cdf0e10cSrcweir         long nMaximum;
3511cdf0e10cSrcweir         sal_Bool bNoBalance = sal_False;
3512cdf0e10cSrcweir         SWRECTFN( this )
3513cdf0e10cSrcweir         if( IsSctFrm() )
3514cdf0e10cSrcweir         {
3515cdf0e10cSrcweir             nMaximum = (Frm().*fnRect->fnGetHeight)() - nBorder +
3516cdf0e10cSrcweir                        (Frm().*fnRect->fnBottomDist)(
3517cdf0e10cSrcweir                                         (GetUpper()->*fnRect->fnGetPrtBottom)() );
3518cdf0e10cSrcweir             nMaximum += GetUpper()->Grow( LONG_MAX, sal_True );
3519cdf0e10cSrcweir             if( nMaximum < nMinimum )
3520cdf0e10cSrcweir             {
3521cdf0e10cSrcweir                 if( nMaximum < 0 )
3522cdf0e10cSrcweir                     nMinimum = nMaximum = 0;
3523cdf0e10cSrcweir                 else
3524cdf0e10cSrcweir                     nMinimum = nMaximum;
3525cdf0e10cSrcweir             }
3526cdf0e10cSrcweir             if( nMaximum > BROWSE_HEIGHT )
3527cdf0e10cSrcweir                 nMaximum = BROWSE_HEIGHT;
3528cdf0e10cSrcweir 
3529cdf0e10cSrcweir             bNoBalance = ((SwSectionFrm*)this)->GetSection()->GetFmt()->
3530cdf0e10cSrcweir                          GetBalancedColumns().GetValue();
3531cdf0e10cSrcweir             SwFrm* pAny = ContainsAny();
3532cdf0e10cSrcweir             if( bNoBalance ||
3533cdf0e10cSrcweir                 ( !(Frm().*fnRect->fnGetHeight)() && pAny ) )
3534cdf0e10cSrcweir             {
3535cdf0e10cSrcweir                 long nTop = (this->*fnRect->fnGetTopMargin)();
3536cdf0e10cSrcweir                 // --> OD 2004-11-01 #i23129# - correction: enlarge section
3537cdf0e10cSrcweir                 // to the calculated maximum height.
3538cdf0e10cSrcweir                 (Frm().*fnRect->fnAddBottom)( nMaximum -
3539cdf0e10cSrcweir                                               (Frm().*fnRect->fnGetHeight)() );
3540cdf0e10cSrcweir                 // <--
3541cdf0e10cSrcweir                 if( nTop > nMaximum )
3542cdf0e10cSrcweir                     nTop = nMaximum;
3543cdf0e10cSrcweir                 (this->*fnRect->fnSetYMargins)( nTop, 0 );
3544cdf0e10cSrcweir             }
3545cdf0e10cSrcweir             if( !pAny && !((SwSectionFrm*)this)->IsFtnLock() )
3546cdf0e10cSrcweir             {
3547cdf0e10cSrcweir                 SwFtnContFrm* pFtnCont = ((SwSectionFrm*)this)->ContainsFtnCont();
3548cdf0e10cSrcweir                 if( pFtnCont )
3549cdf0e10cSrcweir                 {
3550cdf0e10cSrcweir                     SwFrm* pFtnAny = pFtnCont->ContainsAny();
3551cdf0e10cSrcweir                     if( pFtnAny && pFtnAny->IsValid() )
3552cdf0e10cSrcweir                     {
3553cdf0e10cSrcweir                         bBackLock = sal_True;
3554cdf0e10cSrcweir                         ((SwSectionFrm*)this)->SetFtnLock( sal_True );
3555cdf0e10cSrcweir                     }
3556cdf0e10cSrcweir                 }
3557cdf0e10cSrcweir             }
3558cdf0e10cSrcweir         }
3559cdf0e10cSrcweir         else
3560cdf0e10cSrcweir             nMaximum = LONG_MAX;
3561cdf0e10cSrcweir 
3562cdf0e10cSrcweir         // --> OD 2004-08-25 #i3317# - reset temporarly consideration
3563cdf0e10cSrcweir         // of wrapping style influence
3564cdf0e10cSrcweir         SwPageFrm* pPageFrm = FindPageFrm();
3565cdf0e10cSrcweir         SwSortedObjs* pObjs = pPageFrm ? pPageFrm->GetSortedObjs() : 0L;
3566cdf0e10cSrcweir         if ( pObjs )
3567cdf0e10cSrcweir         {
3568cdf0e10cSrcweir             sal_uInt32 i = 0;
3569cdf0e10cSrcweir             for ( i = 0; i < pObjs->Count(); ++i )
3570cdf0e10cSrcweir             {
3571cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
3572cdf0e10cSrcweir 
3573cdf0e10cSrcweir                 if ( IsAnLower( pAnchoredObj->GetAnchorFrm() ) )
3574cdf0e10cSrcweir                 {
3575cdf0e10cSrcweir                     pAnchoredObj->SetTmpConsiderWrapInfluence( false );
3576cdf0e10cSrcweir                 }
3577cdf0e10cSrcweir             }
3578cdf0e10cSrcweir         }
3579cdf0e10cSrcweir         // <--
3580cdf0e10cSrcweir         do
3581cdf0e10cSrcweir         {
3582cdf0e10cSrcweir             //Kann eine Weile dauern, deshalb hier auf Waitcrsr pruefen.
3583cdf0e10cSrcweir             if ( pImp )
3584cdf0e10cSrcweir                 pImp->CheckWaitCrsr();
3585cdf0e10cSrcweir 
3586cdf0e10cSrcweir             bValidSize = sal_True;
3587cdf0e10cSrcweir             //Erstmal die Spalten formatieren, das entlastet den
3588cdf0e10cSrcweir             //Stack ein wenig.
3589cdf0e10cSrcweir             //Bei der Gelegenheit stellen wir auch gleich mal die
3590cdf0e10cSrcweir             //Breiten und Hoehen der Spalten ein (so sie denn falsch sind).
3591cdf0e10cSrcweir             SwLayoutFrm *pCol = (SwLayoutFrm*)Lower();
3592cdf0e10cSrcweir 
3593cdf0e10cSrcweir             // --> FME 2004-07-19 #i27399#
3594cdf0e10cSrcweir             // Simply setting the column width based on the values returned by
3595cdf0e10cSrcweir             // CalcColWidth does not work for automatic column width.
3596cdf0e10cSrcweir             AdjustColumns( &rCol, sal_False );
3597cdf0e10cSrcweir             // <--
3598cdf0e10cSrcweir 
3599cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < nNumCols; ++i )
3600cdf0e10cSrcweir             {
3601cdf0e10cSrcweir                 pCol->Calc();
3602cdf0e10cSrcweir                 // ColumnFrms besitzen jetzt einen BodyFrm, der auch kalkuliert werden will
3603cdf0e10cSrcweir                 pCol->Lower()->Calc();
3604cdf0e10cSrcweir                 if( pCol->Lower()->GetNext() )
3605cdf0e10cSrcweir                     pCol->Lower()->GetNext()->Calc();  // SwFtnCont
3606cdf0e10cSrcweir                 pCol = (SwLayoutFrm*)pCol->GetNext();
3607cdf0e10cSrcweir             }
3608cdf0e10cSrcweir 
3609cdf0e10cSrcweir             ::CalcCntnt( this );
3610cdf0e10cSrcweir 
3611cdf0e10cSrcweir             pCol = (SwLayoutFrm*)Lower();
3612cdf0e10cSrcweir             ASSERT( pCol && pCol->GetNext(), ":-( Spalten auf Urlaub?");
3613cdf0e10cSrcweir             // bMinDiff wird gesetzt, wenn es keine leere Spalte gibt
3614cdf0e10cSrcweir             sal_Bool bMinDiff = sal_True;
3615cdf0e10cSrcweir             // OD 28.03.2003 #108446# - check for all column content and all columns
3616cdf0e10cSrcweir             while ( bMinDiff && pCol )
3617cdf0e10cSrcweir             {
3618cdf0e10cSrcweir                 bMinDiff = 0 != pCol->ContainsCntnt();
3619cdf0e10cSrcweir                 pCol = (SwLayoutFrm*)pCol->GetNext();
3620cdf0e10cSrcweir             }
3621cdf0e10cSrcweir             pCol = (SwLayoutFrm*)Lower();
3622cdf0e10cSrcweir             // OD 28.03.2003 #108446# - initialize local variable
3623cdf0e10cSrcweir             SwFrm *pLow = NULL;
3624cdf0e10cSrcweir             SwTwips nDiff = 0;
3625cdf0e10cSrcweir             SwTwips nMaxFree = 0;
3626cdf0e10cSrcweir             SwTwips nAllFree = LONG_MAX;
3627cdf0e10cSrcweir             // bFoundLower wird gesetzt, wenn es mind. eine nichtleere Spalte gibt
3628cdf0e10cSrcweir             sal_Bool bFoundLower = sal_False;
3629cdf0e10cSrcweir             while( pCol )
3630cdf0e10cSrcweir             {
3631cdf0e10cSrcweir                 SwLayoutFrm* pLay = (SwLayoutFrm*)pCol->Lower();
3632cdf0e10cSrcweir                 SwTwips nInnerHeight = (pLay->Frm().*fnRect->fnGetHeight)() -
3633cdf0e10cSrcweir                                        (pLay->Prt().*fnRect->fnGetHeight)();
3634cdf0e10cSrcweir                 if( pLay->Lower() )
3635cdf0e10cSrcweir                 {
3636cdf0e10cSrcweir                     bFoundLower = sal_True;
3637cdf0e10cSrcweir                     nInnerHeight += pLay->InnerHeight();
3638cdf0e10cSrcweir                 }
3639cdf0e10cSrcweir                 else if( nInnerHeight < 0 )
3640cdf0e10cSrcweir                     nInnerHeight = 0;
3641cdf0e10cSrcweir 
3642cdf0e10cSrcweir                 if( pLay->GetNext() )
3643cdf0e10cSrcweir                 {
3644cdf0e10cSrcweir                     bFoundLower = sal_True;
3645cdf0e10cSrcweir                     pLay = (SwLayoutFrm*)pLay->GetNext();
3646*7de601c3SJohn Bampton                     ASSERT( pLay->IsFtnContFrm(),"FtnContainer expected" );
3647cdf0e10cSrcweir                     nInnerHeight += pLay->InnerHeight();
3648cdf0e10cSrcweir                     nInnerHeight += (pLay->Frm().*fnRect->fnGetHeight)() -
3649cdf0e10cSrcweir                                     (pLay->Prt().*fnRect->fnGetHeight)();
3650cdf0e10cSrcweir                 }
3651cdf0e10cSrcweir                 nInnerHeight -= (pCol->Prt().*fnRect->fnGetHeight)();
3652cdf0e10cSrcweir                 if( nInnerHeight > nDiff )
3653cdf0e10cSrcweir                 {
3654cdf0e10cSrcweir                     nDiff = nInnerHeight;
3655cdf0e10cSrcweir                     nAllFree = 0;
3656cdf0e10cSrcweir                 }
3657cdf0e10cSrcweir                 else
3658cdf0e10cSrcweir                 {
3659cdf0e10cSrcweir                     if( nMaxFree < -nInnerHeight )
3660cdf0e10cSrcweir                         nMaxFree = -nInnerHeight;
3661cdf0e10cSrcweir                     if( nAllFree > -nInnerHeight )
3662cdf0e10cSrcweir                         nAllFree = -nInnerHeight;
3663cdf0e10cSrcweir                 }
3664cdf0e10cSrcweir                 pCol = (SwLayoutFrm*)pCol->GetNext();
3665cdf0e10cSrcweir             }
3666cdf0e10cSrcweir 
3667cdf0e10cSrcweir             if ( bFoundLower || ( IsSctFrm() && ((SwSectionFrm*)this)->HasFollow() ) )
3668cdf0e10cSrcweir             {
3669cdf0e10cSrcweir                 SwTwips nMinDiff = ::lcl_CalcMinColDiff( this );
3670cdf0e10cSrcweir                 // Hier wird entschieden, ob wir wachsen muessen, naemlich wenn
3671cdf0e10cSrcweir                 // ein Spalteninhalt (nDiff) oder ein Fly herausragt.
3672cdf0e10cSrcweir                 // Bei spaltigen Bereichen wird beruecksichtigt, dass mit dem
3673cdf0e10cSrcweir                 // Besitz eines nichtleeren Follows die Groesse festgelegt ist.
3674cdf0e10cSrcweir                 if ( nDiff || ::lcl_IsFlyHeightClipped( this ) ||
3675cdf0e10cSrcweir                      ( IsSctFrm() && ((SwSectionFrm*)this)->CalcMinDiff( nMinDiff ) ) )
3676cdf0e10cSrcweir                 {
3677cdf0e10cSrcweir                     long nPrtHeight = (Prt().*fnRect->fnGetHeight)();
3678cdf0e10cSrcweir                     // Das Minimum darf nicht kleiner sein als unsere PrtHeight,
3679cdf0e10cSrcweir                     // solange noch etwas herausragt.
3680cdf0e10cSrcweir                     if( nMinimum < nPrtHeight )
3681cdf0e10cSrcweir                         nMinimum = nPrtHeight;
3682cdf0e10cSrcweir                     // Es muss sichergestellt sein, dass das Maximum nicht kleiner
3683cdf0e10cSrcweir                     // als die PrtHeight ist, wenn noch etwas herausragt
3684cdf0e10cSrcweir                     if( nMaximum < nPrtHeight )
3685cdf0e10cSrcweir                         nMaximum = nPrtHeight;  // Robust, aber kann das ueberhaupt eintreten?
3686cdf0e10cSrcweir                     if( !nDiff ) // wenn nur Flys herausragen, wachsen wir um nMinDiff
3687cdf0e10cSrcweir                         nDiff = nMinDiff;
3688cdf0e10cSrcweir                     // Wenn wir um mehr als nMinDiff wachsen wollen, wird dies auf die
3689cdf0e10cSrcweir                     // Spalten verteilt
3690cdf0e10cSrcweir                     if ( Abs(nDiff - nMinDiff) > nNumCols && nDiff > (long)nNumCols )
3691cdf0e10cSrcweir                         nDiff /= nNumCols;
3692cdf0e10cSrcweir 
3693cdf0e10cSrcweir                     if ( bMinDiff )
3694cdf0e10cSrcweir                     {   // Wenn es keinen leeren Spalten gibt, wollen wir mind. um nMinDiff
3695cdf0e10cSrcweir                         // wachsen. Sonderfall: Wenn wir kleiner als die minimale Frmhoehe
3696cdf0e10cSrcweir                         // sind und die PrtHeight kleiner als nMinDiff ist, wachsen wir so,
3697cdf0e10cSrcweir                         // dass die PrtHeight hinterher genau nMinDiff ist.
3698cdf0e10cSrcweir                         long nFrmHeight = (Frm().*fnRect->fnGetHeight)();
3699cdf0e10cSrcweir                         if ( nFrmHeight > nMinHeight || nPrtHeight >= nMinDiff )
3700cdf0e10cSrcweir                             nDiff = Max( nDiff, nMinDiff );
3701cdf0e10cSrcweir                         else if( nDiff < nMinDiff )
3702cdf0e10cSrcweir                             nDiff = nMinDiff - nPrtHeight + 1;
3703cdf0e10cSrcweir                     }
3704cdf0e10cSrcweir                     // nMaximum ist eine Groesse, in der der Inhalt gepasst hat,
3705cdf0e10cSrcweir                     // oder der von der Umgebung vorgegebene Wert, deshalb
3706cdf0e10cSrcweir                     // brauchen wir nicht ueber diesen Wrt hinauswachsen.
3707cdf0e10cSrcweir                     if( nDiff + nPrtHeight > nMaximum )
3708cdf0e10cSrcweir                         nDiff = nMaximum - nPrtHeight;
3709cdf0e10cSrcweir                 }
3710cdf0e10cSrcweir                 else if( nMaximum > nMinimum ) // Wir passen, haben wir auch noch Spielraum?
3711cdf0e10cSrcweir                 {
3712cdf0e10cSrcweir                     long nPrtHeight = (Prt().*fnRect->fnGetHeight)();
3713cdf0e10cSrcweir                     if ( nMaximum < nPrtHeight )
3714cdf0e10cSrcweir                         nDiff = nMaximum - nPrtHeight; // wir sind ueber eine funktionierende
3715cdf0e10cSrcweir                         // Hoehe hinausgewachsen und schrumpfen wieder auf diese zurueck,
3716cdf0e10cSrcweir                         // aber kann das ueberhaupt eintreten?
3717cdf0e10cSrcweir                     else
3718cdf0e10cSrcweir                     {   // Wir haben ein neues Maximum, eine Groesse, fuer die der Inhalt passt.
3719cdf0e10cSrcweir                         nMaximum = nPrtHeight;
3720cdf0e10cSrcweir                         // Wenn der Freiraum in den Spalten groesser ist als nMinDiff und wir
3721cdf0e10cSrcweir                         // nicht dadurch wieder unter das Minimum rutschen, wollen wir ein wenig
3722cdf0e10cSrcweir                         // Luft herauslassen.
3723cdf0e10cSrcweir                         if ( !bNoBalance &&
3724cdf0e10cSrcweir                              // --> OD 2004-11-04 #i23129# - <nMinDiff> can be
3725cdf0e10cSrcweir                              // big, because of an object at the beginning of
3726cdf0e10cSrcweir                              // a column. Thus, decrease optimization here.
3727cdf0e10cSrcweir                              //nMaxFree >= nMinDiff &&
3728cdf0e10cSrcweir                              nMaxFree > 0 &&
3729cdf0e10cSrcweir                              // <--
3730cdf0e10cSrcweir                              ( !nAllFree ||
3731cdf0e10cSrcweir                                nMinimum < nPrtHeight - nMinDiff ) )
3732cdf0e10cSrcweir                         {
3733cdf0e10cSrcweir                             nMaxFree /= nNumCols; // auf die Spalten verteilen
3734cdf0e10cSrcweir                             nDiff = nMaxFree < nMinDiff ? -nMinDiff : -nMaxFree; // mind. nMinDiff
3735cdf0e10cSrcweir                             if( nPrtHeight + nDiff <= nMinimum ) // Unter das Minimum?
3736cdf0e10cSrcweir                                 nDiff = ( nMinimum - nMaximum ) / 2; // dann lieber die Mitte
3737cdf0e10cSrcweir                         }
3738cdf0e10cSrcweir                         else if( nAllFree )
3739cdf0e10cSrcweir                         {
3740cdf0e10cSrcweir                             nDiff = -nAllFree;
3741cdf0e10cSrcweir                             if( nPrtHeight + nDiff <= nMinimum ) // Less than minimum?
3742cdf0e10cSrcweir                                 nDiff = ( nMinimum - nMaximum ) / 2; // Take the center
3743cdf0e10cSrcweir                         }
3744cdf0e10cSrcweir                     }
3745cdf0e10cSrcweir                 }
3746cdf0e10cSrcweir                 if( nDiff ) // jetzt wird geschrumpft oder gewachsen..
3747cdf0e10cSrcweir                 {
3748cdf0e10cSrcweir                     Size aOldSz( Prt().SSize() );
3749cdf0e10cSrcweir                     long nTop = (this->*fnRect->fnGetTopMargin)();
3750cdf0e10cSrcweir                     nDiff = (Prt().*fnRect->fnGetHeight)() + nDiff + nBorder -
3751cdf0e10cSrcweir                             (Frm().*fnRect->fnGetHeight)();
3752cdf0e10cSrcweir                     (Frm().*fnRect->fnAddBottom)( nDiff );
3753cdf0e10cSrcweir                     // --> OD 2006-08-16 #i68520#
3754cdf0e10cSrcweir                     if ( dynamic_cast<SwFlyFrm*>(this) )
3755cdf0e10cSrcweir                     {
3756cdf0e10cSrcweir                         dynamic_cast<SwFlyFrm*>(this)->InvalidateObjRectWithSpaces();
3757cdf0e10cSrcweir                     }
3758cdf0e10cSrcweir                     // <--
3759cdf0e10cSrcweir                     (this->*fnRect->fnSetYMargins)( nTop, nBorder - nTop );
3760cdf0e10cSrcweir                     ChgLowersProp( aOldSz );
3761cdf0e10cSrcweir                     NotifyLowerObjs();
3762cdf0e10cSrcweir 
3763cdf0e10cSrcweir                     // --> OD 2004-08-25 #i3317# - reset temporarly consideration
3764cdf0e10cSrcweir                     // of wrapping style influence
3765cdf0e10cSrcweir                     SwPageFrm* pTmpPageFrm = FindPageFrm();
3766cdf0e10cSrcweir                     SwSortedObjs* pTmpObjs = pTmpPageFrm ? pTmpPageFrm->GetSortedObjs() : 0L;
3767cdf0e10cSrcweir                     if ( pTmpObjs )
3768cdf0e10cSrcweir                     {
3769cdf0e10cSrcweir                         sal_uInt32 i = 0;
3770cdf0e10cSrcweir                         for ( i = 0; i < pTmpObjs->Count(); ++i )
3771cdf0e10cSrcweir                         {
3772cdf0e10cSrcweir                             SwAnchoredObject* pAnchoredObj = (*pTmpObjs)[i];
3773cdf0e10cSrcweir 
3774cdf0e10cSrcweir                             if ( IsAnLower( pAnchoredObj->GetAnchorFrm() ) )
3775cdf0e10cSrcweir                             {
3776cdf0e10cSrcweir                                 pAnchoredObj->SetTmpConsiderWrapInfluence( false );
3777cdf0e10cSrcweir                             }
3778cdf0e10cSrcweir                         }
3779cdf0e10cSrcweir                     }
3780cdf0e10cSrcweir                     // <--
3781cdf0e10cSrcweir                     //Es muss geeignet invalidiert werden, damit
3782cdf0e10cSrcweir                     //sich die Frms huebsch ausbalancieren
3783cdf0e10cSrcweir                     //- Der jeweils erste ab der zweiten Spalte bekommt
3784cdf0e10cSrcweir                     //  ein InvalidatePos();
3785cdf0e10cSrcweir                     pCol = (SwLayoutFrm*)Lower()->GetNext();
3786cdf0e10cSrcweir                     while ( pCol )
3787cdf0e10cSrcweir                     {
3788cdf0e10cSrcweir                         pLow = pCol->Lower();
3789cdf0e10cSrcweir                         if ( pLow )
3790cdf0e10cSrcweir                             pLow->_InvalidatePos();
3791cdf0e10cSrcweir                         pCol = (SwLayoutFrm*)pCol->GetNext();
3792cdf0e10cSrcweir                     }
3793cdf0e10cSrcweir                     if( IsSctFrm() && ((SwSectionFrm*)this)->HasFollow() )
3794cdf0e10cSrcweir                     {
3795cdf0e10cSrcweir                         // Wenn wir einen Follow erzeugt haben, muessen wir
3796cdf0e10cSrcweir                         // seinem Inhalt die Chance geben, im CalcCntnt
3797cdf0e10cSrcweir                         // zurueckzufliessen
3798cdf0e10cSrcweir                         SwCntntFrm* pTmpCntnt =
3799cdf0e10cSrcweir                             ((SwSectionFrm*)this)->GetFollow()->ContainsCntnt();
3800cdf0e10cSrcweir                         if( pTmpCntnt )
3801cdf0e10cSrcweir                             pTmpCntnt->_InvalidatePos();
3802cdf0e10cSrcweir                     }
3803cdf0e10cSrcweir                 }
3804cdf0e10cSrcweir                 else
3805cdf0e10cSrcweir                     bEnd = sal_True;
3806cdf0e10cSrcweir             }
3807cdf0e10cSrcweir             else
3808cdf0e10cSrcweir                 bEnd = sal_True;
3809cdf0e10cSrcweir 
3810cdf0e10cSrcweir         } while ( !bEnd || !bValidSize );
3811cdf0e10cSrcweir     }
3812cdf0e10cSrcweir     // OD 01.04.2003 #108446# - Don't collect endnotes for sections. Thus, set
3813cdf0e10cSrcweir     // 2nd parameter to <true>.
3814cdf0e10cSrcweir     ::CalcCntnt( this, true );
3815cdf0e10cSrcweir     if( IsSctFrm() )
3816cdf0e10cSrcweir     {
3817cdf0e10cSrcweir         // OD 14.03.2003 #i11760# - adjust 2nd parameter - sal_True --> true
3818cdf0e10cSrcweir         ::CalcCntnt( this, true );
3819cdf0e10cSrcweir         if( bBackLock )
3820cdf0e10cSrcweir             ((SwSectionFrm*)this)->SetFtnLock( sal_False );
3821cdf0e10cSrcweir     }
3822cdf0e10cSrcweir }
3823cdf0e10cSrcweir 
3824cdf0e10cSrcweir 
3825cdf0e10cSrcweir /*************************************************************************
3826cdf0e10cSrcweir |*
3827cdf0e10cSrcweir |*  SwRootFrm::InvalidateAllCntnt()
3828cdf0e10cSrcweir |*
3829cdf0e10cSrcweir |*  Ersterstellung      MA 13. Feb. 98
3830cdf0e10cSrcweir |*  Letzte Aenderung    MA 12. Aug. 00
3831cdf0e10cSrcweir |*
3832cdf0e10cSrcweir |*************************************************************************/
3833cdf0e10cSrcweir 
lcl_InvalidateSection(SwFrm * pCnt,sal_uInt8 nInv)3834cdf0e10cSrcweir SwCntntFrm* lcl_InvalidateSection( SwFrm *pCnt, sal_uInt8 nInv )
3835cdf0e10cSrcweir {
3836cdf0e10cSrcweir     SwSectionFrm* pSect = pCnt->FindSctFrm();
3837cdf0e10cSrcweir     // Wenn unser CntntFrm in einer Tabelle oder Fussnote steht, sind nur
3838cdf0e10cSrcweir     // Bereiche gemeint, die ebenfalls innerhalb liegen.
3839cdf0e10cSrcweir     // Ausnahme: Wenn direkt eine Tabelle uebergeben wird.
3840cdf0e10cSrcweir     if( ( ( pCnt->IsInTab() && !pSect->IsInTab() ) ||
3841cdf0e10cSrcweir         ( pCnt->IsInFtn() && !pSect->IsInFtn() ) ) && !pCnt->IsTabFrm() )
3842cdf0e10cSrcweir         return NULL;
3843cdf0e10cSrcweir     if( nInv & INV_SIZE )
3844cdf0e10cSrcweir         pSect->_InvalidateSize();
3845cdf0e10cSrcweir     if( nInv & INV_POS )
3846cdf0e10cSrcweir         pSect->_InvalidatePos();
3847cdf0e10cSrcweir     if( nInv & INV_PRTAREA )
3848cdf0e10cSrcweir         pSect->_InvalidatePrt();
3849cdf0e10cSrcweir     SwFlowFrm *pFoll = pSect->GetFollow();
3850cdf0e10cSrcweir     // Temporary separation from follow
3851cdf0e10cSrcweir     pSect->SetFollow( NULL );
3852cdf0e10cSrcweir     SwCntntFrm* pRet = pSect->FindLastCntnt();
3853cdf0e10cSrcweir     pSect->SetFollow( pFoll );
3854cdf0e10cSrcweir     return pRet;
3855cdf0e10cSrcweir }
3856cdf0e10cSrcweir 
lcl_InvalidateTable(SwTabFrm * pTable,sal_uInt8 nInv)3857cdf0e10cSrcweir SwCntntFrm* lcl_InvalidateTable( SwTabFrm *pTable, sal_uInt8 nInv )
3858cdf0e10cSrcweir {
3859cdf0e10cSrcweir     if( ( nInv & INV_SECTION ) && pTable->IsInSct() )
3860cdf0e10cSrcweir         lcl_InvalidateSection( pTable, nInv );
3861cdf0e10cSrcweir     if( nInv & INV_SIZE )
3862cdf0e10cSrcweir         pTable->_InvalidateSize();
3863cdf0e10cSrcweir     if( nInv & INV_POS )
3864cdf0e10cSrcweir         pTable->_InvalidatePos();
3865cdf0e10cSrcweir     if( nInv & INV_PRTAREA )
3866cdf0e10cSrcweir         pTable->_InvalidatePrt();
3867cdf0e10cSrcweir     return pTable->FindLastCntnt();
3868cdf0e10cSrcweir }
3869cdf0e10cSrcweir 
3870cdf0e10cSrcweir void lcl_InvalidateAllCntnt( SwCntntFrm *pCnt, sal_uInt8 nInv );
3871cdf0e10cSrcweir 
lcl_InvalidateCntnt(SwCntntFrm * pCnt,sal_uInt8 nInv)3872cdf0e10cSrcweir void lcl_InvalidateCntnt( SwCntntFrm *pCnt, sal_uInt8 nInv )
3873cdf0e10cSrcweir {
3874cdf0e10cSrcweir     SwCntntFrm *pLastTabCnt = NULL;
3875cdf0e10cSrcweir     SwCntntFrm *pLastSctCnt = NULL;
3876cdf0e10cSrcweir     while ( pCnt )
3877cdf0e10cSrcweir     {
3878cdf0e10cSrcweir         if( nInv & INV_SECTION )
3879cdf0e10cSrcweir         {
3880cdf0e10cSrcweir             if( pCnt->IsInSct() )
3881cdf0e10cSrcweir             {
3882cdf0e10cSrcweir                 // Siehe oben bei Tabellen
3883cdf0e10cSrcweir                 if( !pLastSctCnt )
3884cdf0e10cSrcweir                     pLastSctCnt = lcl_InvalidateSection( pCnt, nInv );
3885cdf0e10cSrcweir                 if( pLastSctCnt == pCnt )
3886cdf0e10cSrcweir                     pLastSctCnt = NULL;
3887cdf0e10cSrcweir             }
3888cdf0e10cSrcweir #ifdef DBG_UTIL
3889cdf0e10cSrcweir             else
3890cdf0e10cSrcweir                 ASSERT( !pLastSctCnt, "Where's the last SctCntnt?" );
3891cdf0e10cSrcweir #endif
3892cdf0e10cSrcweir         }
3893cdf0e10cSrcweir         if( nInv & INV_TABLE )
3894cdf0e10cSrcweir         {
3895cdf0e10cSrcweir             if( pCnt->IsInTab() )
3896cdf0e10cSrcweir             {
3897cdf0e10cSrcweir                 // Um nicht fuer jeden CntntFrm einer Tabelle das FindTabFrm() zu rufen
3898cdf0e10cSrcweir                 // und wieder die gleiche Tabelle zu invalidieren, merken wir uns den letzten
3899cdf0e10cSrcweir                 // CntntFrm der Tabelle und reagieren erst wieder auf IsInTab(), wenn wir
3900cdf0e10cSrcweir                 // an diesem vorbei sind.
3901cdf0e10cSrcweir                 // Beim Eintritt in die Tabelle wird der LastSctCnt auf Null gesetzt,
3902cdf0e10cSrcweir                 // damit Bereiche im Innern der Tabelle richtig invalidiert werden.
3903cdf0e10cSrcweir                 // Sollte die Tabelle selbst in einem Bereich stehen, so wird an
3904cdf0e10cSrcweir                 // diesem die Invalidierung bis zu dreimal durchgefuehrt, das ist vertretbar.
3905cdf0e10cSrcweir                 if( !pLastTabCnt )
3906cdf0e10cSrcweir                 {
3907cdf0e10cSrcweir                     pLastTabCnt = lcl_InvalidateTable( pCnt->FindTabFrm(), nInv );
3908cdf0e10cSrcweir                     pLastSctCnt = NULL;
3909cdf0e10cSrcweir                 }
3910cdf0e10cSrcweir                 if( pLastTabCnt == pCnt )
3911cdf0e10cSrcweir                 {
3912cdf0e10cSrcweir                     pLastTabCnt = NULL;
3913cdf0e10cSrcweir                     pLastSctCnt = NULL;
3914cdf0e10cSrcweir                 }
3915cdf0e10cSrcweir             }
3916cdf0e10cSrcweir #ifdef DBG_UTIL
3917cdf0e10cSrcweir             else
3918cdf0e10cSrcweir                 ASSERT( !pLastTabCnt, "Where's the last TabCntnt?" );
3919cdf0e10cSrcweir #endif
3920cdf0e10cSrcweir         }
3921cdf0e10cSrcweir 
3922cdf0e10cSrcweir         if( nInv & INV_SIZE )
3923cdf0e10cSrcweir             pCnt->Prepare( PREP_CLEAR, 0, sal_False );
3924cdf0e10cSrcweir         if( nInv & INV_POS )
3925cdf0e10cSrcweir             pCnt->_InvalidatePos();
3926cdf0e10cSrcweir         if( nInv & INV_PRTAREA )
3927cdf0e10cSrcweir             pCnt->_InvalidatePrt();
3928cdf0e10cSrcweir         if ( nInv & INV_LINENUM )
3929cdf0e10cSrcweir             pCnt->InvalidateLineNum();
3930cdf0e10cSrcweir         if ( pCnt->GetDrawObjs() )
3931cdf0e10cSrcweir             lcl_InvalidateAllCntnt( pCnt, nInv );
3932cdf0e10cSrcweir         pCnt = pCnt->GetNextCntntFrm();
3933cdf0e10cSrcweir     }
3934cdf0e10cSrcweir }
3935cdf0e10cSrcweir 
lcl_InvalidateAllCntnt(SwCntntFrm * pCnt,sal_uInt8 nInv)3936cdf0e10cSrcweir void lcl_InvalidateAllCntnt( SwCntntFrm *pCnt, sal_uInt8 nInv )
3937cdf0e10cSrcweir {
3938cdf0e10cSrcweir     SwSortedObjs &rObjs = *pCnt->GetDrawObjs();
3939cdf0e10cSrcweir     for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
3940cdf0e10cSrcweir     {
3941cdf0e10cSrcweir         SwAnchoredObject* pAnchoredObj = rObjs[i];
3942cdf0e10cSrcweir         if ( pAnchoredObj->ISA(SwFlyFrm) )
3943cdf0e10cSrcweir         {
3944cdf0e10cSrcweir             SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3945cdf0e10cSrcweir             if ( pFly->IsFlyInCntFrm() )
3946cdf0e10cSrcweir             {
3947cdf0e10cSrcweir                 ::lcl_InvalidateCntnt( pFly->ContainsCntnt(), nInv );
3948cdf0e10cSrcweir                 if( nInv & INV_DIRECTION )
3949cdf0e10cSrcweir                     pFly->CheckDirChange();
3950cdf0e10cSrcweir             }
3951cdf0e10cSrcweir         }
3952cdf0e10cSrcweir     }
3953cdf0e10cSrcweir }
3954cdf0e10cSrcweir 
InvalidateAllCntnt(sal_uInt8 nInv)3955cdf0e10cSrcweir void SwRootFrm::InvalidateAllCntnt( sal_uInt8 nInv )
3956cdf0e10cSrcweir {
3957cdf0e10cSrcweir     // Erst werden alle Seitengebundenen FlyFrms abgearbeitet.
3958cdf0e10cSrcweir     SwPageFrm *pPage = (SwPageFrm*)Lower();
3959cdf0e10cSrcweir     while( pPage )
3960cdf0e10cSrcweir     {
3961cdf0e10cSrcweir         pPage->InvalidateFlyLayout();
3962cdf0e10cSrcweir         pPage->InvalidateFlyCntnt();
3963cdf0e10cSrcweir         pPage->InvalidateFlyInCnt();
3964cdf0e10cSrcweir         pPage->InvalidateLayout();
3965cdf0e10cSrcweir         pPage->InvalidateCntnt();
3966cdf0e10cSrcweir         pPage->InvalidatePage( pPage ); //Damit ggf. auch der Turbo verschwindet
3967cdf0e10cSrcweir 
3968cdf0e10cSrcweir         if ( pPage->GetSortedObjs() )
3969cdf0e10cSrcweir         {
3970cdf0e10cSrcweir             const SwSortedObjs &rObjs = *pPage->GetSortedObjs();
3971cdf0e10cSrcweir             for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
3972cdf0e10cSrcweir             {
3973cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = rObjs[i];
3974cdf0e10cSrcweir                 if ( pAnchoredObj->ISA(SwFlyFrm) )
3975cdf0e10cSrcweir                 {
3976cdf0e10cSrcweir                     SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
3977cdf0e10cSrcweir                     ::lcl_InvalidateCntnt( pFly->ContainsCntnt(), nInv );
3978cdf0e10cSrcweir                     if ( nInv & INV_DIRECTION )
3979cdf0e10cSrcweir                         pFly->CheckDirChange();
3980cdf0e10cSrcweir                 }
3981cdf0e10cSrcweir             }
3982cdf0e10cSrcweir         }
3983cdf0e10cSrcweir         if( nInv & INV_DIRECTION )
3984cdf0e10cSrcweir             pPage->CheckDirChange();
3985cdf0e10cSrcweir         pPage = (SwPageFrm*)(pPage->GetNext());
3986cdf0e10cSrcweir     }
3987cdf0e10cSrcweir 
3988cdf0e10cSrcweir     //Hier den gesamten Dokumentinhalt und die zeichengebundenen Flys.
3989cdf0e10cSrcweir     ::lcl_InvalidateCntnt( ContainsCntnt(), nInv );
3990cdf0e10cSrcweir 
3991cdf0e10cSrcweir     if( nInv & INV_PRTAREA )
3992cdf0e10cSrcweir     {
3993cdf0e10cSrcweir         ViewShell *pSh  = getRootFrm()->GetCurrShell();
3994cdf0e10cSrcweir         if( pSh )
3995cdf0e10cSrcweir             pSh->InvalidateWindows( Frm() );
3996cdf0e10cSrcweir     }
3997cdf0e10cSrcweir }
3998cdf0e10cSrcweir 
3999cdf0e10cSrcweir /** method to invalidate/re-calculate the position of all floating
4000cdf0e10cSrcweir     screen objects (Writer fly frames and drawing objects), which are
4001cdf0e10cSrcweir     anchored to paragraph or to character.
4002cdf0e10cSrcweir 
4003cdf0e10cSrcweir     OD 2004-03-16 #i11860#
4004cdf0e10cSrcweir 
4005cdf0e10cSrcweir     @author OD
4006cdf0e10cSrcweir */
InvalidateAllObjPos()4007cdf0e10cSrcweir void SwRootFrm::InvalidateAllObjPos()
4008cdf0e10cSrcweir {
4009cdf0e10cSrcweir     const SwPageFrm* pPageFrm = static_cast<const SwPageFrm*>(Lower());
4010cdf0e10cSrcweir     while( pPageFrm )
4011cdf0e10cSrcweir     {
4012cdf0e10cSrcweir         pPageFrm->InvalidateFlyLayout();
4013cdf0e10cSrcweir 
4014cdf0e10cSrcweir         if ( pPageFrm->GetSortedObjs() )
4015cdf0e10cSrcweir         {
4016cdf0e10cSrcweir             const SwSortedObjs& rObjs = *(pPageFrm->GetSortedObjs());
4017cdf0e10cSrcweir             for ( sal_uInt8 i = 0; i < rObjs.Count(); ++i )
4018cdf0e10cSrcweir             {
4019cdf0e10cSrcweir                 SwAnchoredObject* pAnchoredObj = rObjs[i];
4020cdf0e10cSrcweir                 const SwFmtAnchor& rAnch = pAnchoredObj->GetFrmFmt().GetAnchor();
4021cdf0e10cSrcweir                 if ((rAnch.GetAnchorId() != FLY_AT_PARA) &&
4022cdf0e10cSrcweir                     (rAnch.GetAnchorId() != FLY_AT_CHAR))
4023cdf0e10cSrcweir                 {
4024cdf0e10cSrcweir                     // only to paragraph and to character anchored objects are considered.
4025cdf0e10cSrcweir                     continue;
4026cdf0e10cSrcweir                 }
4027cdf0e10cSrcweir                 // --> OD 2004-07-07 #i28701# - special invalidation for anchored
4028cdf0e10cSrcweir                 // objects, whose wrapping style influence has to be considered.
4029cdf0e10cSrcweir                 if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
4030cdf0e10cSrcweir                     pAnchoredObj->InvalidateObjPosForConsiderWrapInfluence( true );
4031cdf0e10cSrcweir                 else
4032cdf0e10cSrcweir                     pAnchoredObj->InvalidateObjPos();
4033cdf0e10cSrcweir                 // <--
4034cdf0e10cSrcweir             }
4035cdf0e10cSrcweir         }
4036cdf0e10cSrcweir 
4037cdf0e10cSrcweir         pPageFrm = static_cast<const SwPageFrm*>(pPageFrm->GetNext());
4038cdf0e10cSrcweir     }
4039cdf0e10cSrcweir }
4040