1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_ANCHOREDOBJECTPOSITION_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_ANCHOREDOBJECTPOSITION_HXX
23 #include <swtypes.hxx>
33 class SwFormatHoriOrient
;
34 class SwAnchoredObject
;
36 namespace objectpositioning
38 class SwEnvironmentOfAnchoredObject
;
40 class SwAnchoredObjectPosition
43 // object to be positioned
45 // #i26791# - anchored object the object belongs to;
46 SwAnchoredObject
* mpAnchoredObj
;
47 // frame the object is anchored at
48 SwFrame
* mpAnchorFrame
;
52 const SwFrameFormat
* mpFrameFormat
;
53 // does the object represents a Writer fly frame
56 bool mbFollowTextFlow
;
58 // for compatibility option <DoNotCaptureDrawObjsOnPage>
59 bool mbDoNotCaptureAnchoredObj
;
61 /** determine information about object
63 member <mbIsObjFly>, <mpAnchoredObj>, <mpAnchorFrame>, <mpContact>
64 and <mpFrameFormat> are set
66 void GetInfoAboutObj();
69 // --> OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
70 SwTwips
ImplAdjustVertRelPos( const SwTwips nTopOfAnch
,
73 const SwFrame
& rPageAlignLayFrame
,
74 const SwTwips nProposedRelPosY
,
75 const bool bFollowTextFlow
,
76 const bool bCheckBottom
) const;
77 SwTwips
ImplAdjustHoriRelPos( const SwFrame
& _rPageAlignLayFrame
,
78 const SwTwips _nProposedRelPosX
) const;
81 SwAnchoredObjectPosition( SdrObject
& _rDrawObj
);
82 virtual ~SwAnchoredObjectPosition();
84 // accessors for object and its corresponding data/information
85 SdrObject
& GetObject() const
93 SwAnchoredObject
& GetAnchoredObj() const
95 return *mpAnchoredObj
;
97 SwFrame
& GetAnchorFrame() const
99 return *mpAnchorFrame
;
101 const SwFrameFormat
& GetFrameFormat() const
103 return *mpFrameFormat
;
106 bool DoesObjFollowsTextFlow() const
108 return mbFollowTextFlow
;
111 // virtual methods providing data for to character anchored objects.
112 virtual bool IsAnchoredToChar() const;
113 virtual const SwFrame
* ToCharOrientFrame() const;
114 virtual const SwRect
* ToCharRect() const;
116 virtual SwTwips
ToCharTopOfLine() const;
118 /** helper method to determine top of a frame for the vertical object
123 SwTwips
GetTopForObjPos( const SwFrame
& _rFrame
,
124 const SwRectFn
& _fnRect
,
125 const bool _bVert
) const;
127 void GetVertAlignmentValues( const SwFrame
& _rVertOrientFrame
,
128 const SwFrame
& _rPageAlignLayFrame
,
129 const sal_Int16 _eRelOrient
,
130 SwTwips
& _orAlignAreaHeight
,
131 SwTwips
& _orAlignAreaOffset
) const;
133 // #i26791# - add output parameter <_roVertOffsetToFrameAnchorPos>
134 SwTwips
GetVertRelPos( const SwFrame
& _rVertOrientFrame
,
135 const SwFrame
& _rPageAlignLayFrame
,
136 const sal_Int16 _eVertOrient
,
137 const sal_Int16 _eRelOrient
,
138 const SwTwips _nVertPos
,
139 const SvxLRSpaceItem
& _rLRSpacing
,
140 const SvxULSpaceItem
& _rULSpacing
,
141 SwTwips
& _roVertOffsetToFrameAnchorPos
) const;
143 /** adjust calculated vertical in order to keep object inside
144 'page' alignment layout frame.
146 #i31805# - add parameter <_bCheckBottom>
147 #i26945# - add parameter <_bFollowTextFlow>
148 #i62875# - made inline, intrinsic actions moved
149 to private method <ImplAdjustVertRelPos>, which is only
150 called, if <mbDoNotCaptureAnchoredObj> not set.
151 OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
154 input parameter - 'vertical' position, at which the relative
155 position of the object is calculated from.
158 input parameter - boolean, indicating, if object is in vertical
162 input parameter - boolean, indicating, if object is in mongolian
163 layout (vertical left-to-right layout).
165 @param rPageAlignLayFrame
166 input parameter - layout frame, which determines the 'page area'
167 the object has to be vertical positioned in.
169 @param nProposedRelPosY
170 input parameter - proposed relative vertical position, which
173 @param bFollowTextFlow
174 input parameter - value of attribute 'Follow text flow' of the
178 input parameter - boolean indicating, if bottom of anchored
179 object has to be checked and thus, (if needed) the proposed
180 relative position has to be adjusted. default value <true>
182 SwTwips
AdjustVertRelPos( const SwTwips nTopOfAnch
,
185 const SwFrame
& rPageAlignLayFrame
,
186 const SwTwips nProposedRelPosY
,
187 const bool bFollowTextFlow
,
188 const bool bCheckBottom
= true ) const
190 return !mbDoNotCaptureAnchoredObj
191 ? ImplAdjustVertRelPos( nTopOfAnch
, bVert
, bVertL2R
,
199 /** calculate relative horizontal position
201 #i26791# - add output parameter
202 <_roHoriOffsetToFrameAnchorPos>
204 @param _rHoriOrientFrame
205 input parameter - frame the horizontal position of the object
209 input parameter - object instance to retrieve environment
210 information about the object
213 input parameter - horizontal positioning and alignment, for which
214 the relative position is calculated.
217 input parameter - left and right spacing of the object to the text
220 input parameter - upper and lower spacing of the object to the text
222 @param _bObjWrapThrough
223 input parameter - boolean indicating, if object has wrap mode
227 input parameter - relative vertical position
229 @param _roHoriOffsetToFrameAnchorPos
230 output parameter - 'horizontal' offset to frame anchor position
231 according to the alignment
233 @return relative horizontal position in SwTwips
235 SwTwips
CalcRelPosX( const SwFrame
& _rHoriOrientFrame
,
236 const SwEnvironmentOfAnchoredObject
& _rEnvOfObj
,
237 const SwFormatHoriOrient
& _rHoriOrient
,
238 const SvxLRSpaceItem
& _rLRSpacing
,
239 const SvxULSpaceItem
& _rULSpacing
,
240 const bool _bObjWrapThrough
,
241 const SwTwips _nRelPosY
,
242 SwTwips
& _roHoriOffsetToFrameAnchorPos
245 /** adjust calculated horizontal in order to keep object inside
246 'page' alignment layout frame for object type position TO_CNTNT
248 #i62875# - made inline, intrinsic actions moved
249 to private method <ImplAdjustHoriRelPos>, which is only
250 called, if <mbDoNotCaptureAnchoredObj> not set.
252 @param _rPageAlignLayFrame
253 input parameter - layout frame, which determines the 'page area'
254 the object has to be horizontal positioned in.
256 @param _nProposedRelPosX
257 input parameter - proposed relative horizontal position, which
260 @return adjusted relative horizontal position in SwTwips.
262 SwTwips
AdjustHoriRelPos( const SwFrame
& _rPageAlignLayFrame
,
263 const SwTwips _nProposedRelPosX
) const
265 return !mbDoNotCaptureAnchoredObj
266 ? ImplAdjustHoriRelPos( _rPageAlignLayFrame
, _nProposedRelPosX
)
270 /** toggle given horizontal orientation and relative alignment
272 @param _bToggleLeftRight
273 input parameter - boolean indicating, if horizontal orientation
274 and relative alignment has to be toggled.
276 @param _ioeHoriOrient
277 input/output parameter - horizontal orientation, that is toggled,
280 @param _iopeRelOrient
281 optional input/output parameter (default value NULL)
282 - if set, relative alignment, that is toggled, if needed.
284 static void ToggleHoriOrientAndAlign( const bool _bToggleLeftRight
,
285 sal_Int16
& _ioeHoriOrient
,
286 sal_Int16
& _iopeRelOrient
289 /** determine alignment values for horizontal position of object
291 @param _rHoriOrientFrame
292 input parameter - frame the horizontal position of the object
295 @param _rPageAlignLayFrame
296 input parameter - layout frame, which determines the 'page area'
297 the object has to be horizontal positioned in.
300 input parameter - horizontal relative alignment, for which
301 the relative position is calculated.
303 @param _bToggleLeftRight
304 input parameter - boolean indicating, if left/right alignments
307 @param _bObjWrapThrough
308 input parameter - boolean indicating, if object has wrap mode
310 important note: value is only relevant, if _rHoriOrientFrame is
313 @param _orAlignAreaWidth
314 output parameter - width in SwTwips of the area the horizontal
315 position is aligned to.
317 @param _orAlignAreaOffset
318 output parameter - offset in SwTwips of the area the horizontal
319 position is aligned to. offset is given to the 'left' of the
322 @param _obAlignedRelToPage
323 output parameter - boolean indicating, that object is aligned
326 void GetHoriAlignmentValues( const SwFrame
& _rHoriOrientFrame
,
327 const SwFrame
& _rPageAlignLayFrame
,
328 const sal_Int16 _eRelOrient
,
329 const bool _bObjWrapThrough
,
330 SwTwips
& _orAlignAreaWidth
,
331 SwTwips
& _orAlignAreaOffset
,
332 bool& _obAlignedRelToPage
) const;
334 /** adjust calculated horizontal position in order to draw object
335 aside other objects with same positioning
337 @param _rHoriOrientFrame
338 input parameter - frame the horizontal position of the object
341 @param _nProposedRelPosX
342 input parameter - proposed relative horizontal position, which
346 input parameter - relative vertical position
349 input parameter - horizontal position of object
352 input parameter - alignment of object
355 input parameter - left and right spacing of the object to the text
358 input parameter - upper and lower spacing of the object to the text
361 input parameter - boolean indicating, if object is on an even page.
363 @return adjusted relative horizontal position in SwTwips
365 SwTwips
AdjustHoriRelPosForDrawAside( const SwFrame
& _rHoriOrientFrame
,
366 const SwTwips _nProposedRelPosX
,
367 const SwTwips _nRelPosY
,
368 const sal_Int16 _eHoriOrient
,
369 const sal_Int16 _eRelOrient
,
370 const SvxLRSpaceItem
& _rLRSpacing
,
371 const SvxULSpaceItem
& _rULSpacing
,
372 const bool _bEvenPage
375 /** determine, if object has to draw aside given fly frame
377 method used by <AdjustHoriRelPosForDrawAside(..)>
380 input parameter - fly frame the draw aside check is done for.
383 input parameter - proposed object rectangle
386 input parameter - context of the object
389 input parameter - index of the anchor frame of the object
392 input parameter - boolean indicating, if object is on an even page.
395 input parameter - horizontal position of object
398 input parameter - alignment of object
400 @return boolean indicating, if object has to be drawn aside
403 bool DrawAsideFly( const SwFlyFrame
* _pFly
,
404 const SwRect
& _rObjRect
,
405 const SwFrame
* _pObjContext
,
406 const sal_uLong _nObjIndex
,
407 const bool _bEvenPage
,
408 const sal_Int16 _eHoriOrient
,
409 const sal_Int16 _eRelOrient
412 /** determine, if object has to draw aside another object
414 the different alignments of the objects determines, if one has
415 to draw aside another one. Thus, the given alignment are checked
416 against each other, which one has to be drawn aside the other one.
417 depending on parameter _bLeft check is done for left or right
419 method used by <DrawAsideFly(..)>
422 input parameter - alignment 1
425 input parameter - alignment 2
428 input parameter - boolean indicating, if check is done for left
429 or for right positioning.
431 @return boolean indicating, if an object with an alignment
432 <_eRelOrient1> has to be drawn aside an object with an
433 alignment <_eRelOrient2>
435 static bool Minor_( sal_Int16 _eRelOrient1
,
436 sal_Int16 _eRelOrient2
,
440 virtual void CalcPosition() = 0;
446 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */