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

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

Issue 1919563002: Pass CFX_*StringCs to FX_HashCode_GETA and _GETW hash functions. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: win again again again Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/parser/xfa_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
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 for (CXFA_Node *pCurDataScope = pDataScope, *pLastDataScope = NULL;
Lei Zhang 2016/04/23 01:33:29 My eyes!
Tom Sepez 2016/04/25 16:50:21 Made slightly better with both for-loops having on
425 pCurDataScope && 424 pCurDataScope && pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets;
426 pCurDataScope->GetPacketID() == XFA_XDPPACKET_Datasets; 425 pLastDataScope = pCurDataScope,
427 pLastDataScope = pCurDataScope, 426 pCurDataScope =
428 pCurDataScope = 427 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) {
429 pCurDataScope->GetNodeItem(XFA_NODEITEM_Parent)) { 428 for (CXFA_Node* pDataChild = pCurDataScope->GetFirstChildByName(dwNameHash);
430 for (CXFA_Node* pDataChild = 429 pDataChild;
431 pCurDataScope->GetFirstChildByName(dwNameHash); 430 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) {
432 pDataChild; 431 if (pDataChild == pLastDataScope ||
433 pDataChild = pDataChild->GetNextSameNameSibling(dwNameHash)) { 432 (eMatchNodeType != XFA_ELEMENT_DataModel &&
434 if (pDataChild == pLastDataScope || 433 pDataChild->GetClassID() != eMatchNodeType) ||
435 (eMatchNodeType != XFA_ELEMENT_DataModel && 434 pDataChild->HasBindItem()) {
436 pDataChild->GetClassID() != eMatchNodeType) || 435 continue;
437 pDataChild->HasBindItem()) {
438 continue;
439 }
440 return pDataChild;
441 } 436 }
437 return pDataChild;
442 } 438 }
443 } 439 }
444 return NULL; 440 return nullptr;
445 } 441 }
442
446 static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument, 443 static CXFA_Node* XFA_DataMerge_FindDataRefDataNode(CXFA_Document* pDocument,
447 CFX_WideStringC wsRef, 444 CFX_WideStringC wsRef,
448 CXFA_Node* pDataScope, 445 CXFA_Node* pDataScope,
449 XFA_ELEMENT eMatchNodeType, 446 XFA_ELEMENT eMatchNodeType,
450 CXFA_Node* pTemplateNode, 447 CXFA_Node* pTemplateNode,
451 FX_BOOL bForceBind, 448 FX_BOOL bForceBind,
452 FX_BOOL bUpLevel = TRUE) { 449 FX_BOOL bUpLevel = TRUE) {
453 uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew; 450 uint32_t dFlags = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_BindNew;
454 if (bUpLevel || wsRef != FX_WSTRC(L"name")) { 451 if (bUpLevel || wsRef != FX_WSTRC(L"name")) {
455 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings); 452 dFlags |= (XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 551 }
555 return pNewNode; 552 return pNewNode;
556 } 553 }
557 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager( 554 static CXFA_Node* XFA_NodeMerge_CloneOrMergeInstanceManager(
558 CXFA_Document* pDocument, 555 CXFA_Document* pDocument,
559 CXFA_Node* pFormParent, 556 CXFA_Node* pFormParent,
560 CXFA_Node* pTemplateNode, 557 CXFA_Node* pTemplateNode,
561 CXFA_NodeArray& subforms) { 558 CXFA_NodeArray& subforms) {
562 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name); 559 CFX_WideStringC wsSubformName = pTemplateNode->GetCData(XFA_ATTRIBUTE_Name);
563 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName; 560 CFX_WideString wsInstMgrNodeName = FX_WSTRC(L"_") + wsSubformName;
564 uint32_t dwInstNameHash = FX_HashCode_String_GetW( 561 uint32_t dwInstNameHash =
565 wsInstMgrNodeName.c_str(), wsInstMgrNodeName.GetLength()); 562 FX_HashCode_GetW(wsInstMgrNodeName.AsStringC(), false);
566 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance( 563 CXFA_Node* pExistingNode = XFA_DataMerge_FindFormDOMInstance(
567 pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent); 564 pDocument, XFA_ELEMENT_InstanceManager, dwInstNameHash, pFormParent);
568 if (pExistingNode) { 565 if (pExistingNode) {
569 uint32_t dwNameHash = pTemplateNode->GetNameHash(); 566 uint32_t dwNameHash = pTemplateNode->GetNameHash();
570 for (CXFA_Node* pNode = 567 for (CXFA_Node* pNode =
571 pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling); 568 pExistingNode->GetNodeItem(XFA_NODEITEM_NextSibling);
572 pNode;) { 569 pNode;) {
573 XFA_ELEMENT eCurType = pNode->GetClassID(); 570 XFA_ELEMENT eCurType = pNode->GetClassID();
574 if (eCurType == XFA_ELEMENT_InstanceManager) { 571 if (eCurType == XFA_ELEMENT_InstanceManager) {
575 break; 572 break;
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1423 } 1420 }
1424 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL); 1421 pFormRoot->SetObject(XFA_ATTRIBUTE_BindingNode, NULL);
1425 } 1422 }
1426 XFA_DataMerge_ClearGlobalBinding(this); 1423 XFA_DataMerge_ClearGlobalBinding(this);
1427 if (bDoDataMerge) { 1424 if (bDoDataMerge) {
1428 DoDataMerge(); 1425 DoDataMerge();
1429 } 1426 }
1430 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor(); 1427 CXFA_LayoutProcessor* pLayoutProcessor = GetLayoutProcessor();
1431 pLayoutProcessor->SetForceReLayout(TRUE); 1428 pLayoutProcessor->SetForceReLayout(TRUE);
1432 } 1429 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698