1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef CORE_SRC_FPDFDOC_PDF_VT_H_ 8 #define CORE_SRC_FPDFDOC_PDF_VT_H_ 9 10 class CPVT_Size; 11 class CPVT_FloatRect; 12 struct CPVT_SectionInfo; 13 struct CPVT_LineInfo; 14 struct CPVT_WordInfo; 15 class CLine; 16 class CLines; 17 class CSection; 18 class CTypeset; 19 class CPDF_EditContainer; 20 class CPDF_VariableText; 21 class CPDF_VariableText_Iterator; 22 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) 23 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) 24 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) 25 26 class CPVT_Size { 27 public: 28 CPVT_Size() : x(0.0f), y(0.0f) {} 29 CPVT_Size(FX_FLOAT other_x, FX_FLOAT other_y) { 30 x = other_x; 31 y = other_y; 32 } 33 FX_FLOAT x, y; 34 }; 35 class CPVT_FloatRect : public CFX_FloatRect { 36 public: 37 CPVT_FloatRect() { left = top = right = bottom = 0.0f; } 38 CPVT_FloatRect(FX_FLOAT other_left, 39 FX_FLOAT other_top, 40 FX_FLOAT other_right, 41 FX_FLOAT other_bottom) { 42 left = other_left; 43 top = other_top; 44 right = other_right; 45 bottom = other_bottom; 46 } 47 explicit CPVT_FloatRect(const CPDF_Rect& rect) { 48 left = rect.left; 49 top = rect.top; 50 right = rect.right; 51 bottom = rect.bottom; 52 } 53 void Default() { left = top = right = bottom = 0.0f; } 54 FX_FLOAT Height() const { 55 if (top > bottom) 56 return top - bottom; 57 return bottom - top; 58 } 59 }; 60 struct CPVT_SectionInfo { 61 CPVT_SectionInfo() 62 : rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps(NULL) {} 63 virtual ~CPVT_SectionInfo() { 64 delete pSecProps; 65 delete pWordProps; 66 } 67 CPVT_SectionInfo(const CPVT_SectionInfo& other) 68 : rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps(NULL) { 69 operator=(other); 70 } 71 void operator=(const CPVT_SectionInfo& other) { 72 if (this == &other) { 73 return; 74 } 75 rcSection = other.rcSection; 76 nTotalLine = other.nTotalLine; 77 if (other.pSecProps) { 78 if (pSecProps) { 79 *pSecProps = *other.pSecProps; 80 } else { 81 pSecProps = new CPVT_SecProps(*other.pSecProps); 82 } 83 } 84 if (other.pWordProps) { 85 if (pWordProps) { 86 *pWordProps = *other.pWordProps; 87 } else { 88 pWordProps = new CPVT_WordProps(*other.pWordProps); 89 } 90 } 91 } 92 CPVT_FloatRect rcSection; 93 int32_t nTotalLine; 94 CPVT_SecProps* pSecProps; 95 CPVT_WordProps* pWordProps; 96 }; 97 struct CPVT_LineInfo { 98 CPVT_LineInfo() 99 : nTotalWord(0), 100 nBeginWordIndex(-1), 101 nEndWordIndex(-1), 102 fLineX(0.0f), 103 fLineY(0.0f), 104 fLineWidth(0.0f), 105 fLineAscent(0.0f), 106 fLineDescent(0.0f) {} 107 int32_t nTotalWord; 108 int32_t nBeginWordIndex; 109 int32_t nEndWordIndex; 110 FX_FLOAT fLineX; 111 FX_FLOAT fLineY; 112 FX_FLOAT fLineWidth; 113 FX_FLOAT fLineAscent; 114 FX_FLOAT fLineDescent; 115 }; 116 struct CPVT_WordInfo { 117 CPVT_WordInfo() 118 : Word(0), 119 nCharset(0), 120 fWordX(0.0f), 121 fWordY(0.0f), 122 fWordTail(0.0f), 123 nFontIndex(-1), 124 pWordProps(NULL) {} 125 CPVT_WordInfo(FX_WORD word, 126 int32_t charset, 127 int32_t fontIndex, 128 CPVT_WordProps* pProps) 129 : Word(word), 130 nCharset(charset), 131 fWordX(0.0f), 132 fWordY(0.0f), 133 fWordTail(0.0f), 134 nFontIndex(fontIndex), 135 pWordProps(pProps) {} 136 virtual ~CPVT_WordInfo() { delete pWordProps; } 137 CPVT_WordInfo(const CPVT_WordInfo& word) 138 : Word(0), 139 nCharset(0), 140 fWordX(0.0f), 141 fWordY(0.0f), 142 fWordTail(0.0f), 143 nFontIndex(-1), 144 pWordProps(NULL) { 145 operator=(word); 146 } 147 void operator=(const CPVT_WordInfo& word) { 148 if (this == &word) { 149 return; 150 } 151 Word = word.Word; 152 nCharset = word.nCharset; 153 nFontIndex = word.nFontIndex; 154 if (word.pWordProps) { 155 if (pWordProps) { 156 *pWordProps = *word.pWordProps; 157 } else { 158 pWordProps = new CPVT_WordProps(*word.pWordProps); 159 } 160 } 161 } 162 FX_WORD Word; 163 int32_t nCharset; 164 FX_FLOAT fWordX; 165 FX_FLOAT fWordY; 166 FX_FLOAT fWordTail; 167 int32_t nFontIndex; 168 CPVT_WordProps* pWordProps; 169 }; 170 struct CPVT_FloatRange { 171 CPVT_FloatRange() : fMin(0.0f), fMax(0.0f) {} 172 CPVT_FloatRange(FX_FLOAT min, FX_FLOAT max) : fMin(min), fMax(max) {} 173 FX_FLOAT Range() const { return fMax - fMin; } 174 FX_FLOAT fMin, fMax; 175 }; 176 template <class TYPE> 177 class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> { 178 public: 179 FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; } 180 TYPE GetAt(int nIndex) const { 181 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { 182 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); 183 } 184 return NULL; 185 } 186 void RemoveAt(int nIndex) { 187 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { 188 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); 189 } 190 } 191 }; 192 class CLine { 193 public: 194 CLine(); 195 virtual ~CLine(); 196 CPVT_WordPlace GetBeginWordPlace() const; 197 CPVT_WordPlace GetEndWordPlace() const; 198 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; 199 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; 200 CPVT_WordPlace LinePlace; 201 CPVT_LineInfo m_LineInfo; 202 }; 203 class CLines { 204 public: 205 CLines() : m_nTotal(0) {} 206 virtual ~CLines() { RemoveAll(); } 207 int32_t GetSize() const { return m_Lines.GetSize(); } 208 CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); } 209 void Empty() { m_nTotal = 0; } 210 void RemoveAll() { 211 for (int32_t i = 0, sz = GetSize(); i < sz; i++) { 212 delete GetAt(i); 213 } 214 m_Lines.RemoveAll(); 215 m_nTotal = 0; 216 } 217 int32_t Add(const CPVT_LineInfo& lineinfo) { 218 if (m_nTotal >= GetSize()) { 219 CLine* pLine = new CLine; 220 pLine->m_LineInfo = lineinfo; 221 m_Lines.Add(pLine); 222 } else if (CLine* pLine = GetAt(m_nTotal)) { 223 pLine->m_LineInfo = lineinfo; 224 } 225 return m_nTotal++; 226 } 227 void Clear() { 228 for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) { 229 delete GetAt(i); 230 m_Lines.RemoveAt(i); 231 } 232 } 233 234 private: 235 CPVT_ArrayTemplate<CLine*> m_Lines; 236 int32_t m_nTotal; 237 }; 238 class CSection { 239 friend class CTypeset; 240 241 public: 242 explicit CSection(CPDF_VariableText* pVT); 243 virtual ~CSection(); 244 void ResetAll(); 245 void ResetLineArray(); 246 void ResetWordArray(); 247 void ResetLinePlace(); 248 CPVT_WordPlace AddWord(const CPVT_WordPlace& place, 249 const CPVT_WordInfo& wordinfo); 250 CPVT_WordPlace AddLine(const CPVT_LineInfo& lineinfo); 251 void ClearWords(const CPVT_WordRange& PlaceRange); 252 void ClearWord(const CPVT_WordPlace& place); 253 CPVT_FloatRect Rearrange(); 254 CPVT_Size GetSectionSize(FX_FLOAT fFontSize); 255 CPVT_WordPlace GetBeginWordPlace() const; 256 CPVT_WordPlace GetEndWordPlace() const; 257 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; 258 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; 259 void UpdateWordPlace(CPVT_WordPlace& place) const; 260 CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const; 261 CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, 262 const CPVT_WordPlace& lineplace) const; 263 CPVT_WordPlace SearchWordPlace(FX_FLOAT fx, 264 const CPVT_WordRange& range) const; 265 266 public: 267 CPVT_WordPlace SecPlace; 268 CPVT_SectionInfo m_SecInfo; 269 CLines m_LineArray; 270 CPVT_ArrayTemplate<CPVT_WordInfo*> m_WordArray; 271 272 private: 273 void ClearLeftWords(int32_t nWordIndex); 274 void ClearRightWords(int32_t nWordIndex); 275 void ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex); 276 277 CPDF_VariableText* m_pVT; 278 }; 279 class CTypeset { 280 public: 281 explicit CTypeset(CSection* pSection); 282 virtual ~CTypeset(); 283 CPVT_Size GetEditSize(FX_FLOAT fFontSize); 284 CPVT_FloatRect Typeset(); 285 CPVT_FloatRect CharArray(); 286 287 private: 288 void SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize); 289 void OutputLines(); 290 291 CPVT_FloatRect m_rcRet; 292 CPDF_VariableText* m_pVT; 293 CSection* m_pSection; 294 }; 295 class CPDF_EditContainer { 296 public: 297 CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {} 298 virtual ~CPDF_EditContainer() {} 299 virtual void SetPlateRect(const CPDF_Rect& rect) { m_rcPlate = rect; } 300 virtual const CPDF_Rect& GetPlateRect() const { return m_rcPlate; } 301 virtual void SetContentRect(const CPVT_FloatRect& rect) { 302 m_rcContent = rect; 303 } 304 virtual CPDF_Rect GetContentRect() const { return m_rcContent; } 305 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } 306 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } 307 CPVT_Size GetPlateSize() const { 308 return CPVT_Size(GetPlateWidth(), GetPlateHeight()); 309 } 310 CPDF_Point GetBTPoint() const { 311 return CPDF_Point(m_rcPlate.left, m_rcPlate.top); 312 } 313 CPDF_Point GetETPoint() const { 314 return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom); 315 } 316 inline CPDF_Point InToOut(const CPDF_Point& point) const { 317 return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y); 318 } 319 inline CPDF_Point OutToIn(const CPDF_Point& point) const { 320 return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y); 321 } 322 inline CPDF_Rect InToOut(const CPVT_FloatRect& rect) const { 323 CPDF_Point ptLeftTop = InToOut(CPDF_Point(rect.left, rect.top)); 324 CPDF_Point ptRightBottom = InToOut(CPDF_Point(rect.right, rect.bottom)); 325 return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, 326 ptLeftTop.y); 327 } 328 inline CPVT_FloatRect OutToIn(const CPDF_Rect& rect) const { 329 CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top)); 330 CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom)); 331 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, 332 ptRightBottom.y); 333 } 334 335 private: 336 CPDF_Rect m_rcPlate; 337 CPVT_FloatRect m_rcContent; 338 }; 339 340 class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { 341 friend class CTypeset; 342 friend class CSection; 343 friend class CPDF_VariableText_Iterator; 344 345 public: 346 CPDF_VariableText(); 347 ~CPDF_VariableText() override; 348 349 // IPDF_VariableText 350 IPDF_VariableText_Provider* SetProvider( 351 IPDF_VariableText_Provider* pProvider) override; 352 IPDF_VariableText_Iterator* GetIterator() override; 353 void SetPlateRect(const CPDF_Rect& rect) override { 354 CPDF_EditContainer::SetPlateRect(rect); 355 } 356 void SetAlignment(int32_t nFormat = 0) override { m_nAlignment = nFormat; } 357 void SetPasswordChar(FX_WORD wSubWord = '*') override { 358 m_wSubWord = wSubWord; 359 } 360 void SetLimitChar(int32_t nLimitChar = 0) override { 361 m_nLimitChar = nLimitChar; 362 } 363 void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) override { 364 m_fCharSpace = fCharSpace; 365 } 366 void SetHorzScale(int32_t nHorzScale = 100) override { 367 m_nHorzScale = nHorzScale; 368 } 369 void SetMultiLine(FX_BOOL bMultiLine = TRUE) override { 370 m_bMultiLine = bMultiLine; 371 } 372 void SetAutoReturn(FX_BOOL bAuto = TRUE) override { m_bLimitWidth = bAuto; } 373 void SetFontSize(FX_FLOAT fFontSize) override { m_fFontSize = fFontSize; } 374 void SetCharArray(int32_t nCharArray = 0) override { 375 m_nCharArray = nCharArray; 376 } 377 void SetAutoFontSize(FX_BOOL bAuto = TRUE) override { 378 m_bAutoFontSize = bAuto; 379 } 380 void SetRichText(FX_BOOL bRichText) override { m_bRichText = bRichText; } 381 void SetLineLeading(FX_FLOAT fLineLeading) override { 382 m_fLineLeading = fLineLeading; 383 } 384 void Initialize() override; 385 FX_BOOL IsValid() const override { return m_bInitial; } 386 FX_BOOL IsRichText() const override { return m_bRichText; } 387 void RearrangeAll() override; 388 void RearrangePart(const CPVT_WordRange& PlaceRange) override; 389 void ResetAll() override; 390 void SetText(const FX_WCHAR* text, 391 int32_t charset = 1, 392 const CPVT_SecProps* pSecProps = NULL, 393 const CPVT_WordProps* pWordProps = NULL) override; 394 CPVT_WordPlace InsertWord(const CPVT_WordPlace& place, 395 FX_WORD word, 396 int32_t charset = 1, 397 const CPVT_WordProps* pWordProps = NULL) override; 398 CPVT_WordPlace InsertSection( 399 const CPVT_WordPlace& place, 400 const CPVT_SecProps* pSecProps = NULL, 401 const CPVT_WordProps* pWordProps = NULL) override; 402 CPVT_WordPlace InsertText(const CPVT_WordPlace& place, 403 const FX_WCHAR* text, 404 int32_t charset = 1, 405 const CPVT_SecProps* pSecProps = NULL, 406 const CPVT_WordProps* pWordProps = NULL) override; 407 CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange) override; 408 CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place) override; 409 CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place) override; 410 const CPDF_Rect& GetPlateRect() const override { 411 return CPDF_EditContainer::GetPlateRect(); 412 } 413 CPDF_Rect GetContentRect() const override; 414 int32_t GetTotalWords() const override; 415 FX_FLOAT GetFontSize() const override { return m_fFontSize; } 416 int32_t GetAlignment() const override { return m_nAlignment; } 417 FX_WORD GetPasswordChar() const override { return GetSubWord(); } 418 int32_t GetCharArray() const override { return m_nCharArray; } 419 int32_t GetLimitChar() const override { return m_nLimitChar; } 420 FX_BOOL IsMultiLine() const override { return m_bMultiLine; } 421 int32_t GetHorzScale() const override { return m_nHorzScale; } 422 FX_FLOAT GetCharSpace() const override { return m_fCharSpace; } 423 CPVT_WordPlace GetBeginWordPlace() const override; 424 CPVT_WordPlace GetEndWordPlace() const override; 425 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const override; 426 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const override; 427 CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const override; 428 CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, 429 const CPDF_Point& point) const override; 430 CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, 431 const CPDF_Point& point) const override; 432 CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override; 433 CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override; 434 CPVT_WordPlace GetSectionBeginPlace( 435 const CPVT_WordPlace& place) const override; 436 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const override; 437 void UpdateWordPlace(CPVT_WordPlace& place) const override; 438 CPVT_WordPlace AdjustLineHeader(const CPVT_WordPlace& place, 439 FX_BOOL bPrevOrNext) const override; 440 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const override; 441 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const override; 442 443 FX_WORD GetSubWord() const { return m_wSubWord; } 444 445 private: 446 int32_t GetCharWidth(int32_t nFontIndex, 447 FX_WORD Word, 448 FX_WORD SubWord, 449 int32_t nWordStyle); 450 int32_t GetTypeAscent(int32_t nFontIndex); 451 int32_t GetTypeDescent(int32_t nFontIndex); 452 int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); 453 int32_t GetDefaultFontIndex(); 454 FX_BOOL IsLatinWord(FX_WORD word); 455 456 CPVT_WordPlace AddSection(const CPVT_WordPlace& place, 457 const CPVT_SectionInfo& secinfo); 458 CPVT_WordPlace AddLine(const CPVT_WordPlace& place, 459 const CPVT_LineInfo& lineinfo); 460 CPVT_WordPlace AddWord(const CPVT_WordPlace& place, 461 const CPVT_WordInfo& wordinfo); 462 FX_BOOL GetWordInfo(const CPVT_WordPlace& place, CPVT_WordInfo& wordinfo); 463 FX_BOOL SetWordInfo(const CPVT_WordPlace& place, 464 const CPVT_WordInfo& wordinfo); 465 FX_BOOL GetLineInfo(const CPVT_WordPlace& place, CPVT_LineInfo& lineinfo); 466 FX_BOOL GetSectionInfo(const CPVT_WordPlace& place, 467 CPVT_SectionInfo& secinfo); 468 FX_FLOAT GetWordFontSize(const CPVT_WordInfo& WordInfo, 469 FX_BOOL bFactFontSize = FALSE); 470 FX_FLOAT GetWordWidth(int32_t nFontIndex, 471 FX_WORD Word, 472 FX_WORD SubWord, 473 FX_FLOAT fCharSpace, 474 int32_t nHorzScale, 475 FX_FLOAT fFontSize, 476 FX_FLOAT fWordTail, 477 int32_t nWordStyle); 478 FX_FLOAT GetWordWidth(const CPVT_WordInfo& WordInfo); 479 FX_FLOAT GetWordAscent(const CPVT_WordInfo& WordInfo, FX_FLOAT fFontSize); 480 FX_FLOAT GetWordDescent(const CPVT_WordInfo& WordInfo, FX_FLOAT fFontSize); 481 FX_FLOAT GetWordAscent(const CPVT_WordInfo& WordInfo, 482 FX_BOOL bFactFontSize = FALSE); 483 FX_FLOAT GetWordDescent(const CPVT_WordInfo& WordInfo, 484 FX_BOOL bFactFontSize = FALSE); 485 FX_FLOAT GetLineAscent(const CPVT_SectionInfo& SecInfo); 486 FX_FLOAT GetLineDescent(const CPVT_SectionInfo& SecInfo); 487 FX_FLOAT GetFontAscent(int32_t nFontIndex, FX_FLOAT fFontSize); 488 FX_FLOAT GetFontDescent(int32_t nFontIndex, FX_FLOAT fFontSize); 489 int32_t GetWordFontIndex(const CPVT_WordInfo& WordInfo); 490 FX_FLOAT GetCharSpace(const CPVT_WordInfo& WordInfo); 491 int32_t GetHorzScale(const CPVT_WordInfo& WordInfo); 492 FX_FLOAT GetLineLeading(const CPVT_SectionInfo& SecInfo); 493 FX_FLOAT GetLineIndent(const CPVT_SectionInfo& SecInfo); 494 int32_t GetAlignment(const CPVT_SectionInfo& SecInfo); 495 496 void ClearSectionRightWords(const CPVT_WordPlace& place); 497 498 FX_BOOL ClearEmptySection(const CPVT_WordPlace& place); 499 void ClearEmptySections(const CPVT_WordRange& PlaceRange); 500 void LinkLatterSection(const CPVT_WordPlace& place); 501 void ClearWords(const CPVT_WordRange& PlaceRange); 502 CPVT_WordPlace ClearLeftWord(const CPVT_WordPlace& place); 503 CPVT_WordPlace ClearRightWord(const CPVT_WordPlace& place); 504 505 private: 506 CPVT_FloatRect Rearrange(const CPVT_WordRange& PlaceRange); 507 FX_FLOAT GetAutoFontSize(); 508 FX_BOOL IsBigger(FX_FLOAT fFontSize); 509 CPVT_FloatRect RearrangeSections(const CPVT_WordRange& PlaceRange); 510 511 void ResetSectionArray(); 512 513 CPVT_ArrayTemplate<CSection*> m_SectionArray; 514 int32_t m_nLimitChar; 515 int32_t m_nCharArray; 516 FX_BOOL m_bMultiLine; 517 FX_BOOL m_bLimitWidth; 518 FX_BOOL m_bAutoFontSize; 519 int32_t m_nAlignment; 520 FX_FLOAT m_fLineLeading; 521 FX_FLOAT m_fCharSpace; 522 int32_t m_nHorzScale; 523 FX_WORD m_wSubWord; 524 FX_FLOAT m_fFontSize; 525 526 private: 527 FX_BOOL m_bInitial; 528 FX_BOOL m_bRichText; 529 IPDF_VariableText_Provider* m_pVTProvider; 530 CPDF_VariableText_Iterator* m_pVTIterator; 531 }; 532 533 class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator { 534 public: 535 explicit CPDF_VariableText_Iterator(CPDF_VariableText* pVT); 536 ~CPDF_VariableText_Iterator() override; 537 538 // IPDF_VariableText_Iterator 539 FX_BOOL NextWord() override; 540 FX_BOOL PrevWord() override; 541 FX_BOOL NextLine() override; 542 FX_BOOL PrevLine() override; 543 FX_BOOL NextSection() override; 544 FX_BOOL PrevSection() override; 545 FX_BOOL SetWord(const CPVT_Word& word) override; 546 FX_BOOL GetWord(CPVT_Word& word) const override; 547 FX_BOOL GetLine(CPVT_Line& line) const override; 548 FX_BOOL GetSection(CPVT_Section& section) const override; 549 FX_BOOL SetSection(const CPVT_Section& section) override; 550 void SetAt(int32_t nWordIndex) override; 551 void SetAt(const CPVT_WordPlace& place) override; 552 const CPVT_WordPlace& GetAt() const override { return m_CurPos; } 553 554 private: 555 CPVT_WordPlace m_CurPos; 556 CPDF_VariableText* m_pVT; 557 }; 558 559 #endif // CORE_SRC_FPDFDOC_PDF_VT_H_ 560