summaryrefslogtreecommitdiff
path: root/vcl/inc/impglyphitem.hxx
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2019-07-05 22:12:39 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2019-07-06 03:15:58 +0200
commitaf8f249ad6368fb957b98ea70bfdf6778709d2eb (patch)
treea0693930c1a4e887efcb502aa033dea0916ef734 /vcl/inc/impglyphitem.hxx
parenta36e0f34f2d1baa95f3fe1c9afe6882abcf554dc (diff)
Constify GlyphItem
This hides all the data, which shouldn't change after init. Real const makes a lot of problems for copying, so this is the 2nd option to just add getters for private data. While at it use typed_flags for the GlyphItemFlags. Change-Id: Ic1eeabe2398f6c30080fdd516285b72c620b11be Reviewed-on: https://gerrit.libreoffice.org/75147 Tested-by: Jenkins Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'vcl/inc/impglyphitem.hxx')
-rw-r--r--vcl/inc/impglyphitem.hxx77
1 files changed, 51 insertions, 26 deletions
diff --git a/vcl/inc/impglyphitem.hxx b/vcl/inc/impglyphitem.hxx
index 987df438894c..a04113a1fbae 100644
--- a/vcl/inc/impglyphitem.hxx
+++ b/vcl/inc/impglyphitem.hxx
@@ -20,6 +20,7 @@
#ifndef INCLUDED_VCL_IMPGLYPHITEM_HXX
#define INCLUDED_VCL_IMPGLYPHITEM_HXX
+#include <o3tl/typed_flags_set.hxx>
#include <tools/gen.hxx>
#include <vcl/dllapi.h>
#include <vcl/glyphitem.hxx>
@@ -28,57 +29,75 @@
#include "fontinstance.hxx"
-struct VCL_DLLPUBLIC GlyphItem
+enum class GlyphItemFlags
+{
+ NONE = 0,
+ IS_IN_CLUSTER = 0x001,
+ IS_RTL_GLYPH = 0x002,
+ IS_DIACRITIC = 0x004,
+ IS_VERTICAL = 0x008,
+ IS_SPACING = 0x010,
+ ALLOW_KASHIDA = 0x020,
+ IS_DROPPED = 0x040,
+ IS_CLUSTER_START = 0x080
+};
+namespace o3tl
+{
+template <> struct typed_flags<GlyphItemFlags> : is_typed_flags<GlyphItemFlags, 0xff>
+{
+};
+};
+
+class VCL_DLLPUBLIC GlyphItem
{
sal_GlyphId m_aGlyphId;
int m_nCharCount; // number of characters making up this glyph
int m_nOrigWidth; // original glyph width
LogicalFontInstance* m_pFontInstance;
-
int m_nCharPos; // index in string
- int m_nFlags;
- int m_nNewWidth; // width after adjustments
+ GlyphItemFlags m_nFlags;
int m_nXOffset;
+
+public:
+ int m_nNewWidth; // width after adjustments
Point m_aLinearPos; // absolute position of non rotated string
GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point& rLinearPos,
- long nFlags, int nOrigWidth, int nXOffset, LogicalFontInstance* pFontInstance)
+ GlyphItemFlags nFlags, int nOrigWidth, int nXOffset,
+ LogicalFontInstance* pFontInstance)
: m_aGlyphId(aGlyphId)
, m_nCharCount(nCharCount)
, m_nOrigWidth(nOrigWidth)
, m_pFontInstance(pFontInstance)
, m_nCharPos(nCharPos)
, m_nFlags(nFlags)
- , m_nNewWidth(nOrigWidth)
, m_nXOffset(nXOffset)
+ , m_nNewWidth(nOrigWidth)
, m_aLinearPos(rLinearPos)
{
assert(m_pFontInstance);
}
- enum
- {
- IS_IN_CLUSTER = 0x001,
- IS_RTL_GLYPH = 0x002,
- IS_DIACRITIC = 0x004,
- IS_VERTICAL = 0x008,
- IS_SPACING = 0x010,
- ALLOW_KASHIDA = 0x020,
- IS_DROPPED = 0x040,
- IS_CLUSTER_START = 0x080
- };
-
- bool IsInCluster() const { return ((m_nFlags & IS_IN_CLUSTER) != 0); }
- bool IsRTLGlyph() const { return ((m_nFlags & IS_RTL_GLYPH) != 0); }
- bool IsDiacritic() const { return ((m_nFlags & IS_DIACRITIC) != 0); }
- bool IsVertical() const { return ((m_nFlags & IS_VERTICAL) != 0); }
- bool IsSpacing() const { return ((m_nFlags & IS_SPACING) != 0); }
- bool AllowKashida() const { return ((m_nFlags & ALLOW_KASHIDA) != 0); }
- bool IsDropped() const { return ((m_nFlags & IS_DROPPED) != 0); }
- bool IsClusterStart() const { return ((m_nFlags & IS_CLUSTER_START) != 0); }
+ bool IsInCluster() const { return bool(m_nFlags & GlyphItemFlags::IS_IN_CLUSTER); }
+ bool IsRTLGlyph() const { return bool(m_nFlags & GlyphItemFlags::IS_RTL_GLYPH); }
+ bool IsDiacritic() const { return bool(m_nFlags & GlyphItemFlags::IS_DIACRITIC); }
+ bool IsVertical() const { return bool(m_nFlags & GlyphItemFlags::IS_VERTICAL); }
+ bool IsSpacing() const { return bool(m_nFlags & GlyphItemFlags::IS_SPACING); }
+ bool AllowKashida() const { return bool(m_nFlags & GlyphItemFlags::ALLOW_KASHIDA); }
+ bool IsDropped() const { return bool(m_nFlags & GlyphItemFlags::IS_DROPPED); }
+ bool IsClusterStart() const { return bool(m_nFlags & GlyphItemFlags::IS_CLUSTER_START); }
inline bool GetGlyphBoundRect(tools::Rectangle&) const;
inline bool GetGlyphOutline(basegfx::B2DPolyPolygon&) const;
+ inline void dropGlyph();
+
+ sal_GlyphId glyphId() const { return m_aGlyphId; }
+ int charCount() const { return m_nCharCount; }
+ int origWidth() const { return m_nOrigWidth; }
+ LogicalFontInstance* fontInstance() const { return m_pFontInstance; }
+ GlyphItemFlags flags() const { return m_nFlags; }
+ int charPos() const { return m_nCharPos; }
+ int xOffset() const { return m_nXOffset; }
};
VCL_DLLPUBLIC bool GlyphItem::GetGlyphBoundRect(tools::Rectangle& rRect) const
@@ -91,6 +110,12 @@ VCL_DLLPUBLIC bool GlyphItem::GetGlyphOutline(basegfx::B2DPolyPolygon& rPoly) co
return m_pFontInstance->GetGlyphOutline(m_aGlyphId, rPoly, IsVertical());
}
+void GlyphItem::dropGlyph()
+{
+ m_nCharPos = -1;
+ m_nFlags |= GlyphItemFlags::IS_DROPPED;
+}
+
class SalLayoutGlyphsImpl : public std::vector<GlyphItem>
{
friend class GenericSalLayout;