Update ooo320-m1
[ooovba.git] / svx / inc / svx / sdr / primitive2d / sdrtextprimitive2d.hxx
blob7de94812cb39bf1e88e72be91ab382f8986dc0f4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrtextprimitive2d.hxx,v $
11 * $Revision: 1.2.18.1 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
33 #define INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
35 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
36 #include <basegfx/polygon/b2dpolypolygon.hxx>
37 #include <basegfx/matrix/b2dhommatrix.hxx>
38 #include <com/sun/star/drawing/XDrawPage.hpp>
39 #include <svx/outlobj.hxx>
40 #include <tools/color.hxx>
41 #include <svx/sdr/attribute/sdrformtextattribute.hxx>
42 #include <tools/weakbase.hxx>
43 #include <svx/sdtaitm.hxx>
45 //////////////////////////////////////////////////////////////////////////////
46 // predefines
47 class SdrText;
49 //////////////////////////////////////////////////////////////////////////////
51 namespace drawinglayer
53 namespace primitive2d
55 class SdrTextPrimitive2D : public BasePrimitive2D
57 private:
58 // The text model data; this sould later just be the OutlinerParaObject or
59 // something equal
60 ::tools::WeakReference< SdrText > mrSdrText;
62 // #i97628#
63 // The text content; now as local OutlinerParaObject copy (internally RefCounted and
64 // COW) and in exclusive, local form as needed in a primitive
65 const OutlinerParaObject maOutlinerParaObject;
67 // remeber last VisualizingPage for which a decomposition was made. If the new target
68 // is not given or different, the decomposition needs to be potentially removed
69 // for supporting e.g. page number change on MasterPage objects or the different
70 // field renderings in SubGeometry and MasterPage mnode
71 com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > mxLastVisualizingPage;
73 // remember last PageNumber for which a decomposition was made. This is only used
74 // when mbContainsPageField is true, else it is 0
75 sal_Int16 mnLastPageNumber;
77 // remember last PageCount for which a decomposition was made. This is only used
78 // when mbContainsPageCountField is true, else it is 0
79 sal_Int16 mnLastPageCount;
81 // #i101443# remember last TextBackgroundColor to decide if a new decomposition is
82 // needed because of background color change
83 Color maLastTextBackgroundColor;
85 // bitfield
86 // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction
87 unsigned mbContainsPageField : 1;
88 unsigned mbContainsPageCountField : 1;
89 unsigned mbContainsOtherFields : 1;
91 protected:
92 // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
93 Primitive2DSequence encapsulateWithTextHierarchyBlockPrimitive2D(const Primitive2DSequence& rCandidate) const;
95 public:
96 SdrTextPrimitive2D(
97 const SdrText* pSdrText,
98 const OutlinerParaObject& rOutlinerParaObjectPtr);
100 // get data
101 const SdrText* getSdrText() const { return mrSdrText.get(); }
102 const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; }
104 // compare operator
105 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
107 // own get2DDecomposition to take aspect of decomposition with or without spell checker
108 // into account
109 virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
111 // transformed clone operator
112 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const = 0;
114 } // end of namespace primitive2d
115 } // end of namespace drawinglayer
117 //////////////////////////////////////////////////////////////////////////////
119 namespace drawinglayer
121 namespace primitive2d
123 class SdrContourTextPrimitive2D : public SdrTextPrimitive2D
125 private:
126 // unit contour polygon (scaled to [0.0 .. 1.0])
127 basegfx::B2DPolyPolygon maUnitPolyPolygon;
129 // complete contour polygon transform (scale, rotate, shear, translate)
130 basegfx::B2DHomMatrix maObjectTransform;
132 protected:
133 // local decomposition.
134 virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
136 public:
137 SdrContourTextPrimitive2D(
138 const SdrText* pSdrText,
139 const OutlinerParaObject& rOutlinerParaObjectPtr,
140 const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
141 const basegfx::B2DHomMatrix& rObjectTransform);
143 // get data
144 const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; }
145 const basegfx::B2DHomMatrix& getObjectTransform() const { return maObjectTransform; }
147 // compare operator
148 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
150 // transformed clone operator
151 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const;
153 // provide unique ID
154 DeclPrimitrive2DIDBlock()
156 } // end of namespace primitive2d
157 } // end of namespace drawinglayer
159 //////////////////////////////////////////////////////////////////////////////
161 namespace drawinglayer
163 namespace primitive2d
165 class SdrPathTextPrimitive2D : public SdrTextPrimitive2D
167 private:
168 // the path to use. Each paragraph will use one Polygon.
169 basegfx::B2DPolyPolygon maPathPolyPolygon;
171 // the Fontwork parameters
172 attribute::SdrFormTextAttribute maSdrFormTextAttribute;
174 protected:
175 // local decomposition.
176 virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
178 public:
179 SdrPathTextPrimitive2D(
180 const SdrText* pSdrText,
181 const OutlinerParaObject& rOutlinerParaObjectPtr,
182 const basegfx::B2DPolyPolygon& rPathPolyPolygon,
183 const attribute::SdrFormTextAttribute& rSdrFormTextAttribute);
185 // get data
186 const basegfx::B2DPolyPolygon& getPathPolyPolygon() const { return maPathPolyPolygon; }
187 const attribute::SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; }
189 // compare operator
190 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
192 // transformed clone operator
193 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const;
195 // provide unique ID
196 DeclPrimitrive2DIDBlock()
198 } // end of namespace primitive2d
199 } // end of namespace drawinglayer
201 //////////////////////////////////////////////////////////////////////////////
203 namespace drawinglayer
205 namespace primitive2d
207 class SdrBlockTextPrimitive2D : public SdrTextPrimitive2D
209 private:
210 // text range transformation from unit range ([0.0 .. 1.0]) to text range
211 basegfx::B2DHomMatrix maTextRangeTransform;
213 // text alignments
214 SdrTextHorzAdjust maSdrTextHorzAdjust;
215 SdrTextVertAdjust maSdrTextVertAdjust;
217 // bitfield
218 unsigned mbFixedCellHeight : 1;
219 unsigned mbUnlimitedPage : 1; // force layout with no text break
220 unsigned mbCellText : 1; // this is a cell text as block text
221 unsigned mbWordWrap : 1; // for CustomShapes text layout
223 protected:
224 // local decomposition.
225 virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
227 public:
228 SdrBlockTextPrimitive2D(
229 const SdrText* pSdrText,
230 const OutlinerParaObject& rOutlinerParaObjectPtr,
231 const basegfx::B2DHomMatrix& rTextRangeTransform,
232 SdrTextHorzAdjust aSdrTextHorzAdjust,
233 SdrTextVertAdjust aSdrTextVertAdjust,
234 bool bFixedCellHeight,
235 bool bUnlimitedPage,
236 bool bCellText,
237 bool bWordWrap);
239 // get data
240 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
241 SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; }
242 SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; }
243 bool isFixedCellHeight() const { return mbFixedCellHeight; }
244 bool getUnlimitedPage() const { return mbUnlimitedPage; }
245 bool getCellText() const { return mbCellText; }
246 bool getWordWrap() const { return mbWordWrap; }
248 // compare operator
249 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
251 // transformed clone operator
252 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const;
254 // provide unique ID
255 DeclPrimitrive2DIDBlock()
257 } // end of namespace primitive2d
258 } // end of namespace drawinglayer
260 //////////////////////////////////////////////////////////////////////////////
262 namespace drawinglayer
264 namespace primitive2d
266 class SdrStretchTextPrimitive2D : public SdrTextPrimitive2D
268 private:
269 // text range transformation from unit range ([0.0 .. 1.0]) to text range
270 basegfx::B2DHomMatrix maTextRangeTransform;
272 // bitfield
273 unsigned mbFixedCellHeight : 1;
275 protected:
276 // local decomposition.
277 virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
279 public:
280 SdrStretchTextPrimitive2D(
281 const SdrText* pSdrText,
282 const OutlinerParaObject& rOutlinerParaObjectPtr,
283 const basegfx::B2DHomMatrix& rTextRangeTransform,
284 bool bFixedCellHeight);
286 // get data
287 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
288 bool isFixedCellHeight() const { return mbFixedCellHeight; }
290 // compare operator
291 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
293 // transformed clone operator
294 virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const;
296 // provide unique ID
297 DeclPrimitrive2DIDBlock()
299 } // end of namespace primitive2d
300 } // end of namespace drawinglayer
302 //////////////////////////////////////////////////////////////////////////////
304 namespace drawinglayer
306 namespace primitive2d
308 class SdrAutoFitTextPrimitive2D : public SdrTextPrimitive2D
310 private:
311 ::basegfx::B2DHomMatrix maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range
313 // bitfield
314 unsigned mbWordWrap : 1; // for CustomShapes text layout
316 protected:
317 // local decomposition.
318 virtual Primitive2DSequence createLocalDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
320 public:
321 SdrAutoFitTextPrimitive2D(
322 const SdrText* pSdrText,
323 const OutlinerParaObject& rOutlinerParaObjectPtr,
324 const ::basegfx::B2DHomMatrix& rTextRangeTransform,
325 bool bWordWrap);
327 // get data
328 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
329 bool getWordWrap() const { return mbWordWrap; }
331 // compare operator
332 virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
334 // transformed clone operator
335 virtual SdrTextPrimitive2D* createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const;
337 // provide unique ID
338 DeclPrimitrive2DIDBlock()
340 } // end of namespace primitive2d
341 } // end of namespace drawinglayer
343 //////////////////////////////////////////////////////////////////////////////
345 #endif //INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
347 // eof