1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <drawinglayer/drawinglayerdllapi.h>
23 
24 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
25 #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx>
26 
27 namespace basegfx::utils {
28     class B2DHomMatrixBufferedOnDemandDecompose;
29 }
30 
31 namespace drawinglayer::primitive2d
32 {
33         /** TextDecoratedPortionPrimitive2D class
34 
35             This primitive expands the TextSimplePortionPrimitive2D by common
36             decorations used in the office. It can be decomposed and will create
37             a TextSimplePortionPrimitive2D and all the contained decorations (if used)
38             as geometry.
39          */
40         class DRAWINGLAYER_DLLPUBLIC TextDecoratedPortionPrimitive2D final : public TextSimplePortionPrimitive2D
41         {
42         private:
43             /// decoration definitions
44             basegfx::BColor                             maOverlineColor;
45             basegfx::BColor                             maTextlineColor;
46             TextLine                                    meFontOverline;
47             TextLine                                    meFontUnderline;
48             TextStrikeout                               meTextStrikeout;
49             TextEmphasisMark                            meTextEmphasisMark;
50             TextRelief                                  meTextRelief;
51 
52             bool                                        mbUnderlineAbove : 1;
53             bool                                        mbWordLineMode : 1;
54             bool                                        mbEmphasisMarkAbove : 1;
55             bool                                        mbEmphasisMarkBelow : 1;
56             bool                                        mbShadow : 1;
57 
58             /// helper methods
59             void impCreateGeometryContent(
60                 std::vector< Primitive2DReference >& rTarget,
61                 basegfx::utils::B2DHomMatrixBufferedOnDemandDecompose const & rDecTrans,
62                 const OUString& rText,
63                 sal_Int32 nTextPosition,
64                 sal_Int32 nTextLength,
65                 const ::std::vector< double >& rDXArray,
66                 const attribute::FontAttribute& rFontAttribute) const;
67 
68             /// local decomposition.
69             virtual void create2DDecomposition(Primitive2DContainer& rContainer, const geometry::ViewInformation2D& rViewInformation) const override;
70 
71         public:
72             /// constructor
73             TextDecoratedPortionPrimitive2D(
74                 /// TextSimplePortionPrimitive2D parameters
75                 const basegfx::B2DHomMatrix& rNewTransform,
76                 const OUString& rText,
77                 sal_Int32 nTextPosition,
78                 sal_Int32 nTextLength,
79                 const ::std::vector< double >& rDXArray,
80                 const attribute::FontAttribute& rFontAttribute,
81                 const css::lang::Locale& rLocale,
82                 const basegfx::BColor& rFontColor,
83                 const Color& rFillColor,
84 
85                 /// local parameters
86                 const basegfx::BColor& rOverlineColor,
87                 const basegfx::BColor& rTextlineColor,
88                 TextLine eFontOverline = TEXT_LINE_NONE,
89                 TextLine eFontUnderline = TEXT_LINE_NONE,
90                 bool bUnderlineAbove = false,
91                 TextStrikeout eTextStrikeout = TEXT_STRIKEOUT_NONE,
92                 bool bWordLineMode = false,
93                 TextEmphasisMark eTextEmphasisMark = TEXT_FONT_EMPHASIS_MARK_NONE,
94                 bool bEmphasisMarkAbove = true,
95                 bool bEmphasisMarkBelow = false,
96                 TextRelief eTextRelief = TEXT_RELIEF_NONE,
97                 bool bShadow = false);
98 
99             /// data read access
getFontOverline() const100             TextLine getFontOverline() const { return meFontOverline; }
getFontUnderline() const101             TextLine getFontUnderline() const { return meFontUnderline; }
getTextStrikeout() const102             TextStrikeout getTextStrikeout() const { return meTextStrikeout; }
getTextEmphasisMark() const103             TextEmphasisMark getTextEmphasisMark() const { return meTextEmphasisMark; }
getTextRelief() const104             TextRelief getTextRelief() const { return meTextRelief; }
getOverlineColor() const105             const basegfx::BColor& getOverlineColor() const { return maOverlineColor; }
getTextlineColor() const106             const basegfx::BColor& getTextlineColor() const { return maTextlineColor; }
getUnderlineAbove() const107             bool getUnderlineAbove() const { return mbUnderlineAbove; }
getWordLineMode() const108             bool getWordLineMode() const { return mbWordLineMode; }
getEmphasisMarkAbove() const109             bool getEmphasisMarkAbove() const { return mbEmphasisMarkAbove; }
getEmphasisMarkBelow() const110             bool getEmphasisMarkBelow() const { return mbEmphasisMarkBelow; }
getShadow() const111             bool getShadow() const { return mbShadow; }
112 
113             /// compare operator
114             virtual bool operator==( const BasePrimitive2D& rPrimitive ) const override;
115 
116             /// get range
117             virtual basegfx::B2DRange getB2DRange(const geometry::ViewInformation2D& rViewInformation) const override;
118 
119             /// provide unique ID
120             virtual sal_uInt32 getPrimitive2DID() const override;
121         };
122 } // end of namespace drawinglayer::primitive2d
123 
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
125