xref: /aoo42x/main/sw/source/core/layout/calcmove.cxx (revision 6d53c851)
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
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
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.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include "rootfrm.hxx"
27cdf0e10cSrcweir #include "pagefrm.hxx"
28cdf0e10cSrcweir #include "cntfrm.hxx"
29cdf0e10cSrcweir #include "viewsh.hxx"
30cdf0e10cSrcweir #include "doc.hxx"
31cdf0e10cSrcweir #include "viewimp.hxx"
32cdf0e10cSrcweir #include "viewopt.hxx"
33cdf0e10cSrcweir #include "swtypes.hxx"
34cdf0e10cSrcweir #include "dflyobj.hxx"
35cdf0e10cSrcweir #include "dcontact.hxx"
36cdf0e10cSrcweir #include "flyfrm.hxx"
37cdf0e10cSrcweir #include "frmtool.hxx"
38cdf0e10cSrcweir #include "txtftn.hxx"
39cdf0e10cSrcweir #include "fmtftn.hxx"
40cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
41cdf0e10cSrcweir #include <editeng/keepitem.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <vcl/outdev.hxx>
44cdf0e10cSrcweir #include <fmtfsize.hxx>
45cdf0e10cSrcweir #include <fmtanchr.hxx>
46cdf0e10cSrcweir #include <fmtclbl.hxx>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #include "tabfrm.hxx"
49cdf0e10cSrcweir #include "ftnfrm.hxx"
50cdf0e10cSrcweir #include "txtfrm.hxx"
51cdf0e10cSrcweir #include "pagedesc.hxx"
52cdf0e10cSrcweir #include "ftninfo.hxx"
53cdf0e10cSrcweir #include "sectfrm.hxx"
54cdf0e10cSrcweir #include "dbg_lay.hxx"
55cdf0e10cSrcweir 
56cdf0e10cSrcweir // --> OD 2004-06-23 #i28701#
57cdf0e10cSrcweir #include <sortedobjs.hxx>
58cdf0e10cSrcweir #include <layouter.hxx>
59cdf0e10cSrcweir // --> OD 2004-11-01 #i36347#
60cdf0e10cSrcweir #include <flyfrms.hxx>
61cdf0e10cSrcweir // <--
62cdf0e10cSrcweir 
63cdf0e10cSrcweir //------------------------------------------------------------------------
64cdf0e10cSrcweir //				Move-Methoden
65cdf0e10cSrcweir //------------------------------------------------------------------------
66cdf0e10cSrcweir 
67cdf0e10cSrcweir /*************************************************************************
68cdf0e10cSrcweir |*
69cdf0e10cSrcweir |*	SwCntntFrm::ShouldBwdMoved()
70cdf0e10cSrcweir |*
71cdf0e10cSrcweir |* 	Beschreibung		Returnwert sagt, ob der Frm verschoben werden sollte.
72cdf0e10cSrcweir |*	Ersterstellung		MA 05. Dec. 96
73cdf0e10cSrcweir |*	Letzte Aenderung	MA 05. Dec. 96
74cdf0e10cSrcweir |*
75cdf0e10cSrcweir |*************************************************************************/
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 
ShouldBwdMoved(SwLayoutFrm * pNewUpper,sal_Bool,sal_Bool &)78cdf0e10cSrcweir sal_Bool SwCntntFrm::ShouldBwdMoved( SwLayoutFrm *pNewUpper, sal_Bool, sal_Bool & )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir 	if ( (SwFlowFrm::IsMoveBwdJump() || !IsPrevObjMove()))
81cdf0e10cSrcweir 	{
82cdf0e10cSrcweir 		//Das zurueckfliessen von Frm's ist leider etwas Zeitintensiv.
83cdf0e10cSrcweir 		//Der haufigste Fall ist der, dass dort wo der Frm hinfliessen
84cdf0e10cSrcweir 		//moechte die FixSize die gleiche ist, die der Frm selbst hat.
85cdf0e10cSrcweir 		//In diesem Fall kann einfach geprueft werden, ob der Frm genug
86cdf0e10cSrcweir 		//Platz fuer seine VarSize findet, ist dies nicht der Fall kann
87cdf0e10cSrcweir 		//gleich auf das Verschieben verzichtet werden.
88cdf0e10cSrcweir 		//Die Pruefung, ob der Frm genug Platz findet fuehrt er selbst
89cdf0e10cSrcweir 		//durch, dabei wird beruecksichtigt, dass er sich moeglicherweise
90cdf0e10cSrcweir 		//aufspalten kann.
91cdf0e10cSrcweir 		//Wenn jedoch die FixSize eine andere ist oder Flys im Spiel sind
92cdf0e10cSrcweir 		//(an der alten oder neuen Position) hat alle Prueferei keinen Sinn
93cdf0e10cSrcweir 		//der Frm muss dann halt Probehalber verschoben werden (Wenn ueberhaupt
94cdf0e10cSrcweir 		//etwas Platz zur Verfuegung steht).
95cdf0e10cSrcweir 
96cdf0e10cSrcweir 		//Die FixSize der Umgebungen in denen Cntnts herumlungern ist immer
97cdf0e10cSrcweir 		//Die Breite.
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 		//Wenn mehr als ein Blatt zurueckgegangen wurde (z.B. ueberspringen
100cdf0e10cSrcweir 		//von Leerseiten), so muss in jedemfall gemoved werden - sonst wuerde,
101cdf0e10cSrcweir 		//falls der Frm nicht in das Blatt passt, nicht mehr auf die
102cdf0e10cSrcweir 		//dazwischenliegenden Blaetter geachtet werden.
103cdf0e10cSrcweir 		sal_uInt8 nMoveAnyway = 0;
104cdf0e10cSrcweir 		SwPageFrm * const pNewPage = pNewUpper->FindPageFrm();
105cdf0e10cSrcweir 		SwPageFrm *pOldPage = FindPageFrm();
106cdf0e10cSrcweir 
107cdf0e10cSrcweir 		if ( SwFlowFrm::IsMoveBwdJump() )
108cdf0e10cSrcweir 			return sal_True;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir 		if( IsInFtn() && IsInSct() )
111cdf0e10cSrcweir 		{
112cdf0e10cSrcweir 			SwFtnFrm* pFtn = FindFtnFrm();
113cdf0e10cSrcweir 			SwSectionFrm* pMySect = pFtn->FindSctFrm();
114cdf0e10cSrcweir 			if( pMySect && pMySect->IsFtnLock() )
115cdf0e10cSrcweir 			{
116cdf0e10cSrcweir 				SwSectionFrm *pSect = pNewUpper->FindSctFrm();
117cdf0e10cSrcweir 				while( pSect && pSect->IsInFtn() )
118cdf0e10cSrcweir 					pSect = pSect->GetUpper()->FindSctFrm();
119cdf0e10cSrcweir 				ASSERT( pSect, "Escaping footnote" );
120cdf0e10cSrcweir 				if( pSect != pMySect )
121cdf0e10cSrcweir 					return sal_False;
122cdf0e10cSrcweir 			}
123cdf0e10cSrcweir 		}
124cdf0e10cSrcweir         SWRECTFN( this )
125cdf0e10cSrcweir         SWRECTFNX( pNewUpper )
126cdf0e10cSrcweir         if( Abs( (pNewUpper->Prt().*fnRectX->fnGetWidth)() -
127cdf0e10cSrcweir                  (GetUpper()->Prt().*fnRect->fnGetWidth)() ) > 1 )
128cdf0e10cSrcweir 			nMoveAnyway = 2; // Damit kommt nur noch ein _WouldFit mit Umhaengen in Frage
129cdf0e10cSrcweir 
130cdf0e10cSrcweir         // OD 2004-05-26 #i25904# - do *not* move backward,
131cdf0e10cSrcweir         // if <nMoveAnyway> equals 3 and no space is left in new upper.
132cdf0e10cSrcweir         nMoveAnyway |= BwdMoveNecessary( pOldPage, Frm() );
133cdf0e10cSrcweir 		{
134cdf0e10cSrcweir             const IDocumentSettingAccess* pIDSA = pNewPage->GetFmt()->getIDocumentSettingAccess();
135cdf0e10cSrcweir 			SwTwips nSpace = 0;
136cdf0e10cSrcweir 			SwRect aRect( pNewUpper->Prt() );
137cdf0e10cSrcweir 			aRect.Pos() += pNewUpper->Frm().Pos();
138cdf0e10cSrcweir 			const SwFrm *pPrevFrm = pNewUpper->Lower();
139cdf0e10cSrcweir 			while ( pPrevFrm )
140cdf0e10cSrcweir 			{
141cdf0e10cSrcweir                 SwTwips nNewTop = (pPrevFrm->Frm().*fnRectX->fnGetBottom)();
142cdf0e10cSrcweir                 // OD 2004-03-01 #106629#:
143cdf0e10cSrcweir                 // consider lower spacing of last frame in a table cell
144cdf0e10cSrcweir                 {
145cdf0e10cSrcweir                     // check, if last frame is inside table and if it includes
146cdf0e10cSrcweir                     // its lower spacing.
147cdf0e10cSrcweir                     if ( !pPrevFrm->GetNext() && pPrevFrm->IsInTab() &&
148cdf0e10cSrcweir                          pIDSA->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS) )
149cdf0e10cSrcweir                     {
150cdf0e10cSrcweir                         const SwFrm* pLastFrm = pPrevFrm;
151cdf0e10cSrcweir                         // if last frame is a section, take its last content
152cdf0e10cSrcweir                         if ( pPrevFrm->IsSctFrm() )
153cdf0e10cSrcweir                         {
154cdf0e10cSrcweir                             pLastFrm = static_cast<const SwSectionFrm*>(pPrevFrm)->FindLastCntnt();
155cdf0e10cSrcweir                             if ( pLastFrm &&
156cdf0e10cSrcweir                                  pLastFrm->FindTabFrm() != pPrevFrm->FindTabFrm() )
157cdf0e10cSrcweir                             {
158cdf0e10cSrcweir                                 pLastFrm = pLastFrm->FindTabFrm();
159cdf0e10cSrcweir                             }
160cdf0e10cSrcweir                         }
161cdf0e10cSrcweir 
162cdf0e10cSrcweir                         if ( pLastFrm )
163cdf0e10cSrcweir                         {
164cdf0e10cSrcweir                             SwBorderAttrAccess aAccess( SwFrm::GetCache(), pLastFrm );
165cdf0e10cSrcweir                             const SwBorderAttrs& rAttrs = *aAccess.Get();
166cdf0e10cSrcweir                             nNewTop -= rAttrs.GetULSpace().GetLower();
167cdf0e10cSrcweir                         }
168cdf0e10cSrcweir                     }
169cdf0e10cSrcweir                 }
170cdf0e10cSrcweir                 (aRect.*fnRectX->fnSetTop)( nNewTop );
171cdf0e10cSrcweir 
172cdf0e10cSrcweir                 pPrevFrm = pPrevFrm->GetNext();
173cdf0e10cSrcweir             }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 			nMoveAnyway |= BwdMoveNecessary( pNewPage, aRect);
176cdf0e10cSrcweir 
177cdf0e10cSrcweir             //determine space left in new upper frame
178cdf0e10cSrcweir             nSpace = (aRect.*fnRectX->fnGetHeight)();
179cdf0e10cSrcweir             const ViewShell *pSh = pNewUpper->getRootFrm()->GetCurrShell();
180cdf0e10cSrcweir             if ( IsInFtn() ||
181cdf0e10cSrcweir                  (pSh && pSh->GetViewOptions()->getBrowseMode()) ||
182cdf0e10cSrcweir                  pNewUpper->IsCellFrm() ||
183cdf0e10cSrcweir                  ( pNewUpper->IsInSct() && ( pNewUpper->IsSctFrm() ||
184cdf0e10cSrcweir                    ( pNewUpper->IsColBodyFrm() &&
185cdf0e10cSrcweir                      !pNewUpper->GetUpper()->GetPrev() &&
186cdf0e10cSrcweir                      !pNewUpper->GetUpper()->GetNext() ) ) ) )
187cdf0e10cSrcweir                 nSpace += pNewUpper->Grow( LONG_MAX, sal_True );
188cdf0e10cSrcweir 
189cdf0e10cSrcweir 			if ( nMoveAnyway < 3 )
190cdf0e10cSrcweir 			{
191cdf0e10cSrcweir                 if ( nSpace )
192cdf0e10cSrcweir 				{
193cdf0e10cSrcweir 					//Keine Beruecksichtigung der Fussnoten die an dem Absatz
194cdf0e10cSrcweir 					//kleben, denn dies wuerde extrem unuebersichtlichen Code
195cdf0e10cSrcweir 					//beduerfen (wg. Beruecksichtung der Breiten und vor allem
196cdf0e10cSrcweir 					//der Flys, die ja wieder Einfluss auf die Fussnoten nehmen...).
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 					// _WouldFit kann bei gleicher Breite und _nur_ selbst verankerten Flys
199cdf0e10cSrcweir 					// befragt werden.
200cdf0e10cSrcweir 					// _WouldFit kann auch gefragt werden, wenn _nur_ fremdverankerte Flys vorliegen,
201cdf0e10cSrcweir 					// dabei ist sogar die Breite egal, da ein TestFormat in der neuen Umgebung
202cdf0e10cSrcweir 					// vorgenommen wird.
203cdf0e10cSrcweir                     // --> OD 2007-11-26 #b6614158#
204cdf0e10cSrcweir                     const sal_uInt8 nBwdMoveNecessaryResult =
205cdf0e10cSrcweir                                             BwdMoveNecessary( pNewPage, aRect);
206cdf0e10cSrcweir                     const bool bObjsInNewUpper( nBwdMoveNecessaryResult == 2 ||
207cdf0e10cSrcweir                                                 nBwdMoveNecessaryResult == 3 );
208cdf0e10cSrcweir 
209cdf0e10cSrcweir                     return _WouldFit( nSpace, pNewUpper, nMoveAnyway == 2,
210cdf0e10cSrcweir                                       bObjsInNewUpper );
211cdf0e10cSrcweir                     // <--
212cdf0e10cSrcweir 				}
213cdf0e10cSrcweir 				//Bei einem spaltigen Bereichsfrischling kann _WouldFit kein
214cdf0e10cSrcweir 				//brauchbares Ergebnis liefern, also muessen wir wirklich
215cdf0e10cSrcweir 				//zurueckfliessen
216cdf0e10cSrcweir 				else if( pNewUpper->IsInSct() && pNewUpper->IsColBodyFrm() &&
217cdf0e10cSrcweir                     !(pNewUpper->Prt().*fnRectX->fnGetWidth)() &&
218cdf0e10cSrcweir 					( pNewUpper->GetUpper()->GetPrev() ||
219cdf0e10cSrcweir 					  pNewUpper->GetUpper()->GetNext() ) )
220cdf0e10cSrcweir 					return sal_True;
221cdf0e10cSrcweir 				else
222cdf0e10cSrcweir 					return sal_False; // Kein Platz, dann ist es sinnlos, zurueckzufliessen
223cdf0e10cSrcweir 			}
224cdf0e10cSrcweir             else
225cdf0e10cSrcweir             {
226cdf0e10cSrcweir                 // OD 2004-05-26 #i25904# - check for space left in new upper
227cdf0e10cSrcweir                 if ( nSpace )
228cdf0e10cSrcweir                     return sal_True;
229cdf0e10cSrcweir                 else
230cdf0e10cSrcweir                     return sal_False;
231cdf0e10cSrcweir             }
232cdf0e10cSrcweir 		}
233cdf0e10cSrcweir 	}
234cdf0e10cSrcweir 	return  sal_False;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
237cdf0e10cSrcweir //------------------------------------------------------------------------
238cdf0e10cSrcweir //				Calc-Methoden
239cdf0e10cSrcweir //------------------------------------------------------------------------
240cdf0e10cSrcweir 
241cdf0e10cSrcweir /*************************************************************************
242cdf0e10cSrcweir |*
243cdf0e10cSrcweir |*	SwFrm::Prepare()
244cdf0e10cSrcweir |*
245cdf0e10cSrcweir |*	Beschreibung		Bereitet den Frm auf die 'Formatierung' (MakeAll())
246cdf0e10cSrcweir |*		vor. Diese Methode dient dazu auf dem Stack Platz einzusparen,
247cdf0e10cSrcweir |*		denn zur Positionsberechnung des Frm muss sichergestellt sein, dass
248cdf0e10cSrcweir |*		die Position von Upper und Prev gueltig sind, mithin also ein
249cdf0e10cSrcweir |*		rekursiver Aufruf (Schleife waere relativ teuer, da selten notwendig).
250cdf0e10cSrcweir |*		Jeder Aufruf von MakeAll verbraucht aber ca. 500Byte Stack -
251cdf0e10cSrcweir |*		das Ende ist leicht abzusehen. _Prepare benoetigt nur wenig Stack,
252cdf0e10cSrcweir |*		deshalb solle der Rekursive Aufruf hier kein Problem sein.
253cdf0e10cSrcweir |*		Ein weiterer Vorteil ist, das eines schoenen Tages das _Prepare und
254cdf0e10cSrcweir |*		damit die Formatierung von Vorgaengern umgangen werden kann.
255cdf0e10cSrcweir |*		So kann evtl. mal 'schnell' an's Dokumentende gesprungen werden.
256cdf0e10cSrcweir |*	Ersterstellung		MA ??
257cdf0e10cSrcweir |*	Letzte Aenderung	MA 13. Dec. 93
258cdf0e10cSrcweir |*
259cdf0e10cSrcweir |*************************************************************************/
260cdf0e10cSrcweir //Zwei kleine Freundschaften werden hier zu einem Geheimbund.
PrepareLock(SwFlowFrm * pTab)261cdf0e10cSrcweir inline void PrepareLock( SwFlowFrm *pTab )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir 	pTab->LockJoin();
264cdf0e10cSrcweir }
PrepareUnlock(SwFlowFrm * pTab)265cdf0e10cSrcweir inline void PrepareUnlock( SwFlowFrm *pTab )
266cdf0e10cSrcweir {
267cdf0e10cSrcweir 	pTab->UnlockJoin();
268cdf0e10cSrcweir 
269cdf0e10cSrcweir }
270cdf0e10cSrcweir 
271cdf0e10cSrcweir // hopefully, one day this function simply will return 'false'
lcl_IsCalcUpperAllowed(const SwFrm & rFrm)272cdf0e10cSrcweir bool lcl_IsCalcUpperAllowed( const SwFrm& rFrm )
273cdf0e10cSrcweir {
274cdf0e10cSrcweir     return !rFrm.GetUpper()->IsSctFrm() &&
275cdf0e10cSrcweir            !rFrm.GetUpper()->IsFooterFrm() &&
276cdf0e10cSrcweir            // --> OD 2004-11-02 #i23129#, #i36347# - no format of upper Writer fly frame
277cdf0e10cSrcweir            !rFrm.GetUpper()->IsFlyFrm() &&
278cdf0e10cSrcweir            // <--
279cdf0e10cSrcweir            !( rFrm.GetUpper()->IsTabFrm() && rFrm.GetUpper()->GetUpper()->IsInTab() ) &&
280cdf0e10cSrcweir            !( rFrm.IsTabFrm() && rFrm.GetUpper()->IsInTab() );
281cdf0e10cSrcweir }
282cdf0e10cSrcweir 
PrepareMake()283cdf0e10cSrcweir void SwFrm::PrepareMake()
284cdf0e10cSrcweir {
285cdf0e10cSrcweir     StackHack aHack;
286cdf0e10cSrcweir 	if ( GetUpper() )
287cdf0e10cSrcweir 	{
288cdf0e10cSrcweir         if ( lcl_IsCalcUpperAllowed( *this ) )
289cdf0e10cSrcweir             GetUpper()->Calc();
290cdf0e10cSrcweir 		ASSERT( GetUpper(), ":-( Layoutgeruest wackelig (Upper wech)." );
291cdf0e10cSrcweir 		if ( !GetUpper() )
292cdf0e10cSrcweir 			return;
293cdf0e10cSrcweir 
294cdf0e10cSrcweir 		const sal_Bool bCnt = IsCntntFrm();
295cdf0e10cSrcweir 		const sal_Bool bTab = IsTabFrm();
296cdf0e10cSrcweir 		sal_Bool bNoSect = IsInSct();
297cdf0e10cSrcweir 		sal_Bool bOldTabLock = sal_False, bFoll = sal_False;
298cdf0e10cSrcweir 		SwFlowFrm* pThis = bCnt ? (SwCntntFrm*)this : NULL;
299cdf0e10cSrcweir 
300cdf0e10cSrcweir 		if ( bTab )
301cdf0e10cSrcweir 		{
302cdf0e10cSrcweir 			pThis = (SwTabFrm*)this;
303cdf0e10cSrcweir 			bOldTabLock = ((SwTabFrm*)this)->IsJoinLocked();
304cdf0e10cSrcweir 			::PrepareLock( (SwTabFrm*)this );
305cdf0e10cSrcweir 			bFoll = pThis->IsFollow();
306cdf0e10cSrcweir 		}
307cdf0e10cSrcweir 		else if( IsSctFrm() )
308cdf0e10cSrcweir 		{
309cdf0e10cSrcweir 			pThis = (SwSectionFrm*)this;
310cdf0e10cSrcweir 			bFoll = pThis->IsFollow();
311cdf0e10cSrcweir 			bNoSect = sal_False;
312cdf0e10cSrcweir 		}
313cdf0e10cSrcweir 		else if ( bCnt && sal_True == (bFoll = pThis->IsFollow()) &&
314cdf0e10cSrcweir 			 GetPrev() )
315cdf0e10cSrcweir 		{
316cdf0e10cSrcweir 			//Wenn der Master gereade ein CalcFollow ruft braucht die Kette
317cdf0e10cSrcweir 			//nicht durchlaufen werden. Das spart Zeit und vermeidet Probleme.
318cdf0e10cSrcweir 			if ( ((SwTxtFrm*)((SwTxtFrm*)this)->FindMaster())->IsLocked() )
319cdf0e10cSrcweir 			{
320cdf0e10cSrcweir 				MakeAll();
321cdf0e10cSrcweir 				return;
322cdf0e10cSrcweir 			}
323cdf0e10cSrcweir 		}
324cdf0e10cSrcweir 
325cdf0e10cSrcweir         // --> OD 2005-03-04 #i44049# - no format of previous frame, if current
326cdf0e10cSrcweir         // frame is a table frame and its previous frame wants to keep with it.
327cdf0e10cSrcweir         const bool bFormatPrev = !bTab ||
328cdf0e10cSrcweir                                  !GetPrev() ||
329cdf0e10cSrcweir                                  !GetPrev()->GetAttrSet()->GetKeep().GetValue();
330cdf0e10cSrcweir         if ( bFormatPrev )
331cdf0e10cSrcweir         {
332cdf0e10cSrcweir             SwFrm *pFrm = GetUpper()->Lower();
333cdf0e10cSrcweir             while ( pFrm != this )
334cdf0e10cSrcweir             {
335cdf0e10cSrcweir                 ASSERT( pFrm, ":-( Layoutgeruest wackelig (this not found)." );
336cdf0e10cSrcweir                 if ( !pFrm )
337cdf0e10cSrcweir                     return; //Oioioioi ...
338cdf0e10cSrcweir 
339cdf0e10cSrcweir                 if ( !pFrm->IsValid() )
340cdf0e10cSrcweir                 {
341cdf0e10cSrcweir                     //Ein kleiner Eingriff der hoffentlich etwas zur Verbesserung
342cdf0e10cSrcweir                     //der Stabilitaet beitraegt:
343cdf0e10cSrcweir                     //Wenn ich Follow _und_ Nachbar eines Frms vor mir bin,
344cdf0e10cSrcweir                     //so wuerde dieser mich beim Formatieren deleten; wie jeder
345cdf0e10cSrcweir                     //leicht sehen kann waere dies eine etwas unuebersichtliche
346cdf0e10cSrcweir                     //Situation die es zu vermeiden gilt.
347cdf0e10cSrcweir                     if ( bFoll && pFrm->IsFlowFrm() &&
348cdf0e10cSrcweir                          (SwFlowFrm::CastFlowFrm(pFrm))->IsAnFollow( pThis ) )
349cdf0e10cSrcweir                         break;
350cdf0e10cSrcweir 
351cdf0e10cSrcweir     //MA: 24. Mar. 94, Calc wuerde doch nur wieder in ein _Prepare laufen und so
352cdf0e10cSrcweir     //die ganze Kette nocheinmal abhuenern.
353cdf0e10cSrcweir     //              pFrm->Calc();
354cdf0e10cSrcweir                     pFrm->MakeAll();
355cdf0e10cSrcweir                     if( IsSctFrm() && !((SwSectionFrm*)this)->GetSection() )
356cdf0e10cSrcweir                         break;
357cdf0e10cSrcweir                 }
358cdf0e10cSrcweir                 //Die Kette kann bei CntntFrms waehrend des durchlaufens
359cdf0e10cSrcweir                 //aufgebrochen werden, deshalb muss der Nachfolger etwas
360cdf0e10cSrcweir                 //umstaendlich ermittelt werden. However, irgendwann _muss_
361cdf0e10cSrcweir                 //ich wieder bei mir selbst ankommen.
362cdf0e10cSrcweir                 pFrm = pFrm->FindNext();
363cdf0e10cSrcweir 
364cdf0e10cSrcweir                 //Wenn wir in einem SectionFrm gestartet sind, koennen wir durch die
365cdf0e10cSrcweir                 //MakeAll-Aufrufe in einen Section-Follow gewandert sein.
366cdf0e10cSrcweir                 //FindNext liefert allerdings den SectionFrm, nicht seinen Inhalt.
367cdf0e10cSrcweir                 // => wir finden uns selbst nicht mehr!
368cdf0e10cSrcweir                 if( bNoSect && pFrm && pFrm->IsSctFrm() )
369cdf0e10cSrcweir                 {
370cdf0e10cSrcweir                     SwFrm* pCnt = ((SwSectionFrm*)pFrm)->ContainsAny();
371cdf0e10cSrcweir                     if( pCnt )
372cdf0e10cSrcweir                         pFrm = pCnt;
373cdf0e10cSrcweir                 }
374cdf0e10cSrcweir             }
375cdf0e10cSrcweir             ASSERT( GetUpper(), "Layoutgeruest wackelig (Upper wech II)." );
376cdf0e10cSrcweir             if ( !GetUpper() )
377cdf0e10cSrcweir                 return;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir             if ( lcl_IsCalcUpperAllowed( *this ) )
380cdf0e10cSrcweir                 GetUpper()->Calc();
381cdf0e10cSrcweir 
382cdf0e10cSrcweir             ASSERT( GetUpper(), "Layoutgeruest wackelig (Upper wech III)." );
383cdf0e10cSrcweir         }
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 		if ( bTab && !bOldTabLock )
386cdf0e10cSrcweir 			::PrepareUnlock( (SwTabFrm*)this );
387cdf0e10cSrcweir 	}
388cdf0e10cSrcweir 	MakeAll();
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
OptPrepareMake()391cdf0e10cSrcweir void SwFrm::OptPrepareMake()
392cdf0e10cSrcweir {
393cdf0e10cSrcweir     // --> OD 2004-11-02 #i23129#, #i36347# - no format of upper Writer fly frame
394cdf0e10cSrcweir     if ( GetUpper() && !GetUpper()->IsFooterFrm() &&
395cdf0e10cSrcweir          !GetUpper()->IsFlyFrm() )
396cdf0e10cSrcweir     // <--
397cdf0e10cSrcweir 	{
398cdf0e10cSrcweir 		GetUpper()->Calc();
399cdf0e10cSrcweir 		ASSERT( GetUpper(), ":-( Layoutgeruest wackelig (Upper wech)." );
400cdf0e10cSrcweir 		if ( !GetUpper() )
401cdf0e10cSrcweir 			return;
402cdf0e10cSrcweir 	}
403cdf0e10cSrcweir 	if ( GetPrev() && !GetPrev()->IsValid() )
404cdf0e10cSrcweir 		PrepareMake();
405cdf0e10cSrcweir 	else
406cdf0e10cSrcweir 	{
407cdf0e10cSrcweir 		StackHack aHack;
408cdf0e10cSrcweir 		MakeAll();
409cdf0e10cSrcweir 	}
410cdf0e10cSrcweir }
411cdf0e10cSrcweir 
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 
PrepareCrsr()414cdf0e10cSrcweir void SwFrm::PrepareCrsr()
415cdf0e10cSrcweir {
416cdf0e10cSrcweir 	StackHack aHack;
417cdf0e10cSrcweir 	if( GetUpper() && !GetUpper()->IsSctFrm() )
418cdf0e10cSrcweir 	{
419cdf0e10cSrcweir 		GetUpper()->PrepareCrsr();
420cdf0e10cSrcweir 		GetUpper()->Calc();
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 		ASSERT( GetUpper(), ":-( Layoutgeruest wackelig (Upper wech)." );
423cdf0e10cSrcweir 		if ( !GetUpper() )
424cdf0e10cSrcweir 			return;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 		const sal_Bool bCnt = IsCntntFrm();
427cdf0e10cSrcweir 		const sal_Bool bTab = IsTabFrm();
428cdf0e10cSrcweir 		sal_Bool bNoSect = IsInSct();
429cdf0e10cSrcweir 
430cdf0e10cSrcweir 		sal_Bool bOldTabLock = sal_False, bFoll;
431cdf0e10cSrcweir 		SwFlowFrm* pThis = bCnt ? (SwCntntFrm*)this : NULL;
432cdf0e10cSrcweir 
433cdf0e10cSrcweir 		if ( bTab )
434cdf0e10cSrcweir 		{
435cdf0e10cSrcweir 			bOldTabLock = ((SwTabFrm*)this)->IsJoinLocked();
436cdf0e10cSrcweir 			::PrepareLock( (SwTabFrm*)this );
437cdf0e10cSrcweir 			pThis = (SwTabFrm*)this;
438cdf0e10cSrcweir 		}
439cdf0e10cSrcweir 		else if( IsSctFrm() )
440cdf0e10cSrcweir 		{
441cdf0e10cSrcweir 			pThis = (SwSectionFrm*)this;
442cdf0e10cSrcweir 			bNoSect = sal_False;
443cdf0e10cSrcweir 		}
444cdf0e10cSrcweir 		bFoll = pThis && pThis->IsFollow();
445cdf0e10cSrcweir 
446cdf0e10cSrcweir 		SwFrm *pFrm = GetUpper()->Lower();
447cdf0e10cSrcweir 		while ( pFrm != this )
448cdf0e10cSrcweir 		{
449cdf0e10cSrcweir 			ASSERT( pFrm, ":-( Layoutgeruest wackelig (this not found)." );
450cdf0e10cSrcweir 			if ( !pFrm )
451cdf0e10cSrcweir 				return;	//Oioioioi ...
452cdf0e10cSrcweir 
453cdf0e10cSrcweir 			if ( !pFrm->IsValid() )
454cdf0e10cSrcweir 			{
455cdf0e10cSrcweir 				//Ein kleiner Eingriff der hoffentlich etwas zur Verbesserung
456cdf0e10cSrcweir 				//der Stabilitaet beitraegt:
457cdf0e10cSrcweir 				//Wenn ich Follow _und_ Nachbar eines Frms vor mir bin,
458cdf0e10cSrcweir 				//so wuerde dieser mich beim Formatieren deleten; wie jeder
459cdf0e10cSrcweir 				//leicht sehen kann waere dies eine etwas unuebersichtliche
460cdf0e10cSrcweir 				//Situation die es zu vermeiden gilt.
461cdf0e10cSrcweir 				if ( bFoll && pFrm->IsFlowFrm() &&
462cdf0e10cSrcweir 					 (SwFlowFrm::CastFlowFrm(pFrm))->IsAnFollow( pThis ) )
463cdf0e10cSrcweir 					break;
464cdf0e10cSrcweir 
465cdf0e10cSrcweir 				pFrm->MakeAll();
466cdf0e10cSrcweir 			}
467cdf0e10cSrcweir 			//Die Kette kann bei CntntFrms waehrend des durchlaufens
468cdf0e10cSrcweir 			//aufgebrochen werden, deshalb muss der Nachfolger etwas
469cdf0e10cSrcweir 			//umstaendlich ermittelt werden. However, irgendwann _muss_
470cdf0e10cSrcweir 			//ich wieder bei mir selbst ankommen.
471cdf0e10cSrcweir 			pFrm = pFrm->FindNext();
472cdf0e10cSrcweir 			if( bNoSect && pFrm && pFrm->IsSctFrm() )
473cdf0e10cSrcweir 			{
474cdf0e10cSrcweir 				SwFrm* pCnt = ((SwSectionFrm*)pFrm)->ContainsAny();
475cdf0e10cSrcweir 				if( pCnt )
476cdf0e10cSrcweir 					pFrm = pCnt;
477cdf0e10cSrcweir 			}
478cdf0e10cSrcweir 		}
479cdf0e10cSrcweir 		ASSERT( GetUpper(), "Layoutgeruest wackelig (Upper wech II)." );
480cdf0e10cSrcweir 		if ( !GetUpper() )
481cdf0e10cSrcweir 			return;
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 		GetUpper()->Calc();
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 		ASSERT( GetUpper(), "Layoutgeruest wackelig (Upper wech III)." );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir 		if ( bTab && !bOldTabLock )
488cdf0e10cSrcweir 			::PrepareUnlock( (SwTabFrm*)this );
489cdf0e10cSrcweir 	}
490cdf0e10cSrcweir 	Calc();
491cdf0e10cSrcweir }
492cdf0e10cSrcweir 
493cdf0e10cSrcweir /*************************************************************************
494cdf0e10cSrcweir |*
495cdf0e10cSrcweir |*	SwFrm::MakePos()
496cdf0e10cSrcweir |*
497cdf0e10cSrcweir |*	Ersterstellung		MA ??
498cdf0e10cSrcweir |*	Letzte Aenderung	MA 24. May. 93
499cdf0e10cSrcweir |*
500cdf0e10cSrcweir |*************************************************************************/
501cdf0e10cSrcweir 
502cdf0e10cSrcweir // Hier wird GetPrev() zurueckgegeben, allerdings werden
503cdf0e10cSrcweir // dabei leere SectionFrms ueberlesen
lcl_Prev(SwFrm * pFrm,sal_Bool bSectPrv=sal_True)504cdf0e10cSrcweir SwFrm* lcl_Prev( SwFrm* pFrm, sal_Bool bSectPrv = sal_True )
505cdf0e10cSrcweir {
506cdf0e10cSrcweir 	SwFrm* pRet = pFrm->GetPrev();
507cdf0e10cSrcweir 	if( !pRet && pFrm->GetUpper() && pFrm->GetUpper()->IsSctFrm() &&
508cdf0e10cSrcweir 		bSectPrv && !pFrm->IsColumnFrm() )
509cdf0e10cSrcweir 		pRet = pFrm->GetUpper()->GetPrev();
510cdf0e10cSrcweir 	while( pRet && pRet->IsSctFrm() &&
511cdf0e10cSrcweir 		   !((SwSectionFrm*)pRet)->GetSection() )
512cdf0e10cSrcweir 		pRet = pRet->GetPrev();
513cdf0e10cSrcweir 	return pRet;
514cdf0e10cSrcweir }
515cdf0e10cSrcweir 
lcl_NotHiddenPrev(SwFrm * pFrm)516cdf0e10cSrcweir SwFrm* lcl_NotHiddenPrev( SwFrm* pFrm )
517cdf0e10cSrcweir {
518cdf0e10cSrcweir 	SwFrm *pRet = pFrm;
519cdf0e10cSrcweir 	do
520cdf0e10cSrcweir 	{
521cdf0e10cSrcweir 		pRet = lcl_Prev( pRet );
522cdf0e10cSrcweir 	} while ( pRet && pRet->IsTxtFrm() && ((SwTxtFrm*)pRet)->IsHiddenNow() );
523cdf0e10cSrcweir 	return pRet;
524cdf0e10cSrcweir }
525cdf0e10cSrcweir 
MakePos()526cdf0e10cSrcweir void SwFrm::MakePos()
527cdf0e10cSrcweir {
528cdf0e10cSrcweir 	if ( !bValidPos )
529cdf0e10cSrcweir 	{
530cdf0e10cSrcweir 		bValidPos = sal_True;
531cdf0e10cSrcweir 		sal_Bool bUseUpper = sal_False;
532cdf0e10cSrcweir 		SwFrm* pPrv = lcl_Prev( this );
533cdf0e10cSrcweir         if ( pPrv &&
534cdf0e10cSrcweir              ( !pPrv->IsCntntFrm() ||
535cdf0e10cSrcweir                ( ((SwCntntFrm*)pPrv)->GetFollow() != this ) )
536cdf0e10cSrcweir            )
537cdf0e10cSrcweir 		{
538cdf0e10cSrcweir             if ( !StackHack::IsLocked() &&
539cdf0e10cSrcweir                  ( !IsInSct() || IsSctFrm() ) &&
540cdf0e10cSrcweir                  !pPrv->IsSctFrm() &&
541cdf0e10cSrcweir                  !pPrv->GetAttrSet()->GetKeep().GetValue()
542cdf0e10cSrcweir                )
543cdf0e10cSrcweir             {
544cdf0e10cSrcweir 				pPrv->Calc();	//hierbei kann der Prev verschwinden!
545cdf0e10cSrcweir             }
546cdf0e10cSrcweir 			else if ( pPrv->Frm().Top() == 0 )
547cdf0e10cSrcweir             {
548cdf0e10cSrcweir 				bUseUpper = sal_True;
549cdf0e10cSrcweir             }
550cdf0e10cSrcweir 		}
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 		pPrv = lcl_Prev( this, sal_False );
553cdf0e10cSrcweir         sal_uInt16 nMyType = GetType();
554cdf0e10cSrcweir         SWRECTFN( ( IsCellFrm() && GetUpper() ? GetUpper() : this  ) )
555cdf0e10cSrcweir         if ( !bUseUpper && pPrv )
556cdf0e10cSrcweir         {
557cdf0e10cSrcweir             aFrm.Pos( pPrv->Frm().Pos() );
558cdf0e10cSrcweir             if( FRM_NEIGHBOUR & nMyType )
559cdf0e10cSrcweir             {
560cdf0e10cSrcweir                 sal_Bool bR2L = IsRightToLeft();
561cdf0e10cSrcweir                 if( bR2L )
562cdf0e10cSrcweir                     (aFrm.*fnRect->fnSetPosX)( (aFrm.*fnRect->fnGetLeft)() -
563cdf0e10cSrcweir                                                (aFrm.*fnRect->fnGetWidth)() );
564cdf0e10cSrcweir                 else
565cdf0e10cSrcweir                     (aFrm.*fnRect->fnSetPosX)( (aFrm.*fnRect->fnGetLeft)() +
566cdf0e10cSrcweir                                           (pPrv->Frm().*fnRect->fnGetWidth)() );
567cdf0e10cSrcweir 
568cdf0e10cSrcweir                 // cells may now leave their uppers
569cdf0e10cSrcweir                 if( bVert && FRM_CELL & nMyType && !bReverse )
570cdf0e10cSrcweir                     aFrm.Pos().X() -= aFrm.Width() -pPrv->Frm().Width();
571cdf0e10cSrcweir             }
572cdf0e10cSrcweir             else if( bVert && FRM_NOTE_VERT & nMyType )
573cdf0e10cSrcweir             {
574cdf0e10cSrcweir                 if( bReverse )
575cdf0e10cSrcweir                     aFrm.Pos().X() += pPrv->Frm().Width();
576cdf0e10cSrcweir                 else
577cdf0e10cSrcweir                     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
578cdf0e10cSrcweir                 {
579cdf0e10cSrcweir 					if ( bVertL2R )
580cdf0e10cSrcweir                    		aFrm.Pos().X() += pPrv->Frm().Width();
581cdf0e10cSrcweir                 	else
582cdf0e10cSrcweir                    		aFrm.Pos().X() -= aFrm.Width();
583cdf0e10cSrcweir               	}
584cdf0e10cSrcweir             }
585cdf0e10cSrcweir             else
586cdf0e10cSrcweir                 aFrm.Pos().Y() += pPrv->Frm().Height();
587cdf0e10cSrcweir         }
588cdf0e10cSrcweir 		else if ( GetUpper() )
589cdf0e10cSrcweir 		{
590cdf0e10cSrcweir             // OD 15.10.2002 #103517# - add safeguard for <SwFooterFrm::Calc()>
591cdf0e10cSrcweir             // If parent frame is a footer frame and its <ColLocked()>, then
592cdf0e10cSrcweir             // do *not* calculate it.
593cdf0e10cSrcweir             // NOTE: Footer frame is <ColLocked()> during its
594cdf0e10cSrcweir             //     <FormatSize(..)>, which is called from <Format(..)>, which
595cdf0e10cSrcweir             //     is called from <MakeAll()>, which is called from <Calc()>.
596cdf0e10cSrcweir             // --> OD 2005-11-17 #i56850#
597cdf0e10cSrcweir             // - no format of upper Writer fly frame, which is anchored
598cdf0e10cSrcweir             //   at-paragraph or at-character.
599cdf0e10cSrcweir             if ( !GetUpper()->IsTabFrm() &&
600cdf0e10cSrcweir                  !( IsTabFrm() && GetUpper()->IsInTab() ) &&
601cdf0e10cSrcweir                  !GetUpper()->IsSctFrm() &&
602cdf0e10cSrcweir                  !dynamic_cast<SwFlyAtCntFrm*>(GetUpper()) &&
603cdf0e10cSrcweir                  !( GetUpper()->IsFooterFrm() &&
604cdf0e10cSrcweir                     GetUpper()->IsColLocked() )
605cdf0e10cSrcweir                )
606cdf0e10cSrcweir             {
607cdf0e10cSrcweir                 GetUpper()->Calc();
608cdf0e10cSrcweir             }
609cdf0e10cSrcweir             // <--
610cdf0e10cSrcweir 			pPrv = lcl_Prev( this, sal_False );
611cdf0e10cSrcweir 			if ( !bUseUpper && pPrv )
612cdf0e10cSrcweir             {
613cdf0e10cSrcweir                 aFrm.Pos( pPrv->Frm().Pos() );
614cdf0e10cSrcweir                 if( FRM_NEIGHBOUR & nMyType )
615cdf0e10cSrcweir                 {
616cdf0e10cSrcweir                     sal_Bool bR2L = IsRightToLeft();
617cdf0e10cSrcweir                     if( bR2L )
618cdf0e10cSrcweir                         (aFrm.*fnRect->fnSetPosX)( (aFrm.*fnRect->fnGetLeft)() -
619cdf0e10cSrcweir                                                  (aFrm.*fnRect->fnGetWidth)() );
620cdf0e10cSrcweir                     else
621cdf0e10cSrcweir                         (aFrm.*fnRect->fnSetPosX)( (aFrm.*fnRect->fnGetLeft)() +
622cdf0e10cSrcweir                                           (pPrv->Frm().*fnRect->fnGetWidth)() );
623cdf0e10cSrcweir 
624cdf0e10cSrcweir                     // cells may now leave their uppers
625cdf0e10cSrcweir                     if( bVert && FRM_CELL & nMyType && !bReverse )
626cdf0e10cSrcweir                         aFrm.Pos().X() -= aFrm.Width() -pPrv->Frm().Width();
627cdf0e10cSrcweir                 }
628cdf0e10cSrcweir                 else if( bVert && FRM_NOTE_VERT & nMyType )
629cdf0e10cSrcweir                 {
630cdf0e10cSrcweir                     if( bReverse )
631cdf0e10cSrcweir                         aFrm.Pos().X() += pPrv->Frm().Width();
632cdf0e10cSrcweir                     else
633cdf0e10cSrcweir                         aFrm.Pos().X() -= aFrm.Width();
634cdf0e10cSrcweir                 }
635cdf0e10cSrcweir                 else
636cdf0e10cSrcweir                     aFrm.Pos().Y() += pPrv->Frm().Height();
637cdf0e10cSrcweir 			}
638cdf0e10cSrcweir 			else
639cdf0e10cSrcweir 			{
640cdf0e10cSrcweir 				aFrm.Pos( GetUpper()->Frm().Pos() );
641cdf0e10cSrcweir 				aFrm.Pos() += GetUpper()->Prt().Pos();
642cdf0e10cSrcweir                 if( FRM_NEIGHBOUR & nMyType && IsRightToLeft() )
643cdf0e10cSrcweir                 {
644cdf0e10cSrcweir                     if( bVert )
645cdf0e10cSrcweir                         aFrm.Pos().Y() += GetUpper()->Prt().Height()
646cdf0e10cSrcweir                                           - aFrm.Height();
647cdf0e10cSrcweir                     else
648cdf0e10cSrcweir                         aFrm.Pos().X() += GetUpper()->Prt().Width()
649cdf0e10cSrcweir                                           - aFrm.Width();
650cdf0e10cSrcweir                 }
651cdf0e10cSrcweir                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
652cdf0e10cSrcweir                 else if( bVert && !bVertL2R && FRM_NOTE_VERT & nMyType && !bReverse )
653cdf0e10cSrcweir                     aFrm.Pos().X() -= aFrm.Width() - GetUpper()->Prt().Width();
654cdf0e10cSrcweir 			}
655cdf0e10cSrcweir 		}
656cdf0e10cSrcweir 		else
657cdf0e10cSrcweir 			aFrm.Pos().X() = aFrm.Pos().Y() = 0;
658cdf0e10cSrcweir         //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
659cdf0e10cSrcweir         if( IsBodyFrm() && bVert && !bVertL2R && !bReverse && GetUpper() )
660cdf0e10cSrcweir             aFrm.Pos().X() += GetUpper()->Prt().Width() - aFrm.Width();
661cdf0e10cSrcweir 		bValidPos = sal_True;
662cdf0e10cSrcweir 	}
663cdf0e10cSrcweir }
664cdf0e10cSrcweir 
665cdf0e10cSrcweir /*************************************************************************
666cdf0e10cSrcweir |*
667cdf0e10cSrcweir |*	SwPageFrm::MakeAll()
668cdf0e10cSrcweir |*
669cdf0e10cSrcweir |*	Ersterstellung		MA 23. Feb. 93
670cdf0e10cSrcweir |*	Letzte Aenderung	MA 20. Jul. 98
671cdf0e10cSrcweir |*
672cdf0e10cSrcweir |*************************************************************************/
673cdf0e10cSrcweir // --> OD 2004-07-01 #i28701# - new type <SwSortedObjs>
lcl_CheckObjects(SwSortedObjs * pSortedObjs,SwFrm * pFrm,long & rBot)674cdf0e10cSrcweir void lcl_CheckObjects( SwSortedObjs* pSortedObjs, SwFrm* pFrm, long& rBot )
675cdf0e10cSrcweir {
676cdf0e10cSrcweir 	//Und dann kann es natuerlich noch Absatzgebundene
677cdf0e10cSrcweir 	//Rahmen geben, die unterhalb ihres Absatzes stehen.
678cdf0e10cSrcweir 	long nMax = 0;
679cdf0e10cSrcweir 	for ( sal_uInt16 i = 0; i < pSortedObjs->Count(); ++i )
680cdf0e10cSrcweir 	{
681cdf0e10cSrcweir         // --> OD 2004-07-01 #i28701# - consider changed type of <SwSortedObjs>
682cdf0e10cSrcweir         // entries.
683cdf0e10cSrcweir         SwAnchoredObject* pObj = (*pSortedObjs)[i];
684cdf0e10cSrcweir 		long nTmp = 0;
685cdf0e10cSrcweir         if ( pObj->ISA(SwFlyFrm) )
686cdf0e10cSrcweir 		{
687cdf0e10cSrcweir             SwFlyFrm *pFly = static_cast<SwFlyFrm*>(pObj);
688cdf0e10cSrcweir 			if( pFly->Frm().Top() != WEIT_WECH &&
689cdf0e10cSrcweir 				( pFrm->IsPageFrm() ? pFly->IsFlyLayFrm() :
690cdf0e10cSrcweir 				  ( pFly->IsFlyAtCntFrm() &&
691cdf0e10cSrcweir                     ( pFrm->IsBodyFrm() ? pFly->GetAnchorFrm()->IsInDocBody() :
692cdf0e10cSrcweir                                           pFly->GetAnchorFrm()->IsInFtn() ) ) ) )
693cdf0e10cSrcweir 			{
694cdf0e10cSrcweir 				nTmp = pFly->Frm().Bottom();
695cdf0e10cSrcweir 			}
696cdf0e10cSrcweir 		}
697cdf0e10cSrcweir 		else
698cdf0e10cSrcweir             nTmp = pObj->GetObjRect().Bottom();
699cdf0e10cSrcweir 		nMax = Max( nTmp, nMax );
700cdf0e10cSrcweir         // <--
701cdf0e10cSrcweir 	}
702cdf0e10cSrcweir 	++nMax; //Unterkante vs. Hoehe!
703cdf0e10cSrcweir 	rBot = Max( rBot, nMax );
704cdf0e10cSrcweir }
705cdf0e10cSrcweir 
MakeAll()706cdf0e10cSrcweir void SwPageFrm::MakeAll()
707cdf0e10cSrcweir {
708cdf0e10cSrcweir 	PROTOCOL_ENTER( this, PROT_MAKEALL, 0, 0 )
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 	const SwRect aOldRect( Frm() );		//Anpassung der Root-Groesse
711cdf0e10cSrcweir 	const SwLayNotify aNotify( this );	//uebernimmt im DTor die Benachrichtigung
712cdf0e10cSrcweir 	SwBorderAttrAccess *pAccess = 0;
713cdf0e10cSrcweir 	const SwBorderAttrs*pAttrs = 0;
714cdf0e10cSrcweir 
715cdf0e10cSrcweir     while ( !bValidPos || !bValidSize || !bValidPrtArea )
716cdf0e10cSrcweir 	{
717cdf0e10cSrcweir 		if ( !bValidPos )
718cdf0e10cSrcweir 		{
719cdf0e10cSrcweir             // PAGES01
720cdf0e10cSrcweir             bValidPos = sal_True; // positioning of the pages is taken care of by the root frame
721cdf0e10cSrcweir         }
722cdf0e10cSrcweir 
723cdf0e10cSrcweir 		if ( !bValidSize || !bValidPrtArea )
724cdf0e10cSrcweir 		{
725cdf0e10cSrcweir 			if ( IsEmptyPage() )
726cdf0e10cSrcweir 			{
727cdf0e10cSrcweir 				Frm().Width( 0 );  Prt().Width( 0 );
728cdf0e10cSrcweir 				Frm().Height( 0 ); Prt().Height( 0 );
729cdf0e10cSrcweir 				Prt().Left( 0 );   Prt().Top( 0 );
730cdf0e10cSrcweir 				bValidSize = bValidPrtArea = sal_True;
731cdf0e10cSrcweir 			}
732cdf0e10cSrcweir 			else
733cdf0e10cSrcweir 			{
734cdf0e10cSrcweir 				if ( !pAccess )
735cdf0e10cSrcweir 				{
736cdf0e10cSrcweir 					pAccess = new SwBorderAttrAccess( SwFrm::GetCache(), this );
737cdf0e10cSrcweir 					pAttrs = pAccess->Get();
738cdf0e10cSrcweir 				}
739cdf0e10cSrcweir 				//Bei der BrowseView gelten feste Einstellungen.
740cdf0e10cSrcweir 				ViewShell *pSh = getRootFrm()->GetCurrShell();
741cdf0e10cSrcweir                 if ( pSh && pSh->GetViewOptions()->getBrowseMode() )
742cdf0e10cSrcweir 				{
743cdf0e10cSrcweir 					const Size aBorder = pSh->GetOut()->PixelToLogic( pSh->GetBrowseBorder() );
744cdf0e10cSrcweir 					const long nTop    = pAttrs->CalcTopLine()   + aBorder.Height();
745cdf0e10cSrcweir 					const long nBottom = pAttrs->CalcBottomLine()+ aBorder.Height();
746cdf0e10cSrcweir 
747cdf0e10cSrcweir 					long nWidth = GetUpper() ? ((SwRootFrm*)GetUpper())->GetBrowseWidth() : 0;
748cdf0e10cSrcweir 					if ( nWidth < pSh->GetBrowseWidth() )
749cdf0e10cSrcweir 						nWidth = pSh->GetBrowseWidth();
750cdf0e10cSrcweir 					nWidth += + 2 * aBorder.Width();
751cdf0e10cSrcweir /*
752cdf0e10cSrcweir 					long nWidth = GetUpper() ? ((SwRootFrm*)GetUpper())->GetBrowseWidth() + 2 * aBorder.Width() : 0;
753cdf0e10cSrcweir 					if ( nWidth < pSh->VisArea().Width() )
754cdf0e10cSrcweir 						nWidth = pSh->VisArea().Width(); */
755cdf0e10cSrcweir 
756cdf0e10cSrcweir 					nWidth = Max( nWidth, 2L * aBorder.Width() + 4L*MM50 );
757cdf0e10cSrcweir 					Frm().Width( nWidth );
758cdf0e10cSrcweir 
759cdf0e10cSrcweir 					SwLayoutFrm *pBody = FindBodyCont();
760cdf0e10cSrcweir 					if ( pBody && pBody->Lower() && pBody->Lower()->IsColumnFrm() )
761cdf0e10cSrcweir 					{
762cdf0e10cSrcweir 						//Fuer Spalten gilt eine feste Hoehe
763cdf0e10cSrcweir 						Frm().Height( pAttrs->GetSize().Height() );
764cdf0e10cSrcweir 					}
765cdf0e10cSrcweir 					else
766cdf0e10cSrcweir 					{
767cdf0e10cSrcweir 						//Fuer Seiten ohne Spalten bestimmt der Inhalt die
768cdf0e10cSrcweir 						//Groesse.
769cdf0e10cSrcweir 						long nBot = Frm().Top() + nTop;
770cdf0e10cSrcweir 						SwFrm *pFrm = Lower();
771cdf0e10cSrcweir 						while ( pFrm )
772cdf0e10cSrcweir 						{
773cdf0e10cSrcweir 							long nTmp = 0;
774cdf0e10cSrcweir 							SwFrm *pCnt = ((SwLayoutFrm*)pFrm)->ContainsAny();
775cdf0e10cSrcweir 							while ( pCnt && (pCnt->GetUpper() == pFrm ||
776cdf0e10cSrcweir 											 ((SwLayoutFrm*)pFrm)->IsAnLower( pCnt )))
777cdf0e10cSrcweir 							{
778cdf0e10cSrcweir 								nTmp += pCnt->Frm().Height();
779cdf0e10cSrcweir 								if( pCnt->IsTxtFrm() &&
780cdf0e10cSrcweir 									((SwTxtFrm*)pCnt)->IsUndersized() )
781cdf0e10cSrcweir 									nTmp += ((SwTxtFrm*)pCnt)->GetParHeight()
782cdf0e10cSrcweir 											- pCnt->Prt().Height();
783cdf0e10cSrcweir 								else if( pCnt->IsSctFrm() &&
784cdf0e10cSrcweir 										 ((SwSectionFrm*)pCnt)->IsUndersized() )
785cdf0e10cSrcweir 									nTmp += ((SwSectionFrm*)pCnt)->Undersize();
786cdf0e10cSrcweir 								pCnt = pCnt->FindNext();
787cdf0e10cSrcweir 							}
788cdf0e10cSrcweir                             // OD 29.10.2002 #97265# - consider invalid body frame properties
789cdf0e10cSrcweir                             if ( pFrm->IsBodyFrm() &&
790cdf0e10cSrcweir                                  ( !pFrm->GetValidSizeFlag() ||
791cdf0e10cSrcweir                                    !pFrm->GetValidPrtAreaFlag() ) &&
792cdf0e10cSrcweir                                  ( pFrm->Frm().Height() < pFrm->Prt().Height() )
793cdf0e10cSrcweir                                )
794cdf0e10cSrcweir                             {
795cdf0e10cSrcweir                                 nTmp = Min( nTmp, pFrm->Frm().Height() );
796cdf0e10cSrcweir                             }
797cdf0e10cSrcweir                             else
798cdf0e10cSrcweir                             {
799cdf0e10cSrcweir                                 // OD 30.10.2002 #97265# - assert invalid lower property
800cdf0e10cSrcweir                                 ASSERT( !(pFrm->Frm().Height() < pFrm->Prt().Height()),
801cdf0e10cSrcweir                                         "SwPageFrm::MakeAll(): Lower with frame height < printing height" );
802cdf0e10cSrcweir                                 nTmp += pFrm->Frm().Height() - pFrm->Prt().Height();
803cdf0e10cSrcweir                             }
804cdf0e10cSrcweir 							if ( !pFrm->IsBodyFrm() )
805cdf0e10cSrcweir 								nTmp = Min( nTmp, pFrm->Frm().Height() );
806cdf0e10cSrcweir 							nBot += nTmp;
807cdf0e10cSrcweir 							// Hier werden die absatzgebundenen Objekte ueberprueft,
808cdf0e10cSrcweir 							// ob sie ueber den Body/FtnCont hinausragen.
809cdf0e10cSrcweir 							if( pSortedObjs && !pFrm->IsHeaderFrm() &&
810cdf0e10cSrcweir 								!pFrm->IsFooterFrm() )
811cdf0e10cSrcweir 								lcl_CheckObjects( pSortedObjs, pFrm, nBot );
812cdf0e10cSrcweir 							pFrm = pFrm->GetNext();
813cdf0e10cSrcweir 						}
814cdf0e10cSrcweir 						nBot += nBottom;
815cdf0e10cSrcweir 						//Und die Seitengebundenen
816cdf0e10cSrcweir 						if ( pSortedObjs )
817cdf0e10cSrcweir 							lcl_CheckObjects( pSortedObjs, this, nBot );
818cdf0e10cSrcweir 						nBot -= Frm().Top();
819cdf0e10cSrcweir                         // --> OD 2004-11-10 #i35143# - If second page frame
820cdf0e10cSrcweir                         // exists, the first page doesn't have to fulfill the
821cdf0e10cSrcweir                         // visible area.
822cdf0e10cSrcweir                         if ( !GetPrev() && !GetNext() )
823cdf0e10cSrcweir                         // <--
824cdf0e10cSrcweir                         {
825cdf0e10cSrcweir                             nBot = Max( nBot, pSh->VisArea().Height() );
826cdf0e10cSrcweir                         }
827cdf0e10cSrcweir                         // --> OD 2004-11-10 #i35143# - Assure, that the page
828cdf0e10cSrcweir                         // doesn't exceed the defined browse height.
829cdf0e10cSrcweir                         Frm().Height( Min( nBot, BROWSE_HEIGHT ) );
830cdf0e10cSrcweir                         // <--
831cdf0e10cSrcweir 					}
832cdf0e10cSrcweir 					Prt().Left ( pAttrs->CalcLeftLine() + aBorder.Width() );
833cdf0e10cSrcweir 					Prt().Top  ( nTop );
834cdf0e10cSrcweir 					Prt().Width( Frm().Width() - ( Prt().Left()
835cdf0e10cSrcweir 						+ pAttrs->CalcRightLine() + aBorder.Width() ) );
836cdf0e10cSrcweir 					Prt().Height( Frm().Height() - (nTop + nBottom) );
837cdf0e10cSrcweir 					bValidSize = bValidPrtArea = sal_True;
838cdf0e10cSrcweir 				}
839cdf0e10cSrcweir 				else
840cdf0e10cSrcweir 				{	//FixSize einstellen, bei Seiten nicht vom Upper sondern vom
841cdf0e10cSrcweir 					//Attribut vorgegeben.
842cdf0e10cSrcweir 					Frm().SSize( pAttrs->GetSize() );
843cdf0e10cSrcweir 					Format( pAttrs );
844cdf0e10cSrcweir 				}
845cdf0e10cSrcweir 			}
846cdf0e10cSrcweir 		}
847cdf0e10cSrcweir 	} //while ( !bValidPos || !bValidSize || !bValidPrtArea )
848cdf0e10cSrcweir 	delete pAccess;
849cdf0e10cSrcweir 
850cdf0e10cSrcweir     // PAGES01
851cdf0e10cSrcweir     if ( Frm() != aOldRect && GetUpper() )
852cdf0e10cSrcweir         static_cast<SwRootFrm*>(GetUpper())->CheckViewLayout( 0, 0 );
853cdf0e10cSrcweir 
854cdf0e10cSrcweir #ifdef DBG_UTIL
855cdf0e10cSrcweir 	//Der Upper (Root) muss mindestens so breit
856cdf0e10cSrcweir 	//sein, dass er die breiteste Seite aufnehmen kann.
857cdf0e10cSrcweir 	if ( GetUpper() )
858cdf0e10cSrcweir     {
859cdf0e10cSrcweir         ASSERT( GetUpper()->Prt().Width() >= aFrm.Width(), "Rootsize" );
860cdf0e10cSrcweir 	}
861cdf0e10cSrcweir #endif
862cdf0e10cSrcweir }
863cdf0e10cSrcweir 
864cdf0e10cSrcweir /*************************************************************************
865cdf0e10cSrcweir |*
866cdf0e10cSrcweir |*	SwLayoutFrm::MakeAll()
867cdf0e10cSrcweir |*
868cdf0e10cSrcweir |*	Ersterstellung		MA ??
869cdf0e10cSrcweir |*	Letzte Aenderung	MA 28. Nov. 95
870cdf0e10cSrcweir |*
871cdf0e10cSrcweir |*************************************************************************/
872cdf0e10cSrcweir 
873cdf0e10cSrcweir 
MakeAll()874cdf0e10cSrcweir void SwLayoutFrm::MakeAll()
875cdf0e10cSrcweir {
876cdf0e10cSrcweir 	PROTOCOL_ENTER( this, PROT_MAKEALL, 0, 0 )
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 		//uebernimmt im DTor die Benachrichtigung
879cdf0e10cSrcweir 	const SwLayNotify aNotify( this );
880cdf0e10cSrcweir     sal_Bool bVert = IsVertical();
881cdf0e10cSrcweir     //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
882cdf0e10cSrcweir     SwRectFn fnRect = ( IsNeighbourFrm() == bVert )? fnRectHori : ( IsVertLR() ? fnRectVertL2R : fnRectVert );
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 	SwBorderAttrAccess *pAccess = 0;
885cdf0e10cSrcweir 	const SwBorderAttrs*pAttrs = 0;
886cdf0e10cSrcweir 
887cdf0e10cSrcweir 	while ( !bValidPos || !bValidSize || !bValidPrtArea )
888cdf0e10cSrcweir 	{
889cdf0e10cSrcweir 		if ( !bValidPos )
890cdf0e10cSrcweir 			MakePos();
891cdf0e10cSrcweir 
892cdf0e10cSrcweir 		if ( GetUpper() )
893cdf0e10cSrcweir 		{
894cdf0e10cSrcweir             // NEW TABLES
895cdf0e10cSrcweir             if ( IsLeaveUpperAllowed() )
896cdf0e10cSrcweir             {
897cdf0e10cSrcweir                 if ( !bValidSize )
898cdf0e10cSrcweir                     bValidPrtArea = sal_False;
899cdf0e10cSrcweir             }
900cdf0e10cSrcweir             else
901cdf0e10cSrcweir             {
902cdf0e10cSrcweir                 if ( !bValidSize )
903cdf0e10cSrcweir                 {
904cdf0e10cSrcweir                     //FixSize einstellen, die VarSize wird von Format() nach
905cdf0e10cSrcweir                     //Berechnung der PrtArea eingestellt.
906cdf0e10cSrcweir                     bValidPrtArea = sal_False;
907cdf0e10cSrcweir 
908cdf0e10cSrcweir                     SwTwips nPrtWidth = (GetUpper()->Prt().*fnRect->fnGetWidth)();
909cdf0e10cSrcweir                     if( bVert && ( IsBodyFrm() || IsFtnContFrm() ) )
910cdf0e10cSrcweir                     {
911cdf0e10cSrcweir                         SwFrm* pNxt = GetPrev();
912cdf0e10cSrcweir                         while( pNxt && !pNxt->IsHeaderFrm() )
913cdf0e10cSrcweir                             pNxt = pNxt->GetPrev();
914cdf0e10cSrcweir                         if( pNxt )
915cdf0e10cSrcweir                             nPrtWidth -= pNxt->Frm().Height();
916cdf0e10cSrcweir                         pNxt = GetNext();
917cdf0e10cSrcweir                         while( pNxt && !pNxt->IsFooterFrm() )
918cdf0e10cSrcweir                             pNxt = pNxt->GetNext();
919cdf0e10cSrcweir                         if( pNxt )
920cdf0e10cSrcweir                             nPrtWidth -= pNxt->Frm().Height();
921cdf0e10cSrcweir                     }
922cdf0e10cSrcweir 
923cdf0e10cSrcweir                     const long nDiff = nPrtWidth - (Frm().*fnRect->fnGetWidth)();
924cdf0e10cSrcweir 
925cdf0e10cSrcweir                     if( IsNeighbourFrm() && IsRightToLeft() )
926cdf0e10cSrcweir                         (Frm().*fnRect->fnSubLeft)( nDiff );
927cdf0e10cSrcweir                     else
928cdf0e10cSrcweir                         (Frm().*fnRect->fnAddRight)( nDiff );
929cdf0e10cSrcweir                 }
930cdf0e10cSrcweir                 else
931cdf0e10cSrcweir                 {
932cdf0e10cSrcweir                     // Don't leave your upper
933cdf0e10cSrcweir                     const SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
934cdf0e10cSrcweir                     if( (Frm().*fnRect->fnOverStep)( nDeadLine ) )
935cdf0e10cSrcweir                         bValidSize = sal_False;
936cdf0e10cSrcweir                 }
937cdf0e10cSrcweir             }
938cdf0e10cSrcweir 		}
939cdf0e10cSrcweir 		if ( !bValidSize || !bValidPrtArea )
940cdf0e10cSrcweir 		{
941cdf0e10cSrcweir 			if ( !pAccess )
942cdf0e10cSrcweir 			{
943cdf0e10cSrcweir 				pAccess = new SwBorderAttrAccess( SwFrm::GetCache(), this );
944cdf0e10cSrcweir 				pAttrs  = pAccess->Get();
945cdf0e10cSrcweir 			}
946cdf0e10cSrcweir 			Format( pAttrs );
947cdf0e10cSrcweir 		}
948cdf0e10cSrcweir 	} //while ( !bValidPos || !bValidSize || !bValidPrtArea )
949cdf0e10cSrcweir 	if ( pAccess )
950cdf0e10cSrcweir 		delete pAccess;
951cdf0e10cSrcweir }
952cdf0e10cSrcweir 
953cdf0e10cSrcweir /*************************************************************************
954cdf0e10cSrcweir |*
955cdf0e10cSrcweir |*	SwCntntFrm::MakePrtArea()
956cdf0e10cSrcweir |*
957cdf0e10cSrcweir |*	Ersterstellung		MA 17. Nov. 92
958cdf0e10cSrcweir |*	Letzte Aenderung	MA 03. Mar. 96
959cdf0e10cSrcweir |*
960cdf0e10cSrcweir |*************************************************************************/
961cdf0e10cSrcweir 
MakePrtArea(const SwBorderAttrs & rAttrs)962cdf0e10cSrcweir sal_Bool SwCntntFrm::MakePrtArea( const SwBorderAttrs &rAttrs )
963cdf0e10cSrcweir {
964cdf0e10cSrcweir 	sal_Bool bSizeChgd = sal_False;
965cdf0e10cSrcweir 
966cdf0e10cSrcweir 	if ( !bValidPrtArea )
967cdf0e10cSrcweir 	{
968cdf0e10cSrcweir 		bValidPrtArea = sal_True;
969cdf0e10cSrcweir 
970cdf0e10cSrcweir         SWRECTFN( this )
971cdf0e10cSrcweir 		const sal_Bool bTxtFrm = IsTxtFrm();
972cdf0e10cSrcweir 		SwTwips nUpper = 0;
973cdf0e10cSrcweir 		if ( bTxtFrm && ((SwTxtFrm*)this)->IsHiddenNow() )
974cdf0e10cSrcweir 		{
975cdf0e10cSrcweir 			if ( ((SwTxtFrm*)this)->HasFollow() )
976cdf0e10cSrcweir 				((SwTxtFrm*)this)->JoinFrm();
977cdf0e10cSrcweir 
978cdf0e10cSrcweir             if( (Prt().*fnRect->fnGetHeight)() )
979cdf0e10cSrcweir 				((SwTxtFrm*)this)->HideHidden();
980cdf0e10cSrcweir             Prt().Pos().X() = Prt().Pos().Y() = 0;
981cdf0e10cSrcweir             (Prt().*fnRect->fnSetWidth)( (Frm().*fnRect->fnGetWidth)() );
982cdf0e10cSrcweir             (Prt().*fnRect->fnSetHeight)( 0 );
983cdf0e10cSrcweir             nUpper = -( (Frm().*fnRect->fnGetHeight)() );
984cdf0e10cSrcweir 		}
985cdf0e10cSrcweir 		else
986cdf0e10cSrcweir 		{
987cdf0e10cSrcweir 			//Vereinfachung: CntntFrms sind immer in der Hoehe Variabel!
988cdf0e10cSrcweir 
989cdf0e10cSrcweir 			//An der FixSize gibt der umgebende Frame die Groesse vor, die
990cdf0e10cSrcweir 			//Raender werden einfach abgezogen.
991cdf0e10cSrcweir             const long nLeft = rAttrs.CalcLeft( this );
992cdf0e10cSrcweir             const long nRight = ((SwBorderAttrs&)rAttrs).CalcRight( this );
993cdf0e10cSrcweir             (this->*fnRect->fnSetXMargins)( nLeft, nRight );
994cdf0e10cSrcweir 
995cdf0e10cSrcweir 			ViewShell *pSh = getRootFrm()->GetCurrShell();
996cdf0e10cSrcweir             SwTwips nWidthArea;
997cdf0e10cSrcweir             if( pSh && 0!=(nWidthArea=(pSh->VisArea().*fnRect->fnGetWidth)()) &&
998cdf0e10cSrcweir                 GetUpper()->IsPageBodyFrm() &&  // nicht dagegen bei BodyFrms in Columns
999cdf0e10cSrcweir                 pSh->GetViewOptions()->getBrowseMode() )
1000cdf0e10cSrcweir 			{
1001cdf0e10cSrcweir 				//Nicht ueber die Kante des sichbaren Bereiches hinausragen.
1002cdf0e10cSrcweir 				//Die Seite kann breiter sein, weil es Objekte mit "ueberbreite"
1003cdf0e10cSrcweir 				//geben kann (RootFrm::ImplCalcBrowseWidth())
1004cdf0e10cSrcweir 				long nMinWidth = 0;
1005cdf0e10cSrcweir 
1006cdf0e10cSrcweir 				for (sal_uInt16 i = 0; GetDrawObjs() && i < GetDrawObjs()->Count();++i)
1007cdf0e10cSrcweir 				{
1008cdf0e10cSrcweir                     // --> OD 2004-07-01 #i28701# - consider changed type of
1009cdf0e10cSrcweir                     // <SwSortedObjs> entries
1010cdf0e10cSrcweir                     SwAnchoredObject* pObj = (*GetDrawObjs())[i];
1011cdf0e10cSrcweir                     const SwFrmFmt& rFmt = pObj->GetFrmFmt();
1012cdf0e10cSrcweir                     const sal_Bool bFly = pObj->ISA(SwFlyFrm);
1013cdf0e10cSrcweir                     if ((bFly && (WEIT_WECH == pObj->GetObjRect().Width()))
1014cdf0e10cSrcweir                         || rFmt.GetFrmSize().GetWidthPercent())
1015cdf0e10cSrcweir                     {
1016cdf0e10cSrcweir 						continue;
1017cdf0e10cSrcweir                     }
1018cdf0e10cSrcweir 
1019cdf0e10cSrcweir                     if ( FLY_AS_CHAR == rFmt.GetAnchor().GetAnchorId() )
1020cdf0e10cSrcweir                     {
1021cdf0e10cSrcweir 						nMinWidth = Max( nMinWidth,
1022cdf0e10cSrcweir                                          bFly ? rFmt.GetFrmSize().GetWidth()
1023cdf0e10cSrcweir                                               : pObj->GetObjRect().Width() );
1024cdf0e10cSrcweir                     }
1025cdf0e10cSrcweir                     // <--
1026cdf0e10cSrcweir 				}
1027cdf0e10cSrcweir 
1028cdf0e10cSrcweir 				const Size aBorder = pSh->GetOut()->PixelToLogic( pSh->GetBrowseBorder() );
1029cdf0e10cSrcweir                 long nWidth = nWidthArea - 2 * ( IsVertical() ? aBorder.Height() : aBorder.Width() );
1030cdf0e10cSrcweir                 nWidth -= (Prt().*fnRect->fnGetLeft)();
1031cdf0e10cSrcweir 				nWidth -= rAttrs.CalcRightLine();
1032cdf0e10cSrcweir 				nWidth = Max( nMinWidth, nWidth );
1033cdf0e10cSrcweir                 (Prt().*fnRect->fnSetWidth)( Min( nWidth,
1034cdf0e10cSrcweir                                             (Prt().*fnRect->fnGetWidth)() ) );
1035cdf0e10cSrcweir 			}
1036cdf0e10cSrcweir 
1037cdf0e10cSrcweir             if ( (Prt().*fnRect->fnGetWidth)() <= MINLAY )
1038cdf0e10cSrcweir 			{
1039cdf0e10cSrcweir 				//Die PrtArea sollte schon wenigstens MINLAY breit sein, passend
1040cdf0e10cSrcweir 				//zu den Minimalwerten des UI
1041cdf0e10cSrcweir                 (Prt().*fnRect->fnSetWidth)( Min( long(MINLAY),
1042cdf0e10cSrcweir                                              (Frm().*fnRect->fnGetWidth)() ) );
1043cdf0e10cSrcweir                 SwTwips nTmp = (Frm().*fnRect->fnGetWidth)() -
1044cdf0e10cSrcweir                                (Prt().*fnRect->fnGetWidth)();
1045cdf0e10cSrcweir                 if( (Prt().*fnRect->fnGetLeft)() > nTmp )
1046cdf0e10cSrcweir                     (Prt().*fnRect->fnSetLeft)( nTmp );
1047cdf0e10cSrcweir 			}
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir 			//Fuer die VarSize gelten folgende Regeln:
1050cdf0e10cSrcweir 			//1. Der erste einer Kette hat keinen Rand nach oben
1051cdf0e10cSrcweir 			//2. Nach unten gibt es nie einen Rand
1052cdf0e10cSrcweir 			//3. Der Rand nach oben ist das Maximum aus dem Abstand des
1053cdf0e10cSrcweir 			//	 Prev nach unten und dem eigenen Abstand nach oben.
1054cdf0e10cSrcweir 			//Die drei Regeln werden auf die Berechnung der Freiraeume, die von
1055cdf0e10cSrcweir 			//UL- bzw. LRSpace vorgegeben werden, angewand. Es gibt in alle
1056cdf0e10cSrcweir 			//Richtungen jedoch ggf. trotzdem einen Abstand; dieser wird durch
1057cdf0e10cSrcweir 			//Umrandung und/oder Schatten vorgegeben.
1058cdf0e10cSrcweir 			//4. Der Abstand fuer TextFrms entspricht mindestens dem Durchschuss
1059cdf0e10cSrcweir 
1060cdf0e10cSrcweir 			nUpper = CalcUpperSpace( &rAttrs, NULL );
1061cdf0e10cSrcweir 
1062cdf0e10cSrcweir             // OD 2004-03-02 #106629# - use new method <CalcLowerSpace(..)>
1063cdf0e10cSrcweir             SwTwips nLower = CalcLowerSpace( &rAttrs );
1064cdf0e10cSrcweir //            // in balanced columned section frames we do not want the
1065cdf0e10cSrcweir //            // common border
1066cdf0e10cSrcweir //            sal_Bool bCommonBorder = sal_True;
1067cdf0e10cSrcweir //            if ( IsInSct() && GetUpper()->IsColBodyFrm() )
1068cdf0e10cSrcweir //            {
1069cdf0e10cSrcweir //                const SwSectionFrm* pSct = FindSctFrm();
1070cdf0e10cSrcweir //                bCommonBorder = pSct->GetFmt()->GetBalancedColumns().GetValue();
1071cdf0e10cSrcweir //            }
1072cdf0e10cSrcweir //            SwTwips nLower = bCommonBorder ?
1073cdf0e10cSrcweir //                             rAttrs.GetBottomLine( this ) :
1074cdf0e10cSrcweir //                             rAttrs.CalcBottomLine();
1075cdf0e10cSrcweir 
1076cdf0e10cSrcweir             (Prt().*fnRect->fnSetPosY)( (!bVert || bReverse) ? nUpper : nLower);
1077cdf0e10cSrcweir             nUpper += nLower;
1078cdf0e10cSrcweir             nUpper -= (Frm().*fnRect->fnGetHeight)() -
1079cdf0e10cSrcweir                       (Prt().*fnRect->fnGetHeight)();
1080cdf0e10cSrcweir 		}
1081cdf0e10cSrcweir 		//Wenn Unterschiede zwischen Alter und neuer Groesse,
1082cdf0e10cSrcweir 		//Grow() oder Shrink() rufen
1083cdf0e10cSrcweir 		if ( nUpper )
1084cdf0e10cSrcweir 		{
1085cdf0e10cSrcweir 			if ( nUpper > 0 )
1086cdf0e10cSrcweir                 GrowFrm( nUpper );
1087cdf0e10cSrcweir 			else
1088cdf0e10cSrcweir                 ShrinkFrm( -nUpper );
1089cdf0e10cSrcweir 			bSizeChgd = sal_True;
1090cdf0e10cSrcweir 		}
1091cdf0e10cSrcweir 	}
1092cdf0e10cSrcweir 	return bSizeChgd;
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir 
1095cdf0e10cSrcweir /*************************************************************************
1096cdf0e10cSrcweir |*
1097cdf0e10cSrcweir |*	SwCntntFrm::MakeAll()
1098cdf0e10cSrcweir |*
1099cdf0e10cSrcweir |*	Ersterstellung		MA ??
1100cdf0e10cSrcweir |*	Letzte Aenderung	MA 16. Dec. 96
1101cdf0e10cSrcweir |*
1102cdf0e10cSrcweir |*************************************************************************/
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir #define STOP_FLY_FORMAT 10
1105cdf0e10cSrcweir // --> OD 2006-09-25 #b6448963# - loop prevention
1106cdf0e10cSrcweir const int cnStopFormat = 15;
1107cdf0e10cSrcweir // <--
1108cdf0e10cSrcweir 
ValidateSz(SwFrm * pFrm)1109cdf0e10cSrcweir inline void ValidateSz( SwFrm *pFrm )
1110cdf0e10cSrcweir {
1111cdf0e10cSrcweir 	if ( pFrm )
1112cdf0e10cSrcweir 	{
1113cdf0e10cSrcweir 		pFrm->bValidSize = sal_True;
1114cdf0e10cSrcweir 		pFrm->bValidPrtArea = sal_True;
1115cdf0e10cSrcweir 	}
1116cdf0e10cSrcweir }
1117cdf0e10cSrcweir 
MakeAll()1118cdf0e10cSrcweir void SwCntntFrm::MakeAll()
1119cdf0e10cSrcweir {
1120cdf0e10cSrcweir 	ASSERT( GetUpper(), "keinen Upper?" );
1121cdf0e10cSrcweir 	ASSERT( IsTxtFrm(), "MakeAll(), NoTxt" );
1122cdf0e10cSrcweir 
1123cdf0e10cSrcweir 	if ( !IsFollow() && StackHack::IsLocked() )
1124cdf0e10cSrcweir 		return;
1125cdf0e10cSrcweir 
1126cdf0e10cSrcweir 	if ( IsJoinLocked() )
1127cdf0e10cSrcweir 		return;
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir     ASSERT( !((SwTxtFrm*)this)->IsSwapped(), "Calculation of a swapped frame" );
1130cdf0e10cSrcweir 
1131cdf0e10cSrcweir     StackHack aHack;
1132cdf0e10cSrcweir 
1133cdf0e10cSrcweir 	if ( ((SwTxtFrm*)this)->IsLocked() )
1134cdf0e10cSrcweir 	{
1135cdf0e10cSrcweir 		ASSERT( sal_False, "Format fuer gelockten TxtFrm." );
1136cdf0e10cSrcweir 		return;
1137cdf0e10cSrcweir 	}
1138cdf0e10cSrcweir 
1139cdf0e10cSrcweir 	LockJoin();
1140cdf0e10cSrcweir     long nFormatCount = 0;
1141cdf0e10cSrcweir     // --> OD 2006-09-25 #b6448963# - loop prevention
1142cdf0e10cSrcweir     int nConsequetiveFormatsWithoutChange = 0;
1143cdf0e10cSrcweir     // <--
1144cdf0e10cSrcweir 	PROTOCOL_ENTER( this, PROT_MAKEALL, 0, 0 )
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir #ifdef DBG_UTIL
1147cdf0e10cSrcweir     const SwDoc *pDoc = GetAttrSet()->GetDoc();
1148cdf0e10cSrcweir 	if( pDoc )
1149cdf0e10cSrcweir 	{
1150cdf0e10cSrcweir 		static sal_Bool bWarn = sal_False;
1151cdf0e10cSrcweir 		if( pDoc->InXMLExport() )
1152cdf0e10cSrcweir 		{
1153cdf0e10cSrcweir 			ASSERT( bWarn, "Formatting during XML-export!" );
1154cdf0e10cSrcweir 			bWarn = sal_True;
1155cdf0e10cSrcweir 		}
1156cdf0e10cSrcweir 		else
1157cdf0e10cSrcweir 			bWarn = sal_False;
1158cdf0e10cSrcweir 	}
1159cdf0e10cSrcweir #endif
1160cdf0e10cSrcweir 
1161cdf0e10cSrcweir 	//uebernimmt im DTor die Benachrichtigung
1162cdf0e10cSrcweir 	SwCntntNotify *pNotify = new SwCntntNotify( this );
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir 	sal_Bool	bMakePage	= sal_True;		//solange sal_True kann eine neue Seite
1165cdf0e10cSrcweir 									//angelegt werden (genau einmal)
1166cdf0e10cSrcweir 	sal_Bool 	bMovedBwd	= sal_False;	//Wird sal_True wenn der Frame zurueckfliesst
1167cdf0e10cSrcweir 	sal_Bool	bMovedFwd	= sal_False;	//solange sal_False kann der Frm zurueck-
1168cdf0e10cSrcweir 									//fliessen (solange, bis er einmal
1169cdf0e10cSrcweir 									//vorwaerts ge'moved wurde).
1170cdf0e10cSrcweir 	sal_Bool	bFormatted	= sal_False;	//Fuer die Witwen und Waisen Regelung
1171cdf0e10cSrcweir 									//wird der letzte CntntFrm einer Kette
1172cdf0e10cSrcweir 									//u.U. zum Formatieren angeregt, dies
1173cdf0e10cSrcweir 									//braucht nur einmal zu passieren.
1174cdf0e10cSrcweir 									//Immer wenn der Frm gemoved wird muss
1175cdf0e10cSrcweir 									//das Flag zurueckgesetzt werden.
1176cdf0e10cSrcweir 	sal_Bool	bMustFit	= sal_False;	//Wenn einmal die Notbremse gezogen wurde,
1177cdf0e10cSrcweir 									//werden keine anderen Prepares mehr
1178cdf0e10cSrcweir 									//abgesetzt.
1179cdf0e10cSrcweir 	sal_Bool	bFitPromise = sal_False;	//Wenn ein Absatz nicht passte, mit WouldFit
1180cdf0e10cSrcweir 									//aber verspricht, dass er sich passend
1181cdf0e10cSrcweir 									//einstellt wird dieses Flag gesetzt.
1182cdf0e10cSrcweir 									//Wenn er dann sein Versprechen nicht haelt,
1183cdf0e10cSrcweir 									//kann kontrolliert verfahren werden.
1184cdf0e10cSrcweir 	sal_Bool bMoveable;
1185cdf0e10cSrcweir 	const sal_Bool bFly	= IsInFly();
1186cdf0e10cSrcweir 	const sal_Bool bTab = IsInTab();
1187cdf0e10cSrcweir 	const sal_Bool bFtn = IsInFtn();
1188cdf0e10cSrcweir 	const sal_Bool bSct = IsInSct();
1189cdf0e10cSrcweir 	Point aOldFrmPos;				//Damit bei Turnarounds jew. mit der
1190cdf0e10cSrcweir 	Point aOldPrtPos;				//letzten Pos verglichen und geprueft
1191cdf0e10cSrcweir 									//werden kann, ob ein Prepare sinnvoll ist.
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir 	SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
1194cdf0e10cSrcweir 	const SwBorderAttrs &rAttrs = *aAccess.Get();
1195cdf0e10cSrcweir 
1196cdf0e10cSrcweir     // OD 2004-02-26 #i25029#
1197cdf0e10cSrcweir     if ( !IsFollow() && rAttrs.JoinedWithPrev( *(this) ) )
1198cdf0e10cSrcweir     {
1199cdf0e10cSrcweir         pNotify->SetBordersJoinedWithPrev();
1200cdf0e10cSrcweir     }
1201cdf0e10cSrcweir 
1202cdf0e10cSrcweir     const sal_Bool bKeep = IsKeep( rAttrs.GetAttrSet() );
1203cdf0e10cSrcweir 
1204cdf0e10cSrcweir 	SwSaveFtnHeight *pSaveFtn = 0;
1205cdf0e10cSrcweir 	if ( bFtn )
1206cdf0e10cSrcweir 	{
1207cdf0e10cSrcweir 		SwFtnFrm *pFtn = FindFtnFrm();
1208cdf0e10cSrcweir 		SwSectionFrm* pSct = pFtn->FindSctFrm();
1209cdf0e10cSrcweir 		if ( !((SwTxtFrm*)pFtn->GetRef())->IsLocked() )
1210cdf0e10cSrcweir 		{
1211cdf0e10cSrcweir 			SwFtnBossFrm* pBoss = pFtn->GetRef()->FindFtnBossFrm(
1212cdf0e10cSrcweir 									pFtn->GetAttr()->GetFtn().IsEndNote() );
1213cdf0e10cSrcweir 			if( !pSct || pSct->IsColLocked() || !pSct->Growable() )
1214cdf0e10cSrcweir 				pSaveFtn = new SwSaveFtnHeight( pBoss,
1215cdf0e10cSrcweir                     ((SwTxtFrm*)pFtn->GetRef())->GetFtnLine( pFtn->GetAttr() ) );
1216cdf0e10cSrcweir 		}
1217cdf0e10cSrcweir 	}
1218cdf0e10cSrcweir 
1219cdf0e10cSrcweir     // --> OD 2008-08-12 #b6732519#
1220cdf0e10cSrcweir     if ( GetUpper()->IsSctFrm() &&
1221cdf0e10cSrcweir          HasFollow() &&
1222cdf0e10cSrcweir          GetFollow()->GetFrm() == GetNext() )
1223cdf0e10cSrcweir     {
1224cdf0e10cSrcweir         dynamic_cast<SwTxtFrm*>(this)->JoinFrm();
1225cdf0e10cSrcweir     }
1226cdf0e10cSrcweir     // <--
1227cdf0e10cSrcweir 
1228cdf0e10cSrcweir     // --> OD 2004-06-23 #i28701# - move master forward, if it has to move,
1229cdf0e10cSrcweir     // because of its object positioning.
1230cdf0e10cSrcweir     if ( !static_cast<SwTxtFrm*>(this)->IsFollow() )
1231cdf0e10cSrcweir     {
1232cdf0e10cSrcweir         sal_uInt32 nToPageNum = 0L;
1233cdf0e10cSrcweir         const bool bMoveFwdByObjPos = SwLayouter::FrmMovedFwdByObjPos(
1234cdf0e10cSrcweir                                                     *(GetAttrSet()->GetDoc()),
1235cdf0e10cSrcweir                                                     *(static_cast<SwTxtFrm*>(this)),
1236cdf0e10cSrcweir                                                     nToPageNum );
1237cdf0e10cSrcweir         // --> OD 2006-01-27 #i58182#
1238cdf0e10cSrcweir         // Also move a paragraph forward, which is the first one inside a table cell.
1239cdf0e10cSrcweir         if ( bMoveFwdByObjPos &&
1240cdf0e10cSrcweir              FindPageFrm()->GetPhyPageNum() < nToPageNum &&
1241cdf0e10cSrcweir              ( lcl_Prev( this ) ||
1242cdf0e10cSrcweir                GetUpper()->IsCellFrm() ||
1243cdf0e10cSrcweir                ( GetUpper()->IsSctFrm() &&
1244cdf0e10cSrcweir                  GetUpper()->GetUpper()->IsCellFrm() ) ) &&
1245cdf0e10cSrcweir              IsMoveable() )
1246cdf0e10cSrcweir         {
1247cdf0e10cSrcweir             bMovedFwd = sal_True;
1248cdf0e10cSrcweir             MoveFwd( bMakePage, sal_False );
1249cdf0e10cSrcweir         }
1250cdf0e10cSrcweir         // <--
1251cdf0e10cSrcweir     }
1252cdf0e10cSrcweir     // <--
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir     //Wenn ein Follow neben seinem Master steht und nicht passt, kann er
1255cdf0e10cSrcweir 	//gleich verschoben werden.
1256cdf0e10cSrcweir     if ( lcl_Prev( this ) && ((SwTxtFrm*)this)->IsFollow() && IsMoveable() )
1257cdf0e10cSrcweir 	{
1258cdf0e10cSrcweir 		bMovedFwd = sal_True;
1259cdf0e10cSrcweir         // OD 2004-03-02 #106629# - If follow frame is in table, it's master
1260cdf0e10cSrcweir         // will be the last in the current table cell. Thus, invalidate the
1261cdf0e10cSrcweir         // printing area of the master,
1262cdf0e10cSrcweir         if ( IsInTab() )
1263cdf0e10cSrcweir         {
1264cdf0e10cSrcweir             lcl_Prev( this )->InvalidatePrt();
1265cdf0e10cSrcweir         }
1266cdf0e10cSrcweir         MoveFwd( bMakePage, sal_False );
1267cdf0e10cSrcweir     }
1268cdf0e10cSrcweir 
1269cdf0e10cSrcweir     // OD 08.11.2002 #104840# - check footnote content for forward move.
1270cdf0e10cSrcweir     // If a content of a footnote is on a prior page/column as its invalid
1271cdf0e10cSrcweir     // reference, it can be moved forward.
1272cdf0e10cSrcweir     if ( bFtn && !bValidPos )
1273cdf0e10cSrcweir     {
1274cdf0e10cSrcweir         SwFtnFrm* pFtn = FindFtnFrm();
1275cdf0e10cSrcweir         SwCntntFrm* pRefCnt = pFtn ? pFtn->GetRef() : 0;
1276cdf0e10cSrcweir         if ( pRefCnt && !pRefCnt->IsValid() )
1277cdf0e10cSrcweir         {
1278cdf0e10cSrcweir             SwFtnBossFrm* pFtnBossOfFtn = pFtn->FindFtnBossFrm();
1279cdf0e10cSrcweir             SwFtnBossFrm* pFtnBossOfRef = pRefCnt->FindFtnBossFrm();
1280cdf0e10cSrcweir             //<loop of movefwd until condition held or no move>
1281cdf0e10cSrcweir             if ( pFtnBossOfFtn && pFtnBossOfRef &&
1282cdf0e10cSrcweir                  pFtnBossOfFtn != pFtnBossOfRef &&
1283cdf0e10cSrcweir                  pFtnBossOfFtn->IsBefore( pFtnBossOfRef ) )
1284cdf0e10cSrcweir             {
1285cdf0e10cSrcweir                 bMovedFwd = sal_True;
1286cdf0e10cSrcweir                 MoveFwd( bMakePage, sal_False );
1287cdf0e10cSrcweir             }
1288cdf0e10cSrcweir         }
1289cdf0e10cSrcweir     }
1290cdf0e10cSrcweir 
1291cdf0e10cSrcweir     SWRECTFN( this )
1292cdf0e10cSrcweir 
1293cdf0e10cSrcweir 	while ( !bValidPos || !bValidSize || !bValidPrtArea )
1294cdf0e10cSrcweir 	{
1295cdf0e10cSrcweir         // --> OD 2006-09-25 #b6448963# - loop prevention
1296cdf0e10cSrcweir         SwRect aOldFrm_StopFormat( Frm() );
1297cdf0e10cSrcweir         SwRect aOldPrt_StopFormat( Prt() );
1298cdf0e10cSrcweir         // <--
1299cdf0e10cSrcweir 		if ( sal_True == (bMoveable = IsMoveable()) )
1300cdf0e10cSrcweir 		{
1301cdf0e10cSrcweir 			SwFrm *pPre = GetIndPrev();
1302cdf0e10cSrcweir 			if ( CheckMoveFwd( bMakePage, bKeep, bMovedBwd ) )
1303cdf0e10cSrcweir 			{
1304cdf0e10cSrcweir                 SWREFRESHFN( this )
1305cdf0e10cSrcweir 				bMovedFwd = sal_True;
1306cdf0e10cSrcweir 				if ( bMovedBwd )
1307cdf0e10cSrcweir 				{
1308cdf0e10cSrcweir 					//Beim zurueckfliessen wurde der Upper angeregt sich
1309cdf0e10cSrcweir 					//vollstaendig zu Painten, dass koennen wir uns jetzt
1310cdf0e10cSrcweir 					//nach dem hin und her fliessen sparen.
1311cdf0e10cSrcweir 					GetUpper()->ResetCompletePaint();
1312cdf0e10cSrcweir 					//Der Vorgaenger wurde Invalidiert, das ist jetzt auch obsolete.
1313cdf0e10cSrcweir 					ASSERT( pPre, "missing old Prev" );
1314cdf0e10cSrcweir 					if( !pPre->IsSctFrm() )
1315cdf0e10cSrcweir 						::ValidateSz( pPre );
1316cdf0e10cSrcweir 				}
1317cdf0e10cSrcweir 				bMoveable = IsMoveable();
1318cdf0e10cSrcweir 			}
1319cdf0e10cSrcweir 		}
1320cdf0e10cSrcweir 
1321cdf0e10cSrcweir         aOldFrmPos = (Frm().*fnRect->fnGetPos)();
1322cdf0e10cSrcweir         aOldPrtPos = (Prt().*fnRect->fnGetPos)();
1323cdf0e10cSrcweir 
1324cdf0e10cSrcweir 		if ( !bValidPos )
1325cdf0e10cSrcweir 			MakePos();
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir 		//FixSize einstellen, die VarSize wird von Format() justiert.
1328cdf0e10cSrcweir 		if ( !bValidSize )
1329cdf0e10cSrcweir         {
1330cdf0e10cSrcweir             // --> OD 2006-01-03 #125452#
1331cdf0e10cSrcweir             // invalidate printing area flag, if the following conditions are hold:
1332cdf0e10cSrcweir             // - current frame width is 0.
1333cdf0e10cSrcweir             // - current printing area width is 0.
1334cdf0e10cSrcweir             // - frame width is adjusted to a value greater than 0.
1335cdf0e10cSrcweir             // - printing area flag is sal_True.
1336cdf0e10cSrcweir             // Thus, it's assured that the printing area is adjusted, if the
1337cdf0e10cSrcweir             // frame area width changes its width from 0 to something greater
1338cdf0e10cSrcweir             // than 0.
1339cdf0e10cSrcweir             // Note: A text frame can be in such a situation, if the format is
1340cdf0e10cSrcweir             //       triggered by method call <SwCrsrShell::SetCrsr()> after
1341cdf0e10cSrcweir             //       loading the document.
1342cdf0e10cSrcweir             const SwTwips nNewFrmWidth = (GetUpper()->Prt().*fnRect->fnGetWidth)();
1343cdf0e10cSrcweir             if ( bValidPrtArea && nNewFrmWidth > 0 &&
1344cdf0e10cSrcweir                  (Frm().*fnRect->fnGetWidth)() == 0 &&
1345cdf0e10cSrcweir                  (Prt().*fnRect->fnGetWidth)() == 0 )
1346cdf0e10cSrcweir             {
1347cdf0e10cSrcweir                 bValidPrtArea = sal_False;
1348cdf0e10cSrcweir             }
1349cdf0e10cSrcweir 
1350cdf0e10cSrcweir             (Frm().*fnRect->fnSetWidth)( nNewFrmWidth );
1351cdf0e10cSrcweir             // <--
1352cdf0e10cSrcweir         }
1353cdf0e10cSrcweir 		if ( !bValidPrtArea )
1354cdf0e10cSrcweir 		{
1355cdf0e10cSrcweir             const long nOldW = (Prt().*fnRect->fnGetWidth)();
1356cdf0e10cSrcweir             // --> OD 2004-09-28 #i34730# - keep current frame height
1357cdf0e10cSrcweir             const SwTwips nOldH = (Frm().*fnRect->fnGetHeight)();
1358cdf0e10cSrcweir             // <--
1359cdf0e10cSrcweir 			MakePrtArea( rAttrs );
1360cdf0e10cSrcweir             if ( nOldW != (Prt().*fnRect->fnGetWidth)() )
1361cdf0e10cSrcweir 				Prepare( PREP_FIXSIZE_CHG );
1362cdf0e10cSrcweir             // --> OD 2004-09-28 #i34730# - check, if frame height has changed.
1363cdf0e10cSrcweir             // If yes, send a PREP_ADJUST_FRM and invalidate the size flag to
1364cdf0e10cSrcweir             // force a format. The format will check in its method
1365cdf0e10cSrcweir             // <SwTxtFrm::CalcPreps()>, if the already formatted lines still
1366cdf0e10cSrcweir             // fit and if not, performs necessary actions.
1367cdf0e10cSrcweir             // --> OD 2005-01-10 #i40150# - no check, if frame is undersized.
1368cdf0e10cSrcweir             if ( bValidSize && !IsUndersized() &&
1369cdf0e10cSrcweir                  nOldH != (Frm().*fnRect->fnGetHeight)() )
1370cdf0e10cSrcweir             {
1371cdf0e10cSrcweir                 // --> OD 2004-11-25 #115759# - no PREP_ADJUST_FRM and size
1372cdf0e10cSrcweir                 // invalidation, if height decreases only by the additional
1373cdf0e10cSrcweir                 // lower space as last content of a table cell and an existing
1374cdf0e10cSrcweir                 // follow containing one line exists.
1375cdf0e10cSrcweir                 const SwTwips nHDiff = nOldH - (Frm().*fnRect->fnGetHeight)();
1376cdf0e10cSrcweir                 const bool bNoPrepAdjustFrm =
1377cdf0e10cSrcweir                     nHDiff > 0 && IsInTab() && GetFollow() &&
1378cdf0e10cSrcweir                     ( 1 == static_cast<SwTxtFrm*>(GetFollow())->GetLineCount( STRING_LEN ) || (static_cast<SwTxtFrm*>(GetFollow())->Frm().*fnRect->fnGetWidth)() < 0 ) &&
1379cdf0e10cSrcweir                     GetFollow()->CalcAddLowerSpaceAsLastInTableCell() == nHDiff;
1380cdf0e10cSrcweir                 if ( !bNoPrepAdjustFrm )
1381cdf0e10cSrcweir                 {
1382cdf0e10cSrcweir                     Prepare( PREP_ADJUST_FRM );
1383cdf0e10cSrcweir                     bValidSize = sal_False;
1384cdf0e10cSrcweir                 }
1385cdf0e10cSrcweir                 // <--
1386cdf0e10cSrcweir             }
1387cdf0e10cSrcweir             // <--
1388cdf0e10cSrcweir 		}
1389cdf0e10cSrcweir 
1390cdf0e10cSrcweir 		//Damit die Witwen- und Waisen-Regelung eine Change bekommt muss der
1391cdf0e10cSrcweir 		//CntntFrm benachrichtigt werden.
1392cdf0e10cSrcweir 		//Kriterium:
1393cdf0e10cSrcweir 		//- Er muss Moveable sein (sonst mach das Spalten keinen Sinn.)
1394cdf0e10cSrcweir 		//- Er muss mit der Unterkante der PrtArea des Upper ueberlappen.
1395cdf0e10cSrcweir 		if ( !bMustFit )
1396cdf0e10cSrcweir 		{
1397cdf0e10cSrcweir 			sal_Bool bWidow = sal_True;
1398cdf0e10cSrcweir             const SwTwips nDeadLine = (GetUpper()->*fnRect->fnGetPrtBottom)();
1399cdf0e10cSrcweir             if ( bMoveable && !bFormatted && ( GetFollow() ||
1400cdf0e10cSrcweir                  ( (Frm().*fnRect->fnOverStep)( nDeadLine ) ) ) )
1401cdf0e10cSrcweir             {
1402cdf0e10cSrcweir 				Prepare( PREP_WIDOWS_ORPHANS, 0, sal_False );
1403cdf0e10cSrcweir 				bValidSize = bWidow = sal_False;
1404cdf0e10cSrcweir 			}
1405cdf0e10cSrcweir             if( (Frm().*fnRect->fnGetPos)() != aOldFrmPos ||
1406cdf0e10cSrcweir                 (Prt().*fnRect->fnGetPos)() != aOldPrtPos )
1407cdf0e10cSrcweir 			{
1408cdf0e10cSrcweir 				// In diesem Prepare erfolgt ggf. ein _InvalidateSize().
1409cdf0e10cSrcweir 				// bValidSize wird sal_False und das Format() wird gerufen.
1410cdf0e10cSrcweir 				Prepare( PREP_POS_CHGD, (const void*)&bFormatted, sal_False );
1411cdf0e10cSrcweir 				if ( bWidow && GetFollow() )
1412cdf0e10cSrcweir 				{	Prepare( PREP_WIDOWS_ORPHANS, 0, sal_False );
1413cdf0e10cSrcweir 					bValidSize = sal_False;
1414cdf0e10cSrcweir 				}
1415cdf0e10cSrcweir 			}
1416cdf0e10cSrcweir 		}
1417cdf0e10cSrcweir 		if ( !bValidSize )
1418cdf0e10cSrcweir         {
1419cdf0e10cSrcweir             bValidSize = bFormatted = sal_True;
1420cdf0e10cSrcweir             ++nFormatCount;
1421cdf0e10cSrcweir             if( nFormatCount > STOP_FLY_FORMAT )
1422cdf0e10cSrcweir                 SetFlyLock( sal_True );
1423cdf0e10cSrcweir             // --> OD 2006-09-25 #b6448963# - loop prevention
1424cdf0e10cSrcweir             // No format any longer, if <cnStopFormat> consequetive formats
1425cdf0e10cSrcweir             // without change occur.
1426cdf0e10cSrcweir             if ( nConsequetiveFormatsWithoutChange <= cnStopFormat )
1427cdf0e10cSrcweir             {
1428cdf0e10cSrcweir                 Format();
1429cdf0e10cSrcweir             }
1430cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1431cdf0e10cSrcweir             else
1432cdf0e10cSrcweir             {
1433cdf0e10cSrcweir                 ASSERT( false, "debug assertion: <SwCntntFrm::MakeAll()> - format of text frame suppressed by fix b6448963" );
1434cdf0e10cSrcweir             }
1435cdf0e10cSrcweir #endif
1436cdf0e10cSrcweir             // <--
1437cdf0e10cSrcweir 		}
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir         // FME 16.07.2003 #i16930# - removed this code because it did not work
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir         // OD 04.04.2003 #108446# - react on the situation detected in the text
1442cdf0e10cSrcweir         // formatting - see <SwTxtFrm::FormatAdjust(..)>:
1443cdf0e10cSrcweir         // text frame has to move forward, because its text formatting stopped,
1444cdf0e10cSrcweir         // created a follow and detected, that it contains no content.
1445cdf0e10cSrcweir /*        if ( IsTxtFrm() && bValidPos && bValidSize && bValidPrtArea &&
1446cdf0e10cSrcweir              (Frm().*fnRect->fnGetHeight)() == 0 &&
1447cdf0e10cSrcweir              HasFollow()
1448cdf0e10cSrcweir            )
1449cdf0e10cSrcweir         {
1450cdf0e10cSrcweir             SwFrm* pOldUpper = GetUpper();
1451cdf0e10cSrcweir             MoveFwd( sal_True, sal_False );
1452cdf0e10cSrcweir             if ( GetUpper() != pOldUpper )
1453cdf0e10cSrcweir             {
1454cdf0e10cSrcweir                 bMovedFwd = sal_True;
1455cdf0e10cSrcweir                 SWREFRESHFN( this )
1456cdf0e10cSrcweir                 continue;
1457cdf0e10cSrcweir             }
1458cdf0e10cSrcweir         } */
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir         //Wenn ich der erste einer Kette bin koennte ich mal sehen ob
1461cdf0e10cSrcweir 		//ich zurueckfliessen kann (wenn ich mich ueberhaupt bewegen soll).
1462cdf0e10cSrcweir 		//Damit es keine Oszillation gibt, darf ich nicht gerade vorwaerts
1463cdf0e10cSrcweir 		//geflossen sein.
1464cdf0e10cSrcweir 		sal_Bool bDummy;
1465cdf0e10cSrcweir         if ( !lcl_Prev( this ) &&
1466cdf0e10cSrcweir              !bMovedFwd &&
1467cdf0e10cSrcweir              ( bMoveable || ( bFly && !bTab ) ) &&
1468cdf0e10cSrcweir 			 ( !bFtn || !GetUpper()->FindFtnFrm()->GetPrev() )
1469cdf0e10cSrcweir              && MoveBwd( bDummy ) )
1470cdf0e10cSrcweir         {
1471cdf0e10cSrcweir             SWREFRESHFN( this )
1472cdf0e10cSrcweir 			bMovedBwd = sal_True;
1473cdf0e10cSrcweir 			bFormatted = sal_False;
1474cdf0e10cSrcweir             if ( bKeep && bMoveable )
1475cdf0e10cSrcweir 			{
1476cdf0e10cSrcweir 				if( CheckMoveFwd( bMakePage, sal_False, bMovedBwd ) )
1477cdf0e10cSrcweir 				{
1478cdf0e10cSrcweir 					bMovedFwd = sal_True;
1479cdf0e10cSrcweir 					bMoveable = IsMoveable();
1480cdf0e10cSrcweir                     SWREFRESHFN( this )
1481cdf0e10cSrcweir 				}
1482cdf0e10cSrcweir                 Point aOldPos = (Frm().*fnRect->fnGetPos)();
1483cdf0e10cSrcweir                 MakePos();
1484cdf0e10cSrcweir                 if( aOldPos != (Frm().*fnRect->fnGetPos)() )
1485cdf0e10cSrcweir 				{
1486cdf0e10cSrcweir 					Prepare( PREP_POS_CHGD, (const void*)&bFormatted, sal_False );
1487cdf0e10cSrcweir 					if ( !bValidSize )
1488cdf0e10cSrcweir 					{
1489cdf0e10cSrcweir                         (Frm().*fnRect->fnSetWidth)( (GetUpper()->
1490cdf0e10cSrcweir                                                 Prt().*fnRect->fnGetWidth)() );
1491cdf0e10cSrcweir 						if ( !bValidPrtArea )
1492cdf0e10cSrcweir 						{
1493cdf0e10cSrcweir                             const long nOldW = (Prt().*fnRect->fnGetWidth)();
1494cdf0e10cSrcweir                             MakePrtArea( rAttrs );
1495cdf0e10cSrcweir                             if( nOldW != (Prt().*fnRect->fnGetWidth)() )
1496cdf0e10cSrcweir 								Prepare( PREP_FIXSIZE_CHG, 0, sal_False );
1497cdf0e10cSrcweir 						}
1498cdf0e10cSrcweir 						if( GetFollow() )
1499cdf0e10cSrcweir 							Prepare( PREP_WIDOWS_ORPHANS, 0, sal_False );
1500cdf0e10cSrcweir 						bValidSize = bFormatted = sal_True;
1501cdf0e10cSrcweir 						Format();
1502cdf0e10cSrcweir 					}
1503cdf0e10cSrcweir 				}
1504cdf0e10cSrcweir                 SwFrm *pNxt = HasFollow() ? NULL : FindNext();
1505cdf0e10cSrcweir 				while( pNxt && pNxt->IsSctFrm() )
1506cdf0e10cSrcweir 				{   // Leere Bereiche auslassen, in die anderen hinein
1507cdf0e10cSrcweir 					if( ((SwSectionFrm*)pNxt)->GetSection() )
1508cdf0e10cSrcweir 					{
1509cdf0e10cSrcweir 						SwFrm* pTmp = ((SwSectionFrm*)pNxt)->ContainsAny();
1510cdf0e10cSrcweir 						if( pTmp )
1511cdf0e10cSrcweir 						{
1512cdf0e10cSrcweir 							pNxt = pTmp;
1513cdf0e10cSrcweir 							break;
1514cdf0e10cSrcweir 						}
1515cdf0e10cSrcweir 					}
1516cdf0e10cSrcweir 					pNxt = pNxt->FindNext();
1517cdf0e10cSrcweir 				}
1518cdf0e10cSrcweir                 if ( pNxt )
1519cdf0e10cSrcweir 				{
1520cdf0e10cSrcweir                     pNxt->Calc();
1521cdf0e10cSrcweir                     if( bValidPos && !GetIndNext() )
1522cdf0e10cSrcweir                     {
1523cdf0e10cSrcweir                         SwSectionFrm *pSct = FindSctFrm();
1524cdf0e10cSrcweir                         if( pSct && !pSct->GetValidSizeFlag() )
1525cdf0e10cSrcweir                         {
1526cdf0e10cSrcweir                             SwSectionFrm* pNxtSct = pNxt->FindSctFrm();
1527cdf0e10cSrcweir                             if( pNxtSct && pSct->IsAnFollow( pNxtSct ) )
1528cdf0e10cSrcweir                                 bValidPos = sal_False;
1529cdf0e10cSrcweir                         }
1530cdf0e10cSrcweir                         else
1531cdf0e10cSrcweir                             bValidPos = sal_False;
1532cdf0e10cSrcweir                     }
1533cdf0e10cSrcweir 				}
1534cdf0e10cSrcweir 			}
1535cdf0e10cSrcweir 		}
1536cdf0e10cSrcweir 
1537cdf0e10cSrcweir 		//Der TxtFrm Validiert sich bei Fussnoten ggf. selbst, dass kann leicht
1538cdf0e10cSrcweir 		//dazu fuehren, dass seine Position obwohl unrichtig valide ist.
1539cdf0e10cSrcweir 		if ( bValidPos )
1540cdf0e10cSrcweir 		{
1541cdf0e10cSrcweir             // --> OD 2006-01-23 #i59341#
1542cdf0e10cSrcweir             // Workaround for inadequate layout algorithm:
1543cdf0e10cSrcweir             // suppress invalidation and calculation of position, if paragraph
1544cdf0e10cSrcweir             // has formatted itself at least STOP_FLY_FORMAT times and
1545cdf0e10cSrcweir             // has anchored objects.
1546cdf0e10cSrcweir             // Thus, the anchored objects get the possibility to format itself
1547cdf0e10cSrcweir             // and this probably solve the layout loop.
1548cdf0e10cSrcweir             if ( bFtn &&
1549cdf0e10cSrcweir                  nFormatCount <= STOP_FLY_FORMAT &&
1550cdf0e10cSrcweir                  !GetDrawObjs() )
1551cdf0e10cSrcweir             // <--
1552cdf0e10cSrcweir             {
1553cdf0e10cSrcweir                 bValidPos = sal_False;
1554cdf0e10cSrcweir                 MakePos();
1555cdf0e10cSrcweir                 aOldFrmPos = (Frm().*fnRect->fnGetPos)();
1556cdf0e10cSrcweir                 aOldPrtPos = (Prt().*fnRect->fnGetPos)();
1557cdf0e10cSrcweir             }
1558cdf0e10cSrcweir 		}
1559cdf0e10cSrcweir 
1560cdf0e10cSrcweir         // --> OD 2006-09-25 #b6448963# - loop prevention
1561cdf0e10cSrcweir         {
1562cdf0e10cSrcweir             if ( aOldFrm_StopFormat == Frm() &&
1563cdf0e10cSrcweir                  aOldPrt_StopFormat == Prt() )
1564cdf0e10cSrcweir             {
1565cdf0e10cSrcweir                 ++nConsequetiveFormatsWithoutChange;
1566cdf0e10cSrcweir             }
1567cdf0e10cSrcweir             else
1568cdf0e10cSrcweir             {
1569cdf0e10cSrcweir                 nConsequetiveFormatsWithoutChange = 0;
1570cdf0e10cSrcweir             }
1571cdf0e10cSrcweir         }
1572cdf0e10cSrcweir         // <--
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir 		//Wieder ein Wert ungueltig? - dann nochmal das ganze...
1575cdf0e10cSrcweir 		if ( !bValidPos || !bValidSize || !bValidPrtArea )
1576cdf0e10cSrcweir 			continue;
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir 		//Fertig?
1579cdf0e10cSrcweir 		// Achtung, wg. Hoehe==0, ist es besser statt Bottom() Top()+Height() zu nehmen
1580cdf0e10cSrcweir         // (kommt bei Undersized TxtFrms an der Unterkante eines spaltigen Bereichs vor)
1581cdf0e10cSrcweir         const long nPrtBottom = (GetUpper()->*fnRect->fnGetPrtBottom)();
1582cdf0e10cSrcweir         const long nBottomDist =  (Frm().*fnRect->fnBottomDist)( nPrtBottom );
1583cdf0e10cSrcweir         if( nBottomDist >= 0 )
1584cdf0e10cSrcweir 		{
1585cdf0e10cSrcweir             if ( bKeep && bMoveable )
1586cdf0e10cSrcweir 			{
1587cdf0e10cSrcweir 				//Wir sorgen dafuer, dass der Nachfolger gleich mit formatiert
1588cdf0e10cSrcweir 				//wird. Dadurch halten wir das Heft in der Hand, bis wirklich
1589cdf0e10cSrcweir 				//(fast) alles stabil ist. So vermeiden wir Endlosschleifen,
1590cdf0e10cSrcweir 				//die durch staendig wiederholte Versuche entstehen.
1591cdf0e10cSrcweir 				//Das bMoveFwdInvalid ist fuer #38407# notwendig. War urspruenglich
1592cdf0e10cSrcweir 				//in flowfrm.cxx rev 1.38 behoben, das unterbrach aber obiges
1593cdf0e10cSrcweir 				//Schema und spielte lieber Tuerme von Hanoi (#43669#).
1594cdf0e10cSrcweir                 SwFrm *pNxt = HasFollow() ? NULL : FindNext();
1595cdf0e10cSrcweir 				// Bei Bereichen nehmen wir lieber den Inhalt, denn nur
1596cdf0e10cSrcweir 				// dieser kann ggf. die Seite wechseln
1597cdf0e10cSrcweir 				while( pNxt && pNxt->IsSctFrm() )
1598cdf0e10cSrcweir 				{
1599cdf0e10cSrcweir 					if( ((SwSectionFrm*)pNxt)->GetSection() )
1600cdf0e10cSrcweir 					{
1601cdf0e10cSrcweir 						pNxt = ((SwSectionFrm*)pNxt)->ContainsAny();
1602cdf0e10cSrcweir 						break;
1603cdf0e10cSrcweir 					}
1604cdf0e10cSrcweir 					pNxt = pNxt->FindNext();
1605cdf0e10cSrcweir 				}
1606cdf0e10cSrcweir 				if ( pNxt )
1607cdf0e10cSrcweir 				{
1608cdf0e10cSrcweir                     const sal_Bool bMoveFwdInvalid = 0 != GetIndNext();
1609cdf0e10cSrcweir                     const sal_Bool bNxtNew =
1610cdf0e10cSrcweir                         ( 0 == (pNxt->Prt().*fnRect->fnGetHeight)() ) &&
1611cdf0e10cSrcweir                         (!pNxt->IsTxtFrm() ||!((SwTxtFrm*)pNxt)->IsHiddenNow());
1612cdf0e10cSrcweir 
1613cdf0e10cSrcweir                     pNxt->Calc();
1614cdf0e10cSrcweir 
1615cdf0e10cSrcweir                     if ( !bMovedBwd &&
1616cdf0e10cSrcweir                          ((bMoveFwdInvalid && !GetIndNext()) ||
1617cdf0e10cSrcweir                           bNxtNew) )
1618cdf0e10cSrcweir                     {
1619cdf0e10cSrcweir                         if( bMovedFwd )
1620cdf0e10cSrcweir                             pNotify->SetInvaKeep();
1621cdf0e10cSrcweir                         bMovedFwd = sal_False;
1622cdf0e10cSrcweir                     }
1623cdf0e10cSrcweir 				}
1624cdf0e10cSrcweir 			}
1625cdf0e10cSrcweir 			continue;
1626cdf0e10cSrcweir 		}
1627cdf0e10cSrcweir 
1628cdf0e10cSrcweir 		//Ich passe nicht mehr in meinen Uebergeordneten, also ist es jetzt
1629cdf0e10cSrcweir 		//an der Zeit moeglichst konstruktive Veranderungen vorzunehmen
1630cdf0e10cSrcweir 
1631cdf0e10cSrcweir 		//Wenn ich den uebergeordneten Frm nicht verlassen darf, habe
1632cdf0e10cSrcweir 		//ich ein Problem; Frei nach Artur Dent tun wir das einzige das man
1633cdf0e10cSrcweir 		//mit einen nicht loesbaren Problem tun kann: wir ignorieren es - und
1634cdf0e10cSrcweir 		//zwar mit aller Kraft.
1635cdf0e10cSrcweir 		if ( !bMoveable || IsUndersized() )
1636cdf0e10cSrcweir 		{
1637cdf0e10cSrcweir 			if( !bMoveable && IsInTab() )
1638cdf0e10cSrcweir 			{
1639cdf0e10cSrcweir                 long nDiff = -(Frm().*fnRect->fnBottomDist)(
1640cdf0e10cSrcweir                                         (GetUpper()->*fnRect->fnGetPrtBottom)() );
1641cdf0e10cSrcweir                 long nReal = GetUpper()->Grow( nDiff );
1642cdf0e10cSrcweir 				if( nReal )
1643cdf0e10cSrcweir 					continue;
1644cdf0e10cSrcweir 			}
1645cdf0e10cSrcweir 			break;
1646cdf0e10cSrcweir 		}
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir 		//Wenn ich nun ueberhaupt ganz und garnicht in meinen Upper passe
1649cdf0e10cSrcweir 		//so kann die Situation vielleicht doch noch durch Aufbrechen
1650cdf0e10cSrcweir 		//aufgeklart werden. Diese Situation tritt bei einem frisch
1651cdf0e10cSrcweir 		//erzeugten Follow auf, der zwar auf die Folgeseite geschoben wurde
1652cdf0e10cSrcweir 		//aber selbst noch zu gross fuer diese ist; also wiederum
1653cdf0e10cSrcweir 		//aufgespalten werden muss.
1654cdf0e10cSrcweir 		//Wenn ich nicht passe und nicht Spaltbar (WouldFit()) bin, so schicke
1655cdf0e10cSrcweir 		//ich meinem TxtFrmanteil die Nachricht, dass eben falls moeglich
1656cdf0e10cSrcweir 		//trotz des Attributes 'nicht aufspalten' aufgespalten werden muss.
1657cdf0e10cSrcweir 		sal_Bool bMoveOrFit = sal_False;
1658cdf0e10cSrcweir 		sal_Bool bDontMoveMe = !GetIndPrev();
1659cdf0e10cSrcweir 		if( bDontMoveMe && IsInSct() )
1660cdf0e10cSrcweir 		{
1661cdf0e10cSrcweir 			SwFtnBossFrm* pBoss = FindFtnBossFrm();
1662cdf0e10cSrcweir 			bDontMoveMe = !pBoss->IsInSct() ||
1663cdf0e10cSrcweir 						  ( !pBoss->Lower()->GetNext() && !pBoss->GetPrev() );
1664cdf0e10cSrcweir 		}
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir         // Finally, we are able to split table rows. Therefore, bDontMoveMe
1667cdf0e10cSrcweir         // can be set to sal_False:
1668cdf0e10cSrcweir         if( bDontMoveMe && IsInTab() &&
1669cdf0e10cSrcweir             0 != const_cast<SwCntntFrm*>(this)->GetNextCellLeaf( MAKEPAGE_NONE ) )
1670cdf0e10cSrcweir             bDontMoveMe = sal_False;
1671cdf0e10cSrcweir 
1672cdf0e10cSrcweir         if ( bDontMoveMe && (Frm().*fnRect->fnGetHeight)() >
1673cdf0e10cSrcweir                             (GetUpper()->Prt().*fnRect->fnGetHeight)() )
1674cdf0e10cSrcweir 		{
1675cdf0e10cSrcweir             if ( !bFitPromise )
1676cdf0e10cSrcweir 			{
1677cdf0e10cSrcweir                 SwTwips nTmp = (GetUpper()->Prt().*fnRect->fnGetHeight)() -
1678cdf0e10cSrcweir                                (Prt().*fnRect->fnGetTop)();
1679cdf0e10cSrcweir                 sal_Bool bSplit = !IsFwdMoveAllowed();
1680cdf0e10cSrcweir                 if ( nTmp > 0 && WouldFit( nTmp, bSplit, sal_False ) )
1681cdf0e10cSrcweir 				{
1682cdf0e10cSrcweir 					Prepare( PREP_WIDOWS_ORPHANS, 0, sal_False );
1683cdf0e10cSrcweir 					bValidSize = sal_False;
1684cdf0e10cSrcweir 					bFitPromise = sal_True;
1685cdf0e10cSrcweir 					continue;
1686cdf0e10cSrcweir 				}
1687cdf0e10cSrcweir 				/* -----------------19.02.99 12:58-------------------
1688cdf0e10cSrcweir 				 * Frueher wurde in Rahmen und Bereichen niemals versucht,
1689cdf0e10cSrcweir 				 * durch bMoveOrFit den TxtFrm unter Verzicht auf seine
1690cdf0e10cSrcweir 				 * Attribute (Widows,Keep) doch noch passend zu bekommen.
1691cdf0e10cSrcweir 				 * Dies haette zumindest bei spaltigen Rahmen versucht
1692cdf0e10cSrcweir 				 * werden muessen, spaetestens bei verketteten Rahmen und
1693cdf0e10cSrcweir 				 * in Bereichen muss es versucht werden.
1694cdf0e10cSrcweir 				 * Ausnahme: Wenn wir im FormatWidthCols stehen, duerfen die
1695cdf0e10cSrcweir 				 * Attribute nicht ausser Acht gelassen werden.
1696cdf0e10cSrcweir 				 * --------------------------------------------------*/
1697cdf0e10cSrcweir 				else if ( !bFtn && bMoveable &&
1698cdf0e10cSrcweir 					  ( !bFly || !FindFlyFrm()->IsColLocked() ) &&
1699cdf0e10cSrcweir 					  ( !bSct || !FindSctFrm()->IsColLocked() ) )
1700cdf0e10cSrcweir 					bMoveOrFit = sal_True;
1701cdf0e10cSrcweir             }
1702cdf0e10cSrcweir #ifdef DBG_UTIL
1703cdf0e10cSrcweir 			else
1704cdf0e10cSrcweir 			{
1705cdf0e10cSrcweir 				ASSERT( sal_False, "+TxtFrm hat WouldFit-Versprechen nicht eingehalten." );
1706cdf0e10cSrcweir 			}
1707cdf0e10cSrcweir #endif
1708cdf0e10cSrcweir 		}
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir 		//Mal sehen ob ich irgenwo Platz finde...
1711cdf0e10cSrcweir 		//Benachbarte Fussnoten werden in _MoveFtnCntFwd 'vorgeschoben'
1712cdf0e10cSrcweir 		SwFrm *pPre = GetIndPrev();
1713cdf0e10cSrcweir 		SwFrm *pOldUp = GetUpper();
1714cdf0e10cSrcweir 
1715cdf0e10cSrcweir /* MA 13. Oct. 98: Was soll das denn sein!?
1716cdf0e10cSrcweir  * AMA 14. Dec 98: Wenn ein spaltiger Bereich keinen Platz mehr fuer seinen ersten ContentFrm
1717cdf0e10cSrcweir  * 		bietet, so soll dieser nicht nur in die naechste Spalte, sondern ggf. bis zur naechsten
1718cdf0e10cSrcweir  * 		Seite wandern und dort einen Section-Follow erzeugen.
1719cdf0e10cSrcweir  */
1720cdf0e10cSrcweir 		if( IsInSct() && bMovedFwd && bMakePage && pOldUp->IsColBodyFrm() &&
1721cdf0e10cSrcweir 			pOldUp->GetUpper()->GetUpper()->IsSctFrm() &&
1722cdf0e10cSrcweir 			( pPre || pOldUp->GetUpper()->GetPrev() ) &&
1723cdf0e10cSrcweir 			((SwSectionFrm*)pOldUp->GetUpper()->GetUpper())->MoveAllowed(this) )
1724cdf0e10cSrcweir 			bMovedFwd = sal_False;
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir         const sal_Bool bCheckForGrownBody = pOldUp->IsBodyFrm();
1727cdf0e10cSrcweir         const long nOldBodyHeight = (pOldUp->Frm().*fnRect->fnGetHeight)();
1728cdf0e10cSrcweir 
1729cdf0e10cSrcweir 		if ( !bMovedFwd && !MoveFwd( bMakePage, sal_False ) )
1730cdf0e10cSrcweir 			bMakePage = sal_False;
1731cdf0e10cSrcweir         SWREFRESHFN( this )
1732cdf0e10cSrcweir 
1733cdf0e10cSrcweir         // If MoveFwd moves the paragraph to the next page, a following
1734cdf0e10cSrcweir         // paragraph, which contains footnotes can can cause the old upper
1735*6d53c851Smseidel         // frame to grow. In this case we explicitly allow a new check
1736cdf0e10cSrcweir         // for MoveBwd. Robust: We also check the bMovedBwd flag again.
1737cdf0e10cSrcweir         // If pOldUp was a footnote frame, it has been deleted inside MoveFwd.
1738cdf0e10cSrcweir         // Therefore we only check for growing body frames.
1739cdf0e10cSrcweir         if ( bCheckForGrownBody && ! bMovedBwd && pOldUp != GetUpper() &&
1740cdf0e10cSrcweir              (pOldUp->Frm().*fnRect->fnGetHeight)() > nOldBodyHeight )
1741cdf0e10cSrcweir             bMovedFwd = sal_False;
1742cdf0e10cSrcweir         else
1743cdf0e10cSrcweir             bMovedFwd = sal_True;
1744cdf0e10cSrcweir 
1745cdf0e10cSrcweir         bFormatted = sal_False;
1746cdf0e10cSrcweir 		if ( bMoveOrFit && GetUpper() == pOldUp )
1747cdf0e10cSrcweir 		{
1748cdf0e10cSrcweir             // FME 2007-08-30 #i81146# new loop control
1749cdf0e10cSrcweir             if ( nConsequetiveFormatsWithoutChange <= cnStopFormat )
1750cdf0e10cSrcweir             {
1751cdf0e10cSrcweir     			Prepare( PREP_MUST_FIT, 0, sal_False );
1752cdf0e10cSrcweir 	    		bValidSize = sal_False;
1753cdf0e10cSrcweir 		    	bMustFit = sal_True;
1754cdf0e10cSrcweir 			    continue;
1755cdf0e10cSrcweir             }
1756cdf0e10cSrcweir 
1757cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1758cdf0e10cSrcweir             ASSERT( false, "LoopControl in SwCntntFrm::MakeAll" )
1759cdf0e10cSrcweir #endif
1760cdf0e10cSrcweir 		}
1761cdf0e10cSrcweir 		if ( bMovedBwd && GetUpper() )
1762cdf0e10cSrcweir 		{	//Unuetz gewordene Invalidierungen zuruecknehmen.
1763cdf0e10cSrcweir 			GetUpper()->ResetCompletePaint();
1764cdf0e10cSrcweir 			if( pPre && !pPre->IsSctFrm() )
1765cdf0e10cSrcweir 				::ValidateSz( pPre );
1766cdf0e10cSrcweir 		}
1767cdf0e10cSrcweir 
1768cdf0e10cSrcweir 	} //while ( !bValidPos || !bValidSize || !bValidPrtArea )
1769cdf0e10cSrcweir 
1770cdf0e10cSrcweir 
1771cdf0e10cSrcweir     // NEW: Looping Louie (Light). Should not be applied in balanced sections.
1772cdf0e10cSrcweir     // Should only be applied if there is no better solution!
1773cdf0e10cSrcweir     LOOPING_LOUIE_LIGHT( bMovedFwd && bMovedBwd && !IsInBalancedSection() &&
1774cdf0e10cSrcweir                             (
1775cdf0e10cSrcweir 
1776cdf0e10cSrcweir                                 // --> FME 2005-01-26 #118572#
1777cdf0e10cSrcweir                                 ( bFtn && !FindFtnFrm()->GetRef()->IsInSct() ) ||
1778cdf0e10cSrcweir                                 // <--
1779cdf0e10cSrcweir 
1780cdf0e10cSrcweir                                 // --> FME 2005-01-27 #i33887#
1781cdf0e10cSrcweir                                 ( IsInSct() && bKeep )
1782cdf0e10cSrcweir                                 // <--
1783cdf0e10cSrcweir 
1784cdf0e10cSrcweir                                 // ... add your conditions here ...
1785cdf0e10cSrcweir 
1786cdf0e10cSrcweir                             ),
1787cdf0e10cSrcweir                          static_cast<SwTxtFrm&>(*this) );
1788cdf0e10cSrcweir 
1789cdf0e10cSrcweir 
1790cdf0e10cSrcweir     if ( pSaveFtn )
1791cdf0e10cSrcweir 		delete pSaveFtn;
1792cdf0e10cSrcweir 
1793cdf0e10cSrcweir 	UnlockJoin();
1794cdf0e10cSrcweir 	if ( bMovedFwd || bMovedBwd )
1795cdf0e10cSrcweir 		pNotify->SetInvaKeep();
1796cdf0e10cSrcweir     // OD 2004-02-26 #i25029#
1797cdf0e10cSrcweir     if ( bMovedFwd )
1798cdf0e10cSrcweir     {
1799cdf0e10cSrcweir         pNotify->SetInvalidatePrevPrtArea();
1800cdf0e10cSrcweir     }
1801cdf0e10cSrcweir 	delete pNotify;
1802cdf0e10cSrcweir     SetFlyLock( sal_False );
1803cdf0e10cSrcweir }
1804cdf0e10cSrcweir 
1805cdf0e10cSrcweir /*************************************************************************
1806cdf0e10cSrcweir |*
1807cdf0e10cSrcweir |*	SwCntntFrm::_WouldFit()
1808cdf0e10cSrcweir |*
1809cdf0e10cSrcweir |*	Ersterstellung		MA 28. Feb. 95
1810cdf0e10cSrcweir |*	Letzte Aenderung	AMA 15. Feb. 99
1811cdf0e10cSrcweir |*
1812cdf0e10cSrcweir |*************************************************************************/
1813cdf0e10cSrcweir 
1814cdf0e10cSrcweir 
1815cdf0e10cSrcweir 
1816cdf0e10cSrcweir 
MakeNxt(SwFrm * pFrm,SwFrm * pNxt)1817cdf0e10cSrcweir void MakeNxt( SwFrm *pFrm, SwFrm *pNxt )
1818cdf0e10cSrcweir {
1819cdf0e10cSrcweir 	//fix(25455): Validieren, sonst kommt es zu einer Rekursion.
1820cdf0e10cSrcweir 	//Der erste Versuch, der Abbruch mit pFrm = 0 wenn !Valid,
1821cdf0e10cSrcweir 	//fuehrt leider zu dem Problem, dass das Keep dann u.U. nicht mehr
1822cdf0e10cSrcweir 	//korrekt beachtet wird (27417)
1823cdf0e10cSrcweir 	const sal_Bool bOldPos = pFrm->GetValidPosFlag();
1824cdf0e10cSrcweir 	const sal_Bool bOldSz  = pFrm->GetValidSizeFlag();
1825cdf0e10cSrcweir 	const sal_Bool bOldPrt = pFrm->GetValidPrtAreaFlag();
1826cdf0e10cSrcweir 	pFrm->bValidPos = pFrm->bValidPrtArea = pFrm->bValidSize = sal_True;
1827cdf0e10cSrcweir 
1828cdf0e10cSrcweir 	//fix(29272): Nicht MakeAll rufen, dort wird evtl. pFrm wieder invalidert
1829cdf0e10cSrcweir 	//und kommt rekursiv wieder herein.
1830cdf0e10cSrcweir 	if ( pNxt->IsCntntFrm() )
1831cdf0e10cSrcweir 	{
1832cdf0e10cSrcweir 		SwCntntNotify aNotify( (SwCntntFrm*)pNxt );
1833cdf0e10cSrcweir 		SwBorderAttrAccess aAccess( SwFrm::GetCache(), pNxt );
1834cdf0e10cSrcweir 		const SwBorderAttrs &rAttrs = *aAccess.Get();
1835cdf0e10cSrcweir 		if ( !pNxt->GetValidSizeFlag() )
1836cdf0e10cSrcweir         {
1837cdf0e10cSrcweir             if( pNxt->IsVertical() )
1838cdf0e10cSrcweir                 pNxt->Frm().Height( pNxt->GetUpper()->Prt().Height() );
1839cdf0e10cSrcweir             else
1840cdf0e10cSrcweir                 pNxt->Frm().Width( pNxt->GetUpper()->Prt().Width() );
1841cdf0e10cSrcweir         }
1842cdf0e10cSrcweir 		((SwCntntFrm*)pNxt)->MakePrtArea( rAttrs );
1843cdf0e10cSrcweir 		pNxt->Format( &rAttrs );
1844cdf0e10cSrcweir 	}
1845cdf0e10cSrcweir 	else
1846cdf0e10cSrcweir 	{
1847cdf0e10cSrcweir 		SwLayNotify aNotify( (SwLayoutFrm*)pNxt );
1848cdf0e10cSrcweir 		SwBorderAttrAccess aAccess( SwFrm::GetCache(), pNxt );
1849cdf0e10cSrcweir 		const SwBorderAttrs &rAttrs = *aAccess.Get();
1850cdf0e10cSrcweir 		if ( !pNxt->GetValidSizeFlag() )
1851cdf0e10cSrcweir         {
1852cdf0e10cSrcweir             if( pNxt->IsVertical() )
1853cdf0e10cSrcweir                 pNxt->Frm().Height( pNxt->GetUpper()->Prt().Height() );
1854cdf0e10cSrcweir             else
1855cdf0e10cSrcweir                 pNxt->Frm().Width( pNxt->GetUpper()->Prt().Width() );
1856cdf0e10cSrcweir         }
1857cdf0e10cSrcweir 		pNxt->Format( &rAttrs );
1858cdf0e10cSrcweir 	}
1859cdf0e10cSrcweir 
1860cdf0e10cSrcweir 	pFrm->bValidPos  	 = bOldPos;
1861cdf0e10cSrcweir 	pFrm->bValidSize 	 = bOldSz;
1862cdf0e10cSrcweir 	pFrm->bValidPrtArea  = bOldPrt;
1863cdf0e10cSrcweir }
1864cdf0e10cSrcweir 
1865cdf0e10cSrcweir // Diese Routine ueberprueft, ob zwischen dem FtnBoss von pFrm und dem
1866cdf0e10cSrcweir // von pNxt keine anderen FtnBosse liegen
1867cdf0e10cSrcweir 
lcl_IsNextFtnBoss(const SwFrm * pFrm,const SwFrm * pNxt)1868cdf0e10cSrcweir sal_Bool lcl_IsNextFtnBoss( const SwFrm *pFrm, const SwFrm* pNxt )
1869cdf0e10cSrcweir {
1870cdf0e10cSrcweir 	ASSERT( pFrm && pNxt, "lcl_IsNextFtnBoss: No Frames?" );
1871cdf0e10cSrcweir 	pFrm = pFrm->FindFtnBossFrm();
1872cdf0e10cSrcweir 	pNxt = pNxt->FindFtnBossFrm();
1873cdf0e10cSrcweir 	// Falls pFrm eine letzte Spalte ist, wird stattdessen die Seite genommen
1874cdf0e10cSrcweir 	while( pFrm && pFrm->IsColumnFrm() && !pFrm->GetNext() )
1875cdf0e10cSrcweir 		pFrm = pFrm->GetUpper()->FindFtnBossFrm();
1876cdf0e10cSrcweir 	// Falls pNxt eine erste Spalte ist, wird stattdessen die Seite genommen
1877cdf0e10cSrcweir 	while( pNxt && pNxt->IsColumnFrm() && !pNxt->GetPrev() )
1878cdf0e10cSrcweir 		pNxt = pNxt->GetUpper()->FindFtnBossFrm();
1879cdf0e10cSrcweir 	// So, jetzt muessen pFrm und pNxt entweder zwei benachbarte Seiten oder Spalten sein.
1880cdf0e10cSrcweir 	return ( pFrm && pNxt && pFrm->GetNext() == pNxt );
1881cdf0e10cSrcweir }
1882cdf0e10cSrcweir 
1883cdf0e10cSrcweir // --> OD 2007-11-26 #b6614158#
_WouldFit(SwTwips nSpace,SwLayoutFrm * pNewUpper,sal_Bool bTstMove,const bool bObjsInNewUpper)1884cdf0e10cSrcweir sal_Bool SwCntntFrm::_WouldFit( SwTwips nSpace,
1885cdf0e10cSrcweir                             SwLayoutFrm *pNewUpper,
1886cdf0e10cSrcweir                             sal_Bool bTstMove,
1887cdf0e10cSrcweir                             const bool bObjsInNewUpper )
1888cdf0e10cSrcweir // <--
1889cdf0e10cSrcweir {
1890cdf0e10cSrcweir 	//Damit die Fussnote sich ihren Platz sorgsam waehlt, muss
1891cdf0e10cSrcweir 	//sie in jedem Fall gemoved werden, wenn zwischen dem
1892cdf0e10cSrcweir 	//neuen Upper und ihrer aktuellen Seite/Spalte mindestens eine
1893cdf0e10cSrcweir 	//Seite/Spalte liegt.
1894cdf0e10cSrcweir 	SwFtnFrm* pFtnFrm = 0;
1895cdf0e10cSrcweir 	if ( IsInFtn() )
1896cdf0e10cSrcweir 	{
1897cdf0e10cSrcweir 		if( !lcl_IsNextFtnBoss( pNewUpper, this ) )
1898cdf0e10cSrcweir 			return sal_True;
1899cdf0e10cSrcweir 		pFtnFrm = FindFtnFrm();
1900cdf0e10cSrcweir 	}
1901cdf0e10cSrcweir 
1902cdf0e10cSrcweir 	sal_Bool bRet;
1903cdf0e10cSrcweir 	sal_Bool bSplit = !pNewUpper->Lower();
1904cdf0e10cSrcweir 	SwCntntFrm *pFrm = this;
1905cdf0e10cSrcweir     const SwFrm *pTmpPrev = pNewUpper->Lower();
1906cdf0e10cSrcweir     if( pTmpPrev && pTmpPrev->IsFtnFrm() )
1907cdf0e10cSrcweir         pTmpPrev = ((SwFtnFrm*)pTmpPrev)->Lower();
1908cdf0e10cSrcweir     while ( pTmpPrev && pTmpPrev->GetNext() )
1909cdf0e10cSrcweir         pTmpPrev = pTmpPrev->GetNext();
1910cdf0e10cSrcweir 	do
1911cdf0e10cSrcweir 	{
1912cdf0e10cSrcweir         // --> FME 2005-03-31 #b6236853# #i46181#
1913cdf0e10cSrcweir         SwTwips nSecondCheck = 0;
1914cdf0e10cSrcweir         SwTwips nOldSpace = nSpace;
1915cdf0e10cSrcweir         sal_Bool bOldSplit = bSplit;
1916cdf0e10cSrcweir         // <--
1917cdf0e10cSrcweir 
1918cdf0e10cSrcweir 		if ( bTstMove || IsInFly() || ( IsInSct() &&
1919cdf0e10cSrcweir 			 ( pFrm->GetUpper()->IsColBodyFrm() || ( pFtnFrm &&
1920cdf0e10cSrcweir 			   pFtnFrm->GetUpper()->GetUpper()->IsColumnFrm() ) ) ) )
1921cdf0e10cSrcweir 		{
1922cdf0e10cSrcweir 			//Jetzt wirds ein bischen hinterlistig; empfindliche Gemueter sollten
1923cdf0e10cSrcweir 			//lieber wegsehen. Wenn ein Flys Spalten enthaelt so sind die Cntnts
1924cdf0e10cSrcweir 			//moveable, mit Ausnahme der in der letzten Spalte (siehe
1925cdf0e10cSrcweir 			//SwFrm::IsMoveable()). Zurueckfliessen duerfen sie aber natuerlich.
1926cdf0e10cSrcweir 			//Das WouldFit() liefert leider nur dann einen vernueftigen Wert, wenn
1927cdf0e10cSrcweir 			//der Frm moveable ist. Um dem WouldFit() einen Moveable Frm
1928cdf0e10cSrcweir 			//vorzugaukeln haenge ich ihn einfach solange um.
1929cdf0e10cSrcweir 			// Auch bei spaltigen Bereichen muss umgehaengt werden, damit
1930cdf0e10cSrcweir 			// SwSectionFrm::Growable() den richtigen Wert liefert.
1931cdf0e10cSrcweir 			// Innerhalb von Fussnoten muss ggf. sogar der SwFtnFrm umgehaengt werden,
1932cdf0e10cSrcweir 			// falls es dort keinen SwFtnFrm gibt.
1933cdf0e10cSrcweir 			SwFrm* pTmpFrm = pFrm->IsInFtn() && !pNewUpper->FindFtnFrm() ?
1934cdf0e10cSrcweir 							 (SwFrm*)pFrm->FindFtnFrm() : pFrm;
1935cdf0e10cSrcweir 			SwLayoutFrm *pUp = pTmpFrm->GetUpper();
1936cdf0e10cSrcweir 			SwFrm *pOldNext = pTmpFrm->GetNext();
1937cdf0e10cSrcweir 			pTmpFrm->Remove();
1938cdf0e10cSrcweir 			pTmpFrm->InsertBefore( pNewUpper, 0 );
1939cdf0e10cSrcweir             if ( pFrm->IsTxtFrm() &&
1940cdf0e10cSrcweir                  ( bTstMove ||
1941cdf0e10cSrcweir                    ((SwTxtFrm*)pFrm)->HasFollow() ||
1942cdf0e10cSrcweir                    ( !((SwTxtFrm*)pFrm)->HasPara() &&
1943cdf0e10cSrcweir                      !((SwTxtFrm*)pFrm)->IsEmpty()
1944cdf0e10cSrcweir                    )
1945cdf0e10cSrcweir                  )
1946cdf0e10cSrcweir                )
1947cdf0e10cSrcweir 			{
1948cdf0e10cSrcweir 				bTstMove = sal_True;
1949cdf0e10cSrcweir                 bRet = ((SwTxtFrm*)pFrm)->TestFormat( pTmpPrev, nSpace, bSplit );
1950cdf0e10cSrcweir 			}
1951cdf0e10cSrcweir 			else
1952cdf0e10cSrcweir                 bRet = pFrm->WouldFit( nSpace, bSplit, sal_False );
1953cdf0e10cSrcweir 
1954cdf0e10cSrcweir             pTmpFrm->Remove();
1955cdf0e10cSrcweir 			pTmpFrm->InsertBefore( pUp, pOldNext );
1956cdf0e10cSrcweir 		}
1957cdf0e10cSrcweir 		else
1958cdf0e10cSrcweir         {
1959cdf0e10cSrcweir             bRet = pFrm->WouldFit( nSpace, bSplit, sal_False );
1960cdf0e10cSrcweir             nSecondCheck = !bSplit ? 1 : 0;
1961cdf0e10cSrcweir         }
1962cdf0e10cSrcweir 
1963cdf0e10cSrcweir         SwBorderAttrAccess aAccess( SwFrm::GetCache(), pFrm );
1964cdf0e10cSrcweir         const SwBorderAttrs &rAttrs = *aAccess.Get();
1965cdf0e10cSrcweir 
1966cdf0e10cSrcweir 		//Bitter aber wahr: Der Abstand muss auch noch mit einkalkuliert werden.
1967cdf0e10cSrcweir 		//Bei TestFormatierung ist dies bereits geschehen.
1968cdf0e10cSrcweir 		if ( bRet && !bTstMove )
1969cdf0e10cSrcweir 		{
1970cdf0e10cSrcweir 			SwTwips nUpper;
1971cdf0e10cSrcweir 
1972cdf0e10cSrcweir             if ( pTmpPrev )
1973cdf0e10cSrcweir 			{
1974cdf0e10cSrcweir                 nUpper = CalcUpperSpace( NULL, pTmpPrev );
1975cdf0e10cSrcweir 
1976cdf0e10cSrcweir                 // in balanced columned section frames we do not want the
1977cdf0e10cSrcweir                 // common border
1978cdf0e10cSrcweir                 sal_Bool bCommonBorder = sal_True;
1979cdf0e10cSrcweir                 if ( pFrm->IsInSct() && pFrm->GetUpper()->IsColBodyFrm() )
1980cdf0e10cSrcweir                 {
1981cdf0e10cSrcweir                     const SwSectionFrm* pSct = pFrm->FindSctFrm();
1982cdf0e10cSrcweir                     bCommonBorder = pSct->GetFmt()->GetBalancedColumns().GetValue();
1983cdf0e10cSrcweir                 }
1984cdf0e10cSrcweir 
1985cdf0e10cSrcweir                 // --> FME 2005-03-31 #b6236853# #i46181#
1986cdf0e10cSrcweir                 nSecondCheck = ( 1 == nSecondCheck &&
1987cdf0e10cSrcweir                                  pFrm == this &&
1988cdf0e10cSrcweir                                  IsTxtFrm() &&
1989cdf0e10cSrcweir                                  bCommonBorder &&
1990cdf0e10cSrcweir                                  !static_cast<const SwTxtFrm*>(this)->IsEmpty() ) ?
1991cdf0e10cSrcweir                                  nUpper :
1992cdf0e10cSrcweir                                  0;
1993cdf0e10cSrcweir                 // <--
1994cdf0e10cSrcweir 
1995cdf0e10cSrcweir                 nUpper += bCommonBorder ?
1996cdf0e10cSrcweir                           rAttrs.GetBottomLine( *(pFrm) ) :
1997cdf0e10cSrcweir                           rAttrs.CalcBottomLine();
1998cdf0e10cSrcweir 
1999cdf0e10cSrcweir             }
2000cdf0e10cSrcweir 			else
2001cdf0e10cSrcweir             {
2002cdf0e10cSrcweir                 // --> FME 2005-03-31 #b6236853# #i46181#
2003cdf0e10cSrcweir                 nSecondCheck = 0;
2004cdf0e10cSrcweir                 // <--
2005cdf0e10cSrcweir 
2006cdf0e10cSrcweir                 if( pFrm->IsVertical() )
2007cdf0e10cSrcweir                     nUpper = pFrm->Frm().Width() - pFrm->Prt().Width();
2008cdf0e10cSrcweir                 else
2009cdf0e10cSrcweir                     nUpper = pFrm->Frm().Height() - pFrm->Prt().Height();
2010cdf0e10cSrcweir             }
2011cdf0e10cSrcweir 
2012cdf0e10cSrcweir 			nSpace -= nUpper;
2013cdf0e10cSrcweir 
2014cdf0e10cSrcweir 			if ( nSpace < 0 )
2015cdf0e10cSrcweir             {
2016cdf0e10cSrcweir 				bRet = sal_False;
2017cdf0e10cSrcweir 
2018cdf0e10cSrcweir                 // --> FME 2005-03-31 #b6236853# #i46181#
2019cdf0e10cSrcweir                 if ( nSecondCheck > 0 )
2020cdf0e10cSrcweir                 {
2021cdf0e10cSrcweir                     // The following code is indented to solve a (rare) problem
2022cdf0e10cSrcweir                     // causing some frames not to move backward:
2023cdf0e10cSrcweir                     // SwTxtFrm::WouldFit() claims that the whole paragraph
2024cdf0e10cSrcweir                     // fits into the given space and subtracts the height of
2025cdf0e10cSrcweir                     // all lines from nSpace. nSpace - nUpper is not a valid
2026cdf0e10cSrcweir                     // indicator if the frame should be allowed to move backward.
2027cdf0e10cSrcweir                     // We do a second check with the original remaining space
2028cdf0e10cSrcweir                     // reduced by the required upper space:
2029cdf0e10cSrcweir                     nOldSpace -= nSecondCheck;
2030cdf0e10cSrcweir                     const bool bSecondRet = nOldSpace >= 0 && pFrm->WouldFit( nOldSpace, bOldSplit, sal_False );
2031cdf0e10cSrcweir                     if ( bSecondRet && bOldSplit && nOldSpace >= 0 )
2032cdf0e10cSrcweir                     {
2033cdf0e10cSrcweir                         bRet = sal_True;
2034cdf0e10cSrcweir                         bSplit = sal_True;
2035cdf0e10cSrcweir                     }
2036cdf0e10cSrcweir                 }
2037cdf0e10cSrcweir                 // <--
2038cdf0e10cSrcweir             }
2039cdf0e10cSrcweir 		}
2040cdf0e10cSrcweir 
2041cdf0e10cSrcweir         // OD 2004-03-01 #106629# - also consider lower spacing in table cells
2042cdf0e10cSrcweir         if ( bRet && IsInTab() &&
2043cdf0e10cSrcweir              pNewUpper->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::ADD_PARA_SPACING_TO_TABLE_CELLS) )
2044cdf0e10cSrcweir         {
2045cdf0e10cSrcweir             nSpace -= rAttrs.GetULSpace().GetLower();
2046cdf0e10cSrcweir             if ( nSpace < 0 )
2047cdf0e10cSrcweir             {
2048cdf0e10cSrcweir                 bRet = sal_False;
2049cdf0e10cSrcweir             }
2050cdf0e10cSrcweir         }
2051cdf0e10cSrcweir 
2052cdf0e10cSrcweir         if ( bRet && !bSplit && pFrm->IsKeep( rAttrs.GetAttrSet() ) )
2053cdf0e10cSrcweir 		{
2054cdf0e10cSrcweir 			if( bTstMove )
2055cdf0e10cSrcweir             {
2056cdf0e10cSrcweir 				while( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->HasFollow() )
2057cdf0e10cSrcweir                 {
2058cdf0e10cSrcweir 					pFrm = ((SwTxtFrm*)pFrm)->GetFollow();
2059cdf0e10cSrcweir                 }
2060cdf0e10cSrcweir                 // OD 11.04.2003 #108824# - If last follow frame of <this> text
2061cdf0e10cSrcweir                 // frame isn't valid, a formatting of the next content frame
2062cdf0e10cSrcweir                 // doesn't makes sense. Thus, return sal_True.
2063cdf0e10cSrcweir                 if ( IsAnFollow( pFrm ) && !pFrm->IsValid() )
2064cdf0e10cSrcweir                 {
2065cdf0e10cSrcweir                     ASSERT( false, "Only a warning for task 108824:/n<SwCntntFrm::_WouldFit(..) - follow not valid!" );
2066cdf0e10cSrcweir                     return sal_True;
2067cdf0e10cSrcweir                 }
2068cdf0e10cSrcweir             }
2069cdf0e10cSrcweir 			SwFrm *pNxt;
2070cdf0e10cSrcweir 			if( 0 != (pNxt = pFrm->FindNext()) && pNxt->IsCntntFrm() &&
2071cdf0e10cSrcweir 				( !pFtnFrm || ( pNxt->IsInFtn() &&
2072cdf0e10cSrcweir 				  pNxt->FindFtnFrm()->GetAttr() == pFtnFrm->GetAttr() ) ) )
2073cdf0e10cSrcweir 			{
2074cdf0e10cSrcweir 				// ProbeFormatierung vertraegt keine absatz- oder gar zeichengebundene Objekte
2075cdf0e10cSrcweir                 // --> OD 2007-11-26 #b6614158#
2076cdf0e10cSrcweir                 // current solution for the test formatting doesn't work, if
2077cdf0e10cSrcweir                 // objects are present in the remaining area of the new upper
2078cdf0e10cSrcweir                 if ( bTstMove &&
2079cdf0e10cSrcweir                      ( pNxt->GetDrawObjs() || bObjsInNewUpper ) )
2080cdf0e10cSrcweir                 {
2081cdf0e10cSrcweir                     return sal_True;
2082cdf0e10cSrcweir                 }
2083cdf0e10cSrcweir                 // <--
2084cdf0e10cSrcweir 
2085cdf0e10cSrcweir 				if ( !pNxt->IsValid() )
2086cdf0e10cSrcweir 					MakeNxt( pFrm, pNxt );
2087cdf0e10cSrcweir 
2088cdf0e10cSrcweir 				//Kleiner Trick: Wenn der naechste einen Vorgaenger hat, so hat
2089cdf0e10cSrcweir 				//er den Absatzabstand bereits berechnet. Er braucht dann nicht
2090cdf0e10cSrcweir 				//teuer kalkuliert werden.
2091cdf0e10cSrcweir 				if( lcl_NotHiddenPrev( pNxt ) )
2092cdf0e10cSrcweir                     pTmpPrev = 0;
2093cdf0e10cSrcweir 				else
2094cdf0e10cSrcweir 				{
2095cdf0e10cSrcweir 					if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsHiddenNow() )
2096cdf0e10cSrcweir                         pTmpPrev = lcl_NotHiddenPrev( pFrm );
2097cdf0e10cSrcweir 					else
2098cdf0e10cSrcweir                         pTmpPrev = pFrm;
2099cdf0e10cSrcweir 				}
2100cdf0e10cSrcweir 				pFrm = (SwCntntFrm*)pNxt;
2101cdf0e10cSrcweir 			}
2102cdf0e10cSrcweir 			else
2103cdf0e10cSrcweir 				pFrm = 0;
2104cdf0e10cSrcweir 		}
2105cdf0e10cSrcweir 		else
2106cdf0e10cSrcweir 			pFrm = 0;
2107cdf0e10cSrcweir 
2108cdf0e10cSrcweir 	} while ( bRet && pFrm );
2109cdf0e10cSrcweir 
2110cdf0e10cSrcweir 	return bRet;
2111cdf0e10cSrcweir }
2112