OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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_SRC_FPDFDOC_PDF_VT_H_ | 7 #ifndef CORE_SRC_FPDFDOC_PDF_VT_H_ |
8 #define CORE_SRC_FPDFDOC_PDF_VT_H_ | 8 #define CORE_SRC_FPDFDOC_PDF_VT_H_ |
9 | 9 |
10 class CPVT_Size; | 10 class CPVT_Size; |
11 class CPVT_FloatRect; | 11 class CPVT_FloatRect; |
12 struct CPVT_SectionInfo; | 12 struct CPVT_SectionInfo; |
13 struct CPVT_LineInfo; | 13 struct CPVT_LineInfo; |
14 struct CPVT_WordInfo; | 14 struct CPVT_WordInfo; |
15 class CLine; | 15 class CLine; |
16 class CLines; | 16 class CLines; |
17 class CSection; | 17 class CSection; |
18 class CTypeset; | 18 class CTypeset; |
19 class CPDF_EditContainer; | 19 class CPDF_EditContainer; |
20 class CPDF_VariableText; | 20 class CPDF_VariableText; |
21 class CPDF_VariableText_Iterator; | 21 class CPDF_VariableText_Iterator; |
22 #define IsFloatZero(f)» » » » » » ((f) < 0.0001 &&
(f) > -0.0001) | 22 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
23 #define IsFloatBigger(fa,fb)» » » » ((fa) > (fb) && !IsFloat
Zero((fa) - (fb))) | 23 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
24 #define IsFloatSmaller(fa,fb)» » » » ((fa) < (fb) && !IsFloat
Zero((fa) - (fb))) | 24 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
25 template<class T> T FPDF_MIN (const T & i, const T & j) | 25 template <class T> |
26 { | 26 T FPDF_MIN(const T& i, const T& j) { |
27 return ((i < j) ? i : j); | 27 return ((i < j) ? i : j); |
28 } | 28 } |
29 template<class T> T FPDF_MAX (const T & i, const T & j) | 29 template <class T> |
30 { | 30 T FPDF_MAX(const T& i, const T& j) { |
31 return ((i > j) ? i : j); | 31 return ((i > j) ? i : j); |
32 } | 32 } |
33 class CPVT_Size | 33 class CPVT_Size { |
34 { | 34 public: |
35 public: | 35 CPVT_Size() : x(0.0f), y(0.0f) {} |
36 CPVT_Size() : x(0.0f), y(0.0f) | 36 CPVT_Size(FX_FLOAT other_x, FX_FLOAT other_y) { |
37 { | 37 x = other_x; |
38 } | 38 y = other_y; |
39 CPVT_Size(FX_FLOAT other_x, FX_FLOAT other_y) | 39 } |
40 { | 40 FX_FLOAT x, y; |
41 x = other_x; | 41 }; |
42 y = other_y; | 42 class CPVT_FloatRect : public CFX_FloatRect { |
43 } | 43 public: |
44 FX_FLOAT x, y; | 44 CPVT_FloatRect() { left = top = right = bottom = 0.0f; } |
45 }; | 45 CPVT_FloatRect(FX_FLOAT other_left, |
46 class CPVT_FloatRect : public CFX_FloatRect | 46 FX_FLOAT other_top, |
47 { | 47 FX_FLOAT other_right, |
48 public: | 48 FX_FLOAT other_bottom) { |
49 CPVT_FloatRect() | 49 left = other_left; |
50 { | 50 top = other_top; |
51 left = top = right = bottom = 0.0f; | 51 right = other_right; |
52 } | 52 bottom = other_bottom; |
53 CPVT_FloatRect(FX_FLOAT other_left, | 53 } |
54 FX_FLOAT other_top, | 54 CPVT_FloatRect(const CPDF_Rect& rect) { |
55 FX_FLOAT other_right, | 55 left = rect.left; |
56 FX_FLOAT other_bottom) | 56 top = rect.top; |
57 { | 57 right = rect.right; |
58 left = other_left; | 58 bottom = rect.bottom; |
59 top = other_top; | 59 } |
60 right = other_right; | 60 void Default() { left = top = right = bottom = 0.0f; } |
61 bottom = other_bottom; | 61 FX_FLOAT Height() const { |
62 } | 62 if (top > bottom) |
63 CPVT_FloatRect(const CPDF_Rect & rect) | 63 return top - bottom; |
64 { | 64 return bottom - top; |
65 left = rect.left; | 65 } |
66 top = rect.top; | |
67 right = rect.right; | |
68 bottom = rect.bottom; | |
69 } | |
70 void Default() | |
71 { | |
72 left = top = right = bottom = 0.0f; | |
73 } | |
74 FX_FLOAT Height() const | |
75 { | |
76 if (top > bottom) | |
77 return top - bottom; | |
78 return bottom - top; | |
79 } | |
80 }; | 66 }; |
81 struct CPVT_SectionInfo { | 67 struct CPVT_SectionInfo { |
82 CPVT_SectionInfo() : rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps
(NULL) | 68 CPVT_SectionInfo() |
83 { | 69 : rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps(NULL) {} |
84 } | 70 virtual ~CPVT_SectionInfo() { |
85 virtual ~CPVT_SectionInfo() | 71 delete pSecProps; |
86 { | 72 delete pWordProps; |
87 delete pSecProps; | 73 } |
88 delete pWordProps; | 74 CPVT_SectionInfo(const CPVT_SectionInfo& other) |
89 } | 75 : rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps(NULL) { |
90 CPVT_SectionInfo(const CPVT_SectionInfo & other): rcSection(), nTotalLine(0)
, pSecProps(NULL), pWordProps(NULL) | 76 operator=(other); |
91 { | 77 } |
92 operator = (other); | 78 void operator=(const CPVT_SectionInfo& other) { |
93 } | 79 if (this == &other) { |
94 void operator = (const CPVT_SectionInfo & other) | 80 return; |
95 { | 81 } |
96 if (this == &other) { | 82 rcSection = other.rcSection; |
97 return; | 83 nTotalLine = other.nTotalLine; |
98 } | 84 if (other.pSecProps) { |
99 rcSection = other.rcSection; | 85 if (pSecProps) { |
100 nTotalLine = other.nTotalLine; | 86 *pSecProps = *other.pSecProps; |
101 if (other.pSecProps) { | 87 } else { |
102 if (pSecProps) { | 88 pSecProps = new CPVT_SecProps(*other.pSecProps); |
103 *pSecProps = *other.pSecProps; | 89 } |
104 } else { | 90 } |
105 pSecProps = new CPVT_SecProps(*other.pSecProps); | 91 if (other.pWordProps) { |
106 } | 92 if (pWordProps) { |
107 } | 93 *pWordProps = *other.pWordProps; |
108 if (other.pWordProps) { | 94 } else { |
109 if (pWordProps) { | 95 pWordProps = new CPVT_WordProps(*other.pWordProps); |
110 *pWordProps = *other.pWordProps; | 96 } |
111 } else { | 97 } |
112 pWordProps = new CPVT_WordProps(*other.pWordProps); | 98 } |
113 } | 99 CPVT_FloatRect rcSection; |
114 } | 100 int32_t nTotalLine; |
115 } | 101 CPVT_SecProps* pSecProps; |
116 CPVT_FloatRect» » » » rcSection; | 102 CPVT_WordProps* pWordProps; |
117 int32_t» » » » » nTotalLine; | |
118 CPVT_SecProps*» » » » pSecProps; | |
119 CPVT_WordProps*» » » » pWordProps; | |
120 }; | 103 }; |
121 struct CPVT_LineInfo { | 104 struct CPVT_LineInfo { |
122 CPVT_LineInfo() : nTotalWord(0), nBeginWordIndex(-1), nEndWordIndex(-1), | 105 CPVT_LineInfo() |
123 fLineX(0.0f), fLineY(0.0f), fLineWidth(0.0f), fLineAscent(0.0f), fLineDe
scent(0.0f) | 106 : nTotalWord(0), |
124 { | 107 nBeginWordIndex(-1), |
125 } | 108 nEndWordIndex(-1), |
126 int32_t» » » » » nTotalWord; | 109 fLineX(0.0f), |
127 int32_t» » » » » nBeginWordIndex; | 110 fLineY(0.0f), |
128 int32_t» » » » » nEndWordIndex; | 111 fLineWidth(0.0f), |
129 FX_FLOAT» » » » » fLineX; | 112 fLineAscent(0.0f), |
130 FX_FLOAT» » » » » fLineY; | 113 fLineDescent(0.0f) {} |
131 FX_FLOAT» » » » » fLineWidth; | 114 int32_t nTotalWord; |
132 FX_FLOAT» » » » » fLineAscent; | 115 int32_t nBeginWordIndex; |
133 FX_FLOAT» » » » » fLineDescent; | 116 int32_t nEndWordIndex; |
134 }; | 117 FX_FLOAT fLineX; |
135 struct CPVT_WordInfo { | 118 FX_FLOAT fLineY; |
136 CPVT_WordInfo() : Word(0), nCharset(0), | 119 FX_FLOAT fLineWidth; |
137 fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), nFontIndex(-1), pWordProps(
NULL) | 120 FX_FLOAT fLineAscent; |
138 { | 121 FX_FLOAT fLineDescent; |
139 } | 122 }; |
140 CPVT_WordInfo(FX_WORD word, int32_t charset, int32_t fontIndex, CPVT_WordPro
ps * pProps): | 123 struct CPVT_WordInfo { |
141 Word(word), nCharset(charset), fWordX(0.0f), fWordY(0.0f), fWordTail(0.0
f), | 124 CPVT_WordInfo() |
142 nFontIndex(fontIndex), pWordProps(pProps) | 125 : Word(0), |
143 { | 126 nCharset(0), |
144 } | 127 fWordX(0.0f), |
145 virtual ~CPVT_WordInfo() | 128 fWordY(0.0f), |
146 { | 129 fWordTail(0.0f), |
147 delete pWordProps; | 130 nFontIndex(-1), |
148 } | 131 pWordProps(NULL) {} |
149 CPVT_WordInfo(const CPVT_WordInfo & word): Word(0), nCharset(0), | 132 CPVT_WordInfo(FX_WORD word, |
150 fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), nFontIndex(-1), pWordProps(
NULL) | 133 int32_t charset, |
151 { | 134 int32_t fontIndex, |
152 operator = (word); | 135 CPVT_WordProps* pProps) |
153 } | 136 : Word(word), |
154 void operator = (const CPVT_WordInfo & word) | 137 nCharset(charset), |
155 { | 138 fWordX(0.0f), |
156 if (this == &word) { | 139 fWordY(0.0f), |
157 return; | 140 fWordTail(0.0f), |
158 } | 141 nFontIndex(fontIndex), |
159 Word = word.Word; | 142 pWordProps(pProps) {} |
160 nCharset = word.nCharset; | 143 virtual ~CPVT_WordInfo() { delete pWordProps; } |
161 nFontIndex = word.nFontIndex; | 144 CPVT_WordInfo(const CPVT_WordInfo& word) |
162 if (word.pWordProps) { | 145 : Word(0), |
163 if (pWordProps) { | 146 nCharset(0), |
164 *pWordProps = *word.pWordProps; | 147 fWordX(0.0f), |
165 } else { | 148 fWordY(0.0f), |
166 pWordProps = new CPVT_WordProps(*word.pWordProps); | 149 fWordTail(0.0f), |
167 } | 150 nFontIndex(-1), |
168 } | 151 pWordProps(NULL) { |
169 } | 152 operator=(word); |
170 FX_WORD» » » » » » Word; | 153 } |
171 int32_t» » » » » nCharset; | 154 void operator=(const CPVT_WordInfo& word) { |
172 FX_FLOAT» » » » » fWordX; | 155 if (this == &word) { |
173 FX_FLOAT» » » » » fWordY; | 156 return; |
174 FX_FLOAT» » » » » fWordTail; | 157 } |
175 int32_t» » » » » nFontIndex; | 158 Word = word.Word; |
176 CPVT_WordProps*» » » » pWordProps; | 159 nCharset = word.nCharset; |
| 160 nFontIndex = word.nFontIndex; |
| 161 if (word.pWordProps) { |
| 162 if (pWordProps) { |
| 163 *pWordProps = *word.pWordProps; |
| 164 } else { |
| 165 pWordProps = new CPVT_WordProps(*word.pWordProps); |
| 166 } |
| 167 } |
| 168 } |
| 169 FX_WORD Word; |
| 170 int32_t nCharset; |
| 171 FX_FLOAT fWordX; |
| 172 FX_FLOAT fWordY; |
| 173 FX_FLOAT fWordTail; |
| 174 int32_t nFontIndex; |
| 175 CPVT_WordProps* pWordProps; |
177 }; | 176 }; |
178 struct CPVT_FloatRange { | 177 struct CPVT_FloatRange { |
179 CPVT_FloatRange() : fMin(0.0f), fMax(0.0f) | 178 CPVT_FloatRange() : fMin(0.0f), fMax(0.0f) {} |
180 { | 179 CPVT_FloatRange(FX_FLOAT min, FX_FLOAT max) : fMin(min), fMax(max) {} |
181 } | 180 FX_FLOAT Range() const { return fMax - fMin; } |
182 CPVT_FloatRange(FX_FLOAT min, FX_FLOAT max) : fMin(min), fMax(max) | 181 FX_FLOAT fMin, fMax; |
183 { | 182 }; |
184 } | 183 template <class TYPE> |
185 FX_FLOAT Range() const | 184 class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> { |
186 { | 185 public: |
187 return fMax - fMin; | 186 FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; } |
188 } | 187 TYPE GetAt(int nIndex) const { |
189 FX_FLOAT fMin, fMax; | 188 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { |
190 }; | 189 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); |
191 template<class TYPE> class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> | 190 } |
192 { | 191 return NULL; |
193 public: | 192 } |
194 FX_BOOL IsEmpty() | 193 void RemoveAt(int nIndex) { |
195 { | 194 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { |
196 return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; | 195 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); |
197 } | 196 } |
198 TYPE GetAt(int nIndex) const | 197 } |
199 { | 198 }; |
200 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { | 199 class CLine { |
201 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); | 200 public: |
202 } | 201 CLine(); |
203 return NULL; | 202 virtual ~CLine(); |
204 } | 203 CPVT_WordPlace GetBeginWordPlace() const; |
205 void RemoveAt(int nIndex) | 204 CPVT_WordPlace GetEndWordPlace() const; |
206 { | 205 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; |
207 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { | 206 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; |
208 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); | 207 CPVT_WordPlace LinePlace; |
209 } | 208 CPVT_LineInfo m_LineInfo; |
210 } | 209 }; |
211 }; | 210 class CLines { |
212 class CLine | 211 public: |
213 { | 212 CLines() : m_nTotal(0) {} |
214 public: | 213 virtual ~CLines() { RemoveAll(); } |
215 CLine(); | 214 int32_t GetSize() const { return m_Lines.GetSize(); } |
216 virtual ~CLine(); | 215 CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); } |
217 CPVT_WordPlace GetBegin
WordPlace() const; | 216 void Empty() { m_nTotal = 0; } |
218 CPVT_WordPlace GetEndWo
rdPlace() const; | 217 void RemoveAll() { |
219 CPVT_WordPlace GetPrevW
ordPlace(const CPVT_WordPlace & place) const; | 218 for (int32_t i = 0, sz = GetSize(); i < sz; i++) { |
220 CPVT_WordPlace GetNextW
ordPlace(const CPVT_WordPlace & place) const; | 219 delete GetAt(i); |
221 CPVT_WordPlace LinePlac
e; | 220 } |
222 CPVT_LineInfo m_LineIn
fo; | 221 m_Lines.RemoveAll(); |
223 }; | 222 m_nTotal = 0; |
224 class CLines | 223 } |
225 { | 224 int32_t Add(const CPVT_LineInfo& lineinfo) { |
226 public: | 225 if (m_nTotal >= GetSize()) { |
227 CLines() : m_nTotal(0) {} | 226 CLine* pLine = new CLine; |
228 virtual ~CLines() | 227 pLine->m_LineInfo = lineinfo; |
229 { | 228 m_Lines.Add(pLine); |
230 RemoveAll(); | 229 } else if (CLine* pLine = GetAt(m_nTotal)) { |
231 } | 230 pLine->m_LineInfo = lineinfo; |
232 int32_t GetSize(
) const | 231 } |
233 { | 232 return m_nTotal++; |
234 return m_Lines.GetSize(); | 233 } |
235 } | 234 void Clear() { |
236 CLine *
GetAt(int32_t nIndex) const | 235 for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) { |
237 { | 236 delete GetAt(i); |
238 return m_Lines.GetAt(nIndex); | 237 m_Lines.RemoveAt(i); |
239 } | 238 } |
240 void
Empty() | 239 } |
241 { | 240 |
242 m_nTotal = 0; | 241 private: |
243 } | 242 CPVT_ArrayTemplate<CLine*> m_Lines; |
244 void
RemoveAll() | 243 int32_t m_nTotal; |
245 { | 244 }; |
246 for (int32_t i = 0, sz = GetSize(); i < sz; i++) { | 245 class CSection { |
247 delete GetAt(i); | 246 friend class CTypeset; |
248 } | 247 |
249 m_Lines.RemoveAll(); | 248 public: |
250 m_nTotal = 0; | 249 CSection(CPDF_VariableText* pVT); |
251 } | 250 virtual ~CSection(); |
252 int32_t Add(cons
t CPVT_LineInfo & lineinfo) | 251 void ResetAll(); |
253 { | 252 void ResetLineArray(); |
254 if (m_nTotal >= GetSize()) { | 253 void ResetWordArray(); |
255 CLine* pLine = new CLine; | 254 void ResetLinePlace(); |
256 pLine->m_LineInfo = lineinfo; | 255 CPVT_WordPlace AddWord(const CPVT_WordPlace& place, |
257 m_Lines.Add(pLine); | 256 const CPVT_WordInfo& wordinfo); |
258 } else if (CLine* pLine = GetAt(m_nTotal)) { | 257 CPVT_WordPlace AddLine(const CPVT_LineInfo& lineinfo); |
259 pLine->m_LineInfo = lineinfo; | 258 void ClearWords(const CPVT_WordRange& PlaceRange); |
260 } | 259 void ClearWord(const CPVT_WordPlace& place); |
261 return m_nTotal++; | 260 CPVT_FloatRect Rearrange(); |
262 } | 261 CPVT_Size GetSectionSize(FX_FLOAT fFontSize); |
263 void
Clear() | 262 CPVT_WordPlace GetBeginWordPlace() const; |
264 { | 263 CPVT_WordPlace GetEndWordPlace() const; |
265 for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) { | 264 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; |
266 delete GetAt(i); | 265 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; |
267 m_Lines.RemoveAt(i); | 266 void UpdateWordPlace(CPVT_WordPlace& place) const; |
268 } | 267 CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const; |
269 } | 268 CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, |
270 private: | 269 const CPVT_WordPlace& lineplace) const; |
271 CPVT_ArrayTemplate<CLine*> m_Lines; | 270 CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, |
272 int32_t m_nTotal
; | 271 const CPVT_WordRange& range) const; |
273 }; | 272 |
274 class CSection | 273 public: |
275 { | 274 CPVT_WordPlace SecPlace; |
276 friend class CTypeset; | 275 CPVT_SectionInfo m_SecInfo; |
277 public: | 276 CLines m_LineArray; |
278 CSection(CPDF_VariableText * pVT); | 277 CPVT_ArrayTemplate<CPVT_WordInfo*> m_WordArray; |
279 virtual ~CSection(); | 278 |
280 void
ResetAll(); | 279 private: |
281 void
ResetLineArray(); | 280 void ClearLeftWords(int32_t nWordIndex); |
282 void
ResetWordArray(); | 281 void ClearRightWords(int32_t nWordIndex); |
283 void
ResetLinePlace(); | 282 void ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex); |
284 CPVT_WordPlace AddWord(
const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo); | 283 |
285 CPVT_WordPlace AddLine(
const CPVT_LineInfo & lineinfo); | 284 CPDF_VariableText* m_pVT; |
286 void
ClearWords(const CPVT_WordRange & PlaceRange); | 285 }; |
287 void
ClearWord(const CPVT_WordPlace & place); | 286 class CTypeset { |
288 CPVT_FloatRect Rearrang
e(); | 287 public: |
289 CPVT_Size GetSecti
onSize(FX_FLOAT fFontSize); | 288 CTypeset(CSection* pSection); |
290 CPVT_WordPlace GetBegin
WordPlace() const; | 289 virtual ~CTypeset(); |
291 CPVT_WordPlace GetEndWo
rdPlace() const; | 290 CPVT_Size GetEditSize(FX_FLOAT fFontSize); |
292 CPVT_WordPlace GetPrevW
ordPlace(const CPVT_WordPlace & place) const; | 291 CPVT_FloatRect Typeset(); |
293 CPVT_WordPlace GetNextW
ordPlace(const CPVT_WordPlace & place) const; | 292 CPVT_FloatRect CharArray(); |
294 void
UpdateWordPlace(CPVT_WordPlace & place) const; | 293 |
295 CPVT_WordPlace SearchWo
rdPlace(const CPDF_Point & point) const; | 294 private: |
296 CPVT_WordPlace SearchWo
rdPlace(FX_FLOAT fx, const CPVT_WordPlace & lineplace) const; | 295 void SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize); |
297 CPVT_WordPlace SearchWo
rdPlace(FX_FLOAT fx, const CPVT_WordRange & range) const; | 296 void OutputLines(); |
298 public: | 297 |
299 CPVT_WordPlace SecPlace
; | 298 CPVT_FloatRect m_rcRet; |
300 CPVT_SectionInfo m_SecInfo; | 299 CPDF_VariableText* m_pVT; |
301 CLines
m_LineArray; | 300 CSection* m_pSection; |
302 CPVT_ArrayTemplate<CPVT_WordInfo*> m_WordArray; | 301 }; |
303 private: | 302 class CPDF_EditContainer { |
304 void
ClearLeftWords(int32_t nWordIndex); | 303 public: |
305 void
ClearRightWords(int32_t nWordIndex); | 304 CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0){}; |
306 void
ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex); | 305 virtual ~CPDF_EditContainer(){}; |
307 | 306 virtual void SetPlateRect(const CPDF_Rect& rect) { m_rcPlate = rect; }; |
308 CPDF_VariableText *m_pVT; | 307 virtual const CPDF_Rect& GetPlateRect() const { return m_rcPlate; }; |
309 }; | 308 virtual void SetContentRect(const CPVT_FloatRect& rect) { |
310 class CTypeset | 309 m_rcContent = rect; |
311 { | 310 }; |
312 public: | 311 virtual CPDF_Rect GetContentRect() const { return m_rcContent; }; |
313 CTypeset(CSection * pSection); | 312 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; }; |
314 virtual ~CTypeset(); | 313 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; }; |
315 CPVT_Size GetEditS
ize(FX_FLOAT fFontSize); | 314 CPVT_Size GetPlateSize() const { |
316 CPVT_FloatRect Typeset(
); | 315 return CPVT_Size(GetPlateWidth(), GetPlateHeight()); |
317 CPVT_FloatRect CharArra
y(); | 316 }; |
318 private: | 317 CPDF_Point GetBTPoint() const { |
319 void
SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize); | 318 return CPDF_Point(m_rcPlate.left, m_rcPlate.top); |
320 void
OutputLines(); | 319 }; |
321 | 320 CPDF_Point GetETPoint() const { |
322 CPVT_FloatRect m_rcRet; | 321 return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom); |
323 CPDF_VariableText * m_pVT; | 322 }; |
324 CSection * m_pSec
tion; | 323 inline CPDF_Point InToOut(const CPDF_Point& point) const { |
325 }; | 324 return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y); |
326 class CPDF_EditContainer | 325 }; |
327 { | 326 inline CPDF_Point OutToIn(const CPDF_Point& point) const { |
328 public: | 327 return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y); |
329 CPDF_EditContainer(): m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {}; | 328 }; |
330 virtual ~CPDF_EditContainer() {}; | 329 inline CPDF_Rect InToOut(const CPVT_FloatRect& rect) const { |
331 virtual void SetPlate
Rect(const CPDF_Rect & rect) | 330 CPDF_Point ptLeftTop = InToOut(CPDF_Point(rect.left, rect.top)); |
332 { | 331 CPDF_Point ptRightBottom = InToOut(CPDF_Point(rect.right, rect.bottom)); |
333 m_rcPlate = rect; | 332 return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, |
334 }; | 333 ptLeftTop.y); |
335 virtual const CPDF_Rect & GetPlateRect() const | 334 }; |
336 { | 335 inline CPVT_FloatRect OutToIn(const CPDF_Rect& rect) const { |
337 return m_rcPlate; | 336 CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top)); |
338 }; | 337 CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom)); |
339 virtual void SetConte
ntRect(const CPVT_FloatRect & rect) | 338 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, |
340 { | 339 ptRightBottom.y); |
341 m_rcContent = rect; | 340 }; |
342 }; | 341 |
343 virtual CPDF_Rect GetContentRect()
const | 342 private: |
344 { | 343 CPDF_Rect m_rcPlate; |
345 return m_rcContent; | 344 CPVT_FloatRect m_rcContent; |
346 }; | 345 }; |
347 FX_FLOAT GetPlate
Width() const | 346 class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { |
348 { | 347 friend class CTypeset; |
349 return m_rcPlate.right - m_rcPlate.left; | 348 friend class CSection; |
350 }; | 349 friend class CPDF_VariableText_Iterator; |
351 FX_FLOAT GetPlate
Height() const | 350 |
352 { | 351 public: |
353 return m_rcPlate.top - m_rcPlate.bottom; | 352 CPDF_VariableText(); |
354 }; | 353 virtual ~CPDF_VariableText(); |
355 CPVT_Size GetPlate
Size() const | 354 IPDF_VariableText_Provider* SetProvider( |
356 { | 355 IPDF_VariableText_Provider* pProvider); |
357 return CPVT_Size(GetPlateWidth(), GetPlateHeight()); | 356 IPDF_VariableText_Iterator* GetIterator(); |
358 }; | 357 void SetPlateRect(const CPDF_Rect& rect) { |
359 CPDF_Point GetBTPoi
nt() const | 358 CPDF_EditContainer::SetPlateRect(rect); |
360 { | 359 } |
361 return CPDF_Point(m_rcPlate.left, m_rcPlate.top); | 360 void SetAlignment(int32_t nFormat = 0) { m_nAlignment = nFormat; } |
362 }; | 361 void SetPasswordChar(FX_WORD wSubWord = '*') { m_wSubWord = wSubWord; } |
363 CPDF_Point GetETPoi
nt() const | 362 void SetLimitChar(int32_t nLimitChar = 0) { m_nLimitChar = nLimitChar; } |
364 { | 363 void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) { m_fCharSpace = fCharSpace; } |
365 return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom); | 364 void SetHorzScale(int32_t nHorzScale = 100) { m_nHorzScale = nHorzScale; } |
366 }; | 365 void SetMultiLine(FX_BOOL bMultiLine = TRUE) { m_bMultiLine = bMultiLine; } |
367 inline CPDF_Point InToOut(const CP
DF_Point & point) const | 366 void SetAutoReturn(FX_BOOL bAuto = TRUE) { m_bLimitWidth = bAuto; } |
368 { | 367 void SetFontSize(FX_FLOAT fFontSize) { m_fFontSize = fFontSize; } |
369 return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y); | 368 void SetCharArray(int32_t nCharArray = 0) { m_nCharArray = nCharArray; } |
370 }; | 369 void SetAutoFontSize(FX_BOOL bAuto = TRUE) { m_bAutoFontSize = bAuto; } |
371 inline CPDF_Point OutToIn(const CP
DF_Point & point) const | 370 void SetRichText(FX_BOOL bRichText) { m_bRichText = bRichText; } |
372 { | 371 void SetLineLeading(FX_FLOAT fLineLeading) { m_fLineLeading = fLineLeading; } |
373 return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y); | 372 void Initialize(); |
374 }; | 373 FX_BOOL IsValid() const { return m_bInitial; } |
375 inline CPDF_Rect InToOut(const CP
VT_FloatRect & rect) const | 374 FX_BOOL IsRichText() const { return m_bRichText; } |
376 { | 375 void RearrangeAll(); |
377 CPDF_Point ptLeftTop = InToOut(CPDF_Point(rect.left, rect.top)); | 376 void RearrangePart(const CPVT_WordRange& PlaceRange); |
378 CPDF_Point ptRightBottom = InToOut(CPDF_Point(rect.right, rect.bottom)); | 377 void ResetAll(); |
379 return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, ptLeftTo
p.y); | 378 void SetText(const FX_WCHAR* text, |
380 }; | 379 int32_t charset = 1, |
381 inline CPVT_FloatRect OutToIn(const CP
DF_Rect & rect) const | 380 const CPVT_SecProps* pSecProps = NULL, |
382 { | 381 const CPVT_WordProps* pWordProps = NULL); |
383 CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top)); | 382 CPVT_WordPlace InsertWord(const CPVT_WordPlace& place, |
384 CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom)); | 383 FX_WORD word, |
385 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, ptRight
Bottom.y); | 384 int32_t charset = 1, |
386 }; | 385 const CPVT_WordProps* pWordProps = NULL); |
387 | 386 CPVT_WordPlace InsertSection(const CPVT_WordPlace& place, |
388 private: | 387 const CPVT_SecProps* pSecProps = NULL, |
389 CPDF_Rect m_rcPlat
e; | 388 const CPVT_WordProps* pWordProps = NULL); |
390 CPVT_FloatRect m_rcCont
ent; | 389 CPVT_WordPlace InsertText(const CPVT_WordPlace& place, |
391 }; | 390 const FX_WCHAR* text, |
392 class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer | 391 int32_t charset = 1, |
393 { | 392 const CPVT_SecProps* pSecProps = NULL, |
394 friend class CTypeset; | 393 const CPVT_WordProps* pWordProps = NULL); |
395 friend class CSection; | 394 CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange); |
396 friend class CPDF_VariableText_Iterator; | 395 CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place); |
397 public: | 396 CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place); |
398 CPDF_VariableText(); | 397 const CPDF_Rect& GetPlateRect() const { |
399 virtual ~CPDF_VariableText(); | 398 return CPDF_EditContainer::GetPlateRect(); |
400 IPDF_VariableText_Provider* SetProvider(IPDF_Variabl
eText_Provider * pProvider); | 399 } |
401 IPDF_VariableText_Iterator* GetIterator(); | 400 CPDF_Rect GetContentRect() const; |
402 void
SetPlateRect(const CPDF_Rect & rect) | 401 int32_t GetTotalWords() const; |
403 { | 402 FX_FLOAT GetFontSize() const { return m_fFontSize; } |
404 CPDF_EditContainer::SetPlateRect(rect); | 403 int32_t GetAlignment() const { return m_nAlignment; } |
405 } | 404 int32_t GetCharArray() const { return m_nCharArray; } |
406 void
SetAlignment(int32_t nFormat = 0) | 405 int32_t GetLimitChar() const { return m_nLimitChar; } |
407 { | 406 FX_BOOL IsMultiLine() const { return m_bMultiLine; } |
408 m_nAlignment = nFormat; | 407 int32_t GetHorzScale() const { return m_nHorzScale; } |
409 } | 408 FX_FLOAT GetCharSpace() const { return m_fCharSpace; } |
410 void
SetPasswordChar(FX_WORD wSubWord = '*') | 409 |
411 { | 410 CPVT_WordPlace GetBeginWordPlace() const; |
412 m_wSubWord = wSubWord; | 411 CPVT_WordPlace GetEndWordPlace() const; |
413 } | 412 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; |
414 void
SetLimitChar(int32_t nLimitChar = 0) | 413 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; |
415 { | 414 CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const; |
416 m_nLimitChar = nLimitChar; | 415 CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, |
417 } | 416 const CPDF_Point& point) const; |
418 void
SetCharSpace(FX_FLOAT fCharSpace = 0.0f) | 417 CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, |
419 { | 418 const CPDF_Point& point) const; |
420 m_fCharSpace = fCharSpace; | 419 CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const; |
421 } | 420 CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const; |
422 void
SetHorzScale(int32_t nHorzScale = 100) | 421 CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace& place) const; |
423 { | 422 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const; |
424 m_nHorzScale = nHorzScale; | 423 void UpdateWordPlace(CPVT_WordPlace& place) const; |
425 } | 424 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const; |
426 void
SetMultiLine(FX_BOOL bMultiLine = TRUE) | 425 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const; |
427 { | 426 FX_WORD GetPasswordChar() const { return GetSubWord(); } |
428 m_bMultiLine = bMultiLine; | 427 FX_WORD GetSubWord() const { return m_wSubWord; } |
429 } | 428 |
430 void
SetAutoReturn(FX_BOOL bAuto = TRUE) | 429 private: |
431 { | 430 int32_t GetCharWidth(int32_t nFontIndex, |
432 m_bLimitWidth = bAuto; | 431 FX_WORD Word, |
433 } | 432 FX_WORD SubWord, |
434 void
SetFontSize(FX_FLOAT fFontSize) | 433 int32_t nWordStyle); |
435 { | 434 int32_t GetTypeAscent(int32_t nFontIndex); |
436 m_fFontSize = fFontSize; | 435 int32_t GetTypeDescent(int32_t nFontIndex); |
437 } | 436 int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); |
438 void
SetCharArray(int32_t nCharArray = 0) | 437 int32_t GetDefaultFontIndex(); |
439 { | 438 FX_BOOL IsLatinWord(FX_WORD word); |
440 m_nCharArray = nCharArray; | 439 |
441 } | 440 private: |
442 void
SetAutoFontSize(FX_BOOL bAuto = TRUE) | 441 CPVT_WordPlace AddSection(const CPVT_WordPlace& place, |
443 { | 442 const CPVT_SectionInfo& secinfo); |
444 m_bAutoFontSize = bAuto; | 443 CPVT_WordPlace AddLine(const CPVT_WordPlace& place, |
445 } | 444 const CPVT_LineInfo& lineinfo); |
446 void
SetRichText(FX_BOOL bRichText) | 445 CPVT_WordPlace AddWord(const CPVT_WordPlace& place, |
447 { | 446 const CPVT_WordInfo& wordinfo); |
448 m_bRichText = bRichText; | 447 FX_BOOL GetWordInfo(const CPVT_WordPlace& place, CPVT_WordInfo& wordinfo); |
449 } | 448 FX_BOOL SetWordInfo(const CPVT_WordPlace& place, |
450 void
SetLineLeading(FX_FLOAT fLineLeading) | 449 const CPVT_WordInfo& wordinfo); |
451 { | 450 FX_BOOL GetLineInfo(const CPVT_WordPlace& place, CPVT_LineInfo& lineinfo); |
452 m_fLineLeading = fLineLeading; | 451 FX_BOOL GetSectionInfo(const CPVT_WordPlace& place, |
453 } | 452 CPVT_SectionInfo& secinfo); |
454 void
Initialize(); | 453 FX_FLOAT GetWordFontSize(const CPVT_WordInfo& WordInfo, |
455 FX_BOOL
IsValid() const | 454 FX_BOOL bFactFontSize = FALSE); |
456 { | 455 FX_FLOAT GetWordWidth(int32_t nFontIndex, |
457 return m_bInitial; | 456 FX_WORD Word, |
458 } | 457 FX_WORD SubWord, |
459 FX_BOOL
IsRichText() const | 458 FX_FLOAT fCharSpace, |
460 { | 459 int32_t nHorzScale, |
461 return m_bRichText; | 460 FX_FLOAT fFontSize, |
462 } | 461 FX_FLOAT fWordTail, |
463 void
RearrangeAll(); | 462 int32_t nWordStyle); |
464 void
RearrangePart(const CPVT_WordRange & PlaceRange); | 463 FX_FLOAT GetWordWidth(const CPVT_WordInfo& WordInfo); |
465 void
ResetAll(); | 464 FX_FLOAT GetWordAscent(const CPVT_WordInfo& WordInfo, FX_FLOAT fFontSize); |
466 void
SetText(const FX_WCHAR* text, int32_t charset = 1, const CPVT_SecProps * pSecPro
ps = NULL, | 465 FX_FLOAT GetWordDescent(const CPVT_WordInfo& WordInfo, FX_FLOAT fFontSize); |
467 const CPVT_WordProps * pWordProps = NULL); | 466 FX_FLOAT GetWordAscent(const CPVT_WordInfo& WordInfo, |
468 CPVT_WordPlace InsertWo
rd(const CPVT_WordPlace & place, FX_WORD word, int32_t charset = 1, | 467 FX_BOOL bFactFontSize = FALSE); |
469 const CPVT_WordProps * pWordProps = NULL); | 468 FX_FLOAT GetWordDescent(const CPVT_WordInfo& WordInfo, |
470 CPVT_WordPlace InsertSe
ction(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps = NULL, | 469 FX_BOOL bFactFontSize = FALSE); |
471 const CPVT_WordProps * pWordProps = NULL); | 470 FX_FLOAT GetLineAscent(const CPVT_SectionInfo& SecInfo); |
472 CPVT_WordPlace InsertTe
xt(const CPVT_WordPlace & place, const FX_WCHAR* text, int32_t charset = 1, | 471 FX_FLOAT GetLineDescent(const CPVT_SectionInfo& SecInfo); |
473 const CPVT_SecProps * pSecProps = NULL, const CPVT_WordProps * p
WordProps = NULL); | 472 FX_FLOAT GetFontAscent(int32_t nFontIndex, FX_FLOAT fFontSize); |
474 CPVT_WordPlace DeleteWo
rds(const CPVT_WordRange & PlaceRange); | 473 FX_FLOAT GetFontDescent(int32_t nFontIndex, FX_FLOAT fFontSize); |
475 CPVT_WordPlace DeleteWo
rd(const CPVT_WordPlace & place); | 474 int32_t GetWordFontIndex(const CPVT_WordInfo& WordInfo); |
476 CPVT_WordPlace BackSpac
eWord(const CPVT_WordPlace & place); | 475 FX_FLOAT GetCharSpace(const CPVT_WordInfo& WordInfo); |
477 const CPDF_Rect & GetPlateRect() c
onst | 476 int32_t GetHorzScale(const CPVT_WordInfo& WordInfo); |
478 { | 477 FX_FLOAT GetLineLeading(const CPVT_SectionInfo& SecInfo); |
479 return CPDF_EditContainer::GetPlateRect(); | 478 FX_FLOAT GetLineIndent(const CPVT_SectionInfo& SecInfo); |
480 } | 479 int32_t GetAlignment(const CPVT_SectionInfo& SecInfo); |
481 CPDF_Rect GetConte
ntRect() const; | 480 |
482 int32_t GetTotal
Words() const; | 481 void ClearSectionRightWords(const CPVT_WordPlace& place); |
483 FX_FLOAT GetFontS
ize() const | 482 CPVT_WordPlace AjustLineHeader(const CPVT_WordPlace& place, |
484 { | 483 FX_BOOL bPrevOrNext) const; |
485 return m_fFontSize; | 484 FX_BOOL ClearEmptySection(const CPVT_WordPlace& place); |
486 } | 485 void ClearEmptySections(const CPVT_WordRange& PlaceRange); |
487 int32_t GetAlign
ment() const | 486 void LinkLatterSection(const CPVT_WordPlace& place); |
488 { | 487 void ClearWords(const CPVT_WordRange& PlaceRange); |
489 return m_nAlignment; | 488 CPVT_WordPlace ClearLeftWord(const CPVT_WordPlace& place); |
490 } | 489 CPVT_WordPlace ClearRightWord(const CPVT_WordPlace& place); |
491 int32_t GetCharA
rray() const | 490 |
492 { | 491 private: |
493 return m_nCharArray; | 492 CPVT_FloatRect Rearrange(const CPVT_WordRange& PlaceRange); |
494 } | 493 FX_FLOAT GetAutoFontSize(); |
495 int32_t GetLimit
Char() const | 494 FX_BOOL IsBigger(FX_FLOAT fFontSize); |
496 { | 495 CPVT_FloatRect RearrangeSections(const CPVT_WordRange& PlaceRange); |
497 return m_nLimitChar; | 496 |
498 } | 497 private: |
499 FX_BOOL
IsMultiLine() const | 498 void ResetSectionArray(); |
500 { | 499 |
501 return m_bMultiLine; | 500 private: |
502 } | 501 CPVT_ArrayTemplate<CSection*> m_SectionArray; |
503 int32_t GetHorzS
cale() const | 502 int32_t m_nLimitChar; |
504 { | 503 int32_t m_nCharArray; |
505 return m_nHorzScale; | 504 FX_BOOL m_bMultiLine; |
506 } | 505 FX_BOOL m_bLimitWidth; |
507 FX_FLOAT GetCharS
pace() const | 506 FX_BOOL m_bAutoFontSize; |
508 { | 507 int32_t m_nAlignment; |
509 return m_fCharSpace; | 508 FX_FLOAT m_fLineLeading; |
510 } | 509 FX_FLOAT m_fCharSpace; |
511 | 510 int32_t m_nHorzScale; |
512 CPVT_WordPlace GetBegin
WordPlace() const; | 511 FX_WORD m_wSubWord; |
513 CPVT_WordPlace GetEndWo
rdPlace() const; | 512 FX_FLOAT m_fFontSize; |
514 CPVT_WordPlace GetPrevW
ordPlace(const CPVT_WordPlace & place) const; | 513 |
515 CPVT_WordPlace GetNextW
ordPlace(const CPVT_WordPlace & place) const; | 514 private: |
516 CPVT_WordPlace SearchWo
rdPlace(const CPDF_Point & point) const; | 515 FX_BOOL m_bInitial; |
517 CPVT_WordPlace GetUpWor
dPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const; | 516 FX_BOOL m_bRichText; |
518 CPVT_WordPlace GetDownW
ordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const; | 517 IPDF_VariableText_Provider* m_pVTProvider; |
519 CPVT_WordPlace GetLineB
eginPlace(const CPVT_WordPlace & place) const; | 518 CPDF_VariableText_Iterator* m_pVTIterator; |
520 CPVT_WordPlace GetLineE
ndPlace(const CPVT_WordPlace & place) const; | 519 }; |
521 CPVT_WordPlace GetSecti
onBeginPlace(const CPVT_WordPlace & place) const; | 520 class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator { |
522 CPVT_WordPlace GetSecti
onEndPlace(const CPVT_WordPlace & place) const; | 521 public: |
523 void
UpdateWordPlace(CPVT_WordPlace & place) const; | 522 CPDF_VariableText_Iterator(CPDF_VariableText* pVT); |
524 int32_t WordPlac
eToWordIndex(const CPVT_WordPlace & place) const; | 523 virtual ~CPDF_VariableText_Iterator(); |
525 CPVT_WordPlace WordInde
xToWordPlace(int32_t index) const; | 524 FX_BOOL NextWord(); |
526 FX_WORD
GetPasswordChar() const | 525 FX_BOOL PrevWord(); |
527 { | 526 FX_BOOL NextLine(); |
528 return GetSubWord(); | 527 FX_BOOL PrevLine(); |
529 } | 528 FX_BOOL NextSection(); |
530 FX_WORD
GetSubWord() const | 529 FX_BOOL PrevSection(); |
531 { | 530 FX_BOOL SetWord(const CPVT_Word& word); |
532 return m_wSubWord; | 531 FX_BOOL GetWord(CPVT_Word& word) const; |
533 } | 532 FX_BOOL GetLine(CPVT_Line& line) const; |
534 private: | 533 FX_BOOL GetSection(CPVT_Section& section) const; |
535 int32_t GetCharW
idth(int32_t nFontIndex, FX_WORD Word, FX_WORD SubWord, int32_t nWordStyle); | 534 FX_BOOL SetSection(const CPVT_Section& section); |
536 int32_t GetTypeA
scent(int32_t nFontIndex); | 535 void SetAt(int32_t nWordIndex); |
537 int32_t GetTypeD
escent(int32_t nFontIndex); | 536 void SetAt(const CPVT_WordPlace& place); |
538 int32_t GetWordF
ontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); | 537 const CPVT_WordPlace& GetAt() const { return m_CurPos; }; |
539 int32_t GetDefau
ltFontIndex(); | 538 |
540 FX_BOOL
IsLatinWord(FX_WORD word); | 539 private: |
541 private: | 540 CPVT_WordPlace m_CurPos; |
542 | 541 CPDF_VariableText* m_pVT; |
543 CPVT_WordPlace AddSecti
on(const CPVT_WordPlace & place, const CPVT_SectionInfo & secinfo); | |
544 CPVT_WordPlace AddLine(
const CPVT_WordPlace & place, const CPVT_LineInfo & lineinfo); | |
545 CPVT_WordPlace AddWord(
const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo); | |
546 FX_BOOL
GetWordInfo(const CPVT_WordPlace & place, CPVT_WordInfo & wordinfo); | |
547 FX_BOOL
SetWordInfo(const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo); | |
548 FX_BOOL
GetLineInfo(const CPVT_WordPlace & place, CPVT_LineInfo & lineinfo); | |
549 FX_BOOL
GetSectionInfo(const CPVT_WordPlace & place, CPVT_SectionInfo & secinfo); | |
550 FX_FLOAT GetWordF
ontSize(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE); | |
551 FX_FLOAT GetWordW
idth(int32_t nFontIndex, FX_WORD Word, FX_WORD SubWord, | |
552 FX_FLOAT fCharSpace, int32_t nHorzScale, | |
553 FX_FLOAT fFontSize, FX_FLOAT fWordTail, int32_t nWordStyle); | |
554 FX_FLOAT GetWordW
idth(const CPVT_WordInfo & WordInfo); | |
555 FX_FLOAT GetWordA
scent(const CPVT_WordInfo & WordInfo, FX_FLOAT fFontSize); | |
556 FX_FLOAT GetWordD
escent(const CPVT_WordInfo & WordInfo, FX_FLOAT fFontSize); | |
557 FX_FLOAT GetWordA
scent(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE); | |
558 FX_FLOAT GetWordD
escent(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE); | |
559 FX_FLOAT GetLineA
scent(const CPVT_SectionInfo & SecInfo); | |
560 FX_FLOAT GetLineD
escent(const CPVT_SectionInfo & SecInfo); | |
561 FX_FLOAT GetFontA
scent(int32_t nFontIndex, FX_FLOAT fFontSize); | |
562 FX_FLOAT GetFontD
escent(int32_t nFontIndex, FX_FLOAT fFontSize); | |
563 int32_t GetWordF
ontIndex(const CPVT_WordInfo & WordInfo); | |
564 FX_FLOAT GetCharS
pace(const CPVT_WordInfo & WordInfo); | |
565 int32_t GetHorzS
cale(const CPVT_WordInfo & WordInfo); | |
566 FX_FLOAT GetLineL
eading(const CPVT_SectionInfo & SecInfo); | |
567 FX_FLOAT GetLineI
ndent(const CPVT_SectionInfo & SecInfo); | |
568 int32_t GetAlign
ment(const CPVT_SectionInfo& SecInfo); | |
569 | |
570 void
ClearSectionRightWords(const CPVT_WordPlace & place); | |
571 CPVT_WordPlace AjustLin
eHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const; | |
572 FX_BOOL
ClearEmptySection(const CPVT_WordPlace & place); | |
573 void
ClearEmptySections(const CPVT_WordRange & PlaceRange); | |
574 void
LinkLatterSection(const CPVT_WordPlace & place); | |
575 void
ClearWords(const CPVT_WordRange & PlaceRange); | |
576 CPVT_WordPlace ClearLef
tWord(const CPVT_WordPlace & place); | |
577 CPVT_WordPlace ClearRig
htWord(const CPVT_WordPlace & place); | |
578 private: | |
579 CPVT_FloatRect Rearrang
e(const CPVT_WordRange & PlaceRange); | |
580 FX_FLOAT GetAutoF
ontSize(); | |
581 FX_BOOL
IsBigger(FX_FLOAT fFontSize); | |
582 CPVT_FloatRect Rearrang
eSections(const CPVT_WordRange & PlaceRange); | |
583 private: | |
584 void
ResetSectionArray(); | |
585 private: | |
586 CPVT_ArrayTemplate<CSection*> m_SectionArray; | |
587 int32_t m_nLimit
Char; | |
588 int32_t m_nCharA
rray; | |
589 FX_BOOL
m_bMultiLine; | |
590 FX_BOOL
m_bLimitWidth; | |
591 FX_BOOL
m_bAutoFontSize; | |
592 int32_t m_nAlign
ment; | |
593 FX_FLOAT m_fLineL
eading; | |
594 FX_FLOAT m_fCharS
pace; | |
595 int32_t m_nHorzS
cale; | |
596 FX_WORD
m_wSubWord; | |
597 FX_FLOAT m_fFontS
ize; | |
598 | |
599 private: | |
600 FX_BOOL
m_bInitial; | |
601 FX_BOOL
m_bRichText; | |
602 IPDF_VariableText_Provider * m_pVTProvider; | |
603 CPDF_VariableText_Iterator * m_pVTIterator; | |
604 }; | |
605 class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator | |
606 { | |
607 public: | |
608 CPDF_VariableText_Iterator(CPDF_VariableText * pVT); | |
609 virtual ~CPDF_VariableText_Iterator(); | |
610 FX_BOOL
NextWord(); | |
611 FX_BOOL
PrevWord(); | |
612 FX_BOOL
NextLine(); | |
613 FX_BOOL
PrevLine(); | |
614 FX_BOOL
NextSection(); | |
615 FX_BOOL
PrevSection(); | |
616 FX_BOOL
SetWord(const CPVT_Word & word); | |
617 FX_BOOL
GetWord(CPVT_Word & word) const; | |
618 FX_BOOL
GetLine(CPVT_Line & line) const; | |
619 FX_BOOL
GetSection(CPVT_Section & section) const; | |
620 FX_BOOL
SetSection(const CPVT_Section & section); | |
621 void
SetAt(int32_t nWordIndex); | |
622 void
SetAt(const CPVT_WordPlace & place); | |
623 const CPVT_WordPlace & GetAt() const | |
624 { | |
625 return m_CurPos; | |
626 }; | |
627 private: | |
628 CPVT_WordPlace m_CurPos
; | |
629 CPDF_VariableText * m_pVT; | |
630 }; | 542 }; |
631 | 543 |
632 #endif // CORE_SRC_FPDFDOC_PDF_VT_H_ | 544 #endif // CORE_SRC_FPDFDOC_PDF_VT_H_ |
OLD | NEW |