LibreOffice Module vcl (master) 1
sallayout.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_VCL_INC_SALLAYOUT_HXX
21#define INCLUDED_VCL_INC_SALLAYOUT_HXX
22
23#include <sal/config.h>
24
26#include <tools/gen.hxx>
27#include <tools/degree.hxx>
29
30#include <vcl/dllapi.h>
32#include <vcl/vclenum.hxx> // for typedef sal_UCS4
33#include <vcl/vcllayout.hxx>
34
35#include "ImplLayoutRuns.hxx"
36#include "impglyphitem.hxx"
37
38#include <com/sun/star/i18n/XBreakIterator.hpp>
39
40#include <hb.h>
41
42#include <iostream>
43#include <memory>
44#include <vector>
45
46#define MAX_FALLBACK 16
47
49class SalGraphics;
50enum class SalLayoutFlags;
51
52namespace vcl::font {
53 class PhysicalFontFace;
54}
55
56namespace vcl::text {
57 class TextLayoutCache;
58}
59
60class MultiSalLayout final : public SalLayout
61{
62public:
63 void DrawText(SalGraphics&) const override;
64 sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const override;
65 DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray, const OUString& rStr) const override;
66 void GetCaretPositions(int nArraySize, sal_Int32* pCaretXArray) const override;
67 bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart,
68 const LogicalFontInstance** ppGlyphFont = nullptr,
69 const vcl::font::PhysicalFontFace** pFallbackFont = nullptr) const override;
70 bool GetOutline(basegfx::B2DPolyPolygonVector&) const override;
71 bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const override;
72 SalLayoutGlyphs GetGlyphs() const final override;
73
74 // used only by OutputDevice::ImplLayout, TODO: make friend
75 explicit MultiSalLayout( std::unique_ptr<SalLayout> pBaseLayout );
76 void AddFallback(std::unique_ptr<SalLayout> pFallbackLayout, ImplLayoutRuns const &);
77 // give up ownership of the initial pBaseLayout taken by the ctor
78 std::unique_ptr<SalLayout> ReleaseBaseLayout();
81 void InitFont() const override;
82
83 void SetIncomplete(bool bIncomplete);
84
86 vcl::text::ImplLayoutArgs& rMultiArgs,
87 const double* pMultiDXArray);
88
89 virtual bool IsMultiSalLayout() const override;
90
91 virtual ~MultiSalLayout() override;
92
93private:
94 MultiSalLayout( const MultiSalLayout& ) = delete;
96
97 std::unique_ptr<GenericSalLayout> mpLayouts[ MAX_FALLBACK ];
101};
102
104{
107 vcl::text::ImplLayoutArgs& rMultiArgs,
108 const double* pMultiDXArray);
109
110public:
112 ~GenericSalLayout() override;
113
114 void AdjustLayout(vcl::text::ImplLayoutArgs&) final override;
115 bool LayoutText(vcl::text::ImplLayoutArgs&, const SalLayoutGlyphsImpl*) final override;
116 void DrawText(SalGraphics&) const final override;
117 SalLayoutGlyphs GetGlyphs() const final override;
118
119 bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const final override;
120
121 // used by upper layers
122 DeviceCoordinate GetTextWidth() const final override;
123 DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray, const OUString& rStr) const final override;
124 sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const final override;
125 void GetCaretPositions(int nArraySize, sal_Int32* pCaretXArray) const final override;
126
127 // used by display layers
129 { return *m_GlyphItems.GetFont(); }
130
131 bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart,
132 const LogicalFontInstance** ppGlyphFont = nullptr,
133 const vcl::font::PhysicalFontFace** pFallbackFont = nullptr) const override;
134
135 const SalLayoutGlyphsImpl& GlyphsImpl() const { return m_GlyphItems; }
136
137private:
138 // for glyph+font+script fallback
139 void MoveGlyph(int nStart, tools::Long nNewXPos);
140 void DropGlyph(int nStart);
141 void Simplify(bool bIsBase);
142
145
146 void ApplyDXArray(const double*, const sal_Bool*);
147 void Justify(DeviceCoordinate nNewWidth);
148 void ApplyAsianKerning(std::u16string_view rStr);
149
150 void GetCharWidths(std::vector<DeviceCoordinate>& rCharWidths,
151 const OUString& rStr) const;
152
153 void SetNeedFallback(vcl::text::ImplLayoutArgs&, sal_Int32, bool);
154
155 bool HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aNextChar);
156
157 void ParseFeatures(std::u16string_view name);
158
159 css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
160
162
163 OString msLanguage;
164 std::vector<hb_feature_t> maFeatures;
165
166 hb_set_t* mpVertGlyphs;
167 const bool mbFuzzing;
168};
169
170#endif // INCLUDED_VCL_INC_SALLAYOUT_HXX
171
172/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SalLayoutFlags
SalLayoutGlyphsImpl m_GlyphItems
Definition: sallayout.hxx:161
GenericSalLayout & operator=(const GenericSalLayout &)=delete
const SalLayoutGlyphsImpl & GlyphsImpl() const
Definition: sallayout.hxx:135
hb_set_t * mpVertGlyphs
Definition: sallayout.hxx:166
std::vector< hb_feature_t > maFeatures
Definition: sallayout.hxx:164
OString msLanguage
Definition: sallayout.hxx:163
const bool mbFuzzing
Definition: sallayout.hxx:167
GenericSalLayout(const GenericSalLayout &)=delete
css::uno::Reference< css::i18n::XBreakIterator > mxBreak
Definition: sallayout.hxx:159
bool GetOutline(basegfx::B2DPolyPolygonVector &) const override
Definition: sallayout.cxx:1176
void AdjustLayout(vcl::text::ImplLayoutArgs &) override
Definition: sallayout.cxx:662
bool GetNextGlyph(const GlyphItem **pGlyph, DevicePoint &rPos, int &nStart, const LogicalFontInstance **ppGlyphFont=nullptr, const vcl::font::PhysicalFontFace **pFallbackFont=nullptr) const override
Definition: sallayout.cxx:1146
void ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs &rArgs, vcl::text::ImplLayoutArgs &rMultiArgs, const double *pMultiDXArray)
Definition: sallayout.cxx:740
void SetIncomplete(bool bIncomplete)
Definition: sallayout.cxx:631
virtual bool IsMultiSalLayout() const override
Definition: sallayout.cxx:1225
std::unique_ptr< GenericSalLayout > mpLayouts[MAX_FALLBACK]
Definition: sallayout.hxx:97
MultiSalLayout(const MultiSalLayout &)=delete
std::unique_ptr< SalLayout > ReleaseBaseLayout()
Definition: sallayout.cxx:626
void DrawText(SalGraphics &) const override
Definition: sallayout.cxx:1021
void InitFont() const override
Definition: sallayout.cxx:1015
DeviceCoordinate FillDXArray(std::vector< DeviceCoordinate > *pDXArray, const OUString &rStr) const override
Definition: sallayout.cxx:1077
sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const override
Definition: sallayout.cxx:1036
bool LayoutText(vcl::text::ImplLayoutArgs &, const SalLayoutGlyphsImpl *) override
Definition: sallayout.cxx:653
SalLayoutGlyphs GetGlyphs() const final override
Definition: sallayout.cxx:1217
MultiSalLayout & operator=(const MultiSalLayout &)=delete
void GetCaretPositions(int nArraySize, sal_Int32 *pCaretXArray) const override
Definition: sallayout.cxx:1122
ImplLayoutRuns maFallbackRuns[MAX_FALLBACK]
Definition: sallayout.hxx:98
void AddFallback(std::unique_ptr< SalLayout > pFallbackLayout, ImplLayoutRuns const &)
Definition: sallayout.cxx:641
virtual ~MultiSalLayout() override
Definition: sallayout.cxx:637
bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const override
Definition: sallayout.cxx:1193
MultiSalLayout(std::unique_ptr< SalLayout > pBaseLayout)
Definition: sallayout.cxx:616
virtual bool LayoutText(vcl::text::ImplLayoutArgs &, const SalLayoutGlyphsImpl *)=0
virtual void AdjustLayout(vcl::text::ImplLayoutArgs &)
Definition: sallayout.cxx:146
virtual bool GetNextGlyph(const GlyphItem **pGlyph, DevicePoint &rPos, int &nStart, const LogicalFontInstance **ppGlyphFont=nullptr, const vcl::font::PhysicalFontFace **pFallbackFont=nullptr) const =0
virtual void DrawText(SalGraphics &) const =0
virtual SalLayoutGlyphs GetGlyphs() const
Definition: sallayout.cxx:263
abstract base class for physical font faces
sal_Int32 DeviceCoordinate
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
::std::vector< B2DPolyPolygon > B2DPolyPolygonVector
long Long
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
Definition: drawmode.cxx:159
A PhysicalFontFaceCollection is created by a PhysicalFontCollection and becomes invalid when original...
#define MAX_FALLBACK
Definition: sallayout.hxx:46
unsigned char sal_Bool
sal_uInt32 sal_UCS4
Definition: vclenum.hxx:172