Update git submodules
[LibreOffice.git] / svx / inc / sdr / primitive2d / sdrtextprimitive2d.hxx
blobddb0a4075d3db85ec6d65cb0f583e5d8b6cfa440
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 #pragma once
22 #include <drawinglayer/primitive2d/BufferedDecompositionPrimitive2D.hxx>
23 #include <basegfx/polygon/b2dpolypolygon.hxx>
24 #include <basegfx/matrix/b2dhommatrix.hxx>
25 #include <com/sun/star/drawing/XDrawPage.hpp>
26 #include <editeng/outlobj.hxx>
27 #include <tools/color.hxx>
28 #include <sdr/attribute/sdrformtextattribute.hxx>
29 #include <svx/sdtaitm.hxx>
30 #include <rtl/ref.hxx>
31 #include <unotools/weakref.hxx>
34 // predefines
35 class SdrText;
38 namespace drawinglayer::primitive2d
40 class SdrTextPrimitive2D : public BufferedDecompositionPrimitive2D
42 private:
43 // The text model data; this should later just be the OutlinerParaObject or
44 // something equal
45 ::unotools::WeakReference< SdrText > mxSdrText;
47 // #i97628#
48 // The text content; now as local OutlinerParaObject copy (internally RefCounted and
49 // COW) and in exclusive, local form as needed in a primitive
50 const OutlinerParaObject maOutlinerParaObject;
52 // remember last VisualizingPage for which a decomposition was made. If the new target
53 // is not given or different, the decomposition needs to be potentially removed
54 // for supporting e.g. page number change on MasterPage objects or the different
55 // field renderings in SubGeometry and MasterPage node
56 css::uno::Reference< css::drawing::XDrawPage > mxLastVisualizingPage;
58 // remember last PageNumber for which a decomposition was made. This is only used
59 // when mbContainsPageField is true, else it is 0
60 sal_Int16 mnLastPageNumber;
62 // remember last PageCount for which a decomposition was made. This is only used
63 // when mbContainsPageCountField is true, else it is 0
64 sal_Int16 mnLastPageCount;
66 // #i101443# remember last TextBackgroundColor to decide if a new decomposition is
67 // needed because of background color change
68 Color maLastTextBackgroundColor;
70 // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction
71 bool mbContainsPageField : 1;
72 bool mbContainsPageCountField : 1;
73 bool mbContainsOtherFields : 1;
75 protected:
76 // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
77 static Primitive2DReference encapsulateWithTextHierarchyBlockPrimitive2D(Primitive2DContainer&& aCandidate);
79 public:
80 SdrTextPrimitive2D(
81 const SdrText* pSdrText,
82 OutlinerParaObject aOutlinerParaObjectPtr);
84 // get data
85 const SdrText* getSdrText() const;
86 const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; }
88 // compare operator
89 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
91 // own get2DDecomposition to take aspect of decomposition with or without spell checker
92 // into account
93 virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
95 // transformed clone operator
96 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const = 0;
98 } // end of namespace drawinglayer::primitive2d
101 namespace drawinglayer::primitive2d
103 class SdrContourTextPrimitive2D final : public SdrTextPrimitive2D
105 private:
106 // unit contour polygon (scaled to [0.0 .. 1.0])
107 basegfx::B2DPolyPolygon maUnitPolyPolygon;
109 // complete contour polygon transform (scale, rotate, shear, translate)
110 basegfx::B2DHomMatrix maObjectTransform;
112 // local decomposition.
113 virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override;
115 public:
116 SdrContourTextPrimitive2D(
117 const SdrText* pSdrText,
118 const OutlinerParaObject& rOutlinerParaObjectPtr,
119 basegfx::B2DPolyPolygon aUnitPolyPolygon,
120 basegfx::B2DHomMatrix aObjectTransform);
122 // get data
123 const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; }
124 const basegfx::B2DHomMatrix& getObjectTransform() const { return maObjectTransform; }
126 // compare operator
127 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
129 // transformed clone operator
130 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
132 // provide unique ID
133 virtual sal_uInt32 getPrimitive2DID() const override;
135 } // end of namespace drawinglayer::primitive2d
138 namespace drawinglayer::primitive2d
140 class SdrPathTextPrimitive2D final : public SdrTextPrimitive2D
142 private:
143 // the path to use. Each paragraph will use one Polygon.
144 basegfx::B2DPolyPolygon maPathPolyPolygon;
146 // the Fontwork parameters
147 attribute::SdrFormTextAttribute maSdrFormTextAttribute;
149 // local decomposition.
150 virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override;
152 public:
153 SdrPathTextPrimitive2D(
154 const SdrText* pSdrText,
155 const OutlinerParaObject& rOutlinerParaObjectPtr,
156 basegfx::B2DPolyPolygon aPathPolyPolygon,
157 attribute::SdrFormTextAttribute aSdrFormTextAttribute);
159 // get data
160 const basegfx::B2DPolyPolygon& getPathPolyPolygon() const { return maPathPolyPolygon; }
161 const attribute::SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; }
163 // compare operator
164 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
166 // transformed clone operator
167 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
169 // provide unique ID
170 virtual sal_uInt32 getPrimitive2DID() const override;
172 } // end of namespace drawinglayer::primitive2d
175 namespace drawinglayer::primitive2d
177 class SdrBlockTextPrimitive2D final : public SdrTextPrimitive2D
179 private:
180 // text range transformation from unit range ([0.0 .. 1.0]) to text range
181 basegfx::B2DHomMatrix maTextRangeTransform;
183 // text alignments
184 SdrTextHorzAdjust maSdrTextHorzAdjust;
185 SdrTextVertAdjust maSdrTextVertAdjust;
187 bool mbFixedCellHeight : 1;
188 bool mbUnlimitedPage : 1; // force layout with no text break
189 bool mbCellText : 1; // this is a cell text as block text
190 bool mbWordWrap : 1; // for CustomShapes text layout
192 // local decomposition.
193 virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override;
195 public:
196 SdrBlockTextPrimitive2D(
197 const SdrText* pSdrText,
198 const OutlinerParaObject& rOutlinerParaObjectPtr,
199 basegfx::B2DHomMatrix aTextRangeTransform,
200 SdrTextHorzAdjust aSdrTextHorzAdjust,
201 SdrTextVertAdjust aSdrTextVertAdjust,
202 bool bFixedCellHeight,
203 bool bUnlimitedPage,
204 bool bCellText,
205 bool bWordWrap);
207 // get data
208 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
209 SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; }
210 SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; }
211 bool isFixedCellHeight() const { return mbFixedCellHeight; }
212 bool getUnlimitedPage() const { return mbUnlimitedPage; }
213 bool getCellText() const { return mbCellText; }
214 bool getWordWrap() const { return mbWordWrap; }
216 // compare operator
217 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
219 // transformed clone operator
220 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
222 // provide unique ID
223 virtual sal_uInt32 getPrimitive2DID() const override;
225 } // end of namespace drawinglayer::primitive2d
228 namespace drawinglayer::primitive2d
230 class SdrStretchTextPrimitive2D final : public SdrTextPrimitive2D
232 private:
233 // text range transformation from unit range ([0.0 .. 1.0]) to text range
234 basegfx::B2DHomMatrix maTextRangeTransform;
236 bool mbFixedCellHeight : 1;
238 // local decomposition.
239 virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override;
241 public:
242 SdrStretchTextPrimitive2D(
243 const SdrText* pSdrText,
244 const OutlinerParaObject& rOutlinerParaObjectPtr,
245 basegfx::B2DHomMatrix aTextRangeTransform,
246 bool bFixedCellHeight);
248 // get data
249 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
250 bool isFixedCellHeight() const { return mbFixedCellHeight; }
252 // compare operator
253 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
255 // transformed clone operator
256 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
258 // provide unique ID
259 virtual sal_uInt32 getPrimitive2DID() const override;
261 } // end of namespace drawinglayer::primitive2d
264 namespace drawinglayer::primitive2d
266 class SdrAutoFitTextPrimitive2D final : public SdrTextPrimitive2D
268 private:
269 ::basegfx::B2DHomMatrix maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range
271 bool mbWordWrap : 1; // for CustomShapes text layout
272 bool mbFixedCellHeight : 1;
274 // local decomposition.
275 virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override;
277 public:
278 SdrAutoFitTextPrimitive2D(
279 const SdrText* pSdrText,
280 const OutlinerParaObject& rOutlinerParaObjectPtr,
281 ::basegfx::B2DHomMatrix aTextRangeTransform,
282 bool bWordWrap,
283 bool bFixedCellHeight);
285 // get data
286 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
287 bool getWordWrap() const { return mbWordWrap; }
288 bool isFixedCellHeight() const { return mbFixedCellHeight; }
290 // compare operator
291 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
293 // transformed clone operator
294 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const override;
296 // provide unique ID
297 virtual sal_uInt32 getPrimitive2DID() const override;
299 } // end of namespace drawinglayer::primitive2d
301 namespace drawinglayer::primitive2d
303 class SdrChainedTextPrimitive2D final : public SdrTextPrimitive2D
305 private:
306 // XXX: might have position of overflowing text
308 ::basegfx::B2DHomMatrix maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range
310 // local decomposition.
311 virtual Primitive2DReference create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const override;
313 public:
314 SdrChainedTextPrimitive2D(
315 const SdrText* pSdrText,
316 const OutlinerParaObject& rOutlinerParaObjectPtrs,
317 ::basegfx::B2DHomMatrix aTextRangeTransform);
319 // get data
320 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
321 //bool getWordWrap() const { return true; } // XXX: Hack! Should have a proper implementation//
323 // compare operator
324 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
326 // transformed clone operator
327 virtual rtl::Reference<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
329 // provide unique ID
330 virtual sal_uInt32 getPrimitive2DID() const override;
332 } // end of namespace drawinglayer::primitive2d
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */