Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_SVX_INC_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
21 : #define INCLUDED_SVX_INC_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
22 :
23 : #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
24 : #include <basegfx/polygon/b2dpolypolygon.hxx>
25 : #include <basegfx/matrix/b2dhommatrix.hxx>
26 : #include <com/sun/star/drawing/XDrawPage.hpp>
27 : #include <editeng/outlobj.hxx>
28 : #include <tools/color.hxx>
29 : #include <svx/sdr/attribute/sdrformtextattribute.hxx>
30 : #include <tools/weakbase.hxx>
31 : #include <svx/sdtaitm.hxx>
32 :
33 :
34 : // predefines
35 : class SdrText;
36 :
37 :
38 :
39 : namespace drawinglayer
40 : {
41 : namespace primitive2d
42 : {
43 17019 : class SdrTextPrimitive2D : public BufferedDecompositionPrimitive2D
44 : {
45 : private:
46 : // The text model data; this should later just be the OutlinerParaObject or
47 : // something equal
48 : ::tools::WeakReference< SdrText > mrSdrText;
49 :
50 : // #i97628#
51 : // The text content; now as local OutlinerParaObject copy (internally RefCounted and
52 : // COW) and in exclusive, local form as needed in a primitive
53 : const OutlinerParaObject maOutlinerParaObject;
54 :
55 : // remember last VisualizingPage for which a decomposition was made. If the new target
56 : // is not given or different, the decomposition needs to be potentially removed
57 : // for supporting e.g. page number change on MasterPage objects or the different
58 : // field renderings in SubGeometry and MasterPage mnode
59 : com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > mxLastVisualizingPage;
60 :
61 : // remember last PageNumber for which a decomposition was made. This is only used
62 : // when mbContainsPageField is true, else it is 0
63 : sal_Int16 mnLastPageNumber;
64 :
65 : // remember last PageCount for which a decomposition was made. This is only used
66 : // when mbContainsPageCountField is true, else it is 0
67 : sal_Int16 mnLastPageCount;
68 :
69 : // #i101443# remember last TextBackgroundColor to decide if a new decomposition is
70 : // needed because of background color change
71 : Color maLastTextBackgroundColor;
72 :
73 : // bitfield
74 : // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction
75 : bool mbContainsPageField : 1;
76 : bool mbContainsPageCountField : 1;
77 : bool mbContainsOtherFields : 1;
78 :
79 : protected:
80 : // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
81 : static Primitive2DSequence encapsulateWithTextHierarchyBlockPrimitive2D(const Primitive2DSequence& rCandidate);
82 :
83 : public:
84 : SdrTextPrimitive2D(
85 : const SdrText* pSdrText,
86 : const OutlinerParaObject& rOutlinerParaObjectPtr);
87 :
88 : // get data
89 330663 : const SdrText* getSdrText() const { return mrSdrText.get(); }
90 34837 : const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; }
91 :
92 : // compare operator
93 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
94 :
95 : // own get2DDecomposition to take aspect of decomposition with or without spell checker
96 : // into account
97 : virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const SAL_OVERRIDE;
98 :
99 : // transformed clone operator
100 : virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const = 0;
101 : };
102 : } // end of namespace primitive2d
103 : } // end of namespace drawinglayer
104 :
105 :
106 :
107 : namespace drawinglayer
108 : {
109 : namespace primitive2d
110 : {
111 0 : class SdrContourTextPrimitive2D : public SdrTextPrimitive2D
112 : {
113 : private:
114 : // unit contour polygon (scaled to [0.0 .. 1.0])
115 : basegfx::B2DPolyPolygon maUnitPolyPolygon;
116 :
117 : // complete contour polygon transform (scale, rotate, shear, translate)
118 : basegfx::B2DHomMatrix maObjectTransform;
119 :
120 : protected:
121 : // local decomposition.
122 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const SAL_OVERRIDE;
123 :
124 : public:
125 : SdrContourTextPrimitive2D(
126 : const SdrText* pSdrText,
127 : const OutlinerParaObject& rOutlinerParaObjectPtr,
128 : const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
129 : const basegfx::B2DHomMatrix& rObjectTransform);
130 :
131 : // get data
132 0 : const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; }
133 0 : const basegfx::B2DHomMatrix& getObjectTransform() const { return maObjectTransform; }
134 :
135 : // compare operator
136 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
137 :
138 : // transformed clone operator
139 : virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const SAL_OVERRIDE;
140 :
141 : // provide unique ID
142 : DeclPrimitive2DIDBlock()
143 : };
144 : } // end of namespace primitive2d
145 : } // end of namespace drawinglayer
146 :
147 :
148 :
149 : namespace drawinglayer
150 : {
151 : namespace primitive2d
152 : {
153 0 : class SdrPathTextPrimitive2D : public SdrTextPrimitive2D
154 : {
155 : private:
156 : // the path to use. Each paragraph will use one Polygon.
157 : basegfx::B2DPolyPolygon maPathPolyPolygon;
158 :
159 : // the Fontwork parameters
160 : attribute::SdrFormTextAttribute maSdrFormTextAttribute;
161 :
162 : protected:
163 : // local decomposition.
164 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const SAL_OVERRIDE;
165 :
166 : public:
167 : SdrPathTextPrimitive2D(
168 : const SdrText* pSdrText,
169 : const OutlinerParaObject& rOutlinerParaObjectPtr,
170 : const basegfx::B2DPolyPolygon& rPathPolyPolygon,
171 : const attribute::SdrFormTextAttribute& rSdrFormTextAttribute);
172 :
173 : // get data
174 0 : const basegfx::B2DPolyPolygon& getPathPolyPolygon() const { return maPathPolyPolygon; }
175 0 : const attribute::SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; }
176 :
177 : // compare operator
178 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
179 :
180 : // transformed clone operator
181 : virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const SAL_OVERRIDE;
182 :
183 : // provide unique ID
184 : DeclPrimitive2DIDBlock()
185 : };
186 : } // end of namespace primitive2d
187 : } // end of namespace drawinglayer
188 :
189 :
190 :
191 : namespace drawinglayer
192 : {
193 : namespace primitive2d
194 : {
195 33556 : class SdrBlockTextPrimitive2D : public SdrTextPrimitive2D
196 : {
197 : private:
198 : // text range transformation from unit range ([0.0 .. 1.0]) to text range
199 : basegfx::B2DHomMatrix maTextRangeTransform;
200 :
201 : // text alignments
202 : SdrTextHorzAdjust maSdrTextHorzAdjust;
203 : SdrTextVertAdjust maSdrTextVertAdjust;
204 :
205 : // bitfield
206 : bool mbFixedCellHeight : 1;
207 : bool mbUnlimitedPage : 1; // force layout with no text break
208 : bool mbCellText : 1; // this is a cell text as block text
209 : bool mbWordWrap : 1; // for CustomShapes text layout
210 : bool mbClipOnBounds : 1; // for CustomShapes text layout
211 :
212 : protected:
213 : // local decomposition.
214 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const SAL_OVERRIDE;
215 :
216 : public:
217 : SdrBlockTextPrimitive2D(
218 : const SdrText* pSdrText,
219 : const OutlinerParaObject& rOutlinerParaObjectPtr,
220 : const basegfx::B2DHomMatrix& rTextRangeTransform,
221 : SdrTextHorzAdjust aSdrTextHorzAdjust,
222 : SdrTextVertAdjust aSdrTextVertAdjust,
223 : bool bFixedCellHeight,
224 : bool bUnlimitedPage,
225 : bool bCellText,
226 : bool bWordWrap,
227 : bool bClipOnBounds);
228 :
229 : // get data
230 17425 : const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
231 17425 : SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; }
232 17425 : SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; }
233 17425 : bool isFixedCellHeight() const { return mbFixedCellHeight; }
234 17324 : bool getUnlimitedPage() const { return mbUnlimitedPage; }
235 17425 : bool getCellText() const { return mbCellText; }
236 17425 : bool getWordWrap() const { return mbWordWrap; }
237 17425 : bool getClipOnBounds() const { return mbClipOnBounds; }
238 :
239 : // compare operator
240 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
241 :
242 : // transformed clone operator
243 : virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const SAL_OVERRIDE;
244 :
245 : // provide unique ID
246 : DeclPrimitive2DIDBlock()
247 : };
248 : } // end of namespace primitive2d
249 : } // end of namespace drawinglayer
250 :
251 :
252 :
253 : namespace drawinglayer
254 : {
255 : namespace primitive2d
256 : {
257 0 : class SdrStretchTextPrimitive2D : public SdrTextPrimitive2D
258 : {
259 : private:
260 : // text range transformation from unit range ([0.0 .. 1.0]) to text range
261 : basegfx::B2DHomMatrix maTextRangeTransform;
262 :
263 : // bitfield
264 : bool mbFixedCellHeight : 1;
265 :
266 : protected:
267 : // local decomposition.
268 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const SAL_OVERRIDE;
269 :
270 : public:
271 : SdrStretchTextPrimitive2D(
272 : const SdrText* pSdrText,
273 : const OutlinerParaObject& rOutlinerParaObjectPtr,
274 : const basegfx::B2DHomMatrix& rTextRangeTransform,
275 : bool bFixedCellHeight);
276 :
277 : // get data
278 0 : const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
279 0 : bool isFixedCellHeight() const { return mbFixedCellHeight; }
280 :
281 : // compare operator
282 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
283 :
284 : // transformed clone operator
285 : virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const SAL_OVERRIDE;
286 :
287 : // provide unique ID
288 : DeclPrimitive2DIDBlock()
289 : };
290 : } // end of namespace primitive2d
291 : } // end of namespace drawinglayer
292 :
293 :
294 :
295 : namespace drawinglayer
296 : {
297 : namespace primitive2d
298 : {
299 136 : class SdrAutoFitTextPrimitive2D : public SdrTextPrimitive2D
300 : {
301 : private:
302 : ::basegfx::B2DHomMatrix maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range
303 :
304 : // bitfield
305 : bool mbWordWrap : 1; // for CustomShapes text layout
306 :
307 : protected:
308 : // local decomposition.
309 : virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const SAL_OVERRIDE;
310 :
311 : public:
312 : SdrAutoFitTextPrimitive2D(
313 : const SdrText* pSdrText,
314 : const OutlinerParaObject& rOutlinerParaObjectPtr,
315 : const ::basegfx::B2DHomMatrix& rTextRangeTransform,
316 : bool bWordWrap);
317 :
318 : // get data
319 71 : const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
320 71 : bool getWordWrap() const { return mbWordWrap; }
321 :
322 : // compare operator
323 : virtual bool operator==(const BasePrimitive2D& rPrimitive) const SAL_OVERRIDE;
324 :
325 : // transformed clone operator
326 : virtual SdrTextPrimitive2D* createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const SAL_OVERRIDE;
327 :
328 : // provide unique ID
329 : DeclPrimitive2DIDBlock()
330 : };
331 : } // end of namespace primitive2d
332 : } // end of namespace drawinglayer
333 :
334 :
335 :
336 : #endif // INCLUDED_SVX_INC_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
337 :
338 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|