OLD | NEW |
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/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fde/xml/fde_xml_imp.h" | 10 #include "xfa/fde/xml/fde_xml_imp.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 pXMLDataElement->SetString(L"href", wsHref); | 135 pXMLDataElement->SetString(L"href", wsHref); |
136 } | 136 } |
137 } break; | 137 } break; |
138 case XFA_Element::ChoiceList: | 138 case XFA_Element::ChoiceList: |
139 defValue.GetChildValueContent(wsValue); | 139 defValue.GetChildValueContent(wsValue); |
140 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | 140 if (pWidgetData->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { |
141 CFX_WideStringArray wsSelTextArray; | 141 CFX_WideStringArray wsSelTextArray; |
142 pWidgetData->GetSelectedItemsValue(wsSelTextArray); | 142 pWidgetData->GetSelectedItemsValue(wsSelTextArray); |
143 int32_t iSize = wsSelTextArray.GetSize(); | 143 int32_t iSize = wsSelTextArray.GetSize(); |
144 if (iSize >= 1) { | 144 if (iSize >= 1) { |
145 CXFA_Node* pValue = NULL; | 145 CXFA_Node* pValue = nullptr; |
146 for (int32_t i = 0; i < iSize; i++) { | 146 for (int32_t i = 0; i < iSize; i++) { |
147 pValue = pDataNode->CreateSamePacketNode(XFA_Element::DataValue); | 147 pValue = pDataNode->CreateSamePacketNode(XFA_Element::DataValue); |
148 pValue->SetCData(XFA_ATTRIBUTE_Name, L"value"); | 148 pValue->SetCData(XFA_ATTRIBUTE_Name, L"value"); |
149 pValue->CreateXMLMappingNode(); | 149 pValue->CreateXMLMappingNode(); |
150 pDataNode->InsertChild(pValue); | 150 pDataNode->InsertChild(pValue); |
151 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); | 151 pValue->SetCData(XFA_ATTRIBUTE_Value, wsSelTextArray[i]); |
152 } | 152 } |
153 } else { | 153 } else { |
154 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); | 154 CFDE_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); |
155 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); | 155 ASSERT(pXMLNode->GetType() == FDE_XMLNODE_Element); |
156 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", | 156 static_cast<CFDE_XMLElement*>(pXMLNode)->SetString(L"xfa:dataNode", |
157 L"dataGroup"); | 157 L"dataGroup"); |
158 } | 158 } |
159 } else if (!wsValue.IsEmpty()) { | 159 } else if (!wsValue.IsEmpty()) { |
160 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 160 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); |
161 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 161 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
162 } | 162 } |
163 break; | 163 break; |
164 case XFA_Element::CheckButton: | 164 case XFA_Element::CheckButton: |
165 defValue.GetChildValueContent(wsValue); | 165 defValue.GetChildValueContent(wsValue); |
166 if (wsValue.IsEmpty()) { | 166 if (wsValue.IsEmpty()) { |
167 break; | 167 break; |
168 } | 168 } |
169 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); | 169 pWidgetData->GetFormatDataValue(wsValue, wsFormatedValue); |
170 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); | 170 pDataNode->SetAttributeValue(wsValue, wsFormatedValue); |
171 break; | 171 break; |
172 case XFA_Element::ExclGroup: { | 172 case XFA_Element::ExclGroup: { |
173 CXFA_Node* pChecked = NULL; | 173 CXFA_Node* pChecked = nullptr; |
174 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 174 CXFA_Node* pChild = pFormNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
175 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 175 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
176 if (pChild->GetElementType() != XFA_Element::Field) { | 176 if (pChild->GetElementType() != XFA_Element::Field) { |
177 continue; | 177 continue; |
178 } | 178 } |
179 CXFA_Node* pValue = pChild->GetChild(0, XFA_Element::Value); | 179 CXFA_Node* pValue = pChild->GetChild(0, XFA_Element::Value); |
180 if (!pValue) { | 180 if (!pValue) { |
181 continue; | 181 continue; |
182 } | 182 } |
183 CXFA_Value valueChild(pValue); | 183 CXFA_Value valueChild(pValue); |
(...skipping 25 matching lines...) Expand all Loading... |
209 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 209 for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
210 if (pChild == pChecked) { | 210 if (pChild == pChecked) { |
211 continue; | 211 continue; |
212 } | 212 } |
213 if (pChild->GetElementType() != XFA_Element::Field) { | 213 if (pChild->GetElementType() != XFA_Element::Field) { |
214 continue; | 214 continue; |
215 } | 215 } |
216 CXFA_Node* pValue = pChild->GetProperty(0, XFA_Element::Value); | 216 CXFA_Node* pValue = pChild->GetProperty(0, XFA_Element::Value); |
217 CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items); | 217 CXFA_Node* pItems = pChild->GetChild(0, XFA_Element::Items); |
218 CXFA_Node* pText = | 218 CXFA_Node* pText = |
219 pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : NULL; | 219 pItems ? pItems->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr; |
220 if (pText) { | 220 if (pText) { |
221 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); | 221 pText = pText->GetNodeItem(XFA_NODEITEM_NextSibling); |
222 } | 222 } |
223 CFX_WideString wsContent; | 223 CFX_WideString wsContent; |
224 if (pText) { | 224 if (pText) { |
225 pText->TryContent(wsContent); | 225 pText->TryContent(wsContent); |
226 } | 226 } |
227 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsContent, | 227 XFA_DataMerge_FormValueNode_SetChildContent(pValue, wsContent, |
228 XFA_Element::Text); | 228 XFA_Element::Text); |
229 } | 229 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 case XFA_Element::TextEdit: | 333 case XFA_Element::TextEdit: |
334 default: | 334 default: |
335 XFA_DataMerge_FormValueNode_SetChildContent( | 335 XFA_DataMerge_FormValueNode_SetChildContent( |
336 defValue.GetNode(), wsNormailizeValue, XFA_Element::Text); | 336 defValue.GetNode(), wsNormailizeValue, XFA_Element::Text); |
337 break; | 337 break; |
338 } | 338 } |
339 } | 339 } |
340 } | 340 } |
341 static CXFA_Node* XFA_DataMerge_GetGlobalBinding(CXFA_Document* pDocument, | 341 static CXFA_Node* XFA_DataMerge_GetGlobalBinding(CXFA_Document* pDocument, |
342 uint32_t dwNameHash) { | 342 uint32_t dwNameHash) { |
343 CXFA_Node* pNode = NULL; | 343 CXFA_Node* pNode = nullptr; |
344 pDocument->m_rgGlobalBinding.Lookup(dwNameHash, pNode); | 344 pDocument->m_rgGlobalBinding.Lookup(dwNameHash, pNode); |
345 return pNode; | 345 return pNode; |
346 } | 346 } |
347 static void XFA_DataMerge_RegisterGlobalBinding(CXFA_Document* pDocument, | 347 static void XFA_DataMerge_RegisterGlobalBinding(CXFA_Document* pDocument, |
348 uint32_t dwNameHash, | 348 uint32_t dwNameHash, |
349 CXFA_Node* pDataNode) { | 349 CXFA_Node* pDataNode) { |
350 pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode); | 350 pDocument->m_rgGlobalBinding.SetAt(dwNameHash, pDataNode); |
351 } | 351 } |
352 static void XFA_DataMerge_ClearGlobalBinding(CXFA_Document* pDocument) { | 352 static void XFA_DataMerge_ClearGlobalBinding(CXFA_Document* pDocument) { |
353 pDocument->m_rgGlobalBinding.RemoveAll(); | 353 pDocument->m_rgGlobalBinding.RemoveAll(); |
354 } | 354 } |
355 static CXFA_Node* XFA_DataMerge_ScopeMatchGlobalBinding( | 355 static CXFA_Node* XFA_DataMerge_ScopeMatchGlobalBinding( |
356 CXFA_Node* pDataScope, | 356 CXFA_Node* pDataScope, |
357 uint32_t dwNameHash, | 357 uint32_t dwNameHash, |
358 XFA_Element eMatchDataNodeType, | 358 XFA_Element eMatchDataNodeType, |
359 FX_BOOL bUpLevel = TRUE) { | 359 FX_BOOL bUpLevel = TRUE) { |
360 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL; | 360 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = nullptr; |
361 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; | 361 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; |
362 pLastDataScope = pCurDataScope, | 362 pLastDataScope = pCurDataScope, |
363 pCurDataScope = | 363 pCurDataScope = |
364 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { | 364 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { |
365 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); | 365 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); |
366 pDataChild; | 366 pDataChild; |
367 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { | 367 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { |
368 if (pDataChild == pLastDataScope || | 368 if (pDataChild == pLastDataScope || |
369 (eMatchDataNodeType != XFA_Element::DataModel && | 369 (eMatchDataNodeType != XFA_Element::DataModel && |
370 pDataChild->GetElementType() != eMatchDataNodeType) || | 370 pDataChild->GetElementType() != eMatchDataNodeType) || |
371 pDataChild->HasBindItem()) { | 371 pDataChild->HasBindItem()) { |
372 continue; | 372 continue; |
373 } | 373 } |
374 return pDataChild; | 374 return pDataChild; |
375 } | 375 } |
376 for (CXFA_Node* pDataChild = | 376 for (CXFA_Node* pDataChild = |
377 pCurDataScope->GetFirstChildByClass(XFA_Element::DataGroup); | 377 pCurDataScope->GetFirstChildByClass(XFA_Element::DataGroup); |
378 pDataChild; pDataChild = pDataChild->GetNextSameClassSibling( | 378 pDataChild; pDataChild = pDataChild->GetNextSameClassSibling( |
379 XFA_Element::DataGroup)) { | 379 XFA_Element::DataGroup)) { |
380 CXFA_Node* pDataNode = XFA_DataMerge_ScopeMatchGlobalBinding( | 380 CXFA_Node* pDataNode = XFA_DataMerge_ScopeMatchGlobalBinding( |
381 pDataChild, dwNameHash, eMatchDataNodeType, FALSE); | 381 pDataChild, dwNameHash, eMatchDataNodeType, FALSE); |
382 if (pDataNode) { | 382 if (pDataNode) { |
383 return pDataNode; | 383 return pDataNode; |
384 } | 384 } |
385 } | 385 } |
386 if (!bUpLevel) { | 386 if (!bUpLevel) { |
387 break; | 387 break; |
388 } | 388 } |
389 } | 389 } |
390 return NULL; | 390 return nullptr; |
391 } | 391 } |
392 static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, | 392 static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, |
393 CFX_WideStringC wsName, | 393 CFX_WideStringC wsName, |
394 CXFA_Node* pDataScope, | 394 CXFA_Node* pDataScope, |
395 XFA_Element eMatchNodeType) { | 395 XFA_Element eMatchNodeType) { |
396 if (wsName.IsEmpty()) | 396 if (wsName.IsEmpty()) |
397 return nullptr; | 397 return nullptr; |
398 | 398 |
399 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); | 399 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); |
400 CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); | 400 CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 } | 448 } |
449 XFA_RESOLVENODE_RS rs; | 449 XFA_RESOLVENODE_RS rs; |
450 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags, | 450 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, dFlags, |
451 pTemplateNode); | 451 pTemplateNode); |
452 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll || | 452 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeAll || |
453 rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll || | 453 rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeMidAll || |
454 rs.nodes.GetSize() > 1) { | 454 rs.nodes.GetSize() > 1) { |
455 return pDocument->GetNotBindNode(rs.nodes); | 455 return pDocument->GetNotBindNode(rs.nodes); |
456 } | 456 } |
457 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { | 457 if (rs.dwFlags == XFA_RESOLVENODE_RSTYPE_CreateNodeOne) { |
458 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL; | 458 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : nullptr; |
459 CXFA_Node* pNode = ToNode(pObject); | 459 CXFA_Node* pNode = ToNode(pObject); |
460 if (!bForceBind && pNode && pNode->HasBindItem()) { | 460 if (!bForceBind && pNode && pNode->HasBindItem()) { |
461 pNode = NULL; | 461 pNode = nullptr; |
462 } | 462 } |
463 return pNode; | 463 return pNode; |
464 } | 464 } |
465 return NULL; | 465 return nullptr; |
466 } | 466 } |
467 CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, | 467 CXFA_Node* XFA_DataMerge_FindFormDOMInstance(CXFA_Document* pDocument, |
468 XFA_Element eType, | 468 XFA_Element eType, |
469 uint32_t dwNameHash, | 469 uint32_t dwNameHash, |
470 CXFA_Node* pFormParent) { | 470 CXFA_Node* pFormParent) { |
471 CXFA_Node* pFormChild = pFormParent->GetNodeItem(XFA_NODEITEM_FirstChild); | 471 CXFA_Node* pFormChild = pFormParent->GetNodeItem(XFA_NODEITEM_FirstChild); |
472 for (; pFormChild; | 472 for (; pFormChild; |
473 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 473 pFormChild = pFormChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
474 if (pFormChild->GetElementType() == eType && | 474 if (pFormChild->GetElementType() == eType && |
475 pFormChild->GetNameHash() == dwNameHash && pFormChild->IsUnusedNode()) { | 475 pFormChild->GetNameHash() == dwNameHash && pFormChild->IsUnusedNode()) { |
476 return pFormChild; | 476 return pFormChild; |
477 } | 477 } |
478 } | 478 } |
479 return NULL; | 479 return nullptr; |
480 } | 480 } |
481 static FX_BOOL XFA_NeedGenerateForm(CXFA_Node* pTemplateChild, | 481 static FX_BOOL XFA_NeedGenerateForm(CXFA_Node* pTemplateChild, |
482 FX_BOOL bUseInstanceManager = TRUE) { | 482 FX_BOOL bUseInstanceManager = TRUE) { |
483 XFA_Element eType = pTemplateChild->GetElementType(); | 483 XFA_Element eType = pTemplateChild->GetElementType(); |
484 if (eType == XFA_Element::Variables) { | 484 if (eType == XFA_Element::Variables) { |
485 return TRUE; | 485 return TRUE; |
486 } | 486 } |
487 if (pTemplateChild->IsContainerNode()) { | 487 if (pTemplateChild->IsContainerNode()) { |
488 return FALSE; | 488 return FALSE; |
489 } | 489 } |
490 if (eType == XFA_Element::Proto || | 490 if (eType == XFA_Element::Proto || |
491 (bUseInstanceManager && eType == XFA_Element::Occur)) { | 491 (bUseInstanceManager && eType == XFA_Element::Occur)) { |
492 return FALSE; | 492 return FALSE; |
493 } | 493 } |
494 return TRUE; | 494 return TRUE; |
495 } | 495 } |
496 CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument, | 496 CXFA_Node* XFA_NodeMerge_CloneOrMergeContainer(CXFA_Document* pDocument, |
497 CXFA_Node* pFormParent, | 497 CXFA_Node* pFormParent, |
498 CXFA_Node* pTemplateNode, | 498 CXFA_Node* pTemplateNode, |
499 FX_BOOL bRecursive, | 499 FX_BOOL bRecursive, |
500 CXFA_NodeArray* pSubformArray) { | 500 CXFA_NodeArray* pSubformArray) { |
501 CXFA_Node* pExistingNode = NULL; | 501 CXFA_Node* pExistingNode = nullptr; |
502 if (pSubformArray == NULL) { | 502 if (!pSubformArray) { |
503 pExistingNode = XFA_DataMerge_FindFormDOMInstance( | 503 pExistingNode = XFA_DataMerge_FindFormDOMInstance( |
504 pDocument, pTemplateNode->GetElementType(), | 504 pDocument, pTemplateNode->GetElementType(), |
505 pTemplateNode->GetNameHash(), pFormParent); | 505 pTemplateNode->GetNameHash(), pFormParent); |
506 } else if (pSubformArray->GetSize() > 0) { | 506 } else if (pSubformArray->GetSize() > 0) { |
507 pExistingNode = pSubformArray->GetAt(0); | 507 pExistingNode = pSubformArray->GetAt(0); |
508 pSubformArray->RemoveAt(0); | 508 pSubformArray->RemoveAt(0); |
509 } | 509 } |
510 if (pExistingNode) { | 510 if (pExistingNode) { |
511 if (pSubformArray) { | 511 if (pSubformArray) { |
512 pFormParent->InsertChild(pExistingNode); | 512 pFormParent->InsertChild(pExistingNode); |
(...skipping 11 matching lines...) Expand all Loading... |
524 if (XFA_NeedGenerateForm(pTemplateChild)) { | 524 if (XFA_NeedGenerateForm(pTemplateChild)) { |
525 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pExistingNode, | 525 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pExistingNode, |
526 pTemplateChild, bRecursive); | 526 pTemplateChild, bRecursive); |
527 } | 527 } |
528 } | 528 } |
529 } | 529 } |
530 pExistingNode->SetFlag(XFA_NodeFlag_Initialized, true); | 530 pExistingNode->SetFlag(XFA_NodeFlag_Initialized, true); |
531 return pExistingNode; | 531 return pExistingNode; |
532 } | 532 } |
533 CXFA_Node* pNewNode = pTemplateNode->CloneTemplateToForm(FALSE); | 533 CXFA_Node* pNewNode = pTemplateNode->CloneTemplateToForm(FALSE); |
534 pFormParent->InsertChild(pNewNode, NULL); | 534 pFormParent->InsertChild(pNewNode, nullptr); |
535 if (bRecursive) { | 535 if (bRecursive) { |
536 for (CXFA_Node* pTemplateChild = | 536 for (CXFA_Node* pTemplateChild = |
537 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 537 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
538 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( | 538 pTemplateChild; pTemplateChild = pTemplateChild->GetNodeItem( |
539 XFA_NODEITEM_NextSibling)) { | 539 XFA_NODEITEM_NextSibling)) { |
540 if (XFA_NeedGenerateForm(pTemplateChild)) { | 540 if (XFA_NeedGenerateForm(pTemplateChild)) { |
541 CXFA_Node* pNewChild = pTemplateChild->CloneTemplateToForm(TRUE); | 541 CXFA_Node* pNewChild = pTemplateChild->CloneTemplateToForm(TRUE); |
542 pNewNode->InsertChild(pNewChild, NULL); | 542 pNewNode->InsertChild(pNewChild, nullptr); |
543 } | 543 } |
544 } | 544 } |
545 } | 545 } |
546 return pNewNode; | 546 return pNewNode; |
547 } | 547 } |
548 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( | 548 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( |
549 CXFA_Document* pDocument, | 549 CXFA_Document* pDocument, |
550 CXFA_Node* pFormParent, | 550 CXFA_Node* pFormParent, |
551 CXFA_Node* pTemplateNode, | 551 CXFA_Node* pTemplateNode, |
552 CXFA_NodeArray& subforms) { | 552 CXFA_NodeArray& subforms) { |
(...skipping 30 matching lines...) Expand all Loading... |
583 pExistingNode->ClearFlag(XFA_NodeFlag_UnusedNode); | 583 pExistingNode->ClearFlag(XFA_NodeFlag_UnusedNode); |
584 pExistingNode->SetTemplateNode(pTemplateNode); | 584 pExistingNode->SetTemplateNode(pTemplateNode); |
585 return pExistingNode; | 585 return pExistingNode; |
586 } | 586 } |
587 CXFA_Node* pNewNode = pDocument->GetParser()->GetFactory()->CreateNode( | 587 CXFA_Node* pNewNode = pDocument->GetParser()->GetFactory()->CreateNode( |
588 XFA_XDPPACKET_Form, XFA_Element::InstanceManager); | 588 XFA_XDPPACKET_Form, XFA_Element::InstanceManager); |
589 ASSERT(pNewNode); | 589 ASSERT(pNewNode); |
590 wsInstMgrNodeName = | 590 wsInstMgrNodeName = |
591 FX_WSTRC(L"_") + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); | 591 FX_WSTRC(L"_") + pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); |
592 pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName); | 592 pNewNode->SetCData(XFA_ATTRIBUTE_Name, wsInstMgrNodeName); |
593 pFormParent->InsertChild(pNewNode, NULL); | 593 pFormParent->InsertChild(pNewNode, nullptr); |
594 pNewNode->SetTemplateNode(pTemplateNode); | 594 pNewNode->SetTemplateNode(pTemplateNode); |
595 return pNewNode; | 595 return pNewNode; |
596 } | 596 } |
597 static CXFA_Node* XFA_DataMerge_FindMatchingDataNode( | 597 static CXFA_Node* XFA_DataMerge_FindMatchingDataNode( |
598 CXFA_Document* pDocument, | 598 CXFA_Document* pDocument, |
599 CXFA_Node* pTemplateNode, | 599 CXFA_Node* pTemplateNode, |
600 CXFA_Node* pDataScope, | 600 CXFA_Node* pDataScope, |
601 FX_BOOL& bAccessedDataDOM, | 601 FX_BOOL& bAccessedDataDOM, |
602 FX_BOOL bForceBind, | 602 FX_BOOL bForceBind, |
603 CXFA_NodeIteratorTemplate<CXFA_Node, | 603 CXFA_NodeIteratorTemplate<CXFA_Node, |
604 CXFA_TraverseStrategy_XFAContainerNode>* | 604 CXFA_TraverseStrategy_XFAContainerNode>* |
605 pIterator, | 605 pIterator, |
606 FX_BOOL& bSelfMatch, | 606 FX_BOOL& bSelfMatch, |
607 XFA_ATTRIBUTEENUM& eBindMatch, | 607 XFA_ATTRIBUTEENUM& eBindMatch, |
608 FX_BOOL bUpLevel = TRUE) { | 608 FX_BOOL bUpLevel = TRUE) { |
609 FX_BOOL bOwnIterator = FALSE; | 609 FX_BOOL bOwnIterator = FALSE; |
610 if (!pIterator) { | 610 if (!pIterator) { |
611 bOwnIterator = TRUE; | 611 bOwnIterator = TRUE; |
612 pIterator = new CXFA_NodeIteratorTemplate< | 612 pIterator = new CXFA_NodeIteratorTemplate< |
613 CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode); | 613 CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode); |
614 } | 614 } |
615 CXFA_Node* pResult = NULL; | 615 CXFA_Node* pResult = nullptr; |
616 for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); | 616 for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); |
617 pCurTemplateNode;) { | 617 pCurTemplateNode;) { |
618 XFA_Element eMatchNodeType; | 618 XFA_Element eMatchNodeType; |
619 switch (pCurTemplateNode->GetElementType()) { | 619 switch (pCurTemplateNode->GetElementType()) { |
620 case XFA_Element::Subform: | 620 case XFA_Element::Subform: |
621 eMatchNodeType = XFA_Element::DataGroup; | 621 eMatchNodeType = XFA_Element::DataGroup; |
622 break; | 622 break; |
623 case XFA_Element::Field: { | 623 case XFA_Element::Field: { |
624 eMatchNodeType = XFA_FieldIsMultiListBox(pCurTemplateNode) | 624 eMatchNodeType = XFA_FieldIsMultiListBox(pCurTemplateNode) |
625 ? XFA_Element::DataGroup | 625 ? XFA_Element::DataGroup |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 } | 744 } |
745 } | 745 } |
746 static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( | 746 static CXFA_Node* XFA_DataMerge_CopyContainer_SubformSet( |
747 CXFA_Document* pDocument, | 747 CXFA_Document* pDocument, |
748 CXFA_Node* pTemplateNode, | 748 CXFA_Node* pTemplateNode, |
749 CXFA_Node* pFormParentNode, | 749 CXFA_Node* pFormParentNode, |
750 CXFA_Node* pDataScope, | 750 CXFA_Node* pDataScope, |
751 FX_BOOL bOneInstance, | 751 FX_BOOL bOneInstance, |
752 FX_BOOL bDataMerge) { | 752 FX_BOOL bDataMerge) { |
753 XFA_Element eType = pTemplateNode->GetElementType(); | 753 XFA_Element eType = pTemplateNode->GetElementType(); |
754 CXFA_Node* pOccurNode = NULL; | 754 CXFA_Node* pOccurNode = nullptr; |
755 CXFA_Node* pFirstInstance = NULL; | 755 CXFA_Node* pFirstInstance = nullptr; |
756 FX_BOOL bUseInstanceManager = | 756 FX_BOOL bUseInstanceManager = |
757 pFormParentNode->GetElementType() != XFA_Element::Area; | 757 pFormParentNode->GetElementType() != XFA_Element::Area; |
758 CXFA_Node* pInstMgrNode = NULL; | 758 CXFA_Node* pInstMgrNode = nullptr; |
759 CXFA_NodeArray subformArray; | 759 CXFA_NodeArray subformArray; |
760 CXFA_NodeArray* pSearchArray = NULL; | 760 CXFA_NodeArray* pSearchArray = nullptr; |
761 if (!bOneInstance && | 761 if (!bOneInstance && |
762 (eType == XFA_Element::SubformSet || eType == XFA_Element::Subform)) { | 762 (eType == XFA_Element::SubformSet || eType == XFA_Element::Subform)) { |
763 pInstMgrNode = | 763 pInstMgrNode = |
764 bUseInstanceManager | 764 bUseInstanceManager |
765 ? XFA_NodeMerge_CloneOrMergeInstanceManager( | 765 ? XFA_NodeMerge_CloneOrMergeInstanceManager( |
766 pDocument, pFormParentNode, pTemplateNode, subformArray) | 766 pDocument, pFormParentNode, pTemplateNode, subformArray) |
767 : NULL; | 767 : nullptr; |
768 if (CXFA_Node* pOccurTemplateNode = | 768 if (CXFA_Node* pOccurTemplateNode = |
769 pTemplateNode->GetFirstChildByClass(XFA_Element::Occur)) { | 769 pTemplateNode->GetFirstChildByClass(XFA_Element::Occur)) { |
770 pOccurNode = pInstMgrNode | 770 pOccurNode = pInstMgrNode |
771 ? XFA_NodeMerge_CloneOrMergeContainer( | 771 ? XFA_NodeMerge_CloneOrMergeContainer( |
772 pDocument, pInstMgrNode, pOccurTemplateNode, FALSE) | 772 pDocument, pInstMgrNode, pOccurTemplateNode, FALSE) |
773 : pOccurTemplateNode; | 773 : pOccurTemplateNode; |
774 } else if (pInstMgrNode) { | 774 } else if (pInstMgrNode) { |
775 pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_Element::Occur); | 775 pOccurNode = pInstMgrNode->GetFirstChildByClass(XFA_Element::Occur); |
776 if (pOccurNode) { | 776 if (pOccurNode) { |
777 pOccurNode->ClearFlag(XFA_NodeFlag_UnusedNode); | 777 pOccurNode->ClearFlag(XFA_NodeFlag_UnusedNode); |
778 } | 778 } |
779 } | 779 } |
780 if (pInstMgrNode) { | 780 if (pInstMgrNode) { |
781 pInstMgrNode->SetFlag(XFA_NodeFlag_Initialized, true); | 781 pInstMgrNode->SetFlag(XFA_NodeFlag_Initialized, true); |
782 pSearchArray = &subformArray; | 782 pSearchArray = &subformArray; |
783 if (pFormParentNode->GetElementType() == XFA_Element::PageArea) { | 783 if (pFormParentNode->GetElementType() == XFA_Element::PageArea) { |
784 bOneInstance = TRUE; | 784 bOneInstance = TRUE; |
785 if (subformArray.GetSize() < 1) { | 785 if (subformArray.GetSize() < 1) { |
786 pSearchArray = NULL; | 786 pSearchArray = nullptr; |
787 } | 787 } |
788 } else if ((pTemplateNode->GetNameHash() == 0) && | 788 } else if ((pTemplateNode->GetNameHash() == 0) && |
789 (subformArray.GetSize() < 1)) { | 789 (subformArray.GetSize() < 1)) { |
790 pSearchArray = NULL; | 790 pSearchArray = nullptr; |
791 } | 791 } |
792 } | 792 } |
793 } | 793 } |
794 int32_t iMax = 1, iInit = 1, iMin = 1; | 794 int32_t iMax = 1, iInit = 1, iMin = 1; |
795 if (!bOneInstance) { | 795 if (!bOneInstance) { |
796 XFA_GetOccurInfo(pOccurNode, iMin, iMax, iInit); | 796 XFA_GetOccurInfo(pOccurNode, iMin, iMax, iInit); |
797 } | 797 } |
798 XFA_ATTRIBUTEENUM eRelation = | 798 XFA_ATTRIBUTEENUM eRelation = |
799 eType == XFA_Element::SubformSet | 799 eType == XFA_Element::SubformSet |
800 ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation) | 800 ? pTemplateNode->GetEnum(XFA_ATTRIBUTE_Relation) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { | 879 if (XFA_NeedGenerateForm(pTemplateChild, bUseInstanceManager)) { |
880 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, | 880 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pSubformSetNode, |
881 pTemplateChild, TRUE); | 881 pTemplateChild, TRUE); |
882 } else if (pTemplateChild->IsContainerNode()) { | 882 } else if (pTemplateChild->IsContainerNode()) { |
883 bSelfMatch = FALSE; | 883 bSelfMatch = FALSE; |
884 eBindMatch = XFA_ATTRIBUTEENUM_None; | 884 eBindMatch = XFA_ATTRIBUTEENUM_None; |
885 CXFA_Node* pDataMatch; | 885 CXFA_Node* pDataMatch; |
886 if (eRelation != XFA_ATTRIBUTEENUM_Ordered && | 886 if (eRelation != XFA_ATTRIBUTEENUM_Ordered && |
887 (pDataMatch = XFA_DataMerge_FindMatchingDataNode( | 887 (pDataMatch = XFA_DataMerge_FindMatchingDataNode( |
888 pDocument, pTemplateChild, pDataScope, bAccessedDataDOM, | 888 pDocument, pTemplateChild, pDataScope, bAccessedDataDOM, |
889 FALSE, NULL, bSelfMatch, eBindMatch)) != nullptr) { | 889 FALSE, nullptr, bSelfMatch, eBindMatch)) != nullptr) { |
890 XFA_DataMerge_RecurseRecord sNewRecord = {pTemplateChild, | 890 XFA_DataMerge_RecurseRecord sNewRecord = {pTemplateChild, |
891 pDataMatch}; | 891 pDataMatch}; |
892 if (bSelfMatch) { | 892 if (bSelfMatch) { |
893 rgItemMatchList.InsertAt(0, sNewRecord); | 893 rgItemMatchList.InsertAt(0, sNewRecord); |
894 } else { | 894 } else { |
895 rgItemMatchList.Add(sNewRecord); | 895 rgItemMatchList.Add(sNewRecord); |
896 } | 896 } |
897 } else { | 897 } else { |
898 rgItemUnmatchList.Add(pTemplateChild); | 898 rgItemUnmatchList.Add(pTemplateChild); |
899 } | 899 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 if (iLimit < iMin) { | 953 if (iLimit < iMin) { |
954 iLimit = iInit; | 954 iLimit = iInit; |
955 } | 955 } |
956 } | 956 } |
957 for (; (iLimit < 0 || iCurRepeatIndex < iLimit); iCurRepeatIndex++) { | 957 for (; (iLimit < 0 || iCurRepeatIndex < iLimit); iCurRepeatIndex++) { |
958 if (pInstMgrNode) { | 958 if (pInstMgrNode) { |
959 if (pSearchArray && pSearchArray->GetSize() < 1) { | 959 if (pSearchArray && pSearchArray->GetSize() < 1) { |
960 if (pTemplateNode->GetNameHash() != 0) { | 960 if (pTemplateNode->GetNameHash() != 0) { |
961 break; | 961 break; |
962 } | 962 } |
963 pSearchArray = NULL; | 963 pSearchArray = nullptr; |
964 } | 964 } |
965 } else if (!XFA_DataMerge_FindFormDOMInstance( | 965 } else if (!XFA_DataMerge_FindFormDOMInstance( |
966 pDocument, pTemplateNode->GetElementType(), | 966 pDocument, pTemplateNode->GetElementType(), |
967 pTemplateNode->GetNameHash(), pFormParentNode)) { | 967 pTemplateNode->GetNameHash(), pFormParentNode)) { |
968 break; | 968 break; |
969 } | 969 } |
970 CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer( | 970 CXFA_Node* pSubformNode = XFA_NodeMerge_CloneOrMergeContainer( |
971 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); | 971 pDocument, pFormParentNode, pTemplateNode, FALSE, pSearchArray); |
972 ASSERT(pSubformNode); | 972 ASSERT(pSubformNode); |
973 if (!pFirstInstance) { | 973 if (!pFirstInstance) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 1029 pTemplateNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
1030 pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem( | 1030 pTemplateChildNode; pTemplateChildNode = pTemplateChildNode->GetNodeItem( |
1031 XFA_NODEITEM_NextSibling)) { | 1031 XFA_NODEITEM_NextSibling)) { |
1032 if (XFA_NeedGenerateForm(pTemplateChildNode)) { | 1032 if (XFA_NeedGenerateForm(pTemplateChildNode)) { |
1033 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode, | 1033 XFA_NodeMerge_CloneOrMergeContainer(pDocument, pFieldNode, |
1034 pTemplateChildNode, TRUE); | 1034 pTemplateChildNode, TRUE); |
1035 } else if (pTemplateNode->GetElementType() == XFA_Element::ExclGroup && | 1035 } else if (pTemplateNode->GetElementType() == XFA_Element::ExclGroup && |
1036 pTemplateChildNode->IsContainerNode()) { | 1036 pTemplateChildNode->IsContainerNode()) { |
1037 if (pTemplateChildNode->GetElementType() == XFA_Element::Field) { | 1037 if (pTemplateChildNode->GetElementType() == XFA_Element::Field) { |
1038 XFA_DataMerge_CopyContainer_Field(pDocument, pTemplateChildNode, | 1038 XFA_DataMerge_CopyContainer_Field(pDocument, pTemplateChildNode, |
1039 pFieldNode, NULL, FALSE); | 1039 pFieldNode, nullptr, FALSE); |
1040 } | 1040 } |
1041 } | 1041 } |
1042 } | 1042 } |
1043 if (bDataMerge) { | 1043 if (bDataMerge) { |
1044 FX_BOOL bAccessedDataDOM = FALSE; | 1044 FX_BOOL bAccessedDataDOM = FALSE; |
1045 FX_BOOL bSelfMatch = FALSE; | 1045 FX_BOOL bSelfMatch = FALSE; |
1046 XFA_ATTRIBUTEENUM eBindMatch; | 1046 XFA_ATTRIBUTEENUM eBindMatch; |
1047 CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( | 1047 CXFA_Node* pDataNode = XFA_DataMerge_FindMatchingDataNode( |
1048 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, TRUE, NULL, | 1048 pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, TRUE, nullptr, |
1049 bSelfMatch, eBindMatch, bUpLevel); | 1049 bSelfMatch, eBindMatch, bUpLevel); |
1050 if (pDataNode) { | 1050 if (pDataNode) { |
1051 XFA_DataMerge_CreateDataBinding(pFieldNode, pDataNode); | 1051 XFA_DataMerge_CreateDataBinding(pFieldNode, pDataNode); |
1052 } | 1052 } |
1053 } else { | 1053 } else { |
1054 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFieldNode); | 1054 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFieldNode); |
1055 } | 1055 } |
1056 return pFieldNode; | 1056 return pFieldNode; |
1057 } | 1057 } |
1058 CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode, | 1058 CXFA_Node* CXFA_Document::DataMerge_CopyContainer(CXFA_Node* pTemplateNode, |
(...skipping 16 matching lines...) Expand all Loading... |
1075 return XFA_DataMerge_CopyContainer_Field( | 1075 return XFA_DataMerge_CopyContainer_Field( |
1076 this, pTemplateNode, pFormNode, pDataScope, bDataMerge, bUpLevel); | 1076 this, pTemplateNode, pFormNode, pDataScope, bDataMerge, bUpLevel); |
1077 case XFA_Element::PageSet: | 1077 case XFA_Element::PageSet: |
1078 break; | 1078 break; |
1079 case XFA_Element::Variables: | 1079 case XFA_Element::Variables: |
1080 break; | 1080 break; |
1081 default: | 1081 default: |
1082 ASSERT(FALSE); | 1082 ASSERT(FALSE); |
1083 break; | 1083 break; |
1084 } | 1084 } |
1085 return NULL; | 1085 return nullptr; |
1086 } | 1086 } |
1087 | 1087 |
1088 static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, | 1088 static void XFA_DataMerge_UpdateBindingRelations(CXFA_Document* pDocument, |
1089 CXFA_Node* pFormNode, | 1089 CXFA_Node* pFormNode, |
1090 CXFA_Node* pDataScope, | 1090 CXFA_Node* pDataScope, |
1091 FX_BOOL bDataRef, | 1091 FX_BOOL bDataRef, |
1092 FX_BOOL bParentDataRef) { | 1092 FX_BOOL bParentDataRef) { |
1093 FX_BOOL bMatchRef = TRUE; | 1093 FX_BOOL bMatchRef = TRUE; |
1094 XFA_Element eType = pFormNode->GetElementType(); | 1094 XFA_Element eType = pFormNode->GetElementType(); |
1095 CXFA_Node* pDataNode = pFormNode->GetBindData(); | 1095 CXFA_Node* pDataNode = pFormNode->GetBindData(); |
1096 if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup || | 1096 if (eType == XFA_Element::Subform || eType == XFA_Element::ExclGroup || |
1097 eType == XFA_Element::Field) { | 1097 eType == XFA_Element::Field) { |
1098 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); | 1098 CXFA_Node* pTemplateNode = pFormNode->GetTemplateNode(); |
1099 CXFA_Node* pTemplateNodeBind = | 1099 CXFA_Node* pTemplateNodeBind = |
1100 pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_Element::Bind) | 1100 pTemplateNode ? pTemplateNode->GetFirstChildByClass(XFA_Element::Bind) |
1101 : NULL; | 1101 : nullptr; |
1102 XFA_ATTRIBUTEENUM eMatch = | 1102 XFA_ATTRIBUTEENUM eMatch = |
1103 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) | 1103 pTemplateNodeBind ? pTemplateNodeBind->GetEnum(XFA_ATTRIBUTE_Match) |
1104 : XFA_ATTRIBUTEENUM_Once; | 1104 : XFA_ATTRIBUTEENUM_Once; |
1105 switch (eMatch) { | 1105 switch (eMatch) { |
1106 case XFA_ATTRIBUTEENUM_None: | 1106 case XFA_ATTRIBUTEENUM_None: |
1107 if (!bDataRef || bParentDataRef) { | 1107 if (!bDataRef || bParentDataRef) { |
1108 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); | 1108 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); |
1109 } | 1109 } |
1110 break; | 1110 break; |
1111 case XFA_ATTRIBUTEENUM_Once: | 1111 case XFA_ATTRIBUTEENUM_Once: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 bMatchRef = bDataRef; | 1172 bMatchRef = bDataRef; |
1173 bParentDataRef = TRUE; | 1173 bParentDataRef = TRUE; |
1174 if (!pDataNode && bDataRef) { | 1174 if (!pDataNode && bDataRef) { |
1175 CFX_WideStringC wsRef = | 1175 CFX_WideStringC wsRef = |
1176 pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref); | 1176 pTemplateNodeBind->GetCData(XFA_ATTRIBUTE_Ref); |
1177 uint32_t dFlags = | 1177 uint32_t dFlags = |
1178 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode; | 1178 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_CreateNode; |
1179 XFA_RESOLVENODE_RS rs; | 1179 XFA_RESOLVENODE_RS rs; |
1180 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, | 1180 pDocument->GetScriptContext()->ResolveObjects(pDataScope, wsRef, rs, |
1181 dFlags, pTemplateNode); | 1181 dFlags, pTemplateNode); |
1182 CXFA_Object* pObject = (rs.nodes.GetSize() > 0) ? rs.nodes[0] : NULL; | 1182 CXFA_Object* pObject = |
| 1183 (rs.nodes.GetSize() > 0) ? rs.nodes[0] : nullptr; |
1183 pDataNode = ToNode(pObject); | 1184 pDataNode = ToNode(pObject); |
1184 if (pDataNode) { | 1185 if (pDataNode) { |
1185 XFA_DataMerge_CreateDataBinding( | 1186 XFA_DataMerge_CreateDataBinding( |
1186 pFormNode, pDataNode, | 1187 pFormNode, pDataNode, |
1187 rs.dwFlags == XFA_RESOVENODE_RSTYPE_ExistNodes); | 1188 rs.dwFlags == XFA_RESOVENODE_RSTYPE_ExistNodes); |
1188 } else { | 1189 } else { |
1189 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); | 1190 XFA_DataMerge_FormValueNode_MatchNoneCreateChild(pFormNode); |
1190 } | 1191 } |
1191 } | 1192 } |
1192 } break; | 1193 } break; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 if (!pDatasetsRoot) { | 1251 if (!pDatasetsRoot) { |
1251 CFDE_XMLElement* pDatasetsXMLNode = new CFDE_XMLElement(L"xfa:datasets"); | 1252 CFDE_XMLElement* pDatasetsXMLNode = new CFDE_XMLElement(L"xfa:datasets"); |
1252 pDatasetsXMLNode->SetString(L"xmlns:xfa", | 1253 pDatasetsXMLNode->SetString(L"xmlns:xfa", |
1253 L"http://www.xfa.org/schema/xfa-data/1.0/"); | 1254 L"http://www.xfa.org/schema/xfa-data/1.0/"); |
1254 pDatasetsRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataModel); | 1255 pDatasetsRoot = CreateNode(XFA_XDPPACKET_Datasets, XFA_Element::DataModel); |
1255 pDatasetsRoot->SetCData(XFA_ATTRIBUTE_Name, L"datasets"); | 1256 pDatasetsRoot->SetCData(XFA_ATTRIBUTE_Name, L"datasets"); |
1256 m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode); | 1257 m_pRootNode->GetXMLMappingNode()->InsertChildNode(pDatasetsXMLNode); |
1257 m_pRootNode->InsertChild(pDatasetsRoot); | 1258 m_pRootNode->InsertChild(pDatasetsRoot); |
1258 pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode); | 1259 pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode); |
1259 } | 1260 } |
1260 CXFA_Node *pDataRoot = NULL, *pDDRoot = NULL; | 1261 CXFA_Node *pDataRoot = nullptr, *pDDRoot = nullptr; |
1261 CFX_WideString wsDatasetsURI; | 1262 CFX_WideString wsDatasetsURI; |
1262 pDatasetsRoot->TryNamespace(wsDatasetsURI); | 1263 pDatasetsRoot->TryNamespace(wsDatasetsURI); |
1263 for (CXFA_Node* pChildNode = | 1264 for (CXFA_Node* pChildNode = |
1264 pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild); | 1265 pDatasetsRoot->GetNodeItem(XFA_NODEITEM_FirstChild); |
1265 pChildNode; | 1266 pChildNode; |
1266 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 1267 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
1267 if (pChildNode->GetElementType() != XFA_Element::DataGroup) { | 1268 if (pChildNode->GetElementType() != XFA_Element::DataGroup) { |
1268 continue; | 1269 continue; |
1269 } | 1270 } |
1270 CFX_WideString wsNamespaceURI; | 1271 CFX_WideString wsNamespaceURI; |
(...skipping 26 matching lines...) Expand all Loading... |
1297 } | 1298 } |
1298 CXFA_Node* pDataTopLevel = | 1299 CXFA_Node* pDataTopLevel = |
1299 pDataRoot->GetFirstChildByClass(XFA_Element::DataGroup); | 1300 pDataRoot->GetFirstChildByClass(XFA_Element::DataGroup); |
1300 uint32_t dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0; | 1301 uint32_t dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0; |
1301 CXFA_Node* pTemplateRoot = | 1302 CXFA_Node* pTemplateRoot = |
1302 m_pRootNode->GetFirstChildByClass(XFA_Element::Template); | 1303 m_pRootNode->GetFirstChildByClass(XFA_Element::Template); |
1303 if (!pTemplateRoot) { | 1304 if (!pTemplateRoot) { |
1304 return; | 1305 return; |
1305 } | 1306 } |
1306 CXFA_Node* pTemplateChosen = | 1307 CXFA_Node* pTemplateChosen = |
1307 dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) : NULL; | 1308 dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) |
| 1309 : nullptr; |
1308 if (!pTemplateChosen || | 1310 if (!pTemplateChosen || |
1309 pTemplateChosen->GetElementType() != XFA_Element::Subform) { | 1311 pTemplateChosen->GetElementType() != XFA_Element::Subform) { |
1310 pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform); | 1312 pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_Element::Subform); |
1311 } | 1313 } |
1312 if (!pTemplateChosen) { | 1314 if (!pTemplateChosen) { |
1313 return; | 1315 return; |
1314 } | 1316 } |
1315 CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_Element::Form); | 1317 CXFA_Node* pFormRoot = m_pRootNode->GetFirstChildByClass(XFA_Element::Form); |
1316 FX_BOOL bEmptyForm = FALSE; | 1318 FX_BOOL bEmptyForm = FALSE; |
1317 if (!pFormRoot) { | 1319 if (!pFormRoot) { |
1318 bEmptyForm = TRUE; | 1320 bEmptyForm = TRUE; |
1319 pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_Element::Form); | 1321 pFormRoot = CreateNode(XFA_XDPPACKET_Form, XFA_Element::Form); |
1320 ASSERT(pFormRoot); | 1322 ASSERT(pFormRoot); |
1321 pFormRoot->SetCData(XFA_ATTRIBUTE_Name, L"form"); | 1323 pFormRoot->SetCData(XFA_ATTRIBUTE_Name, L"form"); |
1322 m_pRootNode->InsertChild(pFormRoot, NULL); | 1324 m_pRootNode->InsertChild(pFormRoot, nullptr); |
1323 } else { | 1325 } else { |
1324 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> | 1326 CXFA_NodeIteratorTemplate<CXFA_Node, CXFA_TraverseStrategy_XFANode> |
1325 sIterator(pFormRoot); | 1327 sIterator(pFormRoot); |
1326 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; | 1328 for (CXFA_Node* pNode = sIterator.MoveToNext(); pNode; |
1327 pNode = sIterator.MoveToNext()) { | 1329 pNode = sIterator.MoveToNext()) { |
1328 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); | 1330 pNode->SetFlag(XFA_NodeFlag_UnusedNode, true); |
1329 } | 1331 } |
1330 } | 1332 } |
1331 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( | 1333 CXFA_Node* pSubformSetNode = XFA_NodeMerge_CloneOrMergeContainer( |
1332 this, pFormRoot, pTemplateChosen, FALSE); | 1334 this, pFormRoot, pTemplateChosen, FALSE); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 } | 1394 } |
1393 } | 1395 } |
1394 } | 1396 } |
1395 } | 1397 } |
1396 void CXFA_Document::DoDataRemerge(FX_BOOL bDoDataMerge) { | 1398 void CXFA_Document::DoDataRemerge(FX_BOOL bDoDataMerge) { |
1397 CXFA_Node* pFormRoot = ToNode(GetXFAObject(XFA_HASHCODE_Form)); | 1399 CXFA_Node* pFormRoot = ToNode(GetXFAObject(XFA_HASHCODE_Form)); |
1398 if (pFormRoot) { | 1400 if (pFormRoot) { |
1399 while (CXFA_Node* pNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) { | 1401 while (CXFA_Node* pNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild)) { |
1400 pFormRoot->RemoveChild(pNode); | 1402 pFormRoot->RemoveChild(pNode); |
1401 } | 1403 } |
1402 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 1404 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, nullptr); |
1403 } | 1405 } |
1404 XFA_DataMerge_ClearGlobalBinding(this); | 1406 XFA_DataMerge_ClearGlobalBinding(this); |
1405 if (bDoDataMerge) { | 1407 if (bDoDataMerge) { |
1406 DoDataMerge(); | 1408 DoDataMerge(); |
1407 } | 1409 } |
1408 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); | 1410 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); |
1409 pLayoutProcessor->SetForceReLayout(TRUE); | 1411 pLayoutProcessor->SetForceReLayout(TRUE); |
1410 } | 1412 } |
OLD | NEW |