update dev300-m58
[ooovba.git] / sw / source / core / inc / anchoredobjectposition.hxx
blob8c98a1f89c8fc7414271010f805505d69ca7bdbd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: anchoredobjectposition.hxx,v $
10 * $Revision: 1.12.214.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _ANCHOREDOBJECTPOSITION_HXX
31 #define _ANCHOREDOBJECTPOSITION_HXX
33 #include <swtypes.hxx>
34 // OD 2004-03-16 #i11860#
35 #include <frame.hxx>
37 class SdrObject;
38 class SwFrm;
39 class SwFlyFrm;
40 class SwContact;
41 class SwFrmFmt;
42 class SwRect;
43 class SvxLRSpaceItem;
44 class SvxULSpaceItem;
45 class SwFmtHoriOrient;
46 // OD 2004-03-23 #i26701#
47 class SwAnchoredObject;
49 namespace objectpositioning
51 class SwEnvironmentOfAnchoredObject;
53 class SwAnchoredObjectPosition
55 private:
56 // object to be positioned
57 SdrObject& mrDrawObj;
59 // information about object
60 // does the object represents a Writer fly frame
61 bool mbIsObjFly;
62 // OD 2004-03-23 #i26791# - anchored object the object belongs to;
63 SwAnchoredObject* mpAnchoredObj;
64 // frame the object is anchored at
65 SwFrm* mpAnchorFrm;
66 // contact object
67 SwContact* mpContact;
68 // frame format
69 const SwFrmFmt* mpFrmFmt;
70 // --> OD 2006-03-15 #i62875#
71 bool mbFollowTextFlow;
72 // <--
73 // --> OD 2006-03-15 #i62875#
74 // for compatibility option <DoNotCaptureDrawObjsOnPage>
75 bool mbDoNotCaptureAnchoredObj;
76 // <--
78 /** determine information about object
80 OD 30.07.2003 #110978#
81 member <mbIsObjFly>, <mpAnchoredObj>, <mpAnchorFrm>, <mpContact>
82 and <mpFrmFmt> are set
84 @author OD
86 void _GetInfoAboutObj();
88 // --> OD 2006-03-15 #i62875#
89 SwTwips _ImplAdjustVertRelPos( const SwTwips _nTopOfAnch,
90 const bool _bVert,
91 const SwFrm& _rPageAlignLayFrm,
92 const SwTwips _nProposedRelPosY,
93 const bool _bFollowTextFlow,
94 const bool _bCheckBottom = true ) const;
95 SwTwips _ImplAdjustHoriRelPos( const SwFrm& _rPageAlignLayFrm,
96 const SwTwips _nProposedRelPosX ) const;
97 // <--
99 protected:
100 SwAnchoredObjectPosition( SdrObject& _rDrawObj );
101 virtual ~SwAnchoredObjectPosition();
103 // accessors for object and its corresponding data/information
104 inline SdrObject& GetObject() const
106 return mrDrawObj;
108 inline bool IsObjFly() const
110 return mbIsObjFly;
112 inline SwAnchoredObject& GetAnchoredObj() const
114 return *mpAnchoredObj;
116 inline SwFrm& GetAnchorFrm() const
118 return *mpAnchorFrm;
120 inline SwContact& GetContact() const
122 return *mpContact;
124 inline const SwFrmFmt& GetFrmFmt() const
126 return *mpFrmFmt;
128 // --> OD 2006-03-15 #i62875#
129 inline bool DoesObjFollowsTextFlow() const
131 return mbFollowTextFlow;
133 // <--
135 // virtual methods providing data for to character anchored objects.
136 virtual bool IsAnchoredToChar() const;
137 virtual const SwFrm* ToCharOrientFrm() const;
138 virtual const SwRect* ToCharRect() const;
139 // OD 12.11.2003 #i22341#
140 virtual SwTwips ToCharTopOfLine() const;
142 // *********************************************************************
143 /** helper method to determine top of a frame for the vertical
144 object positioning
146 OD 2004-03-11 #i11860#
148 @author OD
150 SwTwips _GetTopForObjPos( const SwFrm& _rFrm,
151 const SwRectFn& _fnRect,
152 const bool _bVert ) const;
154 // *********************************************************************
155 void _GetVertAlignmentValues( const SwFrm& _rVertOrientFrm,
156 const SwFrm& _rPageAlignLayFrm,
157 const sal_Int16 _eRelOrient,
158 SwTwips& _orAlignAreaHeight,
159 SwTwips& _orAlignAreaOffset ) const;
161 // *********************************************************************
162 // --> OD 2004-06-17 #i26791# - add output parameter <_roVertOffsetToFrmAnchorPos>
163 SwTwips _GetVertRelPos( const SwFrm& _rVertOrientFrm,
164 const SwFrm& _rPageAlignLayFrm,
165 const sal_Int16 _eVertOrient,
166 const sal_Int16 _eRelOrient,
167 const SwTwips _nVertPos,
168 const SvxLRSpaceItem& _rLRSpacing,
169 const SvxULSpaceItem& _rULSpacing,
170 SwTwips& _roVertOffsetToFrmAnchorPos ) const;
172 // *********************************************************************
173 /** adjust calculated vertical in order to keep object inside
174 'page' alignment layout frame.
176 OD 2004-07-22 #i31805# - add parameter <_bCheckBottom>
177 OD 2004-10-08 #i26945# - add parameter <_bFollowTextFlow>
178 OD 2006-03-15 #i62875# - made inline, intrinsic actions moved
179 to private method <_ImplAdjustVertRelPos>, which is only
180 called, if <mbDoNotCaptureAnchoredObj> not set.
182 @param _nTopOfAnch
183 input parameter - 'vertical' position, at which the relative
184 position of the object is calculated from.
186 @param _bVert
187 input parameter - boolean, indicating, if object is in vertical
188 layout.
190 @param _rPageAlignLayFrm
191 input parameter - layout frame, which determines the 'page area'
192 the object has to be vertical positioned in.
194 @param _nProposedRelPosY
195 input parameter - proposed relative vertical position, which
196 will be adjusted.
198 @param _bFollowTextFlow
199 input parameter - value of attribute 'Follow text flow' of the
200 anchored object.
202 @param _bCheckBottom
203 input parameter - boolean indicating, if bottom of anchored
204 object has to be checked and thus, (if needed) the proposed
205 relative position has to be adjusted. default value <true>
207 @author OD
209 inline SwTwips _AdjustVertRelPos( const SwTwips _nTopOfAnch,
210 const bool _bVert,
211 const SwFrm& _rPageAlignLayFrm,
212 const SwTwips _nProposedRelPosY,
213 const bool _bFollowTextFlow,
214 const bool _bCheckBottom = true ) const
216 return !mbDoNotCaptureAnchoredObj
217 ? _ImplAdjustVertRelPos( _nTopOfAnch, _bVert,
218 _rPageAlignLayFrm,
219 _nProposedRelPosY,
220 _bFollowTextFlow,
221 _bCheckBottom )
222 : _nProposedRelPosY;
225 // *********************************************************************
226 /** calculate relative horizontal position
228 --> OD 2004-06-17 #i26791# - add output parameter
229 <_roHoriOffsetToFrmAnchorPos>
231 @author OD
233 @param _rHoriOrientFrm
234 input parameter - frame the horizontal position of the object
235 is oriented at.
237 @param _rEnvOfObj
238 input parameter - object instance to retrieve environment
239 information about the object
241 @param _rHoriOrient
242 input parameter - horizontal positioning and alignment, for which
243 the relative position is calculated.
245 @param _rLRSpacing
246 input parameter - left and right spacing of the object to the text
248 @param _rULSpacing
249 input parameter - upper and lower spacing of the object to the text
251 @param _bObjWrapThrough
252 input parameter - boolean indicating, if object has wrap mode
253 'wrap through'.
255 @param _nRelPosY
256 input parameter - relative vertical position
258 @param _roHoriOffsetToFrmAnchorPos
259 output parameter - 'horizontal' offset to frame anchor position
260 according to the alignment
262 @return relative horizontal position in SwTwips
264 SwTwips _CalcRelPosX( const SwFrm& _rHoriOrientFrm,
265 const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
266 const SwFmtHoriOrient& _rHoriOrient,
267 const SvxLRSpaceItem& _rLRSpacing,
268 const SvxULSpaceItem& _rULSpacing,
269 const bool _bObjWrapThrough,
270 const SwTwips _nRelPosY,
271 SwTwips& _roHoriOffsetToFrmAnchorPos
272 ) const;
274 // *********************************************************************
275 /** adjust calculated horizontal in order to keep object inside
276 'page' alignment layout frame for object type position TO_CNTNT
278 OD 2006-03-15 #i62875# - made inline, intrinsic actions moved
279 to private method <_ImplAdjustHoriRelPos>, which is only
280 called, if <mbDoNotCaptureAnchoredObj> not set.
282 @author OD
284 @param _rPageAlignLayFrm
285 input paramter - layout frame, which determines the 'page area'
286 the object has to be horizontal positioned in.
288 @param _nProposedRelPosX
289 input parameter - proposed relative horizontal position, which
290 will be adjusted.
292 @return adjusted relative horizontal position in SwTwips.
294 inline SwTwips _AdjustHoriRelPos( const SwFrm& _rPageAlignLayFrm,
295 const SwTwips _nProposedRelPosX ) const
297 return !mbDoNotCaptureAnchoredObj
298 ? _ImplAdjustHoriRelPos( _rPageAlignLayFrm, _nProposedRelPosX )
299 : _nProposedRelPosX;
302 // *********************************************************************
303 /** toggle given horizontal orientation and relative alignment
305 @author OD
307 @param _bToggleLeftRight
308 input parameter - boolean indicating, if horizontal orientation
309 and relative alignment has to be toggled.
311 @param _ioeHoriOrient
312 input/output parameter - horizontal orientation, that is toggled,
313 if needed.
315 @param _iopeRelOrient
316 optional input/output parameter (default value NULL)
317 - if set, relative alignment, that is toggled, if needed.
319 void _ToggleHoriOrientAndAlign( const bool _bToggleLeftRight,
320 sal_Int16& _ioeHoriOrient,
321 sal_Int16& _iopeRelOrient
322 ) const;
324 // *********************************************************************
325 /** determine alignment values for horizontal position of object
327 @author OD
329 @param _rHoriOrientFrm
330 input parameter - frame the horizontal position of the object
331 is oriented at.
333 @param _rPageAlignLayFrm
334 input paramter - layout frame, which determines the 'page area'
335 the object has to be horizontal positioned in.
337 @param _eRelOrient
338 input parameter - horizontal relative alignment, for which
339 the relative position is calculated.
341 @param _bToggleLeftRight
342 input parameter - boolean indicating, if left/right alignments
343 have to be toggled.
345 @param _bObjWrapThrough
346 input parameter - boolean indicating, if object has wrap mode
347 'wrap through'.
348 important note: value is only relevant, if _rHoriOrientFrm is
349 a text frame.
351 @param _orAlignAreaWidth
352 output parameter - width in SwTwips of the area the horizontal
353 position is aligned to.
355 @param _orAlignAreaOffset
356 output parameter - offset in SwTwips of the area the horizontal
357 position is aligned to. offset is given to the 'left' of the
358 anchor position.
360 @param _obAlignedRelToPage
361 output parameter - boolean indicating, that object is aligned
362 to 'page area'.
364 void _GetHoriAlignmentValues( const SwFrm& _rHoriOrientFrm,
365 const SwFrm& _rPageAlignLayFrm,
366 const sal_Int16 _eRelOrient,
367 const bool _bObjWrapThrough,
368 SwTwips& _orAlignAreaWidth,
369 SwTwips& _orAlignAreaOffset,
370 bool& _obAlignedRelToPage ) const;
372 // *********************************************************************
373 /** adjust calculated horizontal position in order to draw object
374 aside other objects with same positioning
376 @author OD
378 @param _rHoriOrientFrm
379 input parameter - frame the horizontal position of the object
380 is oriented at.
382 @param _nProposedRelPosX
383 input parameter - proposed relative horizontal position, which
384 will be adjusted.
386 @param _nRelPosY
387 input parameter - relative vertical position
389 @param _eHoriOrient
390 input parameter - horizontal position of object
392 @param _eRelOrient
393 inpt parameter - alignment of object
395 @param _rLRSpacing
396 input parameter - left and right spacing of the object to the text
398 @param _rULSpacing
399 input parameter - upper and lower spacing of the object to the text
401 @param _bEvenPage
402 input parameter - boolean indicating, if object is on an even page.
404 @return adjusted relative horizontal position in SwTwips
406 SwTwips _AdjustHoriRelPosForDrawAside( const SwFrm& _rHoriOrientFrm,
407 const SwTwips _nProposedRelPosX,
408 const SwTwips _nRelPosY,
409 const sal_Int16 _eHoriOrient,
410 const sal_Int16 _eRelOrient,
411 const SvxLRSpaceItem& _rLRSpacing,
412 const SvxULSpaceItem& _rULSpacing,
413 const bool _bEvenPage
414 ) const;
416 // *********************************************************************
417 /** detemine, if object has to draw aside given fly frame
419 method used by <_AdjustHoriRelPosForDrawAside(..)>
421 @author OD
423 @param _pFly
424 input parameter - fly frame the draw aside check is done for.
426 @param _rObjRect
427 input parameter - proposed object rectangle
429 @param _pObjContext
430 input parameter - context of the object
432 @param _nObjIndex
433 input parameter - index of the anchor frame of the object
435 @param _bEvenPage
436 input parameter - boolean indicating, if object is on an even page.
438 @param _eHoriOrient
439 input parameter - horizontal position of object
441 @param _eRelOrient
442 inpt parameter - alignment of object
444 @return boolean indicating, if object has to be drawn aside
445 given fly frame.
447 bool _DrawAsideFly( const SwFlyFrm* _pFly,
448 const SwRect& _rObjRect,
449 const SwFrm* _pObjContext,
450 const ULONG _nObjIndex,
451 const bool _bEvenPage,
452 const sal_Int16 _eHoriOrient,
453 const sal_Int16 _eRelOrient
454 ) const;
456 // *********************************************************************
457 /** determine, if object has to draw aside another object
459 the different alignments of the objects determines, if one has
460 to draw aside another one. Thus, the given alignment are checked
461 against each other, which one has to be drawn aside the other one.
462 depending on parameter _bLeft check is done for left or right
463 positioning.
464 method used by <_DrawAsideFly(..)>
466 @author OD
468 @param _eRelOrient1
469 input parameter - alignment 1
471 @param _eRelOrient2
472 input parameter - alignment 2
474 @param _bLeft
475 input parameter - boolean indicating, if check is done for left
476 or for right positioning.
478 @return boolean indicating, if an object with an alignment
479 <_eRelOrient1> has to be drawn aside an object with an
480 alignment <_eRelOrient2>
482 bool _Minor( sal_Int16 _eRelOrient1,
483 sal_Int16 _eRelOrient2,
484 bool _bLeft ) const;
486 public:
487 virtual void CalcPosition() = 0;
489 } // namespace objectpositioning
491 #endif