1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ascharanchoredobjectposition.hxx,v $
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 _ASCHARANCHOREDOBJECTPOSITION_HXX
31 #define _ASCHARANCHOREDOBJECTPOSITION_HXX
32 #include <anchoredobjectposition.hxx>
33 #include <sal/types.h>
34 #include <swtypes.hxx>
38 class SwFmtVertOrient
;
40 namespace objectpositioning
42 // flags for positioning algorithm of as-character-anchored objects
43 typedef sal_uInt8 AsCharFlags
;
44 #define AS_CHAR_NOFLAG 0
45 #define AS_CHAR_QUICK 1
46 #define AS_CHAR_ULSPACE 2
47 #define AS_CHAR_INIT 4
48 #define AS_CHAR_ROTATE 8
49 #define AS_CHAR_REVERSE 16
50 #define AS_CHAR_BIDI 32
52 class SwAsCharAnchoredObjectPosition
: public SwAnchoredObjectPosition
55 // data to calculate object position
56 // proposed anchor position, starting point for the calculation
57 // of the object position
58 const Point
& mrProposedAnchorPos
;
59 // flags that influences the calculation of the anchor position
60 // AS_CHAR_QUICK : quick formatting - calculated position not set at object
61 // AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position
62 // AS_CHAR_INIT : initial calculation
63 // AS_CHAR_ROTATE : object is rotated by 90 degrees
64 // AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees)
65 // AS_CHAR_BIDI : object belongs to a BIDI-multi-portion
66 const AsCharFlags mnFlags
;
67 // needed line values for the different alignments.
68 const SwTwips mnLineAscent
;
69 const SwTwips mnLineDescent
;
70 const SwTwips mnLineAscentInclObjs
;
71 const SwTwips mnLineDescentInclObjs
;
73 // calculated data for object position
76 SwRect maObjBoundRect
;
77 // line alignment relative to line height; gives feedback for line formatting
78 // 0 - no line alignment, 1 - at top, 2 - at center, 3 - at bottom
79 sal_uInt8 mnLineAlignment
;
81 // method to cast <SwAnchoredObjectPosition::GetAnchorFrm()>
82 const SwTxtFrm
& GetAnchorTxtFrm() const;
84 /** determine the relative position to base line for object position
88 @param _ObjBoundHeight
89 height including corresponding spacing of the object, for which
90 the Y-position has to be calculated.
93 given vertical positioning and alignment
95 @return relative position to the base line
97 SwTwips
_GetRelPosToBase( const SwTwips _nObjBoundHeight
,
98 const SwFmtVertOrient
& _rVert
);
100 // *********************************************************************
102 /** construtor; provided object to be positioned and needed data
103 for calculation of the object position
105 OD 28.10.2003 #110978#
108 input parameter - object, that is be positioned.
110 @param _rProposedAnchorPos
111 proposed anchor position; starting point for the calculation
112 of the anchor position
115 flags that influences the calculation of the anchor position
116 AS_CHAR_QUICK : quick formatting - calculated position not set at object
117 AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position
118 AS_CHAR_INIT : initial calculation
119 AS_CHAR_ROTATE : object is rotated by 90 degrees
120 AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees)
121 AS_CHAR_BIDI : object belongs to a BIDI-multi-portion
123 @param _nLineAscent, _nLineDescent, _nLineAscentInclObjs,
124 _nLineDescentInclObjs - needed line values for the different
129 SwAsCharAnchoredObjectPosition( SdrObject
& _rDrawObj
,
130 const Point
& _rProposedAnchorPos
,
131 const AsCharFlags _nFlags
,
132 const SwTwips _nLineAscent
,
133 const SwTwips _nLineDescent
,
134 const SwTwips _nLineAscentInclObjs
,
135 const SwTwips _nLineDescentInclObjs
);
136 virtual ~SwAsCharAnchoredObjectPosition();
138 /** calculate position for object position
140 members <maAnchorPos>, <mnRelPos>, <maObjBoundRect> and
141 <mnLineAlignment> are calculated.
142 calculated position is set at the given object.
146 virtual void CalcPosition();
148 /** calculated anchored position for object position type AS_CHAR
152 Point
GetAnchorPos() const;
154 /** calculated relative position to base line for object position type AS_CHAR
158 SwTwips
GetRelPosY() const;
160 /** determined object rectangle including spacing for object position type AS_CHAR
164 SwRect
GetObjBoundRectInclSpacing() const;
166 /** determined line alignment relative to line height
170 sal_uInt8
GetLineAlignment() const;
172 } // namespace objectpositioning