xref: /AOO41X/main/svx/inc/svx/sdr/primitive2d/sdrtextprimitive2d.hxx (revision 3334a7e6acdae9820fa1a6f556bb10129a8de6b2)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
25 #define INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/primitive2d/baseprimitive2d.hxx>
28 #include <basegfx/polygon/b2dpolypolygon.hxx>
29 #include <basegfx/matrix/b2dhommatrix.hxx>
30 #include <com/sun/star/drawing/XDrawPage.hpp>
31 #include <editeng/outlobj.hxx>
32 #include <tools/color.hxx>
33 #include <svx/sdr/attribute/sdrformtextattribute.hxx>
34 #include <tools/weakbase.hxx>
35 #include <svx/sdtaitm.hxx>
36 
37 //////////////////////////////////////////////////////////////////////////////
38 // predefines
39 class SdrText;
40 
41 //////////////////////////////////////////////////////////////////////////////
42 
43 namespace drawinglayer
44 {
45     namespace primitive2d
46     {
47         class SdrTextPrimitive2D : public BufferedDecompositionPrimitive2D
48         {
49         private:
50             // The text model data; this sould later just be the OutlinerParaObject or
51             // something equal
52             ::tools::WeakReference< SdrText >       mrSdrText;
53 
54             // #i97628#
55             // The text content; now as local OutlinerParaObject copy (internally RefCounted and
56             // COW) and in exclusive, local form as needed in a primitive
57             const OutlinerParaObject                maOutlinerParaObject;
58 
59             // remeber last VisualizingPage for which a decomposition was made. If the new target
60             // is not given or different, the decomposition needs to be potentially removed
61             // for supporting e.g. page number change on MasterPage objects or the different
62             // field renderings in SubGeometry and MasterPage mnode
63             com::sun::star::uno::Reference< com::sun::star::drawing::XDrawPage > mxLastVisualizingPage;
64 
65             // remember last PageNumber for which a decomposition was made. This is only used
66             // when mbContainsPageField is true, else it is 0
67             sal_Int16                               mnLastPageNumber;
68 
69             // remember last PageCount for which a decomposition was made. This is only used
70             // when mbContainsPageCountField is true, else it is 0
71             sal_Int16                               mnLastPageCount;
72 
73             // #i101443# remember last TextBackgroundColor to decide if a new decomposition is
74             // needed because of background color change
75             Color                                   maLastTextBackgroundColor;
76 
77             // bitfield
78             // is there a PageNumber, Header, Footer or DateTimeField used? Evaluated at construction
79             unsigned                                mbContainsPageField : 1;
80             unsigned                                mbContainsPageCountField : 1;
81             unsigned                                mbContainsOtherFields : 1;
82 
83         protected:
84             // support for XTEXT_PAINTSHAPE_BEGIN/XTEXT_PAINTSHAPE_END Metafile comments
85             Primitive2DSequence encapsulateWithTextHierarchyBlockPrimitive2D(const Primitive2DSequence& rCandidate) const;
86 
87         public:
88             SdrTextPrimitive2D(
89                 const SdrText* pSdrText,
90                 const OutlinerParaObject& rOutlinerParaObjectPtr);
91 
92             // get data
getSdrText() const93             const SdrText* getSdrText() const { return mrSdrText.get(); }
getOutlinerParaObject() const94             const OutlinerParaObject& getOutlinerParaObject() const { return maOutlinerParaObject; }
95 
96             // compare operator
97             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
98 
99             // own get2DDecomposition to take aspect of decomposition with or without spell checker
100             // into account
101             virtual Primitive2DSequence get2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
102 
103             // transformed clone operator
104             virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const = 0;
105         };
106     } // end of namespace primitive2d
107 } // end of namespace drawinglayer
108 
109 //////////////////////////////////////////////////////////////////////////////
110 
111 namespace drawinglayer
112 {
113     namespace primitive2d
114     {
115         class SdrContourTextPrimitive2D : public SdrTextPrimitive2D
116         {
117         private:
118             // unit contour polygon (scaled to [0.0 .. 1.0])
119             basegfx::B2DPolyPolygon             maUnitPolyPolygon;
120 
121             // complete contour polygon transform (scale, rotate, shear, translate)
122             basegfx::B2DHomMatrix               maObjectTransform;
123 
124         protected:
125             // local decomposition.
126             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
127 
128         public:
129             SdrContourTextPrimitive2D(
130                 const SdrText* pSdrText,
131                 const OutlinerParaObject& rOutlinerParaObjectPtr,
132                 const basegfx::B2DPolyPolygon& rUnitPolyPolygon,
133                 const basegfx::B2DHomMatrix& rObjectTransform);
134 
135             // get data
getUnitPolyPolygon() const136             const basegfx::B2DPolyPolygon& getUnitPolyPolygon() const { return maUnitPolyPolygon; }
getObjectTransform() const137             const basegfx::B2DHomMatrix& getObjectTransform() const { return maObjectTransform; }
138 
139             // compare operator
140             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
141 
142             // transformed clone operator
143             virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const;
144 
145             // provide unique ID
146             DeclPrimitrive2DIDBlock()
147         };
148     } // end of namespace primitive2d
149 } // end of namespace drawinglayer
150 
151 //////////////////////////////////////////////////////////////////////////////
152 
153 namespace drawinglayer
154 {
155     namespace primitive2d
156     {
157         class SdrPathTextPrimitive2D : public SdrTextPrimitive2D
158         {
159         private:
160             // the path to use. Each paragraph will use one Polygon.
161             basegfx::B2DPolyPolygon             maPathPolyPolygon;
162 
163             // the Fontwork parameters
164             attribute::SdrFormTextAttribute     maSdrFormTextAttribute;
165 
166         protected:
167             // local decomposition.
168             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
169 
170         public:
171             SdrPathTextPrimitive2D(
172                 const SdrText* pSdrText,
173                 const OutlinerParaObject& rOutlinerParaObjectPtr,
174                 const basegfx::B2DPolyPolygon& rPathPolyPolygon,
175                 const attribute::SdrFormTextAttribute& rSdrFormTextAttribute);
176 
177             // get data
getPathPolyPolygon() const178             const basegfx::B2DPolyPolygon& getPathPolyPolygon() const { return maPathPolyPolygon; }
getSdrFormTextAttribute() const179             const attribute::SdrFormTextAttribute& getSdrFormTextAttribute() const { return maSdrFormTextAttribute; }
180 
181             // compare operator
182             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
183 
184             // transformed clone operator
185             virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const;
186 
187             // provide unique ID
188             DeclPrimitrive2DIDBlock()
189         };
190     } // end of namespace primitive2d
191 } // end of namespace drawinglayer
192 
193 //////////////////////////////////////////////////////////////////////////////
194 
195 namespace drawinglayer
196 {
197     namespace primitive2d
198     {
199         class SdrBlockTextPrimitive2D : public SdrTextPrimitive2D
200         {
201         private:
202             // text range transformation from unit range ([0.0 .. 1.0]) to text range
203             basegfx::B2DHomMatrix                   maTextRangeTransform;
204 
205             // text alignments
206             SdrTextHorzAdjust                       maSdrTextHorzAdjust;
207             SdrTextVertAdjust                       maSdrTextVertAdjust;
208 
209             // bitfield
210             unsigned                                mbFixedCellHeight : 1;
211             unsigned                                mbUnlimitedPage : 1;    // force layout with no text break
212             unsigned                                mbCellText : 1;         // this is a cell text as block text
213             unsigned                                mbWordWrap : 1;         // for CustomShapes text layout
214             unsigned                                mbClipOnBounds : 1;     // for CustomShapes text layout
215 
216         protected:
217             // local decomposition.
218             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
219 
220         public:
221             SdrBlockTextPrimitive2D(
222                 const SdrText* pSdrText,
223                 const OutlinerParaObject& rOutlinerParaObjectPtr,
224                 const basegfx::B2DHomMatrix& rTextRangeTransform,
225                 SdrTextHorzAdjust aSdrTextHorzAdjust,
226                 SdrTextVertAdjust aSdrTextVertAdjust,
227                 bool bFixedCellHeight,
228                 bool bUnlimitedPage,
229                 bool bCellText,
230                 bool bWordWrap,
231                 bool bClipOnBounds);
232 
233             // get data
getTextRangeTransform() const234             const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
getSdrTextHorzAdjust() const235             SdrTextHorzAdjust getSdrTextHorzAdjust() const { return maSdrTextHorzAdjust; }
getSdrTextVertAdjust() const236             SdrTextVertAdjust getSdrTextVertAdjust() const { return maSdrTextVertAdjust; }
isFixedCellHeight() const237             bool isFixedCellHeight() const { return mbFixedCellHeight; }
getUnlimitedPage() const238             bool getUnlimitedPage() const { return mbUnlimitedPage; }
getCellText() const239             bool getCellText() const { return mbCellText; }
getWordWrap() const240             bool getWordWrap() const { return mbWordWrap; }
getClipOnBounds() const241             bool getClipOnBounds() const { return mbClipOnBounds; }
242 
243             // compare operator
244             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
245 
246             // transformed clone operator
247             virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const;
248 
249             // provide unique ID
250             DeclPrimitrive2DIDBlock()
251         };
252     } // end of namespace primitive2d
253 } // end of namespace drawinglayer
254 
255 //////////////////////////////////////////////////////////////////////////////
256 
257 namespace drawinglayer
258 {
259     namespace primitive2d
260     {
261         class SdrStretchTextPrimitive2D : public SdrTextPrimitive2D
262         {
263         private:
264             // text range transformation from unit range ([0.0 .. 1.0]) to text range
265             basegfx::B2DHomMatrix                   maTextRangeTransform;
266 
267             // bitfield
268             unsigned                                mbFixedCellHeight : 1;
269 
270         protected:
271             // local decomposition.
272             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const;
273 
274         public:
275             SdrStretchTextPrimitive2D(
276                 const SdrText* pSdrText,
277                 const OutlinerParaObject& rOutlinerParaObjectPtr,
278                 const basegfx::B2DHomMatrix& rTextRangeTransform,
279                 bool bFixedCellHeight);
280 
281             // get data
getTextRangeTransform() const282             const basegfx::B2DHomMatrix& getTextRangeTransform() const { return maTextRangeTransform; }
isFixedCellHeight() const283             bool isFixedCellHeight() const { return mbFixedCellHeight; }
284 
285             // compare operator
286             virtual bool operator==(const BasePrimitive2D& rPrimitive) const;
287 
288             // transformed clone operator
289             virtual SdrTextPrimitive2D* createTransformedClone(const basegfx::B2DHomMatrix& rTransform) const;
290 
291             // provide unique ID
292             DeclPrimitrive2DIDBlock()
293         };
294     } // end of namespace primitive2d
295 } // end of namespace drawinglayer
296 
297 //////////////////////////////////////////////////////////////////////////////
298 
299 #endif //INCLUDED_SDR_PRIMITIVE2D_SDRTEXTPRIMITIVE2D_HXX
300 
301 // eof
302