Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Side by Side Diff: core/fpdfdoc/doc_form.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix a bad merge Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/doc_basic.cpp ('k') | core/fpdfdoc/doc_tagged.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h" 9 #include "core/fpdfapi/fpdf_font/include/cpdf_fontencoding.h"
10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 count += children.GetAt(i)->CountFields(nLevel + 1); 90 count += children.GetAt(i)->CountFields(nLevel + 1);
91 } 91 }
92 return count; 92 return count;
93 } 93 }
94 CPDF_FormField* GetField(int* fields_to_go) { 94 CPDF_FormField* GetField(int* fields_to_go) {
95 if (field_ptr) { 95 if (field_ptr) {
96 if (*fields_to_go == 0) { 96 if (*fields_to_go == 0) {
97 return field_ptr; 97 return field_ptr;
98 } 98 }
99 --*fields_to_go; 99 --*fields_to_go;
100 return NULL; 100 return nullptr;
101 } 101 }
102 for (int i = 0; i < children.GetSize(); i++) { 102 for (int i = 0; i < children.GetSize(); i++) {
103 if (CPDF_FormField* pField = children.GetAt(i)->GetField(fields_to_go)) 103 if (CPDF_FormField* pField = children.GetAt(i)->GetField(fields_to_go))
104 return pField; 104 return pField;
105 } 105 }
106 return NULL; 106 return nullptr;
107 } 107 }
108 CPDF_FormField* GetField(int index) { 108 CPDF_FormField* GetField(int index) {
109 int fields_to_go = index; 109 int fields_to_go = index;
110 return GetField(&fields_to_go); 110 return GetField(&fields_to_go);
111 } 111 }
112 }; 112 };
113 CFieldTree(); 113 CFieldTree();
114 ~CFieldTree(); 114 ~CFieldTree();
115 void SetField(const CFX_WideString& full_name, CPDF_FormField* field_ptr); 115 void SetField(const CFX_WideString& full_name, CPDF_FormField* field_ptr);
116 CPDF_FormField* GetField(const CFX_WideString& full_name); 116 CPDF_FormField* GetField(const CFX_WideString& full_name);
117 CPDF_FormField* RemoveField(const CFX_WideString& full_name); 117 CPDF_FormField* RemoveField(const CFX_WideString& full_name);
118 void RemoveAll(); 118 void RemoveAll();
119 _Node* FindNode(const CFX_WideString& full_name); 119 _Node* FindNode(const CFX_WideString& full_name);
120 _Node* AddChild(_Node* pParent, 120 _Node* AddChild(_Node* pParent,
121 const CFX_WideString& short_name, 121 const CFX_WideString& short_name,
122 CPDF_FormField* field_ptr); 122 CPDF_FormField* field_ptr);
123 void RemoveNode(_Node* pNode, int nLevel = 0); 123 void RemoveNode(_Node* pNode, int nLevel = 0);
124 _Node* _Lookup(_Node* pParent, const CFX_WideString& short_name); 124 _Node* _Lookup(_Node* pParent, const CFX_WideString& short_name);
125 _Node m_Root; 125 _Node m_Root;
126 }; 126 };
127 CFieldTree::CFieldTree() { 127 CFieldTree::CFieldTree() {
128 m_Root.parent = NULL; 128 m_Root.parent = nullptr;
129 m_Root.field_ptr = NULL; 129 m_Root.field_ptr = nullptr;
130 } 130 }
131 CFieldTree::~CFieldTree() { 131 CFieldTree::~CFieldTree() {
132 RemoveAll(); 132 RemoveAll();
133 } 133 }
134 CFieldTree::_Node* CFieldTree::AddChild(_Node* pParent, 134 CFieldTree::_Node* CFieldTree::AddChild(_Node* pParent,
135 const CFX_WideString& short_name, 135 const CFX_WideString& short_name,
136 CPDF_FormField* field_ptr) { 136 CPDF_FormField* field_ptr) {
137 if (!pParent) { 137 if (!pParent) {
138 return NULL; 138 return nullptr;
139 } 139 }
140 _Node* pNode = new _Node; 140 _Node* pNode = new _Node;
141 pNode->parent = pParent; 141 pNode->parent = pParent;
142 pNode->short_name = short_name; 142 pNode->short_name = short_name;
143 pNode->field_ptr = field_ptr; 143 pNode->field_ptr = field_ptr;
144 pParent->children.Add(pNode); 144 pParent->children.Add(pNode);
145 return pNode; 145 return pNode;
146 } 146 }
147 void CFieldTree::RemoveNode(_Node* pNode, int nLevel) { 147 void CFieldTree::RemoveNode(_Node* pNode, int nLevel) {
148 if (!pNode) { 148 if (!pNode) {
149 return; 149 return;
150 } 150 }
151 if (nLevel <= nMaxRecursion) { 151 if (nLevel <= nMaxRecursion) {
152 for (int i = 0; i < pNode->children.GetSize(); i++) { 152 for (int i = 0; i < pNode->children.GetSize(); i++) {
153 RemoveNode(pNode->children[i], nLevel + 1); 153 RemoveNode(pNode->children[i], nLevel + 1);
154 } 154 }
155 } 155 }
156 delete pNode; 156 delete pNode;
157 } 157 }
158 CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent, 158 CFieldTree::_Node* CFieldTree::_Lookup(_Node* pParent,
159 const CFX_WideString& short_name) { 159 const CFX_WideString& short_name) {
160 if (!pParent) { 160 if (!pParent) {
161 return NULL; 161 return nullptr;
162 } 162 }
163 for (int i = 0; i < pParent->children.GetSize(); i++) { 163 for (int i = 0; i < pParent->children.GetSize(); i++) {
164 _Node* pNode = pParent->children[i]; 164 _Node* pNode = pParent->children[i];
165 if (pNode->short_name.GetLength() == short_name.GetLength() && 165 if (pNode->short_name.GetLength() == short_name.GetLength() &&
166 FXSYS_memcmp(pNode->short_name.c_str(), short_name.c_str(), 166 FXSYS_memcmp(pNode->short_name.c_str(), short_name.c_str(),
167 short_name.GetLength() * sizeof(FX_WCHAR)) == 0) { 167 short_name.GetLength() * sizeof(FX_WCHAR)) == 0) {
168 return pNode; 168 return pNode;
169 } 169 }
170 } 170 }
171 return NULL; 171 return nullptr;
172 } 172 }
173 void CFieldTree::RemoveAll() { 173 void CFieldTree::RemoveAll() {
174 for (int i = 0; i < m_Root.children.GetSize(); i++) { 174 for (int i = 0; i < m_Root.children.GetSize(); i++) {
175 RemoveNode(m_Root.children[i]); 175 RemoveNode(m_Root.children[i]);
176 } 176 }
177 } 177 }
178 void CFieldTree::SetField(const CFX_WideString& full_name, 178 void CFieldTree::SetField(const CFX_WideString& full_name,
179 CPDF_FormField* field_ptr) { 179 CPDF_FormField* field_ptr) {
180 if (full_name == L"") { 180 if (full_name == L"") {
181 return; 181 return;
182 } 182 }
183 CFieldNameExtractor name_extractor(full_name); 183 CFieldNameExtractor name_extractor(full_name);
184 const FX_WCHAR* pName; 184 const FX_WCHAR* pName;
185 FX_STRSIZE nLength; 185 FX_STRSIZE nLength;
186 name_extractor.GetNext(pName, nLength); 186 name_extractor.GetNext(pName, nLength);
187 _Node *pNode = &m_Root, *pLast = NULL; 187 _Node *pNode = &m_Root, *pLast = nullptr;
188 while (nLength > 0) { 188 while (nLength > 0) {
189 pLast = pNode; 189 pLast = pNode;
190 CFX_WideString name = CFX_WideString(pName, nLength); 190 CFX_WideString name = CFX_WideString(pName, nLength);
191 pNode = _Lookup(pLast, name); 191 pNode = _Lookup(pLast, name);
192 if (!pNode) { 192 if (!pNode) {
193 pNode = AddChild(pLast, name, NULL); 193 pNode = AddChild(pLast, name, nullptr);
194 } 194 }
195 name_extractor.GetNext(pName, nLength); 195 name_extractor.GetNext(pName, nLength);
196 } 196 }
197 if (pNode != &m_Root) { 197 if (pNode != &m_Root) {
198 pNode->field_ptr = field_ptr; 198 pNode->field_ptr = field_ptr;
199 } 199 }
200 } 200 }
201 CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) { 201 CPDF_FormField* CFieldTree::GetField(const CFX_WideString& full_name) {
202 if (full_name == L"") { 202 if (full_name == L"") {
203 return NULL; 203 return nullptr;
204 } 204 }
205 CFieldNameExtractor name_extractor(full_name); 205 CFieldNameExtractor name_extractor(full_name);
206 const FX_WCHAR* pName; 206 const FX_WCHAR* pName;
207 FX_STRSIZE nLength; 207 FX_STRSIZE nLength;
208 name_extractor.GetNext(pName, nLength); 208 name_extractor.GetNext(pName, nLength);
209 _Node *pNode = &m_Root, *pLast = NULL; 209 _Node *pNode = &m_Root, *pLast = nullptr;
210 while (nLength > 0 && pNode) { 210 while (nLength > 0 && pNode) {
211 pLast = pNode; 211 pLast = pNode;
212 CFX_WideString name = CFX_WideString(pName, nLength); 212 CFX_WideString name = CFX_WideString(pName, nLength);
213 pNode = _Lookup(pLast, name); 213 pNode = _Lookup(pLast, name);
214 name_extractor.GetNext(pName, nLength); 214 name_extractor.GetNext(pName, nLength);
215 } 215 }
216 return pNode ? pNode->field_ptr : NULL; 216 return pNode ? pNode->field_ptr : nullptr;
217 } 217 }
218 CPDF_FormField* CFieldTree::RemoveField(const CFX_WideString& full_name) { 218 CPDF_FormField* CFieldTree::RemoveField(const CFX_WideString& full_name) {
219 if (full_name == L"") { 219 if (full_name == L"") {
220 return NULL; 220 return nullptr;
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;
227 _Node* pLast = nullptr;
227 while (nLength > 0 && pNode) { 228 while (nLength > 0 && pNode) {
228 pLast = pNode; 229 pLast = pNode;
229 CFX_WideString name = CFX_WideString(pName, nLength); 230 CFX_WideString name = CFX_WideString(pName, nLength);
230 pNode = _Lookup(pLast, name); 231 pNode = _Lookup(pLast, name);
231 name_extractor.GetNext(pName, nLength); 232 name_extractor.GetNext(pName, nLength);
232 } 233 }
233 if (pNode && pNode != &m_Root) { 234 if (pNode && pNode != &m_Root) {
234 for (int i = 0; i < pLast->children.GetSize(); i++) { 235 for (int i = 0; i < pLast->children.GetSize(); i++) {
235 if (pNode == pLast->children[i]) { 236 if (pNode == pLast->children[i]) {
236 pLast->children.RemoveAt(i); 237 pLast->children.RemoveAt(i);
237 break; 238 break;
238 } 239 }
239 } 240 }
240 CPDF_FormField* pField = pNode->field_ptr; 241 CPDF_FormField* pField = pNode->field_ptr;
241 RemoveNode(pNode); 242 RemoveNode(pNode);
242 return pField; 243 return pField;
243 } 244 }
244 return NULL; 245 return nullptr;
245 } 246 }
246 CFieldTree::_Node* CFieldTree::FindNode(const CFX_WideString& full_name) { 247 CFieldTree::_Node* CFieldTree::FindNode(const CFX_WideString& full_name) {
247 if (full_name == L"") { 248 if (full_name == L"") {
248 return NULL; 249 return nullptr;
249 } 250 }
250 CFieldNameExtractor name_extractor(full_name); 251 CFieldNameExtractor name_extractor(full_name);
251 const FX_WCHAR* pName; 252 const FX_WCHAR* pName;
252 FX_STRSIZE nLength; 253 FX_STRSIZE nLength;
253 name_extractor.GetNext(pName, nLength); 254 name_extractor.GetNext(pName, nLength);
254 _Node *pNode = &m_Root, *pLast = NULL; 255 _Node *pNode = &m_Root, *pLast = nullptr;
255 while (nLength > 0 && pNode) { 256 while (nLength > 0 && pNode) {
256 pLast = pNode; 257 pLast = pNode;
257 CFX_WideString name = CFX_WideString(pName, nLength); 258 CFX_WideString name = CFX_WideString(pName, nLength);
258 pNode = _Lookup(pLast, name); 259 pNode = _Lookup(pLast, name);
259 name_extractor.GetNext(pName, nLength); 260 name_extractor.GetNext(pName, nLength);
260 } 261 }
261 return pNode; 262 return pNode;
262 } 263 }
263 264
264 CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument) 265 CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return 1; 369 return 1;
369 } 370 }
370 LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; 371 LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam;
371 memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); 372 memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA));
372 pData->bFind = TRUE; 373 pData->bFind = TRUE;
373 return 0; 374 return 0;
374 } 375 }
375 static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) { 376 static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) {
376 PDF_FONTDATA fd; 377 PDF_FONTDATA fd;
377 memset(&fd, 0, sizeof(PDF_FONTDATA)); 378 memset(&fd, 0, sizeof(PDF_FONTDATA));
378 HDC hDC = ::GetDC(NULL); 379 HDC hDC = ::GetDC(nullptr);
379 EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd, 380 EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd,
380 0); 381 0);
381 ::ReleaseDC(NULL, hDC); 382 ::ReleaseDC(nullptr, hDC);
382 if (fd.bFind) { 383 if (fd.bFind) {
383 memcpy(&lf, &fd.lf, sizeof(LOGFONTA)); 384 memcpy(&lf, &fd.lf, sizeof(LOGFONTA));
384 } 385 }
385 return fd.bFind; 386 return fd.bFind;
386 } 387 }
387 static FX_BOOL RetrieveSpecificFont(uint8_t charSet, 388 static FX_BOOL RetrieveSpecificFont(uint8_t charSet,
388 uint8_t pitchAndFamily, 389 uint8_t pitchAndFamily,
389 LPCSTR pcsFontName, 390 LPCSTR pcsFontName,
390 LOGFONTA& lf) { 391 LOGFONTA& lf) {
391 memset(&lf, 0, sizeof(LOGFONTA)); 392 memset(&lf, 0, sizeof(LOGFONTA));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 434 }
434 if (!bRet) { 435 if (!bRet) {
435 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, 436 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE,
436 "Arial Unicode MS", lf); 437 "Arial Unicode MS", lf);
437 } 438 }
438 if (!bRet) { 439 if (!bRet) {
439 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, 440 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE,
440 "Microsoft Sans Serif", lf); 441 "Microsoft Sans Serif", lf);
441 } 442 }
442 if (!bRet) { 443 if (!bRet) {
443 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, NULL, lf); 444 bRet =
445 RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, nullptr, lf);
444 } 446 }
445 if (bRet) { 447 if (bRet) {
446 if (pLogFont) { 448 if (pLogFont) {
447 memcpy(pLogFont, &lf, sizeof(LOGFONTA)); 449 memcpy(pLogFont, &lf, sizeof(LOGFONTA));
448 } 450 }
449 csFontName = lf.lfFaceName; 451 csFontName = lf.lfFaceName;
450 return csFontName; 452 return csFontName;
451 } 453 }
452 #endif 454 #endif
453 return csFontName; 455 return csFontName;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 608 }
607 } 609 }
608 if (csSub.IsEmpty()) { 610 if (csSub.IsEmpty()) {
609 return FALSE; 611 return FALSE;
610 } 612 }
611 csNewFieldName = csSub; 613 csNewFieldName = csSub;
612 return TRUE; 614 return TRUE;
613 } 615 }
614 FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, 616 FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName,
615 int iType) { 617 int iType) {
616 return ValidateFieldName(csNewFieldName, iType, NULL, NULL); 618 return ValidateFieldName(csNewFieldName, iType, nullptr, nullptr);
617 } 619 }
618 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, 620 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField,
619 CFX_WideString& csNewFieldName) { 621 CFX_WideString& csNewFieldName) {
620 return pField && !csNewFieldName.IsEmpty() && 622 return pField && !csNewFieldName.IsEmpty() &&
621 ValidateFieldName(csNewFieldName, 623 ValidateFieldName(csNewFieldName,
622 ((CPDF_FormField*)pField)->GetFieldType(), pField, 624 ((CPDF_FormField*)pField)->GetFieldType(), pField,
623 NULL); 625 nullptr);
624 } 626 }
625 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, 627 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl,
626 CFX_WideString& csNewFieldName) { 628 CFX_WideString& csNewFieldName) {
627 if (!pControl || csNewFieldName.IsEmpty()) { 629 if (!pControl || csNewFieldName.IsEmpty()) {
628 return FALSE; 630 return FALSE;
629 } 631 }
630 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); 632 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField();
631 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, 633 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField,
632 pControl); 634 pControl);
633 } 635 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 if (csFieldName == L"") { 683 if (csFieldName == L"") {
682 return m_pFieldTree->m_Root.GetField(index); 684 return m_pFieldTree->m_Root.GetField(index);
683 } 685 }
684 CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName); 686 CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName);
685 return pNode ? pNode->GetField(index) : nullptr; 687 return pNode ? pNode->GetField(index) : nullptr;
686 } 688 }
687 689
688 CPDF_FormField* CPDF_InterForm::GetFieldByDict( 690 CPDF_FormField* CPDF_InterForm::GetFieldByDict(
689 CPDF_Dictionary* pFieldDict) const { 691 CPDF_Dictionary* pFieldDict) const {
690 if (!pFieldDict) { 692 if (!pFieldDict) {
691 return NULL; 693 return nullptr;
692 } 694 }
693 CFX_WideString csWName = GetFullName(pFieldDict); 695 CFX_WideString csWName = GetFullName(pFieldDict);
694 return m_pFieldTree->GetField(csWName); 696 return m_pFieldTree->GetField(csWName);
695 } 697 }
696 698
697 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, 699 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
698 FX_FLOAT pdf_x, 700 FX_FLOAT pdf_x,
699 FX_FLOAT pdf_y, 701 FX_FLOAT pdf_y,
700 int* z_order) const { 702 int* z_order) const {
701 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots"); 703 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots");
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 921 }
920 for (size_t i = 0; i < pAnnots->GetCount(); i++) { 922 for (size_t i = 0; i < pAnnots->GetCount(); i++) {
921 CPDF_Dictionary* pAnnot = pAnnots->GetDictAt(i); 923 CPDF_Dictionary* pAnnot = pAnnots->GetDictAt(i);
922 if (pAnnot && pAnnot->GetStringBy("Subtype") == "Widget") { 924 if (pAnnot && pAnnot->GetStringBy("Subtype") == "Widget") {
923 LoadField(pAnnot); 925 LoadField(pAnnot);
924 } 926 }
925 } 927 }
926 } 928 }
927 CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { 929 CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
928 if (!pFieldDict->KeyExist("T")) { 930 if (!pFieldDict->KeyExist("T")) {
929 return NULL; 931 return nullptr;
930 } 932 }
931 CPDF_Dictionary* pDict = pFieldDict; 933 CPDF_Dictionary* pDict = pFieldDict;
932 CFX_WideString csWName = GetFullName(pFieldDict); 934 CFX_WideString csWName = GetFullName(pFieldDict);
933 if (csWName.IsEmpty()) { 935 if (csWName.IsEmpty()) {
934 return NULL; 936 return nullptr;
935 } 937 }
936 CPDF_FormField* pField = NULL; 938 CPDF_FormField* pField = nullptr;
937 pField = m_pFieldTree->GetField(csWName); 939 pField = m_pFieldTree->GetField(csWName);
938 if (!pField) { 940 if (!pField) {
939 CPDF_Dictionary* pParent = pFieldDict; 941 CPDF_Dictionary* pParent = pFieldDict;
940 if (!pFieldDict->KeyExist("T") && 942 if (!pFieldDict->KeyExist("T") &&
941 pFieldDict->GetStringBy("Subtype") == "Widget") { 943 pFieldDict->GetStringBy("Subtype") == "Widget") {
942 pParent = pFieldDict->GetDictBy("Parent"); 944 pParent = pFieldDict->GetDictBy("Parent");
943 if (!pParent) { 945 if (!pParent) {
944 pParent = pFieldDict; 946 pParent = pFieldDict;
945 } 947 }
946 } 948 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 return ExportToFDF(pdf_path, fields, true, bSimpleFileSpec); 1044 return ExportToFDF(pdf_path, fields, true, bSimpleFileSpec);
1043 } 1045 }
1044 1046
1045 CFDF_Document* CPDF_InterForm::ExportToFDF( 1047 CFDF_Document* CPDF_InterForm::ExportToFDF(
1046 const CFX_WideStringC& pdf_path, 1048 const CFX_WideStringC& pdf_path,
1047 const std::vector<CPDF_FormField*>& fields, 1049 const std::vector<CPDF_FormField*>& fields,
1048 bool bIncludeOrExclude, 1050 bool bIncludeOrExclude,
1049 bool bSimpleFileSpec) const { 1051 bool bSimpleFileSpec) const {
1050 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); 1052 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc();
1051 if (!pDoc) { 1053 if (!pDoc) {
1052 return NULL; 1054 return nullptr;
1053 } 1055 }
1054 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictBy("FDF"); 1056 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictBy("FDF");
1055 if (!pdf_path.IsEmpty()) { 1057 if (!pdf_path.IsEmpty()) {
1056 if (bSimpleFileSpec) { 1058 if (bSimpleFileSpec) {
1057 CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path); 1059 CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path);
1058 pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath)); 1060 pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath));
1059 pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath)); 1061 pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath));
1060 } else { 1062 } else {
1061 CPDF_FileSpec filespec; 1063 CPDF_FileSpec filespec;
1062 filespec.SetFileName(pdf_path); 1064 filespec.SetFileName(pdf_path);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 FDF_ImportField(pField, L"", bNotify); 1190 FDF_ImportField(pField, L"", bNotify);
1189 } 1191 }
1190 if (bNotify && m_pFormNotify) 1192 if (bNotify && m_pFormNotify)
1191 m_pFormNotify->AfterFormImportData(this); 1193 m_pFormNotify->AfterFormImportData(this);
1192 return TRUE; 1194 return TRUE;
1193 } 1195 }
1194 1196
1195 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { 1197 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) {
1196 m_pFormNotify = pNotify; 1198 m_pFormNotify = pNotify;
1197 } 1199 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_basic.cpp ('k') | core/fpdfdoc/doc_tagged.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698