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

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

Issue 1090693002: Replace FX_NEW with new, remove tests in fpdfdoc. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Typo. Created 5 years, 8 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/src/fpdfdoc/doc_annot.cpp ('k') | core/src/fpdfdoc/doc_link.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 "../../include/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 #include "../../include/fxcrt/fx_xml.h" 8 #include "../../include/fxcrt/fx_xml.h"
9 CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict); 9 CFX_WideString GetFullName(CPDF_Dictionary* pFieldDict);
10 void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Docu ment* pDocument); 10 void InitInterFormDict(CPDF_Dictionary*& pFormDict, CPDF_Docu ment* pDocument);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 CFieldTree::~CFieldTree() 120 CFieldTree::~CFieldTree()
121 { 121 {
122 RemoveAll(); 122 RemoveAll();
123 } 123 }
124 CFieldTree::_Node *CFieldTree::AddChild(_Node *pParent, const CFX_WideString &sh ort_name, CPDF_FormField *field_ptr) 124 CFieldTree::_Node *CFieldTree::AddChild(_Node *pParent, const CFX_WideString &sh ort_name, CPDF_FormField *field_ptr)
125 { 125 {
126 if (pParent == NULL) { 126 if (pParent == NULL) {
127 return NULL; 127 return NULL;
128 } 128 }
129 _Node *pNode = FX_NEW _Node; 129 _Node* pNode = new _Node;
130 if (pNode == NULL) {
131 return NULL;
132 }
133 pNode->parent = pParent; 130 pNode->parent = pParent;
134 pNode->short_name = short_name; 131 pNode->short_name = short_name;
135 pNode->field_ptr = field_ptr; 132 pNode->field_ptr = field_ptr;
136 pParent->children.Add(pNode); 133 pParent->children.Add(pNode);
137 return pNode; 134 return pNode;
138 } 135 }
139 void CFieldTree::RemoveNode(_Node *pNode, int nLevel) 136 void CFieldTree::RemoveNode(_Node *pNode, int nLevel)
140 { 137 {
141 if (pNode == NULL) { 138 if (pNode == NULL) {
142 return ; 139 return ;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 name_extractor.GetNext(pName, nLength); 260 name_extractor.GetNext(pName, nLength);
264 } 261 }
265 return pNode; 262 return pNode;
266 } 263 }
267 CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bGenerateAP) : CFX_PrivateData() 264 CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bGenerateAP) : CFX_PrivateData()
268 { 265 {
269 m_pDocument = pDocument; 266 m_pDocument = pDocument;
270 m_bGenerateAP = bGenerateAP; 267 m_bGenerateAP = bGenerateAP;
271 m_pFormNotify = NULL; 268 m_pFormNotify = NULL;
272 m_bUpdated = FALSE; 269 m_bUpdated = FALSE;
273 m_pFieldTree = FX_NEW CFieldTree; 270 m_pFieldTree = new CFieldTree;
274 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); 271 CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
275 m_pFormDict = pRoot->GetDict("AcroForm"); 272 m_pFormDict = pRoot->GetDict("AcroForm");
276 if (m_pFormDict == NULL) { 273 if (m_pFormDict == NULL) {
277 return; 274 return;
278 } 275 }
279 CPDF_Array* pFields = m_pFormDict->GetArray("Fields"); 276 CPDF_Array* pFields = m_pFormDict->GetArray("Fields");
280 if (pFields == NULL) { 277 if (pFields == NULL) {
281 return; 278 return;
282 } 279 }
283 int count = pFields->GetCount(); 280 int count = pFields->GetCount();
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 pParent->SetAt(FX_BSTRC("FT"), pFTValue->Clone()); 1324 pParent->SetAt(FX_BSTRC("FT"), pFTValue->Clone());
1328 } 1325 }
1329 } 1326 }
1330 if (pFieldDict->KeyExist(FX_BSTRC("Ff"))) { 1327 if (pFieldDict->KeyExist(FX_BSTRC("Ff"))) {
1331 CPDF_Object *pFfValue = pFieldDict->GetElementValue(FX_BSTRC("Ff ")); 1328 CPDF_Object *pFfValue = pFieldDict->GetElementValue(FX_BSTRC("Ff "));
1332 if (pFfValue) { 1329 if (pFfValue) {
1333 pParent->SetAt(FX_BSTRC("Ff"), pFfValue->Clone()); 1330 pParent->SetAt(FX_BSTRC("Ff"), pFfValue->Clone());
1334 } 1331 }
1335 } 1332 }
1336 } 1333 }
1337 pField = FX_NEW CPDF_FormField(this, pParent); 1334 pField = new CPDF_FormField(this, pParent);
1338 CPDF_Object* pTObj = pDict->GetElement("T"); 1335 CPDF_Object* pTObj = pDict->GetElement("T");
1339 if (pTObj && pTObj->GetType() == PDFOBJ_REFERENCE) { 1336 if (pTObj && pTObj->GetType() == PDFOBJ_REFERENCE) {
1340 CPDF_Object* pClone = pTObj->Clone(TRUE); 1337 CPDF_Object* pClone = pTObj->Clone(TRUE);
1341 if (pClone) { 1338 if (pClone) {
1342 pDict->SetAt("T", pClone); 1339 pDict->SetAt("T", pClone);
1343 } else { 1340 } else {
1344 pDict->SetAtName("T", ""); 1341 pDict->SetAtName("T", "");
1345 } 1342 }
1346 } 1343 }
1347 m_pFieldTree->SetField(csWName, pField); 1344 m_pFieldTree->SetField(csWName, pField);
(...skipping 16 matching lines...) Expand all
1364 } 1361 }
1365 } 1362 }
1366 return pField; 1363 return pField;
1367 } 1364 }
1368 CPDF_FormControl* CPDF_InterForm::AddControl(const CPDF_FormField* pField, const CPDF_Dictionary* pWidgetDict) 1365 CPDF_FormControl* CPDF_InterForm::AddControl(const CPDF_FormField* pField, const CPDF_Dictionary* pWidgetDict)
1369 { 1366 {
1370 void *rValue = NULL; 1367 void *rValue = NULL;
1371 if (m_ControlMap.Lookup((CPDF_Dictionary*)pWidgetDict, rValue)) { 1368 if (m_ControlMap.Lookup((CPDF_Dictionary*)pWidgetDict, rValue)) {
1372 return (CPDF_FormControl*)rValue; 1369 return (CPDF_FormControl*)rValue;
1373 } 1370 }
1374 CPDF_FormControl* pControl = FX_NEW CPDF_FormControl((CPDF_FormField*)pField , (CPDF_Dictionary*)pWidgetDict); 1371 CPDF_FormControl* pControl = new CPDF_FormControl((CPDF_FormField*)pField, ( CPDF_Dictionary*)pWidgetDict);
1375 if (pControl == NULL) {
1376 return NULL;
1377 }
1378 m_ControlMap.SetAt((CPDF_Dictionary*)pWidgetDict, pControl); 1372 m_ControlMap.SetAt((CPDF_Dictionary*)pWidgetDict, pControl);
1379 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl); 1373 ((CPDF_FormField*)pField)->m_ControlList.Add(pControl);
1380 return pControl; 1374 return pControl;
1381 } 1375 }
1382 CPDF_FormField* CPDF_InterForm::CheckRequiredFields(const CFX_PtrArray *fields, FX_BOOL bIncludeOrExclude) const 1376 CPDF_FormField* CPDF_InterForm::CheckRequiredFields(const CFX_PtrArray *fields, FX_BOOL bIncludeOrExclude) const
1383 { 1377 {
1384 int nCount = m_pFieldTree->m_Root.CountFields(); 1378 int nCount = m_pFieldTree->m_Root.CountFields();
1385 for (int i = 0; i < nCount; i++) { 1379 for (int i = 0; i < nCount; i++) {
1386 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i); 1380 CPDF_FormField* pField = m_pFieldTree->m_Root.GetField(i);
1387 if (pField == NULL) { 1381 if (pField == NULL) {
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 continue; 1649 continue;
1656 } 1650 }
1657 CPDF_FormControl* pControl = NULL; 1651 CPDF_FormControl* pControl = NULL;
1658 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) { 1652 if (m_ControlMap.Lookup(pAnnotDict, (void*&)pControl)) {
1659 return iNewPage; 1653 return iNewPage;
1660 } 1654 }
1661 } 1655 }
1662 } while (TRUE); 1656 } while (TRUE);
1663 return -1; 1657 return -1;
1664 } 1658 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_annot.cpp ('k') | core/src/fpdfdoc/doc_link.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698