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_object.h" | 7 #include "xfa/fxfa/parser/xfa_object.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fgas/crt/fgas_codepage.h" | 10 #include "xfa/fgas/crt/fgas_codepage.h" |
11 #include "xfa/fgas/crt/fgas_system.h" | 11 #include "xfa/fgas/crt/fgas_system.h" |
12 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 12 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
13 #include "xfa/fxfa/parser/xfa_basic_imp.h" | 13 #include "xfa/fxfa/parser/xfa_basic_imp.h" |
14 #include "xfa/fxfa/parser/xfa_docdata.h" | 14 #include "xfa/fxfa/parser/xfa_docdata.h" |
15 #include "xfa/fxfa/parser/xfa_doclayout.h" | 15 #include "xfa/fxfa/parser/xfa_doclayout.h" |
16 #include "xfa/fxfa/parser/xfa_document.h" | 16 #include "xfa/fxfa/parser/xfa_document.h" |
17 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 17 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
18 #include "xfa/fxfa/parser/xfa_localemgr.h" | 18 #include "xfa/fxfa/parser/xfa_localemgr.h" |
19 #include "xfa/fxfa/parser/xfa_parser.h" | 19 #include "xfa/fxfa/parser/xfa_parser.h" |
20 #include "xfa/fxfa/parser/xfa_script.h" | 20 #include "xfa/fxfa/parser/xfa_script.h" |
21 #include "xfa/fxfa/parser/xfa_utils.h" | 21 #include "xfa/fxfa/parser/xfa_utils.h" |
22 #include "xfa/fxjse/cfxjse_arguments.h" | 22 #include "xfa/fxjse/cfxjse_arguments.h" |
23 | 23 |
24 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, uint32_t uFlags) | 24 CXFA_Object::CXFA_Object(CXFA_Document* pDocument, uint32_t uFlags) |
25 : m_pDocument(pDocument), m_uFlags(uFlags) {} | 25 : m_pDocument(pDocument), m_uFlags(uFlags) {} |
26 void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { | 26 void CXFA_Object::GetClassName(CFX_WideStringC& wsName) const { |
27 wsName = XFA_GetElementByID(GetClassID())->pName; | 27 wsName = XFA_GetObjectByByID(GetClassID())->pName; |
28 } | 28 } |
29 uint32_t CXFA_Object::GetClassHashCode() const { | 29 uint32_t CXFA_Object::GetClassHashCode() const { |
30 return XFA_GetElementByID(GetClassID())->uHash; | 30 return XFA_GetObjectByByID(GetClassID())->uHash; |
31 } | 31 } |
32 XFA_ELEMENT CXFA_Object::GetClassID() const { | 32 XFA_ELEMENT CXFA_Object::GetClassID() const { |
33 if (IsNode()) { | 33 if (IsNode()) { |
34 return AsNode()->GetClassID(); | 34 return AsNode()->GetClassID(); |
35 } | 35 } |
36 if (IsOrdinaryObject()) { | 36 if (IsOrdinaryObject()) { |
37 return AsOrdinaryObject()->GetClassID(); | 37 return AsOrdinaryObject()->GetClassID(); |
38 } | 38 } |
39 if (IsNodeList()) { | 39 if (IsNodeList()) { |
40 return AsNodeList()->GetClassID(); | 40 return AsNodeList()->GetClassID(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 } | 75 } |
76 | 76 |
77 static void XFA_CopyWideString(void*& pData) { | 77 static void XFA_CopyWideString(void*& pData) { |
78 if (pData) { | 78 if (pData) { |
79 CFX_WideString* pNewData = new CFX_WideString(*(CFX_WideString*)pData); | 79 CFX_WideString* pNewData = new CFX_WideString(*(CFX_WideString*)pData); |
80 pData = pNewData; | 80 pData = pNewData; |
81 } | 81 } |
82 } | 82 } |
83 static XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = { | 83 static XFA_MAPDATABLOCKCALLBACKINFO deleteWideStringCallBack = { |
84 XFA_DeleteWideString, XFA_CopyWideString}; | 84 XFA_DeleteWideString, XFA_CopyWideString}; |
85 static XFA_OBJECTTYPE XFA_GetElementObjectType(XFA_ELEMENT eElement) { | 85 static XFA_OBJECTTYPE XFA_GetObjectByObjectType(XFA_ELEMENT eElement) { |
86 return (XFA_OBJECTTYPE)XFA_GetElementByID(eElement)->eObjectType; | 86 return (XFA_OBJECTTYPE)XFA_GetObjectByByID(eElement)->eObjectType; |
87 } | 87 } |
88 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, | 88 CXFA_Node::CXFA_Node(CXFA_Document* pDoc, |
89 uint16_t ePacket, | 89 uint16_t ePacket, |
90 XFA_ELEMENT eElement) | 90 XFA_ELEMENT eElement) |
91 : CXFA_Object(pDoc, XFA_GetElementObjectType(eElement)), | 91 : CXFA_Object(pDoc, XFA_GetObjectByObjectType(eElement)), |
92 m_pNext(nullptr), | 92 m_pNext(nullptr), |
93 m_pChild(nullptr), | 93 m_pChild(nullptr), |
94 m_pLastChild(nullptr), | 94 m_pLastChild(nullptr), |
95 m_pParent(nullptr), | 95 m_pParent(nullptr), |
96 m_pXMLNode(nullptr), | 96 m_pXMLNode(nullptr), |
97 m_eNodeClass(eElement), | 97 m_eNodeClass(eElement), |
98 m_ePacket(ePacket), | 98 m_ePacket(ePacket), |
99 m_dwNameHash(0), | 99 m_dwNameHash(0), |
100 m_pAuxNode(nullptr), | 100 m_pAuxNode(nullptr), |
101 m_pMapModuleData(nullptr) { | 101 m_pMapModuleData(nullptr) { |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 } else { | 272 } else { |
273 if (bFilterChildren) { | 273 if (bFilterChildren) { |
274 nodes.Add(pChild); | 274 nodes.Add(pChild); |
275 } | 275 } |
276 } | 276 } |
277 pChild = pChild->m_pNext; | 277 pChild = pChild->m_pNext; |
278 } | 278 } |
279 if (bFilterOneOfProperties && nodes.GetSize() < 1) { | 279 if (bFilterOneOfProperties && nodes.GetSize() < 1) { |
280 int32_t iProperties = 0; | 280 int32_t iProperties = 0; |
281 const XFA_PROPERTY* pProperty = | 281 const XFA_PROPERTY* pProperty = |
282 XFA_GetElementProperties(GetClassID(), iProperties); | 282 XFA_GetObjectByProperties(GetClassID(), iProperties); |
283 if (pProperty == NULL || iProperties < 1) { | 283 if (pProperty == NULL || iProperties < 1) { |
284 return 0; | 284 return 0; |
285 } | 285 } |
286 for (int32_t i = 0; i < iProperties; i++) { | 286 for (int32_t i = 0; i < iProperties; i++) { |
287 if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) { | 287 if (pProperty[i].uFlags & XFA_PROPERTYFLAG_DefaultOneOf) { |
288 IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); | 288 IXFA_ObjFactory* pFactory = m_pDocument->GetParser()->GetFactory(); |
289 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID()); | 289 const XFA_PACKETINFO* pPacket = XFA_GetPacketByID(GetPacketID()); |
290 CXFA_Node* pNewNode = | 290 CXFA_Node* pNewNode = |
291 pFactory->CreateNode(pPacket, (XFA_ELEMENT)pProperty[i].eName); | 291 pFactory->CreateNode(pPacket, (XFA_ELEMENT)pProperty[i].eName); |
292 if (!pNewNode) { | 292 if (!pNewNode) { |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
869 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); | 869 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); |
870 wsExpression = | 870 wsExpression = |
871 CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); | 871 CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); |
872 CFX_WideString wsValue; | 872 CFX_WideString wsValue; |
873 GetAttribute(wsExpression, wsValue); | 873 GetAttribute(wsExpression, wsValue); |
874 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); | 874 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); |
875 if (hValue) { | 875 if (hValue) { |
876 FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); | 876 FXJSE_Value_SetUTF8String(hValue, FX_UTF8Encode(wsValue)); |
877 } | 877 } |
878 } | 878 } |
879 void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { | 879 void CXFA_Node::Script_NodeClass_GetObjectBy(CFXJSE_Arguments* pArguments) { |
880 int32_t iLength = pArguments->GetLength(); | 880 int32_t iLength = pArguments->GetLength(); |
881 if (iLength < 1 || iLength > 2) { | 881 if (iLength < 1 || iLength > 2) { |
882 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement"); | 882 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement"); |
883 return; | 883 return; |
884 } | 884 } |
885 CFX_WideString wsExpression; | 885 CFX_WideString wsExpression; |
886 int32_t iValue = 0; | 886 int32_t iValue = 0; |
887 if (iLength >= 1) { | 887 if (iLength >= 1) { |
888 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); | 888 CFX_ByteString bsExpression = pArguments->GetUTF8String(0); |
889 wsExpression = | 889 wsExpression = |
890 CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); | 890 CFX_WideString::FromUTF8(bsExpression, bsExpression.GetLength()); |
891 } | 891 } |
892 if (iLength >= 2) { | 892 if (iLength >= 2) { |
893 iValue = pArguments->GetInt32(1); | 893 iValue = pArguments->GetInt32(1); |
894 } | 894 } |
895 const XFA_ELEMENTINFO* pElementInfo = XFA_GetElementByName(wsExpression); | 895 const XFA_ELEMENTINFO* pElementInfo = XFA_GetObjectByByName(wsExpression); |
dsinclair
2016/03/29 20:45:25
ByBy
| |
896 CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName); | 896 CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName); |
897 FXJSE_Value_Set(pArguments->GetReturnValue(), | 897 FXJSE_Value_Set(pArguments->GetReturnValue(), |
898 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); | 898 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); |
899 } | 899 } |
900 void CXFA_Node::Script_NodeClass_IsPropertySpecified( | 900 void CXFA_Node::Script_NodeClass_IsPropertySpecified( |
901 CFXJSE_Arguments* pArguments) { | 901 CFXJSE_Arguments* pArguments) { |
902 int32_t iLength = pArguments->GetLength(); | 902 int32_t iLength = pArguments->GetLength(); |
903 if (iLength < 1 || iLength > 3) { | 903 if (iLength < 1 || iLength > 3) { |
904 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 904 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
905 L"isPropertySpecified"); | 905 L"isPropertySpecified"); |
(...skipping 14 matching lines...) Expand all Loading... | |
920 iIndex = pArguments->GetInt32(2); | 920 iIndex = pArguments->GetInt32(2); |
921 } | 921 } |
922 FX_BOOL bHas = FALSE; | 922 FX_BOOL bHas = FALSE; |
923 const XFA_ATTRIBUTEINFO* pAttributeInfo = | 923 const XFA_ATTRIBUTEINFO* pAttributeInfo = |
924 XFA_GetAttributeByName(wsExpression); | 924 XFA_GetAttributeByName(wsExpression); |
925 CFX_WideString wsValue; | 925 CFX_WideString wsValue; |
926 if (pAttributeInfo) { | 926 if (pAttributeInfo) { |
927 bHas = HasAttribute(pAttributeInfo->eName); | 927 bHas = HasAttribute(pAttributeInfo->eName); |
928 } | 928 } |
929 if (!bHas) { | 929 if (!bHas) { |
930 const XFA_ELEMENTINFO* pElementInfo = XFA_GetElementByName(wsExpression); | 930 const XFA_ELEMENTINFO* pElementInfo = XFA_GetObjectByByName(wsExpression); |
931 bHas = (GetProperty(iIndex, pElementInfo->eName) != NULL); | 931 bHas = (GetProperty(iIndex, pElementInfo->eName) != NULL); |
932 } | 932 } |
933 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); | 933 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); |
934 if (hValue) { | 934 if (hValue) { |
935 FXJSE_Value_SetBoolean(hValue, bHas); | 935 FXJSE_Value_SetBoolean(hValue, bHas); |
936 } | 936 } |
937 } | 937 } |
938 void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { | 938 void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { |
939 int32_t iLength = pArguments->GetLength(); | 939 int32_t iLength = pArguments->GetLength(); |
940 if (iLength < 1 || iLength > 3) { | 940 if (iLength < 1 || iLength > 3) { |
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2714 strTagName = CFX_WideString::FromUTF8(bsTagName, bsTagName.GetLength()); | 2714 strTagName = CFX_WideString::FromUTF8(bsTagName, bsTagName.GetLength()); |
2715 if (argc > 1) { | 2715 if (argc > 1) { |
2716 CFX_ByteString bsName = pArguments->GetUTF8String(1); | 2716 CFX_ByteString bsName = pArguments->GetUTF8String(1); |
2717 strName = CFX_WideString::FromUTF8(bsName, bsName.GetLength()); | 2717 strName = CFX_WideString::FromUTF8(bsName, bsName.GetLength()); |
2718 if (argc == 3) { | 2718 if (argc == 3) { |
2719 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2); | 2719 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2); |
2720 strNameSpace = | 2720 strNameSpace = |
2721 CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength()); | 2721 CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength()); |
2722 } | 2722 } |
2723 } | 2723 } |
2724 const XFA_ELEMENTINFO* pElement = XFA_GetElementByName(strTagName); | 2724 const XFA_ELEMENTINFO* pElement = XFA_GetObjectByByName(strTagName); |
2725 CXFA_Node* pNewNode = CreateSamePacketNode(pElement->eName); | 2725 CXFA_Node* pNewNode = CreateSamePacketNode(pElement->eName); |
2726 if (!pNewNode) { | 2726 if (!pNewNode) { |
2727 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2727 FXJSE_Value_SetNull(pArguments->GetReturnValue()); |
2728 } else { | 2728 } else { |
2729 if (!strName.IsEmpty()) { | 2729 if (!strName.IsEmpty()) { |
2730 if (XFA_GetAttributeOfElement(pElement->eName, XFA_ATTRIBUTE_Name, | 2730 if (XFA_GetAttributeOfElement(pElement->eName, XFA_ATTRIBUTE_Name, |
2731 XFA_XDPPACKET_UNKNOWN)) { | 2731 XFA_XDPPACKET_UNKNOWN)) { |
2732 pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName, TRUE); | 2732 pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName, TRUE); |
2733 if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) { | 2733 if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) { |
2734 pNewNode->CreateXMLMappingNode(); | 2734 pNewNode->CreateXMLMappingNode(); |
(...skipping 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5402 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5402 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
5403 } | 5403 } |
5404 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5404 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
5405 return m_pAttachNode->RemoveChild(pNode); | 5405 return m_pAttachNode->RemoveChild(pNode); |
5406 } | 5406 } |
5407 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5407 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
5408 return m_pAttachNode->GetChild( | 5408 return m_pAttachNode->GetChild( |
5409 iIndex, XFA_ELEMENT_UNKNOWN, | 5409 iIndex, XFA_ELEMENT_UNKNOWN, |
5410 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5410 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
5411 } | 5411 } |
OLD | NEW |