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

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

Issue 2095653002: Remove NULL in xfa/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 5 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() 20 CXFA_ResolveProcessor::CXFA_ResolveProcessor()
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() { 23 CXFA_ResolveProcessor::~CXFA_ResolveProcessor() {
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) {
(...skipping 38 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();
(...skipping 112 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->GetElementType() == XFA_Element::Variables) { 233 if (pChild->GetElementType() == 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->GetElementType() == XFA_Element::PageSet) { 237 } else if (pChild->GetElementType() == 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 nodes.Add(childProperty); 346 nodes.Add(childProperty);
347 } 347 }
348 } 348 }
349 if (nodes.GetSize() > nNum) { 349 if (nodes.GetSize() > nNum) {
350 XFA_ResolveNode_FilterCondition(rnd, wsCondition); 350 XFA_ResolveNode_FilterCondition(rnd, wsCondition);
351 if (nodes.GetSize() > 0) { 351 if (nodes.GetSize() > 0) {
352 return 1; 352 return 1;
353 } 353 }
354 return 0; 354 return 0;
355 } 355 }
356 CXFA_Node* pProp = NULL; 356 CXFA_Node* pProp = nullptr;
357 if (XFA_Element::Subform == curNode->GetElementType() && 357 if (XFA_Element::Subform == curNode->GetElementType() &&
358 XFA_HASHCODE_Occur == uNameHash) { 358 XFA_HASHCODE_Occur == uNameHash) {
359 CXFA_Node* pInstanceManager = 359 CXFA_Node* pInstanceManager =
360 curNode->AsNode()->GetInstanceMgrOfSubform(); 360 curNode->AsNode()->GetInstanceMgrOfSubform();
361 if (pInstanceManager) { 361 if (pInstanceManager) {
362 pProp = pInstanceManager->GetProperty(0, XFA_Element::Occur, TRUE); 362 pProp = pInstanceManager->GetProperty(0, XFA_Element::Occur, TRUE);
363 } 363 }
364 } else { 364 } else {
365 const XFA_ELEMENTINFO* pElement = 365 const XFA_ELEMENTINFO* pElement =
366 XFA_GetElementByName(wsName.AsStringC()); 366 XFA_GetElementByName(wsName.AsStringC());
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 break; 644 break;
645 } 645 }
646 } 646 }
647 if (bAll) { 647 if (bAll) {
648 if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) { 648 if (rnd.m_dwStyles & XFA_RESOLVENODE_CreateNode) {
649 if (rnd.m_dwStyles & XFA_RESOLVENODE_Bind) { 649 if (rnd.m_dwStyles & XFA_RESOLVENODE_Bind) {
650 m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode); 650 m_pNodeHelper->m_pCreateParent = ToNode(rnd.m_CurNode);
651 m_pNodeHelper->m_iCreateCount = 1; 651 m_pNodeHelper->m_iCreateCount = 1;
652 findNodes.RemoveAll(); 652 findNodes.RemoveAll();
653 m_pNodeHelper->m_iCurAllStart = -1; 653 m_pNodeHelper->m_iCurAllStart = -1;
654 m_pNodeHelper->m_pAllStartParent = NULL; 654 m_pNodeHelper->m_pAllStartParent = nullptr;
655 } else { 655 } else {
656 if (m_pNodeHelper->m_iCurAllStart == -1) { 656 if (m_pNodeHelper->m_iCurAllStart == -1) {
657 m_pNodeHelper->m_iCurAllStart = m_iCurStart; 657 m_pNodeHelper->m_iCurAllStart = m_iCurStart;
658 m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurNode); 658 m_pNodeHelper->m_pAllStartParent = ToNode(rnd.m_CurNode);
659 } 659 }
660 } 660 }
661 } else if (rnd.m_dwStyles & XFA_RESOLVENODE_BindNew) { 661 } else if (rnd.m_dwStyles & XFA_RESOLVENODE_BindNew) {
662 if (m_pNodeHelper->m_iCurAllStart == -1) { 662 if (m_pNodeHelper->m_iCurAllStart == -1) {
663 m_pNodeHelper->m_iCurAllStart = m_iCurStart; 663 m_pNodeHelper->m_iCurAllStart = m_iCurStart;
664 } 664 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 } else { 820 } else {
821 iIndex = iCount - 1; 821 iIndex = iCount - 1;
822 } 822 }
823 } else { 823 } else {
824 iIndex = iCount - 1; 824 iIndex = iCount - 1;
825 } 825 }
826 } 826 }
827 827
828 CXFA_ResolveNodesData::CXFA_ResolveNodesData(CXFA_ScriptContext* pSC) 828 CXFA_ResolveNodesData::CXFA_ResolveNodesData(CXFA_ScriptContext* pSC)
829 : m_pSC(pSC), 829 : m_pSC(pSC),
830 m_CurNode(NULL), 830 m_CurNode(nullptr),
831 m_wsName(), 831 m_wsName(),
832 m_uHashName(XFA_HASHCODE_None), 832 m_uHashName(XFA_HASHCODE_None),
833 m_wsCondition(), 833 m_wsCondition(),
834 m_nLevel(0), 834 m_nLevel(0),
835 m_Nodes(), 835 m_Nodes(),
836 m_dwStyles(XFA_RESOLVENODE_Children), 836 m_dwStyles(XFA_RESOLVENODE_Children),
837 m_pScriptAttribute(NULL), 837 m_pScriptAttribute(nullptr),
838 m_dwFlag(XFA_RESOVENODE_RSTYPE_Nodes) {} 838 m_dwFlag(XFA_RESOVENODE_RSTYPE_Nodes) {}
839 839
840 CXFA_ResolveNodesData::~CXFA_ResolveNodesData() { 840 CXFA_ResolveNodesData::~CXFA_ResolveNodesData() {
841 m_Nodes.RemoveAll(); 841 m_Nodes.RemoveAll();
842 } 842 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698