xref: /AOO41X/main/drawinglayer/inc/drawinglayer/primitive2d/textdecoratedprimitive2d.hxx (revision 693be7f615b07ee08c4eb2232b246abfb35b35b4)
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_DRAWINGLAYER_PRIMITIVE2D_TEXTDECORATEDPRIMITIVE2D_HXX
25 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTDECORATEDPRIMITIVE2D_HXX
26 
27 #include <drawinglayer/drawinglayerdllapi.h>
28 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
29 #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx>
30 
31 //////////////////////////////////////////////////////////////////////////////
32 // predeclarations
33 
34 namespace basegfx { namespace tools {
35     class B2DHomMatrixBufferedOnDemandDecompose;
36 }}
37 
38 namespace com { namespace sun { namespace star { namespace i18n {
39     struct Boundary;
40 }}}}
41 
42 //////////////////////////////////////////////////////////////////////////////
43 
44 namespace drawinglayer
45 {
46     namespace primitive2d
47     {
48         /** TextDecoratedPortionPrimitive2D class
49 
50             This primitive expands the TextSimplePortionPrimitive2D by common
51             decorations used in the office. It can be decomposed and will create
52             a TextSimplePortionPrimitive2D and all the contained decorations (if used)
53             as geometry.
54          */
55         class DRAWINGLAYER_DLLPUBLIC TextDecoratedPortionPrimitive2D : public TextSimplePortionPrimitive2D
56         {
57         private:
58             /// decoration definitions
59             basegfx::BColor                             maOverlineColor;
60             basegfx::BColor                             maTextlineColor;
61             TextLine                                    meFontOverline;
62             TextLine                                    meFontUnderline;
63             TextStrikeout                               meTextStrikeout;
64             TextEmphasisMark                            meTextEmphasisMark;
65             TextRelief                                  meTextRelief;
66 
67             /// bitfield
68             unsigned                                    mbUnderlineAbove : 1;
69             unsigned                                    mbWordLineMode : 1;
70             unsigned                                    mbEmphasisMarkAbove : 1;
71             unsigned                                    mbEmphasisMarkBelow : 1;
72             unsigned                                    mbShadow : 1;
73 
74             /// helper methods
75             void impCreateGeometryContent(
76                 std::vector< Primitive2DReference >& rTarget,
77                 basegfx::tools::B2DHomMatrixBufferedOnDemandDecompose& rDecTrans,
78                 const String& rText,
79                 xub_StrLen aTextPosition,
80                 xub_StrLen aTextLength,
81                 const ::std::vector< double >& rDXArray,
82                 const attribute::FontAttribute& rFontAttribute) const;
83 
84         protected:
85             /// local decomposition.
86             virtual Primitive2DSequence create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const;
87 
88         public:
89             /// constructor
90             TextDecoratedPortionPrimitive2D(
91 
92                 /// TextSimplePortionPrimitive2D parameters
93                 const basegfx::B2DHomMatrix& rNewTransform,
94                 const String& rText,
95                 xub_StrLen aTextPosition,
96                 xub_StrLen aTextLength,
97                 const ::std::vector< double >& rDXArray,
98                 const attribute::FontAttribute& rFontAttribute,
99                 const ::com::sun::star::lang::Locale& rLocale,
100                 const basegfx::BColor& rFontColor,
101 
102                 /// local parameters
103                 const basegfx::BColor& rOverlineColor,
104                 const basegfx::BColor& rTextlineColor,
105                 TextLine eFontOverline = TEXT_LINE_NONE,
106                 TextLine eFontUnderline = TEXT_LINE_NONE,
107                 bool bUnderlineAbove = false,
108                 TextStrikeout eTextStrikeout = TEXT_STRIKEOUT_NONE,
109                 bool bWordLineMode = false,
110                 TextEmphasisMark eTextEmphasisMark = TEXT_EMPHASISMARK_NONE,
111                 bool bEmphasisMarkAbove = true,
112                 bool bEmphasisMarkBelow = false,
113                 TextRelief eTextRelief = TEXT_RELIEF_NONE,
114                 bool bShadow = false);
115 
116             /// data read access
getFontOverline() const117             TextLine getFontOverline() const { return meFontOverline; }
getFontUnderline() const118             TextLine getFontUnderline() const { return meFontUnderline; }
getTextStrikeout() const119             TextStrikeout getTextStrikeout() const { return meTextStrikeout; }
getTextEmphasisMark() const120             TextEmphasisMark getTextEmphasisMark() const { return meTextEmphasisMark; }
getTextRelief() const121             TextRelief getTextRelief() const { return meTextRelief; }
getOverlineColor() const122             const basegfx::BColor& getOverlineColor() const { return maOverlineColor; }
getTextlineColor() const123             const basegfx::BColor& getTextlineColor() const { return maTextlineColor; }
getUnderlineAbove() const124             bool getUnderlineAbove() const { return mbUnderlineAbove; }
getWordLineMode() const125             bool getWordLineMode() const { return mbWordLineMode; }
getEmphasisMarkAbove() const126             bool getEmphasisMarkAbove() const { return mbEmphasisMarkAbove; }
getEmphasisMarkBelow() const127             bool getEmphasisMarkBelow() const { return mbEmphasisMarkBelow; }
getShadow() const128             bool getShadow() const { return mbShadow; }
129 
130             /// check if this needs to be a TextDecoratedPortionPrimitive2D or
131             /// if a TextSimplePortionPrimitive2D would be suficcient
132             bool decoratedIsNeeded() const;
133 
134             /// compare operator
135             virtual bool operator==( const BasePrimitive2D& rPrimitive ) const;
136 
137             /// get range
138             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const;
139 
140             /// provide unique ID
141             DeclPrimitrive2DIDBlock()
142         };
143     } // end of namespace primitive2d
144 } // end of namespace drawinglayer
145 
146 //////////////////////////////////////////////////////////////////////////////
147 
148 #endif //INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTDECORATEDPRIMITIVE2D_HXX
149 
150 //////////////////////////////////////////////////////////////////////////////
151 // eof
152