Branch libreoffice-6-3
[LibreOffice.git] / include / drawinglayer / primitive2d / textlayoutdevice.hxx
blob61607232d92c6d3a3ebe83ff363d6e00d796eb3c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTLAYOUTDEVICE_HXX
21 #define INCLUDED_DRAWINGLAYER_PRIMITIVE2D_TEXTLAYOUTDEVICE_HXX
23 #include <drawinglayer/drawinglayerdllapi.h>
25 #include <basegfx/range/b2drange.hxx>
26 #include <vector>
27 #include <basegfx/polygon/b2dpolypolygon.hxx>
28 #include <vcl/svapp.hxx>
30 // predefines
31 class VirtualDevice;
32 namespace vcl { class Font; }
33 class GDIMetaFile;
34 namespace tools { class Rectangle; }
35 enum class DrawTextFlags;
36 namespace drawinglayer { namespace attribute {
37 class FontAttribute;
40 namespace com::sun::star::lang { struct Locale; }
42 // access to one global impTimedRefDev incarnation in namespace drawinglayer::primitive
44 namespace drawinglayer
46 namespace primitive2d
48 /** TextLayouterDevice class
50 This helper class exists to isolate all accesses to VCL
51 text formatting/handling functionality for primitive implementations.
52 When in the future FontHandling may move to an own library independent
53 from VCL, primitives will be prepared.
55 class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice
57 /// internally used VirtualDevice
58 SolarMutexGuard maSolarGuard;
59 VirtualDevice& mrDevice;
61 public:
62 /// constructor/destructor
63 TextLayouterDevice();
64 ~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE;
66 /// tooling methods
67 void setFont(const vcl::Font& rFont);
68 void setFontAttribute(
69 const attribute::FontAttribute& rFontAttribute,
70 double fFontScaleX,
71 double fFontScaleY,
72 const css::lang::Locale & rLocale);
74 double getTextHeight() const;
75 double getOverlineHeight() const;
76 double getOverlineOffset() const;
77 double getUnderlineHeight() const;
78 double getUnderlineOffset() const;
79 double getStrikeoutOffset() const;
81 double getTextWidth(
82 const OUString& rText,
83 sal_uInt32 nIndex,
84 sal_uInt32 nLength) const;
86 void getTextOutlines(
87 basegfx::B2DPolyPolygonVector&,
88 const OUString& rText,
89 sal_uInt32 nIndex,
90 sal_uInt32 nLength,
91 const ::std::vector< double >& rDXArray) const;
93 basegfx::B2DRange getTextBoundRect(
94 const OUString& rText,
95 sal_uInt32 nIndex,
96 sal_uInt32 nLength) const;
98 double getFontAscent() const;
99 double getFontDescent() const;
101 void addTextRectActions(
102 const tools::Rectangle& rRectangle,
103 const OUString& rText,
104 DrawTextFlags nStyle,
105 GDIMetaFile& rGDIMetaFile) const;
107 ::std::vector< double > getTextArray(
108 const OUString& rText,
109 sal_uInt32 nIndex,
110 sal_uInt32 nLength) const;
112 } // end of namespace primitive2d
113 } // end of namespace drawinglayer
115 // helper methods for vcl font handling
117 namespace drawinglayer
119 namespace primitive2d
121 /** Create a VCL-Font based on the definitions in FontAttribute
122 and the given FontScaling. The FontScaling defines the FontHeight
123 (fFontScaleY) and the FontWidth (fFontScaleX). The combination of
124 both defines FontStretching, where no stretching happens at
125 fFontScaleY == fFontScaleX
127 vcl::Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute(
128 const attribute::FontAttribute& rFontAttribute,
129 double fFontScaleX,
130 double fFontScaleY,
131 double fFontRotation,
132 const css::lang::Locale & rLocale);
134 /** Generate FontAttribute DataSet derived from the given VCL-Font.
135 The FontScaling with fFontScaleY, fFontScaleX relationship (see
136 above) will be set in return parameter o_rSize to allow further
137 processing
139 attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC getFontAttributeFromVclFont(
140 basegfx::B2DVector& o_rSize,
141 const vcl::Font& rFont,
142 bool bRTL,
143 bool bBiDiStrong);
145 } // end of namespace primitive2d
146 } // end of namespace drawinglayer
148 #endif //_DRAWINGLAYER_TEXTLAYOUTDEVICE_HXX
150 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */