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 #include "../../include/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
8 #include "doc_utils.h" | 8 #include "doc_utils.h" |
9 | 9 |
10 const int nMaxRecursion = 32; | 10 const int nMaxRecursion = 32; |
11 | 11 |
12 class _CFieldNameExtractor { | 12 class CFieldNameExtractor { |
13 public: | 13 public: |
14 _CFieldNameExtractor(const CFX_WideString& full_name) { | 14 explicit CFieldNameExtractor(const CFX_WideString& full_name) { |
15 m_pStart = full_name.c_str(); | 15 m_pStart = full_name.c_str(); |
16 m_pEnd = m_pStart + full_name.GetLength(); | 16 m_pEnd = m_pStart + full_name.GetLength(); |
17 m_pCur = m_pStart; | 17 m_pCur = m_pStart; |
18 } | 18 } |
19 void GetNext(const FX_WCHAR*& pSubName, FX_STRSIZE& size) { | 19 void GetNext(const FX_WCHAR*& pSubName, FX_STRSIZE& size) { |
20 pSubName = m_pCur; | 20 pSubName = m_pCur; |
21 while (m_pCur < m_pEnd && m_pCur[0] != L'.') { | 21 while (m_pCur < m_pEnd && m_pCur[0] != L'.') { |
22 m_pCur++; | 22 m_pCur++; |
23 } | 23 } |
24 size = (FX_STRSIZE)(m_pCur - pSubName); | 24 size = (FX_STRSIZE)(m_pCur - pSubName); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
144 for (int i = 0; i < ptr_array.GetSize(); i++) { | 144 for (int i = 0; i < ptr_array.GetSize(); i++) { |
145 _Node* pNode = (_Node*)ptr_array[i]; | 145 _Node* pNode = (_Node*)ptr_array[i]; |
146 RemoveNode(pNode); | 146 RemoveNode(pNode); |
147 } | 147 } |
148 } | 148 } |
149 void CFieldTree::SetField(const CFX_WideString& full_name, | 149 void CFieldTree::SetField(const CFX_WideString& full_name, |
150 CPDF_FormField* field_ptr) { | 150 CPDF_FormField* field_ptr) { |
151 if (full_name == L"") { | 151 if (full_name == L"") { |
152 return; | 152 return; |
153 } | 153 } |
154 _CFieldNameExtractor name_extractor(full_name); | 154 CFieldNameExtractor name_extractor(full_name); |
155 const FX_WCHAR* pName; | 155 const FX_WCHAR* pName; |
156 FX_STRSIZE nLength; | 156 FX_STRSIZE nLength; |
157 name_extractor.GetNext(pName, nLength); | 157 name_extractor.GetNext(pName, nLength); |
158 _Node *pNode = &m_Root, *pLast = NULL; | 158 _Node *pNode = &m_Root, *pLast = NULL; |
159 while (nLength > 0) { | 159 while (nLength > 0) { |
160 pLast = pNode; | 160 pLast = pNode; |
161 CFX_WideString name = CFX_WideString(pName, nLength); | 161 CFX_WideString name = CFX_WideString(pName, nLength); |
162 pNode = _Lookup(pLast, name); | 162 pNode = _Lookup(pLast, name); |
163 if (pNode == NULL) { | 163 if (pNode == NULL) { |
164 pNode = AddChild(pLast, name, NULL); | 164 pNode = AddChild(pLast, name, NULL); |
165 } | 165 } |
166 name_extractor.GetNext(pName, nLength); | 166 name_extractor.GetNext(pName, nLength); |
167 } | 167 } |
168 if (pNode != &m_Root) { | 168 if (pNode != &m_Root) { |
169 pNode->field_ptr = field_ptr; | 169 pNode->field_ptr = field_ptr; |
170 } | 170 } |
171 } | 171 } |
172 CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) { | 172 CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) { |
173 if (full_name == L"") { | 173 if (full_name == L"") { |
174 return NULL; | 174 return NULL; |
175 } | 175 } |
176 _CFieldNameExtractor name_extractor(full_name); | 176 CFieldNameExtractor name_extractor(full_name); |
177 const FX_WCHAR* pName; | 177 const FX_WCHAR* pName; |
178 FX_STRSIZE nLength; | 178 FX_STRSIZE nLength; |
179 name_extractor.GetNext(pName, nLength); | 179 name_extractor.GetNext(pName, nLength); |
180 _Node *pNode = &m_Root, *pLast = NULL; | 180 _Node *pNode = &m_Root, *pLast = NULL; |
181 while (nLength > 0 && pNode) { | 181 while (nLength > 0 && pNode) { |
182 pLast = pNode; | 182 pLast = pNode; |
183 CFX_WideString name = CFX_WideString(pName, nLength); | 183 CFX_WideString name = CFX_WideString(pName, nLength); |
184 pNode = _Lookup(pLast, name); | 184 pNode = _Lookup(pLast, name); |
185 name_extractor.GetNext(pName, nLength); | 185 name_extractor.GetNext(pName, nLength); |
186 } | 186 } |
187 return pNode ? pNode->field_ptr : NULL; | 187 return pNode ? pNode->field_ptr : NULL; |
188 } | 188 } |
189 CPDF_FormField* CFieldTree::RemoveField(const CFX_WideString& full_name) { | 189 CPDF_FormField* CFieldTree::RemoveField(const CFX_WideString& full_name) { |
190 if (full_name == L"") { | 190 if (full_name == L"") { |
191 return NULL; | 191 return NULL; |
192 } | 192 } |
193 _CFieldNameExtractor name_extractor(full_name); | 193 CFieldNameExtractor name_extractor(full_name); |
194 const FX_WCHAR* pName; | 194 const FX_WCHAR* pName; |
195 FX_STRSIZE nLength; | 195 FX_STRSIZE nLength; |
196 name_extractor.GetNext(pName, nLength); | 196 name_extractor.GetNext(pName, nLength); |
197 _Node *pNode = &m_Root, *pLast = NULL; | 197 _Node *pNode = &m_Root, *pLast = NULL; |
198 while (nLength > 0 && pNode) { | 198 while (nLength > 0 && pNode) { |
199 pLast = pNode; | 199 pLast = pNode; |
200 CFX_WideString name = CFX_WideString(pName, nLength); | 200 CFX_WideString name = CFX_WideString(pName, nLength); |
201 pNode = _Lookup(pLast, name); | 201 pNode = _Lookup(pLast, name); |
202 name_extractor.GetNext(pName, nLength); | 202 name_extractor.GetNext(pName, nLength); |
203 } | 203 } |
204 if (pNode && pNode != &m_Root) { | 204 if (pNode && pNode != &m_Root) { |
205 CFX_PtrArray& ptr_array = pLast->children; | 205 CFX_PtrArray& ptr_array = pLast->children; |
206 for (int i = 0; i < ptr_array.GetSize(); i++) { | 206 for (int i = 0; i < ptr_array.GetSize(); i++) { |
207 if (pNode == (_Node*)ptr_array[i]) { | 207 if (pNode == (_Node*)ptr_array[i]) { |
208 ptr_array.RemoveAt(i); | 208 ptr_array.RemoveAt(i); |
209 break; | 209 break; |
210 } | 210 } |
211 } | 211 } |
212 CPDF_FormField* pField = pNode->field_ptr; | 212 CPDF_FormField* pField = pNode->field_ptr; |
213 RemoveNode(pNode); | 213 RemoveNode(pNode); |
214 return pField; | 214 return pField; |
215 } | 215 } |
216 return NULL; | 216 return NULL; |
217 } | 217 } |
218 CFieldTree::_Node* CFieldTree::FindNode(const CFX_WideString& full_name) { | 218 CFieldTree::_Node* CFieldTree::FindNode(const CFX_WideString& full_name) { |
219 if (full_name == L"") { | 219 if (full_name == L"") { |
220 return NULL; | 220 return NULL; |
221 } | 221 } |
222 _CFieldNameExtractor name_extractor(full_name); | 222 CFieldNameExtractor name_extractor(full_name); |
223 const FX_WCHAR* pName; | 223 const FX_WCHAR* pName; |
224 FX_STRSIZE nLength; | 224 FX_STRSIZE nLength; |
225 name_extractor.GetNext(pName, nLength); | 225 name_extractor.GetNext(pName, nLength); |
226 _Node *pNode = &m_Root, *pLast = NULL; | 226 _Node *pNode = &m_Root, *pLast = NULL; |
227 while (nLength > 0 && pNode) { | 227 while (nLength > 0 && pNode) { |
228 pLast = pNode; | 228 pLast = pNode; |
229 CFX_WideString name = CFX_WideString(pName, nLength); | 229 CFX_WideString name = CFX_WideString(pName, nLength); |
230 pNode = _Lookup(pLast, name); | 230 pNode = _Lookup(pLast, name); |
231 name_extractor.GetNext(pName, nLength); | 231 name_extractor.GetNext(pName, nLength); |
232 } | 232 } |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
758 allFieldNames.RemoveAll(); | 758 allFieldNames.RemoveAll(); |
759 int nCount = m_pFieldTree->m_Root.CountFields(); | 759 int nCount = m_pFieldTree->m_Root.CountFields(); |
760 for (int i = 0; i < nCount; i++) { | 760 for (int i = 0; i < nCount; i++) { |
761 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 761 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
762 if (pField) { | 762 if (pField) { |
763 CFX_WideString full_name = GetFullName(pField->GetFieldDict()); | 763 CFX_WideString full_name = GetFullName(pField->GetFieldDict()); |
764 allFieldNames.Add(full_name); | 764 allFieldNames.Add(full_name); |
765 } | 765 } |
766 } | 766 } |
767 } | 767 } |
768 FX_BOOL CPDF_InterForm::IsValidFormField(const void* pField) { | 768 |
769 if (pField == NULL) { | |
770 return FALSE; | |
771 } | |
772 int nCount = m_pFieldTree->m_Root.CountFields(); | |
773 for (int i = 0; i < nCount; i++) { | |
774 CPDF_FormField* pFormField = m_pFieldTree->m_Root.GetField(i); | |
775 if (pField == pFormField) { | |
776 return TRUE; | |
777 } | |
778 } | |
779 return FALSE; | |
780 } | |
781 CPDF_FormField* CPDF_InterForm::GetFieldByDict( | 769 CPDF_FormField* CPDF_InterForm::GetFieldByDict( |
782 CPDF_Dictionary* pFieldDict) const { | 770 CPDF_Dictionary* pFieldDict) const { |
783 if (pFieldDict == NULL) { | 771 if (pFieldDict == NULL) { |
784 return NULL; | 772 return NULL; |
785 } | 773 } |
786 CFX_WideString csWName = GetFullName(pFieldDict); | 774 CFX_WideString csWName = GetFullName(pFieldDict); |
787 return m_pFieldTree->GetField(csWName); | 775 return m_pFieldTree->GetField(csWName); |
788 } | 776 } |
789 | 777 |
790 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, | 778 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 } | 927 } |
940 CPDF_Font* CPDF_InterForm::GetDefaultFormFont() { | 928 CPDF_Font* CPDF_InterForm::GetDefaultFormFont() { |
941 return GetDefaultInterFormFont(m_pFormDict, m_pDocument); | 929 return GetDefaultInterFormFont(m_pFormDict, m_pDocument); |
942 } | 930 } |
943 int CPDF_InterForm::GetFormAlignment() { | 931 int CPDF_InterForm::GetFormAlignment() { |
944 if (m_pFormDict == NULL) { | 932 if (m_pFormDict == NULL) { |
945 return 0; | 933 return 0; |
946 } | 934 } |
947 return m_pFormDict->GetInteger("Q", 0); | 935 return m_pFormDict->GetInteger("Q", 0); |
948 } | 936 } |
949 FX_BOOL CPDF_InterForm::ResetForm(const CFX_PtrArray& fields, | 937 |
950 FX_BOOL bIncludeOrExclude, | 938 bool CPDF_InterForm::ResetForm(const std::vector<CPDF_FormField*>& fields, |
951 FX_BOOL bNotify) { | 939 bool bIncludeOrExclude, |
952 if (bNotify && m_pFormNotify != NULL) { | 940 bool bNotify) { |
941 if (bNotify && m_pFormNotify) { | |
942 int iRet = m_pFormNotify->BeforeFormReset(this); | |
Tom Sepez
2015/11/09 21:25:31
nit: local not needed. This returns an int, right
Lei Zhang
2015/11/09 22:45:28
Done.
| |
943 if (iRet < 0) { | |
944 return false; | |
945 } | |
946 } | |
947 int nCount = m_pFieldTree->m_Root.CountFields(); | |
948 for (int i = 0; i < nCount; ++i) { | |
949 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | |
950 if (!pField) | |
951 continue; | |
952 | |
953 auto it = std::find(fields.begin(), fields.end(), pField); | |
954 if (bIncludeOrExclude == (it != fields.end())) | |
955 pField->ResetField(bNotify); | |
956 } | |
957 if (bNotify && m_pFormNotify) | |
958 m_pFormNotify->AfterFormReset(this); | |
959 return true; | |
960 } | |
961 | |
962 bool CPDF_InterForm::ResetForm(bool bNotify) { | |
963 if (bNotify && m_pFormNotify) { | |
953 int iRet = m_pFormNotify->BeforeFormReset(this); | 964 int iRet = m_pFormNotify->BeforeFormReset(this); |
Tom Sepez
2015/11/09 21:25:31
ditto
Lei Zhang
2015/11/09 22:45:28
Done. return false, even.
| |
954 if (iRet < 0) { | 965 if (iRet < 0) { |
955 return FALSE; | 966 return FALSE; |
956 } | 967 } |
957 } | 968 } |
958 int nCount = m_pFieldTree->m_Root.CountFields(); | 969 int nCount = m_pFieldTree->m_Root.CountFields(); |
959 for (int i = 0; i < nCount; i++) { | 970 for (int i = 0; i < nCount; ++i) { |
960 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 971 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
961 if (pField == NULL) { | 972 if (!pField) |
962 continue; | 973 continue; |
963 } | 974 |
964 FX_BOOL bFind = FALSE; | |
965 int iCount = fields.GetSize(); | |
966 for (int i = 0; i < iCount; i++) { | |
967 if (pField == (CPDF_FormField*)fields[i]) { | |
968 bFind = TRUE; | |
969 break; | |
970 } | |
971 } | |
972 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { | |
973 pField->ResetField(bNotify); | |
974 } | |
975 } | |
976 if (bNotify && m_pFormNotify != NULL) { | |
977 m_pFormNotify->AfterFormReset(this); | |
978 } | |
979 return TRUE; | |
980 } | |
981 FX_BOOL CPDF_InterForm::ResetForm(FX_BOOL bNotify) { | |
982 if (bNotify && m_pFormNotify != NULL) { | |
983 int iRet = m_pFormNotify->BeforeFormReset(this); | |
984 if (iRet < 0) { | |
985 return FALSE; | |
986 } | |
987 } | |
988 int nCount = m_pFieldTree->m_Root.CountFields(); | |
989 for (int i = 0; i < nCount; i++) { | |
990 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | |
991 if (pField == NULL) { | |
992 continue; | |
993 } | |
994 pField->ResetField(bNotify); | 975 pField->ResetField(bNotify); |
995 } | 976 } |
996 if (bNotify && m_pFormNotify != NULL) { | 977 if (bNotify && m_pFormNotify) |
997 m_pFormNotify->AfterFormReset(this); | 978 m_pFormNotify->AfterFormReset(this); |
998 } | 979 return true; |
999 return TRUE; | |
1000 } | 980 } |
981 | |
1001 void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { | 982 void CPDF_InterForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) { |
1002 if (nLevel > nMaxRecursion) { | 983 if (nLevel > nMaxRecursion) { |
1003 return; | 984 return; |
1004 } | 985 } |
1005 if (pFieldDict == NULL) { | 986 if (pFieldDict == NULL) { |
1006 return; | 987 return; |
1007 } | 988 } |
1008 FX_DWORD dwParentObjNum = pFieldDict->GetObjNum(); | 989 FX_DWORD dwParentObjNum = pFieldDict->GetObjNum(); |
1009 CPDF_Array* pKids = pFieldDict->GetArray("Kids"); | 990 CPDF_Array* pKids = pFieldDict->GetArray("Kids"); |
1010 if (!pKids) { | 991 if (!pKids) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1119 const auto it = m_ControlMap.find(pWidgetDict); | 1100 const auto it = m_ControlMap.find(pWidgetDict); |
1120 if (it != m_ControlMap.end()) | 1101 if (it != m_ControlMap.end()) |
1121 return it->second; | 1102 return it->second; |
1122 | 1103 |
1123 CPDF_FormControl* pControl = | 1104 CPDF_FormControl* pControl = |
1124 new CPDF_FormControl((CPDF_FormField*)pField, pWidgetDict); | 1105 new CPDF_FormControl((CPDF_FormField*)pField, pWidgetDict); |
1125 m_ControlMap[pWidgetDict] = pControl; | 1106 m_ControlMap[pWidgetDict] = pControl; |
1126 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl); | 1107 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl); |
1127 return pControl; | 1108 return pControl; |
1128 } | 1109 } |
1110 | |
1129 CPDF_FormField* CPDF_InterForm::CheckRequiredFields( | 1111 CPDF_FormField* CPDF_InterForm::CheckRequiredFields( |
1130 const CFX_PtrArray* fields, | 1112 const std::vector<CPDF_FormField*>* fields, |
1131 FX_BOOL bIncludeOrExclude) const { | 1113 FX_BOOL bIncludeOrExclude) const { |
1132 int nCount = m_pFieldTree->m_Root.CountFields(); | 1114 int nCount = m_pFieldTree->m_Root.CountFields(); |
1133 for (int i = 0; i < nCount; i++) { | 1115 for (int i = 0; i < nCount; ++i) { |
1134 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 1116 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
1135 if (pField == NULL) { | 1117 if (!pField) |
1136 continue; | 1118 continue; |
1137 } | 1119 |
1138 int32_t iType = pField->GetType(); | 1120 int32_t iType = pField->GetType(); |
1139 if (iType == CPDF_FormField::PushButton || | 1121 if (iType == CPDF_FormField::PushButton || |
1140 iType == CPDF_FormField::CheckBox || iType == CPDF_FormField::ListBox) { | 1122 iType == CPDF_FormField::CheckBox || iType == CPDF_FormField::ListBox) { |
1141 continue; | 1123 continue; |
1142 } | 1124 } |
1143 FX_DWORD dwFlags = pField->GetFieldFlags(); | 1125 FX_DWORD dwFlags = pField->GetFieldFlags(); |
1144 if (dwFlags & 0x04) { | 1126 if (dwFlags & 0x04) |
Tom Sepez
2015/11/09 21:25:31
nit: magic number.
Lei Zhang
2015/11/09 22:45:28
Added a TODO.
| |
1145 continue; | 1127 continue; |
1128 | |
1129 bool bFind = true; | |
1130 if (fields) { | |
1131 auto it = std::find(fields->begin(), fields->end(), pField); | |
1132 bFind = (it != fields->end()); | |
1146 } | 1133 } |
1147 FX_BOOL bFind = TRUE; | 1134 if (bIncludeOrExclude == bFind) { |
1148 if (fields != NULL) { | |
1149 bFind = fields->Find(pField, 0) >= 0; | |
1150 } | |
1151 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { | |
1152 CPDF_Dictionary* pFieldDict = pField->m_pDict; | 1135 CPDF_Dictionary* pFieldDict = pField->m_pDict; |
1153 if ((dwFlags & 0x02) != 0 && pFieldDict->GetString("V").IsEmpty()) { | 1136 if ((dwFlags & 0x02) != 0 && pFieldDict->GetString("V").IsEmpty()) { |
1154 return pField; | 1137 return pField; |
1155 } | 1138 } |
1156 } | 1139 } |
1157 } | 1140 } |
1158 return NULL; | 1141 return nullptr; |
1159 } | 1142 } |
1143 | |
1160 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, | 1144 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, |
1161 FX_BOOL bSimpleFileSpec) const { | 1145 bool bSimpleFileSpec) const { |
1162 CFX_PtrArray fields; | 1146 std::vector<CPDF_FormField*> fields; |
1163 int nCount = m_pFieldTree->m_Root.CountFields(); | 1147 int nCount = m_pFieldTree->m_Root.CountFields(); |
1164 for (int i = 0; i < nCount; i++) { | 1148 for (int i = 0; i < nCount; ++i) { |
1165 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 1149 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
Tom Sepez
2015/11/09 21:25:31
nit: local not needed.
Lei Zhang
2015/11/09 22:45:28
Done.
| |
1166 fields.Add(pField); | 1150 fields.push_back(pField); |
1167 } | 1151 } |
1168 return ExportToFDF(pdf_path, fields, TRUE, bSimpleFileSpec); | 1152 return ExportToFDF(pdf_path, fields, true, bSimpleFileSpec); |
1169 } | 1153 } |
1154 | |
1155 // TODO(thestig): Fix this. | |
Tom Sepez
2015/11/09 21:25:31
nit: by fix this, you mean "move to header"?
Lei Zhang
2015/11/09 22:45:28
Yes, another day.
| |
1170 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath); | 1156 CFX_WideString FILESPEC_EncodeFileName(const CFX_WideStringC& filepath); |
1171 CFDF_Document* CPDF_InterForm::ExportToFDF(const CFX_WideStringC& pdf_path, | 1157 |
1172 CFX_PtrArray& fields, | 1158 CFDF_Document* CPDF_InterForm::ExportToFDF( |
1173 FX_BOOL bIncludeOrExclude, | 1159 const CFX_WideStringC& pdf_path, |
1174 FX_BOOL bSimpleFileSpec) const { | 1160 const std::vector<CPDF_FormField*>& fields, |
1161 bool bIncludeOrExclude, | |
1162 bool bSimpleFileSpec) const { | |
1175 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); | 1163 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); |
1176 if (pDoc == NULL) { | 1164 if (pDoc == NULL) { |
1177 return NULL; | 1165 return NULL; |
1178 } | 1166 } |
1179 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF"); | 1167 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDict("FDF"); |
1180 if (!pdf_path.IsEmpty()) { | 1168 if (!pdf_path.IsEmpty()) { |
1181 if (bSimpleFileSpec) { | 1169 if (bSimpleFileSpec) { |
1182 CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path); | 1170 CFX_WideString wsFilePath = FILESPEC_EncodeFileName(pdf_path); |
1183 pMainDict->SetAtString(FX_BSTRC("F"), | 1171 pMainDict->SetAtString(FX_BSTRC("F"), |
1184 CFX_ByteString::FromUnicode(wsFilePath)); | 1172 CFX_ByteString::FromUnicode(wsFilePath)); |
(...skipping 12 matching lines...) Expand all Loading... | |
1197 int nCount = m_pFieldTree->m_Root.CountFields(); | 1185 int nCount = m_pFieldTree->m_Root.CountFields(); |
1198 for (int i = 0; i < nCount; i++) { | 1186 for (int i = 0; i < nCount; i++) { |
1199 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); | 1187 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); |
1200 if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) { | 1188 if (pField == NULL || pField->GetType() == CPDF_FormField::PushButton) { |
1201 continue; | 1189 continue; |
1202 } | 1190 } |
1203 FX_DWORD dwFlags = pField->GetFieldFlags(); | 1191 FX_DWORD dwFlags = pField->GetFieldFlags(); |
1204 if (dwFlags & 0x04) { | 1192 if (dwFlags & 0x04) { |
1205 continue; | 1193 continue; |
1206 } | 1194 } |
1207 FX_BOOL bFind = fields.Find(pField, 0) >= 0; | 1195 auto it = std::find(fields.begin(), fields.end(), pField); |
1208 if ((bIncludeOrExclude && bFind) || (!bIncludeOrExclude && !bFind)) { | 1196 if (bIncludeOrExclude == (it != fields.end())) { |
1209 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty()) { | 1197 if ((dwFlags & 0x02) != 0 && pField->m_pDict->GetString("V").IsEmpty()) { |
Tom Sepez
2015/11/09 21:25:31
nit: magic number.
Lei Zhang
2015/11/09 22:45:28
Acknowledged.
| |
1210 continue; | 1198 continue; |
1211 } | 1199 } |
1212 CFX_WideString fullname = GetFullName(pField->GetFieldDict()); | 1200 CFX_WideString fullname = GetFullName(pField->GetFieldDict()); |
1213 CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create(); | 1201 CPDF_Dictionary* pFieldDict = CPDF_Dictionary::Create(); |
1214 if (pFieldDict == NULL) { | 1202 if (pFieldDict == NULL) { |
1215 return NULL; | 1203 return NULL; |
1216 } | 1204 } |
1217 CPDF_String* pString = CPDF_String::Create(fullname); | 1205 CPDF_String* pString = CPDF_String::Create(fullname); |
1218 if (pString == NULL) { | 1206 if (pString == NULL) { |
1219 pFieldDict->Release(); | 1207 pFieldDict->Release(); |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1370 FDF_ImportField(pField, L"", bNotify); | 1358 FDF_ImportField(pField, L"", bNotify); |
1371 } | 1359 } |
1372 if (bNotify && m_pFormNotify != NULL) { | 1360 if (bNotify && m_pFormNotify != NULL) { |
1373 m_pFormNotify->AfterFormImportData(this); | 1361 m_pFormNotify->AfterFormImportData(this); |
1374 } | 1362 } |
1375 return TRUE; | 1363 return TRUE; |
1376 } | 1364 } |
1377 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) { | 1365 void CPDF_InterForm::SetFormNotify(const CPDF_FormNotify* pNotify) { |
1378 m_pFormNotify = (CPDF_FormNotify*)pNotify; | 1366 m_pFormNotify = (CPDF_FormNotify*)pNotify; |
1379 } | 1367 } |
OLD | NEW |