bump product version to 7.2.5.1
[LibreOffice.git] / svx / inc / sdr / primitive2d / sdrtextprimitive2d.hxx
blob8a9f25b9b243d34ac362d1f55c50de13da4a7043
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_SVX_INC_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
21 #define INCLUDED_SVX_INC_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 <sdr/attribute/sdrformtextattribute.hxx>
30 #include <tools/weakbase.h>
31 #include <svx/sdtaitm.hxx>
32 #include <rtl/ref.hxx>
35 // predefines
36 class SdrText;
39 namespace drawinglayer::primitive2d
41 class SdrTextPrimitive2D : public BufferedDecompositionPrimitive2D
43 private:
44 // The text model data; this should later just be the OutlinerParaObject or
45 // something equal
46 ::tools::WeakReference< SdrText > mrSdrText;
48 // #i97628#
49 // The text content; now as local OutlinerParaObject copy (internally RefCounted and
50 // COW) and in exclusive, local form as needed in a primitive
51 const OutlinerParaObject maOutlinerParaObject;
53 // remember last VisualizingPage for which a decomposition was made. If the new target
54 // is not given or different, the decomposition needs to be potentially removed
55 // for supporting e.g. page number change on MasterPage objects or the different
56 // field renderings in SubGeometry and MasterPage node
57 css::uno::Reference< css::drawing::XDrawPage > mxLastVisualizingPage;
59 // remember last PageNumber for which a decomposition was made. This is only used
60 // when mbContainsPageField is true, else it is 0
61 sal_Int16 mnLastPageNumber;
63 // remember last PageCount for which a decomposition was made. This is only used
64 // when mbContainsPageCountField is true, else it is 0
65 sal_Int16 mnLastPageCount;
67 // #i101443# remember last TextBackgroundColor to decide if a new decomposition is
68 // needed because of background color change
69 Color maLastTextBackgroundColor;
71 // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction
72 bool mbContainsPageField : 1;
73 bool mbContainsPageCountField : 1;
74 bool mbContainsOtherFields : 1;
76 protected:
77 // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
78 static void encapsulateWithTextHierarchyBlockPrimitive2D(Primitive2DContainer& rContainer, const Primitive2DContainer& rCandidate);
80 public:
81 SdrTextPrimitive2D(
82 const SdrText* pSdrText,
83 const OutlinerParaObject& rOutlinerParaObjectPtr);
85 // get data
86 const SdrText* getSdrText() const;
87 const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; }
89 // compare operator
90 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
92 // own get2DDecomposition to take aspect of decomposition with or without spell checker
93 // into account
94 virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
96 // transformed clone operator
97 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const = 0;
99 } // end of namespace drawinglayer::primitive2d
102 namespace drawinglayer::primitive2d
104 class SdrContourTextPrimitive2D final : public SdrTextPrimitive2D
106 private:
107 // unit contour polygon (scaled to [0.0 .. 1.0])
108 basegfx::B2DPolyPolygon maUnitPolyPolygon;
110 // complete contour polygon transform (scale, rotate, shear, translate)
111 basegfx::B2DHomMatrix maObjectTransform;
113 // local decomposition.
114 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
116 public:
117 SdrContourTextPrimitive2D(
118 const SdrText* pSdrText,
119 const OutlinerParaObject& rOutlinerParaObjectPtr,
120 const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
121 const basegfx::B2DHomMatrix& rObjectTransform);
123 // get data
124 const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; }
125 const basegfx::B2DHomMatrix& getObjectTransform() const { return maObjectTransform; }
127 // compare operator
128 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
130 // transformed clone operator
131 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
133 // provide unique ID
134 virtual sal_uInt32 getPrimitive2DID() const override;
136 } // end of namespace drawinglayer::primitive2d
139 namespace drawinglayer::primitive2d
141 class SdrPathTextPrimitive2D final : public SdrTextPrimitive2D
143 private:
144 // the path to use. Each paragraph will use one Polygon.
145 basegfx::B2DPolyPolygon maPathPolyPolygon;
147 // the Fontwork parameters
148 attribute::SdrFormTextAttribute maSdrFormTextAttribute;
150 // local decomposition.
151 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
153 public:
154 SdrPathTextPrimitive2D(
155 const SdrText* pSdrText,
156 const OutlinerParaObject& rOutlinerParaObjectPtr,
157 const basegfx::B2DPolyPolygon& rPathPolyPolygon,
158 const attribute::SdrFormTextAttribute& rSdrFormTextAttribute);
160 // get data
161 const basegfx::B2DPolyPolygon& getPathPolyPolygon() const { return maPathPolyPolygon; }
162 const attribute::SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; }
164 // compare operator
165 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
167 // transformed clone operator
168 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
170 // provide unique ID
171 virtual sal_uInt32 getPrimitive2DID() const override;
173 } // end of namespace drawinglayer::primitive2d
176 namespace drawinglayer::primitive2d
178 class SdrBlockTextPrimitive2D final : public SdrTextPrimitive2D
180 private:
181 // text range transformation from unit range ([0.0 .. 1.0]) to text range
182 basegfx::B2DHomMatrix maTextRangeTransform;
184 // text alignments
185 SdrTextHorzAdjust maSdrTextHorzAdjust;
186 SdrTextVertAdjust maSdrTextVertAdjust;
188 bool mbFixedCellHeight : 1;
189 bool mbUnlimitedPage : 1; // force layout with no text break
190 bool mbCellText : 1; // this is a cell text as block text
191 bool mbWordWrap : 1; // for CustomShapes text layout
193 // local decomposition.
194 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
196 public:
197 SdrBlockTextPrimitive2D(
198 const SdrText* pSdrText,
199 const OutlinerParaObject& rOutlinerParaObjectPtr,
200 const basegfx::B2DHomMatrix& rTextRangeTransform,
201 SdrTextHorzAdjust aSdrTextHorzAdjust,
202 SdrTextVertAdjust aSdrTextVertAdjust,
203 bool bFixedCellHeight,
204 bool bUnlimitedPage,
205 bool bCellText,
206 bool bWordWrap);
208 // get data
209 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
210 SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; }
211 SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; }
212 bool isFixedCellHeight() const { return mbFixedCellHeight; }
213 bool getUnlimitedPage() const { return mbUnlimitedPage; }
214 bool getCellText() const { return mbCellText; }
215 bool getWordWrap() const { return mbWordWrap; }
217 // compare operator
218 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
220 // transformed clone operator
221 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
223 // provide unique ID
224 virtual sal_uInt32 getPrimitive2DID() const override;
226 } // end of namespace drawinglayer::primitive2d
229 namespace drawinglayer::primitive2d
231 class SdrStretchTextPrimitive2D final : public SdrTextPrimitive2D
233 private:
234 // text range transformation from unit range ([0.0 .. 1.0]) to text range
235 basegfx::B2DHomMatrix maTextRangeTransform;
237 bool mbFixedCellHeight : 1;
239 // local decomposition.
240 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
242 public:
243 SdrStretchTextPrimitive2D(
244 const SdrText* pSdrText,
245 const OutlinerParaObject& rOutlinerParaObjectPtr,
246 const basegfx::B2DHomMatrix& rTextRangeTransform,
247 bool bFixedCellHeight);
249 // get data
250 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
251 bool isFixedCellHeight() const { return mbFixedCellHeight; }
253 // compare operator
254 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
256 // transformed clone operator
257 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
259 // provide unique ID
260 virtual sal_uInt32 getPrimitive2DID() const override;
262 } // end of namespace drawinglayer::primitive2d
265 namespace drawinglayer::primitive2d
267 class SdrAutoFitTextPrimitive2D final : public SdrTextPrimitive2D
269 private:
270 ::basegfx::B2DHomMatrix maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range
272 bool mbWordWrap : 1; // for CustomShapes text layout
274 // local decomposition.
275 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
277 public:
278 SdrAutoFitTextPrimitive2D(
279 const SdrText* pSdrText,
280 const OutlinerParaObject& rOutlinerParaObjectPtr,
281 const ::basegfx::B2DHomMatrix& rTextRangeTransform,
282 bool bWordWrap);
284 // get data
285 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
286 bool getWordWrap() const { return mbWordWrap; }
288 // compare operator
289 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
291 // transformed clone operator
292 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const override;
294 // provide unique ID
295 virtual sal_uInt32 getPrimitive2DID() const override;
297 } // end of namespace drawinglayer::primitive2d
299 namespace drawinglayer::primitive2d
301 class SdrChainedTextPrimitive2D final : public SdrTextPrimitive2D
303 private:
304 // XXX: might have position of overflowing text
306 ::basegfx::B2DHomMatrix maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range
308 // local decomposition.
309 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
311 public:
312 SdrChainedTextPrimitive2D(
313 const SdrText* pSdrText,
314 const OutlinerParaObject& rOutlinerParaObjectPtrs,
315 const ::basegfx::B2DHomMatrix& rTextRangeTransform);
317 // get data
318 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
319 //bool getWordWrap() const { return true; } // XXX: Hack! Should have a proper implementation//
321 // compare operator
322 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
324 // transformed clone operator
325 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
327 // provide unique ID
328 virtual sal_uInt32 getPrimitive2DID() const override;
330 } // end of namespace drawinglayer::primitive2d
333 #endif // INCLUDED_SVX_INC_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
335 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */