Avoid potential negative array index access to cached text.
[LibreOffice.git] / vcl / inc / win / winlayout.hxx
blobe1d66a0e1ab29b79f92823fbc81bec0db0688bc3
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 <sal/config.h>
24 #include <rtl/ustring.hxx>
26 #include <sallayout.hxx>
27 #include <svsys.h>
28 #include <win/salgdi.h>
29 #include <o3tl/sorted_vector.hxx>
31 // win32 specific logical font instance
32 class WinFontInstance : public LogicalFontInstance
34 friend rtl::Reference<LogicalFontInstance> WinFontFace::CreateFontInstance(const vcl::font::FontSelectPattern&) const;
36 public:
37 ~WinFontInstance() override;
39 bool hasHScale() const;
40 float getHScale() const;
42 void SetGraphics(WinSalGraphics*);
43 WinSalGraphics* GetGraphics() const { return m_pGraphics; }
45 HFONT GetHFONT() const { return m_hFont; }
46 // Return true if the font is for vertical writing.
47 // I.e. the font name of the LOGFONT is prefixed with '@'.
48 bool IsCJKVerticalFont() const { return m_bIsCJKVerticalFont; }
49 sal_Int32 GetTmDescent() const { return m_nTmDescent; }
51 const WinFontFace * GetFontFace() const { return static_cast<const WinFontFace *>(LogicalFontInstance::GetFontFace()); }
52 WinFontFace * GetFontFace() { return static_cast<WinFontFace *>(LogicalFontInstance::GetFontFace()); }
54 bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon&, bool) const override;
56 IDWriteFontFace* GetDWFontFace() const;
58 private:
59 explicit WinFontInstance(const WinFontFace&, const vcl::font::FontSelectPattern&);
61 virtual void ImplInitHbFont(hb_font_t*) override;
63 WinSalGraphics *m_pGraphics;
64 HFONT m_hFont;
65 bool m_bIsCJKVerticalFont;
66 sal_Int32 m_nTmDescent;
67 mutable sal::systools::COMReference<IDWriteFontFace> mxDWFontFace;
70 class TextOutRenderer
72 protected:
73 explicit TextOutRenderer() = default;
74 TextOutRenderer(const TextOutRenderer &) = delete;
75 TextOutRenderer & operator = (const TextOutRenderer &) = delete;
77 public:
78 static TextOutRenderer & get(bool bUseDWrite, bool bRenderingModeNatural);
80 virtual ~TextOutRenderer() = default;
82 virtual bool operator ()(GenericSalLayout const &rLayout,
83 SalGraphics &rGraphics,
84 HDC hDC,
85 bool bRenderingModeNatural) = 0;
88 class ExTextOutRenderer : public TextOutRenderer
90 ExTextOutRenderer(const ExTextOutRenderer &) = delete;
91 ExTextOutRenderer & operator = (const ExTextOutRenderer &) = delete;
93 public:
94 explicit ExTextOutRenderer() = default;
96 bool operator ()(GenericSalLayout const &rLayout,
97 SalGraphics &rGraphics,
98 HDC hDC,
99 bool bRenderingModeNatural) override;
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */