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); |
Tom Sepez
2016/09/28 20:21:06
nit: const method (this and the next one)?
Lei Zhang
2016/09/28 20:42:40
Done, and a bit more.
| |
55 FX_BOOL ValidateFieldName(const CPDF_FormField* pField, | 53 CPDF_FormField* GetField(uint32_t index, const CFX_WideString& csFieldName); |
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, | |
62 const CFX_WideString& csFieldName = L""); | |
63 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; | 54 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; |
64 | 55 |
65 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, | 56 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, |
66 FX_FLOAT pdf_x, | 57 FX_FLOAT pdf_x, |
67 FX_FLOAT pdf_y, | 58 FX_FLOAT pdf_y, |
68 int* z_order) const; | 59 int* z_order) const; |
69 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; | 60 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; |
70 | 61 |
71 CPDF_Document* GetDocument() const { return m_pDocument; } | |
72 CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } | |
73 FX_BOOL NeedConstructAP() const; | 62 FX_BOOL NeedConstructAP() const; |
74 int CountFieldsInCalculationOrder(); | 63 int CountFieldsInCalculationOrder(); |
75 CPDF_FormField* GetFieldInCalculationOrder(int index); | 64 CPDF_FormField* GetFieldInCalculationOrder(int index); |
76 int FindFieldInCalculationOrder(const CPDF_FormField* pField); | 65 int FindFieldInCalculationOrder(const CPDF_FormField* pField); |
77 | 66 |
78 uint32_t CountFormFonts(); | |
79 CPDF_Font* GetFormFont(uint32_t index, CFX_ByteString& csNameTag); | |
80 CPDF_Font* GetFormFont(CFX_ByteString csNameTag); | 67 CPDF_Font* GetFormFont(CFX_ByteString csNameTag); |
81 CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag); | |
82 CPDF_Font* GetNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); | |
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, | 68 FX_BOOL FindFormFont(CFX_ByteString csFontName, |
86 CPDF_Font*& pFont, | 69 CPDF_Font*& pFont, |
87 CFX_ByteString& csNameTag); | 70 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(); | 71 CPDF_DefaultAppearance GetDefaultAppearance(); |
103 CPDF_Font* GetDefaultFormFont(); | |
104 int GetFormAlignment(); | 72 int GetFormAlignment(); |
105 | 73 |
106 CPDF_FormField* CheckRequiredFields( | 74 CPDF_FormField* CheckRequiredFields( |
107 const std::vector<CPDF_FormField*>* fields, | 75 const std::vector<CPDF_FormField*>* fields, |
108 bool bIncludeOrExclude) const; | 76 bool bIncludeOrExclude) const; |
109 | 77 |
110 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, | 78 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, |
111 bool bSimpleFileSpec = false) const; | 79 bool bSimpleFileSpec) const; |
112 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, | 80 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, |
113 const std::vector<CPDF_FormField*>& fields, | 81 const std::vector<CPDF_FormField*>& fields, |
114 bool bIncludeOrExclude = true, | 82 bool bIncludeOrExclude, |
115 bool bSimpleFileSpec = false) const; | 83 bool bSimpleFileSpec) const; |
116 FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); | |
117 | 84 |
118 bool ResetForm(const std::vector<CPDF_FormField*>& fields, | 85 bool ResetForm(const std::vector<CPDF_FormField*>& fields, |
119 bool bIncludeOrExclude = true, | 86 bool bIncludeOrExclude = true, |
120 bool bNotify = false); | 87 bool bNotify = false); |
121 bool ResetForm(bool bNotify = false); | 88 bool ResetForm(bool bNotify = false); |
122 | 89 |
123 void SetFormNotify(IPDF_FormNotify* pNotify); | 90 void SetFormNotify(IPDF_FormNotify* pNotify); |
124 FX_BOOL HasXFAForm() const; | 91 FX_BOOL HasXFAForm() const; |
125 void FixPageFields(const CPDF_Page* pPage); | 92 void FixPageFields(const CPDF_Page* pPage); |
126 | 93 |
127 private: | 94 private: |
128 friend class CPDF_FormControl; | 95 friend class CPDF_FormControl; |
129 friend class CPDF_FormField; | 96 friend class CPDF_FormField; |
130 | 97 |
131 void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); | 98 void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); |
132 CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name); | |
133 CPDF_FormField* AddTerminalField(CPDF_Dictionary* pFieldDict); | 99 CPDF_FormField* AddTerminalField(CPDF_Dictionary* pFieldDict); |
134 CPDF_FormControl* AddControl(CPDF_FormField* pField, | 100 CPDF_FormControl* AddControl(CPDF_FormField* pField, |
135 CPDF_Dictionary* pWidgetDict); | 101 CPDF_Dictionary* pWidgetDict); |
136 void FDF_ImportField(CPDF_Dictionary* pField, | 102 void FDF_ImportField(CPDF_Dictionary* pField, |
137 const CFX_WideString& parent_name, | 103 const CFX_WideString& parent_name, |
138 FX_BOOL bNotify = FALSE, | 104 FX_BOOL bNotify = FALSE, |
139 int nLevel = 0); | 105 int nLevel = 0); |
140 FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, | 106 FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, |
141 int iType, | 107 int iType, |
142 const CPDF_FormField* pExcludedField, | 108 const CPDF_FormField* pExcludedField, |
143 const CPDF_FormControl* pExcludedControl); | 109 const CPDF_FormControl* pExcludedControl); |
144 int CompareFieldName(const CFX_WideString& name1, | 110 int CompareFieldName(const CFX_WideString& name1, |
145 const CFX_WideString& name2); | 111 const CFX_WideString& name2); |
146 int CompareFieldName(const CFX_ByteString& name1, | |
147 const CFX_ByteString& name2); | |
148 | 112 |
149 static FX_BOOL s_bUpdateAP; | 113 static bool s_bUpdateAP; |
150 | 114 |
151 CPDF_Document* const m_pDocument; | 115 CPDF_Document* const m_pDocument; |
152 CPDF_Dictionary* m_pFormDict; | 116 CPDF_Dictionary* m_pFormDict; |
153 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; | 117 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; |
154 std::unique_ptr<CFieldTree> m_pFieldTree; | 118 std::unique_ptr<CFieldTree> m_pFieldTree; |
155 CFX_ByteString m_bsEncoding; | 119 CFX_ByteString m_bsEncoding; |
156 IPDF_FormNotify* m_pFormNotify; | 120 IPDF_FormNotify* m_pFormNotify; |
157 }; | 121 }; |
158 | 122 |
159 #endif // CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ | 123 #endif // CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ |
OLD | NEW |