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
27#include <tools/gen.hxx>
28#include <tools/degree.hxx>
30
31#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(double nMaxWidth, double nCharExtra, int nFactor) const override;
65 double GetTextWidth() const final override;
66 double FillDXArray(std::vector<double>* pDXArray, const OUString& rStr) const override;
67 void GetCaretPositions(std::vector<double>& rCaretPositions, const OUString& rStr) const override;
68 bool GetNextGlyph(const GlyphItem** pGlyph, basegfx::B2DPoint& rPos, int& nStart,
69 const LogicalFontInstance** ppGlyphFont = 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 ~MultiSalLayout() override;
90
91private:
92 MultiSalLayout( const MultiSalLayout& ) = delete;
94
95 std::unique_ptr<GenericSalLayout> mpLayouts[ MAX_FALLBACK ];
99};
100
102{
105 vcl::text::ImplLayoutArgs& rMultiArgs,
106 const double* pMultiDXArray);
107
108public:
110 ~GenericSalLayout() override;
111
112 void AdjustLayout(vcl::text::ImplLayoutArgs&) final override;
113 bool LayoutText(vcl::text::ImplLayoutArgs&, const SalLayoutGlyphsImpl*) final override;
114 void DrawText(SalGraphics&) const final override;
115 SalLayoutGlyphs GetGlyphs() const final override;
116
117 bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const final override;
118
119 // used by upper layers
120 double GetTextWidth() const final override;
121 double FillDXArray(std::vector<double>* pDXArray, const OUString& rStr) const final override;
122 sal_Int32 GetTextBreak(double nMaxWidth, double nCharExtra, int nFactor) const final override;
123 void GetCaretPositions(std::vector<double>& rCaretPositions, const OUString& rStr) const override;
124
125 // used by display layers
127 { return *m_GlyphItems.GetFont(); }
128
129 bool GetNextGlyph(const GlyphItem** pGlyph, basegfx::B2DPoint& rPos, int& nStart,
130 const LogicalFontInstance** ppGlyphFont = nullptr) const override;
131
132 const SalLayoutGlyphsImpl& GlyphsImpl() const { return m_GlyphItems; }
133
134private:
135 // for glyph+font+script fallback
136 void MoveGlyph(int nStart, double nNewXPos);
137 void DropGlyph(int nStart);
138 void Simplify(bool bIsBase);
139
142
143 void ApplyDXArray(const double*, const sal_Bool*);
144 void Justify(double nNewWidth);
145 void ApplyAsianKerning(std::u16string_view rStr);
146
147 void GetCharWidths(std::vector<double>& rCharWidths,
148 const OUString& rStr) const;
149
150 void SetNeedFallback(vcl::text::ImplLayoutArgs&, sal_Int32, bool);
151
152 bool HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aNextChar);
153
154 void ParseFeatures(std::u16string_view name);
155
156 css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
157
159
160 OString msLanguage;
161 std::vector<hb_feature_t> maFeatures;
162
163 hb_set_t* mpVertGlyphs;
164 const bool mbFuzzing;
165};
166
167#endif // INCLUDED_VCL_INC_SALLAYOUT_HXX
168
169/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SalLayoutFlags
SalLayoutGlyphsImpl m_GlyphItems
Definition: sallayout.hxx:158
GenericSalLayout & operator=(const GenericSalLayout &)=delete
const SalLayoutGlyphsImpl & GlyphsImpl() const
Definition: sallayout.hxx:132
hb_set_t * mpVertGlyphs
Definition: sallayout.hxx:163
std::vector< hb_feature_t > maFeatures
Definition: sallayout.hxx:161
OString msLanguage
Definition: sallayout.hxx:160
const bool mbFuzzing
Definition: sallayout.hxx:164
GenericSalLayout(const GenericSalLayout &)=delete
css::uno::Reference< css::i18n::XBreakIterator > mxBreak
Definition: sallayout.hxx:156
bool GetNextGlyph(const GlyphItem **pGlyph, basegfx::B2DPoint &rPos, int &nStart, const LogicalFontInstance **ppGlyphFont=nullptr) const override
Definition: sallayout.cxx:1107
bool GetOutline(basegfx::B2DPolyPolygonVector &) const override
Definition: sallayout.cxx:1133
void AdjustLayout(vcl::text::ImplLayoutArgs &) override
Definition: sallayout.cxx:657
void ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs &rArgs, vcl::text::ImplLayoutArgs &rMultiArgs, const double *pMultiDXArray)
Definition: sallayout.cxx:718
void SetIncomplete(bool bIncomplete)
Definition: sallayout.cxx:626
std::unique_ptr< GenericSalLayout > mpLayouts[MAX_FALLBACK]
Definition: sallayout.hxx:95
MultiSalLayout(const MultiSalLayout &)=delete
std::unique_ptr< SalLayout > ReleaseBaseLayout()
Definition: sallayout.cxx:621
sal_Int32 GetTextBreak(double nMaxWidth, double nCharExtra, int nFactor) const override
Definition: sallayout.cxx:999
void DrawText(SalGraphics &) const override
Definition: sallayout.cxx:984
void InitFont() const override
Definition: sallayout.cxx:978
double GetTextWidth() const final override
Definition: sallayout.cxx:1032
double FillDXArray(std::vector< double > *pDXArray, const OUString &rStr) const override
Definition: sallayout.cxx:1048
bool LayoutText(vcl::text::ImplLayoutArgs &, const SalLayoutGlyphsImpl *) override
Definition: sallayout.cxx:648
SalLayoutGlyphs GetGlyphs() const final override
Definition: sallayout.cxx:1174
MultiSalLayout & operator=(const MultiSalLayout &)=delete
ImplLayoutRuns maFallbackRuns[MAX_FALLBACK]
Definition: sallayout.hxx:96
void AddFallback(std::unique_ptr< SalLayout > pFallbackLayout, ImplLayoutRuns const &)
Definition: sallayout.cxx:636
virtual ~MultiSalLayout() override
Definition: sallayout.cxx:632
void GetCaretPositions(std::vector< double > &rCaretPositions, const OUString &rStr) const override
Definition: sallayout.cxx:1081
bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const override
Definition: sallayout.cxx:1150
MultiSalLayout(std::unique_ptr< SalLayout > pBaseLayout)
Definition: sallayout.cxx:612
virtual bool LayoutText(vcl::text::ImplLayoutArgs &, const SalLayoutGlyphsImpl *)=0
virtual void AdjustLayout(vcl::text::ImplLayoutArgs &)
Definition: sallayout.cxx:136
virtual void DrawText(SalGraphics &) const =0
virtual bool GetNextGlyph(const GlyphItem **pGlyph, basegfx::B2DPoint &rPos, int &nStart, const LogicalFontInstance **ppGlyphFont=nullptr) const =0
virtual SalLayoutGlyphs GetGlyphs() const
Definition: sallayout.cxx:253
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
::std::vector< B2DPolyPolygon > B2DPolyPolygonVector
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
Definition: drawmode.cxx:171
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:160