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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 if (!bUpLevel) { | 390 if (!bUpLevel) { |
391 break; | 391 break; |
392 } | 392 } |
393 } | 393 } |
394 return NULL; | 394 return NULL; |
395 } | 395 } |
396 static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, | 396 static CXFA_Node* XFA_DataMerge_FindGlobalDataNode(CXFA_Document* pDocument, |
397 CFX_WideStringC wsName, | 397 CFX_WideStringC wsName, |
398 CXFA_Node* pDataScope, | 398 CXFA_Node* pDataScope, |
399 XFA_ELEMENT eMatchNodeType) { | 399 XFA_ELEMENT eMatchNodeType) { |
400 uint32_t dwNameHash = | 400 if (wsName.IsEmpty()) |
401 wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.c_str(), | 401 return nullptr; |
402 wsName.GetLength()); | 402 |
403 if (dwNameHash != 0) { | 403 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); |
404 CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); | 404 CXFA_Node* pBounded = XFA_DataMerge_GetGlobalBinding(pDocument, dwNameHash); |
405 if (!pBounded) { | 405 if (!pBounded) { |
406 pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash, | 406 pBounded = XFA_DataMerge_ScopeMatchGlobalBinding(pDataScope, dwNameHash, |
407 eMatchNodeType); | 407 eMatchNodeType); |
408 if (pBounded) { | 408 if (pBounded) { |
409 XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded); | 409 XFA_DataMerge_RegisterGlobalBinding(pDocument, dwNameHash, pBounded); |
410 } | |
411 } | 410 } |
412 return pBounded; | |
413 } | 411 } |
414 return NULL; | 412 return pBounded; |
415 } | 413 } |
| 414 |
416 static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument, | 415 static CXFA_Node* XFA_DataMerge_FindOnceDataNode(CXFA_Document* pDocument, |
417 CFX_WideStringC wsName, | 416 CFX_WideStringC wsName, |
418 CXFA_Node* pDataScope, | 417 CXFA_Node* pDataScope, |
419 XFA_ELEMENT eMatchNodeType) { | 418 XFA_ELEMENT eMatchNodeType) { |
420 uint32_t dwNameHash = | 419 if (wsName.IsEmpty()) |
421 wsName.IsEmpty() ? 0 : FX_HashCode_String_GetW(wsName.c_str(), | 420 return nullptr; |
422 wsName.GetLength()); | 421 |
423 if (dwNameHash != 0) { | 422 uint32_t dwNameHash = FX_HashCode_GetW(wsName, false); |
424 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL; | 423 CXFA_Node* pLastDataScope = nullptr; |
425 pCurDataScope && | 424 for (CXFA_Node* pCurDataScope = pDataScope; |
426 pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; | 425 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; |
427 pLastDataScope = pCurDataScope, | 426 pCurDataScope = pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { |
428 pCurDataScope = | 427 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash); |
429 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { | 428 pDataChild; |
430 for (CXFA_Node* pDataChild = | 429 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { |
431 pCurDataScope->GetFirstChildByName(dwNameHash); | 430 if (pDataChild == pLastDataScope || pDataChild->HasBindItem() || |
432 pDataChild; | 431 (eMatchNodeType != XFA_ELEMENT_DataModel && |
433 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { | 432 pDataChild->GetClassID() != eMatchNodeType)) { |
434 if (pDataChild == pLastDataScope || | 433 continue; |
435 (eMatchNodeType != XFA_ELEMENT_DataModel && | |
436 pDataChild->GetClassID() != eMatchNodeType) || | |
437 pDataChild->HasBindItem()) { | |
438 continue; | |
439 } | |
440 return pDataChild; | |
441 } | 434 } |
| 435 return pDataChild; |
442 } | 436 } |
| 437 pLastDataScope = pCurDataScope; |
443 } | 438 } |
444 return NULL; | 439 return nullptr; |
445 } | 440 } |
| 441 |
446 static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, | 442 static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, |
447 CFX_WideStringC wsRef, | 443 CFX_WideStringC wsRef, |
448 CXFA_Node* pDataScope, | 444 CXFA_Node* pDataScope, |
449 XFA_ELEMENT eMatchNodeType, | 445 XFA_ELEMENT eMatchNodeType, |
450 CXFA_Node* pTemplateNode, | 446 CXFA_Node* pTemplateNode, |
451 FX_BOOL bForceBind, | 447 FX_BOOL bForceBind, |
452 FX_BOOL bUpLevel = TRUE) { | 448 FX_BOOL bUpLevel = TRUE) { |
453 uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew; | 449 uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew; |
454 if (bUpLevel || wsRef != FX_WSTRC(L"name")) { | 450 if (bUpLevel || wsRef != FX_WSTRC(L"name")) { |
455 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); | 451 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 } | 550 } |
555 return pNewNode; | 551 return pNewNode; |
556 } | 552 } |
557 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( | 553 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( |
558 CXFA_Document* pDocument, | 554 CXFA_Document* pDocument, |
559 CXFA_Node* pFormParent, | 555 CXFA_Node* pFormParent, |
560 CXFA_Node* pTemplateNode, | 556 CXFA_Node* pTemplateNode, |
561 CXFA_NodeArray& subforms) { | 557 CXFA_NodeArray& subforms) { |
562 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); | 558 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); |
563 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; | 559 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; |
564 uint32_t dwInstNameHash = FX_HashCode_String_GetW( | 560 uint32_t dwInstNameHash = |
565 wsInstMgrNodeName.c_str(), wsInstMgrNodeName.GetLength()); | 561 FX_HashCode_GetW(wsInstMgrNodeName.AsStringC(), false); |
566 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( | 562 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( |
567 pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent); | 563 pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent); |
568 if (pExistingNode) { | 564 if (pExistingNode) { |
569 uint32_t dwNameHash = pTemplateNode->GetNameHash(); | 565 uint32_t dwNameHash = pTemplateNode->GetNameHash(); |
570 for (CXFA_Node* pNode = | 566 for (CXFA_Node* pNode = |
571 pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 567 pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
572 pNode;) { | 568 pNode;) { |
573 XFA_ELEMENT eCurType = pNode->GetClassID(); | 569 XFA_ELEMENT eCurType = pNode->GetClassID(); |
574 if (eCurType == XFA_ELEMENT_InstanceManager) { | 570 if (eCurType == XFA_ELEMENT_InstanceManager) { |
575 break; | 571 break; |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 } | 1419 } |
1424 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); | 1420 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); |
1425 } | 1421 } |
1426 XFA_DataMerge_ClearGlobalBinding(this); | 1422 XFA_DataMerge_ClearGlobalBinding(this); |
1427 if (bDoDataMerge) { | 1423 if (bDoDataMerge) { |
1428 DoDataMerge(); | 1424 DoDataMerge(); |
1429 } | 1425 } |
1430 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); | 1426 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); |
1431 pLayoutProcessor->SetForceReLayout(TRUE); | 1427 pLayoutProcessor->SetForceReLayout(TRUE); |
1432 } | 1428 } |
OLD | NEW |