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