1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
21 #define INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
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>
33 //////////////////////////////////////////////////////////////////////////////
37 //////////////////////////////////////////////////////////////////////////////
39 namespace drawinglayer
43 class SdrTextPrimitive2D
: public BufferedDecompositionPrimitive2D
46 // The text model data; this sould later just be the OutlinerParaObject or
48 ::tools::WeakReference
< SdrText
> mrSdrText
;
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
;
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
;
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
;
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
;
69 // #i101443# remember last TextBackgroundColor to decide if a new decomposition is
70 // needed because of background color change
71 Color maLastTextBackgroundColor
;
74 // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction
75 unsigned mbContainsPageField
: 1;
76 unsigned mbContainsPageCountField
: 1;
77 unsigned mbContainsOtherFields
: 1;
80 // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
81 Primitive2DSequence
encapsulateWithTextHierarchyBlockPrimitive2D(const Primitive2DSequence
& rCandidate
) const;
85 const SdrText
* pSdrText
,
86 const OutlinerParaObject
& rOutlinerParaObjectPtr
);
89 const SdrText
* getSdrText() const { return mrSdrText
.get(); }
90 const OutlinerParaObject
& getOutlinerParaObject() const { return maOutlinerParaObject
; }
93 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const;
95 // own get2DDecomposition to take aspect of decomposition with or without spell checker
97 virtual Primitive2DSequence
get2DDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const;
99 // transformed clone operator
100 virtual SdrTextPrimitive2D
* createTransformedClone(const basegfx::B2DHomMatrix
& rTransform
) const = 0;
102 } // end of namespace primitive2d
103 } // end of namespace drawinglayer
105 //////////////////////////////////////////////////////////////////////////////
107 namespace drawinglayer
109 namespace primitive2d
111 class SdrContourTextPrimitive2D
: public SdrTextPrimitive2D
114 // unit contour polygon (scaled to [0.0 .. 1.0])
115 basegfx::B2DPolyPolygon maUnitPolyPolygon
;
117 // complete contour polygon transform (scale, rotate, shear, translate)
118 basegfx::B2DHomMatrix maObjectTransform
;
121 // local decomposition.
122 virtual Primitive2DSequence
create2DDecomposition(const geometry::ViewInformation2D
& aViewInformation
) const;
125 SdrContourTextPrimitive2D(
126 const SdrText
* pSdrText
,
127 const OutlinerParaObject
& rOutlinerParaObjectPtr
,
128 const basegfx::B2DPolyPolygon
& rUnitPolyPolygon
,
129 const basegfx::B2DHomMatrix
& rObjectTransform
);
132 const basegfx::B2DPolyPolygon
& getUnitPolyPolygon() const { return maUnitPolyPolygon
; }
133 const basegfx::B2DHomMatrix
& getObjectTransform() const { return maObjectTransform
; }
136 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const;
138 // transformed clone operator
139 virtual SdrTextPrimitive2D
* createTransformedClone(const basegfx::B2DHomMatrix
& rTransform
) const;
142 DeclPrimitive2DIDBlock()
144 } // end of namespace primitive2d
145 } // end of namespace drawinglayer
147 //////////////////////////////////////////////////////////////////////////////
149 namespace drawinglayer
151 namespace primitive2d
153 class SdrPathTextPrimitive2D
: public SdrTextPrimitive2D
156 // the path to use. Each paragraph will use one Polygon.
157 basegfx::B2DPolyPolygon maPathPolyPolygon
;
159 // the Fontwork parameters
160 attribute::SdrFormTextAttribute maSdrFormTextAttribute
;
163 // local decomposition.
164 virtual Primitive2DSequence
create2DDecomposition(const geometry::ViewInformation2D
& aViewInformation
) const;
167 SdrPathTextPrimitive2D(
168 const SdrText
* pSdrText
,
169 const OutlinerParaObject
& rOutlinerParaObjectPtr
,
170 const basegfx::B2DPolyPolygon
& rPathPolyPolygon
,
171 const attribute::SdrFormTextAttribute
& rSdrFormTextAttribute
);
174 const basegfx::B2DPolyPolygon
& getPathPolyPolygon() const { return maPathPolyPolygon
; }
175 const attribute::SdrFormTextAttribute
& getSdrFormTextAttribute() const { return maSdrFormTextAttribute
; }
178 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const;
180 // transformed clone operator
181 virtual SdrTextPrimitive2D
* createTransformedClone(const basegfx::B2DHomMatrix
& rTransform
) const;
184 DeclPrimitive2DIDBlock()
186 } // end of namespace primitive2d
187 } // end of namespace drawinglayer
189 //////////////////////////////////////////////////////////////////////////////
191 namespace drawinglayer
193 namespace primitive2d
195 class SdrBlockTextPrimitive2D
: public SdrTextPrimitive2D
198 // text range transformation from unit range ([0.0 .. 1.0]) to text range
199 basegfx::B2DHomMatrix maTextRangeTransform
;
202 SdrTextHorzAdjust maSdrTextHorzAdjust
;
203 SdrTextVertAdjust maSdrTextVertAdjust
;
206 unsigned mbFixedCellHeight
: 1;
207 unsigned mbUnlimitedPage
: 1; // force layout with no text break
208 unsigned mbCellText
: 1; // this is a cell text as block text
209 unsigned mbWordWrap
: 1; // for CustomShapes text layout
210 unsigned mbClipOnBounds
: 1; // for CustomShapes text layout
213 // local decomposition.
214 virtual Primitive2DSequence
create2DDecomposition(const geometry::ViewInformation2D
& aViewInformation
) const;
217 SdrBlockTextPrimitive2D(
218 const SdrText
* pSdrText
,
219 const OutlinerParaObject
& rOutlinerParaObjectPtr
,
220 const basegfx::B2DHomMatrix
& rTextRangeTransform
,
221 SdrTextHorzAdjust aSdrTextHorzAdjust
,
222 SdrTextVertAdjust aSdrTextVertAdjust
,
223 bool bFixedCellHeight
,
230 const basegfx::B2DHomMatrix
& getTextRangeTransform() const { return maTextRangeTransform
; }
231 SdrTextHorzAdjust
getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust
; }
232 SdrTextVertAdjust
getSdrTextVertAdjust() const { return maSdrTextVertAdjust
; }
233 bool isFixedCellHeight() const { return mbFixedCellHeight
; }
234 bool getUnlimitedPage() const { return mbUnlimitedPage
; }
235 bool getCellText() const { return mbCellText
; }
236 bool getWordWrap() const { return mbWordWrap
; }
237 bool getClipOnBounds() const { return mbClipOnBounds
; }
240 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const;
242 // transformed clone operator
243 virtual SdrTextPrimitive2D
* createTransformedClone(const basegfx::B2DHomMatrix
& rTransform
) const;
246 DeclPrimitive2DIDBlock()
248 } // end of namespace primitive2d
249 } // end of namespace drawinglayer
251 //////////////////////////////////////////////////////////////////////////////
253 namespace drawinglayer
255 namespace primitive2d
257 class SdrStretchTextPrimitive2D
: public SdrTextPrimitive2D
260 // text range transformation from unit range ([0.0 .. 1.0]) to text range
261 basegfx::B2DHomMatrix maTextRangeTransform
;
264 unsigned mbFixedCellHeight
: 1;
267 // local decomposition.
268 virtual Primitive2DSequence
create2DDecomposition(const geometry::ViewInformation2D
& aViewInformation
) const;
271 SdrStretchTextPrimitive2D(
272 const SdrText
* pSdrText
,
273 const OutlinerParaObject
& rOutlinerParaObjectPtr
,
274 const basegfx::B2DHomMatrix
& rTextRangeTransform
,
275 bool bFixedCellHeight
);
278 const basegfx::B2DHomMatrix
& getTextRangeTransform() const { return maTextRangeTransform
; }
279 bool isFixedCellHeight() const { return mbFixedCellHeight
; }
282 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const;
284 // transformed clone operator
285 virtual SdrTextPrimitive2D
* createTransformedClone(const basegfx::B2DHomMatrix
& rTransform
) const;
288 DeclPrimitive2DIDBlock()
290 } // end of namespace primitive2d
291 } // end of namespace drawinglayer
293 //////////////////////////////////////////////////////////////////////////////
295 namespace drawinglayer
297 namespace primitive2d
299 class SdrAutoFitTextPrimitive2D
: public SdrTextPrimitive2D
302 ::basegfx::B2DHomMatrix maTextRangeTransform
; // text range transformation from unit range ([0.0 .. 1.0]) to text range
305 unsigned mbWordWrap
: 1; // for CustomShapes text layout
308 // local decomposition.
309 virtual Primitive2DSequence
create2DDecomposition(const geometry::ViewInformation2D
& aViewInformation
) const;
312 SdrAutoFitTextPrimitive2D(
313 const SdrText
* pSdrText
,
314 const OutlinerParaObject
& rOutlinerParaObjectPtr
,
315 const ::basegfx::B2DHomMatrix
& rTextRangeTransform
,
319 const basegfx::B2DHomMatrix
& getTextRangeTransform() const { return maTextRangeTransform
; }
320 bool getWordWrap() const { return mbWordWrap
; }
323 virtual bool operator==(const BasePrimitive2D
& rPrimitive
) const;
325 // transformed clone operator
326 virtual SdrTextPrimitive2D
* createTransformedClone(const ::basegfx::B2DHomMatrix
& rTransform
) const;
329 DeclPrimitive2DIDBlock()
331 } // end of namespace primitive2d
332 } // end of namespace drawinglayer
334 //////////////////////////////////////////////////////////////////////////////
336 #endif //INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
338 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */