gb_var2file: remove now unused chunk-size parameter
[LibreOffice.git] / vcl / inc / impglyphitem.hxx
blob87f966bd1676008fa5c60a4ca3ef4011b22b0960
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_IMPGLYPHITEM_HXX
21 #define INCLUDED_VCL_IMPGLYPHITEM_HXX
23 #include <o3tl/typed_flags_set.hxx>
24 #include <tools/gen.hxx>
25 #include <vcl/dllapi.h>
26 #include <vcl/outdev.hxx>
27 #include <vector>
29 #include "font/LogicalFontInstance.hxx"
30 #include "glyphid.hxx"
32 enum class GlyphItemFlags : sal_uInt8
34 NONE = 0,
35 IS_IN_CLUSTER = 0x01,
36 IS_RTL_GLYPH = 0x02,
37 IS_VERTICAL = 0x04,
38 IS_SPACING = 0x08,
39 IS_DROPPED = 0x10,
40 IS_CLUSTER_START = 0x20,
41 IS_UNSAFE_TO_BREAK = 0x40, // HB_GLYPH_FLAG_UNSAFE_TO_BREAK from harfbuzz
42 IS_SAFE_TO_INSERT_KASHIDA = 0x80 // HB_GLYPH_FLAG_SAFE_TO_INSERT_TATWEEL from harfbuzz
44 namespace o3tl
46 template <> struct typed_flags<GlyphItemFlags> : is_typed_flags<GlyphItemFlags, 0xff>
51 class VCL_DLLPUBLIC GlyphItem
53 DevicePoint m_aLinearPos; // absolute position of non rotated string
54 DeviceCoordinate m_nOrigWidth; // original glyph width
55 sal_Int32 m_nCharPos; // index in string
56 sal_Int32 m_nXOffset;
57 sal_Int32 m_nYOffset;
58 DeviceCoordinate m_nNewWidth; // width after adjustments
59 sal_GlyphId m_aGlyphId;
60 GlyphItemFlags m_nFlags;
61 sal_Int8 m_nCharCount; // number of characters making up this glyph
63 public:
64 GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const DevicePoint& rLinearPos,
65 GlyphItemFlags nFlags, DeviceCoordinate nOrigWidth, int nXOffset, int nYOffset)
66 : m_aLinearPos(rLinearPos)
67 , m_nOrigWidth(nOrigWidth)
68 , m_nCharPos(nCharPos)
69 , m_nXOffset(nXOffset)
70 , m_nYOffset(nYOffset)
71 , m_nNewWidth(nOrigWidth)
72 , m_aGlyphId(aGlyphId)
73 , m_nFlags(nFlags)
74 , m_nCharCount(nCharCount)
78 bool IsInCluster() const { return bool(m_nFlags & GlyphItemFlags::IS_IN_CLUSTER); }
79 bool IsRTLGlyph() const { return bool(m_nFlags & GlyphItemFlags::IS_RTL_GLYPH); }
80 bool IsVertical() const { return bool(m_nFlags & GlyphItemFlags::IS_VERTICAL); }
81 bool IsSpacing() const { return bool(m_nFlags & GlyphItemFlags::IS_SPACING); }
82 bool IsDropped() const { return bool(m_nFlags & GlyphItemFlags::IS_DROPPED); }
83 bool IsClusterStart() const { return bool(m_nFlags & GlyphItemFlags::IS_CLUSTER_START); }
84 bool IsUnsafeToBreak() const { return bool(m_nFlags & GlyphItemFlags::IS_UNSAFE_TO_BREAK); }
85 bool IsSafeToInsertKashida() const
87 return bool(m_nFlags & GlyphItemFlags::IS_SAFE_TO_INSERT_KASHIDA);
90 inline bool GetGlyphBoundRect(const LogicalFontInstance*, tools::Rectangle&) const;
91 inline bool GetGlyphOutline(const LogicalFontInstance*, basegfx::B2DPolyPolygon&) const;
92 inline void dropGlyph();
94 sal_GlyphId glyphId() const { return m_aGlyphId; }
95 int charCount() const { return m_nCharCount; }
96 DeviceCoordinate origWidth() const { return m_nOrigWidth; }
97 int charPos() const { return m_nCharPos; }
98 int xOffset() const { return m_nXOffset; }
99 int yOffset() const { return m_nYOffset; }
100 DeviceCoordinate newWidth() const { return m_nNewWidth; }
101 const DevicePoint& linearPos() const { return m_aLinearPos; }
103 void setNewWidth(DeviceCoordinate width) { m_nNewWidth = width; }
104 void addNewWidth(DeviceCoordinate width) { m_nNewWidth += width; }
105 void setLinearPos(const DevicePoint& point) { m_aLinearPos = point; }
106 void setLinearPosX(double x) { m_aLinearPos.setX(x); }
107 void adjustLinearPosX(double diff) { m_aLinearPos.adjustX(diff); }
108 bool isLayoutEquivalent(const GlyphItem& other) const
110 return m_aLinearPos == other.m_aLinearPos && m_nOrigWidth == other.m_nOrigWidth
111 && m_nCharPos == other.m_nCharPos && m_nXOffset == other.m_nXOffset
112 && m_nYOffset == other.m_nYOffset && m_nNewWidth == other.m_nNewWidth
113 && m_aGlyphId == other.m_aGlyphId && m_nCharCount == other.m_nCharCount
114 && (m_nFlags & ~GlyphItemFlags::IS_UNSAFE_TO_BREAK)
115 == (other.m_nFlags & ~GlyphItemFlags::IS_UNSAFE_TO_BREAK);
119 bool GlyphItem::GetGlyphBoundRect(const LogicalFontInstance* pFontInstance,
120 tools::Rectangle& rRect) const
122 return pFontInstance->GetGlyphBoundRect(m_aGlyphId, rRect, IsVertical());
125 bool GlyphItem::GetGlyphOutline(const LogicalFontInstance* pFontInstance,
126 basegfx::B2DPolyPolygon& rPoly) const
128 return pFontInstance->GetGlyphOutline(m_aGlyphId, rPoly, IsVertical());
131 void GlyphItem::dropGlyph()
133 m_nCharPos = -1;
134 m_nFlags |= GlyphItemFlags::IS_DROPPED;
137 class SalLayoutGlyphsImpl : public std::vector<GlyphItem>
139 public:
140 SalLayoutGlyphsImpl(LogicalFontInstance& rFontInstance)
141 : m_rFontInstance(&rFontInstance)
144 SalLayoutGlyphsImpl* clone() const;
145 SalLayoutGlyphsImpl* cloneCharRange(sal_Int32 index, sal_Int32 length) const;
146 const rtl::Reference<LogicalFontInstance>& GetFont() const { return m_rFontInstance; }
147 bool IsValid() const;
148 void SetFlags(SalLayoutFlags flags) { mnFlags = flags; }
149 SalLayoutFlags GetFlags() const { return mnFlags; }
150 #ifdef DBG_UTIL
151 bool isLayoutEquivalent(const SalLayoutGlyphsImpl* other) const;
152 #endif
154 private:
155 bool isSafeToBreak(const_iterator pos, bool rtl) const;
156 rtl::Reference<LogicalFontInstance> m_rFontInstance;
157 SalLayoutFlags mnFlags = SalLayoutFlags::NONE;
160 #endif // INCLUDED_VCL_IMPGLYPHITEM_HXX
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */