tdf#154546 skip dispatch when presenter controller is not set
[LibreOffice.git] / include / drawinglayer / primitive2d / textlayoutdevice.hxx
blob6348de0ddd25135b59e0a6dc5d5e65955dab4bd0
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 #pragma once
22 #include <drawinglayer/drawinglayerdllapi.h>
24 #include <basegfx/range/b2drange.hxx>
25 #include <vector>
26 #include <basegfx/polygon/b2dpolypolygon.hxx>
27 #include <vcl/svapp.hxx>
29 // predefines
30 class VirtualDevice;
31 class GDIMetaFile;
32 enum class DrawTextFlags;
33 namespace vcl
35 class Font;
37 namespace tools
39 class Rectangle;
41 namespace drawinglayer::attribute
43 class FontAttribute;
45 namespace com::sun::star::lang
47 struct Locale;
50 // access to one global impTimedRefDev incarnation in namespace drawinglayer::primitive
52 namespace drawinglayer::primitive2d
54 /** TextLayouterDevice class
56 This helper class exists to isolate all accesses to VCL
57 text formatting/handling functionality for primitive implementations.
58 When in the future FontHandling may move to an own library independent
59 from VCL, primitives will be prepared.
61 class DRAWINGLAYER_DLLPUBLIC TextLayouterDevice
63 /// internally used VirtualDevice
64 SolarMutexGuard maSolarGuard;
65 VirtualDevice& mrDevice;
67 public:
68 /// constructor/destructor
69 TextLayouterDevice();
70 ~TextLayouterDevice() COVERITY_NOEXCEPT_FALSE;
72 /// tooling methods
73 void setFont(const vcl::Font& rFont);
74 void setFontAttribute(const attribute::FontAttribute& rFontAttribute, double fFontScaleX,
75 double fFontScaleY, const css::lang::Locale& rLocale);
77 double getTextHeight() const;
78 double getOverlineHeight() const;
79 double getOverlineOffset() const;
80 double getUnderlineHeight() const;
81 double getUnderlineOffset() const;
82 double getStrikeoutOffset() const;
84 double getTextWidth(const OUString& rText, sal_uInt32 nIndex, sal_uInt32 nLength) const;
86 void getTextOutlines(basegfx::B2DPolyPolygonVector&, const OUString& rText, sal_uInt32 nIndex,
87 sal_uInt32 nLength, const ::std::vector<double>& rDXArray,
88 const ::std::vector<sal_Bool>& rKashidaArray) const;
90 basegfx::B2DRange getTextBoundRect(const OUString& rText, sal_uInt32 nIndex,
91 sal_uInt32 nLength) const;
93 double getFontAscent() const;
94 double getFontDescent() const;
96 void addTextRectActions(const tools::Rectangle& rRectangle, const OUString& rText,
97 DrawTextFlags nStyle, GDIMetaFile& rGDIMetaFile) const;
99 ::std::vector<double> getTextArray(const OUString& rText, sal_uInt32 nIndex,
100 sal_uInt32 nLength) const;
102 ::std::vector<double> getCaretPositions(const OUString& rText, sal_uInt32 nIndex,
103 sal_uInt32 nLength) const;
106 // helper methods for vcl font handling
108 /** Create a VCL-Font based on the definitions in FontAttribute
109 and the given FontScaling. The FontScaling defines the FontHeight
110 (fFontScaleY) and the FontWidth (fFontScaleX). The combination of
111 both defines FontStretching, where no stretching happens at
112 fFontScaleY == fFontScaleX
114 vcl::Font DRAWINGLAYER_DLLPUBLIC getVclFontFromFontAttribute(
115 const attribute::FontAttribute& rFontAttribute, double fFontScaleX, double fFontScaleY,
116 double fFontRotation, const css::lang::Locale& rLocale);
118 /** Generate FontAttribute DataSet derived from the given VCL-Font.
119 The FontScaling with fFontScaleY, fFontScaleX relationship (see
120 above) will be set in return parameter o_rSize to allow further
121 processing
123 attribute::FontAttribute DRAWINGLAYER_DLLPUBLIC getFontAttributeFromVclFont(
124 basegfx::B2DVector& o_rSize, const vcl::Font& rFont, bool bRTL, bool bBiDiStrong);
126 } // end of namespace drawinglayer::primitive2d
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */