LibreOffice Module vcl (master)  1
impglyphitem.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_IMPGLYPHITEM_HXX
21 #define INCLUDED_VCL_IMPGLYPHITEM_HXX
22 
23 #include <o3tl/typed_flags_set.hxx>
24 #include <tools/gen.hxx>
25 #include <vcl/dllapi.h>
26 #include <vcl/glyphitem.hxx>
27 #include <vcl/outdev.hxx>
28 #include <vector>
29 
30 #include "fontinstance.hxx"
31 
32 enum class GlyphItemFlags
33 {
34  NONE = 0,
35  IS_IN_CLUSTER = 0x001,
36  IS_RTL_GLYPH = 0x002,
37  IS_DIACRITIC = 0x004,
38  IS_VERTICAL = 0x008,
39  IS_SPACING = 0x010,
40  ALLOW_KASHIDA = 0x020,
41  IS_DROPPED = 0x040,
42  IS_CLUSTER_START = 0x080
43 };
44 namespace o3tl
45 {
46 template <> struct typed_flags<GlyphItemFlags> : is_typed_flags<GlyphItemFlags, 0xff>
47 {
48 };
49 };
50 
52 {
54  int m_nCharCount; // number of characters making up this glyph
55  int m_nOrigWidth; // original glyph width
57  int m_nCharPos; // index in string
60 
61 public:
62  int m_nNewWidth; // width after adjustments
63  Point m_aLinearPos; // absolute position of non rotated string
64 
65  GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point& rLinearPos,
66  GlyphItemFlags nFlags, int nOrigWidth, int nXOffset,
67  LogicalFontInstance* pFontInstance)
68  : m_aGlyphId(aGlyphId)
69  , m_nCharCount(nCharCount)
70  , m_nOrigWidth(nOrigWidth)
71  , m_pFontInstance(pFontInstance)
72  , m_nCharPos(nCharPos)
73  , m_nFlags(nFlags)
74  , m_nXOffset(nXOffset)
75  , m_nNewWidth(nOrigWidth)
76  , m_aLinearPos(rLinearPos)
77  {
78  assert(m_pFontInstance);
79  }
80 
81  bool IsInCluster() const { return bool(m_nFlags & GlyphItemFlags::IS_IN_CLUSTER); }
82  bool IsRTLGlyph() const { return bool(m_nFlags & GlyphItemFlags::IS_RTL_GLYPH); }
83  bool IsDiacritic() const { return bool(m_nFlags & GlyphItemFlags::IS_DIACRITIC); }
84  bool IsVertical() const { return bool(m_nFlags & GlyphItemFlags::IS_VERTICAL); }
85  bool IsSpacing() const { return bool(m_nFlags & GlyphItemFlags::IS_SPACING); }
86  bool AllowKashida() const { return bool(m_nFlags & GlyphItemFlags::ALLOW_KASHIDA); }
87  bool IsDropped() const { return bool(m_nFlags & GlyphItemFlags::IS_DROPPED); }
88  bool IsClusterStart() const { return bool(m_nFlags & GlyphItemFlags::IS_CLUSTER_START); }
89 
90  inline bool GetGlyphBoundRect(tools::Rectangle&) const;
91  inline bool GetGlyphOutline(basegfx::B2DPolyPolygon&) const;
92  inline void dropGlyph();
93 
94  sal_GlyphId glyphId() const { return m_aGlyphId; }
95  int charCount() const { return m_nCharCount; }
96  int origWidth() const { return m_nOrigWidth; }
97  int charPos() const { return m_nCharPos; }
98  int xOffset() const { return m_nXOffset; }
99 };
100 
102 {
104 }
105 
107 {
109 }
110 
112 {
113  m_nCharPos = -1;
115 }
116 
117 class SalLayoutGlyphsImpl : public std::vector<GlyphItem>
118 {
119  friend class GenericSalLayout;
120 
121 public:
123  SalLayoutGlyphsImpl* clone(SalLayoutGlyphs& rGlyphs) const;
125  bool IsValid() const;
126  void Invalidate();
127 
128 private:
131 
133  : m_rFontInstance(&rFontInstance)
134  {
135  rGlyphs.m_pImpl = this;
136  }
137 };
138 
139 #endif // INCLUDED_VCL_IMPGLYPHITEM_HXX
140 
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetGlyphBoundRect(sal_GlyphId, tools::Rectangle &, bool) const
bool AllowKashida() const
Point m_aLinearPos
bool IsDiacritic() const
int m_nCharCount
SalLayoutGlyphsImpl * clone(SalLayoutGlyphs &rGlyphs) const
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
bool GetGlyphOutline(basegfx::B2DPolyPolygon &) const
bool IsSpacing() const
bool IsValid() const
sal_uInt16 sal_GlyphId
Definition: glyphitem.hxx:26
SalLayoutFlags mnFlags
void dropGlyph()
sal_GlyphId glyphId() const
SalLayoutGlyphsImpl * m_pImpl
Definition: glyphitem.hxx:33
int m_nOrigWidth
GlyphItemFlags m_nFlags
bool IsVertical() const
bool IsInCluster() const
LogicalFontInstance & GetFont() const
bool IsDropped() const
bool IsRTLGlyph() const
rtl::Reference< LogicalFontInstance > m_rFontInstance
int charCount() const
int charPos() const
SalLayoutFlags
Definition: outdev.hxx:121
int origWidth() const
bool IsClusterStart() const
sal_GlyphId m_aGlyphId
virtual bool GetGlyphOutline(sal_GlyphId, basegfx::B2DPolyPolygon &, bool) const =0
GlyphItemFlags
LogicalFontInstance * m_pFontInstance
int xOffset() const
SalLayoutGlyphsImpl(SalLayoutGlyphs &rGlyphs, LogicalFontInstance &rFontInstance)
bool GetGlyphBoundRect(tools::Rectangle &) const
GlyphItem(int nCharPos, int nCharCount, sal_GlyphId aGlyphId, const Point &rLinearPos, GlyphItemFlags nFlags, int nOrigWidth, int nXOffset, LogicalFontInstance *pFontInstance)