nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / inc / anchoredobjectposition.hxx
blob2a30da4d6c1c32e2cb08d7d66bad0ca839d68418
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
24 #include "frame.hxx"
26 class SdrObject;
27 class SwFlyFrame;
28 class SwContact;
29 class SwFrameFormat;
30 class SwRect;
31 class SvxLRSpaceItem;
32 class SvxULSpaceItem;
33 class SwFormatHoriOrient;
34 class SwAnchoredObject;
36 namespace objectpositioning
38 class SwEnvironmentOfAnchoredObject;
40 class SwAnchoredObjectPosition
42 private:
43 // object to be positioned
44 SdrObject& mrDrawObj;
45 // #i26791# - anchored object the object belongs to;
46 SwAnchoredObject* mpAnchoredObj;
47 // frame the object is anchored at
48 SwFrame* mpAnchorFrame;
49 // contact object
50 SwContact* mpContact;
51 // frame format
52 const SwFrameFormat* mpFrameFormat;
53 // does the object represents a Writer fly frame
54 bool mbIsObjFly;
55 // #i62875#
56 bool mbFollowTextFlow;
57 // #i62875#
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();
68 // #i62875#
69 // --> OD 2009-09-01 #mongolianlayout# - add parameter <bVertL2R>
70 SwTwips ImplAdjustVertRelPos( const SwTwips nTopOfAnch,
71 const bool bVert,
72 const bool bVertL2R,
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;
80 protected:
81 SwAnchoredObjectPosition( SdrObject& _rDrawObj );
82 virtual ~SwAnchoredObjectPosition();
84 // accessors for object and its corresponding data/information
85 SdrObject& GetObject() const
87 return mrDrawObj;
89 bool IsObjFly() const
91 return mbIsObjFly;
93 SwAnchoredObject& GetAnchoredObj() const
95 return *mpAnchoredObj;
97 SwFrame& GetAnchorFrame() const
99 return *mpAnchorFrame;
101 const SwFrameFormat& GetFrameFormat() const
103 return *mpFrameFormat;
105 // #i62875#
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;
115 // #i22341#
116 virtual SwTwips ToCharTopOfLine() const;
118 /** helper method to determine top of a frame for the vertical object
119 positioning
121 #i11860#
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>
153 @param nTopOfAnch
154 input parameter - 'vertical' position, at which the relative
155 position of the object is calculated from.
157 @param bVert
158 input parameter - boolean, indicating, if object is in vertical
159 layout.
161 @param bVertL2R
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
171 will be adjusted.
173 @param bFollowTextFlow
174 input parameter - value of attribute 'Follow text flow' of the
175 anchored object.
177 @param bCheckBottom
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,
183 const bool bVert,
184 const bool bVertL2R,
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,
192 rPageAlignLayFrame,
193 nProposedRelPosY,
194 bFollowTextFlow,
195 bCheckBottom )
196 : nProposedRelPosY;
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
206 is oriented at.
208 @param _rEnvOfObj
209 input parameter - object instance to retrieve environment
210 information about the object
212 @param _rHoriOrient
213 input parameter - horizontal positioning and alignment, for which
214 the relative position is calculated.
216 @param _rLRSpacing
217 input parameter - left and right spacing of the object to the text
219 @param _rULSpacing
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
224 'wrap through'.
226 @param _nRelPosY
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
243 ) const;
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
258 will be adjusted.
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 )
267 : _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,
278 if needed.
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
293 is oriented at.
295 @param _rPageAlignLayFrame
296 input parameter - layout frame, which determines the 'page area'
297 the object has to be horizontal positioned in.
299 @param _eRelOrient
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
305 have to be toggled.
307 @param _bObjWrapThrough
308 input parameter - boolean indicating, if object has wrap mode
309 'wrap through'.
310 important note: value is only relevant, if _rHoriOrientFrame is
311 a text frame.
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
320 anchor position.
322 @param _obAlignedRelToPage
323 output parameter - boolean indicating, that object is aligned
324 to 'page area'.
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
339 is oriented at.
341 @param _nProposedRelPosX
342 input parameter - proposed relative horizontal position, which
343 will be adjusted.
345 @param _nRelPosY
346 input parameter - relative vertical position
348 @param _eHoriOrient
349 input parameter - horizontal position of object
351 @param _eRelOrient
352 input parameter - alignment of object
354 @param _rLRSpacing
355 input parameter - left and right spacing of the object to the text
357 @param _rULSpacing
358 input parameter - upper and lower spacing of the object to the text
360 @param _bEvenPage
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
373 ) const;
375 /** determine, if object has to draw aside given fly frame
377 method used by <AdjustHoriRelPosForDrawAside(..)>
379 @param _pFly
380 input parameter - fly frame the draw aside check is done for.
382 @param _rObjRect
383 input parameter - proposed object rectangle
385 @param _pObjContext
386 input parameter - context of the object
388 @param _nObjIndex
389 input parameter - index of the anchor frame of the object
391 @param _bEvenPage
392 input parameter - boolean indicating, if object is on an even page.
394 @param _eHoriOrient
395 input parameter - horizontal position of object
397 @param _eRelOrient
398 input parameter - alignment of object
400 @return boolean indicating, if object has to be drawn aside
401 given fly frame.
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
410 ) const;
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
418 positioning.
419 method used by <DrawAsideFly(..)>
421 @param _eRelOrient1
422 input parameter - alignment 1
424 @param _eRelOrient2
425 input parameter - alignment 2
427 @param _bLeft
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,
437 bool _bLeft );
439 public:
440 virtual void CalcPosition() = 0;
444 #endif
446 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */