| 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/fde/xml/fde_xml_imp.h" | 10 #include "xfa/fde/xml/fde_xml_imp.h" |
| (...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 | 1068 |
| 1069 void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { | 1069 void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) { |
| 1070 int32_t iLength = pArguments->GetLength(); | 1070 int32_t iLength = pArguments->GetLength(); |
| 1071 if (iLength < 0 || iLength > 1) { | 1071 if (iLength < 0 || iLength > 1) { |
| 1072 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML"); | 1072 ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"saveXML"); |
| 1073 return; | 1073 return; |
| 1074 } | 1074 } |
| 1075 FX_BOOL bPrettyMode = FALSE; | 1075 FX_BOOL bPrettyMode = FALSE; |
| 1076 if (iLength == 1) { | 1076 if (iLength == 1) { |
| 1077 CFX_ByteString bsPretty = pArguments->GetUTF8String(0); | 1077 CFX_ByteString bsPretty = pArguments->GetUTF8String(0); |
| 1078 if (!bsPretty.Equal("pretty")) { | 1078 if (bsPretty != "pretty") { |
| 1079 ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 1079 ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 1080 return; | 1080 return; |
| 1081 } | 1081 } |
| 1082 bPrettyMode = TRUE; | 1082 bPrettyMode = TRUE; |
| 1083 } | 1083 } |
| 1084 CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | 1084 CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
| 1085 if (GetPacketID() == XFA_XDPPACKET_Form) { | 1085 if (GetPacketID() == XFA_XDPPACKET_Form) { |
| 1086 IFX_MemoryStream* pMemoryStream = FX_CreateMemoryStream(TRUE); | 1086 IFX_MemoryStream* pMemoryStream = FX_CreateMemoryStream(TRUE); |
| 1087 IFX_Stream* pStream = IFX_Stream::CreateStream( | 1087 IFX_Stream* pStream = IFX_Stream::CreateStream( |
| 1088 (IFX_FileWrite*)pMemoryStream, | 1088 (IFX_FileWrite*)pMemoryStream, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 CFX_WideString wsNameSpace; | 1249 CFX_WideString wsNameSpace; |
| 1250 if (iLength >= 1) { | 1250 if (iLength >= 1) { |
| 1251 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0); | 1251 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0); |
| 1252 wsNameSpace = | 1252 wsNameSpace = |
| 1253 CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength()); | 1253 CFX_WideString::FromUTF8(bsNameSpace, bsNameSpace.GetLength()); |
| 1254 } | 1254 } |
| 1255 CFX_WideString wsNodeNameSpace; | 1255 CFX_WideString wsNodeNameSpace; |
| 1256 TryNamespace(wsNodeNameSpace); | 1256 TryNamespace(wsNodeNameSpace); |
| 1257 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); | 1257 FXJSE_HVALUE hValue = pArguments->GetReturnValue(); |
| 1258 if (hValue) { | 1258 if (hValue) { |
| 1259 FXJSE_Value_SetBoolean(hValue, wsNodeNameSpace.Equal(wsNameSpace)); | 1259 FXJSE_Value_SetBoolean(hValue, wsNodeNameSpace == wsNameSpace); |
| 1260 } | 1260 } |
| 1261 } | 1261 } |
| 1262 void CXFA_Node::Script_ModelClass_Context(FXJSE_HVALUE hValue, | 1262 void CXFA_Node::Script_ModelClass_Context(FXJSE_HVALUE hValue, |
| 1263 FX_BOOL bSetting, | 1263 FX_BOOL bSetting, |
| 1264 XFA_ATTRIBUTE eAttribute) {} | 1264 XFA_ATTRIBUTE eAttribute) {} |
| 1265 void CXFA_Node::Script_ModelClass_AliasNode(FXJSE_HVALUE hValue, | 1265 void CXFA_Node::Script_ModelClass_AliasNode(FXJSE_HVALUE hValue, |
| 1266 FX_BOOL bSetting, | 1266 FX_BOOL bSetting, |
| 1267 XFA_ATTRIBUTE eAttribute) {} | 1267 XFA_ATTRIBUTE eAttribute) {} |
| 1268 void CXFA_Node::Script_Attribute_Integer(FXJSE_HVALUE hValue, | 1268 void CXFA_Node::Script_Attribute_Integer(FXJSE_HVALUE hValue, |
| 1269 FX_BOOL bSetting, | 1269 FX_BOOL bSetting, |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 int32_t iValue = FXSYS_atoi(newValue); | 1738 int32_t iValue = FXSYS_atoi(newValue); |
| 1739 CFX_WideString wsNewValue = (iValue == 0) ? FX_WSTRC(L"0") : FX_WSTRC(L"1"); | 1739 CFX_WideString wsNewValue = (iValue == 0) ? FX_WSTRC(L"0") : FX_WSTRC(L"1"); |
| 1740 CFX_WideString wsFormatValue(wsNewValue); | 1740 CFX_WideString wsFormatValue(wsNewValue); |
| 1741 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); | 1741 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); |
| 1742 if (pContainerWidgetData) { | 1742 if (pContainerWidgetData) { |
| 1743 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); | 1743 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); |
| 1744 } | 1744 } |
| 1745 SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE); | 1745 SetScriptContent(wsNewValue, wsFormatValue, TRUE, TRUE); |
| 1746 } else { | 1746 } else { |
| 1747 CFX_WideString wsValue = GetScriptContent(TRUE); | 1747 CFX_WideString wsValue = GetScriptContent(TRUE); |
| 1748 FXJSE_Value_SetBoolean(hValue, wsValue.Equal(FX_WSTRC(L"1"))); | 1748 FXJSE_Value_SetBoolean(hValue, wsValue == FX_WSTRC(L"1")); |
| 1749 } | 1749 } |
| 1750 } | 1750 } |
| 1751 struct XFA_ExecEventParaInfo { | 1751 struct XFA_ExecEventParaInfo { |
| 1752 public: | 1752 public: |
| 1753 uint32_t m_uHash; | 1753 uint32_t m_uHash; |
| 1754 const FX_WCHAR* m_lpcEventName; | 1754 const FX_WCHAR* m_lpcEventName; |
| 1755 XFA_EVENTTYPE m_eventType; | 1755 XFA_EVENTTYPE m_eventType; |
| 1756 uint32_t m_validFlags; | 1756 uint32_t m_validFlags; |
| 1757 }; | 1757 }; |
| 1758 static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { | 1758 static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { |
| (...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4293 pNode->SetScriptContent(wsContent, wsContent, bNotify, TRUE, FALSE); | 4293 pNode->SetScriptContent(wsContent, wsContent, bNotify, TRUE, FALSE); |
| 4294 } | 4294 } |
| 4295 } | 4295 } |
| 4296 pBindNode = NULL; | 4296 pBindNode = NULL; |
| 4297 break; | 4297 break; |
| 4298 } | 4298 } |
| 4299 case XFA_OBJECTTYPE_ContentNode: { | 4299 case XFA_OBJECTTYPE_ContentNode: { |
| 4300 CFX_WideString wsContentType; | 4300 CFX_WideString wsContentType; |
| 4301 if (GetClassID() == XFA_ELEMENT_ExData) { | 4301 if (GetClassID() == XFA_ELEMENT_ExData) { |
| 4302 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); | 4302 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); |
| 4303 if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { | 4303 if (wsContentType == FX_WSTRC(L"text/html")) { |
| 4304 wsContentType = FX_WSTRC(L""); | 4304 wsContentType = FX_WSTRC(L""); |
| 4305 SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType); | 4305 SetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType); |
| 4306 } | 4306 } |
| 4307 } | 4307 } |
| 4308 CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); | 4308 CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); |
| 4309 if (!pContentRawDataNode) { | 4309 if (!pContentRawDataNode) { |
| 4310 pContentRawDataNode = | 4310 pContentRawDataNode = CreateSamePacketNode( |
| 4311 CreateSamePacketNode((wsContentType.Equal(FX_WSTRC(L"text/xml"))) | 4311 (wsContentType == FX_WSTRC(L"text/xml")) ? XFA_ELEMENT_Sharpxml |
| 4312 ? XFA_ELEMENT_Sharpxml | 4312 : XFA_ELEMENT_Sharptext); |
| 4313 : XFA_ELEMENT_Sharptext); | |
| 4314 InsertChild(pContentRawDataNode); | 4313 InsertChild(pContentRawDataNode); |
| 4315 } | 4314 } |
| 4316 return pContentRawDataNode->SetScriptContent( | 4315 return pContentRawDataNode->SetScriptContent( |
| 4317 wsContent, wsXMLValue, bNotify, bScriptModify, bSyncData); | 4316 wsContent, wsXMLValue, bNotify, bScriptModify, bSyncData); |
| 4318 } break; | 4317 } break; |
| 4319 case XFA_OBJECTTYPE_NodeC: | 4318 case XFA_OBJECTTYPE_NodeC: |
| 4320 case XFA_OBJECTTYPE_TextNode: | 4319 case XFA_OBJECTTYPE_TextNode: |
| 4321 pNode = this; | 4320 pNode = this; |
| 4322 break; | 4321 break; |
| 4323 case XFA_OBJECTTYPE_NodeV: | 4322 case XFA_OBJECTTYPE_NodeV: |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4399 : FALSE; | 4398 : FALSE; |
| 4400 } | 4399 } |
| 4401 break; | 4400 break; |
| 4402 case XFA_OBJECTTYPE_ContentNode: { | 4401 case XFA_OBJECTTYPE_ContentNode: { |
| 4403 CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); | 4402 CXFA_Node* pContentRawDataNode = GetNodeItem(XFA_NODEITEM_FirstChild); |
| 4404 if (!pContentRawDataNode) { | 4403 if (!pContentRawDataNode) { |
| 4405 XFA_ELEMENT element = XFA_ELEMENT_Sharptext; | 4404 XFA_ELEMENT element = XFA_ELEMENT_Sharptext; |
| 4406 if (GetClassID() == XFA_ELEMENT_ExData) { | 4405 if (GetClassID() == XFA_ELEMENT_ExData) { |
| 4407 CFX_WideString wsContentType; | 4406 CFX_WideString wsContentType; |
| 4408 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); | 4407 GetAttribute(XFA_ATTRIBUTE_ContentType, wsContentType, FALSE); |
| 4409 if (wsContentType.Equal(FX_WSTRC(L"text/html"))) { | 4408 if (wsContentType == FX_WSTRC(L"text/html")) { |
| 4410 element = XFA_ELEMENT_SharpxHTML; | 4409 element = XFA_ELEMENT_SharpxHTML; |
| 4411 } else if (wsContentType.Equal(FX_WSTRC(L"text/xml"))) { | 4410 } else if (wsContentType == FX_WSTRC(L"text/xml")) { |
| 4412 element = XFA_ELEMENT_Sharpxml; | 4411 element = XFA_ELEMENT_Sharpxml; |
| 4413 } | 4412 } |
| 4414 } | 4413 } |
| 4415 pContentRawDataNode = CreateSamePacketNode(element); | 4414 pContentRawDataNode = CreateSamePacketNode(element); |
| 4416 InsertChild(pContentRawDataNode); | 4415 InsertChild(pContentRawDataNode); |
| 4417 } | 4416 } |
| 4418 return pContentRawDataNode->TryContent(wsContent, bScriptModify, bProto); | 4417 return pContentRawDataNode->TryContent(wsContent, bScriptModify, bProto); |
| 4419 } | 4418 } |
| 4420 case XFA_OBJECTTYPE_NodeC: | 4419 case XFA_OBJECTTYPE_NodeC: |
| 4421 case XFA_OBJECTTYPE_NodeV: | 4420 case XFA_OBJECTTYPE_NodeV: |
| (...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5405 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5404 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
| 5406 } | 5405 } |
| 5407 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5406 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
| 5408 return m_pAttachNode->RemoveChild(pNode); | 5407 return m_pAttachNode->RemoveChild(pNode); |
| 5409 } | 5408 } |
| 5410 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5409 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
| 5411 return m_pAttachNode->GetChild( | 5410 return m_pAttachNode->GetChild( |
| 5412 iIndex, XFA_ELEMENT_UNKNOWN, | 5411 iIndex, XFA_ELEMENT_UNKNOWN, |
| 5413 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5412 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
| 5414 } | 5413 } |
| OLD | NEW |