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