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_script_nodehelper.h" | 7 #include "xfa/fxfa/parser/xfa_script_nodehelper.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 pScriptContext->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); | 361 pScriptContext->GetDocument()->GetXFAObject(XFA_HASHCODE_Datasets)); |
362 } | 362 } |
363 if (wsName.GetAt(0) == '#') { | 363 if (wsName.GetAt(0) == '#') { |
364 bIsClassName = TRUE; | 364 bIsClassName = TRUE; |
365 wsName = wsName.Right(wsName.GetLength() - 1); | 365 wsName = wsName.Right(wsName.GetLength() - 1); |
366 } | 366 } |
367 if (m_iCreateCount == 0) { | 367 if (m_iCreateCount == 0) { |
368 XFA_CreateNode_ForCondition(wsCondition); | 368 XFA_CreateNode_ForCondition(wsCondition); |
369 } | 369 } |
370 if (bIsClassName) { | 370 if (bIsClassName) { |
371 const XFA_ELEMENTINFO* lpElement = | 371 const XFA_ELEMENTINFO* lpElement = XFA_GetElementByName(wsName.AsStringC()); |
372 XFA_GetElementByName(wsName.AsWideStringC()); | |
373 if (lpElement == NULL) { | 372 if (lpElement == NULL) { |
374 return FALSE; | 373 return FALSE; |
375 } | 374 } |
376 for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { | 375 for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { |
377 CXFA_Node* pNewNode = | 376 CXFA_Node* pNewNode = |
378 m_pCreateParent->CreateSamePacketNode(lpElement->eName); | 377 m_pCreateParent->CreateSamePacketNode(lpElement->eName); |
379 if (pNewNode) { | 378 if (pNewNode) { |
380 m_pCreateParent->InsertChild(pNewNode); | 379 m_pCreateParent->InsertChild(pNewNode); |
381 if (iIndex == m_iCreateCount - 1) { | 380 if (iIndex == m_iCreateCount - 1) { |
382 m_pCreateParent = pNewNode; | 381 m_pCreateParent = pNewNode; |
383 } | 382 } |
384 bResult = TRUE; | 383 bResult = TRUE; |
385 } | 384 } |
386 } | 385 } |
387 } else { | 386 } else { |
388 XFA_ELEMENT eClassType = XFA_ELEMENT_DataGroup; | 387 XFA_ELEMENT eClassType = XFA_ELEMENT_DataGroup; |
389 if (bLastNode) { | 388 if (bLastNode) { |
390 eClassType = m_eLastCreateType; | 389 eClassType = m_eLastCreateType; |
391 } | 390 } |
392 for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { | 391 for (int32_t iIndex = 0; iIndex < m_iCreateCount; iIndex++) { |
393 CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType); | 392 CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType); |
394 if (pNewNode) { | 393 if (pNewNode) { |
395 pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName.AsWideStringC()); | 394 pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, wsName.AsStringC()); |
396 pNewNode->CreateXMLMappingNode(); | 395 pNewNode->CreateXMLMappingNode(); |
397 m_pCreateParent->InsertChild(pNewNode); | 396 m_pCreateParent->InsertChild(pNewNode); |
398 if (iIndex == m_iCreateCount - 1) { | 397 if (iIndex == m_iCreateCount - 1) { |
399 m_pCreateParent = pNewNode; | 398 m_pCreateParent = pNewNode; |
400 } | 399 } |
401 bResult = TRUE; | 400 bResult = TRUE; |
402 } | 401 } |
403 } | 402 } |
404 } | 403 } |
405 if (!bResult) { | 404 if (!bResult) { |
(...skipping 15 matching lines...) Expand all Loading... |
421 m_eLastCreateType = XFA_ELEMENT_DataValue; | 420 m_eLastCreateType = XFA_ELEMENT_DataValue; |
422 } | 421 } |
423 } | 422 } |
424 FX_BOOL CXFA_NodeHelper::XFA_NodeIsProperty(CXFA_Node* refNode) { | 423 FX_BOOL CXFA_NodeHelper::XFA_NodeIsProperty(CXFA_Node* refNode) { |
425 CXFA_Node* parent = | 424 CXFA_Node* parent = |
426 XFA_ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); | 425 XFA_ResolveNodes_GetParent(refNode, XFA_LOGIC_NoTransparent); |
427 return parent && refNode && | 426 return parent && refNode && |
428 XFA_GetPropertyOfElement(parent->GetClassID(), refNode->GetClassID(), | 427 XFA_GetPropertyOfElement(parent->GetClassID(), refNode->GetClassID(), |
429 XFA_XDPPACKET_UNKNOWN); | 428 XFA_XDPPACKET_UNKNOWN); |
430 } | 429 } |
OLD | NEW |