Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / svx / inc / sdr / primitive2d / sdrtextprimitive2d.hxx
blob84bacaf129aa5ec2d7106c19b24148af75ef95c5
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 <svx/sdr/attribute/sdrformtextattribute.hxx>
30 #include <tools/weakbase.hxx>
31 #include <svx/sdtaitm.hxx>
34 // predefines
35 class SdrText;
38 namespace drawinglayer
40 namespace primitive2d
42 class SdrTextPrimitive2D : public BufferedDecompositionPrimitive2D
44 private:
45 // The text model data; this should later just be the OutlinerParaObject or
46 // something equal
47 ::tools::WeakReference< SdrText > mrSdrText;
49 // #i97628#
50 // The text content; now as local OutlinerParaObject copy (internally RefCounted and
51 // COW) and in exclusive, local form as needed in a primitive
52 const OutlinerParaObject maOutlinerParaObject;
54 // remember last VisualizingPage for which a decomposition was made. If the new target
55 // is not given or different, the decomposition needs to be potentially removed
56 // for supporting e.g. page number change on MasterPage objects or the different
57 // field renderings in SubGeometry and MasterPage node
58 css::uno::Reference< css::drawing::XDrawPage > mxLastVisualizingPage;
60 // remember last PageNumber for which a decomposition was made. This is only used
61 // when mbContainsPageField is true, else it is 0
62 sal_Int16 mnLastPageNumber;
64 // remember last PageCount for which a decomposition was made. This is only used
65 // when mbContainsPageCountField is true, else it is 0
66 sal_Int16 mnLastPageCount;
68 // #i101443# remember last TextBackgroundColor to decide if a new decomposition is
69 // needed because of background color change
70 Color maLastTextBackgroundColor;
72 // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction
73 bool mbContainsPageField : 1;
74 bool mbContainsPageCountField : 1;
75 bool mbContainsOtherFields : 1;
77 protected:
78 // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
79 static void encapsulateWithTextHierarchyBlockPrimitive2D(Primitive2DContainer& rContainer, const Primitive2DContainer& rCandidate);
81 public:
82 SdrTextPrimitive2D(
83 const SdrText* pSdrText,
84 const OutlinerParaObject& rOutlinerParaObjectPtr);
86 // get data
87 const SdrText* getSdrText() const;
88 const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; }
90 // compare operator
91 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
93 // own get2DDecomposition to take aspect of decomposition with or without spell checker
94 // into account
95 virtual void get2DDecomposition(Primitive2DDecompositionVisitor& rVisitor, const geometry::ViewInformation2D& rViewInformation) const override;
97 // transformed clone operator
98 virtual std::unique_ptr<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const = 0;
100 } // end of namespace primitive2d
101 } // end of namespace drawinglayer
104 namespace drawinglayer
106 namespace primitive2d
108 class SdrContourTextPrimitive2D : public SdrTextPrimitive2D
110 private:
111 // unit contour polygon (scaled to [0.0 .. 1.0])
112 basegfx::B2DPolyPolygon const maUnitPolyPolygon;
114 // complete contour polygon transform (scale, rotate, shear, translate)
115 basegfx::B2DHomMatrix const maObjectTransform;
117 protected:
118 // local decomposition.
119 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
121 public:
122 SdrContourTextPrimitive2D(
123 const SdrText* pSdrText,
124 const OutlinerParaObject& rOutlinerParaObjectPtr,
125 const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
126 const basegfx::B2DHomMatrix& rObjectTransform);
128 // get data
129 const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; }
130 const basegfx::B2DHomMatrix& getObjectTransform() const { return maObjectTransform; }
132 // compare operator
133 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
135 // transformed clone operator
136 virtual std::unique_ptr<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
138 // provide unique ID
139 DeclPrimitive2DIDBlock()
141 } // end of namespace primitive2d
142 } // end of namespace drawinglayer
145 namespace drawinglayer
147 namespace primitive2d
149 class SdrPathTextPrimitive2D : public SdrTextPrimitive2D
151 private:
152 // the path to use. Each paragraph will use one Polygon.
153 basegfx::B2DPolyPolygon const maPathPolyPolygon;
155 // the Fontwork parameters
156 attribute::SdrFormTextAttribute const maSdrFormTextAttribute;
158 protected:
159 // local decomposition.
160 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
162 public:
163 SdrPathTextPrimitive2D(
164 const SdrText* pSdrText,
165 const OutlinerParaObject& rOutlinerParaObjectPtr,
166 const basegfx::B2DPolyPolygon& rPathPolyPolygon,
167 const attribute::SdrFormTextAttribute& rSdrFormTextAttribute);
169 // get data
170 const basegfx::B2DPolyPolygon& getPathPolyPolygon() const { return maPathPolyPolygon; }
171 const attribute::SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; }
173 // compare operator
174 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
176 // transformed clone operator
177 virtual std::unique_ptr<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
179 // provide unique ID
180 DeclPrimitive2DIDBlock()
182 } // end of namespace primitive2d
183 } // end of namespace drawinglayer
186 namespace drawinglayer
188 namespace primitive2d
190 class SdrBlockTextPrimitive2D : public SdrTextPrimitive2D
192 private:
193 // text range transformation from unit range ([0.0 .. 1.0]) to text range
194 basegfx::B2DHomMatrix const maTextRangeTransform;
196 // text alignments
197 SdrTextHorzAdjust const maSdrTextHorzAdjust;
198 SdrTextVertAdjust const maSdrTextVertAdjust;
200 bool const mbFixedCellHeight : 1;
201 bool const mbUnlimitedPage : 1; // force layout with no text break
202 bool const mbCellText : 1; // this is a cell text as block text
203 bool const mbWordWrap : 1; // for CustomShapes text layout
204 bool const mbClipOnBounds : 1; // for CustomShapes text layout
206 protected:
207 // local decomposition.
208 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
210 public:
211 SdrBlockTextPrimitive2D(
212 const SdrText* pSdrText,
213 const OutlinerParaObject& rOutlinerParaObjectPtr,
214 const basegfx::B2DHomMatrix& rTextRangeTransform,
215 SdrTextHorzAdjust aSdrTextHorzAdjust,
216 SdrTextVertAdjust aSdrTextVertAdjust,
217 bool bFixedCellHeight,
218 bool bUnlimitedPage,
219 bool bCellText,
220 bool bWordWrap,
221 bool bClipOnBounds);
223 // get data
224 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
225 SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; }
226 SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; }
227 bool isFixedCellHeight() const { return mbFixedCellHeight; }
228 bool getUnlimitedPage() const { return mbUnlimitedPage; }
229 bool getCellText() const { return mbCellText; }
230 bool getWordWrap() const { return mbWordWrap; }
231 bool getClipOnBounds() const { return mbClipOnBounds; }
233 // compare operator
234 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
236 // transformed clone operator
237 virtual std::unique_ptr<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
239 // provide unique ID
240 DeclPrimitive2DIDBlock()
242 } // end of namespace primitive2d
243 } // end of namespace drawinglayer
246 namespace drawinglayer
248 namespace primitive2d
250 class SdrStretchTextPrimitive2D : public SdrTextPrimitive2D
252 private:
253 // text range transformation from unit range ([0.0 .. 1.0]) to text range
254 basegfx::B2DHomMatrix const maTextRangeTransform;
256 bool const mbFixedCellHeight : 1;
258 protected:
259 // local decomposition.
260 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
262 public:
263 SdrStretchTextPrimitive2D(
264 const SdrText* pSdrText,
265 const OutlinerParaObject& rOutlinerParaObjectPtr,
266 const basegfx::B2DHomMatrix& rTextRangeTransform,
267 bool bFixedCellHeight);
269 // get data
270 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
271 bool isFixedCellHeight() const { return mbFixedCellHeight; }
273 // compare operator
274 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
276 // transformed clone operator
277 virtual std::unique_ptr<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
279 // provide unique ID
280 DeclPrimitive2DIDBlock()
282 } // end of namespace primitive2d
283 } // end of namespace drawinglayer
286 namespace drawinglayer
288 namespace primitive2d
290 class SdrAutoFitTextPrimitive2D : public SdrTextPrimitive2D
292 private:
293 ::basegfx::B2DHomMatrix const maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range
295 bool const mbWordWrap : 1; // for CustomShapes text layout
297 protected:
298 // local decomposition.
299 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
301 public:
302 SdrAutoFitTextPrimitive2D(
303 const SdrText* pSdrText,
304 const OutlinerParaObject& rOutlinerParaObjectPtr,
305 const ::basegfx::B2DHomMatrix& rTextRangeTransform,
306 bool bWordWrap);
308 // get data
309 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
310 bool getWordWrap() const { return mbWordWrap; }
312 // compare operator
313 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
315 // transformed clone operator
316 virtual std::unique_ptr<SdrTextPrimitive2D> createTransformedClone(const ::basegfx::B2DHomMatrix& rTransform) const override;
318 // provide unique ID
319 DeclPrimitive2DIDBlock()
321 } // end of namespace primitive2d
322 } // end of namespace drawinglayer
324 namespace drawinglayer
326 namespace primitive2d
328 class SdrChainedTextPrimitive2D : public SdrTextPrimitive2D
330 private:
331 // XXX: might have position of overflowing text
333 ::basegfx::B2DHomMatrix const maTextRangeTransform; // text range transformation from unit range ([0.0 .. 1.0]) to text range
334 protected:
335 // local decomposition.
336 virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& aViewInformation) const override;
338 public:
339 SdrChainedTextPrimitive2D(
340 const SdrText* pSdrText,
341 const OutlinerParaObject& rOutlinerParaObjectPtrs,
342 const ::basegfx::B2DHomMatrix& rTextRangeTransform);
344 // get data
345 const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
346 //bool getWordWrap() const { return true; } // XXX: Hack! Should have a proper implementation//
348 // compare operator
349 virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
351 // transformed clone operator
352 virtual std::unique_ptr<SdrTextPrimitive2D> createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const override;
354 // provide unique ID
355 DeclPrimitive2DIDBlock()
357 } // end of namespace primitive2d
358 } // end of namespace drawinglayer
361 #endif // INCLUDED_SVX_INC_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
363 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */