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 28 #ifndef INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX 29 #define INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX 30 31 #include <drawinglayer/primitive2d/baseprimitive2d.hxx> 32 #include <basegfx/polygon/b2dpolypolygon.hxx> 33 #include <basegfx/matrix/b2dhommatrix.hxx> 34 #include <com/sun/star/drawing/XDrawPage.hpp> 35 #include <editeng/outlobj.hxx> 36 #include <tools/color.hxx> 37 #include <svx/sdr/attribute/sdrformtextattribute.hxx> 38 #include <tools/weakbase.hxx> 39 #include <svx/sdtaitm.hxx> 40 41 ////////////////////////////////////////////////////////////////////////////// 42 // predefines 43 class SdrText; 44 45 ////////////////////////////////////////////////////////////////////////////// 46 47 namespace drawinglayer 48 { 49 namespace primitive2d 50 { 51 class SdrTextPrimitive2D : public BufferedDecompositionPrimitive2D 52 { 53 private: 54 // The text model data; this sould later just be the OutlinerParaObject or 55 // something equal 56 ::tools::WeakReference< SdrText > mrSdrText; 57 58 // #i97628# 59 // The text content; now as local OutlinerParaObject copy (internally RefCounted and 60 // COW) and in exclusive, local form as needed in a primitive 61 const OutlinerParaObject maOutlinerParaObject; 62 63 // remeber last VisualizingPage for which a decomposition was made. If the new target 64 // is not given or different, the decomposition needs to be potentially removed 65 // for supporting e.g. page number change on MasterPage objects or the different 66 // field renderings in SubGeometry and MasterPage mnode 67 com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > mxLastVisualizingPage; 68 69 // remember last PageNumber for which a decomposition was made. This is only used 70 // when mbContainsPageField is true, else it is 0 71 sal_Int16 mnLastPageNumber; 72 73 // remember last PageCount for which a decomposition was made. This is only used 74 // when mbContainsPageCountField is true, else it is 0 75 sal_Int16 mnLastPageCount; 76 77 // #i101443# remember last TextBackgroundColor to decide if a new decomposition is 78 // needed because of background color change 79 Color maLastTextBackgroundColor; 80 81 // bitfield 82 // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction 83 unsigned mbContainsPageField : 1; 84 unsigned mbContainsPageCountField : 1; 85 unsigned mbContainsOtherFields : 1; 86 87 protected: 88 // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments 89 Primitive2DSequence encapsulateWithTextHierarchyBlockPrimitive2D(const Primitive2DSequence& rCandidate) const; 90 91 public: 92 SdrTextPrimitive2D( 93 const SdrText* pSdrText, 94 const OutlinerParaObject& rOutlinerParaObjectPtr); 95 96 // get data 97 const SdrText* getSdrText() const { return mrSdrText.get(); } 98 const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; } 99 100 // compare operator 101 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 102 103 // own get2DDecomposition to take aspect of decomposition with or without spell checker 104 // into account 105 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const; 106 107 // transformed clone operator 108 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const = 0; 109 }; 110 } // end of namespace primitive2d 111 } // end of namespace drawinglayer 112 113 ////////////////////////////////////////////////////////////////////////////// 114 115 namespace drawinglayer 116 { 117 namespace primitive2d 118 { 119 class SdrContourTextPrimitive2D : public SdrTextPrimitive2D 120 { 121 private: 122 // unit contour polygon (scaled to [0.0 .. 1.0]) 123 basegfx::B2DPolyPolygon maUnitPolyPolygon; 124 125 // complete contour polygon transform (scale, rotate, shear, translate) 126 basegfx::B2DHomMatrix maObjectTransform; 127 128 protected: 129 // local decomposition. 130 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; 131 132 public: 133 SdrContourTextPrimitive2D( 134 const SdrText* pSdrText, 135 const OutlinerParaObject& rOutlinerParaObjectPtr, 136 const basegfx::B2DPolyPolygon& rUnitPolyPolygon, 137 const basegfx::B2DHomMatrix& rObjectTransform); 138 139 // get data 140 const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; } 141 const basegfx::B2DHomMatrix& getObjectTransform() const { return maObjectTransform; } 142 143 // compare operator 144 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 145 146 // transformed clone operator 147 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const; 148 149 // provide unique ID 150 DeclPrimitrive2DIDBlock() 151 }; 152 } // end of namespace primitive2d 153 } // end of namespace drawinglayer 154 155 ////////////////////////////////////////////////////////////////////////////// 156 157 namespace drawinglayer 158 { 159 namespace primitive2d 160 { 161 class SdrPathTextPrimitive2D : public SdrTextPrimitive2D 162 { 163 private: 164 // the path to use. Each paragraph will use one Polygon. 165 basegfx::B2DPolyPolygon maPathPolyPolygon; 166 167 // the Fontwork parameters 168 attribute::SdrFormTextAttribute maSdrFormTextAttribute; 169 170 protected: 171 // local decomposition. 172 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; 173 174 public: 175 SdrPathTextPrimitive2D( 176 const SdrText* pSdrText, 177 const OutlinerParaObject& rOutlinerParaObjectPtr, 178 const basegfx::B2DPolyPolygon& rPathPolyPolygon, 179 const attribute::SdrFormTextAttribute& rSdrFormTextAttribute); 180 181 // get data 182 const basegfx::B2DPolyPolygon& getPathPolyPolygon() const { return maPathPolyPolygon; } 183 const attribute::SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; } 184 185 // compare operator 186 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 187 188 // transformed clone operator 189 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const; 190 191 // provide unique ID 192 DeclPrimitrive2DIDBlock() 193 }; 194 } // end of namespace primitive2d 195 } // end of namespace drawinglayer 196 197 ////////////////////////////////////////////////////////////////////////////// 198 199 namespace drawinglayer 200 { 201 namespace primitive2d 202 { 203 class SdrBlockTextPrimitive2D : public SdrTextPrimitive2D 204 { 205 private: 206 // text range transformation from unit range ([0.0 .. 1.0]) to text range 207 basegfx::B2DHomMatrix maTextRangeTransform; 208 209 // text alignments 210 SdrTextHorzAdjust maSdrTextHorzAdjust; 211 SdrTextVertAdjust maSdrTextVertAdjust; 212 213 // bitfield 214 unsigned mbFixedCellHeight : 1; 215 unsigned mbUnlimitedPage : 1; // force layout with no text break 216 unsigned mbCellText : 1; // this is a cell text as block text 217 unsigned mbWordWrap : 1; // for CustomShapes text layout 218 unsigned mbClipOnBounds : 1; // for CustomShapes text layout 219 220 protected: 221 // local decomposition. 222 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; 223 224 public: 225 SdrBlockTextPrimitive2D( 226 const SdrText* pSdrText, 227 const OutlinerParaObject& rOutlinerParaObjectPtr, 228 const basegfx::B2DHomMatrix& rTextRangeTransform, 229 SdrTextHorzAdjust aSdrTextHorzAdjust, 230 SdrTextVertAdjust aSdrTextVertAdjust, 231 bool bFixedCellHeight, 232 bool bUnlimitedPage, 233 bool bCellText, 234 bool bWordWrap, 235 bool bClipOnBounds); 236 237 // get data 238 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; } 239 SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; } 240 SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; } 241 bool isFixedCellHeight() const { return mbFixedCellHeight; } 242 bool getUnlimitedPage() const { return mbUnlimitedPage; } 243 bool getCellText() const { return mbCellText; } 244 bool getWordWrap() const { return mbWordWrap; } 245 bool getClipOnBounds() const { return mbClipOnBounds; } 246 247 // compare operator 248 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 249 250 // transformed clone operator 251 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const; 252 253 // provide unique ID 254 DeclPrimitrive2DIDBlock() 255 }; 256 } // end of namespace primitive2d 257 } // end of namespace drawinglayer 258 259 ////////////////////////////////////////////////////////////////////////////// 260 261 namespace drawinglayer 262 { 263 namespace primitive2d 264 { 265 class SdrStretchTextPrimitive2D : public SdrTextPrimitive2D 266 { 267 private: 268 // text range transformation from unit range ([0.0 .. 1.0]) to text range 269 basegfx::B2DHomMatrix maTextRangeTransform; 270 271 // bitfield 272 unsigned mbFixedCellHeight : 1; 273 274 protected: 275 // local decomposition. 276 virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const; 277 278 public: 279 SdrStretchTextPrimitive2D( 280 const SdrText* pSdrText, 281 const OutlinerParaObject& rOutlinerParaObjectPtr, 282 const basegfx::B2DHomMatrix& rTextRangeTransform, 283 bool bFixedCellHeight); 284 285 // get data 286 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; } 287 bool isFixedCellHeight() const { return mbFixedCellHeight; } 288 289 // compare operator 290 virtual bool operator==(const BasePrimitive2D& rPrimitive) const; 291 292 // transformed clone operator 293 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const; 294 295 // provide unique ID 296 DeclPrimitrive2DIDBlock() 297 }; 298 } // end of namespace primitive2d 299 } // end of namespace drawinglayer 300 301 ////////////////////////////////////////////////////////////////////////////// 302 303 #endif //INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX 304 305 // eof 306