1*efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*efeef26fSAndrew Rist * distributed with this work for additional information
6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*efeef26fSAndrew Rist * software distributed under the License is distributed on an
15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17*efeef26fSAndrew Rist * specific language governing permissions and limitations
18*efeef26fSAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*efeef26fSAndrew Rist *************************************************************/
21*efeef26fSAndrew Rist
22*efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <objectformattertxtfrm.hxx>
27cdf0e10cSrcweir #include <anchoredobject.hxx>
28cdf0e10cSrcweir #include <sortedobjs.hxx>
29cdf0e10cSrcweir #include <flyfrms.hxx>
30cdf0e10cSrcweir #include <txtfrm.hxx>
31cdf0e10cSrcweir #include <pagefrm.hxx>
32cdf0e10cSrcweir #include <rowfrm.hxx>
33cdf0e10cSrcweir #include <layouter.hxx>
34cdf0e10cSrcweir #include <frmfmt.hxx>
35cdf0e10cSrcweir #include <fmtanchr.hxx>
36cdf0e10cSrcweir #include <fmtwrapinfluenceonobjpos.hxx>
37cdf0e10cSrcweir // --> OD 2004-11-03 #114798#
38cdf0e10cSrcweir #include <fmtfollowtextflow.hxx>
39cdf0e10cSrcweir // <--
40cdf0e10cSrcweir #include <layact.hxx>
41cdf0e10cSrcweir
42cdf0e10cSrcweir using namespace ::com::sun::star;
43cdf0e10cSrcweir
44cdf0e10cSrcweir // =============================================================================
45cdf0e10cSrcweir
46cdf0e10cSrcweir // --> OD 2004-12-03 #115759# - little helper class to forbid follow formatting
47cdf0e10cSrcweir // for the given text frame
48cdf0e10cSrcweir class SwForbidFollowFormat
49cdf0e10cSrcweir {
50cdf0e10cSrcweir private:
51cdf0e10cSrcweir SwTxtFrm& mrTxtFrm;
52cdf0e10cSrcweir const bool bOldFollowFormatAllowed;
53cdf0e10cSrcweir
54cdf0e10cSrcweir public:
SwForbidFollowFormat(SwTxtFrm & _rTxtFrm)55cdf0e10cSrcweir SwForbidFollowFormat( SwTxtFrm& _rTxtFrm )
56cdf0e10cSrcweir : mrTxtFrm( _rTxtFrm ),
57cdf0e10cSrcweir bOldFollowFormatAllowed( _rTxtFrm.FollowFormatAllowed() )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir mrTxtFrm.ForbidFollowFormat();
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
~SwForbidFollowFormat()62cdf0e10cSrcweir ~SwForbidFollowFormat()
63cdf0e10cSrcweir {
64cdf0e10cSrcweir if ( bOldFollowFormatAllowed )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir mrTxtFrm.AllowFollowFormat();
67cdf0e10cSrcweir }
68cdf0e10cSrcweir }
69cdf0e10cSrcweir };
70cdf0e10cSrcweir // <--
71cdf0e10cSrcweir
72cdf0e10cSrcweir // =============================================================================
73cdf0e10cSrcweir // implementation of class <SwObjectFormatterTxtFrm>
74cdf0e10cSrcweir // =============================================================================
SwObjectFormatterTxtFrm(SwTxtFrm & _rAnchorTxtFrm,const SwPageFrm & _rPageFrm,SwTxtFrm * _pMasterAnchorTxtFrm,SwLayAction * _pLayAction)75cdf0e10cSrcweir SwObjectFormatterTxtFrm::SwObjectFormatterTxtFrm( SwTxtFrm& _rAnchorTxtFrm,
76cdf0e10cSrcweir const SwPageFrm& _rPageFrm,
77cdf0e10cSrcweir SwTxtFrm* _pMasterAnchorTxtFrm,
78cdf0e10cSrcweir SwLayAction* _pLayAction )
79cdf0e10cSrcweir : SwObjectFormatter( _rPageFrm, _pLayAction, true ),
80cdf0e10cSrcweir mrAnchorTxtFrm( _rAnchorTxtFrm ),
81cdf0e10cSrcweir mpMasterAnchorTxtFrm( _pMasterAnchorTxtFrm )
82cdf0e10cSrcweir {
83cdf0e10cSrcweir }
84cdf0e10cSrcweir
~SwObjectFormatterTxtFrm()85cdf0e10cSrcweir SwObjectFormatterTxtFrm::~SwObjectFormatterTxtFrm()
86cdf0e10cSrcweir {
87cdf0e10cSrcweir }
88cdf0e10cSrcweir
CreateObjFormatter(SwTxtFrm & _rAnchorTxtFrm,const SwPageFrm & _rPageFrm,SwLayAction * _pLayAction)89cdf0e10cSrcweir SwObjectFormatterTxtFrm* SwObjectFormatterTxtFrm::CreateObjFormatter(
90cdf0e10cSrcweir SwTxtFrm& _rAnchorTxtFrm,
91cdf0e10cSrcweir const SwPageFrm& _rPageFrm,
92cdf0e10cSrcweir SwLayAction* _pLayAction )
93cdf0e10cSrcweir {
94cdf0e10cSrcweir SwObjectFormatterTxtFrm* pObjFormatter = 0L;
95cdf0e10cSrcweir
96cdf0e10cSrcweir // determine 'master' of <_rAnchorTxtFrm>, if anchor frame is a follow text frame.
97cdf0e10cSrcweir SwTxtFrm* pMasterOfAnchorFrm = 0L;
98cdf0e10cSrcweir if ( _rAnchorTxtFrm.IsFollow() )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir pMasterOfAnchorFrm = _rAnchorTxtFrm.FindMaster();
101cdf0e10cSrcweir while ( pMasterOfAnchorFrm->IsFollow() )
102cdf0e10cSrcweir {
103cdf0e10cSrcweir pMasterOfAnchorFrm = pMasterOfAnchorFrm->FindMaster();
104cdf0e10cSrcweir }
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
107cdf0e10cSrcweir // create object formatter, if floating screen objects are registered
108cdf0e10cSrcweir // at anchor frame (or at 'master' anchor frame)
109cdf0e10cSrcweir if ( _rAnchorTxtFrm.GetDrawObjs() ||
110cdf0e10cSrcweir ( pMasterOfAnchorFrm && pMasterOfAnchorFrm->GetDrawObjs() ) )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir pObjFormatter =
113cdf0e10cSrcweir new SwObjectFormatterTxtFrm( _rAnchorTxtFrm, _rPageFrm,
114cdf0e10cSrcweir pMasterOfAnchorFrm, _pLayAction );
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
117cdf0e10cSrcweir return pObjFormatter;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
GetAnchorFrm()120cdf0e10cSrcweir SwFrm& SwObjectFormatterTxtFrm::GetAnchorFrm()
121cdf0e10cSrcweir {
122cdf0e10cSrcweir return mrAnchorTxtFrm;
123cdf0e10cSrcweir }
124cdf0e10cSrcweir
125cdf0e10cSrcweir // --> OD 2005-01-10 #i40147# - add parameter <_bCheckForMovedFwd>.
DoFormatObj(SwAnchoredObject & _rAnchoredObj,const bool _bCheckForMovedFwd)126cdf0e10cSrcweir bool SwObjectFormatterTxtFrm::DoFormatObj( SwAnchoredObject& _rAnchoredObj,
127cdf0e10cSrcweir const bool _bCheckForMovedFwd )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir // check, if only as-character anchored object have to be formatted, and
130cdf0e10cSrcweir // check the anchor type
131cdf0e10cSrcweir if ( FormatOnlyAsCharAnchored() &&
132cdf0e10cSrcweir !(_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AS_CHAR) )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir return true;
135cdf0e10cSrcweir }
136cdf0e10cSrcweir
137cdf0e10cSrcweir // --> OD 2005-07-13 #124218# - consider, if the layout action has to be
138cdf0e10cSrcweir // restarted due to a delete of a page frame.
139cdf0e10cSrcweir if ( GetLayAction() && GetLayAction()->IsAgain() )
140cdf0e10cSrcweir {
141cdf0e10cSrcweir return false;
142cdf0e10cSrcweir }
143cdf0e10cSrcweir // <--
144cdf0e10cSrcweir
145cdf0e10cSrcweir bool bSuccess( true );
146cdf0e10cSrcweir
147cdf0e10cSrcweir if ( _rAnchoredObj.IsFormatPossible() )
148cdf0e10cSrcweir {
149cdf0e10cSrcweir _rAnchoredObj.SetRestartLayoutProcess( false );
150cdf0e10cSrcweir
151cdf0e10cSrcweir _FormatObj( _rAnchoredObj );
152cdf0e10cSrcweir // --> OD 2005-07-13 #124218# - consider, if the layout action has to be
153cdf0e10cSrcweir // restarted due to a delete of a page frame.
154cdf0e10cSrcweir if ( GetLayAction() && GetLayAction()->IsAgain() )
155cdf0e10cSrcweir {
156cdf0e10cSrcweir return false;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir // <--
159cdf0e10cSrcweir
160cdf0e10cSrcweir // check, if layout process has to be restarted.
161cdf0e10cSrcweir // if yes, perform needed invalidations.
162cdf0e10cSrcweir // --> OD 2004-11-03 #114798# - no restart of layout process,
163cdf0e10cSrcweir // if anchored object is anchored inside a Writer fly frame,
164cdf0e10cSrcweir // its position is already locked, and it follows the text flow.
165cdf0e10cSrcweir const bool bRestart =
166cdf0e10cSrcweir _rAnchoredObj.RestartLayoutProcess() &&
167cdf0e10cSrcweir !( _rAnchoredObj.PositionLocked() &&
168cdf0e10cSrcweir _rAnchoredObj.GetAnchorFrm()->IsInFly() &&
169cdf0e10cSrcweir _rAnchoredObj.GetFrmFmt().GetFollowTextFlow().GetValue() );
170cdf0e10cSrcweir if ( bRestart )
171cdf0e10cSrcweir // <--
172cdf0e10cSrcweir {
173cdf0e10cSrcweir bSuccess = false;
174cdf0e10cSrcweir _InvalidatePrevObjs( _rAnchoredObj );
175cdf0e10cSrcweir _InvalidateFollowObjs( _rAnchoredObj, true );
176cdf0e10cSrcweir }
177cdf0e10cSrcweir
178cdf0e10cSrcweir // format anchor text frame, if wrapping style influence of the object
179cdf0e10cSrcweir // has to be considered and it's <NONE_SUCCESSIVE_POSITIONED>
180cdf0e10cSrcweir // --> OD 2004-08-25 #i3317# - consider also anchored objects, whose
181cdf0e10cSrcweir // wrapping style influence is temporarly considered.
182cdf0e10cSrcweir // --> OD 2005-01-10 #i40147# - consider also anchored objects, for
183cdf0e10cSrcweir // whose the check of a moved forward anchor frame is requested.
184cdf0e10cSrcweir // --> OD 2006-07-24 #b6449874# - revise decision made for i3317:
185cdf0e10cSrcweir // anchored objects, whose wrapping style influence is temporarly considered,
186cdf0e10cSrcweir // have to be considered in method <SwObjectFormatterTxtFrm::DoFormatObjs()>
187cdf0e10cSrcweir if ( bSuccess &&
188cdf0e10cSrcweir _rAnchoredObj.ConsiderObjWrapInfluenceOnObjPos() &&
189cdf0e10cSrcweir ( _bCheckForMovedFwd ||
190cdf0e10cSrcweir _rAnchoredObj.GetFrmFmt().GetWrapInfluenceOnObjPos().
191cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE
192cdf0e10cSrcweir GetWrapInfluenceOnObjPos( true ) ==
193cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - constant name has changed
194cdf0e10cSrcweir text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ) )
195cdf0e10cSrcweir // <--
196cdf0e10cSrcweir {
197cdf0e10cSrcweir // --> OD 2004-10-11 #i26945# - check conditions for move forward of
198cdf0e10cSrcweir // anchor text frame
199cdf0e10cSrcweir // determine, if anchor text frame has previous frame
200cdf0e10cSrcweir const bool bDoesAnchorHadPrev = ( mrAnchorTxtFrm.GetIndPrev() != 0 );
201cdf0e10cSrcweir
202cdf0e10cSrcweir // --> OD 2005-01-11 #i40141# - use new method - it also formats the
203cdf0e10cSrcweir // section the anchor frame is in.
204cdf0e10cSrcweir _FormatAnchorFrmForCheckMoveFwd();
205cdf0e10cSrcweir // <--
206cdf0e10cSrcweir
207cdf0e10cSrcweir // --> OD 2004-10-22 #i35911#
208cdf0e10cSrcweir if ( _rAnchoredObj.HasClearedEnvironment() )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir _rAnchoredObj.SetClearedEnvironment( true );
211cdf0e10cSrcweir // --> OD 2005-03-08 #i44049# - consider, that anchor frame
212cdf0e10cSrcweir // could already been marked to move forward.
213cdf0e10cSrcweir SwPageFrm* pAnchorPageFrm( mrAnchorTxtFrm.FindPageFrm() );
214cdf0e10cSrcweir if ( pAnchorPageFrm != _rAnchoredObj.GetPageFrm() )
215cdf0e10cSrcweir {
216cdf0e10cSrcweir bool bInsert( true );
217cdf0e10cSrcweir sal_uInt32 nToPageNum( 0L );
218cdf0e10cSrcweir const SwDoc& rDoc = *(GetPageFrm().GetFmt()->GetDoc());
219cdf0e10cSrcweir if ( SwLayouter::FrmMovedFwdByObjPos(
220cdf0e10cSrcweir rDoc, mrAnchorTxtFrm, nToPageNum ) )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir if ( nToPageNum < pAnchorPageFrm->GetPhyPageNum() )
223cdf0e10cSrcweir SwLayouter::RemoveMovedFwdFrm( rDoc, mrAnchorTxtFrm );
224cdf0e10cSrcweir else
225cdf0e10cSrcweir bInsert = false;
226cdf0e10cSrcweir }
227cdf0e10cSrcweir if ( bInsert )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir SwLayouter::InsertMovedFwdFrm( rDoc, mrAnchorTxtFrm,
230cdf0e10cSrcweir pAnchorPageFrm->GetPhyPageNum() );
231cdf0e10cSrcweir mrAnchorTxtFrm.InvalidatePos();
232cdf0e10cSrcweir bSuccess = false;
233cdf0e10cSrcweir _InvalidatePrevObjs( _rAnchoredObj );
234cdf0e10cSrcweir _InvalidateFollowObjs( _rAnchoredObj, true );
235cdf0e10cSrcweir }
236cdf0e10cSrcweir else
237cdf0e10cSrcweir {
238cdf0e10cSrcweir ASSERT( false,
239cdf0e10cSrcweir "<SwObjectFormatterTxtFrm::DoFormatObj(..)> - anchor frame not marked to move forward" );
240cdf0e10cSrcweir }
241cdf0e10cSrcweir }
242cdf0e10cSrcweir // <--
243cdf0e10cSrcweir }
244cdf0e10cSrcweir else if ( !mrAnchorTxtFrm.IsFollow() && bDoesAnchorHadPrev )
245cdf0e10cSrcweir // <--
246cdf0e10cSrcweir {
247cdf0e10cSrcweir // index of anchored object in collection of page numbers and
248cdf0e10cSrcweir // anchor types
249cdf0e10cSrcweir sal_uInt32 nIdx( CountOfCollected() );
250cdf0e10cSrcweir ASSERT( nIdx > 0,
251cdf0e10cSrcweir "<SwObjectFormatterTxtFrm::DoFormatObj(..)> - anchored object not collected!?" );
252cdf0e10cSrcweir --nIdx;
253cdf0e10cSrcweir
254cdf0e10cSrcweir sal_uInt32 nToPageNum( 0L );
255cdf0e10cSrcweir // --> OD 2005-03-30 #i43913#
256cdf0e10cSrcweir bool bDummy( false );
257cdf0e10cSrcweir // --> OD 2006-01-27 #i58182# - consider new method signature
258cdf0e10cSrcweir if ( SwObjectFormatterTxtFrm::CheckMovedFwdCondition( *GetCollectedObj( nIdx ),
259cdf0e10cSrcweir GetPgNumOfCollected( nIdx ),
260cdf0e10cSrcweir IsCollectedAnchoredAtMaster( nIdx ),
261cdf0e10cSrcweir nToPageNum, bDummy ) )
262cdf0e10cSrcweir // <--
263cdf0e10cSrcweir {
264cdf0e10cSrcweir // --> OD 2005-06-01 #i49987# - consider, that anchor frame
265cdf0e10cSrcweir // could already been marked to move forward.
266cdf0e10cSrcweir bool bInsert( true );
267cdf0e10cSrcweir sal_uInt32 nMovedFwdToPageNum( 0L );
268cdf0e10cSrcweir const SwDoc& rDoc = *(GetPageFrm().GetFmt()->GetDoc());
269cdf0e10cSrcweir if ( SwLayouter::FrmMovedFwdByObjPos(
270cdf0e10cSrcweir rDoc, mrAnchorTxtFrm, nMovedFwdToPageNum ) )
271cdf0e10cSrcweir {
272cdf0e10cSrcweir if ( nMovedFwdToPageNum < nToPageNum )
273cdf0e10cSrcweir SwLayouter::RemoveMovedFwdFrm( rDoc, mrAnchorTxtFrm );
274cdf0e10cSrcweir else
275cdf0e10cSrcweir bInsert = false;
276cdf0e10cSrcweir }
277cdf0e10cSrcweir if ( bInsert )
278cdf0e10cSrcweir {
279cdf0e10cSrcweir // Indicate that anchor text frame has to move forward and
280cdf0e10cSrcweir // invalidate its position to force a re-format.
281cdf0e10cSrcweir SwLayouter::InsertMovedFwdFrm( rDoc, mrAnchorTxtFrm,
282cdf0e10cSrcweir nToPageNum );
283cdf0e10cSrcweir mrAnchorTxtFrm.InvalidatePos();
284cdf0e10cSrcweir
285cdf0e10cSrcweir // Indicate restart of the layout process
286cdf0e10cSrcweir bSuccess = false;
287cdf0e10cSrcweir
288cdf0e10cSrcweir // If needed, invalidate previous objects anchored at same anchor
289cdf0e10cSrcweir // text frame.
290cdf0e10cSrcweir _InvalidatePrevObjs( _rAnchoredObj );
291cdf0e10cSrcweir
292cdf0e10cSrcweir // Invalidate object and following objects for the restart of the
293cdf0e10cSrcweir // layout process
294cdf0e10cSrcweir _InvalidateFollowObjs( _rAnchoredObj, true );
295cdf0e10cSrcweir }
296cdf0e10cSrcweir else
297cdf0e10cSrcweir {
298cdf0e10cSrcweir ASSERT( false,
299cdf0e10cSrcweir "<SwObjectFormatterTxtFrm::DoFormatObj(..)> - anchor frame not marked to move forward" );
300cdf0e10cSrcweir }
301cdf0e10cSrcweir // <--
302cdf0e10cSrcweir }
303cdf0e10cSrcweir }
304cdf0e10cSrcweir // <--
305cdf0e10cSrcweir // --> OD 2005-01-12 #i40155# - mark anchor frame not to wrap around
306cdf0e10cSrcweir // objects under the condition, that its follow contains all its text.
307cdf0e10cSrcweir else if ( !mrAnchorTxtFrm.IsFollow() &&
308cdf0e10cSrcweir mrAnchorTxtFrm.GetFollow() &&
309cdf0e10cSrcweir mrAnchorTxtFrm.GetFollow()->GetOfst() == 0 )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir SwLayouter::InsertFrmNotToWrap(
312cdf0e10cSrcweir *(mrAnchorTxtFrm.FindPageFrm()->GetFmt()->GetDoc()),
313cdf0e10cSrcweir mrAnchorTxtFrm );
314cdf0e10cSrcweir SwLayouter::RemoveMovedFwdFrm(
315cdf0e10cSrcweir *(mrAnchorTxtFrm.FindPageFrm()->GetFmt()->GetDoc()),
316cdf0e10cSrcweir mrAnchorTxtFrm );
317cdf0e10cSrcweir }
318cdf0e10cSrcweir // <--
319cdf0e10cSrcweir }
320cdf0e10cSrcweir }
321cdf0e10cSrcweir
322cdf0e10cSrcweir return bSuccess;
323cdf0e10cSrcweir }
324cdf0e10cSrcweir
DoFormatObjs()325cdf0e10cSrcweir bool SwObjectFormatterTxtFrm::DoFormatObjs()
326cdf0e10cSrcweir {
327cdf0e10cSrcweir if ( !mrAnchorTxtFrm.IsValid() )
328cdf0e10cSrcweir {
329cdf0e10cSrcweir if ( GetLayAction() &&
330cdf0e10cSrcweir mrAnchorTxtFrm.FindPageFrm() != &GetPageFrm() )
331cdf0e10cSrcweir {
332cdf0e10cSrcweir // notify layout action, thus is can restart the layout process on
333cdf0e10cSrcweir // a previous page.
334cdf0e10cSrcweir GetLayAction()->SetAgain();
335cdf0e10cSrcweir }
336cdf0e10cSrcweir else
337cdf0e10cSrcweir {
338cdf0e10cSrcweir // the anchor text frame has to be valid, thus assert.
339cdf0e10cSrcweir ASSERT( false,
340cdf0e10cSrcweir "<SwObjectFormatterTxtFrm::DoFormatObjs()> called for invalidate anchor text frame." );
341cdf0e10cSrcweir }
342cdf0e10cSrcweir
343cdf0e10cSrcweir return false;
344cdf0e10cSrcweir }
345cdf0e10cSrcweir
346cdf0e10cSrcweir bool bSuccess( true );
347cdf0e10cSrcweir
348cdf0e10cSrcweir if ( mrAnchorTxtFrm.IsFollow() )
349cdf0e10cSrcweir {
350cdf0e10cSrcweir // Only floating screen objects anchored as-character are directly
351cdf0e10cSrcweir // registered at a follow text frame. The other floating screen objects
352cdf0e10cSrcweir // are registered at the 'master' anchor text frame.
353cdf0e10cSrcweir // Thus, format the other floating screen objects through the 'master'
354cdf0e10cSrcweir // anchor text frame
355cdf0e10cSrcweir ASSERT( mpMasterAnchorTxtFrm,
356cdf0e10cSrcweir "SwObjectFormatterTxtFrm::DoFormatObjs() - missing 'master' anchor text frame" );
357cdf0e10cSrcweir bSuccess = _FormatObjsAtFrm( mpMasterAnchorTxtFrm );
358cdf0e10cSrcweir
359cdf0e10cSrcweir if ( bSuccess )
360cdf0e10cSrcweir {
361cdf0e10cSrcweir // format of as-character anchored floating screen objects - no failure
362cdf0e10cSrcweir // excepted on the format of these objects.
363cdf0e10cSrcweir bSuccess = _FormatObjsAtFrm();
364cdf0e10cSrcweir }
365cdf0e10cSrcweir }
366cdf0e10cSrcweir else
367cdf0e10cSrcweir {
368cdf0e10cSrcweir bSuccess = _FormatObjsAtFrm();
369cdf0e10cSrcweir }
370cdf0e10cSrcweir
371cdf0e10cSrcweir // --> OD 2006-07-24 #b449874#
372cdf0e10cSrcweir // consider anchored objects, whose wrapping style influence are temporarly
373cdf0e10cSrcweir // considered.
374cdf0e10cSrcweir if ( bSuccess &&
375cdf0e10cSrcweir ( ConsiderWrapOnObjPos() ||
376cdf0e10cSrcweir ( !mrAnchorTxtFrm.IsFollow() &&
377cdf0e10cSrcweir _AtLeastOneObjIsTmpConsiderWrapInfluence() ) ) )
378cdf0e10cSrcweir // <--
379cdf0e10cSrcweir {
380cdf0e10cSrcweir const bool bDoesAnchorHadPrev = ( mrAnchorTxtFrm.GetIndPrev() != 0 );
381cdf0e10cSrcweir
382cdf0e10cSrcweir // Format anchor text frame after its objects are formatted.
383cdf0e10cSrcweir // Note: The format of the anchor frame also formats the invalid
384cdf0e10cSrcweir // previous frames of the anchor frame. The format of the previous
385cdf0e10cSrcweir // frames is needed to get a correct result of format of the
386cdf0e10cSrcweir // anchor frame for the following check for moved forward anchors
387cdf0e10cSrcweir // --> OD 2005-01-11 #i40141# - use new method - it also formats the
388cdf0e10cSrcweir // section the anchor frame is in.
389cdf0e10cSrcweir _FormatAnchorFrmForCheckMoveFwd();
390cdf0e10cSrcweir // <--
391cdf0e10cSrcweir
392cdf0e10cSrcweir sal_uInt32 nToPageNum( 0L );
393cdf0e10cSrcweir // --> OD 2005-03-30 #i43913#
394cdf0e10cSrcweir bool bInFollow( false );
395cdf0e10cSrcweir // <--
396cdf0e10cSrcweir SwAnchoredObject* pObj = 0L;
397cdf0e10cSrcweir if ( !mrAnchorTxtFrm.IsFollow() )
398cdf0e10cSrcweir {
399cdf0e10cSrcweir pObj = _GetFirstObjWithMovedFwdAnchor(
400cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - constant name has changed
401cdf0e10cSrcweir text::WrapInfluenceOnPosition::ONCE_CONCURRENT,
402cdf0e10cSrcweir // <--
403cdf0e10cSrcweir nToPageNum, bInFollow );
404cdf0e10cSrcweir }
405cdf0e10cSrcweir // --> OD 2004-10-25 #i35911#
406cdf0e10cSrcweir if ( pObj && pObj->HasClearedEnvironment() )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir pObj->SetClearedEnvironment( true );
409cdf0e10cSrcweir // --> OD 2005-03-08 #i44049# - consider, that anchor frame
410cdf0e10cSrcweir // could already been marked to move forward.
411cdf0e10cSrcweir SwPageFrm* pAnchorPageFrm( mrAnchorTxtFrm.FindPageFrm() );
412cdf0e10cSrcweir // --> OD 2005-03-30 #i43913# - consider, that anchor frame
413cdf0e10cSrcweir // is a follow or is in a follow row, which will move forward.
414cdf0e10cSrcweir if ( pAnchorPageFrm != pObj->GetPageFrm() ||
415cdf0e10cSrcweir bInFollow )
416cdf0e10cSrcweir // <--
417cdf0e10cSrcweir {
418cdf0e10cSrcweir bool bInsert( true );
419cdf0e10cSrcweir sal_uInt32 nTmpToPageNum( 0L );
420cdf0e10cSrcweir const SwDoc& rDoc = *(GetPageFrm().GetFmt()->GetDoc());
421cdf0e10cSrcweir if ( SwLayouter::FrmMovedFwdByObjPos(
422cdf0e10cSrcweir rDoc, mrAnchorTxtFrm, nTmpToPageNum ) )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir if ( nTmpToPageNum < pAnchorPageFrm->GetPhyPageNum() )
425cdf0e10cSrcweir SwLayouter::RemoveMovedFwdFrm( rDoc, mrAnchorTxtFrm );
426cdf0e10cSrcweir else
427cdf0e10cSrcweir bInsert = false;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir if ( bInsert )
430cdf0e10cSrcweir {
431cdf0e10cSrcweir SwLayouter::InsertMovedFwdFrm( rDoc, mrAnchorTxtFrm,
432cdf0e10cSrcweir pAnchorPageFrm->GetPhyPageNum() );
433cdf0e10cSrcweir mrAnchorTxtFrm.InvalidatePos();
434cdf0e10cSrcweir bSuccess = false;
435cdf0e10cSrcweir _InvalidatePrevObjs( *pObj );
436cdf0e10cSrcweir _InvalidateFollowObjs( *pObj, true );
437cdf0e10cSrcweir }
438cdf0e10cSrcweir else
439cdf0e10cSrcweir {
440cdf0e10cSrcweir ASSERT( false,
441cdf0e10cSrcweir "<SwObjectFormatterTxtFrm::DoFormatObjs(..)> - anchor frame not marked to move forward" );
442cdf0e10cSrcweir }
443cdf0e10cSrcweir }
444cdf0e10cSrcweir }
445cdf0e10cSrcweir else if ( pObj && bDoesAnchorHadPrev )
446cdf0e10cSrcweir // <--
447cdf0e10cSrcweir {
448cdf0e10cSrcweir // Object found, whose anchor is moved forward
449cdf0e10cSrcweir
450cdf0e10cSrcweir // --> OD 2005-06-01 #i49987# - consider, that anchor frame
451cdf0e10cSrcweir // could already been marked to move forward.
452cdf0e10cSrcweir bool bInsert( true );
453cdf0e10cSrcweir sal_uInt32 nMovedFwdToPageNum( 0L );
454cdf0e10cSrcweir const SwDoc& rDoc = *(GetPageFrm().GetFmt()->GetDoc());
455cdf0e10cSrcweir if ( SwLayouter::FrmMovedFwdByObjPos(
456cdf0e10cSrcweir rDoc, mrAnchorTxtFrm, nMovedFwdToPageNum ) )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir if ( nMovedFwdToPageNum < nToPageNum )
459cdf0e10cSrcweir SwLayouter::RemoveMovedFwdFrm( rDoc, mrAnchorTxtFrm );
460cdf0e10cSrcweir else
461cdf0e10cSrcweir bInsert = false;
462cdf0e10cSrcweir }
463cdf0e10cSrcweir if ( bInsert )
464cdf0e10cSrcweir {
465cdf0e10cSrcweir // Indicate that anchor text frame has to move forward and
466cdf0e10cSrcweir // invalidate its position to force a re-format.
467cdf0e10cSrcweir SwLayouter::InsertMovedFwdFrm( rDoc, mrAnchorTxtFrm, nToPageNum );
468cdf0e10cSrcweir mrAnchorTxtFrm.InvalidatePos();
469cdf0e10cSrcweir
470cdf0e10cSrcweir // Indicate restart of the layout process
471cdf0e10cSrcweir bSuccess = false;
472cdf0e10cSrcweir
473cdf0e10cSrcweir // If needed, invalidate previous objects anchored at same anchor
474cdf0e10cSrcweir // text frame.
475cdf0e10cSrcweir _InvalidatePrevObjs( *pObj );
476cdf0e10cSrcweir
477cdf0e10cSrcweir // Invalidate object and following objects for the restart of the
478cdf0e10cSrcweir // layout process
479cdf0e10cSrcweir _InvalidateFollowObjs( *pObj, true );
480cdf0e10cSrcweir }
481cdf0e10cSrcweir else
482cdf0e10cSrcweir {
483cdf0e10cSrcweir ASSERT( false,
484cdf0e10cSrcweir "<SwObjectFormatterTxtFrm::DoFormatObjs(..)> - anchor frame not marked to move forward" );
485cdf0e10cSrcweir }
486cdf0e10cSrcweir // <--
487cdf0e10cSrcweir }
488cdf0e10cSrcweir // <--
489cdf0e10cSrcweir // --> OD 2005-01-12 #i40155# - mark anchor frame not to wrap around
490cdf0e10cSrcweir // objects under the condition, that its follow contains all its text.
491cdf0e10cSrcweir else if ( !mrAnchorTxtFrm.IsFollow() &&
492cdf0e10cSrcweir mrAnchorTxtFrm.GetFollow() &&
493cdf0e10cSrcweir mrAnchorTxtFrm.GetFollow()->GetOfst() == 0 )
494cdf0e10cSrcweir {
495cdf0e10cSrcweir SwLayouter::InsertFrmNotToWrap(
496cdf0e10cSrcweir *(mrAnchorTxtFrm.FindPageFrm()->GetFmt()->GetDoc()),
497cdf0e10cSrcweir mrAnchorTxtFrm );
498cdf0e10cSrcweir SwLayouter::RemoveMovedFwdFrm(
499cdf0e10cSrcweir *(mrAnchorTxtFrm.FindPageFrm()->GetFmt()->GetDoc()),
500cdf0e10cSrcweir mrAnchorTxtFrm );
501cdf0e10cSrcweir }
502cdf0e10cSrcweir // <--
503cdf0e10cSrcweir }
504cdf0e10cSrcweir
505cdf0e10cSrcweir return bSuccess;
506cdf0e10cSrcweir }
507cdf0e10cSrcweir
_InvalidatePrevObjs(SwAnchoredObject & _rAnchoredObj)508cdf0e10cSrcweir void SwObjectFormatterTxtFrm::_InvalidatePrevObjs( SwAnchoredObject& _rAnchoredObj )
509cdf0e10cSrcweir {
510cdf0e10cSrcweir // invalidate all previous objects, whose wrapping influence on the object
511cdf0e10cSrcweir // positioning is <NONE_CONCURRENT_POSIITIONED>.
512cdf0e10cSrcweir // Note: list of objects at anchor frame is sorted by this property.
513cdf0e10cSrcweir if ( _rAnchoredObj.GetFrmFmt().GetWrapInfluenceOnObjPos().
514cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE
515cdf0e10cSrcweir GetWrapInfluenceOnObjPos( true ) ==
516cdf0e10cSrcweir // <--
517cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - constant name has changed
518cdf0e10cSrcweir text::WrapInfluenceOnPosition::ONCE_CONCURRENT )
519cdf0e10cSrcweir // <--
520cdf0e10cSrcweir {
521cdf0e10cSrcweir const SwSortedObjs* pObjs = GetAnchorFrm().GetDrawObjs();
522cdf0e10cSrcweir if ( pObjs )
523cdf0e10cSrcweir {
524cdf0e10cSrcweir // determine start index
525cdf0e10cSrcweir sal_Int32 i = pObjs->ListPosOf( _rAnchoredObj ) - 1;
526cdf0e10cSrcweir for ( ; i >= 0; --i )
527cdf0e10cSrcweir {
528cdf0e10cSrcweir SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
529cdf0e10cSrcweir if ( pAnchoredObj->GetFrmFmt().GetWrapInfluenceOnObjPos().
530cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE
531cdf0e10cSrcweir GetWrapInfluenceOnObjPos( true ) ==
532cdf0e10cSrcweir // <--
533cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - constant name has changed
534cdf0e10cSrcweir text::WrapInfluenceOnPosition::ONCE_CONCURRENT )
535cdf0e10cSrcweir // <--
536cdf0e10cSrcweir {
537cdf0e10cSrcweir pAnchoredObj->InvalidateObjPosForConsiderWrapInfluence( true );
538cdf0e10cSrcweir }
539cdf0e10cSrcweir }
540cdf0e10cSrcweir }
541cdf0e10cSrcweir }
542cdf0e10cSrcweir }
543cdf0e10cSrcweir
_InvalidateFollowObjs(SwAnchoredObject & _rAnchoredObj,const bool _bInclObj)544cdf0e10cSrcweir void SwObjectFormatterTxtFrm::_InvalidateFollowObjs( SwAnchoredObject& _rAnchoredObj,
545cdf0e10cSrcweir const bool _bInclObj )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir if ( _bInclObj )
548cdf0e10cSrcweir {
549cdf0e10cSrcweir _rAnchoredObj.InvalidateObjPosForConsiderWrapInfluence( true );
550cdf0e10cSrcweir }
551cdf0e10cSrcweir
552cdf0e10cSrcweir const SwSortedObjs* pObjs = GetPageFrm().GetSortedObjs();
553cdf0e10cSrcweir if ( pObjs )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir // determine start index
556cdf0e10cSrcweir sal_uInt32 i = pObjs->ListPosOf( _rAnchoredObj ) + 1;
557cdf0e10cSrcweir for ( ; i < pObjs->Count(); ++i )
558cdf0e10cSrcweir {
559cdf0e10cSrcweir SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
560cdf0e10cSrcweir pAnchoredObj->InvalidateObjPosForConsiderWrapInfluence( true );
561cdf0e10cSrcweir }
562cdf0e10cSrcweir }
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
_GetFirstObjWithMovedFwdAnchor(const sal_Int16 _nWrapInfluenceOnPosition,sal_uInt32 & _noToPageNum,bool & _boInFollow)565cdf0e10cSrcweir SwAnchoredObject* SwObjectFormatterTxtFrm::_GetFirstObjWithMovedFwdAnchor(
566cdf0e10cSrcweir const sal_Int16 _nWrapInfluenceOnPosition,
567cdf0e10cSrcweir sal_uInt32& _noToPageNum,
568cdf0e10cSrcweir bool& _boInFollow )
569cdf0e10cSrcweir {
570cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - constant names have changed
571cdf0e10cSrcweir ASSERT( _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_SUCCESSIVE ||
572cdf0e10cSrcweir _nWrapInfluenceOnPosition == text::WrapInfluenceOnPosition::ONCE_CONCURRENT,
573cdf0e10cSrcweir "<SwObjectFormatterTxtFrm::_GetFirstObjWithMovedFwdAnchor(..)> - invalid value for parameter <_nWrapInfluenceOnPosition>" );
574cdf0e10cSrcweir // <--
575cdf0e10cSrcweir
576cdf0e10cSrcweir SwAnchoredObject* pRetAnchoredObj = 0L;
577cdf0e10cSrcweir
578cdf0e10cSrcweir sal_uInt32 i = 0L;
579cdf0e10cSrcweir for ( ; i < CountOfCollected(); ++i )
580cdf0e10cSrcweir {
581cdf0e10cSrcweir SwAnchoredObject* pAnchoredObj = GetCollectedObj(i);
582cdf0e10cSrcweir if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() &&
583cdf0e10cSrcweir pAnchoredObj->GetFrmFmt().GetWrapInfluenceOnObjPos().
584cdf0e10cSrcweir // --> OD 2004-10-18 #i35017# - handle ITERATIVE as ONCE_SUCCESSIVE
585cdf0e10cSrcweir GetWrapInfluenceOnObjPos( true ) == _nWrapInfluenceOnPosition )
586cdf0e10cSrcweir // <--
587cdf0e10cSrcweir {
588cdf0e10cSrcweir // --> OD 2004-10-11 #i26945# - use new method <_CheckMovedFwdCondition(..)>
589cdf0e10cSrcweir // --> OD 2005-03-30 #i43913#
590cdf0e10cSrcweir // --> OD 2006-01-27 #i58182# - consider new method signature
591cdf0e10cSrcweir if ( SwObjectFormatterTxtFrm::CheckMovedFwdCondition( *GetCollectedObj( i ),
592cdf0e10cSrcweir GetPgNumOfCollected( i ),
593cdf0e10cSrcweir IsCollectedAnchoredAtMaster( i ),
594cdf0e10cSrcweir _noToPageNum, _boInFollow ) )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir pRetAnchoredObj = pAnchoredObj;
597cdf0e10cSrcweir break;
598cdf0e10cSrcweir }
599cdf0e10cSrcweir // <--
600cdf0e10cSrcweir }
601cdf0e10cSrcweir }
602cdf0e10cSrcweir
603cdf0e10cSrcweir return pRetAnchoredObj;
604cdf0e10cSrcweir }
605cdf0e10cSrcweir
606cdf0e10cSrcweir // --> OD 2006-01-27 #i58182#
607cdf0e10cSrcweir // - replace private method by corresponding static public method
CheckMovedFwdCondition(SwAnchoredObject & _rAnchoredObj,const sal_uInt32 _nFromPageNum,const bool _bAnchoredAtMasterBeforeFormatAnchor,sal_uInt32 & _noToPageNum,bool & _boInFollow)608cdf0e10cSrcweir bool SwObjectFormatterTxtFrm::CheckMovedFwdCondition(
609cdf0e10cSrcweir SwAnchoredObject& _rAnchoredObj,
610cdf0e10cSrcweir const sal_uInt32 _nFromPageNum,
611cdf0e10cSrcweir const bool _bAnchoredAtMasterBeforeFormatAnchor,
612cdf0e10cSrcweir sal_uInt32& _noToPageNum,
613cdf0e10cSrcweir bool& _boInFollow )
614cdf0e10cSrcweir {
615cdf0e10cSrcweir bool bAnchorIsMovedForward( false );
616cdf0e10cSrcweir
617cdf0e10cSrcweir SwPageFrm* pPageFrmOfAnchor = _rAnchoredObj.FindPageFrmOfAnchor();
618cdf0e10cSrcweir if ( pPageFrmOfAnchor )
619cdf0e10cSrcweir {
620cdf0e10cSrcweir const sal_uInt32 nPageNum = pPageFrmOfAnchor->GetPhyPageNum();
621cdf0e10cSrcweir if ( nPageNum > _nFromPageNum )
622cdf0e10cSrcweir {
623cdf0e10cSrcweir _noToPageNum = nPageNum;
624cdf0e10cSrcweir // --> OD 2006-06-28 #b6443897#
625cdf0e10cSrcweir // Handling of special case:
626cdf0e10cSrcweir // If anchor frame is move forward into a follow flow row,
627cdf0e10cSrcweir // <_noToPageNum> is set to <_nFromPageNum + 1>, because it is
628cdf0e10cSrcweir // possible that the anchor page frame isn't valid, because the
629cdf0e10cSrcweir // page distance between master row and follow flow row is greater
630cdf0e10cSrcweir // than 1.
631cdf0e10cSrcweir if ( _noToPageNum > (_nFromPageNum + 1) )
632cdf0e10cSrcweir {
633cdf0e10cSrcweir SwFrm* pAnchorFrm = _rAnchoredObj.GetAnchorFrmContainingAnchPos();
634cdf0e10cSrcweir if ( pAnchorFrm->IsInTab() &&
635cdf0e10cSrcweir pAnchorFrm->IsInFollowFlowRow() )
636cdf0e10cSrcweir {
637cdf0e10cSrcweir _noToPageNum = _nFromPageNum + 1;
638cdf0e10cSrcweir }
639cdf0e10cSrcweir }
640cdf0e10cSrcweir // <--
641cdf0e10cSrcweir bAnchorIsMovedForward = true;
642cdf0e10cSrcweir }
643cdf0e10cSrcweir }
644cdf0e10cSrcweir // <--
645cdf0e10cSrcweir // --> OD 2004-11-05 #i26945# - check, if an at-paragraph|at-character
646cdf0e10cSrcweir // anchored object is now anchored at a follow text frame, which will be
647cdf0e10cSrcweir // on the next page. Also check, if an at-character anchored object
648cdf0e10cSrcweir // is now anchored at a text frame, which is in a follow flow row,
649cdf0e10cSrcweir // which will be on the next page.
650cdf0e10cSrcweir if ( !bAnchorIsMovedForward &&
651cdf0e10cSrcweir _bAnchoredAtMasterBeforeFormatAnchor &&
652cdf0e10cSrcweir ((_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_CHAR) ||
653cdf0e10cSrcweir (_rAnchoredObj.GetFrmFmt().GetAnchor().GetAnchorId() == FLY_AT_PARA)))
654cdf0e10cSrcweir {
655cdf0e10cSrcweir SwFrm* pAnchorFrm = _rAnchoredObj.GetAnchorFrmContainingAnchPos();
656cdf0e10cSrcweir ASSERT( pAnchorFrm->IsTxtFrm(),
657cdf0e10cSrcweir "<SwObjectFormatterTxtFrm::CheckMovedFwdCondition(..) - wrong type of anchor frame>" );
658cdf0e10cSrcweir SwTxtFrm* pAnchorTxtFrm = static_cast<SwTxtFrm*>(pAnchorFrm);
659cdf0e10cSrcweir bool bCheck( false );
660cdf0e10cSrcweir if ( pAnchorTxtFrm->IsFollow() )
661cdf0e10cSrcweir {
662cdf0e10cSrcweir bCheck = true;
663cdf0e10cSrcweir }
664cdf0e10cSrcweir else if( pAnchorTxtFrm->IsInTab() )
665cdf0e10cSrcweir {
666cdf0e10cSrcweir const SwRowFrm* pMasterRow = pAnchorTxtFrm->IsInFollowFlowRow();
667cdf0e10cSrcweir if ( pMasterRow &&
668cdf0e10cSrcweir pMasterRow->FindPageFrm() == pPageFrmOfAnchor )
669cdf0e10cSrcweir {
670cdf0e10cSrcweir bCheck = true;
671cdf0e10cSrcweir }
672cdf0e10cSrcweir }
673cdf0e10cSrcweir if ( bCheck )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir // check, if found text frame will be on the next page
676cdf0e10cSrcweir // by checking, if it's in a column, which has no next.
677cdf0e10cSrcweir SwFrm* pColFrm = pAnchorTxtFrm->FindColFrm();
678cdf0e10cSrcweir while ( pColFrm && !pColFrm->GetNext() )
679cdf0e10cSrcweir {
680cdf0e10cSrcweir pColFrm = pColFrm->FindColFrm();
681cdf0e10cSrcweir }
682cdf0e10cSrcweir if ( !pColFrm || !pColFrm->GetNext() )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir _noToPageNum = _nFromPageNum + 1;
685cdf0e10cSrcweir bAnchorIsMovedForward = true;
686cdf0e10cSrcweir // --> OD 2005-03-30 #i43913#
687cdf0e10cSrcweir _boInFollow = true;
688cdf0e10cSrcweir // <--
689cdf0e10cSrcweir }
690cdf0e10cSrcweir }
691cdf0e10cSrcweir }
692cdf0e10cSrcweir // <--
693cdf0e10cSrcweir
694cdf0e10cSrcweir return bAnchorIsMovedForward;
695cdf0e10cSrcweir }
696cdf0e10cSrcweir // <--
697cdf0e10cSrcweir
698cdf0e10cSrcweir // --> OD 2005-01-12 #i40140# - helper method to format layout frames used by
699cdf0e10cSrcweir // method <SwObjectFormatterTxtFrm::_FormatAnchorFrmForCheckMoveFwd()>
700cdf0e10cSrcweir // --> OD 2005-03-04 #i44049# - format till a certain lower frame, if provided.
lcl_FormatCntntOfLayoutFrm(SwLayoutFrm * pLayFrm,SwFrm * pLastLowerFrm=0L)701cdf0e10cSrcweir void lcl_FormatCntntOfLayoutFrm( SwLayoutFrm* pLayFrm,
702cdf0e10cSrcweir SwFrm* pLastLowerFrm = 0L )
703cdf0e10cSrcweir {
704cdf0e10cSrcweir SwFrm* pLowerFrm = pLayFrm->GetLower();
705cdf0e10cSrcweir while ( pLowerFrm )
706cdf0e10cSrcweir {
707cdf0e10cSrcweir // --> OD 2005-03-04 #i44049#
708cdf0e10cSrcweir if ( pLastLowerFrm && pLowerFrm == pLastLowerFrm )
709cdf0e10cSrcweir {
710cdf0e10cSrcweir break;
711cdf0e10cSrcweir }
712cdf0e10cSrcweir // <--
713cdf0e10cSrcweir if ( pLowerFrm->IsLayoutFrm() )
714cdf0e10cSrcweir lcl_FormatCntntOfLayoutFrm( static_cast<SwLayoutFrm*>(pLowerFrm),
715cdf0e10cSrcweir pLastLowerFrm );
716cdf0e10cSrcweir else
717cdf0e10cSrcweir pLowerFrm->Calc();
718cdf0e10cSrcweir
719cdf0e10cSrcweir pLowerFrm = pLowerFrm->GetNext();
720cdf0e10cSrcweir }
721cdf0e10cSrcweir }
722cdf0e10cSrcweir // <--
723cdf0e10cSrcweir /** method to format given anchor text frame and its previous frames
724cdf0e10cSrcweir
725cdf0e10cSrcweir OD 2005-11-17 #i56300#
726cdf0e10cSrcweir Usage: Needed to check, if the anchor text frame is moved forward
727cdf0e10cSrcweir due to the positioning and wrapping of its anchored objects, and
728cdf0e10cSrcweir to format the frames, which have become invalid due to the anchored
729cdf0e10cSrcweir object formatting in the iterative object positioning algorithm
730cdf0e10cSrcweir
731cdf0e10cSrcweir @author OD
732cdf0e10cSrcweir */
FormatAnchorFrmAndItsPrevs(SwTxtFrm & _rAnchorTxtFrm)733cdf0e10cSrcweir void SwObjectFormatterTxtFrm::FormatAnchorFrmAndItsPrevs( SwTxtFrm& _rAnchorTxtFrm )
734cdf0e10cSrcweir {
735cdf0e10cSrcweir // --> OD 2005-04-13 #i47014# - no format of section and previous columns
736cdf0e10cSrcweir // for follow text frames.
737cdf0e10cSrcweir if ( !_rAnchorTxtFrm.IsFollow() )
738cdf0e10cSrcweir {
739cdf0e10cSrcweir // if anchor frame is directly inside a section, format this section and
740cdf0e10cSrcweir // its previous frames.
741cdf0e10cSrcweir // Note: It's a very simple format without formatting objects.
742cdf0e10cSrcweir if ( _rAnchorTxtFrm.IsInSct() )
743cdf0e10cSrcweir {
744cdf0e10cSrcweir SwFrm* pSectFrm = _rAnchorTxtFrm.GetUpper();
745cdf0e10cSrcweir while ( pSectFrm )
746cdf0e10cSrcweir {
747cdf0e10cSrcweir if ( pSectFrm->IsSctFrm() || pSectFrm->IsCellFrm() )
748cdf0e10cSrcweir {
749cdf0e10cSrcweir break;
750cdf0e10cSrcweir }
751cdf0e10cSrcweir pSectFrm = pSectFrm->GetUpper();
752cdf0e10cSrcweir }
753cdf0e10cSrcweir if ( pSectFrm && pSectFrm->IsSctFrm() )
754cdf0e10cSrcweir {
755cdf0e10cSrcweir // --> OD 2005-03-04 #i44049#
756cdf0e10cSrcweir _rAnchorTxtFrm.LockJoin();
757cdf0e10cSrcweir // <--
758cdf0e10cSrcweir SwFrm* pFrm = pSectFrm->GetUpper()->GetLower();
759cdf0e10cSrcweir // --> OD 2005-05-23 #i49605# - section frame could move forward
760cdf0e10cSrcweir // by the format of its previous frame.
761cdf0e10cSrcweir // Thus, check for valid <pFrm>.
762cdf0e10cSrcweir while ( pFrm && pFrm != pSectFrm )
763cdf0e10cSrcweir // <--
764cdf0e10cSrcweir {
765cdf0e10cSrcweir if ( pFrm->IsLayoutFrm() )
766cdf0e10cSrcweir lcl_FormatCntntOfLayoutFrm( static_cast<SwLayoutFrm*>(pFrm) );
767cdf0e10cSrcweir else
768cdf0e10cSrcweir pFrm->Calc();
769cdf0e10cSrcweir
770cdf0e10cSrcweir pFrm = pFrm->GetNext();
771cdf0e10cSrcweir }
772cdf0e10cSrcweir lcl_FormatCntntOfLayoutFrm( static_cast<SwLayoutFrm*>(pSectFrm),
773cdf0e10cSrcweir &_rAnchorTxtFrm );
774cdf0e10cSrcweir // --> OD 2005-03-04 #i44049#
775cdf0e10cSrcweir _rAnchorTxtFrm.UnlockJoin();
776cdf0e10cSrcweir // <--
777cdf0e10cSrcweir }
778cdf0e10cSrcweir }
779cdf0e10cSrcweir
780cdf0e10cSrcweir // --> OD 2005-01-12 #i40140# - if anchor frame is inside a column,
781cdf0e10cSrcweir // format the content of the previous columns.
782cdf0e10cSrcweir // Note: It's a very simple format without formatting objects.
783cdf0e10cSrcweir SwFrm* pColFrmOfAnchor = _rAnchorTxtFrm.FindColFrm();
784cdf0e10cSrcweir if ( pColFrmOfAnchor )
785cdf0e10cSrcweir {
786cdf0e10cSrcweir // --> OD 2005-03-04 #i44049#
787cdf0e10cSrcweir _rAnchorTxtFrm.LockJoin();
788cdf0e10cSrcweir // <--
789cdf0e10cSrcweir SwFrm* pColFrm = pColFrmOfAnchor->GetUpper()->GetLower();
790cdf0e10cSrcweir while ( pColFrm != pColFrmOfAnchor )
791cdf0e10cSrcweir {
792cdf0e10cSrcweir SwFrm* pFrm = pColFrm->GetLower();
793cdf0e10cSrcweir while ( pFrm )
794cdf0e10cSrcweir {
795cdf0e10cSrcweir if ( pFrm->IsLayoutFrm() )
796cdf0e10cSrcweir lcl_FormatCntntOfLayoutFrm( static_cast<SwLayoutFrm*>(pFrm) );
797cdf0e10cSrcweir else
798cdf0e10cSrcweir pFrm->Calc();
799cdf0e10cSrcweir
800cdf0e10cSrcweir pFrm = pFrm->GetNext();
801cdf0e10cSrcweir }
802cdf0e10cSrcweir
803cdf0e10cSrcweir pColFrm = pColFrm->GetNext();
804cdf0e10cSrcweir }
805cdf0e10cSrcweir // --> OD 2005-03-04 #i44049#
806cdf0e10cSrcweir _rAnchorTxtFrm.UnlockJoin();
807cdf0e10cSrcweir // <--
808cdf0e10cSrcweir }
809cdf0e10cSrcweir // <--
810cdf0e10cSrcweir }
811cdf0e10cSrcweir // <--
812cdf0e10cSrcweir
813cdf0e10cSrcweir // format anchor frame - format of its follow not needed
814cdf0e10cSrcweir // --> OD 2005-04-08 #i43255# - forbid follow format, only if anchor text
815cdf0e10cSrcweir // frame is in table
816cdf0e10cSrcweir if ( _rAnchorTxtFrm.IsInTab() )
817cdf0e10cSrcweir {
818cdf0e10cSrcweir SwForbidFollowFormat aForbidFollowFormat( _rAnchorTxtFrm );
819cdf0e10cSrcweir _rAnchorTxtFrm.Calc();
820cdf0e10cSrcweir }
821cdf0e10cSrcweir else
822cdf0e10cSrcweir {
823cdf0e10cSrcweir _rAnchorTxtFrm.Calc();
824cdf0e10cSrcweir }
825cdf0e10cSrcweir }
826cdf0e10cSrcweir
827cdf0e10cSrcweir /** method to format the anchor frame for checking of the move forward condition
828cdf0e10cSrcweir
829cdf0e10cSrcweir OD 2005-01-11 #i40141#
830cdf0e10cSrcweir
831cdf0e10cSrcweir @author OD
832cdf0e10cSrcweir */
_FormatAnchorFrmForCheckMoveFwd()833cdf0e10cSrcweir void SwObjectFormatterTxtFrm::_FormatAnchorFrmForCheckMoveFwd()
834cdf0e10cSrcweir {
835cdf0e10cSrcweir SwObjectFormatterTxtFrm::FormatAnchorFrmAndItsPrevs( mrAnchorTxtFrm );
836cdf0e10cSrcweir }
837cdf0e10cSrcweir
838cdf0e10cSrcweir /** method to determine if at least one anchored object has state
839cdf0e10cSrcweir <temporarly consider wrapping style influence> set.
840cdf0e10cSrcweir
841cdf0e10cSrcweir OD 2006-07-24 #b6449874#
842cdf0e10cSrcweir
843cdf0e10cSrcweir @author OD
844cdf0e10cSrcweir */
_AtLeastOneObjIsTmpConsiderWrapInfluence()845cdf0e10cSrcweir bool SwObjectFormatterTxtFrm::_AtLeastOneObjIsTmpConsiderWrapInfluence()
846cdf0e10cSrcweir {
847cdf0e10cSrcweir bool bRet( false );
848cdf0e10cSrcweir
849cdf0e10cSrcweir const SwSortedObjs* pObjs = GetAnchorFrm().GetDrawObjs();
850cdf0e10cSrcweir if ( pObjs && pObjs->Count() > 1 )
851cdf0e10cSrcweir {
852cdf0e10cSrcweir sal_uInt32 i = 0;
853cdf0e10cSrcweir for ( ; i < pObjs->Count(); ++i )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
856cdf0e10cSrcweir if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
857cdf0e10cSrcweir {
858cdf0e10cSrcweir bRet = true;
859cdf0e10cSrcweir break;
860cdf0e10cSrcweir }
861cdf0e10cSrcweir }
862cdf0e10cSrcweir }
863cdf0e10cSrcweir
864cdf0e10cSrcweir return bRet;
865cdf0e10cSrcweir }
866cdf0e10cSrcweir
867