1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
25 #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx>
27 namespace basegfx::utils
{
28 class B2DHomMatrixBufferedOnDemandDecompose
;
31 namespace drawinglayer::primitive2d
33 /** TextDecoratedPortionPrimitive2D class
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)
40 class DRAWINGLAYER_DLLPUBLIC TextDecoratedPortionPrimitive2D final
: public TextSimplePortionPrimitive2D
43 /// a sequence used for buffering broken up text for WordLineMode
44 mutable Primitive2DContainer maBufferedBrokenUpText
;
46 /// a sequence used for buffering getOrCreateDecorationGeometryContent
47 mutable Primitive2DContainer maBufferedDecorationGeometry
;
49 /// decoration definitions
50 basegfx::BColor maOverlineColor
;
51 basegfx::BColor maTextlineColor
;
52 TextLine meFontOverline
;
53 TextLine meFontUnderline
;
54 TextStrikeout meTextStrikeout
;
55 TextEmphasisMark meTextEmphasisMark
;
56 TextRelief meTextRelief
;
58 bool mbUnderlineAbove
: 1;
59 bool mbWordLineMode
: 1;
60 bool mbEmphasisMarkAbove
: 1;
61 bool mbEmphasisMarkBelow
: 1;
65 void impCreateGeometryContent(
66 Primitive2DContainer
& rTarget
,
67 basegfx::utils::B2DHomMatrixBufferedOnDemandDecompose
const & rDecTrans
,
68 const OUString
& rText
,
69 sal_Int32 nTextPosition
,
70 sal_Int32 nTextLength
,
71 const ::std::vector
< double >& rDXArray
,
72 const ::std::vector
< sal_Bool
>& rKashidaArray
,
73 const attribute::FontAttribute
& rFontAttribute
) const;
75 /// local decomposition.
76 virtual Primitive2DReference
create2DDecomposition(const geometry::ViewInformation2D
& rViewInformation
) const override
;
80 TextDecoratedPortionPrimitive2D(
81 /// TextSimplePortionPrimitive2D parameters
82 const basegfx::B2DHomMatrix
& rNewTransform
,
83 const OUString
& rText
,
84 sal_Int32 nTextPosition
,
85 sal_Int32 nTextLength
,
86 std::vector
< double >&& rDXArray
,
87 std::vector
< sal_Bool
>&& rKashidaArray
,
88 const attribute::FontAttribute
& rFontAttribute
,
89 const css::lang::Locale
& rLocale
,
90 const basegfx::BColor
& rFontColor
,
91 const Color
& rFillColor
,
94 const basegfx::BColor
& rOverlineColor
,
95 const basegfx::BColor
& rTextlineColor
,
96 TextLine eFontOverline
= TEXT_LINE_NONE
,
97 TextLine eFontUnderline
= TEXT_LINE_NONE
,
98 bool bUnderlineAbove
= false,
99 TextStrikeout eTextStrikeout
= TEXT_STRIKEOUT_NONE
,
100 bool bWordLineMode
= false,
101 TextEmphasisMark eTextEmphasisMark
= TEXT_FONT_EMPHASIS_MARK_NONE
,
102 bool bEmphasisMarkAbove
= true,
103 bool bEmphasisMarkBelow
= false,
104 TextRelief eTextRelief
= TEXT_RELIEF_NONE
,
105 bool bShadow
= false);
108 TextLine
getFontOverline() const { return meFontOverline
; }
109 TextLine
getFontUnderline() const { return meFontUnderline
; }
110 TextStrikeout
getTextStrikeout() const { return meTextStrikeout
; }
111 TextEmphasisMark
getTextEmphasisMark() const { return meTextEmphasisMark
; }
112 TextRelief
getTextRelief() const { return meTextRelief
; }
113 const basegfx::BColor
& getOverlineColor() const { return maOverlineColor
; }
114 const basegfx::BColor
& getTextlineColor() const { return maTextlineColor
; }
115 bool getUnderlineAbove() const { return mbUnderlineAbove
; }
116 bool getWordLineMode() const { return mbWordLineMode
; }
117 bool getEmphasisMarkAbove() const { return mbEmphasisMarkAbove
; }
118 bool getEmphasisMarkBelow() const { return mbEmphasisMarkBelow
; }
119 bool getShadow() const { return mbShadow
; }
121 /// helper top create DecorationGeometry as Primitives
122 const Primitive2DContainer
& getOrCreateDecorationGeometryContent(
123 basegfx::utils::B2DHomMatrixBufferedOnDemandDecompose
const & rDecTrans
,
124 const OUString
& rText
,
125 sal_Int32 nTextPosition
,
126 sal_Int32 nTextLength
,
127 const std::vector
< double >& rDXArray
) const;
129 /// helper for break-up text if needed
130 const Primitive2DContainer
& getOrCreateBrokenUpText() const;
132 /// helpers for determining various decoration states
133 virtual bool hasTextRelief() const override
;
134 virtual bool hasShadow() const override
;
135 virtual bool hasTextDecoration() const override
;
138 virtual bool operator==( const BasePrimitive2D
& rPrimitive
) const override
;
141 virtual basegfx::B2DRange
getB2DRange(const geometry::ViewInformation2D
& rViewInformation
) const override
;
143 /// provide unique ID
144 virtual sal_uInt32
getPrimitive2DID() const override
;
146 } // end of namespace drawinglayer::primitive2d
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */