xref: /aoo41x/main/sw/source/core/layout/fly.cxx (revision 2a0ce834)
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 "hintids.hxx"
27cdf0e10cSrcweir #include <svl/itemiter.hxx>
28cdf0e10cSrcweir #include <svtools/imap.hxx>
29cdf0e10cSrcweir #include <vcl/graph.hxx>
30cdf0e10cSrcweir #include <tools/poly.hxx>
31cdf0e10cSrcweir #include <svx/contdlg.hxx>
32cdf0e10cSrcweir #include <editeng/protitem.hxx>
33cdf0e10cSrcweir #include <editeng/opaqitem.hxx>
34cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
35cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
36cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
37cdf0e10cSrcweir #include <editeng/keepitem.hxx>
38cdf0e10cSrcweir #include <fmtanchr.hxx>
39cdf0e10cSrcweir #include <fmtfsize.hxx>
40cdf0e10cSrcweir #include <fmtclds.hxx>
41cdf0e10cSrcweir #include <fmtcntnt.hxx>
42cdf0e10cSrcweir #include <fmturl.hxx>
43cdf0e10cSrcweir #include <fmtsrnd.hxx>
44cdf0e10cSrcweir #include <fmtornt.hxx>
45cdf0e10cSrcweir #include <fmtpdsc.hxx>
46cdf0e10cSrcweir #include <fmtcnct.hxx>
47cdf0e10cSrcweir #include <layhelp.hxx>
48cdf0e10cSrcweir #include <ndtxt.hxx>
49cdf0e10cSrcweir #include <svx/svdogrp.hxx>
50cdf0e10cSrcweir #include <ndgrf.hxx>
51cdf0e10cSrcweir #include <tolayoutanchoredobjectposition.hxx>
52cdf0e10cSrcweir #include <fmtfollowtextflow.hxx>
53cdf0e10cSrcweir #include <sortedobjs.hxx>
54cdf0e10cSrcweir #include <objectformatter.hxx>
55cdf0e10cSrcweir #include <anchoredobject.hxx>
56cdf0e10cSrcweir #include <ndole.hxx>
57cdf0e10cSrcweir #include <swtable.hxx>
58cdf0e10cSrcweir #include <svx/svdpage.hxx>
59cdf0e10cSrcweir #include "doc.hxx"
60cdf0e10cSrcweir #include "viewsh.hxx"
61cdf0e10cSrcweir #include "layouter.hxx"
62cdf0e10cSrcweir #include "pagefrm.hxx"
63cdf0e10cSrcweir #include "rootfrm.hxx"
64cdf0e10cSrcweir #include "cntfrm.hxx"
65cdf0e10cSrcweir #include "pam.hxx"
66cdf0e10cSrcweir #include "frmatr.hxx"
67cdf0e10cSrcweir #include "viewimp.hxx"
68cdf0e10cSrcweir #include "viewopt.hxx"
69cdf0e10cSrcweir #include "errhdl.hxx"
70cdf0e10cSrcweir #include "dcontact.hxx"
71cdf0e10cSrcweir #include "dflyobj.hxx"
72cdf0e10cSrcweir #include "dview.hxx"
73cdf0e10cSrcweir #include "flyfrm.hxx"
74cdf0e10cSrcweir #include "frmtool.hxx"
75cdf0e10cSrcweir #include "frmfmt.hxx"
76cdf0e10cSrcweir #include "hints.hxx"
77cdf0e10cSrcweir #include "swregion.hxx"
78cdf0e10cSrcweir #include "tabfrm.hxx"
79cdf0e10cSrcweir #include "txtfrm.hxx"
80cdf0e10cSrcweir #include "ndnotxt.hxx"
81cdf0e10cSrcweir #include "notxtfrm.hxx"   // GetGrfArea
82cdf0e10cSrcweir #include "flyfrms.hxx"
83cdf0e10cSrcweir #include "ndindex.hxx"   // GetGrfArea
84cdf0e10cSrcweir #include "sectfrm.hxx"
85cdf0e10cSrcweir #include <vcl/svapp.hxx>
86cdf0e10cSrcweir #include <vcl/salbtype.hxx>		// FRound
87cdf0e10cSrcweir #include "switerator.hxx"
88cdf0e10cSrcweir 
89cdf0e10cSrcweir using namespace ::com::sun::star;
90cdf0e10cSrcweir 
91cdf0e10cSrcweir 
92cdf0e10cSrcweir // OD 2004-03-23 #i26791
93cdf0e10cSrcweir TYPEINIT2(SwFlyFrm,SwLayoutFrm,SwAnchoredObject);
94cdf0e10cSrcweir 
95cdf0e10cSrcweir /*************************************************************************
96cdf0e10cSrcweir |*
97cdf0e10cSrcweir |*	SwFlyFrm::SwFlyFrm()
98cdf0e10cSrcweir |*
99cdf0e10cSrcweir |*	Ersterstellung		MA 28. Sep. 92
100cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Apr. 99
101cdf0e10cSrcweir |*
102cdf0e10cSrcweir |*************************************************************************/
103cdf0e10cSrcweir 
SwFlyFrm(SwFlyFrmFmt * pFmt,SwFrm * pSib,SwFrm * pAnch)104cdf0e10cSrcweir SwFlyFrm::SwFlyFrm( SwFlyFrmFmt *pFmt, SwFrm* pSib, SwFrm *pAnch ) :
105cdf0e10cSrcweir 	SwLayoutFrm( pFmt, pSib ),
106cdf0e10cSrcweir     // OD 2004-03-22 #i26791#
107cdf0e10cSrcweir     SwAnchoredObject(),
108cdf0e10cSrcweir     // OD 2004-05-27 #i26791# - moved to <SwAnchoredObject>
109cdf0e10cSrcweir //    aRelPos(),
110cdf0e10cSrcweir 	pPrevLink( 0 ),
111cdf0e10cSrcweir 	pNextLink( 0 ),
112cdf0e10cSrcweir 	bInCnt( sal_False ),
113cdf0e10cSrcweir 	bAtCnt( sal_False ),
114cdf0e10cSrcweir 	bLayout( sal_False ),
115cdf0e10cSrcweir     bAutoPosition( sal_False ),
116cdf0e10cSrcweir     bNoShrink( sal_False ),
117cdf0e10cSrcweir     bLockDeleteContent( sal_False )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir     nType = FRMC_FLY;
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	bInvalid = bNotifyBack = sal_True;
122cdf0e10cSrcweir 	bLocked  = bMinHeight =
123cdf0e10cSrcweir 	bHeightClipped = bWidthClipped = bFormatHeightOnly = sal_False;
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	//Grosseneinstellung, Fixe groesse ist immer die Breite
126cdf0e10cSrcweir 	const SwFmtFrmSize &rFrmSize = pFmt->GetFrmSize();
127cdf0e10cSrcweir     sal_Bool bVert = sal_False;
128cdf0e10cSrcweir     sal_uInt16 nDir =
129cdf0e10cSrcweir         ((SvxFrameDirectionItem&)pFmt->GetFmtAttr( RES_FRAMEDIR )).GetValue();
130cdf0e10cSrcweir     if( FRMDIR_ENVIRONMENT == nDir )
131cdf0e10cSrcweir     {
132cdf0e10cSrcweir         bDerivedVert = 1;
133cdf0e10cSrcweir         bDerivedR2L = 1;
134cdf0e10cSrcweir         if( pAnch && pAnch->IsVertical() )
135cdf0e10cSrcweir             bVert = sal_True;
136cdf0e10cSrcweir     }
137cdf0e10cSrcweir     else
138cdf0e10cSrcweir     {
139cdf0e10cSrcweir         bInvalidVert = 0;
140cdf0e10cSrcweir         bDerivedVert = 0;
141cdf0e10cSrcweir         bDerivedR2L = 0;
142cdf0e10cSrcweir         if( FRMDIR_HORI_LEFT_TOP == nDir || FRMDIR_HORI_RIGHT_TOP == nDir )
143cdf0e10cSrcweir         {
144cdf0e10cSrcweir             //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
145cdf0e10cSrcweir             bVertLR = 0;
146cdf0e10cSrcweir             bVertical = 0;
147cdf0e10cSrcweir 		}
148cdf0e10cSrcweir         else
149cdf0e10cSrcweir         {
150cdf0e10cSrcweir             const ViewShell *pSh = getRootFrm() ? getRootFrm()->GetCurrShell() : 0;
151cdf0e10cSrcweir             if( pSh && pSh->GetViewOptions()->getBrowseMode() )
152cdf0e10cSrcweir             {
153cdf0e10cSrcweir                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
154cdf0e10cSrcweir                 bVertLR = 0;
155cdf0e10cSrcweir                 bVertical = 0;
156cdf0e10cSrcweir             }
157cdf0e10cSrcweir             else
158cdf0e10cSrcweir             {
159cdf0e10cSrcweir                 bVertical = 1;
160cdf0e10cSrcweir                 //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
161cdf0e10cSrcweir             	if ( FRMDIR_VERT_TOP_LEFT == nDir )
162cdf0e10cSrcweir                 	bVertLR = 1;
163cdf0e10cSrcweir                 else
164cdf0e10cSrcweir                 	bVertLR = 0;
165cdf0e10cSrcweir             }
166cdf0e10cSrcweir         }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir         bVert = bVertical;
169cdf0e10cSrcweir         bInvalidR2L = 0;
170cdf0e10cSrcweir         if( FRMDIR_HORI_RIGHT_TOP == nDir )
171cdf0e10cSrcweir             bRightToLeft = 1;
172cdf0e10cSrcweir         else
173cdf0e10cSrcweir             bRightToLeft = 0;
174cdf0e10cSrcweir     }
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     Frm().Width( rFrmSize.GetWidth() );
177cdf0e10cSrcweir     Frm().Height( rFrmSize.GetHeightSizeType() == ATT_VAR_SIZE ? MINFLY : rFrmSize.GetHeight() );
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	//Hoehe Fix oder Variabel oder was?
180cdf0e10cSrcweir     if ( rFrmSize.GetHeightSizeType() == ATT_MIN_SIZE )
181cdf0e10cSrcweir 		bMinHeight = sal_True;
182cdf0e10cSrcweir     else if ( rFrmSize.GetHeightSizeType() == ATT_FIX_SIZE )
183cdf0e10cSrcweir         bFixSize = sal_True;
184cdf0e10cSrcweir 
185cdf0e10cSrcweir     // OD 2004-02-12 #110582#-2 - insert columns, if necessary
186cdf0e10cSrcweir     InsertColumns();
187cdf0e10cSrcweir 
188cdf0e10cSrcweir 	//Erst das Init, dann den Inhalt, denn zum Inhalt koennen  widerum
189cdf0e10cSrcweir 	//Objekte/Rahmen gehoeren die dann angemeldet werden.
190cdf0e10cSrcweir     InitDrawObj( sal_False );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir     // OD 2004-01-19 #110582#
193cdf0e10cSrcweir     Chain( pAnch );
194cdf0e10cSrcweir 
195cdf0e10cSrcweir     // OD 2004-01-19 #110582#
196cdf0e10cSrcweir     InsertCnt();
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	//Und erstmal in den Wald stellen die Kiste, damit bei neuen Dokument nicht
199cdf0e10cSrcweir 	//unnoetig viel formatiert wird.
200cdf0e10cSrcweir 	Frm().Pos().X() = Frm().Pos().Y() = WEIT_WECH;
201cdf0e10cSrcweir }
202cdf0e10cSrcweir 
203cdf0e10cSrcweir // OD 2004-01-19 #110582#
Chain(SwFrm * _pAnch)204cdf0e10cSrcweir void SwFlyFrm::Chain( SwFrm* _pAnch )
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     // Connect to chain neighboors.
207cdf0e10cSrcweir     // No problem, if a neighboor doesn't exist - the construction of the
208cdf0e10cSrcweir     // neighboor will make the connection
209cdf0e10cSrcweir     const SwFmtChain& rChain = GetFmt()->GetChain();
210cdf0e10cSrcweir     if ( rChain.GetPrev() || rChain.GetNext() )
211cdf0e10cSrcweir     {
212cdf0e10cSrcweir         if ( rChain.GetNext() )
213cdf0e10cSrcweir         {
214cdf0e10cSrcweir             SwFlyFrm* pFollow = FindChainNeighbour( *rChain.GetNext(), _pAnch );
215cdf0e10cSrcweir             if ( pFollow )
216cdf0e10cSrcweir             {
217cdf0e10cSrcweir                 ASSERT( !pFollow->GetPrevLink(), "wrong chain detected" );
218cdf0e10cSrcweir                 if ( !pFollow->GetPrevLink() )
219cdf0e10cSrcweir                     SwFlyFrm::ChainFrames( this, pFollow );
220cdf0e10cSrcweir             }
221cdf0e10cSrcweir         }
222cdf0e10cSrcweir         if ( rChain.GetPrev() )
223cdf0e10cSrcweir         {
224cdf0e10cSrcweir             SwFlyFrm *pMaster = FindChainNeighbour( *rChain.GetPrev(), _pAnch );
225cdf0e10cSrcweir             if ( pMaster )
226cdf0e10cSrcweir             {
227cdf0e10cSrcweir                 ASSERT( !pMaster->GetNextLink(), "wrong chain detected" );
228cdf0e10cSrcweir                 if ( !pMaster->GetNextLink() )
229cdf0e10cSrcweir                     SwFlyFrm::ChainFrames( pMaster, this );
230cdf0e10cSrcweir             }
231cdf0e10cSrcweir         }
232cdf0e10cSrcweir     }
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir // OD 2004-01-19 #110582#
InsertCnt()236cdf0e10cSrcweir void SwFlyFrm::InsertCnt()
237cdf0e10cSrcweir {
238cdf0e10cSrcweir     if ( !GetPrevLink() )
239cdf0e10cSrcweir     {
240cdf0e10cSrcweir         const SwFmtCntnt& rCntnt = GetFmt()->GetCntnt();
241cdf0e10cSrcweir         ASSERT( rCntnt.GetCntntIdx(), ":-( no content prepared." );
242cdf0e10cSrcweir         sal_uLong nIndex = rCntnt.GetCntntIdx()->GetIndex();
243cdf0e10cSrcweir         // Lower() bedeutet SwColumnFrm, eingefuegt werden muss der Inhalt dann in den (Column)BodyFrm
244cdf0e10cSrcweir         ::_InsertCnt( Lower() ? (SwLayoutFrm*)((SwLayoutFrm*)Lower())->Lower() : (SwLayoutFrm*)this,
245cdf0e10cSrcweir                       GetFmt()->GetDoc(), nIndex );
246cdf0e10cSrcweir 
247cdf0e10cSrcweir         //NoTxt haben immer eine FixHeight.
248cdf0e10cSrcweir         if ( Lower() && Lower()->IsNoTxtFrm() )
249cdf0e10cSrcweir         {
250cdf0e10cSrcweir             bFixSize = sal_True;
251cdf0e10cSrcweir             bMinHeight = sal_False;
252cdf0e10cSrcweir         }
253cdf0e10cSrcweir     }
254cdf0e10cSrcweir }
255cdf0e10cSrcweir 
256cdf0e10cSrcweir  // OD 2004-02-12 #110582#-2
InsertColumns()257cdf0e10cSrcweir  void SwFlyFrm::InsertColumns()
258cdf0e10cSrcweir  {
259cdf0e10cSrcweir     // --> OD 2009-08-12 #i97379#
260cdf0e10cSrcweir     // Check, if column are allowed.
261cdf0e10cSrcweir     // Columns are not allowed for fly frames, which represent graphics or embedded objects.
262cdf0e10cSrcweir     const SwFmtCntnt& rCntnt = GetFmt()->GetCntnt();
263cdf0e10cSrcweir     ASSERT( rCntnt.GetCntntIdx(), "<SwFlyFrm::InsertColumns()> - no content prepared." );
264cdf0e10cSrcweir     SwNodeIndex aFirstCntnt( *(rCntnt.GetCntntIdx()), 1 );
265cdf0e10cSrcweir     if ( aFirstCntnt.GetNode().IsNoTxtNode() )
266cdf0e10cSrcweir     {
267cdf0e10cSrcweir         return;
268cdf0e10cSrcweir     }
269cdf0e10cSrcweir     // <--
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     const SwFmtCol &rCol = GetFmt()->GetCol();
272cdf0e10cSrcweir     if ( rCol.GetNumCols() > 1 )
273cdf0e10cSrcweir     {
274cdf0e10cSrcweir         //PrtArea ersteinmal so gross wie der Frm, damit die Spalten
275cdf0e10cSrcweir         //vernuenftig eingesetzt werden koennen; das schaukelt sich dann
276cdf0e10cSrcweir         //schon zurecht.
277cdf0e10cSrcweir         Prt().Width( Frm().Width() );
278cdf0e10cSrcweir         Prt().Height( Frm().Height() );
279cdf0e10cSrcweir         const SwFmtCol aOld; //ChgColumns() verlaesst sich darauf, dass auch ein
280cdf0e10cSrcweir                              //Old-Wert hereingereicht wird.
281cdf0e10cSrcweir         ChgColumns( aOld, rCol );
282cdf0e10cSrcweir     }
283cdf0e10cSrcweir  }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir /*************************************************************************
286cdf0e10cSrcweir |*
287cdf0e10cSrcweir |*	SwFlyFrm::~SwFlyFrm()
288cdf0e10cSrcweir |*
289cdf0e10cSrcweir |*	Ersterstellung		MA 28. Sep. 92
290cdf0e10cSrcweir |*	Letzte Aenderung	MA 07. Jul. 95
291cdf0e10cSrcweir |*
292cdf0e10cSrcweir |*************************************************************************/
293cdf0e10cSrcweir 
~SwFlyFrm()294cdf0e10cSrcweir SwFlyFrm::~SwFlyFrm()
295cdf0e10cSrcweir {
296cdf0e10cSrcweir 	// Accessible objects for fly frames will be destroyed in this destructor.
297cdf0e10cSrcweir 	// For frames bound as char or frames that don't have an anchor we have
298cdf0e10cSrcweir 	// to do that ourselves. For any other frame the call RemoveFly at the
299cdf0e10cSrcweir 	// anchor will do that.
300cdf0e10cSrcweir     if( IsAccessibleFrm() && GetFmt() && (IsFlyInCntFrm() || !GetAnchorFrm()) )
301cdf0e10cSrcweir 	{
302cdf0e10cSrcweir 		SwRootFrm *pRootFrm = getRootFrm();
303cdf0e10cSrcweir 		if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
304cdf0e10cSrcweir 		{
305cdf0e10cSrcweir 			ViewShell *pVSh = pRootFrm->GetCurrShell();
306cdf0e10cSrcweir 			if( pVSh && pVSh->Imp() )
307cdf0e10cSrcweir 			{
308cdf0e10cSrcweir 				// Lowers aren't disposed already, so we have to do a recursive
309cdf0e10cSrcweir 				// dispose
310cdf0e10cSrcweir 				pVSh->Imp()->DisposeAccessibleFrm( this, sal_True );
311cdf0e10cSrcweir 			}
312cdf0e10cSrcweir 		}
313cdf0e10cSrcweir 	}
314cdf0e10cSrcweir 
315cdf0e10cSrcweir 	if( GetFmt() && !GetFmt()->GetDoc()->IsInDtor() )
316cdf0e10cSrcweir 	{
317cdf0e10cSrcweir         // OD 2004-01-19 #110582#
318cdf0e10cSrcweir         Unchain();
319cdf0e10cSrcweir 
320cdf0e10cSrcweir         // OD 2004-01-19 #110582#
321cdf0e10cSrcweir         DeleteCnt();
322cdf0e10cSrcweir 
323cdf0e10cSrcweir 		//Tschuess sagen.
324cdf0e10cSrcweir         if ( GetAnchorFrm() )
325cdf0e10cSrcweir             AnchorFrm()->RemoveFly( this );
326cdf0e10cSrcweir 	}
327cdf0e10cSrcweir 
328cdf0e10cSrcweir     FinitDrawObj();
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir // OD 2004-01-19 #110582#
Unchain()332cdf0e10cSrcweir void SwFlyFrm::Unchain()
333cdf0e10cSrcweir {
334cdf0e10cSrcweir     if ( GetPrevLink() )
335cdf0e10cSrcweir         UnchainFrames( GetPrevLink(), this );
336cdf0e10cSrcweir     if ( GetNextLink() )
337cdf0e10cSrcweir         UnchainFrames( this, GetNextLink() );
338cdf0e10cSrcweir }
339cdf0e10cSrcweir 
340cdf0e10cSrcweir // OD 2004-01-19 #110582#
DeleteCnt()341cdf0e10cSrcweir void SwFlyFrm::DeleteCnt()
342cdf0e10cSrcweir {
343cdf0e10cSrcweir     // #110582#-2
344cdf0e10cSrcweir     if ( IsLockDeleteContent() )
345cdf0e10cSrcweir         return;
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     SwFrm* pFrm = pLower;
348cdf0e10cSrcweir     while ( pFrm )
349cdf0e10cSrcweir     {
350cdf0e10cSrcweir         while ( pFrm->GetDrawObjs() && pFrm->GetDrawObjs()->Count() )
351cdf0e10cSrcweir         {
352cdf0e10cSrcweir             SwAnchoredObject *pAnchoredObj = (*pFrm->GetDrawObjs())[0];
353cdf0e10cSrcweir             if ( pAnchoredObj->ISA(SwFlyFrm) )
354cdf0e10cSrcweir                 delete pAnchoredObj;
355cdf0e10cSrcweir             else if ( pAnchoredObj->ISA(SwAnchoredDrawObject) )
356cdf0e10cSrcweir             {
357cdf0e10cSrcweir                 // OD 23.06.2003 #108784# - consider 'virtual' drawing objects
358cdf0e10cSrcweir                 SdrObject* pObj = pAnchoredObj->DrawObj();
359cdf0e10cSrcweir                 if ( pObj->ISA(SwDrawVirtObj) )
360cdf0e10cSrcweir                 {
361cdf0e10cSrcweir                     SwDrawVirtObj* pDrawVirtObj = static_cast<SwDrawVirtObj*>(pObj);
362cdf0e10cSrcweir                     pDrawVirtObj->RemoveFromWriterLayout();
363cdf0e10cSrcweir                     pDrawVirtObj->RemoveFromDrawingPage();
364cdf0e10cSrcweir                 }
365cdf0e10cSrcweir                 else
366cdf0e10cSrcweir                 {
367cdf0e10cSrcweir                     SwDrawContact* pContact =
368cdf0e10cSrcweir                             static_cast<SwDrawContact*>(::GetUserCall( pObj ));
369cdf0e10cSrcweir                     if ( pContact )
370cdf0e10cSrcweir                     {
371cdf0e10cSrcweir                         pContact->DisconnectFromLayout();
372cdf0e10cSrcweir                     }
373cdf0e10cSrcweir                 }
374cdf0e10cSrcweir             }
375cdf0e10cSrcweir         }
376cdf0e10cSrcweir 
377cdf0e10cSrcweir         pFrm->Remove();
378cdf0e10cSrcweir         delete pFrm;
379cdf0e10cSrcweir         pFrm = pLower;
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir 
382cdf0e10cSrcweir     InvalidatePage();
383cdf0e10cSrcweir }
384cdf0e10cSrcweir 
385cdf0e10cSrcweir /*************************************************************************
386cdf0e10cSrcweir |*
387cdf0e10cSrcweir |*	SwFlyFrm::InitDrawObj()
388cdf0e10cSrcweir |*
389cdf0e10cSrcweir |*	Ersterstellung		MA 02. Dec. 94
390cdf0e10cSrcweir |*	Letzte Aenderung	MA 30. Nov. 95
391cdf0e10cSrcweir |*
392cdf0e10cSrcweir |*************************************************************************/
393cdf0e10cSrcweir 
_GetOrdNumForNewRef(const SwFlyDrawContact * pContact)394cdf0e10cSrcweir sal_uInt32 SwFlyFrm::_GetOrdNumForNewRef( const SwFlyDrawContact* pContact )
395cdf0e10cSrcweir {
396cdf0e10cSrcweir     sal_uInt32 nOrdNum( 0L );
397cdf0e10cSrcweir 
398cdf0e10cSrcweir     // search for another Writer fly frame registered at same frame format
399cdf0e10cSrcweir     SwIterator<SwFlyFrm,SwFmt> aIter( *pContact->GetFmt() );
400cdf0e10cSrcweir     const SwFlyFrm* pFlyFrm( 0L );
401cdf0e10cSrcweir     for ( pFlyFrm = aIter.First(); pFlyFrm; pFlyFrm = aIter.Next() )
402cdf0e10cSrcweir     {
403cdf0e10cSrcweir         if ( pFlyFrm != this )
404cdf0e10cSrcweir         {
405cdf0e10cSrcweir             break;
406cdf0e10cSrcweir         }
407cdf0e10cSrcweir     }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir     if ( pFlyFrm )
410cdf0e10cSrcweir     {
411cdf0e10cSrcweir         // another Writer fly frame found. Take its order number
412cdf0e10cSrcweir         nOrdNum = pFlyFrm->GetVirtDrawObj()->GetOrdNum();
413cdf0e10cSrcweir     }
414cdf0e10cSrcweir     else
415cdf0e10cSrcweir     {
416cdf0e10cSrcweir         // no other Writer fly frame found. Take order number of 'master' object
417cdf0e10cSrcweir         // --> OD 2004-11-11 #i35748# - use method <GetOrdNumDirect()> instead
418cdf0e10cSrcweir         // of method <GetOrdNum()> to avoid a recalculation of the order number,
419cdf0e10cSrcweir         // which isn't intended.
420cdf0e10cSrcweir         nOrdNum = pContact->GetMaster()->GetOrdNumDirect();
421cdf0e10cSrcweir         // <--
422cdf0e10cSrcweir     }
423cdf0e10cSrcweir 
424cdf0e10cSrcweir     return nOrdNum;
425cdf0e10cSrcweir }
426cdf0e10cSrcweir 
CreateNewRef(SwFlyDrawContact * pContact)427cdf0e10cSrcweir SwVirtFlyDrawObj* SwFlyFrm::CreateNewRef( SwFlyDrawContact *pContact )
428cdf0e10cSrcweir {
429cdf0e10cSrcweir 	SwVirtFlyDrawObj *pDrawObj = new SwVirtFlyDrawObj( *pContact->GetMaster(), this );
430cdf0e10cSrcweir 	pDrawObj->SetModel( pContact->GetMaster()->GetModel() );
431cdf0e10cSrcweir 	pDrawObj->SetUserCall( pContact );
432cdf0e10cSrcweir 
433cdf0e10cSrcweir     //Der Reader erzeugt die Master und setzt diese, um die Z-Order zu
434cdf0e10cSrcweir 	//transportieren, in die Page ein. Beim erzeugen der ersten Referenz werden
435cdf0e10cSrcweir 	//die Master aus der Liste entfernt und fuehren von da an ein
436cdf0e10cSrcweir 	//Schattendasein.
437cdf0e10cSrcweir     SdrPage* pPg( 0L );
438cdf0e10cSrcweir 	if ( 0 != ( pPg = pContact->GetMaster()->GetPage() ) )
439cdf0e10cSrcweir 	{
440cdf0e10cSrcweir 		const sal_uInt32 nOrdNum = pContact->GetMaster()->GetOrdNum();
441cdf0e10cSrcweir 		pPg->ReplaceObject( pDrawObj, nOrdNum );
442cdf0e10cSrcweir 	}
443cdf0e10cSrcweir     // --> OD 2004-08-16 #i27030# - insert new <SwVirtFlyDrawObj> instance
444cdf0e10cSrcweir     // into drawing page with correct order number
445cdf0e10cSrcweir     else
446cdf0e10cSrcweir     {
447cdf0e10cSrcweir         pContact->GetFmt()->getIDocumentDrawModelAccess()->GetDrawModel()->GetPage( 0 )->
448cdf0e10cSrcweir                         InsertObject( pDrawObj, _GetOrdNumForNewRef( pContact ) );
449cdf0e10cSrcweir     }
450cdf0e10cSrcweir     // <--
451cdf0e10cSrcweir     // --> OD 2004-12-13 #i38889# - assure, that new <SwVirtFlyDrawObj> instance
452cdf0e10cSrcweir     // is in a visible layer.
453cdf0e10cSrcweir     pContact->MoveObjToVisibleLayer( pDrawObj );
454cdf0e10cSrcweir     // <--
455cdf0e10cSrcweir     return pDrawObj;
456cdf0e10cSrcweir }
457cdf0e10cSrcweir 
458cdf0e10cSrcweir 
459cdf0e10cSrcweir 
InitDrawObj(sal_Bool bNotify)460cdf0e10cSrcweir void SwFlyFrm::InitDrawObj( sal_Bool bNotify )
461cdf0e10cSrcweir {
462cdf0e10cSrcweir 	//ContactObject aus dem Format suchen. Wenn bereits eines existiert, so
463cdf0e10cSrcweir 	//braucht nur eine neue Ref erzeugt werden, anderfalls ist es jetzt an
464cdf0e10cSrcweir 	//der Zeit das Contact zu erzeugen.
465cdf0e10cSrcweir 
466cdf0e10cSrcweir     IDocumentDrawModelAccess* pIDDMA = GetFmt()->getIDocumentDrawModelAccess();
467cdf0e10cSrcweir 	SwFlyDrawContact *pContact = SwIterator<SwFlyDrawContact,SwFmt>::FirstElement( *GetFmt() );
468cdf0e10cSrcweir 	if ( !pContact )
469cdf0e10cSrcweir     {
470cdf0e10cSrcweir         // --> OD 2005-08-08 #i52858# - method name changed
471cdf0e10cSrcweir 		pContact = new SwFlyDrawContact( (SwFlyFrmFmt*)GetFmt(),
472cdf0e10cSrcweir                                           pIDDMA->GetOrCreateDrawModel() );
473cdf0e10cSrcweir         // <--
474cdf0e10cSrcweir     }
475cdf0e10cSrcweir 	ASSERT( pContact, "InitDrawObj failed" );
476cdf0e10cSrcweir     // OD 2004-03-22 #i26791#
477cdf0e10cSrcweir     SetDrawObj( *(CreateNewRef( pContact )) );
478cdf0e10cSrcweir 
479cdf0e10cSrcweir     //Den richtigen Layer setzen.
480cdf0e10cSrcweir     // OD 2004-01-19 #110582#
481cdf0e10cSrcweir     SdrLayerID nHeavenId = pIDDMA->GetHeavenId();
482cdf0e10cSrcweir     SdrLayerID nHellId = pIDDMA->GetHellId();
483cdf0e10cSrcweir     // OD 2004-03-22 #i26791#
484cdf0e10cSrcweir     GetVirtDrawObj()->SetLayer( GetFmt()->GetOpaque().GetValue()
485cdf0e10cSrcweir                                 ? nHeavenId
486cdf0e10cSrcweir                                 : nHellId );
487cdf0e10cSrcweir 	if ( bNotify )
488cdf0e10cSrcweir 		NotifyDrawObj();
489cdf0e10cSrcweir }
490cdf0e10cSrcweir 
491cdf0e10cSrcweir /*************************************************************************
492cdf0e10cSrcweir |*
493cdf0e10cSrcweir |*	SwFlyFrm::FinitDrawObj()
494cdf0e10cSrcweir |*
495cdf0e10cSrcweir |*	Ersterstellung		MA 12. Dec. 94
496cdf0e10cSrcweir |*	Letzte Aenderung	MA 15. May. 95
497cdf0e10cSrcweir |*
498cdf0e10cSrcweir |*************************************************************************/
499cdf0e10cSrcweir 
FinitDrawObj()500cdf0e10cSrcweir void SwFlyFrm::FinitDrawObj()
501cdf0e10cSrcweir {
502cdf0e10cSrcweir     if ( !GetVirtDrawObj() )
503cdf0e10cSrcweir 		return;
504cdf0e10cSrcweir 
505cdf0e10cSrcweir 	//Bei den SdrPageViews abmelden falls das Objekt dort noch selektiert ist.
506cdf0e10cSrcweir 	if ( !GetFmt()->GetDoc()->IsInDtor() )
507cdf0e10cSrcweir 	{
508cdf0e10cSrcweir 		ViewShell *p1St = getRootFrm()->GetCurrShell();
509cdf0e10cSrcweir 		if ( p1St )
510cdf0e10cSrcweir 		{
511cdf0e10cSrcweir 			ViewShell *pSh = p1St;
512cdf0e10cSrcweir 			do
513cdf0e10cSrcweir 			{	//z.Zt. kann das Drawing nur ein Unmark auf alles, weil das
514cdf0e10cSrcweir 				//Objekt bereits Removed wurde.
515cdf0e10cSrcweir 				if( pSh->HasDrawView() )
516cdf0e10cSrcweir 					pSh->Imp()->GetDrawView()->UnmarkAll();
517cdf0e10cSrcweir 				pSh = (ViewShell*)pSh->GetNext();
518cdf0e10cSrcweir 
519cdf0e10cSrcweir 			} while ( pSh != p1St );
520cdf0e10cSrcweir 		}
521cdf0e10cSrcweir 	}
522cdf0e10cSrcweir 
523cdf0e10cSrcweir 	//VirtObject mit in das Grab nehmen. Wenn das letzte VirObject
524cdf0e10cSrcweir 	//zerstoert wird, mussen das DrawObject und DrawContact ebenfalls
525cdf0e10cSrcweir 	//zerstoert werden.
526cdf0e10cSrcweir 	SwFlyDrawContact *pMyContact = 0;
527cdf0e10cSrcweir 	if ( GetFmt() )
528cdf0e10cSrcweir 	{
529cdf0e10cSrcweir         bool bContinue = true;
530cdf0e10cSrcweir         SwIterator<SwFrm,SwFmt> aFrmIter( *GetFmt() );
531cdf0e10cSrcweir         for ( SwFrm* pFrm = aFrmIter.First(); pFrm; pFrm = aFrmIter.Next() )
532cdf0e10cSrcweir             if ( pFrm != this )
533cdf0e10cSrcweir             {
534cdf0e10cSrcweir                 // don't delete Contact if there is still a Frm
535cdf0e10cSrcweir                 bContinue = false;
536cdf0e10cSrcweir                 break;
537cdf0e10cSrcweir             }
538cdf0e10cSrcweir 
539cdf0e10cSrcweir         if ( bContinue )
540cdf0e10cSrcweir             // no Frm left, find Contact object to destroy
541cdf0e10cSrcweir             pMyContact = SwIterator<SwFlyDrawContact,SwFmt>::FirstElement( *GetFmt() );
542cdf0e10cSrcweir 	}
543cdf0e10cSrcweir 
544cdf0e10cSrcweir     // OD, OS 2004-03-31 #116203# - clear user call of Writer fly frame 'master'
545cdf0e10cSrcweir     // <SdrObject> to assure, that a <SwXFrame::dispose()> doesn't delete the
546cdf0e10cSrcweir     // Writer fly frame again.
547cdf0e10cSrcweir     if ( pMyContact )
548cdf0e10cSrcweir     {
549cdf0e10cSrcweir         pMyContact->GetMaster()->SetUserCall( 0 );
550cdf0e10cSrcweir     }
551cdf0e10cSrcweir     GetVirtDrawObj()->SetUserCall( 0 ); //Ruft sonst Delete des ContactObj
552cdf0e10cSrcweir     delete GetVirtDrawObj();			//Meldet sich selbst beim Master ab.
553cdf0e10cSrcweir 	if ( pMyContact )
554cdf0e10cSrcweir 		delete pMyContact;		//zerstoert den Master selbst.
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir /*************************************************************************
558cdf0e10cSrcweir |*
559cdf0e10cSrcweir |*	SwFlyFrm::ChainFrames()
560cdf0e10cSrcweir |*
561cdf0e10cSrcweir |*	Ersterstellung		MA 29. Oct. 97
562cdf0e10cSrcweir |*	Letzte Aenderung	MA 20. Jan. 98
563cdf0e10cSrcweir |*
564cdf0e10cSrcweir |*************************************************************************/
565cdf0e10cSrcweir 
ChainFrames(SwFlyFrm * pMaster,SwFlyFrm * pFollow)566cdf0e10cSrcweir void SwFlyFrm::ChainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow )
567cdf0e10cSrcweir {
568cdf0e10cSrcweir 	ASSERT( pMaster && pFollow, "uncomplete chain" );
569cdf0e10cSrcweir 	ASSERT( !pMaster->GetNextLink(), "link can not be changed" );
570cdf0e10cSrcweir 	ASSERT( !pFollow->GetPrevLink(), "link can not be changed" );
571cdf0e10cSrcweir 
572cdf0e10cSrcweir 	pMaster->pNextLink = pFollow;
573cdf0e10cSrcweir 	pFollow->pPrevLink = pMaster;
574cdf0e10cSrcweir 
575cdf0e10cSrcweir 	if ( pMaster->ContainsCntnt() )
576cdf0e10cSrcweir 	{
577cdf0e10cSrcweir 		//Damit ggf. ein Textfluss zustande kommt muss invalidiert werden.
578cdf0e10cSrcweir 		SwFrm *pInva = pMaster->FindLastLower();
579cdf0e10cSrcweir         SWRECTFN( pMaster )
580cdf0e10cSrcweir         const long nBottom = (pMaster->*fnRect->fnGetPrtBottom)();
581cdf0e10cSrcweir 		while ( pInva )
582cdf0e10cSrcweir 		{
583cdf0e10cSrcweir             if( (pInva->Frm().*fnRect->fnBottomDist)( nBottom ) <= 0 )
584cdf0e10cSrcweir 			{
585cdf0e10cSrcweir 				pInva->InvalidateSize();
586cdf0e10cSrcweir 				pInva->Prepare( PREP_CLEAR );
587cdf0e10cSrcweir 				pInva = pInva->FindPrev();
588cdf0e10cSrcweir 			}
589cdf0e10cSrcweir 			else
590cdf0e10cSrcweir 				pInva = 0;
591cdf0e10cSrcweir 		}
592cdf0e10cSrcweir 	}
593cdf0e10cSrcweir 
594cdf0e10cSrcweir 	if ( pFollow->ContainsCntnt() )
595cdf0e10cSrcweir 	{
596cdf0e10cSrcweir 		//Es gibt nur noch den Inhalt des Masters, der Inhalt vom Follow
597cdf0e10cSrcweir 		//hat keine Frames mehr (sollte immer nur genau ein leerer TxtNode sein).
598cdf0e10cSrcweir 		SwFrm *pFrm = pFollow->ContainsCntnt();
599cdf0e10cSrcweir 		ASSERT( !pFrm->IsTabFrm() && !pFrm->FindNext(), "follow in chain contains content" );
600cdf0e10cSrcweir 		pFrm->Cut();
601cdf0e10cSrcweir 		delete pFrm;
602cdf0e10cSrcweir 	}
603cdf0e10cSrcweir 
604cdf0e10cSrcweir     // invalidate accessible relation set (accessibility wrapper)
605cdf0e10cSrcweir     ViewShell* pSh = pMaster->getRootFrm()->GetCurrShell();
606cdf0e10cSrcweir     if( pSh )
607cdf0e10cSrcweir     {
608cdf0e10cSrcweir         SwRootFrm* pLayout = pMaster->getRootFrm();
609cdf0e10cSrcweir         if( pLayout && pLayout->IsAnyShellAccessible() )
610cdf0e10cSrcweir         pSh->Imp()->InvalidateAccessibleRelationSet( pMaster, pFollow );
611cdf0e10cSrcweir     }
612cdf0e10cSrcweir }
613cdf0e10cSrcweir 
UnchainFrames(SwFlyFrm * pMaster,SwFlyFrm * pFollow)614cdf0e10cSrcweir void SwFlyFrm::UnchainFrames( SwFlyFrm *pMaster, SwFlyFrm *pFollow )
615cdf0e10cSrcweir {
616cdf0e10cSrcweir 	pMaster->pNextLink = 0;
617cdf0e10cSrcweir 	pFollow->pPrevLink = 0;
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 	if ( pFollow->ContainsCntnt() )
620cdf0e10cSrcweir 	{
621cdf0e10cSrcweir 		//Der Master saugt den Inhalt vom Follow auf
622cdf0e10cSrcweir 		SwLayoutFrm *pUpper = pMaster;
623cdf0e10cSrcweir 		if ( pUpper->Lower()->IsColumnFrm() )
624cdf0e10cSrcweir 		{
625cdf0e10cSrcweir             pUpper = static_cast<SwLayoutFrm*>(pUpper->GetLastLower());
626cdf0e10cSrcweir             pUpper = static_cast<SwLayoutFrm*>(pUpper->Lower()); // der (Column)BodyFrm
627cdf0e10cSrcweir 			ASSERT( pUpper && pUpper->IsColBodyFrm(), "Missing ColumnBody" );
628cdf0e10cSrcweir 		}
629cdf0e10cSrcweir 		SwFlyFrm *pFoll = pFollow;
630cdf0e10cSrcweir 		while ( pFoll )
631cdf0e10cSrcweir 		{
632cdf0e10cSrcweir 			SwFrm *pTmp = ::SaveCntnt( pFoll );
633cdf0e10cSrcweir 			if ( pTmp )
634cdf0e10cSrcweir                 ::RestoreCntnt( pTmp, pUpper, pMaster->FindLastLower(), true );
635cdf0e10cSrcweir             pFoll->SetCompletePaint();
636cdf0e10cSrcweir 			pFoll->InvalidateSize();
637cdf0e10cSrcweir 			pFoll = pFoll->GetNextLink();
638cdf0e10cSrcweir 		}
639cdf0e10cSrcweir 	}
640cdf0e10cSrcweir 
641cdf0e10cSrcweir 	//Der Follow muss mit seinem eigenen Inhalt versorgt werden.
642cdf0e10cSrcweir 	const SwFmtCntnt &rCntnt = pFollow->GetFmt()->GetCntnt();
643cdf0e10cSrcweir 	ASSERT( rCntnt.GetCntntIdx(), ":-( Kein Inhalt vorbereitet." );
644cdf0e10cSrcweir 	sal_uLong nIndex = rCntnt.GetCntntIdx()->GetIndex();
645cdf0e10cSrcweir 	// Lower() bedeutet SwColumnFrm, dieser beinhaltet wieder einen SwBodyFrm
646cdf0e10cSrcweir 	::_InsertCnt( pFollow->Lower() ? (SwLayoutFrm*)((SwLayoutFrm*)pFollow->Lower())->Lower()
647cdf0e10cSrcweir 								   : (SwLayoutFrm*)pFollow,
648cdf0e10cSrcweir 				  pFollow->GetFmt()->GetDoc(), ++nIndex );
649cdf0e10cSrcweir 
650cdf0e10cSrcweir     // invalidate accessible relation set (accessibility wrapper)
651cdf0e10cSrcweir     ViewShell* pSh = pMaster->getRootFrm()->GetCurrShell();
652cdf0e10cSrcweir     if( pSh )
653cdf0e10cSrcweir     {
654cdf0e10cSrcweir         SwRootFrm* pLayout = pMaster->getRootFrm();
655cdf0e10cSrcweir         if( pLayout && pLayout->IsAnyShellAccessible() )
656cdf0e10cSrcweir         pSh->Imp()->InvalidateAccessibleRelationSet( pMaster, pFollow );
657cdf0e10cSrcweir }
658cdf0e10cSrcweir }
659cdf0e10cSrcweir 
660cdf0e10cSrcweir /*************************************************************************
661cdf0e10cSrcweir |*
662cdf0e10cSrcweir |*	SwFlyFrm::FindChainNeighbour()
663cdf0e10cSrcweir |*
664cdf0e10cSrcweir |*	Ersterstellung		MA 11. Nov. 97
665cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Apr. 99
666cdf0e10cSrcweir |*
667cdf0e10cSrcweir |*************************************************************************/
668cdf0e10cSrcweir 
FindChainNeighbour(SwFrmFmt & rChain,SwFrm * pAnch)669cdf0e10cSrcweir SwFlyFrm *SwFlyFrm::FindChainNeighbour( SwFrmFmt &rChain, SwFrm *pAnch )
670cdf0e10cSrcweir {
671cdf0e10cSrcweir 	//Wir suchen denjenigen Fly, der in dem selben Bereich steht.
672cdf0e10cSrcweir 	//Bereiche koennen zunaechst nur Kopf-/Fusszeilen oder Flys sein.
673cdf0e10cSrcweir 
674cdf0e10cSrcweir 	if ( !pAnch )			//Wenn ein Anchor uebergeben Wurde zaehlt dieser: Ctor!
675cdf0e10cSrcweir         pAnch = AnchorFrm();
676cdf0e10cSrcweir 
677cdf0e10cSrcweir 	SwLayoutFrm *pLay;
678cdf0e10cSrcweir 	if ( pAnch->IsInFly() )
679cdf0e10cSrcweir 		pLay = pAnch->FindFlyFrm();
680cdf0e10cSrcweir 	else
681cdf0e10cSrcweir 	{
682cdf0e10cSrcweir 		//FindFooterOrHeader taugt hier nicht, weil evtl. noch keine Verbindung
683cdf0e10cSrcweir 		//zum Anker besteht.
684cdf0e10cSrcweir 		pLay = pAnch->GetUpper();
685cdf0e10cSrcweir 		while ( pLay && !(pLay->GetType() & (FRM_HEADER|FRM_FOOTER)) )
686cdf0e10cSrcweir 			pLay = pLay->GetUpper();
687cdf0e10cSrcweir 	}
688cdf0e10cSrcweir 
689cdf0e10cSrcweir 	SwIterator<SwFlyFrm,SwFmt> aIter( rChain );
690cdf0e10cSrcweir 	SwFlyFrm *pFly = aIter.First();
691cdf0e10cSrcweir 	if ( pLay )
692cdf0e10cSrcweir 	{
693cdf0e10cSrcweir 		while ( pFly )
694cdf0e10cSrcweir 		{
695cdf0e10cSrcweir             if ( pFly->GetAnchorFrm() )
696cdf0e10cSrcweir 			{
697cdf0e10cSrcweir                 if ( pFly->GetAnchorFrm()->IsInFly() )
698cdf0e10cSrcweir 				{
699cdf0e10cSrcweir                     if ( pFly->AnchorFrm()->FindFlyFrm() == pLay )
700cdf0e10cSrcweir 						break;
701cdf0e10cSrcweir 				}
702cdf0e10cSrcweir 				else if ( pLay == pFly->FindFooterOrHeader() )
703cdf0e10cSrcweir 					break;
704cdf0e10cSrcweir 			}
705cdf0e10cSrcweir 			pFly = aIter.Next();
706cdf0e10cSrcweir 		}
707cdf0e10cSrcweir 	}
708cdf0e10cSrcweir 	else if ( pFly )
709cdf0e10cSrcweir 	{
710cdf0e10cSrcweir 		ASSERT( !aIter.Next(), "chain with more than one inkarnation" );
711cdf0e10cSrcweir 	}
712cdf0e10cSrcweir 	return pFly;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir 
715cdf0e10cSrcweir 
716cdf0e10cSrcweir /*************************************************************************
717cdf0e10cSrcweir |*
718cdf0e10cSrcweir |*	SwFlyFrm::FindLastLower()
719cdf0e10cSrcweir |*
720cdf0e10cSrcweir |*	Ersterstellung		MA 29. Oct. 97
721cdf0e10cSrcweir |*	Letzte Aenderung	MA 29. Oct. 97
722cdf0e10cSrcweir |*
723cdf0e10cSrcweir |*************************************************************************/
724cdf0e10cSrcweir 
FindLastLower()725cdf0e10cSrcweir SwFrm *SwFlyFrm::FindLastLower()
726cdf0e10cSrcweir {
727cdf0e10cSrcweir 	SwFrm *pRet = ContainsAny();
728cdf0e10cSrcweir 	if ( pRet && pRet->IsInTab() )
729cdf0e10cSrcweir 		pRet = pRet->FindTabFrm();
730cdf0e10cSrcweir 	SwFrm *pNxt = pRet;
731cdf0e10cSrcweir 	while ( pNxt && IsAnLower( pNxt ) )
732cdf0e10cSrcweir 	{	pRet = pNxt;
733cdf0e10cSrcweir 		pNxt = pNxt->FindNext();
734cdf0e10cSrcweir 	}
735cdf0e10cSrcweir 	return pRet;
736cdf0e10cSrcweir }
737cdf0e10cSrcweir 
738cdf0e10cSrcweir 
739cdf0e10cSrcweir /*************************************************************************
740cdf0e10cSrcweir |*
741cdf0e10cSrcweir |*	SwFlyFrm::FrmSizeChg()
742cdf0e10cSrcweir |*
743cdf0e10cSrcweir |*	Ersterstellung		MA 17. Dec. 92
744cdf0e10cSrcweir |*	Letzte Aenderung	MA 24. Jul. 96
745cdf0e10cSrcweir |*
746cdf0e10cSrcweir |*************************************************************************/
747cdf0e10cSrcweir 
FrmSizeChg(const SwFmtFrmSize & rFrmSize)748cdf0e10cSrcweir sal_Bool SwFlyFrm::FrmSizeChg( const SwFmtFrmSize &rFrmSize )
749cdf0e10cSrcweir {
750cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
751cdf0e10cSrcweir 	SwTwips nDiffHeight = Frm().Height();
752cdf0e10cSrcweir     if ( rFrmSize.GetHeightSizeType() == ATT_VAR_SIZE )
753cdf0e10cSrcweir         bFixSize = bMinHeight = sal_False;
754cdf0e10cSrcweir 	else
755cdf0e10cSrcweir 	{
756cdf0e10cSrcweir         if ( rFrmSize.GetHeightSizeType() == ATT_FIX_SIZE )
757cdf0e10cSrcweir         {
758cdf0e10cSrcweir             bFixSize = sal_True;
759cdf0e10cSrcweir 			bMinHeight = sal_False;
760cdf0e10cSrcweir 		}
761cdf0e10cSrcweir         else if ( rFrmSize.GetHeightSizeType() == ATT_MIN_SIZE )
762cdf0e10cSrcweir         {
763cdf0e10cSrcweir             bFixSize = sal_False;
764cdf0e10cSrcweir 			bMinHeight = sal_True;
765cdf0e10cSrcweir 		}
766cdf0e10cSrcweir 		nDiffHeight -= rFrmSize.GetHeight();
767cdf0e10cSrcweir 	}
768cdf0e10cSrcweir 	//Wenn der Fly Spalten enthaehlt muessen der Fly und
769cdf0e10cSrcweir 	//die Spalten schon einmal auf die Wunschwerte gebracht
770cdf0e10cSrcweir 	//werden, sonst haben wir ein kleines Problem.
771cdf0e10cSrcweir 	if ( Lower() )
772cdf0e10cSrcweir 	{
773cdf0e10cSrcweir 		if ( Lower()->IsColumnFrm() )
774cdf0e10cSrcweir 		{
775cdf0e10cSrcweir             const SwRect aOld( GetObjRectWithSpaces() );
776cdf0e10cSrcweir 			const Size	 aOldSz( Prt().SSize() );
777cdf0e10cSrcweir 			const SwTwips nDiffWidth = Frm().Width() - rFrmSize.GetWidth();
778cdf0e10cSrcweir 			aFrm.Height( aFrm.Height() - nDiffHeight );
779cdf0e10cSrcweir 			aFrm.Width ( aFrm.Width()  - nDiffWidth  );
780cdf0e10cSrcweir             // --> OD 2006-08-16 #i68520#
781cdf0e10cSrcweir             InvalidateObjRectWithSpaces();
782cdf0e10cSrcweir             // <--
783cdf0e10cSrcweir 			aPrt.Height( aPrt.Height() - nDiffHeight );
784cdf0e10cSrcweir 			aPrt.Width ( aPrt.Width()  - nDiffWidth  );
785cdf0e10cSrcweir 			ChgLowersProp( aOldSz );
786cdf0e10cSrcweir 			::Notify( this, FindPageFrm(), aOld );
787cdf0e10cSrcweir 			bValidPos = sal_False;
788cdf0e10cSrcweir 			bRet = sal_True;
789cdf0e10cSrcweir 		}
790cdf0e10cSrcweir 		else if ( Lower()->IsNoTxtFrm() )
791cdf0e10cSrcweir 		{
792cdf0e10cSrcweir             bFixSize = sal_True;
793cdf0e10cSrcweir 			bMinHeight = sal_False;
794cdf0e10cSrcweir 		}
795cdf0e10cSrcweir 	}
796cdf0e10cSrcweir 	return bRet;
797cdf0e10cSrcweir }
798cdf0e10cSrcweir 
799cdf0e10cSrcweir /*************************************************************************
800cdf0e10cSrcweir |*
801cdf0e10cSrcweir |*	SwFlyFrm::Modify()
802cdf0e10cSrcweir |*
803cdf0e10cSrcweir |*	Ersterstellung		MA 17. Dec. 92
804cdf0e10cSrcweir |*	Letzte Aenderung	MA 17. Jan. 97
805cdf0e10cSrcweir |*
806cdf0e10cSrcweir |*************************************************************************/
807cdf0e10cSrcweir 
Modify(const SfxPoolItem * pOld,const SfxPoolItem * pNew)808cdf0e10cSrcweir void SwFlyFrm::Modify( const SfxPoolItem* pOld, const SfxPoolItem * pNew )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir 	sal_uInt8 nInvFlags = 0;
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 	if( pNew && RES_ATTRSET_CHG == pNew->Which() )
813cdf0e10cSrcweir 	{
814cdf0e10cSrcweir 		SfxItemIter aNIter( *((SwAttrSetChg*)pNew)->GetChgSet() );
815cdf0e10cSrcweir 		SfxItemIter aOIter( *((SwAttrSetChg*)pOld)->GetChgSet() );
816cdf0e10cSrcweir 		SwAttrSetChg aOldSet( *(SwAttrSetChg*)pOld );
817cdf0e10cSrcweir 		SwAttrSetChg aNewSet( *(SwAttrSetChg*)pNew );
818cdf0e10cSrcweir 		while( sal_True )
819cdf0e10cSrcweir 		{
820cdf0e10cSrcweir 			_UpdateAttr( (SfxPoolItem*)aOIter.GetCurItem(),
821cdf0e10cSrcweir 						 (SfxPoolItem*)aNIter.GetCurItem(), nInvFlags,
822cdf0e10cSrcweir 						 &aOldSet, &aNewSet );
823cdf0e10cSrcweir 			if( aNIter.IsAtEnd() )
824cdf0e10cSrcweir 				break;
825cdf0e10cSrcweir 			aNIter.NextItem();
826cdf0e10cSrcweir 			aOIter.NextItem();
827cdf0e10cSrcweir 		}
828cdf0e10cSrcweir 		if ( aOldSet.Count() || aNewSet.Count() )
829cdf0e10cSrcweir 			SwLayoutFrm::Modify( &aOldSet, &aNewSet );
830cdf0e10cSrcweir 	}
831cdf0e10cSrcweir 	else
832cdf0e10cSrcweir 		_UpdateAttr( pOld, pNew, nInvFlags );
833cdf0e10cSrcweir 
834cdf0e10cSrcweir 	if ( nInvFlags != 0 )
835cdf0e10cSrcweir 	{
836cdf0e10cSrcweir 		_Invalidate();
837cdf0e10cSrcweir 		if ( nInvFlags & 0x01 )
838cdf0e10cSrcweir         {
839cdf0e10cSrcweir 			_InvalidatePos();
840cdf0e10cSrcweir             // --> OD 2006-08-16 #i68520#
841cdf0e10cSrcweir             InvalidateObjRectWithSpaces();
842cdf0e10cSrcweir             // <--
843cdf0e10cSrcweir         }
844cdf0e10cSrcweir 		if ( nInvFlags & 0x02 )
845cdf0e10cSrcweir         {
846cdf0e10cSrcweir 			_InvalidateSize();
847cdf0e10cSrcweir             // --> OD 2006-08-16 #i68520#
848cdf0e10cSrcweir             InvalidateObjRectWithSpaces();
849cdf0e10cSrcweir             // <--
850cdf0e10cSrcweir         }
851cdf0e10cSrcweir         if ( nInvFlags & 0x04 )
852cdf0e10cSrcweir 			_InvalidatePrt();
853cdf0e10cSrcweir 		if ( nInvFlags & 0x08 )
854cdf0e10cSrcweir 			SetNotifyBack();
855cdf0e10cSrcweir 		if ( nInvFlags & 0x10 )
856cdf0e10cSrcweir 			SetCompletePaint();
857cdf0e10cSrcweir 		if ( ( nInvFlags & 0x40 ) && Lower() && Lower()->IsNoTxtFrm() )
858cdf0e10cSrcweir             ClrContourCache( GetVirtDrawObj() );
859cdf0e10cSrcweir 		SwRootFrm *pRoot;
860cdf0e10cSrcweir 		if ( nInvFlags & 0x20 && 0 != (pRoot = getRootFrm()) )
861cdf0e10cSrcweir 			pRoot->InvalidateBrowseWidth();
862cdf0e10cSrcweir         // --> OD 2004-06-28 #i28701#
863cdf0e10cSrcweir         if ( nInvFlags & 0x80 )
864cdf0e10cSrcweir         {
865cdf0e10cSrcweir             // update sorted object lists, the Writer fly frame is registered at.
866cdf0e10cSrcweir             UpdateObjInSortedList();
867cdf0e10cSrcweir         }
868cdf0e10cSrcweir         // <--
869cdf0e10cSrcweir         // --> OD #i87645# - reset flags for the layout process (only if something has been invalidated)
870cdf0e10cSrcweir         ResetLayoutProcessBools();
871cdf0e10cSrcweir         // <--
872cdf0e10cSrcweir 	}
873cdf0e10cSrcweir }
874cdf0e10cSrcweir 
_UpdateAttr(const SfxPoolItem * pOld,const SfxPoolItem * pNew,sal_uInt8 & rInvFlags,SwAttrSetChg * pOldSet,SwAttrSetChg * pNewSet)875cdf0e10cSrcweir void SwFlyFrm::_UpdateAttr( const SfxPoolItem *pOld, const SfxPoolItem *pNew,
876cdf0e10cSrcweir 							sal_uInt8 &rInvFlags,
877cdf0e10cSrcweir 							SwAttrSetChg *pOldSet, SwAttrSetChg *pNewSet )
878cdf0e10cSrcweir {
879cdf0e10cSrcweir 	sal_Bool bClear = sal_True;
880cdf0e10cSrcweir 	const sal_uInt16 nWhich = pOld ? pOld->Which() : pNew ? pNew->Which() : 0;
881cdf0e10cSrcweir 	ViewShell *pSh = getRootFrm()->GetCurrShell();
882cdf0e10cSrcweir 	switch( nWhich )
883cdf0e10cSrcweir 	{
884cdf0e10cSrcweir         case RES_VERT_ORIENT:
885cdf0e10cSrcweir 		case RES_HORI_ORIENT:
886cdf0e10cSrcweir         // OD 22.09.2003 #i18732# - consider new option 'follow text flow'
887cdf0e10cSrcweir         case RES_FOLLOW_TEXT_FLOW:
888cdf0e10cSrcweir         {
889cdf0e10cSrcweir             //Achtung! _immer_ Aktion in ChgRePos() mitpflegen.
890cdf0e10cSrcweir 			rInvFlags |= 0x09;
891cdf0e10cSrcweir         }
892cdf0e10cSrcweir         break;
893cdf0e10cSrcweir         // OD 2004-07-01 #i28701# - consider new option 'wrap influence on position'
894cdf0e10cSrcweir         case RES_WRAP_INFLUENCE_ON_OBJPOS:
895cdf0e10cSrcweir         {
896cdf0e10cSrcweir             rInvFlags |= 0x89;
897cdf0e10cSrcweir         }
898cdf0e10cSrcweir         break;
899cdf0e10cSrcweir         case RES_SURROUND:
900cdf0e10cSrcweir         {
901cdf0e10cSrcweir             // OD 2004-05-13 #i28701# - invalidate position on change of
902cdf0e10cSrcweir             // wrapping style.
903cdf0e10cSrcweir             //rInvFlags |= 0x40;
904cdf0e10cSrcweir             rInvFlags |= 0x41;
905cdf0e10cSrcweir 			//Der Hintergrund muss benachrichtigt und Invalidiert werden.
906cdf0e10cSrcweir             const SwRect aTmp( GetObjRectWithSpaces() );
907cdf0e10cSrcweir 			NotifyBackground( FindPageFrm(), aTmp, PREP_FLY_ATTR_CHG );
908cdf0e10cSrcweir 
909cdf0e10cSrcweir 			// Durch eine Umlaufaenderung von rahmengebundenen Rahmen kann eine
910cdf0e10cSrcweir 			// vertikale Ausrichtung aktiviert/deaktiviert werden => MakeFlyPos
911cdf0e10cSrcweir 			if( FLY_AT_FLY == GetFmt()->GetAnchor().GetAnchorId() )
912cdf0e10cSrcweir 				rInvFlags |= 0x09;
913cdf0e10cSrcweir 
914cdf0e10cSrcweir 			//Ggf. die Kontur am Node loeschen.
915cdf0e10cSrcweir 			if ( Lower() && Lower()->IsNoTxtFrm() &&
916cdf0e10cSrcweir 				 !GetFmt()->GetSurround().IsContour() )
917cdf0e10cSrcweir 			{
918cdf0e10cSrcweir 				SwNoTxtNode *pNd = (SwNoTxtNode*)((SwCntntFrm*)Lower())->GetNode();
919cdf0e10cSrcweir 				if ( pNd->HasContour() )
920cdf0e10cSrcweir 					pNd->SetContour( 0 );
921cdf0e10cSrcweir 			}
922cdf0e10cSrcweir             // --> OD 2004-06-28 #i28701# - perform reorder of object lists
923cdf0e10cSrcweir             // at anchor frame and at page frame.
924cdf0e10cSrcweir             rInvFlags |= 0x80;
925cdf0e10cSrcweir         }
926cdf0e10cSrcweir         break;
927cdf0e10cSrcweir 
928cdf0e10cSrcweir 		case RES_PROTECT:
929cdf0e10cSrcweir 			{
930cdf0e10cSrcweir 			const SvxProtectItem *pP = (SvxProtectItem*)pNew;
931cdf0e10cSrcweir             GetVirtDrawObj()->SetMoveProtect( pP->IsPosProtected()   );
932cdf0e10cSrcweir             GetVirtDrawObj()->SetResizeProtect( pP->IsSizeProtected() );
933cdf0e10cSrcweir             if( pSh )
934cdf0e10cSrcweir             {
935cdf0e10cSrcweir                 SwRootFrm* pLayout = getRootFrm();
936cdf0e10cSrcweir                 if( pLayout && pLayout->IsAnyShellAccessible() )
937cdf0e10cSrcweir 				pSh->Imp()->InvalidateAccessibleEditableState( sal_True, this );
938cdf0e10cSrcweir             }
939cdf0e10cSrcweir 			break;
940cdf0e10cSrcweir 			}
941cdf0e10cSrcweir 
942cdf0e10cSrcweir 		case RES_COL:
943cdf0e10cSrcweir 			{
944cdf0e10cSrcweir 				ChgColumns( *(const SwFmtCol*)pOld, *(const SwFmtCol*)pNew );
945cdf0e10cSrcweir 				const SwFmtFrmSize &rNew = GetFmt()->GetFrmSize();
946cdf0e10cSrcweir 				if ( FrmSizeChg( rNew ) )
947cdf0e10cSrcweir 					NotifyDrawObj();
948cdf0e10cSrcweir 				rInvFlags |= 0x1A;
949cdf0e10cSrcweir 				break;
950cdf0e10cSrcweir 			}
951cdf0e10cSrcweir 
952cdf0e10cSrcweir 		case RES_FRM_SIZE:
953cdf0e10cSrcweir 		case RES_FMT_CHG:
954cdf0e10cSrcweir 		{
955cdf0e10cSrcweir 			const SwFmtFrmSize &rNew = GetFmt()->GetFrmSize();
956cdf0e10cSrcweir 			if ( FrmSizeChg( rNew ) )
957cdf0e10cSrcweir 				NotifyDrawObj();
958cdf0e10cSrcweir 			rInvFlags |= 0x7F;
959cdf0e10cSrcweir 			if ( RES_FMT_CHG == nWhich )
960cdf0e10cSrcweir 			{
961cdf0e10cSrcweir                 SwRect aNew( GetObjRectWithSpaces() );
962cdf0e10cSrcweir 				SwRect aOld( aFrm );
963cdf0e10cSrcweir 				const SvxULSpaceItem &rUL = ((SwFmtChg*)pOld)->pChangedFmt->GetULSpace();
964cdf0e10cSrcweir 				aOld.Top( Max( aOld.Top() - long(rUL.GetUpper()), 0L ) );
965cdf0e10cSrcweir 				aOld.SSize().Height()+= rUL.GetLower();
966cdf0e10cSrcweir 				const SvxLRSpaceItem &rLR = ((SwFmtChg*)pOld)->pChangedFmt->GetLRSpace();
967cdf0e10cSrcweir 				aOld.Left  ( Max( aOld.Left() - long(rLR.GetLeft()), 0L ) );
968cdf0e10cSrcweir 				aOld.SSize().Width() += rLR.GetRight();
969cdf0e10cSrcweir 				aNew.Union( aOld );
970cdf0e10cSrcweir 				NotifyBackground( FindPageFrm(), aNew, PREP_CLEAR );
971cdf0e10cSrcweir 
972cdf0e10cSrcweir 				//Dummer Fall. Bei der Zusweisung einer Vorlage k?nnen wir uns
973cdf0e10cSrcweir 				//nicht auf das alte Spaltenattribut verlassen. Da diese
974cdf0e10cSrcweir 				//wenigstens anzahlgemass fuer ChgColumns vorliegen muessen,
975cdf0e10cSrcweir 				//bleibt uns nur einen temporaeres Attribut zu basteln.
976cdf0e10cSrcweir 				SwFmtCol aCol;
977cdf0e10cSrcweir 				if ( Lower() && Lower()->IsColumnFrm() )
978cdf0e10cSrcweir 				{
979cdf0e10cSrcweir 					sal_uInt16 nCol = 0;
980cdf0e10cSrcweir 					SwFrm *pTmp = Lower();
981cdf0e10cSrcweir 					do
982cdf0e10cSrcweir 					{	++nCol;
983cdf0e10cSrcweir 						pTmp = pTmp->GetNext();
984cdf0e10cSrcweir 					} while ( pTmp );
985cdf0e10cSrcweir 					aCol.Init( nCol, 0, 1000 );
986cdf0e10cSrcweir 				}
987cdf0e10cSrcweir 				ChgColumns( aCol, GetFmt()->GetCol() );
988cdf0e10cSrcweir 			}
989cdf0e10cSrcweir 
990cdf0e10cSrcweir 			SwFmtURL aURL( GetFmt()->GetURL() );
991cdf0e10cSrcweir 			if ( aURL.GetMap() )
992cdf0e10cSrcweir 			{
993cdf0e10cSrcweir 				const SwFmtFrmSize &rOld = nWhich == RES_FRM_SIZE ?
994cdf0e10cSrcweir 								*(SwFmtFrmSize*)pNew :
995cdf0e10cSrcweir 								((SwFmtChg*)pOld)->pChangedFmt->GetFrmSize();
996cdf0e10cSrcweir 				//#35091# Kann beim Laden von Vorlagen mal 0 sein
997cdf0e10cSrcweir 				if ( rOld.GetWidth() && rOld.GetHeight() )
998cdf0e10cSrcweir 				{
999cdf0e10cSrcweir 
1000cdf0e10cSrcweir 					Fraction aScaleX( rOld.GetWidth(), rNew.GetWidth() );
1001cdf0e10cSrcweir 					Fraction aScaleY( rOld.GetHeight(), rOld.GetHeight() );
1002cdf0e10cSrcweir 					aURL.GetMap()->Scale( aScaleX, aScaleY );
1003cdf0e10cSrcweir 					SwFrmFmt *pFmt = GetFmt();
1004cdf0e10cSrcweir 					pFmt->LockModify();
1005cdf0e10cSrcweir                     pFmt->SetFmtAttr( aURL );
1006cdf0e10cSrcweir 					pFmt->UnlockModify();
1007cdf0e10cSrcweir 				}
1008cdf0e10cSrcweir 			}
1009cdf0e10cSrcweir 			const SvxProtectItem &rP = GetFmt()->GetProtect();
1010cdf0e10cSrcweir             GetVirtDrawObj()->SetMoveProtect( rP.IsPosProtected()    );
1011cdf0e10cSrcweir             GetVirtDrawObj()->SetResizeProtect( rP.IsSizeProtected() );
1012cdf0e10cSrcweir 
1013cdf0e10cSrcweir 			if ( pSh )
1014cdf0e10cSrcweir 				pSh->InvalidateWindows( Frm() );
1015cdf0e10cSrcweir             const IDocumentDrawModelAccess* pIDDMA = GetFmt()->getIDocumentDrawModelAccess();
1016cdf0e10cSrcweir 			const sal_uInt8 nId = GetFmt()->GetOpaque().GetValue() ?
1017cdf0e10cSrcweir                              pIDDMA->GetHeavenId() :
1018cdf0e10cSrcweir                              pIDDMA->GetHellId();
1019cdf0e10cSrcweir             GetVirtDrawObj()->SetLayer( nId );
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir 			if ( Lower() )
1022cdf0e10cSrcweir 			{
1023cdf0e10cSrcweir 				//Ggf. die Kontur am Node loeschen.
1024cdf0e10cSrcweir 				if( Lower()->IsNoTxtFrm() &&
1025cdf0e10cSrcweir 					 !GetFmt()->GetSurround().IsContour() )
1026cdf0e10cSrcweir 				{
1027cdf0e10cSrcweir 					SwNoTxtNode *pNd = (SwNoTxtNode*)((SwCntntFrm*)Lower())->GetNode();
1028cdf0e10cSrcweir 					if ( pNd->HasContour() )
1029cdf0e10cSrcweir 						pNd->SetContour( 0 );
1030cdf0e10cSrcweir 				}
1031cdf0e10cSrcweir 				else if( !Lower()->IsColumnFrm() )
1032cdf0e10cSrcweir 				{
1033cdf0e10cSrcweir                     SwFrm* pFrm = GetLastLower();
1034cdf0e10cSrcweir                     if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
1035cdf0e10cSrcweir 						pFrm->Prepare( PREP_ADJUST_FRM );
1036cdf0e10cSrcweir 				}
1037cdf0e10cSrcweir 			}
1038cdf0e10cSrcweir 
1039cdf0e10cSrcweir             // --> OD 2004-06-28 #i28701# - perform reorder of object lists
1040cdf0e10cSrcweir             // at anchor frame and at page frame.
1041cdf0e10cSrcweir             rInvFlags |= 0x80;
1042cdf0e10cSrcweir 
1043cdf0e10cSrcweir             break;
1044cdf0e10cSrcweir 		}
1045cdf0e10cSrcweir 		case RES_UL_SPACE:
1046cdf0e10cSrcweir 		case RES_LR_SPACE:
1047cdf0e10cSrcweir         {
1048cdf0e10cSrcweir             rInvFlags |= 0x41;
1049cdf0e10cSrcweir             if( pSh && pSh->GetViewOptions()->getBrowseMode() )
1050cdf0e10cSrcweir 				getRootFrm()->InvalidateBrowseWidth();
1051cdf0e10cSrcweir             SwRect aNew( GetObjRectWithSpaces() );
1052cdf0e10cSrcweir 			SwRect aOld( aFrm );
1053cdf0e10cSrcweir 			if ( RES_UL_SPACE == nWhich )
1054cdf0e10cSrcweir 			{
1055cdf0e10cSrcweir 				const SvxULSpaceItem &rUL = *(SvxULSpaceItem*)pNew;
1056cdf0e10cSrcweir 				aOld.Top( Max( aOld.Top() - long(rUL.GetUpper()), 0L ) );
1057cdf0e10cSrcweir 				aOld.SSize().Height()+= rUL.GetLower();
1058cdf0e10cSrcweir 			}
1059cdf0e10cSrcweir 			else
1060cdf0e10cSrcweir 			{
1061cdf0e10cSrcweir 				const SvxLRSpaceItem &rLR = *(SvxLRSpaceItem*)pNew;
1062cdf0e10cSrcweir 				aOld.Left  ( Max( aOld.Left() - long(rLR.GetLeft()), 0L ) );
1063cdf0e10cSrcweir 				aOld.SSize().Width() += rLR.GetRight();
1064cdf0e10cSrcweir 			}
1065cdf0e10cSrcweir 			aNew.Union( aOld );
1066cdf0e10cSrcweir 			NotifyBackground( FindPageFrm(), aNew, PREP_CLEAR );
1067cdf0e10cSrcweir         }
1068cdf0e10cSrcweir         break;
1069cdf0e10cSrcweir 
1070cdf0e10cSrcweir 		case RES_BOX:
1071cdf0e10cSrcweir 		case RES_SHADOW:
1072cdf0e10cSrcweir 			rInvFlags |= 0x17;
1073cdf0e10cSrcweir 			break;
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir         case RES_FRAMEDIR :
1076cdf0e10cSrcweir             SetDerivedVert( sal_False );
1077cdf0e10cSrcweir             SetDerivedR2L( sal_False );
1078cdf0e10cSrcweir             CheckDirChange();
1079cdf0e10cSrcweir             break;
1080cdf0e10cSrcweir 
1081cdf0e10cSrcweir         case RES_OPAQUE:
1082cdf0e10cSrcweir             {
1083cdf0e10cSrcweir                 if ( pSh )
1084cdf0e10cSrcweir                     pSh->InvalidateWindows( Frm() );
1085cdf0e10cSrcweir 
1086cdf0e10cSrcweir                 const IDocumentDrawModelAccess* pIDDMA = GetFmt()->getIDocumentDrawModelAccess();
1087cdf0e10cSrcweir                 const sal_uInt8 nId = ((SvxOpaqueItem*)pNew)->GetValue() ?
1088cdf0e10cSrcweir                                     pIDDMA->GetHeavenId() :
1089cdf0e10cSrcweir                                     pIDDMA->GetHellId();
1090cdf0e10cSrcweir                 GetVirtDrawObj()->SetLayer( nId );
1091cdf0e10cSrcweir                 if( pSh )
1092cdf0e10cSrcweir                 {
1093cdf0e10cSrcweir                     SwRootFrm* pLayout = getRootFrm();
1094cdf0e10cSrcweir                     if( pLayout && pLayout->IsAnyShellAccessible() )
1095cdf0e10cSrcweir                 {
1096cdf0e10cSrcweir                     pSh->Imp()->DisposeAccessibleFrm( this );
1097cdf0e10cSrcweir                     pSh->Imp()->AddAccessibleFrm( this );
1098cdf0e10cSrcweir                 }
1099cdf0e10cSrcweir                 }
1100cdf0e10cSrcweir                 // --> OD 2004-06-28 #i28701# - perform reorder of object lists
1101cdf0e10cSrcweir                 // at anchor frame and at page frame.
1102cdf0e10cSrcweir                 rInvFlags |= 0x80;
1103cdf0e10cSrcweir             }
1104cdf0e10cSrcweir 			break;
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir 		case RES_URL:
1107cdf0e10cSrcweir 			//Das Interface arbeitet bei Textrahmen auf der Rahmengroesse,
1108cdf0e10cSrcweir 			//die Map muss sich aber auf die FrmSize beziehen
1109cdf0e10cSrcweir 			if ( (!Lower() || !Lower()->IsNoTxtFrm()) &&
1110cdf0e10cSrcweir 				 ((SwFmtURL*)pNew)->GetMap() && ((SwFmtURL*)pOld)->GetMap() )
1111cdf0e10cSrcweir 			{
1112cdf0e10cSrcweir 				const SwFmtFrmSize &rSz = GetFmt()->GetFrmSize();
1113cdf0e10cSrcweir 				if ( rSz.GetHeight() != Frm().Height() ||
1114cdf0e10cSrcweir 					 rSz.GetWidth()  != Frm().Width() )
1115cdf0e10cSrcweir 				{
1116cdf0e10cSrcweir 					SwFmtURL aURL( GetFmt()->GetURL() );
1117cdf0e10cSrcweir 					Fraction aScaleX( Frm().Width(),  rSz.GetWidth() );
1118cdf0e10cSrcweir 					Fraction aScaleY( Frm().Height(), rSz.GetHeight() );
1119cdf0e10cSrcweir 					aURL.GetMap()->Scale( aScaleX, aScaleY );
1120cdf0e10cSrcweir 					SwFrmFmt *pFmt = GetFmt();
1121cdf0e10cSrcweir 					pFmt->LockModify();
1122cdf0e10cSrcweir                     pFmt->SetFmtAttr( aURL );
1123cdf0e10cSrcweir 					pFmt->UnlockModify();
1124cdf0e10cSrcweir 				}
1125cdf0e10cSrcweir 			}
1126cdf0e10cSrcweir 			/* Keine Invalidierung notwendig */
1127cdf0e10cSrcweir 			break;
1128cdf0e10cSrcweir 
1129cdf0e10cSrcweir 		case RES_CHAIN:
1130cdf0e10cSrcweir 			{
1131cdf0e10cSrcweir 				SwFmtChain *pChain = (SwFmtChain*)pNew;
1132cdf0e10cSrcweir 				if ( pChain->GetNext() )
1133cdf0e10cSrcweir 				{
1134cdf0e10cSrcweir 					SwFlyFrm *pFollow = FindChainNeighbour( *pChain->GetNext() );
1135cdf0e10cSrcweir 					if ( GetNextLink() && pFollow != GetNextLink() )
1136cdf0e10cSrcweir 						SwFlyFrm::UnchainFrames( this, GetNextLink());
1137cdf0e10cSrcweir 					if ( pFollow )
1138cdf0e10cSrcweir 					{
1139cdf0e10cSrcweir 						if ( pFollow->GetPrevLink() &&
1140cdf0e10cSrcweir 							 pFollow->GetPrevLink() != this )
1141cdf0e10cSrcweir 							SwFlyFrm::UnchainFrames( pFollow->GetPrevLink(),
1142cdf0e10cSrcweir 													 pFollow );
1143cdf0e10cSrcweir 						if ( !GetNextLink() )
1144cdf0e10cSrcweir 							SwFlyFrm::ChainFrames( this, pFollow );
1145cdf0e10cSrcweir 					}
1146cdf0e10cSrcweir 				}
1147cdf0e10cSrcweir 				else if ( GetNextLink() )
1148cdf0e10cSrcweir 					SwFlyFrm::UnchainFrames( this, GetNextLink() );
1149cdf0e10cSrcweir 				if ( pChain->GetPrev() )
1150cdf0e10cSrcweir 				{
1151cdf0e10cSrcweir 					SwFlyFrm *pMaster = FindChainNeighbour( *pChain->GetPrev() );
1152cdf0e10cSrcweir 					if ( GetPrevLink() && pMaster != GetPrevLink() )
1153cdf0e10cSrcweir 						SwFlyFrm::UnchainFrames( GetPrevLink(), this );
1154cdf0e10cSrcweir 					if ( pMaster )
1155cdf0e10cSrcweir 					{
1156cdf0e10cSrcweir 						if ( pMaster->GetNextLink() &&
1157cdf0e10cSrcweir 							 pMaster->GetNextLink() != this )
1158cdf0e10cSrcweir 							SwFlyFrm::UnchainFrames( pMaster,
1159cdf0e10cSrcweir 													 pMaster->GetNextLink() );
1160cdf0e10cSrcweir 						if ( !GetPrevLink() )
1161cdf0e10cSrcweir 							SwFlyFrm::ChainFrames( pMaster, this );
1162cdf0e10cSrcweir 					}
1163cdf0e10cSrcweir 				}
1164cdf0e10cSrcweir 				else if ( GetPrevLink() )
1165cdf0e10cSrcweir 					SwFlyFrm::UnchainFrames( GetPrevLink(), this );
1166cdf0e10cSrcweir 			}
1167cdf0e10cSrcweir 
1168cdf0e10cSrcweir 		default:
1169cdf0e10cSrcweir 			bClear = sal_False;
1170cdf0e10cSrcweir 	}
1171cdf0e10cSrcweir 	if ( bClear )
1172cdf0e10cSrcweir 	{
1173cdf0e10cSrcweir 		if ( pOldSet || pNewSet )
1174cdf0e10cSrcweir 		{
1175cdf0e10cSrcweir 			if ( pOldSet )
1176cdf0e10cSrcweir 				pOldSet->ClearItem( nWhich );
1177cdf0e10cSrcweir 			if ( pNewSet )
1178cdf0e10cSrcweir 				pNewSet->ClearItem( nWhich );
1179cdf0e10cSrcweir 		}
1180cdf0e10cSrcweir 		else
1181cdf0e10cSrcweir 			SwLayoutFrm::Modify( pOld, pNew );
1182cdf0e10cSrcweir 	}
1183cdf0e10cSrcweir }
1184cdf0e10cSrcweir 
1185cdf0e10cSrcweir /*************************************************************************
1186cdf0e10cSrcweir |*
1187cdf0e10cSrcweir |*				  SwFlyFrm::GetInfo()
1188cdf0e10cSrcweir |*
1189cdf0e10cSrcweir |*	  Beschreibung		erfragt Informationen
1190cdf0e10cSrcweir |*	  Ersterstellung	JP 31.03.94
1191cdf0e10cSrcweir |*	  Letzte Aenderung	JP 31.03.94
1192cdf0e10cSrcweir |*
1193cdf0e10cSrcweir *************************************************************************/
1194cdf0e10cSrcweir 
1195cdf0e10cSrcweir 	// erfrage vom Modify Informationen
GetInfo(SfxPoolItem & rInfo) const1196cdf0e10cSrcweir sal_Bool SwFlyFrm::GetInfo( SfxPoolItem & rInfo ) const
1197cdf0e10cSrcweir {
1198cdf0e10cSrcweir 	if( RES_AUTOFMT_DOCNODE == rInfo.Which() )
1199cdf0e10cSrcweir 		return sal_False;	// es gibt einen FlyFrm also wird er benutzt
1200cdf0e10cSrcweir 	return sal_True;		// weiter suchen
1201cdf0e10cSrcweir }
1202cdf0e10cSrcweir 
1203cdf0e10cSrcweir /*************************************************************************
1204cdf0e10cSrcweir |*
1205cdf0e10cSrcweir |*	SwFlyFrm::_Invalidate()
1206cdf0e10cSrcweir |*
1207cdf0e10cSrcweir |*	Ersterstellung		MA 15. Oct. 92
1208cdf0e10cSrcweir |*	Letzte Aenderung	MA 26. Jun. 96
1209cdf0e10cSrcweir |*
1210cdf0e10cSrcweir |*************************************************************************/
1211cdf0e10cSrcweir 
_Invalidate(SwPageFrm * pPage)1212cdf0e10cSrcweir void SwFlyFrm::_Invalidate( SwPageFrm *pPage )
1213cdf0e10cSrcweir {
1214cdf0e10cSrcweir 	InvalidatePage( pPage );
1215cdf0e10cSrcweir 	bNotifyBack = bInvalid = sal_True;
1216cdf0e10cSrcweir 
1217cdf0e10cSrcweir 	SwFlyFrm *pFrm;
1218cdf0e10cSrcweir     if ( GetAnchorFrm() && 0 != (pFrm = AnchorFrm()->FindFlyFrm()) )
1219cdf0e10cSrcweir 	{
1220cdf0e10cSrcweir 		//Gaanz dumm: Wenn der Fly innerhalb eines Fly gebunden ist, der
1221cdf0e10cSrcweir 		//Spalten enthaehlt, sollte das Format von diesem ausgehen.
1222cdf0e10cSrcweir 		if ( !pFrm->IsLocked() && !pFrm->IsColLocked() &&
1223cdf0e10cSrcweir 			 pFrm->Lower() && pFrm->Lower()->IsColumnFrm() )
1224cdf0e10cSrcweir 			pFrm->InvalidateSize();
1225cdf0e10cSrcweir 	}
1226cdf0e10cSrcweir 
1227cdf0e10cSrcweir     // --> OD 2008-01-21 #i85216#
1228cdf0e10cSrcweir     // if vertical position is oriented at a layout frame inside a ghost section,
1229cdf0e10cSrcweir     // assure that the position is invalidated and that the information about
1230cdf0e10cSrcweir     // the vertical position oriented frame is cleared
1231cdf0e10cSrcweir     if ( GetVertPosOrientFrm() && GetVertPosOrientFrm()->IsLayoutFrm() )
1232cdf0e10cSrcweir     {
1233cdf0e10cSrcweir         const SwSectionFrm* pSectFrm( GetVertPosOrientFrm()->FindSctFrm() );
1234cdf0e10cSrcweir         if ( pSectFrm && pSectFrm->GetSection() == 0 )
1235cdf0e10cSrcweir         {
1236cdf0e10cSrcweir             InvalidatePos();
1237cdf0e10cSrcweir             ClearVertPosOrientFrm();
1238cdf0e10cSrcweir         }
1239cdf0e10cSrcweir     }
1240cdf0e10cSrcweir     // <--
1241cdf0e10cSrcweir }
1242cdf0e10cSrcweir 
1243cdf0e10cSrcweir /*************************************************************************
1244cdf0e10cSrcweir |*
1245cdf0e10cSrcweir |*	SwFlyFrm::ChgRelPos()
1246cdf0e10cSrcweir |*
1247cdf0e10cSrcweir |*	Beschreibung		Aenderung der relativen Position, die Position wird
1248cdf0e10cSrcweir |*		damit automatisch Fix, das Attribut wird entprechend angepasst.
1249cdf0e10cSrcweir |*	Ersterstellung		MA 25. Aug. 92
1250cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Aug. 95
1251cdf0e10cSrcweir |*
1252cdf0e10cSrcweir |*************************************************************************/
1253cdf0e10cSrcweir 
ChgRelPos(const Point & rNewPos)1254cdf0e10cSrcweir void SwFlyFrm::ChgRelPos( const Point &rNewPos )
1255cdf0e10cSrcweir {
1256cdf0e10cSrcweir     if ( GetCurrRelPos() != rNewPos )
1257cdf0e10cSrcweir 	{
1258cdf0e10cSrcweir 		SwFrmFmt *pFmt = GetFmt();
1259cdf0e10cSrcweir         const bool bVert = GetAnchorFrm()->IsVertical();
1260cdf0e10cSrcweir         const SwTwips nNewY = bVert ? rNewPos.X() : rNewPos.Y();
1261cdf0e10cSrcweir         SwTwips nTmpY = nNewY == LONG_MAX ? 0 : nNewY;
1262cdf0e10cSrcweir         if( bVert )
1263cdf0e10cSrcweir             nTmpY = -nTmpY;
1264cdf0e10cSrcweir 		SfxItemSet aSet( pFmt->GetDoc()->GetAttrPool(),
1265cdf0e10cSrcweir 						 RES_VERT_ORIENT, RES_HORI_ORIENT);
1266cdf0e10cSrcweir 
1267cdf0e10cSrcweir 		SwFmtVertOrient aVert( pFmt->GetVertOrient() );
1268cdf0e10cSrcweir 		SwTxtFrm *pAutoFrm = NULL;
1269cdf0e10cSrcweir         // --> OD 2004-11-12 #i34948# - handle also at-page and at-fly anchored
1270cdf0e10cSrcweir         // Writer fly frames
1271cdf0e10cSrcweir         const RndStdIds eAnchorType = GetFrmFmt().GetAnchor().GetAnchorId();
1272cdf0e10cSrcweir         if ( eAnchorType == FLY_AT_PAGE )
1273cdf0e10cSrcweir         {
1274cdf0e10cSrcweir             aVert.SetVertOrient( text::VertOrientation::NONE );
1275cdf0e10cSrcweir             aVert.SetRelationOrient( text::RelOrientation::PAGE_FRAME );
1276cdf0e10cSrcweir         }
1277cdf0e10cSrcweir         else if ( eAnchorType == FLY_AT_FLY )
1278cdf0e10cSrcweir         {
1279cdf0e10cSrcweir             aVert.SetVertOrient( text::VertOrientation::NONE );
1280cdf0e10cSrcweir             aVert.SetRelationOrient( text::RelOrientation::FRAME );
1281cdf0e10cSrcweir         }
1282cdf0e10cSrcweir         // <--
1283cdf0e10cSrcweir         else if ( IsFlyAtCntFrm() || text::VertOrientation::NONE != aVert.GetVertOrient() )
1284cdf0e10cSrcweir 		{
1285cdf0e10cSrcweir             if( text::RelOrientation::CHAR == aVert.GetRelationOrient() && IsAutoPos() )
1286cdf0e10cSrcweir 			{
1287cdf0e10cSrcweir                 if( LONG_MAX != nNewY )
1288cdf0e10cSrcweir 				{
1289cdf0e10cSrcweir                     aVert.SetVertOrient( text::VertOrientation::NONE );
1290cdf0e10cSrcweir 					xub_StrLen nOfs =
1291cdf0e10cSrcweir 						pFmt->GetAnchor().GetCntntAnchor()->nContent.GetIndex();
1292cdf0e10cSrcweir                     ASSERT( GetAnchorFrm()->IsTxtFrm(), "TxtFrm expected" );
1293cdf0e10cSrcweir                     pAutoFrm = (SwTxtFrm*)GetAnchorFrm();
1294cdf0e10cSrcweir 					while( pAutoFrm->GetFollow() &&
1295cdf0e10cSrcweir 						   pAutoFrm->GetFollow()->GetOfst() <= nOfs )
1296cdf0e10cSrcweir 					{
1297cdf0e10cSrcweir                         if( pAutoFrm == GetAnchorFrm() )
1298cdf0e10cSrcweir 							nTmpY += pAutoFrm->GetRelPos().Y();
1299cdf0e10cSrcweir 						nTmpY -= pAutoFrm->GetUpper()->Prt().Height();
1300cdf0e10cSrcweir 						pAutoFrm = pAutoFrm->GetFollow();
1301cdf0e10cSrcweir 					}
1302cdf0e10cSrcweir 					nTmpY = ((SwFlyAtCntFrm*)this)->GetRelCharY(pAutoFrm)-nTmpY;
1303cdf0e10cSrcweir 				}
1304cdf0e10cSrcweir 				else
1305cdf0e10cSrcweir                     aVert.SetVertOrient( text::VertOrientation::CHAR_BOTTOM );
1306cdf0e10cSrcweir 			}
1307cdf0e10cSrcweir 			else
1308cdf0e10cSrcweir 			{
1309cdf0e10cSrcweir                 aVert.SetVertOrient( text::VertOrientation::NONE );
1310cdf0e10cSrcweir                 aVert.SetRelationOrient( text::RelOrientation::FRAME );
1311cdf0e10cSrcweir 			}
1312cdf0e10cSrcweir 		}
1313cdf0e10cSrcweir 		aVert.SetPos( nTmpY );
1314cdf0e10cSrcweir 		aSet.Put( aVert );
1315cdf0e10cSrcweir 
1316cdf0e10cSrcweir         //Fuer Flys im Cnt ist die horizontale Ausrichtung uninteressant,
1317cdf0e10cSrcweir 		//den sie ist stets 0.
1318cdf0e10cSrcweir 		if ( !IsFlyInCntFrm() )
1319cdf0e10cSrcweir 		{
1320cdf0e10cSrcweir             const SwTwips nNewX = bVert ? rNewPos.Y() : rNewPos.X();
1321cdf0e10cSrcweir             SwTwips nTmpX = nNewX == LONG_MAX ? 0 : nNewX;
1322cdf0e10cSrcweir 			SwFmtHoriOrient aHori( pFmt->GetHoriOrient() );
1323cdf0e10cSrcweir             // --> OD 2004-11-12 #i34948# - handle also at-page and at-fly anchored
1324cdf0e10cSrcweir             // Writer fly frames
1325cdf0e10cSrcweir             if ( eAnchorType == FLY_AT_PAGE )
1326cdf0e10cSrcweir             {
1327cdf0e10cSrcweir                 aHori.SetHoriOrient( text::HoriOrientation::NONE );
1328cdf0e10cSrcweir                 aHori.SetRelationOrient( text::RelOrientation::PAGE_FRAME );
1329cdf0e10cSrcweir                 aHori.SetPosToggle( sal_False );
1330cdf0e10cSrcweir             }
1331cdf0e10cSrcweir             else if ( eAnchorType == FLY_AT_FLY )
1332cdf0e10cSrcweir             {
1333cdf0e10cSrcweir                 aHori.SetHoriOrient( text::HoriOrientation::NONE );
1334cdf0e10cSrcweir                 aHori.SetRelationOrient( text::RelOrientation::FRAME );
1335cdf0e10cSrcweir                 aHori.SetPosToggle( sal_False );
1336cdf0e10cSrcweir             }
1337cdf0e10cSrcweir             // <--
1338cdf0e10cSrcweir             else if ( IsFlyAtCntFrm() || text::HoriOrientation::NONE != aHori.GetHoriOrient() )
1339cdf0e10cSrcweir 			{
1340cdf0e10cSrcweir                 aHori.SetHoriOrient( text::HoriOrientation::NONE );
1341cdf0e10cSrcweir                 if( text::RelOrientation::CHAR == aHori.GetRelationOrient() && IsAutoPos() )
1342cdf0e10cSrcweir 				{
1343cdf0e10cSrcweir                     if( LONG_MAX != nNewX )
1344cdf0e10cSrcweir 					{
1345cdf0e10cSrcweir 						if( !pAutoFrm )
1346cdf0e10cSrcweir 						{
1347cdf0e10cSrcweir 							xub_StrLen nOfs = pFmt->GetAnchor().GetCntntAnchor()
1348cdf0e10cSrcweir 										  ->nContent.GetIndex();
1349cdf0e10cSrcweir                             ASSERT( GetAnchorFrm()->IsTxtFrm(), "TxtFrm expected");
1350cdf0e10cSrcweir                             pAutoFrm = (SwTxtFrm*)GetAnchorFrm();
1351cdf0e10cSrcweir 							while( pAutoFrm->GetFollow() &&
1352cdf0e10cSrcweir 								   pAutoFrm->GetFollow()->GetOfst() <= nOfs )
1353cdf0e10cSrcweir 								pAutoFrm = pAutoFrm->GetFollow();
1354cdf0e10cSrcweir 						}
1355cdf0e10cSrcweir 						nTmpX -= ((SwFlyAtCntFrm*)this)->GetRelCharX(pAutoFrm);
1356cdf0e10cSrcweir 					}
1357cdf0e10cSrcweir 				}
1358cdf0e10cSrcweir 				else
1359cdf0e10cSrcweir                     aHori.SetRelationOrient( text::RelOrientation::FRAME );
1360cdf0e10cSrcweir 				aHori.SetPosToggle( sal_False );
1361cdf0e10cSrcweir 			}
1362cdf0e10cSrcweir 			aHori.SetPos( nTmpX );
1363cdf0e10cSrcweir 			aSet.Put( aHori );
1364cdf0e10cSrcweir 		}
1365cdf0e10cSrcweir         SetCurrRelPos( rNewPos );
1366cdf0e10cSrcweir 		pFmt->GetDoc()->SetAttr( aSet, *pFmt );
1367cdf0e10cSrcweir 	}
1368cdf0e10cSrcweir }
1369cdf0e10cSrcweir /*************************************************************************
1370cdf0e10cSrcweir |*
1371cdf0e10cSrcweir |*	SwFlyFrm::Format()
1372cdf0e10cSrcweir |*
1373cdf0e10cSrcweir |*	Beschreibung:		"Formatiert" den Frame; Frm und PrtArea.
1374cdf0e10cSrcweir |*						Die Fixsize wird hier nicht eingestellt.
1375cdf0e10cSrcweir |*	Ersterstellung		MA 14. Jun. 93
1376cdf0e10cSrcweir |*	Letzte Aenderung	MA 13. Jun. 96
1377cdf0e10cSrcweir |*
1378cdf0e10cSrcweir |*************************************************************************/
1379cdf0e10cSrcweir 
Format(const SwBorderAttrs * pAttrs)1380cdf0e10cSrcweir void SwFlyFrm::Format( const SwBorderAttrs *pAttrs )
1381cdf0e10cSrcweir {
1382cdf0e10cSrcweir 	ASSERT( pAttrs, "FlyFrm::Format, pAttrs ist 0." );
1383cdf0e10cSrcweir 
1384cdf0e10cSrcweir 	ColLock();
1385cdf0e10cSrcweir 
1386cdf0e10cSrcweir 	if ( !bValidSize )
1387cdf0e10cSrcweir 	{
1388cdf0e10cSrcweir 		if ( Frm().Top() == WEIT_WECH && Frm().Left() == WEIT_WECH )
1389cdf0e10cSrcweir         {
1390cdf0e10cSrcweir 			//Sicherheitsschaltung wegnehmen (siehe SwFrm::CTor)
1391cdf0e10cSrcweir 			Frm().Pos().X() = Frm().Pos().Y() = 0;
1392cdf0e10cSrcweir             // --> OD 2006-08-16 #i68520#
1393cdf0e10cSrcweir             InvalidateObjRectWithSpaces();
1394cdf0e10cSrcweir             // <--
1395cdf0e10cSrcweir         }
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir 		//Breite der Spalten pruefen und ggf. einstellen.
1398cdf0e10cSrcweir 		if ( Lower() && Lower()->IsColumnFrm() )
1399cdf0e10cSrcweir 			AdjustColumns( 0, sal_False );
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir 		bValidSize = sal_True;
1402cdf0e10cSrcweir 
1403cdf0e10cSrcweir         const SwTwips nUL = pAttrs->CalcTopLine()  + pAttrs->CalcBottomLine();
1404cdf0e10cSrcweir         const SwTwips nLR = pAttrs->CalcLeftLine() + pAttrs->CalcRightLine();
1405cdf0e10cSrcweir         const SwFmtFrmSize &rFrmSz = GetFmt()->GetFrmSize();
1406cdf0e10cSrcweir               Size aRelSize( CalcRel( rFrmSz ) );
1407cdf0e10cSrcweir 
1408cdf0e10cSrcweir         ASSERT( pAttrs->GetSize().Height() != 0 || rFrmSz.GetHeightPercent(), "Hoehe des RahmenAttr ist 0." );
1409cdf0e10cSrcweir         ASSERT( pAttrs->GetSize().Width()  != 0 || rFrmSz.GetWidthPercent(), "Breite des RahmenAttr ist 0." );
1410cdf0e10cSrcweir 
1411cdf0e10cSrcweir         SWRECTFN( this )
1412cdf0e10cSrcweir         if( !HasFixSize() )
1413cdf0e10cSrcweir 		{
1414cdf0e10cSrcweir             SwTwips nRemaining = 0;
1415cdf0e10cSrcweir 
1416cdf0e10cSrcweir             long nMinHeight = 0;
1417cdf0e10cSrcweir             if( IsMinHeight() )
1418cdf0e10cSrcweir                 nMinHeight = bVert ? aRelSize.Width() : aRelSize.Height();
1419cdf0e10cSrcweir 
1420cdf0e10cSrcweir             if ( Lower() )
1421cdf0e10cSrcweir 			{
1422cdf0e10cSrcweir 				if ( Lower()->IsColumnFrm() )
1423cdf0e10cSrcweir 				{
1424cdf0e10cSrcweir 					FormatWidthCols( *pAttrs, nUL, nMinHeight );
1425cdf0e10cSrcweir                     nRemaining = (Lower()->Frm().*fnRect->fnGetHeight)();
1426cdf0e10cSrcweir 				}
1427cdf0e10cSrcweir 				else
1428cdf0e10cSrcweir 				{
1429cdf0e10cSrcweir 					SwFrm *pFrm = Lower();
1430cdf0e10cSrcweir 					while ( pFrm )
1431cdf0e10cSrcweir                     {
1432cdf0e10cSrcweir                         nRemaining += (pFrm->Frm().*fnRect->fnGetHeight)();
1433cdf0e10cSrcweir 						if( pFrm->IsTxtFrm() && ((SwTxtFrm*)pFrm)->IsUndersized() )
1434cdf0e10cSrcweir 							// Dieser TxtFrm waere gern ein bisschen groesser
1435cdf0e10cSrcweir 							nRemaining += ((SwTxtFrm*)pFrm)->GetParHeight()
1436cdf0e10cSrcweir                                     - (pFrm->Prt().*fnRect->fnGetHeight)();
1437cdf0e10cSrcweir 						else if( pFrm->IsSctFrm() && ((SwSectionFrm*)pFrm)->IsUndersized() )
1438cdf0e10cSrcweir 							nRemaining += ((SwSectionFrm*)pFrm)->Undersize();
1439cdf0e10cSrcweir 						pFrm = pFrm->GetNext();
1440cdf0e10cSrcweir 					}
1441cdf0e10cSrcweir                     // --> OD 2006-02-09 #130878#
1442cdf0e10cSrcweir                     // Do not keep old height, if content has no height.
1443cdf0e10cSrcweir                     // The old height could be wrong due to wrong layout cache
1444cdf0e10cSrcweir                     // and isn't corrected in the further formatting, because
1445cdf0e10cSrcweir                     // the fly frame doesn't become invalid anymore.
1446cdf0e10cSrcweir //                    if( !nRemaining )
1447cdf0e10cSrcweir //                        nRemaining = nOldHeight - nUL;
1448cdf0e10cSrcweir                     // <--
1449cdf0e10cSrcweir 				}
1450cdf0e10cSrcweir 				if ( GetDrawObjs() )
1451cdf0e10cSrcweir 				{
1452cdf0e10cSrcweir                     sal_uInt32 nCnt = GetDrawObjs()->Count();
1453cdf0e10cSrcweir                     SwTwips nTop = (Frm().*fnRect->fnGetTop)();
1454cdf0e10cSrcweir                     SwTwips nBorder = (Frm().*fnRect->fnGetHeight)() -
1455cdf0e10cSrcweir                                       (Prt().*fnRect->fnGetHeight)();
1456cdf0e10cSrcweir 					for ( sal_uInt16 i = 0; i < nCnt; ++i )
1457cdf0e10cSrcweir 					{
1458cdf0e10cSrcweir                         SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
1459cdf0e10cSrcweir                         if ( pAnchoredObj->ISA(SwFlyFrm) )
1460cdf0e10cSrcweir 						{
1461cdf0e10cSrcweir                             SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
1462cdf0e10cSrcweir                             // OD 06.11.2003 #i22305# - consider
1463cdf0e10cSrcweir                             // only Writer fly frames, which follow the text flow.
1464cdf0e10cSrcweir                             if ( pFly->IsFlyLayFrm() &&
1465cdf0e10cSrcweir                                  pFly->Frm().Top() != WEIT_WECH &&
1466cdf0e10cSrcweir                                  pFly->GetFmt()->GetFollowTextFlow().GetValue() )
1467cdf0e10cSrcweir 							{
1468cdf0e10cSrcweir                                 SwTwips nDist = -(pFly->Frm().*fnRect->
1469cdf0e10cSrcweir                                     fnBottomDist)( nTop );
1470cdf0e10cSrcweir                                 if( nDist > nBorder + nRemaining )
1471cdf0e10cSrcweir                                     nRemaining = nDist - nBorder;
1472cdf0e10cSrcweir 							}
1473cdf0e10cSrcweir 						}
1474cdf0e10cSrcweir 					}
1475cdf0e10cSrcweir 				}
1476cdf0e10cSrcweir 			}
1477cdf0e10cSrcweir 
1478cdf0e10cSrcweir             if( IsMinHeight() && (nRemaining + nUL) < nMinHeight )
1479cdf0e10cSrcweir 				nRemaining = nMinHeight - nUL;
1480cdf0e10cSrcweir 			//Weil das Grow/Shrink der Flys die Groessen nicht direkt
1481cdf0e10cSrcweir 			//einstellt, sondern indirekt per Invalidate ein Format
1482cdf0e10cSrcweir 			//ausloesst, muessen die Groessen hier direkt eingestellt
1483cdf0e10cSrcweir 			//werden. Benachrichtung laeuft bereits mit.
1484cdf0e10cSrcweir 			//Weil bereits haeufiger 0en per Attribut hereinkamen wehre
1485cdf0e10cSrcweir 			//ich mich ab sofort dagegen.
1486cdf0e10cSrcweir 			if ( nRemaining < MINFLY )
1487cdf0e10cSrcweir 				nRemaining = MINFLY;
1488cdf0e10cSrcweir             (Prt().*fnRect->fnSetHeight)( nRemaining );
1489cdf0e10cSrcweir             nRemaining -= (Frm().*fnRect->fnGetHeight)();
1490cdf0e10cSrcweir             (Frm().*fnRect->fnAddBottom)( nRemaining + nUL );
1491cdf0e10cSrcweir             // --> OD 2006-08-16 #i68520#
1492cdf0e10cSrcweir             if ( nRemaining + nUL != 0 )
1493cdf0e10cSrcweir             {
1494cdf0e10cSrcweir                 InvalidateObjRectWithSpaces();
1495cdf0e10cSrcweir             }
1496cdf0e10cSrcweir             // <--
1497cdf0e10cSrcweir 			bValidSize = sal_True;
1498cdf0e10cSrcweir 		}
1499cdf0e10cSrcweir 		else
1500cdf0e10cSrcweir 		{
1501cdf0e10cSrcweir 			bValidSize = sal_True;	//Fixe Frms formatieren sich nicht.
1502cdf0e10cSrcweir 								//Flys stellen ihre Groesse anhand des Attr ein.
1503cdf0e10cSrcweir             SwTwips nNewSize = bVert ? aRelSize.Width() : aRelSize.Height();
1504cdf0e10cSrcweir             nNewSize -= nUL;
1505cdf0e10cSrcweir             if( nNewSize < MINFLY )
1506cdf0e10cSrcweir                 nNewSize = MINFLY;
1507cdf0e10cSrcweir             (Prt().*fnRect->fnSetHeight)( nNewSize );
1508cdf0e10cSrcweir             nNewSize += nUL - (Frm().*fnRect->fnGetHeight)();
1509cdf0e10cSrcweir             (Frm().*fnRect->fnAddBottom)( nNewSize );
1510cdf0e10cSrcweir             // --> OD 2006-08-16 #i68520#
1511cdf0e10cSrcweir             if ( nNewSize != 0 )
1512cdf0e10cSrcweir             {
1513cdf0e10cSrcweir                 InvalidateObjRectWithSpaces();
1514cdf0e10cSrcweir             }
1515cdf0e10cSrcweir             // <--
1516cdf0e10cSrcweir         }
1517cdf0e10cSrcweir 
1518cdf0e10cSrcweir 		if ( !bFormatHeightOnly )
1519cdf0e10cSrcweir 		{
1520cdf0e10cSrcweir             ASSERT( aRelSize == CalcRel( rFrmSz ), "SwFlyFrm::Format CalcRel problem" )
1521cdf0e10cSrcweir             SwTwips nNewSize = bVert ? aRelSize.Height() : aRelSize.Width();
1522cdf0e10cSrcweir 
1523cdf0e10cSrcweir             if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
1524cdf0e10cSrcweir             {
1525cdf0e10cSrcweir                 // #i9046# Autowidth for fly frames
1526cdf0e10cSrcweir                 const SwTwips nAutoWidth = CalcAutoWidth();
1527cdf0e10cSrcweir                 if ( nAutoWidth )
1528cdf0e10cSrcweir                 {
1529cdf0e10cSrcweir                     if( ATT_MIN_SIZE == rFrmSz.GetWidthSizeType() )
1530cdf0e10cSrcweir                         nNewSize = Max( nNewSize - nLR, nAutoWidth );
1531cdf0e10cSrcweir                     else
1532cdf0e10cSrcweir                         nNewSize = nAutoWidth;
1533cdf0e10cSrcweir                 }
1534cdf0e10cSrcweir             }
153591100364SJian Hong Cheng             /*else
153691100364SJian Hong Cheng                 nNewSize -= nLR;*/
153791100364SJian Hong Cheng 			else
153891100364SJian Hong Cheng 			{//Bug 120881:For enlarging fixed size Pagenumber frame,kangjian
153991100364SJian Hong Cheng 				if(nNewSize <= 500 && IsPageNumberingFrm())
154091100364SJian Hong Cheng 					nNewSize = nNewSize - nLR + 150;
154191100364SJian Hong Cheng 
154291100364SJian Hong Cheng 				else
154391100364SJian Hong Cheng 					nNewSize -= nLR;
154491100364SJian Hong Cheng 			//Bug 120881(End)
154591100364SJian Hong Cheng 			}
1546cdf0e10cSrcweir 
1547cdf0e10cSrcweir             if( nNewSize < MINFLY )
1548cdf0e10cSrcweir                 nNewSize = MINFLY;
1549cdf0e10cSrcweir             (Prt().*fnRect->fnSetWidth)( nNewSize );
1550cdf0e10cSrcweir             nNewSize += nLR - (Frm().*fnRect->fnGetWidth)();
1551cdf0e10cSrcweir             (Frm().*fnRect->fnAddRight)( nNewSize );
1552cdf0e10cSrcweir             // --> OD 2006-08-16 #i68520#
1553cdf0e10cSrcweir             if ( nNewSize != 0 )
1554cdf0e10cSrcweir             {
1555cdf0e10cSrcweir                 InvalidateObjRectWithSpaces();
1556cdf0e10cSrcweir             }
1557cdf0e10cSrcweir             // <--
1558cdf0e10cSrcweir         }
1559cdf0e10cSrcweir 	}
1560cdf0e10cSrcweir 	ColUnlock();
1561cdf0e10cSrcweir }
1562cdf0e10cSrcweir 
1563cdf0e10cSrcweir // OD 14.03.2003 #i11760# - change parameter <bNoColl>: type <bool>;
1564cdf0e10cSrcweir //                          default value = false.
1565cdf0e10cSrcweir // OD 14.03.2003 #i11760# - add new parameter <bNoCalcFollow> with
1566cdf0e10cSrcweir //                          default value = false.
1567cdf0e10cSrcweir // OD 11.04.2003 #108824# - new parameter <bNoCalcFollow> was used by method
1568cdf0e10cSrcweir //                          <FormatWidthCols(..)> to avoid follow formatting
1569cdf0e10cSrcweir //                          for text frames. But, unformatted follows causes
1570cdf0e10cSrcweir //                          problems in method <SwCntntFrm::_WouldFit(..)>,
1571cdf0e10cSrcweir //                          which assumes that the follows are formatted.
1572cdf0e10cSrcweir //                          Thus, <bNoCalcFollow> no longer used by <FormatWidthCols(..)>.
1573cdf0e10cSrcweir //void CalcCntnt( SwLayoutFrm *pLay, sal_Bool bNoColl )
CalcCntnt(SwLayoutFrm * pLay,bool bNoColl,bool bNoCalcFollow)1574cdf0e10cSrcweir void CalcCntnt( SwLayoutFrm *pLay,
1575cdf0e10cSrcweir                 bool bNoColl,
1576cdf0e10cSrcweir                 bool bNoCalcFollow )
1577cdf0e10cSrcweir {
1578cdf0e10cSrcweir 	SwSectionFrm* pSect;
1579cdf0e10cSrcweir 	sal_Bool bCollect = sal_False;
1580cdf0e10cSrcweir 	if( pLay->IsSctFrm() )
1581cdf0e10cSrcweir 	{
1582cdf0e10cSrcweir 		pSect = (SwSectionFrm*)pLay;
1583cdf0e10cSrcweir 		if( pSect->IsEndnAtEnd() && !bNoColl )
1584cdf0e10cSrcweir 		{
1585cdf0e10cSrcweir 			bCollect = sal_True;
1586cdf0e10cSrcweir 			SwLayouter::CollectEndnotes( pLay->GetFmt()->GetDoc(), pSect );
1587cdf0e10cSrcweir 		}
1588cdf0e10cSrcweir 		pSect->CalcFtnCntnt();
1589cdf0e10cSrcweir 	}
1590cdf0e10cSrcweir 	else
1591cdf0e10cSrcweir 		pSect = NULL;
1592cdf0e10cSrcweir 	SwFrm *pFrm = pLay->ContainsAny();
1593cdf0e10cSrcweir 	if ( !pFrm )
1594cdf0e10cSrcweir 	{
1595cdf0e10cSrcweir 		if( pSect )
1596cdf0e10cSrcweir 		{
1597cdf0e10cSrcweir 			if( pSect->HasFollow() )
1598cdf0e10cSrcweir 				pFrm = pSect->GetFollow()->ContainsAny();
1599cdf0e10cSrcweir 			if( !pFrm )
1600cdf0e10cSrcweir 			{
1601cdf0e10cSrcweir 				if( pSect->IsEndnAtEnd() )
1602cdf0e10cSrcweir 				{
1603cdf0e10cSrcweir 					if( bCollect )
1604cdf0e10cSrcweir 						pLay->GetFmt()->GetDoc()->GetLayouter()->
1605cdf0e10cSrcweir 							InsertEndnotes( pSect );
1606cdf0e10cSrcweir 					sal_Bool bLock = pSect->IsFtnLock();
1607cdf0e10cSrcweir 					pSect->SetFtnLock( sal_True );
1608cdf0e10cSrcweir 					pSect->CalcFtnCntnt();
1609cdf0e10cSrcweir 					pSect->CalcFtnCntnt();
1610cdf0e10cSrcweir 					pSect->SetFtnLock( bLock );
1611cdf0e10cSrcweir 				}
1612cdf0e10cSrcweir 				return;
1613cdf0e10cSrcweir 			}
1614cdf0e10cSrcweir 			pFrm->_InvalidatePos();
1615cdf0e10cSrcweir 		}
1616cdf0e10cSrcweir 		else
1617cdf0e10cSrcweir 			return;
1618cdf0e10cSrcweir 	}
1619cdf0e10cSrcweir 	pFrm->InvalidatePage();
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir 	do
1622cdf0e10cSrcweir 	{
1623cdf0e10cSrcweir         // local variables to avoid loops caused by anchored object positioning
1624cdf0e10cSrcweir         SwAnchoredObject* pAgainObj1 = 0;
1625cdf0e10cSrcweir         SwAnchoredObject* pAgainObj2 = 0;
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir         // FME 2007-08-30 #i81146# new loop control
1628cdf0e10cSrcweir         sal_uInt16 nLoopControlRuns = 0;
1629cdf0e10cSrcweir         const sal_uInt16 nLoopControlMax = 20;
1630cdf0e10cSrcweir         const SwFrm* pLoopControlCond = 0;
1631cdf0e10cSrcweir 
1632cdf0e10cSrcweir         SwFrm* pLast;
1633cdf0e10cSrcweir 		do
1634cdf0e10cSrcweir 		{
1635cdf0e10cSrcweir 			pLast = pFrm;
1636cdf0e10cSrcweir             if( pFrm->IsVertical() ?
1637cdf0e10cSrcweir                 ( pFrm->GetUpper()->Prt().Height() != pFrm->Frm().Height() )
1638cdf0e10cSrcweir                 : ( pFrm->GetUpper()->Prt().Width() != pFrm->Frm().Width() ) )
1639cdf0e10cSrcweir 			{
1640cdf0e10cSrcweir 				pFrm->Prepare( PREP_FIXSIZE_CHG );
1641cdf0e10cSrcweir 				pFrm->_InvalidateSize();
1642cdf0e10cSrcweir 			}
1643cdf0e10cSrcweir 
1644cdf0e10cSrcweir 			if ( pFrm->IsTabFrm() )
1645cdf0e10cSrcweir 			{
1646cdf0e10cSrcweir 				((SwTabFrm*)pFrm)->bCalcLowers = sal_True;
1647cdf0e10cSrcweir                 // OD 26.08.2003 #i18103# - lock move backward of follow table,
1648cdf0e10cSrcweir                 // if no section content is formatted or follow table belongs
1649cdf0e10cSrcweir                 // to the section, which content is formatted.
1650cdf0e10cSrcweir                 if ( ((SwTabFrm*)pFrm)->IsFollow() &&
1651cdf0e10cSrcweir                      ( !pSect || pSect == pFrm->FindSctFrm() ) )
1652cdf0e10cSrcweir                 {
1653cdf0e10cSrcweir 					((SwTabFrm*)pFrm)->bLockBackMove = sal_True;
1654cdf0e10cSrcweir                 }
1655cdf0e10cSrcweir 			}
1656cdf0e10cSrcweir 
1657cdf0e10cSrcweir             // OD 14.03.2003 #i11760# - forbid format of follow, if requested.
1658cdf0e10cSrcweir             if ( bNoCalcFollow && pFrm->IsTxtFrm() )
1659cdf0e10cSrcweir                 static_cast<SwTxtFrm*>(pFrm)->ForbidFollowFormat();
1660cdf0e10cSrcweir 
1661cdf0e10cSrcweir             pFrm->Calc();
1662cdf0e10cSrcweir 
1663cdf0e10cSrcweir             // OD 14.03.2003 #i11760# - reset control flag for follow format.
1664cdf0e10cSrcweir             if ( pFrm->IsTxtFrm() )
1665cdf0e10cSrcweir             {
1666cdf0e10cSrcweir                 static_cast<SwTxtFrm*>(pFrm)->AllowFollowFormat();
1667cdf0e10cSrcweir             }
1668cdf0e10cSrcweir 
1669cdf0e10cSrcweir             // #111937# The keep-attribute can cause the position
1670cdf0e10cSrcweir             // of the prev to be invalid:
1671cdf0e10cSrcweir             // OD 2004-03-15 #116560# - Do not consider invalid previous frame
1672cdf0e10cSrcweir             // due to its keep-attribute, if current frame is a follow or is locked.
1673cdf0e10cSrcweir             // --> OD 2005-03-08 #i44049# - do not consider invalid previous
1674cdf0e10cSrcweir             // frame due to its keep-attribute, if it can't move forward.
1675cdf0e10cSrcweir             // --> OD 2006-01-27 #i57765# - do not consider invalid previous
1676cdf0e10cSrcweir             // frame, if current frame has a column/page break before attribute.
1677cdf0e10cSrcweir             SwFrm* pTmpPrev = pFrm->FindPrev();
1678cdf0e10cSrcweir             SwFlowFrm* pTmpPrevFlowFrm = pTmpPrev && pTmpPrev->IsFlowFrm() ? SwFlowFrm::CastFlowFrm(pTmpPrev) : 0;
1679cdf0e10cSrcweir             SwFlowFrm* pTmpFlowFrm     = pFrm->IsFlowFrm() ? SwFlowFrm::CastFlowFrm(pFrm) : 0;
1680cdf0e10cSrcweir 
1681cdf0e10cSrcweir             bool bPrevInvalid = pTmpPrevFlowFrm && pTmpFlowFrm &&
1682cdf0e10cSrcweir                                !pTmpFlowFrm->IsFollow() &&
1683cdf0e10cSrcweir                                !StackHack::IsLocked() && // #i76382#
1684cdf0e10cSrcweir                                !pTmpFlowFrm->IsJoinLocked() &&
1685cdf0e10cSrcweir                                !pTmpPrev->GetValidPosFlag() &&
1686cdf0e10cSrcweir                                 pLay->IsAnLower( pTmpPrev ) &&
1687cdf0e10cSrcweir                                 pTmpPrevFlowFrm->IsKeep( *pTmpPrev->GetAttrSet() ) &&
1688cdf0e10cSrcweir                                 pTmpPrevFlowFrm->IsKeepFwdMoveAllowed();
1689cdf0e10cSrcweir             // <--
1690cdf0e10cSrcweir 
1691cdf0e10cSrcweir             // format floating screen objects anchored to the frame.
1692cdf0e10cSrcweir             bool bRestartLayoutProcess = false;
1693cdf0e10cSrcweir             if ( !bPrevInvalid && pFrm->GetDrawObjs() && pLay->IsAnLower( pFrm ) )
1694cdf0e10cSrcweir 			{
1695cdf0e10cSrcweir                 bool bAgain = false;
1696cdf0e10cSrcweir                 SwPageFrm* pPageFrm = pFrm->FindPageFrm();
1697cdf0e10cSrcweir                 sal_uInt32 nCnt = pFrm->GetDrawObjs()->Count();
1698cdf0e10cSrcweir 				for ( sal_uInt16 i = 0; i < nCnt; ++i )
1699cdf0e10cSrcweir 				{
1700cdf0e10cSrcweir                     // --> OD 2004-07-01 #i28701#
1701cdf0e10cSrcweir                     SwAnchoredObject* pAnchoredObj = (*pFrm->GetDrawObjs())[i];
1702cdf0e10cSrcweir                     // determine, if anchored object has to be formatted.
1703cdf0e10cSrcweir                     if ( pAnchoredObj->PositionLocked() )
1704cdf0e10cSrcweir                     {
1705cdf0e10cSrcweir                         continue;
1706cdf0e10cSrcweir                     }
1707cdf0e10cSrcweir 
1708cdf0e10cSrcweir                     // format anchored object
1709cdf0e10cSrcweir                     if ( pAnchoredObj->IsFormatPossible() )
1710cdf0e10cSrcweir                     {
1711cdf0e10cSrcweir                         // --> OD 2005-05-17 #i43737# - no invalidation of
1712cdf0e10cSrcweir                         // anchored object needed - causes loops for as-character
1713cdf0e10cSrcweir                         // anchored objects.
1714cdf0e10cSrcweir                         //pAnchoredObj->InvalidateObjPos();
1715cdf0e10cSrcweir                         // <--
1716cdf0e10cSrcweir                         SwRect aRect( pAnchoredObj->GetObjRect() );
1717cdf0e10cSrcweir                         if ( !SwObjectFormatter::FormatObj( *pAnchoredObj, pFrm, pPageFrm ) )
1718cdf0e10cSrcweir                         {
1719cdf0e10cSrcweir                             bRestartLayoutProcess = true;
1720cdf0e10cSrcweir                             break;
1721cdf0e10cSrcweir                         }
1722cdf0e10cSrcweir                         // --> OD 2004-08-25 #i3317# - restart layout process,
1723cdf0e10cSrcweir                         // if the position of the anchored object is locked now.
1724cdf0e10cSrcweir                         if ( pAnchoredObj->PositionLocked() )
1725cdf0e10cSrcweir                         {
1726cdf0e10cSrcweir                             bRestartLayoutProcess = true;
1727cdf0e10cSrcweir                             break;
1728cdf0e10cSrcweir                         }
1729cdf0e10cSrcweir                         // <--
1730cdf0e10cSrcweir 
1731cdf0e10cSrcweir                         if ( aRect != pAnchoredObj->GetObjRect() )
1732cdf0e10cSrcweir                         {
1733cdf0e10cSrcweir                             bAgain = true;
1734cdf0e10cSrcweir                             if ( pAgainObj2 == pAnchoredObj )
1735cdf0e10cSrcweir                             {
1736cdf0e10cSrcweir                                 ASSERT( false,
1737cdf0e10cSrcweir                                         "::CalcCntnt(..) - loop detected, perform attribute changes to avoid the loop" );
1738cdf0e10cSrcweir                                 //Oszillation unterbinden.
1739cdf0e10cSrcweir                                 SwFrmFmt& rFmt = pAnchoredObj->GetFrmFmt();
1740cdf0e10cSrcweir                                 SwFmtSurround aAttr( rFmt.GetSurround() );
1741cdf0e10cSrcweir                                 if( SURROUND_THROUGHT != aAttr.GetSurround() )
1742cdf0e10cSrcweir                                 {
1743cdf0e10cSrcweir                                     // Bei autopositionierten hilft manchmal nur
1744cdf0e10cSrcweir                                     // noch, auf Durchlauf zu schalten
1745cdf0e10cSrcweir                                     if ((rFmt.GetAnchor().GetAnchorId() ==
1746cdf0e10cSrcweir                                             FLY_AT_CHAR) &&
1747cdf0e10cSrcweir                                         (SURROUND_PARALLEL ==
1748cdf0e10cSrcweir                                             aAttr.GetSurround()))
1749cdf0e10cSrcweir                                     {
1750cdf0e10cSrcweir                                         aAttr.SetSurround( SURROUND_THROUGHT );
1751cdf0e10cSrcweir                                     }
1752cdf0e10cSrcweir                                     else
1753cdf0e10cSrcweir                                     {
1754cdf0e10cSrcweir                                         aAttr.SetSurround( SURROUND_PARALLEL );
1755cdf0e10cSrcweir                                     }
1756cdf0e10cSrcweir                                     rFmt.LockModify();
1757cdf0e10cSrcweir                                     rFmt.SetFmtAttr( aAttr );
1758cdf0e10cSrcweir                                     rFmt.UnlockModify();
1759cdf0e10cSrcweir                                 }
1760cdf0e10cSrcweir                             }
1761cdf0e10cSrcweir                             else
1762cdf0e10cSrcweir                             {
1763cdf0e10cSrcweir                                 if ( pAgainObj1 == pAnchoredObj )
1764cdf0e10cSrcweir                                     pAgainObj2 = pAnchoredObj;
1765cdf0e10cSrcweir                                 pAgainObj1 = pAnchoredObj;
1766cdf0e10cSrcweir                             }
1767cdf0e10cSrcweir                         }
1768cdf0e10cSrcweir 
1769cdf0e10cSrcweir                         if ( !pFrm->GetDrawObjs() )
1770cdf0e10cSrcweir                             break;
1771cdf0e10cSrcweir                         if ( pFrm->GetDrawObjs()->Count() < nCnt )
1772cdf0e10cSrcweir                         {
1773cdf0e10cSrcweir                             --i;
1774cdf0e10cSrcweir                             --nCnt;
1775cdf0e10cSrcweir                         }
1776cdf0e10cSrcweir                     }
1777cdf0e10cSrcweir 				}
1778cdf0e10cSrcweir 
1779cdf0e10cSrcweir                 // --> OD 2004-06-11 #i28701# - restart layout process, if
1780cdf0e10cSrcweir                 // requested by floating screen object formatting
1781cdf0e10cSrcweir                 if ( bRestartLayoutProcess )
1782cdf0e10cSrcweir                 {
1783cdf0e10cSrcweir                     pFrm = pLay->ContainsAny();
1784cdf0e10cSrcweir                     pAgainObj1 = 0L;
1785cdf0e10cSrcweir                     pAgainObj2 = 0L;
1786cdf0e10cSrcweir                     continue;
1787cdf0e10cSrcweir                 }
1788cdf0e10cSrcweir 
1789cdf0e10cSrcweir                 // OD 2004-05-17 #i28701# - format anchor frame after its objects
1790cdf0e10cSrcweir                 // are formatted, if the wrapping style influence has to be considered.
1791cdf0e10cSrcweir                 if ( pLay->GetFmt()->getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
1792cdf0e10cSrcweir                 {
1793cdf0e10cSrcweir                     pFrm->Calc();
1794cdf0e10cSrcweir                 }
1795cdf0e10cSrcweir                 // <--
1796cdf0e10cSrcweir 
1797cdf0e10cSrcweir                 if ( bAgain )
1798cdf0e10cSrcweir 				{
1799cdf0e10cSrcweir 					pFrm = pLay->ContainsCntnt();
1800cdf0e10cSrcweir 					if ( pFrm && pFrm->IsInTab() )
1801cdf0e10cSrcweir 						pFrm = pFrm->FindTabFrm();
1802cdf0e10cSrcweir 					if( pFrm && pFrm->IsInSct() )
1803cdf0e10cSrcweir 					{
1804cdf0e10cSrcweir 						SwSectionFrm* pTmp = pFrm->FindSctFrm();
1805cdf0e10cSrcweir 						if( pTmp != pLay && pLay->IsAnLower( pTmp ) )
1806cdf0e10cSrcweir 							pFrm = pTmp;
1807cdf0e10cSrcweir 					}
1808cdf0e10cSrcweir 
1809cdf0e10cSrcweir                     if ( pFrm == pLoopControlCond )
1810cdf0e10cSrcweir                         ++nLoopControlRuns;
1811cdf0e10cSrcweir                     else
1812cdf0e10cSrcweir                     {
1813cdf0e10cSrcweir                         nLoopControlRuns = 0;
1814cdf0e10cSrcweir                         pLoopControlCond = pFrm;
1815cdf0e10cSrcweir                     }
1816cdf0e10cSrcweir 
1817cdf0e10cSrcweir                     if ( nLoopControlRuns < nLoopControlMax )
1818cdf0e10cSrcweir                         continue;
1819cdf0e10cSrcweir 
1820cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
1821cdf0e10cSrcweir                     ASSERT( false, "LoopControl in CalcCntnt" )
1822cdf0e10cSrcweir #endif
1823cdf0e10cSrcweir 				}
1824cdf0e10cSrcweir 			}
1825cdf0e10cSrcweir 			if ( pFrm->IsTabFrm() )
1826cdf0e10cSrcweir 			{
1827cdf0e10cSrcweir 				if ( ((SwTabFrm*)pFrm)->IsFollow() )
1828cdf0e10cSrcweir 					((SwTabFrm*)pFrm)->bLockBackMove = sal_False;
1829cdf0e10cSrcweir 			}
1830cdf0e10cSrcweir 
1831cdf0e10cSrcweir             pFrm = bPrevInvalid ? pTmpPrev : pFrm->FindNext();
1832cdf0e10cSrcweir             if( !bPrevInvalid && pFrm && pFrm->IsSctFrm() && pSect )
1833cdf0e10cSrcweir 			{
1834cdf0e10cSrcweir 				// Es koennen hier leere SectionFrms herumspuken
1835cdf0e10cSrcweir 				while( pFrm && pFrm->IsSctFrm() && !((SwSectionFrm*)pFrm)->GetSection() )
1836cdf0e10cSrcweir 					pFrm = pFrm->FindNext();
1837cdf0e10cSrcweir 				// Wenn FindNext den Follow des urspruenglichen Bereichs liefert,
1838cdf0e10cSrcweir 				// wollen wir mit dessen Inhalt weitermachen, solange dieser
1839cdf0e10cSrcweir 				// zurueckfliesst.
1840cdf0e10cSrcweir 				if( pFrm && pFrm->IsSctFrm() && ( pFrm == pSect->GetFollow() ||
1841cdf0e10cSrcweir 					((SwSectionFrm*)pFrm)->IsAnFollow( pSect ) ) )
1842cdf0e10cSrcweir 				{
1843cdf0e10cSrcweir 					pFrm = ((SwSectionFrm*)pFrm)->ContainsAny();
1844cdf0e10cSrcweir 					if( pFrm )
1845cdf0e10cSrcweir 						pFrm->_InvalidatePos();
1846cdf0e10cSrcweir 				}
1847cdf0e10cSrcweir 			}
1848cdf0e10cSrcweir 			// Im pLay bleiben, Ausnahme, bei SectionFrms mit Follow wird der erste
1849cdf0e10cSrcweir 			// CntntFrm des Follows anformatiert, damit er die Chance erhaelt, in
1850cdf0e10cSrcweir 			// pLay zu landen. Solange diese Frames in pLay landen, geht's weiter.
1851cdf0e10cSrcweir         } while ( pFrm &&
1852cdf0e10cSrcweir                   ( pLay->IsAnLower( pFrm ) ||
1853cdf0e10cSrcweir                     ( pSect &&
1854cdf0e10cSrcweir                       ( ( pSect->HasFollow() &&
1855cdf0e10cSrcweir                           ( pLay->IsAnLower( pLast ) ||
1856cdf0e10cSrcweir                             ( pLast->IsInSct() &&
1857cdf0e10cSrcweir                               pLast->FindSctFrm()->IsAnFollow(pSect) ) ) &&
1858cdf0e10cSrcweir                           pSect->GetFollow()->IsAnLower( pFrm )  ) ||
1859cdf0e10cSrcweir                         ( pFrm->IsInSct() &&
1860cdf0e10cSrcweir                           pFrm->FindSctFrm()->IsAnFollow( pSect ) ) ) ) ) );
1861cdf0e10cSrcweir 		if( pSect )
1862cdf0e10cSrcweir 		{
1863cdf0e10cSrcweir 			if( bCollect )
1864cdf0e10cSrcweir 			{
1865cdf0e10cSrcweir 				pLay->GetFmt()->GetDoc()->GetLayouter()->InsertEndnotes(pSect);
1866cdf0e10cSrcweir 				pSect->CalcFtnCntnt();
1867cdf0e10cSrcweir 			}
1868cdf0e10cSrcweir 			if( pSect->HasFollow() )
1869cdf0e10cSrcweir 			{
1870cdf0e10cSrcweir 				SwSectionFrm* pNxt = pSect->GetFollow();
1871cdf0e10cSrcweir 				while( pNxt && !pNxt->ContainsCntnt() )
1872cdf0e10cSrcweir 					pNxt = pNxt->GetFollow();
1873cdf0e10cSrcweir 				if( pNxt )
1874cdf0e10cSrcweir 					pNxt->CalcFtnCntnt();
1875cdf0e10cSrcweir 			}
1876cdf0e10cSrcweir 			if( bCollect )
1877cdf0e10cSrcweir 			{
1878cdf0e10cSrcweir 				pFrm = pLay->ContainsAny();
1879cdf0e10cSrcweir 				bCollect = sal_False;
1880cdf0e10cSrcweir 				if( pFrm )
1881cdf0e10cSrcweir 					continue;
1882cdf0e10cSrcweir 			}
1883cdf0e10cSrcweir 		}
1884cdf0e10cSrcweir 		break;
1885cdf0e10cSrcweir 	}
1886cdf0e10cSrcweir 	while( sal_True );
1887cdf0e10cSrcweir }
1888cdf0e10cSrcweir 
1889cdf0e10cSrcweir /*************************************************************************
1890cdf0e10cSrcweir |*
1891cdf0e10cSrcweir |*	SwFlyFrm::MakeFlyPos()
1892cdf0e10cSrcweir |*
1893cdf0e10cSrcweir |*	Ersterstellung		MA ??
1894cdf0e10cSrcweir |*	Letzte Aenderung	MA 14. Nov. 96
1895cdf0e10cSrcweir |*
1896cdf0e10cSrcweir |*************************************************************************/
1897cdf0e10cSrcweir // OD 2004-03-23 #i26791#
1898cdf0e10cSrcweir //void SwFlyFrm::MakeFlyPos()
MakeObjPos()1899cdf0e10cSrcweir void SwFlyFrm::MakeObjPos()
1900cdf0e10cSrcweir {
1901cdf0e10cSrcweir     if ( !bValidPos )
1902cdf0e10cSrcweir     {
1903cdf0e10cSrcweir         bValidPos = sal_True;
1904cdf0e10cSrcweir 
1905cdf0e10cSrcweir         // OD 29.10.2003 #113049# - use new class to position object
1906cdf0e10cSrcweir         GetAnchorFrm()->Calc();
1907cdf0e10cSrcweir         objectpositioning::SwToLayoutAnchoredObjectPosition
1908cdf0e10cSrcweir                 aObjPositioning( *GetVirtDrawObj() );
1909cdf0e10cSrcweir         aObjPositioning.CalcPosition();
1910cdf0e10cSrcweir 
1911cdf0e10cSrcweir         // --> OD 2006-10-05 #i58280#
1912cdf0e10cSrcweir         // update relative position
1913cdf0e10cSrcweir         SetCurrRelPos( aObjPositioning.GetRelPos() );
1914cdf0e10cSrcweir         // <--
1915cdf0e10cSrcweir 
1916cdf0e10cSrcweir         SWRECTFN( GetAnchorFrm() );
1917cdf0e10cSrcweir         aFrm.Pos( aObjPositioning.GetRelPos() );
1918cdf0e10cSrcweir         aFrm.Pos() += (GetAnchorFrm()->Frm().*fnRect->fnGetPos)();
1919cdf0e10cSrcweir         // --> OD 2006-09-11 #i69335#
1920cdf0e10cSrcweir         InvalidateObjRectWithSpaces();
1921cdf0e10cSrcweir         // <--
1922cdf0e10cSrcweir     }
1923cdf0e10cSrcweir }
1924cdf0e10cSrcweir 
1925cdf0e10cSrcweir /*************************************************************************
1926cdf0e10cSrcweir |*
1927cdf0e10cSrcweir |*	SwFlyFrm::MakePrtArea()
1928cdf0e10cSrcweir |*
1929cdf0e10cSrcweir |*	Ersterstellung		MA 23. Jun. 93
1930cdf0e10cSrcweir |*	Letzte Aenderung	MA 23. Jun. 93
1931cdf0e10cSrcweir |*
1932cdf0e10cSrcweir |*************************************************************************/
MakePrtArea(const SwBorderAttrs & rAttrs)1933cdf0e10cSrcweir void SwFlyFrm::MakePrtArea( const SwBorderAttrs &rAttrs )
1934cdf0e10cSrcweir {
1935cdf0e10cSrcweir 
1936cdf0e10cSrcweir 	if ( !bValidPrtArea )
1937cdf0e10cSrcweir 	{
1938cdf0e10cSrcweir 		bValidPrtArea = sal_True;
1939cdf0e10cSrcweir 
1940cdf0e10cSrcweir         // OD 31.07.2003 #110978# - consider vertical layout
1941cdf0e10cSrcweir         SWRECTFN( this )
1942cdf0e10cSrcweir         (this->*fnRect->fnSetXMargins)( rAttrs.CalcLeftLine(),
1943cdf0e10cSrcweir                                         rAttrs.CalcRightLine() );
1944cdf0e10cSrcweir         (this->*fnRect->fnSetYMargins)( rAttrs.CalcTopLine(),
1945cdf0e10cSrcweir                                         rAttrs.CalcBottomLine() );
1946cdf0e10cSrcweir 	}
1947cdf0e10cSrcweir }
1948cdf0e10cSrcweir 
1949cdf0e10cSrcweir /*************************************************************************
1950cdf0e10cSrcweir |*
1951cdf0e10cSrcweir |*	SwFlyFrm::_Grow(), _Shrink()
1952cdf0e10cSrcweir |*
1953cdf0e10cSrcweir |*	Ersterstellung		MA 05. Oct. 92
1954cdf0e10cSrcweir |*	Letzte Aenderung	MA 05. Sep. 96
1955cdf0e10cSrcweir |*
1956cdf0e10cSrcweir |*************************************************************************/
1957cdf0e10cSrcweir 
_Grow(SwTwips nDist,sal_Bool bTst)1958cdf0e10cSrcweir SwTwips SwFlyFrm::_Grow( SwTwips nDist, sal_Bool bTst )
1959cdf0e10cSrcweir {
1960cdf0e10cSrcweir     SWRECTFN( this )
1961cdf0e10cSrcweir     if ( Lower() && !IsColLocked() && !HasFixSize() )
1962cdf0e10cSrcweir 	{
1963cdf0e10cSrcweir         SwTwips nSize = (Frm().*fnRect->fnGetHeight)();
1964cdf0e10cSrcweir         if( nSize > 0 && nDist > ( LONG_MAX - nSize ) )
1965cdf0e10cSrcweir             nDist = LONG_MAX - nSize;
1966cdf0e10cSrcweir 
1967cdf0e10cSrcweir 		if ( nDist <= 0L )
1968cdf0e10cSrcweir 			return 0L;
1969cdf0e10cSrcweir 
1970cdf0e10cSrcweir 		if ( Lower()->IsColumnFrm() )
1971cdf0e10cSrcweir 		{	//Bei Spaltigkeit ubernimmt das Format die Kontrolle ueber
1972cdf0e10cSrcweir 			//das Wachstum (wg. des Ausgleichs).
1973cdf0e10cSrcweir 			if ( !bTst )
1974cdf0e10cSrcweir             {
1975cdf0e10cSrcweir                 // --> OD 2004-06-09 #i28701# - unlock position of Writer fly frame
1976cdf0e10cSrcweir                 UnlockPosition();
1977cdf0e10cSrcweir                 _InvalidatePos();
1978cdf0e10cSrcweir 				InvalidateSize();
1979cdf0e10cSrcweir 			}
1980cdf0e10cSrcweir 			return 0L;
1981cdf0e10cSrcweir 		}
1982cdf0e10cSrcweir 
1983cdf0e10cSrcweir 		if ( !bTst )
1984cdf0e10cSrcweir 		{
1985cdf0e10cSrcweir             const SwRect aOld( GetObjRectWithSpaces() );
1986cdf0e10cSrcweir 			_InvalidateSize();
1987cdf0e10cSrcweir 			const sal_Bool bOldLock = bLocked;
1988cdf0e10cSrcweir 			Unlock();
1989cdf0e10cSrcweir             if ( IsFlyFreeFrm() )
1990cdf0e10cSrcweir             {
1991cdf0e10cSrcweir                 // --> OD 2004-11-12 #i37068# - no format of position here
1992cdf0e10cSrcweir                 // and prevent move in method <CheckClip(..)>.
1993cdf0e10cSrcweir                 // This is needed to prevent layout loop caused by nested
1994cdf0e10cSrcweir                 // Writer fly frames - inner Writer fly frames format its
1995cdf0e10cSrcweir                 // anchor, which grows/shrinks the outer Writer fly frame.
1996cdf0e10cSrcweir                 // Note: position will be invalidated below.
1997cdf0e10cSrcweir                 bValidPos = sal_True;
1998cdf0e10cSrcweir                 // --> OD 2005-10-10 #i55416#
1999cdf0e10cSrcweir                 // Suppress format of width for autowidth frame, because the
2000cdf0e10cSrcweir                 // format of the width would call <SwTxtFrm::CalcFitToContent()>
2001cdf0e10cSrcweir                 // for the lower frame, which initiated this grow.
2002cdf0e10cSrcweir                 const sal_Bool bOldFormatHeightOnly = bFormatHeightOnly;
2003cdf0e10cSrcweir                 const SwFmtFrmSize& rFrmSz = GetFmt()->GetFrmSize();
2004cdf0e10cSrcweir                 if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
2005cdf0e10cSrcweir                 {
2006cdf0e10cSrcweir                     bFormatHeightOnly = sal_True;
2007cdf0e10cSrcweir                 }
2008cdf0e10cSrcweir                 // <--
2009cdf0e10cSrcweir                 static_cast<SwFlyFreeFrm*>(this)->SetNoMoveOnCheckClip( true );
2010cdf0e10cSrcweir                 ((SwFlyFreeFrm*)this)->SwFlyFreeFrm::MakeAll();
2011cdf0e10cSrcweir                 static_cast<SwFlyFreeFrm*>(this)->SetNoMoveOnCheckClip( false );
2012cdf0e10cSrcweir                 // --> OD 2005-10-10 #i55416#
2013cdf0e10cSrcweir                 if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
2014cdf0e10cSrcweir                 {
2015cdf0e10cSrcweir                     bFormatHeightOnly = bOldFormatHeightOnly;
2016cdf0e10cSrcweir                 }
2017cdf0e10cSrcweir                 // <--
2018cdf0e10cSrcweir                 // <--
2019cdf0e10cSrcweir             }
2020cdf0e10cSrcweir             else
2021cdf0e10cSrcweir 				MakeAll();
2022cdf0e10cSrcweir 			_InvalidateSize();
2023cdf0e10cSrcweir 			InvalidatePos();
2024cdf0e10cSrcweir 			if ( bOldLock )
2025cdf0e10cSrcweir 				Lock();
2026cdf0e10cSrcweir             const SwRect aNew( GetObjRectWithSpaces() );
2027cdf0e10cSrcweir 			if ( aOld != aNew )
2028cdf0e10cSrcweir 				::Notify( this, FindPageFrm(), aOld );
2029cdf0e10cSrcweir             return (aNew.*fnRect->fnGetHeight)()-(aOld.*fnRect->fnGetHeight)();
2030cdf0e10cSrcweir 		}
2031cdf0e10cSrcweir 		return nDist;
2032cdf0e10cSrcweir 	}
2033cdf0e10cSrcweir 	return 0L;
2034cdf0e10cSrcweir }
2035cdf0e10cSrcweir 
_Shrink(SwTwips nDist,sal_Bool bTst)2036cdf0e10cSrcweir SwTwips SwFlyFrm::_Shrink( SwTwips nDist, sal_Bool bTst )
2037cdf0e10cSrcweir {
2038cdf0e10cSrcweir     if( Lower() && !IsColLocked() && !HasFixSize() && !IsNoShrink() )
2039cdf0e10cSrcweir 	{
2040cdf0e10cSrcweir         SWRECTFN( this )
2041cdf0e10cSrcweir         SwTwips nHeight = (Frm().*fnRect->fnGetHeight)();
2042cdf0e10cSrcweir         if ( nDist > nHeight )
2043cdf0e10cSrcweir             nDist = nHeight;
2044cdf0e10cSrcweir 
2045cdf0e10cSrcweir         SwTwips nVal = nDist;
2046cdf0e10cSrcweir 		if ( IsMinHeight() )
2047cdf0e10cSrcweir 		{
2048cdf0e10cSrcweir             const SwFmtFrmSize& rFmtSize = GetFmt()->GetFrmSize();
2049cdf0e10cSrcweir             SwTwips nFmtHeight = bVert ? rFmtSize.GetWidth() : rFmtSize.GetHeight();
2050cdf0e10cSrcweir 
2051cdf0e10cSrcweir             nVal = Min( nDist, nHeight - nFmtHeight );
2052cdf0e10cSrcweir 		}
2053cdf0e10cSrcweir 
2054cdf0e10cSrcweir 		if ( nVal <= 0L )
2055cdf0e10cSrcweir 			return 0L;
2056cdf0e10cSrcweir 
2057cdf0e10cSrcweir 		if ( Lower()->IsColumnFrm() )
2058cdf0e10cSrcweir 		{	//Bei Spaltigkeit ubernimmt das Format die Kontrolle ueber
2059cdf0e10cSrcweir 			//das Wachstum (wg. des Ausgleichs).
2060cdf0e10cSrcweir 			if ( !bTst )
2061cdf0e10cSrcweir 			{
2062cdf0e10cSrcweir                 SwRect aOld( GetObjRectWithSpaces() );
2063cdf0e10cSrcweir                 (Frm().*fnRect->fnSetHeight)( nHeight - nVal );
2064cdf0e10cSrcweir                 // --> OD 2006-08-16 #i68520#
2065cdf0e10cSrcweir                 if ( nHeight - nVal != 0 )
2066cdf0e10cSrcweir                 {
2067cdf0e10cSrcweir                     InvalidateObjRectWithSpaces();
2068cdf0e10cSrcweir                 }
2069cdf0e10cSrcweir                 // <--
2070cdf0e10cSrcweir                 nHeight = (Prt().*fnRect->fnGetHeight)();
2071cdf0e10cSrcweir                 (Prt().*fnRect->fnSetHeight)( nHeight - nVal );
2072cdf0e10cSrcweir 				_InvalidatePos();
2073cdf0e10cSrcweir 				InvalidateSize();
2074cdf0e10cSrcweir 				::Notify( this, FindPageFrm(), aOld );
2075cdf0e10cSrcweir 				NotifyDrawObj();
2076cdf0e10cSrcweir                 if ( GetAnchorFrm()->IsInFly() )
2077cdf0e10cSrcweir                     AnchorFrm()->FindFlyFrm()->Shrink( nDist, bTst );
2078cdf0e10cSrcweir 			}
2079cdf0e10cSrcweir 			return 0L;
2080cdf0e10cSrcweir 		}
2081cdf0e10cSrcweir 
2082cdf0e10cSrcweir 		if ( !bTst )
2083cdf0e10cSrcweir 		{
2084cdf0e10cSrcweir             const SwRect aOld( GetObjRectWithSpaces() );
2085cdf0e10cSrcweir 			_InvalidateSize();
2086cdf0e10cSrcweir 			const sal_Bool bOldLocked = bLocked;
2087cdf0e10cSrcweir 			Unlock();
2088cdf0e10cSrcweir             if ( IsFlyFreeFrm() )
2089cdf0e10cSrcweir             {
2090cdf0e10cSrcweir                 // --> OD 2004-11-12 #i37068# - no format of position here
2091cdf0e10cSrcweir                 // and prevent move in method <CheckClip(..)>.
2092cdf0e10cSrcweir                 // This is needed to prevent layout loop caused by nested
2093cdf0e10cSrcweir                 // Writer fly frames - inner Writer fly frames format its
2094cdf0e10cSrcweir                 // anchor, which grows/shrinks the outer Writer fly frame.
2095cdf0e10cSrcweir                 // Note: position will be invalidated below.
2096cdf0e10cSrcweir                 bValidPos = sal_True;
2097cdf0e10cSrcweir                 // --> OD 2005-10-10 #i55416#
2098cdf0e10cSrcweir                 // Suppress format of width for autowidth frame, because the
2099cdf0e10cSrcweir                 // format of the width would call <SwTxtFrm::CalcFitToContent()>
2100cdf0e10cSrcweir                 // for the lower frame, which initiated this shrink.
2101cdf0e10cSrcweir                 const sal_Bool bOldFormatHeightOnly = bFormatHeightOnly;
2102cdf0e10cSrcweir                 const SwFmtFrmSize& rFrmSz = GetFmt()->GetFrmSize();
2103cdf0e10cSrcweir                 if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
2104cdf0e10cSrcweir                 {
2105cdf0e10cSrcweir                     bFormatHeightOnly = sal_True;
2106cdf0e10cSrcweir                 }
2107cdf0e10cSrcweir                 // <--
2108cdf0e10cSrcweir                 static_cast<SwFlyFreeFrm*>(this)->SetNoMoveOnCheckClip( true );
2109cdf0e10cSrcweir                 ((SwFlyFreeFrm*)this)->SwFlyFreeFrm::MakeAll();
2110cdf0e10cSrcweir                 static_cast<SwFlyFreeFrm*>(this)->SetNoMoveOnCheckClip( false );
2111cdf0e10cSrcweir                 // --> OD 2005-10-10 #i55416#
2112cdf0e10cSrcweir                 if ( rFrmSz.GetWidthSizeType() != ATT_FIX_SIZE )
2113cdf0e10cSrcweir                 {
2114cdf0e10cSrcweir                     bFormatHeightOnly = bOldFormatHeightOnly;
2115cdf0e10cSrcweir                 }
2116cdf0e10cSrcweir                 // <--
2117cdf0e10cSrcweir                 // <--
2118cdf0e10cSrcweir             }
2119cdf0e10cSrcweir             else
2120cdf0e10cSrcweir 				MakeAll();
2121cdf0e10cSrcweir 			_InvalidateSize();
2122cdf0e10cSrcweir 			InvalidatePos();
2123cdf0e10cSrcweir 			if ( bOldLocked )
2124cdf0e10cSrcweir 				Lock();
2125cdf0e10cSrcweir             const SwRect aNew( GetObjRectWithSpaces() );
2126cdf0e10cSrcweir 			if ( aOld != aNew )
2127cdf0e10cSrcweir 			{
2128cdf0e10cSrcweir 				::Notify( this, FindPageFrm(), aOld );
2129cdf0e10cSrcweir                 if ( GetAnchorFrm()->IsInFly() )
2130cdf0e10cSrcweir                     AnchorFrm()->FindFlyFrm()->Shrink( nDist, bTst );
2131cdf0e10cSrcweir 			}
2132cdf0e10cSrcweir             return (aOld.*fnRect->fnGetHeight)() -
2133cdf0e10cSrcweir                    (aNew.*fnRect->fnGetHeight)();
2134cdf0e10cSrcweir 		}
2135cdf0e10cSrcweir 		return nVal;
2136cdf0e10cSrcweir 	}
2137cdf0e10cSrcweir 	return 0L;
2138cdf0e10cSrcweir }
2139cdf0e10cSrcweir 
2140cdf0e10cSrcweir /*************************************************************************
2141cdf0e10cSrcweir |*
2142cdf0e10cSrcweir |*	SwFlyFrm::ChgSize()
2143cdf0e10cSrcweir |*
2144cdf0e10cSrcweir |*	Ersterstellung		MA 05. Oct. 92
2145cdf0e10cSrcweir |*	Letzte Aenderung	MA 04. Sep. 96
2146cdf0e10cSrcweir |*
2147cdf0e10cSrcweir |*************************************************************************/
2148cdf0e10cSrcweir 
ChgSize(const Size & aNewSize)2149cdf0e10cSrcweir Size SwFlyFrm::ChgSize( const Size& aNewSize )
2150cdf0e10cSrcweir {
2151cdf0e10cSrcweir     // --> OD 2006-01-19 #i53298#
2152cdf0e10cSrcweir     // If the fly frame anchored at-paragraph or at-character contains an OLE
2153cdf0e10cSrcweir     // object, assure that the new size fits into the current clipping area
2154cdf0e10cSrcweir     // of the fly frame
2155cdf0e10cSrcweir     Size aAdjustedNewSize( aNewSize );
2156cdf0e10cSrcweir     {
2157cdf0e10cSrcweir         if ( dynamic_cast<SwFlyAtCntFrm*>(this) &&
2158cdf0e10cSrcweir              Lower() && dynamic_cast<SwNoTxtFrm*>(Lower()) &&
2159cdf0e10cSrcweir              static_cast<SwNoTxtFrm*>(Lower())->GetNode()->GetOLENode() )
2160cdf0e10cSrcweir         {
2161cdf0e10cSrcweir             SwRect aClipRect;
2162cdf0e10cSrcweir             ::CalcClipRect( GetVirtDrawObj(), aClipRect, sal_False );
2163cdf0e10cSrcweir             if ( aAdjustedNewSize.Width() > aClipRect.Width() )
2164cdf0e10cSrcweir             {
2165cdf0e10cSrcweir                 aAdjustedNewSize.setWidth( aClipRect.Width() );
2166cdf0e10cSrcweir             }
2167cdf0e10cSrcweir             if ( aAdjustedNewSize.Height() > aClipRect.Height() )
2168cdf0e10cSrcweir             {
2169cdf0e10cSrcweir                 aAdjustedNewSize.setWidth( aClipRect.Height() );
2170cdf0e10cSrcweir             }
2171cdf0e10cSrcweir         }
2172cdf0e10cSrcweir     }
2173cdf0e10cSrcweir     // <--
2174cdf0e10cSrcweir     if ( aAdjustedNewSize != Frm().SSize() )
2175cdf0e10cSrcweir 	{
2176cdf0e10cSrcweir 		SwFrmFmt *pFmt = GetFmt();
2177cdf0e10cSrcweir 		SwFmtFrmSize aSz( pFmt->GetFrmSize() );
2178cdf0e10cSrcweir         aSz.SetWidth( aAdjustedNewSize.Width() );
2179cdf0e10cSrcweir         // --> OD 2006-01-19 #i53298# - no tolerance any more.
2180cdf0e10cSrcweir         // If it reveals that the tolerance is still needed, then suppress a
2181cdf0e10cSrcweir         // <SetAttr> call, if <aSz> equals the current <SwFmtFrmSize> attribute.
2182cdf0e10cSrcweir //        if ( Abs(aAdjustedNewSize.Height() - aSz.GetHeight()) > 1 )
2183cdf0e10cSrcweir         aSz.SetHeight( aAdjustedNewSize.Height() );
2184cdf0e10cSrcweir         // <--
2185cdf0e10cSrcweir 		// uebers Doc fuers Undo!
2186cdf0e10cSrcweir 		pFmt->GetDoc()->SetAttr( aSz, *pFmt );
2187cdf0e10cSrcweir 		return aSz.GetSize();
2188cdf0e10cSrcweir 	}
2189cdf0e10cSrcweir 	else
2190cdf0e10cSrcweir 		return Frm().SSize();
2191cdf0e10cSrcweir }
2192cdf0e10cSrcweir 
2193cdf0e10cSrcweir /*************************************************************************
2194cdf0e10cSrcweir |*
2195cdf0e10cSrcweir |*	SwFlyFrm::IsLowerOf()
2196cdf0e10cSrcweir |*
2197cdf0e10cSrcweir |*	Ersterstellung		MA 27. Dec. 93
2198cdf0e10cSrcweir |*	Letzte Aenderung	MA 27. Dec. 93
2199cdf0e10cSrcweir |*
2200cdf0e10cSrcweir |*************************************************************************/
2201cdf0e10cSrcweir 
IsLowerOf(const SwLayoutFrm * pUpperFrm) const2202cdf0e10cSrcweir sal_Bool SwFlyFrm::IsLowerOf( const SwLayoutFrm* pUpperFrm ) const
2203cdf0e10cSrcweir {
2204cdf0e10cSrcweir     ASSERT( GetAnchorFrm(), "8-( Fly is lost in Space." );
2205cdf0e10cSrcweir     const SwFrm* pFrm = GetAnchorFrm();
2206cdf0e10cSrcweir     do
2207cdf0e10cSrcweir     {
2208cdf0e10cSrcweir         if ( pFrm == pUpperFrm )
2209cdf0e10cSrcweir             return sal_True;
2210cdf0e10cSrcweir         pFrm = pFrm->IsFlyFrm()
2211cdf0e10cSrcweir                ? ((const SwFlyFrm*)pFrm)->GetAnchorFrm()
2212cdf0e10cSrcweir                : pFrm->GetUpper();
2213cdf0e10cSrcweir     } while ( pFrm );
2214cdf0e10cSrcweir     return sal_False;
2215cdf0e10cSrcweir }
2216cdf0e10cSrcweir 
2217cdf0e10cSrcweir /*************************************************************************
2218cdf0e10cSrcweir |*
2219cdf0e10cSrcweir |*	SwFlyFrm::Cut()
2220cdf0e10cSrcweir |*
2221cdf0e10cSrcweir |*	Ersterstellung		MA 23. Feb. 94
2222cdf0e10cSrcweir |*	Letzte Aenderung	MA 23. Feb. 94
2223cdf0e10cSrcweir |*
2224cdf0e10cSrcweir |*************************************************************************/
2225cdf0e10cSrcweir 
Cut()2226cdf0e10cSrcweir void SwFlyFrm::Cut()
2227cdf0e10cSrcweir {
2228cdf0e10cSrcweir }
2229cdf0e10cSrcweir 
2230cdf0e10cSrcweir /*************************************************************************
2231cdf0e10cSrcweir |*
2232cdf0e10cSrcweir |*	SwFrm::AppendFly(), RemoveFly()
2233cdf0e10cSrcweir |*
2234cdf0e10cSrcweir |*	Ersterstellung		MA 25. Aug. 92
2235cdf0e10cSrcweir |*	Letzte Aenderung	MA 09. Jun. 95
2236cdf0e10cSrcweir |*
2237cdf0e10cSrcweir |*************************************************************************/
2238cdf0e10cSrcweir 
AppendFly(SwFlyFrm * pNew)2239cdf0e10cSrcweir void SwFrm::AppendFly( SwFlyFrm *pNew )
2240cdf0e10cSrcweir {
2241cdf0e10cSrcweir     if ( !pDrawObjs )
2242cdf0e10cSrcweir         pDrawObjs = new SwSortedObjs();
2243cdf0e10cSrcweir     pDrawObjs->Insert( *pNew );
2244cdf0e10cSrcweir     pNew->ChgAnchorFrm( this );
2245cdf0e10cSrcweir 
2246*2a0ce834SOliver-Rainer Wittmann     SwPageFrm* pPage = FindPageFrm();
2247*2a0ce834SOliver-Rainer Wittmann     if ( pPage != NULL )
2248*2a0ce834SOliver-Rainer Wittmann     {
2249*2a0ce834SOliver-Rainer Wittmann         pPage->AppendFlyToPage( pNew );
2250cdf0e10cSrcweir     }
2251cdf0e10cSrcweir }
2252cdf0e10cSrcweir 
RemoveFly(SwFlyFrm * pToRemove)2253cdf0e10cSrcweir void SwFrm::RemoveFly( SwFlyFrm *pToRemove )
2254cdf0e10cSrcweir {
2255cdf0e10cSrcweir 	//Bei der Seite Abmelden - kann schon passiert sein weil die Seite
2256cdf0e10cSrcweir 	//bereits destruiert wurde.
2257cdf0e10cSrcweir 	SwPageFrm *pPage = pToRemove->FindPageFrm();
2258cdf0e10cSrcweir 	if ( pPage && pPage->GetSortedObjs() )
2259cdf0e10cSrcweir     {
2260cdf0e10cSrcweir         pPage->RemoveFlyFromPage( pToRemove );
2261cdf0e10cSrcweir     }
2262cdf0e10cSrcweir     // --> OD 2008-05-19 #i73201#
2263cdf0e10cSrcweir     else
2264cdf0e10cSrcweir     {
2265cdf0e10cSrcweir         if ( pToRemove->IsAccessibleFrm() &&
2266cdf0e10cSrcweir              pToRemove->GetFmt() &&
2267cdf0e10cSrcweir              !pToRemove->IsFlyInCntFrm() )
2268cdf0e10cSrcweir         {
2269cdf0e10cSrcweir             SwRootFrm *pRootFrm = getRootFrm();
2270cdf0e10cSrcweir             if( pRootFrm && pRootFrm->IsAnyShellAccessible() )
2271cdf0e10cSrcweir             {
2272cdf0e10cSrcweir                 ViewShell *pVSh = pRootFrm->GetCurrShell();
2273cdf0e10cSrcweir                 if( pVSh && pVSh->Imp() )
2274cdf0e10cSrcweir                 {
2275cdf0e10cSrcweir                     pVSh->Imp()->DisposeAccessibleFrm( pToRemove );
2276cdf0e10cSrcweir                 }
2277cdf0e10cSrcweir             }
2278cdf0e10cSrcweir         }
2279cdf0e10cSrcweir     }
2280cdf0e10cSrcweir     // <--
2281cdf0e10cSrcweir 
2282cdf0e10cSrcweir     pDrawObjs->Remove( *pToRemove );
2283cdf0e10cSrcweir 	if ( !pDrawObjs->Count() )
2284cdf0e10cSrcweir 		DELETEZ( pDrawObjs );
2285cdf0e10cSrcweir 
2286cdf0e10cSrcweir     pToRemove->ChgAnchorFrm( 0 );
2287cdf0e10cSrcweir 
2288cdf0e10cSrcweir 	if ( !pToRemove->IsFlyInCntFrm() && GetUpper() && IsInTab() )//MA_FLY_HEIGHT
2289cdf0e10cSrcweir 		GetUpper()->InvalidateSize();
2290cdf0e10cSrcweir }
2291cdf0e10cSrcweir 
2292cdf0e10cSrcweir /*************************************************************************
2293cdf0e10cSrcweir |*
2294cdf0e10cSrcweir |*	SwFrm::AppendDrawObj(), RemoveDrawObj()
2295cdf0e10cSrcweir |*
2296cdf0e10cSrcweir |*  --> OD 2004-07-06 #i28701# - new methods
2297cdf0e10cSrcweir |*
2298cdf0e10cSrcweir |*************************************************************************/
AppendDrawObj(SwAnchoredObject & _rNewObj)2299cdf0e10cSrcweir void SwFrm::AppendDrawObj( SwAnchoredObject& _rNewObj )
2300cdf0e10cSrcweir {
2301cdf0e10cSrcweir     if ( !_rNewObj.ISA(SwAnchoredDrawObject) )
2302cdf0e10cSrcweir     {
2303cdf0e10cSrcweir         ASSERT( false,
2304cdf0e10cSrcweir                 "SwFrm::AppendDrawObj(..) - anchored object of unexcepted type -> object not appended" );
2305cdf0e10cSrcweir         return;
2306cdf0e10cSrcweir     }
2307cdf0e10cSrcweir 
2308cdf0e10cSrcweir     if ( !_rNewObj.GetDrawObj()->ISA(SwDrawVirtObj) &&
2309cdf0e10cSrcweir          _rNewObj.GetAnchorFrm() && _rNewObj.GetAnchorFrm() != this )
2310cdf0e10cSrcweir     {
2311cdf0e10cSrcweir         // perform disconnect from layout, if 'master' drawing object is appended
2312cdf0e10cSrcweir         // to a new frame.
2313cdf0e10cSrcweir         static_cast<SwDrawContact*>(::GetUserCall( _rNewObj.GetDrawObj() ))->
2314cdf0e10cSrcweir                                                 DisconnectFromLayout( false );
2315cdf0e10cSrcweir     }
2316cdf0e10cSrcweir 
2317cdf0e10cSrcweir     if ( _rNewObj.GetAnchorFrm() != this )
2318cdf0e10cSrcweir     {
2319cdf0e10cSrcweir         if ( !pDrawObjs )
2320cdf0e10cSrcweir             pDrawObjs = new SwSortedObjs();
2321cdf0e10cSrcweir         pDrawObjs->Insert( _rNewObj );
2322cdf0e10cSrcweir         _rNewObj.ChgAnchorFrm( this );
2323cdf0e10cSrcweir     }
2324cdf0e10cSrcweir 
2325cdf0e10cSrcweir     // --> OD 2010-09-14 #i113730#
2326cdf0e10cSrcweir     // Assure the control objects and group objects containing controls are on the control layer
2327cdf0e10cSrcweir     if ( ::CheckControlLayer( _rNewObj.DrawObj() ) )
2328cdf0e10cSrcweir     {
2329cdf0e10cSrcweir         const IDocumentDrawModelAccess* pIDDMA = (IsFlyFrm())
2330cdf0e10cSrcweir             ? static_cast<SwFlyFrm*>(this)->GetFmt()->
2331cdf0e10cSrcweir                     getIDocumentDrawModelAccess()
2332cdf0e10cSrcweir             : GetUpper()->GetFmt()->getIDocumentDrawModelAccess();
2333cdf0e10cSrcweir         const SdrLayerID aCurrentLayer(_rNewObj.DrawObj()->GetLayer());
2334cdf0e10cSrcweir         const SdrLayerID aControlLayerID(pIDDMA->GetControlsId());
2335cdf0e10cSrcweir         const SdrLayerID aInvisibleControlLayerID(pIDDMA->GetInvisibleControlsId());
2336cdf0e10cSrcweir 
2337cdf0e10cSrcweir         if(aCurrentLayer != aControlLayerID && aCurrentLayer != aInvisibleControlLayerID)
2338cdf0e10cSrcweir         {
2339cdf0e10cSrcweir             if ( aCurrentLayer == pIDDMA->GetInvisibleHellId() ||
2340cdf0e10cSrcweir                  aCurrentLayer == pIDDMA->GetInvisibleHeavenId() )
2341cdf0e10cSrcweir             {
2342cdf0e10cSrcweir                 _rNewObj.DrawObj()->SetLayer(aInvisibleControlLayerID);
2343cdf0e10cSrcweir             }
2344cdf0e10cSrcweir             else
2345cdf0e10cSrcweir             {
2346cdf0e10cSrcweir                 _rNewObj.DrawObj()->SetLayer(aControlLayerID);
2347cdf0e10cSrcweir             }
2348cdf0e10cSrcweir         }
2349cdf0e10cSrcweir     }
2350cdf0e10cSrcweir     // <--
2351cdf0e10cSrcweir 
2352cdf0e10cSrcweir     // no direct positioning needed, but invalidate the drawing object position
2353cdf0e10cSrcweir     _rNewObj.InvalidateObjPos();
2354cdf0e10cSrcweir 
2355cdf0e10cSrcweir     // register at page frame
2356cdf0e10cSrcweir     SwPageFrm* pPage = FindPageFrm();
2357cdf0e10cSrcweir     if ( pPage )
2358cdf0e10cSrcweir     {
2359cdf0e10cSrcweir         pPage->AppendDrawObjToPage( _rNewObj );
2360cdf0e10cSrcweir     }
2361cdf0e10cSrcweir 
2362cdf0e10cSrcweir     // Notify accessible layout.
2363cdf0e10cSrcweir     ViewShell* pSh = getRootFrm()->GetCurrShell();
2364cdf0e10cSrcweir     if( pSh )
2365cdf0e10cSrcweir     {
2366cdf0e10cSrcweir         SwRootFrm* pLayout = getRootFrm();
2367cdf0e10cSrcweir         if( pLayout && pLayout->IsAnyShellAccessible() )
2368cdf0e10cSrcweir         pSh->Imp()->AddAccessibleObj( _rNewObj.GetDrawObj() );
2369cdf0e10cSrcweir     }
2370cdf0e10cSrcweir }
2371cdf0e10cSrcweir 
RemoveDrawObj(SwAnchoredObject & _rToRemoveObj)2372cdf0e10cSrcweir void SwFrm::RemoveDrawObj( SwAnchoredObject& _rToRemoveObj )
2373cdf0e10cSrcweir {
2374cdf0e10cSrcweir     // Notify accessible layout.
2375cdf0e10cSrcweir     ViewShell* pSh = getRootFrm()->GetCurrShell();
2376cdf0e10cSrcweir     if( pSh )
2377cdf0e10cSrcweir     {
2378cdf0e10cSrcweir         SwRootFrm* pLayout = getRootFrm();
2379cdf0e10cSrcweir         if( pLayout && pLayout->IsAnyShellAccessible() )
2380cdf0e10cSrcweir         pSh->Imp()->DisposeAccessibleObj( _rToRemoveObj.GetDrawObj() );
2381cdf0e10cSrcweir     }
2382cdf0e10cSrcweir 
2383cdf0e10cSrcweir     // deregister from page frame
2384cdf0e10cSrcweir     SwPageFrm* pPage = _rToRemoveObj.GetPageFrm();
2385cdf0e10cSrcweir     if ( pPage && pPage->GetSortedObjs() )
2386cdf0e10cSrcweir         pPage->RemoveDrawObjFromPage( _rToRemoveObj );
2387cdf0e10cSrcweir 
2388cdf0e10cSrcweir     pDrawObjs->Remove( _rToRemoveObj );
2389cdf0e10cSrcweir     if ( !pDrawObjs->Count() )
2390cdf0e10cSrcweir         DELETEZ( pDrawObjs );
2391cdf0e10cSrcweir 
2392cdf0e10cSrcweir     _rToRemoveObj.ChgAnchorFrm( 0 );
2393cdf0e10cSrcweir }
2394cdf0e10cSrcweir 
2395cdf0e10cSrcweir /*************************************************************************
2396cdf0e10cSrcweir |*
2397cdf0e10cSrcweir |*  SwFrm::InvalidateObjs()
2398cdf0e10cSrcweir |*
2399cdf0e10cSrcweir |*	Ersterstellung		MA 29. Nov. 96
2400cdf0e10cSrcweir |*	Letzte Aenderung	MA 29. Nov. 96
2401cdf0e10cSrcweir |*
2402cdf0e10cSrcweir |*************************************************************************/
2403cdf0e10cSrcweir // --> OD 2004-07-01 #i28701# - change purpose of method and adjust its name
InvalidateObjs(const bool _bInvaPosOnly,const bool _bNoInvaOfAsCharAnchoredObjs)2404cdf0e10cSrcweir void SwFrm::InvalidateObjs( const bool _bInvaPosOnly,
2405cdf0e10cSrcweir                             const bool _bNoInvaOfAsCharAnchoredObjs )
2406cdf0e10cSrcweir {
2407cdf0e10cSrcweir 	if ( GetDrawObjs() )
2408cdf0e10cSrcweir 	{
2409cdf0e10cSrcweir         // --> OD 2004-10-08 #i26945# - determine page the frame is on,
2410cdf0e10cSrcweir         // in order to check, if anchored object is registered at the same
2411cdf0e10cSrcweir         // page.
2412cdf0e10cSrcweir         const SwPageFrm* pPageFrm = FindPageFrm();
2413cdf0e10cSrcweir         // <--
2414cdf0e10cSrcweir         // --> OD 2004-07-01 #i28701# - re-factoring
2415cdf0e10cSrcweir         sal_uInt32 i = 0;
2416cdf0e10cSrcweir         for ( ; i < GetDrawObjs()->Count(); ++i )
2417cdf0e10cSrcweir         {
2418cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*GetDrawObjs())[i];
2419cdf0e10cSrcweir             if ( _bNoInvaOfAsCharAnchoredObjs &&
2420cdf0e10cSrcweir                  (pAnchoredObj->GetFrmFmt().GetAnchor().GetAnchorId()
2421cdf0e10cSrcweir                     == FLY_AS_CHAR) )
2422cdf0e10cSrcweir             {
2423cdf0e10cSrcweir                 continue;
2424cdf0e10cSrcweir             }
2425cdf0e10cSrcweir             // --> OD 2004-10-08 #i26945# - no invalidation, if anchored object
2426cdf0e10cSrcweir             // isn't registered at the same page and instead is registered at
2427cdf0e10cSrcweir             // the page, where its anchor character text frame is on.
2428cdf0e10cSrcweir             if ( pAnchoredObj->GetPageFrm() &&
2429cdf0e10cSrcweir                  pAnchoredObj->GetPageFrm() != pPageFrm )
2430cdf0e10cSrcweir             {
2431cdf0e10cSrcweir                 SwTxtFrm* pAnchorCharFrm = pAnchoredObj->FindAnchorCharFrm();
2432cdf0e10cSrcweir                 if ( pAnchorCharFrm &&
2433cdf0e10cSrcweir                      pAnchoredObj->GetPageFrm() == pAnchorCharFrm->FindPageFrm() )
2434cdf0e10cSrcweir                 {
2435cdf0e10cSrcweir                     continue;
2436cdf0e10cSrcweir                 }
2437cdf0e10cSrcweir                 // --> OD 2004-11-24 #115759# - unlock its position, if anchored
2438cdf0e10cSrcweir                 // object isn't registered at the page, where its anchor
2439cdf0e10cSrcweir                 // character text frame is on, respectively if it has no
2440cdf0e10cSrcweir                 // anchor character text frame.
2441cdf0e10cSrcweir                 else
2442cdf0e10cSrcweir                 {
2443cdf0e10cSrcweir                     pAnchoredObj->UnlockPosition();
2444cdf0e10cSrcweir                 }
2445cdf0e10cSrcweir                 // <--
2446cdf0e10cSrcweir             }
2447cdf0e10cSrcweir             // <--
2448cdf0e10cSrcweir             // --> OD 2005-07-18 #i51474# - reset flag, that anchored object
2449cdf0e10cSrcweir             // has cleared environment, and unlock its position, if the anchored
2450cdf0e10cSrcweir             // object is registered at the same page as the anchor frame is on.
2451cdf0e10cSrcweir             if ( pAnchoredObj->ClearedEnvironment() &&
2452cdf0e10cSrcweir                  pAnchoredObj->GetPageFrm() &&
2453cdf0e10cSrcweir                  pAnchoredObj->GetPageFrm() == pPageFrm )
2454cdf0e10cSrcweir             {
2455cdf0e10cSrcweir                 pAnchoredObj->UnlockPosition();
2456cdf0e10cSrcweir                 pAnchoredObj->SetClearedEnvironment( false );
2457cdf0e10cSrcweir             }
2458cdf0e10cSrcweir             // <--
2459cdf0e10cSrcweir             // distinguish between writer fly frames and drawing objects
2460cdf0e10cSrcweir             if ( pAnchoredObj->ISA(SwFlyFrm) )
2461cdf0e10cSrcweir             {
2462cdf0e10cSrcweir                 SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pAnchoredObj);
2463cdf0e10cSrcweir                 pFly->_Invalidate();
2464cdf0e10cSrcweir                 pFly->_InvalidatePos();
2465cdf0e10cSrcweir                 if ( !_bInvaPosOnly )
2466cdf0e10cSrcweir                     pFly->_InvalidateSize();
2467cdf0e10cSrcweir             }
2468cdf0e10cSrcweir             else
2469cdf0e10cSrcweir             {
2470cdf0e10cSrcweir                 pAnchoredObj->InvalidateObjPos();
2471cdf0e10cSrcweir             } // end of distinction between writer fly frames and drawing objects
2472cdf0e10cSrcweir 
2473cdf0e10cSrcweir         } // end of loop on objects, which are connected to the frame
2474cdf0e10cSrcweir 	}
2475cdf0e10cSrcweir }
2476cdf0e10cSrcweir 
2477cdf0e10cSrcweir /*************************************************************************
2478cdf0e10cSrcweir |*
2479cdf0e10cSrcweir |*  SwLayoutFrm::NotifyLowerObjs()
2480cdf0e10cSrcweir |*
2481cdf0e10cSrcweir |*************************************************************************/
2482cdf0e10cSrcweir // --> OD 2004-07-01 #i28701# - change purpose of method and its name
2483cdf0e10cSrcweir // --> OD 2004-10-08 #i26945# - correct check, if anchored object is a lower
2484cdf0e10cSrcweir // of the layout frame. E.g., anchor character text frame can be a follow text
2485cdf0e10cSrcweir // frame.
2486cdf0e10cSrcweir // --> OD 2005-03-11 #i44016# - add parameter <_bUnlockPosOfObjs> to
2487cdf0e10cSrcweir // force an unlockposition call for the lower objects.
NotifyLowerObjs(const bool _bUnlockPosOfObjs)2488cdf0e10cSrcweir void SwLayoutFrm::NotifyLowerObjs( const bool _bUnlockPosOfObjs )
2489cdf0e10cSrcweir {
2490cdf0e10cSrcweir     // invalidate lower floating screen objects
2491cdf0e10cSrcweir     SwPageFrm* pPageFrm = FindPageFrm();
2492cdf0e10cSrcweir     if ( pPageFrm && pPageFrm->GetSortedObjs() )
2493cdf0e10cSrcweir 	{
2494cdf0e10cSrcweir         SwSortedObjs& rObjs = *(pPageFrm->GetSortedObjs());
2495cdf0e10cSrcweir         for ( sal_uInt32 i = 0; i < rObjs.Count(); ++i )
2496cdf0e10cSrcweir 		{
2497cdf0e10cSrcweir             SwAnchoredObject* pObj = rObjs[i];
2498cdf0e10cSrcweir             // --> OD 2004-10-08 #i26945# - check, if anchored object is a lower
2499cdf0e10cSrcweir             // of the layout frame is changed to check, if its anchor frame
2500cdf0e10cSrcweir             // is a lower of the layout frame.
2501cdf0e10cSrcweir             // determine the anchor frame - usually it's the anchor frame,
2502cdf0e10cSrcweir             // for at-character/as-character anchored objects the anchor character
2503cdf0e10cSrcweir             // text frame is taken.
2504cdf0e10cSrcweir             const SwFrm* pAnchorFrm = pObj->GetAnchorFrmContainingAnchPos();
2505cdf0e10cSrcweir             // <--
2506cdf0e10cSrcweir             if ( pObj->ISA(SwFlyFrm) )
2507cdf0e10cSrcweir 			{
2508cdf0e10cSrcweir                 SwFlyFrm* pFly = static_cast<SwFlyFrm*>(pObj);
2509cdf0e10cSrcweir 
2510cdf0e10cSrcweir 				if ( pFly->Frm().Left() == WEIT_WECH )
2511cdf0e10cSrcweir 					continue;
2512cdf0e10cSrcweir 
2513cdf0e10cSrcweir                 if ( pFly->IsAnLower( this ) )
2514cdf0e10cSrcweir 					continue;
2515cdf0e10cSrcweir 
2516cdf0e10cSrcweir                 // --> OD 2004-10-08 #i26945# - use <pAnchorFrm> to check, if
2517cdf0e10cSrcweir                 // fly frame is lower of layout frame resp. if fly frame is
2518cdf0e10cSrcweir                 // at a different page registered as its anchor frame is on.
2519cdf0e10cSrcweir                 const bool bLow = IsAnLower( pAnchorFrm );
2520cdf0e10cSrcweir                 if ( bLow || pAnchorFrm->FindPageFrm() != pPageFrm )
2521cdf0e10cSrcweir                 // <--
2522cdf0e10cSrcweir 				{
2523cdf0e10cSrcweir                     pFly->_Invalidate( pPageFrm );
2524cdf0e10cSrcweir 					if ( !bLow || pFly->IsFlyAtCntFrm() )
2525cdf0e10cSrcweir                     {
2526cdf0e10cSrcweir                         // --> OD 2005-03-11 #i44016#
2527cdf0e10cSrcweir                         if ( _bUnlockPosOfObjs )
2528cdf0e10cSrcweir                         {
2529cdf0e10cSrcweir                             pFly->UnlockPosition();
2530cdf0e10cSrcweir                         }
2531cdf0e10cSrcweir                         // <--
2532cdf0e10cSrcweir                         pFly->_InvalidatePos();
2533cdf0e10cSrcweir                     }
2534cdf0e10cSrcweir 					else
2535cdf0e10cSrcweir 						pFly->_InvalidatePrt();
2536cdf0e10cSrcweir 				}
2537cdf0e10cSrcweir 			}
2538cdf0e10cSrcweir             else
2539cdf0e10cSrcweir             {
2540cdf0e10cSrcweir                 ASSERT( pObj->ISA(SwAnchoredDrawObject),
2541cdf0e10cSrcweir                         "<SwLayoutFrm::NotifyFlys() - anchored object of unexcepted type" );
2542cdf0e10cSrcweir                 // --> OD 2004-10-08 #i26945# - use <pAnchorFrm> to check, if
2543cdf0e10cSrcweir                 // fly frame is lower of layout frame resp. if fly frame is
2544cdf0e10cSrcweir                 // at a different page registered as its anchor frame is on.
2545cdf0e10cSrcweir                 if ( IsAnLower( pAnchorFrm ) ||
2546cdf0e10cSrcweir                      pAnchorFrm->FindPageFrm() != pPageFrm )
2547cdf0e10cSrcweir                 // <--
2548cdf0e10cSrcweir                 {
2549cdf0e10cSrcweir                     // --> OD 2005-03-11 #i44016#
2550cdf0e10cSrcweir                     if ( _bUnlockPosOfObjs )
2551cdf0e10cSrcweir                     {
2552cdf0e10cSrcweir                         pObj->UnlockPosition();
2553cdf0e10cSrcweir                     }
2554cdf0e10cSrcweir                     // <--
2555cdf0e10cSrcweir                     pObj->InvalidateObjPos();
2556cdf0e10cSrcweir                 }
2557cdf0e10cSrcweir             }
2558cdf0e10cSrcweir 		}
2559cdf0e10cSrcweir 	}
2560cdf0e10cSrcweir }
2561cdf0e10cSrcweir 
2562cdf0e10cSrcweir /*************************************************************************
2563cdf0e10cSrcweir |*
2564cdf0e10cSrcweir |*	SwFlyFrm::NotifyDrawObj()
2565cdf0e10cSrcweir |*
2566cdf0e10cSrcweir |*	Ersterstellung		OK 22. Nov. 94
2567cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. Jan. 97
2568cdf0e10cSrcweir |*
2569cdf0e10cSrcweir |*************************************************************************/
2570cdf0e10cSrcweir 
NotifyDrawObj()2571cdf0e10cSrcweir void SwFlyFrm::NotifyDrawObj()
2572cdf0e10cSrcweir {
2573cdf0e10cSrcweir     SwVirtFlyDrawObj* pObj = GetVirtDrawObj();
2574cdf0e10cSrcweir     pObj->SetRect();
2575cdf0e10cSrcweir     pObj->SetRectsDirty();
2576cdf0e10cSrcweir     pObj->SetChanged();
2577cdf0e10cSrcweir     pObj->BroadcastObjectChange();
2578cdf0e10cSrcweir 	if ( GetFmt()->GetSurround().IsContour() )
2579cdf0e10cSrcweir         ClrContourCache( pObj );
2580cdf0e10cSrcweir }
2581cdf0e10cSrcweir 
2582cdf0e10cSrcweir /*************************************************************************
2583cdf0e10cSrcweir |*
2584cdf0e10cSrcweir |*  SwFlyFrm::CalcRel()
2585cdf0e10cSrcweir |*
2586cdf0e10cSrcweir |*	Ersterstellung		MA 13. Jun. 96
2587cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. Oct. 96
2588cdf0e10cSrcweir |*
2589cdf0e10cSrcweir |*************************************************************************/
2590cdf0e10cSrcweir 
CalcRel(const SwFmtFrmSize & rSz) const2591cdf0e10cSrcweir Size SwFlyFrm::CalcRel( const SwFmtFrmSize &rSz ) const
2592cdf0e10cSrcweir {
2593cdf0e10cSrcweir 	Size aRet( rSz.GetSize() );
2594cdf0e10cSrcweir 
2595cdf0e10cSrcweir     const SwFrm *pRel = IsFlyLayFrm() ? GetAnchorFrm() : GetAnchorFrm()->GetUpper();
2596cdf0e10cSrcweir 	if( pRel ) // LAYER_IMPL
2597cdf0e10cSrcweir 	{
2598cdf0e10cSrcweir 		long nRelWidth = LONG_MAX, nRelHeight = LONG_MAX;
2599cdf0e10cSrcweir 		const ViewShell *pSh = getRootFrm()->GetCurrShell();
2600cdf0e10cSrcweir 		if ( ( pRel->IsBodyFrm() || pRel->IsPageFrm() ) &&
2601cdf0e10cSrcweir              pSh && pSh->GetViewOptions()->getBrowseMode() &&
2602cdf0e10cSrcweir 			 pSh->VisArea().HasArea() )
2603cdf0e10cSrcweir 		{
2604cdf0e10cSrcweir 			nRelWidth  = pSh->GetBrowseWidth();
2605cdf0e10cSrcweir 			nRelHeight = pSh->VisArea().Height();
2606cdf0e10cSrcweir 			Size aBorder = pSh->GetOut()->PixelToLogic( pSh->GetBrowseBorder() );
2607cdf0e10cSrcweir 			long nDiff = nRelWidth - pRel->Prt().Width();
2608cdf0e10cSrcweir 			if ( nDiff > 0 )
2609cdf0e10cSrcweir 				nRelWidth -= nDiff;
2610cdf0e10cSrcweir 			nRelHeight -= 2*aBorder.Height();
2611cdf0e10cSrcweir 			nDiff = nRelHeight - pRel->Prt().Height();
2612cdf0e10cSrcweir 			if ( nDiff > 0 )
2613cdf0e10cSrcweir 				nRelHeight -= nDiff;
2614cdf0e10cSrcweir 		}
2615cdf0e10cSrcweir 		nRelWidth  = Min( nRelWidth,  pRel->Prt().Width() );
2616cdf0e10cSrcweir 		nRelHeight = Min( nRelHeight, pRel->Prt().Height() );
2617cdf0e10cSrcweir         if( !pRel->IsPageFrm() )
2618cdf0e10cSrcweir         {
2619cdf0e10cSrcweir             const SwPageFrm* pPage = FindPageFrm();
2620cdf0e10cSrcweir             if( pPage )
2621cdf0e10cSrcweir             {
2622cdf0e10cSrcweir                 nRelWidth  = Min( nRelWidth,  pPage->Prt().Width() );
2623cdf0e10cSrcweir                 nRelHeight = Min( nRelHeight, pPage->Prt().Height() );
2624cdf0e10cSrcweir             }
2625cdf0e10cSrcweir         }
2626cdf0e10cSrcweir 
2627cdf0e10cSrcweir 		if ( rSz.GetWidthPercent() && rSz.GetWidthPercent() != 0xFF )
2628cdf0e10cSrcweir 			aRet.Width() = nRelWidth * rSz.GetWidthPercent() / 100;
2629cdf0e10cSrcweir 		if ( rSz.GetHeightPercent() && rSz.GetHeightPercent() != 0xFF )
2630cdf0e10cSrcweir 			aRet.Height() = nRelHeight * rSz.GetHeightPercent() / 100;
2631cdf0e10cSrcweir 
2632cdf0e10cSrcweir 		if ( rSz.GetWidthPercent() == 0xFF )
2633cdf0e10cSrcweir 		{
2634cdf0e10cSrcweir 			aRet.Width() *= aRet.Height();
2635cdf0e10cSrcweir 			aRet.Width() /= rSz.GetHeight();
2636cdf0e10cSrcweir 		}
2637cdf0e10cSrcweir 		else if ( rSz.GetHeightPercent() == 0xFF )
2638cdf0e10cSrcweir 		{
2639cdf0e10cSrcweir 			aRet.Height() *= aRet.Width();
2640cdf0e10cSrcweir 			aRet.Height() /= rSz.GetWidth();
2641cdf0e10cSrcweir 		}
2642cdf0e10cSrcweir     }
2643cdf0e10cSrcweir 	return aRet;
2644cdf0e10cSrcweir }
2645cdf0e10cSrcweir 
2646cdf0e10cSrcweir /*************************************************************************
2647cdf0e10cSrcweir |*
2648cdf0e10cSrcweir |*  SwFlyFrm::CalcAutoWidth()
2649cdf0e10cSrcweir |*
2650cdf0e10cSrcweir |*************************************************************************/
2651cdf0e10cSrcweir 
lcl_CalcAutoWidth(const SwLayoutFrm & rFrm)2652cdf0e10cSrcweir SwTwips lcl_CalcAutoWidth( const SwLayoutFrm& rFrm )
2653cdf0e10cSrcweir {
2654cdf0e10cSrcweir     SwTwips nRet = 0;
2655cdf0e10cSrcweir     SwTwips nMin = 0;
2656cdf0e10cSrcweir     const SwFrm* pFrm = rFrm.Lower();
2657cdf0e10cSrcweir 
2658cdf0e10cSrcweir     // No autowidth defined for columned frames
2659cdf0e10cSrcweir     if ( !pFrm || pFrm->IsColumnFrm() )
2660cdf0e10cSrcweir         return nRet;
2661cdf0e10cSrcweir 
2662cdf0e10cSrcweir     while ( pFrm )
2663cdf0e10cSrcweir     {
2664cdf0e10cSrcweir         if ( pFrm->IsSctFrm() )
2665cdf0e10cSrcweir         {
2666cdf0e10cSrcweir             nMin = lcl_CalcAutoWidth( *(SwSectionFrm*)pFrm );
2667cdf0e10cSrcweir         }
2668cdf0e10cSrcweir         if ( pFrm->IsTxtFrm() )
2669cdf0e10cSrcweir         {
2670cdf0e10cSrcweir             nMin = ((SwTxtFrm*)pFrm)->CalcFitToContent();
2671cdf0e10cSrcweir             const SvxLRSpaceItem &rSpace =
2672cdf0e10cSrcweir                 ((SwTxtFrm*)pFrm)->GetTxtNode()->GetSwAttrSet().GetLRSpace();
267372aeb479SOliver-Rainer Wittmann             if (!((SwTxtFrm*)pFrm)->IsLocked())
267472aeb479SOliver-Rainer Wittmann                 nMin += rSpace.GetRight() + rSpace.GetTxtLeft() + rSpace.GetTxtFirstLineOfst();
2675cdf0e10cSrcweir         }
2676cdf0e10cSrcweir         else if ( pFrm->IsTabFrm() )
2677cdf0e10cSrcweir         {
2678cdf0e10cSrcweir             const SwFmtFrmSize& rTblFmtSz = ((SwTabFrm*)pFrm)->GetTable()->GetFrmFmt()->GetFrmSize();
2679cdf0e10cSrcweir             if ( USHRT_MAX == rTblFmtSz.GetSize().Width() ||
2680cdf0e10cSrcweir                  text::HoriOrientation::NONE == ((SwTabFrm*)pFrm)->GetFmt()->GetHoriOrient().GetHoriOrient() )
2681cdf0e10cSrcweir             {
2682cdf0e10cSrcweir                 const SwPageFrm* pPage = rFrm.FindPageFrm();
2683cdf0e10cSrcweir                 // auto width table
2684cdf0e10cSrcweir                 nMin = pFrm->GetUpper()->IsVertical() ?
2685cdf0e10cSrcweir                     pPage->Prt().Height() :
2686cdf0e10cSrcweir                     pPage->Prt().Width();
2687cdf0e10cSrcweir             }
2688cdf0e10cSrcweir             else
2689cdf0e10cSrcweir             {
2690cdf0e10cSrcweir                 nMin = rTblFmtSz.GetSize().Width();
2691cdf0e10cSrcweir             }
2692cdf0e10cSrcweir         }
2693cdf0e10cSrcweir 
2694cdf0e10cSrcweir         if ( nMin > nRet )
2695cdf0e10cSrcweir             nRet = nMin;
2696cdf0e10cSrcweir 
2697cdf0e10cSrcweir         pFrm = pFrm->GetNext();
2698cdf0e10cSrcweir     }
2699cdf0e10cSrcweir 
2700cdf0e10cSrcweir     return nRet;
2701cdf0e10cSrcweir }
2702cdf0e10cSrcweir 
CalcAutoWidth() const2703cdf0e10cSrcweir SwTwips SwFlyFrm::CalcAutoWidth() const
2704cdf0e10cSrcweir {
2705cdf0e10cSrcweir     return lcl_CalcAutoWidth( *this );
2706cdf0e10cSrcweir }
2707cdf0e10cSrcweir 
2708cdf0e10cSrcweir /*************************************************************************
2709cdf0e10cSrcweir |*
2710cdf0e10cSrcweir |*	SwFlyFrm::AddSpacesToFrm
2711cdf0e10cSrcweir |*
2712cdf0e10cSrcweir |*	Ersterstellung		MA 11. Nov. 96
2713cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. Mar. 97
2714cdf0e10cSrcweir |*
2715cdf0e10cSrcweir |*************************************************************************/
2716cdf0e10cSrcweir 
2717cdf0e10cSrcweir //SwRect SwFlyFrm::AddSpacesToFrm() const
2718cdf0e10cSrcweir //{
2719cdf0e10cSrcweir //  SwRect aRect( Frm() );
2720cdf0e10cSrcweir //  const SvxULSpaceItem &rUL = GetFmt()->GetULSpace();
2721cdf0e10cSrcweir //  const SvxLRSpaceItem &rLR = GetFmt()->GetLRSpace();
2722cdf0e10cSrcweir //  aRect.Left( Max( aRect.Left() - long(rLR.GetLeft()), 0L ) );
2723cdf0e10cSrcweir //  aRect.SSize().Width() += rLR.GetRight();
2724cdf0e10cSrcweir //  aRect.Top( Max( aRect.Top() - long(rUL.GetUpper()), 0L ) );
2725cdf0e10cSrcweir //  aRect.SSize().Height()+= rUL.GetLower();
2726cdf0e10cSrcweir //  return aRect;
2727cdf0e10cSrcweir //}
2728cdf0e10cSrcweir 
2729cdf0e10cSrcweir /*************************************************************************
2730cdf0e10cSrcweir |*
2731cdf0e10cSrcweir |*	SwFlyFrm::GetContour()
2732cdf0e10cSrcweir |*
2733cdf0e10cSrcweir |*	Ersterstellung		MA 09. Jan. 97
2734cdf0e10cSrcweir |*	Letzte Aenderung	MA 10. Jan. 97
2735cdf0e10cSrcweir |*
2736cdf0e10cSrcweir |*************************************************************************/
2737cdf0e10cSrcweir /// OD 16.04.2003 #i13147# - If called for paint and the <SwNoTxtFrm> contains
2738cdf0e10cSrcweir /// a graphic, load of intrinsic graphic has to be avoided.
GetContour(PolyPolygon & rContour,const sal_Bool _bForPaint) const2739cdf0e10cSrcweir sal_Bool SwFlyFrm::GetContour( PolyPolygon&   rContour,
2740cdf0e10cSrcweir                            const sal_Bool _bForPaint ) const
2741cdf0e10cSrcweir {
2742cdf0e10cSrcweir 	sal_Bool bRet = sal_False;
2743cdf0e10cSrcweir 	if( GetFmt()->GetSurround().IsContour() && Lower() &&
2744cdf0e10cSrcweir 		Lower()->IsNoTxtFrm() )
2745cdf0e10cSrcweir 	{
2746cdf0e10cSrcweir 		SwNoTxtNode *pNd = (SwNoTxtNode*)((SwCntntFrm*)Lower())->GetNode();
2747cdf0e10cSrcweir         // OD 16.04.2003 #i13147# - determine <GraphicObject> instead of <Graphic>
2748cdf0e10cSrcweir         // in order to avoid load of graphic, if <SwNoTxtNode> contains a graphic
2749cdf0e10cSrcweir         // node and method is called for paint.
2750cdf0e10cSrcweir         const GraphicObject* pGrfObj = NULL;
2751cdf0e10cSrcweir         sal_Bool bGrfObjCreated = sal_False;
2752cdf0e10cSrcweir         const SwGrfNode* pGrfNd = pNd->GetGrfNode();
2753cdf0e10cSrcweir         if ( pGrfNd && _bForPaint )
2754cdf0e10cSrcweir         {
2755cdf0e10cSrcweir             pGrfObj = &(pGrfNd->GetGrfObj());
2756cdf0e10cSrcweir         }
2757cdf0e10cSrcweir         else
2758cdf0e10cSrcweir         {
2759cdf0e10cSrcweir             pGrfObj = new GraphicObject( pNd->GetGraphic() );
2760cdf0e10cSrcweir             bGrfObjCreated = sal_True;
2761cdf0e10cSrcweir         }
2762cdf0e10cSrcweir         ASSERT( pGrfObj, "SwFlyFrm::GetContour() - No Graphic/GraphicObject found at <SwNoTxtNode>." );
2763cdf0e10cSrcweir         if ( pGrfObj && pGrfObj->GetType() != GRAPHIC_NONE )
2764cdf0e10cSrcweir         {
2765cdf0e10cSrcweir             if( !pNd->HasContour() )
2766cdf0e10cSrcweir             {
2767cdf0e10cSrcweir                 // OD 16.04.2003 #i13147# - no <CreateContour> for a graphic
2768cdf0e10cSrcweir                 // during paint. Thus, return (value of <bRet> should be <sal_False>).
2769cdf0e10cSrcweir                 if ( pGrfNd && _bForPaint )
2770cdf0e10cSrcweir                 {
2771cdf0e10cSrcweir                     ASSERT( false, "SwFlyFrm::GetContour() - No Contour found at <SwNoTxtNode> during paint." );
2772cdf0e10cSrcweir                     return bRet;
2773cdf0e10cSrcweir                 }
2774cdf0e10cSrcweir                 pNd->CreateContour();
2775cdf0e10cSrcweir             }
2776cdf0e10cSrcweir             pNd->GetContour( rContour );
2777cdf0e10cSrcweir 			//Der Node haelt das Polygon passend zur Originalgroesse der Grafik
2778cdf0e10cSrcweir 			//hier muss die Skalierung einkalkuliert werden.
2779cdf0e10cSrcweir 			SwRect aClip;
2780cdf0e10cSrcweir 			SwRect aOrig;
2781cdf0e10cSrcweir 			Lower()->Calc();
2782cdf0e10cSrcweir 			((SwNoTxtFrm*)Lower())->GetGrfArea( aClip, &aOrig, sal_False );
2783cdf0e10cSrcweir             // OD 16.04.2003 #i13147# - copy method code <SvxContourDlg::ScaleContour(..)>
2784cdf0e10cSrcweir             // in order to avoid that graphic has to be loaded for contour scale.
2785cdf0e10cSrcweir             //SvxContourDlg::ScaleContour( rContour, aGrf, MAP_TWIP, aOrig.SSize() );
2786cdf0e10cSrcweir             {
2787cdf0e10cSrcweir                 OutputDevice*   pOutDev = Application::GetDefaultDevice();
2788cdf0e10cSrcweir                 const MapMode   aDispMap( MAP_TWIP );
2789cdf0e10cSrcweir                 const MapMode   aGrfMap( pGrfObj->GetPrefMapMode() );
2790cdf0e10cSrcweir                 const Size      aGrfSize( pGrfObj->GetPrefSize() );
2791cdf0e10cSrcweir                 double          fScaleX;
2792cdf0e10cSrcweir                 double          fScaleY;
2793cdf0e10cSrcweir                 Size            aOrgSize;
2794cdf0e10cSrcweir                 Point           aNewPoint;
2795cdf0e10cSrcweir                 sal_Bool            bPixelMap = aGrfMap.GetMapUnit() == MAP_PIXEL;
2796cdf0e10cSrcweir 
2797cdf0e10cSrcweir                 if ( bPixelMap )
2798cdf0e10cSrcweir                     aOrgSize = pOutDev->PixelToLogic( aGrfSize, aDispMap );
2799cdf0e10cSrcweir                 else
2800cdf0e10cSrcweir                     aOrgSize = pOutDev->LogicToLogic( aGrfSize, aGrfMap, aDispMap );
2801cdf0e10cSrcweir 
2802cdf0e10cSrcweir                 if ( aOrgSize.Width() && aOrgSize.Height() )
2803cdf0e10cSrcweir                 {
2804cdf0e10cSrcweir                     fScaleX = (double) aOrig.Width() / aOrgSize.Width();
2805cdf0e10cSrcweir                     fScaleY = (double) aOrig.Height() / aOrgSize.Height();
2806cdf0e10cSrcweir 
2807cdf0e10cSrcweir                     for ( sal_uInt16 j = 0, nPolyCount = rContour.Count(); j < nPolyCount; j++ )
2808cdf0e10cSrcweir                     {
2809cdf0e10cSrcweir                         Polygon& rPoly = rContour[ j ];
2810cdf0e10cSrcweir 
2811cdf0e10cSrcweir                         for ( sal_uInt16 i = 0, nCount = rPoly.GetSize(); i < nCount; i++ )
2812cdf0e10cSrcweir                         {
2813cdf0e10cSrcweir                             if ( bPixelMap )
2814cdf0e10cSrcweir                                 aNewPoint = pOutDev->PixelToLogic( rPoly[ i ], aDispMap  );
2815cdf0e10cSrcweir                             else
2816cdf0e10cSrcweir                                 aNewPoint = pOutDev->LogicToLogic( rPoly[ i ], aGrfMap, aDispMap  );
2817cdf0e10cSrcweir 
2818cdf0e10cSrcweir                             rPoly[ i ] = Point( FRound( aNewPoint.X() * fScaleX ), FRound( aNewPoint.Y() * fScaleY ) );
2819cdf0e10cSrcweir                         }
2820cdf0e10cSrcweir                     }
2821cdf0e10cSrcweir                 }
2822cdf0e10cSrcweir             }
2823cdf0e10cSrcweir             // OD 17.04.2003 #i13147# - destroy created <GraphicObject>.
2824cdf0e10cSrcweir             if ( bGrfObjCreated )
2825cdf0e10cSrcweir             {
2826cdf0e10cSrcweir                 delete pGrfObj;
2827cdf0e10cSrcweir             }
2828cdf0e10cSrcweir             rContour.Move( aOrig.Left(), aOrig.Top() );
2829cdf0e10cSrcweir             if( !aClip.Width() )
2830cdf0e10cSrcweir                 aClip.Width( 1 );
2831cdf0e10cSrcweir             if( !aClip.Height() )
2832cdf0e10cSrcweir                 aClip.Height( 1 );
2833cdf0e10cSrcweir             rContour.Clip( aClip.SVRect() );
2834cdf0e10cSrcweir 			rContour.Optimize(POLY_OPTIMIZE_CLOSE);
2835cdf0e10cSrcweir 			bRet = sal_True;
2836cdf0e10cSrcweir 		}
2837cdf0e10cSrcweir 	}
2838cdf0e10cSrcweir 	return bRet;
2839cdf0e10cSrcweir }
2840cdf0e10cSrcweir 
2841cdf0e10cSrcweir // OD 2004-03-25 #i26791#
GetVirtDrawObj() const2842cdf0e10cSrcweir const SwVirtFlyDrawObj* SwFlyFrm::GetVirtDrawObj() const
2843cdf0e10cSrcweir {
2844cdf0e10cSrcweir     return static_cast<const SwVirtFlyDrawObj*>(GetDrawObj());
2845cdf0e10cSrcweir }
GetVirtDrawObj()2846cdf0e10cSrcweir SwVirtFlyDrawObj* SwFlyFrm::GetVirtDrawObj()
2847cdf0e10cSrcweir {
2848cdf0e10cSrcweir     return static_cast<SwVirtFlyDrawObj*>(DrawObj());
2849cdf0e10cSrcweir }
2850cdf0e10cSrcweir 
2851cdf0e10cSrcweir // =============================================================================
2852cdf0e10cSrcweir // OD 2004-03-24 #i26791# - implementation of pure virtual method declared in
2853cdf0e10cSrcweir // base class <SwAnchoredObject>
2854cdf0e10cSrcweir // =============================================================================
InvalidateObjPos()2855cdf0e10cSrcweir void SwFlyFrm::InvalidateObjPos()
2856cdf0e10cSrcweir {
2857cdf0e10cSrcweir     InvalidatePos();
2858cdf0e10cSrcweir     // --> OD 2006-08-10 #i68520#
2859cdf0e10cSrcweir     InvalidateObjRectWithSpaces();
2860cdf0e10cSrcweir     // <--
2861cdf0e10cSrcweir }
2862cdf0e10cSrcweir 
GetFrmFmt()2863cdf0e10cSrcweir SwFrmFmt& SwFlyFrm::GetFrmFmt()
2864cdf0e10cSrcweir {
2865cdf0e10cSrcweir     ASSERT( GetFmt(),
2866cdf0e10cSrcweir             "<SwFlyFrm::GetFrmFmt()> - missing frame format -> crash." );
2867cdf0e10cSrcweir     return *GetFmt();
2868cdf0e10cSrcweir }
GetFrmFmt() const2869cdf0e10cSrcweir const SwFrmFmt& SwFlyFrm::GetFrmFmt() const
2870cdf0e10cSrcweir {
2871cdf0e10cSrcweir     ASSERT( GetFmt(),
2872cdf0e10cSrcweir             "<SwFlyFrm::GetFrmFmt()> - missing frame format -> crash." );
2873cdf0e10cSrcweir     return *GetFmt();
2874cdf0e10cSrcweir }
2875cdf0e10cSrcweir 
GetObjRect() const2876cdf0e10cSrcweir const SwRect SwFlyFrm::GetObjRect() const
2877cdf0e10cSrcweir {
2878cdf0e10cSrcweir     return Frm();
2879cdf0e10cSrcweir }
2880cdf0e10cSrcweir 
2881cdf0e10cSrcweir // --> OD 2006-10-05 #i70122#
2882cdf0e10cSrcweir // for Writer fly frames the bounding rectangle equals the object rectangles
GetObjBoundRect() const2883cdf0e10cSrcweir const SwRect SwFlyFrm::GetObjBoundRect() const
2884cdf0e10cSrcweir {
2885cdf0e10cSrcweir     return GetObjRect();
2886cdf0e10cSrcweir }
2887cdf0e10cSrcweir // <--
2888cdf0e10cSrcweir 
2889cdf0e10cSrcweir // --> OD 2006-08-10 #i68520#
_SetObjTop(const SwTwips _nTop)2890cdf0e10cSrcweir bool SwFlyFrm::_SetObjTop( const SwTwips _nTop )
2891cdf0e10cSrcweir {
2892cdf0e10cSrcweir     const bool bChanged( Frm().Pos().Y() != _nTop );
2893cdf0e10cSrcweir 
2894cdf0e10cSrcweir     Frm().Pos().Y() = _nTop;
2895cdf0e10cSrcweir 
2896cdf0e10cSrcweir     return bChanged;
2897cdf0e10cSrcweir }
_SetObjLeft(const SwTwips _nLeft)2898cdf0e10cSrcweir bool SwFlyFrm::_SetObjLeft( const SwTwips _nLeft )
2899cdf0e10cSrcweir {
2900cdf0e10cSrcweir     const bool bChanged( Frm().Pos().X() != _nLeft );
2901cdf0e10cSrcweir 
2902cdf0e10cSrcweir     Frm().Pos().X() = _nLeft;
2903cdf0e10cSrcweir 
2904cdf0e10cSrcweir     return bChanged;
2905cdf0e10cSrcweir }
2906cdf0e10cSrcweir // <--
2907cdf0e10cSrcweir 
2908cdf0e10cSrcweir /** method to assure that anchored object is registered at the correct
2909cdf0e10cSrcweir     page frame
2910cdf0e10cSrcweir 
2911cdf0e10cSrcweir     OD 2004-07-02 #i28701#
2912cdf0e10cSrcweir 
2913cdf0e10cSrcweir     @author OD
2914cdf0e10cSrcweir */
RegisterAtCorrectPage()2915cdf0e10cSrcweir void SwFlyFrm::RegisterAtCorrectPage()
2916cdf0e10cSrcweir {
2917cdf0e10cSrcweir     // default behaviour is to do nothing.
2918cdf0e10cSrcweir }
2919cdf0e10cSrcweir 
2920cdf0e10cSrcweir /** method to determine, if a <MakeAll()> on the Writer fly frame is possible
2921cdf0e10cSrcweir 
2922cdf0e10cSrcweir     OD 2004-05-11 #i28701#
2923cdf0e10cSrcweir 
2924cdf0e10cSrcweir     @author OD
2925cdf0e10cSrcweir */
IsFormatPossible() const2926cdf0e10cSrcweir bool SwFlyFrm::IsFormatPossible() const
2927cdf0e10cSrcweir {
2928cdf0e10cSrcweir     return SwAnchoredObject::IsFormatPossible() &&
2929cdf0e10cSrcweir            !IsLocked() && !IsColLocked();
2930cdf0e10cSrcweir }
2931cdf0e10cSrcweir 
GetAnchoredObjects(std::list<SwAnchoredObject * > & aList,const SwFmt & rFmt)2932cdf0e10cSrcweir void SwFlyFrm::GetAnchoredObjects( std::list<SwAnchoredObject*>& aList, const SwFmt& rFmt )
2933cdf0e10cSrcweir {
2934cdf0e10cSrcweir     SwIterator<SwFlyFrm,SwFmt> aIter( rFmt );
2935cdf0e10cSrcweir     for( SwFlyFrm* pFlyFrm = aIter.First(); pFlyFrm; pFlyFrm = aIter.Next() )
2936cdf0e10cSrcweir         aList.push_back( pFlyFrm );
2937cdf0e10cSrcweir }
2938cdf0e10cSrcweir 
GetFmt() const2939cdf0e10cSrcweir const SwFlyFrmFmt * SwFlyFrm::GetFmt() const
2940cdf0e10cSrcweir {
2941cdf0e10cSrcweir     return static_cast< const SwFlyFrmFmt * >( GetDep() );
2942cdf0e10cSrcweir }
2943cdf0e10cSrcweir 
GetFmt()2944cdf0e10cSrcweir SwFlyFrmFmt * SwFlyFrm::GetFmt()
2945cdf0e10cSrcweir {
2946cdf0e10cSrcweir     return static_cast< SwFlyFrmFmt * >( GetDep() );
2947cdf0e10cSrcweir }
2948cdf0e10cSrcweir 
294991100364SJian Hong Cheng //Bug 120881:Modify here for Directly Page Numbering
IsPageNumberingFrm()295091100364SJian Hong Cheng sal_Bool SwFlyFrm::IsPageNumberingFrm()
295191100364SJian Hong Cheng {
295291100364SJian Hong Cheng 	if (!GetAnchorFrm())//Invalidate frame...
295391100364SJian Hong Cheng 		return false;
295491100364SJian Hong Cheng 	if (bInCnt || bLayout)//Incorrect anchor type...
295591100364SJian Hong Cheng 		return false;
295691100364SJian Hong Cheng 	if (!(GetAnchorFrm()->IsTxtFrm() && GetAnchorFrm()->GetUpper()
295791100364SJian Hong Cheng 		&& (GetAnchorFrm()->GetUpper()->FindFooterOrHeader())))//Not in header or footer frame
295891100364SJian Hong Cheng 		return false;
295991100364SJian Hong Cheng 
296091100364SJian Hong Cheng 	if (pNextLink || pPrevLink)//Linked...
296191100364SJian Hong Cheng 		return false;
296291100364SJian Hong Cheng 
296391100364SJian Hong Cheng 	SwFrmFmt* pFmt = NULL;
2964973b5647SPavel Janík 	if ((pFmt = GetFmt()))
296591100364SJian Hong Cheng 	{
296691100364SJian Hong Cheng 		if (pLower && pLower->GetNext() && pFmt->GetCol().GetNumCols()>1)//Has more than 1 column...
296791100364SJian Hong Cheng 			return false;
296891100364SJian Hong Cheng 	}
296991100364SJian Hong Cheng 
297091100364SJian Hong Cheng 	if (!pLower)//Do not has even 1 child frame?
297191100364SJian Hong Cheng 		return false;
297291100364SJian Hong Cheng 
297391100364SJian Hong Cheng 	for (SwFrm* pIter = pLower;pIter!=NULL;pIter=pIter->GetNext())
297491100364SJian Hong Cheng 	{
297591100364SJian Hong Cheng 		if (pIter->IsTxtFrm() && ((SwTxtFrm*)pIter)->HasPageNumberField())
297691100364SJian Hong Cheng 		{
297791100364SJian Hong Cheng 			return true;
297891100364SJian Hong Cheng 		}
297991100364SJian Hong Cheng 	}
298091100364SJian Hong Cheng 	return false;
298191100364SJian Hong Cheng }
298291100364SJian Hong Cheng 
298391100364SJian Hong Cheng //Bug 120881(End)
298491100364SJian Hong Cheng 
2985