1*1d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1d2dbeb0SAndrew Rist  * distributed with this work for additional information
6*1d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
9*1d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1d2dbeb0SAndrew Rist  *
11*1d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1d2dbeb0SAndrew Rist  *
13*1d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
15*1d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
18*1d2dbeb0SAndrew Rist  * under the License.
19*1d2dbeb0SAndrew Rist  *
20*1d2dbeb0SAndrew Rist  *************************************************************/
21*1d2dbeb0SAndrew Rist 
22*1d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _ASCHARANCHOREDOBJECTPOSITION_HXX
24cdf0e10cSrcweir #define _ASCHARANCHOREDOBJECTPOSITION_HXX
25cdf0e10cSrcweir #include <anchoredobjectposition.hxx>
26cdf0e10cSrcweir #include <sal/types.h>
27cdf0e10cSrcweir #include <swtypes.hxx>
28cdf0e10cSrcweir #include <swrect.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir class SwTxtFrm;
31cdf0e10cSrcweir class SwFmtVertOrient;
32cdf0e10cSrcweir 
33cdf0e10cSrcweir namespace objectpositioning
34cdf0e10cSrcweir {
35cdf0e10cSrcweir     // flags for positioning algorithm of as-character-anchored objects
36cdf0e10cSrcweir     typedef sal_uInt8 AsCharFlags;
37cdf0e10cSrcweir     #define AS_CHAR_NOFLAG  0
38cdf0e10cSrcweir     #define AS_CHAR_QUICK   1
39cdf0e10cSrcweir     #define AS_CHAR_ULSPACE 2
40cdf0e10cSrcweir     #define AS_CHAR_INIT    4
41cdf0e10cSrcweir     #define AS_CHAR_ROTATE  8
42cdf0e10cSrcweir     #define AS_CHAR_REVERSE 16
43cdf0e10cSrcweir     #define AS_CHAR_BIDI    32
44cdf0e10cSrcweir 
45cdf0e10cSrcweir     class SwAsCharAnchoredObjectPosition : public SwAnchoredObjectPosition
46cdf0e10cSrcweir     {
47cdf0e10cSrcweir         private:
48cdf0e10cSrcweir          // data to calculate object position
49cdf0e10cSrcweir             // proposed anchor position, starting point for the calculation
50cdf0e10cSrcweir             // of the object position
51cdf0e10cSrcweir             const Point& mrProposedAnchorPos;
52cdf0e10cSrcweir             // flags that influences the calculation of the anchor position
53cdf0e10cSrcweir             // AS_CHAR_QUICK   : quick formatting - calculated position not set at object
54cdf0e10cSrcweir             // AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position
55cdf0e10cSrcweir             // AS_CHAR_INIT    : initial calculation
56cdf0e10cSrcweir             // AS_CHAR_ROTATE  : object is rotated by 90 degrees
57cdf0e10cSrcweir             // AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees)
58cdf0e10cSrcweir             // AS_CHAR_BIDI    : object belongs to a BIDI-multi-portion
59cdf0e10cSrcweir             const AsCharFlags mnFlags;
60cdf0e10cSrcweir             // needed line values for the different alignments.
61cdf0e10cSrcweir             const SwTwips mnLineAscent;
62cdf0e10cSrcweir             const SwTwips mnLineDescent;
63cdf0e10cSrcweir             const SwTwips mnLineAscentInclObjs;
64cdf0e10cSrcweir             const SwTwips mnLineDescentInclObjs;
65cdf0e10cSrcweir 
66cdf0e10cSrcweir          // calculated data for object position
67cdf0e10cSrcweir             Point       maAnchorPos;
68cdf0e10cSrcweir             SwTwips     mnRelPos;
69cdf0e10cSrcweir             SwRect      maObjBoundRect;
70cdf0e10cSrcweir             // line alignment relative to line height; gives feedback for line formatting
71cdf0e10cSrcweir             // 0 - no line alignment, 1 - at top, 2 - at center, 3 - at bottom
72cdf0e10cSrcweir             sal_uInt8   mnLineAlignment;
73cdf0e10cSrcweir 
74cdf0e10cSrcweir             // method to cast <SwAnchoredObjectPosition::GetAnchorFrm()>
75cdf0e10cSrcweir             const SwTxtFrm& GetAnchorTxtFrm() const;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir             /** determine the relative position to base line for object position
78cdf0e10cSrcweir 
79cdf0e10cSrcweir                 @author OD
80cdf0e10cSrcweir 
81cdf0e10cSrcweir                 @param _ObjBoundHeight
82cdf0e10cSrcweir                 height including corresponding spacing of the object, for which
83cdf0e10cSrcweir                 the Y-position has to be calculated.
84cdf0e10cSrcweir 
85cdf0e10cSrcweir                 @param _rVert
86cdf0e10cSrcweir                 given vertical positioning and alignment
87cdf0e10cSrcweir 
88cdf0e10cSrcweir                 @return relative position to the base line
89cdf0e10cSrcweir             */
90cdf0e10cSrcweir             SwTwips _GetRelPosToBase( const SwTwips          _nObjBoundHeight,
91cdf0e10cSrcweir                                       const SwFmtVertOrient& _rVert );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir         // *********************************************************************
94cdf0e10cSrcweir         public:
95cdf0e10cSrcweir             /** construtor; provided object to be positioned and needed data
96cdf0e10cSrcweir                 for calculation of the object position
97cdf0e10cSrcweir 
98cdf0e10cSrcweir                 OD 28.10.2003 #110978#
99cdf0e10cSrcweir 
100cdf0e10cSrcweir                 @param _rDrawObj
101cdf0e10cSrcweir                 input parameter - object, that is be positioned.
102cdf0e10cSrcweir 
103cdf0e10cSrcweir                 @param _rProposedAnchorPos
104cdf0e10cSrcweir                 proposed anchor position; starting point for the calculation
105cdf0e10cSrcweir                 of the anchor position
106cdf0e10cSrcweir 
107cdf0e10cSrcweir                 @param _nFlags
108cdf0e10cSrcweir                 flags that influences the calculation of the anchor position
109cdf0e10cSrcweir                 AS_CHAR_QUICK   : quick formatting - calculated position not set at object
110cdf0e10cSrcweir                 AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position
111cdf0e10cSrcweir                 AS_CHAR_INIT    : initial calculation
112cdf0e10cSrcweir                 AS_CHAR_ROTATE  : object is rotated by 90 degrees
113cdf0e10cSrcweir                 AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees)
114cdf0e10cSrcweir                 AS_CHAR_BIDI    : object belongs to a BIDI-multi-portion
115cdf0e10cSrcweir 
116cdf0e10cSrcweir                 @param _nLineAscent, _nLineDescent, _nLineAscentInclObjs,
117cdf0e10cSrcweir                 _nLineDescentInclObjs - needed line values for the different
118cdf0e10cSrcweir                 alignments.
119cdf0e10cSrcweir 
120cdf0e10cSrcweir                 @author OD
121cdf0e10cSrcweir             */
122cdf0e10cSrcweir             SwAsCharAnchoredObjectPosition( SdrObject&      _rDrawObj,
123cdf0e10cSrcweir                                             const Point&    _rProposedAnchorPos,
124cdf0e10cSrcweir                                             const AsCharFlags _nFlags,
125cdf0e10cSrcweir                                             const SwTwips     _nLineAscent,
126cdf0e10cSrcweir                                             const SwTwips     _nLineDescent,
127cdf0e10cSrcweir                                             const SwTwips     _nLineAscentInclObjs,
128cdf0e10cSrcweir                                             const SwTwips     _nLineDescentInclObjs );
129cdf0e10cSrcweir             virtual ~SwAsCharAnchoredObjectPosition();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir             /** calculate position for object position
132cdf0e10cSrcweir 
133cdf0e10cSrcweir                 members <maAnchorPos>, <mnRelPos>, <maObjBoundRect> and
134cdf0e10cSrcweir                 <mnLineAlignment> are calculated.
135cdf0e10cSrcweir                 calculated position is set at the given object.
136cdf0e10cSrcweir 
137cdf0e10cSrcweir                 @author OD
138cdf0e10cSrcweir             */
139cdf0e10cSrcweir             virtual void CalcPosition();
140cdf0e10cSrcweir 
141cdf0e10cSrcweir             /** calculated anchored position for object position type AS_CHAR
142cdf0e10cSrcweir 
143cdf0e10cSrcweir                 @author OD
144cdf0e10cSrcweir             */
145cdf0e10cSrcweir             Point GetAnchorPos() const;
146cdf0e10cSrcweir 
147cdf0e10cSrcweir             /** calculated relative position to base line for object position type AS_CHAR
148cdf0e10cSrcweir 
149cdf0e10cSrcweir                 @author OD
150cdf0e10cSrcweir             */
151cdf0e10cSrcweir             SwTwips GetRelPosY() const;
152cdf0e10cSrcweir 
153cdf0e10cSrcweir             /** determined object rectangle including spacing for object position type AS_CHAR
154cdf0e10cSrcweir 
155cdf0e10cSrcweir                 @author OD
156cdf0e10cSrcweir             */
157cdf0e10cSrcweir             SwRect GetObjBoundRectInclSpacing() const;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir             /** determined line alignment relative to line height
160cdf0e10cSrcweir 
161cdf0e10cSrcweir                 @author OD
162cdf0e10cSrcweir             */
163cdf0e10cSrcweir             sal_uInt8 GetLineAlignment() const;
164cdf0e10cSrcweir     };
165cdf0e10cSrcweir } // namespace objectpositioning
166cdf0e10cSrcweir 
167cdf0e10cSrcweir #endif
168