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