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

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

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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 | « xfa/fxfa/parser/xfa_document_datamerger_imp.h ('k') | xfa/fxfa/parser/xfa_layout_itemlayout.h » ('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 "xfa/fxfa/parser/xfa_document_datamerger_imp.h" 7 #include "xfa/fxfa/parser/xfa_document_datamerger_imp.h"
8 8
9 #include "core/fxcrt/fx_ext.h" 9 #include "core/fxcrt/fx_ext.h"
10 #include "xfa/fde/xml/fde_xml_imp.h" 10 #include "xfa/fde/xml/fde_xml_imp.h"
(...skipping 19 matching lines...) Expand all
30 static CXFA_Node* GetParent(CXFA_Node* pDDGroupNode) { 30 static CXFA_Node* GetParent(CXFA_Node* pDDGroupNode) {
31 return pDDGroupNode->GetNodeItem(XFA_NODEITEM_Parent); 31 return pDDGroupNode->GetNodeItem(XFA_NODEITEM_Parent);
32 } 32 }
33 }; 33 };
34 34
35 struct RecurseRecord { 35 struct RecurseRecord {
36 CXFA_Node* pTemplateChild; 36 CXFA_Node* pTemplateChild;
37 CXFA_Node* pDataChild; 37 CXFA_Node* pDataChild;
38 }; 38 };
39 39
40 FX_BOOL GetOccurInfo(CXFA_Node* pOccurNode, 40 bool GetOccurInfo(CXFA_Node* pOccurNode,
41 int32_t& iMin, 41 int32_t& iMin,
42 int32_t& iMax, 42 int32_t& iMax,
43 int32_t& iInit) { 43 int32_t& iInit) {
44 if (!pOccurNode) 44 if (!pOccurNode)
45 return FALSE; 45 return false;
46 46
47 CXFA_Occur occur(pOccurNode); 47 CXFA_Occur occur(pOccurNode);
48 return occur.GetOccurInfo(iMin, iMax, iInit); 48 return occur.GetOccurInfo(iMin, iMax, iInit);
49 } 49 }
50 50
51 CXFA_Node* FormValueNode_CreateChild(CXFA_Node* pValueNode, XFA_Element iType) { 51 CXFA_Node* FormValueNode_CreateChild(CXFA_Node* pValueNode, XFA_Element iType) {
52 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild); 52 CXFA_Node* pChildNode = pValueNode->GetNodeItem(XFA_NODEITEM_FirstChild);
53 if (!pChildNode) { 53 if (!pChildNode) {
54 if (iType == XFA_Element::Unknown) 54 if (iType == XFA_Element::Unknown)
55 return nullptr; 55 return nullptr;
56 pChildNode = pValueNode->GetProperty(0, iType); 56 pChildNode = pValueNode->GetProperty(0, iType);
57 } 57 }
58 return pChildNode; 58 return pChildNode;
59 } 59 }
60 60
61 void FormValueNode_MatchNoneCreateChild(CXFA_Node* pFormNode) { 61 void FormValueNode_MatchNoneCreateChild(CXFA_Node* pFormNode) {
62 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); 62 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
63 ASSERT(pWidgetData); 63 ASSERT(pWidgetData);
64 pWidgetData->GetUIType(); 64 pWidgetData->GetUIType();
65 } 65 }
66 66
67 FX_BOOL FormValueNode_SetChildContent( 67 bool FormValueNode_SetChildContent(CXFA_Node* pValueNode,
68 CXFA_Node* pValueNode, 68 const CFX_WideString& wsContent,
69 const CFX_WideString& wsContent, 69 XFA_Element iType = XFA_Element::Unknown) {
70 XFA_Element iType = XFA_Element::Unknown) {
71 if (!pValueNode) 70 if (!pValueNode)
72 return FALSE; 71 return false;
73 72
74 ASSERT(pValueNode->GetPacketID() == XFA_XDPPACKET_Form); 73 ASSERT(pValueNode->GetPacketID() == XFA_XDPPACKET_Form);
75 CXFA_Node* pChildNode = FormValueNode_CreateChild(pValueNode, iType); 74 CXFA_Node* pChildNode = FormValueNode_CreateChild(pValueNode, iType);
76 if (!pChildNode) 75 if (!pChildNode)
77 return FALSE; 76 return false;
78 77
79 switch (pChildNode->GetObjectType()) { 78 switch (pChildNode->GetObjectType()) {
80 case XFA_ObjectType::ContentNode: { 79 case XFA_ObjectType::ContentNode: {
81 CXFA_Node* pContentRawDataNode = 80 CXFA_Node* pContentRawDataNode =
82 pChildNode->GetNodeItem(XFA_NODEITEM_FirstChild); 81 pChildNode->GetNodeItem(XFA_NODEITEM_FirstChild);
83 if (!pContentRawDataNode) { 82 if (!pContentRawDataNode) {
84 XFA_Element element = XFA_Element::Sharptext; 83 XFA_Element element = XFA_Element::Sharptext;
85 if (pChildNode->GetElementType() == XFA_Element::ExData) { 84 if (pChildNode->GetElementType() == XFA_Element::ExData) {
86 CFX_WideString wsContentType; 85 CFX_WideString wsContentType;
87 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, 86 pChildNode->GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType,
88 FALSE); 87 false);
89 if (wsContentType == FX_WSTRC(L"text/html")) 88 if (wsContentType == FX_WSTRC(L"text/html"))
90 element = XFA_Element::SharpxHTML; 89 element = XFA_Element::SharpxHTML;
91 else if (wsContentType == FX_WSTRC(L"text/xml")) 90 else if (wsContentType == FX_WSTRC(L"text/xml"))
92 element = XFA_Element::Sharpxml; 91 element = XFA_Element::Sharpxml;
93 } 92 }
94 pContentRawDataNode = pChildNode->CreateSamePacketNode(element); 93 pContentRawDataNode = pChildNode->CreateSamePacketNode(element);
95 pChildNode->InsertChild(pContentRawDataNode); 94 pChildNode->InsertChild(pContentRawDataNode);
96 } 95 }
97 pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); 96 pContentRawDataNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
98 break; 97 break;
99 } 98 }
100 case XFA_ObjectType::NodeC: 99 case XFA_ObjectType::NodeC:
101 case XFA_ObjectType::TextNode: 100 case XFA_ObjectType::TextNode:
102 case XFA_ObjectType::NodeV: { 101 case XFA_ObjectType::NodeV: {
103 pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent); 102 pChildNode->SetCData(XFA_ATTRIBUTE_Value, wsContent);
104 break; 103 break;
105 } 104 }
106 default: 105 default:
107 ASSERT(FALSE); 106 ASSERT(false);
108 break; 107 break;
109 } 108 }
110 return TRUE; 109 return true;
111 } 110 }
112 111
113 void CreateDataBinding(CXFA_Node* pFormNode, 112 void CreateDataBinding(CXFA_Node* pFormNode,
114 CXFA_Node* pDataNode, 113 CXFA_Node* pDataNode,
115 FX_BOOL bDataToForm) { 114 bool bDataToForm) {
116 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode); 115 pFormNode->SetObject(XFA_ATTRIBUTE_BindingNode, pDataNode);
117 pDataNode->AddBindItem(pFormNode); 116 pDataNode->AddBindItem(pFormNode);
118 XFA_Element eType = pFormNode->GetElementType(); 117 XFA_Element eType = pFormNode->GetElementType();
119 if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) 118 if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup)
120 return; 119 return;
121 120
122 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); 121 CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData();
123 ASSERT(pWidgetData); 122 ASSERT(pWidgetData);
124 XFA_Element eUIType = pWidgetData->GetUIType(); 123 XFA_Element eUIType = pWidgetData->GetUIType();
125 CXFA_Value defValue(pFormNode->GetProperty(0, XFA_Element::Value)); 124 CXFA_Value defValue(pFormNode->GetProperty(0, XFA_Element::Value));
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue, 314 FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue,
316 XFA_Element::Text); 315 XFA_Element::Text);
317 } 316 }
318 break; 317 break;
319 case XFA_Element::CheckButton: 318 case XFA_Element::CheckButton:
320 FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue, 319 FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue,
321 XFA_Element::Text); 320 XFA_Element::Text);
322 break; 321 break;
323 case XFA_Element::ExclGroup: { 322 case XFA_Element::ExclGroup: {
324 pWidgetData->SetSelectedMemberByValue(wsNormalizeValue.AsStringC(), false, 323 pWidgetData->SetSelectedMemberByValue(wsNormalizeValue.AsStringC(), false,
325 FALSE, FALSE); 324 false, false);
326 break; 325 break;
327 } 326 }
328 case XFA_Element::DateTimeEdit: 327 case XFA_Element::DateTimeEdit:
329 FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue, 328 FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue,
330 XFA_Element::DateTime); 329 XFA_Element::DateTime);
331 break; 330 break;
332 case XFA_Element::NumericEdit: { 331 case XFA_Element::NumericEdit: {
333 CFX_WideString wsPicture; 332 CFX_WideString wsPicture;
334 pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind); 333 pWidgetData->GetPictureContent(wsPicture, XFA_VALUEPICTURE_DataBind);
335 if (wsPicture.IsEmpty()) { 334 if (wsPicture.IsEmpty()) {
(...skipping 25 matching lines...) Expand all
361 360
362 void RegisterGlobalBinding(CXFA_Document* pDocument, 361 void RegisterGlobalBinding(CXFA_Document* pDocument,
363 uint32_t dwNameHash, 362 uint32_t dwNameHash,
364 CXFA_Node* pDataNode) { 363 CXFA_Node* pDataNode) {
365 pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode); 364 pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode);
366 } 365 }
367 366
368 CXFA_Node* ScopeMatchGlobalBinding(CXFA_Node* pDataScope, 367 CXFA_Node* ScopeMatchGlobalBinding(CXFA_Node* pDataScope,
369 uint32_t dwNameHash, 368 uint32_t dwNameHash,
370 XFA_Element eMatchDataNodeType, 369 XFA_Element eMatchDataNodeType,
371 FX_BOOL bUpLevel) { 370 bool bUpLevel) {
372 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = nullptr; 371 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = nullptr;
373 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; 372 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets;
374 pLastDataScope = pCurDataScope, 373 pLastDataScope = pCurDataScope,
375 pCurDataScope = 374 pCurDataScope =
376 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { 375 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) {
377 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); 376 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash);
378 pDataChild; 377 pDataChild;
379 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { 378 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) {
380 if (pDataChild == pLastDataScope || 379 if (pDataChild == pLastDataScope ||
381 (eMatchDataNodeType != XFA_Element::DataModel && 380 (eMatchDataNodeType != XFA_Element::DataModel &&
382 pDataChild->GetElementType() != eMatchDataNodeType) || 381 pDataChild->GetElementType() != eMatchDataNodeType) ||
383 pDataChild->HasBindItem()) { 382 pDataChild->HasBindItem()) {
384 continue; 383 continue;
385 } 384 }
386 return pDataChild; 385 return pDataChild;
387 } 386 }
388 387
389 for (CXFA_Node* pDataChild = 388 for (CXFA_Node* pDataChild =
390 pCurDataScope->GetFirstChildByClass(XFA_Element::DataGroup); 389 pCurDataScope->GetFirstChildByClass(XFA_Element::DataGroup);
391 pDataChild; pDataChild = pDataChild->GetNextSameClassSibling( 390 pDataChild; pDataChild = pDataChild->GetNextSameClassSibling(
392 XFA_Element::DataGroup)) { 391 XFA_Element::DataGroup)) {
393 CXFA_Node* pDataNode = ScopeMatchGlobalBinding(pDataChild, dwNameHash, 392 CXFA_Node* pDataNode = ScopeMatchGlobalBinding(pDataChild, dwNameHash,
394 eMatchDataNodeType, FALSE); 393 eMatchDataNodeType, false);
395 if (pDataNode) 394 if (pDataNode)
396 return pDataNode; 395 return pDataNode;
397 } 396 }
398 if (!bUpLevel) 397 if (!bUpLevel)
399 break; 398 break;
400 } 399 }
401 return nullptr; 400 return nullptr;
402 } 401 }
403 402
404 CXFA_Node* FindGlobalDataNode(CXFA_Document* pDocument, 403 CXFA_Node* FindGlobalDataNode(CXFA_Document* pDocument,
405 CFX_WideStringC wsName, 404 CFX_WideStringC wsName,
406 CXFA_Node* pDataScope, 405 CXFA_Node* pDataScope,
407 XFA_Element eMatchNodeType) { 406 XFA_Element eMatchNodeType) {
408 if (wsName.IsEmpty()) 407 if (wsName.IsEmpty())
409 return nullptr; 408 return nullptr;
410 409
411 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); 410 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false);
412 CXFA_Node* pBounded = GetGlobalBinding(pDocument, dwNameHash); 411 CXFA_Node* pBounded = GetGlobalBinding(pDocument, dwNameHash);
413 if (!pBounded) { 412 if (!pBounded) {
414 pBounded = 413 pBounded =
415 ScopeMatchGlobalBinding(pDataScope, dwNameHash, eMatchNodeType, TRUE); 414 ScopeMatchGlobalBinding(pDataScope, dwNameHash, eMatchNodeType, true);
416 if (pBounded) 415 if (pBounded)
417 RegisterGlobalBinding(pDocument, dwNameHash, pBounded); 416 RegisterGlobalBinding(pDocument, dwNameHash, pBounded);
418 } 417 }
419 return pBounded; 418 return pBounded;
420 } 419 }
421 420
422 CXFA_Node* FindOnceDataNode(CXFA_Document* pDocument, 421 CXFA_Node* FindOnceDataNode(CXFA_Document* pDocument,
423 CFX_WideStringC wsName, 422 CFX_WideStringC wsName,
424 CXFA_Node* pDataScope, 423 CXFA_Node* pDataScope,
425 XFA_Element eMatchNodeType) { 424 XFA_Element eMatchNodeType) {
(...skipping 18 matching lines...) Expand all
444 pLastDataScope = pCurDataScope; 443 pLastDataScope = pCurDataScope;
445 } 444 }
446 return nullptr; 445 return nullptr;
447 } 446 }
448 447
449 CXFA_Node* FindDataRefDataNode(CXFA_Document* pDocument, 448 CXFA_Node* FindDataRefDataNode(CXFA_Document* pDocument,
450 CFX_WideStringC wsRef, 449 CFX_WideStringC wsRef,
451 CXFA_Node* pDataScope, 450 CXFA_Node* pDataScope,
452 XFA_Element eMatchNodeType, 451 XFA_Element eMatchNodeType,
453 CXFA_Node* pTemplateNode, 452 CXFA_Node* pTemplateNode,
454 FX_BOOL bForceBind, 453 bool bForceBind,
455 FX_BOOL bUpLevel) { 454 bool bUpLevel) {
456 uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew; 455 uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew;
457 if (bUpLevel || wsRef != FX_WSTRC(L"name")) 456 if (bUpLevel || wsRef != FX_WSTRC(L"name"))
458 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); 457 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings);
459 458
460 XFA_RESOLVENODE_RS rs; 459 XFA_RESOLVENODE_RS rs;
461 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags, 460 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags,
462 pTemplateNode); 461 pTemplateNode);
463 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll || 462 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll ||
464 rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll || 463 rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll ||
465 rs.nodes.GetSize() > 1) { 464 rs.nodes.GetSize() > 1) {
466 return pDocument->GetNotBindNode(rs.nodes); 465 return pDocument->GetNotBindNode(rs.nodes);
467 } 466 }
468 467
469 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { 468 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) {
470 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : nullptr; 469 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : nullptr;
471 CXFA_Node* pNode = ToNode(pObject); 470 CXFA_Node* pNode = ToNode(pObject);
472 return (bForceBind || !pNode || !pNode->HasBindItem()) ? pNode : nullptr; 471 return (bForceBind || !pNode || !pNode->HasBindItem()) ? pNode : nullptr;
473 } 472 }
474 return nullptr; 473 return nullptr;
475 } 474 }
476 475
477 FX_BOOL NeedGenerateForm(CXFA_Node* pTemplateChild, 476 bool NeedGenerateForm(CXFA_Node* pTemplateChild, bool bUseInstanceManager) {
478 FX_BOOL bUseInstanceManager) {
479 XFA_Element eType = pTemplateChild->GetElementType(); 477 XFA_Element eType = pTemplateChild->GetElementType();
480 if (eType == XFA_Element::Variables) 478 if (eType == XFA_Element::Variables)
481 return TRUE; 479 return true;
482 if (pTemplateChild->IsContainerNode()) 480 if (pTemplateChild->IsContainerNode())
483 return FALSE; 481 return false;
484 if (eType == XFA_Element::Proto || 482 if (eType == XFA_Element::Proto ||
485 (bUseInstanceManager && eType == XFA_Element::Occur)) { 483 (bUseInstanceManager && eType == XFA_Element::Occur)) {
486 return FALSE; 484 return false;
487 } 485 }
488 return TRUE; 486 return true;
489 } 487 }
490 488
491 CXFA_Node* CloneOrMergeInstanceManager(CXFA_Document* pDocument, 489 CXFA_Node* CloneOrMergeInstanceManager(CXFA_Document* pDocument,
492 CXFA_Node* pFormParent, 490 CXFA_Node* pFormParent,
493 CXFA_Node* pTemplateNode, 491 CXFA_Node* pTemplateNode,
494 CXFA_NodeArray& subforms) { 492 CXFA_NodeArray& subforms) {
495 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); 493 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
496 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; 494 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName;
497 uint32_t dwInstNameHash = 495 uint32_t dwInstNameHash =
498 FX_HashCode_GetW(wsInstMgrNodeName.AsStringC(), false); 496 FX_HashCode_GetW(wsInstMgrNodeName.AsStringC(), false);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName); 532 pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName);
535 pFormParent->InsertChild(pNewNode, nullptr); 533 pFormParent->InsertChild(pNewNode, nullptr);
536 pNewNode->SetTemplateNode(pTemplateNode); 534 pNewNode->SetTemplateNode(pTemplateNode);
537 return pNewNode; 535 return pNewNode;
538 } 536 }
539 537
540 CXFA_Node* FindMatchingDataNode( 538 CXFA_Node* FindMatchingDataNode(
541 CXFA_Document* pDocument, 539 CXFA_Document* pDocument,
542 CXFA_Node* pTemplateNode, 540 CXFA_Node* pTemplateNode,
543 CXFA_Node* pDataScope, 541 CXFA_Node* pDataScope,
544 FX_BOOL& bAccessedDataDOM, 542 bool& bAccessedDataDOM,
545 FX_BOOL bForceBind, 543 bool bForceBind,
546 CXFA_NodeIteratorTemplate<CXFA_Node, 544 CXFA_NodeIteratorTemplate<CXFA_Node,
547 CXFA_TraverseStrategy_XFAContainerNode>* 545 CXFA_TraverseStrategy_XFAContainerNode>*
548 pIterator, 546 pIterator,
549 FX_BOOL& bSelfMatch, 547 bool& bSelfMatch,
550 XFA_ATTRIBUTEENUM& eBindMatch, 548 XFA_ATTRIBUTEENUM& eBindMatch,
551 FX_BOOL bUpLevel) { 549 bool bUpLevel) {
552 FX_BOOL bOwnIterator = FALSE; 550 bool bOwnIterator = false;
553 if (!pIterator) { 551 if (!pIterator) {
554 bOwnIterator = TRUE; 552 bOwnIterator = true;
555 pIterator = new CXFA_NodeIteratorTemplate< 553 pIterator = new CXFA_NodeIteratorTemplate<
556 CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode); 554 CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode);
557 } 555 }
558 556
559 CXFA_Node* pResult = nullptr; 557 CXFA_Node* pResult = nullptr;
560 for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); 558 for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent();
561 pCurTemplateNode;) { 559 pCurTemplateNode;) {
562 XFA_Element eMatchNodeType; 560 XFA_Element eMatchNodeType;
563 switch (pCurTemplateNode->GetElementType()) { 561 switch (pCurTemplateNode->GetElementType()) {
564 case XFA_Element::Subform: 562 case XFA_Element::Subform:
(...skipping 24 matching lines...) Expand all
589 pCurTemplateNode->GetFirstChildByClass(XFA_Element::Bind); 587 pCurTemplateNode->GetFirstChildByClass(XFA_Element::Bind);
590 XFA_ATTRIBUTEENUM eMatch = 588 XFA_ATTRIBUTEENUM eMatch =
591 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) 589 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match)
592 : XFA_ATTRIBUTEENUM_Once; 590 : XFA_ATTRIBUTEENUM_Once;
593 eBindMatch = eMatch; 591 eBindMatch = eMatch;
594 switch (eMatch) { 592 switch (eMatch) {
595 case XFA_ATTRIBUTEENUM_None: 593 case XFA_ATTRIBUTEENUM_None:
596 pCurTemplateNode = pIterator->MoveToNext(); 594 pCurTemplateNode = pIterator->MoveToNext();
597 continue; 595 continue;
598 case XFA_ATTRIBUTEENUM_Global: 596 case XFA_ATTRIBUTEENUM_Global:
599 bAccessedDataDOM = TRUE; 597 bAccessedDataDOM = true;
600 if (!bForceBind) { 598 if (!bForceBind) {
601 pCurTemplateNode = pIterator->MoveToNext(); 599 pCurTemplateNode = pIterator->MoveToNext();
602 continue; 600 continue;
603 } 601 }
604 if (eMatchNodeType == XFA_Element::DataValue || 602 if (eMatchNodeType == XFA_Element::DataValue ||
605 (eMatchNodeType == XFA_Element::DataGroup && 603 (eMatchNodeType == XFA_Element::DataGroup &&
606 XFA_FieldIsMultiListBox(pTemplateNodeBind))) { 604 XFA_FieldIsMultiListBox(pTemplateNodeBind))) {
607 CXFA_Node* pGlobalBindNode = FindGlobalDataNode( 605 CXFA_Node* pGlobalBindNode = FindGlobalDataNode(
608 pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name), 606 pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name),
609 pDataScope, eMatchNodeType); 607 pDataScope, eMatchNodeType);
610 if (!pGlobalBindNode) { 608 if (!pGlobalBindNode) {
611 pCurTemplateNode = pIterator->MoveToNext(); 609 pCurTemplateNode = pIterator->MoveToNext();
612 continue; 610 continue;
613 } 611 }
614 pResult = pGlobalBindNode; 612 pResult = pGlobalBindNode;
615 break; 613 break;
616 } 614 }
617 case XFA_ATTRIBUTEENUM_Once: { 615 case XFA_ATTRIBUTEENUM_Once: {
618 bAccessedDataDOM = TRUE; 616 bAccessedDataDOM = true;
619 CXFA_Node* pOnceBindNode = FindOnceDataNode( 617 CXFA_Node* pOnceBindNode = FindOnceDataNode(
620 pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name), 618 pDocument, pCurTemplateNode->GetCData(XFA_ATTRIBUTE_Name),
621 pDataScope, eMatchNodeType); 619 pDataScope, eMatchNodeType);
622 if (!pOnceBindNode) { 620 if (!pOnceBindNode) {
623 pCurTemplateNode = pIterator->MoveToNext(); 621 pCurTemplateNode = pIterator->MoveToNext();
624 continue; 622 continue;
625 } 623 }
626 pResult = pOnceBindNode; 624 pResult = pOnceBindNode;
627 break; 625 break;
628 } 626 }
629 case XFA_ATTRIBUTEENUM_DataRef: { 627 case XFA_ATTRIBUTEENUM_DataRef: {
630 bAccessedDataDOM = TRUE; 628 bAccessedDataDOM = true;
631 CXFA_Node* pDataRefBindNode = FindDataRefDataNode( 629 CXFA_Node* pDataRefBindNode = FindDataRefDataNode(
632 pDocument, pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref), 630 pDocument, pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref),
633 pDataScope, eMatchNodeType, pTemplateNode, bForceBind, bUpLevel); 631 pDataScope, eMatchNodeType, pTemplateNode, bForceBind, bUpLevel);
634 if (pDataRefBindNode && 632 if (pDataRefBindNode &&
635 pDataRefBindNode->GetElementType() == eMatchNodeType) { 633 pDataRefBindNode->GetElementType() == eMatchNodeType) {
636 pResult = pDataRefBindNode; 634 pResult = pDataRefBindNode;
637 } 635 }
638 if (!pResult) { 636 if (!pResult) {
639 pCurTemplateNode = pIterator->SkipChildrenAndMoveToNext(); 637 pCurTemplateNode = pIterator->SkipChildrenAndMoveToNext();
640 continue; 638 continue;
641 } 639 }
642 break; 640 break;
643 } 641 }
644 default: 642 default:
645 break; 643 break;
646 } 644 }
647 if (pCurTemplateNode == pTemplateNode && pResult) 645 if (pCurTemplateNode == pTemplateNode && pResult)
648 bSelfMatch = TRUE; 646 bSelfMatch = true;
649 break; 647 break;
650 } 648 }
651 if (bOwnIterator) 649 if (bOwnIterator)
652 delete pIterator; 650 delete pIterator;
653 return pResult; 651 return pResult;
654 } 652 }
655 653
656 void SortRecurseRecord(CFX_ArrayTemplate<RecurseRecord>& rgRecords, 654 void SortRecurseRecord(CFX_ArrayTemplate<RecurseRecord>& rgRecords,
657 CXFA_Node* pDataScope, 655 CXFA_Node* pDataScope,
658 FX_BOOL bChoiceMode) { 656 bool bChoiceMode) {
659 int32_t iCount = rgRecords.GetSize(); 657 int32_t iCount = rgRecords.GetSize();
660 CFX_ArrayTemplate<RecurseRecord> rgResultRecord; 658 CFX_ArrayTemplate<RecurseRecord> rgResultRecord;
661 for (CXFA_Node* pChildNode = pDataScope->GetNodeItem(XFA_NODEITEM_FirstChild); 659 for (CXFA_Node* pChildNode = pDataScope->GetNodeItem(XFA_NODEITEM_FirstChild);
662 pChildNode; 660 pChildNode;
663 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 661 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
664 for (int32_t i = 0; i < iCount; i++) { 662 for (int32_t i = 0; i < iCount; i++) {
665 CXFA_Node* pNode = rgRecords[i].pDataChild; 663 CXFA_Node* pNode = rgRecords[i].pDataChild;
666 if (pChildNode == pNode) { 664 if (pChildNode == pNode) {
667 RecurseRecord sNewRecord = {rgRecords[i].pTemplateChild, pNode}; 665 RecurseRecord sNewRecord = {rgRecords[i].pTemplateChild, pNode};
668 rgResultRecord.Add(sNewRecord); 666 rgResultRecord.Add(sNewRecord);
(...skipping 16 matching lines...) Expand all
685 } 683 }
686 rgRecords.RemoveAll(); 684 rgRecords.RemoveAll();
687 rgRecords.Copy(rgResultRecord); 685 rgRecords.Copy(rgResultRecord);
688 } 686 }
689 } 687 }
690 688
691 CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument, 689 CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument,
692 CXFA_Node* pTemplateNode, 690 CXFA_Node* pTemplateNode,
693 CXFA_Node* pFormParentNode, 691 CXFA_Node* pFormParentNode,
694 CXFA_Node* pDataScope, 692 CXFA_Node* pDataScope,
695 FX_BOOL bOneInstance, 693 bool bOneInstance,
696 FX_BOOL bDataMerge) { 694 bool bDataMerge) {
697 XFA_Element eType = pTemplateNode->GetElementType(); 695 XFA_Element eType = pTemplateNode->GetElementType();
698 CXFA_Node* pOccurNode = nullptr; 696 CXFA_Node* pOccurNode = nullptr;
699 CXFA_Node* pFirstInstance = nullptr; 697 CXFA_Node* pFirstInstance = nullptr;
700 FX_BOOL bUseInstanceManager = 698 bool bUseInstanceManager =
701 pFormParentNode->GetElementType() != XFA_Element::Area; 699 pFormParentNode->GetElementType() != XFA_Element::Area;
702 CXFA_Node* pInstMgrNode = nullptr; 700 CXFA_Node* pInstMgrNode = nullptr;
703 CXFA_NodeArray subformArray; 701 CXFA_NodeArray subformArray;
704 CXFA_NodeArray* pSearchArray = nullptr; 702 CXFA_NodeArray* pSearchArray = nullptr;
705 if (!bOneInstance && 703 if (!bOneInstance &&
706 (eType == XFA_Element::SubformSet || eType == XFA_Element::Subform)) { 704 (eType == XFA_Element::SubformSet || eType == XFA_Element::Subform)) {
707 pInstMgrNode = bUseInstanceManager ? CloneOrMergeInstanceManager( 705 pInstMgrNode = bUseInstanceManager ? CloneOrMergeInstanceManager(
708 pDocument, pFormParentNode, 706 pDocument, pFormParentNode,
709 pTemplateNode, subformArray) 707 pTemplateNode, subformArray)
710 : nullptr; 708 : nullptr;
711 if (CXFA_Node* pOccurTemplateNode = 709 if (CXFA_Node* pOccurTemplateNode =
712 pTemplateNode->GetFirstChildByClass(XFA_Element::Occur)) { 710 pTemplateNode->GetFirstChildByClass(XFA_Element::Occur)) {
713 pOccurNode = pInstMgrNode ? XFA_NodeMerge_CloneOrMergeContainer( 711 pOccurNode = pInstMgrNode ? XFA_NodeMerge_CloneOrMergeContainer(
714 pDocument, pInstMgrNode, 712 pDocument, pInstMgrNode,
715 pOccurTemplateNode, FALSE, nullptr) 713 pOccurTemplateNode, false, nullptr)
716 : pOccurTemplateNode; 714 : pOccurTemplateNode;
717 } else if (pInstMgrNode) { 715 } else if (pInstMgrNode) {
718 pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_Element::Occur); 716 pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_Element::Occur);
719 if (pOccurNode) 717 if (pOccurNode)
720 pOccurNode->ClearFlag(XFA_NodeFlag_UnusedNode); 718 pOccurNode->ClearFlag(XFA_NodeFlag_UnusedNode);
721 } 719 }
722 if (pInstMgrNode) { 720 if (pInstMgrNode) {
723 pInstMgrNode->SetFlag(XFA_NodeFlag_Initialized, true); 721 pInstMgrNode->SetFlag(XFA_NodeFlag_Initialized, true);
724 pSearchArray = &subformArray; 722 pSearchArray = &subformArray;
725 if (pFormParentNode->GetElementType() == XFA_Element::PageArea) { 723 if (pFormParentNode->GetElementType() == XFA_Element::PageArea) {
726 bOneInstance = TRUE; 724 bOneInstance = true;
727 if (subformArray.GetSize() < 1) 725 if (subformArray.GetSize() < 1)
728 pSearchArray = nullptr; 726 pSearchArray = nullptr;
729 } else if ((pTemplateNode->GetNameHash() == 0) && 727 } else if ((pTemplateNode->GetNameHash() == 0) &&
730 (subformArray.GetSize() < 1)) { 728 (subformArray.GetSize() < 1)) {
731 pSearchArray = nullptr; 729 pSearchArray = nullptr;
732 } 730 }
733 } 731 }
734 } 732 }
735 733
736 int32_t iMax = 1; 734 int32_t iMax = 1;
737 int32_t iInit = 1; 735 int32_t iInit = 1;
738 int32_t iMin = 1; 736 int32_t iMin = 1;
739 if (!bOneInstance) 737 if (!bOneInstance)
740 GetOccurInfo(pOccurNode, iMin, iMax, iInit); 738 GetOccurInfo(pOccurNode, iMin, iMax, iInit);
741 739
742 XFA_ATTRIBUTEENUM eRelation = 740 XFA_ATTRIBUTEENUM eRelation =
743 eType == XFA_Element::SubformSet 741 eType == XFA_Element::SubformSet
744 ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation) 742 ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation)
745 : XFA_ATTRIBUTEENUM_Ordered; 743 : XFA_ATTRIBUTEENUM_Ordered;
746 int32_t iCurRepeatIndex = 0; 744 int32_t iCurRepeatIndex = 0;
747 XFA_ATTRIBUTEENUM eParentBindMatch = XFA_ATTRIBUTEENUM_None; 745 XFA_ATTRIBUTEENUM eParentBindMatch = XFA_ATTRIBUTEENUM_None;
748 if (bDataMerge) { 746 if (bDataMerge) {
749 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode> 747 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>
750 sNodeIterator(pTemplateNode); 748 sNodeIterator(pTemplateNode);
751 FX_BOOL bAccessedDataDOM = FALSE; 749 bool bAccessedDataDOM = false;
752 if (eType == XFA_Element::SubformSet || eType == XFA_Element::Area) { 750 if (eType == XFA_Element::SubformSet || eType == XFA_Element::Area) {
753 sNodeIterator.MoveToNext(); 751 sNodeIterator.MoveToNext();
754 } else { 752 } else {
755 CFX_MapPtrTemplate<CXFA_Node*, CXFA_Node*> subformMapArray; 753 CFX_MapPtrTemplate<CXFA_Node*, CXFA_Node*> subformMapArray;
756 CXFA_NodeArray nodeArray; 754 CXFA_NodeArray nodeArray;
757 for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { 755 for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) {
758 FX_BOOL bSelfMatch = FALSE; 756 bool bSelfMatch = false;
759 XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; 757 XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None;
760 CXFA_Node* pDataNode = FindMatchingDataNode( 758 CXFA_Node* pDataNode = FindMatchingDataNode(
761 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, FALSE, 759 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, false,
762 &sNodeIterator, bSelfMatch, eBindMatch, TRUE); 760 &sNodeIterator, bSelfMatch, eBindMatch, true);
763 if (!pDataNode || sNodeIterator.GetCurrent() != pTemplateNode) 761 if (!pDataNode || sNodeIterator.GetCurrent() != pTemplateNode)
764 break; 762 break;
765 763
766 eParentBindMatch = eBindMatch; 764 eParentBindMatch = eBindMatch;
767 CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer( 765 CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer(
768 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); 766 pDocument, pFormParentNode, pTemplateNode, false, pSearchArray);
769 if (!pFirstInstance) 767 if (!pFirstInstance)
770 pFirstInstance = pSubformNode; 768 pFirstInstance = pSubformNode;
771 769
772 CreateDataBinding(pSubformNode, pDataNode, TRUE); 770 CreateDataBinding(pSubformNode, pDataNode, true);
773 ASSERT(pSubformNode); 771 ASSERT(pSubformNode);
774 subformMapArray.SetAt(pSubformNode, pDataNode); 772 subformMapArray.SetAt(pSubformNode, pDataNode);
775 nodeArray.Add(pSubformNode); 773 nodeArray.Add(pSubformNode);
776 } 774 }
777 775
778 subformMapArray.GetStartPosition(); 776 subformMapArray.GetStartPosition();
779 for (int32_t iIndex = 0; iIndex < nodeArray.GetSize(); iIndex++) { 777 for (int32_t iIndex = 0; iIndex < nodeArray.GetSize(); iIndex++) {
780 CXFA_Node* pSubform = nodeArray[iIndex]; 778 CXFA_Node* pSubform = nodeArray[iIndex];
781 CXFA_Node* pDataNode = 779 CXFA_Node* pDataNode =
782 reinterpret_cast<CXFA_Node*>(subformMapArray.GetValueAt(pSubform)); 780 reinterpret_cast<CXFA_Node*>(subformMapArray.GetValueAt(pSubform));
783 for (CXFA_Node* pTemplateChild = 781 for (CXFA_Node* pTemplateChild =
784 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); 782 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
785 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( 783 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
786 XFA_NODEITEM_NextSibling)) { 784 XFA_NODEITEM_NextSibling)) {
787 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { 785 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
788 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubform, 786 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubform,
789 pTemplateChild, TRUE, nullptr); 787 pTemplateChild, true, nullptr);
790 } else if (pTemplateChild->IsContainerNode()) { 788 } else if (pTemplateChild->IsContainerNode()) {
791 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubform, 789 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubform,
792 pDataNode, FALSE, TRUE, FALSE); 790 pDataNode, false, true, false);
793 } 791 }
794 } 792 }
795 } 793 }
796 subformMapArray.RemoveAll(); 794 subformMapArray.RemoveAll();
797 } 795 }
798 796
799 for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) { 797 for (; iMax < 0 || iCurRepeatIndex < iMax; iCurRepeatIndex++) {
800 FX_BOOL bSelfMatch = FALSE; 798 bool bSelfMatch = false;
801 XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None; 799 XFA_ATTRIBUTEENUM eBindMatch = XFA_ATTRIBUTEENUM_None;
802 if (!FindMatchingDataNode(pDocument, pTemplateNode, pDataScope, 800 if (!FindMatchingDataNode(pDocument, pTemplateNode, pDataScope,
803 bAccessedDataDOM, FALSE, &sNodeIterator, 801 bAccessedDataDOM, false, &sNodeIterator,
804 bSelfMatch, eBindMatch, TRUE)) { 802 bSelfMatch, eBindMatch, true)) {
805 break; 803 break;
806 } 804 }
807 if (eBindMatch == XFA_ATTRIBUTEENUM_DataRef && 805 if (eBindMatch == XFA_ATTRIBUTEENUM_DataRef &&
808 eParentBindMatch == XFA_ATTRIBUTEENUM_DataRef) { 806 eParentBindMatch == XFA_ATTRIBUTEENUM_DataRef) {
809 break; 807 break;
810 } 808 }
811 809
812 if (eRelation == XFA_ATTRIBUTEENUM_Choice || 810 if (eRelation == XFA_ATTRIBUTEENUM_Choice ||
813 eRelation == XFA_ATTRIBUTEENUM_Unordered) { 811 eRelation == XFA_ATTRIBUTEENUM_Unordered) {
814 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( 812 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
815 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); 813 pDocument, pFormParentNode, pTemplateNode, false, pSearchArray);
816 ASSERT(pSubformSetNode); 814 ASSERT(pSubformSetNode);
817 if (!pFirstInstance) 815 if (!pFirstInstance)
818 pFirstInstance = pSubformSetNode; 816 pFirstInstance = pSubformSetNode;
819 817
820 CFX_ArrayTemplate<RecurseRecord> rgItemMatchList; 818 CFX_ArrayTemplate<RecurseRecord> rgItemMatchList;
821 CFX_ArrayTemplate<CXFA_Node*> rgItemUnmatchList; 819 CFX_ArrayTemplate<CXFA_Node*> rgItemUnmatchList;
822 for (CXFA_Node* pTemplateChild = 820 for (CXFA_Node* pTemplateChild =
823 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); 821 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
824 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( 822 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
825 XFA_NODEITEM_NextSibling)) { 823 XFA_NODEITEM_NextSibling)) {
826 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { 824 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
827 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, 825 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode,
828 pTemplateChild, TRUE, nullptr); 826 pTemplateChild, true, nullptr);
829 } else if (pTemplateChild->IsContainerNode()) { 827 } else if (pTemplateChild->IsContainerNode()) {
830 bSelfMatch = FALSE; 828 bSelfMatch = false;
831 eBindMatch = XFA_ATTRIBUTEENUM_None; 829 eBindMatch = XFA_ATTRIBUTEENUM_None;
832 if (eRelation != XFA_ATTRIBUTEENUM_Ordered) { 830 if (eRelation != XFA_ATTRIBUTEENUM_Ordered) {
833 CXFA_Node* pDataMatch = FindMatchingDataNode( 831 CXFA_Node* pDataMatch = FindMatchingDataNode(
834 pDocument, pTemplateChild, pDataScope, bAccessedDataDOM, 832 pDocument, pTemplateChild, pDataScope, bAccessedDataDOM,
835 FALSE, nullptr, bSelfMatch, eBindMatch, TRUE); 833 false, nullptr, bSelfMatch, eBindMatch, true);
836 if (pDataMatch) { 834 if (pDataMatch) {
837 RecurseRecord sNewRecord = {pTemplateChild, pDataMatch}; 835 RecurseRecord sNewRecord = {pTemplateChild, pDataMatch};
838 if (bSelfMatch) 836 if (bSelfMatch)
839 rgItemMatchList.InsertAt(0, sNewRecord); 837 rgItemMatchList.InsertAt(0, sNewRecord);
840 else 838 else
841 rgItemMatchList.Add(sNewRecord); 839 rgItemMatchList.Add(sNewRecord);
842 } else { 840 } else {
843 rgItemUnmatchList.Add(pTemplateChild); 841 rgItemUnmatchList.Add(pTemplateChild);
844 } 842 }
845 } else { 843 } else {
846 rgItemUnmatchList.Add(pTemplateChild); 844 rgItemUnmatchList.Add(pTemplateChild);
847 } 845 }
848 } 846 }
849 } 847 }
850 848
851 switch (eRelation) { 849 switch (eRelation) {
852 case XFA_ATTRIBUTEENUM_Choice: { 850 case XFA_ATTRIBUTEENUM_Choice: {
853 ASSERT(rgItemMatchList.GetSize()); 851 ASSERT(rgItemMatchList.GetSize());
854 SortRecurseRecord(rgItemMatchList, pDataScope, TRUE); 852 SortRecurseRecord(rgItemMatchList, pDataScope, true);
855 pDocument->DataMerge_CopyContainer( 853 pDocument->DataMerge_CopyContainer(
856 rgItemMatchList[0].pTemplateChild, pSubformSetNode, pDataScope, 854 rgItemMatchList[0].pTemplateChild, pSubformSetNode, pDataScope,
857 FALSE, TRUE, TRUE); 855 false, true, true);
858 break; 856 break;
859 } 857 }
860 case XFA_ATTRIBUTEENUM_Unordered: { 858 case XFA_ATTRIBUTEENUM_Unordered: {
861 if (rgItemMatchList.GetSize()) { 859 if (rgItemMatchList.GetSize()) {
862 SortRecurseRecord(rgItemMatchList, pDataScope, FALSE); 860 SortRecurseRecord(rgItemMatchList, pDataScope, false);
863 for (int32_t i = 0, count = rgItemMatchList.GetSize(); i < count; 861 for (int32_t i = 0, count = rgItemMatchList.GetSize(); i < count;
864 i++) { 862 i++) {
865 pDocument->DataMerge_CopyContainer( 863 pDocument->DataMerge_CopyContainer(
866 rgItemMatchList[i].pTemplateChild, pSubformSetNode, 864 rgItemMatchList[i].pTemplateChild, pSubformSetNode,
867 pDataScope, FALSE, TRUE, TRUE); 865 pDataScope, false, true, true);
868 } 866 }
869 } 867 }
870 for (int32_t i = 0, count = rgItemUnmatchList.GetSize(); i < count; 868 for (int32_t i = 0, count = rgItemUnmatchList.GetSize(); i < count;
871 i++) { 869 i++) {
872 pDocument->DataMerge_CopyContainer(rgItemUnmatchList[i], 870 pDocument->DataMerge_CopyContainer(rgItemUnmatchList[i],
873 pSubformSetNode, pDataScope, 871 pSubformSetNode, pDataScope,
874 FALSE, TRUE, TRUE); 872 false, true, true);
875 } 873 }
876 break; 874 break;
877 } 875 }
878 default: 876 default:
879 break; 877 break;
880 } 878 }
881 } else { 879 } else {
882 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( 880 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
883 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); 881 pDocument, pFormParentNode, pTemplateNode, false, pSearchArray);
884 ASSERT(pSubformSetNode); 882 ASSERT(pSubformSetNode);
885 if (!pFirstInstance) 883 if (!pFirstInstance)
886 pFirstInstance = pSubformSetNode; 884 pFirstInstance = pSubformSetNode;
887 885
888 for (CXFA_Node* pTemplateChild = 886 for (CXFA_Node* pTemplateChild =
889 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); 887 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
890 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( 888 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
891 XFA_NODEITEM_NextSibling)) { 889 XFA_NODEITEM_NextSibling)) {
892 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { 890 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
893 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, 891 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode,
894 pTemplateChild, TRUE, nullptr); 892 pTemplateChild, true, nullptr);
895 } else if (pTemplateChild->IsContainerNode()) { 893 } else if (pTemplateChild->IsContainerNode()) {
896 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, 894 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode,
897 pDataScope, FALSE, TRUE, TRUE); 895 pDataScope, false, true, true);
898 } 896 }
899 } 897 }
900 } 898 }
901 } 899 }
902 900
903 if (iCurRepeatIndex == 0 && bAccessedDataDOM == FALSE) { 901 if (iCurRepeatIndex == 0 && bAccessedDataDOM == false) {
904 int32_t iLimit = iMax; 902 int32_t iLimit = iMax;
905 if (pInstMgrNode && pTemplateNode->GetNameHash() == 0) { 903 if (pInstMgrNode && pTemplateNode->GetNameHash() == 0) {
906 iLimit = subformArray.GetSize(); 904 iLimit = subformArray.GetSize();
907 if (iLimit < iMin) 905 if (iLimit < iMin)
908 iLimit = iInit; 906 iLimit = iInit;
909 } 907 }
910 908
911 for (; (iLimit < 0 || iCurRepeatIndex < iLimit); iCurRepeatIndex++) { 909 for (; (iLimit < 0 || iCurRepeatIndex < iLimit); iCurRepeatIndex++) {
912 if (pInstMgrNode) { 910 if (pInstMgrNode) {
913 if (pSearchArray && pSearchArray->GetSize() < 1) { 911 if (pSearchArray && pSearchArray->GetSize() < 1) {
914 if (pTemplateNode->GetNameHash() != 0) 912 if (pTemplateNode->GetNameHash() != 0)
915 break; 913 break;
916 pSearchArray = nullptr; 914 pSearchArray = nullptr;
917 } 915 }
918 } else if (!XFA_DataMerge_FindFormDOMInstance( 916 } else if (!XFA_DataMerge_FindFormDOMInstance(
919 pDocument, pTemplateNode->GetElementType(), 917 pDocument, pTemplateNode->GetElementType(),
920 pTemplateNode->GetNameHash(), pFormParentNode)) { 918 pTemplateNode->GetNameHash(), pFormParentNode)) {
921 break; 919 break;
922 } 920 }
923 CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer( 921 CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer(
924 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); 922 pDocument, pFormParentNode, pTemplateNode, false, pSearchArray);
925 ASSERT(pSubformNode); 923 ASSERT(pSubformNode);
926 if (!pFirstInstance) 924 if (!pFirstInstance)
927 pFirstInstance = pSubformNode; 925 pFirstInstance = pSubformNode;
928 926
929 for (CXFA_Node* pTemplateChild = 927 for (CXFA_Node* pTemplateChild =
930 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); 928 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
931 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( 929 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
932 XFA_NODEITEM_NextSibling)) { 930 XFA_NODEITEM_NextSibling)) {
933 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { 931 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
934 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformNode, 932 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformNode,
935 pTemplateChild, TRUE, nullptr); 933 pTemplateChild, true, nullptr);
936 } else if (pTemplateChild->IsContainerNode()) { 934 } else if (pTemplateChild->IsContainerNode()) {
937 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformNode, 935 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformNode,
938 pDataScope, FALSE, TRUE, TRUE); 936 pDataScope, false, true, true);
939 } 937 }
940 } 938 }
941 } 939 }
942 } 940 }
943 } 941 }
944 942
945 int32_t iMinimalLimit = iCurRepeatIndex == 0 ? iInit : iMin; 943 int32_t iMinimalLimit = iCurRepeatIndex == 0 ? iInit : iMin;
946 for (; iCurRepeatIndex < iMinimalLimit; iCurRepeatIndex++) { 944 for (; iCurRepeatIndex < iMinimalLimit; iCurRepeatIndex++) {
947 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( 945 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
948 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); 946 pDocument, pFormParentNode, pTemplateNode, false, pSearchArray);
949 ASSERT(pSubformSetNode); 947 ASSERT(pSubformSetNode);
950 if (!pFirstInstance) 948 if (!pFirstInstance)
951 pFirstInstance = pSubformSetNode; 949 pFirstInstance = pSubformSetNode;
952 950
953 FX_BOOL bFound = FALSE; 951 bool bFound = false;
954 for (CXFA_Node* pTemplateChild = 952 for (CXFA_Node* pTemplateChild =
955 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); 953 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
956 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( 954 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
957 XFA_NODEITEM_NextSibling)) { 955 XFA_NODEITEM_NextSibling)) {
958 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { 956 if (NeedGenerateForm(pTemplateChild, bUseInstanceManager)) {
959 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, 957 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode,
960 pTemplateChild, TRUE, nullptr); 958 pTemplateChild, true, nullptr);
961 } else if (pTemplateChild->IsContainerNode()) { 959 } else if (pTemplateChild->IsContainerNode()) {
962 if (bFound && eRelation == XFA_ATTRIBUTEENUM_Choice) 960 if (bFound && eRelation == XFA_ATTRIBUTEENUM_Choice)
963 continue; 961 continue;
964 962
965 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, 963 pDocument->DataMerge_CopyContainer(pTemplateChild, pSubformSetNode,
966 pDataScope, FALSE, bDataMerge, TRUE); 964 pDataScope, false, bDataMerge, true);
967 bFound = TRUE; 965 bFound = true;
968 } 966 }
969 } 967 }
970 } 968 }
971 return pFirstInstance; 969 return pFirstInstance;
972 } 970 }
973 971
974 CXFA_Node* CopyContainer_Field(CXFA_Document* pDocument, 972 CXFA_Node* CopyContainer_Field(CXFA_Document* pDocument,
975 CXFA_Node* pTemplateNode, 973 CXFA_Node* pTemplateNode,
976 CXFA_Node* pFormNode, 974 CXFA_Node* pFormNode,
977 CXFA_Node* pDataScope, 975 CXFA_Node* pDataScope,
978 FX_BOOL bDataMerge, 976 bool bDataMerge,
979 FX_BOOL bUpLevel) { 977 bool bUpLevel) {
980 CXFA_Node* pFieldNode = XFA_NodeMerge_CloneOrMergeContainer( 978 CXFA_Node* pFieldNode = XFA_NodeMerge_CloneOrMergeContainer(
981 pDocument, pFormNode, pTemplateNode, FALSE, nullptr); 979 pDocument, pFormNode, pTemplateNode, false, nullptr);
982 ASSERT(pFieldNode); 980 ASSERT(pFieldNode);
983 for (CXFA_Node* pTemplateChildNode = 981 for (CXFA_Node* pTemplateChildNode =
984 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); 982 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
985 pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem( 983 pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem(
986 XFA_NODEITEM_NextSibling)) { 984 XFA_NODEITEM_NextSibling)) {
987 if (NeedGenerateForm(pTemplateChildNode, TRUE)) { 985 if (NeedGenerateForm(pTemplateChildNode, true)) {
988 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode, 986 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode,
989 pTemplateChildNode, TRUE, nullptr); 987 pTemplateChildNode, true, nullptr);
990 } else if (pTemplateNode->GetElementType() == XFA_Element::ExclGroup && 988 } else if (pTemplateNode->GetElementType() == XFA_Element::ExclGroup &&
991 pTemplateChildNode->IsContainerNode()) { 989 pTemplateChildNode->IsContainerNode()) {
992 if (pTemplateChildNode->GetElementType() == XFA_Element::Field) { 990 if (pTemplateChildNode->GetElementType() == XFA_Element::Field) {
993 CopyContainer_Field(pDocument, pTemplateChildNode, pFieldNode, nullptr, 991 CopyContainer_Field(pDocument, pTemplateChildNode, pFieldNode, nullptr,
994 FALSE, TRUE); 992 false, true);
995 } 993 }
996 } 994 }
997 } 995 }
998 if (bDataMerge) { 996 if (bDataMerge) {
999 FX_BOOL bAccessedDataDOM = FALSE; 997 bool bAccessedDataDOM = false;
1000 FX_BOOL bSelfMatch = FALSE; 998 bool bSelfMatch = false;
1001 XFA_ATTRIBUTEENUM eBindMatch; 999 XFA_ATTRIBUTEENUM eBindMatch;
1002 CXFA_Node* pDataNode = FindMatchingDataNode( 1000 CXFA_Node* pDataNode = FindMatchingDataNode(
1003 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, TRUE, nullptr, 1001 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, true, nullptr,
1004 bSelfMatch, eBindMatch, bUpLevel); 1002 bSelfMatch, eBindMatch, bUpLevel);
1005 if (pDataNode) 1003 if (pDataNode)
1006 CreateDataBinding(pFieldNode, pDataNode, TRUE); 1004 CreateDataBinding(pFieldNode, pDataNode, true);
1007 } else { 1005 } else {
1008 FormValueNode_MatchNoneCreateChild(pFieldNode); 1006 FormValueNode_MatchNoneCreateChild(pFieldNode);
1009 } 1007 }
1010 return pFieldNode; 1008 return pFieldNode;
1011 } 1009 }
1012 1010
1013 CXFA_Node* MaybeCreateDataNode(CXFA_Document* pDocument, 1011 CXFA_Node* MaybeCreateDataNode(CXFA_Document* pDocument,
1014 CXFA_Node* pDataParent, 1012 CXFA_Node* pDataParent,
1015 XFA_Element eNodeType, 1013 XFA_Element eNodeType,
1016 const CFX_WideString& wsName) { 1014 const CFX_WideString& wsName) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 pDataNode->SetDataDescriptionNode(pDDNode); 1059 pDataNode->SetDataDescriptionNode(pDDNode);
1062 pDataNode->SetFlag(XFA_NodeFlag_Initialized, false); 1060 pDataNode->SetFlag(XFA_NodeFlag_Initialized, false);
1063 return pDataNode; 1061 return pDataNode;
1064 } 1062 }
1065 return nullptr; 1063 return nullptr;
1066 } 1064 }
1067 1065
1068 void UpdateBindingRelations(CXFA_Document* pDocument, 1066 void UpdateBindingRelations(CXFA_Document* pDocument,
1069 CXFA_Node* pFormNode, 1067 CXFA_Node* pFormNode,
1070 CXFA_Node* pDataScope, 1068 CXFA_Node* pDataScope,
1071 FX_BOOL bDataRef, 1069 bool bDataRef,
1072 FX_BOOL bParentDataRef) { 1070 bool bParentDataRef) {
1073 FX_BOOL bMatchRef = TRUE; 1071 bool bMatchRef = true;
1074 XFA_Element eType = pFormNode->GetElementType(); 1072 XFA_Element eType = pFormNode->GetElementType();
1075 CXFA_Node* pDataNode = pFormNode->GetBindData(); 1073 CXFA_Node* pDataNode = pFormNode->GetBindData();
1076 if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup || 1074 if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup ||
1077 eType == XFA_Element::Field) { 1075 eType == XFA_Element::Field) {
1078 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); 1076 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode();
1079 CXFA_Node* pTemplateNodeBind = 1077 CXFA_Node* pTemplateNodeBind =
1080 pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_Element::Bind) 1078 pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_Element::Bind)
1081 : nullptr; 1079 : nullptr;
1082 XFA_ATTRIBUTEENUM eMatch = 1080 XFA_ATTRIBUTEENUM eMatch =
1083 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) 1081 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match)
(...skipping 10 matching lines...) Expand all
1094 pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) != 1092 pFormNode->GetEnum(XFA_ATTRIBUTE_Scope) !=
1095 XFA_ATTRIBUTEENUM_None) { 1093 XFA_ATTRIBUTEENUM_None) {
1096 XFA_Element eDataNodeType = (eType == XFA_Element::Subform || 1094 XFA_Element eDataNodeType = (eType == XFA_Element::Subform ||
1097 XFA_FieldIsMultiListBox(pFormNode)) 1095 XFA_FieldIsMultiListBox(pFormNode))
1098 ? XFA_Element::DataGroup 1096 ? XFA_Element::DataGroup
1099 : XFA_Element::DataValue; 1097 : XFA_Element::DataValue;
1100 pDataNode = MaybeCreateDataNode( 1098 pDataNode = MaybeCreateDataNode(
1101 pDocument, pDataScope, eDataNodeType, 1099 pDocument, pDataScope, eDataNodeType,
1102 CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name))); 1100 CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name)));
1103 if (pDataNode) 1101 if (pDataNode)
1104 CreateDataBinding(pFormNode, pDataNode, FALSE); 1102 CreateDataBinding(pFormNode, pDataNode, false);
1105 } 1103 }
1106 if (!pDataNode) 1104 if (!pDataNode)
1107 FormValueNode_MatchNoneCreateChild(pFormNode); 1105 FormValueNode_MatchNoneCreateChild(pFormNode);
1108 1106
1109 } else { 1107 } else {
1110 CXFA_Node* pDataParent = 1108 CXFA_Node* pDataParent =
1111 pDataNode->GetNodeItem(XFA_NODEITEM_Parent); 1109 pDataNode->GetNodeItem(XFA_NODEITEM_Parent);
1112 if (pDataParent != pDataScope) { 1110 if (pDataParent != pDataScope) {
1113 ASSERT(pDataParent); 1111 ASSERT(pDataParent);
1114 pDataParent->RemoveChild(pDataNode); 1112 pDataParent->RemoveChild(pDataNode);
(...skipping 11 matching lines...) Expand all
1126 XFA_Element eDataNodeType = (eType == XFA_Element::Subform || 1124 XFA_Element eDataNodeType = (eType == XFA_Element::Subform ||
1127 XFA_FieldIsMultiListBox(pFormNode)) 1125 XFA_FieldIsMultiListBox(pFormNode))
1128 ? XFA_Element::DataGroup 1126 ? XFA_Element::DataGroup
1129 : XFA_Element::DataValue; 1127 : XFA_Element::DataValue;
1130 CXFA_Node* pRecordNode = 1128 CXFA_Node* pRecordNode =
1131 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)); 1129 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record));
1132 pDataNode = MaybeCreateDataNode( 1130 pDataNode = MaybeCreateDataNode(
1133 pDocument, pRecordNode, eDataNodeType, 1131 pDocument, pRecordNode, eDataNodeType,
1134 CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name))); 1132 CFX_WideString(pFormNode->GetCData(XFA_ATTRIBUTE_Name)));
1135 if (pDataNode) { 1133 if (pDataNode) {
1136 CreateDataBinding(pFormNode, pDataNode, FALSE); 1134 CreateDataBinding(pFormNode, pDataNode, false);
1137 RegisterGlobalBinding(pDocument, pFormNode->GetNameHash(), 1135 RegisterGlobalBinding(pDocument, pFormNode->GetNameHash(),
1138 pDataNode); 1136 pDataNode);
1139 } 1137 }
1140 } else { 1138 } else {
1141 CreateDataBinding(pFormNode, pDataNode, TRUE); 1139 CreateDataBinding(pFormNode, pDataNode, true);
1142 } 1140 }
1143 } 1141 }
1144 if (!pDataNode) 1142 if (!pDataNode)
1145 FormValueNode_MatchNoneCreateChild(pFormNode); 1143 FormValueNode_MatchNoneCreateChild(pFormNode);
1146 } 1144 }
1147 break; 1145 break;
1148 case XFA_ATTRIBUTEENUM_DataRef: { 1146 case XFA_ATTRIBUTEENUM_DataRef: {
1149 bMatchRef = bDataRef; 1147 bMatchRef = bDataRef;
1150 bParentDataRef = TRUE; 1148 bParentDataRef = true;
1151 if (!pDataNode && bDataRef) { 1149 if (!pDataNode && bDataRef) {
1152 CFX_WideStringC wsRef = 1150 CFX_WideStringC wsRef =
1153 pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref); 1151 pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref);
1154 uint32_t dFlags = 1152 uint32_t dFlags =
1155 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode; 1153 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode;
1156 XFA_RESOLVENODE_RS rs; 1154 XFA_RESOLVENODE_RS rs;
1157 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, 1155 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs,
1158 dFlags, pTemplateNode); 1156 dFlags, pTemplateNode);
1159 CXFA_Object* pObject = 1157 CXFA_Object* pObject =
1160 (rs.nodes.GetSize() > 0) ? rs.nodes[0] : nullptr; 1158 (rs.nodes.GetSize() > 0) ? rs.nodes[0] : nullptr;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 pFormChild->GetNameHash() == dwNameHash && pFormChild->IsUnusedNode()) { 1240 pFormChild->GetNameHash() == dwNameHash && pFormChild->IsUnusedNode()) {
1243 return pFormChild; 1241 return pFormChild;
1244 } 1242 }
1245 } 1243 }
1246 return nullptr; 1244 return nullptr;
1247 } 1245 }
1248 1246
1249 CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument, 1247 CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument,
1250 CXFA_Node* pFormParent, 1248 CXFA_Node* pFormParent,
1251 CXFA_Node* pTemplateNode, 1249 CXFA_Node* pTemplateNode,
1252 FX_BOOL bRecursive, 1250 bool bRecursive,
1253 CXFA_NodeArray* pSubformArray) { 1251 CXFA_NodeArray* pSubformArray) {
1254 CXFA_Node* pExistingNode = nullptr; 1252 CXFA_Node* pExistingNode = nullptr;
1255 if (!pSubformArray) { 1253 if (!pSubformArray) {
1256 pExistingNode = XFA_DataMerge_FindFormDOMInstance( 1254 pExistingNode = XFA_DataMerge_FindFormDOMInstance(
1257 pDocument, pTemplateNode->GetElementType(), 1255 pDocument, pTemplateNode->GetElementType(),
1258 pTemplateNode->GetNameHash(), pFormParent); 1256 pTemplateNode->GetNameHash(), pFormParent);
1259 } else if (pSubformArray->GetSize() > 0) { 1257 } else if (pSubformArray->GetSize() > 0) {
1260 pExistingNode = pSubformArray->GetAt(0); 1258 pExistingNode = pSubformArray->GetAt(0);
1261 pSubformArray->RemoveAt(0); 1259 pSubformArray->RemoveAt(0);
1262 } 1260 }
1263 1261
1264 if (pExistingNode) { 1262 if (pExistingNode) {
1265 if (pSubformArray) { 1263 if (pSubformArray) {
1266 pFormParent->InsertChild(pExistingNode); 1264 pFormParent->InsertChild(pExistingNode);
1267 } else if (pExistingNode->IsContainerNode()) { 1265 } else if (pExistingNode->IsContainerNode()) {
1268 pFormParent->RemoveChild(pExistingNode); 1266 pFormParent->RemoveChild(pExistingNode);
1269 pFormParent->InsertChild(pExistingNode); 1267 pFormParent->InsertChild(pExistingNode);
1270 } 1268 }
1271 pExistingNode->ClearFlag(XFA_NodeFlag_UnusedNode); 1269 pExistingNode->ClearFlag(XFA_NodeFlag_UnusedNode);
1272 pExistingNode->SetTemplateNode(pTemplateNode); 1270 pExistingNode->SetTemplateNode(pTemplateNode);
1273 if (bRecursive && pExistingNode->GetElementType() != XFA_Element::Items) { 1271 if (bRecursive && pExistingNode->GetElementType() != XFA_Element::Items) {
1274 for (CXFA_Node* pTemplateChild = 1272 for (CXFA_Node* pTemplateChild =
1275 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1273 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1276 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( 1274 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
1277 XFA_NODEITEM_NextSibling)) { 1275 XFA_NODEITEM_NextSibling)) {
1278 if (NeedGenerateForm(pTemplateChild, TRUE)) { 1276 if (NeedGenerateForm(pTemplateChild, true)) {
1279 XFA_NodeMerge_CloneOrMergeContainer( 1277 XFA_NodeMerge_CloneOrMergeContainer(
1280 pDocument, pExistingNode, pTemplateChild, bRecursive, nullptr); 1278 pDocument, pExistingNode, pTemplateChild, bRecursive, nullptr);
1281 } 1279 }
1282 } 1280 }
1283 } 1281 }
1284 pExistingNode->SetFlag(XFA_NodeFlag_Initialized, true); 1282 pExistingNode->SetFlag(XFA_NodeFlag_Initialized, true);
1285 return pExistingNode; 1283 return pExistingNode;
1286 } 1284 }
1287 1285
1288 CXFA_Node* pNewNode = pTemplateNode->CloneTemplateToForm(FALSE); 1286 CXFA_Node* pNewNode = pTemplateNode->CloneTemplateToForm(false);
1289 pFormParent->InsertChild(pNewNode, nullptr); 1287 pFormParent->InsertChild(pNewNode, nullptr);
1290 if (bRecursive) { 1288 if (bRecursive) {
1291 for (CXFA_Node* pTemplateChild = 1289 for (CXFA_Node* pTemplateChild =
1292 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1290 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1293 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( 1291 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem(
1294 XFA_NODEITEM_NextSibling)) { 1292 XFA_NODEITEM_NextSibling)) {
1295 if (NeedGenerateForm(pTemplateChild, TRUE)) { 1293 if (NeedGenerateForm(pTemplateChild, true)) {
1296 CXFA_Node* pNewChild = pTemplateChild->CloneTemplateToForm(TRUE); 1294 CXFA_Node* pNewChild = pTemplateChild->CloneTemplateToForm(true);
1297 pNewNode->InsertChild(pNewChild, nullptr); 1295 pNewNode->InsertChild(pNewChild, nullptr);
1298 } 1296 }
1299 } 1297 }
1300 } 1298 }
1301 return pNewNode; 1299 return pNewNode;
1302 } 1300 }
1303 1301
1304 CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode) { 1302 CXFA_Node* XFA_DataMerge_FindDataScope(CXFA_Node* pParentFormNode) {
1305 for (CXFA_Node* pRootBoundNode = pParentFormNode; 1303 for (CXFA_Node* pRootBoundNode = pParentFormNode;
1306 pRootBoundNode && pRootBoundNode->IsContainerNode(); 1304 pRootBoundNode && pRootBoundNode->IsContainerNode();
1307 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) { 1305 pRootBoundNode = pRootBoundNode->GetNodeItem(XFA_NODEITEM_Parent)) {
1308 CXFA_Node* pDataScope = pRootBoundNode->GetBindData(); 1306 CXFA_Node* pDataScope = pRootBoundNode->GetBindData();
1309 if (pDataScope) 1307 if (pDataScope)
1310 return pDataScope; 1308 return pDataScope;
1311 } 1309 }
1312 return ToNode( 1310 return ToNode(
1313 pParentFormNode->GetDocument()->GetXFAObject(XFA_HASHCODE_Data)); 1311 pParentFormNode->GetDocument()->GetXFAObject(XFA_HASHCODE_Data));
1314 } 1312 }
1315 1313
1316 CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode, 1314 CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode,
1317 CXFA_Node* pFormNode, 1315 CXFA_Node* pFormNode,
1318 CXFA_Node* pDataScope, 1316 CXFA_Node* pDataScope,
1319 FX_BOOL bOneInstance, 1317 bool bOneInstance,
1320 FX_BOOL bDataMerge, 1318 bool bDataMerge,
1321 FX_BOOL bUpLevel) { 1319 bool bUpLevel) {
1322 switch (pTemplateNode->GetElementType()) { 1320 switch (pTemplateNode->GetElementType()) {
1323 case XFA_Element::SubformSet: 1321 case XFA_Element::SubformSet:
1324 case XFA_Element::Subform: 1322 case XFA_Element::Subform:
1325 case XFA_Element::Area: 1323 case XFA_Element::Area:
1326 case XFA_Element::PageArea: 1324 case XFA_Element::PageArea:
1327 return CopyContainer_SubformSet(this, pTemplateNode, pFormNode, 1325 return CopyContainer_SubformSet(this, pTemplateNode, pFormNode,
1328 pDataScope, bOneInstance, bDataMerge); 1326 pDataScope, bOneInstance, bDataMerge);
1329 case XFA_Element::ExclGroup: 1327 case XFA_Element::ExclGroup:
1330 case XFA_Element::Field: 1328 case XFA_Element::Field:
1331 case XFA_Element::Draw: 1329 case XFA_Element::Draw:
1332 case XFA_Element::ContentArea: 1330 case XFA_Element::ContentArea:
1333 return CopyContainer_Field(this, pTemplateNode, pFormNode, pDataScope, 1331 return CopyContainer_Field(this, pTemplateNode, pFormNode, pDataScope,
1334 bDataMerge, bUpLevel); 1332 bDataMerge, bUpLevel);
1335 case XFA_Element::PageSet: 1333 case XFA_Element::PageSet:
1336 case XFA_Element::Variables: 1334 case XFA_Element::Variables:
1337 break; 1335 break;
1338 default: 1336 default:
1339 ASSERT(FALSE); 1337 ASSERT(false);
1340 break; 1338 break;
1341 } 1339 }
1342 return nullptr; 1340 return nullptr;
1343 } 1341 }
1344 1342
1345 void CXFA_Document::DataMerge_UpdateBindingRelations( 1343 void CXFA_Document::DataMerge_UpdateBindingRelations(
1346 CXFA_Node* pFormUpdateRoot) { 1344 CXFA_Node* pFormUpdateRoot) {
1347 CXFA_Node* pDataScope = XFA_DataMerge_FindDataScope( 1345 CXFA_Node* pDataScope = XFA_DataMerge_FindDataScope(
1348 pFormUpdateRoot->GetNodeItem(XFA_NODEITEM_Parent)); 1346 pFormUpdateRoot->GetNodeItem(XFA_NODEITEM_Parent));
1349 if (!pDataScope) 1347 if (!pDataScope)
1350 return; 1348 return;
1351 1349
1352 UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, FALSE, FALSE); 1350 UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, false, false);
1353 UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, TRUE, FALSE); 1351 UpdateBindingRelations(this, pFormUpdateRoot, pDataScope, true, false);
1354 } 1352 }
1355 1353
1356 CXFA_Node* CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes) { 1354 CXFA_Node* CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes) {
1357 for (int32_t i = 0; i < arrayNodes.GetSize(); i++) { 1355 for (int32_t i = 0; i < arrayNodes.GetSize(); i++) {
1358 CXFA_Node* pNode = arrayNodes[i]->AsNode(); 1356 CXFA_Node* pNode = arrayNodes[i]->AsNode();
1359 if (pNode && !pNode->HasBindItem()) 1357 if (pNode && !pNode->HasBindItem())
1360 return pNode; 1358 return pNode;
1361 } 1359 }
1362 return nullptr; 1360 return nullptr;
1363 } 1361 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) 1418 dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash)
1421 : nullptr; 1419 : nullptr;
1422 if (!pTemplateChosen || 1420 if (!pTemplateChosen ||
1423 pTemplateChosen->GetElementType() != XFA_Element::Subform) { 1421 pTemplateChosen->GetElementType() != XFA_Element::Subform) {
1424 pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform); 1422 pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform);
1425 } 1423 }
1426 if (!pTemplateChosen) 1424 if (!pTemplateChosen)
1427 return; 1425 return;
1428 1426
1429 CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_Element::Form); 1427 CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_Element::Form);
1430 FX_BOOL bEmptyForm = FALSE; 1428 bool bEmptyForm = false;
1431 if (!pFormRoot) { 1429 if (!pFormRoot) {
1432 bEmptyForm = TRUE; 1430 bEmptyForm = true;
1433 pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_Element::Form); 1431 pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_Element::Form);
1434 ASSERT(pFormRoot); 1432 ASSERT(pFormRoot);
1435 pFormRoot->SetCData(XFA_ATTRIBUTE_Name, L"form"); 1433 pFormRoot->SetCData(XFA_ATTRIBUTE_Name, L"form");
1436 m_pRootNode->InsertChild(pFormRoot, nullptr); 1434 m_pRootNode->InsertChild(pFormRoot, nullptr);
1437 } else { 1435 } else {
1438 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> 1436 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode>
1439 sIterator(pFormRoot); 1437 sIterator(pFormRoot);
1440 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; 1438 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode;
1441 pNode = sIterator.MoveToNext()) { 1439 pNode = sIterator.MoveToNext()) {
1442 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); 1440 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true);
1443 } 1441 }
1444 } 1442 }
1445 1443
1446 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( 1444 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer(
1447 this, pFormRoot, pTemplateChosen, FALSE, nullptr); 1445 this, pFormRoot, pTemplateChosen, false, nullptr);
1448 ASSERT(pSubformSetNode); 1446 ASSERT(pSubformSetNode);
1449 if (!pDataTopLevel) { 1447 if (!pDataTopLevel) {
1450 CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name); 1448 CFX_WideStringC wsFormName = pSubformSetNode->GetCData(XFA_ATTRIBUTE_Name);
1451 CFX_WideString wsDataTopLevelName(wsFormName.IsEmpty() ? L"form" 1449 CFX_WideString wsDataTopLevelName(wsFormName.IsEmpty() ? L"form"
1452 : wsFormName); 1450 : wsFormName);
1453 CFDE_XMLElement* pDataTopLevelXMLNode = 1451 CFDE_XMLElement* pDataTopLevelXMLNode =
1454 new CFDE_XMLElement(wsDataTopLevelName); 1452 new CFDE_XMLElement(wsDataTopLevelName);
1455 1453
1456 pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup); 1454 pDataTopLevel = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataGroup);
1457 pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName); 1455 pDataTopLevel->SetCData(XFA_ATTRIBUTE_Name, wsDataTopLevelName);
1458 pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode); 1456 pDataTopLevel->SetXMLMappingNode(pDataTopLevelXMLNode);
1459 CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild); 1457 CXFA_Node* pBeforeNode = pDataRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
1460 pDataRoot->InsertChild(pDataTopLevel, pBeforeNode); 1458 pDataRoot->InsertChild(pDataTopLevel, pBeforeNode);
1461 } 1459 }
1462 1460
1463 ASSERT(pDataTopLevel); 1461 ASSERT(pDataTopLevel);
1464 CreateDataBinding(pSubformSetNode, pDataTopLevel, TRUE); 1462 CreateDataBinding(pSubformSetNode, pDataTopLevel, true);
1465 for (CXFA_Node* pTemplateChild = 1463 for (CXFA_Node* pTemplateChild =
1466 pTemplateChosen->GetNodeItem(XFA_NODEITEM_FirstChild); 1464 pTemplateChosen->GetNodeItem(XFA_NODEITEM_FirstChild);
1467 pTemplateChild; 1465 pTemplateChild;
1468 pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1466 pTemplateChild = pTemplateChild->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1469 if (NeedGenerateForm(pTemplateChild, TRUE)) { 1467 if (NeedGenerateForm(pTemplateChild, true)) {
1470 XFA_NodeMerge_CloneOrMergeContainer(this, pSubformSetNode, pTemplateChild, 1468 XFA_NodeMerge_CloneOrMergeContainer(this, pSubformSetNode, pTemplateChild,
1471 TRUE, nullptr); 1469 true, nullptr);
1472 } else if (pTemplateChild->IsContainerNode()) { 1470 } else if (pTemplateChild->IsContainerNode()) {
1473 DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel, 1471 DataMerge_CopyContainer(pTemplateChild, pSubformSetNode, pDataTopLevel,
1474 FALSE, TRUE, TRUE); 1472 false, true, true);
1475 } 1473 }
1476 } 1474 }
1477 if (pDDRoot) 1475 if (pDDRoot)
1478 UpdateDataRelation(pDataRoot, pDDRoot); 1476 UpdateDataRelation(pDataRoot, pDDRoot);
1479 1477
1480 DataMerge_UpdateBindingRelations(pSubformSetNode); 1478 DataMerge_UpdateBindingRelations(pSubformSetNode);
1481 CXFA_Node* pPageSetNode = 1479 CXFA_Node* pPageSetNode =
1482 pSubformSetNode->GetFirstChildByClass(XFA_Element::PageSet); 1480 pSubformSetNode->GetFirstChildByClass(XFA_Element::PageSet);
1483 while (pPageSetNode) { 1481 while (pPageSetNode) {
1484 m_pPendingPageSet.Add(pPageSetNode); 1482 m_pPendingPageSet.Add(pPageSetNode);
(...skipping 21 matching lines...) Expand all
1506 pNode->SetFlag(XFA_NodeFlag_Initialized, true); 1504 pNode->SetFlag(XFA_NodeFlag_Initialized, true);
1507 pNode = sIterator.MoveToNext(); 1505 pNode = sIterator.MoveToNext();
1508 } 1506 }
1509 } else { 1507 } else {
1510 pNode->SetFlag(XFA_NodeFlag_Initialized, true); 1508 pNode->SetFlag(XFA_NodeFlag_Initialized, true);
1511 pNode = sIterator.MoveToNext(); 1509 pNode = sIterator.MoveToNext();
1512 } 1510 }
1513 } 1511 }
1514 } 1512 }
1515 1513
1516 void CXFA_Document::DoDataRemerge(FX_BOOL bDoDataMerge) { 1514 void CXFA_Document::DoDataRemerge(bool bDoDataMerge) {
1517 CXFA_Node* pFormRoot = ToNode(GetXFAObject(XFA_HASHCODE_Form)); 1515 CXFA_Node* pFormRoot = ToNode(GetXFAObject(XFA_HASHCODE_Form));
1518 if (pFormRoot) { 1516 if (pFormRoot) {
1519 while (CXFA_Node* pNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) 1517 while (CXFA_Node* pNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild))
1520 pFormRoot->RemoveChild(pNode); 1518 pFormRoot->RemoveChild(pNode);
1521 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); 1519 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr);
1522 } 1520 }
1523 m_rgGlobalBinding.RemoveAll(); 1521 m_rgGlobalBinding.RemoveAll();
1524 if (bDoDataMerge) 1522 if (bDoDataMerge)
1525 DoDataMerge(); 1523 DoDataMerge();
1526 1524
1527 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); 1525 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor();
1528 pLayoutProcessor->SetForceReLayout(TRUE); 1526 pLayoutProcessor->SetForceReLayout(true);
1529 } 1527 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/xfa_document_datamerger_imp.h ('k') | xfa/fxfa/parser/xfa_layout_itemlayout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698