OLD | NEW |
---|---|
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_ | 7 #ifndef CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_ |
8 #define CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_ | 8 #define CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "core/fpdfdoc/cpvt_arraytemplate.h" | |
12 #include "core/fpdfdoc/cpvt_floatrect.h" | 13 #include "core/fpdfdoc/cpvt_floatrect.h" |
13 #include "core/fpdfdoc/cpvt_lineinfo.h" | 14 #include "core/fpdfdoc/cpvt_lineinfo.h" |
14 #include "core/fpdfdoc/include/cpvt_line.h" | 15 #include "core/fpdfdoc/include/cpvt_line.h" |
15 #include "core/fpdfdoc/include/cpvt_wordplace.h" | 16 #include "core/fpdfdoc/include/cpvt_wordplace.h" |
16 #include "core/fpdfdoc/include/cpvt_wordrange.h" | 17 #include "core/fpdfdoc/include/cpvt_wordrange.h" |
17 #include "core/fpdfdoc/pdf_vt.h" | |
18 #include "core/fxcrt/include/fx_coordinates.h" | 18 #include "core/fxcrt/include/fx_coordinates.h" |
19 #include "core/fxcrt/include/fx_string.h" | 19 #include "core/fxcrt/include/fx_string.h" |
20 #include "core/fxcrt/include/fx_system.h" | 20 #include "core/fxcrt/include/fx_system.h" |
21 #include "core/fxge/include/fx_font.h" | 21 #include "core/fxge/include/fx_font.h" |
22 | 22 |
23 class CSection; | 23 class CSection; |
24 class IPVT_FontMap; | 24 class IPVT_FontMap; |
25 | 25 |
26 struct CPVT_SecProps; | 26 struct CPVT_SecProps; |
27 struct CPVT_Section; | 27 struct CPVT_Section; |
28 struct CPVT_SectionInfo; | 28 struct CPVT_SectionInfo; |
29 struct CPVT_Word; | 29 struct CPVT_Word; |
30 struct CPVT_WordInfo; | 30 struct CPVT_WordInfo; |
31 struct CPVT_WordProps; | 31 struct CPVT_WordProps; |
32 | 32 |
33 #define VARIABLETEXT_HALF 0.5f | 33 #define VARIABLETEXT_HALF 0.5f |
34 | 34 |
35 class CPDF_VariableText : private CPDF_EditContainer { | 35 class CPDF_VariableText { |
36 public: | 36 public: |
37 enum class ScriptType { Normal, Super, Sub }; | 37 enum class ScriptType { Normal, Super, Sub }; |
38 | 38 |
39 class Iterator { | 39 class Iterator { |
40 public: | 40 public: |
41 explicit Iterator(CPDF_VariableText* pVT); | 41 explicit Iterator(CPDF_VariableText* pVT); |
42 ~Iterator(); | 42 ~Iterator(); |
43 | 43 |
44 FX_BOOL NextWord(); | 44 FX_BOOL NextWord(); |
45 FX_BOOL PrevWord(); | 45 FX_BOOL PrevWord(); |
(...skipping 29 matching lines...) Expand all Loading... | |
75 int32_t charset, | 75 int32_t charset, |
76 int32_t nFontIndex); | 76 int32_t nFontIndex); |
77 virtual FX_BOOL IsLatinWord(uint16_t word); | 77 virtual FX_BOOL IsLatinWord(uint16_t word); |
78 virtual int32_t GetDefaultFontIndex(); | 78 virtual int32_t GetDefaultFontIndex(); |
79 | 79 |
80 private: | 80 private: |
81 IPVT_FontMap* const m_pFontMap; | 81 IPVT_FontMap* const m_pFontMap; |
82 }; | 82 }; |
83 | 83 |
84 CPDF_VariableText(); | 84 CPDF_VariableText(); |
85 ~CPDF_VariableText() override; | 85 ~CPDF_VariableText(); |
86 | 86 |
87 void SetProvider(CPDF_VariableText::Provider* pProvider); | 87 void SetProvider(CPDF_VariableText::Provider* pProvider); |
88 CPDF_VariableText::Iterator* GetIterator(); | 88 CPDF_VariableText::Iterator* GetIterator(); |
89 | 89 |
90 // CPDF_EditContainer. | 90 void SetContentRect(const CPVT_FloatRect& rect); |
91 void SetPlateRect(const CFX_FloatRect& rect) override; | 91 CFX_FloatRect GetContentRect() const; |
92 CFX_FloatRect GetContentRect() const override; | 92 void SetPlateRect(const CFX_FloatRect& rect); |
93 const CFX_FloatRect& GetPlateRect() const override; | 93 const CFX_FloatRect& GetPlateRect() const; |
94 | 94 |
95 void SetAlignment(int32_t nFormat) { m_nAlignment = nFormat; } | 95 void SetAlignment(int32_t nFormat) { m_nAlignment = nFormat; } |
96 void SetPasswordChar(uint16_t wSubWord) { m_wSubWord = wSubWord; } | 96 void SetPasswordChar(uint16_t wSubWord) { m_wSubWord = wSubWord; } |
97 void SetLimitChar(int32_t nLimitChar) { m_nLimitChar = nLimitChar; } | 97 void SetLimitChar(int32_t nLimitChar) { m_nLimitChar = nLimitChar; } |
98 void SetCharSpace(FX_FLOAT fCharSpace) { m_fCharSpace = fCharSpace; } | 98 void SetCharSpace(FX_FLOAT fCharSpace) { m_fCharSpace = fCharSpace; } |
99 void SetMultiLine(FX_BOOL bMultiLine) { m_bMultiLine = bMultiLine; } | 99 void SetMultiLine(FX_BOOL bMultiLine) { m_bMultiLine = bMultiLine; } |
100 void SetAutoReturn(FX_BOOL bAuto) { m_bLimitWidth = bAuto; } | 100 void SetAutoReturn(FX_BOOL bAuto) { m_bLimitWidth = bAuto; } |
101 void SetFontSize(FX_FLOAT fFontSize) { m_fFontSize = fFontSize; } | 101 void SetFontSize(FX_FLOAT fFontSize) { m_fFontSize = fFontSize; } |
102 void SetCharArray(int32_t nCharArray) { m_nCharArray = nCharArray; } | 102 void SetCharArray(int32_t nCharArray) { m_nCharArray = nCharArray; } |
103 void SetAutoFontSize(FX_BOOL bAuto) { m_bAutoFontSize = bAuto; } | 103 void SetAutoFontSize(FX_BOOL bAuto) { m_bAutoFontSize = bAuto; } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace& place) const; | 144 CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace& place) const; |
145 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const; | 145 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const; |
146 void UpdateWordPlace(CPVT_WordPlace& place) const; | 146 void UpdateWordPlace(CPVT_WordPlace& place) const; |
147 CPVT_WordPlace AdjustLineHeader(const CPVT_WordPlace& place, | 147 CPVT_WordPlace AdjustLineHeader(const CPVT_WordPlace& place, |
148 FX_BOOL bPrevOrNext) const; | 148 FX_BOOL bPrevOrNext) const; |
149 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const; | 149 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const; |
150 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const; | 150 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const; |
151 | 151 |
152 uint16_t GetSubWord() const { return m_wSubWord; } | 152 uint16_t GetSubWord() const { return m_wSubWord; } |
153 | 153 |
154 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } | |
155 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } | |
156 CFX_SizeF GetPlateSize() const { | |
157 return CFX_SizeF(GetPlateWidth(), GetPlateHeight()); | |
158 } | |
159 CFX_FloatPoint GetBTPoint() const { | |
160 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); | |
161 } | |
162 CFX_FloatPoint GetETPoint() const { | |
163 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); | |
164 } | |
165 CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const { | |
166 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); | |
167 } | |
168 CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const { | |
169 return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); | |
170 } | |
171 CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const { | |
172 CFX_FloatPoint ptLeftTop = InToOut(CFX_FloatPoint(rect.left, rect.top)); | |
Lei Zhang
2016/07/28 21:50:03
Feels like these should be moved out of the header
dsinclair
2016/08/02 17:55:47
Done.
| |
173 CFX_FloatPoint ptRightBottom = | |
174 InToOut(CFX_FloatPoint(rect.right, rect.bottom)); | |
175 return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, | |
176 ptLeftTop.y); | |
177 } | |
178 CPVT_FloatRect OutToIn(const CFX_FloatRect& rect) const { | |
179 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); | |
180 CFX_FloatPoint ptRightBottom = | |
181 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); | |
182 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, | |
183 ptRightBottom.y); | |
184 } | |
185 | |
154 private: | 186 private: |
155 friend class CTypeset; | 187 friend class CTypeset; |
156 friend class CSection; | 188 friend class CSection; |
157 | 189 |
158 int32_t GetCharWidth(int32_t nFontIndex, | 190 int32_t GetCharWidth(int32_t nFontIndex, |
159 uint16_t Word, | 191 uint16_t Word, |
160 uint16_t SubWord, | 192 uint16_t SubWord, |
161 int32_t nWordStyle); | 193 int32_t nWordStyle); |
162 int32_t GetTypeAscent(int32_t nFontIndex); | 194 int32_t GetTypeAscent(int32_t nFontIndex); |
163 int32_t GetTypeDescent(int32_t nFontIndex); | 195 int32_t GetTypeDescent(int32_t nFontIndex); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 FX_BOOL m_bAutoFontSize; | 258 FX_BOOL m_bAutoFontSize; |
227 int32_t m_nAlignment; | 259 int32_t m_nAlignment; |
228 FX_FLOAT m_fLineLeading; | 260 FX_FLOAT m_fLineLeading; |
229 FX_FLOAT m_fCharSpace; | 261 FX_FLOAT m_fCharSpace; |
230 int32_t m_nHorzScale; | 262 int32_t m_nHorzScale; |
231 uint16_t m_wSubWord; | 263 uint16_t m_wSubWord; |
232 FX_FLOAT m_fFontSize; | 264 FX_FLOAT m_fFontSize; |
233 FX_BOOL m_bInitial; | 265 FX_BOOL m_bInitial; |
234 CPDF_VariableText::Provider* m_pVTProvider; | 266 CPDF_VariableText::Provider* m_pVTProvider; |
235 std::unique_ptr<CPDF_VariableText::Iterator> m_pVTIterator; | 267 std::unique_ptr<CPDF_VariableText::Iterator> m_pVTIterator; |
268 CFX_FloatRect m_rcPlate; | |
269 CPVT_FloatRect m_rcContent; | |
236 }; | 270 }; |
237 | 271 |
238 #endif // CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_ | 272 #endif // CORE_FPDFDOC_INCLUDE_CPDF_VARIABLETEXT_H_ |
OLD | NEW |