Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(407)

Side by Side Diff: core/src/fpdfdoc/pdf_vt.h

Issue 1296043002: Merge to XFA: Use override in more classes in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top)); 341 CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top));
342 CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom)); 342 CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom));
343 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, 343 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x,
344 ptRightBottom.y); 344 ptRightBottom.y);
345 }; 345 };
346 346
347 private: 347 private:
348 CPDF_Rect m_rcPlate; 348 CPDF_Rect m_rcPlate;
349 CPVT_FloatRect m_rcContent; 349 CPVT_FloatRect m_rcContent;
350 }; 350 };
351
351 class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer { 352 class CPDF_VariableText : public IPDF_VariableText, private CPDF_EditContainer {
352 friend class CTypeset; 353 friend class CTypeset;
353 friend class CSection; 354 friend class CSection;
354 friend class CPDF_VariableText_Iterator; 355 friend class CPDF_VariableText_Iterator;
355 356
356 public: 357 public:
357 CPDF_VariableText(); 358 CPDF_VariableText();
358 virtual ~CPDF_VariableText(); 359 ~CPDF_VariableText() override;
360
361 // IPDF_VariableText
359 IPDF_VariableText_Provider* SetProvider( 362 IPDF_VariableText_Provider* SetProvider(
360 IPDF_VariableText_Provider* pProvider); 363 IPDF_VariableText_Provider* pProvider) override;
361 IPDF_VariableText_Iterator* GetIterator(); 364 IPDF_VariableText_Iterator* GetIterator() override;
362 void SetPlateRect(const CPDF_Rect& rect) { 365 void SetPlateRect(const CPDF_Rect& rect) override {
363 CPDF_EditContainer::SetPlateRect(rect); 366 CPDF_EditContainer::SetPlateRect(rect);
364 } 367 }
365 void SetAlignment(int32_t nFormat = 0) { m_nAlignment = nFormat; } 368 void SetAlignment(int32_t nFormat = 0) override { m_nAlignment = nFormat; }
366 void SetPasswordChar(FX_WORD wSubWord = '*') { m_wSubWord = wSubWord; } 369 void SetPasswordChar(FX_WORD wSubWord = '*') override {
367 void SetLimitChar(int32_t nLimitChar = 0) { m_nLimitChar = nLimitChar; } 370 m_wSubWord = wSubWord;
368 void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) { m_fCharSpace = fCharSpace; } 371 }
369 void SetHorzScale(int32_t nHorzScale = 100) { m_nHorzScale = nHorzScale; } 372 void SetLimitChar(int32_t nLimitChar = 0) override {
370 void SetMultiLine(FX_BOOL bMultiLine = TRUE) { m_bMultiLine = bMultiLine; } 373 m_nLimitChar = nLimitChar;
371 void SetAutoReturn(FX_BOOL bAuto = TRUE) { m_bLimitWidth = bAuto; } 374 }
372 void SetFontSize(FX_FLOAT fFontSize) { m_fFontSize = fFontSize; } 375 void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) override {
373 void SetCharArray(int32_t nCharArray = 0) { m_nCharArray = nCharArray; } 376 m_fCharSpace = fCharSpace;
374 void SetAutoFontSize(FX_BOOL bAuto = TRUE) { m_bAutoFontSize = bAuto; } 377 }
375 void SetRichText(FX_BOOL bRichText) { m_bRichText = bRichText; } 378 void SetHorzScale(int32_t nHorzScale = 100) override {
376 void SetLineLeading(FX_FLOAT fLineLeading) { m_fLineLeading = fLineLeading; } 379 m_nHorzScale = nHorzScale;
377 void Initialize(); 380 }
378 FX_BOOL IsValid() const { return m_bInitial; } 381 void SetMultiLine(FX_BOOL bMultiLine = TRUE) override {
379 FX_BOOL IsRichText() const { return m_bRichText; } 382 m_bMultiLine = bMultiLine;
380 void RearrangeAll(); 383 }
381 void RearrangePart(const CPVT_WordRange& PlaceRange); 384 void SetAutoReturn(FX_BOOL bAuto = TRUE) override { m_bLimitWidth = bAuto; }
382 void ResetAll(); 385 void SetFontSize(FX_FLOAT fFontSize) override { m_fFontSize = fFontSize; }
386 void SetCharArray(int32_t nCharArray = 0) override {
387 m_nCharArray = nCharArray;
388 }
389 void SetAutoFontSize(FX_BOOL bAuto = TRUE) override {
390 m_bAutoFontSize = bAuto;
391 }
392 void SetRichText(FX_BOOL bRichText) override { m_bRichText = bRichText; }
393 void SetLineLeading(FX_FLOAT fLineLeading) override {
394 m_fLineLeading = fLineLeading;
395 }
396 void Initialize() override;
397 FX_BOOL IsValid() const override { return m_bInitial; }
398 FX_BOOL IsRichText() const override { return m_bRichText; }
399 void RearrangeAll() override;
400 void RearrangePart(const CPVT_WordRange& PlaceRange) override;
401 void ResetAll() override;
383 void SetText(const FX_WCHAR* text, 402 void SetText(const FX_WCHAR* text,
384 int32_t charset = 1, 403 int32_t charset = 1,
385 const CPVT_SecProps* pSecProps = NULL, 404 const CPVT_SecProps* pSecProps = NULL,
386 const CPVT_WordProps* pWordProps = NULL); 405 const CPVT_WordProps* pWordProps = NULL) override;
387 CPVT_WordPlace InsertWord(const CPVT_WordPlace& place, 406 CPVT_WordPlace InsertWord(const CPVT_WordPlace& place,
388 FX_WORD word, 407 FX_WORD word,
389 int32_t charset = 1, 408 int32_t charset = 1,
390 const CPVT_WordProps* pWordProps = NULL); 409 const CPVT_WordProps* pWordProps = NULL) override;
391 CPVT_WordPlace InsertSection(const CPVT_WordPlace& place, 410 CPVT_WordPlace InsertSection(
392 const CPVT_SecProps* pSecProps = NULL, 411 const CPVT_WordPlace& place,
393 const CPVT_WordProps* pWordProps = NULL); 412 const CPVT_SecProps* pSecProps = NULL,
413 const CPVT_WordProps* pWordProps = NULL) override;
394 CPVT_WordPlace InsertText(const CPVT_WordPlace& place, 414 CPVT_WordPlace InsertText(const CPVT_WordPlace& place,
395 const FX_WCHAR* text, 415 const FX_WCHAR* text,
396 int32_t charset = 1, 416 int32_t charset = 1,
397 const CPVT_SecProps* pSecProps = NULL, 417 const CPVT_SecProps* pSecProps = NULL,
398 const CPVT_WordProps* pWordProps = NULL); 418 const CPVT_WordProps* pWordProps = NULL) override;
399 CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange); 419 CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange) override;
400 CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place); 420 CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place) override;
401 CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place); 421 CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place) override;
402 const CPDF_Rect& GetPlateRect() const { 422 const CPDF_Rect& GetPlateRect() const override {
403 return CPDF_EditContainer::GetPlateRect(); 423 return CPDF_EditContainer::GetPlateRect();
404 } 424 }
405 CPDF_Rect GetContentRect() const; 425 CPDF_Rect GetContentRect() const override;
406 int32_t GetTotalWords() const; 426 int32_t GetTotalWords() const override;
407 FX_FLOAT GetFontSize() const { return m_fFontSize; } 427 FX_FLOAT GetFontSize() const override { return m_fFontSize; }
408 int32_t GetAlignment() const { return m_nAlignment; } 428 int32_t GetAlignment() const override { return m_nAlignment; }
409 int32_t GetCharArray() const { return m_nCharArray; } 429 FX_WORD GetPasswordChar() const override { return GetSubWord(); }
410 int32_t GetLimitChar() const { return m_nLimitChar; } 430 int32_t GetCharArray() const override { return m_nCharArray; }
411 FX_BOOL IsMultiLine() const { return m_bMultiLine; } 431 int32_t GetLimitChar() const override { return m_nLimitChar; }
412 int32_t GetHorzScale() const { return m_nHorzScale; } 432 FX_BOOL IsMultiLine() const override { return m_bMultiLine; }
413 FX_FLOAT GetCharSpace() const { return m_fCharSpace; } 433 int32_t GetHorzScale() const override { return m_nHorzScale; }
434 FX_FLOAT GetCharSpace() const override { return m_fCharSpace; }
435 CPVT_WordPlace GetBeginWordPlace() const override;
436 CPVT_WordPlace GetEndWordPlace() const override;
437 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const override;
438 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const override;
439 CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const override;
440 CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place,
441 const CPDF_Point& point) const override;
442 CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place,
443 const CPDF_Point& point) const override;
444 CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override;
445 CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override;
446 CPVT_WordPlace GetSectionBeginPlace(
447 const CPVT_WordPlace& place) const override;
448 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const override;
449 void UpdateWordPlace(CPVT_WordPlace& place) const override;
450 CPVT_WordPlace AdjustLineHeader(const CPVT_WordPlace& place,
451 FX_BOOL bPrevOrNext) const override;
452 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const override;
453 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const override;
414 454
415 CPVT_WordPlace GetBeginWordPlace() const;
416 CPVT_WordPlace GetEndWordPlace() const;
417 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
418 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const;
419 CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const;
420 CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place,
421 const CPDF_Point& point) const;
422 CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place,
423 const CPDF_Point& point) const;
424 CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const;
425 CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const;
426 CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace& place) const;
427 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const;
428 void UpdateWordPlace(CPVT_WordPlace& place) const;
429 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const;
430 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const;
431 FX_WORD GetPasswordChar() const { return GetSubWord(); }
432 FX_WORD GetSubWord() const { return m_wSubWord; } 455 FX_WORD GetSubWord() const { return m_wSubWord; }
433 456
434 private: 457 private:
435 int32_t GetCharWidth(int32_t nFontIndex, 458 int32_t GetCharWidth(int32_t nFontIndex,
436 FX_WORD Word, 459 FX_WORD Word,
437 FX_WORD SubWord, 460 FX_WORD SubWord,
438 int32_t nWordStyle); 461 int32_t nWordStyle);
439 int32_t GetTypeAscent(int32_t nFontIndex); 462 int32_t GetTypeAscent(int32_t nFontIndex);
440 int32_t GetTypeDescent(int32_t nFontIndex); 463 int32_t GetTypeDescent(int32_t nFontIndex);
441 int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); 464 int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex);
442 int32_t GetDefaultFontIndex(); 465 int32_t GetDefaultFontIndex();
443 FX_BOOL IsLatinWord(FX_WORD word); 466 FX_BOOL IsLatinWord(FX_WORD word);
444 467
445 private:
446 CPVT_WordPlace AddSection(const CPVT_WordPlace& place, 468 CPVT_WordPlace AddSection(const CPVT_WordPlace& place,
447 const CPVT_SectionInfo& secinfo); 469 const CPVT_SectionInfo& secinfo);
448 CPVT_WordPlace AddLine(const CPVT_WordPlace& place, 470 CPVT_WordPlace AddLine(const CPVT_WordPlace& place,
449 const CPVT_LineInfo& lineinfo); 471 const CPVT_LineInfo& lineinfo);
450 CPVT_WordPlace AddWord(const CPVT_WordPlace& place, 472 CPVT_WordPlace AddWord(const CPVT_WordPlace& place,
451 const CPVT_WordInfo& wordinfo); 473 const CPVT_WordInfo& wordinfo);
452 FX_BOOL GetWordInfo(const CPVT_WordPlace& place, CPVT_WordInfo& wordinfo); 474 FX_BOOL GetWordInfo(const CPVT_WordPlace& place, CPVT_WordInfo& wordinfo);
453 FX_BOOL SetWordInfo(const CPVT_WordPlace& place, 475 FX_BOOL SetWordInfo(const CPVT_WordPlace& place,
454 const CPVT_WordInfo& wordinfo); 476 const CPVT_WordInfo& wordinfo);
455 FX_BOOL GetLineInfo(const CPVT_WordPlace& place, CPVT_LineInfo& lineinfo); 477 FX_BOOL GetLineInfo(const CPVT_WordPlace& place, CPVT_LineInfo& lineinfo);
(...skipping 21 matching lines...) Expand all
477 FX_FLOAT GetFontAscent(int32_t nFontIndex, FX_FLOAT fFontSize); 499 FX_FLOAT GetFontAscent(int32_t nFontIndex, FX_FLOAT fFontSize);
478 FX_FLOAT GetFontDescent(int32_t nFontIndex, FX_FLOAT fFontSize); 500 FX_FLOAT GetFontDescent(int32_t nFontIndex, FX_FLOAT fFontSize);
479 int32_t GetWordFontIndex(const CPVT_WordInfo& WordInfo); 501 int32_t GetWordFontIndex(const CPVT_WordInfo& WordInfo);
480 FX_FLOAT GetCharSpace(const CPVT_WordInfo& WordInfo); 502 FX_FLOAT GetCharSpace(const CPVT_WordInfo& WordInfo);
481 int32_t GetHorzScale(const CPVT_WordInfo& WordInfo); 503 int32_t GetHorzScale(const CPVT_WordInfo& WordInfo);
482 FX_FLOAT GetLineLeading(const CPVT_SectionInfo& SecInfo); 504 FX_FLOAT GetLineLeading(const CPVT_SectionInfo& SecInfo);
483 FX_FLOAT GetLineIndent(const CPVT_SectionInfo& SecInfo); 505 FX_FLOAT GetLineIndent(const CPVT_SectionInfo& SecInfo);
484 int32_t GetAlignment(const CPVT_SectionInfo& SecInfo); 506 int32_t GetAlignment(const CPVT_SectionInfo& SecInfo);
485 507
486 void ClearSectionRightWords(const CPVT_WordPlace& place); 508 void ClearSectionRightWords(const CPVT_WordPlace& place);
487 CPVT_WordPlace AjustLineHeader(const CPVT_WordPlace& place, 509
488 FX_BOOL bPrevOrNext) const;
489 FX_BOOL ClearEmptySection(const CPVT_WordPlace& place); 510 FX_BOOL ClearEmptySection(const CPVT_WordPlace& place);
490 void ClearEmptySections(const CPVT_WordRange& PlaceRange); 511 void ClearEmptySections(const CPVT_WordRange& PlaceRange);
491 void LinkLatterSection(const CPVT_WordPlace& place); 512 void LinkLatterSection(const CPVT_WordPlace& place);
492 void ClearWords(const CPVT_WordRange& PlaceRange); 513 void ClearWords(const CPVT_WordRange& PlaceRange);
493 CPVT_WordPlace ClearLeftWord(const CPVT_WordPlace& place); 514 CPVT_WordPlace ClearLeftWord(const CPVT_WordPlace& place);
494 CPVT_WordPlace ClearRightWord(const CPVT_WordPlace& place); 515 CPVT_WordPlace ClearRightWord(const CPVT_WordPlace& place);
495 516
496 private: 517 private:
497 CPVT_FloatRect Rearrange(const CPVT_WordRange& PlaceRange); 518 CPVT_FloatRect Rearrange(const CPVT_WordRange& PlaceRange);
498 FX_FLOAT GetAutoFontSize(); 519 FX_FLOAT GetAutoFontSize();
499 FX_BOOL IsBigger(FX_FLOAT fFontSize); 520 FX_BOOL IsBigger(FX_FLOAT fFontSize);
500 CPVT_FloatRect RearrangeSections(const CPVT_WordRange& PlaceRange); 521 CPVT_FloatRect RearrangeSections(const CPVT_WordRange& PlaceRange);
501 522
502 private:
503 void ResetSectionArray(); 523 void ResetSectionArray();
504 524
505 private:
506 CPVT_ArrayTemplate<CSection*> m_SectionArray; 525 CPVT_ArrayTemplate<CSection*> m_SectionArray;
507 int32_t m_nLimitChar; 526 int32_t m_nLimitChar;
508 int32_t m_nCharArray; 527 int32_t m_nCharArray;
509 FX_BOOL m_bMultiLine; 528 FX_BOOL m_bMultiLine;
510 FX_BOOL m_bLimitWidth; 529 FX_BOOL m_bLimitWidth;
511 FX_BOOL m_bAutoFontSize; 530 FX_BOOL m_bAutoFontSize;
512 int32_t m_nAlignment; 531 int32_t m_nAlignment;
513 FX_FLOAT m_fLineLeading; 532 FX_FLOAT m_fLineLeading;
514 FX_FLOAT m_fCharSpace; 533 FX_FLOAT m_fCharSpace;
515 int32_t m_nHorzScale; 534 int32_t m_nHorzScale;
516 FX_WORD m_wSubWord; 535 FX_WORD m_wSubWord;
517 FX_FLOAT m_fFontSize; 536 FX_FLOAT m_fFontSize;
518 537
519 private: 538 private:
520 FX_BOOL m_bInitial; 539 FX_BOOL m_bInitial;
521 FX_BOOL m_bRichText; 540 FX_BOOL m_bRichText;
522 IPDF_VariableText_Provider* m_pVTProvider; 541 IPDF_VariableText_Provider* m_pVTProvider;
523 CPDF_VariableText_Iterator* m_pVTIterator; 542 CPDF_VariableText_Iterator* m_pVTIterator;
524 }; 543 };
544
525 class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator { 545 class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator {
526 public: 546 public:
527 CPDF_VariableText_Iterator(CPDF_VariableText* pVT); 547 CPDF_VariableText_Iterator(CPDF_VariableText* pVT);
528 virtual ~CPDF_VariableText_Iterator(); 548 ~CPDF_VariableText_Iterator() override;
529 FX_BOOL NextWord(); 549
530 FX_BOOL PrevWord(); 550 // IPDF_VariableText_Iterator
531 FX_BOOL NextLine(); 551 FX_BOOL NextWord() override;
532 FX_BOOL PrevLine(); 552 FX_BOOL PrevWord() override;
533 FX_BOOL NextSection(); 553 FX_BOOL NextLine() override;
534 FX_BOOL PrevSection(); 554 FX_BOOL PrevLine() override;
535 FX_BOOL SetWord(const CPVT_Word& word); 555 FX_BOOL NextSection() override;
536 FX_BOOL GetWord(CPVT_Word& word) const; 556 FX_BOOL PrevSection() override;
537 FX_BOOL GetLine(CPVT_Line& line) const; 557 FX_BOOL SetWord(const CPVT_Word& word) override;
538 FX_BOOL GetSection(CPVT_Section& section) const; 558 FX_BOOL GetWord(CPVT_Word& word) const override;
539 FX_BOOL SetSection(const CPVT_Section& section); 559 FX_BOOL GetLine(CPVT_Line& line) const override;
540 void SetAt(int32_t nWordIndex); 560 FX_BOOL GetSection(CPVT_Section& section) const override;
541 void SetAt(const CPVT_WordPlace& place); 561 FX_BOOL SetSection(const CPVT_Section& section) override;
542 const CPVT_WordPlace& GetAt() const { return m_CurPos; }; 562 void SetAt(int32_t nWordIndex) override;
563 void SetAt(const CPVT_WordPlace& place) override;
564 const CPVT_WordPlace& GetAt() const override { return m_CurPos; };
543 565
544 private: 566 private:
545 CPVT_WordPlace m_CurPos; 567 CPVT_WordPlace m_CurPos;
546 CPDF_VariableText* m_pVT; 568 CPDF_VariableText* m_pVT;
547 }; 569 };
548 570
549 #endif // CORE_SRC_FPDFDOC_PDF_VT_H_ 571 #endif // CORE_SRC_FPDFDOC_PDF_VT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698