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 <tocntntanchoredobjectposition.hxx>
27cdf0e10cSrcweir #include <anchoredobject.hxx>
28cdf0e10cSrcweir #include <frame.hxx>
29cdf0e10cSrcweir #include <txtfrm.hxx>
30cdf0e10cSrcweir #include <pagefrm.hxx>
31cdf0e10cSrcweir #include <sectfrm.hxx>
32cdf0e10cSrcweir // --> OD 2004-10-15 #i26945#
33cdf0e10cSrcweir #include <tabfrm.hxx>
34cdf0e10cSrcweir // <--
35cdf0e10cSrcweir #include "rootfrm.hxx"
36cdf0e10cSrcweir #include "viewopt.hxx"
37cdf0e10cSrcweir #include "viewsh.hxx"
38cdf0e10cSrcweir #include <frmfmt.hxx>
39cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
40cdf0e10cSrcweir #include <fmtsrnd.hxx>
41cdf0e10cSrcweir #include <fmtfsize.hxx>
42cdf0e10cSrcweir #include <fmtanchr.hxx>
43cdf0e10cSrcweir #include <fmtornt.hxx>
44cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
45cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
46cdf0e10cSrcweir #include <svx/svdobj.hxx>
47cdf0e10cSrcweir #include <pam.hxx>
48cdf0e10cSrcweir #include <environmentofanchoredobject.hxx>
49cdf0e10cSrcweir #include <frmtool.hxx>
50cdf0e10cSrcweir #include <ndtxt.hxx>
51cdf0e10cSrcweir #include <dflyobj.hxx>
52cdf0e10cSrcweir
53cdf0e10cSrcweir using namespace objectpositioning;
54cdf0e10cSrcweir using namespace ::com::sun::star;
55cdf0e10cSrcweir
56cdf0e10cSrcweir
SwToCntntAnchoredObjectPosition(SdrObject & _rDrawObj)57cdf0e10cSrcweir SwToCntntAnchoredObjectPosition::SwToCntntAnchoredObjectPosition( SdrObject& _rDrawObj )
58cdf0e10cSrcweir : SwAnchoredObjectPosition ( _rDrawObj ),
59cdf0e10cSrcweir mpVertPosOrientFrm( 0 ),
60cdf0e10cSrcweir // --> OD 2004-06-17 #i26791#
61cdf0e10cSrcweir maOffsetToFrmAnchorPos( Point() ),
62cdf0e10cSrcweir mbAnchorToChar ( false ),
63cdf0e10cSrcweir mpToCharOrientFrm( 0 ),
64cdf0e10cSrcweir mpToCharRect( 0 ),
65cdf0e10cSrcweir // OD 12.11.2003 #i22341#
66cdf0e10cSrcweir mnToCharTopOfLine( 0 )
67cdf0e10cSrcweir {}
68cdf0e10cSrcweir
~SwToCntntAnchoredObjectPosition()69cdf0e10cSrcweir SwToCntntAnchoredObjectPosition::~SwToCntntAnchoredObjectPosition()
70cdf0e10cSrcweir {}
71cdf0e10cSrcweir
IsAnchoredToChar() const72cdf0e10cSrcweir bool SwToCntntAnchoredObjectPosition::IsAnchoredToChar() const
73cdf0e10cSrcweir {
74cdf0e10cSrcweir return mbAnchorToChar;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
ToCharOrientFrm() const77cdf0e10cSrcweir const SwFrm* SwToCntntAnchoredObjectPosition::ToCharOrientFrm() const
78cdf0e10cSrcweir {
79cdf0e10cSrcweir return mpToCharOrientFrm;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
ToCharRect() const82cdf0e10cSrcweir const SwRect* SwToCntntAnchoredObjectPosition::ToCharRect() const
83cdf0e10cSrcweir {
84cdf0e10cSrcweir return mpToCharRect;
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
87cdf0e10cSrcweir // OD 12.11.2003 #i22341#
ToCharTopOfLine() const88cdf0e10cSrcweir SwTwips SwToCntntAnchoredObjectPosition::ToCharTopOfLine() const
89cdf0e10cSrcweir {
90cdf0e10cSrcweir return mnToCharTopOfLine;
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
GetAnchorTxtFrm() const93cdf0e10cSrcweir SwTxtFrm& SwToCntntAnchoredObjectPosition::GetAnchorTxtFrm() const
94cdf0e10cSrcweir {
95cdf0e10cSrcweir ASSERT( GetAnchorFrm().ISA(SwTxtFrm),
96cdf0e10cSrcweir "SwToCntntAnchoredObjectPosition::GetAnchorTxtFrm() - wrong anchor frame type" );
97cdf0e10cSrcweir
98cdf0e10cSrcweir return static_cast<SwTxtFrm&>(GetAnchorFrm());
99cdf0e10cSrcweir }
100cdf0e10cSrcweir
101cdf0e10cSrcweir // --> OD 2004-07-20 #i23512#
lcl_DoesVertPosFits(const SwTwips _nRelPosY,const SwTwips _nAvail,const SwLayoutFrm * _pUpperOfOrientFrm,const bool _bBrowse,const bool _bGrowInTable,SwLayoutFrm * & _orpLayoutFrmToGrow)102cdf0e10cSrcweir bool lcl_DoesVertPosFits( const SwTwips _nRelPosY,
103cdf0e10cSrcweir const SwTwips _nAvail,
104cdf0e10cSrcweir const SwLayoutFrm* _pUpperOfOrientFrm,
105cdf0e10cSrcweir const bool _bBrowse,
106cdf0e10cSrcweir const bool _bGrowInTable,
107cdf0e10cSrcweir SwLayoutFrm*& _orpLayoutFrmToGrow )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir bool bVertPosFits = false;
110cdf0e10cSrcweir
111cdf0e10cSrcweir if ( _nRelPosY <= _nAvail )
112cdf0e10cSrcweir {
113cdf0e10cSrcweir bVertPosFits = true;
114cdf0e10cSrcweir }
115cdf0e10cSrcweir else if ( _bBrowse )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir if ( _pUpperOfOrientFrm->IsInSct() )
118cdf0e10cSrcweir {
119cdf0e10cSrcweir SwSectionFrm* pSctFrm =
120cdf0e10cSrcweir const_cast<SwSectionFrm*>(_pUpperOfOrientFrm->FindSctFrm());
121cdf0e10cSrcweir bVertPosFits = pSctFrm->GetUpper()->Grow( _nRelPosY - _nAvail, sal_True ) > 0;
122cdf0e10cSrcweir // Note: do not provide a layout frame for a grow.
123cdf0e10cSrcweir }
124cdf0e10cSrcweir else
125cdf0e10cSrcweir {
126cdf0e10cSrcweir bVertPosFits = const_cast<SwLayoutFrm*>(_pUpperOfOrientFrm)->
127cdf0e10cSrcweir Grow( _nRelPosY - _nAvail, sal_True ) > 0;
128cdf0e10cSrcweir if ( bVertPosFits )
129cdf0e10cSrcweir _orpLayoutFrmToGrow = const_cast<SwLayoutFrm*>(_pUpperOfOrientFrm);
130cdf0e10cSrcweir }
131cdf0e10cSrcweir }
132cdf0e10cSrcweir else if ( _pUpperOfOrientFrm->IsInTab() && _bGrowInTable )
133cdf0e10cSrcweir {
134cdf0e10cSrcweir // --> OD 2005-06-08 #i45085# - check, if upper frame would grow the
135cdf0e10cSrcweir // excepted amount of twips.
136cdf0e10cSrcweir const SwTwips nTwipsGrown = const_cast<SwLayoutFrm*>(_pUpperOfOrientFrm)->
137cdf0e10cSrcweir Grow( _nRelPosY - _nAvail, sal_True ) > 0;
138cdf0e10cSrcweir bVertPosFits = ( nTwipsGrown == ( _nRelPosY - _nAvail ) );
139cdf0e10cSrcweir // <--
140cdf0e10cSrcweir if ( bVertPosFits )
141cdf0e10cSrcweir _orpLayoutFrmToGrow = const_cast<SwLayoutFrm*>(_pUpperOfOrientFrm);
142cdf0e10cSrcweir }
143cdf0e10cSrcweir
144cdf0e10cSrcweir return bVertPosFits;
145cdf0e10cSrcweir }
146cdf0e10cSrcweir // <--
147cdf0e10cSrcweir
CalcPosition()148cdf0e10cSrcweir void SwToCntntAnchoredObjectPosition::CalcPosition()
149cdf0e10cSrcweir {
150cdf0e10cSrcweir // get format of object
151cdf0e10cSrcweir const SwFrmFmt& rFrmFmt = GetFrmFmt();
152cdf0e10cSrcweir
153cdf0e10cSrcweir // declare and set <pFooter> to footer frame, if object is anchored
154cdf0e10cSrcweir // at a frame belonging to the footer.
155cdf0e10cSrcweir const SwFrm* pFooter = GetAnchorFrm().FindFooterOrHeader();
156cdf0e10cSrcweir if ( pFooter && !pFooter->IsFooterFrm() )
157cdf0e10cSrcweir pFooter = NULL;
158cdf0e10cSrcweir
159cdf0e10cSrcweir // declare and set <bBrowse> to true, if document is in browser mode and
160cdf0e10cSrcweir // object is anchored at the body, but not at frame belonging to a table.
161cdf0e10cSrcweir bool bBrowse = GetAnchorFrm().IsInDocBody() && !GetAnchorFrm().IsInTab();
162cdf0e10cSrcweir if( bBrowse )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir const ViewShell *pSh = GetAnchorFrm().getRootFrm()->GetCurrShell();
165cdf0e10cSrcweir if( !pSh || !pSh->GetViewOptions()->getBrowseMode() )
166cdf0e10cSrcweir bBrowse = false;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir // determine left/right and its upper/lower spacing.
170cdf0e10cSrcweir const SvxLRSpaceItem &rLR = rFrmFmt.GetLRSpace();
171cdf0e10cSrcweir const SvxULSpaceItem &rUL = rFrmFmt.GetULSpace();
172cdf0e10cSrcweir
173cdf0e10cSrcweir // determine, if object has no surrounding.
174cdf0e10cSrcweir const SwFmtSurround& rSurround = rFrmFmt.GetSurround();
175cdf0e10cSrcweir const bool bNoSurround = rSurround.GetSurround() == SURROUND_NONE;
176cdf0e10cSrcweir const bool bWrapThrough = rSurround.GetSurround() == SURROUND_THROUGHT;
177cdf0e10cSrcweir
178cdf0e10cSrcweir // OD 29.10.2003 #110978# - new class <SwEnvironmentOfAnchoredObject>
179cdf0e10cSrcweir SwEnvironmentOfAnchoredObject aEnvOfObj( DoesObjFollowsTextFlow() );
180cdf0e10cSrcweir
181cdf0e10cSrcweir // OD 30.09.2003 #i18732# - grow only, if object has to follow the text flow
182cdf0e10cSrcweir const bool bGrow = DoesObjFollowsTextFlow() &&
183cdf0e10cSrcweir ( !GetAnchorFrm().IsInTab() ||
184cdf0e10cSrcweir !rFrmFmt.GetFrmSize().GetHeightPercent() );
185cdf0e10cSrcweir
186cdf0e10cSrcweir // get text frame the object is anchored at
187cdf0e10cSrcweir const SwTxtFrm& rAnchorTxtFrm = GetAnchorTxtFrm();
188cdf0e10cSrcweir SWRECTFN( (&rAnchorTxtFrm) )
189cdf0e10cSrcweir
190cdf0e10cSrcweir const SwRect aObjBoundRect( GetAnchoredObj().GetObjRect() );
191cdf0e10cSrcweir
192cdf0e10cSrcweir // local variable keeping the calculated relative position; initialized with
193cdf0e10cSrcweir // current relative position.
194cdf0e10cSrcweir // OD 2004-03-24 #i26791# - use new object instance of <SwAnchoredObject>
195cdf0e10cSrcweir Point aRelPos( GetAnchoredObj().GetCurrRelPos() );
196cdf0e10cSrcweir
197cdf0e10cSrcweir SwTwips nRelDiff = 0;
198cdf0e10cSrcweir
199cdf0e10cSrcweir bool bMoveable = rAnchorTxtFrm.IsMoveable();
200cdf0e10cSrcweir
201cdf0e10cSrcweir // determine frame the object position has to be oriented at.
202cdf0e10cSrcweir const SwTxtFrm* pOrientFrm = &rAnchorTxtFrm;
203cdf0e10cSrcweir const SwTxtFrm* pAnchorFrmForVertPos = &rAnchorTxtFrm;
204cdf0e10cSrcweir {
205cdf0e10cSrcweir // if object is at-character anchored, determine character-rectangle
206cdf0e10cSrcweir // and frame, position has to be oriented at.
207cdf0e10cSrcweir mbAnchorToChar = (FLY_AT_CHAR == rFrmFmt.GetAnchor().GetAnchorId());
208cdf0e10cSrcweir if ( mbAnchorToChar )
209cdf0e10cSrcweir {
210cdf0e10cSrcweir const SwFmtAnchor& rAnch = rFrmFmt.GetAnchor();
211cdf0e10cSrcweir // OD 2004-03-24 #i26791# - use new object instance of <SwAnchoredObject>
212cdf0e10cSrcweir // OD 2005-01-12 - Due to table break algorithm the character
213cdf0e10cSrcweir // rectangle can have no height. Thus, check also the width
214cdf0e10cSrcweir if ( ( !GetAnchoredObj().GetLastCharRect().Height() &&
215cdf0e10cSrcweir !GetAnchoredObj().GetLastCharRect().Width() ) ||
216cdf0e10cSrcweir !GetAnchoredObj().GetLastTopOfLine() )
217cdf0e10cSrcweir {
218cdf0e10cSrcweir // --> OD 2010-07-02 #i111886#
219cdf0e10cSrcweir // Check existence of paragraph portion information in order
220cdf0e10cSrcweir // to avoid formatting which could cause deletion of follow frames.
221cdf0e10cSrcweir GetAnchoredObj().CheckCharRectAndTopOfLine();
222cdf0e10cSrcweir // <--
223cdf0e10cSrcweir // OD 2005-01-12 - Due to table break algorithm the character
224cdf0e10cSrcweir // rectangle can have no height. Thus, check also the width
225cdf0e10cSrcweir if ( ( !GetAnchoredObj().GetLastCharRect().Height() &&
226cdf0e10cSrcweir !GetAnchoredObj().GetLastCharRect().Width() ) ||
227cdf0e10cSrcweir !GetAnchoredObj().GetLastTopOfLine() )
228cdf0e10cSrcweir {
229cdf0e10cSrcweir // --> OD 2005-01-12 - get default for <mpVertPosOrientFrm>,
230cdf0e10cSrcweir // if it's not set.
231cdf0e10cSrcweir if ( !mpVertPosOrientFrm )
232cdf0e10cSrcweir {
233cdf0e10cSrcweir mpVertPosOrientFrm = rAnchorTxtFrm.GetUpper();
234cdf0e10cSrcweir }
235cdf0e10cSrcweir // <--
236cdf0e10cSrcweir return;
237cdf0e10cSrcweir }
238cdf0e10cSrcweir }
239cdf0e10cSrcweir mpToCharRect = &(GetAnchoredObj().GetLastCharRect());
240cdf0e10cSrcweir // OD 12.11.2003 #i22341# - get top of line, in which the anchor
241cdf0e10cSrcweir // character is.
242cdf0e10cSrcweir mnToCharTopOfLine = GetAnchoredObj().GetLastTopOfLine();
243cdf0e10cSrcweir pOrientFrm = &(const_cast<SwTxtFrm&>(rAnchorTxtFrm).GetFrmAtOfst(
244cdf0e10cSrcweir rAnch.GetCntntAnchor()->nContent.GetIndex() ) );
245cdf0e10cSrcweir mpToCharOrientFrm = pOrientFrm;
246cdf0e10cSrcweir }
247cdf0e10cSrcweir }
248cdf0e10cSrcweir SWREFRESHFN( pOrientFrm )
249cdf0e10cSrcweir
250cdf0e10cSrcweir // determine vertical position
251cdf0e10cSrcweir {
252cdf0e10cSrcweir
253cdf0e10cSrcweir // determine vertical positioning and alignment attributes
254cdf0e10cSrcweir SwFmtVertOrient aVert( rFrmFmt.GetVertOrient() );
255cdf0e10cSrcweir
256cdf0e10cSrcweir // OD 22.09.2003 #i18732# - determine layout frame for vertical
257cdf0e10cSrcweir // positions aligned to 'page areas'.
258cdf0e10cSrcweir const SwLayoutFrm& rPageAlignLayFrm =
259cdf0e10cSrcweir aEnvOfObj.GetVertEnvironmentLayoutFrm( *pOrientFrm );
260cdf0e10cSrcweir
261cdf0e10cSrcweir if ( aVert.GetVertOrient() != text::VertOrientation::NONE )
262cdf0e10cSrcweir {
263cdf0e10cSrcweir // OD 22.09.2003 #i18732# - adjustments for follow text flow or not
264cdf0e10cSrcweir // AND vertical alignment at 'page areas'.
265cdf0e10cSrcweir SwTwips nAlignAreaHeight;
266cdf0e10cSrcweir SwTwips nAlignAreaOffset;
267cdf0e10cSrcweir _GetVertAlignmentValues( *pOrientFrm, rPageAlignLayFrm,
268cdf0e10cSrcweir aVert.GetRelationOrient(),
269cdf0e10cSrcweir nAlignAreaHeight, nAlignAreaOffset );
270cdf0e10cSrcweir
271cdf0e10cSrcweir // determine relative vertical position
272cdf0e10cSrcweir SwTwips nRelPosY = nAlignAreaOffset;
273cdf0e10cSrcweir const SwTwips nObjHeight = (aObjBoundRect.*fnRect->fnGetHeight)();
274cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
275cdf0e10cSrcweir const SwTwips nUpperSpace = bVert
276cdf0e10cSrcweir ? ( bVertL2R
277cdf0e10cSrcweir ? rLR.GetLeft()
278cdf0e10cSrcweir : rLR.GetRight() )
279cdf0e10cSrcweir : rUL.GetUpper();
280cdf0e10cSrcweir // --> OD 2009-08-31 #monglianlayout#
281cdf0e10cSrcweir const SwTwips nLowerSpace = bVert
282cdf0e10cSrcweir ? ( bVertL2R
283cdf0e10cSrcweir ? rLR.GetLeft()
284cdf0e10cSrcweir : rLR.GetRight() )
285cdf0e10cSrcweir : rUL.GetLower();
286cdf0e10cSrcweir // <--
287cdf0e10cSrcweir switch ( aVert.GetVertOrient() )
288cdf0e10cSrcweir {
289cdf0e10cSrcweir case text::VertOrientation::CHAR_BOTTOM:
290cdf0e10cSrcweir {
291cdf0e10cSrcweir if ( mbAnchorToChar )
292cdf0e10cSrcweir {
293cdf0e10cSrcweir // bottom (to character anchored)
294cdf0e10cSrcweir nRelPosY += nAlignAreaHeight + nUpperSpace;
295cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
296cdf0e10cSrcweir if ( bVert && !bVertL2R )
297cdf0e10cSrcweir {
298cdf0e10cSrcweir nRelPosY += nObjHeight;
299cdf0e10cSrcweir }
300cdf0e10cSrcweir break;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir }
303cdf0e10cSrcweir // no break here
304cdf0e10cSrcweir case text::VertOrientation::TOP:
305cdf0e10cSrcweir {
306cdf0e10cSrcweir // OD 12.11.2003 #i22341# - special case for vertical
307cdf0e10cSrcweir // alignment at top of line
308cdf0e10cSrcweir if ( mbAnchorToChar &&
309cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
310cdf0e10cSrcweir {
311cdf0e10cSrcweir nRelPosY -= (nObjHeight + nLowerSpace);
312cdf0e10cSrcweir }
313cdf0e10cSrcweir else
314cdf0e10cSrcweir {
315cdf0e10cSrcweir nRelPosY += nUpperSpace;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir }
318cdf0e10cSrcweir break;
319cdf0e10cSrcweir // OD 14.11.2003 #i22341#
320cdf0e10cSrcweir case text::VertOrientation::LINE_TOP:
321cdf0e10cSrcweir {
322cdf0e10cSrcweir if ( mbAnchorToChar &&
323cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir nRelPosY -= (nObjHeight + nLowerSpace);
326cdf0e10cSrcweir }
327cdf0e10cSrcweir else
328cdf0e10cSrcweir {
329cdf0e10cSrcweir ASSERT( false,
330cdf0e10cSrcweir "<SwToCntntAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
331cdf0e10cSrcweir }
332cdf0e10cSrcweir }
333cdf0e10cSrcweir break;
334cdf0e10cSrcweir case text::VertOrientation::CENTER:
335cdf0e10cSrcweir {
336cdf0e10cSrcweir nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
337cdf0e10cSrcweir }
338cdf0e10cSrcweir break;
339cdf0e10cSrcweir // OD 14.11.2003 #i22341#
340cdf0e10cSrcweir case text::VertOrientation::LINE_CENTER:
341cdf0e10cSrcweir {
342cdf0e10cSrcweir if ( mbAnchorToChar &&
343cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
344cdf0e10cSrcweir {
345cdf0e10cSrcweir nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
346cdf0e10cSrcweir }
347cdf0e10cSrcweir else
348cdf0e10cSrcweir {
349cdf0e10cSrcweir ASSERT( false,
350cdf0e10cSrcweir "<SwToCntntAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
351cdf0e10cSrcweir }
352cdf0e10cSrcweir }
353cdf0e10cSrcweir break;
354cdf0e10cSrcweir case text::VertOrientation::BOTTOM:
355cdf0e10cSrcweir {
356cdf0e10cSrcweir if ( ( aVert.GetRelationOrient() == text::RelOrientation::FRAME ||
357cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA ) &&
358cdf0e10cSrcweir bNoSurround )
359cdf0e10cSrcweir {
360cdf0e10cSrcweir // bottom (aligned to 'paragraph areas')
361cdf0e10cSrcweir nRelPosY += nAlignAreaHeight + nUpperSpace;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir else
364cdf0e10cSrcweir {
365cdf0e10cSrcweir // OD 12.11.2003 #i22341# - special case for vertical
366cdf0e10cSrcweir // alignment at top of line
367cdf0e10cSrcweir if ( mbAnchorToChar &&
368cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
369cdf0e10cSrcweir {
370cdf0e10cSrcweir nRelPosY += nUpperSpace;
371cdf0e10cSrcweir }
372cdf0e10cSrcweir else
373cdf0e10cSrcweir {
374cdf0e10cSrcweir nRelPosY += nAlignAreaHeight -
375cdf0e10cSrcweir ( nObjHeight + nLowerSpace );
376cdf0e10cSrcweir }
377cdf0e10cSrcweir }
378cdf0e10cSrcweir }
379cdf0e10cSrcweir break;
380cdf0e10cSrcweir // OD 14.11.2003 #i22341#
381cdf0e10cSrcweir case text::VertOrientation::LINE_BOTTOM:
382cdf0e10cSrcweir {
383cdf0e10cSrcweir if ( mbAnchorToChar &&
384cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE )
385cdf0e10cSrcweir {
386cdf0e10cSrcweir nRelPosY += nUpperSpace;
387cdf0e10cSrcweir }
388cdf0e10cSrcweir else
389cdf0e10cSrcweir {
390cdf0e10cSrcweir ASSERT( false,
391cdf0e10cSrcweir "<SwToCntntAnchoredObjectPosition::CalcPosition()> - unknown combination of vertical position and vertical alignment." );
392cdf0e10cSrcweir }
393cdf0e10cSrcweir }
394cdf0e10cSrcweir break;
395cdf0e10cSrcweir default:
396cdf0e10cSrcweir break;
397cdf0e10cSrcweir }
398cdf0e10cSrcweir
399cdf0e10cSrcweir // adjust relative position by distance between anchor frame and
400cdf0e10cSrcweir // the frame, the object is oriented at.
401cdf0e10cSrcweir // OD 2004-05-21 #i28701# - correction: adjust relative position,
402cdf0e10cSrcweir // only if the floating screen object has to follow the text flow.
403cdf0e10cSrcweir if ( DoesObjFollowsTextFlow() && pOrientFrm != &rAnchorTxtFrm )
404cdf0e10cSrcweir {
405cdf0e10cSrcweir // OD 2004-03-11 #i11860# - use new method <_GetTopForObjPos>
406cdf0e10cSrcweir // to get top of frame for object positioning.
407cdf0e10cSrcweir const SwTwips nTopOfOrient = _GetTopForObjPos( *pOrientFrm, fnRect, bVert );
408cdf0e10cSrcweir nRelPosY += (*fnRect->fnYDiff)( nTopOfOrient,
409cdf0e10cSrcweir _GetTopForObjPos( rAnchorTxtFrm, fnRect, bVert ) );
410cdf0e10cSrcweir }
411cdf0e10cSrcweir
412cdf0e10cSrcweir // --> OD 2005-02-07 #i42124# - capture object inside vertical
413cdf0e10cSrcweir // layout environment.
414cdf0e10cSrcweir {
415cdf0e10cSrcweir const SwTwips nTopOfAnch =
416cdf0e10cSrcweir _GetTopForObjPos( *pOrientFrm, fnRect, bVert );
417cdf0e10cSrcweir const SwLayoutFrm& rVertEnvironLayFrm =
418cdf0e10cSrcweir aEnvOfObj.GetVertEnvironmentLayoutFrm(
419cdf0e10cSrcweir *(pOrientFrm->GetUpper()) );
420cdf0e10cSrcweir const bool bCheckBottom = !DoesObjFollowsTextFlow();
421cdf0e10cSrcweir nRelPosY = _AdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
422cdf0e10cSrcweir rVertEnvironLayFrm, nRelPosY,
423cdf0e10cSrcweir DoesObjFollowsTextFlow(),
424cdf0e10cSrcweir bCheckBottom );
425cdf0e10cSrcweir }
426cdf0e10cSrcweir // <--
427cdf0e10cSrcweir // keep calculated relative vertical position - needed for filters
428cdf0e10cSrcweir // (including the xml-filter)
429cdf0e10cSrcweir {
430cdf0e10cSrcweir // determine position
431cdf0e10cSrcweir SwTwips nAttrRelPosY = nRelPosY - nAlignAreaOffset;
432cdf0e10cSrcweir // set
433cdf0e10cSrcweir if ( nAttrRelPosY != aVert.GetPos() )
434cdf0e10cSrcweir {
435cdf0e10cSrcweir aVert.SetPos( nAttrRelPosY );
436cdf0e10cSrcweir const_cast<SwFrmFmt&>(rFrmFmt).LockModify();
437cdf0e10cSrcweir const_cast<SwFrmFmt&>(rFrmFmt).SetFmtAttr( aVert );
438cdf0e10cSrcweir const_cast<SwFrmFmt&>(rFrmFmt).UnlockModify();
439cdf0e10cSrcweir }
440cdf0e10cSrcweir }
441cdf0e10cSrcweir
442cdf0e10cSrcweir // determine absolute 'vertical' position, depending on layout-direction
443cdf0e10cSrcweir // --> OD 2004-06-17 #i26791# - determine offset to 'vertical' frame
444cdf0e10cSrcweir // anchor position, depending on layout-direction
445cdf0e10cSrcweir if ( bVert )
446cdf0e10cSrcweir {
447cdf0e10cSrcweir aRelPos.X() = nRelPosY;
448cdf0e10cSrcweir maOffsetToFrmAnchorPos.X() = nAlignAreaOffset;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir else
451cdf0e10cSrcweir {
452cdf0e10cSrcweir aRelPos.Y() = nRelPosY;
453cdf0e10cSrcweir maOffsetToFrmAnchorPos.Y() = nAlignAreaOffset;
454cdf0e10cSrcweir }
455cdf0e10cSrcweir }
456cdf0e10cSrcweir
457cdf0e10cSrcweir // OD 29.10.2003 #110978# - determine upper of frame vertical position
458cdf0e10cSrcweir // is oriented at.
459cdf0e10cSrcweir // OD 2004-05-21 #i28701# - determine 'virtual' anchor frame.
460cdf0e10cSrcweir // This frame is used in the following instead of the 'real' anchor
461cdf0e10cSrcweir // frame <rAnchorTxtFrm> for the 'vertical' position in all cases.
462cdf0e10cSrcweir const SwLayoutFrm* pUpperOfOrientFrm = 0L;
463cdf0e10cSrcweir {
464cdf0e10cSrcweir // OD 2004-05-21 #i28701# - As long as the anchor frame is on the
465cdf0e10cSrcweir // same page as <pOrientFrm> and the vertical position isn't aligned
466cdf0e10cSrcweir // automatic at the anchor character or the top of the line of the
467cdf0e10cSrcweir // anchor character, the anchor frame determines the vertical position.
468cdf0e10cSrcweir if ( &rAnchorTxtFrm == pOrientFrm ||
469cdf0e10cSrcweir ( rAnchorTxtFrm.FindPageFrm() == pOrientFrm->FindPageFrm() &&
470cdf0e10cSrcweir aVert.GetVertOrient() == text::VertOrientation::NONE &&
471cdf0e10cSrcweir aVert.GetRelationOrient() != text::RelOrientation::CHAR &&
472cdf0e10cSrcweir aVert.GetRelationOrient() != text::RelOrientation::TEXT_LINE ) )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir pUpperOfOrientFrm = rAnchorTxtFrm.GetUpper();
475cdf0e10cSrcweir pAnchorFrmForVertPos = &rAnchorTxtFrm;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir else
478cdf0e10cSrcweir {
479cdf0e10cSrcweir pUpperOfOrientFrm = pOrientFrm->GetUpper();
480cdf0e10cSrcweir pAnchorFrmForVertPos = pOrientFrm;
481cdf0e10cSrcweir }
482cdf0e10cSrcweir }
483cdf0e10cSrcweir
484cdf0e10cSrcweir // ignore one-column sections.
485cdf0e10cSrcweir // --> OD 2004-07-20 #i23512# - correction: also ignore one-columned
486cdf0e10cSrcweir // sections with footnotes/endnotes
487cdf0e10cSrcweir if ( pUpperOfOrientFrm->IsInSct() )
488cdf0e10cSrcweir {
489cdf0e10cSrcweir const SwSectionFrm* pSctFrm = pUpperOfOrientFrm->FindSctFrm();
490cdf0e10cSrcweir const bool bIgnoreSection = pUpperOfOrientFrm->IsSctFrm() ||
491cdf0e10cSrcweir ( pSctFrm->Lower()->IsColumnFrm() &&
492cdf0e10cSrcweir !pSctFrm->Lower()->GetNext() );
493cdf0e10cSrcweir if ( bIgnoreSection )
494cdf0e10cSrcweir pUpperOfOrientFrm = pSctFrm->GetUpper();
495cdf0e10cSrcweir }
496cdf0e10cSrcweir
497cdf0e10cSrcweir if ( aVert.GetVertOrient() == text::VertOrientation::NONE )
498cdf0e10cSrcweir {
499cdf0e10cSrcweir // local variable <nRelPosY> for calculation of relative vertical
500cdf0e10cSrcweir // distance to anchor.
501cdf0e10cSrcweir SwTwips nRelPosY = 0;
502cdf0e10cSrcweir // --> OD 2004-06-17 #i26791# - local variable <nVertOffsetToFrmAnchorPos>
503cdf0e10cSrcweir // for determination of the 'vertical' offset to the frame anchor
504cdf0e10cSrcweir // position
505cdf0e10cSrcweir SwTwips nVertOffsetToFrmAnchorPos( 0L );
506cdf0e10cSrcweir // OD 12.11.2003 #i22341# - add special case for vertical alignment
507cdf0e10cSrcweir // at top of line.
508cdf0e10cSrcweir if ( mbAnchorToChar &&
509cdf0e10cSrcweir ( aVert.GetRelationOrient() == text::RelOrientation::CHAR ||
510cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::TEXT_LINE ) )
511cdf0e10cSrcweir {
512cdf0e10cSrcweir // OD 2004-03-11 #i11860# - use new method <_GetTopForObjPos>
513cdf0e10cSrcweir // to get top of frame for object positioning.
514cdf0e10cSrcweir SwTwips nTopOfOrient = _GetTopForObjPos( *pOrientFrm, fnRect, bVert );
515cdf0e10cSrcweir if ( aVert.GetRelationOrient() == text::RelOrientation::CHAR )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir nVertOffsetToFrmAnchorPos = (*fnRect->fnYDiff)(
518cdf0e10cSrcweir (ToCharRect()->*fnRect->fnGetBottom)(),
519cdf0e10cSrcweir nTopOfOrient );
520cdf0e10cSrcweir }
521cdf0e10cSrcweir else
522cdf0e10cSrcweir {
523cdf0e10cSrcweir nVertOffsetToFrmAnchorPos = (*fnRect->fnYDiff)( ToCharTopOfLine(),
524cdf0e10cSrcweir nTopOfOrient );
525cdf0e10cSrcweir }
526cdf0e10cSrcweir nRelPosY = nVertOffsetToFrmAnchorPos - aVert.GetPos();
527cdf0e10cSrcweir }
528cdf0e10cSrcweir else
529cdf0e10cSrcweir {
530cdf0e10cSrcweir // OD 2004-05-21 #i28701# - correction: use <pAnchorFrmForVertPos>
531cdf0e10cSrcweir // instead of <pOrientFrm> and do not adjust relative position
532cdf0e10cSrcweir // to get correct vertical position.
533cdf0e10cSrcweir nVertOffsetToFrmAnchorPos = 0L;
534cdf0e10cSrcweir // OD 2004-03-11 #i11860# - use new method <_GetTopForObjPos>
535cdf0e10cSrcweir // to get top of frame for object positioning.
536cdf0e10cSrcweir const SwTwips nTopOfOrient =
537cdf0e10cSrcweir _GetTopForObjPos( *pAnchorFrmForVertPos, fnRect, bVert );
538cdf0e10cSrcweir // OD 02.10.2002 #102646# - increase <nRelPosY> by margin height,
539cdf0e10cSrcweir // if position is vertical aligned to "paragraph text area"
540cdf0e10cSrcweir if ( aVert.GetRelationOrient() == text::RelOrientation::PRINT_AREA )
541cdf0e10cSrcweir {
542cdf0e10cSrcweir // OD 2004-03-11 #i11860# - consider upper space amount
543cdf0e10cSrcweir // of previous frame
544cdf0e10cSrcweir SwTwips nTopMargin = (pAnchorFrmForVertPos->*fnRect->fnGetTopMargin)();
545cdf0e10cSrcweir if ( pAnchorFrmForVertPos->IsTxtFrm() )
546cdf0e10cSrcweir {
547cdf0e10cSrcweir nTopMargin -= static_cast<const SwTxtFrm*>(pAnchorFrmForVertPos)->
548cdf0e10cSrcweir GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
549cdf0e10cSrcweir }
550cdf0e10cSrcweir nVertOffsetToFrmAnchorPos += nTopMargin;
551cdf0e10cSrcweir }
552cdf0e10cSrcweir // OD 22.09.2003 #i18732# - adjust <nRelPosY> by difference
553cdf0e10cSrcweir // between 'page area' and 'anchor' frame, if position is
554cdf0e10cSrcweir // vertical aligned to 'page areas'
555cdf0e10cSrcweir else if ( aVert.GetRelationOrient() == text::RelOrientation::PAGE_FRAME )
556cdf0e10cSrcweir {
557cdf0e10cSrcweir nVertOffsetToFrmAnchorPos += (*fnRect->fnYDiff)(
558cdf0e10cSrcweir (rPageAlignLayFrm.Frm().*fnRect->fnGetTop)(),
559cdf0e10cSrcweir nTopOfOrient );
560cdf0e10cSrcweir }
561cdf0e10cSrcweir else if ( aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA )
562cdf0e10cSrcweir {
563cdf0e10cSrcweir SwRect aPgPrtRect( rPageAlignLayFrm.Frm() );
564cdf0e10cSrcweir if ( rPageAlignLayFrm.IsPageFrm() )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir aPgPrtRect =
567cdf0e10cSrcweir static_cast<const SwPageFrm&>(rPageAlignLayFrm).PrtWithoutHeaderAndFooter();
568cdf0e10cSrcweir }
569cdf0e10cSrcweir nVertOffsetToFrmAnchorPos += (*fnRect->fnYDiff)(
570cdf0e10cSrcweir (aPgPrtRect.*fnRect->fnGetTop)(),
571cdf0e10cSrcweir nTopOfOrient );
572cdf0e10cSrcweir }
573cdf0e10cSrcweir nRelPosY = nVertOffsetToFrmAnchorPos + aVert.GetPos();
574cdf0e10cSrcweir }
575cdf0e10cSrcweir
576cdf0e10cSrcweir // <pUpperOfOrientFrm>: layout frame, at which the position has to
577cdf0e10cSrcweir // is oriented at
578cdf0e10cSrcweir // <nRelPosY>: rest of the relative distance in the current
579cdf0e10cSrcweir // layout frame
580cdf0e10cSrcweir // <nAvail>: space, which is available in the current
581cdf0e10cSrcweir // layout frame
582cdf0e10cSrcweir
583cdf0e10cSrcweir // --> OD 2004-06-17 #i26791# - determine offset to 'vertical'
584cdf0e10cSrcweir // frame anchor position, depending on layout-direction
585cdf0e10cSrcweir if ( bVert )
586cdf0e10cSrcweir maOffsetToFrmAnchorPos.X() = nVertOffsetToFrmAnchorPos;
587cdf0e10cSrcweir else
588cdf0e10cSrcweir maOffsetToFrmAnchorPos.Y() = nVertOffsetToFrmAnchorPos;
589cdf0e10cSrcweir // <--
590cdf0e10cSrcweir // OD 2004-03-11 #i11860# - use new method <_GetTopForObjPos>
591cdf0e10cSrcweir // to get top of frame for object positioning.
592cdf0e10cSrcweir const SwTwips nTopOfAnch = _GetTopForObjPos( *pAnchorFrmForVertPos, fnRect, bVert );
593cdf0e10cSrcweir if( nRelPosY <= 0 )
594cdf0e10cSrcweir {
595cdf0e10cSrcweir // OD 08.09.2003 #110354# - allow negative position, but keep it
596cdf0e10cSrcweir // inside environment layout frame.
597cdf0e10cSrcweir const SwLayoutFrm& rVertEnvironLayFrm =
598cdf0e10cSrcweir aEnvOfObj.GetVertEnvironmentLayoutFrm( *pUpperOfOrientFrm );
599cdf0e10cSrcweir // --> OD 2004-07-22 #i31805# - do not check, if bottom of
600cdf0e10cSrcweir // anchored object would fit into environment layout frame, if
601cdf0e10cSrcweir // anchored object has to follow the text flow.
602cdf0e10cSrcweir const bool bCheckBottom = !DoesObjFollowsTextFlow();
603cdf0e10cSrcweir nRelPosY = _AdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
604cdf0e10cSrcweir rVertEnvironLayFrm, nRelPosY,
605cdf0e10cSrcweir DoesObjFollowsTextFlow(),
606cdf0e10cSrcweir bCheckBottom );
607cdf0e10cSrcweir // <--
608cdf0e10cSrcweir if ( bVert )
609cdf0e10cSrcweir aRelPos.X() = nRelPosY;
610cdf0e10cSrcweir else
611cdf0e10cSrcweir aRelPos.Y() = nRelPosY;
612cdf0e10cSrcweir }
613cdf0e10cSrcweir else
614cdf0e10cSrcweir {
615cdf0e10cSrcweir SWREFRESHFN( pAnchorFrmForVertPos )
616cdf0e10cSrcweir SwTwips nAvail =
617cdf0e10cSrcweir (*fnRect->fnYDiff)( (pUpperOfOrientFrm->*fnRect->fnGetPrtBottom)(),
618cdf0e10cSrcweir nTopOfAnch );
619cdf0e10cSrcweir const bool bInFtn = pAnchorFrmForVertPos->IsInFtn();
620cdf0e10cSrcweir while ( nRelPosY )
621cdf0e10cSrcweir {
622cdf0e10cSrcweir // --> OD 2004-07-20 #i23512# - correction:
623cdf0e10cSrcweir // consider section frame for grow in online layout.
624cdf0e10cSrcweir // use new local method <lcl_DoesVertPosFits(..)>
625cdf0e10cSrcweir SwLayoutFrm* pLayoutFrmToGrow = 0L;
626cdf0e10cSrcweir const bool bDoesVertPosFits = lcl_DoesVertPosFits(
627cdf0e10cSrcweir nRelPosY, nAvail, pUpperOfOrientFrm, bBrowse,
628cdf0e10cSrcweir bGrow, pLayoutFrmToGrow );
629cdf0e10cSrcweir
630cdf0e10cSrcweir if ( bDoesVertPosFits )
631cdf0e10cSrcweir {
632cdf0e10cSrcweir SwTwips nTmpRelPosY =
633cdf0e10cSrcweir (*fnRect->fnYDiff)( (pUpperOfOrientFrm->*fnRect->fnGetPrtBottom)(),
634cdf0e10cSrcweir nTopOfAnch ) -
635cdf0e10cSrcweir nAvail + nRelPosY;
636cdf0e10cSrcweir // --> OD 2004-07-06 #i28701# - adjust calculated
637cdf0e10cSrcweir // relative vertical position to object's environment.
638cdf0e10cSrcweir const SwFrm& rVertEnvironLayFrm =
639cdf0e10cSrcweir aEnvOfObj.GetVertEnvironmentLayoutFrm( *pUpperOfOrientFrm );
640cdf0e10cSrcweir // --> OD 2004-08-20 - do not check, if bottom of
641cdf0e10cSrcweir // anchored object would fit into environment layout
642cdf0e10cSrcweir // frame, if anchored object has to follow the text flow.
643cdf0e10cSrcweir const bool bCheckBottom = !DoesObjFollowsTextFlow();
644cdf0e10cSrcweir nTmpRelPosY = _AdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
645cdf0e10cSrcweir rVertEnvironLayFrm,
646cdf0e10cSrcweir nTmpRelPosY,
647cdf0e10cSrcweir DoesObjFollowsTextFlow(),
648cdf0e10cSrcweir bCheckBottom );
649cdf0e10cSrcweir // <--
650cdf0e10cSrcweir if ( bVert )
651cdf0e10cSrcweir aRelPos.X() = nTmpRelPosY;
652cdf0e10cSrcweir else
653cdf0e10cSrcweir aRelPos.Y() = nTmpRelPosY;
654cdf0e10cSrcweir
655cdf0e10cSrcweir // --> OD 2004-07-20 #i23512# - use local variable
656cdf0e10cSrcweir // <pLayoutFrmToGrow> provided by new method
657cdf0e10cSrcweir // <lcl_DoesVertPosFits(..)>.
658cdf0e10cSrcweir if ( pLayoutFrmToGrow )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir pLayoutFrmToGrow->Grow( nRelPosY - nAvail );
661cdf0e10cSrcweir }
662cdf0e10cSrcweir // <--
663cdf0e10cSrcweir nRelPosY = 0;
664cdf0e10cSrcweir }
665cdf0e10cSrcweir else
666cdf0e10cSrcweir {
667cdf0e10cSrcweir // --> OD 2004-10-04 #i26495# - floating screen objects,
668cdf0e10cSrcweir // which are anchored inside a table, doesn't follow
669cdf0e10cSrcweir // the text flow.
670cdf0e10cSrcweir if ( DoesObjFollowsTextFlow() &&
671cdf0e10cSrcweir !( aVert.GetRelationOrient() == text::RelOrientation::PAGE_FRAME ||
672cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA ) &&
673cdf0e10cSrcweir !GetAnchorFrm().IsInTab() )
674cdf0e10cSrcweir // <--
675cdf0e10cSrcweir {
676cdf0e10cSrcweir if ( bMoveable )
677cdf0e10cSrcweir {
678cdf0e10cSrcweir // follow the text flow
679cdf0e10cSrcweir nRelPosY -= nAvail;
680cdf0e10cSrcweir MakePageType eMakePage = bInFtn ? MAKEPAGE_NONE
681cdf0e10cSrcweir : MAKEPAGE_APPEND;
682cdf0e10cSrcweir const bool bInSct = pUpperOfOrientFrm->IsInSct();
683cdf0e10cSrcweir if( bInSct )
684cdf0e10cSrcweir eMakePage = MAKEPAGE_NOSECTION;
685cdf0e10cSrcweir
686cdf0e10cSrcweir const SwLayoutFrm* pTmp =
687cdf0e10cSrcweir pUpperOfOrientFrm->GetLeaf( eMakePage, sal_True, &rAnchorTxtFrm );
688cdf0e10cSrcweir if ( pTmp &&
689cdf0e10cSrcweir ( !bInSct ||
690cdf0e10cSrcweir pUpperOfOrientFrm->FindSctFrm()->IsAnFollow( pTmp->FindSctFrm() ) ) )
691cdf0e10cSrcweir {
692cdf0e10cSrcweir pUpperOfOrientFrm = pTmp;
693cdf0e10cSrcweir bMoveable = rAnchorTxtFrm.IsMoveable( (SwLayoutFrm*)pUpperOfOrientFrm );
694cdf0e10cSrcweir SWREFRESHFN( pUpperOfOrientFrm )
695cdf0e10cSrcweir nAvail = (pUpperOfOrientFrm->Prt().*fnRect->fnGetHeight)();
696cdf0e10cSrcweir }
697cdf0e10cSrcweir else
698cdf0e10cSrcweir {
699cdf0e10cSrcweir // if there isn't enough space in the (colmuned)
700cdf0e10cSrcweir // section, leave it and set available space <nAvail>
701cdf0e10cSrcweir // to the space below the section.
702cdf0e10cSrcweir // if the new available space isn't also enough,
703cdf0e10cSrcweir // new pages can be created.
704cdf0e10cSrcweir if( bInSct )
705cdf0e10cSrcweir {
706cdf0e10cSrcweir const SwFrm* pSct = pUpperOfOrientFrm->FindSctFrm();
707cdf0e10cSrcweir pUpperOfOrientFrm = pSct->GetUpper();
708cdf0e10cSrcweir nAvail = (*fnRect->fnYDiff)(
709cdf0e10cSrcweir (pUpperOfOrientFrm->*fnRect->fnGetPrtBottom)(),
710cdf0e10cSrcweir (pSct->*fnRect->fnGetPrtBottom)() );
711cdf0e10cSrcweir }
712cdf0e10cSrcweir else
713cdf0e10cSrcweir {
714cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
715cdf0e10cSrcweir ASSERT( false, "<SwToCntntAnchoredObjectPosition::CalcPosition()> - code under investigation by OD, please inform OD about this assertion!" );
716cdf0e10cSrcweir #endif
717cdf0e10cSrcweir nRelDiff = nRelPosY;
718cdf0e10cSrcweir nRelPosY = 0;
719cdf0e10cSrcweir }
720cdf0e10cSrcweir }
721cdf0e10cSrcweir }
722cdf0e10cSrcweir else
723cdf0e10cSrcweir {
724cdf0e10cSrcweir nRelPosY = 0;
725cdf0e10cSrcweir }
726cdf0e10cSrcweir }
727cdf0e10cSrcweir else
728cdf0e10cSrcweir {
729cdf0e10cSrcweir // OD 06.10.2003 #i18732# - do not follow text flow respectively
730cdf0e10cSrcweir // align at 'page areas', but stay inside given environment
731cdf0e10cSrcweir const SwFrm& rVertEnvironLayFrm =
732cdf0e10cSrcweir aEnvOfObj.GetVertEnvironmentLayoutFrm( *pUpperOfOrientFrm );
733cdf0e10cSrcweir nRelPosY = _AdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
734cdf0e10cSrcweir rVertEnvironLayFrm,
735cdf0e10cSrcweir nRelPosY,
736cdf0e10cSrcweir DoesObjFollowsTextFlow() );
737cdf0e10cSrcweir if( bVert )
738cdf0e10cSrcweir aRelPos.X() = nRelPosY;
739cdf0e10cSrcweir else
740cdf0e10cSrcweir aRelPos.Y() = nRelPosY;
741cdf0e10cSrcweir nRelPosY = 0;
742cdf0e10cSrcweir }
743cdf0e10cSrcweir }
744cdf0e10cSrcweir } // end of <while ( nRelPosY )>
745cdf0e10cSrcweir } // end of else <nRelPosY <= 0>
746cdf0e10cSrcweir } // end of <aVert.GetVertOrient() == text::VertOrientation::NONE>
747cdf0e10cSrcweir
748cdf0e10cSrcweir //Damit das Teil ggf. auf die richtige Seite gestellt und in die
749cdf0e10cSrcweir //PrtArea des LayLeaf gezogen werden kann, muss hier seine
750cdf0e10cSrcweir //absolute Position berechnet werden.
751cdf0e10cSrcweir const SwTwips nTopOfAnch = _GetTopForObjPos( *pAnchorFrmForVertPos, fnRect, bVert );
752cdf0e10cSrcweir if( bVert )
753cdf0e10cSrcweir {
754cdf0e10cSrcweir // --> OD 2009-08-31 #monglianlayout#
755cdf0e10cSrcweir if ( !bVertL2R )
756cdf0e10cSrcweir {
757cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch -
758cdf0e10cSrcweir ( aRelPos.X() - nRelDiff ) -
759cdf0e10cSrcweir aObjBoundRect.Width() );
760cdf0e10cSrcweir }
761cdf0e10cSrcweir else
762cdf0e10cSrcweir {
763cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch +
764cdf0e10cSrcweir ( aRelPos.X() - nRelDiff ) );
765cdf0e10cSrcweir }
766cdf0e10cSrcweir // <--
767cdf0e10cSrcweir }
768cdf0e10cSrcweir else
769cdf0e10cSrcweir {
770cdf0e10cSrcweir GetAnchoredObj().SetObjTop( nTopOfAnch +
771cdf0e10cSrcweir ( aRelPos.Y() - nRelDiff ) );
772cdf0e10cSrcweir }
773cdf0e10cSrcweir
774cdf0e10cSrcweir // grow environment under certain conditions
775cdf0e10cSrcweir // ignore one-column sections.
776cdf0e10cSrcweir // --> OD 2004-07-20 #i23512# - correction: also ignore one-columned
777cdf0e10cSrcweir // sections with footnotes/endnotes
778cdf0e10cSrcweir if ( pUpperOfOrientFrm->IsInSct() )
779cdf0e10cSrcweir {
780cdf0e10cSrcweir const SwSectionFrm* pSctFrm = pUpperOfOrientFrm->FindSctFrm();
781cdf0e10cSrcweir const bool bIgnoreSection = pUpperOfOrientFrm->IsSctFrm() ||
782cdf0e10cSrcweir ( pSctFrm->Lower()->IsColumnFrm() &&
783cdf0e10cSrcweir !pSctFrm->Lower()->GetNext() );
784cdf0e10cSrcweir if ( bIgnoreSection )
785cdf0e10cSrcweir pUpperOfOrientFrm = pSctFrm->GetUpper();
786cdf0e10cSrcweir }
787cdf0e10cSrcweir SwTwips nDist = (GetAnchoredObj().GetObjRect().*fnRect->fnBottomDist)(
788cdf0e10cSrcweir (pUpperOfOrientFrm->*fnRect->fnGetPrtBottom)() );
789cdf0e10cSrcweir if( nDist < 0 )
790cdf0e10cSrcweir {
791cdf0e10cSrcweir // --> OD 2004-07-20 #i23512# - correction:
792cdf0e10cSrcweir // consider section frame for grow in online layout and
793cdf0e10cSrcweir // consider page alignment for grow in table.
794cdf0e10cSrcweir SwLayoutFrm* pLayoutFrmToGrow = 0L;
795cdf0e10cSrcweir if ( bBrowse && rAnchorTxtFrm.IsMoveable() )
796cdf0e10cSrcweir {
797cdf0e10cSrcweir if ( pUpperOfOrientFrm->IsInSct() )
798cdf0e10cSrcweir {
799cdf0e10cSrcweir pLayoutFrmToGrow = const_cast<SwLayoutFrm*>(
800cdf0e10cSrcweir pUpperOfOrientFrm->FindSctFrm()->GetUpper());
801cdf0e10cSrcweir nDist = (GetAnchoredObj().GetObjRect().*fnRect->fnBottomDist)(
802cdf0e10cSrcweir (pLayoutFrmToGrow->*fnRect->fnGetPrtBottom)() );
803cdf0e10cSrcweir if ( nDist >= 0 )
804cdf0e10cSrcweir {
805cdf0e10cSrcweir pLayoutFrmToGrow = 0L;
806cdf0e10cSrcweir }
807cdf0e10cSrcweir }
808cdf0e10cSrcweir else
809cdf0e10cSrcweir {
810cdf0e10cSrcweir pLayoutFrmToGrow =
811cdf0e10cSrcweir const_cast<SwLayoutFrm*>(pUpperOfOrientFrm);
812cdf0e10cSrcweir }
813cdf0e10cSrcweir }
814cdf0e10cSrcweir else if ( rAnchorTxtFrm.IsInTab() && bGrow )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir pLayoutFrmToGrow = const_cast<SwLayoutFrm*>(pUpperOfOrientFrm);
817cdf0e10cSrcweir }
818cdf0e10cSrcweir if ( pLayoutFrmToGrow )
819cdf0e10cSrcweir {
820cdf0e10cSrcweir pLayoutFrmToGrow->Grow( -nDist );
821cdf0e10cSrcweir }
822cdf0e10cSrcweir // <--
823cdf0e10cSrcweir }
824cdf0e10cSrcweir
825cdf0e10cSrcweir if ( DoesObjFollowsTextFlow() &&
826cdf0e10cSrcweir !( aVert.GetRelationOrient() == text::RelOrientation::PAGE_FRAME ||
827cdf0e10cSrcweir aVert.GetRelationOrient() == text::RelOrientation::PAGE_PRINT_AREA ) )
828cdf0e10cSrcweir {
829cdf0e10cSrcweir
830cdf0e10cSrcweir nDist = (GetAnchoredObj().GetObjRect().*fnRect->fnBottomDist)(
831cdf0e10cSrcweir (pUpperOfOrientFrm->*fnRect->fnGetPrtBottom)() );
832cdf0e10cSrcweir // --> OD 2004-10-04 #i26945# - floating screen objects, which are
833cdf0e10cSrcweir // anchored inside a table, doesn't follow the text flow. But, they
834cdf0e10cSrcweir // have to stay inside its layout environment.
835cdf0e10cSrcweir if ( nDist < 0 && pOrientFrm->IsInTab() )
836cdf0e10cSrcweir {
837cdf0e10cSrcweir // If the anchor frame is the first content of the table cell
838cdf0e10cSrcweir // and has no follow, the table frame is notified,
839cdf0e10cSrcweir // that the object doesn't fit into the table cell.
840cdf0e10cSrcweir // Adjustment of position isn't needed in this case.
841cdf0e10cSrcweir if ( pOrientFrm == &rAnchorTxtFrm &&
842cdf0e10cSrcweir !pOrientFrm->GetFollow() &&
843cdf0e10cSrcweir !pOrientFrm->GetIndPrev() )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir const_cast<SwTabFrm*>(pOrientFrm->FindTabFrm())
846cdf0e10cSrcweir ->SetDoesObjsFit( sal_False );
847cdf0e10cSrcweir }
848cdf0e10cSrcweir else
849cdf0e10cSrcweir {
850cdf0e10cSrcweir SwTwips nTmpRelPosY( 0L );
851cdf0e10cSrcweir if ( bVert )
852cdf0e10cSrcweir nTmpRelPosY = aRelPos.X() - nDist;
853cdf0e10cSrcweir else
854cdf0e10cSrcweir nTmpRelPosY = aRelPos.Y() + nDist;
855cdf0e10cSrcweir const SwLayoutFrm& rVertEnvironLayFrm =
856cdf0e10cSrcweir aEnvOfObj.GetVertEnvironmentLayoutFrm( *pUpperOfOrientFrm );
857cdf0e10cSrcweir nTmpRelPosY = _AdjustVertRelPos( nTopOfAnch, bVert, bVertL2R,
858cdf0e10cSrcweir rVertEnvironLayFrm,
859cdf0e10cSrcweir nTmpRelPosY,
860cdf0e10cSrcweir DoesObjFollowsTextFlow(),
861cdf0e10cSrcweir false );
862cdf0e10cSrcweir if ( bVert )
863cdf0e10cSrcweir {
864cdf0e10cSrcweir aRelPos.X() = nTmpRelPosY;
865cdf0e10cSrcweir // --> OD 2009-08-31 #mongolianlayout#
866cdf0e10cSrcweir if ( !bVertL2R )
867cdf0e10cSrcweir {
868cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch -
869cdf0e10cSrcweir aRelPos.X() -
870cdf0e10cSrcweir aObjBoundRect.Width() );
871cdf0e10cSrcweir }
872cdf0e10cSrcweir else
873cdf0e10cSrcweir {
874cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch + aRelPos.X() );
875cdf0e10cSrcweir }
876cdf0e10cSrcweir // <--
877cdf0e10cSrcweir }
878cdf0e10cSrcweir else
879cdf0e10cSrcweir {
880cdf0e10cSrcweir aRelPos.Y() = nTmpRelPosY;
881cdf0e10cSrcweir GetAnchoredObj().SetObjTop( nTopOfAnch + aRelPos.Y() );
882cdf0e10cSrcweir }
883cdf0e10cSrcweir // If the anchor frame is the first content of the table cell
884cdf0e10cSrcweir // and the object still doesn't fit, the table frame is notified,
885cdf0e10cSrcweir // that the object doesn't fit into the table cell.
886cdf0e10cSrcweir nDist = (GetAnchoredObj().GetObjRect().*fnRect->fnBottomDist)(
887cdf0e10cSrcweir (pUpperOfOrientFrm->*fnRect->fnGetPrtBottom)() );
888cdf0e10cSrcweir if ( nDist < 0 &&
889cdf0e10cSrcweir pOrientFrm == &rAnchorTxtFrm && !pOrientFrm->GetIndPrev() )
890cdf0e10cSrcweir {
891cdf0e10cSrcweir const_cast<SwTabFrm*>(pOrientFrm->FindTabFrm())
892cdf0e10cSrcweir ->SetDoesObjsFit( sal_False );
893cdf0e10cSrcweir }
894cdf0e10cSrcweir }
895cdf0e10cSrcweir }
896cdf0e10cSrcweir else
897cdf0e10cSrcweir {
898cdf0e10cSrcweir // <--
899cdf0e10cSrcweir // follow text flow
900cdf0e10cSrcweir const bool bInFtn = rAnchorTxtFrm.IsInFtn();
901cdf0e10cSrcweir while( bMoveable && nDist < 0 )
902cdf0e10cSrcweir {
903cdf0e10cSrcweir bool bInSct = pUpperOfOrientFrm->IsInSct();
904cdf0e10cSrcweir if ( bInSct )
905cdf0e10cSrcweir {
906cdf0e10cSrcweir const SwLayoutFrm* pTmp = pUpperOfOrientFrm->FindSctFrm()->GetUpper();
907cdf0e10cSrcweir nDist = (GetAnchoredObj().GetObjRect().*fnRect->fnBottomDist)(
908cdf0e10cSrcweir (pTmp->*fnRect->fnGetPrtBottom)() );
909cdf0e10cSrcweir // --> OD 2004-11-01 #i23129# - Try to flow into next
910cdf0e10cSrcweir // section|section column. Thus, do *not* leave section
911cdf0e10cSrcweir // area, if anchored object doesn't fit into upper of section.
912cdf0e10cSrcweir // But the anchored object is allowed to overlap bottom
913cdf0e10cSrcweir // section|section column.
914cdf0e10cSrcweir if ( nDist >= 0 )
915cdf0e10cSrcweir {
916cdf0e10cSrcweir break;
917cdf0e10cSrcweir }
918cdf0e10cSrcweir // <--
919cdf0e10cSrcweir }
920cdf0e10cSrcweir if ( !bInSct &&
921cdf0e10cSrcweir (GetAnchoredObj().GetObjRect().*fnRect->fnGetTop)() ==
922cdf0e10cSrcweir (pUpperOfOrientFrm->*fnRect->fnGetPrtTop)() )
923cdf0e10cSrcweir //Das teil passt nimmer, da hilft auch kein moven.
924cdf0e10cSrcweir break;
925cdf0e10cSrcweir
926cdf0e10cSrcweir const SwLayoutFrm* pNextLay = pUpperOfOrientFrm->GetLeaf(
927cdf0e10cSrcweir ( bInSct
928cdf0e10cSrcweir ? MAKEPAGE_NOSECTION
929cdf0e10cSrcweir : ( bInFtn ? MAKEPAGE_NONE : MAKEPAGE_APPEND ) ),
930cdf0e10cSrcweir sal_True, &rAnchorTxtFrm );
931cdf0e10cSrcweir // OD 06.10.2003 #110978# - correction:
932cdf0e10cSrcweir // If anchor is in footnote and proposed next layout environment
933cdf0e10cSrcweir // isn't a footnote frame, object can't follow the text flow
934cdf0e10cSrcweir if ( bInFtn && pNextLay && !pNextLay->IsFtnFrm() )
935cdf0e10cSrcweir {
936cdf0e10cSrcweir pNextLay = 0L;
937cdf0e10cSrcweir }
938cdf0e10cSrcweir if ( pNextLay )
939cdf0e10cSrcweir {
940cdf0e10cSrcweir SWRECTFNX( pNextLay )
941cdf0e10cSrcweir if ( !bInSct ||
942cdf0e10cSrcweir ( pUpperOfOrientFrm->FindSctFrm()->IsAnFollow( pNextLay->FindSctFrm() ) &&
943cdf0e10cSrcweir (pNextLay->Prt().*fnRectX->fnGetHeight)() ) )
944cdf0e10cSrcweir {
945cdf0e10cSrcweir SwTwips nTmpRelPosY =
946cdf0e10cSrcweir (*fnRect->fnYDiff)( (pNextLay->*fnRect->fnGetPrtTop)(),
947cdf0e10cSrcweir nTopOfAnch );
948cdf0e10cSrcweir if ( bVert )
949cdf0e10cSrcweir aRelPos.X() = nTmpRelPosY;
950cdf0e10cSrcweir else
951cdf0e10cSrcweir aRelPos.Y() = nTmpRelPosY;
952cdf0e10cSrcweir pUpperOfOrientFrm = pNextLay;
953cdf0e10cSrcweir SWREFRESHFN( pUpperOfOrientFrm )
954cdf0e10cSrcweir bMoveable = rAnchorTxtFrm.IsMoveable( (SwLayoutFrm*)pUpperOfOrientFrm );
955cdf0e10cSrcweir if( bVertX )
956cdf0e10cSrcweir {
957cdf0e10cSrcweir // --> OD 2009-08-31 #mongolianlayout#
958cdf0e10cSrcweir if ( !bVertL2R )
959cdf0e10cSrcweir {
960cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch -
961cdf0e10cSrcweir aRelPos.X() -
962cdf0e10cSrcweir aObjBoundRect.Width() );
963cdf0e10cSrcweir }
964cdf0e10cSrcweir else
965cdf0e10cSrcweir {
966cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch +
967cdf0e10cSrcweir aRelPos.X() );
968cdf0e10cSrcweir }
969cdf0e10cSrcweir // <--
970cdf0e10cSrcweir }
971cdf0e10cSrcweir else
972cdf0e10cSrcweir GetAnchoredObj().SetObjTop( nTopOfAnch +
973cdf0e10cSrcweir aRelPos.Y() );
974cdf0e10cSrcweir nDist = (GetAnchoredObj().GetObjRect().*fnRect->fnBottomDist)(
975cdf0e10cSrcweir (pUpperOfOrientFrm->*fnRect->fnGetPrtBottom)() );
976cdf0e10cSrcweir }
977cdf0e10cSrcweir // --> OD 2004-11-01 #i23129# - leave section area
978cdf0e10cSrcweir else if ( bInSct )
979cdf0e10cSrcweir {
980cdf0e10cSrcweir const SwLayoutFrm* pTmp = pUpperOfOrientFrm->FindSctFrm()->GetUpper();
981cdf0e10cSrcweir nDist = (GetAnchoredObj().GetObjRect().*fnRect->fnBottomDist)(
982cdf0e10cSrcweir (pTmp->*fnRect->fnGetPrtBottom)() );
983cdf0e10cSrcweir if( nDist < 0 )
984cdf0e10cSrcweir pUpperOfOrientFrm = pTmp;
985cdf0e10cSrcweir else
986cdf0e10cSrcweir break;
987cdf0e10cSrcweir }
988cdf0e10cSrcweir // <--
989cdf0e10cSrcweir }
990cdf0e10cSrcweir else if ( bInSct )
991cdf0e10cSrcweir {
992cdf0e10cSrcweir // Wenn wir innerhalb des Bereich nicht genug Platz haben, gucken
993cdf0e10cSrcweir // wir uns mal die Seite an.
994cdf0e10cSrcweir const SwLayoutFrm* pTmp = pUpperOfOrientFrm->FindSctFrm()->GetUpper();
995cdf0e10cSrcweir nDist = (GetAnchoredObj().GetObjRect().*fnRect->fnBottomDist)(
996cdf0e10cSrcweir (pTmp->*fnRect->fnGetPrtBottom)() );
997cdf0e10cSrcweir if( nDist < 0 )
998cdf0e10cSrcweir pUpperOfOrientFrm = pTmp;
999cdf0e10cSrcweir else
1000cdf0e10cSrcweir break;
1001cdf0e10cSrcweir }
1002cdf0e10cSrcweir else
1003cdf0e10cSrcweir bMoveable = false;
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir }
1006cdf0e10cSrcweir }
1007cdf0e10cSrcweir
1008cdf0e10cSrcweir // keep layout frame vertical position is oriented at.
1009cdf0e10cSrcweir mpVertPosOrientFrm = pUpperOfOrientFrm;
1010cdf0e10cSrcweir
1011cdf0e10cSrcweir }
1012cdf0e10cSrcweir
1013cdf0e10cSrcweir // determine 'horizontal' position
1014cdf0e10cSrcweir {
1015cdf0e10cSrcweir // determine horizontal positioning and alignment attributes
1016cdf0e10cSrcweir SwFmtHoriOrient aHori( rFrmFmt.GetHoriOrient() );
1017cdf0e10cSrcweir
1018cdf0e10cSrcweir // set calculated vertical position in order to determine correct
1019cdf0e10cSrcweir // frame, the horizontal position is oriented at.
1020cdf0e10cSrcweir const SwTwips nTopOfAnch = _GetTopForObjPos( *pAnchorFrmForVertPos, fnRect, bVert );
1021cdf0e10cSrcweir if( bVert )
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir // --> OD 2009-08-31 #mongolianlayout#
1024cdf0e10cSrcweir if ( !bVertL2R )
1025cdf0e10cSrcweir {
1026cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch -
1027cdf0e10cSrcweir aRelPos.X() - aObjBoundRect.Width() );
1028cdf0e10cSrcweir }
1029cdf0e10cSrcweir else
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch + aRelPos.X() );
1032cdf0e10cSrcweir }
1033cdf0e10cSrcweir // <--
1034cdf0e10cSrcweir }
1035cdf0e10cSrcweir else
1036cdf0e10cSrcweir GetAnchoredObj().SetObjTop( nTopOfAnch + aRelPos.Y() );
1037cdf0e10cSrcweir
1038cdf0e10cSrcweir // determine frame, horizontal position is oriented at.
1039cdf0e10cSrcweir // OD 2004-05-21 #i28701# - If floating screen object doesn't follow
1040cdf0e10cSrcweir // the text flow, its horizontal position is oriented at <pOrientFrm>.
1041cdf0e10cSrcweir const SwFrm* pHoriOrientFrm = DoesObjFollowsTextFlow()
1042cdf0e10cSrcweir ? &_GetHoriVirtualAnchor( *mpVertPosOrientFrm )
1043cdf0e10cSrcweir : pOrientFrm;
1044cdf0e10cSrcweir
1045cdf0e10cSrcweir // --> OD 2004-06-17 #i26791# - get 'horizontal' offset to frame anchor position.
1046cdf0e10cSrcweir SwTwips nHoriOffsetToFrmAnchorPos( 0L );
1047cdf0e10cSrcweir SwTwips nRelPosX = _CalcRelPosX( *pHoriOrientFrm, aEnvOfObj,
1048cdf0e10cSrcweir aHori, rLR, rUL, bWrapThrough,
1049cdf0e10cSrcweir ( bVert ? aRelPos.X() : aRelPos.Y() ),
1050cdf0e10cSrcweir nHoriOffsetToFrmAnchorPos );
1051cdf0e10cSrcweir
1052cdf0e10cSrcweir // --> OD 2004-06-17 #i26791# - determine offset to 'horizontal' frame
1053cdf0e10cSrcweir // anchor position, depending on layout-direction
1054cdf0e10cSrcweir if ( bVert )
1055cdf0e10cSrcweir {
1056cdf0e10cSrcweir aRelPos.Y() = nRelPosX;
1057cdf0e10cSrcweir maOffsetToFrmAnchorPos.Y() = nHoriOffsetToFrmAnchorPos;
1058cdf0e10cSrcweir }
1059cdf0e10cSrcweir else
1060cdf0e10cSrcweir {
1061cdf0e10cSrcweir aRelPos.X() = nRelPosX;
1062cdf0e10cSrcweir maOffsetToFrmAnchorPos.X() = nHoriOffsetToFrmAnchorPos;
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir // save calculated horizontal position - needed for filters
1066cdf0e10cSrcweir // (including the xml-filter)
1067cdf0e10cSrcweir {
1068cdf0e10cSrcweir SwTwips nAttrRelPosX = nRelPosX - nHoriOffsetToFrmAnchorPos;
1069cdf0e10cSrcweir if ( aHori.GetHoriOrient() != text::HoriOrientation::NONE &&
1070cdf0e10cSrcweir aHori.GetPos() != nAttrRelPosX )
1071cdf0e10cSrcweir {
1072cdf0e10cSrcweir aHori.SetPos( nAttrRelPosX );
1073cdf0e10cSrcweir const_cast<SwFrmFmt&>(rFrmFmt).LockModify();
1074cdf0e10cSrcweir const_cast<SwFrmFmt&>(rFrmFmt).SetFmtAttr( aHori );
1075cdf0e10cSrcweir const_cast<SwFrmFmt&>(rFrmFmt).UnlockModify();
1076cdf0e10cSrcweir }
1077cdf0e10cSrcweir }
1078cdf0e10cSrcweir }
1079cdf0e10cSrcweir
1080cdf0e10cSrcweir // set absolute position at object
1081cdf0e10cSrcweir const SwTwips nTopOfAnch = _GetTopForObjPos( *pAnchorFrmForVertPos, fnRect, bVert );
1082cdf0e10cSrcweir if( bVert )
1083cdf0e10cSrcweir {
1084cdf0e10cSrcweir // --> OD 2009-08-31 #mongolianlayout#
1085cdf0e10cSrcweir if ( !bVertL2R )
1086cdf0e10cSrcweir {
1087cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch -
1088cdf0e10cSrcweir aRelPos.X() - aObjBoundRect.Width() );
1089cdf0e10cSrcweir }
1090cdf0e10cSrcweir else
1091cdf0e10cSrcweir {
1092cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( nTopOfAnch + aRelPos.X() );
1093cdf0e10cSrcweir }
1094cdf0e10cSrcweir // <--
1095cdf0e10cSrcweir GetAnchoredObj().SetObjTop( rAnchorTxtFrm.Frm().Top() +
1096cdf0e10cSrcweir aRelPos.Y() );
1097cdf0e10cSrcweir }
1098cdf0e10cSrcweir else
1099cdf0e10cSrcweir {
1100cdf0e10cSrcweir GetAnchoredObj().SetObjLeft( rAnchorTxtFrm.Frm().Left() +
1101cdf0e10cSrcweir aRelPos.X() );
1102cdf0e10cSrcweir GetAnchoredObj().SetObjTop( nTopOfAnch + aRelPos.Y() );
1103cdf0e10cSrcweir }
1104cdf0e10cSrcweir
1105cdf0e10cSrcweir // set relative position at object
1106cdf0e10cSrcweir GetAnchoredObj().SetCurrRelPos( aRelPos );
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir /** determine frame for horizontal position
1110cdf0e10cSrcweir
1111cdf0e10cSrcweir @author OD
1112cdf0e10cSrcweir */
_GetHoriVirtualAnchor(const SwLayoutFrm & _rProposedFrm) const1113cdf0e10cSrcweir const SwFrm& SwToCntntAnchoredObjectPosition::_GetHoriVirtualAnchor(
1114cdf0e10cSrcweir const SwLayoutFrm& _rProposedFrm ) const
1115cdf0e10cSrcweir {
1116cdf0e10cSrcweir const SwFrm* pHoriVirtAnchFrm = &_rProposedFrm;
1117cdf0e10cSrcweir
1118cdf0e10cSrcweir // Search for first lower content frame, which is the anchor or a follow
1119cdf0e10cSrcweir // of the anchor (Note: <Anchor.IsAnFollow( Anchor )> is true)
1120cdf0e10cSrcweir // If none found, <_rProposedFrm> is returned.
1121cdf0e10cSrcweir const SwFrm* pFrm = _rProposedFrm.Lower();
1122cdf0e10cSrcweir while ( pFrm )
1123cdf0e10cSrcweir {
1124cdf0e10cSrcweir if ( pFrm->IsCntntFrm() &&
1125cdf0e10cSrcweir GetAnchorTxtFrm().IsAnFollow( static_cast<const SwCntntFrm*>(pFrm) ) )
1126cdf0e10cSrcweir {
1127cdf0e10cSrcweir pHoriVirtAnchFrm = pFrm;
1128cdf0e10cSrcweir break;
1129cdf0e10cSrcweir }
1130cdf0e10cSrcweir pFrm = pFrm->GetNext();
1131cdf0e10cSrcweir }
1132cdf0e10cSrcweir
1133cdf0e10cSrcweir return *pHoriVirtAnchFrm;
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir
GetVertPosOrientFrm() const1136cdf0e10cSrcweir const SwLayoutFrm& SwToCntntAnchoredObjectPosition::GetVertPosOrientFrm() const
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir return *mpVertPosOrientFrm;
1139cdf0e10cSrcweir }
1140cdf0e10cSrcweir
1141