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>
26 #include <basegfx/polygon/b2dpolypolygon.hxx>
27 #include <vcl/svapp.hxx>
31 namespace vcl
{ class Font
; }
33 namespace tools
{ class Rectangle
; }
34 enum class DrawTextFlags
;
35 namespace drawinglayer::attribute
{
39 namespace com::sun::star::lang
{ struct Locale
; }
41 // access to one global impTimedRefDev incarnation in namespace drawinglayer::primitive
43 namespace drawinglayer::primitive2d
45 /** TextLayouterDevice class
47 This helper class exists to isolate all accesses to VCL
48 text formatting/handling functionality for primitive implementations.
49 When in the future FontHandling may move to an own library independent
50 from VCL, primitives will be prepared.
52 class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice
54 /// internally used VirtualDevice
55 SolarMutexGuard maSolarGuard
;
56 VirtualDevice
& mrDevice
;
59 /// constructor/destructor
61 ~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE
;
64 void setFont(const vcl::Font
& rFont
);
65 void setFontAttribute(
66 const attribute::FontAttribute
& rFontAttribute
,
69 const css::lang::Locale
& rLocale
);
71 double getTextHeight() const;
72 double getOverlineHeight() const;
73 double getOverlineOffset() const;
74 double getUnderlineHeight() const;
75 double getUnderlineOffset() const;
76 double getStrikeoutOffset() const;
79 const OUString
& rText
,
81 sal_uInt32 nLength
) const;
84 basegfx::B2DPolyPolygonVector
&,
85 const OUString
& rText
,
88 const ::std::vector
< double >& rDXArray
) const;
90 basegfx::B2DRange
getTextBoundRect(
91 const OUString
& rText
,
93 sal_uInt32 nLength
) const;
95 double getFontAscent() const;
96 double getFontDescent() const;
98 void addTextRectActions(
99 const tools::Rectangle
& rRectangle
,
100 const OUString
& rText
,
101 DrawTextFlags nStyle
,
102 GDIMetaFile
& rGDIMetaFile
) const;
104 ::std::vector
< double > getTextArray(
105 const OUString
& rText
,
107 sal_uInt32 nLength
) const;
109 ::std::vector
< double > getCaretPositions(
110 const OUString
& rText
,
112 sal_uInt32 nLength
) const;
115 // helper methods for vcl font handling
117 /** Create a VCL-Font based on the definitions in FontAttribute
118 and the given FontScaling. The FontScaling defines the FontHeight
119 (fFontScaleY) and the FontWidth (fFontScaleX). The combination of
120 both defines FontStretching, where no stretching happens at
121 fFontScaleY == fFontScaleX
123 vcl::Font DRAWINGLAYER_DLLPUBLIC
getVclFontFromFontAttribute(
124 const attribute::FontAttribute
& rFontAttribute
,
127 double fFontRotation
,
128 const css::lang::Locale
& rLocale
);
130 /** Generate FontAttribute DataSet derived from the given VCL-Font.
131 The FontScaling with fFontScaleY, fFontScaleX relationship (see
132 above) will be set in return parameter o_rSize to allow further
135 attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC
getFontAttributeFromVclFont(
136 basegfx::B2DVector
& o_rSize
,
137 const vcl::Font
& rFont
,
141 } // end of namespace drawinglayer::primitive2d
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */