| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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_CPDF_INTERFORM_H_ | 7 #ifndef CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ |
| 8 #define CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ | 8 #define CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, | 30 CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, |
| 31 CPDF_Document* pDocument, | 31 CPDF_Document* pDocument, |
| 32 CFX_ByteString& csNameTag); | 32 CFX_ByteString& csNameTag); |
| 33 | 33 |
| 34 class CPDF_InterForm { | 34 class CPDF_InterForm { |
| 35 public: | 35 public: |
| 36 explicit CPDF_InterForm(CPDF_Document* pDocument); | 36 explicit CPDF_InterForm(CPDF_Document* pDocument); |
| 37 ~CPDF_InterForm(); | 37 ~CPDF_InterForm(); |
| 38 | 38 |
| 39 static void SetUpdateAP(FX_BOOL bUpdateAP); | 39 static void SetUpdateAP(bool bUpdateAP); |
| 40 static FX_BOOL IsUpdateAPEnabled(); | 40 static bool IsUpdateAPEnabled(); |
| 41 static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, | 41 static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, |
| 42 const FX_CHAR* csType, | 42 const FX_CHAR* csType, |
| 43 int iMinLen = 2, | 43 int iMinLen, |
| 44 const FX_CHAR* csPrefix = ""); | 44 const FX_CHAR* csPrefix); |
| 45 static CPDF_Font* AddStandardFont(CPDF_Document* pDocument, | 45 static CPDF_Font* AddStandardFont(CPDF_Document* pDocument, |
| 46 CFX_ByteString csFontName); | 46 CFX_ByteString csFontName); |
| 47 static CFX_ByteString GetNativeFont(uint8_t iCharSet, | 47 static CFX_ByteString GetNativeFont(uint8_t iCharSet, void* pLogFont); |
| 48 void* pLogFont = nullptr); | |
| 49 static CFX_ByteString GetNativeFont(void* pLogFont = nullptr); | |
| 50 static uint8_t GetNativeCharSet(); | 48 static uint8_t GetNativeCharSet(); |
| 51 static CPDF_Font* AddNativeFont(uint8_t iCharSet, CPDF_Document* pDocument); | 49 static CPDF_Font* AddNativeFont(uint8_t iCharSet, CPDF_Document* pDocument); |
| 52 static CPDF_Font* AddNativeFont(CPDF_Document* pDocument); | 50 static CPDF_Font* AddNativeFont(CPDF_Document* pDocument); |
| 53 | 51 |
| 54 FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType); | 52 size_t CountFields(const CFX_WideString& csFieldName) const; |
| 55 FX_BOOL ValidateFieldName(const CPDF_FormField* pField, | |
| 56 CFX_WideString& csNewFieldName); | |
| 57 FX_BOOL ValidateFieldName(const CPDF_FormControl* pControl, | |
| 58 CFX_WideString& csNewFieldName); | |
| 59 | |
| 60 uint32_t CountFields(const CFX_WideString& csFieldName = L""); | |
| 61 CPDF_FormField* GetField(uint32_t index, | 53 CPDF_FormField* GetField(uint32_t index, |
| 62 const CFX_WideString& csFieldName = L""); | 54 const CFX_WideString& csFieldName) const; |
| 63 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; | 55 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; |
| 64 | 56 |
| 65 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, | 57 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, |
| 66 FX_FLOAT pdf_x, | 58 FX_FLOAT pdf_x, |
| 67 FX_FLOAT pdf_y, | 59 FX_FLOAT pdf_y, |
| 68 int* z_order) const; | 60 int* z_order) const; |
| 69 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; | 61 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; |
| 70 | 62 |
| 71 CPDF_Document* GetDocument() const { return m_pDocument; } | |
| 72 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } | |
| 73 FX_BOOL NeedConstructAP() const; | 63 FX_BOOL NeedConstructAP() const; |
| 74 int CountFieldsInCalculationOrder(); | 64 int CountFieldsInCalculationOrder(); |
| 75 CPDF_FormField* GetFieldInCalculationOrder(int index); | 65 CPDF_FormField* GetFieldInCalculationOrder(int index); |
| 76 int FindFieldInCalculationOrder(const CPDF_FormField* pField); | 66 int FindFieldInCalculationOrder(const CPDF_FormField* pField); |
| 77 | 67 |
| 78 uint32_t CountFormFonts(); | |
| 79 CPDF_Font* GetFormFont(uint32_t index, CFX_ByteString& csNameTag); | |
| 80 CPDF_Font* GetFormFont(CFX_ByteString csNameTag); | 68 CPDF_Font* GetFormFont(CFX_ByteString csNameTag); |
| 81 CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag); | 69 CPDF_DefaultAppearance GetDefaultAppearance() const; |
| 82 CPDF_Font* GetNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); | 70 int GetFormAlignment() const; |
| 83 CPDF_Font* GetNativeFormFont(CFX_ByteString& csNameTag); | |
| 84 FX_BOOL FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); | |
| 85 FX_BOOL FindFormFont(CFX_ByteString csFontName, | |
| 86 CPDF_Font*& pFont, | |
| 87 CFX_ByteString& csNameTag); | |
| 88 | |
| 89 FX_BOOL FindFormFont(CFX_WideString csFontName, | |
| 90 CPDF_Font*& pFont, | |
| 91 CFX_ByteString& csNameTag) { | |
| 92 return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag); | |
| 93 } | |
| 94 | |
| 95 void AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); | |
| 96 CPDF_Font* AddNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); | |
| 97 CPDF_Font* AddNativeFormFont(CFX_ByteString& csNameTag); | |
| 98 | |
| 99 void RemoveFormFont(const CPDF_Font* pFont); | |
| 100 void RemoveFormFont(CFX_ByteString csNameTag); | |
| 101 | |
| 102 CPDF_DefaultAppearance GetDefaultAppearance(); | |
| 103 CPDF_Font* GetDefaultFormFont(); | |
| 104 int GetFormAlignment(); | |
| 105 | 71 |
| 106 CPDF_FormField* CheckRequiredFields( | 72 CPDF_FormField* CheckRequiredFields( |
| 107 const std::vector<CPDF_FormField*>* fields, | 73 const std::vector<CPDF_FormField*>* fields, |
| 108 bool bIncludeOrExclude) const; | 74 bool bIncludeOrExclude) const; |
| 109 | 75 |
| 110 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, | 76 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, |
| 111 bool bSimpleFileSpec = false) const; | 77 bool bSimpleFileSpec) const; |
| 112 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, | 78 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, |
| 113 const std::vector<CPDF_FormField*>& fields, | 79 const std::vector<CPDF_FormField*>& fields, |
| 114 bool bIncludeOrExclude = true, | 80 bool bIncludeOrExclude, |
| 115 bool bSimpleFileSpec = false) const; | 81 bool bSimpleFileSpec) const; |
| 116 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); | |
| 117 | 82 |
| 118 bool ResetForm(const std::vector<CPDF_FormField*>& fields, | 83 bool ResetForm(const std::vector<CPDF_FormField*>& fields, |
| 119 bool bIncludeOrExclude = true, | 84 bool bIncludeOrExclude, |
| 120 bool bNotify = false); | 85 bool bNotify); |
| 121 bool ResetForm(bool bNotify = false); | 86 bool ResetForm(bool bNotify); |
| 122 | 87 |
| 123 void SetFormNotify(IPDF_FormNotify* pNotify); | 88 void SetFormNotify(IPDF_FormNotify* pNotify); |
| 124 FX_BOOL HasXFAForm() const; | 89 FX_BOOL HasXFAForm() const; |
| 125 void FixPageFields(const CPDF_Page* pPage); | 90 void FixPageFields(const CPDF_Page* pPage); |
| 126 | 91 |
| 127 private: | 92 private: |
| 128 friend class CPDF_FormControl; | 93 friend class CPDF_FormControl; |
| 129 friend class CPDF_FormField; | 94 friend class CPDF_FormField; |
| 130 | 95 |
| 131 void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); | 96 void LoadField(CPDF_Dictionary* pFieldDict, int nLevel); |
| 132 CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name); | |
| 133 CPDF_FormField* AddTerminalField(CPDF_Dictionary* pFieldDict); | 97 CPDF_FormField* AddTerminalField(CPDF_Dictionary* pFieldDict); |
| 134 CPDF_FormControl* AddControl(CPDF_FormField* pField, | 98 CPDF_FormControl* AddControl(CPDF_FormField* pField, |
| 135 CPDF_Dictionary* pWidgetDict); | 99 CPDF_Dictionary* pWidgetDict); |
| 136 void FDF_ImportField(CPDF_Dictionary* pField, | 100 void FDF_ImportField(CPDF_Dictionary* pField, |
| 137 const CFX_WideString& parent_name, | 101 const CFX_WideString& parent_name, |
| 138 FX_BOOL bNotify = FALSE, | 102 FX_BOOL bNotify = FALSE, |
| 139 int nLevel = 0); | 103 int nLevel = 0); |
| 140 FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, | 104 bool ValidateFieldName(CFX_WideString& csNewFieldName, |
| 141 int iType, | 105 int iType, |
| 142 const CPDF_FormField* pExcludedField, | 106 const CPDF_FormField* pExcludedField, |
| 143 const CPDF_FormControl* pExcludedControl); | 107 const CPDF_FormControl* pExcludedControl) const; |
| 144 int CompareFieldName(const CFX_WideString& name1, | |
| 145 const CFX_WideString& name2); | |
| 146 int CompareFieldName(const CFX_ByteString& name1, | |
| 147 const CFX_ByteString& name2); | |
| 148 | 108 |
| 149 static FX_BOOL s_bUpdateAP; | 109 static bool s_bUpdateAP; |
| 150 | 110 |
| 151 CPDF_Document* const m_pDocument; | 111 CPDF_Document* const m_pDocument; |
| 152 CPDF_Dictionary* m_pFormDict; | 112 CPDF_Dictionary* m_pFormDict; |
| 153 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; | 113 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; |
| 154 std::unique_ptr<CFieldTree> m_pFieldTree; | 114 std::unique_ptr<CFieldTree> m_pFieldTree; |
| 155 CFX_ByteString m_bsEncoding; | 115 CFX_ByteString m_bsEncoding; |
| 156 IPDF_FormNotify* m_pFormNotify; | 116 IPDF_FormNotify* m_pFormNotify; |
| 157 }; | 117 }; |
| 158 | 118 |
| 159 #endif // CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ | 119 #endif // CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ |
| OLD | NEW |