xref: /AOO41X/main/sw/source/core/layout/anchoredobject.cxx (revision efeef26f81c84063fb0a91bde3856d4a51172d90)
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 <anchoredobject.hxx>
27cdf0e10cSrcweir #include <pam.hxx>
28cdf0e10cSrcweir #include <frame.hxx>
29cdf0e10cSrcweir #include <txtfrm.hxx>
30cdf0e10cSrcweir #include <frmfmt.hxx>
31cdf0e10cSrcweir #include <fmtanchr.hxx>
32cdf0e10cSrcweir #include <fmtornt.hxx>
33cdf0e10cSrcweir // --> OD 2004-06-29 #i28701#
34cdf0e10cSrcweir #include <doc.hxx>
35cdf0e10cSrcweir #include <fmtsrnd.hxx>
36cdf0e10cSrcweir #include <svx/svdobj.hxx>
37cdf0e10cSrcweir #include <dcontact.hxx>
38cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
39cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
40cdf0e10cSrcweir #include <sortedobjs.hxx>
41cdf0e10cSrcweir #include <pagefrm.hxx>
42cdf0e10cSrcweir // <--
43cdf0e10cSrcweir #include <frmatr.hxx>
44cdf0e10cSrcweir // --> OD 2004-08-25 #i3317#
45cdf0e10cSrcweir #include <colfrm.hxx>
46cdf0e10cSrcweir // <--
47cdf0e10cSrcweir // --> OD 2004-10-22 #i35911#
48cdf0e10cSrcweir #include <layouter.hxx>
49cdf0e10cSrcweir 
50cdf0e10cSrcweir 
51cdf0e10cSrcweir using namespace ::com::sun::star;
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 
54cdf0e10cSrcweir // <--
55cdf0e10cSrcweir // ============================================================================
56cdf0e10cSrcweir // --> OD 2004-06-30 #i28701# -
57cdf0e10cSrcweir // implementation of helper class <SwObjPositioningInProgress>
58cdf0e10cSrcweir // ============================================================================
SwObjPositioningInProgress(SdrObject & _rSdrObj)59cdf0e10cSrcweir SwObjPositioningInProgress::SwObjPositioningInProgress( SdrObject& _rSdrObj ) :
60cdf0e10cSrcweir     mpAnchoredObj( 0L ),
61cdf0e10cSrcweir     // --> OD 2005-08-09 #i52904#
62cdf0e10cSrcweir     mbOldObjPositioningInProgress( false )
63cdf0e10cSrcweir     // <--
64cdf0e10cSrcweir {
65cdf0e10cSrcweir     mpAnchoredObj = ::GetUserCall( &_rSdrObj )->GetAnchoredObj( &_rSdrObj );
66cdf0e10cSrcweir     // --> OD 2005-08-09 #i52904#
67cdf0e10cSrcweir     mbOldObjPositioningInProgress = mpAnchoredObj->IsPositioningInProgress();
68cdf0e10cSrcweir     // <--
69cdf0e10cSrcweir     mpAnchoredObj->SetPositioningInProgress( true );
70cdf0e10cSrcweir }
SwObjPositioningInProgress(SwAnchoredObject & _rAnchoredObj)71cdf0e10cSrcweir SwObjPositioningInProgress::SwObjPositioningInProgress( SwAnchoredObject& _rAnchoredObj ) :
72cdf0e10cSrcweir     mpAnchoredObj( &_rAnchoredObj ),
73cdf0e10cSrcweir     // --> OD 2005-08-09 #i52904#
74cdf0e10cSrcweir     mbOldObjPositioningInProgress( false )
75cdf0e10cSrcweir     // <--
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     // --> OD 2005-08-09 #i52904#
78cdf0e10cSrcweir     mbOldObjPositioningInProgress = mpAnchoredObj->IsPositioningInProgress();
79cdf0e10cSrcweir     // <--
80cdf0e10cSrcweir     mpAnchoredObj->SetPositioningInProgress( true );
81cdf0e10cSrcweir }
82cdf0e10cSrcweir 
~SwObjPositioningInProgress()83cdf0e10cSrcweir SwObjPositioningInProgress::~SwObjPositioningInProgress()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir     if ( mpAnchoredObj )
86cdf0e10cSrcweir     {
87cdf0e10cSrcweir         // --> OD 2005-08-09 #i52904#
88cdf0e10cSrcweir         mpAnchoredObj->SetPositioningInProgress( mbOldObjPositioningInProgress );
89cdf0e10cSrcweir         // <--
90cdf0e10cSrcweir     }
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
93cdf0e10cSrcweir // ============================================================================
94cdf0e10cSrcweir 
95cdf0e10cSrcweir TYPEINIT0(SwAnchoredObject);
96cdf0e10cSrcweir 
SwAnchoredObject()97cdf0e10cSrcweir SwAnchoredObject::SwAnchoredObject() :
98cdf0e10cSrcweir     mpDrawObj( 0L ),
99cdf0e10cSrcweir     mpAnchorFrm( 0L ),
100cdf0e10cSrcweir     // --> OD 2004-06-30 #i28701#
101cdf0e10cSrcweir     mpPageFrm( 0L ),
102cdf0e10cSrcweir     // <--
103cdf0e10cSrcweir     maRelPos(),
104cdf0e10cSrcweir     maLastCharRect(),
105cdf0e10cSrcweir     mnLastTopOfLine( 0L ),
106cdf0e10cSrcweir     mpVertPosOrientFrm( 0L ),
107cdf0e10cSrcweir     // --> OD 2004-06-29 #i28701#
108cdf0e10cSrcweir     mbPositioningInProgress( false ),
109cdf0e10cSrcweir     mbConsiderForTextWrap( false ),
110cdf0e10cSrcweir     mbPositionLocked( false ),
111cdf0e10cSrcweir     // --> OD 2005-01-10 #i40147#
112cdf0e10cSrcweir     mbKeepPositionLockedForSection( false ),
113cdf0e10cSrcweir     // <--
114cdf0e10cSrcweir     mbRestartLayoutProcess( false ),
115cdf0e10cSrcweir     // <--
116cdf0e10cSrcweir     // --> OD 2004-10-22 #i35911#
117cdf0e10cSrcweir     mbClearedEnvironment( false ),
118cdf0e10cSrcweir     // <--
119cdf0e10cSrcweir     // --> OD 2004-08-25 #i3317#
120cdf0e10cSrcweir     mbTmpConsiderWrapInfluence( false ),
121cdf0e10cSrcweir     // <--
122cdf0e10cSrcweir     // --> OD 2006-08-10 #i68520#
123cdf0e10cSrcweir     maObjRectWithSpaces(),
124cdf0e10cSrcweir     mbObjRectWithSpacesValid( false ),
125cdf0e10cSrcweir     maLastObjRect()
126cdf0e10cSrcweir     // <--
127cdf0e10cSrcweir {
128cdf0e10cSrcweir }
129cdf0e10cSrcweir 
~SwAnchoredObject()130cdf0e10cSrcweir SwAnchoredObject::~SwAnchoredObject()
131cdf0e10cSrcweir {
132cdf0e10cSrcweir }
133cdf0e10cSrcweir 
134cdf0e10cSrcweir // =============================================================================
135cdf0e10cSrcweir // accessors for member <mpDrawObj>
136cdf0e10cSrcweir // =============================================================================
SetDrawObj(SdrObject & _rDrawObj)137cdf0e10cSrcweir void SwAnchoredObject::SetDrawObj( SdrObject& _rDrawObj )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir     mpDrawObj = &_rDrawObj;
140cdf0e10cSrcweir }
141cdf0e10cSrcweir 
GetDrawObj() const142cdf0e10cSrcweir const SdrObject* SwAnchoredObject::GetDrawObj() const
143cdf0e10cSrcweir {
144cdf0e10cSrcweir     return mpDrawObj;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir 
DrawObj()147cdf0e10cSrcweir SdrObject* SwAnchoredObject::DrawObj()
148cdf0e10cSrcweir {
149cdf0e10cSrcweir     return mpDrawObj;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir 
152cdf0e10cSrcweir // =============================================================================
153cdf0e10cSrcweir // accessors for member <mpAnchorFrm>
154cdf0e10cSrcweir // =============================================================================
GetAnchorFrm() const155cdf0e10cSrcweir const SwFrm* SwAnchoredObject::GetAnchorFrm() const
156cdf0e10cSrcweir {
157cdf0e10cSrcweir     return mpAnchorFrm;
158cdf0e10cSrcweir }
159cdf0e10cSrcweir 
AnchorFrm()160cdf0e10cSrcweir SwFrm* SwAnchoredObject::AnchorFrm()
161cdf0e10cSrcweir {
162cdf0e10cSrcweir     return mpAnchorFrm;
163cdf0e10cSrcweir }
164cdf0e10cSrcweir 
ChgAnchorFrm(SwFrm * _pNewAnchorFrm)165cdf0e10cSrcweir void SwAnchoredObject::ChgAnchorFrm( SwFrm* _pNewAnchorFrm )
166cdf0e10cSrcweir {
167cdf0e10cSrcweir     mpAnchorFrm = _pNewAnchorFrm;
168cdf0e10cSrcweir 
169cdf0e10cSrcweir     if ( mpAnchorFrm )
170cdf0e10cSrcweir     {
171cdf0e10cSrcweir         ObjectAttachedToAnchorFrame();
172cdf0e10cSrcweir     }
173cdf0e10cSrcweir }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir /** determine anchor frame containing the anchor position
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     OD 2004-10-08 #i26945#
178cdf0e10cSrcweir     the anchor frame, which is determined, is <mpAnchorFrm>
179cdf0e10cSrcweir     for an at-page, at-frame or at-paragraph anchored object
180cdf0e10cSrcweir     and the anchor character frame for an at-character and as-character
181cdf0e10cSrcweir     anchored object.
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     @author OD
184cdf0e10cSrcweir */
GetAnchorFrmContainingAnchPos()185cdf0e10cSrcweir SwFrm* SwAnchoredObject::GetAnchorFrmContainingAnchPos()
186cdf0e10cSrcweir {
187cdf0e10cSrcweir     SwFrm* pAnchorFrmContainingAnchPos = FindAnchorCharFrm();
188cdf0e10cSrcweir     if ( !pAnchorFrmContainingAnchPos )
189cdf0e10cSrcweir     {
190cdf0e10cSrcweir         pAnchorFrmContainingAnchPos = AnchorFrm();
191cdf0e10cSrcweir     }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir     return pAnchorFrmContainingAnchPos;
194cdf0e10cSrcweir }
195cdf0e10cSrcweir 
196cdf0e10cSrcweir // =============================================================================
197cdf0e10cSrcweir // OD 2004-06-30 #i28701# accessors for member <mpPageFrm>
198cdf0e10cSrcweir // =============================================================================
GetPageFrm()199cdf0e10cSrcweir SwPageFrm* SwAnchoredObject::GetPageFrm()
200cdf0e10cSrcweir {
201cdf0e10cSrcweir     return mpPageFrm;
202cdf0e10cSrcweir }
203cdf0e10cSrcweir 
GetPageFrm() const204cdf0e10cSrcweir const SwPageFrm* SwAnchoredObject::GetPageFrm() const
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     return mpPageFrm;
207cdf0e10cSrcweir }
208cdf0e10cSrcweir 
SetPageFrm(SwPageFrm * _pNewPageFrm)209cdf0e10cSrcweir void SwAnchoredObject::SetPageFrm( SwPageFrm* _pNewPageFrm )
210cdf0e10cSrcweir {
211cdf0e10cSrcweir     // --> OD 2006-01-02 #125977#
212cdf0e10cSrcweir     if ( mpPageFrm != _pNewPageFrm )
213cdf0e10cSrcweir     {
214cdf0e10cSrcweir         // clear member, which denotes the layout frame at which the vertical
215cdf0e10cSrcweir         // position is oriented at, if it doesn't fit to the new page frame.
216cdf0e10cSrcweir         if ( GetVertPosOrientFrm() &&
217cdf0e10cSrcweir              ( !_pNewPageFrm ||
218cdf0e10cSrcweir                _pNewPageFrm != GetVertPosOrientFrm()->FindPageFrm() ) )
219cdf0e10cSrcweir         {
220cdf0e10cSrcweir             ClearVertPosOrientFrm();
221cdf0e10cSrcweir         }
222cdf0e10cSrcweir 
223cdf0e10cSrcweir         // assign new page frame
224cdf0e10cSrcweir         mpPageFrm = _pNewPageFrm;
225cdf0e10cSrcweir     }
226cdf0e10cSrcweir     // <--
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir // =============================================================================
230cdf0e10cSrcweir // accessors for member <maLastCharRect>
231cdf0e10cSrcweir // =============================================================================
GetLastCharRect() const232cdf0e10cSrcweir const SwRect& SwAnchoredObject::GetLastCharRect() const
233cdf0e10cSrcweir {
234cdf0e10cSrcweir     return maLastCharRect;
235cdf0e10cSrcweir }
236cdf0e10cSrcweir 
GetRelCharX(const SwFrm * pFrm) const237cdf0e10cSrcweir SwTwips SwAnchoredObject::GetRelCharX( const SwFrm* pFrm ) const
238cdf0e10cSrcweir {
239cdf0e10cSrcweir     return maLastCharRect.Left() - pFrm->Frm().Left();
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
GetRelCharY(const SwFrm * pFrm) const242cdf0e10cSrcweir SwTwips SwAnchoredObject::GetRelCharY( const SwFrm* pFrm ) const
243cdf0e10cSrcweir {
244cdf0e10cSrcweir     return maLastCharRect.Bottom() - pFrm->Frm().Top();
245cdf0e10cSrcweir }
246cdf0e10cSrcweir 
AddLastCharY(long nDiff)247cdf0e10cSrcweir void SwAnchoredObject::AddLastCharY( long nDiff )
248cdf0e10cSrcweir {
249cdf0e10cSrcweir     maLastCharRect.Pos().Y() += nDiff;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
ResetLastCharRectHeight()252cdf0e10cSrcweir void SwAnchoredObject::ResetLastCharRectHeight()
253cdf0e10cSrcweir {
254cdf0e10cSrcweir     maLastCharRect.Height( 0 );
255cdf0e10cSrcweir }
256cdf0e10cSrcweir // =============================================================================
257cdf0e10cSrcweir // accessors for member <mpVertPosOrientFrm>
258cdf0e10cSrcweir // =============================================================================
SetVertPosOrientFrm(const SwLayoutFrm & _rVertPosOrientFrm)259cdf0e10cSrcweir void SwAnchoredObject::SetVertPosOrientFrm( const SwLayoutFrm& _rVertPosOrientFrm )
260cdf0e10cSrcweir {
261cdf0e10cSrcweir     mpVertPosOrientFrm = &_rVertPosOrientFrm;
262cdf0e10cSrcweir 
263cdf0e10cSrcweir     // --> OD 2004-07-02 #i28701# - take over functionality of deleted method
264cdf0e10cSrcweir     // <SwFlyAtCntFrm::AssertPage()>: assure for at-paragraph and at-character
265cdf0e10cSrcweir     // an anchored object, that it is registered at the correct page frame
266cdf0e10cSrcweir     RegisterAtCorrectPage();
267cdf0e10cSrcweir }
268cdf0e10cSrcweir 
269cdf0e10cSrcweir // =============================================================================
270cdf0e10cSrcweir // accessors for member <mnLastTopOfLine>
271cdf0e10cSrcweir // =============================================================================
GetLastTopOfLine() const272cdf0e10cSrcweir SwTwips SwAnchoredObject::GetLastTopOfLine() const
273cdf0e10cSrcweir {
274cdf0e10cSrcweir     return mnLastTopOfLine;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir // OD 2004-05-18 #i28701# - follow-up of #i22341#
AddLastTopOfLineY(SwTwips _nDiff)278cdf0e10cSrcweir void SwAnchoredObject::AddLastTopOfLineY( SwTwips _nDiff )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir     mnLastTopOfLine += _nDiff;
281cdf0e10cSrcweir }
282cdf0e10cSrcweir 
283cdf0e10cSrcweir /** check anchor character rectangle and top of line
284cdf0e10cSrcweir 
285cdf0e10cSrcweir     OD 2004-03-24 #i26791
286cdf0e10cSrcweir     For to-character anchored Writer fly frames the members <maLastCharRect>
287cdf0e10cSrcweir     and <maLastTopOfLine> are updated. These are checked for change and
288cdf0e10cSrcweir     depending on the applied positioning, it's decided, if the Writer fly
289cdf0e10cSrcweir     frame has to be invalidated.
290cdf0e10cSrcweir     OD 2004-07-15 #117380#
291cdf0e10cSrcweir     add parameter <_bCheckForParaPorInf>, default value <true>
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     @author OD
294cdf0e10cSrcweir */
CheckCharRectAndTopOfLine(const bool _bCheckForParaPorInf)295cdf0e10cSrcweir void SwAnchoredObject::CheckCharRectAndTopOfLine(
296cdf0e10cSrcweir                                         const bool _bCheckForParaPorInf )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir     if ( GetAnchorFrm() &&
299cdf0e10cSrcweir          GetAnchorFrm()->IsTxtFrm() )
300cdf0e10cSrcweir     {
301cdf0e10cSrcweir         const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor();
302cdf0e10cSrcweir         if ( (rAnch.GetAnchorId() == FLY_AT_CHAR) &&
303cdf0e10cSrcweir              rAnch.GetCntntAnchor() )
304cdf0e10cSrcweir         {
305cdf0e10cSrcweir             // --> OD 2004-07-14 #117380# - if requested, assure that anchor frame,
306cdf0e10cSrcweir             // which contains the anchor character, has a paragraph portion information.
307cdf0e10cSrcweir             // The paragraph portion information is needed to determine the
308cdf0e10cSrcweir             // anchor character rectangle respectively the top of the line.
309cdf0e10cSrcweir             // Thus, a format of this frame is avoided to determine the
310cdf0e10cSrcweir             // paragraph portion information.
311cdf0e10cSrcweir             // --> OD 2004-10-04 #i26945# - use new method <FindAnchorCharFrm()>
312cdf0e10cSrcweir             const SwTxtFrm& aAnchorCharFrm = *(FindAnchorCharFrm());
313cdf0e10cSrcweir             // <--
314cdf0e10cSrcweir             if ( !_bCheckForParaPorInf || aAnchorCharFrm.HasPara() )
315cdf0e10cSrcweir             {
316cdf0e10cSrcweir                 _CheckCharRect( rAnch, aAnchorCharFrm );
317cdf0e10cSrcweir                 _CheckTopOfLine( rAnch, aAnchorCharFrm );
318cdf0e10cSrcweir             }
319cdf0e10cSrcweir             // <--
320cdf0e10cSrcweir         }
321cdf0e10cSrcweir     }
322cdf0e10cSrcweir }
323cdf0e10cSrcweir 
324cdf0e10cSrcweir /** check anchor character rectangle
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     OD 11.11.2003 #i22341#
327cdf0e10cSrcweir     helper method for method <CheckCharRectAndTopOfLine()>
328cdf0e10cSrcweir     For to-character anchored Writer fly frames the member <maLastCharRect>
329cdf0e10cSrcweir     is updated. This is checked for change and depending on the applied
330cdf0e10cSrcweir     positioning, it's decided, if the Writer fly frame has to be invalidated.
331cdf0e10cSrcweir     OD 2004-07-14 #117380#
332cdf0e10cSrcweir     improvement - add second parameter <_rAnchorCharFrm>
333cdf0e10cSrcweir 
334cdf0e10cSrcweir     @author OD
335cdf0e10cSrcweir */
_CheckCharRect(const SwFmtAnchor & _rAnch,const SwTxtFrm & _rAnchorCharFrm)336cdf0e10cSrcweir void SwAnchoredObject::_CheckCharRect( const SwFmtAnchor& _rAnch,
337cdf0e10cSrcweir                                        const SwTxtFrm& _rAnchorCharFrm )
338cdf0e10cSrcweir {
339cdf0e10cSrcweir     // determine rectangle of anchor character. If not exist, abort operation
340cdf0e10cSrcweir     SwRect aCharRect;
341cdf0e10cSrcweir     if ( !_rAnchorCharFrm.GetAutoPos( aCharRect, *_rAnch.GetCntntAnchor() ) )
342cdf0e10cSrcweir     {
343cdf0e10cSrcweir         return;
344cdf0e10cSrcweir     }
345cdf0e10cSrcweir     // check, if anchor character rectangle has changed
346cdf0e10cSrcweir     if ( aCharRect != maLastCharRect )
347cdf0e10cSrcweir     {
348cdf0e10cSrcweir         // check positioning and alignment for invalidation of position
349cdf0e10cSrcweir         {
350cdf0e10cSrcweir             SWRECTFN( (&_rAnchorCharFrm) );
351cdf0e10cSrcweir             // determine positioning and alignment
352cdf0e10cSrcweir             SwFmtVertOrient aVert( GetFrmFmt().GetVertOrient() );
353cdf0e10cSrcweir             SwFmtHoriOrient aHori( GetFrmFmt().GetHoriOrient() );
354cdf0e10cSrcweir             // check for anchor character rectangle changes for certain
355cdf0e10cSrcweir             // positionings and alignments
356cdf0e10cSrcweir             // OD 07.10.2003 #110978# - add condition to invalidate position,
357cdf0e10cSrcweir             // if vertical aligned at frame/page area and vertical position
358cdf0e10cSrcweir             // of anchor character has changed.
359cdf0e10cSrcweir             const sal_Int16 eVertRelOrient = aVert.GetRelationOrient();
360cdf0e10cSrcweir             if ( ( aHori.GetRelationOrient() == text::RelOrientation::CHAR &&
361cdf0e10cSrcweir                    (aCharRect.*fnRect->fnGetLeft)() !=
362cdf0e10cSrcweir                         (maLastCharRect.*fnRect->fnGetLeft)() ) ||
363cdf0e10cSrcweir                  ( eVertRelOrient == text::RelOrientation::CHAR &&
364cdf0e10cSrcweir                    ( (aCharRect.*fnRect->fnGetTop)() !=
365cdf0e10cSrcweir                         (maLastCharRect.*fnRect->fnGetTop)() ||
366cdf0e10cSrcweir                      (aCharRect.*fnRect->fnGetHeight)() !=
367cdf0e10cSrcweir                         (maLastCharRect.*fnRect->fnGetHeight)() ) ) ||
368cdf0e10cSrcweir                  ( ( ( eVertRelOrient == text::RelOrientation::FRAME ) ||
369cdf0e10cSrcweir                      ( eVertRelOrient == text::RelOrientation::PRINT_AREA ) ||
370cdf0e10cSrcweir                      ( eVertRelOrient == text::RelOrientation::PAGE_FRAME ) ||
371cdf0e10cSrcweir                      ( eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA ) ) &&
372cdf0e10cSrcweir                    ( (aCharRect.*fnRect->fnGetTop)() !=
373cdf0e10cSrcweir                         (maLastCharRect.*fnRect->fnGetTop)() ) ) )
374cdf0e10cSrcweir             {
375cdf0e10cSrcweir                 // --> OD 2004-10-08 #i26945#, #i35911# - unlock position of
376cdf0e10cSrcweir                 // anchored object, if it isn't registered at the page,
377cdf0e10cSrcweir                 // where its anchor character frame is on.
378cdf0e10cSrcweir                 if ( GetPageFrm() != _rAnchorCharFrm.FindPageFrm() )
379cdf0e10cSrcweir                 {
380cdf0e10cSrcweir                     UnlockPosition();
381cdf0e10cSrcweir                 }
382cdf0e10cSrcweir                 // <--
383cdf0e10cSrcweir                 InvalidateObjPos();
384cdf0e10cSrcweir             }
385cdf0e10cSrcweir         }
386cdf0e10cSrcweir         // keep new anchor character rectangle
387cdf0e10cSrcweir         maLastCharRect = aCharRect;
388cdf0e10cSrcweir     }
389cdf0e10cSrcweir }
390cdf0e10cSrcweir 
391cdf0e10cSrcweir /** check top of line
392cdf0e10cSrcweir 
393cdf0e10cSrcweir     OD 11.11.2003 #i22341#
394cdf0e10cSrcweir     helper method for method <CheckCharRectAndTopOfLine()>
395cdf0e10cSrcweir     For to-character anchored Writer fly frames the member <mnLastTopOfLine>
396cdf0e10cSrcweir     is updated. This is checked for change and depending on the applied
397cdf0e10cSrcweir     positioning, it's decided, if the Writer fly frame has to be invalidated.
398cdf0e10cSrcweir     OD 2004-07-14 #117380#
399cdf0e10cSrcweir     improvement - add second parameter <_rAnchorCharFrm>
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     @author OD
402cdf0e10cSrcweir */
_CheckTopOfLine(const SwFmtAnchor & _rAnch,const SwTxtFrm & _rAnchorCharFrm)403cdf0e10cSrcweir void SwAnchoredObject::_CheckTopOfLine( const SwFmtAnchor& _rAnch,
404cdf0e10cSrcweir                                         const SwTxtFrm& _rAnchorCharFrm )
405cdf0e10cSrcweir {
406cdf0e10cSrcweir     SwTwips nTopOfLine = 0L;
407cdf0e10cSrcweir     if ( _rAnchorCharFrm.GetTopOfLine( nTopOfLine, *_rAnch.GetCntntAnchor() ) )
408cdf0e10cSrcweir     {
409cdf0e10cSrcweir         if ( nTopOfLine != mnLastTopOfLine )
410cdf0e10cSrcweir         {
411cdf0e10cSrcweir             // check alignment for invalidation of position
412cdf0e10cSrcweir             if ( GetFrmFmt().GetVertOrient().GetRelationOrient() == text::RelOrientation::TEXT_LINE )
413cdf0e10cSrcweir             {
414cdf0e10cSrcweir                 // --> OD 2004-10-08 #i26945#, #i35911# - unlock position of
415cdf0e10cSrcweir                 // anchored object, if it isn't registered at the page,
416cdf0e10cSrcweir                 // where its anchor character frame is on.
417cdf0e10cSrcweir                 if ( GetPageFrm() != _rAnchorCharFrm.FindPageFrm() )
418cdf0e10cSrcweir                 {
419cdf0e10cSrcweir                     UnlockPosition();
420cdf0e10cSrcweir                 }
421cdf0e10cSrcweir                 // <--
422cdf0e10cSrcweir                 InvalidateObjPos();
423cdf0e10cSrcweir             }
424cdf0e10cSrcweir             // keep new top of line value
425cdf0e10cSrcweir             mnLastTopOfLine = nTopOfLine;
426cdf0e10cSrcweir         }
427cdf0e10cSrcweir     }
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
ClearCharRectAndTopOfLine()430cdf0e10cSrcweir void SwAnchoredObject::ClearCharRectAndTopOfLine()
431cdf0e10cSrcweir {
432cdf0e10cSrcweir     maLastCharRect.Clear();
433cdf0e10cSrcweir     mnLastTopOfLine = 0;
434cdf0e10cSrcweir }
435cdf0e10cSrcweir 
GetCurrRelPos() const436cdf0e10cSrcweir const Point SwAnchoredObject::GetCurrRelPos() const
437cdf0e10cSrcweir {
438cdf0e10cSrcweir     return maRelPos;
439cdf0e10cSrcweir }
SetCurrRelPos(Point _aRelPos)440cdf0e10cSrcweir void SwAnchoredObject::SetCurrRelPos( Point _aRelPos )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir     maRelPos = _aRelPos;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir 
ObjectAttachedToAnchorFrame()445cdf0e10cSrcweir void SwAnchoredObject::ObjectAttachedToAnchorFrame()
446cdf0e10cSrcweir {
447cdf0e10cSrcweir     // default behaviour:
448cdf0e10cSrcweir     // update layout direction, the anchored object is assigned to
449cdf0e10cSrcweir     UpdateLayoutDir();
450cdf0e10cSrcweir }
451cdf0e10cSrcweir 
452cdf0e10cSrcweir /** method update layout direction the layout direction, the anchored
453cdf0e10cSrcweir     object is in
454cdf0e10cSrcweir 
455cdf0e10cSrcweir     OD 2004-07-27 #i31698#
456cdf0e10cSrcweir     method has typically to be called, if the anchored object gets its
457cdf0e10cSrcweir     anchor frame assigned.
458cdf0e10cSrcweir 
459cdf0e10cSrcweir     @author OD
460cdf0e10cSrcweir */
UpdateLayoutDir()461cdf0e10cSrcweir void SwAnchoredObject::UpdateLayoutDir()
462cdf0e10cSrcweir {
463cdf0e10cSrcweir     SwFrmFmt::tLayoutDir nLayoutDir = SwFrmFmt::HORI_L2R;
464cdf0e10cSrcweir     const SwFrm* pAnchorFrm = GetAnchorFrm();
465cdf0e10cSrcweir     if ( pAnchorFrm )
466cdf0e10cSrcweir     {
467cdf0e10cSrcweir         const bool bVert = pAnchorFrm->IsVertical();
468cdf0e10cSrcweir         const bool bR2L = pAnchorFrm->IsRightToLeft();
469cdf0e10cSrcweir         if ( bVert )
470cdf0e10cSrcweir         {
471cdf0e10cSrcweir             nLayoutDir = SwFrmFmt::VERT_R2L;
472cdf0e10cSrcweir         }
473cdf0e10cSrcweir         else if ( bR2L )
474cdf0e10cSrcweir         {
475cdf0e10cSrcweir             nLayoutDir = SwFrmFmt::HORI_R2L;
476cdf0e10cSrcweir         }
477cdf0e10cSrcweir     }
478cdf0e10cSrcweir     GetFrmFmt().SetLayoutDir( nLayoutDir );
479cdf0e10cSrcweir }
480cdf0e10cSrcweir 
481cdf0e10cSrcweir /** method to perform necessary invalidations for the positioning of
482cdf0e10cSrcweir     objects, for whose the wrapping style influence has to be considered
483cdf0e10cSrcweir     on the object positioning.
484cdf0e10cSrcweir 
485cdf0e10cSrcweir     OD 2004-06-30 #i28701#
486cdf0e10cSrcweir 
487cdf0e10cSrcweir     @author OD
488cdf0e10cSrcweir */
InvalidateObjPosForConsiderWrapInfluence(const bool _bNotifyBackgrd)489cdf0e10cSrcweir void SwAnchoredObject::InvalidateObjPosForConsiderWrapInfluence(
490cdf0e10cSrcweir                                                     const bool _bNotifyBackgrd )
491cdf0e10cSrcweir {
492cdf0e10cSrcweir     if ( ConsiderObjWrapInfluenceOnObjPos() )
493cdf0e10cSrcweir     {
494cdf0e10cSrcweir         // indicate that object has not to be considered for text wrap
495cdf0e10cSrcweir         SetConsiderForTextWrap( false );
496cdf0e10cSrcweir         // unlock position
497cdf0e10cSrcweir         UnlockPosition();
498cdf0e10cSrcweir         // invalidate position
499cdf0e10cSrcweir         InvalidateObjPos();
500cdf0e10cSrcweir         // invalidate 'background', if requested
501cdf0e10cSrcweir         if ( _bNotifyBackgrd )
502cdf0e10cSrcweir         {
503cdf0e10cSrcweir             NotifyBackground( GetPageFrm(), GetObjRectWithSpaces(), PREP_FLY_LEAVE );
504cdf0e10cSrcweir         }
505cdf0e10cSrcweir     }
506cdf0e10cSrcweir }
507cdf0e10cSrcweir 
508cdf0e10cSrcweir /** method to determine, if wrapping style influence of the anchored
509cdf0e10cSrcweir     object has to be considered on the object positioning
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     OD 2004-06-30 #i28701#
512cdf0e10cSrcweir     Note: result of this method also decides, if the booleans for the
513cdf0e10cSrcweir     layout process are of relevance.
514cdf0e10cSrcweir 
515cdf0e10cSrcweir     @author OD
516cdf0e10cSrcweir */
ConsiderObjWrapInfluenceOnObjPos() const517cdf0e10cSrcweir bool SwAnchoredObject::ConsiderObjWrapInfluenceOnObjPos() const
518cdf0e10cSrcweir {
519cdf0e10cSrcweir     bool bRet( false );
520cdf0e10cSrcweir 
521cdf0e10cSrcweir     const SwFrmFmt& rObjFmt = GetFrmFmt();
522cdf0e10cSrcweir 
523cdf0e10cSrcweir     // --> OD 2004-08-25 #i3317# - add condition <IsTmpConsiderWrapInfluence()>
524cdf0e10cSrcweir     // --> OD 2005-09-29 #i55204#
525cdf0e10cSrcweir     // - correction: wrapping style influence has been considered, if condition
526cdf0e10cSrcweir     //   <IsTmpConsiderWrapInfluence()> is hold, regardless of its anchor type
527cdf0e10cSrcweir     //   or its wrapping style.
528cdf0e10cSrcweir     if ( IsTmpConsiderWrapInfluence() )
529cdf0e10cSrcweir     {
530cdf0e10cSrcweir         bRet = true;
531cdf0e10cSrcweir     }
532cdf0e10cSrcweir     else if ( rObjFmt.getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
533cdf0e10cSrcweir     // <--
534cdf0e10cSrcweir     {
535cdf0e10cSrcweir         const SwFmtAnchor& rAnchor = rObjFmt.GetAnchor();
536cdf0e10cSrcweir         if ( ((rAnchor.GetAnchorId() == FLY_AT_CHAR) ||
537cdf0e10cSrcweir               (rAnchor.GetAnchorId() == FLY_AT_PARA)) &&
538cdf0e10cSrcweir              rObjFmt.GetSurround().GetSurround() != SURROUND_THROUGHT )
539cdf0e10cSrcweir         {
540cdf0e10cSrcweir             // --> OD 2004-09-23 #i34520# - text also wraps around anchored
541cdf0e10cSrcweir             // objects in the layer Hell - see the text formatting.
542cdf0e10cSrcweir             // Thus, it hasn't to be checked here.
543cdf0e10cSrcweir             bRet = true;
544cdf0e10cSrcweir             // <--
545cdf0e10cSrcweir         }
546cdf0e10cSrcweir     }
547cdf0e10cSrcweir 
548cdf0e10cSrcweir     return bRet;
549cdf0e10cSrcweir }
550cdf0e10cSrcweir 
551cdf0e10cSrcweir /** method to determine, if other anchored objects, also attached at
552cdf0e10cSrcweir     to the anchor frame, have to consider its wrap influence.
553cdf0e10cSrcweir 
554cdf0e10cSrcweir     // --> OD 2005-02-22 #i43255#
555cdf0e10cSrcweir 
556cdf0e10cSrcweir     @author OD
557cdf0e10cSrcweir */
ConsiderObjWrapInfluenceOfOtherObjs() const558cdf0e10cSrcweir bool SwAnchoredObject::ConsiderObjWrapInfluenceOfOtherObjs() const
559cdf0e10cSrcweir {
560cdf0e10cSrcweir     bool bRet( false );
561cdf0e10cSrcweir 
562cdf0e10cSrcweir     const SwSortedObjs* pObjs = GetAnchorFrm()->GetDrawObjs();
563cdf0e10cSrcweir     if ( pObjs->Count() > 1 )
564cdf0e10cSrcweir     {
565cdf0e10cSrcweir         sal_uInt32 i = 0;
566cdf0e10cSrcweir         for ( ; i < pObjs->Count(); ++i )
567cdf0e10cSrcweir         {
568cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
569cdf0e10cSrcweir             if ( pAnchoredObj != this &&
570cdf0e10cSrcweir                  pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
571cdf0e10cSrcweir             {
572cdf0e10cSrcweir                 bRet = true;
573cdf0e10cSrcweir                 break;
574cdf0e10cSrcweir             }
575cdf0e10cSrcweir         }
576cdf0e10cSrcweir     }
577cdf0e10cSrcweir 
578cdf0e10cSrcweir     return bRet;
579cdf0e10cSrcweir }
580cdf0e10cSrcweir 
581cdf0e10cSrcweir // =============================================================================
582cdf0e10cSrcweir // --> OD 2004-06-29 #i28701# - accessors to booleans for layout process
583cdf0e10cSrcweir // =============================================================================
ConsiderForTextWrap() const584cdf0e10cSrcweir bool SwAnchoredObject::ConsiderForTextWrap() const
585cdf0e10cSrcweir {
586cdf0e10cSrcweir     if ( ConsiderObjWrapInfluenceOnObjPos() )
587cdf0e10cSrcweir         return mbConsiderForTextWrap;
588cdf0e10cSrcweir     else
589cdf0e10cSrcweir         return true;
590cdf0e10cSrcweir }
591cdf0e10cSrcweir 
SetConsiderForTextWrap(const bool _bConsiderForTextWrap)592cdf0e10cSrcweir void SwAnchoredObject::SetConsiderForTextWrap( const bool _bConsiderForTextWrap )
593cdf0e10cSrcweir {
594cdf0e10cSrcweir     mbConsiderForTextWrap = _bConsiderForTextWrap;
595cdf0e10cSrcweir }
596cdf0e10cSrcweir 
PositionLocked() const597cdf0e10cSrcweir bool SwAnchoredObject::PositionLocked() const
598cdf0e10cSrcweir {
599cdf0e10cSrcweir     if ( ConsiderObjWrapInfluenceOnObjPos() )
600cdf0e10cSrcweir         return mbPositionLocked;
601cdf0e10cSrcweir     else
602cdf0e10cSrcweir         return false;
603cdf0e10cSrcweir }
604cdf0e10cSrcweir 
RestartLayoutProcess() const605cdf0e10cSrcweir bool SwAnchoredObject::RestartLayoutProcess() const
606cdf0e10cSrcweir {
607cdf0e10cSrcweir     if ( ConsiderObjWrapInfluenceOnObjPos() )
608cdf0e10cSrcweir         return mbRestartLayoutProcess;
609cdf0e10cSrcweir     else
610cdf0e10cSrcweir         return false;
611cdf0e10cSrcweir }
612cdf0e10cSrcweir 
SetRestartLayoutProcess(const bool _bRestartLayoutProcess)613cdf0e10cSrcweir void SwAnchoredObject::SetRestartLayoutProcess( const bool _bRestartLayoutProcess )
614cdf0e10cSrcweir {
615cdf0e10cSrcweir     mbRestartLayoutProcess = _bRestartLayoutProcess;
616cdf0e10cSrcweir }
617cdf0e10cSrcweir 
618cdf0e10cSrcweir // --> OD 2004-10-22 #i35911#
ClearedEnvironment() const619cdf0e10cSrcweir bool SwAnchoredObject::ClearedEnvironment() const
620cdf0e10cSrcweir {
621cdf0e10cSrcweir     if ( ConsiderObjWrapInfluenceOnObjPos() )
622cdf0e10cSrcweir         return mbClearedEnvironment;
623cdf0e10cSrcweir     else
624cdf0e10cSrcweir         return false;
625cdf0e10cSrcweir }
SetClearedEnvironment(const bool _bClearedEnvironment)626cdf0e10cSrcweir void SwAnchoredObject::SetClearedEnvironment( const bool _bClearedEnvironment )
627cdf0e10cSrcweir {
628cdf0e10cSrcweir     mbClearedEnvironment = _bClearedEnvironment;
629cdf0e10cSrcweir }
630cdf0e10cSrcweir // <--
631cdf0e10cSrcweir 
632cdf0e10cSrcweir /** method to determine, if due to anchored object size and wrapping
633cdf0e10cSrcweir     style, its layout environment is cleared.
634cdf0e10cSrcweir 
635cdf0e10cSrcweir     OD 2004-10-22 #i35911#
636cdf0e10cSrcweir 
637cdf0e10cSrcweir     @author OD
638cdf0e10cSrcweir */
HasClearedEnvironment() const639cdf0e10cSrcweir bool SwAnchoredObject::HasClearedEnvironment() const
640cdf0e10cSrcweir {
641cdf0e10cSrcweir     bool bHasClearedEnvironment( false );
642cdf0e10cSrcweir 
643cdf0e10cSrcweir     // --> OD 2005-03-03 #i43913# - layout frame, vertical position is orient at, has to be set.
644cdf0e10cSrcweir     ASSERT( GetVertPosOrientFrm(),
645cdf0e10cSrcweir             "<SwAnchoredObject::HasClearedEnvironment()> - layout frame missing, at which the vertical position is oriented at." );
646cdf0e10cSrcweir     if ( GetVertPosOrientFrm() &&
647cdf0e10cSrcweir          GetAnchorFrm()->IsTxtFrm() &&
648cdf0e10cSrcweir          !static_cast<const SwTxtFrm*>(GetAnchorFrm())->IsFollow() &&
649cdf0e10cSrcweir          static_cast<const SwTxtFrm*>(GetAnchorFrm())->FindPageFrm()->GetPhyPageNum() >=
650cdf0e10cSrcweir                 GetPageFrm()->GetPhyPageNum() )
651cdf0e10cSrcweir     // <--
652cdf0e10cSrcweir     {
653cdf0e10cSrcweir         const SwFrm* pTmpFrm = GetVertPosOrientFrm()->Lower();
654cdf0e10cSrcweir         while ( pTmpFrm && pTmpFrm->IsLayoutFrm() && !pTmpFrm->IsTabFrm() )
655cdf0e10cSrcweir         {
656cdf0e10cSrcweir             pTmpFrm = static_cast<const SwLayoutFrm*>(pTmpFrm)->Lower();
657cdf0e10cSrcweir         }
658cdf0e10cSrcweir         if ( !pTmpFrm )
659cdf0e10cSrcweir         {
660cdf0e10cSrcweir             bHasClearedEnvironment = true;
661cdf0e10cSrcweir         }
662cdf0e10cSrcweir         else if ( pTmpFrm->IsTxtFrm() && !pTmpFrm->GetNext() )
663cdf0e10cSrcweir         {
664cdf0e10cSrcweir             const SwTxtFrm* pTmpTxtFrm = static_cast<const SwTxtFrm*>(pTmpFrm);
665cdf0e10cSrcweir             if ( pTmpTxtFrm->IsUndersized() ||
666cdf0e10cSrcweir                  ( pTmpTxtFrm->GetFollow() &&
667cdf0e10cSrcweir                    pTmpTxtFrm->GetFollow()->GetOfst() == 0 ) )
668cdf0e10cSrcweir             {
669cdf0e10cSrcweir                 bHasClearedEnvironment = true;
670cdf0e10cSrcweir             }
671cdf0e10cSrcweir         }
672cdf0e10cSrcweir     }
673cdf0e10cSrcweir 
674cdf0e10cSrcweir     return bHasClearedEnvironment;
675cdf0e10cSrcweir }
676cdf0e10cSrcweir 
677cdf0e10cSrcweir /** method to add spacing to object area
678cdf0e10cSrcweir 
679cdf0e10cSrcweir     OD 2004-06-30 #i28701#
680cdf0e10cSrcweir     OD 2006-08-10 #i68520# - return constant reference and use cache
681cdf0e10cSrcweir 
682cdf0e10cSrcweir     @author OD
683cdf0e10cSrcweir */
GetObjRectWithSpaces() const684cdf0e10cSrcweir const SwRect& SwAnchoredObject::GetObjRectWithSpaces() const
685cdf0e10cSrcweir {
686cdf0e10cSrcweir     if ( mbObjRectWithSpacesValid &&
687cdf0e10cSrcweir          maLastObjRect != GetObjRect() )
688cdf0e10cSrcweir     {
689cdf0e10cSrcweir         ASSERT( false,
690cdf0e10cSrcweir                 "<SwAnchoredObject::GetObjRectWithSpaces> - cache for object rectangle inclusive spaces marked as valid, but it couldn't be. Missing invalidation of cache. Please inform OD." );
691cdf0e10cSrcweir         InvalidateObjRectWithSpaces();
692cdf0e10cSrcweir     }
693cdf0e10cSrcweir     if ( !mbObjRectWithSpacesValid )
694cdf0e10cSrcweir     {
695cdf0e10cSrcweir         // --> OD 2006-10-05 #i70122# - correction:
696cdf0e10cSrcweir         // use bounding rectangle of anchored objects.
697cdf0e10cSrcweir //        maObjRectWithSpaces = GetObjRect();
698cdf0e10cSrcweir         maObjRectWithSpaces = GetObjBoundRect();
699cdf0e10cSrcweir         // <--
700cdf0e10cSrcweir         const SwFrmFmt& rFmt = GetFrmFmt();
701cdf0e10cSrcweir         const SvxULSpaceItem& rUL = rFmt.GetULSpace();
702cdf0e10cSrcweir         const SvxLRSpaceItem& rLR = rFmt.GetLRSpace();
703cdf0e10cSrcweir         {
704cdf0e10cSrcweir             maObjRectWithSpaces.Top ( Max( maObjRectWithSpaces.Top() - long(rUL.GetUpper()), 0L ));
705cdf0e10cSrcweir             maObjRectWithSpaces.Left( Max( maObjRectWithSpaces.Left()- long(rLR.GetLeft()),  0L ));
706cdf0e10cSrcweir             maObjRectWithSpaces.SSize().Height() += rUL.GetLower();
707cdf0e10cSrcweir             maObjRectWithSpaces.SSize().Width()  += rLR.GetRight();
708cdf0e10cSrcweir         }
709cdf0e10cSrcweir 
710cdf0e10cSrcweir         mbObjRectWithSpacesValid = true;
711cdf0e10cSrcweir         maLastObjRect = GetObjRect();
712cdf0e10cSrcweir     }
713cdf0e10cSrcweir 
714cdf0e10cSrcweir     return maObjRectWithSpaces;
715cdf0e10cSrcweir }
716cdf0e10cSrcweir 
717cdf0e10cSrcweir // --> OD 2006-08-10 #i68520#
SetObjTop(const SwTwips _nTop)718cdf0e10cSrcweir void SwAnchoredObject::SetObjTop( const SwTwips _nTop)
719cdf0e10cSrcweir {
720cdf0e10cSrcweir     const bool bTopChanged( _SetObjTop( _nTop ) );
721cdf0e10cSrcweir     if ( bTopChanged )
722cdf0e10cSrcweir     {
723cdf0e10cSrcweir         mbObjRectWithSpacesValid = false;
724cdf0e10cSrcweir     }
725cdf0e10cSrcweir }
726cdf0e10cSrcweir 
SetObjLeft(const SwTwips _nLeft)727cdf0e10cSrcweir void SwAnchoredObject::SetObjLeft( const SwTwips _nLeft)
728cdf0e10cSrcweir {
729cdf0e10cSrcweir     const bool bLeftChanged( _SetObjLeft( _nLeft ) );
730cdf0e10cSrcweir     if ( bLeftChanged )
731cdf0e10cSrcweir     {
732cdf0e10cSrcweir         mbObjRectWithSpacesValid = false;
733cdf0e10cSrcweir     }
734cdf0e10cSrcweir }
735cdf0e10cSrcweir // <--
736cdf0e10cSrcweir 
737cdf0e10cSrcweir /** method to update anchored object in the <SwSortedObjs> lists
738cdf0e10cSrcweir 
739cdf0e10cSrcweir     OD 2004-07-01 #i28701#
740cdf0e10cSrcweir     If document compatibility option 'Consider wrapping style influence
741cdf0e10cSrcweir     on object positioning' is ON, additionally all anchored objects
742cdf0e10cSrcweir     at the anchor frame and all following anchored objects on the page
743cdf0e10cSrcweir     frame are invalidated.
744cdf0e10cSrcweir 
745cdf0e10cSrcweir     @author OD
746cdf0e10cSrcweir */
UpdateObjInSortedList()747cdf0e10cSrcweir void SwAnchoredObject::UpdateObjInSortedList()
748cdf0e10cSrcweir {
749cdf0e10cSrcweir     if ( GetAnchorFrm() )
750cdf0e10cSrcweir     {
751cdf0e10cSrcweir         if ( GetFrmFmt().getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) )
752cdf0e10cSrcweir         {
753cdf0e10cSrcweir             // invalidate position of all anchored objects at anchor frame
754cdf0e10cSrcweir             if ( GetAnchorFrm()->GetDrawObjs() )
755cdf0e10cSrcweir             {
756cdf0e10cSrcweir                 const SwSortedObjs* pObjs = GetAnchorFrm()->GetDrawObjs();
757cdf0e10cSrcweir                 // determine start index
758cdf0e10cSrcweir                 sal_uInt32 i = 0;
759cdf0e10cSrcweir                 for ( ; i < pObjs->Count(); ++i )
760cdf0e10cSrcweir                 {
761cdf0e10cSrcweir                     SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
762cdf0e10cSrcweir                     if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
763cdf0e10cSrcweir                         pAnchoredObj->InvalidateObjPosForConsiderWrapInfluence( true );
764cdf0e10cSrcweir                     else
765cdf0e10cSrcweir                         pAnchoredObj->InvalidateObjPos();
766cdf0e10cSrcweir                 }
767cdf0e10cSrcweir             }
768cdf0e10cSrcweir             // invalidate all following anchored objects on the page frame
769cdf0e10cSrcweir             if ( GetPageFrm() && GetPageFrm()->GetSortedObjs() )
770cdf0e10cSrcweir             {
771cdf0e10cSrcweir                 const SwSortedObjs* pObjs = GetPageFrm()->GetSortedObjs();
772cdf0e10cSrcweir                 // determine start index
773cdf0e10cSrcweir                 sal_uInt32 i = pObjs->ListPosOf( *this ) + 1;
774cdf0e10cSrcweir                 for ( ; i < pObjs->Count(); ++i )
775cdf0e10cSrcweir                 {
776cdf0e10cSrcweir                     SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
777cdf0e10cSrcweir                     if ( pAnchoredObj->ConsiderObjWrapInfluenceOnObjPos() )
778cdf0e10cSrcweir                         pAnchoredObj->InvalidateObjPosForConsiderWrapInfluence( true );
779cdf0e10cSrcweir                     else
780cdf0e10cSrcweir                         pAnchoredObj->InvalidateObjPos();
781cdf0e10cSrcweir                 }
782cdf0e10cSrcweir             }
783cdf0e10cSrcweir         }
784cdf0e10cSrcweir         // update its position in the sorted object list of its anchor frame
785cdf0e10cSrcweir         AnchorFrm()->GetDrawObjs()->Update( *this );
786cdf0e10cSrcweir         // update its position in the sorted object list of its page frame
787cdf0e10cSrcweir         // note: as-character anchored object aren't registered at a page frame
788cdf0e10cSrcweir         if ( GetFrmFmt().GetAnchor().GetAnchorId() != FLY_AS_CHAR )
789cdf0e10cSrcweir         {
790cdf0e10cSrcweir             GetPageFrm()->GetSortedObjs()->Update( *this );
791cdf0e10cSrcweir         }
792cdf0e10cSrcweir     }
793cdf0e10cSrcweir }
794cdf0e10cSrcweir 
795cdf0e10cSrcweir /** method to determine, if invalidation of position is allowed
796cdf0e10cSrcweir 
797cdf0e10cSrcweir     OD 2004-07-01 #i28701#
798cdf0e10cSrcweir 
799cdf0e10cSrcweir     @author OD
800cdf0e10cSrcweir */
InvalidationOfPosAllowed() const801cdf0e10cSrcweir bool SwAnchoredObject::InvalidationOfPosAllowed() const
802cdf0e10cSrcweir {
803cdf0e10cSrcweir     // --> OD 2004-11-03 #114798# - Check, if page frame layout is in progress,
804cdf0e10cSrcweir     // isn't needed, because of anchored object, whose are moved forward.
805cdf0e10cSrcweir     return !PositionLocked();
806cdf0e10cSrcweir     // <--
807cdf0e10cSrcweir }
808cdf0e10cSrcweir 
809cdf0e10cSrcweir /** method to determine the page frame, on which the 'anchor' of
810cdf0e10cSrcweir     the given anchored object is.
811cdf0e10cSrcweir 
812cdf0e10cSrcweir     OD 2004-07-02 #i28701#
813cdf0e10cSrcweir     OD 2004-09-23 #i33751#, #i34060#
814cdf0e10cSrcweir     Adjust meaning of method and thus its name: If the anchored object
815cdf0e10cSrcweir     or its anchor isn't correctly inserted in the layout, no page frame
816cdf0e10cSrcweir     can be found. Thus, the return type changed to be a pointer and can
817cdf0e10cSrcweir     be NULL.
818cdf0e10cSrcweir 
819cdf0e10cSrcweir     @author OD
820cdf0e10cSrcweir */
FindPageFrmOfAnchor()821cdf0e10cSrcweir SwPageFrm* SwAnchoredObject::FindPageFrmOfAnchor()
822cdf0e10cSrcweir {
823cdf0e10cSrcweir     SwPageFrm* pRetPageFrm = 0L;
824cdf0e10cSrcweir 
825cdf0e10cSrcweir     // --> OD 2005-03-08 #i44339# - check, if anchor frame exists.
826cdf0e10cSrcweir     if ( mpAnchorFrm )
827cdf0e10cSrcweir     {
828cdf0e10cSrcweir         // --> OD 2004-10-08 #i26945# - use new method <GetAnchorFrmContainingAnchPos()>
829cdf0e10cSrcweir         pRetPageFrm = GetAnchorFrmContainingAnchPos()->FindPageFrm();
830cdf0e10cSrcweir         // <--
831cdf0e10cSrcweir     }
832cdf0e10cSrcweir 
833cdf0e10cSrcweir     return pRetPageFrm;
834cdf0e10cSrcweir }
835cdf0e10cSrcweir 
836cdf0e10cSrcweir /** get frame, which contains the anchor character, if the object
837cdf0e10cSrcweir     is anchored at-character or as-character.
838cdf0e10cSrcweir 
839cdf0e10cSrcweir     OD 2004-10-04 #i26945#
840cdf0e10cSrcweir 
841cdf0e10cSrcweir     @author OD
842cdf0e10cSrcweir 
843cdf0e10cSrcweir     @return SwTxtFrm*
844cdf0e10cSrcweir     text frame containing the anchor character. It's NULL, if the object
845cdf0e10cSrcweir     isn't anchored at-character resp. as-character.
846cdf0e10cSrcweir */
FindAnchorCharFrm()847cdf0e10cSrcweir SwTxtFrm* SwAnchoredObject::FindAnchorCharFrm()
848cdf0e10cSrcweir {
849cdf0e10cSrcweir     SwTxtFrm* pAnchorCharFrm( 0L );
850cdf0e10cSrcweir 
851cdf0e10cSrcweir     // --> OD 2005-03-08 #i44339# - check, if anchor frame exists.
852cdf0e10cSrcweir     if ( mpAnchorFrm )
853cdf0e10cSrcweir     {
854cdf0e10cSrcweir         const SwFmtAnchor& rAnch = GetFrmFmt().GetAnchor();
855cdf0e10cSrcweir         if ((rAnch.GetAnchorId() == FLY_AT_CHAR) ||
856cdf0e10cSrcweir             (rAnch.GetAnchorId() == FLY_AS_CHAR))
857cdf0e10cSrcweir         {
858cdf0e10cSrcweir             pAnchorCharFrm = &(static_cast<SwTxtFrm*>(AnchorFrm())->
859cdf0e10cSrcweir                         GetFrmAtOfst( rAnch.GetCntntAnchor()->nContent.GetIndex() ));
860cdf0e10cSrcweir         }
861cdf0e10cSrcweir     }
862cdf0e10cSrcweir     // <--
863cdf0e10cSrcweir 
864cdf0e10cSrcweir     return pAnchorCharFrm;
865cdf0e10cSrcweir }
866cdf0e10cSrcweir 
867cdf0e10cSrcweir /** method to determine, if a format on the anchored object is possible
868cdf0e10cSrcweir 
869cdf0e10cSrcweir     OD 2004-07-23 #i28701#
870cdf0e10cSrcweir     A format is possible, if anchored object is in an invisible layer.
871cdf0e10cSrcweir     Note: method is virtual to refine the conditions for the sub-classes.
872cdf0e10cSrcweir 
873cdf0e10cSrcweir     @author OD
874cdf0e10cSrcweir */
IsFormatPossible() const875cdf0e10cSrcweir bool SwAnchoredObject::IsFormatPossible() const
876cdf0e10cSrcweir {
877cdf0e10cSrcweir     return GetFrmFmt().GetDoc()->IsVisibleLayerId( GetDrawObj()->GetLayer() );
878cdf0e10cSrcweir }
879cdf0e10cSrcweir 
880cdf0e10cSrcweir // --> OD 2004-08-25 #i3317#
SetTmpConsiderWrapInfluence(const bool _bTmpConsiderWrapInfluence)881cdf0e10cSrcweir void SwAnchoredObject::SetTmpConsiderWrapInfluence( const bool _bTmpConsiderWrapInfluence )
882cdf0e10cSrcweir {
883cdf0e10cSrcweir     mbTmpConsiderWrapInfluence = _bTmpConsiderWrapInfluence;
884cdf0e10cSrcweir     // --> OD 2004-10-22 #i35911#
885cdf0e10cSrcweir     if ( mbTmpConsiderWrapInfluence )
886cdf0e10cSrcweir     {
887cdf0e10cSrcweir         SwLayouter::InsertObjForTmpConsiderWrapInfluence( *(GetFrmFmt().GetDoc()),
888cdf0e10cSrcweir                                                           *this );
889cdf0e10cSrcweir     }
890cdf0e10cSrcweir     // <--
891cdf0e10cSrcweir }
892cdf0e10cSrcweir 
IsTmpConsiderWrapInfluence() const893cdf0e10cSrcweir bool SwAnchoredObject::IsTmpConsiderWrapInfluence() const
894cdf0e10cSrcweir {
895cdf0e10cSrcweir     return mbTmpConsiderWrapInfluence;
896cdf0e10cSrcweir }
897cdf0e10cSrcweir // <--
898cdf0e10cSrcweir 
899cdf0e10cSrcweir // --> OD 2006-07-24 #b6449874#
SetTmpConsiderWrapInfluenceOfOtherObjs(const bool bTmpConsiderWrapInfluence)900cdf0e10cSrcweir void SwAnchoredObject::SetTmpConsiderWrapInfluenceOfOtherObjs( const bool bTmpConsiderWrapInfluence )
901cdf0e10cSrcweir {
902cdf0e10cSrcweir     const SwSortedObjs* pObjs = GetAnchorFrm()->GetDrawObjs();
903cdf0e10cSrcweir     if ( pObjs->Count() > 1 )
904cdf0e10cSrcweir     {
905cdf0e10cSrcweir         sal_uInt32 i = 0;
906cdf0e10cSrcweir         for ( ; i < pObjs->Count(); ++i )
907cdf0e10cSrcweir         {
908cdf0e10cSrcweir             SwAnchoredObject* pAnchoredObj = (*pObjs)[i];
909cdf0e10cSrcweir             if ( pAnchoredObj != this )
910cdf0e10cSrcweir             {
911cdf0e10cSrcweir                 pAnchoredObj->SetTmpConsiderWrapInfluence( bTmpConsiderWrapInfluence );
912cdf0e10cSrcweir             }
913cdf0e10cSrcweir         }
914cdf0e10cSrcweir     }
915cdf0e10cSrcweir }
916cdf0e10cSrcweir // <--
917cdf0e10cSrcweir 
918cdf0e10cSrcweir /** method to determine, if the anchored object is overlapping with a
919cdf0e10cSrcweir     previous column
920cdf0e10cSrcweir 
921cdf0e10cSrcweir     OD 2004-08-25 #i3317#
922cdf0e10cSrcweir     overlapping with a previous column means, that the object overlaps
923cdf0e10cSrcweir     with a column, which is a previous one of the column its anchor
924cdf0e10cSrcweir     frame is in.
925cdf0e10cSrcweir     Only applied for at-paragraph and at-character anchored objects.
926cdf0e10cSrcweir 
927cdf0e10cSrcweir     @author OD
928cdf0e10cSrcweir */
OverlapsPrevColumn() const929cdf0e10cSrcweir bool SwAnchoredObject::OverlapsPrevColumn() const
930cdf0e10cSrcweir {
931cdf0e10cSrcweir     bool bOverlapsPrevColumn( false );
932cdf0e10cSrcweir 
933cdf0e10cSrcweir     if ( mpAnchorFrm && mpAnchorFrm->IsTxtFrm() )
934cdf0e10cSrcweir     {
935cdf0e10cSrcweir         const SwFrm* pColFrm = mpAnchorFrm->FindColFrm();
936cdf0e10cSrcweir         if ( pColFrm && pColFrm->GetPrev() )
937cdf0e10cSrcweir         {
938cdf0e10cSrcweir             const SwFrm* pTmpColFrm = pColFrm->GetPrev();
939cdf0e10cSrcweir             SwRect aChkRect;
940cdf0e10cSrcweir             while ( pTmpColFrm )
941cdf0e10cSrcweir             {
942cdf0e10cSrcweir                 aChkRect.Union( pTmpColFrm->Frm() );
943cdf0e10cSrcweir                 pTmpColFrm = pTmpColFrm->GetPrev();
944cdf0e10cSrcweir             }
945cdf0e10cSrcweir             bOverlapsPrevColumn = GetObjRect().IsOver( aChkRect );
946cdf0e10cSrcweir         }
947cdf0e10cSrcweir     }
948cdf0e10cSrcweir 
949cdf0e10cSrcweir     return bOverlapsPrevColumn;
950cdf0e10cSrcweir }
951cdf0e10cSrcweir 
952cdf0e10cSrcweir /** method to determine position of anchored object relative to
953cdf0e10cSrcweir     anchor frame
954cdf0e10cSrcweir 
955cdf0e10cSrcweir     OD 2005-01-06 #i30669#
956cdf0e10cSrcweir     Usage: Needed layout information for WW8 export
957cdf0e10cSrcweir 
958cdf0e10cSrcweir     @author OD
959cdf0e10cSrcweir */
GetRelPosToAnchorFrm() const960cdf0e10cSrcweir Point SwAnchoredObject::GetRelPosToAnchorFrm() const
961cdf0e10cSrcweir {
962cdf0e10cSrcweir     Point aRelPos;
963cdf0e10cSrcweir 
964cdf0e10cSrcweir     ASSERT( GetAnchorFrm(),
965cdf0e10cSrcweir             "<SwAnchoredObject::GetRelPosToAnchorFrm()> - missing anchor frame." );
966cdf0e10cSrcweir     aRelPos = GetObjRect().Pos();
967cdf0e10cSrcweir     aRelPos -= GetAnchorFrm()->Frm().Pos();
968cdf0e10cSrcweir 
969cdf0e10cSrcweir     return aRelPos;
970cdf0e10cSrcweir }
971cdf0e10cSrcweir 
972cdf0e10cSrcweir /** method to determine position of anchored object relative to
973cdf0e10cSrcweir     page frame
974cdf0e10cSrcweir 
975cdf0e10cSrcweir     OD 2005-01-06 #i30669#
976cdf0e10cSrcweir     Usage: Needed layout information for WW8 export
977cdf0e10cSrcweir     OD 2005-01-27 #i33818# - add parameters <_bFollowTextFlow> and
978cdf0e10cSrcweir     <_obRelToTableCell>
979cdf0e10cSrcweir     If <_bFollowTextFlow> is set and object is anchored inside table,
980cdf0e10cSrcweir     the position relative to the table cell is determined. Output
981cdf0e10cSrcweir     parameter <_obRelToTableCell> reflects this situation
982cdf0e10cSrcweir 
983cdf0e10cSrcweir     @author OD
984cdf0e10cSrcweir */
GetRelPosToPageFrm(const bool _bFollowTextFlow,bool & _obRelToTableCell) const985cdf0e10cSrcweir Point SwAnchoredObject::GetRelPosToPageFrm( const bool _bFollowTextFlow,
986cdf0e10cSrcweir                                             bool& _obRelToTableCell ) const
987cdf0e10cSrcweir {
988cdf0e10cSrcweir     Point aRelPos;
989cdf0e10cSrcweir     _obRelToTableCell = false;
990cdf0e10cSrcweir 
991cdf0e10cSrcweir     ASSERT( GetAnchorFrm(),
992cdf0e10cSrcweir             "<SwAnchoredObject::GetRelPosToPageFrm()> - missing anchor frame." );
993cdf0e10cSrcweir     ASSERT( GetAnchorFrm()->FindPageFrm(),
994cdf0e10cSrcweir             "<SwAnchoredObject::GetRelPosToPageFrm()> - missing page frame." );
995cdf0e10cSrcweir 
996cdf0e10cSrcweir     aRelPos = GetObjRect().Pos();
997cdf0e10cSrcweir     // --> OD 2005-01-27 #i33818# - search for cell frame, if object has to
998cdf0e10cSrcweir     // follow the text flow.
999cdf0e10cSrcweir     const SwFrm* pFrm( 0L );
1000cdf0e10cSrcweir     if ( _bFollowTextFlow && !GetAnchorFrm()->IsPageFrm() )
1001cdf0e10cSrcweir     {
1002cdf0e10cSrcweir         pFrm = GetAnchorFrm()->GetUpper();
1003cdf0e10cSrcweir         while ( !pFrm->IsCellFrm() && !pFrm->IsPageFrm() )
1004cdf0e10cSrcweir         {
1005cdf0e10cSrcweir             pFrm = pFrm->GetUpper();
1006cdf0e10cSrcweir         }
1007cdf0e10cSrcweir     }
1008cdf0e10cSrcweir     else
1009cdf0e10cSrcweir     {
1010cdf0e10cSrcweir         pFrm = GetAnchorFrm()->FindPageFrm();
1011cdf0e10cSrcweir     }
1012cdf0e10cSrcweir     if ( pFrm->IsCellFrm() )
1013cdf0e10cSrcweir     {
1014cdf0e10cSrcweir         aRelPos -= ( pFrm->Frm().Pos() + pFrm->Prt().Pos() );
1015cdf0e10cSrcweir         _obRelToTableCell = true;
1016cdf0e10cSrcweir     }
1017cdf0e10cSrcweir     else
1018cdf0e10cSrcweir     {
1019cdf0e10cSrcweir         aRelPos -= pFrm->Frm().Pos();
1020cdf0e10cSrcweir     }
1021cdf0e10cSrcweir     // <--
1022cdf0e10cSrcweir 
1023cdf0e10cSrcweir     return aRelPos;
1024cdf0e10cSrcweir }
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir /** method to determine position of anchored object relative to
1027cdf0e10cSrcweir     anchor character
1028cdf0e10cSrcweir 
1029cdf0e10cSrcweir     OD 2005-01-06 #i30669#
1030cdf0e10cSrcweir     Usage: Needed layout information for WW8 export
1031cdf0e10cSrcweir 
1032cdf0e10cSrcweir     @author OD
1033cdf0e10cSrcweir */
GetRelPosToChar() const1034cdf0e10cSrcweir Point SwAnchoredObject::GetRelPosToChar() const
1035cdf0e10cSrcweir {
1036cdf0e10cSrcweir     Point aRelPos;
1037cdf0e10cSrcweir 
1038cdf0e10cSrcweir     aRelPos = GetObjRect().Pos();
1039cdf0e10cSrcweir     aRelPos -= GetLastCharRect().Pos();
1040cdf0e10cSrcweir 
1041cdf0e10cSrcweir     return aRelPos;
1042cdf0e10cSrcweir }
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir /** method to determine position of anchored object relative to
1045cdf0e10cSrcweir     top of line
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir     OD 2005-01-06 #i30669#
1048cdf0e10cSrcweir     Usage: Needed layout information for WW8 export
1049cdf0e10cSrcweir 
1050cdf0e10cSrcweir     @author OD
1051cdf0e10cSrcweir */
GetRelPosToLine() const1052cdf0e10cSrcweir Point SwAnchoredObject::GetRelPosToLine() const
1053cdf0e10cSrcweir {
1054cdf0e10cSrcweir     Point aRelPos;
1055cdf0e10cSrcweir 
1056cdf0e10cSrcweir     aRelPos = GetObjRect().Pos();
1057cdf0e10cSrcweir     aRelPos.Y() -= GetLastTopOfLine();
1058cdf0e10cSrcweir 
1059cdf0e10cSrcweir     return aRelPos;
1060cdf0e10cSrcweir }
1061