xref: /aoo41x/main/sw/source/core/text/txtfly.cxx (revision efeef26f)
1*efeef26fSAndrew Rist /**************************************************************
2*efeef26fSAndrew Rist  *
3*efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*efeef26fSAndrew Rist  * distributed with this work for additional information
6*efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*efeef26fSAndrew Rist  *
11*efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*efeef26fSAndrew Rist  *
13*efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17*efeef26fSAndrew Rist  * specific language governing permissions and limitations
18*efeef26fSAndrew Rist  * under the License.
19*efeef26fSAndrew Rist  *
20*efeef26fSAndrew Rist  *************************************************************/
21*efeef26fSAndrew Rist 
22*efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vcl/outdev.hxx>
28cdf0e10cSrcweir #include <vcl/virdev.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir #include "viewsh.hxx"
31cdf0e10cSrcweir #include "pagefrm.hxx"
32cdf0e10cSrcweir #include "rootfrm.hxx"
33cdf0e10cSrcweir #include "viewimp.hxx"		// SwViewImp
34cdf0e10cSrcweir #include "pam.hxx"			// SwPosition
35cdf0e10cSrcweir #include "swregion.hxx"		// SwRegionRects
36cdf0e10cSrcweir #include "dcontact.hxx"		// SwContact
37cdf0e10cSrcweir #include "dflyobj.hxx"		// SdrObject
38cdf0e10cSrcweir #include "flyfrm.hxx"	  // SwFlyFrm
39cdf0e10cSrcweir #include "frmtool.hxx"	  // ::DrawGraphic
40cdf0e10cSrcweir #include "porfld.hxx"		// SwGrfNumPortion
41cdf0e10cSrcweir #include "txtfrm.hxx"     // SwTxtFrm
42cdf0e10cSrcweir #include "itrform2.hxx"   // SwTxtFormatter
43cdf0e10cSrcweir #include "porfly.hxx"     // NewFlyCntPortion
44cdf0e10cSrcweir #include "porfld.hxx"     // SwGrfNumPortion
45cdf0e10cSrcweir #include "txtfly.hxx"     // SwTxtFly
46cdf0e10cSrcweir #include "txtpaint.hxx"   // SwSaveClip
47cdf0e10cSrcweir #include "txtatr.hxx"     // SwTxtFlyCnt
48cdf0e10cSrcweir #include "txtcfg.hxx"
49cdf0e10cSrcweir #include "notxtfrm.hxx"
50cdf0e10cSrcweir #include "flyfrms.hxx"
51cdf0e10cSrcweir #include "fmtcnct.hxx"  // SwFmtChain
52cdf0e10cSrcweir #include <pormulti.hxx> 	// SwMultiPortion
53cdf0e10cSrcweir #include <svx/obj3d.hxx>
54cdf0e10cSrcweir #include <editeng/txtrange.hxx>
55cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
56cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
57cdf0e10cSrcweir // --> OD 2004-06-16 #i28701#
58cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
59cdf0e10cSrcweir // <--
60cdf0e10cSrcweir #include <txtflcnt.hxx>
61cdf0e10cSrcweir #include <fmtsrnd.hxx>
62cdf0e10cSrcweir #include <fmtanchr.hxx>
63cdf0e10cSrcweir #include <fmtflcnt.hxx>
64cdf0e10cSrcweir #include <frmfmt.hxx>
65cdf0e10cSrcweir #include <pagedesc.hxx> // SwPageDesc
66cdf0e10cSrcweir #include <tgrditem.hxx>
67cdf0e10cSrcweir #include <sortedobjs.hxx>
68cdf0e10cSrcweir #include <layouter.hxx>
69cdf0e10cSrcweir #include <IDocumentDrawModelAccess.hxx>
70cdf0e10cSrcweir #include <IDocumentLayoutAccess.hxx>
71cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
72cdf0e10cSrcweir #include <svx/obj3d.hxx>
73cdf0e10cSrcweir #include <editeng/txtrange.hxx>
74cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
75cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
76cdf0e10cSrcweir #include <editeng/lspcitem.hxx>
77cdf0e10cSrcweir #include <svx/svdoedge.hxx>
78cdf0e10cSrcweir #include "doc.hxx"
79cdf0e10cSrcweir 
80cdf0e10cSrcweir #ifdef DBG_UTIL
81cdf0e10cSrcweir #include "viewopt.hxx"	// SwViewOptions, nur zum Testen (Test2)
82cdf0e10cSrcweir #include "doc.hxx"
83cdf0e10cSrcweir #endif
84cdf0e10cSrcweir 
85cdf0e10cSrcweir #ifdef VERT_DISTANCE
86cdf0e10cSrcweir #include <math.h>
87cdf0e10cSrcweir #endif
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 
90cdf0e10cSrcweir using namespace ::com::sun::star;
91cdf0e10cSrcweir 
92cdf0e10cSrcweir /*****************************************************************************
93cdf0e10cSrcweir  * Beschreibung:
94cdf0e10cSrcweir  * Die Klasse SwTxtFly soll die Universalschnittstelle zwischen der
95cdf0e10cSrcweir  * Formatierung/Textausgabe und den u.U. ueberlappenden freifliegenden
96cdf0e10cSrcweir  * Frames sein.
97cdf0e10cSrcweir  * Waehrend der Formatierung erkundigt sich der Formatierer beim SwTxtFly,
98cdf0e10cSrcweir  * ob ein bestimmter Bereich durch die Attribute eines ueberlappenden
99cdf0e10cSrcweir  * Frames vorliegt. Solche Bereiche werden in Form von Dummy-Portions
100cdf0e10cSrcweir  * abgebildet.
101cdf0e10cSrcweir  * Die gesamte Textausgabe und Retusche wird ebenfalls an ein SwTxtFly
102cdf0e10cSrcweir  * weitergeleitet. Dieser entscheidet, ob Textteile geclippt werden muessen
103cdf0e10cSrcweir  * und zerteilt z.B. die Bereiche bei einem DrawRect.
104cdf0e10cSrcweir  * Zu beachten ist, dass alle freifliegenden Frames in einem nach TopLeft
105cdf0e10cSrcweir  * sortiertem PtrArray an der Seite zu finden sind. Intern wird immer nur
106cdf0e10cSrcweir  * in dokumentglobalen Werten gerechnet. Die IN- und OUT-Parameter sind
107cdf0e10cSrcweir  * jedoch in den meisten Faellen an die Beduerfnisse des LineIters
108cdf0e10cSrcweir  * zugeschnitten, d.h. sie werden in frame- oder windowlokalen Koordinaten
109cdf0e10cSrcweir  * konvertiert.
110cdf0e10cSrcweir  * Wenn mehrere Frames mit Umlaufattributen in einer Zeile liegen,
111cdf0e10cSrcweir  * ergeben sich unterschiedliche Auswirkungen fuer den Textfluss:
112cdf0e10cSrcweir  *
113cdf0e10cSrcweir  *		L/R    P	 L	   R	 K
114cdf0e10cSrcweir  *		 P	 -P-P- -P-L  -P R- -P K
115cdf0e10cSrcweir  *		 L	 -L P- -L L  -L R- -L K
116cdf0e10cSrcweir  *		 R	  R-P-	R-L   R R-	R K
117cdf0e10cSrcweir  *		 K	  K P-	K L   K R-	K K
118cdf0e10cSrcweir  *
119cdf0e10cSrcweir  * (P=parallel, L=links, R=rechts, K=kein Umlauf)
120cdf0e10cSrcweir  *
121cdf0e10cSrcweir  * Das Verhalten so beschreiben:
122cdf0e10cSrcweir  * Jeder Rahmen kann Text verdraengen, wobei der Einfluss allerdings nur
123cdf0e10cSrcweir  * bis zum naechsten Rahmen reicht.
124cdf0e10cSrcweir  *****************************************************************************/
125cdf0e10cSrcweir 
CalcUnclipped(SwTwips & rTop,SwTwips & rBottom)126cdf0e10cSrcweir void SwTxtFormatter::CalcUnclipped( SwTwips& rTop, SwTwips& rBottom )
127cdf0e10cSrcweir {
128cdf0e10cSrcweir     ASSERT( ! pFrm->IsVertical() || pFrm->IsSwapped(),
129cdf0e10cSrcweir             "SwTxtFormatter::CalcUnclipped with unswapped frame" )
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	long nFlyAsc, nFlyDesc;
132cdf0e10cSrcweir     // OD 08.01.2004 #i11859# - use new method <SwLineLayout::MaxAscentDescent(..)>
133cdf0e10cSrcweir     //lcl_MaxAscDescent( pCurr, rTop, rBottom, nFlyAsc, nFlyDesc );
134cdf0e10cSrcweir     pCurr->MaxAscentDescent( rTop, rBottom, nFlyAsc, nFlyDesc );
135cdf0e10cSrcweir 	rTop = Y() + GetCurr()->GetAscent();
136cdf0e10cSrcweir 	rBottom = rTop + nFlyDesc;
137cdf0e10cSrcweir 	rTop -= nFlyAsc;
138cdf0e10cSrcweir }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir /*************************************************************************
141cdf0e10cSrcweir  * SwTxtFormatter::UpdatePos() aktualisiert die Referenzpunkte der zeichengeb.
142cdf0e10cSrcweir  * Objekte, z. B. nach Adjustierung ( rechtsbuendig, Blocksatz etc. )
143cdf0e10cSrcweir  * ( hauptsaechlich Korrrektur der X-Position )
144cdf0e10cSrcweir  *************************************************************************/
145cdf0e10cSrcweir 
UpdatePos(SwLineLayout * pCurrent,Point aStart,xub_StrLen nStartIdx,sal_Bool bAllWays) const146cdf0e10cSrcweir void SwTxtFormatter::UpdatePos( SwLineLayout *pCurrent, Point aStart,
147cdf0e10cSrcweir 	xub_StrLen nStartIdx, sal_Bool bAllWays ) const
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     ASSERT( ! pFrm->IsVertical() || pFrm->IsSwapped(),
150cdf0e10cSrcweir             "SwTxtFormatter::UpdatePos with unswapped frame" )
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     if( GetInfo().IsTest() )
153cdf0e10cSrcweir 		return;
154cdf0e10cSrcweir     SwLinePortion *pFirst = pCurrent->GetFirstPortion();
155cdf0e10cSrcweir     SwLinePortion *pPos = pFirst;
156cdf0e10cSrcweir 	SwTxtPaintInfo aTmpInf( GetInfo() );
157cdf0e10cSrcweir     aTmpInf.SetpSpaceAdd( pCurrent->GetpLLSpaceAdd() );
158cdf0e10cSrcweir 	aTmpInf.ResetSpaceIdx();
159cdf0e10cSrcweir     aTmpInf.SetKanaComp( pCurrent->GetpKanaComp() );
160cdf0e10cSrcweir     aTmpInf.ResetKanaIdx();
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	// Die Groesse des Frames
163cdf0e10cSrcweir 	aTmpInf.SetIdx( nStartIdx );
164cdf0e10cSrcweir 	aTmpInf.SetPos( aStart );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	long nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc;
167cdf0e10cSrcweir     // OD 08.01.2004 #i11859# - use new method <SwLineLayout::MaxAscentDescent(..)>
168cdf0e10cSrcweir     //lcl_MaxAscDescent( pPos, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc );
169cdf0e10cSrcweir     pCurrent->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir     KSHORT nTmpHeight = pCurrent->GetRealHeight();
172cdf0e10cSrcweir     KSHORT nAscent = pCurrent->GetAscent() + nTmpHeight - pCurrent->Height();
173cdf0e10cSrcweir     objectpositioning::AsCharFlags nFlags = AS_CHAR_ULSPACE;
174cdf0e10cSrcweir 	if( GetMulti() )
175cdf0e10cSrcweir 	{
176cdf0e10cSrcweir 		aTmpInf.SetDirection( GetMulti()->GetDirection() );
177cdf0e10cSrcweir 		if( GetMulti()->HasRotation() )
178cdf0e10cSrcweir 		{
179cdf0e10cSrcweir             nFlags |= AS_CHAR_ROTATE;
180cdf0e10cSrcweir 			if( GetMulti()->IsRevers() )
181cdf0e10cSrcweir 			{
182cdf0e10cSrcweir                 nFlags |= AS_CHAR_REVERSE;
183cdf0e10cSrcweir 				aTmpInf.X( aTmpInf.X() - nAscent );
184cdf0e10cSrcweir 			}
185cdf0e10cSrcweir 			else
186cdf0e10cSrcweir 				aTmpInf.X( aTmpInf.X() + nAscent );
187cdf0e10cSrcweir 		}
188cdf0e10cSrcweir         else
189cdf0e10cSrcweir         {
190cdf0e10cSrcweir             if ( GetMulti()->IsBidi() )
191cdf0e10cSrcweir                 nFlags |= AS_CHAR_BIDI;
192cdf0e10cSrcweir 			aTmpInf.Y( aTmpInf.Y() + nAscent );
193cdf0e10cSrcweir         }
194cdf0e10cSrcweir 	}
195cdf0e10cSrcweir 	else
196cdf0e10cSrcweir 		aTmpInf.Y( aTmpInf.Y() + nAscent );
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	while( pPos )
199cdf0e10cSrcweir 	{
200cdf0e10cSrcweir 		// bislang ist mir nur ein Fall bekannt, wo die Positionsaenderung
201cdf0e10cSrcweir 		// (verursacht durch das Adjustment) fuer eine Portion wichtig
202cdf0e10cSrcweir 		// sein koennte: Bei FlyCntPortions muss ein SetRefPoint erfolgen.
203cdf0e10cSrcweir 		if( ( pPos->IsFlyCntPortion() || pPos->IsGrfNumPortion() )
204cdf0e10cSrcweir 			&& ( bAllWays || !IsQuick() ) )
205cdf0e10cSrcweir 		{
206cdf0e10cSrcweir             // OD 08.01.2004 #i11859# - use new method <SwLineLayout::MaxAscentDescent(..)>
207cdf0e10cSrcweir             //lcl_MaxAscDescent( pFirst, nTmpAscent, nTmpDescent,
208cdf0e10cSrcweir             //                  nFlyAsc, nFlyDesc, pPos );
209cdf0e10cSrcweir             pCurrent->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, pPos );
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 			if( pPos->IsGrfNumPortion() )
212cdf0e10cSrcweir 			{
213cdf0e10cSrcweir 				if( !nFlyAsc && !nFlyDesc )
214cdf0e10cSrcweir 				{
215cdf0e10cSrcweir 					nTmpAscent = nAscent;
216cdf0e10cSrcweir 					nFlyAsc = nAscent;
217cdf0e10cSrcweir 					nTmpDescent = nTmpHeight - nAscent;
218cdf0e10cSrcweir 					nFlyDesc = nTmpDescent;
219cdf0e10cSrcweir 				}
220cdf0e10cSrcweir 				((SwGrfNumPortion*)pPos)->SetBase( nTmpAscent, nTmpDescent,
221cdf0e10cSrcweir 												   nFlyAsc, nFlyDesc );
222cdf0e10cSrcweir 			}
223cdf0e10cSrcweir 			else
224cdf0e10cSrcweir 			{
225cdf0e10cSrcweir                 Point aBase( aTmpInf.GetPos() );
226cdf0e10cSrcweir                 if ( GetInfo().GetTxtFrm()->IsVertical() )
227cdf0e10cSrcweir                     GetInfo().GetTxtFrm()->SwitchHorizontalToVertical( aBase );
228cdf0e10cSrcweir 
229cdf0e10cSrcweir                 ((SwFlyCntPortion*)pPos)->SetBase( *aTmpInf.GetTxtFrm(),
230cdf0e10cSrcweir                     aBase, nTmpAscent, nTmpDescent, nFlyAsc,
231cdf0e10cSrcweir                     nFlyDesc, nFlags );
232cdf0e10cSrcweir 			}
233cdf0e10cSrcweir 		}
234cdf0e10cSrcweir 		if( pPos->IsMultiPortion() && ((SwMultiPortion*)pPos)->HasFlyInCntnt() )
235cdf0e10cSrcweir 		{
236cdf0e10cSrcweir 			ASSERT( !GetMulti(), "Too much multi" );
237cdf0e10cSrcweir 			((SwTxtFormatter*)this)->pMulti = (SwMultiPortion*)pPos;
238cdf0e10cSrcweir 			SwLineLayout *pLay = &GetMulti()->GetRoot();
239cdf0e10cSrcweir             Point aSt( aTmpInf.X(), aStart.Y() );
240cdf0e10cSrcweir 
241cdf0e10cSrcweir             if ( GetMulti()->HasBrackets() )
242cdf0e10cSrcweir             {
243cdf0e10cSrcweir                 ASSERT( GetMulti()->IsDouble(), "Brackets only for doubles");
244cdf0e10cSrcweir                 aSt.X() += ((SwDoubleLinePortion*)GetMulti())->PreWidth();
245cdf0e10cSrcweir             }
246cdf0e10cSrcweir             else if( GetMulti()->HasRotation() )
247cdf0e10cSrcweir 			{
248cdf0e10cSrcweir                 aSt.Y() += pCurrent->GetAscent() - GetMulti()->GetAscent();
249cdf0e10cSrcweir                 if( GetMulti()->IsRevers() )
250cdf0e10cSrcweir                     aSt.X() += GetMulti()->Width();
251cdf0e10cSrcweir                 else
252cdf0e10cSrcweir 					aSt.Y() += GetMulti()->Height();
253cdf0e10cSrcweir 	   		}
254cdf0e10cSrcweir             else if ( GetMulti()->IsBidi() )
255cdf0e10cSrcweir                 // jump to end of the bidi portion
256cdf0e10cSrcweir                 aSt.X() += pLay->Width();
257cdf0e10cSrcweir 
258cdf0e10cSrcweir             xub_StrLen nStIdx = aTmpInf.GetIdx();
259cdf0e10cSrcweir 			do
260cdf0e10cSrcweir 			{
261cdf0e10cSrcweir 				UpdatePos( pLay, aSt, nStIdx, bAllWays );
262cdf0e10cSrcweir 				nStIdx = nStIdx + pLay->GetLen();
263cdf0e10cSrcweir 				aSt.Y() += pLay->Height();
264cdf0e10cSrcweir 				pLay = pLay->GetNext();
265cdf0e10cSrcweir 			} while ( pLay );
266cdf0e10cSrcweir 			((SwTxtFormatter*)this)->pMulti = NULL;
267cdf0e10cSrcweir 		}
268cdf0e10cSrcweir 		pPos->Move( aTmpInf );
269cdf0e10cSrcweir 		pPos = pPos->GetPortion();
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir }
272cdf0e10cSrcweir 
273cdf0e10cSrcweir /*************************************************************************
274cdf0e10cSrcweir  * SwTxtFormatter::AlignFlyInCntBase()
275cdf0e10cSrcweir  * richtet die zeichengeb. Objekte in Y-Richtung ggf. neu aus.
276cdf0e10cSrcweir  *************************************************************************/
277cdf0e10cSrcweir 
AlignFlyInCntBase(long nBaseLine) const278cdf0e10cSrcweir void SwTxtFormatter::AlignFlyInCntBase( long nBaseLine ) const
279cdf0e10cSrcweir {
280cdf0e10cSrcweir     ASSERT( ! pFrm->IsVertical() || pFrm->IsSwapped(),
281cdf0e10cSrcweir             "SwTxtFormatter::AlignFlyInCntBase with unswapped frame" )
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	if( GetInfo().IsTest() )
284cdf0e10cSrcweir 		return;
285cdf0e10cSrcweir 	SwLinePortion *pFirst = pCurr->GetFirstPortion();
286cdf0e10cSrcweir 	SwLinePortion *pPos = pFirst;
287cdf0e10cSrcweir     objectpositioning::AsCharFlags nFlags = AS_CHAR_NOFLAG;
288cdf0e10cSrcweir 	if( GetMulti() && GetMulti()->HasRotation() )
289cdf0e10cSrcweir 	{
290cdf0e10cSrcweir         nFlags |= AS_CHAR_ROTATE;
291cdf0e10cSrcweir 		if( GetMulti()->IsRevers() )
292cdf0e10cSrcweir             nFlags |= AS_CHAR_REVERSE;
293cdf0e10cSrcweir 	}
294cdf0e10cSrcweir 
295cdf0e10cSrcweir 	long nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc;
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	while( pPos )
298cdf0e10cSrcweir 	{
299cdf0e10cSrcweir 		if( pPos->IsFlyCntPortion() || pPos->IsGrfNumPortion() )
300cdf0e10cSrcweir 		{
301cdf0e10cSrcweir             // OD 08.01.2004 #i11859# - use new method <SwLineLayout::MaxAscentDescent(..)>
302cdf0e10cSrcweir             //lcl_MaxAscDescent( pFirst, nTmpAscent, nTmpDescent,
303cdf0e10cSrcweir             //                  nFlyAsc, nFlyDesc, pPos );
304cdf0e10cSrcweir             pCurr->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, pPos );
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 			if( pPos->IsGrfNumPortion() )
307cdf0e10cSrcweir 				((SwGrfNumPortion*)pPos)->SetBase( nTmpAscent, nTmpDescent,
308cdf0e10cSrcweir 												   nFlyAsc, nFlyDesc );
309cdf0e10cSrcweir 			else
310cdf0e10cSrcweir 			{
311cdf0e10cSrcweir                 Point aBase;
312cdf0e10cSrcweir                 if ( GetInfo().GetTxtFrm()->IsVertical() )
313cdf0e10cSrcweir                 {
314cdf0e10cSrcweir                     nBaseLine = GetInfo().GetTxtFrm()->SwitchHorizontalToVertical( nBaseLine );
315cdf0e10cSrcweir                     aBase = Point( nBaseLine, ((SwFlyCntPortion*)pPos)->GetRefPoint().Y() );
316cdf0e10cSrcweir                 }
317cdf0e10cSrcweir                 else
318cdf0e10cSrcweir                     aBase = Point( ((SwFlyCntPortion*)pPos)->GetRefPoint().X(), nBaseLine );
319cdf0e10cSrcweir 
320cdf0e10cSrcweir                 ((SwFlyCntPortion*)pPos)->SetBase( *GetInfo().GetTxtFrm(), aBase, nTmpAscent, nTmpDescent,
321cdf0e10cSrcweir 					nFlyAsc, nFlyDesc, nFlags );
322cdf0e10cSrcweir 			}
323cdf0e10cSrcweir 		}
324cdf0e10cSrcweir 		pPos = pPos->GetPortion();
325cdf0e10cSrcweir 	}
326cdf0e10cSrcweir }
327cdf0e10cSrcweir 
328cdf0e10cSrcweir /*************************************************************************
329cdf0e10cSrcweir  *                      SwTxtFly::ChkFlyUnderflow()
330cdf0e10cSrcweir  * This is called after the real height of the line has been calculated
331cdf0e10cSrcweir  * Therefore it is possible, that more flys from below intersect with the
332cdf0e10cSrcweir  * line, or that flys from above do not intersect with the line anymore
333cdf0e10cSrcweir  * We check this and return true if so, meaning that the line has to be
334cdf0e10cSrcweir  * formatted again
335cdf0e10cSrcweir  *************************************************************************/
336cdf0e10cSrcweir 
ChkFlyUnderflow(SwTxtFormatInfo & rInf) const337cdf0e10cSrcweir sal_Bool SwTxtFormatter::ChkFlyUnderflow( SwTxtFormatInfo &rInf ) const
338cdf0e10cSrcweir {
339cdf0e10cSrcweir     ASSERT( rInf.GetTxtFly()->IsOn(), "SwTxtFormatter::ChkFlyUnderflow: why?" );
340cdf0e10cSrcweir 	if( GetCurr() )
341cdf0e10cSrcweir 	{
342cdf0e10cSrcweir 		// Erst pruefen wir, ob ueberhaupt ein Fly mit der Zeile ueberlappt.
343cdf0e10cSrcweir         // = GetLineHeight()
344cdf0e10cSrcweir         const long nHeight = GetCurr()->GetRealHeight();
345cdf0e10cSrcweir 		SwRect aLine( GetLeftMargin(), Y(), rInf.RealWidth(), nHeight );
346cdf0e10cSrcweir 
347cdf0e10cSrcweir         SwRect aLineVert( aLine );
348cdf0e10cSrcweir         if ( pFrm->IsVertical() )
349cdf0e10cSrcweir             pFrm->SwitchHorizontalToVertical( aLineVert );
350cdf0e10cSrcweir         SwRect aInter( rInf.GetTxtFly()->GetFrm( aLineVert ) );
351cdf0e10cSrcweir         if ( pFrm->IsVertical() )
352cdf0e10cSrcweir             pFrm->SwitchVerticalToHorizontal( aInter );
353cdf0e10cSrcweir 
354cdf0e10cSrcweir 		if( !aInter.HasArea() )
355cdf0e10cSrcweir 			return sal_False;
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 		// Nun ueberpruefen wir jede Portion, die sich haette senken koennen,
358cdf0e10cSrcweir 		// ob sie mit dem Fly ueberlappt.
359cdf0e10cSrcweir 		const SwLinePortion *pPos = GetCurr()->GetFirstPortion();
360cdf0e10cSrcweir         aLine.Pos().Y() = Y() + GetCurr()->GetRealHeight() - GetCurr()->Height();
361cdf0e10cSrcweir         aLine.Height( GetCurr()->Height() );
362cdf0e10cSrcweir 
363cdf0e10cSrcweir 		while( pPos )
364cdf0e10cSrcweir 		{
365cdf0e10cSrcweir             aLine.Width( pPos->Width() );
366cdf0e10cSrcweir 
367cdf0e10cSrcweir             aLineVert = aLine;
368cdf0e10cSrcweir             if ( pFrm->IsVertical() )
369cdf0e10cSrcweir                 pFrm->SwitchHorizontalToVertical( aLineVert );
370cdf0e10cSrcweir             aInter = rInf.GetTxtFly()->GetFrm( aLineVert );
371cdf0e10cSrcweir             if ( pFrm->IsVertical() )
372cdf0e10cSrcweir                 pFrm->SwitchVerticalToHorizontal( aInter );
373cdf0e10cSrcweir 
374cdf0e10cSrcweir             // new flys from below?
375cdf0e10cSrcweir 			if( !pPos->IsFlyPortion() )
376cdf0e10cSrcweir 			{
377cdf0e10cSrcweir 				if( aInter.IsOver( aLine ) )
378cdf0e10cSrcweir 				{
379cdf0e10cSrcweir 					aInter._Intersection( aLine );
380cdf0e10cSrcweir 					if( aInter.HasArea() )
381cdf0e10cSrcweir 					{
382cdf0e10cSrcweir                         // to be evaluated during reformat of this line:
383cdf0e10cSrcweir                         // RealHeight including spacing
384cdf0e10cSrcweir 						rInf.SetLineHeight( KSHORT(nHeight) );
385cdf0e10cSrcweir                         // Height without extra spacing
386cdf0e10cSrcweir                         rInf.SetLineNettoHeight( KSHORT( pCurr->Height() ) );
387cdf0e10cSrcweir 						return sal_True;
388cdf0e10cSrcweir 					}
389cdf0e10cSrcweir 				}
390cdf0e10cSrcweir 			}
391cdf0e10cSrcweir             else
392cdf0e10cSrcweir             {
393cdf0e10cSrcweir                 // the fly portion is not anylonger intersected by a fly
394cdf0e10cSrcweir                 if ( ! aInter.IsOver( aLine ) )
395cdf0e10cSrcweir                 {
396cdf0e10cSrcweir                     rInf.SetLineHeight( KSHORT(nHeight) );
397cdf0e10cSrcweir                     rInf.SetLineNettoHeight( KSHORT( pCurr->Height() ) );
398cdf0e10cSrcweir                     return sal_True;
399cdf0e10cSrcweir                 }
400cdf0e10cSrcweir                 else
401cdf0e10cSrcweir                 {
402cdf0e10cSrcweir 					aInter._Intersection( aLine );
403cdf0e10cSrcweir 
404cdf0e10cSrcweir                     // no area means a fly has become invalid because of
405cdf0e10cSrcweir                     // lowering the line => reformat the line
406cdf0e10cSrcweir                     // we also have to reformat the line, if the fly size
407cdf0e10cSrcweir                     // differs from the intersection intervals size
408cdf0e10cSrcweir                     if( ! aInter.HasArea() ||
409cdf0e10cSrcweir                         ((SwFlyPortion*)pPos)->GetFixWidth() != aInter.Width() )
410cdf0e10cSrcweir 					{
411cdf0e10cSrcweir 						rInf.SetLineHeight( KSHORT(nHeight) );
412cdf0e10cSrcweir                         rInf.SetLineNettoHeight( KSHORT( pCurr->Height() ) );
413cdf0e10cSrcweir 						return sal_True;
414cdf0e10cSrcweir 					}
415cdf0e10cSrcweir 				}
416cdf0e10cSrcweir             }
417cdf0e10cSrcweir 
418cdf0e10cSrcweir 			aLine.Left( aLine.Left() + pPos->Width() );
419cdf0e10cSrcweir 			pPos = pPos->GetPortion();
420cdf0e10cSrcweir 		}
421cdf0e10cSrcweir 	}
422cdf0e10cSrcweir 	return sal_False;
423cdf0e10cSrcweir }
424cdf0e10cSrcweir 
425cdf0e10cSrcweir /*************************************************************************
426cdf0e10cSrcweir  * SwTxtFormatter::CalcFlyWidth()
427cdf0e10cSrcweir  * ermittelt das naechste Objekt, das in die restliche Zeile ragt und
428cdf0e10cSrcweir  * konstruiert die zugehoerige FlyPortion.
429cdf0e10cSrcweir  * Dazu wird SwTxtFly.GetFrm(..) benutzt.
430cdf0e10cSrcweir  *************************************************************************/
431cdf0e10cSrcweir 
432cdf0e10cSrcweir // Durch Flys kann sich der rechte Rand verkuerzen.
433cdf0e10cSrcweir 
CalcFlyWidth(SwTxtFormatInfo & rInf)434cdf0e10cSrcweir void SwTxtFormatter::CalcFlyWidth( SwTxtFormatInfo &rInf )
435cdf0e10cSrcweir {
436cdf0e10cSrcweir     if( GetMulti() || rInf.GetFly() )
437cdf0e10cSrcweir 		return;
438cdf0e10cSrcweir 
439cdf0e10cSrcweir 	SwTxtFly *pTxtFly = rInf.GetTxtFly();
440cdf0e10cSrcweir 	if( !pTxtFly->IsOn() || rInf.IsIgnoreFly() )
441cdf0e10cSrcweir 		return;
442cdf0e10cSrcweir 
443cdf0e10cSrcweir 	const SwLinePortion *pLast = rInf.GetLast();
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	long nAscent;
446cdf0e10cSrcweir     long nTop = Y();
447cdf0e10cSrcweir     long nHeight;
448cdf0e10cSrcweir 
449cdf0e10cSrcweir     if( rInf.GetLineHeight() )
450cdf0e10cSrcweir     {
451cdf0e10cSrcweir         // real line height has already been calculated, we only have to
452cdf0e10cSrcweir         // search for intersections in the lower part of the strip
453cdf0e10cSrcweir         nAscent = pCurr->GetAscent();
454cdf0e10cSrcweir         nHeight = rInf.GetLineNettoHeight();
455cdf0e10cSrcweir         nTop += rInf.GetLineHeight() - nHeight;
456cdf0e10cSrcweir 	}
457cdf0e10cSrcweir 	else
458cdf0e10cSrcweir 	{
459cdf0e10cSrcweir         nAscent = pLast->GetAscent();
460cdf0e10cSrcweir         nHeight = pLast->Height();
461cdf0e10cSrcweir 
462cdf0e10cSrcweir         // we make a first guess for the lines real height
463cdf0e10cSrcweir         if ( ! pCurr->GetRealHeight() )
464cdf0e10cSrcweir             CalcRealHeight();
465cdf0e10cSrcweir 
466cdf0e10cSrcweir         if ( pCurr->GetRealHeight() > nHeight )
467cdf0e10cSrcweir             nTop += pCurr->GetRealHeight() - nHeight;
468cdf0e10cSrcweir         else
469cdf0e10cSrcweir             // important for fixed space between lines
470cdf0e10cSrcweir             nHeight = pCurr->GetRealHeight();
471cdf0e10cSrcweir 	}
472cdf0e10cSrcweir 
473cdf0e10cSrcweir     const long nLeftMar = GetLeftMargin();
474cdf0e10cSrcweir     const long nLeftMin = (rInf.X() || GetDropLeft()) ? nLeftMar : GetLeftMin();
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     SwRect aLine( rInf.X() + nLeftMin, nTop, rInf.RealWidth() - rInf.X()
477cdf0e10cSrcweir 				  + nLeftMar - nLeftMin	, nHeight );
478cdf0e10cSrcweir 
479cdf0e10cSrcweir     SwRect aLineVert( aLine );
480cdf0e10cSrcweir     if ( pFrm->IsRightToLeft() )
481cdf0e10cSrcweir         pFrm->SwitchLTRtoRTL( aLineVert );
482cdf0e10cSrcweir 
483cdf0e10cSrcweir     if ( pFrm->IsVertical() )
484cdf0e10cSrcweir         pFrm->SwitchHorizontalToVertical( aLineVert );
485cdf0e10cSrcweir     SwRect aInter( pTxtFly->GetFrm( aLineVert ) );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir     if ( pFrm->IsRightToLeft() )
488cdf0e10cSrcweir         pFrm->SwitchRTLtoLTR( aInter );
489cdf0e10cSrcweir 
490cdf0e10cSrcweir     if ( pFrm->IsVertical() )
491cdf0e10cSrcweir         pFrm->SwitchVerticalToHorizontal( aInter );
492cdf0e10cSrcweir 
493cdf0e10cSrcweir     if( aInter.IsOver( aLine ) )
494cdf0e10cSrcweir 	{
495cdf0e10cSrcweir         aLine.Left( rInf.X() + nLeftMar );
496cdf0e10cSrcweir 		sal_Bool bForced = sal_False;
497cdf0e10cSrcweir 		if( aInter.Left() <= nLeftMin )
498cdf0e10cSrcweir 		{
499cdf0e10cSrcweir 			SwTwips nFrmLeft = GetTxtFrm()->Frm().Left();
500cdf0e10cSrcweir 			if( GetTxtFrm()->Prt().Left() < 0 )
501cdf0e10cSrcweir 				nFrmLeft += GetTxtFrm()->Prt().Left();
502cdf0e10cSrcweir 			if( aInter.Left() < nFrmLeft )
503cdf0e10cSrcweir 				aInter.Left( nFrmLeft );
504cdf0e10cSrcweir 
505cdf0e10cSrcweir             long nAddMar = 0;
506cdf0e10cSrcweir             if ( pFrm->IsRightToLeft() )
507cdf0e10cSrcweir             {
508cdf0e10cSrcweir                 nAddMar = pFrm->Frm().Right() - Right();
509cdf0e10cSrcweir                 if ( nAddMar < 0 )
510cdf0e10cSrcweir                     nAddMar = 0;
511cdf0e10cSrcweir             }
512cdf0e10cSrcweir             else
513cdf0e10cSrcweir                 nAddMar = nLeftMar - nFrmLeft;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir             aInter.Width( aInter.Width() + nAddMar );
516cdf0e10cSrcweir 			// Bei negativem Erstzeileneinzug setzen wir das Flag,
517cdf0e10cSrcweir 			// um anzuzeigen, dass der Einzug/Rand verschoben wurde
518cdf0e10cSrcweir 			// Dies muss beim DefaultTab an der Nullposition beruecksichtigt
519cdf0e10cSrcweir 			// werden.
520cdf0e10cSrcweir 			if( IsFirstTxtLine() && HasNegFirst() )
521cdf0e10cSrcweir 				bForced = sal_True;
522cdf0e10cSrcweir 		}
523cdf0e10cSrcweir 		aInter.Intersection( aLine );
524cdf0e10cSrcweir 		if( !aInter.HasArea() )
525cdf0e10cSrcweir 			return;
526cdf0e10cSrcweir 
527cdf0e10cSrcweir 		const sal_Bool bFullLine =	aLine.Left()  == aInter.Left() &&
528cdf0e10cSrcweir 								aLine.Right() == aInter.Right();
529cdf0e10cSrcweir 
530cdf0e10cSrcweir 		// Obwohl kein Text mehr da ist, muss eine weitere Zeile
531cdf0e10cSrcweir 		// formatiert werden, weil auch leere Zeilen einem Fly
532cdf0e10cSrcweir 		// ohne Umlauf ausweichen muessen.
533cdf0e10cSrcweir 		if( bFullLine && rInf.GetIdx() == rInf.GetTxt().Len() )
534cdf0e10cSrcweir 		{
535cdf0e10cSrcweir 			rInf.SetNewLine( sal_True );
536cdf0e10cSrcweir 			// 8221: Dummies erkennt man an Ascent == Height
537cdf0e10cSrcweir             pCurr->SetDummy(sal_True);
538cdf0e10cSrcweir 		}
539cdf0e10cSrcweir 
540cdf0e10cSrcweir 		// aInter wird framelokal
541cdf0e10cSrcweir 		aInter.Pos().X() -= nLeftMar;
542cdf0e10cSrcweir 		SwFlyPortion *pFly = new SwFlyPortion( aInter );
543cdf0e10cSrcweir 		if( bForced )
544cdf0e10cSrcweir 		{
545cdf0e10cSrcweir 			pCurr->SetForcedLeftMargin( sal_True );
546cdf0e10cSrcweir             rInf.ForcedLeftMargin( (sal_uInt16)aInter.Width() );
547cdf0e10cSrcweir 		}
548cdf0e10cSrcweir 
549cdf0e10cSrcweir 		if( bFullLine )
550cdf0e10cSrcweir 		{
551cdf0e10cSrcweir 			// 8110: wir muessen um Einheiten von Zeilenhoehen anwachsen,
552cdf0e10cSrcweir 			// um nebeneinanderliegende Flys mit unterschiedlichen
553cdf0e10cSrcweir 			// Umlaufattributen angemessen zu umfliessen.
554cdf0e10cSrcweir 			// Die letzte ausweichende Zeile, sollte in der Hoehe angepasst
555cdf0e10cSrcweir 			// sein, damit nicht der Eindruck von "Rahmenabstaenden" aufkommt.
556cdf0e10cSrcweir 			// 8221: Wichtig ist, dass Ascent == Height ist, weil die FlyPortionWerte
557cdf0e10cSrcweir 			// im CalcLine in pCurr uebertragen werden und IsDummy() darauf
558cdf0e10cSrcweir 			// angewiesen ist.
559cdf0e10cSrcweir 			// Es gibt meines Wissens nur zwei Stellen, in denen DummyLines
560cdf0e10cSrcweir 			// entstehen koennen: hier und in MakeFlyDummies.
561cdf0e10cSrcweir 			// Ausgewertet wird IsDummy() in IsFirstTxtLine() und
562cdf0e10cSrcweir 			// beim Zeilenwandern und im Zusammenhang mit DropCaps.
563cdf0e10cSrcweir 			pFly->Height( KSHORT(aInter.Height()) );
564cdf0e10cSrcweir 
565cdf0e10cSrcweir 			// In nNextTop steckt jetzt die Unterkante des Rahmens, dem wir
566cdf0e10cSrcweir 			// ausweichen oder die Oberkante des naechsten Rahmens, den wir
567cdf0e10cSrcweir 			// beachten muessen. Wir koennen also jetzt getrost bis zu diesem
568cdf0e10cSrcweir 			// Wert anwachsen, so sparen wir einige Leerzeilen.
569cdf0e10cSrcweir             long nNextTop = pTxtFly->GetNextTop();
570cdf0e10cSrcweir             if ( pFrm->IsVertical() )
571cdf0e10cSrcweir                 nNextTop = pFrm->SwitchVerticalToHorizontal( nNextTop );
572cdf0e10cSrcweir             if( nNextTop > aInter.Bottom() )
573cdf0e10cSrcweir 			{
574cdf0e10cSrcweir                 SwTwips nH = nNextTop - aInter.Top();
575cdf0e10cSrcweir 				if( nH < KSHRT_MAX )
576cdf0e10cSrcweir 					pFly->Height( KSHORT( nH ) );
577cdf0e10cSrcweir 			}
578cdf0e10cSrcweir 			if( nAscent < pFly->Height() )
579cdf0e10cSrcweir 				pFly->SetAscent( KSHORT(nAscent) );
580cdf0e10cSrcweir 			else
581cdf0e10cSrcweir 				pFly->SetAscent( pFly->Height() );
582cdf0e10cSrcweir 		}
583cdf0e10cSrcweir 		else
584cdf0e10cSrcweir 		{
585cdf0e10cSrcweir 			if( rInf.GetIdx() == rInf.GetTxt().Len() )
586cdf0e10cSrcweir 			{
587cdf0e10cSrcweir 				// Nicht nHeight nehmen, sonst haben wir einen Riesendescent
588cdf0e10cSrcweir 				pFly->Height( pLast->Height() );
589cdf0e10cSrcweir 				pFly->SetAscent( pLast->GetAscent() );
590cdf0e10cSrcweir 			}
591cdf0e10cSrcweir 			else
592cdf0e10cSrcweir 			{
593cdf0e10cSrcweir 				pFly->Height( KSHORT(aInter.Height()) );
594cdf0e10cSrcweir 				if( nAscent < pFly->Height() )
595cdf0e10cSrcweir 					pFly->SetAscent( KSHORT(nAscent) );
596cdf0e10cSrcweir 				else
597cdf0e10cSrcweir 					pFly->SetAscent( pFly->Height() );
598cdf0e10cSrcweir 			}
599cdf0e10cSrcweir 		}
600cdf0e10cSrcweir 
601cdf0e10cSrcweir 		rInf.SetFly( pFly );
602cdf0e10cSrcweir 
603cdf0e10cSrcweir         if( pFly->Fix() < rInf.Width() )
604cdf0e10cSrcweir 			rInf.Width( pFly->Fix() );
605cdf0e10cSrcweir 
606cdf0e10cSrcweir         GETGRID( pFrm->FindPageFrm() )
607cdf0e10cSrcweir         if ( pGrid )
608cdf0e10cSrcweir         {
609cdf0e10cSrcweir             const SwPageFrm* pPageFrm = pFrm->FindPageFrm();
610cdf0e10cSrcweir             const SwLayoutFrm* pBody = pPageFrm->FindBodyCont();
611cdf0e10cSrcweir 
612cdf0e10cSrcweir             SWRECTFN( pPageFrm )
613cdf0e10cSrcweir 
614cdf0e10cSrcweir             const long nGridOrigin = pBody ?
615cdf0e10cSrcweir                                     (pBody->*fnRect->fnGetPrtLeft)() :
616cdf0e10cSrcweir                                     (pPageFrm->*fnRect->fnGetPrtLeft)();
617cdf0e10cSrcweir 
618cdf0e10cSrcweir 			const SwDoc *pDoc = rInf.GetTxtFrm()->GetNode()->GetDoc();
619cdf0e10cSrcweir             const sal_uInt16 nGridWidth = GETGRIDWIDTH( pGrid, pDoc);	//for textgrid refactor
620cdf0e10cSrcweir 
621cdf0e10cSrcweir             SwTwips nStartX = GetLeftMargin();
622cdf0e10cSrcweir             if ( bVert )
623cdf0e10cSrcweir             {
624cdf0e10cSrcweir                 Point aPoint( nStartX, 0 );
625cdf0e10cSrcweir                 pFrm->SwitchHorizontalToVertical( aPoint );
626cdf0e10cSrcweir                 nStartX = aPoint.Y();
627cdf0e10cSrcweir             }
628cdf0e10cSrcweir 
629cdf0e10cSrcweir             const SwTwips nOfst = nStartX - nGridOrigin;
630cdf0e10cSrcweir             const SwTwips nTmpWidth = rInf.Width() + nOfst;
631cdf0e10cSrcweir 
632cdf0e10cSrcweir             const sal_uLong i = nTmpWidth / nGridWidth + 1;
633cdf0e10cSrcweir 
634cdf0e10cSrcweir             const long nNewWidth = ( i - 1 ) * nGridWidth - nOfst;
635cdf0e10cSrcweir             if ( nNewWidth > 0 )
636cdf0e10cSrcweir                 rInf.Width( (sal_uInt16)nNewWidth );
637cdf0e10cSrcweir             else
638cdf0e10cSrcweir                 rInf.Width( 0 );
639cdf0e10cSrcweir         }
640cdf0e10cSrcweir 	}
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir /*****************************************************************************
644cdf0e10cSrcweir  * SwTxtFormatter::NewFlyCntPortion
645cdf0e10cSrcweir  * legt eine neue Portion fuer ein zeichengebundenes Objekt an.
646cdf0e10cSrcweir  *****************************************************************************/
647cdf0e10cSrcweir 
NewFlyCntPortion(SwTxtFormatInfo & rInf,SwTxtAttr * pHint) const648cdf0e10cSrcweir SwFlyCntPortion *SwTxtFormatter::NewFlyCntPortion( SwTxtFormatInfo &rInf,
649cdf0e10cSrcweir 												   SwTxtAttr *pHint ) const
650cdf0e10cSrcweir {
651cdf0e10cSrcweir 	SwFlyCntPortion *pRet = 0;
652cdf0e10cSrcweir 	const SwFrm *pFrame = (SwFrm*)pFrm;
653cdf0e10cSrcweir 
654cdf0e10cSrcweir 	SwFlyInCntFrm *pFly;
655cdf0e10cSrcweir 	SwFrmFmt* pFrmFmt = ((SwTxtFlyCnt*)pHint)->GetFlyCnt().GetFrmFmt();
656cdf0e10cSrcweir 	if( RES_FLYFRMFMT == pFrmFmt->Which() )
657cdf0e10cSrcweir 		pFly = ((SwTxtFlyCnt*)pHint)->GetFlyFrm(pFrame);
658cdf0e10cSrcweir 	else
659cdf0e10cSrcweir 		pFly = NULL;
660cdf0e10cSrcweir 	// aBase bezeichnet die dokumentglobale Position,
661cdf0e10cSrcweir 	// ab der die neue Extraportion plaziert wird.
662cdf0e10cSrcweir 	// aBase.X() = Offset in der Zeile,
663cdf0e10cSrcweir 	//			   hinter der aktuellen Portion
664cdf0e10cSrcweir 	// aBase.Y() = LineIter.Y() + Ascent der aktuellen Portion
665cdf0e10cSrcweir 
666cdf0e10cSrcweir 	long nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc;
667cdf0e10cSrcweir     // OD 08.01.2004 #i11859# - use new method <SwLineLayout::MaxAscentDescent(..)>
668cdf0e10cSrcweir     //SwLinePortion *pPos = pCurr->GetFirstPortion();
669cdf0e10cSrcweir     //lcl_MaxAscDescent( pPos, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc );
670cdf0e10cSrcweir     pCurr->MaxAscentDescent( nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc );
671cdf0e10cSrcweir 
672cdf0e10cSrcweir 	// Wenn der Ascent des Rahmens groesser als der Ascent der akt. Portion
673cdf0e10cSrcweir 	// ist, wird dieser bei der Base-Berechnung verwendet, sonst wuerde
674cdf0e10cSrcweir 	// der Rahmen zunaechst zu weit nach oben gesetzt, um dann doch wieder
675cdf0e10cSrcweir 	// nach unten zu rutschen und dabei ein Repaint in einem Bereich ausloesen,
676cdf0e10cSrcweir 	// indem er niemals wirklich war.
677cdf0e10cSrcweir     KSHORT nAscent = 0;
678cdf0e10cSrcweir 
679cdf0e10cSrcweir     const bool bTxtFrmVertical = GetInfo().GetTxtFrm()->IsVertical();
680cdf0e10cSrcweir 
681cdf0e10cSrcweir     const bool bUseFlyAscent = pFly && pFly->GetValidPosFlag() &&
682cdf0e10cSrcweir                                0 != ( bTxtFrmVertical ?
683cdf0e10cSrcweir                                       pFly->GetRefPoint().X() :
684cdf0e10cSrcweir                                       pFly->GetRefPoint().Y() );
685cdf0e10cSrcweir 
686cdf0e10cSrcweir     if ( bUseFlyAscent )
687cdf0e10cSrcweir          nAscent = static_cast<sal_uInt16>( Abs( int( bTxtFrmVertical ?
688cdf0e10cSrcweir                                                   pFly->GetRelPos().X() :
689cdf0e10cSrcweir                                                   pFly->GetRelPos().Y() ) ) );
690cdf0e10cSrcweir 
691cdf0e10cSrcweir     // check if be prefer to use the ascent of the last portion:
692cdf0e10cSrcweir     if ( IsQuick() ||
693cdf0e10cSrcweir          !bUseFlyAscent ||
694cdf0e10cSrcweir          nAscent < rInf.GetLast()->GetAscent() )
695cdf0e10cSrcweir     {
696cdf0e10cSrcweir 		nAscent = rInf.GetLast()->GetAscent();
697cdf0e10cSrcweir     }
698cdf0e10cSrcweir     else if( nAscent > nFlyAsc )
699cdf0e10cSrcweir 		nFlyAsc = nAscent;
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 	Point aBase( GetLeftMargin() + rInf.X(), Y() + nAscent );
702cdf0e10cSrcweir     objectpositioning::AsCharFlags nMode = IsQuick() ? AS_CHAR_QUICK : 0;
703cdf0e10cSrcweir 	if( GetMulti() && GetMulti()->HasRotation() )
704cdf0e10cSrcweir 	{
705cdf0e10cSrcweir         nMode |= AS_CHAR_ROTATE;
706cdf0e10cSrcweir 		if( GetMulti()->IsRevers() )
707cdf0e10cSrcweir             nMode |= AS_CHAR_REVERSE;
708cdf0e10cSrcweir 	}
709cdf0e10cSrcweir 
710cdf0e10cSrcweir     Point aTmpBase( aBase );
711cdf0e10cSrcweir     if ( GetInfo().GetTxtFrm()->IsVertical() )
712cdf0e10cSrcweir         GetInfo().GetTxtFrm()->SwitchHorizontalToVertical( aTmpBase );
713cdf0e10cSrcweir 
714cdf0e10cSrcweir 	if( pFly )
715cdf0e10cSrcweir 	{
716cdf0e10cSrcweir         pRet = new SwFlyCntPortion( *GetInfo().GetTxtFrm(), pFly, aTmpBase,
717cdf0e10cSrcweir                                     nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode );
718cdf0e10cSrcweir 		// Wir muessen sicherstellen, dass unser Font wieder im OutputDevice
719cdf0e10cSrcweir 		// steht. Es koennte sein, dass der FlyInCnt frisch eingefuegt wurde,
720cdf0e10cSrcweir 		// dann hat GetFlyFrm dazu gefuehrt, dass er neu angelegt wird.
721cdf0e10cSrcweir 		// Dessen Frames werden sofort formatiert, die verstellen den Font
722cdf0e10cSrcweir 		// und schon haben wir den Salat (3322).
723cdf0e10cSrcweir 		rInf.SelectFont();
724cdf0e10cSrcweir 		if( pRet->GetAscent() > nAscent )
725cdf0e10cSrcweir 		{
726cdf0e10cSrcweir 			aBase.Y() = Y() + pRet->GetAscent();
727cdf0e10cSrcweir             nMode |= AS_CHAR_ULSPACE;
728cdf0e10cSrcweir 			if( !rInf.IsTest() )
729cdf0e10cSrcweir                 aTmpBase = aBase;
730cdf0e10cSrcweir                 if ( GetInfo().GetTxtFrm()->IsVertical() )
731cdf0e10cSrcweir                     GetInfo().GetTxtFrm()->SwitchHorizontalToVertical( aTmpBase );
732cdf0e10cSrcweir 
733cdf0e10cSrcweir                 pRet->SetBase( *rInf.GetTxtFrm(), aTmpBase, nTmpAscent,
734cdf0e10cSrcweir                                nTmpDescent, nFlyAsc, nFlyDesc, nMode );
735cdf0e10cSrcweir 		}
736cdf0e10cSrcweir 	}
737cdf0e10cSrcweir 	else
738cdf0e10cSrcweir 	{
739cdf0e10cSrcweir         pRet = new SwFlyCntPortion( *rInf.GetTxtFrm(), (SwDrawContact*)pFrmFmt->FindContactObj(),
740cdf0e10cSrcweir            aTmpBase, nTmpAscent, nTmpDescent, nFlyAsc, nFlyDesc, nMode );
741cdf0e10cSrcweir 	}
742cdf0e10cSrcweir 	return pRet;
743cdf0e10cSrcweir }
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 
746cdf0e10cSrcweir 
747cdf0e10cSrcweir /*************************************************************************
748cdf0e10cSrcweir  *						SwTxtFly::SwTxtFly()
749cdf0e10cSrcweir  *************************************************************************/
750cdf0e10cSrcweir 
SwTxtFly(const SwTxtFly & rTxtFly)751cdf0e10cSrcweir SwTxtFly::SwTxtFly( const SwTxtFly& rTxtFly )
752cdf0e10cSrcweir {
753cdf0e10cSrcweir 	pPage = rTxtFly.pPage;
754cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
755cdf0e10cSrcweir     mpCurrAnchoredObj = rTxtFly.mpCurrAnchoredObj;
756cdf0e10cSrcweir     // <--
757cdf0e10cSrcweir 	pCurrFrm = rTxtFly.pCurrFrm;
758cdf0e10cSrcweir 	pMaster = rTxtFly.pMaster;
759cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
760cdf0e10cSrcweir     if( rTxtFly.mpAnchoredObjList )
761cdf0e10cSrcweir 	{
762cdf0e10cSrcweir         mpAnchoredObjList = new SwAnchoredObjList( *(rTxtFly.mpAnchoredObjList) );
763cdf0e10cSrcweir 	}
764cdf0e10cSrcweir 	else
765cdf0e10cSrcweir     {
766cdf0e10cSrcweir         mpAnchoredObjList = NULL;
767cdf0e10cSrcweir     }
768cdf0e10cSrcweir     // <--
769cdf0e10cSrcweir 
770cdf0e10cSrcweir 	bOn = rTxtFly.bOn;
771cdf0e10cSrcweir 	bLeftSide = rTxtFly.bLeftSide;
772cdf0e10cSrcweir 	bTopRule = rTxtFly.bTopRule;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir 
CtorInitTxtFly(const SwTxtFrm * pFrm)775cdf0e10cSrcweir void SwTxtFly::CtorInitTxtFly( const SwTxtFrm *pFrm )
776cdf0e10cSrcweir {
777cdf0e10cSrcweir     mbIgnoreCurrentFrame = sal_False;
778cdf0e10cSrcweir     mbIgnoreContour = sal_False;
779cdf0e10cSrcweir     // --> OD 2004-12-17 #118809#
780cdf0e10cSrcweir     mbIgnoreObjsInHeaderFooter = sal_False;
781cdf0e10cSrcweir     // <--
782cdf0e10cSrcweir     pPage = pFrm->FindPageFrm();
783cdf0e10cSrcweir 	const SwFlyFrm* pTmp = pFrm->FindFlyFrm();
784cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
785cdf0e10cSrcweir     mpCurrAnchoredObj = pTmp;
786cdf0e10cSrcweir     // <--
787cdf0e10cSrcweir 	pCurrFrm = pFrm;
788cdf0e10cSrcweir 	pMaster = pCurrFrm->IsFollow() ? NULL : pCurrFrm;
789cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
790cdf0e10cSrcweir     mpAnchoredObjList = NULL;
791cdf0e10cSrcweir     // <--
792cdf0e10cSrcweir     // Wenn wir nicht von einem Frame ueberlappt werden, oder wenn
793cdf0e10cSrcweir 	// es gar keine FlyCollection gibt, dann schaltet wir uns fuer immer ab.
794cdf0e10cSrcweir 	// Aber es koennte sein, dass waehrend der Formatierung eine Zeile
795cdf0e10cSrcweir 	// hinzukommt, die in einen Frame hineinragt. Deswegen keine Optimierung
796cdf0e10cSrcweir 	// per bOn = pSortedFlys && IsAnyFrm();
797cdf0e10cSrcweir 	bOn = pPage->GetSortedObjs() != 0;
798cdf0e10cSrcweir 	bTopRule = sal_True;
799cdf0e10cSrcweir 	bLeftSide = sal_False;
800cdf0e10cSrcweir 	nMinBottom = 0;
801cdf0e10cSrcweir 	nIndex = ULONG_MAX;
802cdf0e10cSrcweir }
803cdf0e10cSrcweir 
804cdf0e10cSrcweir /*************************************************************************
805cdf0e10cSrcweir  *						SwTxtFly::_GetFrm()
806cdf0e10cSrcweir  *
807cdf0e10cSrcweir  * IN:	dokumentglobal	(rRect)
808cdf0e10cSrcweir  * OUT: framelokal		(return-Wert)
809cdf0e10cSrcweir  * Diese Methode wird waehrend der Formatierung vom LineIter gerufen.
810cdf0e10cSrcweir  * 1. um die naechste FlyPortion vorzubereiten
811cdf0e10cSrcweir  * 2. um nach Aenderung der Zeilenhoehe neue Ueberlappungen festzustellen
812cdf0e10cSrcweir  *************************************************************************/
813cdf0e10cSrcweir 
_GetFrm(const SwRect & rRect,sal_Bool bTop) const814cdf0e10cSrcweir SwRect SwTxtFly::_GetFrm( const SwRect &rRect, sal_Bool bTop ) const
815cdf0e10cSrcweir {
816cdf0e10cSrcweir 	SwRect aRet;
817cdf0e10cSrcweir 	if( ForEach( rRect, &aRet, sal_True ) )
818cdf0e10cSrcweir 	{
819cdf0e10cSrcweir         SWRECTFN( pCurrFrm )
820cdf0e10cSrcweir 		if( bTop )
821cdf0e10cSrcweir             (aRet.*fnRect->fnSetTop)( (rRect.*fnRect->fnGetTop)() );
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 		// 8110: Bottom nicht immer anpassen.
824cdf0e10cSrcweir         const SwTwips nRetBottom = (aRet.*fnRect->fnGetBottom)();
825cdf0e10cSrcweir         const SwTwips nRectBottom = (rRect.*fnRect->fnGetBottom)();
826cdf0e10cSrcweir         if ( (*fnRect->fnYDiff)( nRetBottom, nRectBottom ) > 0 ||
827cdf0e10cSrcweir              (aRet.*fnRect->fnGetHeight)() < 0 )
828cdf0e10cSrcweir             (aRet.*fnRect->fnSetBottom)( nRectBottom );
829cdf0e10cSrcweir 	}
830cdf0e10cSrcweir 	return aRet;
831cdf0e10cSrcweir }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir /*************************************************************************
834cdf0e10cSrcweir  *						SwTxtFly::IsAnyFrm()
835cdf0e10cSrcweir  *
836cdf0e10cSrcweir  * IN: dokumentglobal
837cdf0e10cSrcweir  * fuer die Printarea des aktuellen Frame
838cdf0e10cSrcweir  *
839cdf0e10cSrcweir  * dient zum Abschalten des SwTxtFly, wenn keine Objekte ueberlappen (Relax)
840cdf0e10cSrcweir  *
841cdf0e10cSrcweir  *************************************************************************/
842cdf0e10cSrcweir 
IsAnyFrm() const843cdf0e10cSrcweir sal_Bool SwTxtFly::IsAnyFrm() const
844cdf0e10cSrcweir {
845cdf0e10cSrcweir     SWAP_IF_SWAPPED( pCurrFrm )
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 	ASSERT( bOn, "IsAnyFrm: Why?" );
848cdf0e10cSrcweir 	SwRect aRect( pCurrFrm->Frm().Pos() + pCurrFrm->Prt().Pos(),
849cdf0e10cSrcweir 		pCurrFrm->Prt().SSize() );
850cdf0e10cSrcweir 
851cdf0e10cSrcweir     const sal_Bool bRet = ForEach( aRect, NULL, sal_False );
852cdf0e10cSrcweir     UNDO_SWAP( pCurrFrm )
853cdf0e10cSrcweir     return bRet;
854cdf0e10cSrcweir }
855cdf0e10cSrcweir 
856cdf0e10cSrcweir /*************************************************************************
857cdf0e10cSrcweir  *						SwTxtFly::IsAnyObj()
858cdf0e10cSrcweir  *
859cdf0e10cSrcweir  * IN: dokumentglobal
860cdf0e10cSrcweir  * OUT: sal_True Wenn ein Rahmen oder DrawObj beruecksichtigt werden muss
861cdf0e10cSrcweir  * Nur wenn IsAnyObj sal_False liefert, koennen Optimierungen benutzt werden
862cdf0e10cSrcweir  * wie Paint/FormatEmpty fuer leere Absaetze
863cdf0e10cSrcweir  * und auch das virtuelle Outputdevice.
864cdf0e10cSrcweir  *************************************************************************/
865cdf0e10cSrcweir 
IsAnyObj(const SwRect & rRect) const866cdf0e10cSrcweir sal_Bool SwTxtFly::IsAnyObj( const SwRect &rRect ) const
867cdf0e10cSrcweir {
868cdf0e10cSrcweir 	ASSERT ( bOn, "SwTxtFly::IsAnyObj: Who's knocking?" );
869cdf0e10cSrcweir 
870cdf0e10cSrcweir 	SwRect aRect( rRect );
871cdf0e10cSrcweir 	if ( aRect.IsEmpty() )
872cdf0e10cSrcweir 		aRect = SwRect( pCurrFrm->Frm().Pos() + pCurrFrm->Prt().Pos(),
873cdf0e10cSrcweir 						pCurrFrm->Prt().SSize() );
874cdf0e10cSrcweir 
875cdf0e10cSrcweir     const SwSortedObjs *pSorted = pPage->GetSortedObjs();
876cdf0e10cSrcweir 	if( pSorted ) // Eigentlich ist durch bOn sichergestellt, dass es an der
877cdf0e10cSrcweir 	// Seite Objekte gibt, aber wer weiss, wer inzwischen etwas geloescht hat.
878cdf0e10cSrcweir 	{
879cdf0e10cSrcweir 		for ( MSHORT i = 0; i < pSorted->Count(); ++i )
880cdf0e10cSrcweir 		{
881cdf0e10cSrcweir             const SwAnchoredObject* pObj = (*pSorted)[i];
882cdf0e10cSrcweir 
883cdf0e10cSrcweir             const SwRect aBound( pObj->GetObjRectWithSpaces() );
884cdf0e10cSrcweir 
885cdf0e10cSrcweir 			// Optimierung
886cdf0e10cSrcweir             if( pObj->GetObjRect().Left() > aRect.Right() )
887cdf0e10cSrcweir 				continue;
888cdf0e10cSrcweir 
889cdf0e10cSrcweir             // --> OD 2006-08-15 #i68520#
890cdf0e10cSrcweir             if( mpCurrAnchoredObj != pObj && aBound.IsOver( aRect ) )
891cdf0e10cSrcweir             // <--
892cdf0e10cSrcweir 				return sal_True;
893cdf0e10cSrcweir 		}
894cdf0e10cSrcweir 	}
895cdf0e10cSrcweir 	return sal_False;
896cdf0e10cSrcweir }
897cdf0e10cSrcweir 
_GetMaster()898cdf0e10cSrcweir const SwCntntFrm* SwTxtFly::_GetMaster()
899cdf0e10cSrcweir {
900cdf0e10cSrcweir 	pMaster = pCurrFrm;
901cdf0e10cSrcweir 	while( pMaster->IsFollow() )
902cdf0e10cSrcweir 		pMaster = (SwCntntFrm*)pMaster->FindMaster();
903cdf0e10cSrcweir 	return pMaster;
904cdf0e10cSrcweir }
905cdf0e10cSrcweir 
906cdf0e10cSrcweir /*************************************************************************
907cdf0e10cSrcweir  *						SwTxtFly::DrawTextOpaque()
908cdf0e10cSrcweir  *
909cdf0e10cSrcweir  * IN: dokumentglobal
910cdf0e10cSrcweir  * DrawTextOpaque() wird von DrawText() gerufen.
911cdf0e10cSrcweir  * Die Clipregions werden so gesetzt, dass nur die Teile ausgegeben werden,
912cdf0e10cSrcweir  * die nicht in den Bereichen von FlyFrms liegen, die undurchsichtig und
913cdf0e10cSrcweir  * ueber dem aktuellen Frame liegen.
914cdf0e10cSrcweir  * Die On-Optimierung uebernimmt DrawText()!
915cdf0e10cSrcweir  *************************************************************************/
916cdf0e10cSrcweir 
DrawTextOpaque(SwDrawTextInfo & rInf)917cdf0e10cSrcweir sal_Bool SwTxtFly::DrawTextOpaque( SwDrawTextInfo &rInf )
918cdf0e10cSrcweir {
919cdf0e10cSrcweir 	SwSaveClip aClipSave( rInf.GetpOut() );
920cdf0e10cSrcweir 	SwRect aRect( rInf.GetPos(), rInf.GetSize() );
921cdf0e10cSrcweir 	if( rInf.GetSpace() )
922cdf0e10cSrcweir 	{
923cdf0e10cSrcweir 		xub_StrLen nTmpLen = STRING_LEN == rInf.GetLen() ? rInf.GetText().Len() :
924cdf0e10cSrcweir 													  rInf.GetLen();
925cdf0e10cSrcweir 		if( rInf.GetSpace() > 0 )
926cdf0e10cSrcweir 		{
927cdf0e10cSrcweir 			xub_StrLen nSpaceCnt = 0;
928cdf0e10cSrcweir 			const xub_StrLen nEndPos = rInf.GetIdx() + nTmpLen;
929cdf0e10cSrcweir 			for( xub_StrLen nPos = rInf.GetIdx(); nPos < nEndPos; ++nPos )
930cdf0e10cSrcweir 			{
931cdf0e10cSrcweir 				if( CH_BLANK == rInf.GetText().GetChar( nPos ) )
932cdf0e10cSrcweir 					++nSpaceCnt;
933cdf0e10cSrcweir 			}
934cdf0e10cSrcweir 			if( nSpaceCnt )
935cdf0e10cSrcweir 				aRect.Width( aRect.Width() + nSpaceCnt * rInf.GetSpace() );
936cdf0e10cSrcweir 		}
937cdf0e10cSrcweir 		else
938cdf0e10cSrcweir 			aRect.Width( aRect.Width() - nTmpLen * rInf.GetSpace() );
939cdf0e10cSrcweir 	}
940cdf0e10cSrcweir 
941cdf0e10cSrcweir 	if( aClipSave.IsOn() && rInf.GetOut().IsClipRegion() )
942cdf0e10cSrcweir 	{
943cdf0e10cSrcweir 		SwRect aClipRect( rInf.GetOut().GetClipRegion().GetBoundRect() );
944cdf0e10cSrcweir 		aRect.Intersection( aClipRect );
945cdf0e10cSrcweir 	}
946cdf0e10cSrcweir 
947cdf0e10cSrcweir 	SwRegionRects aRegion( aRect );
948cdf0e10cSrcweir 
949cdf0e10cSrcweir 	sal_Bool bOpaque = sal_False;
950cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
951cdf0e10cSrcweir     const sal_uInt32 nCurrOrd = mpCurrAnchoredObj
952cdf0e10cSrcweir                             ? mpCurrAnchoredObj->GetDrawObj()->GetOrdNum()
953cdf0e10cSrcweir                             : SAL_MAX_UINT32;
954cdf0e10cSrcweir     // <--
955cdf0e10cSrcweir 	ASSERT( !bTopRule, "DrawTextOpaque: Wrong TopRule" );
956cdf0e10cSrcweir 
957cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
958cdf0e10cSrcweir     SwAnchoredObjList::size_type nCount( bOn ? GetAnchoredObjList()->size() : 0 );
959cdf0e10cSrcweir     if ( bOn && nCount > 0 )
960cdf0e10cSrcweir     // <--
961cdf0e10cSrcweir 	{
962cdf0e10cSrcweir         MSHORT nHellId = pPage->getRootFrm()->GetCurrShell()->getIDocumentDrawModelAccess()->GetHellId();
963cdf0e10cSrcweir 		for( MSHORT i = 0; i < nCount; ++i )
964cdf0e10cSrcweir 		{
965cdf0e10cSrcweir             // --> OD 2006-08-15 #i68520#
966cdf0e10cSrcweir             const SwAnchoredObject* pTmpAnchoredObj = (*mpAnchoredObjList)[i];
967cdf0e10cSrcweir             if( dynamic_cast<const SwFlyFrm*>(pTmpAnchoredObj) &&
968cdf0e10cSrcweir                 mpCurrAnchoredObj != pTmpAnchoredObj )
969cdf0e10cSrcweir             // <--
970cdf0e10cSrcweir 			{
971cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
972cdf0e10cSrcweir                 const SwFlyFrm* pFly = dynamic_cast<const SwFlyFrm*>(pTmpAnchoredObj);
973cdf0e10cSrcweir                 // <--
974cdf0e10cSrcweir 				if( aRegion.GetOrigin().IsOver( pFly->Frm() ) )
975cdf0e10cSrcweir 				{
976cdf0e10cSrcweir 					const SwFrmFmt *pFmt = pFly->GetFmt();
977cdf0e10cSrcweir 					const SwFmtSurround &rSur = pFmt->GetSurround();
978cdf0e10cSrcweir 					const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
979cdf0e10cSrcweir 						//Nur undurchsichtige und weiter oben liegende.
980cdf0e10cSrcweir                     /// OD 08.10.2002 #103898# - add condition
981cdf0e10cSrcweir                     /// <!(pFly->IsBackgroundTransparent() || pFly->IsShadowTransparent())>
982cdf0e10cSrcweir                     if( !( pFly->IsBackgroundTransparent()
983cdf0e10cSrcweir                            || pFly->IsShadowTransparent() ) &&
984cdf0e10cSrcweir                         SURROUND_THROUGHT == rSur.GetSurround() &&
985cdf0e10cSrcweir                         ( !rSur.IsAnchorOnly() ||
986cdf0e10cSrcweir                           // --> OD 2006-08-15 #i68520#
987cdf0e10cSrcweir                           GetMaster() == pFly->GetAnchorFrm() ||
988cdf0e10cSrcweir                           // <--
989cdf0e10cSrcweir                           ((FLY_AT_PARA != rAnchor.GetAnchorId()) &&
990cdf0e10cSrcweir                            (FLY_AT_CHAR != rAnchor.GetAnchorId())
991cdf0e10cSrcweir                           )
992cdf0e10cSrcweir                         ) &&
993cdf0e10cSrcweir                         // --> OD 2006-08-15 #i68520#
994cdf0e10cSrcweir                         pTmpAnchoredObj->GetDrawObj()->GetLayer() != nHellId &&
995cdf0e10cSrcweir                         nCurrOrd < pTmpAnchoredObj->GetDrawObj()->GetOrdNum()
996cdf0e10cSrcweir                         // <--
997cdf0e10cSrcweir                       )
998cdf0e10cSrcweir 					{
999cdf0e10cSrcweir 						//Ausser der Inhalt ist Transparent
1000cdf0e10cSrcweir 						const SwNoTxtFrm *pNoTxt =
1001cdf0e10cSrcweir 								pFly->Lower() && pFly->Lower()->IsNoTxtFrm()
1002cdf0e10cSrcweir 												   ? (SwNoTxtFrm*)pFly->Lower()
1003cdf0e10cSrcweir 												   : 0;
1004cdf0e10cSrcweir 						if ( !pNoTxt ||
1005cdf0e10cSrcweir 							 (!pNoTxt->IsTransparent() && !rSur.IsContour()) )
1006cdf0e10cSrcweir 						{
1007cdf0e10cSrcweir 							bOpaque = sal_True;
1008cdf0e10cSrcweir 							aRegion -= pFly->Frm();
1009cdf0e10cSrcweir 						}
1010cdf0e10cSrcweir 					}
1011cdf0e10cSrcweir 				}
1012cdf0e10cSrcweir 			}
1013cdf0e10cSrcweir 		}
1014cdf0e10cSrcweir 	}
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir 	Point aPos( rInf.GetPos().X(), rInf.GetPos().Y() + rInf.GetAscent() );
1017cdf0e10cSrcweir 	const Point &rOld = rInf.GetPos();
1018cdf0e10cSrcweir 	rInf.SetPos( aPos );
1019cdf0e10cSrcweir 
1020cdf0e10cSrcweir 	if( !bOpaque )
1021cdf0e10cSrcweir 	{
1022cdf0e10cSrcweir 		if( rInf.GetKern() )
1023cdf0e10cSrcweir 			rInf.GetFont()->_DrawStretchText( rInf );
1024cdf0e10cSrcweir 		else
1025cdf0e10cSrcweir 			rInf.GetFont()->_DrawText( rInf );
1026cdf0e10cSrcweir 		rInf.SetPos( rOld );
1027cdf0e10cSrcweir 		return sal_False;
1028cdf0e10cSrcweir 	}
1029cdf0e10cSrcweir 	else if( aRegion.Count() )
1030cdf0e10cSrcweir 	{
1031cdf0e10cSrcweir 		// Was fuer ein Aufwand ...
1032cdf0e10cSrcweir 		SwSaveClip aClipVout( rInf.GetpOut() );
1033cdf0e10cSrcweir 		for( MSHORT i = 0; i < aRegion.Count(); ++i )
1034cdf0e10cSrcweir 		{
1035cdf0e10cSrcweir 			SwRect &rRect = aRegion[i];
1036cdf0e10cSrcweir 			if( rRect != aRegion.GetOrigin() )
1037cdf0e10cSrcweir 				aClipVout.ChgClip( rRect );
1038cdf0e10cSrcweir 			if( rInf.GetKern() )
1039cdf0e10cSrcweir 				rInf.GetFont()->_DrawStretchText( rInf );
1040cdf0e10cSrcweir 			else
1041cdf0e10cSrcweir 				rInf.GetFont()->_DrawText( rInf );
1042cdf0e10cSrcweir 		}
1043cdf0e10cSrcweir 	}
1044cdf0e10cSrcweir 	rInf.SetPos( rOld );
1045cdf0e10cSrcweir 	return sal_True;
1046cdf0e10cSrcweir }
1047cdf0e10cSrcweir 
1048cdf0e10cSrcweir /*************************************************************************
1049cdf0e10cSrcweir  *						SwTxtFly::DrawFlyRect()
1050cdf0e10cSrcweir  *
1051cdf0e10cSrcweir  * IN: windowlokal
1052cdf0e10cSrcweir  * Zwei Feinheiten gilt es zu beachten:
1053cdf0e10cSrcweir  * 1) DrawRect() oberhalb des ClipRects sind erlaubt !
1054cdf0e10cSrcweir  * 2) FlyToRect() liefert groessere Werte als die Framedaten !
1055cdf0e10cSrcweir  *************************************************************************/
1056cdf0e10cSrcweir 
DrawFlyRect(OutputDevice * pOut,const SwRect & rRect,const SwTxtPaintInfo & rInf,sal_Bool bNoGraphic)1057cdf0e10cSrcweir void SwTxtFly::DrawFlyRect( OutputDevice* pOut, const SwRect &rRect,
1058cdf0e10cSrcweir 		const SwTxtPaintInfo &rInf, sal_Bool bNoGraphic )
1059cdf0e10cSrcweir {
1060cdf0e10cSrcweir 	SwRegionRects aRegion( rRect );
1061cdf0e10cSrcweir 	ASSERT( !bTopRule, "DrawFlyRect: Wrong TopRule" );
1062cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
1063cdf0e10cSrcweir     SwAnchoredObjList::size_type nCount( bOn ? GetAnchoredObjList()->size() : 0 );
1064cdf0e10cSrcweir     if ( bOn && nCount > 0 )
1065cdf0e10cSrcweir     // <--
1066cdf0e10cSrcweir 	{
1067cdf0e10cSrcweir         MSHORT nHellId = pPage->getRootFrm()->GetCurrShell()->getIDocumentDrawModelAccess()->GetHellId();
1068cdf0e10cSrcweir 		for( MSHORT i = 0; i < nCount; ++i )
1069cdf0e10cSrcweir 		{
1070cdf0e10cSrcweir             // --> OD 2006-08-15 #i68520#
1071cdf0e10cSrcweir             const SwAnchoredObject* pAnchoredObjTmp = (*mpAnchoredObjList)[i];
1072cdf0e10cSrcweir             if( mpCurrAnchoredObj != pAnchoredObjTmp &&
1073cdf0e10cSrcweir                 dynamic_cast<const SwFlyFrm*>(pAnchoredObjTmp) )
1074cdf0e10cSrcweir             // <--
1075cdf0e10cSrcweir 			{
1076cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
1077cdf0e10cSrcweir                 const SwFmtSurround& rSur = pAnchoredObjTmp->GetFrmFmt().GetSurround();
1078cdf0e10cSrcweir                 // <--
1079cdf0e10cSrcweir 
1080cdf0e10cSrcweir                 // OD 24.01.2003 #106593# - correct clipping of fly frame area.
1081cdf0e10cSrcweir                 // Consider that fly frame background/shadow can be transparent
1082cdf0e10cSrcweir                 // and <SwAlignRect(..)> fly frame area
1083cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
1084cdf0e10cSrcweir                 const SwFlyFrm* pFly = dynamic_cast<const SwFlyFrm*>(pAnchoredObjTmp);
1085cdf0e10cSrcweir                 // <--
1086cdf0e10cSrcweir                 // --> OD 2005-06-08 #i47804# - consider transparent graphics
1087cdf0e10cSrcweir                 // and OLE objects.
1088cdf0e10cSrcweir                 bool bClipFlyArea =
1089cdf0e10cSrcweir                         ( ( SURROUND_THROUGHT == rSur.GetSurround() )
1090cdf0e10cSrcweir                           // --> OD 2006-08-15 #i68520#
1091cdf0e10cSrcweir                           ? (pAnchoredObjTmp->GetDrawObj()->GetLayer() != nHellId)
1092cdf0e10cSrcweir                           // <--
1093cdf0e10cSrcweir                           : !rSur.IsContour() ) &&
1094cdf0e10cSrcweir                         !pFly->IsBackgroundTransparent() &&
1095cdf0e10cSrcweir                         !pFly->IsShadowTransparent() &&
1096cdf0e10cSrcweir                         ( !pFly->Lower() ||
1097cdf0e10cSrcweir                           !pFly->Lower()->IsNoTxtFrm() ||
1098cdf0e10cSrcweir                           !static_cast<const SwNoTxtFrm*>(pFly->Lower())->IsTransparent() );
1099cdf0e10cSrcweir                 // <--
1100cdf0e10cSrcweir                 if ( bClipFlyArea )
1101cdf0e10cSrcweir 				{
1102cdf0e10cSrcweir                     // --> OD 2006-08-15 #i68520#
1103cdf0e10cSrcweir                     SwRect aFly( pAnchoredObjTmp->GetObjRect() );
1104cdf0e10cSrcweir                     // <--
1105cdf0e10cSrcweir                     // OD 24.01.2003 #106593#
1106cdf0e10cSrcweir                     ::SwAlignRect( aFly, pPage->getRootFrm()->GetCurrShell() );
1107cdf0e10cSrcweir 					if( aFly.Width() > 0 && aFly.Height() > 0 )
1108cdf0e10cSrcweir 						aRegion -= aFly;
1109cdf0e10cSrcweir 				}
1110cdf0e10cSrcweir 			}
1111cdf0e10cSrcweir 		}
1112cdf0e10cSrcweir 	}
1113cdf0e10cSrcweir 
1114cdf0e10cSrcweir 	for( MSHORT i = 0; i < aRegion.Count(); ++i )
1115cdf0e10cSrcweir 	{
1116cdf0e10cSrcweir 		if ( bNoGraphic )
1117cdf0e10cSrcweir 			pOut->DrawRect( aRegion[i].SVRect() );
1118cdf0e10cSrcweir 		else
1119cdf0e10cSrcweir 		{
1120cdf0e10cSrcweir 			ASSERT( ((SvxBrushItem*)-1) != rInf.GetBrushItem(),
1121cdf0e10cSrcweir 					"DrawRect: Uninitialized BrushItem!" );
1122cdf0e10cSrcweir 			::DrawGraphic( rInf.GetBrushItem(), pOut, rInf.GetBrushRect(),
1123cdf0e10cSrcweir 					   aRegion[i] );
1124cdf0e10cSrcweir 		}
1125cdf0e10cSrcweir 	}
1126cdf0e10cSrcweir }
1127cdf0e10cSrcweir 
1128cdf0e10cSrcweir // --> OD 2004-10-06 #i26945# - change first parameter:
1129cdf0e10cSrcweir // Now it's the <SwAnchoredObject> instance of the floating screen object
GetTop(const SwAnchoredObject * _pAnchoredObj,const sal_Bool bInFtn,const sal_Bool bInFooterOrHeader)1130cdf0e10cSrcweir sal_Bool SwTxtFly::GetTop( const SwAnchoredObject* _pAnchoredObj,
1131cdf0e10cSrcweir                            const sal_Bool bInFtn,
1132cdf0e10cSrcweir                            const sal_Bool bInFooterOrHeader )
1133cdf0e10cSrcweir // <--
1134cdf0e10cSrcweir {
1135cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
1136cdf0e10cSrcweir     // <mpCurrAnchoredObj> is set, if <pCurrFrm> is inside a fly frame
1137cdf0e10cSrcweir     if( _pAnchoredObj != mpCurrAnchoredObj )
1138cdf0e10cSrcweir     // <--
1139cdf0e10cSrcweir 	{
1140cdf0e10cSrcweir         // --> OD 2004-10-06 #i26945#
1141cdf0e10cSrcweir         const SdrObject* pNew = _pAnchoredObj->GetDrawObj();
1142cdf0e10cSrcweir         // <--
1143cdf0e10cSrcweir 		// #102344# Ignore connectors which have one or more connections
1144cdf0e10cSrcweir 		if(pNew && pNew->ISA(SdrEdgeObj))
1145cdf0e10cSrcweir 		{
1146cdf0e10cSrcweir 			if(((SdrEdgeObj*)pNew)->GetConnectedNode(sal_True)
1147cdf0e10cSrcweir 				|| ((SdrEdgeObj*)pNew)->GetConnectedNode(sal_False))
1148cdf0e10cSrcweir 			{
1149cdf0e10cSrcweir 				return sal_False;
1150cdf0e10cSrcweir 			}
1151cdf0e10cSrcweir 		}
1152cdf0e10cSrcweir 
1153cdf0e10cSrcweir         if( ( bInFtn || bInFooterOrHeader ) && bTopRule )
1154cdf0e10cSrcweir         {
1155cdf0e10cSrcweir             // --> OD 2004-10-06 #i26945#
1156cdf0e10cSrcweir             const SwFrmFmt& rFrmFmt = _pAnchoredObj->GetFrmFmt();
1157cdf0e10cSrcweir             const SwFmtAnchor& rNewA = rFrmFmt.GetAnchor();
1158cdf0e10cSrcweir             // <--
1159cdf0e10cSrcweir             if (FLY_AT_PAGE == rNewA.GetAnchorId())
1160cdf0e10cSrcweir             {
1161cdf0e10cSrcweir                 if ( bInFtn )
1162cdf0e10cSrcweir                     return sal_False;
1163cdf0e10cSrcweir 
1164cdf0e10cSrcweir                 if ( bInFooterOrHeader )
1165cdf0e10cSrcweir                 {
1166cdf0e10cSrcweir                     SwFmtVertOrient aVert( rFrmFmt.GetVertOrient() );
1167cdf0e10cSrcweir                     sal_Bool bVertPrt = aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ||
1168cdf0e10cSrcweir                             aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA;
1169cdf0e10cSrcweir                     if( bVertPrt )
1170cdf0e10cSrcweir                         return sal_False;
1171cdf0e10cSrcweir                 }
1172cdf0e10cSrcweir             }
1173cdf0e10cSrcweir         }
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir         // --> OD 2006-08-15 #i68520#
1176cdf0e10cSrcweir         // bEvade: consider pNew, if we are not inside a fly
1177cdf0e10cSrcweir         //         consider pNew, if pNew is lower of <mpCurrAnchoredObj>
1178cdf0e10cSrcweir         sal_Bool bEvade = !mpCurrAnchoredObj ||
1179cdf0e10cSrcweir                           Is_Lower_Of( dynamic_cast<const SwFlyFrm*>(mpCurrAnchoredObj), pNew);
1180cdf0e10cSrcweir 
1181cdf0e10cSrcweir         if ( !bEvade )
1182cdf0e10cSrcweir 		{
1183cdf0e10cSrcweir             // We are currently inside a fly frame and pNew is not
1184cdf0e10cSrcweir             // inside this fly frame. We can do some more checks if
1185cdf0e10cSrcweir             // we have to consider pNew.
1186cdf0e10cSrcweir 
1187cdf0e10cSrcweir             // If bTopRule is not set, we ignore the frame types.
1188cdf0e10cSrcweir             // We directly check the z-order
1189cdf0e10cSrcweir 			if ( !bTopRule )
1190cdf0e10cSrcweir 				bEvade = sal_True;
1191cdf0e10cSrcweir 			else
1192cdf0e10cSrcweir 			{
1193cdf0e10cSrcweir 				// innerhalb von verketteten Flys wird nur Lowern ausgewichen
1194cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
1195cdf0e10cSrcweir                 const SwFmtChain &rChain = mpCurrAnchoredObj->GetFrmFmt().GetChain();
1196cdf0e10cSrcweir                 // <--
1197cdf0e10cSrcweir 				if ( !rChain.GetPrev() && !rChain.GetNext() )
1198cdf0e10cSrcweir 				{
1199cdf0e10cSrcweir                     // --> OD 2004-10-06 #i26945#
1200cdf0e10cSrcweir                     const SwFmtAnchor& rNewA = _pAnchoredObj->GetFrmFmt().GetAnchor();
1201cdf0e10cSrcweir                     // <--
1202cdf0e10cSrcweir                     // --> OD 2006-08-15 #i68520#
1203cdf0e10cSrcweir                     const SwFmtAnchor& rCurrA = mpCurrAnchoredObj->GetFrmFmt().GetAnchor();
1204cdf0e10cSrcweir                     // <--
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir                     // If <mpCurrAnchoredObj> is anchored as character, its content
1207cdf0e10cSrcweir                     // does not wrap around pNew
1208cdf0e10cSrcweir                     if (FLY_AS_CHAR == rCurrA.GetAnchorId())
1209cdf0e10cSrcweir 						return sal_False;
1210cdf0e10cSrcweir 
1211cdf0e10cSrcweir                     // If pNew is anchored to page and <mpCurrAnchoredObj is not anchored
1212cdf0e10cSrcweir                     // to page, the content of <mpCurrAnchoredObj> does not wrap around pNew
1213cdf0e10cSrcweir                     // If both pNew and <mpCurrAnchoredObj> are anchored to page, we can do
1214cdf0e10cSrcweir                     // some more checks
1215cdf0e10cSrcweir                     if (FLY_AT_PAGE == rNewA.GetAnchorId())
1216cdf0e10cSrcweir                     {
1217cdf0e10cSrcweir                         if (FLY_AT_PAGE == rCurrA.GetAnchorId())
1218cdf0e10cSrcweir                         {
1219cdf0e10cSrcweir                             bEvade = sal_True;
1220cdf0e10cSrcweir                         }
1221cdf0e10cSrcweir 						else
1222cdf0e10cSrcweir 							return sal_False;
1223cdf0e10cSrcweir 					}
1224cdf0e10cSrcweir                     else if (FLY_AT_PAGE == rCurrA.GetAnchorId())
1225cdf0e10cSrcweir 						return sal_False; // Seitengebundene weichen nur seitengeb. aus
1226cdf0e10cSrcweir 					else if (FLY_AT_FLY == rNewA.GetAnchorId())
1227cdf0e10cSrcweir 						bEvade = sal_True; // Nicht seitengeb. weichen Rahmengeb. aus
1228cdf0e10cSrcweir 					else if( FLY_AT_FLY == rCurrA.GetAnchorId() )
1229cdf0e10cSrcweir 						return sal_False; // Rahmengebundene weichen abs.geb. nicht aus
1230cdf0e10cSrcweir                     // --> OD 2006-01-30 #i57062#
1231cdf0e10cSrcweir                     // In order to avoid loop situation, it's decided to adjust
1232cdf0e10cSrcweir                     // the wrapping behaviour of content of at-paragraph/at-character
1233cdf0e10cSrcweir                     // anchored objects to one in the page header/footer and
1234cdf0e10cSrcweir                     // the document body --> content of at-paragraph/at-character
1235cdf0e10cSrcweir                     // anchored objects doesn't wrap around each other.
1236cdf0e10cSrcweir //                    else if( bInFooterOrHeader )
1237cdf0e10cSrcweir //                        return sal_False;  // In header or footer no wrapping
1238cdf0e10cSrcweir //                                           // if both bounded at paragraph
1239cdf0e10cSrcweir //                    else // Zwei Flies mit (auto-)absatzgebunder Verankerung ...
1240cdf0e10cSrcweir //                    // ... entscheiden nach der Reihenfolge ihrer Anker im Dok.
1241cdf0e10cSrcweir //                      bEvade = rNewA.GetCntntAnchor()->nNode.GetIndex() <=
1242cdf0e10cSrcweir //                              rCurrA.GetCntntAnchor()->nNode.GetIndex();
1243cdf0e10cSrcweir                     else
1244cdf0e10cSrcweir                         return sal_False;
1245cdf0e10cSrcweir                     // <--
1246cdf0e10cSrcweir 				}
1247cdf0e10cSrcweir 			}
1248cdf0e10cSrcweir 
1249cdf0e10cSrcweir             // aber: es wird niemals einem hierarchisch untergeordnetem
1250cdf0e10cSrcweir 			// ausgewichen und ausserdem braucht nur bei Ueberlappung
1251cdf0e10cSrcweir 			// ausgewichen werden.
1252cdf0e10cSrcweir             // --> OD 2006-08-15 #i68520#
1253cdf0e10cSrcweir             bEvade &= ( mpCurrAnchoredObj->GetDrawObj()->GetOrdNum() < pNew->GetOrdNum() );
1254cdf0e10cSrcweir             // <--
1255cdf0e10cSrcweir 			if( bEvade )
1256cdf0e10cSrcweir 			{
1257cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
1258cdf0e10cSrcweir                 SwRect aTmp( _pAnchoredObj->GetObjRectWithSpaces() );
1259cdf0e10cSrcweir                 if ( !aTmp.IsOver( mpCurrAnchoredObj->GetObjRectWithSpaces() ) )
1260cdf0e10cSrcweir                     bEvade = sal_False;
1261cdf0e10cSrcweir                 // <--
1262cdf0e10cSrcweir 			}
1263cdf0e10cSrcweir 		}
1264cdf0e10cSrcweir 
1265cdf0e10cSrcweir         if ( bEvade )
1266cdf0e10cSrcweir 		{
1267cdf0e10cSrcweir             // --> OD 2004-10-06 #i26945#
1268cdf0e10cSrcweir             const SwFmtAnchor& rNewA = _pAnchoredObj->GetFrmFmt().GetAnchor();
1269cdf0e10cSrcweir             // <--
1270cdf0e10cSrcweir             ASSERT( FLY_AS_CHAR != rNewA.GetAnchorId(),
1271cdf0e10cSrcweir                     "Don't call GetTop with a FlyInCntFrm" );
1272cdf0e10cSrcweir             if (FLY_AT_PAGE == rNewA.GetAnchorId())
1273cdf0e10cSrcweir 				return sal_True;  // Seitengebundenen wird immer ausgewichen.
1274cdf0e10cSrcweir 
1275cdf0e10cSrcweir 			// Wenn absatzgebundene Flys in einem FlyCnt gefangen sind, so
1276cdf0e10cSrcweir 			// endet deren Einflussbereich an den Grenzen des FlyCnt!
1277cdf0e10cSrcweir 			// Wenn wir aber gerade den Text des FlyCnt formatieren, dann
1278cdf0e10cSrcweir 			// muss er natuerlich dem absatzgebundenen Frm ausweichen!
1279cdf0e10cSrcweir 			// pCurrFrm ist der Anker von pNew?
1280cdf0e10cSrcweir             // --> OD 2004-10-06 #i26945#
1281cdf0e10cSrcweir             const SwFrm* pTmp = _pAnchoredObj->GetAnchorFrm();
1282cdf0e10cSrcweir             // <--
1283cdf0e10cSrcweir 			if( pTmp == pCurrFrm )
1284cdf0e10cSrcweir 				return sal_True;
1285cdf0e10cSrcweir 			if( pTmp->IsTxtFrm() && ( pTmp->IsInFly() || pTmp->IsInFtn() ) )
1286cdf0e10cSrcweir 			{
1287cdf0e10cSrcweir                 // --> OD 2004-10-06 #i26945#
1288cdf0e10cSrcweir                 Point aPos = _pAnchoredObj->GetObjRect().Pos();
1289cdf0e10cSrcweir                 // <--
1290cdf0e10cSrcweir 				pTmp = GetVirtualUpper( pTmp, aPos );
1291cdf0e10cSrcweir 			}
1292cdf0e10cSrcweir             // --> OD 2004-10-06 #i26945#
1293cdf0e10cSrcweir             // --> OD 2004-11-29 #115759#
1294cdf0e10cSrcweir             // If <pTmp> is a text frame inside a table, take the upper
1295cdf0e10cSrcweir             // of the anchor frame, which contains the anchor position.
1296cdf0e10cSrcweir             else if ( pTmp->IsTxtFrm() && pTmp->IsInTab() )
1297cdf0e10cSrcweir             {
1298cdf0e10cSrcweir                 pTmp = const_cast<SwAnchoredObject*>(_pAnchoredObj)
1299cdf0e10cSrcweir                                 ->GetAnchorFrmContainingAnchPos()->GetUpper();
1300cdf0e10cSrcweir             }
1301cdf0e10cSrcweir             // <--
1302cdf0e10cSrcweir             // --> OD 2004-05-13 #i28701# - consider all objects in same context,
1303cdf0e10cSrcweir             // if wrapping style is considered on object positioning.
1304cdf0e10cSrcweir             // Thus, text will wrap around negative positioned objects.
1305cdf0e10cSrcweir             // --> OD 2004-08-25 #i3317# - remove condition on checking,
1306cdf0e10cSrcweir             // if wrappings style is considered on object postioning.
1307cdf0e10cSrcweir             // Thus, text is wrapping around negative positioned objects.
1308cdf0e10cSrcweir             // --> OD 2004-10-20 #i35640# - no consideration of negative
1309cdf0e10cSrcweir             // positioned objects, if wrapping style isn't considered on
1310cdf0e10cSrcweir             // object position and former text wrapping is applied.
1311cdf0e10cSrcweir             // This condition is typically for documents imported from the
1312cdf0e10cSrcweir             // OpenOffice.org file format.
1313cdf0e10cSrcweir             const IDocumentSettingAccess* pIDSA = pCurrFrm->GetTxtNode()->getIDocumentSettingAccess();
1314cdf0e10cSrcweir             if ( (  pIDSA->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) ||
1315cdf0e10cSrcweir                    !pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) ) &&
1316cdf0e10cSrcweir                  ::FindKontext( pTmp, 0 ) == ::FindKontext( pCurrFrm, 0 ) )
1317cdf0e10cSrcweir             {
1318cdf0e10cSrcweir                 return sal_True;
1319cdf0e10cSrcweir             }
1320cdf0e10cSrcweir             // <--
1321cdf0e10cSrcweir 
1322cdf0e10cSrcweir             const SwFrm* pHeader = 0;
1323cdf0e10cSrcweir             if ( pCurrFrm->GetNext() != pTmp &&
1324cdf0e10cSrcweir                  ( IsFrmInSameKontext( pTmp, pCurrFrm ) ||
1325cdf0e10cSrcweir                    // --> #i13832#, #i24135# wrap around objects in page header
1326cdf0e10cSrcweir                    ( !pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) &&
1327cdf0e10cSrcweir                      0 != ( pHeader = pTmp->FindFooterOrHeader() ) &&
1328cdf0e10cSrcweir                      !pHeader->IsFooterFrm() &&
1329cdf0e10cSrcweir                      pCurrFrm->IsInDocBody() ) ) )
1330cdf0e10cSrcweir                    // <--
1331cdf0e10cSrcweir 			{
1332cdf0e10cSrcweir 				if( pHeader || FLY_AT_FLY == rNewA.GetAnchorId() )
1333cdf0e10cSrcweir 					return sal_True;
1334cdf0e10cSrcweir 
1335cdf0e10cSrcweir                 // Compare indices:
1336cdf0e10cSrcweir 				// Den Index des anderen erhalten wir immer ueber das Ankerattr.
1337cdf0e10cSrcweir 				sal_uLong nTmpIndex = rNewA.GetCntntAnchor()->nNode.GetIndex();
1338cdf0e10cSrcweir 				// Jetzt wird noch ueberprueft, ob der aktuelle Absatz vor dem
1339cdf0e10cSrcweir 				// Anker des verdraengenden Objekts im Text steht, dann wird
1340cdf0e10cSrcweir 				// nicht ausgewichen.
1341cdf0e10cSrcweir 				// Der Index wird moeglichst ueber einen SwFmtAnchor ermittelt,
1342cdf0e10cSrcweir 				// da sonst recht teuer.
1343cdf0e10cSrcweir 				if( ULONG_MAX == nIndex )
1344cdf0e10cSrcweir 					nIndex = pCurrFrm->GetNode()->GetIndex();
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir 				if( nIndex >= nTmpIndex )
1347cdf0e10cSrcweir 					return sal_True;
1348cdf0e10cSrcweir 			}
1349cdf0e10cSrcweir 		}
1350cdf0e10cSrcweir 	}
1351cdf0e10cSrcweir     return sal_False;
1352cdf0e10cSrcweir }
1353cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
1354cdf0e10cSrcweir struct AnchoredObjOrder
1355cdf0e10cSrcweir {
1356cdf0e10cSrcweir     sal_Bool mbR2L;
1357cdf0e10cSrcweir     SwRectFn mfnRect;
1358cdf0e10cSrcweir 
AnchoredObjOrderAnchoredObjOrder1359cdf0e10cSrcweir     AnchoredObjOrder( const sal_Bool bR2L,
1360cdf0e10cSrcweir                        SwRectFn fnRect )
1361cdf0e10cSrcweir         : mbR2L( bR2L ),
1362cdf0e10cSrcweir           mfnRect( fnRect )
1363cdf0e10cSrcweir     {}
1364cdf0e10cSrcweir 
operator ()AnchoredObjOrder1365cdf0e10cSrcweir     bool operator()( const SwAnchoredObject* pListedAnchoredObj,
1366cdf0e10cSrcweir                      const SwAnchoredObject* pNewAnchoredObj )
1367cdf0e10cSrcweir     {
1368cdf0e10cSrcweir         const SwRect aBoundRectOfListedObj( pListedAnchoredObj->GetObjRectWithSpaces() );
1369cdf0e10cSrcweir         const SwRect aBoundRectOfNewObj( pNewAnchoredObj->GetObjRectWithSpaces() );
1370cdf0e10cSrcweir         if ( ( mbR2L &&
1371cdf0e10cSrcweir                ( (aBoundRectOfListedObj.*mfnRect->fnGetRight)() ==
1372cdf0e10cSrcweir                  (aBoundRectOfNewObj.*mfnRect->fnGetRight)() ) ) ||
1373cdf0e10cSrcweir              ( !mbR2L &&
1374cdf0e10cSrcweir                ( (aBoundRectOfListedObj.*mfnRect->fnGetLeft)() ==
1375cdf0e10cSrcweir                  (aBoundRectOfNewObj.*mfnRect->fnGetLeft)() ) ) )
1376cdf0e10cSrcweir         {
1377cdf0e10cSrcweir             SwTwips nTopDiff =
1378cdf0e10cSrcweir                 (*mfnRect->fnYDiff)( (aBoundRectOfNewObj.*mfnRect->fnGetTop)(),
1379cdf0e10cSrcweir                                     (aBoundRectOfListedObj.*mfnRect->fnGetTop)() );
1380cdf0e10cSrcweir             if ( nTopDiff == 0 &&
1381cdf0e10cSrcweir                  ( ( mbR2L &&
1382cdf0e10cSrcweir                      ( (aBoundRectOfNewObj.*mfnRect->fnGetLeft)() >
1383cdf0e10cSrcweir                        (aBoundRectOfListedObj.*mfnRect->fnGetLeft)() ) ) ||
1384cdf0e10cSrcweir                    ( !mbR2L &&
1385cdf0e10cSrcweir                      ( (aBoundRectOfNewObj.*mfnRect->fnGetRight)() <
1386cdf0e10cSrcweir                        (aBoundRectOfListedObj.*mfnRect->fnGetRight)() ) ) ) )
1387cdf0e10cSrcweir             {
1388cdf0e10cSrcweir                 return true;
1389cdf0e10cSrcweir             }
1390cdf0e10cSrcweir             else if ( nTopDiff > 0 )
1391cdf0e10cSrcweir             {
1392cdf0e10cSrcweir                 return true;
1393cdf0e10cSrcweir             }
1394cdf0e10cSrcweir         }
1395cdf0e10cSrcweir         else if ( ( mbR2L &&
1396cdf0e10cSrcweir                     ( (aBoundRectOfListedObj.*mfnRect->fnGetRight)() >
1397cdf0e10cSrcweir                       (aBoundRectOfNewObj.*mfnRect->fnGetRight)() ) ) ||
1398cdf0e10cSrcweir                   ( !mbR2L &&
1399cdf0e10cSrcweir                     ( (aBoundRectOfListedObj.*mfnRect->fnGetLeft)() <
1400cdf0e10cSrcweir                       (aBoundRectOfNewObj.*mfnRect->fnGetLeft)() ) ) )
1401cdf0e10cSrcweir         {
1402cdf0e10cSrcweir             return true;
1403cdf0e10cSrcweir         }
1404cdf0e10cSrcweir 
1405cdf0e10cSrcweir         return false;
1406cdf0e10cSrcweir     }
1407cdf0e10cSrcweir };
1408cdf0e10cSrcweir 
1409cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
InitAnchoredObjList()1410cdf0e10cSrcweir SwAnchoredObjList* SwTxtFly::InitAnchoredObjList()
1411cdf0e10cSrcweir {
1412cdf0e10cSrcweir 	ASSERT( pCurrFrm, "InitFlyList: No Frame, no FlyList" );
1413cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
1414cdf0e10cSrcweir     ASSERT( !mpAnchoredObjList, "InitFlyList: FlyList already initialized" );
1415cdf0e10cSrcweir     // <--
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir     SWAP_IF_SWAPPED( pCurrFrm )
1418cdf0e10cSrcweir 
1419cdf0e10cSrcweir     const SwSortedObjs *pSorted = pPage->GetSortedObjs();
1420cdf0e10cSrcweir     const sal_uInt32 nCount = pSorted ? pSorted->Count() : 0;
1421cdf0e10cSrcweir     // --> #108724# Page header/footer content doesn't have to wrap around
1422cdf0e10cSrcweir     //              floating screen objects
1423cdf0e10cSrcweir     const bool bFooterHeader = 0 != pCurrFrm->FindFooterOrHeader();
1424cdf0e10cSrcweir     const IDocumentSettingAccess* pIDSA = pCurrFrm->GetTxtNode()->getIDocumentSettingAccess();
1425cdf0e10cSrcweir     // --> OD 2005-01-12 #i40155# - check, if frame is marked not to wrap
1426cdf0e10cSrcweir     const sal_Bool bWrapAllowed = ( pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) ||
1427cdf0e10cSrcweir                                     ( !pCurrFrm->IsInFtn() && !bFooterHeader ) ) &&
1428cdf0e10cSrcweir                                       !SwLayouter::FrmNotToWrap( *pCurrFrm->GetTxtNode()->getIDocumentLayoutAccess(), *pCurrFrm );
1429cdf0e10cSrcweir     // <--
1430cdf0e10cSrcweir 
1431cdf0e10cSrcweir     bOn = sal_False;
1432cdf0e10cSrcweir 
1433cdf0e10cSrcweir 	if( nCount && bWrapAllowed )
1434cdf0e10cSrcweir 	{
1435cdf0e10cSrcweir         // --> OD 2006-08-15 #i68520#
1436cdf0e10cSrcweir         mpAnchoredObjList = new SwAnchoredObjList();
1437cdf0e10cSrcweir         // <--
1438cdf0e10cSrcweir 
1439cdf0e10cSrcweir         // --> OD 2004-06-18 #i28701# - consider complete frame area for new
1440cdf0e10cSrcweir         // text wrapping
1441cdf0e10cSrcweir         SwRect aRect;
1442cdf0e10cSrcweir         if ( pIDSA->get(IDocumentSettingAccess::USE_FORMER_TEXT_WRAPPING) )
1443cdf0e10cSrcweir         {
1444cdf0e10cSrcweir             aRect = pCurrFrm->Prt();
1445cdf0e10cSrcweir             aRect += pCurrFrm->Frm().Pos();
1446cdf0e10cSrcweir         }
1447cdf0e10cSrcweir         else
1448cdf0e10cSrcweir         {
1449cdf0e10cSrcweir             aRect = pCurrFrm->Frm();
1450cdf0e10cSrcweir         }
1451cdf0e10cSrcweir 		// Wir machen uns etwas kleiner als wir sind,
1452cdf0e10cSrcweir 		// damit Ein-Twip-Ueberlappungen ignoriert werden. (#49532)
1453cdf0e10cSrcweir         SWRECTFN( pCurrFrm )
1454cdf0e10cSrcweir         const long nRight = (aRect.*fnRect->fnGetRight)() - 1;
1455cdf0e10cSrcweir         const long nLeft = (aRect.*fnRect->fnGetLeft)() + 1;
1456cdf0e10cSrcweir         const sal_Bool bR2L = pCurrFrm->IsRightToLeft();
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir         const IDocumentDrawModelAccess* pIDDMA = pCurrFrm->GetTxtNode()->getIDocumentDrawModelAccess();
1459cdf0e10cSrcweir 
1460cdf0e10cSrcweir         for( sal_uInt32 i = 0; i < nCount; i++ )
1461cdf0e10cSrcweir 		{
1462cdf0e10cSrcweir             // --> OD 2006-08-15 #i68520#
1463cdf0e10cSrcweir //            SwAnchoredObject* pAnchoredObj = (*pSorted)[ i ];
1464cdf0e10cSrcweir //            const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
1465cdf0e10cSrcweir 
1466cdf0e10cSrcweir //            // OD 2004-01-15 #110582# - do not consider hidden objects
1467cdf0e10cSrcweir //            // OD 2004-05-13 #i28701# - check, if object has to be considered
1468cdf0e10cSrcweir //            // for text wrap.
1469cdf0e10cSrcweir //            if ( !pDoc->IsVisibleLayerId( pAnchoredObj->GetDrawObj()->GetLayer() ) ||
1470cdf0e10cSrcweir //                 !pAnchoredObj->ConsiderForTextWrap() ||
1471cdf0e10cSrcweir //                 nRight < (aBound.*fnRect->fnGetLeft)() ||
1472cdf0e10cSrcweir //                 (*fnRect->fnYDiff)( (aRect.*fnRect->fnGetTop)(),
1473cdf0e10cSrcweir //                                     (aBound.*fnRect->fnGetBottom)() ) > 0 ||
1474cdf0e10cSrcweir //                 nLeft > (aBound.*fnRect->fnGetRight)() ||
1475cdf0e10cSrcweir //                 // --> OD 2004-12-17 #118809# - If requested, do not consider
1476cdf0e10cSrcweir //                 // objects in page header|footer for text frames not in page
1477cdf0e10cSrcweir //                 // header|footer. This is requested for the calculation of
1478cdf0e10cSrcweir //                 // the base offset for objects <SwTxtFrm::CalcBaseOfstForFly()>
1479cdf0e10cSrcweir //                 ( mbIgnoreObjsInHeaderFooter && !bFooterHeader &&
1480cdf0e10cSrcweir //                   pAnchoredObj->GetAnchorFrm()->FindFooterOrHeader() ) ||
1481cdf0e10cSrcweir //                 // <--
1482cdf0e10cSrcweir //                 // --> FME 2004-07-14 #i20505# Do not consider oversized objects
1483cdf0e10cSrcweir //                 (aBound.*fnRect->fnGetHeight)() >
1484cdf0e10cSrcweir //                 2 * (pPage->Frm().*fnRect->fnGetHeight)() )
1485cdf0e10cSrcweir //                 // <--
1486cdf0e10cSrcweir //            {
1487cdf0e10cSrcweir //              continue;
1488cdf0e10cSrcweir //            }
1489cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pSorted)[ i ];
1490cdf0e10cSrcweir             if ( !pIDDMA->IsVisibleLayerId( pAnchoredObj->GetDrawObj()->GetLayer() ) ||
1491cdf0e10cSrcweir                  !pAnchoredObj->ConsiderForTextWrap() ||
1492cdf0e10cSrcweir                  ( mbIgnoreObjsInHeaderFooter && !bFooterHeader &&
1493cdf0e10cSrcweir                    pAnchoredObj->GetAnchorFrm()->FindFooterOrHeader() ) )
1494cdf0e10cSrcweir             {
1495cdf0e10cSrcweir                 continue;
1496cdf0e10cSrcweir             }
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir             const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
1499cdf0e10cSrcweir             if ( nRight < (aBound.*fnRect->fnGetLeft)() ||
1500cdf0e10cSrcweir                  (*fnRect->fnYDiff)( (aRect.*fnRect->fnGetTop)(),
1501cdf0e10cSrcweir                                      (aBound.*fnRect->fnGetBottom)() ) > 0 ||
1502cdf0e10cSrcweir                  nLeft > (aBound.*fnRect->fnGetRight)() ||
1503cdf0e10cSrcweir                  (aBound.*fnRect->fnGetHeight)() >
1504cdf0e10cSrcweir                                     2 * (pPage->Frm().*fnRect->fnGetHeight)() )
1505cdf0e10cSrcweir             {
1506cdf0e10cSrcweir                 continue;
1507cdf0e10cSrcweir             }
1508cdf0e10cSrcweir             // <--
1509cdf0e10cSrcweir 
1510cdf0e10cSrcweir             // --> OD 2004-10-06 #i26945# - pass <pAnchoredObj> to method
1511cdf0e10cSrcweir             // <GetTop(..)> instead of only the <SdrObject> instance of the
1512cdf0e10cSrcweir             // anchored object
1513cdf0e10cSrcweir             if ( GetTop( pAnchoredObj, pCurrFrm->IsInFtn(), bFooterHeader ) )
1514cdf0e10cSrcweir             // <--
1515cdf0e10cSrcweir 			{
1516cdf0e10cSrcweir                 // OD 11.03.2003 #107862# - adjust insert position:
1517cdf0e10cSrcweir                 // overlapping objects should be sorted from left to right and
1518cdf0e10cSrcweir                 // inside left to right sorting from top to bottom.
1519cdf0e10cSrcweir                 // If objects on the same position are found, they are sorted
1520cdf0e10cSrcweir                 // on its width.
1521cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
1522cdf0e10cSrcweir //                sal_uInt16 nPos = pFlyList->Count();
1523cdf0e10cSrcweir //                while ( nPos )
1524cdf0e10cSrcweir //                {
1525cdf0e10cSrcweir //                    SdrObject* pTmpObj = (*pFlyList)[ --nPos ];
1526cdf0e10cSrcweir //                    const SwRect aBoundRectOfTmpObj( GetBoundRect( pTmpObj ) );
1527cdf0e10cSrcweir //                    if ( ( bR2L &&
1528cdf0e10cSrcweir //                           ( (aBoundRectOfTmpObj.*fnRect->fnGetRight)() ==
1529cdf0e10cSrcweir //                             (aBound.*fnRect->fnGetRight)() ) ) ||
1530cdf0e10cSrcweir //                         ( !bR2L &&
1531cdf0e10cSrcweir //                           ( (aBoundRectOfTmpObj.*fnRect->fnGetLeft)() ==
1532cdf0e10cSrcweir //                             (aBound.*fnRect->fnGetLeft)() ) ) )
1533cdf0e10cSrcweir //                    {
1534cdf0e10cSrcweir //                        SwTwips nTopDiff =
1535cdf0e10cSrcweir //                            (*fnRect->fnYDiff)( (aBound.*fnRect->fnGetTop)(),
1536cdf0e10cSrcweir //                                                (aBoundRectOfTmpObj.*fnRect->fnGetTop)() );
1537cdf0e10cSrcweir //                        if ( nTopDiff == 0 &&
1538cdf0e10cSrcweir //                             ( ( bR2L &&
1539cdf0e10cSrcweir //                                 ( (aBound.*fnRect->fnGetLeft)() >
1540cdf0e10cSrcweir //                                   (aBoundRectOfTmpObj.*fnRect->fnGetLeft)() ) ) ||
1541cdf0e10cSrcweir //                               ( !bR2L &&
1542cdf0e10cSrcweir //                                 ( (aBound.*fnRect->fnGetRight)() <
1543cdf0e10cSrcweir //                                   (aBoundRectOfTmpObj.*fnRect->fnGetRight)() ) ) ) )
1544cdf0e10cSrcweir //                        {
1545cdf0e10cSrcweir //                            ++nPos;
1546cdf0e10cSrcweir //                            break;
1547cdf0e10cSrcweir //                        }
1548cdf0e10cSrcweir //                        else if ( nTopDiff > 0 )
1549cdf0e10cSrcweir //                        {
1550cdf0e10cSrcweir //                            ++nPos;
1551cdf0e10cSrcweir //                            break;
1552cdf0e10cSrcweir //                        }
1553cdf0e10cSrcweir //                    }
1554cdf0e10cSrcweir //                    else if ( ( bR2L &&
1555cdf0e10cSrcweir //                                ( (aBoundRectOfTmpObj.*fnRect->fnGetRight)() >
1556cdf0e10cSrcweir //                                  (aBound.*fnRect->fnGetRight)() ) ) ||
1557cdf0e10cSrcweir //                              ( !bR2L &&
1558cdf0e10cSrcweir //                                ( (aBoundRectOfTmpObj.*fnRect->fnGetLeft)() <
1559cdf0e10cSrcweir //                                  (aBound.*fnRect->fnGetLeft)() ) ) )
1560cdf0e10cSrcweir //                    {
1561cdf0e10cSrcweir //                        ++nPos;
1562cdf0e10cSrcweir //                        break;
1563cdf0e10cSrcweir //                    }
1564cdf0e10cSrcweir //                }
1565cdf0e10cSrcweir //                SdrObject* pSdrObj = pAnchoredObj->DrawObj();
1566cdf0e10cSrcweir //                pFlyList->C40_INSERT( SdrObject, pSdrObj, nPos );
1567cdf0e10cSrcweir                 {
1568cdf0e10cSrcweir                     SwAnchoredObjList::iterator aInsPosIter =
1569cdf0e10cSrcweir                             std::lower_bound( mpAnchoredObjList->begin(),
1570cdf0e10cSrcweir                                               mpAnchoredObjList->end(),
1571cdf0e10cSrcweir                                               pAnchoredObj,
1572cdf0e10cSrcweir                                               AnchoredObjOrder( bR2L, fnRect ) );
1573cdf0e10cSrcweir 
1574cdf0e10cSrcweir                     mpAnchoredObjList->insert( aInsPosIter, pAnchoredObj );
1575cdf0e10cSrcweir                 }
1576cdf0e10cSrcweir                 // <--
1577cdf0e10cSrcweir 
1578cdf0e10cSrcweir                 const SwFmtSurround &rFlyFmt = pAnchoredObj->GetFrmFmt().GetSurround();
1579cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
1580cdf0e10cSrcweir                 if ( rFlyFmt.IsAnchorOnly() &&
1581cdf0e10cSrcweir                      pAnchoredObj->GetAnchorFrm() == GetMaster() )
1582cdf0e10cSrcweir                 // <--
1583cdf0e10cSrcweir 				{
1584cdf0e10cSrcweir                     const SwFmtVertOrient &rTmpFmt =
1585cdf0e10cSrcweir                                     pAnchoredObj->GetFrmFmt().GetVertOrient();
1586cdf0e10cSrcweir                     if( text::VertOrientation::BOTTOM != rTmpFmt.GetVertOrient() )
1587cdf0e10cSrcweir                         nMinBottom = ( bVert && nMinBottom ) ?
1588cdf0e10cSrcweir                                      Min( nMinBottom, aBound.Left() ) :
1589cdf0e10cSrcweir                                      Max( nMinBottom, (aBound.*fnRect->fnGetBottom)() );
1590cdf0e10cSrcweir 				}
1591cdf0e10cSrcweir 
1592cdf0e10cSrcweir 				bOn = sal_True;
1593cdf0e10cSrcweir 			}
1594cdf0e10cSrcweir 		}
1595cdf0e10cSrcweir 		if( nMinBottom )
1596cdf0e10cSrcweir 		{
1597cdf0e10cSrcweir             SwTwips nMax = (pCurrFrm->GetUpper()->*fnRect->fnGetPrtBottom)();
1598cdf0e10cSrcweir             if( (*fnRect->fnYDiff)( nMinBottom, nMax ) > 0 )
1599cdf0e10cSrcweir 				nMinBottom = nMax;
1600cdf0e10cSrcweir 		}
1601cdf0e10cSrcweir 	}
1602cdf0e10cSrcweir 	else
1603cdf0e10cSrcweir     {
1604cdf0e10cSrcweir         // --> OD 2006-08-15 #i68520#
1605cdf0e10cSrcweir         mpAnchoredObjList = new SwAnchoredObjList();
1606cdf0e10cSrcweir         // <--
1607cdf0e10cSrcweir     }
1608cdf0e10cSrcweir 
1609cdf0e10cSrcweir     UNDO_SWAP( pCurrFrm )
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
1612cdf0e10cSrcweir     return mpAnchoredObjList;
1613cdf0e10cSrcweir     // <--
1614cdf0e10cSrcweir }
1615cdf0e10cSrcweir // <--
1616cdf0e10cSrcweir 
CalcMinBottom() const1617cdf0e10cSrcweir SwTwips SwTxtFly::CalcMinBottom() const
1618cdf0e10cSrcweir {
1619cdf0e10cSrcweir 	SwTwips nRet = 0;
1620cdf0e10cSrcweir     const SwSortedObjs *pDrawObj = GetMaster()->GetDrawObjs();
1621cdf0e10cSrcweir     const sal_uInt32 nCount = pDrawObj ? pDrawObj->Count() : 0;
1622cdf0e10cSrcweir 	if( nCount )
1623cdf0e10cSrcweir 	{
1624cdf0e10cSrcweir 		SwTwips nEndOfFrm = pCurrFrm->Frm().Bottom();
1625cdf0e10cSrcweir         for( sal_uInt32 i = 0; i < nCount; i++ )
1626cdf0e10cSrcweir 		{
1627cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pDrawObj)[ i ];
1628cdf0e10cSrcweir             const SwFmtSurround &rFlyFmt = pAnchoredObj->GetFrmFmt().GetSurround();
1629cdf0e10cSrcweir 			if( rFlyFmt.IsAnchorOnly() )
1630cdf0e10cSrcweir 			{
1631cdf0e10cSrcweir                 const SwFmtVertOrient &rTmpFmt =
1632cdf0e10cSrcweir                                     pAnchoredObj->GetFrmFmt().GetVertOrient();
1633cdf0e10cSrcweir                 if( text::VertOrientation::BOTTOM != rTmpFmt.GetVertOrient() )
1634cdf0e10cSrcweir 				{
1635cdf0e10cSrcweir                     const SwRect aBound( pAnchoredObj->GetObjRectWithSpaces() );
1636cdf0e10cSrcweir 					if( aBound.Top() < nEndOfFrm )
1637cdf0e10cSrcweir 						nRet = Max( nRet, aBound.Bottom() );
1638cdf0e10cSrcweir 				}
1639cdf0e10cSrcweir 			}
1640cdf0e10cSrcweir 		}
1641cdf0e10cSrcweir 		SwTwips nMax = pCurrFrm->GetUpper()->Frm().Top() +
1642cdf0e10cSrcweir 					   pCurrFrm->GetUpper()->Prt().Bottom();
1643cdf0e10cSrcweir 		if( nRet > nMax )
1644cdf0e10cSrcweir 			nRet = nMax;
1645cdf0e10cSrcweir 	}
1646cdf0e10cSrcweir 	return nRet;
1647cdf0e10cSrcweir }
1648cdf0e10cSrcweir 
1649cdf0e10cSrcweir /*************************************************************************
1650cdf0e10cSrcweir  * Hier erfolgt die Berechnung der Kontur ...
1651cdf0e10cSrcweir  * CalcBoundRect(..) und andere
1652cdf0e10cSrcweir  *************************************************************************/
1653cdf0e10cSrcweir 
1654cdf0e10cSrcweir /*************************************************************************
1655cdf0e10cSrcweir  * class SwContourCache
1656cdf0e10cSrcweir  *************************************************************************/
1657cdf0e10cSrcweir 
SwContourCache()1658cdf0e10cSrcweir SwContourCache::SwContourCache() :
1659cdf0e10cSrcweir     nPntCnt( 0 ), nObjCnt( 0 )
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir 	memset( (SdrObject**)pSdrObj, 0, sizeof(pSdrObj) );
1662cdf0e10cSrcweir 	memset( pTextRanger, 0, sizeof(pTextRanger) );
1663cdf0e10cSrcweir }
1664cdf0e10cSrcweir 
~SwContourCache()1665cdf0e10cSrcweir SwContourCache::~SwContourCache()
1666cdf0e10cSrcweir {
1667cdf0e10cSrcweir 	for( MSHORT i = 0; i < nObjCnt; delete pTextRanger[ i++ ] )
1668cdf0e10cSrcweir 		;
1669cdf0e10cSrcweir }
1670cdf0e10cSrcweir 
ClrObject(MSHORT nPos)1671cdf0e10cSrcweir void SwContourCache::ClrObject( MSHORT nPos )
1672cdf0e10cSrcweir {
1673cdf0e10cSrcweir 	ASSERT( pTextRanger[ nPos ], "ClrObject: Allready cleared. Good Bye!" );
1674cdf0e10cSrcweir 	nPntCnt -= pTextRanger[ nPos ]->GetPointCount();
1675cdf0e10cSrcweir 	delete pTextRanger[ nPos ];
1676cdf0e10cSrcweir 	--nObjCnt;
1677cdf0e10cSrcweir 	memmove( (SdrObject**)pSdrObj + nPos, pSdrObj + nPos + 1,
1678cdf0e10cSrcweir 			 ( nObjCnt - nPos ) * sizeof( SdrObject* ) );
1679cdf0e10cSrcweir 	memmove( pTextRanger + nPos, pTextRanger + nPos + 1,
1680cdf0e10cSrcweir 			 ( nObjCnt - nPos ) * sizeof( TextRanger* ) );
1681cdf0e10cSrcweir }
1682cdf0e10cSrcweir 
ClrContourCache(const SdrObject * pObj)1683cdf0e10cSrcweir void ClrContourCache( const SdrObject *pObj )
1684cdf0e10cSrcweir {
1685cdf0e10cSrcweir 	if( pContourCache && pObj )
1686cdf0e10cSrcweir 		for( MSHORT i = 0; i < pContourCache->GetCount(); ++i )
1687cdf0e10cSrcweir 			if( pObj == pContourCache->GetObject( i ) )
1688cdf0e10cSrcweir 			{
1689cdf0e10cSrcweir 				pContourCache->ClrObject( i );
1690cdf0e10cSrcweir 				break;
1691cdf0e10cSrcweir 			}
1692cdf0e10cSrcweir }
1693cdf0e10cSrcweir 
ClrContourCache()1694cdf0e10cSrcweir void ClrContourCache()
1695cdf0e10cSrcweir {
1696cdf0e10cSrcweir 	if( pContourCache )
1697cdf0e10cSrcweir 	{
1698cdf0e10cSrcweir 		for( MSHORT i = 0; i < pContourCache->GetCount();
1699cdf0e10cSrcweir 			 delete pContourCache->pTextRanger[ i++ ] )
1700cdf0e10cSrcweir 			 ;
1701cdf0e10cSrcweir 		pContourCache->nObjCnt = 0;
1702cdf0e10cSrcweir 		pContourCache->nPntCnt = 0;
1703cdf0e10cSrcweir 	}
1704cdf0e10cSrcweir }
1705cdf0e10cSrcweir 
1706cdf0e10cSrcweir /*************************************************************************
1707cdf0e10cSrcweir  * SwContourCache::CalcBoundRect
1708cdf0e10cSrcweir  * berechnet das Rechteck, welches vom Objekt in der angegebenen Zeile
1709cdf0e10cSrcweir  * ueberdeckt wird.
1710cdf0e10cSrcweir  * Bei _nicht_ konturumflossenen Objekten ist dies einfach die Ueber-
1711cdf0e10cSrcweir  * lappung von BoundRect (inkl. Abstand!) und Zeile,
1712cdf0e10cSrcweir  * bei Konturumfluss wird das Polypolygon des Objekts abgeklappert
1713cdf0e10cSrcweir  *************************************************************************/
1714cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
CalcBoundRect(const SwAnchoredObject * pAnchoredObj,const SwRect & rLine,const SwTxtFrm * pFrm,const long nXPos,const sal_Bool bRight)1715cdf0e10cSrcweir const SwRect SwContourCache::CalcBoundRect( const SwAnchoredObject* pAnchoredObj,
1716cdf0e10cSrcweir                                             const SwRect &rLine,
1717cdf0e10cSrcweir                                             const SwTxtFrm* pFrm,
1718cdf0e10cSrcweir                                             const long nXPos,
1719cdf0e10cSrcweir                                             const sal_Bool bRight )
1720cdf0e10cSrcweir {
1721cdf0e10cSrcweir     SwRect aRet;
1722cdf0e10cSrcweir     const SwFrmFmt* pFmt = &(pAnchoredObj->GetFrmFmt());
1723cdf0e10cSrcweir 	if( pFmt->GetSurround().IsContour() &&
1724cdf0e10cSrcweir         ( !pAnchoredObj->ISA(SwFlyFrm) ||
1725cdf0e10cSrcweir           ( static_cast<const SwFlyFrm*>(pAnchoredObj)->Lower() &&
1726cdf0e10cSrcweir             static_cast<const SwFlyFrm*>(pAnchoredObj)->Lower()->IsNoTxtFrm() ) ) )
1727cdf0e10cSrcweir 	{
1728cdf0e10cSrcweir         aRet = pAnchoredObj->GetObjRectWithSpaces();
1729cdf0e10cSrcweir 		if( aRet.IsOver( rLine ) )
1730cdf0e10cSrcweir 		{
1731cdf0e10cSrcweir 			if( !pContourCache )
1732cdf0e10cSrcweir 				pContourCache = new SwContourCache;
1733cdf0e10cSrcweir 
1734cdf0e10cSrcweir             aRet = pContourCache->ContourRect(
1735cdf0e10cSrcweir                     pFmt, pAnchoredObj->GetDrawObj(), pFrm, rLine, nXPos, bRight );
1736cdf0e10cSrcweir 		}
1737cdf0e10cSrcweir 		else
1738cdf0e10cSrcweir 			aRet.Width( 0 );
1739cdf0e10cSrcweir 	}
1740cdf0e10cSrcweir 	else
1741cdf0e10cSrcweir 	{
1742cdf0e10cSrcweir         aRet = pAnchoredObj->GetObjRectWithSpaces();
1743cdf0e10cSrcweir 	}
1744cdf0e10cSrcweir 
1745cdf0e10cSrcweir 	return aRet;
1746cdf0e10cSrcweir }
1747cdf0e10cSrcweir // <--
1748cdf0e10cSrcweir 
ContourRect(const SwFmt * pFmt,const SdrObject * pObj,const SwTxtFrm * pFrm,const SwRect & rLine,const long nXPos,const sal_Bool bRight)1749cdf0e10cSrcweir const SwRect SwContourCache::ContourRect( const SwFmt* pFmt,
1750cdf0e10cSrcweir     const SdrObject* pObj, const SwTxtFrm* pFrm, const SwRect &rLine,
1751cdf0e10cSrcweir     const long nXPos, const sal_Bool bRight )
1752cdf0e10cSrcweir {
1753cdf0e10cSrcweir 	SwRect aRet;
1754cdf0e10cSrcweir 	MSHORT nPos = 0; // Suche im Cache ...
1755cdf0e10cSrcweir 	while( nPos < GetCount() && pObj != pSdrObj[ nPos ] )
1756cdf0e10cSrcweir 		++nPos;
1757cdf0e10cSrcweir 	if( GetCount() == nPos ) // nicht gefunden
1758cdf0e10cSrcweir 	{
1759cdf0e10cSrcweir 		if( nObjCnt == POLY_CNT )
1760cdf0e10cSrcweir 		{
1761cdf0e10cSrcweir 			nPntCnt -= pTextRanger[ --nObjCnt ]->GetPointCount();
1762cdf0e10cSrcweir 			delete pTextRanger[ nObjCnt ];
1763cdf0e10cSrcweir 		}
1764cdf0e10cSrcweir 		::basegfx::B2DPolyPolygon aPolyPolygon;
1765cdf0e10cSrcweir 		::basegfx::B2DPolyPolygon* pPolyPolygon = 0L;
1766cdf0e10cSrcweir 
1767cdf0e10cSrcweir 		if ( pObj->ISA(SwVirtFlyDrawObj) )
1768cdf0e10cSrcweir 		{
1769cdf0e10cSrcweir 			// Vorsicht #37347: Das GetContour() fuehrt zum Laden der Grafik,
1770cdf0e10cSrcweir 			// diese aendert dadurch ggf. ihre Groesse, ruft deshalb ein
1771cdf0e10cSrcweir 			// ClrObject() auf.
1772cdf0e10cSrcweir 			PolyPolygon aPoly;
1773cdf0e10cSrcweir 			if( !((SwVirtFlyDrawObj*)pObj)->GetFlyFrm()->GetContour( aPoly ) )
1774cdf0e10cSrcweir 				aPoly = PolyPolygon( ((SwVirtFlyDrawObj*)pObj)->
1775cdf0e10cSrcweir 									 GetFlyFrm()->Frm().SVRect() );
1776cdf0e10cSrcweir 			aPolyPolygon.clear();
1777cdf0e10cSrcweir 			aPolyPolygon.append(aPoly.getB2DPolyPolygon());
1778cdf0e10cSrcweir 		}
1779cdf0e10cSrcweir 		else
1780cdf0e10cSrcweir 		{
1781cdf0e10cSrcweir             if( !pObj->ISA( E3dObject ) )
1782cdf0e10cSrcweir 			{
1783cdf0e10cSrcweir 				aPolyPolygon = pObj->TakeXorPoly();
1784cdf0e10cSrcweir 			}
1785cdf0e10cSrcweir 
1786cdf0e10cSrcweir 			::basegfx::B2DPolyPolygon aContourPoly(pObj->TakeContour());
1787cdf0e10cSrcweir 			pPolyPolygon = new ::basegfx::B2DPolyPolygon(aContourPoly);
1788cdf0e10cSrcweir 		}
1789cdf0e10cSrcweir 		const SvxLRSpaceItem &rLRSpace = pFmt->GetLRSpace();
1790cdf0e10cSrcweir 		const SvxULSpaceItem &rULSpace = pFmt->GetULSpace();
1791cdf0e10cSrcweir 		memmove( pTextRanger + 1, pTextRanger, nObjCnt * sizeof( TextRanger* ) );
1792cdf0e10cSrcweir 		memmove( (SdrObject**)pSdrObj + 1, pSdrObj, nObjCnt++ * sizeof( SdrObject* ) );
1793cdf0e10cSrcweir 		pSdrObj[ 0 ] = pObj; // Wg. #37347 darf das Object erst nach dem
1794cdf0e10cSrcweir 							 // GetContour() eingetragen werden.
1795cdf0e10cSrcweir         pTextRanger[ 0 ] = new TextRanger( aPolyPolygon, pPolyPolygon, 20,
1796cdf0e10cSrcweir             (sal_uInt16)rLRSpace.GetLeft(), (sal_uInt16)rLRSpace.GetRight(),
1797cdf0e10cSrcweir             pFmt->GetSurround().IsOutside(), sal_False, pFrm->IsVertical() );
1798cdf0e10cSrcweir         pTextRanger[ 0 ]->SetUpper( rULSpace.GetUpper() );
1799cdf0e10cSrcweir 		pTextRanger[ 0 ]->SetLower( rULSpace.GetLower() );
1800cdf0e10cSrcweir 
1801cdf0e10cSrcweir 		delete pPolyPolygon;
1802cdf0e10cSrcweir 		// UPPER_LOWER_TEST
1803cdf0e10cSrcweir #ifdef DBG_UTIL
1804cdf0e10cSrcweir         const ViewShell* pTmpViewShell = pFmt->GetDoc()->GetCurrentViewShell();
1805cdf0e10cSrcweir         if( pTmpViewShell )
1806cdf0e10cSrcweir 		{
1807cdf0e10cSrcweir             sal_Bool bT2 = pTmpViewShell->GetViewOptions()->IsTest2();
1808cdf0e10cSrcweir             sal_Bool bT6 = pTmpViewShell->GetViewOptions()->IsTest6();
1809cdf0e10cSrcweir 			if( bT2 || bT6 )
1810cdf0e10cSrcweir 			{
1811cdf0e10cSrcweir 				if( bT2 )
1812cdf0e10cSrcweir 					pTextRanger[ 0 ]->SetFlag7( sal_True );
1813cdf0e10cSrcweir 				else
1814cdf0e10cSrcweir 					pTextRanger[ 0 ]->SetFlag6( sal_True );
1815cdf0e10cSrcweir 			}
1816cdf0e10cSrcweir 		}
1817cdf0e10cSrcweir #endif
1818cdf0e10cSrcweir 		nPntCnt += pTextRanger[ 0 ]->GetPointCount();
1819cdf0e10cSrcweir 		while( nPntCnt > POLY_MAX && nObjCnt > POLY_MIN )
1820cdf0e10cSrcweir 		{
1821cdf0e10cSrcweir 			nPntCnt -= pTextRanger[ --nObjCnt ]->GetPointCount();
1822cdf0e10cSrcweir 			delete pTextRanger[ nObjCnt ];
1823cdf0e10cSrcweir 		}
1824cdf0e10cSrcweir 	}
1825cdf0e10cSrcweir 	else if( nPos )
1826cdf0e10cSrcweir 	{
1827cdf0e10cSrcweir 		const SdrObject* pTmpObj = pSdrObj[ nPos ];
1828cdf0e10cSrcweir 		TextRanger* pTmpRanger = pTextRanger[ nPos ];
1829cdf0e10cSrcweir 		memmove( (SdrObject**)pSdrObj + 1, pSdrObj, nPos * sizeof( SdrObject* ) );
1830cdf0e10cSrcweir 		memmove( pTextRanger + 1, pTextRanger, nPos * sizeof( TextRanger* ) );
1831cdf0e10cSrcweir 		pSdrObj[ 0 ] = pTmpObj;
1832cdf0e10cSrcweir 		pTextRanger[ 0 ] = pTmpRanger;
1833cdf0e10cSrcweir 	}
1834cdf0e10cSrcweir     SWRECTFN( pFrm )
1835cdf0e10cSrcweir     long nTmpTop = (rLine.*fnRect->fnGetTop)();
1836cdf0e10cSrcweir     // fnGetBottom is top + height
1837cdf0e10cSrcweir     long nTmpBottom = (rLine.*fnRect->fnGetBottom)();
1838cdf0e10cSrcweir 
1839cdf0e10cSrcweir     Range aRange( Min( nTmpTop, nTmpBottom ), Max( nTmpTop, nTmpBottom ) );
1840cdf0e10cSrcweir 
1841cdf0e10cSrcweir 	SvLongs *pTmp = pTextRanger[ 0 ]->GetTextRanges( aRange );
1842cdf0e10cSrcweir 
1843cdf0e10cSrcweir 	MSHORT nCount;
1844cdf0e10cSrcweir 	if( 0 != ( nCount = pTmp->Count() ) )
1845cdf0e10cSrcweir 	{
1846cdf0e10cSrcweir 		MSHORT nIdx = 0;
1847cdf0e10cSrcweir         while( nIdx < nCount && (*pTmp)[ nIdx ] < nXPos )
1848cdf0e10cSrcweir 			++nIdx;
1849cdf0e10cSrcweir 		sal_Bool bOdd = nIdx % 2 ? sal_True : sal_False;
1850cdf0e10cSrcweir 		sal_Bool bSet = sal_True;
1851cdf0e10cSrcweir 		if( bOdd )
1852cdf0e10cSrcweir 			--nIdx; // innerhalb eines Intervalls
1853cdf0e10cSrcweir         else if( ! bRight && ( nIdx >= nCount || (*pTmp)[ nIdx ] != nXPos ) )
1854cdf0e10cSrcweir 		{
1855cdf0e10cSrcweir 			if( nIdx )
1856cdf0e10cSrcweir 				nIdx -= 2; // ein Intervall nach links gehen
1857cdf0e10cSrcweir 			else
1858cdf0e10cSrcweir 				bSet = sal_False; // vor dem erstem Intervall
1859cdf0e10cSrcweir 		}
1860cdf0e10cSrcweir 
1861cdf0e10cSrcweir 		if( bSet && nIdx < nCount )
1862cdf0e10cSrcweir 		{
1863cdf0e10cSrcweir             (aRet.*fnRect->fnSetTopAndHeight)( (rLine.*fnRect->fnGetTop)(),
1864cdf0e10cSrcweir                                                (rLine.*fnRect->fnGetHeight)() );
1865cdf0e10cSrcweir             (aRet.*fnRect->fnSetLeft)( (*pTmp)[ nIdx ] );
1866cdf0e10cSrcweir             (aRet.*fnRect->fnSetRight)( (*pTmp)[ nIdx + 1 ] + 1 );
1867cdf0e10cSrcweir 		}
1868cdf0e10cSrcweir 	}
1869cdf0e10cSrcweir 	return aRet;
1870cdf0e10cSrcweir }
1871cdf0e10cSrcweir 
1872cdf0e10cSrcweir /*************************************************************************
1873cdf0e10cSrcweir  *						SwContourCache::ShowContour()
1874cdf0e10cSrcweir  * zeichnet die PolyPolygone des Caches zu Debugzwecken.
1875cdf0e10cSrcweir  *************************************************************************/
1876cdf0e10cSrcweir #ifdef DBG_UTIL
1877cdf0e10cSrcweir 
ShowContour(OutputDevice * pOut,const SdrObject * pObj,const Color & rClosedColor,const Color & rOpenColor)1878cdf0e10cSrcweir void SwContourCache::ShowContour( OutputDevice* pOut, const SdrObject* pObj,
1879cdf0e10cSrcweir 	const Color& rClosedColor, const Color& rOpenColor )
1880cdf0e10cSrcweir {
1881cdf0e10cSrcweir 	MSHORT nPos = 0; // Suche im Cache ...
1882cdf0e10cSrcweir 	while( nPos < POLY_CNT && pObj != pSdrObj[ nPos ] )
1883cdf0e10cSrcweir 		++nPos;
1884cdf0e10cSrcweir 	if( POLY_CNT != nPos )
1885cdf0e10cSrcweir 	{
1886cdf0e10cSrcweir 		const PolyPolygon* pPol = pTextRanger[ nPos ]->GetLinePolygon();
1887cdf0e10cSrcweir 		if( !pPol )
1888cdf0e10cSrcweir 			pPol = &(pTextRanger[ nPos ]->GetPolyPolygon());
1889cdf0e10cSrcweir 		for( MSHORT i = 0; i < pPol->Count(); ++i )
1890cdf0e10cSrcweir 		{
1891cdf0e10cSrcweir 			pOut->SetLineColor( rOpenColor );
1892cdf0e10cSrcweir 			const Polygon& rPol = (*pPol)[ i ];
1893cdf0e10cSrcweir 			MSHORT nCount = rPol.GetSize();
1894cdf0e10cSrcweir 			if( nCount > 1 && rPol[ 0 ] == rPol[ nCount - 1 ] )
1895cdf0e10cSrcweir 				pOut->SetLineColor( rClosedColor );
1896cdf0e10cSrcweir 			pOut->DrawPolygon( rPol );
1897cdf0e10cSrcweir 		}
1898cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1899cdf0e10cSrcweir 		static KSHORT nRadius = 0;
1900cdf0e10cSrcweir 		if( nRadius )
1901cdf0e10cSrcweir 		{
1902cdf0e10cSrcweir 			KSHORT nHalf = nRadius / 2;
1903cdf0e10cSrcweir 			Size aSz( nRadius, nRadius );
1904cdf0e10cSrcweir 			for( MSHORT i = 0; i < pPol->Count(); ++i )
1905cdf0e10cSrcweir 			{
1906cdf0e10cSrcweir 				const Polygon& rPol = (*pPol)[ i ];
1907cdf0e10cSrcweir 				MSHORT nCount = rPol.GetSize();
1908cdf0e10cSrcweir 				for( MSHORT k = 0; k < nCount; ++k )
1909cdf0e10cSrcweir 				{
1910cdf0e10cSrcweir 					Point aPt( rPol[ k ] );
1911cdf0e10cSrcweir 					aPt.X() -= nHalf;
1912cdf0e10cSrcweir 					aPt.Y() -= nHalf;
1913cdf0e10cSrcweir 					Rectangle aTmp( aPt, aSz );
1914cdf0e10cSrcweir 					pOut->DrawEllipse( aTmp );
1915cdf0e10cSrcweir 				}
1916cdf0e10cSrcweir 			}
1917cdf0e10cSrcweir 		}
1918cdf0e10cSrcweir #endif
1919cdf0e10cSrcweir 	}
1920cdf0e10cSrcweir }
1921cdf0e10cSrcweir #endif
1922cdf0e10cSrcweir 
1923cdf0e10cSrcweir /*************************************************************************
1924cdf0e10cSrcweir  *						SwTxtFly::ShowContour()
1925cdf0e10cSrcweir  * zeichnet die PolyPolygone des Caches zu Debugzwecken.
1926cdf0e10cSrcweir  *************************************************************************/
1927cdf0e10cSrcweir #ifdef DBG_UTIL
1928cdf0e10cSrcweir 
ShowContour(OutputDevice * pOut)1929cdf0e10cSrcweir void SwTxtFly::ShowContour( OutputDevice* pOut )
1930cdf0e10cSrcweir {
1931cdf0e10cSrcweir 	MSHORT nFlyCount;
1932cdf0e10cSrcweir     if( bOn && ( 0 != ( nFlyCount = static_cast<sal_uInt16>(GetAnchoredObjList()->size() ) ) ) )
1933cdf0e10cSrcweir 	{
1934cdf0e10cSrcweir 		Color aRedColor( COL_LIGHTRED );
1935cdf0e10cSrcweir 		Color aGreenColor( COL_LIGHTGREEN );
1936cdf0e10cSrcweir 		Color aSaveColor( pOut->GetLineColor() );
1937cdf0e10cSrcweir 		for( MSHORT j = 0; j < nFlyCount; ++j )
1938cdf0e10cSrcweir 		{
1939cdf0e10cSrcweir             const SwAnchoredObject* pObj = (*mpAnchoredObjList)[ j ];
1940cdf0e10cSrcweir             if( !pObj->GetFrmFmt().GetSurround().IsContour() )
1941cdf0e10cSrcweir 			{
1942cdf0e10cSrcweir                 Rectangle aRect = pObj->GetObjRectWithSpaces().SVRect();
1943cdf0e10cSrcweir 				pOut->DrawRect( aRect );
1944cdf0e10cSrcweir 				continue;
1945cdf0e10cSrcweir 			}
1946cdf0e10cSrcweir             pContourCache->ShowContour( pOut, pObj->GetDrawObj(), aRedColor, aGreenColor );
1947cdf0e10cSrcweir 		}
1948cdf0e10cSrcweir 		pOut->SetLineColor( aSaveColor );
1949cdf0e10cSrcweir 	}
1950cdf0e10cSrcweir }
1951cdf0e10cSrcweir #endif
1952cdf0e10cSrcweir 
1953cdf0e10cSrcweir /*************************************************************************
1954cdf0e10cSrcweir  *						SwTxtFly::ForEach()
1955cdf0e10cSrcweir  *
1956cdf0e10cSrcweir  * sucht nach dem ersten Objekt, welches mit dem Rechteck ueberlappt
1957cdf0e10cSrcweir  *
1958cdf0e10cSrcweir  *************************************************************************/
1959cdf0e10cSrcweir 
ForEach(const SwRect & rRect,SwRect * pRect,sal_Bool bAvoid) const1960cdf0e10cSrcweir sal_Bool SwTxtFly::ForEach( const SwRect &rRect, SwRect* pRect, sal_Bool bAvoid ) const
1961cdf0e10cSrcweir {
1962cdf0e10cSrcweir     SWAP_IF_SWAPPED( pCurrFrm )
1963cdf0e10cSrcweir 
1964cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
1965cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
1966cdf0e10cSrcweir     SwAnchoredObjList::size_type nCount( bOn ? GetAnchoredObjList()->size() : 0 );
1967cdf0e10cSrcweir     if ( bOn && nCount > 0 )
1968cdf0e10cSrcweir     // <--
1969cdf0e10cSrcweir 	{
1970cdf0e10cSrcweir         for( SwAnchoredObjList::size_type i = 0; i < nCount; ++i )
1971cdf0e10cSrcweir 		{
1972cdf0e10cSrcweir             // --> OD 2006-08-15 #i68520#
1973cdf0e10cSrcweir             const SwAnchoredObject* pAnchoredObj = (*mpAnchoredObjList)[i];
1974cdf0e10cSrcweir 
1975cdf0e10cSrcweir             SwRect aRect( pAnchoredObj->GetObjRectWithSpaces() );
1976cdf0e10cSrcweir             // <--
1977cdf0e10cSrcweir 
1978cdf0e10cSrcweir             // Optimierung
1979cdf0e10cSrcweir             SWRECTFN( pCurrFrm )
1980cdf0e10cSrcweir             if( (aRect.*fnRect->fnGetLeft)() > (rRect.*fnRect->fnGetRight)() )
1981cdf0e10cSrcweir 				break;
1982cdf0e10cSrcweir             // --> OD 2006-08-15 #i68520#
1983cdf0e10cSrcweir             if ( mpCurrAnchoredObj != pAnchoredObj && aRect.IsOver( rRect ) )
1984cdf0e10cSrcweir             // <--
1985cdf0e10cSrcweir 			{
1986cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
1987cdf0e10cSrcweir                 const SwFmt* pFmt( &(pAnchoredObj->GetFrmFmt()) );
1988cdf0e10cSrcweir                 const SwFmtSurround &rSur = pFmt->GetSurround();
1989cdf0e10cSrcweir                 // <--
1990cdf0e10cSrcweir 				if( bAvoid )
1991cdf0e10cSrcweir 				{
1992cdf0e10cSrcweir 					// Wenn der Text drunter durchlaeuft, bleibt die
1993cdf0e10cSrcweir 					// Formatierung unbeeinflusst. Im LineIter::DrawText()
1994cdf0e10cSrcweir 					// muessen "nur" geschickt die ClippingRegions gesetzt werden ...
1995cdf0e10cSrcweir 					const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
1996cdf0e10cSrcweir 					if( ( SURROUND_THROUGHT == rSur.GetSurround() &&
1997cdf0e10cSrcweir 						  ( !rSur.IsAnchorOnly() ||
1998cdf0e10cSrcweir                             // --> OD 2006-08-15 #i68520#
1999cdf0e10cSrcweir                             GetMaster() == pAnchoredObj->GetAnchorFrm() ||
2000cdf0e10cSrcweir                             // <--
2001cdf0e10cSrcweir                             ((FLY_AT_PARA != rAnchor.GetAnchorId()) &&
2002cdf0e10cSrcweir                              (FLY_AT_CHAR != rAnchor.GetAnchorId())) ) )
2003cdf0e10cSrcweir 						|| aRect.Top() == WEIT_WECH )
2004cdf0e10cSrcweir 						continue;
2005cdf0e10cSrcweir 				}
2006cdf0e10cSrcweir 
2007cdf0e10cSrcweir                 // --> OD 2006-01-20 #i58642#
2008cdf0e10cSrcweir                 // Compare <GetMaster()> instead of <pCurrFrm> with the anchor
2009cdf0e10cSrcweir                 // frame of the anchored object, because a follow frame have
2010cdf0e10cSrcweir                 // to ignore the anchored objects of its master frame.
2011cdf0e10cSrcweir                 // Note: Anchored objects are always registered at the master
2012cdf0e10cSrcweir                 //       frame, exception are as-character anchored objects,
2013cdf0e10cSrcweir                 //       but these aren't handled here.
2014cdf0e10cSrcweir                 // --> OD 2006-08-15 #i68520#
2015cdf0e10cSrcweir                 if ( mbIgnoreCurrentFrame &&
2016cdf0e10cSrcweir                      GetMaster() == pAnchoredObj->GetAnchorFrm() )
2017cdf0e10cSrcweir                     continue;
2018cdf0e10cSrcweir                 // <--
2019cdf0e10cSrcweir 
2020cdf0e10cSrcweir 				if( pRect )
2021cdf0e10cSrcweir 				{
2022cdf0e10cSrcweir                     // --> OD 2006-08-15 #i68520#
2023cdf0e10cSrcweir                     SwRect aFly = AnchoredObjToRect( pAnchoredObj, rRect );
2024cdf0e10cSrcweir                     // <--
2025cdf0e10cSrcweir 					if( aFly.IsEmpty() || !aFly.IsOver( rRect ) )
2026cdf0e10cSrcweir 						continue;
2027cdf0e10cSrcweir                     if( !bRet || (
2028cdf0e10cSrcweir                         ( !pCurrFrm->IsRightToLeft() &&
2029cdf0e10cSrcweir                           ( (aFly.*fnRect->fnGetLeft)() <
2030cdf0e10cSrcweir                             (pRect->*fnRect->fnGetLeft)() ) ) ||
2031cdf0e10cSrcweir                         ( pCurrFrm->IsRightToLeft() &&
2032cdf0e10cSrcweir                           ( (aFly.*fnRect->fnGetRight)() >
2033cdf0e10cSrcweir                             (pRect->*fnRect->fnGetRight)() ) ) ) )
2034cdf0e10cSrcweir 						*pRect = aFly;
2035cdf0e10cSrcweir 					if( rSur.IsContour() )
2036cdf0e10cSrcweir 					{
2037cdf0e10cSrcweir 						bRet = sal_True;
2038cdf0e10cSrcweir 						continue;
2039cdf0e10cSrcweir 					}
2040cdf0e10cSrcweir 				}
2041cdf0e10cSrcweir 				bRet = sal_True;
2042cdf0e10cSrcweir 				break;
2043cdf0e10cSrcweir 			}
2044cdf0e10cSrcweir 		}
2045cdf0e10cSrcweir 	}
2046cdf0e10cSrcweir 
2047cdf0e10cSrcweir     UNDO_SWAP( pCurrFrm )
2048cdf0e10cSrcweir 
2049cdf0e10cSrcweir 	return bRet;
2050cdf0e10cSrcweir }
2051cdf0e10cSrcweir 
2052cdf0e10cSrcweir /*************************************************************************
2053cdf0e10cSrcweir  *						SwTxtFly::GetPos()
2054cdf0e10cSrcweir  *
2055cdf0e10cSrcweir  * liefert die Position im sorted Array zurueck
2056cdf0e10cSrcweir  *************************************************************************/
2057cdf0e10cSrcweir 
2058cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
GetPos(const SwAnchoredObject * pAnchoredObj) const2059cdf0e10cSrcweir SwAnchoredObjList::size_type SwTxtFly::GetPos( const SwAnchoredObject* pAnchoredObj ) const
2060cdf0e10cSrcweir {
2061cdf0e10cSrcweir     SwAnchoredObjList::size_type nCount = GetAnchoredObjList()->size();
2062cdf0e10cSrcweir     SwAnchoredObjList::size_type nRet = 0;
2063cdf0e10cSrcweir     while ( nRet < nCount && pAnchoredObj != (*mpAnchoredObjList)[ nRet ] )
2064cdf0e10cSrcweir         ++nRet;
2065cdf0e10cSrcweir     return nRet;
2066cdf0e10cSrcweir }
2067cdf0e10cSrcweir // <--
2068cdf0e10cSrcweir 
2069cdf0e10cSrcweir /*************************************************************************
2070cdf0e10cSrcweir  *						SwTxtFly::CalcRightMargin()
2071cdf0e10cSrcweir  *
2072cdf0e10cSrcweir  * pObj ist das Object, der uns gerade ueberlappt.
2073cdf0e10cSrcweir  * pCurrFrm ist der aktuelle Textframe, der ueberlappt wird.
2074cdf0e10cSrcweir  * Der rechte Rand ist der rechte Rand oder
2075cdf0e10cSrcweir  * er wird durch das naechste Object, welches in die Zeile ragt, bestimmt.
2076cdf0e10cSrcweir  *************************************************************************/
2077cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
CalcRightMargin(SwRect & rFly,SwAnchoredObjList::size_type nFlyPos,const SwRect & rLine) const2078cdf0e10cSrcweir void SwTxtFly::CalcRightMargin( SwRect &rFly,
2079cdf0e10cSrcweir                                 SwAnchoredObjList::size_type nFlyPos,
2080cdf0e10cSrcweir                                 const SwRect &rLine ) const
2081cdf0e10cSrcweir {
2082cdf0e10cSrcweir 	// Normalerweise ist der rechte Rand der rechte Rand der Printarea.
2083cdf0e10cSrcweir     ASSERT( ! pCurrFrm->IsVertical() || ! pCurrFrm->IsSwapped(),
2084cdf0e10cSrcweir             "SwTxtFly::CalcRightMargin with swapped frame" )
2085cdf0e10cSrcweir     SWRECTFN( pCurrFrm )
2086cdf0e10cSrcweir     // --> OD 2004-12-14 #118796# - correct determination of right of printing area
2087cdf0e10cSrcweir     SwTwips nRight = (pCurrFrm->*fnRect->fnGetPrtRight)();
2088cdf0e10cSrcweir     // <--
2089cdf0e10cSrcweir     SwTwips nFlyRight = (rFly.*fnRect->fnGetRight)();
2090cdf0e10cSrcweir 	SwRect aLine( rLine );
2091cdf0e10cSrcweir     (aLine.*fnRect->fnSetRight)( nRight );
2092cdf0e10cSrcweir     (aLine.*fnRect->fnSetLeft)( (rFly.*fnRect->fnGetLeft)() );
2093cdf0e10cSrcweir 
2094cdf0e10cSrcweir 	// Es koennte aber sein, dass in die gleiche Zeile noch ein anderes
2095cdf0e10cSrcweir 	// Object hineinragt, welches _ueber_ uns liegt.
2096cdf0e10cSrcweir 	// Wunder der Technik: Flys mit Durchlauf sind fuer die darunterliegenden
2097cdf0e10cSrcweir 	// unsichtbar, das heisst, dass sie bei der Berechnung der Raender
2098cdf0e10cSrcweir 	// anderer Flys ebenfalls nicht auffallen.
2099cdf0e10cSrcweir 	// 3301: pNext->Frm().IsOver( rLine ) ist noetig
2100cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
2101cdf0e10cSrcweir     SwSurround eSurroundForTextWrap;
2102cdf0e10cSrcweir     // <--
2103cdf0e10cSrcweir 
2104cdf0e10cSrcweir 	sal_Bool bStop = sal_False;
2105cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
2106cdf0e10cSrcweir     SwAnchoredObjList::size_type nPos = 0;
2107cdf0e10cSrcweir     // <--
2108cdf0e10cSrcweir 
2109cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
2110cdf0e10cSrcweir     while( nPos < mpAnchoredObjList->size() && !bStop )
2111cdf0e10cSrcweir     // <--
2112cdf0e10cSrcweir 	{
2113cdf0e10cSrcweir 		if( nPos == nFlyPos )
2114cdf0e10cSrcweir 		{
2115cdf0e10cSrcweir 			++nPos;
2116cdf0e10cSrcweir 			continue;
2117cdf0e10cSrcweir 		}
2118cdf0e10cSrcweir         // --> OD 2006-08-15 #i68520#
2119cdf0e10cSrcweir         const SwAnchoredObject* pNext = (*mpAnchoredObjList)[ nPos++ ];
2120cdf0e10cSrcweir         if ( pNext == mpCurrAnchoredObj )
2121cdf0e10cSrcweir 			continue;
2122cdf0e10cSrcweir         eSurroundForTextWrap = _GetSurroundForTextWrap( pNext );
2123cdf0e10cSrcweir         if( SURROUND_THROUGHT == eSurroundForTextWrap )
2124cdf0e10cSrcweir 			continue;
2125cdf0e10cSrcweir         // <--
2126cdf0e10cSrcweir 
2127cdf0e10cSrcweir         const SwRect aTmp( SwContourCache::CalcBoundRect
2128cdf0e10cSrcweir                 ( pNext, aLine, pCurrFrm, nFlyRight, sal_True ) );
2129cdf0e10cSrcweir         SwTwips nTmpRight = (aTmp.*fnRect->fnGetRight)();
2130cdf0e10cSrcweir 
2131cdf0e10cSrcweir 		// Optimierung:
2132cdf0e10cSrcweir 		// In nNextTop wird notiert, an welcher Y-Positon mit Aenderung der
2133cdf0e10cSrcweir 		// Rahmenverhaeltnisse gerechnet werden muss. Dies dient dazu, dass,
2134cdf0e10cSrcweir 		// obwohl nur die Rahmen in der aktuellen Zeilenhoehe betrachtet werden,
2135cdf0e10cSrcweir 		// bei Rahmen ohne Umlauf die Zeilenhoehe so erhoeht wird, dass mit einer
2136cdf0e10cSrcweir 		// einzigen Zeile die Unterkante das Rahmens oder ggf. die Oberkante des
2137cdf0e10cSrcweir 		// naechsten Rahmen erreicht wird.
2138cdf0e10cSrcweir 		// Insbesondere bei HTML-Dokumenten kommen oft (Dummy-)Absaetze in einer
2139cdf0e10cSrcweir 		// 2-Pt.-Schrift vor, bis diese einem groesseren Rahmen ausgewichen sind,
2140cdf0e10cSrcweir 		// erforderte es frueher Unmengen von Leerzeilen.
2141cdf0e10cSrcweir         const long nTmpTop = (aTmp.*fnRect->fnGetTop)();
2142cdf0e10cSrcweir         if( (*fnRect->fnYDiff)( nTmpTop, (aLine.*fnRect->fnGetTop)() ) > 0 )
2143cdf0e10cSrcweir 		{
2144cdf0e10cSrcweir             if( (*fnRect->fnYDiff)( nNextTop, nTmpTop ) > 0 )
2145cdf0e10cSrcweir                 SetNextTop( nTmpTop ); // Die Oberkante des "naechsten" Rahmens
2146cdf0e10cSrcweir 		}
2147cdf0e10cSrcweir         else if( ! (aTmp.*fnRect->fnGetWidth)() ) // Typisch fuer Objekte mit Konturumlauf
2148cdf0e10cSrcweir 		{   // Bei Objekten mit Konturumlauf, die vor der aktuellen Zeile beginnen
2149cdf0e10cSrcweir 			// und hinter ihr enden, trotzdem aber nicht mit ihr ueberlappen,
2150cdf0e10cSrcweir 			// muss die Optimierung ausgeschaltet werden, denn bereits in der
2151cdf0e10cSrcweir 			// naechsten Zeile kann sich dies aendern.
2152cdf0e10cSrcweir             if( ! (aTmp.*fnRect->fnGetHeight)() ||
2153cdf0e10cSrcweir                 (*fnRect->fnYDiff)( (aTmp.*fnRect->fnGetBottom)(),
2154cdf0e10cSrcweir                                     (aLine.*fnRect->fnGetTop)() ) > 0 )
2155cdf0e10cSrcweir 				SetNextTop( 0 );
2156cdf0e10cSrcweir 		}
2157cdf0e10cSrcweir 		if( aTmp.IsOver( aLine ) && nTmpRight > nFlyRight )
2158cdf0e10cSrcweir 		{
2159cdf0e10cSrcweir 			nFlyRight = nTmpRight;
2160cdf0e10cSrcweir             if( SURROUND_RIGHT == eSurroundForTextWrap ||
2161cdf0e10cSrcweir                 SURROUND_PARALLEL == eSurroundForTextWrap )
2162cdf0e10cSrcweir 			{
2163cdf0e10cSrcweir                 // der FlyFrm wird ueberstimmt.
2164cdf0e10cSrcweir                 if( nRight > nFlyRight )
2165cdf0e10cSrcweir                     nRight = nFlyRight;
2166cdf0e10cSrcweir                 bStop = sal_True;
2167cdf0e10cSrcweir             }
2168cdf0e10cSrcweir 		}
2169cdf0e10cSrcweir 	}
2170cdf0e10cSrcweir     (rFly.*fnRect->fnSetRight)( nRight );
2171cdf0e10cSrcweir }
2172cdf0e10cSrcweir // <--
2173cdf0e10cSrcweir 
2174cdf0e10cSrcweir /*************************************************************************
2175cdf0e10cSrcweir  *						SwTxtFly::CalcLeftMargin()
2176cdf0e10cSrcweir  *
2177cdf0e10cSrcweir  * pFly ist der FlyFrm, der uns gerade ueberlappt.
2178cdf0e10cSrcweir  * pCurrFrm ist der aktuelle Textframe, der ueberlappt wird.
2179cdf0e10cSrcweir  * Der linke Rand ist der linke Rand der aktuellen PrintArea oder
2180cdf0e10cSrcweir  * er wird durch den vorigen FlyFrm, der in die Zeile ragt, bestimmt.
2181cdf0e10cSrcweir  *************************************************************************/
2182cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
CalcLeftMargin(SwRect & rFly,SwAnchoredObjList::size_type nFlyPos,const SwRect & rLine) const2183cdf0e10cSrcweir void SwTxtFly::CalcLeftMargin( SwRect &rFly,
2184cdf0e10cSrcweir                                SwAnchoredObjList::size_type nFlyPos,
2185cdf0e10cSrcweir                                const SwRect &rLine ) const
2186cdf0e10cSrcweir {
2187cdf0e10cSrcweir     ASSERT( ! pCurrFrm->IsVertical() || ! pCurrFrm->IsSwapped(),
2188cdf0e10cSrcweir             "SwTxtFly::CalcLeftMargin with swapped frame" )
2189cdf0e10cSrcweir     SWRECTFN( pCurrFrm )
2190cdf0e10cSrcweir     // --> OD 2004-12-14 #118796# - correct determination of left of printing area
2191cdf0e10cSrcweir     SwTwips nLeft = (pCurrFrm->*fnRect->fnGetPrtLeft)();
2192cdf0e10cSrcweir     // <--
2193cdf0e10cSrcweir     const SwTwips nFlyLeft = (rFly.*fnRect->fnGetLeft)();
2194cdf0e10cSrcweir 
2195cdf0e10cSrcweir     if( nLeft > nFlyLeft )
2196cdf0e10cSrcweir 		nLeft = rFly.Left();
2197cdf0e10cSrcweir 
2198cdf0e10cSrcweir     SwRect aLine( rLine );
2199cdf0e10cSrcweir     (aLine.*fnRect->fnSetLeft)( nLeft );
2200cdf0e10cSrcweir 
2201cdf0e10cSrcweir 	// Es koennte aber sein, dass in die gleiche Zeile noch ein anderes
2202cdf0e10cSrcweir 	// Object hineinragt, welches _ueber_ uns liegt.
2203cdf0e10cSrcweir 	// Wunder der Technik: Flys mit Durchlauf sind fuer die darunterliegenden
2204cdf0e10cSrcweir 	// unsichtbar, das heisst, dass sie bei der Berechnung der Raender
2205cdf0e10cSrcweir 	// anderer Flys ebenfalls nicht auffallen.
2206cdf0e10cSrcweir 	// 3301: pNext->Frm().IsOver( rLine ) ist noetig
2207cdf0e10cSrcweir 
2208cdf0e10cSrcweir     // --> OD 2006-08-15 #i68520#
2209cdf0e10cSrcweir     SwAnchoredObjList::size_type nMyPos = nFlyPos;
2210cdf0e10cSrcweir     while( ++nFlyPos < mpAnchoredObjList->size() )
2211cdf0e10cSrcweir     // <--
2212cdf0e10cSrcweir 	{
2213cdf0e10cSrcweir         // --> OD 2006-08-15 #i68520#
2214cdf0e10cSrcweir         const SwAnchoredObject* pNext = (*mpAnchoredObjList)[ nFlyPos ];
2215cdf0e10cSrcweir         const SwRect aTmp( pNext->GetObjRectWithSpaces() );
2216cdf0e10cSrcweir         // <--
2217cdf0e10cSrcweir         if( (aTmp.*fnRect->fnGetLeft)() >= nFlyLeft )
2218cdf0e10cSrcweir 			break;
2219cdf0e10cSrcweir 	}
2220cdf0e10cSrcweir 
2221cdf0e10cSrcweir 	while( nFlyPos )
2222cdf0e10cSrcweir 	{
2223cdf0e10cSrcweir 		if( --nFlyPos == nMyPos )
2224cdf0e10cSrcweir 			continue;
2225cdf0e10cSrcweir         // --> OD 2006-08-15 #i68520#
2226cdf0e10cSrcweir         const SwAnchoredObject* pNext = (*mpAnchoredObjList)[ nFlyPos ];
2227cdf0e10cSrcweir         if( pNext == mpCurrAnchoredObj )
2228cdf0e10cSrcweir             continue;
2229cdf0e10cSrcweir         SwSurround eSurroundForTextWrap = _GetSurroundForTextWrap( pNext );
2230cdf0e10cSrcweir         if( SURROUND_THROUGHT == eSurroundForTextWrap )
2231cdf0e10cSrcweir             continue;
2232cdf0e10cSrcweir         // <--
2233cdf0e10cSrcweir 
2234cdf0e10cSrcweir 		const SwRect aTmp( SwContourCache::CalcBoundRect
2235cdf0e10cSrcweir                 ( pNext, aLine, pCurrFrm, nFlyLeft, sal_False ) );
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir         if( (aTmp.*fnRect->fnGetLeft)() < nFlyLeft && aTmp.IsOver( aLine ) )
2238cdf0e10cSrcweir 		{
2239cdf0e10cSrcweir             // --> OD 2004-12-14 #118796# - no '+1', because <..fnGetRight>
2240cdf0e10cSrcweir             // returns the correct value.
2241cdf0e10cSrcweir             SwTwips nTmpRight = (aTmp.*fnRect->fnGetRight)();
2242cdf0e10cSrcweir             if ( nLeft <= nTmpRight )
2243cdf0e10cSrcweir                 nLeft = nTmpRight;
2244cdf0e10cSrcweir             // <--
2245cdf0e10cSrcweir 
2246cdf0e10cSrcweir 			break;
2247cdf0e10cSrcweir 		}
2248cdf0e10cSrcweir 	}
2249cdf0e10cSrcweir     (rFly.*fnRect->fnSetLeft)( nLeft );
2250cdf0e10cSrcweir }
2251cdf0e10cSrcweir // <--
2252cdf0e10cSrcweir 
2253cdf0e10cSrcweir /*************************************************************************
2254cdf0e10cSrcweir  *						SwTxtFly::FlyToRect()
2255cdf0e10cSrcweir  *
2256cdf0e10cSrcweir  * IN:	dokumentglobal	(rRect)
2257cdf0e10cSrcweir  * OUT: dokumentglobal	(return-Wert)
2258cdf0e10cSrcweir  * Liefert zu einem SwFlyFrm das von ihm in Anspruch genommene Rechteck
2259cdf0e10cSrcweir  * unter Beruecksichtigung der eingestellten Attribute fuer den Abstand
2260cdf0e10cSrcweir  * zum Text zurueck.
2261cdf0e10cSrcweir  *************************************************************************/
2262cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
AnchoredObjToRect(const SwAnchoredObject * pAnchoredObj,const SwRect & rLine) const2263cdf0e10cSrcweir SwRect SwTxtFly::AnchoredObjToRect( const SwAnchoredObject* pAnchoredObj,
2264cdf0e10cSrcweir                             const SwRect &rLine ) const
2265cdf0e10cSrcweir {
2266cdf0e10cSrcweir     SWRECTFN( pCurrFrm )
2267cdf0e10cSrcweir 
2268cdf0e10cSrcweir     const long nXPos = pCurrFrm->IsRightToLeft() ?
2269cdf0e10cSrcweir                        rLine.Right() :
2270cdf0e10cSrcweir                        (rLine.*fnRect->fnGetLeft)();
2271cdf0e10cSrcweir 
2272cdf0e10cSrcweir     SwRect aFly = mbIgnoreContour ?
2273cdf0e10cSrcweir                   pAnchoredObj->GetObjRectWithSpaces() :
2274cdf0e10cSrcweir                   SwContourCache::CalcBoundRect( pAnchoredObj, rLine, pCurrFrm,
2275cdf0e10cSrcweir                                                  nXPos, ! pCurrFrm->IsRightToLeft() );
2276cdf0e10cSrcweir 
2277cdf0e10cSrcweir     if( !aFly.Width() )
2278cdf0e10cSrcweir 		return aFly;
2279cdf0e10cSrcweir 
2280cdf0e10cSrcweir     SetNextTop( (aFly.*fnRect->fnGetBottom)() ); // Damit die Zeile ggf. bis zur Unterkante
2281cdf0e10cSrcweir 								 // des Rahmens waechst.
2282cdf0e10cSrcweir     SwAnchoredObjList::size_type nFlyPos = GetPos( pAnchoredObj );
2283cdf0e10cSrcweir 
2284cdf0e10cSrcweir 	// Bei LEFT und RIGHT vergroessern wir das Rechteck.
2285cdf0e10cSrcweir 	// Hier gibt es einige Probleme, wenn mehrere Frames zu sehen sind.
2286cdf0e10cSrcweir 	// Zur Zeit wird nur der einfachste Fall angenommen:
2287cdf0e10cSrcweir 	// LEFT bedeutet, dass der Text links vom Frame fliessen soll,
2288cdf0e10cSrcweir 	// d.h. der Frame blaeht sich bis zum rechten Rand der Printarea
2289cdf0e10cSrcweir 	// oder bis zum naechsten Frame auf.
2290cdf0e10cSrcweir 	// Bei RIGHT ist es umgekehrt.
2291cdf0e10cSrcweir 	// Ansonsten wird immer der eingestellte Abstand zwischen Text
2292cdf0e10cSrcweir 	// und Frame aufaddiert.
2293cdf0e10cSrcweir     switch( _GetSurroundForTextWrap( pAnchoredObj ) )
2294cdf0e10cSrcweir 	{
2295cdf0e10cSrcweir 		case SURROUND_LEFT :
2296cdf0e10cSrcweir 		{
2297cdf0e10cSrcweir 			CalcRightMargin( aFly, nFlyPos, rLine );
2298cdf0e10cSrcweir 			break;
2299cdf0e10cSrcweir 		}
2300cdf0e10cSrcweir 		case SURROUND_RIGHT :
2301cdf0e10cSrcweir 		{
2302cdf0e10cSrcweir 			CalcLeftMargin( aFly, nFlyPos, rLine );
2303cdf0e10cSrcweir 			break;
2304cdf0e10cSrcweir 		}
2305cdf0e10cSrcweir 		case SURROUND_NONE :
2306cdf0e10cSrcweir 		{
2307cdf0e10cSrcweir 			CalcRightMargin( aFly, nFlyPos, rLine );
2308cdf0e10cSrcweir 			CalcLeftMargin( aFly, nFlyPos, rLine );
2309cdf0e10cSrcweir 			break;
2310cdf0e10cSrcweir 		}
2311cdf0e10cSrcweir         default:
2312cdf0e10cSrcweir             break;
2313cdf0e10cSrcweir 	}
2314cdf0e10cSrcweir 	return aFly;
2315cdf0e10cSrcweir }
2316cdf0e10cSrcweir 
2317cdf0e10cSrcweir // --> OD 2006-08-15 #i68520#
2318cdf0e10cSrcweir // new method <_GetSurroundForTextWrap(..)> replaces methods
2319cdf0e10cSrcweir // <CalcSmart(..)> and <GetOrder(..)>
2320cdf0e10cSrcweir /*************************************************************************
2321cdf0e10cSrcweir  *						SwTxtFly::CalcSmart()
2322cdf0e10cSrcweir  *
2323cdf0e10cSrcweir  * CalcSmart() liefert die Umlaufform zurueck.
2324cdf0e10cSrcweir  *
2325cdf0e10cSrcweir  * Auf beiden Seiten ist weniger als 2 cm Platz fuer den Text
2326cdf0e10cSrcweir  * 	 => kein Umlauf ( SURROUND_NONE )
2327cdf0e10cSrcweir  * Auf genau einer Seite ist mehr als 2 cm Platz
2328cdf0e10cSrcweir  *   => Umlauf auf dieser Seite ( SURROUND_LEFT / SURROUND_RIGHT )
2329cdf0e10cSrcweir  * Auf beiden Seiten ist mehr als 2 cm Platz, das Objekt ist breiter als 1,5 cm
2330cdf0e10cSrcweir  * 	 => Umlauf auf der breiteren Seite ( SURROUND_LEFT / SURROUND_RIGHT )
2331cdf0e10cSrcweir  * Auf beiden Seiten ist mehr als 2 cm Platz, das Objekt ist schmaler als 1,5 cm
2332cdf0e10cSrcweir  * 	 => beidseitiger Umlauf ( SURROUND_PARALLEL	)
2333cdf0e10cSrcweir  *
2334cdf0e10cSrcweir  *************************************************************************/
2335cdf0e10cSrcweir 
2336cdf0e10cSrcweir // Umfluss nur auf Seiten mit mindestens 2 cm Platz fuer den Text
2337cdf0e10cSrcweir #define TEXT_MIN 1134
2338cdf0e10cSrcweir // Beidseitiger Umfluss bis zu einer Rahmenbreite von maximal 1,5 cm
2339cdf0e10cSrcweir #define FRAME_MAX 850
2340cdf0e10cSrcweir 
_GetSurroundForTextWrap(const SwAnchoredObject * pAnchoredObj) const2341cdf0e10cSrcweir SwSurround SwTxtFly::_GetSurroundForTextWrap( const SwAnchoredObject* pAnchoredObj ) const
2342cdf0e10cSrcweir {
2343cdf0e10cSrcweir     const SwFrmFmt* pFmt = &(pAnchoredObj->GetFrmFmt());
2344cdf0e10cSrcweir     const SwFmtSurround &rFlyFmt = pFmt->GetSurround();
2345cdf0e10cSrcweir     SwSurround eSurroundForTextWrap = rFlyFmt.GetSurround();
2346cdf0e10cSrcweir 
2347cdf0e10cSrcweir     if( rFlyFmt.IsAnchorOnly() && pAnchoredObj->GetAnchorFrm() != GetMaster() )
2348cdf0e10cSrcweir     {
2349cdf0e10cSrcweir         const SwFmtAnchor& rAnchor = pFmt->GetAnchor();
2350cdf0e10cSrcweir         if ((FLY_AT_PARA == rAnchor.GetAnchorId()) ||
2351cdf0e10cSrcweir             (FLY_AT_CHAR == rAnchor.GetAnchorId()))
2352cdf0e10cSrcweir         {
2353cdf0e10cSrcweir             return SURROUND_NONE;
2354cdf0e10cSrcweir         }
2355cdf0e10cSrcweir     }
2356cdf0e10cSrcweir 
2357cdf0e10cSrcweir     // Beim Durchlauf und Nowrap wird smart ignoriert.
2358cdf0e10cSrcweir     if( SURROUND_THROUGHT == eSurroundForTextWrap ||
2359cdf0e10cSrcweir         SURROUND_NONE == eSurroundForTextWrap )
2360cdf0e10cSrcweir         return eSurroundForTextWrap;
2361cdf0e10cSrcweir 
2362cdf0e10cSrcweir     // left is left and right is right
2363cdf0e10cSrcweir     if ( pCurrFrm->IsRightToLeft() )
2364cdf0e10cSrcweir     {
2365cdf0e10cSrcweir         if ( SURROUND_LEFT == eSurroundForTextWrap )
2366cdf0e10cSrcweir             eSurroundForTextWrap = SURROUND_RIGHT;
2367cdf0e10cSrcweir         else if ( SURROUND_RIGHT == eSurroundForTextWrap )
2368cdf0e10cSrcweir             eSurroundForTextWrap = SURROUND_LEFT;
2369cdf0e10cSrcweir     }
2370cdf0e10cSrcweir 
2371cdf0e10cSrcweir     // "idealer Seitenumlauf":
2372cdf0e10cSrcweir     if ( SURROUND_IDEAL == eSurroundForTextWrap )
2373cdf0e10cSrcweir     {
2374cdf0e10cSrcweir         SWRECTFN( pCurrFrm )
2375cdf0e10cSrcweir         const long nCurrLeft = (pCurrFrm->*fnRect->fnGetPrtLeft)();
2376cdf0e10cSrcweir         const long nCurrRight = (pCurrFrm->*fnRect->fnGetPrtRight)();
2377cdf0e10cSrcweir         const SwRect aRect( pAnchoredObj->GetObjRectWithSpaces() );
2378cdf0e10cSrcweir         long nFlyLeft = (aRect.*fnRect->fnGetLeft)();
2379cdf0e10cSrcweir         long nFlyRight = (aRect.*fnRect->fnGetRight)();
2380cdf0e10cSrcweir 
2381cdf0e10cSrcweir         if ( nFlyRight < nCurrLeft || nFlyLeft > nCurrRight )
2382cdf0e10cSrcweir             eSurroundForTextWrap = SURROUND_PARALLEL;
2383cdf0e10cSrcweir         else
2384cdf0e10cSrcweir         {
2385cdf0e10cSrcweir             long nLeft = nFlyLeft - nCurrLeft;
2386cdf0e10cSrcweir             long nRight = nCurrRight - nFlyRight;
2387cdf0e10cSrcweir             if( nFlyRight - nFlyLeft > FRAME_MAX )
2388cdf0e10cSrcweir             {
2389cdf0e10cSrcweir                 if( nLeft < nRight )
2390cdf0e10cSrcweir                     nLeft = 0;
2391cdf0e10cSrcweir                 else
2392cdf0e10cSrcweir                     nRight = 0;
2393cdf0e10cSrcweir             }
2394cdf0e10cSrcweir             if( nLeft < TEXT_MIN )
2395cdf0e10cSrcweir                 nLeft = 0;
2396cdf0e10cSrcweir             if( nRight < TEXT_MIN )
2397cdf0e10cSrcweir                 nRight = 0;
2398cdf0e10cSrcweir             if( nLeft )
2399cdf0e10cSrcweir                 eSurroundForTextWrap = nRight ? SURROUND_PARALLEL : SURROUND_LEFT;
2400cdf0e10cSrcweir             else
2401cdf0e10cSrcweir                 eSurroundForTextWrap = nRight ? SURROUND_RIGHT: SURROUND_NONE;
2402cdf0e10cSrcweir         }
2403cdf0e10cSrcweir     }
2404cdf0e10cSrcweir 
2405cdf0e10cSrcweir     return eSurroundForTextWrap;
2406cdf0e10cSrcweir }
2407cdf0e10cSrcweir 
2408cdf0e10cSrcweir /*************************************************************************
2409cdf0e10cSrcweir  *						SwTxtFly::IsAnyFrm( SwRect )
2410cdf0e10cSrcweir  *
2411cdf0e10cSrcweir  * IN: dokumentglobal
2412cdf0e10cSrcweir  *
2413cdf0e10cSrcweir  * dient zum Abschalten des SwTxtFly, wenn keine Objekte ueberlappen (Relax)
2414cdf0e10cSrcweir  *
2415cdf0e10cSrcweir  *************************************************************************/
2416cdf0e10cSrcweir 
IsAnyFrm(const SwRect & rLine) const2417cdf0e10cSrcweir sal_Bool SwTxtFly::IsAnyFrm( const SwRect &rLine ) const
2418cdf0e10cSrcweir {
2419cdf0e10cSrcweir 
2420cdf0e10cSrcweir     SWAP_IF_SWAPPED( pCurrFrm )
2421cdf0e10cSrcweir 
2422cdf0e10cSrcweir 	ASSERT( bOn, "IsAnyFrm: Why?" );
2423cdf0e10cSrcweir 
2424cdf0e10cSrcweir     const sal_Bool bRet = ForEach( rLine, NULL, sal_False );
2425cdf0e10cSrcweir     UNDO_SWAP( pCurrFrm )
2426cdf0e10cSrcweir     return bRet;
2427cdf0e10cSrcweir }
2428