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 <anchoredobjectposition.hxx>
27cdf0e10cSrcweir #ifndef _ENVIRONMENTOFANCHOREDOBJECT
28cdf0e10cSrcweir #include <environmentofanchoredobject.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #include <flyfrm.hxx>
31cdf0e10cSrcweir #include <flyfrms.hxx>
32cdf0e10cSrcweir #include <txtfrm.hxx>
33cdf0e10cSrcweir #include <pagefrm.hxx>
34cdf0e10cSrcweir #include <frmtool.hxx>
35cdf0e10cSrcweir #ifndef _SVX_SVDOBJ_HXX
36cdf0e10cSrcweir #include <svx/svdobj.hxx>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <dflyobj.hxx>
39cdf0e10cSrcweir #include <dcontact.hxx>
40cdf0e10cSrcweir #include <frmfmt.hxx>
41cdf0e10cSrcweir #include <fmtornt.hxx>
42cdf0e10cSrcweir // --> OD 2006-03-15 #i62875#
43cdf0e10cSrcweir #include <fmtfollowtextflow.hxx>
44cdf0e10cSrcweir // <--
45cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
46cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
47cdf0e10cSrcweir #include <ndtxt.hxx>
48cdf0e10cSrcweir #include <IDocumentSettingAccess.hxx>
49cdf0e10cSrcweir
50cdf0e10cSrcweir using namespace ::com::sun::star;
51cdf0e10cSrcweir using namespace objectpositioning;
52cdf0e10cSrcweir
53cdf0e10cSrcweir // **************************************************************************
54cdf0e10cSrcweir // constructor, destructor, initialization
55cdf0e10cSrcweir // **************************************************************************
SwAnchoredObjectPosition(SdrObject & _rDrawObj)56cdf0e10cSrcweir SwAnchoredObjectPosition::SwAnchoredObjectPosition( SdrObject& _rDrawObj )
57cdf0e10cSrcweir : mrDrawObj( _rDrawObj ),
58cdf0e10cSrcweir mbIsObjFly( false ),
59cdf0e10cSrcweir mpAnchoredObj( 0 ),
60cdf0e10cSrcweir mpAnchorFrm( 0 ),
61cdf0e10cSrcweir mpContact( 0 ),
62cdf0e10cSrcweir // --> OD 2006-03-15 #i62875#
63cdf0e10cSrcweir mbFollowTextFlow( false ),
64cdf0e10cSrcweir mbDoNotCaptureAnchoredObj( false )
65cdf0e10cSrcweir // <--
66cdf0e10cSrcweir {
67cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1
68cdf0e10cSrcweir // assert, if object isn't of excepted type
69cdf0e10cSrcweir const bool bObjOfExceptedType =
70cdf0e10cSrcweir mrDrawObj.ISA(SwVirtFlyDrawObj) || // object representing fly frame
71cdf0e10cSrcweir mrDrawObj.ISA(SwDrawVirtObj) || // 'virtual' drawing object
72cdf0e10cSrcweir ( !mrDrawObj.ISA(SdrVirtObj) && // 'master' drawing object
73cdf0e10cSrcweir !mrDrawObj.ISA(SwFlyDrawObj) ); // - indirectly checked
74cdf0e10cSrcweir (void) bObjOfExceptedType;
75cdf0e10cSrcweir ASSERT( bObjOfExceptedType,
76cdf0e10cSrcweir "SwAnchoredObjectPosition(..) - object of unexcepted type!" );
77cdf0e10cSrcweir #endif
78cdf0e10cSrcweir
79cdf0e10cSrcweir _GetInfoAboutObj();
80cdf0e10cSrcweir }
81cdf0e10cSrcweir
82cdf0e10cSrcweir /** determine information about object
83cdf0e10cSrcweir
84cdf0e10cSrcweir OD 30.07.2003 #110978#
85cdf0e10cSrcweir members <mbIsObjFly>, <mpFrmOfObj>, <mpAnchorFrm>, <mpContact>,
86cdf0e10cSrcweir <mbFollowTextFlow> and <mbDoNotCaptureAnchoredObj> are set
87cdf0e10cSrcweir
88cdf0e10cSrcweir @author OD
89cdf0e10cSrcweir */
_GetInfoAboutObj()90cdf0e10cSrcweir void SwAnchoredObjectPosition::_GetInfoAboutObj()
91cdf0e10cSrcweir {
92cdf0e10cSrcweir // determine, if object represents a fly frame
93cdf0e10cSrcweir {
94cdf0e10cSrcweir mbIsObjFly = mrDrawObj.ISA(SwVirtFlyDrawObj);
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
97cdf0e10cSrcweir // determine contact object
98cdf0e10cSrcweir {
99cdf0e10cSrcweir mpContact = static_cast<SwContact*>(GetUserCall( &mrDrawObj ));
100cdf0e10cSrcweir ASSERT( mpContact,
101cdf0e10cSrcweir "SwAnchoredObjectPosition::_GetInfoAboutObj() - missing SwContact-object." );
102cdf0e10cSrcweir }
103cdf0e10cSrcweir
104cdf0e10cSrcweir // determine anchored object, the object belongs to
105cdf0e10cSrcweir {
106cdf0e10cSrcweir // OD 2004-03-30 #i26791#
107cdf0e10cSrcweir mpAnchoredObj = mpContact->GetAnchoredObj( &mrDrawObj );
108cdf0e10cSrcweir ASSERT( mpAnchoredObj,
109cdf0e10cSrcweir "SwAnchoredObjectPosition::_GetInfoAboutObj() - missing anchored object." );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
112cdf0e10cSrcweir // determine frame, the object is anchored at
113cdf0e10cSrcweir {
114cdf0e10cSrcweir // OD 2004-03-23 #i26791#
115cdf0e10cSrcweir mpAnchorFrm = mpAnchoredObj->AnchorFrm();
116cdf0e10cSrcweir ASSERT( mpAnchorFrm,
117cdf0e10cSrcweir "SwAnchoredObjectPosition::_GetInfoAboutObj() - missing anchor frame." );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir
120cdf0e10cSrcweir // determine format the object belongs to
121cdf0e10cSrcweir {
122cdf0e10cSrcweir // --> OD 2004-07-01 #i28701#
123cdf0e10cSrcweir mpFrmFmt = &mpAnchoredObj->GetFrmFmt();
124cdf0e10cSrcweir ASSERT( mpFrmFmt,
125cdf0e10cSrcweir "<SwAnchoredObjectPosition::_GetInfoAboutObj() - missing frame format." );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
128cdf0e10cSrcweir // --> OD 2006-03-15 #i62875#
129cdf0e10cSrcweir // determine attribute value of <Follow-Text-Flow>
130cdf0e10cSrcweir {
131cdf0e10cSrcweir mbFollowTextFlow = mpFrmFmt->GetFollowTextFlow().GetValue();
132cdf0e10cSrcweir }
133cdf0e10cSrcweir
134cdf0e10cSrcweir // determine, if anchored object has not to be captured on the page.
135cdf0e10cSrcweir // the following conditions must be hold to *not* capture it:
136cdf0e10cSrcweir // - corresponding document compatibility flag is set
137cdf0e10cSrcweir // - it's a drawing object
138cdf0e10cSrcweir // - it doesn't follow the text flow
139cdf0e10cSrcweir {
140cdf0e10cSrcweir mbDoNotCaptureAnchoredObj = !mbIsObjFly && !mbFollowTextFlow &&
141cdf0e10cSrcweir mpFrmFmt->getIDocumentSettingAccess()->get(IDocumentSettingAccess::DO_NOT_CAPTURE_DRAW_OBJS_ON_PAGE);
142cdf0e10cSrcweir }
143cdf0e10cSrcweir // <--
144cdf0e10cSrcweir }
145cdf0e10cSrcweir
~SwAnchoredObjectPosition()146cdf0e10cSrcweir SwAnchoredObjectPosition::~SwAnchoredObjectPosition()
147cdf0e10cSrcweir {}
148cdf0e10cSrcweir
IsAnchoredToChar() const149cdf0e10cSrcweir bool SwAnchoredObjectPosition::IsAnchoredToChar() const
150cdf0e10cSrcweir {
151cdf0e10cSrcweir return false;
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
ToCharOrientFrm() const154cdf0e10cSrcweir const SwFrm* SwAnchoredObjectPosition::ToCharOrientFrm() const
155cdf0e10cSrcweir {
156cdf0e10cSrcweir return NULL;
157cdf0e10cSrcweir }
158cdf0e10cSrcweir
ToCharRect() const159cdf0e10cSrcweir const SwRect* SwAnchoredObjectPosition::ToCharRect() const
160cdf0e10cSrcweir {
161cdf0e10cSrcweir return NULL;
162cdf0e10cSrcweir }
163cdf0e10cSrcweir
164cdf0e10cSrcweir // OD 12.11.2003 #i22341#
ToCharTopOfLine() const165cdf0e10cSrcweir SwTwips SwAnchoredObjectPosition::ToCharTopOfLine() const
166cdf0e10cSrcweir {
167cdf0e10cSrcweir return 0L;
168cdf0e10cSrcweir }
169cdf0e10cSrcweir
170cdf0e10cSrcweir /** helper method to determine top of a frame for the vertical
171cdf0e10cSrcweir object positioning
172cdf0e10cSrcweir
173cdf0e10cSrcweir OD 2004-03-11 #i11860#
174cdf0e10cSrcweir
175cdf0e10cSrcweir @author OD
176cdf0e10cSrcweir */
_GetTopForObjPos(const SwFrm & _rFrm,const SwRectFn & _fnRect,const bool _bVert) const177cdf0e10cSrcweir SwTwips SwAnchoredObjectPosition::_GetTopForObjPos( const SwFrm& _rFrm,
178cdf0e10cSrcweir const SwRectFn& _fnRect,
179cdf0e10cSrcweir const bool _bVert ) const
180cdf0e10cSrcweir {
181cdf0e10cSrcweir SwTwips nTopOfFrmForObjPos = (_rFrm.Frm().*_fnRect->fnGetTop)();
182cdf0e10cSrcweir
183cdf0e10cSrcweir if ( _rFrm.IsTxtFrm() )
184cdf0e10cSrcweir {
185cdf0e10cSrcweir const SwTxtFrm& rTxtFrm = static_cast<const SwTxtFrm&>(_rFrm);
186cdf0e10cSrcweir if ( _bVert )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir nTopOfFrmForObjPos -=
189cdf0e10cSrcweir rTxtFrm.GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
190cdf0e10cSrcweir }
191cdf0e10cSrcweir else
192cdf0e10cSrcweir {
193cdf0e10cSrcweir nTopOfFrmForObjPos +=
194cdf0e10cSrcweir rTxtFrm.GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid();
195cdf0e10cSrcweir }
196cdf0e10cSrcweir }
197cdf0e10cSrcweir
198cdf0e10cSrcweir return nTopOfFrmForObjPos;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir
_GetVertAlignmentValues(const SwFrm & _rVertOrientFrm,const SwFrm & _rPageAlignLayFrm,const sal_Int16 _eRelOrient,SwTwips & _orAlignAreaHeight,SwTwips & _orAlignAreaOffset) const201cdf0e10cSrcweir void SwAnchoredObjectPosition::_GetVertAlignmentValues(
202cdf0e10cSrcweir const SwFrm& _rVertOrientFrm,
203cdf0e10cSrcweir const SwFrm& _rPageAlignLayFrm,
204cdf0e10cSrcweir const sal_Int16 _eRelOrient,
205cdf0e10cSrcweir SwTwips& _orAlignAreaHeight,
206cdf0e10cSrcweir SwTwips& _orAlignAreaOffset ) const
207cdf0e10cSrcweir {
208cdf0e10cSrcweir SwTwips nHeight = 0;
209cdf0e10cSrcweir SwTwips nOffset = 0;
210cdf0e10cSrcweir SWRECTFN( (&_rVertOrientFrm) )
211cdf0e10cSrcweir // OD 2004-03-11 #i11860# - top of <_rVertOrientFrm> for object positioning
212cdf0e10cSrcweir const SwTwips nVertOrientTop = _GetTopForObjPos( _rVertOrientFrm, fnRect, bVert );
213cdf0e10cSrcweir // OD 2004-03-11 #i11860# - upper space amount of <_rVertOrientFrm> considered
214cdf0e10cSrcweir // for previous frame
215cdf0e10cSrcweir const SwTwips nVertOrientUpperSpaceForPrevFrmAndPageGrid =
216cdf0e10cSrcweir _rVertOrientFrm.IsTxtFrm()
217cdf0e10cSrcweir ? static_cast<const SwTxtFrm&>(_rVertOrientFrm).
218cdf0e10cSrcweir GetUpperSpaceAmountConsideredForPrevFrmAndPageGrid()
219cdf0e10cSrcweir : 0;
220cdf0e10cSrcweir switch ( _eRelOrient )
221cdf0e10cSrcweir {
222cdf0e10cSrcweir case text::RelOrientation::FRAME:
223cdf0e10cSrcweir {
224cdf0e10cSrcweir // OD 2004-03-11 #i11860# - consider upper space of previous frame
225cdf0e10cSrcweir nHeight = (_rVertOrientFrm.Frm().*fnRect->fnGetHeight)() -
226cdf0e10cSrcweir nVertOrientUpperSpaceForPrevFrmAndPageGrid;
227cdf0e10cSrcweir nOffset = 0;
228cdf0e10cSrcweir }
229cdf0e10cSrcweir break;
230cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
231cdf0e10cSrcweir {
232cdf0e10cSrcweir nHeight = (_rVertOrientFrm.Prt().*fnRect->fnGetHeight)();
233cdf0e10cSrcweir // OD 2004-03-11 #i11860# - consider upper space of previous frame
234cdf0e10cSrcweir nOffset = (_rVertOrientFrm.*fnRect->fnGetTopMargin)() -
235cdf0e10cSrcweir nVertOrientUpperSpaceForPrevFrmAndPageGrid;
236cdf0e10cSrcweir // if aligned to page in horizontal layout, consider header and
237cdf0e10cSrcweir // footer frame height appropriately.
238cdf0e10cSrcweir if( _rVertOrientFrm.IsPageFrm() && !bVert )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir const SwFrm* pPrtFrm =
241cdf0e10cSrcweir static_cast<const SwPageFrm&>(_rVertOrientFrm).Lower();
242cdf0e10cSrcweir while( pPrtFrm )
243cdf0e10cSrcweir {
244cdf0e10cSrcweir if( pPrtFrm->IsHeaderFrm() )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir nHeight -= pPrtFrm->Frm().Height();
247cdf0e10cSrcweir nOffset += pPrtFrm->Frm().Height();
248cdf0e10cSrcweir }
249cdf0e10cSrcweir else if( pPrtFrm->IsFooterFrm() )
250cdf0e10cSrcweir {
251cdf0e10cSrcweir nHeight -= pPrtFrm->Frm().Height();
252cdf0e10cSrcweir }
253cdf0e10cSrcweir pPrtFrm = pPrtFrm->GetNext();
254cdf0e10cSrcweir }
255cdf0e10cSrcweir }
256cdf0e10cSrcweir }
257cdf0e10cSrcweir break;
258cdf0e10cSrcweir case text::RelOrientation::PAGE_FRAME:
259cdf0e10cSrcweir {
260cdf0e10cSrcweir nHeight = (_rPageAlignLayFrm.Frm().*fnRect->fnGetHeight)();
261cdf0e10cSrcweir nOffset = (*fnRect->fnYDiff)(
262cdf0e10cSrcweir (_rPageAlignLayFrm.Frm().*fnRect->fnGetTop)(),
263cdf0e10cSrcweir nVertOrientTop );
264cdf0e10cSrcweir }
265cdf0e10cSrcweir break;
266cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA:
267cdf0e10cSrcweir {
268cdf0e10cSrcweir nHeight = (_rPageAlignLayFrm.Prt().*fnRect->fnGetHeight)();
269cdf0e10cSrcweir nOffset = (_rPageAlignLayFrm.*fnRect->fnGetTopMargin)() +
270cdf0e10cSrcweir (*fnRect->fnYDiff)(
271cdf0e10cSrcweir (_rPageAlignLayFrm.Frm().*fnRect->fnGetTop)(),
272cdf0e10cSrcweir nVertOrientTop );
273cdf0e10cSrcweir // if aligned to page in horizontal layout, consider header and
274cdf0e10cSrcweir // footer frame height appropriately.
275cdf0e10cSrcweir if( _rPageAlignLayFrm.IsPageFrm() && !bVert )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir const SwFrm* pPrtFrm =
278cdf0e10cSrcweir static_cast<const SwPageFrm&>(_rPageAlignLayFrm).Lower();
279cdf0e10cSrcweir while( pPrtFrm )
280cdf0e10cSrcweir {
281cdf0e10cSrcweir if( pPrtFrm->IsHeaderFrm() )
282cdf0e10cSrcweir {
283cdf0e10cSrcweir nHeight -= pPrtFrm->Frm().Height();
284cdf0e10cSrcweir nOffset += pPrtFrm->Frm().Height();
285cdf0e10cSrcweir }
286cdf0e10cSrcweir else if( pPrtFrm->IsFooterFrm() )
287cdf0e10cSrcweir {
288cdf0e10cSrcweir nHeight -= pPrtFrm->Frm().Height();
289cdf0e10cSrcweir }
290cdf0e10cSrcweir pPrtFrm = pPrtFrm->GetNext();
291cdf0e10cSrcweir }
292cdf0e10cSrcweir }
293cdf0e10cSrcweir }
294cdf0e10cSrcweir break;
295cdf0e10cSrcweir // OD 12.11.2003 #i22341# - vertical alignment at top of line
296cdf0e10cSrcweir case text::RelOrientation::TEXT_LINE:
297cdf0e10cSrcweir {
298cdf0e10cSrcweir if ( IsAnchoredToChar() )
299cdf0e10cSrcweir {
300cdf0e10cSrcweir nHeight = 0;
301cdf0e10cSrcweir nOffset = (*fnRect->fnYDiff)( ToCharTopOfLine(), nVertOrientTop );
302cdf0e10cSrcweir }
303cdf0e10cSrcweir else
304cdf0e10cSrcweir {
305cdf0e10cSrcweir ASSERT( false,
306cdf0e10cSrcweir "<SwAnchoredObjectPosition::_GetVertAlignmentValues(..)> - invalid relative alignment" );
307cdf0e10cSrcweir }
308cdf0e10cSrcweir }
309cdf0e10cSrcweir break;
310cdf0e10cSrcweir case text::RelOrientation::CHAR:
311cdf0e10cSrcweir {
312cdf0e10cSrcweir if ( IsAnchoredToChar() )
313cdf0e10cSrcweir {
314cdf0e10cSrcweir nHeight = (ToCharRect()->*fnRect->fnGetHeight)();
315cdf0e10cSrcweir nOffset = (*fnRect->fnYDiff)( (ToCharRect()->*fnRect->fnGetTop)(),
316cdf0e10cSrcweir nVertOrientTop );
317cdf0e10cSrcweir }
318cdf0e10cSrcweir else
319cdf0e10cSrcweir {
320cdf0e10cSrcweir ASSERT( false,
321cdf0e10cSrcweir "<SwAnchoredObjectPosition::_GetVertAlignmentValues(..)> - invalid relative alignment" );
322cdf0e10cSrcweir }
323cdf0e10cSrcweir }
324cdf0e10cSrcweir break;
325cdf0e10cSrcweir // no break here, because text::RelOrientation::CHAR is invalid, if !mbAnchorToChar
326cdf0e10cSrcweir default:
327cdf0e10cSrcweir //case text::RelOrientation::PAGE_LEFT: not valid for vertical alignment
328cdf0e10cSrcweir //case text::RelOrientation::PAGE_RIGHT: not valid for vertical alignment
329cdf0e10cSrcweir //case text::RelOrientation::FRAME_LEFT: not valid for vertical alignment
330cdf0e10cSrcweir //case text::RelOrientation::FRAME_RIGHT: not valid for vertical alignment
331cdf0e10cSrcweir {
332cdf0e10cSrcweir ASSERT( false,
333cdf0e10cSrcweir "<SwAnchoredObjectPosition::_GetVertAlignmentValues(..)> - invalid relative alignment" );
334cdf0e10cSrcweir }
335cdf0e10cSrcweir }
336cdf0e10cSrcweir
337cdf0e10cSrcweir _orAlignAreaHeight = nHeight;
338cdf0e10cSrcweir _orAlignAreaOffset = nOffset;
339cdf0e10cSrcweir }
340cdf0e10cSrcweir
341cdf0e10cSrcweir // --> OD 2004-06-17 #i26791# - add output parameter <_roVertOffsetToFrmAnchorPos>
_GetVertRelPos(const SwFrm & _rVertOrientFrm,const SwFrm & _rPageAlignLayFrm,const sal_Int16 _eVertOrient,const sal_Int16 _eRelOrient,const SwTwips _nVertPos,const SvxLRSpaceItem & _rLRSpacing,const SvxULSpaceItem & _rULSpacing,SwTwips & _roVertOffsetToFrmAnchorPos) const342cdf0e10cSrcweir SwTwips SwAnchoredObjectPosition::_GetVertRelPos(
343cdf0e10cSrcweir const SwFrm& _rVertOrientFrm,
344cdf0e10cSrcweir const SwFrm& _rPageAlignLayFrm,
345cdf0e10cSrcweir const sal_Int16 _eVertOrient,
346cdf0e10cSrcweir const sal_Int16 _eRelOrient,
347cdf0e10cSrcweir const SwTwips _nVertPos,
348cdf0e10cSrcweir const SvxLRSpaceItem& _rLRSpacing,
349cdf0e10cSrcweir const SvxULSpaceItem& _rULSpacing,
350cdf0e10cSrcweir SwTwips& _roVertOffsetToFrmAnchorPos ) const
351cdf0e10cSrcweir {
352cdf0e10cSrcweir SwTwips nRelPosY = 0;
353cdf0e10cSrcweir SWRECTFN( (&_rVertOrientFrm) );
354cdf0e10cSrcweir
355cdf0e10cSrcweir SwTwips nAlignAreaHeight;
356cdf0e10cSrcweir SwTwips nAlignAreaOffset;
357cdf0e10cSrcweir _GetVertAlignmentValues( _rVertOrientFrm, _rPageAlignLayFrm,
358cdf0e10cSrcweir _eRelOrient, nAlignAreaHeight, nAlignAreaOffset );
359cdf0e10cSrcweir
360cdf0e10cSrcweir nRelPosY = nAlignAreaOffset;
361cdf0e10cSrcweir const SwRect aObjBoundRect( GetAnchoredObj().GetObjRect() );
362cdf0e10cSrcweir const SwTwips nObjHeight = (aObjBoundRect.*fnRect->fnGetHeight)();
363cdf0e10cSrcweir
364cdf0e10cSrcweir switch ( _eVertOrient )
365cdf0e10cSrcweir {
366cdf0e10cSrcweir case text::VertOrientation::NONE:
367cdf0e10cSrcweir {
368cdf0e10cSrcweir // 'manual' vertical position
369cdf0e10cSrcweir nRelPosY += _nVertPos;
370cdf0e10cSrcweir }
371cdf0e10cSrcweir break;
372cdf0e10cSrcweir case text::VertOrientation::TOP:
373cdf0e10cSrcweir {
374cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
375cdf0e10cSrcweir nRelPosY += bVert
376cdf0e10cSrcweir ? ( bVertL2R
377cdf0e10cSrcweir ? _rLRSpacing.GetLeft()
378cdf0e10cSrcweir : _rLRSpacing.GetRight() )
379cdf0e10cSrcweir : _rULSpacing.GetUpper();
380cdf0e10cSrcweir }
381cdf0e10cSrcweir break;
382cdf0e10cSrcweir case text::VertOrientation::CENTER:
383cdf0e10cSrcweir {
384cdf0e10cSrcweir nRelPosY += (nAlignAreaHeight / 2) - (nObjHeight / 2);
385cdf0e10cSrcweir }
386cdf0e10cSrcweir break;
387cdf0e10cSrcweir case text::VertOrientation::BOTTOM:
388cdf0e10cSrcweir {
389cdf0e10cSrcweir //Badaa: 2008-04-18 * Support for Classical Mongolian Script (SCMS) joint with Jiayanmin
390cdf0e10cSrcweir nRelPosY += nAlignAreaHeight -
391cdf0e10cSrcweir ( nObjHeight + ( bVert
392cdf0e10cSrcweir ? ( bVertL2R
393cdf0e10cSrcweir ? _rLRSpacing.GetRight()
394cdf0e10cSrcweir : _rLRSpacing.GetLeft() )
395cdf0e10cSrcweir : _rULSpacing.GetLower() ) );
396cdf0e10cSrcweir }
397cdf0e10cSrcweir break;
398cdf0e10cSrcweir default:
399cdf0e10cSrcweir {
400cdf0e10cSrcweir ASSERT( false,
401cdf0e10cSrcweir "<SwAnchoredObjectPosition::_GetVertRelPos(..) - invalid vertical positioning" );
402cdf0e10cSrcweir }
403cdf0e10cSrcweir }
404cdf0e10cSrcweir
405cdf0e10cSrcweir // --> OD 2004-06-17 #i26791#
406cdf0e10cSrcweir _roVertOffsetToFrmAnchorPos = nAlignAreaOffset;
407cdf0e10cSrcweir
408cdf0e10cSrcweir return nRelPosY;
409cdf0e10cSrcweir }
410cdf0e10cSrcweir
411cdf0e10cSrcweir /** adjust calculated vertical in order to keep object inside
412cdf0e10cSrcweir 'page' alignment layout frame.
413cdf0e10cSrcweir
414cdf0e10cSrcweir OD 2004-07-01 #i28701# - parameter <nTopOfAnch> and <bVert> added
415cdf0e10cSrcweir OD 2004-07-22 #i31805# - add parameter <bCheckBottom>
416cdf0e10cSrcweir OD 2004-10-08 #i26945# - add parameter <bFollowTextFlow>
417cdf0e10cSrcweir OD 2006-03-15 #i62875# - method now private and renamed.
418cdf0e10cSrcweir OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
419cdf0e10cSrcweir
420cdf0e10cSrcweir @author OD
421cdf0e10cSrcweir */
_ImplAdjustVertRelPos(const SwTwips nTopOfAnch,const bool bVert,const bool bVertL2R,const SwFrm & rPageAlignLayFrm,const SwTwips nProposedRelPosY,const bool bFollowTextFlow,const bool bCheckBottom) const422cdf0e10cSrcweir SwTwips SwAnchoredObjectPosition::_ImplAdjustVertRelPos( const SwTwips nTopOfAnch,
423cdf0e10cSrcweir const bool bVert,
424cdf0e10cSrcweir const bool bVertL2R,
425cdf0e10cSrcweir const SwFrm& rPageAlignLayFrm,
426cdf0e10cSrcweir const SwTwips nProposedRelPosY,
427cdf0e10cSrcweir const bool bFollowTextFlow,
428cdf0e10cSrcweir const bool bCheckBottom ) const
429cdf0e10cSrcweir {
430cdf0e10cSrcweir SwTwips nAdjustedRelPosY = nProposedRelPosY;
431cdf0e10cSrcweir
432cdf0e10cSrcweir const Size aObjSize( GetAnchoredObj().GetObjRect().SSize() );
433cdf0e10cSrcweir
434cdf0e10cSrcweir // determine the area of 'page' alignment frame, to which the vertical
435cdf0e10cSrcweir // position is restricted.
436cdf0e10cSrcweir // --> OD 2004-07-06 #i28701# - Extend restricted area for the vertical
437cdf0e10cSrcweir // position to area of the page frame, if wrapping style influence is
438cdf0e10cSrcweir // considered on object positioning. Needed to avoid layout loops in the
439cdf0e10cSrcweir // object positioning algorithm considering the wrapping style influence
440cdf0e10cSrcweir // caused by objects, which follow the text flow and thus are restricted
441cdf0e10cSrcweir // to its environment (e.g. page header/footer).
442cdf0e10cSrcweir SwRect aPgAlignArea;
443cdf0e10cSrcweir {
444cdf0e10cSrcweir // --> OD 2004-10-08 #i26945# - no extension of restricted area, if
445cdf0e10cSrcweir // object's attribute follow text flow is set and its inside a table
446cdf0e10cSrcweir if ( GetFrmFmt().getIDocumentSettingAccess()->get(IDocumentSettingAccess::CONSIDER_WRAP_ON_OBJECT_POSITION) &&
447cdf0e10cSrcweir ( !bFollowTextFlow ||
448cdf0e10cSrcweir !GetAnchoredObj().GetAnchorFrm()->IsInTab() ) )
449cdf0e10cSrcweir {
450cdf0e10cSrcweir aPgAlignArea = rPageAlignLayFrm.FindPageFrm()->Frm();
451cdf0e10cSrcweir }
452cdf0e10cSrcweir else
453cdf0e10cSrcweir {
454cdf0e10cSrcweir aPgAlignArea = rPageAlignLayFrm.Frm();
455cdf0e10cSrcweir }
456cdf0e10cSrcweir }
457cdf0e10cSrcweir
458cdf0e10cSrcweir if ( bVert )
459cdf0e10cSrcweir {
460cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
461cdf0e10cSrcweir if ( !bVertL2R )
462cdf0e10cSrcweir // <--
463cdf0e10cSrcweir {
464cdf0e10cSrcweir if ( bCheckBottom &&
465cdf0e10cSrcweir nTopOfAnch - nAdjustedRelPosY - aObjSize.Width() <
466cdf0e10cSrcweir aPgAlignArea.Left() )
467cdf0e10cSrcweir {
468cdf0e10cSrcweir nAdjustedRelPosY = aPgAlignArea.Left() +
469cdf0e10cSrcweir nTopOfAnch -
470cdf0e10cSrcweir aObjSize.Width();
471cdf0e10cSrcweir }
472cdf0e10cSrcweir if ( nTopOfAnch - nAdjustedRelPosY > aPgAlignArea.Right() )
473cdf0e10cSrcweir {
474cdf0e10cSrcweir nAdjustedRelPosY = nTopOfAnch - aPgAlignArea.Right();
475cdf0e10cSrcweir }
476cdf0e10cSrcweir }
477cdf0e10cSrcweir // --> OD 2009-09-01 #mongolianlayout#
478cdf0e10cSrcweir else
479cdf0e10cSrcweir {
480cdf0e10cSrcweir if ( bCheckBottom &&
481cdf0e10cSrcweir nTopOfAnch + nAdjustedRelPosY + aObjSize.Width() >
482cdf0e10cSrcweir aPgAlignArea.Right() )
483cdf0e10cSrcweir {
484cdf0e10cSrcweir nAdjustedRelPosY = aPgAlignArea.Right() -
485cdf0e10cSrcweir nTopOfAnch -
486cdf0e10cSrcweir aObjSize.Width();
487cdf0e10cSrcweir }
488cdf0e10cSrcweir if ( nTopOfAnch + nAdjustedRelPosY < aPgAlignArea.Left() )
489cdf0e10cSrcweir {
490cdf0e10cSrcweir nAdjustedRelPosY = aPgAlignArea.Left() - nTopOfAnch;
491cdf0e10cSrcweir }
492cdf0e10cSrcweir }
493cdf0e10cSrcweir // <--
494cdf0e10cSrcweir }
495cdf0e10cSrcweir else
496cdf0e10cSrcweir {
497cdf0e10cSrcweir if ( bCheckBottom &&
498cdf0e10cSrcweir nTopOfAnch + nAdjustedRelPosY + aObjSize.Height() >
499cdf0e10cSrcweir aPgAlignArea.Top() + aPgAlignArea.Height() )
500cdf0e10cSrcweir {
501cdf0e10cSrcweir nAdjustedRelPosY = aPgAlignArea.Top() + aPgAlignArea.Height() -
502cdf0e10cSrcweir nTopOfAnch -
503cdf0e10cSrcweir aObjSize.Height();
504cdf0e10cSrcweir }
505cdf0e10cSrcweir if ( nTopOfAnch + nAdjustedRelPosY < aPgAlignArea.Top() )
506cdf0e10cSrcweir {
507cdf0e10cSrcweir nAdjustedRelPosY = aPgAlignArea.Top() - nTopOfAnch;
508cdf0e10cSrcweir }
509cdf0e10cSrcweir }
510cdf0e10cSrcweir
511cdf0e10cSrcweir return nAdjustedRelPosY;
512cdf0e10cSrcweir }
513cdf0e10cSrcweir
514cdf0e10cSrcweir /** adjust calculated horizontal in order to keep object inside
515cdf0e10cSrcweir 'page' alignment layout frame.
516cdf0e10cSrcweir
517cdf0e10cSrcweir OD 2006-03-15 #i62875# - method now private and renamed.
518cdf0e10cSrcweir
519cdf0e10cSrcweir @author OD
520cdf0e10cSrcweir */
_ImplAdjustHoriRelPos(const SwFrm & _rPageAlignLayFrm,const SwTwips _nProposedRelPosX) const521cdf0e10cSrcweir SwTwips SwAnchoredObjectPosition::_ImplAdjustHoriRelPos(
522cdf0e10cSrcweir const SwFrm& _rPageAlignLayFrm,
523cdf0e10cSrcweir const SwTwips _nProposedRelPosX ) const
524cdf0e10cSrcweir {
525cdf0e10cSrcweir SwTwips nAdjustedRelPosX = _nProposedRelPosX;
526cdf0e10cSrcweir
527cdf0e10cSrcweir const SwFrm& rAnchorFrm = GetAnchorFrm();
528cdf0e10cSrcweir const bool bVert = rAnchorFrm.IsVertical();
529cdf0e10cSrcweir
530cdf0e10cSrcweir const Size aObjSize( GetAnchoredObj().GetObjRect().SSize() );
531cdf0e10cSrcweir
532cdf0e10cSrcweir if( bVert )
533cdf0e10cSrcweir {
534cdf0e10cSrcweir if ( rAnchorFrm.Frm().Top() + nAdjustedRelPosX + aObjSize.Height() >
535cdf0e10cSrcweir _rPageAlignLayFrm.Frm().Bottom() )
536cdf0e10cSrcweir {
537cdf0e10cSrcweir nAdjustedRelPosX = _rPageAlignLayFrm.Frm().Bottom() -
538cdf0e10cSrcweir rAnchorFrm.Frm().Top() -
539cdf0e10cSrcweir aObjSize.Height();
540cdf0e10cSrcweir }
541cdf0e10cSrcweir if ( rAnchorFrm.Frm().Top() + nAdjustedRelPosX <
542cdf0e10cSrcweir _rPageAlignLayFrm.Frm().Top() )
543cdf0e10cSrcweir {
544cdf0e10cSrcweir nAdjustedRelPosX = _rPageAlignLayFrm.Frm().Top() -
545cdf0e10cSrcweir rAnchorFrm.Frm().Top();
546cdf0e10cSrcweir }
547cdf0e10cSrcweir }
548cdf0e10cSrcweir else
549cdf0e10cSrcweir {
550cdf0e10cSrcweir if ( rAnchorFrm.Frm().Left() + nAdjustedRelPosX + aObjSize.Width() >
551cdf0e10cSrcweir _rPageAlignLayFrm.Frm().Right() )
552cdf0e10cSrcweir {
553cdf0e10cSrcweir nAdjustedRelPosX = _rPageAlignLayFrm.Frm().Right() -
554cdf0e10cSrcweir rAnchorFrm.Frm().Left() -
555cdf0e10cSrcweir aObjSize.Width();
556cdf0e10cSrcweir }
557cdf0e10cSrcweir if ( rAnchorFrm.Frm().Left() + nAdjustedRelPosX <
558cdf0e10cSrcweir _rPageAlignLayFrm.Frm().Left() )
559cdf0e10cSrcweir {
560cdf0e10cSrcweir nAdjustedRelPosX = _rPageAlignLayFrm.Frm().Left() -
561cdf0e10cSrcweir rAnchorFrm.Frm().Left();
562cdf0e10cSrcweir }
563cdf0e10cSrcweir }
564cdf0e10cSrcweir
565cdf0e10cSrcweir return nAdjustedRelPosX;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir
568cdf0e10cSrcweir /** determine alignment value for horizontal position of object
569cdf0e10cSrcweir
570cdf0e10cSrcweir @author OD
571cdf0e10cSrcweir */
_GetHoriAlignmentValues(const SwFrm & _rHoriOrientFrm,const SwFrm & _rPageAlignLayFrm,const sal_Int16 _eRelOrient,const bool _bObjWrapThrough,SwTwips & _orAlignAreaWidth,SwTwips & _orAlignAreaOffset,bool & _obAlignedRelToPage) const572cdf0e10cSrcweir void SwAnchoredObjectPosition::_GetHoriAlignmentValues( const SwFrm& _rHoriOrientFrm,
573cdf0e10cSrcweir const SwFrm& _rPageAlignLayFrm,
574cdf0e10cSrcweir const sal_Int16 _eRelOrient,
575cdf0e10cSrcweir const bool _bObjWrapThrough,
576cdf0e10cSrcweir SwTwips& _orAlignAreaWidth,
577cdf0e10cSrcweir SwTwips& _orAlignAreaOffset,
578cdf0e10cSrcweir bool& _obAlignedRelToPage ) const
579cdf0e10cSrcweir {
580cdf0e10cSrcweir SwTwips nWidth = 0;
581cdf0e10cSrcweir SwTwips nOffset = 0;
582cdf0e10cSrcweir SWRECTFN( (&_rHoriOrientFrm) )
583cdf0e10cSrcweir switch ( _eRelOrient )
584cdf0e10cSrcweir {
585cdf0e10cSrcweir case text::RelOrientation::PRINT_AREA:
586cdf0e10cSrcweir {
587cdf0e10cSrcweir nWidth = (_rHoriOrientFrm.Prt().*fnRect->fnGetWidth)();
588cdf0e10cSrcweir nOffset = (_rHoriOrientFrm.*fnRect->fnGetLeftMargin)();
589cdf0e10cSrcweir if ( _rHoriOrientFrm.IsTxtFrm() )
590cdf0e10cSrcweir {
591cdf0e10cSrcweir // consider movement of text frame left
592cdf0e10cSrcweir nOffset += static_cast<const SwTxtFrm&>(_rHoriOrientFrm).GetBaseOfstForFly( !_bObjWrapThrough );
593cdf0e10cSrcweir }
594cdf0e10cSrcweir else if ( _rHoriOrientFrm.IsPageFrm() && bVert )
595cdf0e10cSrcweir {
596cdf0e10cSrcweir // for to-page anchored objects, consider header/footer frame
597cdf0e10cSrcweir // in vertical layout
598cdf0e10cSrcweir const SwFrm* pPrtFrm =
599cdf0e10cSrcweir static_cast<const SwPageFrm&>(_rHoriOrientFrm).Lower();
600cdf0e10cSrcweir while( pPrtFrm )
601cdf0e10cSrcweir {
602cdf0e10cSrcweir if( pPrtFrm->IsHeaderFrm() )
603cdf0e10cSrcweir {
604cdf0e10cSrcweir nWidth -= pPrtFrm->Frm().Height();
605cdf0e10cSrcweir nOffset += pPrtFrm->Frm().Height();
606cdf0e10cSrcweir }
607cdf0e10cSrcweir else if( pPrtFrm->IsFooterFrm() )
608cdf0e10cSrcweir {
609cdf0e10cSrcweir nWidth -= pPrtFrm->Frm().Height();
610cdf0e10cSrcweir }
611cdf0e10cSrcweir pPrtFrm = pPrtFrm->GetNext();
612cdf0e10cSrcweir }
613cdf0e10cSrcweir }
614cdf0e10cSrcweir break;
615cdf0e10cSrcweir }
616cdf0e10cSrcweir case text::RelOrientation::PAGE_LEFT:
617cdf0e10cSrcweir {
618cdf0e10cSrcweir // align at left border of page frame/fly frame/cell frame
619cdf0e10cSrcweir nWidth = (_rPageAlignLayFrm.*fnRect->fnGetLeftMargin)();
620cdf0e10cSrcweir nOffset = (*fnRect->fnXDiff)(
621cdf0e10cSrcweir (_rPageAlignLayFrm.Frm().*fnRect->fnGetLeft)(),
622cdf0e10cSrcweir (_rHoriOrientFrm.Frm().*fnRect->fnGetLeft)() );
623cdf0e10cSrcweir _obAlignedRelToPage = true;
624cdf0e10cSrcweir }
625cdf0e10cSrcweir break;
626cdf0e10cSrcweir case text::RelOrientation::PAGE_RIGHT:
627cdf0e10cSrcweir {
628cdf0e10cSrcweir // align at right border of page frame/fly frame/cell frame
629cdf0e10cSrcweir nWidth = (_rPageAlignLayFrm.*fnRect->fnGetRightMargin)();
630cdf0e10cSrcweir nOffset = (*fnRect->fnXDiff)(
631cdf0e10cSrcweir (_rPageAlignLayFrm.*fnRect->fnGetPrtRight)(),
632cdf0e10cSrcweir (_rHoriOrientFrm.Frm().*fnRect->fnGetLeft)() );
633cdf0e10cSrcweir _obAlignedRelToPage = true;
634cdf0e10cSrcweir }
635cdf0e10cSrcweir break;
636cdf0e10cSrcweir case text::RelOrientation::FRAME_LEFT:
637cdf0e10cSrcweir {
638cdf0e10cSrcweir // align at left border of anchor frame
639cdf0e10cSrcweir nWidth = (_rHoriOrientFrm.*fnRect->fnGetLeftMargin)();
640cdf0e10cSrcweir nOffset = 0;
641cdf0e10cSrcweir }
642cdf0e10cSrcweir break;
643cdf0e10cSrcweir case text::RelOrientation::FRAME_RIGHT:
644cdf0e10cSrcweir {
645cdf0e10cSrcweir // align at right border of anchor frame
646cdf0e10cSrcweir // OD 19.08.2003 #110978# - unify and simplify
647cdf0e10cSrcweir nWidth = (_rHoriOrientFrm.*fnRect->fnGetRightMargin)();
648cdf0e10cSrcweir //nOffset = (_rHoriOrientFrm.Frm().*fnRect->fnGetWidth)() -
649cdf0e10cSrcweir // nWidth;
650cdf0e10cSrcweir nOffset = (_rHoriOrientFrm.Prt().*fnRect->fnGetRight)();
651cdf0e10cSrcweir }
652cdf0e10cSrcweir break;
653cdf0e10cSrcweir case text::RelOrientation::CHAR:
654cdf0e10cSrcweir {
655cdf0e10cSrcweir // alignment relative to character - assure, that corresponding
656cdf0e10cSrcweir // character rectangle is set.
657cdf0e10cSrcweir if ( IsAnchoredToChar() )
658cdf0e10cSrcweir {
659cdf0e10cSrcweir nWidth = 0;
660cdf0e10cSrcweir nOffset = (*fnRect->fnXDiff)(
661cdf0e10cSrcweir (ToCharRect()->*fnRect->fnGetLeft)(),
662cdf0e10cSrcweir (ToCharOrientFrm()->Frm().*fnRect->fnGetLeft)() );
663cdf0e10cSrcweir break;
664cdf0e10cSrcweir }
665cdf0e10cSrcweir // no break!
666cdf0e10cSrcweir }
667cdf0e10cSrcweir case text::RelOrientation::PAGE_PRINT_AREA:
668cdf0e10cSrcweir {
669cdf0e10cSrcweir nWidth = (_rPageAlignLayFrm.Prt().*fnRect->fnGetWidth)();
670cdf0e10cSrcweir nOffset = (*fnRect->fnXDiff)(
671cdf0e10cSrcweir (_rPageAlignLayFrm.*fnRect->fnGetPrtLeft)(),
672cdf0e10cSrcweir (_rHoriOrientFrm.Frm().*fnRect->fnGetLeft)() );
673cdf0e10cSrcweir if ( _rHoriOrientFrm.IsPageFrm() && bVert )
674cdf0e10cSrcweir {
675cdf0e10cSrcweir // for to-page anchored objects, consider header/footer frame
676cdf0e10cSrcweir // in vertical layout
677cdf0e10cSrcweir const SwFrm* pPrtFrm =
678cdf0e10cSrcweir static_cast<const SwPageFrm&>(_rHoriOrientFrm).Lower();
679cdf0e10cSrcweir while( pPrtFrm )
680cdf0e10cSrcweir {
681cdf0e10cSrcweir if( pPrtFrm->IsHeaderFrm() )
682cdf0e10cSrcweir {
683cdf0e10cSrcweir nWidth -= pPrtFrm->Frm().Height();
684cdf0e10cSrcweir nOffset += pPrtFrm->Frm().Height();
685cdf0e10cSrcweir }
686cdf0e10cSrcweir else if( pPrtFrm->IsFooterFrm() )
687cdf0e10cSrcweir {
688cdf0e10cSrcweir nWidth -= pPrtFrm->Frm().Height();
689cdf0e10cSrcweir }
690cdf0e10cSrcweir pPrtFrm = pPrtFrm->GetNext();
691cdf0e10cSrcweir }
692cdf0e10cSrcweir }
693cdf0e10cSrcweir _obAlignedRelToPage = true;
694cdf0e10cSrcweir break;
695cdf0e10cSrcweir }
696cdf0e10cSrcweir case text::RelOrientation::PAGE_FRAME:
697cdf0e10cSrcweir {
698cdf0e10cSrcweir nWidth = (_rPageAlignLayFrm.Frm().*fnRect->fnGetWidth)();
699cdf0e10cSrcweir nOffset = (*fnRect->fnXDiff)(
700cdf0e10cSrcweir (_rPageAlignLayFrm.Frm().*fnRect->fnGetLeft)(),
701cdf0e10cSrcweir (_rHoriOrientFrm.Frm().*fnRect->fnGetLeft)() );
702cdf0e10cSrcweir _obAlignedRelToPage = true;
703cdf0e10cSrcweir break;
704cdf0e10cSrcweir }
705cdf0e10cSrcweir default:
706cdf0e10cSrcweir // case text::RelOrientation::FRAME:
707cdf0e10cSrcweir {
708cdf0e10cSrcweir nWidth = (_rHoriOrientFrm.Frm().*fnRect->fnGetWidth)();
709cdf0e10cSrcweir nOffset = _rHoriOrientFrm.IsTxtFrm() ?
710cdf0e10cSrcweir static_cast<const SwTxtFrm&>(_rHoriOrientFrm).GetBaseOfstForFly( !_bObjWrapThrough ) :
711cdf0e10cSrcweir 0;
712cdf0e10cSrcweir break;
713cdf0e10cSrcweir }
714cdf0e10cSrcweir }
715cdf0e10cSrcweir
716cdf0e10cSrcweir _orAlignAreaWidth = nWidth;
717cdf0e10cSrcweir _orAlignAreaOffset = nOffset;
718cdf0e10cSrcweir }
719cdf0e10cSrcweir
720cdf0e10cSrcweir /** toggle given horizontal orientation and relative alignment
721cdf0e10cSrcweir
722cdf0e10cSrcweir @author OD
723cdf0e10cSrcweir */
_ToggleHoriOrientAndAlign(const bool _bToggleLeftRight,sal_Int16 & _ioeHoriOrient,sal_Int16 & _iopeRelOrient) const724cdf0e10cSrcweir void SwAnchoredObjectPosition::_ToggleHoriOrientAndAlign(
725cdf0e10cSrcweir const bool _bToggleLeftRight,
726cdf0e10cSrcweir sal_Int16& _ioeHoriOrient,
727cdf0e10cSrcweir sal_Int16& _iopeRelOrient
728cdf0e10cSrcweir ) const
729cdf0e10cSrcweir {
730cdf0e10cSrcweir if( _bToggleLeftRight )
731cdf0e10cSrcweir {
732cdf0e10cSrcweir // toggle orientation
733cdf0e10cSrcweir switch ( _ioeHoriOrient )
734cdf0e10cSrcweir {
735cdf0e10cSrcweir case text::HoriOrientation::RIGHT :
736cdf0e10cSrcweir {
737cdf0e10cSrcweir _ioeHoriOrient = text::HoriOrientation::LEFT;
738cdf0e10cSrcweir }
739cdf0e10cSrcweir break;
740cdf0e10cSrcweir case text::HoriOrientation::LEFT :
741cdf0e10cSrcweir {
742cdf0e10cSrcweir _ioeHoriOrient = text::HoriOrientation::RIGHT;
743cdf0e10cSrcweir }
744cdf0e10cSrcweir break;
745cdf0e10cSrcweir default:
746cdf0e10cSrcweir break;
747cdf0e10cSrcweir }
748cdf0e10cSrcweir
749cdf0e10cSrcweir // toggle relative alignment
750cdf0e10cSrcweir switch ( _iopeRelOrient )
751cdf0e10cSrcweir {
752cdf0e10cSrcweir case text::RelOrientation::PAGE_RIGHT :
753cdf0e10cSrcweir {
754cdf0e10cSrcweir _iopeRelOrient = text::RelOrientation::PAGE_LEFT;
755cdf0e10cSrcweir }
756cdf0e10cSrcweir break;
757cdf0e10cSrcweir case text::RelOrientation::PAGE_LEFT :
758cdf0e10cSrcweir {
759cdf0e10cSrcweir _iopeRelOrient = text::RelOrientation::PAGE_RIGHT;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir break;
762cdf0e10cSrcweir case text::RelOrientation::FRAME_RIGHT :
763cdf0e10cSrcweir {
764cdf0e10cSrcweir _iopeRelOrient = text::RelOrientation::FRAME_LEFT;
765cdf0e10cSrcweir }
766cdf0e10cSrcweir break;
767cdf0e10cSrcweir case text::RelOrientation::FRAME_LEFT :
768cdf0e10cSrcweir {
769cdf0e10cSrcweir _iopeRelOrient = text::RelOrientation::FRAME_RIGHT;
770cdf0e10cSrcweir }
771cdf0e10cSrcweir break;
772cdf0e10cSrcweir default:
773cdf0e10cSrcweir break;
774cdf0e10cSrcweir }
775cdf0e10cSrcweir }
776cdf0e10cSrcweir }
777cdf0e10cSrcweir
778cdf0e10cSrcweir /** calculate relative horizontal position
779cdf0e10cSrcweir
780cdf0e10cSrcweir @author OD
781cdf0e10cSrcweir */
_CalcRelPosX(const SwFrm & _rHoriOrientFrm,const SwEnvironmentOfAnchoredObject & _rEnvOfObj,const SwFmtHoriOrient & _rHoriOrient,const SvxLRSpaceItem & _rLRSpacing,const SvxULSpaceItem & _rULSpacing,const bool _bObjWrapThrough,const SwTwips _nRelPosY,SwTwips & _roHoriOffsetToFrmAnchorPos) const782cdf0e10cSrcweir SwTwips SwAnchoredObjectPosition::_CalcRelPosX(
783cdf0e10cSrcweir const SwFrm& _rHoriOrientFrm,
784cdf0e10cSrcweir const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
785cdf0e10cSrcweir const SwFmtHoriOrient& _rHoriOrient,
786cdf0e10cSrcweir const SvxLRSpaceItem& _rLRSpacing,
787cdf0e10cSrcweir const SvxULSpaceItem& _rULSpacing,
788cdf0e10cSrcweir const bool _bObjWrapThrough,
789cdf0e10cSrcweir const SwTwips _nRelPosY,
790cdf0e10cSrcweir SwTwips& _roHoriOffsetToFrmAnchorPos
791cdf0e10cSrcweir ) const
792cdf0e10cSrcweir {
793cdf0e10cSrcweir // determine 'page' alignment layout frame
794cdf0e10cSrcweir const SwFrm& rPageAlignLayFrm =
795cdf0e10cSrcweir _rEnvOfObj.GetHoriEnvironmentLayoutFrm( _rHoriOrientFrm );
796cdf0e10cSrcweir
797cdf0e10cSrcweir const bool bEvenPage = !rPageAlignLayFrm.OnRightPage();
798cdf0e10cSrcweir const bool bToggle = _rHoriOrient.IsPosToggle() && bEvenPage;
799cdf0e10cSrcweir
800cdf0e10cSrcweir // determine orientation and relative alignment
801cdf0e10cSrcweir sal_Int16 eHoriOrient = _rHoriOrient.GetHoriOrient();
802cdf0e10cSrcweir sal_Int16 eRelOrient = _rHoriOrient.GetRelationOrient();
803cdf0e10cSrcweir // toggle orientation and relative alignment
804cdf0e10cSrcweir _ToggleHoriOrientAndAlign( bToggle, eHoriOrient, eRelOrient );
805cdf0e10cSrcweir
806cdf0e10cSrcweir // determine alignment parameter
807cdf0e10cSrcweir // <nWidth>: 'width' of alignment area
808cdf0e10cSrcweir // <nOffset>: offset of alignment area, relative to 'left' of anchor frame
809cdf0e10cSrcweir SwTwips nWidth = 0;
810cdf0e10cSrcweir SwTwips nOffset = 0;
811cdf0e10cSrcweir bool bAlignedRelToPage = false;
812cdf0e10cSrcweir _GetHoriAlignmentValues( _rHoriOrientFrm, rPageAlignLayFrm,
813cdf0e10cSrcweir eRelOrient, _bObjWrapThrough,
814cdf0e10cSrcweir nWidth, nOffset, bAlignedRelToPage );
815cdf0e10cSrcweir
816cdf0e10cSrcweir const SwFrm& rAnchorFrm = GetAnchorFrm();
817cdf0e10cSrcweir SWRECTFN( (&_rHoriOrientFrm) )
818cdf0e10cSrcweir SwTwips nObjWidth = (GetAnchoredObj().GetObjRect().*fnRect->fnGetWidth)();
819cdf0e10cSrcweir SwTwips nRelPosX = nOffset;
820cdf0e10cSrcweir if ( _rHoriOrient.GetHoriOrient() == text::HoriOrientation::NONE )
821cdf0e10cSrcweir {
822cdf0e10cSrcweir // 'manual' horizonal position
823cdf0e10cSrcweir const bool bR2L = rAnchorFrm.IsRightToLeft();
824cdf0e10cSrcweir if( IsAnchoredToChar() && text::RelOrientation::CHAR == eRelOrient )
825cdf0e10cSrcweir {
826cdf0e10cSrcweir if( bR2L )
827cdf0e10cSrcweir nRelPosX -= _rHoriOrient.GetPos();
828cdf0e10cSrcweir else
829cdf0e10cSrcweir nRelPosX += _rHoriOrient.GetPos();
830cdf0e10cSrcweir }
831cdf0e10cSrcweir else if ( bToggle || ( !_rHoriOrient.IsPosToggle() && bR2L ) )
832cdf0e10cSrcweir {
833cdf0e10cSrcweir // OD 04.08.2003 #110978# - correction: consider <nOffset> also for
834cdf0e10cSrcweir // toggling from left to right.
835cdf0e10cSrcweir nRelPosX += nWidth - nObjWidth - _rHoriOrient.GetPos();
836cdf0e10cSrcweir }
837cdf0e10cSrcweir else
838cdf0e10cSrcweir {
839cdf0e10cSrcweir nRelPosX += _rHoriOrient.GetPos();
840cdf0e10cSrcweir }
841cdf0e10cSrcweir }
842cdf0e10cSrcweir else if ( text::HoriOrientation::CENTER == eHoriOrient )
843cdf0e10cSrcweir nRelPosX += (nWidth / 2) - (nObjWidth / 2);
844cdf0e10cSrcweir else if ( text::HoriOrientation::RIGHT == eHoriOrient )
845cdf0e10cSrcweir nRelPosX += nWidth -
846cdf0e10cSrcweir ( nObjWidth +
847cdf0e10cSrcweir ( bVert ? _rULSpacing.GetLower() : _rLRSpacing.GetRight() ) );
848cdf0e10cSrcweir else
849cdf0e10cSrcweir nRelPosX += bVert ? _rULSpacing.GetUpper() : _rLRSpacing.GetLeft();
850cdf0e10cSrcweir
851cdf0e10cSrcweir // adjust relative position by distance between anchor frame and
852cdf0e10cSrcweir // the frame, the object is oriented at.
853cdf0e10cSrcweir if ( &rAnchorFrm != &_rHoriOrientFrm )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir SwTwips nLeftOrient = (_rHoriOrientFrm.Frm().*fnRect->fnGetLeft)();
856cdf0e10cSrcweir SwTwips nLeftAnchor = (rAnchorFrm.Frm().*fnRect->fnGetLeft)();
857cdf0e10cSrcweir nRelPosX += (*fnRect->fnXDiff)( nLeftOrient, nLeftAnchor );
858cdf0e10cSrcweir }
859cdf0e10cSrcweir
860cdf0e10cSrcweir // OD 2004-05-21 #i28701# - deactivate follow code
861cdf0e10cSrcweir // // adjust relative horizontal position, if object is manual horizontal
862cdf0e10cSrcweir // // positioned (not 'page' aligned) and orients not at the anchor frame,
863cdf0e10cSrcweir // // but it overlaps anchor frame.
864cdf0e10cSrcweir // if ( _rHoriOrient.GetHoriOrient() == text::HoriOrientation::NONE && !bAlignedRelToPage &&
865cdf0e10cSrcweir // &rAnchorFrm != &_rHoriOrientFrm )
866cdf0e10cSrcweir // {
867cdf0e10cSrcweir // // E.g.: consider a columned page/section with an horizontal
868cdf0e10cSrcweir // // negative positioned object.
869cdf0e10cSrcweir // // OD 2004-03-23 #i26791#
870cdf0e10cSrcweir // const SwRect& rObjRect = GetAnchoredObj().GetObjRect();
871cdf0e10cSrcweir // if( bVert )
872cdf0e10cSrcweir // {
873cdf0e10cSrcweir // if( _rHoriOrientFrm.Frm().Top() > rAnchorFrm.Frm().Bottom() &&
874cdf0e10cSrcweir // rObjRect.Right() > rAnchorFrm.Frm().Left() )
875cdf0e10cSrcweir // {
876cdf0e10cSrcweir // const SwTwips nProposedPosX = nRelPosX + rAnchorFrm.Frm().Top();
877cdf0e10cSrcweir // if ( nProposedPosX < rAnchorFrm.Frm().Bottom() )
878cdf0e10cSrcweir // nRelPosX = rAnchorFrm.Frm().Height() + 1;
879cdf0e10cSrcweir // }
880cdf0e10cSrcweir // }
881cdf0e10cSrcweir // else
882cdf0e10cSrcweir // {
883cdf0e10cSrcweir // if( _rHoriOrientFrm.Frm().Left() > rAnchorFrm.Frm().Right() &&
884cdf0e10cSrcweir // rObjRect.Top() < rAnchorFrm.Frm().Bottom() )
885cdf0e10cSrcweir // {
886cdf0e10cSrcweir // // OD 04.08.2003 #110978# - correction: use <nRelPosX>
887cdf0e10cSrcweir // // instead of <aRelPos.X()>
888cdf0e10cSrcweir // const SwTwips nProposedPosX = nRelPosX + rAnchorFrm.Frm().Left();
889cdf0e10cSrcweir // if ( nProposedPosX < rAnchorFrm.Frm().Right() )
890cdf0e10cSrcweir // nRelPosX = rAnchorFrm.Frm().Width() + 1;
891cdf0e10cSrcweir // }
892cdf0e10cSrcweir // }
893cdf0e10cSrcweir // }
894cdf0e10cSrcweir // adjust calculated relative horizontal position, in order to
895cdf0e10cSrcweir // keep object inside 'page' alignment layout frame
896cdf0e10cSrcweir const SwFrm& rEnvironmentLayFrm =
897cdf0e10cSrcweir _rEnvOfObj.GetHoriEnvironmentLayoutFrm( _rHoriOrientFrm );
898cdf0e10cSrcweir nRelPosX = _AdjustHoriRelPos( rEnvironmentLayFrm, nRelPosX );
899cdf0e10cSrcweir
900cdf0e10cSrcweir // if object is a Writer fly frame and it's anchored to a content and
901cdf0e10cSrcweir // it is horizontal positioned left or right, but not relative to character,
902cdf0e10cSrcweir // it has to be drawn aside another object, which have the same horizontal
903cdf0e10cSrcweir // position and lay below it.
904cdf0e10cSrcweir if ( GetAnchoredObj().ISA(SwFlyFrm) &&
905cdf0e10cSrcweir ( GetContact().ObjAnchoredAtPara() || GetContact().ObjAnchoredAtChar() ) &&
906cdf0e10cSrcweir ( eHoriOrient == text::HoriOrientation::LEFT || eHoriOrient == text::HoriOrientation::RIGHT ) &&
907cdf0e10cSrcweir eRelOrient != text::RelOrientation::CHAR )
908cdf0e10cSrcweir {
909cdf0e10cSrcweir nRelPosX = _AdjustHoriRelPosForDrawAside( _rHoriOrientFrm,
910cdf0e10cSrcweir nRelPosX, _nRelPosY,
911cdf0e10cSrcweir eHoriOrient, eRelOrient,
912cdf0e10cSrcweir _rLRSpacing, _rULSpacing,
913cdf0e10cSrcweir bEvenPage );
914cdf0e10cSrcweir }
915cdf0e10cSrcweir
916cdf0e10cSrcweir // --> OD 2004-06-17 #i26791#
917cdf0e10cSrcweir _roHoriOffsetToFrmAnchorPos = nOffset;
918cdf0e10cSrcweir
919cdf0e10cSrcweir return nRelPosX;
920cdf0e10cSrcweir }
921cdf0e10cSrcweir
922cdf0e10cSrcweir // **************************************************************************
923cdf0e10cSrcweir // method incl. helper methods for adjusting proposed horizontal position,
924cdf0e10cSrcweir // if object has to draw aside another object.
925cdf0e10cSrcweir // **************************************************************************
926cdf0e10cSrcweir /** adjust calculated horizontal position in order to draw object
927cdf0e10cSrcweir aside other objects with same positioning
928cdf0e10cSrcweir
929cdf0e10cSrcweir @author OD
930cdf0e10cSrcweir */
_AdjustHoriRelPosForDrawAside(const SwFrm & _rHoriOrientFrm,const SwTwips _nProposedRelPosX,const SwTwips _nRelPosY,const sal_Int16 _eHoriOrient,const sal_Int16 _eRelOrient,const SvxLRSpaceItem & _rLRSpacing,const SvxULSpaceItem & _rULSpacing,const bool _bEvenPage) const931cdf0e10cSrcweir SwTwips SwAnchoredObjectPosition::_AdjustHoriRelPosForDrawAside(
932cdf0e10cSrcweir const SwFrm& _rHoriOrientFrm,
933cdf0e10cSrcweir const SwTwips _nProposedRelPosX,
934cdf0e10cSrcweir const SwTwips _nRelPosY,
935cdf0e10cSrcweir const sal_Int16 _eHoriOrient,
936cdf0e10cSrcweir const sal_Int16 _eRelOrient,
937cdf0e10cSrcweir const SvxLRSpaceItem& _rLRSpacing,
938cdf0e10cSrcweir const SvxULSpaceItem& _rULSpacing,
939cdf0e10cSrcweir const bool _bEvenPage
940cdf0e10cSrcweir ) const
941cdf0e10cSrcweir {
942cdf0e10cSrcweir // OD 2004-03-23 #i26791#
943cdf0e10cSrcweir if ( !GetAnchorFrm().ISA(SwTxtFrm) ||
944cdf0e10cSrcweir !GetAnchoredObj().ISA(SwFlyAtCntFrm) )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir ASSERT( false,
947cdf0e10cSrcweir "<SwAnchoredObjectPosition::_AdjustHoriRelPosForDrawAside(..) - usage for wrong anchor type" );
948cdf0e10cSrcweir return _nProposedRelPosX;
949cdf0e10cSrcweir }
950cdf0e10cSrcweir
951cdf0e10cSrcweir const SwTxtFrm& rAnchorTxtFrm = static_cast<const SwTxtFrm&>(GetAnchorFrm());
952cdf0e10cSrcweir // OD 2004-03-23 #i26791#
953cdf0e10cSrcweir const SwFlyAtCntFrm& rFlyAtCntFrm =
954cdf0e10cSrcweir static_cast<const SwFlyAtCntFrm&>(GetAnchoredObj());
955cdf0e10cSrcweir const SwRect aObjBoundRect( GetAnchoredObj().GetObjRect() );
956cdf0e10cSrcweir SWRECTFN( (&_rHoriOrientFrm) )
957cdf0e10cSrcweir
958cdf0e10cSrcweir SwTwips nAdjustedRelPosX = _nProposedRelPosX;
959cdf0e10cSrcweir
960cdf0e10cSrcweir // determine proposed object bound rectangle
961cdf0e10cSrcweir Point aTmpPos = (rAnchorTxtFrm.Frm().*fnRect->fnGetPos)();
962cdf0e10cSrcweir if( bVert )
963cdf0e10cSrcweir {
964cdf0e10cSrcweir aTmpPos.X() -= _nRelPosY + aObjBoundRect.Width();
965cdf0e10cSrcweir aTmpPos.Y() += nAdjustedRelPosX;
966cdf0e10cSrcweir }
967cdf0e10cSrcweir else
968cdf0e10cSrcweir {
969cdf0e10cSrcweir aTmpPos.X() += nAdjustedRelPosX;
970cdf0e10cSrcweir aTmpPos.Y() += _nRelPosY;
971cdf0e10cSrcweir }
972cdf0e10cSrcweir SwRect aTmpObjRect( aTmpPos, aObjBoundRect.SSize() );
973cdf0e10cSrcweir
974cdf0e10cSrcweir const sal_uInt32 nObjOrdNum = GetObject().GetOrdNum();
975cdf0e10cSrcweir const SwPageFrm* pObjPage = rFlyAtCntFrm.FindPageFrm();
976cdf0e10cSrcweir const SwFrm* pObjContext = ::FindKontext( &rAnchorTxtFrm, FRM_COLUMN );
977cdf0e10cSrcweir sal_uLong nObjIndex = rAnchorTxtFrm.GetTxtNode()->GetIndex();
978cdf0e10cSrcweir SwOrderIter aIter( pObjPage, sal_True );
979cdf0e10cSrcweir const SwFlyFrm* pFly = ((SwVirtFlyDrawObj*)aIter.Bottom())->GetFlyFrm();
980cdf0e10cSrcweir while ( pFly && nObjOrdNum > pFly->GetVirtDrawObj()->GetOrdNumDirect() )
981cdf0e10cSrcweir {
982cdf0e10cSrcweir if ( _DrawAsideFly( pFly, aTmpObjRect, pObjContext, nObjIndex,
983cdf0e10cSrcweir _bEvenPage, _eHoriOrient, _eRelOrient ) )
984cdf0e10cSrcweir {
985cdf0e10cSrcweir if( bVert )
986cdf0e10cSrcweir {
987cdf0e10cSrcweir const SvxULSpaceItem& rOtherUL = pFly->GetFmt()->GetULSpace();
988cdf0e10cSrcweir const SwTwips nOtherTop = pFly->Frm().Top() - rOtherUL.GetUpper();
989cdf0e10cSrcweir const SwTwips nOtherBot = pFly->Frm().Bottom() + rOtherUL.GetLower();
990cdf0e10cSrcweir if ( nOtherTop <= aTmpObjRect.Bottom() + _rULSpacing.GetLower() &&
991cdf0e10cSrcweir nOtherBot >= aTmpObjRect.Top() - _rULSpacing.GetUpper() )
992cdf0e10cSrcweir {
993cdf0e10cSrcweir if ( _eHoriOrient == text::HoriOrientation::LEFT )
994cdf0e10cSrcweir {
995cdf0e10cSrcweir SwTwips nTmp = nOtherBot + 1 + _rULSpacing.GetUpper() -
996cdf0e10cSrcweir rAnchorTxtFrm.Frm().Top();
997cdf0e10cSrcweir if ( nTmp > nAdjustedRelPosX &&
998cdf0e10cSrcweir rAnchorTxtFrm.Frm().Top() + nTmp +
999cdf0e10cSrcweir aObjBoundRect.Height() + _rULSpacing.GetLower()
1000cdf0e10cSrcweir <= pObjPage->Frm().Height() + pObjPage->Frm().Top() )
1001cdf0e10cSrcweir {
1002cdf0e10cSrcweir nAdjustedRelPosX = nTmp;
1003cdf0e10cSrcweir }
1004cdf0e10cSrcweir }
1005cdf0e10cSrcweir else if ( _eHoriOrient == text::HoriOrientation::RIGHT )
1006cdf0e10cSrcweir {
1007cdf0e10cSrcweir SwTwips nTmp = nOtherTop - 1 - _rULSpacing.GetLower() -
1008cdf0e10cSrcweir aObjBoundRect.Height() -
1009cdf0e10cSrcweir rAnchorTxtFrm.Frm().Top();
1010cdf0e10cSrcweir if ( nTmp < nAdjustedRelPosX &&
1011cdf0e10cSrcweir rAnchorTxtFrm.Frm().Top() + nTmp - _rULSpacing.GetUpper()
1012cdf0e10cSrcweir >= pObjPage->Frm().Top() )
1013cdf0e10cSrcweir {
1014cdf0e10cSrcweir nAdjustedRelPosX = nTmp;
1015cdf0e10cSrcweir }
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir aTmpObjRect.Pos().Y() = rAnchorTxtFrm.Frm().Top() +
1018cdf0e10cSrcweir nAdjustedRelPosX;
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir }
1021cdf0e10cSrcweir else
1022cdf0e10cSrcweir {
1023cdf0e10cSrcweir const SvxLRSpaceItem& rOtherLR = pFly->GetFmt()->GetLRSpace();
1024cdf0e10cSrcweir const SwTwips nOtherLeft = pFly->Frm().Left() - rOtherLR.GetLeft();
1025cdf0e10cSrcweir const SwTwips nOtherRight = pFly->Frm().Right() + rOtherLR.GetRight();
1026cdf0e10cSrcweir if( nOtherLeft <= aTmpObjRect.Right() + _rLRSpacing.GetRight() &&
1027cdf0e10cSrcweir nOtherRight >= aTmpObjRect.Left() - _rLRSpacing.GetLeft() )
1028cdf0e10cSrcweir {
1029cdf0e10cSrcweir if ( _eHoriOrient == text::HoriOrientation::LEFT )
1030cdf0e10cSrcweir {
1031cdf0e10cSrcweir SwTwips nTmp = nOtherRight + 1 + _rLRSpacing.GetLeft() -
1032cdf0e10cSrcweir rAnchorTxtFrm.Frm().Left();
1033cdf0e10cSrcweir if ( nTmp > nAdjustedRelPosX &&
1034cdf0e10cSrcweir rAnchorTxtFrm.Frm().Left() + nTmp +
1035cdf0e10cSrcweir aObjBoundRect.Width() + _rLRSpacing.GetRight()
1036cdf0e10cSrcweir <= pObjPage->Frm().Width() + pObjPage->Frm().Left() )
1037cdf0e10cSrcweir {
1038cdf0e10cSrcweir nAdjustedRelPosX = nTmp;
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir }
1041cdf0e10cSrcweir else if ( _eHoriOrient == text::HoriOrientation::RIGHT )
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir SwTwips nTmp = nOtherLeft - 1 - _rLRSpacing.GetRight() -
1044cdf0e10cSrcweir aObjBoundRect.Width() -
1045cdf0e10cSrcweir rAnchorTxtFrm.Frm().Left();
1046cdf0e10cSrcweir if ( nTmp < nAdjustedRelPosX &&
1047cdf0e10cSrcweir rAnchorTxtFrm.Frm().Left() + nTmp - _rLRSpacing.GetLeft()
1048cdf0e10cSrcweir >= pObjPage->Frm().Left() )
1049cdf0e10cSrcweir {
1050cdf0e10cSrcweir nAdjustedRelPosX = nTmp;
1051cdf0e10cSrcweir }
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir aTmpObjRect.Pos().X() = rAnchorTxtFrm.Frm().Left() +
1054cdf0e10cSrcweir nAdjustedRelPosX;
1055cdf0e10cSrcweir }
1056cdf0e10cSrcweir } // end of <if (bVert)>
1057cdf0e10cSrcweir } // end of <if _DrawAsideFly(..)>
1058cdf0e10cSrcweir
1059cdf0e10cSrcweir pFly = ((SwVirtFlyDrawObj*)aIter.Next())->GetFlyFrm();
1060cdf0e10cSrcweir } // end of <loop on fly frames
1061cdf0e10cSrcweir
1062cdf0e10cSrcweir return nAdjustedRelPosX;
1063cdf0e10cSrcweir }
1064cdf0e10cSrcweir
1065cdf0e10cSrcweir /** detemine, if object has to draw aside given fly frame
1066cdf0e10cSrcweir
1067cdf0e10cSrcweir method used by <_AdjustHoriRelPosForDrawAside(..)>
1068cdf0e10cSrcweir
1069cdf0e10cSrcweir @author OD
1070cdf0e10cSrcweir */
_DrawAsideFly(const SwFlyFrm * _pFly,const SwRect & _rObjRect,const SwFrm * _pObjContext,const sal_uLong _nObjIndex,const bool _bEvenPage,const sal_Int16 _eHoriOrient,const sal_Int16 _eRelOrient) const1071cdf0e10cSrcweir bool SwAnchoredObjectPosition::_DrawAsideFly( const SwFlyFrm* _pFly,
1072cdf0e10cSrcweir const SwRect& _rObjRect,
1073cdf0e10cSrcweir const SwFrm* _pObjContext,
1074cdf0e10cSrcweir const sal_uLong _nObjIndex,
1075cdf0e10cSrcweir const bool _bEvenPage,
1076cdf0e10cSrcweir const sal_Int16 _eHoriOrient,
1077cdf0e10cSrcweir const sal_Int16 _eRelOrient
1078cdf0e10cSrcweir ) const
1079cdf0e10cSrcweir {
1080cdf0e10cSrcweir bool bRetVal = false;
1081cdf0e10cSrcweir
1082cdf0e10cSrcweir SWRECTFN( (&GetAnchorFrm()) )
1083cdf0e10cSrcweir
1084cdf0e10cSrcweir if ( _pFly->IsFlyAtCntFrm() &&
1085cdf0e10cSrcweir (_pFly->Frm().*fnRect->fnBottomDist)( (_rObjRect.*fnRect->fnGetTop)() ) < 0 &&
1086cdf0e10cSrcweir (_rObjRect.*fnRect->fnBottomDist)( (_pFly->Frm().*fnRect->fnGetTop)() ) < 0 &&
1087cdf0e10cSrcweir ::FindKontext( _pFly->GetAnchorFrm(), FRM_COLUMN ) == _pObjContext )
1088cdf0e10cSrcweir {
1089cdf0e10cSrcweir sal_uLong nOtherIndex =
1090cdf0e10cSrcweir static_cast<const SwTxtFrm*>(_pFly->GetAnchorFrm())->GetTxtNode()->GetIndex();
1091cdf0e10cSrcweir if( _nObjIndex >= nOtherIndex )
1092cdf0e10cSrcweir {
1093cdf0e10cSrcweir const SwFmtHoriOrient& rHori = _pFly->GetFmt()->GetHoriOrient();
1094cdf0e10cSrcweir sal_Int16 eOtherRelOrient = rHori.GetRelationOrient();
1095cdf0e10cSrcweir if( text::RelOrientation::CHAR != eOtherRelOrient )
1096cdf0e10cSrcweir {
1097cdf0e10cSrcweir sal_Int16 eOtherHoriOrient = rHori.GetHoriOrient();
1098cdf0e10cSrcweir _ToggleHoriOrientAndAlign( _bEvenPage && rHori.IsPosToggle(),
1099cdf0e10cSrcweir eOtherHoriOrient,
1100cdf0e10cSrcweir eOtherRelOrient );
1101cdf0e10cSrcweir if ( eOtherHoriOrient == _eHoriOrient &&
1102cdf0e10cSrcweir _Minor( _eRelOrient, eOtherRelOrient, text::HoriOrientation::LEFT == _eHoriOrient ) )
1103cdf0e10cSrcweir {
1104cdf0e10cSrcweir bRetVal = true;
1105cdf0e10cSrcweir }
1106cdf0e10cSrcweir }
1107cdf0e10cSrcweir }
1108cdf0e10cSrcweir }
1109cdf0e10cSrcweir
1110cdf0e10cSrcweir return bRetVal;
1111cdf0e10cSrcweir }
1112cdf0e10cSrcweir
1113cdf0e10cSrcweir /** determine, if object has to draw aside another object
1114cdf0e10cSrcweir
1115cdf0e10cSrcweir the different alignments of the objects determines, if one has
1116cdf0e10cSrcweir to draw aside another one. Thus, the given alignment are checked
1117cdf0e10cSrcweir against each other, which one has to be drawn aside the other one.
1118cdf0e10cSrcweir depending on parameter _bLeft check is done for left or right
1119cdf0e10cSrcweir positioning.
1120cdf0e10cSrcweir method used by <_DrawAsideFly(..)>
1121cdf0e10cSrcweir
1122cdf0e10cSrcweir @author OD
1123cdf0e10cSrcweir */
_Minor(sal_Int16 _eRelOrient1,sal_Int16 _eRelOrient2,bool _bLeft) const1124cdf0e10cSrcweir bool SwAnchoredObjectPosition::_Minor( sal_Int16 _eRelOrient1,
1125cdf0e10cSrcweir sal_Int16 _eRelOrient2,
1126cdf0e10cSrcweir bool _bLeft ) const
1127cdf0e10cSrcweir {
1128cdf0e10cSrcweir bool bRetVal;
1129cdf0e10cSrcweir
1130cdf0e10cSrcweir // draw aside order for left horizontal position
1131cdf0e10cSrcweir //! one array entry for each value in text::RelOrientation
1132cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA aLeft[ 10 ] =
1133cdf0e10cSrcweir { 5, 6, 0, 1, 8, 4, 7, 2, 3, 9 };
1134cdf0e10cSrcweir // draw aside order for right horizontal position
1135cdf0e10cSrcweir //! one array entry for each value in text::RelOrientation
1136cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA aRight[ 10 ] =
1137cdf0e10cSrcweir { 5, 6, 0, 8, 1, 7, 4, 2, 3, 9 };
1138cdf0e10cSrcweir
1139cdf0e10cSrcweir // decide depending on given order, which frame has to draw aside another frame
1140cdf0e10cSrcweir if( _bLeft )
1141cdf0e10cSrcweir bRetVal = aLeft[ _eRelOrient1 ] >= aLeft[ _eRelOrient2 ];
1142cdf0e10cSrcweir else
1143cdf0e10cSrcweir bRetVal = aRight[ _eRelOrient1 ] >= aRight[ _eRelOrient2 ];
1144cdf0e10cSrcweir
1145cdf0e10cSrcweir return bRetVal;
1146cdf0e10cSrcweir }
1147