calc: on editing invalidation of view with different zoom is wrong
[LibreOffice.git] / vcl / inc / sallayout.hxx
blobd48edaaf67f297a19629332916ee06d2d6739e6b
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 #ifndef INCLUDED_VCL_INC_SALLAYOUT_HXX
21 #define INCLUDED_VCL_INC_SALLAYOUT_HXX
23 #include <sal/config.h>
25 #include <basegfx/polygon/b2dpolypolygon.hxx>
26 #include <tools/gen.hxx>
27 #include <tools/degree.hxx>
28 #include <i18nlangtag/languagetag.hxx>
30 #include <vcl/dllapi.h>
31 #include <vcl/devicecoordinate.hxx>
32 #include <vcl/vclenum.hxx> // for typedef sal_UCS4
33 #include <vcl/vcllayout.hxx>
35 #include "ImplLayoutRuns.hxx"
36 #include "impglyphitem.hxx"
38 #include <com/sun/star/i18n/XBreakIterator.hpp>
40 #include <hb.h>
42 #include <iostream>
43 #include <memory>
44 #include <vector>
46 #define MAX_FALLBACK 16
48 class GenericSalLayout;
49 class SalGraphics;
50 enum class SalLayoutFlags;
52 namespace vcl::font {
53 class PhysicalFontFace;
56 namespace vcl::text {
57 class TextLayoutCache;
60 class MultiSalLayout final : public SalLayout
62 public:
63 void DrawText(SalGraphics&) const override;
64 sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const override;
65 DeviceCoordinate GetTextWidth() const final override;
66 DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray, const OUString& rStr) const override;
67 void GetCaretPositions(int nArraySize, sal_Int32* pCaretXArray) const override;
68 bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& 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;
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();
79 bool LayoutText(vcl::text::ImplLayoutArgs&, const SalLayoutGlyphsImpl*) override;
80 void AdjustLayout(vcl::text::ImplLayoutArgs&) override;
81 void InitFont() const override;
83 void SetIncomplete(bool bIncomplete);
85 void ImplAdjustMultiLayout(vcl::text::ImplLayoutArgs& rArgs,
86 vcl::text::ImplLayoutArgs& rMultiArgs,
87 const double* pMultiDXArray);
89 virtual ~MultiSalLayout() override;
91 private:
92 MultiSalLayout( const MultiSalLayout& ) = delete;
93 MultiSalLayout& operator=( const MultiSalLayout& ) = delete;
95 std::unique_ptr<GenericSalLayout> mpLayouts[ MAX_FALLBACK ];
96 ImplLayoutRuns maFallbackRuns[ MAX_FALLBACK ];
97 int mnLevel;
98 bool mbIncomplete;
101 class VCL_DLLPUBLIC GenericSalLayout : public SalLayout
103 friend void MultiSalLayout::ImplAdjustMultiLayout(
104 vcl::text::ImplLayoutArgs& rArgs,
105 vcl::text::ImplLayoutArgs& rMultiArgs,
106 const double* pMultiDXArray);
108 public:
109 GenericSalLayout(LogicalFontInstance&);
110 ~GenericSalLayout() override;
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;
117 bool IsKashidaPosValid(int nCharPos, int nNextCharPos) const final override;
119 // used by upper layers
120 DeviceCoordinate GetTextWidth() const final override;
121 DeviceCoordinate FillDXArray(std::vector<DeviceCoordinate>* pDXArray, const OUString& rStr) const final override;
122 sal_Int32 GetTextBreak(DeviceCoordinate nMaxWidth, DeviceCoordinate nCharExtra, int nFactor) const final override;
123 void GetCaretPositions(int nArraySize, sal_Int32* pCaretXArray) const final override;
125 // used by display layers
126 LogicalFontInstance& GetFont() const
127 { return *m_GlyphItems.GetFont(); }
129 bool GetNextGlyph(const GlyphItem** pGlyph, DevicePoint& rPos, int& nStart,
130 const LogicalFontInstance** ppGlyphFont = nullptr) const override;
132 const SalLayoutGlyphsImpl& GlyphsImpl() const { return m_GlyphItems; }
134 private:
135 // for glyph+font+script fallback
136 void MoveGlyph(int nStart, double nNewXPos);
137 void DropGlyph(int nStart);
138 void Simplify(bool bIsBase);
140 GenericSalLayout( const GenericSalLayout& ) = delete;
141 GenericSalLayout& operator=( const GenericSalLayout& ) = delete;
143 void ApplyDXArray(const double*, const sal_Bool*);
144 void Justify(DeviceCoordinate nNewWidth);
145 void ApplyAsianKerning(std::u16string_view rStr);
147 void GetCharWidths(std::vector<DeviceCoordinate>& rCharWidths,
148 const OUString& rStr) const;
150 void SetNeedFallback(vcl::text::ImplLayoutArgs&, sal_Int32, bool);
152 bool HasVerticalAlternate(sal_UCS4 aChar, sal_UCS4 aNextChar);
154 void ParseFeatures(std::u16string_view name);
156 css::uno::Reference<css::i18n::XBreakIterator> mxBreak;
158 SalLayoutGlyphsImpl m_GlyphItems;
160 OString msLanguage;
161 std::vector<hb_feature_t> maFeatures;
163 hb_set_t* mpVertGlyphs;
164 const bool mbFuzzing;
167 #endif // INCLUDED_VCL_INC_SALLAYOUT_HXX
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */