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

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: s/NULL/nullptr/ 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
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, *pLast = nullptr;
Tom Sepez 2016/06/02 20:09:48 nit: one per line while we're at it.
Lei Zhang 2016/06/07 07:33:23 Done.
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 }
233 if (pNode && pNode != &m_Root) { 233 if (pNode && pNode != &m_Root) {
234 for (int i = 0; i < pLast->children.GetSize(); i++) { 234 for (int i = 0; i < pLast->children.GetSize(); i++) {
235 if (pNode == pLast->children[i]) { 235 if (pNode == pLast->children[i]) {
236 pLast->children.RemoveAt(i); 236 pLast->children.RemoveAt(i);
237 break; 237 break;
238 } 238 }
239 } 239 }
240 CPDF_FormField* pField = pNode->field_ptr; 240 CPDF_FormField* pField = pNode->field_ptr;
241 RemoveNode(pNode); 241 RemoveNode(pNode);
242 return pField; 242 return pField;
243 } 243 }
244 return NULL; 244 return nullptr;
245 } 245 }
246 CFieldTree::_Node* CFieldTree::FindNode(const CFX_WideString& full_name) { 246 CFieldTree::_Node* CFieldTree::FindNode(const CFX_WideString& full_name) {
247 if (full_name == L"") { 247 if (full_name == L"") {
248 return NULL; 248 return nullptr;
249 } 249 }
250 CFieldNameExtractor name_extractor(full_name); 250 CFieldNameExtractor name_extractor(full_name);
251 const FX_WCHAR* pName; 251 const FX_WCHAR* pName;
252 FX_STRSIZE nLength; 252 FX_STRSIZE nLength;
253 name_extractor.GetNext(pName, nLength); 253 name_extractor.GetNext(pName, nLength);
254 _Node *pNode = &m_Root, *pLast = NULL; 254 _Node *pNode = &m_Root, *pLast = nullptr;
255 while (nLength > 0 && pNode) { 255 while (nLength > 0 && pNode) {
256 pLast = pNode; 256 pLast = pNode;
257 CFX_WideString name = CFX_WideString(pName, nLength); 257 CFX_WideString name = CFX_WideString(pName, nLength);
258 pNode = _Lookup(pLast, name); 258 pNode = _Lookup(pLast, name);
259 name_extractor.GetNext(pName, nLength); 259 name_extractor.GetNext(pName, nLength);
260 } 260 }
261 return pNode; 261 return pNode;
262 } 262 }
263 263
264 CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument) 264 CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 return 1; 368 return 1;
369 } 369 }
370 LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam; 370 LPDF_FONTDATA pData = (LPDF_FONTDATA)lParam;
371 memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA)); 371 memcpy(&pData->lf, &lpelfe->elfLogFont, sizeof(LOGFONTA));
372 pData->bFind = TRUE; 372 pData->bFind = TRUE;
373 return 0; 373 return 0;
374 } 374 }
375 static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) { 375 static FX_BOOL RetrieveSpecificFont(LOGFONTA& lf) {
376 PDF_FONTDATA fd; 376 PDF_FONTDATA fd;
377 memset(&fd, 0, sizeof(PDF_FONTDATA)); 377 memset(&fd, 0, sizeof(PDF_FONTDATA));
378 HDC hDC = ::GetDC(NULL); 378 HDC hDC = ::GetDC(nullptr);
379 EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd, 379 EnumFontFamiliesExA(hDC, &lf, (FONTENUMPROCA)EnumFontFamExProc, (LPARAM)&fd,
380 0); 380 0);
381 ::ReleaseDC(NULL, hDC); 381 ::ReleaseDC(nullptr, hDC);
382 if (fd.bFind) { 382 if (fd.bFind) {
383 memcpy(&lf, &fd.lf, sizeof(LOGFONTA)); 383 memcpy(&lf, &fd.lf, sizeof(LOGFONTA));
384 } 384 }
385 return fd.bFind; 385 return fd.bFind;
386 } 386 }
387 static FX_BOOL RetrieveSpecificFont(uint8_t charSet, 387 static FX_BOOL RetrieveSpecificFont(uint8_t charSet,
388 uint8_t pitchAndFamily, 388 uint8_t pitchAndFamily,
389 LPCSTR pcsFontName, 389 LPCSTR pcsFontName,
390 LOGFONTA& lf) { 390 LOGFONTA& lf) {
391 memset(&lf, 0, sizeof(LOGFONTA)); 391 memset(&lf, 0, sizeof(LOGFONTA));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 } 433 }
434 if (!bRet) { 434 if (!bRet) {
435 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, 435 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE,
436 "Arial Unicode MS", lf); 436 "Arial Unicode MS", lf);
437 } 437 }
438 if (!bRet) { 438 if (!bRet) {
439 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, 439 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE,
440 "Microsoft Sans Serif", lf); 440 "Microsoft Sans Serif", lf);
441 } 441 }
442 if (!bRet) { 442 if (!bRet) {
443 bRet = RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, NULL, lf); 443 bRet =
444 RetrieveSpecificFont(charSet, DEFAULT_PITCH | FF_DONTCARE, nullptr, lf);
444 } 445 }
445 if (bRet) { 446 if (bRet) {
446 if (pLogFont) { 447 if (pLogFont) {
447 memcpy(pLogFont, &lf, sizeof(LOGFONTA)); 448 memcpy(pLogFont, &lf, sizeof(LOGFONTA));
448 } 449 }
449 csFontName = lf.lfFaceName; 450 csFontName = lf.lfFaceName;
450 return csFontName; 451 return csFontName;
451 } 452 }
452 #endif 453 #endif
453 return csFontName; 454 return csFontName;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 607 }
607 } 608 }
608 if (csSub.IsEmpty()) { 609 if (csSub.IsEmpty()) {
609 return FALSE; 610 return FALSE;
610 } 611 }
611 csNewFieldName = csSub; 612 csNewFieldName = csSub;
612 return TRUE; 613 return TRUE;
613 } 614 }
614 FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName, 615 FX_BOOL CPDF_InterForm::ValidateFieldName(CFX_WideString& csNewFieldName,
615 int iType) { 616 int iType) {
616 return ValidateFieldName(csNewFieldName, iType, NULL, NULL); 617 return ValidateFieldName(csNewFieldName, iType, nullptr, nullptr);
617 } 618 }
618 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField, 619 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormField* pField,
619 CFX_WideString& csNewFieldName) { 620 CFX_WideString& csNewFieldName) {
620 return pField && !csNewFieldName.IsEmpty() && 621 return pField && !csNewFieldName.IsEmpty() &&
621 ValidateFieldName(csNewFieldName, 622 ValidateFieldName(csNewFieldName,
622 ((CPDF_FormField*)pField)->GetFieldType(), pField, 623 ((CPDF_FormField*)pField)->GetFieldType(), pField,
623 NULL); 624 nullptr);
624 } 625 }
625 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl, 626 FX_BOOL CPDF_InterForm::ValidateFieldName(const CPDF_FormControl* pControl,
626 CFX_WideString& csNewFieldName) { 627 CFX_WideString& csNewFieldName) {
627 if (!pControl || csNewFieldName.IsEmpty()) { 628 if (!pControl || csNewFieldName.IsEmpty()) {
628 return FALSE; 629 return FALSE;
629 } 630 }
630 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField(); 631 CPDF_FormField* pField = ((CPDF_FormControl*)pControl)->GetField();
631 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField, 632 return ValidateFieldName(csNewFieldName, pField->GetFieldType(), pField,
632 pControl); 633 pControl);
633 } 634 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 if (csFieldName == L"") { 682 if (csFieldName == L"") {
682 return m_pFieldTree->m_Root.GetField(index); 683 return m_pFieldTree->m_Root.GetField(index);
683 } 684 }
684 CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName); 685 CFieldTree::_Node* pNode = m_pFieldTree->FindNode(csFieldName);
685 return pNode ? pNode->GetField(index) : nullptr; 686 return pNode ? pNode->GetField(index) : nullptr;
686 } 687 }
687 688
688 CPDF_FormField* CPDF_InterForm::GetFieldByDict( 689 CPDF_FormField* CPDF_InterForm::GetFieldByDict(
689 CPDF_Dictionary* pFieldDict) const { 690 CPDF_Dictionary* pFieldDict) const {
690 if (!pFieldDict) { 691 if (!pFieldDict) {
691 return NULL; 692 return nullptr;
692 } 693 }
693 CFX_WideString csWName = GetFullName(pFieldDict); 694 CFX_WideString csWName = GetFullName(pFieldDict);
694 return m_pFieldTree->GetField(csWName); 695 return m_pFieldTree->GetField(csWName);
695 } 696 }
696 697
697 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, 698 CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
698 FX_FLOAT pdf_x, 699 FX_FLOAT pdf_x,
699 FX_FLOAT pdf_y, 700 FX_FLOAT pdf_y,
700 int* z_order) const { 701 int* z_order) const {
701 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots"); 702 CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArrayBy("Annots");
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
919 } 920 }
920 for (size_t i = 0; i < pAnnots->GetCount(); i++) { 921 for (size_t i = 0; i < pAnnots->GetCount(); i++) {
921 CPDF_Dictionary* pAnnot = pAnnots->GetDictAt(i); 922 CPDF_Dictionary* pAnnot = pAnnots->GetDictAt(i);
922 if (pAnnot && pAnnot->GetStringBy("Subtype") == "Widget") { 923 if (pAnnot && pAnnot->GetStringBy("Subtype") == "Widget") {
923 LoadField(pAnnot); 924 LoadField(pAnnot);
924 } 925 }
925 } 926 }
926 } 927 }
927 CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) { 928 CPDF_FormField* CPDF_InterForm::AddTerminalField(CPDF_Dictionary* pFieldDict) {
928 if (!pFieldDict->KeyExist("T")) { 929 if (!pFieldDict->KeyExist("T")) {
929 return NULL; 930 return nullptr;
930 } 931 }
931 CPDF_Dictionary* pDict = pFieldDict; 932 CPDF_Dictionary* pDict = pFieldDict;
932 CFX_WideString csWName = GetFullName(pFieldDict); 933 CFX_WideString csWName = GetFullName(pFieldDict);
933 if (csWName.IsEmpty()) { 934 if (csWName.IsEmpty()) {
934 return NULL; 935 return nullptr;
935 } 936 }
936 CPDF_FormField* pField = NULL; 937 CPDF_FormField* pField = nullptr;
937 pField = m_pFieldTree->GetField(csWName); 938 pField = m_pFieldTree->GetField(csWName);
938 if (!pField) { 939 if (!pField) {
939 CPDF_Dictionary* pParent = pFieldDict; 940 CPDF_Dictionary* pParent = pFieldDict;
940 if (!pFieldDict->KeyExist("T") && 941 if (!pFieldDict->KeyExist("T") &&
941 pFieldDict->GetStringBy("Subtype") == "Widget") { 942 pFieldDict->GetStringBy("Subtype") == "Widget") {
942 pParent = pFieldDict->GetDictBy("Parent"); 943 pParent = pFieldDict->GetDictBy("Parent");
943 if (!pParent) { 944 if (!pParent) {
944 pParent = pFieldDict; 945 pParent = pFieldDict;
945 } 946 }
946 } 947 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 return ExportToFDF(pdf_path, fields, true, bSimpleFileSpec); 1043 return ExportToFDF(pdf_path, fields, true, bSimpleFileSpec);
1043 } 1044 }
1044 1045
1045 CFDF_Document* CPDF_InterForm::ExportToFDF( 1046 CFDF_Document* CPDF_InterForm::ExportToFDF(
1046 const CFX_WideStringC& pdf_path, 1047 const CFX_WideStringC& pdf_path,
1047 const std::vector<CPDF_FormField*>& fields, 1048 const std::vector<CPDF_FormField*>& fields,
1048 bool bIncludeOrExclude, 1049 bool bIncludeOrExclude,
1049 bool bSimpleFileSpec) const { 1050 bool bSimpleFileSpec) const {
1050 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc(); 1051 CFDF_Document* pDoc = CFDF_Document::CreateNewDoc();
1051 if (!pDoc) { 1052 if (!pDoc) {
1052 return NULL; 1053 return nullptr;
1053 } 1054 }
1054 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictBy("FDF"); 1055 CPDF_Dictionary* pMainDict = pDoc->GetRoot()->GetDictBy("FDF");
1055 if (!pdf_path.IsEmpty()) { 1056 if (!pdf_path.IsEmpty()) {
1056 if (bSimpleFileSpec) { 1057 if (bSimpleFileSpec) {
1057 CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path); 1058 CFX_WideString wsFilePath = CPDF_FileSpec::EncodeFileName(pdf_path);
1058 pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath)); 1059 pMainDict->SetAtString("F", CFX_ByteString::FromUnicode(wsFilePath));
1059 pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath)); 1060 pMainDict->SetAtString("UF", PDF_EncodeText(wsFilePath));
1060 } else { 1061 } else {
1061 CPDF_FileSpec filespec; 1062 CPDF_FileSpec filespec;
1062 filespec.SetFileName(pdf_path); 1063 filespec.SetFileName(pdf_path);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 FDF_ImportField(pField, L"", bNotify); 1189 FDF_ImportField(pField, L"", bNotify);
1189 } 1190 }
1190 if (bNotify && m_pFormNotify) 1191 if (bNotify && m_pFormNotify)
1191 m_pFormNotify->AfterFormImportData(this); 1192 m_pFormNotify->AfterFormImportData(this);
1192 return TRUE; 1193 return TRUE;
1193 } 1194 }
1194 1195
1195 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) { 1196 void CPDF_InterForm::SetFormNotify(IPDF_FormNotify* pNotify) {
1196 m_pFormNotify = pNotify; 1197 m_pFormNotify = pNotify;
1197 } 1198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698