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

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

Issue 2089443002: Convert XFA_ELEMENT to an enum class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More unknown checks 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"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return XFA_ResolveNodes_Asterisk(rnd); 50 return XFA_ResolveNodes_Asterisk(rnd);
51 // TODO(dsinclair): We could probably remove this. 51 // TODO(dsinclair): We could probably remove this.
52 case '.': 52 case '.':
53 return XFA_ResolveNodes_AnyChild(rnd); 53 return XFA_ResolveNodes_AnyChild(rnd);
54 default: 54 default:
55 break; 55 break;
56 } 56 }
57 if (rnd.m_uHashName == XFA_HASHCODE_This && rnd.m_nLevel == 0) { 57 if (rnd.m_uHashName == XFA_HASHCODE_This && rnd.m_nLevel == 0) {
58 rnd.m_Nodes.Add(rnd.m_pSC->GetThisObject()); 58 rnd.m_Nodes.Add(rnd.m_pSC->GetThisObject());
59 return 1; 59 return 1;
60 } else if (rnd.m_CurNode->GetClassID() == XFA_ELEMENT_Xfa) { 60 } else if (rnd.m_CurNode->GetClassID() == XFA_Element::Xfa) {
61 CXFA_Object* pObjNode = 61 CXFA_Object* pObjNode =
62 rnd.m_pSC->GetDocument()->GetXFAObject(rnd.m_uHashName); 62 rnd.m_pSC->GetDocument()->GetXFAObject(rnd.m_uHashName);
63 if (pObjNode) { 63 if (pObjNode) {
64 rnd.m_Nodes.Add(pObjNode); 64 rnd.m_Nodes.Add(pObjNode);
65 } else if (rnd.m_uHashName == XFA_HASHCODE_Xfa) { 65 } else if (rnd.m_uHashName == XFA_HASHCODE_Xfa) {
66 rnd.m_Nodes.Add(rnd.m_CurNode); 66 rnd.m_Nodes.Add(rnd.m_CurNode);
67 } else if ((rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) && 67 } else if ((rnd.m_dwStyles & XFA_RESOLVENODE_Attributes) &&
68 XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd, 68 XFA_ResolveNodes_ForAttributeRs(rnd.m_CurNode, rnd,
69 rnd.m_wsName.AsStringC())) { 69 rnd.m_wsName.AsStringC())) {
70 return 1; 70 return 1;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = NULL;
230 CXFA_Node* pPageSetNode = NULL; 230 CXFA_Node* pPageSetNode = NULL;
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;
241 } else { 241 } else {
242 const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement( 242 const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement(
243 curNode->GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN); 243 curNode->GetClassID(), pChild->GetClassID(), XFA_XDPPACKET_UNKNOWN);
244 if (pPropert) { 244 if (pPropert) {
245 properties.Add(pChild); 245 properties.Add(pChild);
246 } else { 246 } else {
247 children.Add(pChild); 247 children.Add(pChild);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 for (int32_t i = 0; i < children.GetSize(); i++) { 281 for (int32_t i = 0; i < children.GetSize(); i++) {
282 CXFA_Node* child = children[i]; 282 CXFA_Node* child = children[i];
283 if (dwStyles & XFA_RESOLVENODE_TagName) { 283 if (dwStyles & XFA_RESOLVENODE_TagName) {
284 if (child->GetClassHashCode() == uNameHash) { 284 if (child->GetClassHashCode() == uNameHash) {
285 nodes.Add(child); 285 nodes.Add(child);
286 } 286 }
287 } else if (child->GetNameHash() == uNameHash) { 287 } else if (child->GetNameHash() == uNameHash) {
288 nodes.Add(child); 288 nodes.Add(child);
289 } 289 }
290 if (m_pNodeHelper->XFA_NodeIsTransparent(child) && 290 if (m_pNodeHelper->XFA_NodeIsTransparent(child) &&
291 child->GetClassID() != XFA_ELEMENT_PageSet) { 291 child->GetClassID() != XFA_Element::PageSet) {
292 if (!bSetFlag) { 292 if (!bSetFlag) {
293 XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind); 293 XFA_ResolveNodes_SetStylesForChild(dwStyles, rndFind);
294 bSetFlag = TRUE; 294 bSetFlag = TRUE;
295 } 295 }
296 rndFind.m_CurNode = child; 296 rndFind.m_CurNode = child;
297 CFX_WideString wsSaveCondition = rndFind.m_wsCondition; 297 CFX_WideString wsSaveCondition = rndFind.m_wsCondition;
298 rndFind.m_wsCondition.clear(); 298 rndFind.m_wsCondition.clear();
299 XFA_ResolveNodes_Normal(rndFind); 299 XFA_ResolveNodes_Normal(rndFind);
300 rndFind.m_wsCondition = wsSaveCondition; 300 rndFind.m_wsCondition = wsSaveCondition;
301 if (rndFind.m_Nodes.GetSize() > 0) { 301 if (rndFind.m_Nodes.GetSize() > 0) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 } 333 }
334 if (dwStyles & XFA_RESOLVENODE_Properties) { 334 if (dwStyles & XFA_RESOLVENODE_Properties) {
335 for (int32_t i = 0; i < properties.GetSize(); i++) { 335 for (int32_t i = 0; i < properties.GetSize(); i++) {
336 CXFA_Node* childProperty = properties[i]; 336 CXFA_Node* childProperty = properties[i];
337 if (childProperty->IsUnnamed()) { 337 if (childProperty->IsUnnamed()) {
338 uint32_t uPropHash = childProperty->GetClassHashCode(); 338 uint32_t uPropHash = childProperty->GetClassHashCode();
339 if (uPropHash == uNameHash) { 339 if (uPropHash == uNameHash) {
340 nodes.Add(childProperty); 340 nodes.Add(childProperty);
341 } 341 }
342 } else if (childProperty->GetNameHash() == uNameHash && 342 } else if (childProperty->GetNameHash() == uNameHash &&
343 childProperty->GetClassID() != XFA_ELEMENT_Extras && 343 childProperty->GetClassID() != XFA_Element::Extras &&
344 childProperty->GetClassID() != XFA_ELEMENT_Items) { 344 childProperty->GetClassID() != XFA_Element::Items) {
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 = NULL;
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());
366 if (pElement) { 366 if (pElement) {
367 pProp = curNode->AsNode()->GetProperty( 367 pProp = curNode->AsNode()->GetProperty(
368 0, pElement->eName, pElement->eName != XFA_ELEMENT_PageSet); 368 0, pElement->eName, pElement->eName != XFA_Element::PageSet);
369 } 369 }
370 } 370 }
371 if (pProp) { 371 if (pProp) {
372 nodes.Add(pProp); 372 nodes.Add(pProp);
373 return nodes.GetSize(); 373 return nodes.GetSize();
374 } 374 }
375 } 375 }
376 CXFA_Node* parentNode = m_pNodeHelper->XFA_ResolveNodes_GetParent( 376 CXFA_Node* parentNode = m_pNodeHelper->XFA_ResolveNodes_GetParent(
377 curNode->AsNode(), XFA_LOGIC_NoTransparent); 377 curNode->AsNode(), XFA_LOGIC_NoTransparent);
378 uint32_t uCurClassHash = curNode->GetClassHashCode(); 378 uint32_t uCurClassHash = curNode->GetClassHashCode();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 if (child->GetClassHashCode() == uNameHash) { 420 if (child->GetClassHashCode() == uNameHash) {
421 nodes.Add(child); 421 nodes.Add(child);
422 } 422 }
423 } else if (child->GetNameHash() == uNameHash) { 423 } else if (child->GetNameHash() == uNameHash) {
424 nodes.Add(child); 424 nodes.Add(child);
425 } 425 }
426 const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement( 426 const XFA_PROPERTY* pPropert = XFA_GetPropertyOfElement(
427 parentNode->GetClassID(), child->GetClassID(), XFA_XDPPACKET_UNKNOWN); 427 parentNode->GetClassID(), child->GetClassID(), XFA_XDPPACKET_UNKNOWN);
428 FX_BOOL bInnerSearch = FALSE; 428 FX_BOOL bInnerSearch = FALSE;
429 if (pPropert) { 429 if (pPropert) {
430 if ((child->GetClassID() == XFA_ELEMENT_Variables || 430 if ((child->GetClassID() == XFA_Element::Variables ||
431 child->GetClassID() == XFA_ELEMENT_PageSet)) { 431 child->GetClassID() == XFA_Element::PageSet)) {
432 bInnerSearch = TRUE; 432 bInnerSearch = TRUE;
433 } 433 }
434 } else { 434 } else {
435 if (m_pNodeHelper->XFA_NodeIsTransparent(child)) { 435 if (m_pNodeHelper->XFA_NodeIsTransparent(child)) {
436 bInnerSearch = TRUE; 436 bInnerSearch = TRUE;
437 } 437 }
438 } 438 }
439 if (bInnerSearch) { 439 if (bInnerSearch) {
440 rndFind.m_CurNode = child; 440 rndFind.m_CurNode = child;
441 CFX_WideString wsOriginCondition = rndFind.m_wsCondition; 441 CFX_WideString wsOriginCondition = rndFind.m_wsCondition;
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 CXFA_ResolveNodesData& rnd, 721 CXFA_ResolveNodesData& rnd,
722 CFX_WideString wsCondition) { 722 CFX_WideString wsCondition) {
723 CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes; 723 CXFA_NodeArray& findNodes = (CXFA_NodeArray&)rnd.m_Nodes;
724 int32_t iCurrIndex = 0; 724 int32_t iCurrIndex = 0;
725 const CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray(); 725 const CXFA_NodeArray& array = rnd.m_pSC->GetUpObjectArray();
726 int32_t iSize = array.GetSize(); 726 int32_t iSize = array.GetSize();
727 if (iSize) { 727 if (iSize) {
728 CXFA_Node* curNode = array[iSize - 1]; 728 CXFA_Node* curNode = array[iSize - 1];
729 FX_BOOL bIsProperty = m_pNodeHelper->XFA_NodeIsProperty(curNode); 729 FX_BOOL bIsProperty = m_pNodeHelper->XFA_NodeIsProperty(curNode);
730 if (curNode->IsUnnamed() || 730 if (curNode->IsUnnamed() ||
731 (bIsProperty && curNode->GetClassID() != XFA_ELEMENT_PageSet)) { 731 (bIsProperty && curNode->GetClassID() != XFA_Element::PageSet)) {
732 iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent, 732 iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent,
733 bIsProperty, TRUE); 733 bIsProperty, TRUE);
734 } else { 734 } else {
735 iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent, 735 iCurrIndex = m_pNodeHelper->XFA_GetIndex(curNode, XFA_LOGIC_Transparent,
736 bIsProperty, FALSE); 736 bIsProperty, FALSE);
737 } 737 }
738 } 738 }
739 int32_t iFoundCount = findNodes.GetSize(); 739 int32_t iFoundCount = findNodes.GetSize();
740 wsCondition.TrimLeft(); 740 wsCondition.TrimLeft();
741 wsCondition.TrimRight(); 741 wsCondition.TrimRight();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 resolveNodeRS.dwFlags = XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll; 806 resolveNodeRS.dwFlags = XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll;
807 } 807 }
808 } 808 }
809 return resolveNodeRS.nodes.GetSize(); 809 return resolveNodeRS.nodes.GetSize();
810 } 810 }
811 void CXFA_ResolveProcessor::XFA_ResolveNode_SetIndexDataBind( 811 void CXFA_ResolveProcessor::XFA_ResolveNode_SetIndexDataBind(
812 CFX_WideString& wsNextCondition, 812 CFX_WideString& wsNextCondition,
813 int32_t& iIndex, 813 int32_t& iIndex,
814 int32_t iCount) { 814 int32_t iCount) {
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 }
825 825
826 CXFA_ResolveNodesData::CXFA_ResolveNodesData(CXFA_ScriptContext* pSC) 826 CXFA_ResolveNodesData::CXFA_ResolveNodesData(CXFA_ScriptContext* pSC)
827 : m_pSC(pSC), 827 : m_pSC(pSC),
828 m_CurNode(NULL), 828 m_CurNode(NULL),
829 m_wsName(), 829 m_wsName(),
830 m_uHashName(XFA_HASHCODE_None), 830 m_uHashName(XFA_HASHCODE_None),
831 m_wsCondition(), 831 m_wsCondition(),
832 m_nLevel(0), 832 m_nLevel(0),
833 m_Nodes(), 833 m_Nodes(),
834 m_dwStyles(XFA_RESOLVENODE_Children), 834 m_dwStyles(XFA_RESOLVENODE_Children),
835 m_pScriptAttribute(NULL), 835 m_pScriptAttribute(NULL),
836 m_dwFlag(XFA_RESOVENODE_RSTYPE_Nodes) {} 836 m_dwFlag(XFA_RESOVENODE_RSTYPE_Nodes) {}
837 837
838 CXFA_ResolveNodesData::~CXFA_ResolveNodesData() { 838 CXFA_ResolveNodesData::~CXFA_ResolveNodesData() {
839 m_Nodes.RemoveAll(); 839 m_Nodes.RemoveAll();
840 } 840 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_script_nodehelper.cpp ('k') | xfa/fxfa/parser/xfa_script_signaturepseudomodel.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698