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

Side by Side Diff: xfa/fxfa/parser/xfa_script_resolveprocessor.cpp

Issue 2031873003: Get rid of NULLs in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@nullptr_fpdfsdk
Patch Set: 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 "xfa/fxfa/parser/xfa_script_resolveprocessor.h" 7 #include "xfa/fxfa/parser/xfa_script_resolveprocessor.h"
8 8
9 #include "core/fxcrt/include/fx_ext.h" 9 #include "core/fxcrt/include/fx_ext.h"
10 #include "xfa/fxfa/parser/xfa_doclayout.h" 10 #include "xfa/fxfa/parser/xfa_doclayout.h"
11 #include "xfa/fxfa/parser/xfa_document.h" 11 #include "xfa/fxfa/parser/xfa_document.h"
12 #include "xfa/fxfa/parser/xfa_localemgr.h" 12 #include "xfa/fxfa/parser/xfa_localemgr.h"
13 #include "xfa/fxfa/parser/xfa_object.h" 13 #include "xfa/fxfa/parser/xfa_object.h"
14 #include "xfa/fxfa/parser/xfa_parser.h" 14 #include "xfa/fxfa/parser/xfa_parser.h"
15 #include "xfa/fxfa/parser/xfa_script.h" 15 #include "xfa/fxfa/parser/xfa_script.h"
16 #include "xfa/fxfa/parser/xfa_script_imp.h" 16 #include "xfa/fxfa/parser/xfa_script_imp.h"
17 #include "xfa/fxfa/parser/xfa_script_nodehelper.h" 17 #include "xfa/fxfa/parser/xfa_script_nodehelper.h"
18 #include "xfa/fxfa/parser/xfa_utils.h" 18 #include "xfa/fxfa/parser/xfa_utils.h"
19 19
20 CXFA_ResolveProcessor::CXFA_ResolveProcessor(void) 20 CXFA_ResolveProcessor::CXFA_ResolveProcessor(void)
21 : m_pNodeHelper(new CXFA_NodeHelper), m_iCurStart(0) {} 21 : m_pNodeHelper(new CXFA_NodeHelper), m_iCurStart(0) {}
22 22
23 CXFA_ResolveProcessor::~CXFA_ResolveProcessor(void) { 23 CXFA_ResolveProcessor::~CXFA_ResolveProcessor(void) {
24 delete m_pNodeHelper; 24 delete m_pNodeHelper;
25 } 25 }
26 26
27 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) { 27 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes(CXFA_ResolveNodesData& rnd) {
28 if (rnd.m_CurNode == NULL) { 28 if (!rnd.m_CurNode)
29 return -1; 29 return -1;
30 } 30
31 if (!rnd.m_CurNode->IsNode()) { 31 if (!rnd.m_CurNode->IsNode()) {
32 if (rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) { 32 if (rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) {
33 return XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd, 33 return XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd,
34 rnd.m_wsName.AsStringC()); 34 rnd.m_wsName.AsStringC());
35 } 35 }
36 return 0; 36 return 0;
37 } 37 }
38 if (rnd.m_dwStyles & XFA_RESOLVENODE_AnyChild) { 38 if (rnd.m_dwStyles & XFA_RESOLVENODE_AnyChild) {
39 return XFA_ResolveNodes_AnyChild(rnd); 39 return XFA_ResolveNodes_AnyChild(rnd);
40 } 40 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 int32_t nRet = XFA_ResolveNodes_Normal(rnd); 77 int32_t nRet = XFA_ResolveNodes_Normal(rnd);
78 if (nRet < 1 && rnd.m_uHashName == XFA_HASHCODE_Xfa) { 78 if (nRet < 1 && rnd.m_uHashName == XFA_HASHCODE_Xfa) {
79 rnd.m_Nodes.Add(rnd.m_pSC->GetDocument()->GetRoot()); 79 rnd.m_Nodes.Add(rnd.m_pSC->GetDocument()->GetRoot());
80 } 80 }
81 return rnd.m_Nodes.GetSize(); 81 return rnd.m_Nodes.GetSize();
82 } 82 }
83 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_AnyChild( 83 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_AnyChild(
84 CXFA_ResolveNodesData& rnd) { 84 CXFA_ResolveNodesData& rnd) {
85 CFX_WideString wsName = rnd.m_wsName; 85 CFX_WideString wsName = rnd.m_wsName;
86 CFX_WideString wsCondition = rnd.m_wsCondition; 86 CFX_WideString wsCondition = rnd.m_wsCondition;
87 CXFA_Node* findNode = NULL; 87 CXFA_Node* findNode = nullptr;
88 CXFA_NodeArray siblings; 88 CXFA_NodeArray siblings;
89 FX_BOOL bClassName = FALSE; 89 FX_BOOL bClassName = FALSE;
90 if (wsName.GetAt(0) == '#') { 90 if (wsName.GetAt(0) == '#') {
91 bClassName = TRUE; 91 bClassName = TRUE;
92 wsName = wsName.Right(wsName.GetLength() - 1); 92 wsName = wsName.Right(wsName.GetLength() - 1);
93 } 93 }
94 findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild( 94 findNode = m_pNodeHelper->XFA_ResolveNodes_GetOneChild(
95 ToNode(rnd.m_CurNode), wsName.c_str(), bClassName); 95 ToNode(rnd.m_CurNode), wsName.c_str(), bClassName);
96 if (findNode == NULL) { 96 if (!findNode)
97 return 0; 97 return 0;
98 } 98
99 if (wsCondition.IsEmpty()) { 99 if (wsCondition.IsEmpty()) {
100 rnd.m_Nodes.Add(findNode); 100 rnd.m_Nodes.Add(findNode);
101 return rnd.m_Nodes.GetSize(); 101 return rnd.m_Nodes.GetSize();
102 } 102 }
103 m_pNodeHelper->XFA_CountSiblings(findNode, XFA_LOGIC_Transparent, 103 m_pNodeHelper->XFA_CountSiblings(findNode, XFA_LOGIC_Transparent,
104 (CXFA_NodeArray*)&rnd.m_Nodes, bClassName); 104 (CXFA_NodeArray*)&rnd.m_Nodes, bClassName);
105 XFA_ResolveNode_FilterCondition(rnd, wsCondition); 105 XFA_ResolveNode_FilterCondition(rnd, wsCondition);
106 return rnd.m_Nodes.GetSize(); 106 return rnd.m_Nodes.GetSize();
107 } 107 }
108 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar( 108 int32_t CXFA_ResolveProcessor::XFA_ResolveNodes_Dollar(
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 XFA_HashCode uNameHash = rnd.m_uHashName; 219 XFA_HashCode uNameHash = rnd.m_uHashName;
220 CFX_WideString& wsCondition = rnd.m_wsCondition; 220 CFX_WideString& wsCondition = rnd.m_wsCondition;
221 CXFA_ResolveNodesData rndFind; 221 CXFA_ResolveNodesData rndFind;
222 rndFind.m_wsName = rnd.m_wsName; 222 rndFind.m_wsName = rnd.m_wsName;
223 rndFind.m_wsCondition = rnd.m_wsCondition; 223 rndFind.m_wsCondition = rnd.m_wsCondition;
224 rndFind.m_pSC = rnd.m_pSC; 224 rndFind.m_pSC = rnd.m_pSC;
225 rndFind.m_nLevel = rnd.m_nLevel + 1; 225 rndFind.m_nLevel = rnd.m_nLevel + 1;
226 rndFind.m_uHashName = uNameHash; 226 rndFind.m_uHashName = uNameHash;
227 CXFA_NodeArray children; 227 CXFA_NodeArray children;
228 CXFA_NodeArray properties; 228 CXFA_NodeArray properties;
229 CXFA_Node* pVariablesNode = NULL; 229 CXFA_Node* pVariablesNode = nullptr;
230 CXFA_Node* pPageSetNode = NULL; 230 CXFA_Node* pPageSetNode = nullptr;
231 CXFA_Node* pChild = curNode->GetNodeItem(XFA_NODEITEM_FirstChild); 231 CXFA_Node* pChild = curNode->GetNodeItem(XFA_NODEITEM_FirstChild);
232 while (pChild) { 232 while (pChild) {
233 if (pChild->GetClassID() == XFA_ELEMENT_Variables) { 233 if (pChild->GetClassID() == XFA_ELEMENT_Variables) {
234 pVariablesNode = pChild; 234 pVariablesNode = pChild;
235 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); 235 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
236 continue; 236 continue;
237 } else if (pChild->GetClassID() == XFA_ELEMENT_PageSet) { 237 } else if (pChild->GetClassID() == XFA_ELEMENT_PageSet) {
238 pPageSetNode = pChild; 238 pPageSetNode = pChild;
239 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); 239 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling);
240 continue; 240 continue;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 nodes.Add(childProperty); 345 nodes.Add(childProperty);
346 } 346 }
347 } 347 }
348 if (nodes.GetSize() > nNum) { 348 if (nodes.GetSize() > nNum) {
349 XFA_ResolveNode_FilterCondition(rnd, wsCondition); 349 XFA_ResolveNode_FilterCondition(rnd, wsCondition);
350 if (nodes.GetSize() > 0) { 350 if (nodes.GetSize() > 0) {
351 return 1; 351 return 1;
352 } 352 }
353 return 0; 353 return 0;
354 } 354 }
355 CXFA_Node* pProp = NULL; 355 CXFA_Node* pProp = nullptr;
356 if (XFA_ELEMENT_Subform == curNode->GetClassID() && 356 if (XFA_ELEMENT_Subform == curNode->GetClassID() &&
357 XFA_HASHCODE_Occur == uNameHash) { 357 XFA_HASHCODE_Occur == uNameHash) {
358 CXFA_Node* pInstanceManager = 358 CXFA_Node* pInstanceManager =
359 curNode->AsNode()->GetInstanceMgrOfSubform(); 359 curNode->AsNode()->GetInstanceMgrOfSubform();
360 if (pInstanceManager) { 360 if (pInstanceManager) {
361 pProp = pInstanceManager->GetProperty(0, XFA_ELEMENT_Occur, TRUE); 361 pProp = pInstanceManager->GetProperty(0, XFA_ELEMENT_Occur, TRUE);
362 } 362 }
363 } else { 363 } else {
364 const XFA_ELEMENTINFO* pElement = 364 const XFA_ELEMENTINFO* pElement =
365 XFA_GetElementByName(wsName.AsStringC()); 365 XFA_GetElementByName(wsName.AsStringC());
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 break; 642 break;
643 } 643 }
644 } 644 }
645 if (bAll) { 645 if (bAll) {
646 if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { 646 if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) {
647 if (rnd.m_dwStyles & XFA_RESOLVENODE_Bind) { 647 if (rnd.m_dwStyles & XFA_RESOLVENODE_Bind) {
648 m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); 648 m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode);
649 m_pNodeHelper->m_iCreateCount = 1; 649 m_pNodeHelper->m_iCreateCount = 1;
650 findNodes.RemoveAll(); 650 findNodes.RemoveAll();
651 m_pNodeHelper->m_iCurAllStart = -1; 651 m_pNodeHelper->m_iCurAllStart = -1;
652 m_pNodeHelper->m_pAllStartParent = NULL; 652 m_pNodeHelper->m_pAllStartParent = nullptr;
653 } else { 653 } else {
654 if (m_pNodeHelper->m_iCurAllStart == -1) { 654 if (m_pNodeHelper->m_iCurAllStart == -1) {
655 m_pNodeHelper->m_iCurAllStart = m_iCurStart; 655 m_pNodeHelper->m_iCurAllStart = m_iCurStart;
656 m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurNode); 656 m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurNode);
657 } 657 }
658 } 658 }
659 } else if (rnd.m_dwStyles & XFA_RESOLVENODE_BindNew) { 659 } else if (rnd.m_dwStyles & XFA_RESOLVENODE_BindNew) {
660 if (m_pNodeHelper->m_iCurAllStart == -1) { 660 if (m_pNodeHelper->m_iCurAllStart == -1) {
661 m_pNodeHelper->m_iCurAllStart = m_iCurStart; 661 m_pNodeHelper->m_iCurAllStart = m_iCurStart;
662 } 662 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) { 815 if (m_pNodeHelper->XFA_CreateNode_ForCondition(wsNextCondition)) {
816 if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) { 816 if (m_pNodeHelper->m_eLastCreateType == XFA_ELEMENT_DataGroup) {
817 iIndex = 0; 817 iIndex = 0;
818 } else { 818 } else {
819 iIndex = iCount - 1; 819 iIndex = iCount - 1;
820 } 820 }
821 } else { 821 } else {
822 iIndex = iCount - 1; 822 iIndex = iCount - 1;
823 } 823 }
824 } 824 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_resolveprocessor.h ('k') | xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698