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) const override;
69 bool GetOutline(basegfx::B2DPolyPolygonVector&) const override;
70 bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const override;
71 SalLayoutGlyphs GetGlyphs() const final override;
72
73 // used only by OutputDevice::ImplLayout, TODO: make friend
74 explicit MultiSalLayout( std::unique_ptr<SalLayout> pBaseLayout );
75 void AddFallback(std::unique_ptr<SalLayout> pFallbackLayout, ImplLayoutRuns const &);
76 // give up ownership of the initial pBaseLayout taken by the ctor
77 std::unique_ptr<SalLayout> ReleaseBaseLayout();
80 void InitFont() const override;
81
82 void SetIncomplete(bool bIncomplete);
83
85 vcl::text::ImplLayoutArgs& rMultiArgs,
86 const double* pMultiDXArray);
87
88 virtual ~MultiSalLayout() override;
89
90private:
91 MultiSalLayout( const MultiSalLayout& ) = delete;
93
94 std::unique_ptr<GenericSalLayout> mpLayouts[ MAX_FALLBACK ];
98};
99
101{
104 vcl::text::ImplLayoutArgs& rMultiArgs,
105 const double* pMultiDXArray);
106
107public:
109 ~GenericSalLayout() override;
110
111 void AdjustLayout(vcl::text::ImplLayoutArgs&) final override;
112 bool LayoutText(vcl::text::ImplLayoutArgs&, const SalLayoutGlyphsImpl*) final override;
113 void DrawText(SalGraphics&) const final override;
114 SalLayoutGlyphs GetGlyphs() const final override;
115
116 bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const final override;
117
118 // used by upper layers
119 DeviceCoordinate GetTextWidth() const final override;
120 DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray, const OUString& rStr) const final override;
121 sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const final override;
122 void GetCaretPositions(int nArraySize, sal_Int32* pCaretXArray) const final override;
123
124 // used by display layers
126 { return *m_GlyphItems.GetFont(); }
127
128 bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart,
129 const LogicalFontInstance** ppGlyphFont = nullptr) const override;
130
131 const SalLayoutGlyphsImpl& GlyphsImpl() const { return m_GlyphItems; }
132
133private:
134 // for glyph+font+script fallback
135 void MoveGlyph(int nStart, double nNewXPos);
136 void DropGlyph(int nStart);
137 void Simplify(bool bIsBase);
138
141
142 void ApplyDXArray(const double*, const sal_Bool*);
143 void Justify(DeviceCoordinate nNewWidth);
144 void ApplyAsianKerning(std::u16string_view rStr);
145
146 void GetCharWidths(std::vector<DeviceCoordinate>& rCharWidths,
147 const OUString& rStr) const;
148
149 void SetNeedFallback(vcl::text::ImplLayoutArgs&, sal_Int32, bool);
150
151 bool HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aNextChar);
152
153 void ParseFeatures(std::u16string_view name);
154
155 css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
156
158
159 OString msLanguage;
160 std::vector<hb_feature_t> maFeatures;
161
162 hb_set_t* mpVertGlyphs;
163 const bool mbFuzzing;
164};
165
166#endif // INCLUDED_VCL_INC_SALLAYOUT_HXX
167
168/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SalLayoutFlags
SalLayoutGlyphsImpl m_GlyphItems
Definition: sallayout.hxx:157
GenericSalLayout & operator=(const GenericSalLayout &)=delete
const SalLayoutGlyphsImpl & GlyphsImpl() const
Definition: sallayout.hxx:131
hb_set_t * mpVertGlyphs
Definition: sallayout.hxx:162
std::vector< hb_feature_t > maFeatures
Definition: sallayout.hxx:160
OString msLanguage
Definition: sallayout.hxx:159
const bool mbFuzzing
Definition: sallayout.hxx:163
GenericSalLayout(const GenericSalLayout &)=delete
css::uno::Reference< css::i18n::XBreakIterator > mxBreak
Definition: sallayout.hxx:155
bool GetOutline(basegfx::B2DPolyPolygonVector &) const override
Definition: sallayout.cxx:1106
void AdjustLayout(vcl::text::ImplLayoutArgs &) override
Definition: sallayout.cxx:642
void ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs &rArgs, vcl::text::ImplLayoutArgs &rMultiArgs, const double *pMultiDXArray)
Definition: sallayout.cxx:707
void SetIncomplete(bool bIncomplete)
Definition: sallayout.cxx:611
std::unique_ptr< GenericSalLayout > mpLayouts[MAX_FALLBACK]
Definition: sallayout.hxx:94
MultiSalLayout(const MultiSalLayout &)=delete
std::unique_ptr< SalLayout > ReleaseBaseLayout()
Definition: sallayout.cxx:606
void DrawText(SalGraphics &) const override
Definition: sallayout.cxx:973
void InitFont() const override
Definition: sallayout.cxx:967
DeviceCoordinate FillDXArray(std::vector< DeviceCoordinate > *pDXArray, const OUString &rStr) const override
Definition: sallayout.cxx:1021
sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const override
Definition: sallayout.cxx:988
bool LayoutText(vcl::text::ImplLayoutArgs &, const SalLayoutGlyphsImpl *) override
Definition: sallayout.cxx:633
SalLayoutGlyphs GetGlyphs() const final override
Definition: sallayout.cxx:1147
MultiSalLayout & operator=(const MultiSalLayout &)=delete
void GetCaretPositions(int nArraySize, sal_Int32 *pCaretXArray) const override
Definition: sallayout.cxx:1062
ImplLayoutRuns maFallbackRuns[MAX_FALLBACK]
Definition: sallayout.hxx:95
void AddFallback(std::unique_ptr< SalLayout > pFallbackLayout, ImplLayoutRuns const &)
Definition: sallayout.cxx:621
virtual ~MultiSalLayout() override
Definition: sallayout.cxx:617
bool GetNextGlyph(const GlyphItem **pGlyph, DevicePoint &rPos, int &nStart, const LogicalFontInstance **ppGlyphFont=nullptr) const override
Definition: sallayout.cxx:1080
bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const override
Definition: sallayout.cxx:1123
MultiSalLayout(std::unique_ptr< SalLayout > pBaseLayout)
Definition: sallayout.cxx:597
virtual bool LayoutText(vcl::text::ImplLayoutArgs &, const SalLayoutGlyphsImpl *)=0
virtual bool GetNextGlyph(const GlyphItem **pGlyph, DevicePoint &rPos, int &nStart, const LogicalFontInstance **ppGlyphFont=nullptr) const =0
virtual void AdjustLayout(vcl::text::ImplLayoutArgs &)
Definition: sallayout.cxx:136
virtual void DrawText(SalGraphics &) const =0
virtual SalLayoutGlyphs GetGlyphs() const
Definition: sallayout.cxx:253
sal_Int32 DeviceCoordinate
#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:172