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_INCLUDE_FPDF_DOC_H_ | 7 #ifndef CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_ |
8 #define CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_ | 8 #define CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_ |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <memory> | 11 #include <memory> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
15 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" | 15 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" |
16 #include "core/fxge/include/fx_dib.h" | 16 #include "core/fxge/include/fx_dib.h" |
17 | 17 |
18 class CFDF_Document; | 18 class CFDF_Document; |
19 class CFieldTree; | 19 class CFieldTree; |
| 20 class CFX_RenderDevice; |
20 class CPDF_AAction; | 21 class CPDF_AAction; |
21 class CPDF_Action; | 22 class CPDF_Action; |
22 class CPDF_ActionFields; | 23 class CPDF_ActionFields; |
23 class CPDF_Annot; | 24 class CPDF_Annot; |
24 class CPDF_AnnotList; | 25 class CPDF_AnnotList; |
25 class CPDF_ApSettings; | 26 class CPDF_ApSettings; |
26 class CPDF_Bookmark; | 27 class CPDF_Bookmark; |
27 class CPDF_BookmarkTree; | 28 class CPDF_BookmarkTree; |
28 class CPDF_DefaultAppearance; | 29 class CPDF_DefaultAppearance; |
29 class CPDF_Dest; | 30 class CPDF_Dest; |
| 31 class CPDF_DocJSActions; |
30 class CPDF_Document; | 32 class CPDF_Document; |
31 class CPDF_DocJSActions; | |
32 class CPDF_FileSpec; | 33 class CPDF_FileSpec; |
| 34 class CPDF_Font; |
| 35 class CPDF_Form; |
33 class CPDF_FormControl; | 36 class CPDF_FormControl; |
34 class CPDF_FormField; | 37 class CPDF_FormField; |
35 class CPDF_FormNotify; | |
36 class CPDF_IconFit; | 38 class CPDF_IconFit; |
37 class CPDF_InterForm; | |
38 class CPDF_Link; | 39 class CPDF_Link; |
39 class CPDF_Metadata; | 40 class CPDF_Metadata; |
40 class CPDF_OCContext; | 41 class CPDF_OCContext; |
41 class CPDF_Page; | 42 class CPDF_Page; |
42 class CPDF_PageObject; | 43 class CPDF_PageObject; |
43 class CPDF_Font; | 44 class CPDF_RenderContext; |
44 class CPDF_Form; | |
45 class CPDF_RenderOptions; | 45 class CPDF_RenderOptions; |
46 class CPDF_RenderContext; | |
47 class CPDF_ViewerPreferences; | 46 class CPDF_ViewerPreferences; |
48 class CXML_Element; | 47 class CXML_Element; |
49 class CFX_RenderDevice; | 48 class IPDF_FormNotify; |
50 | 49 |
51 enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE }; | 50 enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE }; |
52 | 51 |
53 class CPDF_NameTree { | 52 class CPDF_NameTree { |
54 public: | 53 public: |
55 explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} | 54 explicit CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} |
56 CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category); | 55 CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category); |
57 | 56 |
58 CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; | 57 CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; |
59 CPDF_Object* LookupValue(const CFX_ByteString& csName) const; | 58 CPDF_Object* LookupValue(const CFX_ByteString& csName) const; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 }; | 444 }; |
446 | 445 |
447 #define FIELDTYPE_UNKNOWN 0 | 446 #define FIELDTYPE_UNKNOWN 0 |
448 #define FIELDTYPE_PUSHBUTTON 1 | 447 #define FIELDTYPE_PUSHBUTTON 1 |
449 #define FIELDTYPE_CHECKBOX 2 | 448 #define FIELDTYPE_CHECKBOX 2 |
450 #define FIELDTYPE_RADIOBUTTON 3 | 449 #define FIELDTYPE_RADIOBUTTON 3 |
451 #define FIELDTYPE_COMBOBOX 4 | 450 #define FIELDTYPE_COMBOBOX 4 |
452 #define FIELDTYPE_LISTBOX 5 | 451 #define FIELDTYPE_LISTBOX 5 |
453 #define FIELDTYPE_TEXTFIELD 6 | 452 #define FIELDTYPE_TEXTFIELD 6 |
454 #define FIELDTYPE_SIGNATURE 7 | 453 #define FIELDTYPE_SIGNATURE 7 |
| 454 |
455 class CPDF_InterForm : public CFX_PrivateData { | 455 class CPDF_InterForm : public CFX_PrivateData { |
456 public: | 456 public: |
457 CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bUpdateAP); | 457 explicit CPDF_InterForm(CPDF_Document* pDocument); |
458 ~CPDF_InterForm(); | 458 ~CPDF_InterForm(); |
459 | 459 |
460 static void EnableUpdateAP(FX_BOOL bUpdateAP); | 460 static void EnableUpdateAP(FX_BOOL bUpdateAP); |
461 | 461 |
462 static FX_BOOL UpdatingAPEnabled(); | 462 static FX_BOOL UpdatingAPEnabled(); |
463 | 463 |
464 static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, | 464 static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, |
465 const FX_CHAR* csType, | 465 const FX_CHAR* csType, |
466 int iMinLen = 2, | 466 int iMinLen = 2, |
467 const FX_CHAR* csPrefix = ""); | 467 const FX_CHAR* csPrefix = ""); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 FX_FLOAT pdf_x, | 499 FX_FLOAT pdf_x, |
500 FX_FLOAT pdf_y, | 500 FX_FLOAT pdf_y, |
501 int* z_order) const; | 501 int* z_order) const; |
502 | 502 |
503 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; | 503 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; |
504 | 504 |
505 CPDF_Document* GetDocument() const { return m_pDocument; } | 505 CPDF_Document* GetDocument() const { return m_pDocument; } |
506 | 506 |
507 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } | 507 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } |
508 | 508 |
509 FX_BOOL NeedConstructAP(); | 509 FX_BOOL NeedConstructAP() const; |
510 | |
511 void NeedConstructAP(FX_BOOL bNeedAP); | |
512 | 510 |
513 int CountFieldsInCalculationOrder(); | 511 int CountFieldsInCalculationOrder(); |
514 | 512 |
515 CPDF_FormField* GetFieldInCalculationOrder(int index); | 513 CPDF_FormField* GetFieldInCalculationOrder(int index); |
516 | 514 |
517 int FindFieldInCalculationOrder(const CPDF_FormField* pField); | 515 int FindFieldInCalculationOrder(const CPDF_FormField* pField); |
518 | 516 |
519 uint32_t CountFormFonts(); | 517 uint32_t CountFormFonts(); |
520 | 518 |
521 CPDF_Font* GetFormFont(uint32_t index, CFX_ByteString& csNameTag); | 519 CPDF_Font* GetFormFont(uint32_t index, CFX_ByteString& csNameTag); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 bool bSimpleFileSpec = false) const; | 567 bool bSimpleFileSpec = false) const; |
570 | 568 |
571 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); | 569 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); |
572 | 570 |
573 bool ResetForm(const std::vector<CPDF_FormField*>& fields, | 571 bool ResetForm(const std::vector<CPDF_FormField*>& fields, |
574 bool bIncludeOrExclude = true, | 572 bool bIncludeOrExclude = true, |
575 bool bNotify = false); | 573 bool bNotify = false); |
576 | 574 |
577 bool ResetForm(bool bNotify = false); | 575 bool ResetForm(bool bNotify = false); |
578 | 576 |
579 CPDF_FormNotify* GetFormNotify() const { return m_pFormNotify; } | 577 void SetFormNotify(IPDF_FormNotify* pNotify); |
580 | |
581 void SetFormNotify(const CPDF_FormNotify* pNotify); | |
582 | |
583 FX_BOOL IsUpdated() { return m_bUpdated; } | |
584 | |
585 void ClearUpdatedFlag() { m_bUpdated = FALSE; } | |
586 | 578 |
587 FX_BOOL HasXFAForm() const; | 579 FX_BOOL HasXFAForm() const; |
588 | 580 |
589 void FixPageFields(const CPDF_Page* pPage); | 581 void FixPageFields(const CPDF_Page* pPage); |
590 | 582 |
591 protected: | 583 protected: |
592 static FX_BOOL m_bUpdateAP; | 584 static FX_BOOL m_bUpdateAP; |
593 | 585 |
594 void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); | 586 void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); |
595 | 587 |
(...skipping 15 matching lines...) Expand all Loading... |
611 const CPDF_FormControl* pExcludedControl); | 603 const CPDF_FormControl* pExcludedControl); |
612 | 604 |
613 int CompareFieldName(const CFX_WideString& name1, | 605 int CompareFieldName(const CFX_WideString& name1, |
614 const CFX_WideString& name2); | 606 const CFX_WideString& name2); |
615 | 607 |
616 int CompareFieldName(const CFX_ByteString& name1, | 608 int CompareFieldName(const CFX_ByteString& name1, |
617 const CFX_ByteString& name2); | 609 const CFX_ByteString& name2); |
618 | 610 |
619 CPDF_Document* const m_pDocument; | 611 CPDF_Document* const m_pDocument; |
620 | 612 |
621 FX_BOOL m_bGenerateAP; | |
622 | |
623 CPDF_Dictionary* m_pFormDict; | 613 CPDF_Dictionary* m_pFormDict; |
624 | 614 |
625 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; | 615 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; |
626 | 616 |
627 std::unique_ptr<CFieldTree> m_pFieldTree; | 617 std::unique_ptr<CFieldTree> m_pFieldTree; |
628 | 618 |
629 CFX_ByteString m_bsEncoding; | 619 CFX_ByteString m_bsEncoding; |
630 | 620 |
631 CPDF_FormNotify* m_pFormNotify; | 621 IPDF_FormNotify* m_pFormNotify; |
632 | 622 |
633 FX_BOOL m_bUpdated; | |
634 friend class CPDF_FormControl; | 623 friend class CPDF_FormControl; |
635 friend class CPDF_FormField; | 624 friend class CPDF_FormField; |
636 }; | 625 }; |
637 | 626 |
638 #define FORMFIELD_READONLY 0x01 | 627 #define FORMFIELD_READONLY 0x01 |
639 #define FORMFIELD_REQUIRED 0x02 | 628 #define FORMFIELD_REQUIRED 0x02 |
640 #define FORMFIELD_NOEXPORT 0x04 | 629 #define FORMFIELD_NOEXPORT 0x04 |
641 #define FORMRADIO_NOTOGGLEOFF 0x100 | 630 #define FORMRADIO_NOTOGGLEOFF 0x100 |
642 #define FORMRADIO_UNISON 0x200 | 631 #define FORMRADIO_UNISON 0x200 |
643 #define FORMTEXT_MULTILINE 0x100 | 632 #define FORMTEXT_MULTILINE 0x100 |
(...skipping 20 matching lines...) Expand all Loading... |
664 CFX_WideString GetFullName(); | 653 CFX_WideString GetFullName(); |
665 | 654 |
666 Type GetType() const { return m_Type; } | 655 Type GetType() const { return m_Type; } |
667 uint32_t GetFlags() const { return m_Flags; } | 656 uint32_t GetFlags() const { return m_Flags; } |
668 | 657 |
669 CPDF_Dictionary* GetFieldDict() const { return m_pDict; } | 658 CPDF_Dictionary* GetFieldDict() const { return m_pDict; } |
670 void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; } | 659 void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; } |
671 | 660 |
672 FX_BOOL ResetField(FX_BOOL bNotify = FALSE); | 661 FX_BOOL ResetField(FX_BOOL bNotify = FALSE); |
673 | 662 |
674 int CountControls() { return m_ControlList.GetSize(); } | 663 int CountControls() const { return m_ControlList.GetSize(); } |
675 | 664 |
676 CPDF_FormControl* GetControl(int index) { return m_ControlList.GetAt(index); } | 665 CPDF_FormControl* GetControl(int index) const { |
| 666 return m_ControlList.GetAt(index); |
| 667 } |
677 | 668 |
678 int GetControlIndex(const CPDF_FormControl* pControl); | 669 int GetControlIndex(const CPDF_FormControl* pControl); |
679 | 670 |
680 int GetFieldType(); | 671 int GetFieldType(); |
681 | 672 |
682 CPDF_AAction GetAdditionalAction(); | 673 CPDF_AAction GetAdditionalAction(); |
683 | 674 |
684 CFX_WideString GetAlternateName(); | 675 CFX_WideString GetAlternateName(); |
685 | 676 |
686 CFX_WideString GetMappingName(); | 677 CFX_WideString GetMappingName(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 FX_BOOL bNotify); | 755 FX_BOOL bNotify); |
765 | 756 |
766 void SyncFieldFlags(); | 757 void SyncFieldFlags(); |
767 | 758 |
768 int FindListSel(CPDF_String* str); | 759 int FindListSel(CPDF_String* str); |
769 | 760 |
770 CFX_WideString GetOptionText(int index, int sub_index); | 761 CFX_WideString GetOptionText(int index, int sub_index); |
771 | 762 |
772 void LoadDA(); | 763 void LoadDA(); |
773 | 764 |
774 void UpdateAP(CPDF_FormControl* pControl); | |
775 | |
776 CFX_WideString GetCheckValue(FX_BOOL bDefault); | 765 CFX_WideString GetCheckValue(FX_BOOL bDefault); |
777 | 766 |
778 FX_BOOL SetCheckValue(const CFX_WideString& value, | 767 FX_BOOL SetCheckValue(const CFX_WideString& value, |
779 FX_BOOL bDefault, | 768 FX_BOOL bDefault, |
780 FX_BOOL bNotify); | 769 FX_BOOL bNotify); |
781 | 770 |
| 771 bool NotifyBeforeSelectionChange(const CFX_WideString& value); |
| 772 void NotifyAfterSelectionChange(); |
| 773 |
| 774 bool NotifyBeforeValueChange(const CFX_WideString& value); |
| 775 void NotifyAfterValueChange(); |
| 776 |
| 777 bool NotifyListOrComboBoxBeforeChange(const CFX_WideString& value); |
| 778 void NotifyListOrComboBoxAfterChange(); |
| 779 |
782 CPDF_FormField::Type m_Type; | 780 CPDF_FormField::Type m_Type; |
783 uint32_t m_Flags; | 781 uint32_t m_Flags; |
784 CPDF_InterForm* m_pForm; | 782 CPDF_InterForm* m_pForm; |
785 CPDF_Dictionary* m_pDict; | 783 CPDF_Dictionary* m_pDict; |
786 CFX_ArrayTemplate<CPDF_FormControl*> m_ControlList; | 784 CFX_ArrayTemplate<CPDF_FormControl*> m_ControlList; |
787 FX_FLOAT m_FontSize; | 785 FX_FLOAT m_FontSize; |
788 CPDF_Font* m_pFont; | 786 CPDF_Font* m_pFont; |
789 | 787 |
790 friend class CPDF_InterForm; | 788 friend class CPDF_InterForm; |
791 friend class CPDF_FormControl; | 789 friend class CPDF_FormControl; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } | 826 CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } |
829 CFX_FloatRect GetRect() const; | 827 CFX_FloatRect GetRect() const; |
830 | 828 |
831 void DrawControl(CFX_RenderDevice* pDevice, | 829 void DrawControl(CFX_RenderDevice* pDevice, |
832 CFX_Matrix* pMatrix, | 830 CFX_Matrix* pMatrix, |
833 CPDF_Page* pPage, | 831 CPDF_Page* pPage, |
834 CPDF_Annot::AppearanceMode mode, | 832 CPDF_Annot::AppearanceMode mode, |
835 const CPDF_RenderOptions* pOptions = nullptr); | 833 const CPDF_RenderOptions* pOptions = nullptr); |
836 | 834 |
837 CFX_ByteString GetCheckedAPState(); | 835 CFX_ByteString GetCheckedAPState(); |
838 CFX_WideString GetExportValue(); | 836 CFX_WideString GetExportValue() const; |
839 | 837 |
840 bool IsChecked() const; | 838 bool IsChecked() const; |
841 bool IsDefaultChecked() const; | 839 bool IsDefaultChecked() const; |
842 | 840 |
843 HighlightingMode GetHighlightingMode(); | 841 HighlightingMode GetHighlightingMode(); |
844 bool HasMKEntry(const CFX_ByteString& csEntry) const; | 842 bool HasMKEntry(const CFX_ByteString& csEntry) const; |
845 int GetRotation(); | 843 int GetRotation(); |
846 | 844 |
847 inline FX_ARGB GetBorderColor(int& iColorType) { | 845 inline FX_ARGB GetBorderColor(int& iColorType) { |
848 return GetColor(iColorType, "BC"); | 846 return GetColor(iColorType, "BC"); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry); | 892 FX_ARGB GetColor(int& iColorType, const CFX_ByteString& csEntry); |
895 FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry); | 893 FX_FLOAT GetOriginalColor(int index, const CFX_ByteString& csEntry); |
896 void GetOriginalColor(int& iColorType, | 894 void GetOriginalColor(int& iColorType, |
897 FX_FLOAT fc[4], | 895 FX_FLOAT fc[4], |
898 const CFX_ByteString& csEntry); | 896 const CFX_ByteString& csEntry); |
899 | 897 |
900 CFX_WideString GetCaption(const CFX_ByteString& csEntry); | 898 CFX_WideString GetCaption(const CFX_ByteString& csEntry); |
901 CPDF_Stream* GetIcon(const CFX_ByteString& csEntry); | 899 CPDF_Stream* GetIcon(const CFX_ByteString& csEntry); |
902 CPDF_ApSettings GetMK() const; | 900 CPDF_ApSettings GetMK() const; |
903 | 901 |
904 CPDF_InterForm* m_pForm; | 902 CPDF_FormField* const m_pField; |
905 CPDF_FormField* m_pField; | 903 CPDF_Dictionary* const m_pWidgetDict; |
906 CPDF_Dictionary* m_pWidgetDict; | 904 CPDF_InterForm* const m_pForm; |
907 | 905 |
908 friend class CPDF_InterForm; | 906 friend class CPDF_InterForm; |
909 friend class CPDF_FormField; | 907 friend class CPDF_FormField; |
910 }; | 908 }; |
911 | 909 |
912 class CPDF_FormNotify { | 910 class IPDF_FormNotify { |
913 public: | 911 public: |
914 virtual ~CPDF_FormNotify() {} | 912 virtual ~IPDF_FormNotify() {} |
915 | 913 |
916 virtual int BeforeValueChange(CPDF_FormField* pField, | 914 virtual int BeforeValueChange(CPDF_FormField* pField, |
917 const CFX_WideString& csValue) { | 915 const CFX_WideString& csValue) { |
918 return 0; | 916 return 0; |
919 } | 917 } |
920 virtual void AfterValueChange(CPDF_FormField* pField) {} | 918 virtual void AfterValueChange(CPDF_FormField* pField) {} |
921 virtual int BeforeSelectionChange(CPDF_FormField* pField, | 919 virtual int BeforeSelectionChange(CPDF_FormField* pField, |
922 const CFX_WideString& csValue) { | 920 const CFX_WideString& csValue) { |
923 return 0; | 921 return 0; |
924 } | 922 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 void GetOriginalColor(int& iColorType, | 1014 void GetOriginalColor(int& iColorType, |
1017 FX_FLOAT fc[4], | 1015 FX_FLOAT fc[4], |
1018 const CFX_ByteString& csEntry) const; | 1016 const CFX_ByteString& csEntry) const; |
1019 | 1017 |
1020 CFX_WideString GetCaption(const CFX_ByteString& csEntry) const; | 1018 CFX_WideString GetCaption(const CFX_ByteString& csEntry) const; |
1021 CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const; | 1019 CPDF_Stream* GetIcon(const CFX_ByteString& csEntry) const; |
1022 | 1020 |
1023 CPDF_Dictionary* const m_pDict; | 1021 CPDF_Dictionary* const m_pDict; |
1024 }; | 1022 }; |
1025 | 1023 |
| 1024 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, |
| 1025 CPDF_Annot::AppearanceMode mode); |
| 1026 |
1026 #endif // CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_ | 1027 #endif // CORE_FPDFDOC_INCLUDE_FPDF_DOC_H_ |
OLD | NEW |