OLD | NEW |
| (Empty) |
1 // Copyright 2016 PDFium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
6 | |
7 #ifndef CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ | |
8 #define CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ | |
9 | |
10 #include <map> | |
11 #include <memory> | |
12 #include <vector> | |
13 | |
14 #include "core/fpdfapi/fpdf_parser/fpdf_parser_decode.h" | |
15 #include "core/fpdfdoc/include/cpdf_defaultappearance.h" | |
16 #include "core/fxcrt/include/fx_string.h" | |
17 #include "core/fxcrt/include/fx_system.h" | |
18 | |
19 class CFieldTree; | |
20 class CFDF_Document; | |
21 class CPDF_Document; | |
22 class CPDF_Dictionary; | |
23 class CPDF_Font; | |
24 class CPDF_FormControl; | |
25 class CPDF_FormField; | |
26 class CPDF_Object; | |
27 class CPDF_Page; | |
28 class IPDF_FormNotify; | |
29 | |
30 CPDF_Font* AddNativeInterFormFont(CPDF_Dictionary*& pFormDict, | |
31 CPDF_Document* pDocument, | |
32 CFX_ByteString& csNameTag); | |
33 | |
34 class CPDF_InterForm { | |
35 public: | |
36 explicit CPDF_InterForm(CPDF_Document* pDocument); | |
37 ~CPDF_InterForm(); | |
38 | |
39 static void SetUpdateAP(bool bUpdateAP); | |
40 static bool IsUpdateAPEnabled(); | |
41 static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, | |
42 const FX_CHAR* csType, | |
43 int iMinLen, | |
44 const FX_CHAR* csPrefix); | |
45 static CPDF_Font* AddStandardFont(CPDF_Document* pDocument, | |
46 CFX_ByteString csFontName); | |
47 static CFX_ByteString GetNativeFont(uint8_t iCharSet, void* pLogFont); | |
48 static uint8_t GetNativeCharSet(); | |
49 static CPDF_Font* AddNativeFont(uint8_t iCharSet, CPDF_Document* pDocument); | |
50 static CPDF_Font* AddNativeFont(CPDF_Document* pDocument); | |
51 | |
52 size_t CountFields(const CFX_WideString& csFieldName) const; | |
53 CPDF_FormField* GetField(uint32_t index, | |
54 const CFX_WideString& csFieldName) const; | |
55 CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; | |
56 | |
57 CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, | |
58 FX_FLOAT pdf_x, | |
59 FX_FLOAT pdf_y, | |
60 int* z_order) const; | |
61 CPDF_FormControl* GetControlByDict(const CPDF_Dictionary* pWidgetDict) const; | |
62 | |
63 FX_BOOL NeedConstructAP() const; | |
64 int CountFieldsInCalculationOrder(); | |
65 CPDF_FormField* GetFieldInCalculationOrder(int index); | |
66 int FindFieldInCalculationOrder(const CPDF_FormField* pField); | |
67 | |
68 CPDF_Font* GetFormFont(CFX_ByteString csNameTag); | |
69 CPDF_DefaultAppearance GetDefaultAppearance() const; | |
70 int GetFormAlignment() const; | |
71 | |
72 CPDF_FormField* CheckRequiredFields( | |
73 const std::vector<CPDF_FormField*>* fields, | |
74 bool bIncludeOrExclude) const; | |
75 | |
76 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, | |
77 bool bSimpleFileSpec) const; | |
78 CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, | |
79 const std::vector<CPDF_FormField*>& fields, | |
80 bool bIncludeOrExclude, | |
81 bool bSimpleFileSpec) const; | |
82 | |
83 bool ResetForm(const std::vector<CPDF_FormField*>& fields, | |
84 bool bIncludeOrExclude, | |
85 bool bNotify); | |
86 bool ResetForm(bool bNotify); | |
87 | |
88 void SetFormNotify(IPDF_FormNotify* pNotify); | |
89 FX_BOOL HasXFAForm() const; | |
90 void FixPageFields(const CPDF_Page* pPage); | |
91 | |
92 private: | |
93 friend class CPDF_FormControl; | |
94 friend class CPDF_FormField; | |
95 | |
96 void LoadField(CPDF_Dictionary* pFieldDict, int nLevel); | |
97 CPDF_FormField* AddTerminalField(CPDF_Dictionary* pFieldDict); | |
98 CPDF_FormControl* AddControl(CPDF_FormField* pField, | |
99 CPDF_Dictionary* pWidgetDict); | |
100 void FDF_ImportField(CPDF_Dictionary* pField, | |
101 const CFX_WideString& parent_name, | |
102 FX_BOOL bNotify = FALSE, | |
103 int nLevel = 0); | |
104 bool ValidateFieldName(CFX_WideString& csNewFieldName, | |
105 int iType, | |
106 const CPDF_FormField* pExcludedField, | |
107 const CPDF_FormControl* pExcludedControl) const; | |
108 | |
109 static bool s_bUpdateAP; | |
110 | |
111 CPDF_Document* const m_pDocument; | |
112 CPDF_Dictionary* m_pFormDict; | |
113 std::map<const CPDF_Dictionary*, CPDF_FormControl*> m_ControlMap; | |
114 std::unique_ptr<CFieldTree> m_pFieldTree; | |
115 CFX_ByteString m_bsEncoding; | |
116 IPDF_FormNotify* m_pFormNotify; | |
117 }; | |
118 | |
119 #endif // CORE_FPDFDOC_INCLUDE_CPDF_INTERFORM_H_ | |
OLD | NEW |