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 <basegfx/range/b2drange.hxx>
25 #include <drawinglayer/primitive2d/textenumsprimitive2d.hxx>
27 #include <basegfx/polygon/b2dpolypolygon.hxx>
28 #include <vcl/kernarray.hxx>
29 #include <vcl/svapp.hxx>
30 #include <tools/fontenum.hxx>
36 enum class DrawTextFlags
;
46 namespace drawinglayer::attribute
50 namespace com::sun::star::lang
56 enum class ComplexTextLayoutFlags
: sal_uInt8
;
63 // access to one global impTimedRefDev incarnation in namespace drawinglayer::primitive
65 namespace drawinglayer::primitive2d
67 /** TextLayouterDevice class
69 This helper class exists to isolate all accesses to VCL
70 text formatting/handling functionality for primitive implementations.
71 When in the future FontHandling may move to an own library independent
72 from VCL, primitives will be prepared.
74 class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice
76 /// internally used VirtualDevice
77 SolarMutexGuard maSolarGuard
;
78 VirtualDevice
& mrDevice
;
79 double mnFontScalingFixX
= 1.0;
80 double mnFontScalingFixY
= 1.0;
83 /// constructor/destructor
85 ~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE
;
88 void setFont(const vcl::Font
& rFont
);
89 void setFontAttribute(const attribute::FontAttribute
& rFontAttribute
, double fFontScaleX
,
90 double fFontScaleY
, const css::lang::Locale
& rLocale
);
91 void setLayoutMode(vcl::text::ComplexTextLayoutFlags nTextLayoutMode
);
92 vcl::text::ComplexTextLayoutFlags
getLayoutMode() const;
93 void setTextColor(const basegfx::BColor
& rColor
);
95 double getTextHeight() const;
96 double getOverlineHeight() const;
97 double getOverlineOffset() const;
98 double getUnderlineHeight() const;
99 double getUnderlineOffset() const;
100 double getStrikeoutOffset() const;
102 double getTextWidth(const OUString
& rText
, sal_uInt32 nIndex
, sal_uInt32 nLength
) const;
104 void getTextOutlines(basegfx::B2DPolyPolygonVector
&, const OUString
& rText
, sal_uInt32 nIndex
,
105 sal_uInt32 nLength
, const ::std::vector
<double>& rDXArray
,
106 const ::std::vector
<sal_Bool
>& rKashidaArray
) const;
108 basegfx::B2DRange
getTextBoundRect(const OUString
& rText
, sal_uInt32 nIndex
,
109 sal_uInt32 nLength
) const;
111 double getFontAscent() const;
112 double getFontDescent() const;
114 void addTextRectActions(const tools::Rectangle
& rRectangle
, const OUString
& rText
,
115 DrawTextFlags nStyle
, GDIMetaFile
& rGDIMetaFile
) const;
117 ::std::vector
<double> getTextArray(const OUString
& rText
, sal_uInt32 nIndex
, sal_uInt32 nLength
,
118 bool bCaret
= false) const;
119 std::unique_ptr
<SalLayout
> getSalLayout(const OUString
& rText
, sal_uInt32 nIndex
,
121 const basegfx::B2DPoint
& rStartPoint
,
122 const KernArray
& rDXArray
,
123 std::span
<const sal_Bool
> pKashidaAry
) const;
124 void createEmphasisMarks(
125 SalLayout
& rSalLayout
, TextEmphasisMark aTextEmphasisMark
, bool bAbove
,
126 const std::function
<void(const basegfx::B2DPoint
&, const basegfx::B2DPolyPolygon
&, bool,
127 const tools::Rectangle
&, const tools::Rectangle
&)>& rCallback
)
131 // helper methods for vcl font handling
133 /** Create a VCL-Font based on the definitions in FontAttribute
134 and the given FontScaling. The FontScaling defines the FontHeight
135 (fFontScaleY) and the FontWidth (fFontScaleX). The combination of
136 both defines FontStretching, where no stretching happens at
137 fFontScaleY == fFontScaleX
139 vcl::Font DRAWINGLAYER_DLLPUBLIC
getVclFontFromFontAttribute(
140 const attribute::FontAttribute
& rFontAttribute
, double fFontScaleX
, double fFontScaleY
,
141 double fFontRotation
, const css::lang::Locale
& rLocale
);
143 /** Generate FontAttribute DataSet derived from the given VCL-Font.
144 The FontScaling with fFontScaleY, fFontScaleX relationship (see
145 above) will be set in return parameter o_rSize to allow further
148 attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC
getFontAttributeFromVclFont(
149 basegfx::B2DVector
& o_rSize
, const vcl::Font
& rFont
, bool bRTL
, bool bBiDiStrong
);
151 } // end of namespace drawinglayer::primitive2d
153 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */