xref: /aoo41x/main/sw/source/core/layout/flylay.cxx (revision 43e393b3)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include "doc.hxx"
27cdf0e10cSrcweir #include "pagefrm.hxx"
28cdf0e10cSrcweir #include "rootfrm.hxx"
29cdf0e10cSrcweir #include "cntfrm.hxx"
30cdf0e10cSrcweir #include "dview.hxx"
31cdf0e10cSrcweir #include "dflyobj.hxx"
32cdf0e10cSrcweir #include "dcontact.hxx"
33cdf0e10cSrcweir #include "flyfrm.hxx"
34cdf0e10cSrcweir #include "ftnfrm.hxx"
35cdf0e10cSrcweir #include "frmtool.hxx"
36cdf0e10cSrcweir #include "frmfmt.hxx"
37cdf0e10cSrcweir #include "errhdl.hxx"
38cdf0e10cSrcweir #include "hints.hxx"
39cdf0e10cSrcweir #include "pam.hxx"
40cdf0e10cSrcweir #include "sectfrm.hxx"
41cdf0e10cSrcweir 
42cdf0e10cSrcweir 
43cdf0e10cSrcweir #include <svx/svdpage.hxx>
44cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
45cdf0e10cSrcweir #include <fmtanchr.hxx>
46cdf0e10cSrcweir #include <fmtornt.hxx>
47cdf0e10cSrcweir #include <fmtfsize.hxx>
48cdf0e10cSrcweir #include "ndole.hxx"
49cdf0e10cSrcweir #include "tabfrm.hxx"
50cdf0e10cSrcweir #include "flyfrms.hxx"
51cdf0e10cSrcweir // OD 22.09.2003 #i18732#
52cdf0e10cSrcweir #include <fmtfollowtextflow.hxx>
53cdf0e10cSrcweir // OD 29.10.2003 #113049#
54cdf0e10cSrcweir #include <environmentofanchoredobject.hxx>
55cdf0e10cSrcweir // OD 2004-05-24 #i28701#
56cdf0e10cSrcweir #include <sortedobjs.hxx>
57cdf0e10cSrcweir #include <viewsh.hxx>
58cdf0e10cSrcweir #include <viewimp.hxx>
59cdf0e10cSrcweir 
60cdf0e10cSrcweir 
61cdf0e10cSrcweir using namespace ::com::sun::star;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir 
64cdf0e10cSrcweir /*************************************************************************
65cdf0e10cSrcweir |*
66cdf0e10cSrcweir |*	SwFlyFreeFrm::SwFlyFreeFrm(), ~SwFlyFreeFrm()
67cdf0e10cSrcweir |*
68cdf0e10cSrcweir |*	Ersterstellung		MA 03. Dec. 92
69cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Apr. 99
70cdf0e10cSrcweir |*
71cdf0e10cSrcweir |*************************************************************************/
72cdf0e10cSrcweir 
SwFlyFreeFrm(SwFlyFrmFmt * pFmt,SwFrm * pSib,SwFrm * pAnch)73cdf0e10cSrcweir SwFlyFreeFrm::SwFlyFreeFrm( SwFlyFrmFmt *pFmt, SwFrm* pSib, SwFrm *pAnch ) :
74cdf0e10cSrcweir 	SwFlyFrm( pFmt, pSib, pAnch ),
75cdf0e10cSrcweir     pPage( 0 ),
76cdf0e10cSrcweir     // --> OD 2004-11-15 #i34753#
77cdf0e10cSrcweir     mbNoMakePos( false ),
78cdf0e10cSrcweir     // <--
79cdf0e10cSrcweir     // --> OD 2004-11-12 #i37068#
80cdf0e10cSrcweir     mbNoMoveOnCheckClip( false )
81cdf0e10cSrcweir     // <--
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
~SwFlyFreeFrm()85cdf0e10cSrcweir SwFlyFreeFrm::~SwFlyFreeFrm()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir 	//und Tschuess.
88cdf0e10cSrcweir     // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()>
89cdf0e10cSrcweir     if( GetPageFrm() )
90cdf0e10cSrcweir     {
91cdf0e10cSrcweir         if( GetFmt()->GetDoc()->IsInDtor() )
92cdf0e10cSrcweir         {
93cdf0e10cSrcweir             // --> OD 2004-06-04 #i29879# - remove also to-frame anchored Writer
94cdf0e10cSrcweir             // fly frame from page.
95cdf0e10cSrcweir             const bool bRemoveFromPage =
96cdf0e10cSrcweir                     GetPageFrm()->GetSortedObjs() &&
97cdf0e10cSrcweir                     ( IsFlyAtCntFrm() ||
98cdf0e10cSrcweir                       ( GetAnchorFrm() && GetAnchorFrm()->IsFlyFrm() ) );
99cdf0e10cSrcweir             if ( bRemoveFromPage )
100cdf0e10cSrcweir             {
101cdf0e10cSrcweir                 GetPageFrm()->GetSortedObjs()->Remove( *this );
102cdf0e10cSrcweir             }
103cdf0e10cSrcweir         }
104cdf0e10cSrcweir         else
105cdf0e10cSrcweir         {
106cdf0e10cSrcweir             SwRect aTmp( GetObjRectWithSpaces() );
107cdf0e10cSrcweir             SwFlyFreeFrm::NotifyBackground( GetPageFrm(), aTmp, PREP_FLY_LEAVE );
108cdf0e10cSrcweir         }
109cdf0e10cSrcweir     }
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // --> OD 2004-06-29 #i28701#
113cdf0e10cSrcweir TYPEINIT1(SwFlyFreeFrm,SwFlyFrm);
114cdf0e10cSrcweir // <--
115cdf0e10cSrcweir /*************************************************************************
116cdf0e10cSrcweir |*
117cdf0e10cSrcweir |*	SwFlyFreeFrm::NotifyBackground()
118cdf0e10cSrcweir |*
119cdf0e10cSrcweir |*	Beschreibung		Benachrichtigt den Hintergrund (alle CntntFrms die
120cdf0e10cSrcweir |*		gerade ueberlappt werden. Ausserdem wird das Window in einigen
121cdf0e10cSrcweir |* 		Faellen direkt invalidiert (vor allem dort, wo keine CntntFrms
122cdf0e10cSrcweir |*		ueberlappt werden.
123cdf0e10cSrcweir |* 		Es werden auch die CntntFrms innerhalb von anderen Flys
124cdf0e10cSrcweir |*		beruecksichtigt.
125cdf0e10cSrcweir |*	Ersterstellung		MA 03. Dec. 92
126cdf0e10cSrcweir |*	Letzte Aenderung	MA 26. Aug. 93
127cdf0e10cSrcweir |*
128cdf0e10cSrcweir |*************************************************************************/
129cdf0e10cSrcweir 
NotifyBackground(SwPageFrm * pPageFrm,const SwRect & rRect,PrepareHint eHint)130cdf0e10cSrcweir void SwFlyFreeFrm::NotifyBackground( SwPageFrm *pPageFrm,
131cdf0e10cSrcweir 									 const SwRect& rRect, PrepareHint eHint )
132cdf0e10cSrcweir {
133cdf0e10cSrcweir     ::Notify_Background( GetVirtDrawObj(), pPageFrm, rRect, eHint, sal_True );
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir /*************************************************************************
137cdf0e10cSrcweir |*
138cdf0e10cSrcweir |*	SwFlyFreeFrm::MakeAll()
139cdf0e10cSrcweir |*
140cdf0e10cSrcweir |*	Ersterstellung		MA 18. Feb. 94
141cdf0e10cSrcweir |*	Letzte Aenderung	MA 03. Mar. 97
142cdf0e10cSrcweir |*
143cdf0e10cSrcweir |*************************************************************************/
144cdf0e10cSrcweir 
MakeAll()145cdf0e10cSrcweir void SwFlyFreeFrm::MakeAll()
146cdf0e10cSrcweir {
147cdf0e10cSrcweir     // OD 2004-01-19 #110582#
148cdf0e10cSrcweir     if ( !GetFmt()->GetDoc()->IsVisibleLayerId( GetVirtDrawObj()->GetLayer() ) )
149cdf0e10cSrcweir     {
150cdf0e10cSrcweir         return;
151cdf0e10cSrcweir     }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     if ( !GetAnchorFrm() || IsLocked() || IsColLocked() )
154cdf0e10cSrcweir 		return;
155cdf0e10cSrcweir     // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()>
156cdf0e10cSrcweir     if( !GetPageFrm() && GetAnchorFrm() && GetAnchorFrm()->IsInFly() )
157cdf0e10cSrcweir     {
158cdf0e10cSrcweir         SwFlyFrm* pFly = AnchorFrm()->FindFlyFrm();
159cdf0e10cSrcweir         SwPageFrm *pPageFrm = pFly ? pFly->FindPageFrm() : NULL;
160cdf0e10cSrcweir         if( pPageFrm )
161cdf0e10cSrcweir             pPageFrm->AppendFlyToPage( this );
162cdf0e10cSrcweir     }
163cdf0e10cSrcweir     if( !GetPageFrm() )
164cdf0e10cSrcweir         return;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir 	Lock();	//Der Vorhang faellt
167cdf0e10cSrcweir 
168cdf0e10cSrcweir 	//uebernimmt im DTor die Benachrichtigung
169cdf0e10cSrcweir 	const SwFlyNotify aNotify( this );
170cdf0e10cSrcweir 
171cdf0e10cSrcweir 	if ( IsClipped() )
172cdf0e10cSrcweir     {
173cdf0e10cSrcweir         bValidSize = bHeightClipped = bWidthClipped = sal_False;
174cdf0e10cSrcweir         // --> OD 2004-11-03 #114798# - no invalidation of position,
175cdf0e10cSrcweir         // if anchored object is anchored inside a Writer fly frame,
176cdf0e10cSrcweir         // its position is already locked, and it follows the text flow.
177cdf0e10cSrcweir         // --> OD 2004-11-15 #i34753# - add condition:
178cdf0e10cSrcweir         // no invalidation of position, if no direct move is requested in <CheckClip(..)>
179cdf0e10cSrcweir         if ( !IsNoMoveOnCheckClip() &&
180cdf0e10cSrcweir              !( PositionLocked() &&
181cdf0e10cSrcweir                 GetAnchorFrm()->IsInFly() &&
182cdf0e10cSrcweir                 GetFrmFmt().GetFollowTextFlow().GetValue() ) )
183cdf0e10cSrcweir         // <--
184cdf0e10cSrcweir         {
185cdf0e10cSrcweir             bValidPos = sal_False;
186cdf0e10cSrcweir         }
187cdf0e10cSrcweir         // <--
188cdf0e10cSrcweir     }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     // FME 2007-08-30 #i81146# new loop control
191cdf0e10cSrcweir     sal_uInt16 nLoopControlRuns = 0;
192cdf0e10cSrcweir     const sal_uInt16 nLoopControlMax = 10;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir 	while ( !bValidPos || !bValidSize || !bValidPrtArea || bFormatHeightOnly )
195cdf0e10cSrcweir 	{
196cdf0e10cSrcweir         SWRECTFN( this )
197cdf0e10cSrcweir         const SwFmtFrmSize *pSz;
198cdf0e10cSrcweir 		{	//Zusaetzlicher Scope, damit aAccess vor dem Check zerstoert wird!
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 			SwBorderAttrAccess aAccess( SwFrm::GetCache(), this );
201cdf0e10cSrcweir 			const SwBorderAttrs &rAttrs = *aAccess.Get();
202cdf0e10cSrcweir 			pSz = &rAttrs.GetAttrSet().GetFrmSize();
203cdf0e10cSrcweir 
204cdf0e10cSrcweir 			//Nur einstellen wenn das Flag gesetzt ist!!
205cdf0e10cSrcweir 			if ( !bValidSize )
206cdf0e10cSrcweir 			{
207cdf0e10cSrcweir 				bValidPrtArea = sal_False;
208cdf0e10cSrcweir /*
209cdf0e10cSrcweir                 // This is also done in the Format function, so I think
210cdf0e10cSrcweir                 // this code is not necessary anymore:
211cdf0e10cSrcweir                 const Size aRelSize( CalcRel( *pSz ) );
212cdf0e10cSrcweir 				const SwTwips nMin = MINFLY + rAttrs.CalcLeftLine()+rAttrs.CalcRightLine();
213cdf0e10cSrcweir                 long nDiff = bVert ? aRelSize.Height() : aRelSize.Width();
214cdf0e10cSrcweir                 if( nDiff < nMin )
215cdf0e10cSrcweir                     nDiff = nMin;
216cdf0e10cSrcweir                 nDiff -= (aFrm.*fnRect->fnGetWidth)();
217cdf0e10cSrcweir                 if( nDiff )
218cdf0e10cSrcweir                 {
219cdf0e10cSrcweir                     (aFrm.*fnRect->fnAddRight)( nDiff );
220cdf0e10cSrcweir                     bValidPos = sal_False;
221cdf0e10cSrcweir                 }
222cdf0e10cSrcweir */
223cdf0e10cSrcweir 			}
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 			if ( !bValidPrtArea )
226cdf0e10cSrcweir 				MakePrtArea( rAttrs );
227cdf0e10cSrcweir 
228cdf0e10cSrcweir 			if ( !bValidSize || bFormatHeightOnly )
229cdf0e10cSrcweir 			{
230cdf0e10cSrcweir 				bValidSize = sal_False;
231cdf0e10cSrcweir 				Format( &rAttrs );
232cdf0e10cSrcweir 				bFormatHeightOnly = sal_False;
233cdf0e10cSrcweir 			}
234cdf0e10cSrcweir 
235cdf0e10cSrcweir 			if ( !bValidPos )
236cdf0e10cSrcweir 			{
237cdf0e10cSrcweir                 const Point aOldPos( (Frm().*fnRect->fnGetPos)() );
238cdf0e10cSrcweir                 // OD 2004-03-23 #i26791# - use new method <MakeObjPos()>
239cdf0e10cSrcweir                 // --> OD 2004-11-15 #i34753# - no positioning, if requested.
240cdf0e10cSrcweir                 if ( IsNoMakePos() )
241cdf0e10cSrcweir                     bValidPos = sal_True;
242cdf0e10cSrcweir                 else
243cdf0e10cSrcweir                     // OD 2004-03-23 #i26791# - use new method <MakeObjPos()>
244cdf0e10cSrcweir                     MakeObjPos();
245cdf0e10cSrcweir                 // <--
246cdf0e10cSrcweir                 if( aOldPos == (Frm().*fnRect->fnGetPos)() )
247cdf0e10cSrcweir 				{
248cdf0e10cSrcweir                     if( !bValidPos && GetAnchorFrm()->IsInSct() &&
249cdf0e10cSrcweir                         !GetAnchorFrm()->FindSctFrm()->IsValid() )
250cdf0e10cSrcweir 						bValidPos = sal_True;
251cdf0e10cSrcweir 				}
252cdf0e10cSrcweir 				else
253cdf0e10cSrcweir 					bValidSize = sal_False;
254cdf0e10cSrcweir 			}
255cdf0e10cSrcweir 		}
256cdf0e10cSrcweir 
257cdf0e10cSrcweir         if ( bValidPos && bValidSize )
258cdf0e10cSrcweir         {
259cdf0e10cSrcweir             ++nLoopControlRuns;
260cdf0e10cSrcweir 
261cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
262cdf0e10cSrcweir             ASSERT( nLoopControlRuns < nLoopControlMax, "LoopControl in SwFlyFreeFrm::MakeAll" )
263cdf0e10cSrcweir #endif
264cdf0e10cSrcweir 
265cdf0e10cSrcweir             if ( nLoopControlRuns < nLoopControlMax )
266cdf0e10cSrcweir 			    CheckClip( *pSz );
267cdf0e10cSrcweir         }
268cdf0e10cSrcweir         else
269cdf0e10cSrcweir             nLoopControlRuns = 0;
270cdf0e10cSrcweir 	}
271cdf0e10cSrcweir 	Unlock();
272cdf0e10cSrcweir 
273cdf0e10cSrcweir #ifdef DBG_UTIL
274cdf0e10cSrcweir     SWRECTFN( this )
275cdf0e10cSrcweir     ASSERT( bHeightClipped || ( (Frm().*fnRect->fnGetHeight)() > 0 &&
276cdf0e10cSrcweir             (Prt().*fnRect->fnGetHeight)() > 0),
277cdf0e10cSrcweir 			"SwFlyFreeFrm::Format(), flipping Fly." );
278cdf0e10cSrcweir 
279cdf0e10cSrcweir #endif
280cdf0e10cSrcweir }
281cdf0e10cSrcweir 
282cdf0e10cSrcweir /** determines, if direct environment of fly frame has 'auto' size
283cdf0e10cSrcweir 
284cdf0e10cSrcweir     OD 07.08.2003 #i17297#, #111066#, #111070#
285cdf0e10cSrcweir     start with anchor frame and search via <GetUpper()> for a header, footer,
286cdf0e10cSrcweir     row or fly frame stopping at page frame.
287cdf0e10cSrcweir     return <true>, if such a frame is found and it has 'auto' size.
288cdf0e10cSrcweir     otherwise <false> is returned.
289cdf0e10cSrcweir 
290cdf0e10cSrcweir     @author OD
291cdf0e10cSrcweir 
292cdf0e10cSrcweir     @return boolean indicating, that direct environment has 'auto' size
293cdf0e10cSrcweir */
HasEnvironmentAutoSize() const294cdf0e10cSrcweir bool SwFlyFreeFrm::HasEnvironmentAutoSize() const
295cdf0e10cSrcweir {
296cdf0e10cSrcweir     bool bRetVal = false;
297cdf0e10cSrcweir 
298cdf0e10cSrcweir     const SwFrm* pToBeCheckedFrm = GetAnchorFrm();
299cdf0e10cSrcweir     while ( pToBeCheckedFrm &&
300cdf0e10cSrcweir             !pToBeCheckedFrm->IsPageFrm() )
301cdf0e10cSrcweir     {
302cdf0e10cSrcweir         if ( pToBeCheckedFrm->IsHeaderFrm() ||
303cdf0e10cSrcweir              pToBeCheckedFrm->IsFooterFrm() ||
304cdf0e10cSrcweir              pToBeCheckedFrm->IsRowFrm() ||
305cdf0e10cSrcweir              pToBeCheckedFrm->IsFlyFrm() )
306cdf0e10cSrcweir         {
307cdf0e10cSrcweir             bRetVal = ATT_FIX_SIZE !=
308cdf0e10cSrcweir                       pToBeCheckedFrm->GetAttrSet()->GetFrmSize().GetHeightSizeType();
309cdf0e10cSrcweir             break;
310cdf0e10cSrcweir         }
311cdf0e10cSrcweir         else
312cdf0e10cSrcweir         {
313cdf0e10cSrcweir             pToBeCheckedFrm = pToBeCheckedFrm->GetUpper();
314cdf0e10cSrcweir         }
315cdf0e10cSrcweir     }
316cdf0e10cSrcweir 
317cdf0e10cSrcweir     return bRetVal;
318cdf0e10cSrcweir }
319cdf0e10cSrcweir 
320cdf0e10cSrcweir /*************************************************************************
321cdf0e10cSrcweir |*
322cdf0e10cSrcweir |*	SwFlyFreeFrm::CheckClip()
323cdf0e10cSrcweir |*
324cdf0e10cSrcweir |*	Ersterstellung		MA 21. Feb. 94
325cdf0e10cSrcweir |*	Letzte Aenderung	MA 03. Mar. 97
326cdf0e10cSrcweir |*
327cdf0e10cSrcweir |*************************************************************************/
328cdf0e10cSrcweir 
CheckClip(const SwFmtFrmSize & rSz)329cdf0e10cSrcweir void SwFlyFreeFrm::CheckClip( const SwFmtFrmSize &rSz )
330cdf0e10cSrcweir {
331cdf0e10cSrcweir 	//Jetzt ist es ggf. an der Zeit geignete Massnahmen zu ergreifen wenn
332cdf0e10cSrcweir 	//der Fly nicht in seine Umgebung passt.
333cdf0e10cSrcweir     //Zuerst gibt der Fly seine Position auf. Danach wird er zunaechst
334cdf0e10cSrcweir     //formatiert. Erst wenn er auch durch die Aufgabe der Position nicht
335cdf0e10cSrcweir 	//passt wird die Breite oder Hoehe aufgegeben - der Rahmen wird soweit
336cdf0e10cSrcweir 	//wie notwendig zusammengequetscht.
337cdf0e10cSrcweir 
338cdf0e10cSrcweir 	const SwVirtFlyDrawObj *pObj = GetVirtDrawObj();
339cdf0e10cSrcweir 	SwRect aClip, aTmpStretch;
340cdf0e10cSrcweir 	::CalcClipRect( pObj, aClip, sal_True );
341cdf0e10cSrcweir 	::CalcClipRect( pObj, aTmpStretch, sal_False );
342cdf0e10cSrcweir 	aClip._Intersection( aTmpStretch );
343cdf0e10cSrcweir 
344cdf0e10cSrcweir     const long nBot = Frm().Top() + Frm().Height();
345cdf0e10cSrcweir     const long nRig = Frm().Left() + Frm().Width();
346cdf0e10cSrcweir     const long nClipBot = aClip.Top() + aClip.Height();
347cdf0e10cSrcweir     const long nClipRig = aClip.Left() + aClip.Width();
348cdf0e10cSrcweir 
349cdf0e10cSrcweir 	const sal_Bool bBot = nBot > nClipBot;
350cdf0e10cSrcweir 	const sal_Bool bRig = nRig > nClipRig;
351cdf0e10cSrcweir 	if ( bBot || bRig )
352cdf0e10cSrcweir 	{
353cdf0e10cSrcweir 		sal_Bool bAgain = sal_False;
354cdf0e10cSrcweir         // --> OD 2004-11-12 #i37068# - no move, if it's requested
355cdf0e10cSrcweir         if ( bBot && !IsNoMoveOnCheckClip() &&
356cdf0e10cSrcweir              !GetDrawObjs() && !GetAnchorFrm()->IsInTab() )
357cdf0e10cSrcweir         // <--
358cdf0e10cSrcweir 		{
359cdf0e10cSrcweir 			SwFrm* pHeader = FindFooterOrHeader();
360cdf0e10cSrcweir 			// In a header, correction of the position is no good idea.
361cdf0e10cSrcweir 			// If the fly moves, some paragraphs has to be formatted, this
362cdf0e10cSrcweir             // could cause a change of the height of the headerframe,
363cdf0e10cSrcweir 			// now the flyframe can change its position and so on ...
364cdf0e10cSrcweir             if ( !pHeader || !pHeader->IsHeaderFrm() )
365cdf0e10cSrcweir 			{
366cdf0e10cSrcweir 				const long nOld = Frm().Top();
367cdf0e10cSrcweir                 Frm().Pos().Y() = Max( aClip.Top(), nClipBot - Frm().Height() );
368cdf0e10cSrcweir                 if ( Frm().Top() != nOld )
369cdf0e10cSrcweir 					bAgain = sal_True;
370cdf0e10cSrcweir 				bHeightClipped = sal_True;
371cdf0e10cSrcweir 			}
372cdf0e10cSrcweir 		}
373cdf0e10cSrcweir 		if ( bRig )
374cdf0e10cSrcweir 		{
375cdf0e10cSrcweir 			const long nOld = Frm().Left();
376cdf0e10cSrcweir             Frm().Pos().X() = Max( aClip.Left(), nClipRig - Frm().Width() );
377cdf0e10cSrcweir 			if ( Frm().Left() != nOld )
378cdf0e10cSrcweir 			{
379cdf0e10cSrcweir 				const SwFmtHoriOrient &rH = GetFmt()->GetHoriOrient();
380cdf0e10cSrcweir 				// Links ausgerichtete duerfen nicht nach links verschoben werden,
381cdf0e10cSrcweir 				// wenn sie einem anderen ausweichen.
382cdf0e10cSrcweir                 if( rH.GetHoriOrient() == text::HoriOrientation::LEFT )
383cdf0e10cSrcweir 					Frm().Pos().X() = nOld;
384cdf0e10cSrcweir 				else
385cdf0e10cSrcweir 					bAgain = sal_True;
386cdf0e10cSrcweir 			}
387cdf0e10cSrcweir 			bWidthClipped = sal_True;
388cdf0e10cSrcweir 		}
389cdf0e10cSrcweir 		if ( bAgain )
390cdf0e10cSrcweir 			bValidSize = sal_False;
391cdf0e10cSrcweir 		else
392cdf0e10cSrcweir 		{
393cdf0e10cSrcweir 			//Wenn wir hier ankommen ragt der Frm in unerlaubte Bereiche
394cdf0e10cSrcweir 			//hinein, und eine Positionskorrektur ist nicht erlaubt bzw.
395cdf0e10cSrcweir 			//moeglich oder noetig.
396cdf0e10cSrcweir 
397cdf0e10cSrcweir 			//Fuer Flys mit OLE-Objekten als Lower sorgen wir dafuer, dass
398cdf0e10cSrcweir 			//immer proportional Resized wird.
399cdf0e10cSrcweir 			Size aOldSize( Frm().SSize() );
400cdf0e10cSrcweir 
401cdf0e10cSrcweir 			//Zuerst wird das FrmRect eingestellt, und dann auf den Frm
402cdf0e10cSrcweir 			//uebertragen.
403cdf0e10cSrcweir 			SwRect aFrmRect( Frm() );
404cdf0e10cSrcweir 
405cdf0e10cSrcweir 			if ( bBot )
406cdf0e10cSrcweir 			{
407cdf0e10cSrcweir 				long nDiff = nClipBot;
408cdf0e10cSrcweir                 nDiff -= aFrmRect.Top(); //nDiff ist die verfuegbare Strecke.
409cdf0e10cSrcweir 				nDiff = aFrmRect.Height() - nDiff;
410cdf0e10cSrcweir 				aFrmRect.Height( aFrmRect.Height() - nDiff );
411cdf0e10cSrcweir 				bHeightClipped = sal_True;
412cdf0e10cSrcweir 			}
413cdf0e10cSrcweir 			if ( bRig )
414cdf0e10cSrcweir 			{
415cdf0e10cSrcweir 				long nDiff = nClipRig;
416cdf0e10cSrcweir                 nDiff -= aFrmRect.Left();//nDiff ist die verfuegbare Strecke.
417cdf0e10cSrcweir 				nDiff = aFrmRect.Width() - nDiff;
418cdf0e10cSrcweir 				aFrmRect.Width( aFrmRect.Width() - nDiff );
419cdf0e10cSrcweir 				bWidthClipped = sal_True;
420cdf0e10cSrcweir 			}
421cdf0e10cSrcweir 
422cdf0e10cSrcweir             // OD 06.08.2003 #i17297#, #111066#, #111070# - no proportional
423cdf0e10cSrcweir             // scaling of graphics in environments, which determines its size
424cdf0e10cSrcweir             // by its content ('auto' size). Otherwise layout loops can occur and
425cdf0e10cSrcweir             // layout sizes of the environment can be incorrect.
426cdf0e10cSrcweir             // Such environment are:
427cdf0e10cSrcweir             // (1) header and footer frames with 'auto' size
428cdf0e10cSrcweir             // (2) table row frames with 'auto' size
429cdf0e10cSrcweir             // (3) fly frames with 'auto' size
430cdf0e10cSrcweir 			// Note: section frames seems to be not critical - didn't found
431cdf0e10cSrcweir             //       any critical layout situation so far.
432cdf0e10cSrcweir             if ( Lower() && Lower()->IsNoTxtFrm() &&
433cdf0e10cSrcweir                  ( static_cast<SwCntntFrm*>(Lower())->GetNode()->GetOLENode() ||
434cdf0e10cSrcweir                    !HasEnvironmentAutoSize() ) )
435cdf0e10cSrcweir 			{
436cdf0e10cSrcweir 				//Wenn Breite und Hoehe angepasst wurden, so ist die
437cdf0e10cSrcweir 				//groessere Veraenderung massgeblich.
438cdf0e10cSrcweir 				if ( aFrmRect.Width() != aOldSize.Width() &&
439cdf0e10cSrcweir 					 aFrmRect.Height()!= aOldSize.Height() )
440cdf0e10cSrcweir 				{
441cdf0e10cSrcweir 					if ( (aOldSize.Width() - aFrmRect.Width()) >
442cdf0e10cSrcweir 						 (aOldSize.Height()- aFrmRect.Height())	)
443cdf0e10cSrcweir 						aFrmRect.Height( aOldSize.Height() );
444cdf0e10cSrcweir 					else
445cdf0e10cSrcweir 						aFrmRect.Width( aOldSize.Width() );
446cdf0e10cSrcweir 				}
447cdf0e10cSrcweir 
448cdf0e10cSrcweir 				//Breite angepasst? - Hoehe dann proportional verkleinern
449cdf0e10cSrcweir 				if( aFrmRect.Width() != aOldSize.Width() )
450cdf0e10cSrcweir                 {
451cdf0e10cSrcweir 					aFrmRect.Height( aFrmRect.Width() * aOldSize.Height() /
452cdf0e10cSrcweir 									 aOldSize.Width() );
453cdf0e10cSrcweir                     bHeightClipped = sal_True;
454cdf0e10cSrcweir                 }
455cdf0e10cSrcweir 				//Hoehe angepasst? - Breite dann proportional verkleinern
456cdf0e10cSrcweir                 else if( aFrmRect.Height() != aOldSize.Height() )
457cdf0e10cSrcweir                 {
458cdf0e10cSrcweir 					aFrmRect.Width( aFrmRect.Height() * aOldSize.Width() /
459cdf0e10cSrcweir 									aOldSize.Height() );
460cdf0e10cSrcweir                     bWidthClipped = sal_True;
461cdf0e10cSrcweir                 }
462cdf0e10cSrcweir 
463cdf0e10cSrcweir                 // OD 07.08.2003 #i17297#, #111066#, #111070# - reactivate change
464cdf0e10cSrcweir                 // of size attribute for fly frames containing an ole object.
465cdf0e10cSrcweir                 // FME: 2004-05-19 Added the aFrmRect.HasArea() hack, because
466cdf0e10cSrcweir                 // the environment of the ole object does not have to be valid
467cdf0e10cSrcweir                 // at this moment, or even worse, it does not have to have a
468cdf0e10cSrcweir                 // resonable size. In this case we do not want to change to
469cdf0e10cSrcweir                 // attributes permanentely. Maybe one day somebody dares to remove
470cdf0e10cSrcweir                 // this code.
471cdf0e10cSrcweir                 if ( aFrmRect.HasArea() &&
472cdf0e10cSrcweir                      static_cast<SwCntntFrm*>(Lower())->GetNode()->GetOLENode() &&
473cdf0e10cSrcweir                      ( bWidthClipped || bHeightClipped ) )
474cdf0e10cSrcweir                 {
475cdf0e10cSrcweir                     SwFlyFrmFmt *pFmt = (SwFlyFrmFmt*)GetFmt();
476cdf0e10cSrcweir                     pFmt->LockModify();
477cdf0e10cSrcweir                     SwFmtFrmSize aFrmSize( rSz );
478cdf0e10cSrcweir                     aFrmSize.SetWidth( aFrmRect.Width() );
479cdf0e10cSrcweir                     aFrmSize.SetHeight( aFrmRect.Height() );
480cdf0e10cSrcweir                     pFmt->SetFmtAttr( aFrmSize );
481cdf0e10cSrcweir                     pFmt->UnlockModify();
482cdf0e10cSrcweir                 }
483cdf0e10cSrcweir 			}
484cdf0e10cSrcweir 
485cdf0e10cSrcweir 			//Jetzt die Einstellungen am Frm vornehmen, bei Spalten werden
486cdf0e10cSrcweir 			//die neuen Werte in die Attribute eingetragen, weil es sonst
487cdf0e10cSrcweir 			//ziemlich fiese Oszillationen gibt.
488cdf0e10cSrcweir 			const long nPrtHeightDiff = Frm().Height() - Prt().Height();
489cdf0e10cSrcweir 			const long nPrtWidthDiff  = Frm().Width()  - Prt().Width();
490cdf0e10cSrcweir 			Frm().Height( aFrmRect.Height() );
491cdf0e10cSrcweir 			Frm().Width ( Max( long(MINLAY), aFrmRect.Width() ) );
492cdf0e10cSrcweir 			if ( Lower() && Lower()->IsColumnFrm() )
493cdf0e10cSrcweir 			{
494cdf0e10cSrcweir 				ColLock();	//Grow/Shrink locken.
495cdf0e10cSrcweir                 const Size aTmpOldSize( Prt().SSize() );
496cdf0e10cSrcweir 				Prt().Height( Frm().Height() - nPrtHeightDiff );
497cdf0e10cSrcweir 				Prt().Width ( Frm().Width()  - nPrtWidthDiff );
498cdf0e10cSrcweir                 ChgLowersProp( aTmpOldSize );
499cdf0e10cSrcweir 				SwFrm *pLow = Lower();
500cdf0e10cSrcweir 				do
501cdf0e10cSrcweir 				{	pLow->Calc();
502cdf0e10cSrcweir 					// auch den (Column)BodyFrm mitkalkulieren
503cdf0e10cSrcweir 					((SwLayoutFrm*)pLow)->Lower()->Calc();
504cdf0e10cSrcweir 					pLow = pLow->GetNext();
505cdf0e10cSrcweir 				} while ( pLow );
506cdf0e10cSrcweir 				::CalcCntnt( this );
507cdf0e10cSrcweir 				ColUnlock();
508cdf0e10cSrcweir 				if ( !bValidSize && !bWidthClipped )
509cdf0e10cSrcweir 					bFormatHeightOnly = bValidSize = sal_True;
510cdf0e10cSrcweir 			}
511cdf0e10cSrcweir 			else
512cdf0e10cSrcweir 			{
513cdf0e10cSrcweir 				Prt().Height( Frm().Height() - nPrtHeightDiff );
514cdf0e10cSrcweir 				Prt().Width ( Frm().Width()  - nPrtWidthDiff );
515cdf0e10cSrcweir 			}
516cdf0e10cSrcweir 		}
517cdf0e10cSrcweir 	}
518cdf0e10cSrcweir 
519cdf0e10cSrcweir     // --> OD 2004-10-14 #i26945#
520cdf0e10cSrcweir     ASSERT( Frm().Height() >= 0,
521cdf0e10cSrcweir             "<SwFlyFreeFrm::CheckClip(..)> - fly frame has negative height now." );
522cdf0e10cSrcweir     // <--
523cdf0e10cSrcweir }
524cdf0e10cSrcweir 
525cdf0e10cSrcweir /** method to determine, if a <MakeAll()> on the Writer fly frame is possible
526cdf0e10cSrcweir 
527cdf0e10cSrcweir     OD 2005-03-03 #i43771#
528cdf0e10cSrcweir 
529cdf0e10cSrcweir     @author OD
530cdf0e10cSrcweir */
IsFormatPossible() const531cdf0e10cSrcweir bool SwFlyFreeFrm::IsFormatPossible() const
532cdf0e10cSrcweir {
533cdf0e10cSrcweir     return SwFlyFrm::IsFormatPossible() &&
534cdf0e10cSrcweir            ( GetPageFrm() ||
535cdf0e10cSrcweir              ( GetAnchorFrm() && GetAnchorFrm()->IsInFly() ) );
536cdf0e10cSrcweir }
537cdf0e10cSrcweir 
538cdf0e10cSrcweir /*************************************************************************
539cdf0e10cSrcweir |*
540cdf0e10cSrcweir |*	SwFlyLayFrm::SwFlyLayFrm()
541cdf0e10cSrcweir |*
542cdf0e10cSrcweir |*	Ersterstellung		MA 25. Aug. 92
543cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Apr. 99
544cdf0e10cSrcweir |*
545cdf0e10cSrcweir |*************************************************************************/
546cdf0e10cSrcweir 
SwFlyLayFrm(SwFlyFrmFmt * pFmt,SwFrm * pSib,SwFrm * pAnch)547cdf0e10cSrcweir SwFlyLayFrm::SwFlyLayFrm( SwFlyFrmFmt *pFmt, SwFrm* pSib, SwFrm *pAnch ) :
548cdf0e10cSrcweir 	SwFlyFreeFrm( pFmt, pSib, pAnch )
549cdf0e10cSrcweir {
550cdf0e10cSrcweir 	bLayout = sal_True;
551cdf0e10cSrcweir }
552cdf0e10cSrcweir 
553cdf0e10cSrcweir // --> OD 2004-06-29 #i28701#
554cdf0e10cSrcweir TYPEINIT1(SwFlyLayFrm,SwFlyFreeFrm);
555cdf0e10cSrcweir // <--
556cdf0e10cSrcweir /*************************************************************************
557cdf0e10cSrcweir |*
558cdf0e10cSrcweir |*	SwFlyLayFrm::Modify()
559cdf0e10cSrcweir |*
560cdf0e10cSrcweir |*	Ersterstellung		MA 08. Feb. 93
561cdf0e10cSrcweir |*	Letzte Aenderung	MA 28. Aug. 93
562cdf0e10cSrcweir |*
563cdf0e10cSrcweir |*************************************************************************/
564cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)565cdf0e10cSrcweir void SwFlyLayFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew )
566cdf0e10cSrcweir {
567cdf0e10cSrcweir 	sal_uInt16 nWhich = pNew ? pNew->Which() : 0;
568cdf0e10cSrcweir 
569cdf0e10cSrcweir 	SwFmtAnchor *pAnch = 0;
570cdf0e10cSrcweir 	if( RES_ATTRSET_CHG == nWhich && SFX_ITEM_SET ==
571cdf0e10cSrcweir 		((SwAttrSetChg*)pNew)->GetChgSet()->GetItemState( RES_ANCHOR, sal_False,
572cdf0e10cSrcweir 			(const SfxPoolItem**)&pAnch ))
573cdf0e10cSrcweir 		;		// Beim GetItemState wird der AnkerPointer gesetzt !
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	else if( RES_ANCHOR == nWhich )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir 		//Ankerwechsel, ich haenge mich selbst um.
578cdf0e10cSrcweir 		//Es darf sich nicht um einen Wechsel des Ankertyps handeln,
579cdf0e10cSrcweir 		//dies ist nur ueber die SwFEShell moeglich.
580cdf0e10cSrcweir 		pAnch = (SwFmtAnchor*)pNew;
581cdf0e10cSrcweir 	}
582cdf0e10cSrcweir 
583cdf0e10cSrcweir 	if( pAnch )
584cdf0e10cSrcweir 	{
585cdf0e10cSrcweir 		ASSERT( pAnch->GetAnchorId() ==
586cdf0e10cSrcweir 				GetFmt()->GetAnchor().GetAnchorId(),
587cdf0e10cSrcweir 				"8-) Unzulaessiger Wechsel des Ankertyps." );
588cdf0e10cSrcweir 
589cdf0e10cSrcweir 		//Abmelden, Seite besorgen, an den entsprechenden LayoutFrm
590cdf0e10cSrcweir 		//haengen.
591cdf0e10cSrcweir         SwRect aOld( GetObjRectWithSpaces() );
592cdf0e10cSrcweir         // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()>
593cdf0e10cSrcweir         SwPageFrm *pOldPage = GetPageFrm();
594cdf0e10cSrcweir         AnchorFrm()->RemoveFly( this );
595cdf0e10cSrcweir 
596cdf0e10cSrcweir         if ( FLY_AT_PAGE == pAnch->GetAnchorId() )
597cdf0e10cSrcweir         {
598cdf0e10cSrcweir 			sal_uInt16 nPgNum = pAnch->GetPageNum();
599cdf0e10cSrcweir 			SwRootFrm *pRoot = getRootFrm();
600cdf0e10cSrcweir             SwPageFrm *pTmpPage = (SwPageFrm*)pRoot->Lower();
601cdf0e10cSrcweir             for ( sal_uInt16 i = 1; (i <= nPgNum) && pTmpPage; ++i,
602cdf0e10cSrcweir                                 pTmpPage = (SwPageFrm*)pTmpPage->GetNext() )
603cdf0e10cSrcweir 			{
604cdf0e10cSrcweir 				if ( i == nPgNum )
605cdf0e10cSrcweir                 {
606cdf0e10cSrcweir                     // --> OD 2005-06-09 #i50432# - adjust synopsis of <PlaceFly(..)>
607cdf0e10cSrcweir                     pTmpPage->PlaceFly( this, 0 );
608cdf0e10cSrcweir                     // <--
609cdf0e10cSrcweir                 }
610cdf0e10cSrcweir 			}
611cdf0e10cSrcweir             if( !pTmpPage )
612cdf0e10cSrcweir 			{
613cdf0e10cSrcweir 				pRoot->SetAssertFlyPages();
614cdf0e10cSrcweir 				pRoot->AssertFlyPages();
615cdf0e10cSrcweir 			}
616cdf0e10cSrcweir 		}
617cdf0e10cSrcweir 		else
618cdf0e10cSrcweir 		{
619cdf0e10cSrcweir 			SwNodeIndex aIdx( pAnch->GetCntntAnchor()->nNode );
620cdf0e10cSrcweir 			SwCntntFrm *pCntnt = GetFmt()->GetDoc()->GetNodes().GoNext( &aIdx )->
621cdf0e10cSrcweir 						 GetCntntNode()->getLayoutFrm( getRootFrm(), 0, 0, sal_False );
622cdf0e10cSrcweir 			if( pCntnt )
623cdf0e10cSrcweir 			{
624cdf0e10cSrcweir 				SwFlyFrm *pTmp = pCntnt->FindFlyFrm();
625cdf0e10cSrcweir 				if( pTmp )
626cdf0e10cSrcweir 					pTmp->AppendFly( this );
627cdf0e10cSrcweir 			}
628cdf0e10cSrcweir 		}
629cdf0e10cSrcweir         // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()>
630cdf0e10cSrcweir         if ( pOldPage && pOldPage != GetPageFrm() )
631cdf0e10cSrcweir 			NotifyBackground( pOldPage, aOld, PREP_FLY_LEAVE );
632cdf0e10cSrcweir 		SetCompletePaint();
633cdf0e10cSrcweir 		InvalidateAll();
634cdf0e10cSrcweir 		SetNotifyBack();
635cdf0e10cSrcweir 	}
636cdf0e10cSrcweir 	else
637cdf0e10cSrcweir 		SwFlyFrm::Modify( pOld, pNew );
638cdf0e10cSrcweir }
639cdf0e10cSrcweir 
640cdf0e10cSrcweir /*************************************************************************
641cdf0e10cSrcweir |*
642cdf0e10cSrcweir |*	SwPageFrm::AppendFly()
643cdf0e10cSrcweir |*
644cdf0e10cSrcweir |*	Ersterstellung		MA 10. Oct. 92
645cdf0e10cSrcweir |*	Letzte Aenderung	MA 08. Jun. 96
646cdf0e10cSrcweir |*
647cdf0e10cSrcweir |*************************************************************************/
648cdf0e10cSrcweir 
AppendFlyToPage(SwFlyFrm * pNew)649cdf0e10cSrcweir void SwPageFrm::AppendFlyToPage( SwFlyFrm *pNew )
650cdf0e10cSrcweir {
651cdf0e10cSrcweir 	if ( !pNew->GetVirtDrawObj()->IsInserted() )
652cdf0e10cSrcweir 		getRootFrm()->GetDrawPage()->InsertObject(
653cdf0e10cSrcweir 				(SdrObject*)pNew->GetVirtDrawObj(),
654cdf0e10cSrcweir 				pNew->GetVirtDrawObj()->GetReferencedObj().GetOrdNumDirect() );
655cdf0e10cSrcweir 
656cdf0e10cSrcweir 	InvalidateSpelling();
657cdf0e10cSrcweir     InvalidateSmartTags();  // SMARTTAGS
658cdf0e10cSrcweir 	InvalidateAutoCompleteWords();
659cdf0e10cSrcweir     InvalidateWordCount();
660cdf0e10cSrcweir 
661cdf0e10cSrcweir 	if ( GetUpper() )
662cdf0e10cSrcweir 	{
663cdf0e10cSrcweir 		((SwRootFrm*)GetUpper())->SetIdleFlags();
664cdf0e10cSrcweir 		((SwRootFrm*)GetUpper())->InvalidateBrowseWidth();
665cdf0e10cSrcweir 	}
666cdf0e10cSrcweir 
667cdf0e10cSrcweir     SdrObject* pObj = pNew->GetVirtDrawObj();
668cdf0e10cSrcweir     ASSERT( pNew->GetAnchorFrm(), "Fly without Anchor" );
669*43e393b3SOliver-Rainer Wittmann     SwFlyFrm* pFly = (SwFlyFrm*)pNew->GetAnchorFrm()->FindFlyFrm();
670*43e393b3SOliver-Rainer Wittmann     if ( pFly && pObj->GetOrdNum() < pFly->GetVirtDrawObj()->GetOrdNum() )
671*43e393b3SOliver-Rainer Wittmann     {
672*43e393b3SOliver-Rainer Wittmann         //#i119945# set pFly's OrdNum to _rNewObj's. So when pFly is removed by Undo, the original OrdNum will not be changed.
673*43e393b3SOliver-Rainer Wittmann         sal_uInt32 nNewNum = pObj->GetOrdNumDirect();
674*43e393b3SOliver-Rainer Wittmann         if ( pObj->GetPage() )
675*43e393b3SOliver-Rainer Wittmann             pObj->GetPage()->SetObjectOrdNum( pFly->GetVirtDrawObj()->GetOrdNumDirect(), nNewNum );
676*43e393b3SOliver-Rainer Wittmann         else
677*43e393b3SOliver-Rainer Wittmann             pFly->GetVirtDrawObj()->SetOrdNum( nNewNum );
678*43e393b3SOliver-Rainer Wittmann     }
679cdf0e10cSrcweir 
680cdf0e10cSrcweir 	//Flys die im Cntnt sitzen beachten wir nicht weiter.
681cdf0e10cSrcweir 	if ( pNew->IsFlyInCntFrm() )
682cdf0e10cSrcweir 		InvalidateFlyInCnt();
683cdf0e10cSrcweir     else
684cdf0e10cSrcweir     {
685cdf0e10cSrcweir         InvalidateFlyCntnt();
686cdf0e10cSrcweir 
687cdf0e10cSrcweir         if ( !pSortedObjs )
688cdf0e10cSrcweir             pSortedObjs = new SwSortedObjs();
689cdf0e10cSrcweir 
690cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
691cdf0e10cSrcweir         const bool bSucessInserted =
692cdf0e10cSrcweir #endif
693cdf0e10cSrcweir         pSortedObjs->Insert( *pNew );
694cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
695cdf0e10cSrcweir         ASSERT( bSucessInserted, "Fly nicht in Sorted eingetragen." )
696cdf0e10cSrcweir         (void) bSucessInserted;
697cdf0e10cSrcweir #endif
698cdf0e10cSrcweir 
699cdf0e10cSrcweir         // --> OD 2008-04-22 #i87493#
700cdf0e10cSrcweir         ASSERT( pNew->GetPageFrm() == 0 || pNew->GetPageFrm() == this,
701cdf0e10cSrcweir                 "<SwPageFrm::AppendFlyToPage(..)> - anchored fly frame seems to be registered at another page frame. Serious defect -> please inform OD." );
702cdf0e10cSrcweir         // <--
703cdf0e10cSrcweir         // --> OD 2004-06-30 #i28701# - use new method <SetPageFrm(..)>
704cdf0e10cSrcweir         pNew->SetPageFrm( this );
705cdf0e10cSrcweir         pNew->InvalidatePage( this );
706cdf0e10cSrcweir         // OD 2004-05-17 #i28701#
707cdf0e10cSrcweir         pNew->UnlockPosition();
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 		// Notify accessible layout. That's required at this place for
710cdf0e10cSrcweir 		// frames only where the anchor is moved. Creation of new frames
711cdf0e10cSrcweir 		// is additionally handled by the SwFrmNotify class.
712cdf0e10cSrcweir 		if( GetUpper() &&
713cdf0e10cSrcweir 			static_cast< SwRootFrm * >( GetUpper() )->IsAnyShellAccessible() &&
714cdf0e10cSrcweir 		 	static_cast< SwRootFrm * >( GetUpper() )->GetCurrShell() )
715cdf0e10cSrcweir 		{
716cdf0e10cSrcweir 			static_cast< SwRootFrm * >( GetUpper() )->GetCurrShell()->Imp()
717cdf0e10cSrcweir 									  ->AddAccessibleFrm( pNew );
718cdf0e10cSrcweir 		}
719cdf0e10cSrcweir     }
720cdf0e10cSrcweir 
721cdf0e10cSrcweir     // --> OD 2004-06-09 #i28701# - correction: consider also drawing objects
722cdf0e10cSrcweir     if ( pNew->GetDrawObjs() )
723cdf0e10cSrcweir     {
724cdf0e10cSrcweir         SwSortedObjs &rObjs = *pNew->GetDrawObjs();
725cdf0e10cSrcweir         for ( sal_uInt16 i = 0; i < rObjs.Count(); ++i )
726cdf0e10cSrcweir         {
727cdf0e10cSrcweir             SwAnchoredObject* pTmpObj = rObjs[i];
728cdf0e10cSrcweir             if ( pTmpObj->ISA(SwFlyFrm) )
729cdf0e10cSrcweir             {
730cdf0e10cSrcweir                 SwFlyFrm* pTmpFly = static_cast<SwFlyFrm*>(pTmpObj);
731cdf0e10cSrcweir                 // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()>
732cdf0e10cSrcweir                 if ( pTmpFly->IsFlyFreeFrm() && !pTmpFly->GetPageFrm() )
733cdf0e10cSrcweir                     AppendFlyToPage( pTmpFly );
734cdf0e10cSrcweir             }
735cdf0e10cSrcweir             else if ( pTmpObj->ISA(SwAnchoredDrawObject) )
736cdf0e10cSrcweir             {
737cdf0e10cSrcweir                 // --> OD 2008-04-22 #i87493#
738cdf0e10cSrcweir //                AppendDrawObjToPage( *pTmpObj );
739cdf0e10cSrcweir                 if ( pTmpObj->GetPageFrm() != this )
740cdf0e10cSrcweir                 {
741cdf0e10cSrcweir                     if ( pTmpObj->GetPageFrm() != 0 )
742cdf0e10cSrcweir                     {
743cdf0e10cSrcweir                         pTmpObj->GetPageFrm()->RemoveDrawObjFromPage( *pTmpObj );
744cdf0e10cSrcweir                     }
745cdf0e10cSrcweir                     AppendDrawObjToPage( *pTmpObj );
746cdf0e10cSrcweir                 }
747cdf0e10cSrcweir                 // <--
748cdf0e10cSrcweir             }
749cdf0e10cSrcweir         }
750cdf0e10cSrcweir     }
751cdf0e10cSrcweir }
752cdf0e10cSrcweir 
753cdf0e10cSrcweir /*************************************************************************
754cdf0e10cSrcweir |*
755cdf0e10cSrcweir |*	SwPageFrm::RemoveFly()
756cdf0e10cSrcweir |*
757cdf0e10cSrcweir |*	Ersterstellung		MA 10. Oct. 92
758cdf0e10cSrcweir |*	Letzte Aenderung	MA 26. Aug. 96
759cdf0e10cSrcweir |*
760cdf0e10cSrcweir |*************************************************************************/
761cdf0e10cSrcweir 
RemoveFlyFromPage(SwFlyFrm * pToRemove)762cdf0e10cSrcweir void SwPageFrm::RemoveFlyFromPage( SwFlyFrm *pToRemove )
763cdf0e10cSrcweir {
764cdf0e10cSrcweir 	const sal_uInt32 nOrdNum = pToRemove->GetVirtDrawObj()->GetOrdNum();
765cdf0e10cSrcweir 	getRootFrm()->GetDrawPage()->RemoveObject( nOrdNum );
766cdf0e10cSrcweir 	pToRemove->GetVirtDrawObj()->ReferencedObj().SetOrdNum( nOrdNum );
767cdf0e10cSrcweir 
768cdf0e10cSrcweir 	if ( GetUpper() )
769cdf0e10cSrcweir 	{
770cdf0e10cSrcweir 		if ( !pToRemove->IsFlyInCntFrm() )
771cdf0e10cSrcweir 			((SwRootFrm*)GetUpper())->SetSuperfluous();
772cdf0e10cSrcweir 		((SwRootFrm*)GetUpper())->InvalidateBrowseWidth();
773cdf0e10cSrcweir 	}
774cdf0e10cSrcweir 
775cdf0e10cSrcweir 	//Flys die im Cntnt sitzen beachten wir nicht weiter.
776cdf0e10cSrcweir 	if ( pToRemove->IsFlyInCntFrm() )
777cdf0e10cSrcweir 		return;
778cdf0e10cSrcweir 
779cdf0e10cSrcweir 	// Notify accessible layout. That's required at this place for
780cdf0e10cSrcweir 	// frames only where the anchor is moved. Creation of new frames
781cdf0e10cSrcweir 	// is additionally handled by the SwFrmNotify class.
782cdf0e10cSrcweir 	if( GetUpper() &&
783cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->IsAnyShellAccessible() &&
784cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->GetCurrShell() )
785cdf0e10cSrcweir 	{
786cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->GetCurrShell()->Imp()
787cdf0e10cSrcweir 								  ->DisposeAccessibleFrm( pToRemove, sal_True );
788cdf0e10cSrcweir 	}
789cdf0e10cSrcweir 
790cdf0e10cSrcweir 	//Collections noch nicht loeschen. Das passiert am Ende
791cdf0e10cSrcweir 	//der Action im RemoveSuperfluous der Seite - angestossen von gleich-
792cdf0e10cSrcweir 	//namiger Methode der Root.
793cdf0e10cSrcweir 	//Die FlyColl kann bereits weg sein, weil der DTor der Seite
794cdf0e10cSrcweir 	//gerade 'laeuft'
795cdf0e10cSrcweir 	if ( pSortedObjs )
796cdf0e10cSrcweir 	{
797cdf0e10cSrcweir         pSortedObjs->Remove( *pToRemove );
798cdf0e10cSrcweir 		if ( !pSortedObjs->Count() )
799cdf0e10cSrcweir 		{	DELETEZ( pSortedObjs );
800cdf0e10cSrcweir 		}
801cdf0e10cSrcweir 	}
802cdf0e10cSrcweir     // --> OD 2004-06-30 #i28701# - use new method <SetPageFrm(..)>
803cdf0e10cSrcweir     pToRemove->SetPageFrm( 0L );
804cdf0e10cSrcweir }
805cdf0e10cSrcweir 
806cdf0e10cSrcweir /*************************************************************************
807cdf0e10cSrcweir |*
808cdf0e10cSrcweir |*	SwPageFrm::MoveFly
809cdf0e10cSrcweir |*
810cdf0e10cSrcweir |*	Ersterstellung		MA 25. Jan. 97
811cdf0e10cSrcweir |*	Letzte Aenderung	MA 25. Jan. 97
812cdf0e10cSrcweir |*
813cdf0e10cSrcweir |*************************************************************************/
814cdf0e10cSrcweir 
MoveFly(SwFlyFrm * pToMove,SwPageFrm * pDest)815cdf0e10cSrcweir void SwPageFrm::MoveFly( SwFlyFrm *pToMove, SwPageFrm *pDest )
816cdf0e10cSrcweir {
817cdf0e10cSrcweir 	//Invalidierungen
818cdf0e10cSrcweir 	if ( GetUpper() )
819cdf0e10cSrcweir 	{
820cdf0e10cSrcweir 		((SwRootFrm*)GetUpper())->SetIdleFlags();
821cdf0e10cSrcweir 		if ( !pToMove->IsFlyInCntFrm() && pDest->GetPhyPageNum() < GetPhyPageNum() )
822cdf0e10cSrcweir 			((SwRootFrm*)GetUpper())->SetSuperfluous();
823cdf0e10cSrcweir 	}
824cdf0e10cSrcweir 
825cdf0e10cSrcweir 	pDest->InvalidateSpelling();
826cdf0e10cSrcweir     pDest->InvalidateSmartTags();   // SMARTTAGS
827cdf0e10cSrcweir 	pDest->InvalidateAutoCompleteWords();
828cdf0e10cSrcweir     pDest->InvalidateWordCount();
829cdf0e10cSrcweir 
830cdf0e10cSrcweir     if ( pToMove->IsFlyInCntFrm() )
831cdf0e10cSrcweir 	{
832cdf0e10cSrcweir 		pDest->InvalidateFlyInCnt();
833cdf0e10cSrcweir 		return;
834cdf0e10cSrcweir 	}
835cdf0e10cSrcweir 
836cdf0e10cSrcweir 	// Notify accessible layout. That's required at this place for
837cdf0e10cSrcweir 	// frames only where the anchor is moved. Creation of new frames
838cdf0e10cSrcweir 	// is additionally handled by the SwFrmNotify class.
839cdf0e10cSrcweir 	if( GetUpper() &&
840cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->IsAnyShellAccessible() &&
841cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->GetCurrShell() )
842cdf0e10cSrcweir 	{
843cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->GetCurrShell()->Imp()
844cdf0e10cSrcweir 								  ->DisposeAccessibleFrm( pToMove, sal_True );
845cdf0e10cSrcweir 	}
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 	//Die FlyColl kann bereits weg sein, weil der DTor der Seite
848cdf0e10cSrcweir 	//gerade 'laeuft'
849cdf0e10cSrcweir 	if ( pSortedObjs )
850cdf0e10cSrcweir 	{
851cdf0e10cSrcweir         pSortedObjs->Remove( *pToMove );
852cdf0e10cSrcweir 		if ( !pSortedObjs->Count() )
853cdf0e10cSrcweir 		{	DELETEZ( pSortedObjs );
854cdf0e10cSrcweir 		}
855cdf0e10cSrcweir 	}
856cdf0e10cSrcweir 
857cdf0e10cSrcweir 	//Anmelden
858cdf0e10cSrcweir 	if ( !pDest->GetSortedObjs() )
859cdf0e10cSrcweir         pDest->pSortedObjs = new SwSortedObjs();
860cdf0e10cSrcweir 
861cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
862cdf0e10cSrcweir     const bool bSucessInserted =
863cdf0e10cSrcweir #endif
864cdf0e10cSrcweir     pDest->GetSortedObjs()->Insert( *pToMove );
865cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
866cdf0e10cSrcweir 	ASSERT( bSucessInserted, "Fly nicht in Sorted eingetragen." )
867cdf0e10cSrcweir     (void) bSucessInserted;
868cdf0e10cSrcweir #endif
869cdf0e10cSrcweir 
870cdf0e10cSrcweir     // --> OD 2004-06-30 #i28701# - use new method <SetPageFrm(..)>
871cdf0e10cSrcweir     pToMove->SetPageFrm( pDest );
872cdf0e10cSrcweir 	pToMove->InvalidatePage( pDest );
873cdf0e10cSrcweir 	pToMove->SetNotifyBack();
874cdf0e10cSrcweir 	pDest->InvalidateFlyCntnt();
875cdf0e10cSrcweir     // OD 2004-05-17 #i28701#
876cdf0e10cSrcweir     pToMove->UnlockPosition();
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 	// Notify accessible layout. That's required at this place for
879cdf0e10cSrcweir 	// frames only where the anchor is moved. Creation of new frames
880cdf0e10cSrcweir 	// is additionally handled by the SwFrmNotify class.
881cdf0e10cSrcweir 	if( GetUpper() &&
882cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->IsAnyShellAccessible() &&
883cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->GetCurrShell() )
884cdf0e10cSrcweir 	{
885cdf0e10cSrcweir 		static_cast< SwRootFrm * >( GetUpper() )->GetCurrShell()->Imp()
886cdf0e10cSrcweir 								  ->AddAccessibleFrm( pToMove );
887cdf0e10cSrcweir 	}
888cdf0e10cSrcweir 
889cdf0e10cSrcweir     // --> OD 2004-06-09 #i28701# - correction: move lowers of Writer fly frame
890cdf0e10cSrcweir     if ( pToMove->GetDrawObjs() )
891cdf0e10cSrcweir     {
892cdf0e10cSrcweir         SwSortedObjs &rObjs = *pToMove->GetDrawObjs();
893cdf0e10cSrcweir         for ( sal_uInt32 i = 0; i < rObjs.Count(); ++i )
894cdf0e10cSrcweir         {
895cdf0e10cSrcweir             SwAnchoredObject* pObj = rObjs[i];
896cdf0e10cSrcweir             if ( pObj->ISA(SwFlyFrm) )
897cdf0e10cSrcweir             {
898cdf0e10cSrcweir                 SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pObj);
899cdf0e10cSrcweir                 if ( pFly->IsFlyFreeFrm() )
900cdf0e10cSrcweir                 {
901cdf0e10cSrcweir                     // --> OD 2004-06-30 #i28701# - use new method <GetPageFrm()>
902cdf0e10cSrcweir                     SwPageFrm* pPageFrm = pFly->GetPageFrm();
903cdf0e10cSrcweir                     if ( pPageFrm )
904cdf0e10cSrcweir                         pPageFrm->MoveFly( pFly, pDest );
905cdf0e10cSrcweir                     else
906cdf0e10cSrcweir                         pDest->AppendFlyToPage( pFly );
907cdf0e10cSrcweir                 }
908cdf0e10cSrcweir             }
909cdf0e10cSrcweir             else if ( pObj->ISA(SwAnchoredDrawObject) )
910cdf0e10cSrcweir             {
911cdf0e10cSrcweir                 RemoveDrawObjFromPage( *pObj );
912cdf0e10cSrcweir                 pDest->AppendDrawObjToPage( *pObj );
913cdf0e10cSrcweir             }
914cdf0e10cSrcweir         }
915cdf0e10cSrcweir     }
916cdf0e10cSrcweir }
917cdf0e10cSrcweir 
918cdf0e10cSrcweir /*************************************************************************
919cdf0e10cSrcweir |*
920cdf0e10cSrcweir |*  SwPageFrm::AppendDrawObjToPage(), RemoveDrawObjFromPage()
921cdf0e10cSrcweir |*
922cdf0e10cSrcweir |*  --> OD 2004-07-02 #i28701# - new methods
923cdf0e10cSrcweir |*
924cdf0e10cSrcweir |*************************************************************************/
AppendDrawObjToPage(SwAnchoredObject & _rNewObj)925cdf0e10cSrcweir void SwPageFrm::AppendDrawObjToPage( SwAnchoredObject& _rNewObj )
926cdf0e10cSrcweir {
927cdf0e10cSrcweir     if ( !_rNewObj.ISA(SwAnchoredDrawObject) )
928cdf0e10cSrcweir     {
929cdf0e10cSrcweir         ASSERT( false,
930cdf0e10cSrcweir                 "SwPageFrm::AppendDrawObjToPage(..) - anchored object of unexcepted type -> object not appended" );
931cdf0e10cSrcweir         return;
932cdf0e10cSrcweir     }
933cdf0e10cSrcweir 
934cdf0e10cSrcweir     if ( GetUpper() )
935cdf0e10cSrcweir     {
936cdf0e10cSrcweir         ((SwRootFrm*)GetUpper())->InvalidateBrowseWidth();
937cdf0e10cSrcweir     }
938cdf0e10cSrcweir 
939cdf0e10cSrcweir     ASSERT( _rNewObj.GetAnchorFrm(), "anchored draw object without anchor" );
940*43e393b3SOliver-Rainer Wittmann     SwFlyFrm* pFlyFrm = (SwFlyFrm*)_rNewObj.GetAnchorFrm()->FindFlyFrm();
941cdf0e10cSrcweir     if ( pFlyFrm &&
942cdf0e10cSrcweir          _rNewObj.GetDrawObj()->GetOrdNum() < pFlyFrm->GetVirtDrawObj()->GetOrdNum() )
943cdf0e10cSrcweir     {
944*43e393b3SOliver-Rainer Wittmann         //#i119945# set pFly's OrdNum to _rNewObj's. So when pFly is removed by Undo, the original OrdNum will not be changed.
945*43e393b3SOliver-Rainer Wittmann         sal_uInt32 nNewNum = _rNewObj.GetDrawObj()->GetOrdNumDirect();
946cdf0e10cSrcweir         if ( _rNewObj.GetDrawObj()->GetPage() )
947*43e393b3SOliver-Rainer Wittmann             _rNewObj.DrawObj()->GetPage()->SetObjectOrdNum( pFlyFrm->GetVirtDrawObj()->GetOrdNumDirect(), nNewNum );
948*43e393b3SOliver-Rainer Wittmann         else
949*43e393b3SOliver-Rainer Wittmann             pFlyFrm->GetVirtDrawObj()->SetOrdNum( nNewNum );
950cdf0e10cSrcweir     }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir     if ( FLY_AS_CHAR == _rNewObj.GetFrmFmt().GetAnchor().GetAnchorId() )
953cdf0e10cSrcweir     {
954cdf0e10cSrcweir         return;
955cdf0e10cSrcweir     }
956cdf0e10cSrcweir 
957cdf0e10cSrcweir     if ( !pSortedObjs )
958cdf0e10cSrcweir     {
959cdf0e10cSrcweir         pSortedObjs = new SwSortedObjs();
960cdf0e10cSrcweir     }
961cdf0e10cSrcweir     if ( !pSortedObjs->Insert( _rNewObj ) )
962cdf0e10cSrcweir     {
963cdf0e10cSrcweir #ifdef DBG_UTIL
964cdf0e10cSrcweir         ASSERT( pSortedObjs->Contains( _rNewObj ),
965cdf0e10cSrcweir                 "Drawing object not appended into list <pSortedObjs>." );
966cdf0e10cSrcweir #endif
967cdf0e10cSrcweir     }
968cdf0e10cSrcweir     // --> OD 2008-04-22 #i87493#
969cdf0e10cSrcweir     ASSERT( _rNewObj.GetPageFrm() == 0 || _rNewObj.GetPageFrm() == this,
970cdf0e10cSrcweir             "<SwPageFrm::AppendDrawObjToPage(..)> - anchored draw object seems to be registered at another page frame. Serious defect -> please inform OD." );
971cdf0e10cSrcweir     // <--
972cdf0e10cSrcweir     _rNewObj.SetPageFrm( this );
973cdf0e10cSrcweir 
974cdf0e10cSrcweir     // invalidate page in order to force a reformat of object layout of the page.
975cdf0e10cSrcweir     InvalidateFlyLayout();
976cdf0e10cSrcweir }
977cdf0e10cSrcweir 
RemoveDrawObjFromPage(SwAnchoredObject & _rToRemoveObj)978cdf0e10cSrcweir void SwPageFrm::RemoveDrawObjFromPage( SwAnchoredObject& _rToRemoveObj )
979cdf0e10cSrcweir {
980cdf0e10cSrcweir     if ( !_rToRemoveObj.ISA(SwAnchoredDrawObject) )
981cdf0e10cSrcweir     {
982cdf0e10cSrcweir         ASSERT( false,
983cdf0e10cSrcweir                 "SwPageFrm::RemoveDrawObjFromPage(..) - anchored object of unexcepted type -> object not removed" );
984cdf0e10cSrcweir         return;
985cdf0e10cSrcweir     }
986cdf0e10cSrcweir 
987cdf0e10cSrcweir     if ( pSortedObjs )
988cdf0e10cSrcweir     {
989cdf0e10cSrcweir         pSortedObjs->Remove( _rToRemoveObj );
990cdf0e10cSrcweir         if ( !pSortedObjs->Count() )
991cdf0e10cSrcweir         {
992cdf0e10cSrcweir             DELETEZ( pSortedObjs );
993cdf0e10cSrcweir         }
994cdf0e10cSrcweir         if ( GetUpper() )
995cdf0e10cSrcweir         {
996cdf0e10cSrcweir             if (FLY_AS_CHAR !=
997cdf0e10cSrcweir                     _rToRemoveObj.GetFrmFmt().GetAnchor().GetAnchorId())
998cdf0e10cSrcweir             {
999cdf0e10cSrcweir                 ((SwRootFrm*)GetUpper())->SetSuperfluous();
1000cdf0e10cSrcweir                 InvalidatePage();
1001cdf0e10cSrcweir             }
1002cdf0e10cSrcweir             ((SwRootFrm*)GetUpper())->InvalidateBrowseWidth();
1003cdf0e10cSrcweir         }
1004cdf0e10cSrcweir     }
1005cdf0e10cSrcweir     _rToRemoveObj.SetPageFrm( 0 );
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir /*************************************************************************
1009cdf0e10cSrcweir |*
1010cdf0e10cSrcweir |*	SwPageFrm::PlaceFly
1011cdf0e10cSrcweir |*
1012cdf0e10cSrcweir |*	Ersterstellung		MA 08. Feb. 93
1013cdf0e10cSrcweir |*	Letzte Aenderung	MA 27. Feb. 93
1014cdf0e10cSrcweir |*
1015cdf0e10cSrcweir |*************************************************************************/
1016cdf0e10cSrcweir 
1017cdf0e10cSrcweir // --> OD 2005-06-09 #i50432# - adjust method description and synopsis.
PlaceFly(SwFlyFrm * pFly,SwFlyFrmFmt * pFmt)1018cdf0e10cSrcweir void SwPageFrm::PlaceFly( SwFlyFrm* pFly, SwFlyFrmFmt* pFmt )
1019cdf0e10cSrcweir {
1020cdf0e10cSrcweir     // --> OD 2005-06-09 #i50432# - consider the case that page is an empty page:
1021cdf0e10cSrcweir     // In this case append the fly frame at the next page
1022cdf0e10cSrcweir     ASSERT( !IsEmptyPage() || GetNext(),
1023cdf0e10cSrcweir             "<SwPageFrm::PlaceFly(..)> - empty page with no next page! -> fly frame appended at empty page" );
1024cdf0e10cSrcweir     if ( IsEmptyPage() && GetNext() )
1025cdf0e10cSrcweir     {
1026cdf0e10cSrcweir         static_cast<SwPageFrm*>(GetNext())->PlaceFly( pFly, pFmt );
1027cdf0e10cSrcweir     }
1028cdf0e10cSrcweir     else
1029cdf0e10cSrcweir     {
1030cdf0e10cSrcweir         //Wenn ein Fly uebergeben wurde, so benutzen wir diesen, ansonsten wird
1031cdf0e10cSrcweir         //mit dem Format einer erzeugt.
1032cdf0e10cSrcweir         if ( pFly )
1033cdf0e10cSrcweir             AppendFly( pFly );
1034cdf0e10cSrcweir         else
1035cdf0e10cSrcweir         {   ASSERT( pFmt, ":-( kein Format fuer Fly uebergeben." );
1036cdf0e10cSrcweir             pFly = new SwFlyLayFrm( (SwFlyFrmFmt*)pFmt, this, this );
1037cdf0e10cSrcweir             AppendFly( pFly );
1038cdf0e10cSrcweir             ::RegistFlys( this, pFly );
1039cdf0e10cSrcweir         }
1040cdf0e10cSrcweir     }
1041cdf0e10cSrcweir     // <--
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir /*************************************************************************
1045cdf0e10cSrcweir |*
1046cdf0e10cSrcweir |*	::CalcClipRect
1047cdf0e10cSrcweir |*
1048cdf0e10cSrcweir |*	Ersterstellung		AMA 24. Sep. 96
1049cdf0e10cSrcweir |*	Letzte Aenderung	MA  18. Dec. 96
1050cdf0e10cSrcweir |*
1051cdf0e10cSrcweir |*************************************************************************/
1052cdf0e10cSrcweir // OD 22.09.2003 #i18732# - adjustments for following text flow or not
1053cdf0e10cSrcweir // AND alignment at 'page areas' for to paragraph/to character anchored objects
1054cdf0e10cSrcweir // OD 06.11.2003 #i22305# - adjustment for following text flow
1055cdf0e10cSrcweir // for to frame anchored objects
1056cdf0e10cSrcweir // OD 2004-06-02 #i29778# - Because the calculation of the position of the
1057cdf0e10cSrcweir // floating screen object (Writer fly frame or drawing object) doesn't perform
1058cdf0e10cSrcweir // a calculation on its upper frames and its anchor frame, a calculation of
1059cdf0e10cSrcweir // the upper frames in this method no longer sensible.
1060cdf0e10cSrcweir // --> OD 2004-07-06 #i28701# - if document compatibility option 'Consider
1061cdf0e10cSrcweir // wrapping style influence on object positioning' is ON, the clip area
1062cdf0e10cSrcweir // corresponds to the one as the object doesn't follows the text flow.
CalcClipRect(const SdrObject * pSdrObj,SwRect & rRect,sal_Bool bMove)1063cdf0e10cSrcweir sal_Bool CalcClipRect( const SdrObject *pSdrObj, SwRect &rRect, sal_Bool bMove )
1064cdf0e10cSrcweir {
1065cdf0e10cSrcweir 	sal_Bool bRet = sal_True;
1066cdf0e10cSrcweir 	if ( pSdrObj->ISA(SwVirtFlyDrawObj) )
1067cdf0e10cSrcweir 	{
1068cdf0e10cSrcweir         const SwFlyFrm* pFly = ((const SwVirtFlyDrawObj*)pSdrObj)->GetFlyFrm();
1069cdf0e10cSrcweir         const bool bFollowTextFlow = pFly->GetFmt()->GetFollowTextFlow().GetValue();
1070cdf0e10cSrcweir         // --> OD 2004-07-06 #i28701#
1071cdf0e10cSrcweir         const bool bConsiderWrapOnObjPos =
1072cdf0e10cSrcweir                                 pFly->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION);
1073cdf0e10cSrcweir         // <--
1074cdf0e10cSrcweir         const SwFmtVertOrient &rV = pFly->GetFmt()->GetVertOrient();
1075cdf0e10cSrcweir         if( pFly->IsFlyLayFrm() )
1076cdf0e10cSrcweir 		{
1077cdf0e10cSrcweir             const SwFrm* pClip;
1078cdf0e10cSrcweir             // OD 06.11.2003 #i22305#
1079cdf0e10cSrcweir             // --> OD 2004-07-06 #i28701#
1080cdf0e10cSrcweir             if ( !bFollowTextFlow || bConsiderWrapOnObjPos )
1081cdf0e10cSrcweir             {
1082cdf0e10cSrcweir                 pClip = pFly->GetAnchorFrm()->FindPageFrm();
1083cdf0e10cSrcweir             }
1084cdf0e10cSrcweir             else
1085cdf0e10cSrcweir             {
1086cdf0e10cSrcweir                 pClip = pFly->GetAnchorFrm();
1087cdf0e10cSrcweir             }
1088cdf0e10cSrcweir 
1089cdf0e10cSrcweir 			rRect = pClip->Frm();
1090cdf0e10cSrcweir             SWRECTFN( pClip )
1091cdf0e10cSrcweir 
1092cdf0e10cSrcweir 			//Vertikales clipping: Top und Bottom, ggf. an PrtArea
1093cdf0e10cSrcweir             if( rV.GetVertOrient() != text::VertOrientation::NONE &&
1094cdf0e10cSrcweir                 rV.GetRelationOrient() == text::RelOrientation::PRINT_AREA )
1095cdf0e10cSrcweir 			{
1096cdf0e10cSrcweir                 (rRect.*fnRect->fnSetTop)( (pClip->*fnRect->fnGetPrtTop)() );
1097cdf0e10cSrcweir                 (rRect.*fnRect->fnSetBottom)( (pClip->*fnRect->fnGetPrtBottom)() );
1098cdf0e10cSrcweir 			}
1099cdf0e10cSrcweir 			//Horizontales clipping: Left und Right, ggf. an PrtArea
1100cdf0e10cSrcweir 			const SwFmtHoriOrient &rH = pFly->GetFmt()->GetHoriOrient();
1101cdf0e10cSrcweir             if( rH.GetHoriOrient() != text::HoriOrientation::NONE &&
1102cdf0e10cSrcweir                 rH.GetRelationOrient() == text::RelOrientation::PRINT_AREA )
1103cdf0e10cSrcweir 			{
1104cdf0e10cSrcweir                 (rRect.*fnRect->fnSetLeft)( (pClip->*fnRect->fnGetPrtLeft)() );
1105cdf0e10cSrcweir                 (rRect.*fnRect->fnSetRight)((pClip->*fnRect->fnGetPrtRight)());
1106cdf0e10cSrcweir 			}
1107cdf0e10cSrcweir 		}
1108cdf0e10cSrcweir 		else if( pFly->IsFlyAtCntFrm() )
1109cdf0e10cSrcweir 		{
1110cdf0e10cSrcweir             // OD 22.09.2003 #i18732# - consider following text flow or not
1111cdf0e10cSrcweir             // AND alignment at 'page areas'
1112cdf0e10cSrcweir             const SwFrm* pVertPosOrientFrm = pFly->GetVertPosOrientFrm();
1113cdf0e10cSrcweir             if ( !pVertPosOrientFrm )
1114cdf0e10cSrcweir             {
1115cdf0e10cSrcweir                 ASSERT( false,
1116cdf0e10cSrcweir                         "::CalcClipRect(..) - frame, vertical position is oriented at, is missing .");
1117cdf0e10cSrcweir                 pVertPosOrientFrm = pFly->GetAnchorFrm();
1118cdf0e10cSrcweir             }
1119cdf0e10cSrcweir 
1120cdf0e10cSrcweir             if ( !bFollowTextFlow || bConsiderWrapOnObjPos )
1121cdf0e10cSrcweir             {
1122cdf0e10cSrcweir                 const SwLayoutFrm* pClipFrm = pVertPosOrientFrm->FindPageFrm();
1123cdf0e10cSrcweir                 rRect = bMove ? pClipFrm->GetUpper()->Frm()
1124cdf0e10cSrcweir                               : pClipFrm->Frm();
1125cdf0e10cSrcweir                 // --> OD 2004-10-14 #i26945# - consider that a table, during
1126cdf0e10cSrcweir                 // its format, can exceed its upper printing area bottom.
1127cdf0e10cSrcweir                 // Thus, enlarge the clip rectangle, if such a case occured
1128cdf0e10cSrcweir                 if ( pFly->GetAnchorFrm()->IsInTab() )
1129cdf0e10cSrcweir                 {
1130cdf0e10cSrcweir                     const SwTabFrm* pTabFrm = const_cast<SwFlyFrm*>(pFly)
1131cdf0e10cSrcweir                                 ->GetAnchorFrmContainingAnchPos()->FindTabFrm();
1132cdf0e10cSrcweir                     SwRect aTmp( pTabFrm->Prt() );
1133cdf0e10cSrcweir                     aTmp += pTabFrm->Frm().Pos();
1134cdf0e10cSrcweir                     rRect.Union( aTmp );
1135cdf0e10cSrcweir                     // --> OD 2005-03-30 #i43913# - consider also the cell frame
1136cdf0e10cSrcweir                     const SwFrm* pCellFrm = const_cast<SwFlyFrm*>(pFly)
1137cdf0e10cSrcweir                                 ->GetAnchorFrmContainingAnchPos()->GetUpper();
1138cdf0e10cSrcweir                     while ( pCellFrm && !pCellFrm->IsCellFrm() )
1139cdf0e10cSrcweir                     {
1140cdf0e10cSrcweir                         pCellFrm = pCellFrm->GetUpper();
1141cdf0e10cSrcweir                     }
1142cdf0e10cSrcweir                     if ( pCellFrm )
1143cdf0e10cSrcweir                     {
1144cdf0e10cSrcweir                         aTmp = pCellFrm->Prt();
1145cdf0e10cSrcweir                         aTmp += pCellFrm->Frm().Pos();
1146cdf0e10cSrcweir                         rRect.Union( aTmp );
1147cdf0e10cSrcweir                     }
1148cdf0e10cSrcweir                     // <--
1149cdf0e10cSrcweir                 }
1150cdf0e10cSrcweir             }
1151cdf0e10cSrcweir             else if ( rV.GetRelationOrient() == text::RelOrientation::PAGE_FRAME ||
1152cdf0e10cSrcweir                       rV.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA )
1153cdf0e10cSrcweir             {
1154cdf0e10cSrcweir                 // OD 29.10.2003 #113049# - new class <SwEnvironmentOfAnchoredObject>
1155cdf0e10cSrcweir                 objectpositioning::SwEnvironmentOfAnchoredObject
1156cdf0e10cSrcweir                                                 aEnvOfObj( bFollowTextFlow );
1157cdf0e10cSrcweir                 const SwLayoutFrm& rVertClipFrm =
1158cdf0e10cSrcweir                     aEnvOfObj.GetVertEnvironmentLayoutFrm( *pVertPosOrientFrm );
1159cdf0e10cSrcweir                 if ( rV.GetRelationOrient() == text::RelOrientation::PAGE_FRAME )
1160cdf0e10cSrcweir                 {
1161cdf0e10cSrcweir                     rRect = rVertClipFrm.Frm();
1162cdf0e10cSrcweir                 }
1163cdf0e10cSrcweir                 else if ( rV.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA )
1164cdf0e10cSrcweir                 {
1165cdf0e10cSrcweir                     if ( rVertClipFrm.IsPageFrm() )
1166cdf0e10cSrcweir                     {
1167cdf0e10cSrcweir                         rRect = static_cast<const SwPageFrm&>(rVertClipFrm).PrtWithoutHeaderAndFooter();
1168cdf0e10cSrcweir                     }
1169cdf0e10cSrcweir                     else
1170cdf0e10cSrcweir                     {
1171cdf0e10cSrcweir                         rRect = rVertClipFrm.Frm();
1172cdf0e10cSrcweir                     }
1173cdf0e10cSrcweir                 }
1174cdf0e10cSrcweir                 const SwLayoutFrm* pHoriClipFrm =
1175cdf0e10cSrcweir                         pFly->GetAnchorFrm()->FindPageFrm()->GetUpper();
1176cdf0e10cSrcweir                 SWRECTFN( pFly->GetAnchorFrm() )
1177cdf0e10cSrcweir                 (rRect.*fnRect->fnSetLeft)( (pHoriClipFrm->Frm().*fnRect->fnGetLeft)() );
1178cdf0e10cSrcweir                 (rRect.*fnRect->fnSetRight)((pHoriClipFrm->Frm().*fnRect->fnGetRight)());
1179cdf0e10cSrcweir             }
1180cdf0e10cSrcweir             else
1181cdf0e10cSrcweir             {
1182cdf0e10cSrcweir                 // --> OD 2004-10-11 #i26945#
1183cdf0e10cSrcweir                 const SwFrm *pClip =
1184cdf0e10cSrcweir                         const_cast<SwFlyFrm*>(pFly)->GetAnchorFrmContainingAnchPos();
1185cdf0e10cSrcweir                 // <--
1186cdf0e10cSrcweir                 SWRECTFN( pClip )
1187cdf0e10cSrcweir                 const SwLayoutFrm *pUp = pClip->GetUpper();
1188cdf0e10cSrcweir                 const SwFrm *pCell = pUp->IsCellFrm() ? pUp : 0;
1189cdf0e10cSrcweir                 sal_uInt16 nType = bMove ? FRM_ROOT   | FRM_FLY | FRM_HEADER |
1190cdf0e10cSrcweir                                        FRM_FOOTER | FRM_FTN
1191cdf0e10cSrcweir                                      : FRM_BODY   | FRM_FLY | FRM_HEADER |
1192cdf0e10cSrcweir                                        FRM_FOOTER | FRM_CELL| FRM_FTN;
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir                 while ( !(pUp->GetType() & nType) || pUp->IsColBodyFrm() )
1195cdf0e10cSrcweir                 {
1196cdf0e10cSrcweir                     pUp = pUp->GetUpper();
1197cdf0e10cSrcweir                     if ( !pCell && pUp->IsCellFrm() )
1198cdf0e10cSrcweir                         pCell = pUp;
1199cdf0e10cSrcweir                 }
1200cdf0e10cSrcweir                 if ( bMove )
1201cdf0e10cSrcweir                 {
1202cdf0e10cSrcweir                     if ( pUp->IsRootFrm() )
1203cdf0e10cSrcweir                     {
1204cdf0e10cSrcweir                         rRect  = pUp->Prt();
1205cdf0e10cSrcweir                         rRect += pUp->Frm().Pos();
1206cdf0e10cSrcweir                         pUp = 0;
1207cdf0e10cSrcweir                     }
1208cdf0e10cSrcweir                 }
1209cdf0e10cSrcweir                 if ( pUp )
1210cdf0e10cSrcweir                 {
1211cdf0e10cSrcweir                     if ( pUp->GetType() & FRM_BODY )
1212cdf0e10cSrcweir                     {
1213cdf0e10cSrcweir                         const SwPageFrm *pPg;
1214cdf0e10cSrcweir                         if ( pUp->GetUpper() != (pPg = pFly->FindPageFrm()) )
1215cdf0e10cSrcweir                             pUp = pPg->FindBodyCont();
1216cdf0e10cSrcweir                         rRect = pUp->GetUpper()->Frm();
1217cdf0e10cSrcweir                         (rRect.*fnRect->fnSetTop)( (pUp->*fnRect->fnGetPrtTop)() );
1218cdf0e10cSrcweir                         (rRect.*fnRect->fnSetBottom)((pUp->*fnRect->fnGetPrtBottom)());
1219cdf0e10cSrcweir                     }
1220cdf0e10cSrcweir                     else
1221cdf0e10cSrcweir                     {
1222cdf0e10cSrcweir                         if( ( pUp->GetType() & (FRM_FLY | FRM_FTN ) ) &&
1223cdf0e10cSrcweir                             !pUp->Frm().IsInside( pFly->Frm().Pos() ) )
1224cdf0e10cSrcweir                         {
1225cdf0e10cSrcweir                             if( pUp->IsFlyFrm() )
1226cdf0e10cSrcweir                             {
1227cdf0e10cSrcweir                                 SwFlyFrm *pTmpFly = (SwFlyFrm*)pUp;
1228cdf0e10cSrcweir                                 while( pTmpFly->GetNextLink() )
1229cdf0e10cSrcweir                                 {
1230cdf0e10cSrcweir                                     pTmpFly = pTmpFly->GetNextLink();
1231cdf0e10cSrcweir                                     if( pTmpFly->Frm().IsInside( pFly->Frm().Pos() ) )
1232cdf0e10cSrcweir                                         break;
1233cdf0e10cSrcweir                                 }
1234cdf0e10cSrcweir                                 pUp = pTmpFly;
1235cdf0e10cSrcweir                             }
1236cdf0e10cSrcweir                             else if( pUp->IsInFtn() )
1237cdf0e10cSrcweir                             {
1238cdf0e10cSrcweir                                 const SwFtnFrm *pTmp = pUp->FindFtnFrm();
1239cdf0e10cSrcweir                                 while( pTmp->GetFollow() )
1240cdf0e10cSrcweir                                 {
1241cdf0e10cSrcweir                                     pTmp = pTmp->GetFollow();
1242cdf0e10cSrcweir                                     if( pTmp->Frm().IsInside( pFly->Frm().Pos() ) )
1243cdf0e10cSrcweir                                         break;
1244cdf0e10cSrcweir                                 }
1245cdf0e10cSrcweir                                 pUp = pTmp;
1246cdf0e10cSrcweir                             }
1247cdf0e10cSrcweir                         }
1248cdf0e10cSrcweir                         rRect = pUp->Prt();
1249cdf0e10cSrcweir                         rRect.Pos() += pUp->Frm().Pos();
1250cdf0e10cSrcweir                         if ( pUp->GetType() & (FRM_HEADER | FRM_FOOTER) )
1251cdf0e10cSrcweir                         {
1252cdf0e10cSrcweir                             rRect.Left ( pUp->GetUpper()->Frm().Left() );
1253cdf0e10cSrcweir                             rRect.Width( pUp->GetUpper()->Frm().Width());
1254cdf0e10cSrcweir                         }
1255cdf0e10cSrcweir                         else if ( pUp->IsCellFrm() )                //MA_FLY_HEIGHT
1256cdf0e10cSrcweir                         {
1257cdf0e10cSrcweir                             const SwFrm *pTab = pUp->FindTabFrm();
1258cdf0e10cSrcweir                             (rRect.*fnRect->fnSetBottom)(
1259cdf0e10cSrcweir                                         (pTab->GetUpper()->*fnRect->fnGetPrtBottom)() );
1260cdf0e10cSrcweir                             // OD 08.08.2003 #110978# - expand to left and right
1261cdf0e10cSrcweir                             // cell border
1262cdf0e10cSrcweir                             rRect.Left ( pUp->Frm().Left() );
1263cdf0e10cSrcweir                             rRect.Width( pUp->Frm().Width() );
1264cdf0e10cSrcweir                         }
1265cdf0e10cSrcweir                     }
1266cdf0e10cSrcweir                 }
1267cdf0e10cSrcweir                 if ( pCell )
1268cdf0e10cSrcweir                 {
1269cdf0e10cSrcweir                     //CellFrms koennen auch in 'unerlaubten' Bereichen stehen, dann
1270cdf0e10cSrcweir                     //darf der Fly das auch.
1271cdf0e10cSrcweir                     SwRect aTmp( pCell->Prt() );
1272cdf0e10cSrcweir                     aTmp += pCell->Frm().Pos();
1273cdf0e10cSrcweir                     rRect.Union( aTmp );
1274cdf0e10cSrcweir                 }
1275cdf0e10cSrcweir             }
1276cdf0e10cSrcweir 		}
1277cdf0e10cSrcweir 		else
1278cdf0e10cSrcweir 		{
1279cdf0e10cSrcweir             const SwFrm *pUp = pFly->GetAnchorFrm()->GetUpper();
1280cdf0e10cSrcweir             SWRECTFN( pFly->GetAnchorFrm() )
1281cdf0e10cSrcweir             while( pUp->IsColumnFrm() || pUp->IsSctFrm() || pUp->IsColBodyFrm())
1282cdf0e10cSrcweir                 pUp = pUp->GetUpper();
1283cdf0e10cSrcweir             rRect = pUp->Frm();
1284cdf0e10cSrcweir             if( !pUp->IsBodyFrm() )
1285cdf0e10cSrcweir             {
1286cdf0e10cSrcweir                 rRect += pUp->Prt().Pos();
1287cdf0e10cSrcweir                 rRect.SSize( pUp->Prt().SSize() );
1288cdf0e10cSrcweir                 if ( pUp->IsCellFrm() )
1289cdf0e10cSrcweir                 {
1290cdf0e10cSrcweir                     const SwFrm *pTab = pUp->FindTabFrm();
1291cdf0e10cSrcweir                     (rRect.*fnRect->fnSetBottom)(
1292cdf0e10cSrcweir                                     (pTab->GetUpper()->*fnRect->fnGetPrtBottom)() );
1293cdf0e10cSrcweir                 }
1294cdf0e10cSrcweir             }
1295cdf0e10cSrcweir             else if ( pUp->GetUpper()->IsPageFrm() )
1296cdf0e10cSrcweir             {
1297cdf0e10cSrcweir                 // #111909# Objects anchored as character may exceed right margin
1298cdf0e10cSrcweir                 // of body frame:
1299cdf0e10cSrcweir                 (rRect.*fnRect->fnSetRight)( (pUp->GetUpper()->Frm().*fnRect->fnGetRight)() );
1300cdf0e10cSrcweir             }
1301cdf0e10cSrcweir             long nHeight = (9*(rRect.*fnRect->fnGetHeight)())/10;
1302cdf0e10cSrcweir             long nTop;
1303cdf0e10cSrcweir             const SwFmt *pFmt = ((SwContact*)GetUserCall(pSdrObj))->GetFmt();
1304cdf0e10cSrcweir             const SvxULSpaceItem &rUL = pFmt->GetULSpace();
1305cdf0e10cSrcweir             if( bMove )
1306cdf0e10cSrcweir             {
1307cdf0e10cSrcweir                 nTop = bVert ? ((SwFlyInCntFrm*)pFly)->GetRefPoint().X() :
1308cdf0e10cSrcweir                                ((SwFlyInCntFrm*)pFly)->GetRefPoint().Y();
1309cdf0e10cSrcweir                 nTop = (*fnRect->fnYInc)( nTop, -nHeight );
1310cdf0e10cSrcweir                 long nWidth = (pFly->Frm().*fnRect->fnGetWidth)();
1311cdf0e10cSrcweir                 (rRect.*fnRect->fnSetLeftAndWidth)( bVert ?
1312cdf0e10cSrcweir                             ((SwFlyInCntFrm*)pFly)->GetRefPoint().Y() :
1313cdf0e10cSrcweir                             ((SwFlyInCntFrm*)pFly)->GetRefPoint().X(), nWidth );
1314cdf0e10cSrcweir                 nHeight = 2*nHeight - rUL.GetLower() - rUL.GetUpper();
1315cdf0e10cSrcweir 			}
1316cdf0e10cSrcweir             else
1317cdf0e10cSrcweir             {
1318cdf0e10cSrcweir                 nTop = (*fnRect->fnYInc)( (pFly->Frm().*fnRect->fnGetBottom)(),
1319cdf0e10cSrcweir                                            rUL.GetLower() - nHeight );
1320cdf0e10cSrcweir                 nHeight = 2*nHeight - (pFly->Frm().*fnRect->fnGetHeight)()
1321cdf0e10cSrcweir                           - rUL.GetLower() - rUL.GetUpper();
1322cdf0e10cSrcweir             }
1323cdf0e10cSrcweir             (rRect.*fnRect->fnSetTopAndHeight)( nTop, nHeight );
1324cdf0e10cSrcweir 		}
1325cdf0e10cSrcweir 	}
1326cdf0e10cSrcweir 	else
1327cdf0e10cSrcweir 	{
1328cdf0e10cSrcweir 		const SwDrawContact *pC = (const SwDrawContact*)GetUserCall(pSdrObj);
1329cdf0e10cSrcweir 		const SwFrmFmt  *pFmt = (const SwFrmFmt*)pC->GetFmt();
1330cdf0e10cSrcweir 		const SwFmtAnchor &rAnch = pFmt->GetAnchor();
1331cdf0e10cSrcweir         if ( FLY_AS_CHAR == rAnch.GetAnchorId() )
1332cdf0e10cSrcweir         {
1333cdf0e10cSrcweir             const SwFrm* pAnchorFrm = pC->GetAnchorFrm( pSdrObj );
1334cdf0e10cSrcweir             if( !pAnchorFrm )
1335cdf0e10cSrcweir             {
1336cdf0e10cSrcweir                 ASSERT( false, "<::CalcClipRect(..)> - missing anchor frame." );
1337cdf0e10cSrcweir                 ((SwDrawContact*)pC)->ConnectToLayout();
1338cdf0e10cSrcweir                 pAnchorFrm = pC->GetAnchorFrm();
1339cdf0e10cSrcweir             }
1340cdf0e10cSrcweir             const SwFrm* pUp = pAnchorFrm->GetUpper();
1341cdf0e10cSrcweir             rRect = pUp->Prt();
1342cdf0e10cSrcweir             rRect += pUp->Frm().Pos();
1343cdf0e10cSrcweir             SWRECTFN( pAnchorFrm )
1344cdf0e10cSrcweir             long nHeight = (9*(rRect.*fnRect->fnGetHeight)())/10;
1345cdf0e10cSrcweir             long nTop;
1346cdf0e10cSrcweir             const SvxULSpaceItem &rUL = pFmt->GetULSpace();
1347cdf0e10cSrcweir             SwRect aSnapRect( pSdrObj->GetSnapRect() );
1348cdf0e10cSrcweir             long nTmpH = 0;
1349cdf0e10cSrcweir             if( bMove )
1350cdf0e10cSrcweir             {
1351cdf0e10cSrcweir                 nTop = (*fnRect->fnYInc)( bVert ? pSdrObj->GetAnchorPos().X() :
1352cdf0e10cSrcweir                                        pSdrObj->GetAnchorPos().Y(), -nHeight );
1353cdf0e10cSrcweir                 long nWidth = (aSnapRect.*fnRect->fnGetWidth)();
1354cdf0e10cSrcweir                 (rRect.*fnRect->fnSetLeftAndWidth)( bVert ?
1355cdf0e10cSrcweir                             pSdrObj->GetAnchorPos().Y() :
1356cdf0e10cSrcweir                             pSdrObj->GetAnchorPos().X(), nWidth );
1357cdf0e10cSrcweir 			}
1358cdf0e10cSrcweir             else
1359cdf0e10cSrcweir             {
1360cdf0e10cSrcweir                 // OD 2004-04-13 #i26791# - value of <nTmpH> is needed to
1361cdf0e10cSrcweir                 // calculate value of <nTop>.
1362cdf0e10cSrcweir                 nTmpH = bVert ? pSdrObj->GetCurrentBoundRect().GetWidth() :
1363cdf0e10cSrcweir                                 pSdrObj->GetCurrentBoundRect().GetHeight();
1364cdf0e10cSrcweir                 nTop = (*fnRect->fnYInc)( (aSnapRect.*fnRect->fnGetTop)(),
1365cdf0e10cSrcweir                                           rUL.GetLower() + nTmpH - nHeight );
1366cdf0e10cSrcweir             }
1367cdf0e10cSrcweir             nHeight = 2*nHeight - nTmpH - rUL.GetLower() - rUL.GetUpper();
1368cdf0e10cSrcweir             (rRect.*fnRect->fnSetTopAndHeight)( nTop, nHeight );
1369cdf0e10cSrcweir 		}
1370cdf0e10cSrcweir 		else
1371cdf0e10cSrcweir         {
1372cdf0e10cSrcweir             // OD 23.06.2003 #108784# - restrict clip rectangle for drawing
1373cdf0e10cSrcweir             // objects in header/footer to the page frame.
1374cdf0e10cSrcweir             // OD 2004-03-29 #i26791#
1375cdf0e10cSrcweir             const SwFrm* pAnchorFrm = pC->GetAnchorFrm( pSdrObj );
1376cdf0e10cSrcweir             if ( pAnchorFrm && pAnchorFrm->FindFooterOrHeader() )
1377cdf0e10cSrcweir             {
1378cdf0e10cSrcweir                 // clip frame is the page frame the header/footer is on.
1379cdf0e10cSrcweir                 const SwFrm* pClipFrm = pAnchorFrm->FindPageFrm();
1380cdf0e10cSrcweir                 rRect = pClipFrm->Frm();
1381cdf0e10cSrcweir             }
1382cdf0e10cSrcweir             else
1383cdf0e10cSrcweir             {
1384cdf0e10cSrcweir                 bRet = sal_False;
1385cdf0e10cSrcweir             }
1386cdf0e10cSrcweir         }
1387cdf0e10cSrcweir 	}
1388cdf0e10cSrcweir 	return bRet;
1389cdf0e10cSrcweir }
1390