1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _ASCHARANCHOREDOBJECTPOSITION_HXX 28 #define _ASCHARANCHOREDOBJECTPOSITION_HXX 29 #include <anchoredobjectposition.hxx> 30 #include <sal/types.h> 31 #include <swtypes.hxx> 32 #include <swrect.hxx> 33 34 class SwTxtFrm; 35 class SwFmtVertOrient; 36 37 namespace objectpositioning 38 { 39 // flags for positioning algorithm of as-character-anchored objects 40 typedef sal_uInt8 AsCharFlags; 41 #define AS_CHAR_NOFLAG 0 42 #define AS_CHAR_QUICK 1 43 #define AS_CHAR_ULSPACE 2 44 #define AS_CHAR_INIT 4 45 #define AS_CHAR_ROTATE 8 46 #define AS_CHAR_REVERSE 16 47 #define AS_CHAR_BIDI 32 48 49 class SwAsCharAnchoredObjectPosition : public SwAnchoredObjectPosition 50 { 51 private: 52 // data to calculate object position 53 // proposed anchor position, starting point for the calculation 54 // of the object position 55 const Point& mrProposedAnchorPos; 56 // flags that influences the calculation of the anchor position 57 // AS_CHAR_QUICK : quick formatting - calculated position not set at object 58 // AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position 59 // AS_CHAR_INIT : initial calculation 60 // AS_CHAR_ROTATE : object is rotated by 90 degrees 61 // AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees) 62 // AS_CHAR_BIDI : object belongs to a BIDI-multi-portion 63 const AsCharFlags mnFlags; 64 // needed line values for the different alignments. 65 const SwTwips mnLineAscent; 66 const SwTwips mnLineDescent; 67 const SwTwips mnLineAscentInclObjs; 68 const SwTwips mnLineDescentInclObjs; 69 70 // calculated data for object position 71 Point maAnchorPos; 72 SwTwips mnRelPos; 73 SwRect maObjBoundRect; 74 // line alignment relative to line height; gives feedback for line formatting 75 // 0 - no line alignment, 1 - at top, 2 - at center, 3 - at bottom 76 sal_uInt8 mnLineAlignment; 77 78 // method to cast <SwAnchoredObjectPosition::GetAnchorFrm()> 79 const SwTxtFrm& GetAnchorTxtFrm() const; 80 81 /** determine the relative position to base line for object position 82 83 @author OD 84 85 @param _ObjBoundHeight 86 height including corresponding spacing of the object, for which 87 the Y-position has to be calculated. 88 89 @param _rVert 90 given vertical positioning and alignment 91 92 @return relative position to the base line 93 */ 94 SwTwips _GetRelPosToBase( const SwTwips _nObjBoundHeight, 95 const SwFmtVertOrient& _rVert ); 96 97 // ********************************************************************* 98 public: 99 /** construtor; provided object to be positioned and needed data 100 for calculation of the object position 101 102 OD 28.10.2003 #110978# 103 104 @param _rDrawObj 105 input parameter - object, that is be positioned. 106 107 @param _rProposedAnchorPos 108 proposed anchor position; starting point for the calculation 109 of the anchor position 110 111 @param _nFlags 112 flags that influences the calculation of the anchor position 113 AS_CHAR_QUICK : quick formatting - calculated position not set at object 114 AS_CHAR_ULSPACE : consider upper/lower spacing - adjustment of anchor position 115 AS_CHAR_INIT : initial calculation 116 AS_CHAR_ROTATE : object is rotated by 90 degrees 117 AS_CHAR_REVERSE : object is reversed (rotated by 270 degrees) 118 AS_CHAR_BIDI : object belongs to a BIDI-multi-portion 119 120 @param _nLineAscent, _nLineDescent, _nLineAscentInclObjs, 121 _nLineDescentInclObjs - needed line values for the different 122 alignments. 123 124 @author OD 125 */ 126 SwAsCharAnchoredObjectPosition( SdrObject& _rDrawObj, 127 const Point& _rProposedAnchorPos, 128 const AsCharFlags _nFlags, 129 const SwTwips _nLineAscent, 130 const SwTwips _nLineDescent, 131 const SwTwips _nLineAscentInclObjs, 132 const SwTwips _nLineDescentInclObjs ); 133 virtual ~SwAsCharAnchoredObjectPosition(); 134 135 /** calculate position for object position 136 137 members <maAnchorPos>, <mnRelPos>, <maObjBoundRect> and 138 <mnLineAlignment> are calculated. 139 calculated position is set at the given object. 140 141 @author OD 142 */ 143 virtual void CalcPosition(); 144 145 /** calculated anchored position for object position type AS_CHAR 146 147 @author OD 148 */ 149 Point GetAnchorPos() const; 150 151 /** calculated relative position to base line for object position type AS_CHAR 152 153 @author OD 154 */ 155 SwTwips GetRelPosY() const; 156 157 /** determined object rectangle including spacing for object position type AS_CHAR 158 159 @author OD 160 */ 161 SwRect GetObjBoundRectInclSpacing() const; 162 163 /** determined line alignment relative to line height 164 165 @author OD 166 */ 167 sal_uInt8 GetLineAlignment() const; 168 }; 169 } // namespace objectpositioning 170 171 #endif 172