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 <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ASSERT(FALSE); | 79 ASSERT(FALSE); |
80 return (XFA_ELEMENT)0; | 80 return (XFA_ELEMENT)0; |
81 } | 81 } |
82 | 82 |
83 void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, | 83 void CXFA_Object::Script_ObjectClass_ClassName(CFXJSE_Value* pValue, |
84 FX_BOOL bSetting, | 84 FX_BOOL bSetting, |
85 XFA_ATTRIBUTE eAttribute) { | 85 XFA_ATTRIBUTE eAttribute) { |
86 if (!bSetting) { | 86 if (!bSetting) { |
87 CFX_WideStringC className; | 87 CFX_WideStringC className; |
88 GetClassName(className); | 88 GetClassName(className); |
89 FXJSE_Value_SetUTF8String( | 89 pValue->SetString( |
90 pValue, | |
91 FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC()); | 90 FX_UTF8Encode(className.c_str(), className.GetLength()).AsStringC()); |
92 } else { | 91 } else { |
93 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 92 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
94 } | 93 } |
95 } | 94 } |
96 | 95 |
97 void CXFA_Object::ThrowException(int32_t iStringID, ...) { | 96 void CXFA_Object::ThrowException(int32_t iStringID, ...) { |
98 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 97 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
99 ASSERT(pAppProvider); | 98 ASSERT(pAppProvider); |
100 CFX_WideString wsFormat; | 99 CFX_WideString wsFormat; |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 return; | 637 return; |
639 CXFA_Node* refNode = this; | 638 CXFA_Node* refNode = this; |
640 if (refNode->GetClassID() == XFA_ELEMENT_Xfa) | 639 if (refNode->GetClassID() == XFA_ELEMENT_Xfa) |
641 refNode = ToNode(pScriptContext->GetThisObject()); | 640 refNode = ToNode(pScriptContext->GetThisObject()); |
642 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | | 641 uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes | |
643 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | | 642 XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent | |
644 XFA_RESOLVENODE_Siblings; | 643 XFA_RESOLVENODE_Siblings; |
645 XFA_RESOLVENODE_RS resoveNodeRS; | 644 XFA_RESOLVENODE_RS resoveNodeRS; |
646 int32_t iRet = pScriptContext->ResolveObjects( | 645 int32_t iRet = pScriptContext->ResolveObjects( |
647 refNode, wsExpression.AsStringC(), resoveNodeRS, dwFlag); | 646 refNode, wsExpression.AsStringC(), resoveNodeRS, dwFlag); |
648 if (iRet < 1) | 647 if (iRet < 1) { |
649 return FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 648 pArguments->GetReturnValue()->SetNull(); |
| 649 return; |
| 650 } |
650 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { | 651 if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) { |
651 CXFA_Object* pNode = resoveNodeRS.nodes[0]; | 652 CXFA_Object* pNode = resoveNodeRS.nodes[0]; |
652 FXJSE_Value_Set(pArguments->GetReturnValue(), | 653 pArguments->GetReturnValue()->Assign( |
653 pScriptContext->GetJSValueFromMap(pNode)); | 654 pScriptContext->GetJSValueFromMap(pNode)); |
654 } else { | 655 } else { |
655 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = | 656 const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo = |
656 resoveNodeRS.pScriptAttribute; | 657 resoveNodeRS.pScriptAttribute; |
657 if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) { | 658 if (lpAttributeInfo && lpAttributeInfo->eValueType == XFA_SCRIPT_Object) { |
658 std::unique_ptr<CFXJSE_Value> pValue( | 659 std::unique_ptr<CFXJSE_Value> pValue( |
659 new CFXJSE_Value(pScriptContext->GetRuntime())); | 660 new CFXJSE_Value(pScriptContext->GetRuntime())); |
660 (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))( | 661 (resoveNodeRS.nodes[0]->*(lpAttributeInfo->lpfnCallback))( |
661 pValue.get(), FALSE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); | 662 pValue.get(), FALSE, (XFA_ATTRIBUTE)lpAttributeInfo->eAttribute); |
662 FXJSE_Value_Set(pArguments->GetReturnValue(), pValue.get()); | 663 pArguments->GetReturnValue()->Assign(pValue.get()); |
663 } else { | 664 } else { |
664 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 665 pArguments->GetReturnValue()->SetNull(); |
665 } | 666 } |
666 } | 667 } |
667 } | 668 } |
668 | 669 |
669 void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { | 670 void CXFA_Node::Script_TreeClass_ResolveNodes(CFXJSE_Arguments* pArguments) { |
670 int32_t iLength = pArguments->GetLength(); | 671 int32_t iLength = pArguments->GetLength(); |
671 if (iLength != 1) { | 672 if (iLength != 1) { |
672 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resolveNodes"); | 673 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"resolveNodes"); |
673 return; | 674 return; |
674 } | 675 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 CXFA_ValueArray valueArray(pScriptContext->GetRuntime()); | 709 CXFA_ValueArray valueArray(pScriptContext->GetRuntime()); |
709 if (resoveNodeRS.GetAttributeResult(valueArray) > 0) { | 710 if (resoveNodeRS.GetAttributeResult(valueArray) > 0) { |
710 CXFA_ObjArray objectArray; | 711 CXFA_ObjArray objectArray; |
711 valueArray.GetAttributeObject(objectArray); | 712 valueArray.GetAttributeObject(objectArray); |
712 for (int32_t i = 0; i < objectArray.GetSize(); i++) { | 713 for (int32_t i = 0; i < objectArray.GetSize(); i++) { |
713 if (objectArray[i]->IsNode()) | 714 if (objectArray[i]->IsNode()) |
714 pNodeList->Append(objectArray[i]->AsNode()); | 715 pNodeList->Append(objectArray[i]->AsNode()); |
715 } | 716 } |
716 } | 717 } |
717 } | 718 } |
718 FXJSE_Value_SetObject(pValue, (CXFA_Object*)pNodeList, | 719 pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass()); |
719 pScriptContext->GetJseNormalClass()); | |
720 } | 720 } |
721 | 721 |
722 void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue, | 722 void CXFA_Node::Script_TreeClass_All(CFXJSE_Value* pValue, |
723 FX_BOOL bSetting, | 723 FX_BOOL bSetting, |
724 XFA_ATTRIBUTE eAttribute) { | 724 XFA_ATTRIBUTE eAttribute) { |
725 if (bSetting) { | 725 if (bSetting) { |
726 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 726 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
727 } else { | 727 } else { |
728 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; | 728 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; |
729 CFX_WideString wsName; | 729 CFX_WideString wsName; |
(...skipping 12 matching lines...) Expand all Loading... |
742 if (bSetting) { | 742 if (bSetting) { |
743 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); | 743 IXFA_AppProvider* pAppProvider = m_pDocument->GetNotify()->GetAppProvider(); |
744 ASSERT(pAppProvider); | 744 ASSERT(pAppProvider); |
745 CFX_WideString wsMessage; | 745 CFX_WideString wsMessage; |
746 pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage); | 746 pAppProvider->LoadString(XFA_IDS_Unable_TO_SET, wsMessage); |
747 FXJSE_ThrowMessage( | 747 FXJSE_ThrowMessage( |
748 "", | 748 "", |
749 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 749 FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
750 } else { | 750 } else { |
751 CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); | 751 CXFA_AttachNodeList* pNodeList = new CXFA_AttachNodeList(m_pDocument, this); |
752 FXJSE_Value_SetObject(pValue, (CXFA_Object*)pNodeList, | 752 pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass()); |
753 pScriptContext->GetJseNormalClass()); | |
754 } | 753 } |
755 } | 754 } |
756 | 755 |
757 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, | 756 void CXFA_Node::Script_TreeClass_ClassAll(CFXJSE_Value* pValue, |
758 FX_BOOL bSetting, | 757 FX_BOOL bSetting, |
759 XFA_ATTRIBUTE eAttribute) { | 758 XFA_ATTRIBUTE eAttribute) { |
760 if (bSetting) { | 759 if (bSetting) { |
761 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 760 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
762 } else { | 761 } else { |
763 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; | 762 uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL; |
764 CFX_WideStringC wsName; | 763 CFX_WideStringC wsName; |
765 GetClassName(wsName); | 764 GetClassName(wsName); |
766 CFX_WideString wsExpression = FX_WSTRC(L"#") + wsName + FX_WSTRC(L"[*]"); | 765 CFX_WideString wsExpression = FX_WSTRC(L"#") + wsName + FX_WSTRC(L"[*]"); |
767 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); | 766 Script_Som_ResolveNodeList(pValue, wsExpression, dwFlag); |
768 } | 767 } |
769 } | 768 } |
770 | 769 |
771 void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, | 770 void CXFA_Node::Script_TreeClass_Parent(CFXJSE_Value* pValue, |
772 FX_BOOL bSetting, | 771 FX_BOOL bSetting, |
773 XFA_ATTRIBUTE eAttribute) { | 772 XFA_ATTRIBUTE eAttribute) { |
774 if (bSetting) { | 773 if (bSetting) { |
775 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 774 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
776 } else { | 775 } else { |
777 CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); | 776 CXFA_Node* pParent = GetNodeItem(XFA_NODEITEM_Parent); |
778 if (pParent) { | 777 if (pParent) { |
779 FXJSE_Value_Set( | 778 pValue->Assign( |
780 pValue, m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent)); | 779 m_pDocument->GetScriptContext()->GetJSValueFromMap(pParent)); |
781 } else { | 780 } else { |
782 FXJSE_Value_SetNull(pValue); | 781 pValue->SetNull(); |
783 } | 782 } |
784 } | 783 } |
785 } | 784 } |
786 | 785 |
787 void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue, | 786 void CXFA_Node::Script_TreeClass_Index(CFXJSE_Value* pValue, |
788 FX_BOOL bSetting, | 787 FX_BOOL bSetting, |
789 XFA_ATTRIBUTE eAttribute) { | 788 XFA_ATTRIBUTE eAttribute) { |
790 if (bSetting) | 789 if (bSetting) |
791 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 790 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
792 else | 791 else |
793 FXJSE_Value_SetInteger(pValue, GetNodeSameNameIndex()); | 792 pValue->SetInteger(GetNodeSameNameIndex()); |
794 } | 793 } |
795 | 794 |
796 void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, | 795 void CXFA_Node::Script_TreeClass_ClassIndex(CFXJSE_Value* pValue, |
797 FX_BOOL bSetting, | 796 FX_BOOL bSetting, |
798 XFA_ATTRIBUTE eAttribute) { | 797 XFA_ATTRIBUTE eAttribute) { |
799 if (bSetting) | 798 if (bSetting) |
800 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 799 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
801 else | 800 else |
802 FXJSE_Value_SetInteger(pValue, GetNodeSameClassIndex()); | 801 pValue->SetInteger(GetNodeSameClassIndex()); |
803 } | 802 } |
804 | 803 |
805 void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue, | 804 void CXFA_Node::Script_TreeClass_SomExpression(CFXJSE_Value* pValue, |
806 FX_BOOL bSetting, | 805 FX_BOOL bSetting, |
807 XFA_ATTRIBUTE eAttribute) { | 806 XFA_ATTRIBUTE eAttribute) { |
808 if (bSetting) { | 807 if (bSetting) { |
809 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 808 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
810 } else { | 809 } else { |
811 CFX_WideString wsSOMExpression; | 810 CFX_WideString wsSOMExpression; |
812 GetSOMExpression(wsSOMExpression); | 811 GetSOMExpression(wsSOMExpression); |
813 FXJSE_Value_SetUTF8String(pValue, | 812 pValue->SetString(FX_UTF8Encode(wsSOMExpression).AsStringC()); |
814 FX_UTF8Encode(wsSOMExpression).AsStringC()); | |
815 } | 813 } |
816 } | 814 } |
817 | 815 |
818 void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { | 816 void CXFA_Node::Script_NodeClass_ApplyXSL(CFXJSE_Arguments* pArguments) { |
819 int32_t iLength = pArguments->GetLength(); | 817 int32_t iLength = pArguments->GetLength(); |
820 if (iLength != 1) { | 818 if (iLength != 1) { |
821 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"applyXSL"); | 819 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"applyXSL"); |
822 return; | 820 return; |
823 } | 821 } |
824 CFX_WideString wsExpression = | 822 CFX_WideString wsExpression = |
(...skipping 28 matching lines...) Expand all Loading... |
853 } | 851 } |
854 | 852 |
855 void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) { | 853 void CXFA_Node::Script_NodeClass_Clone(CFXJSE_Arguments* pArguments) { |
856 int32_t iLength = pArguments->GetLength(); | 854 int32_t iLength = pArguments->GetLength(); |
857 if (iLength != 1) { | 855 if (iLength != 1) { |
858 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clone"); | 856 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"clone"); |
859 return; | 857 return; |
860 } | 858 } |
861 bool bClone = !!pArguments->GetInt32(0); | 859 bool bClone = !!pArguments->GetInt32(0); |
862 CXFA_Node* pCloneNode = Clone(bClone); | 860 CXFA_Node* pCloneNode = Clone(bClone); |
863 FXJSE_Value_Set( | 861 pArguments->GetReturnValue()->Assign( |
864 pArguments->GetReturnValue(), | |
865 m_pDocument->GetScriptContext()->GetJSValueFromMap(pCloneNode)); | 862 m_pDocument->GetScriptContext()->GetJSValueFromMap(pCloneNode)); |
866 } | 863 } |
867 | 864 |
868 void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { | 865 void CXFA_Node::Script_NodeClass_GetAttribute(CFXJSE_Arguments* pArguments) { |
869 int32_t iLength = pArguments->GetLength(); | 866 int32_t iLength = pArguments->GetLength(); |
870 if (iLength != 1) { | 867 if (iLength != 1) { |
871 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getAttribute"); | 868 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getAttribute"); |
872 return; | 869 return; |
873 } | 870 } |
874 CFX_WideString wsExpression = | 871 CFX_WideString wsExpression = |
875 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | 872 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
876 CFX_WideString wsValue; | 873 CFX_WideString wsValue; |
877 GetAttribute(wsExpression.AsStringC(), wsValue); | 874 GetAttribute(wsExpression.AsStringC(), wsValue); |
878 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 875 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
879 if (pValue) | 876 if (pValue) |
880 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsValue).AsStringC()); | 877 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
881 } | 878 } |
882 | 879 |
883 void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { | 880 void CXFA_Node::Script_NodeClass_GetElement(CFXJSE_Arguments* pArguments) { |
884 int32_t iLength = pArguments->GetLength(); | 881 int32_t iLength = pArguments->GetLength(); |
885 if (iLength < 1 || iLength > 2) { | 882 if (iLength < 1 || iLength > 2) { |
886 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement"); | 883 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getElement"); |
887 return; | 884 return; |
888 } | 885 } |
889 CFX_WideString wsExpression; | 886 CFX_WideString wsExpression; |
890 int32_t iValue = 0; | 887 int32_t iValue = 0; |
891 wsExpression = | 888 wsExpression = |
892 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | 889 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
893 if (iLength >= 2) | 890 if (iLength >= 2) |
894 iValue = pArguments->GetInt32(1); | 891 iValue = pArguments->GetInt32(1); |
895 const XFA_ELEMENTINFO* pElementInfo = | 892 const XFA_ELEMENTINFO* pElementInfo = |
896 XFA_GetElementByName(wsExpression.AsStringC()); | 893 XFA_GetElementByName(wsExpression.AsStringC()); |
897 CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName); | 894 CXFA_Node* pNode = GetProperty(iValue, pElementInfo->eName); |
898 FXJSE_Value_Set(pArguments->GetReturnValue(), | 895 pArguments->GetReturnValue()->Assign( |
899 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); | 896 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); |
900 } | 897 } |
901 | 898 |
902 void CXFA_Node::Script_NodeClass_IsPropertySpecified( | 899 void CXFA_Node::Script_NodeClass_IsPropertySpecified( |
903 CFXJSE_Arguments* pArguments) { | 900 CFXJSE_Arguments* pArguments) { |
904 int32_t iLength = pArguments->GetLength(); | 901 int32_t iLength = pArguments->GetLength(); |
905 if (iLength < 1 || iLength > 3) { | 902 if (iLength < 1 || iLength > 3) { |
906 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isPropertySpecified"); | 903 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isPropertySpecified"); |
907 return; | 904 return; |
908 } | 905 } |
909 CFX_WideString wsExpression; | 906 CFX_WideString wsExpression; |
(...skipping 17 matching lines...) Expand all Loading... |
927 bHas = !!GetProperty(iIndex, pElementInfo->eName); | 924 bHas = !!GetProperty(iIndex, pElementInfo->eName); |
928 if (!bHas && bParent && m_pParent) { | 925 if (!bHas && bParent && m_pParent) { |
929 // Also check on the parent. | 926 // Also check on the parent. |
930 bHas = m_pParent->HasAttribute(pAttributeInfo->eName); | 927 bHas = m_pParent->HasAttribute(pAttributeInfo->eName); |
931 if (!bHas) | 928 if (!bHas) |
932 bHas = !!m_pParent->GetProperty(iIndex, pElementInfo->eName); | 929 bHas = !!m_pParent->GetProperty(iIndex, pElementInfo->eName); |
933 } | 930 } |
934 } | 931 } |
935 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 932 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
936 if (pValue) | 933 if (pValue) |
937 FXJSE_Value_SetBoolean(pValue, bHas); | 934 pValue->SetBoolean(bHas); |
938 } | 935 } |
939 | 936 |
940 void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { | 937 void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { |
941 int32_t iLength = pArguments->GetLength(); | 938 int32_t iLength = pArguments->GetLength(); |
942 if (iLength < 1 || iLength > 3) { | 939 if (iLength < 1 || iLength > 3) { |
943 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"loadXML"); | 940 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"loadXML"); |
944 return; | 941 return; |
945 } | 942 } |
946 CFX_WideString wsExpression; | 943 CFX_WideString wsExpression; |
947 bool bIgnoreRoot = true; | 944 bool bIgnoreRoot = true; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1073 } | 1070 } |
1074 bPrettyMode = true; | 1071 bPrettyMode = true; |
1075 } | 1072 } |
1076 CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; | 1073 CFX_ByteStringC bsXMLHeader = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; |
1077 if (GetPacketID() == XFA_XDPPACKET_Form || | 1074 if (GetPacketID() == XFA_XDPPACKET_Form || |
1078 GetPacketID() == XFA_XDPPACKET_Datasets) { | 1075 GetPacketID() == XFA_XDPPACKET_Datasets) { |
1079 CFDE_XMLNode* pElement = nullptr; | 1076 CFDE_XMLNode* pElement = nullptr; |
1080 if (GetPacketID() == XFA_XDPPACKET_Datasets) { | 1077 if (GetPacketID() == XFA_XDPPACKET_Datasets) { |
1081 pElement = GetXMLMappingNode(); | 1078 pElement = GetXMLMappingNode(); |
1082 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { | 1079 if (!pElement || pElement->GetType() != FDE_XMLNODE_Element) { |
1083 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); | 1080 pArguments->GetReturnValue()->SetString(bsXMLHeader); |
1084 return; | 1081 return; |
1085 } | 1082 } |
1086 XFA_DataExporter_DealWithDataGroupNode(this); | 1083 XFA_DataExporter_DealWithDataGroupNode(this); |
1087 } | 1084 } |
1088 std::unique_ptr<IFX_MemoryStream, ReleaseDeleter<IFX_MemoryStream>> | 1085 std::unique_ptr<IFX_MemoryStream, ReleaseDeleter<IFX_MemoryStream>> |
1089 pMemoryStream(FX_CreateMemoryStream(TRUE)); | 1086 pMemoryStream(FX_CreateMemoryStream(TRUE)); |
1090 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> pStream( | 1087 std::unique_ptr<IFX_Stream, ReleaseDeleter<IFX_Stream>> pStream( |
1091 IFX_Stream::CreateStream( | 1088 IFX_Stream::CreateStream( |
1092 static_cast<IFX_FileWrite*>(pMemoryStream.get()), | 1089 static_cast<IFX_FileWrite*>(pMemoryStream.get()), |
1093 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | | 1090 FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | |
1094 FX_STREAMACCESS_Append)); | 1091 FX_STREAMACCESS_Append)); |
1095 if (!pStream) { | 1092 if (!pStream) { |
1096 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), bsXMLHeader); | 1093 pArguments->GetReturnValue()->SetString(bsXMLHeader); |
1097 return; | 1094 return; |
1098 } | 1095 } |
1099 pStream->SetCodePage(FX_CODEPAGE_UTF8); | 1096 pStream->SetCodePage(FX_CODEPAGE_UTF8); |
1100 pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength()); | 1097 pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength()); |
1101 if (GetPacketID() == XFA_XDPPACKET_Form) | 1098 if (GetPacketID() == XFA_XDPPACKET_Form) |
1102 XFA_DataExporter_RegenerateFormFile(this, pStream.get(), nullptr, TRUE); | 1099 XFA_DataExporter_RegenerateFormFile(this, pStream.get(), nullptr, TRUE); |
1103 else | 1100 else |
1104 pElement->SaveXMLNode(pStream.get()); | 1101 pElement->SaveXMLNode(pStream.get()); |
1105 // TODO(weili): Check whether we need to save pretty print XML, pdfium:501. | 1102 // TODO(weili): Check whether we need to save pretty print XML, pdfium:501. |
1106 // For now, just put it here to avoid unused variable warning. | 1103 // For now, just put it here to avoid unused variable warning. |
1107 (void)bPrettyMode; | 1104 (void)bPrettyMode; |
1108 FXJSE_Value_SetUTF8String( | 1105 pArguments->GetReturnValue()->SetString( |
1109 pArguments->GetReturnValue(), | |
1110 CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())); | 1106 CFX_ByteStringC(pMemoryStream->GetBuffer(), pMemoryStream->GetSize())); |
1111 return; | 1107 return; |
1112 } | 1108 } |
1113 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), ""); | 1109 pArguments->GetReturnValue()->SetString(""); |
1114 } | 1110 } |
1115 | 1111 |
1116 void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { | 1112 void CXFA_Node::Script_NodeClass_SetAttribute(CFXJSE_Arguments* pArguments) { |
1117 int32_t iLength = pArguments->GetLength(); | 1113 int32_t iLength = pArguments->GetLength(); |
1118 if (iLength != 2) { | 1114 if (iLength != 2) { |
1119 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setAttribute"); | 1115 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setAttribute"); |
1120 return; | 1116 return; |
1121 } | 1117 } |
1122 CFX_WideString wsAttributeValue = | 1118 CFX_WideString wsAttributeValue = |
1123 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); | 1119 CFX_WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringC()); |
(...skipping 20 matching lines...) Expand all Loading... |
1144 } | 1140 } |
1145 | 1141 |
1146 void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, | 1142 void CXFA_Node::Script_NodeClass_Ns(CFXJSE_Value* pValue, |
1147 FX_BOOL bSetting, | 1143 FX_BOOL bSetting, |
1148 XFA_ATTRIBUTE eAttribute) { | 1144 XFA_ATTRIBUTE eAttribute) { |
1149 if (bSetting) { | 1145 if (bSetting) { |
1150 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1146 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1151 } else { | 1147 } else { |
1152 CFX_WideString wsNameSpace; | 1148 CFX_WideString wsNameSpace; |
1153 TryNamespace(wsNameSpace); | 1149 TryNamespace(wsNameSpace); |
1154 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsNameSpace).AsStringC()); | 1150 pValue->SetString(FX_UTF8Encode(wsNameSpace).AsStringC()); |
1155 } | 1151 } |
1156 } | 1152 } |
1157 | 1153 |
1158 void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, | 1154 void CXFA_Node::Script_NodeClass_Model(CFXJSE_Value* pValue, |
1159 FX_BOOL bSetting, | 1155 FX_BOOL bSetting, |
1160 XFA_ATTRIBUTE eAttribute) { | 1156 XFA_ATTRIBUTE eAttribute) { |
1161 if (bSetting) { | 1157 if (bSetting) { |
1162 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1158 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1163 } else { | 1159 } else { |
1164 FXJSE_Value_Set(pValue, m_pDocument->GetScriptContext()->GetJSValueFromMap( | 1160 pValue->Assign( |
1165 GetModelNode())); | 1161 m_pDocument->GetScriptContext()->GetJSValueFromMap(GetModelNode())); |
1166 } | 1162 } |
1167 } | 1163 } |
1168 | 1164 |
1169 void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, | 1165 void CXFA_Node::Script_NodeClass_IsContainer(CFXJSE_Value* pValue, |
1170 FX_BOOL bSetting, | 1166 FX_BOOL bSetting, |
1171 XFA_ATTRIBUTE eAttribute) { | 1167 XFA_ATTRIBUTE eAttribute) { |
1172 if (bSetting) | 1168 if (bSetting) |
1173 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1169 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1174 else | 1170 else |
1175 FXJSE_Value_SetBoolean(pValue, IsContainerNode()); | 1171 pValue->SetBoolean(IsContainerNode()); |
1176 } | 1172 } |
1177 | 1173 |
1178 void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, | 1174 void CXFA_Node::Script_NodeClass_IsNull(CFXJSE_Value* pValue, |
1179 FX_BOOL bSetting, | 1175 FX_BOOL bSetting, |
1180 XFA_ATTRIBUTE eAttribute) { | 1176 XFA_ATTRIBUTE eAttribute) { |
1181 if (bSetting) { | 1177 if (bSetting) { |
1182 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1178 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1183 } else { | 1179 } else { |
1184 if (GetClassID() == XFA_ELEMENT_Subform) { | 1180 if (GetClassID() == XFA_ELEMENT_Subform) { |
1185 FXJSE_Value_SetBoolean(pValue, FALSE); | 1181 pValue->SetBoolean(FALSE); |
1186 return; | 1182 return; |
1187 } | 1183 } |
1188 CFX_WideString strValue; | 1184 CFX_WideString strValue; |
1189 FXJSE_Value_SetBoolean(pValue, !TryContent(strValue) || strValue.IsEmpty()); | 1185 pValue->SetBoolean(!TryContent(strValue) || strValue.IsEmpty()); |
1190 } | 1186 } |
1191 } | 1187 } |
1192 | 1188 |
1193 void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, | 1189 void CXFA_Node::Script_NodeClass_OneOfChild(CFXJSE_Value* pValue, |
1194 FX_BOOL bSetting, | 1190 FX_BOOL bSetting, |
1195 XFA_ATTRIBUTE eAttribute) { | 1191 XFA_ATTRIBUTE eAttribute) { |
1196 if (bSetting) { | 1192 if (bSetting) { |
1197 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1193 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1198 } else { | 1194 } else { |
1199 CXFA_NodeArray properts; | 1195 CXFA_NodeArray properts; |
1200 int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty); | 1196 int32_t iSize = GetNodeList(properts, XFA_NODEFILTER_OneOfProperty); |
1201 if (iSize > 0) { | 1197 if (iSize > 0) { |
1202 FXJSE_Value_Set( | 1198 pValue->Assign( |
1203 pValue, | |
1204 m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0])); | 1199 m_pDocument->GetScriptContext()->GetJSValueFromMap(properts[0])); |
1205 } | 1200 } |
1206 } | 1201 } |
1207 } | 1202 } |
1208 | 1203 |
1209 void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} | 1204 void CXFA_Node::Script_ContainerClass_GetDelta(CFXJSE_Arguments* pArguments) {} |
| 1205 |
1210 void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { | 1206 void CXFA_Node::Script_ContainerClass_GetDeltas(CFXJSE_Arguments* pArguments) { |
1211 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); | 1207 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); |
1212 FXJSE_Value_SetObject(pArguments->GetReturnValue(), (CXFA_Object*)pFormNodes, | 1208 pArguments->GetReturnValue()->SetObject( |
1213 m_pDocument->GetScriptContext()->GetJseNormalClass()); | 1209 pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass()); |
1214 } | 1210 } |
1215 void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { | 1211 void CXFA_Node::Script_ModelClass_ClearErrorList(CFXJSE_Arguments* pArguments) { |
1216 } | 1212 } |
1217 void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { | 1213 void CXFA_Node::Script_ModelClass_CreateNode(CFXJSE_Arguments* pArguments) { |
1218 Script_Template_CreateNode(pArguments); | 1214 Script_Template_CreateNode(pArguments); |
1219 } | 1215 } |
1220 void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { | 1216 void CXFA_Node::Script_ModelClass_IsCompatibleNS(CFXJSE_Arguments* pArguments) { |
1221 int32_t iLength = pArguments->GetLength(); | 1217 int32_t iLength = pArguments->GetLength(); |
1222 if (iLength < 1) { | 1218 if (iLength < 1) { |
1223 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isCompatibleNS"); | 1219 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"isCompatibleNS"); |
1224 return; | 1220 return; |
1225 } | 1221 } |
1226 CFX_WideString wsNameSpace; | 1222 CFX_WideString wsNameSpace; |
1227 if (iLength >= 1) { | 1223 if (iLength >= 1) { |
1228 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0); | 1224 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(0); |
1229 wsNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC()); | 1225 wsNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC()); |
1230 } | 1226 } |
1231 CFX_WideString wsNodeNameSpace; | 1227 CFX_WideString wsNodeNameSpace; |
1232 TryNamespace(wsNodeNameSpace); | 1228 TryNamespace(wsNodeNameSpace); |
1233 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 1229 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
1234 if (pValue) { | 1230 if (pValue) |
1235 FXJSE_Value_SetBoolean(pValue, wsNodeNameSpace == wsNameSpace); | 1231 pValue->SetBoolean(wsNodeNameSpace == wsNameSpace); |
1236 } | |
1237 } | 1232 } |
1238 void CXFA_Node::Script_ModelClass_Context(CFXJSE_Value* pValue, | 1233 void CXFA_Node::Script_ModelClass_Context(CFXJSE_Value* pValue, |
1239 FX_BOOL bSetting, | 1234 FX_BOOL bSetting, |
1240 XFA_ATTRIBUTE eAttribute) {} | 1235 XFA_ATTRIBUTE eAttribute) {} |
1241 void CXFA_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue, | 1236 void CXFA_Node::Script_ModelClass_AliasNode(CFXJSE_Value* pValue, |
1242 FX_BOOL bSetting, | 1237 FX_BOOL bSetting, |
1243 XFA_ATTRIBUTE eAttribute) {} | 1238 XFA_ATTRIBUTE eAttribute) {} |
1244 void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue, | 1239 void CXFA_Node::Script_Attribute_Integer(CFXJSE_Value* pValue, |
1245 FX_BOOL bSetting, | 1240 FX_BOOL bSetting, |
1246 XFA_ATTRIBUTE eAttribute) { | 1241 XFA_ATTRIBUTE eAttribute) { |
1247 if (bSetting) { | 1242 if (bSetting) { |
1248 SetInteger(eAttribute, FXJSE_Value_ToInteger(pValue), true); | 1243 SetInteger(eAttribute, pValue->ToInteger(), true); |
1249 } else { | 1244 } else { |
1250 FXJSE_Value_SetInteger(pValue, GetInteger(eAttribute)); | 1245 pValue->SetInteger(GetInteger(eAttribute)); |
1251 } | 1246 } |
1252 } | 1247 } |
1253 void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue, | 1248 void CXFA_Node::Script_Attribute_IntegerRead(CFXJSE_Value* pValue, |
1254 FX_BOOL bSetting, | 1249 FX_BOOL bSetting, |
1255 XFA_ATTRIBUTE eAttribute) { | 1250 XFA_ATTRIBUTE eAttribute) { |
1256 if (!bSetting) { | 1251 if (!bSetting) { |
1257 FXJSE_Value_SetInteger(pValue, GetInteger(eAttribute)); | 1252 pValue->SetInteger(GetInteger(eAttribute)); |
1258 } else { | 1253 } else { |
1259 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1254 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1260 } | 1255 } |
1261 } | 1256 } |
1262 void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue, | 1257 void CXFA_Node::Script_Attribute_BOOL(CFXJSE_Value* pValue, |
1263 FX_BOOL bSetting, | 1258 FX_BOOL bSetting, |
1264 XFA_ATTRIBUTE eAttribute) { | 1259 XFA_ATTRIBUTE eAttribute) { |
1265 if (bSetting) { | 1260 if (bSetting) { |
1266 SetBoolean(eAttribute, FXJSE_Value_ToBoolean(pValue), true); | 1261 SetBoolean(eAttribute, pValue->ToBoolean(), true); |
1267 } else { | 1262 } else { |
1268 FXJSE_Value_SetUTF8String(pValue, GetBoolean(eAttribute) ? "1" : "0"); | 1263 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); |
1269 } | 1264 } |
1270 } | 1265 } |
1271 void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue, | 1266 void CXFA_Node::Script_Attribute_BOOLRead(CFXJSE_Value* pValue, |
1272 FX_BOOL bSetting, | 1267 FX_BOOL bSetting, |
1273 XFA_ATTRIBUTE eAttribute) { | 1268 XFA_ATTRIBUTE eAttribute) { |
1274 if (!bSetting) { | 1269 if (!bSetting) { |
1275 FXJSE_Value_SetUTF8String(pValue, GetBoolean(eAttribute) ? "1" : "0"); | 1270 pValue->SetString(GetBoolean(eAttribute) ? "1" : "0"); |
1276 } else { | 1271 } else { |
1277 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1272 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1278 } | 1273 } |
1279 } | 1274 } |
1280 | 1275 |
1281 void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( | 1276 void CXFA_Node::Script_Attribute_SendAttributeChangeMessage( |
1282 XFA_ATTRIBUTE eAttribute, | 1277 XFA_ATTRIBUTE eAttribute, |
1283 FX_BOOL bScriptModify) { | 1278 FX_BOOL bScriptModify) { |
1284 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 1279 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
1285 if (!pLayoutPro) | 1280 if (!pLayoutPro) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 pLayoutPro->AddChangedContainer(pParent); | 1425 pLayoutPro->AddChangedContainer(pParent); |
1431 } | 1426 } |
1432 } | 1427 } |
1433 } | 1428 } |
1434 | 1429 |
1435 void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue, | 1430 void CXFA_Node::Script_Attribute_String(CFXJSE_Value* pValue, |
1436 FX_BOOL bSetting, | 1431 FX_BOOL bSetting, |
1437 XFA_ATTRIBUTE eAttribute) { | 1432 XFA_ATTRIBUTE eAttribute) { |
1438 if (bSetting) { | 1433 if (bSetting) { |
1439 CFX_ByteString szValue; | 1434 CFX_ByteString szValue; |
1440 FXJSE_Value_ToUTF8String(pValue, szValue); | 1435 pValue->ToString(szValue); |
1441 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); | 1436 CFX_WideString wsValue = CFX_WideString::FromUTF8(szValue.AsStringC()); |
1442 SetAttribute(eAttribute, wsValue.AsStringC(), true); | 1437 SetAttribute(eAttribute, wsValue.AsStringC(), true); |
1443 if (eAttribute == XFA_ATTRIBUTE_Use && GetClassID() == XFA_ELEMENT_Desc) { | 1438 if (eAttribute == XFA_ATTRIBUTE_Use && GetClassID() == XFA_ELEMENT_Desc) { |
1444 CFX_WideString wsUseVal = wsValue, wsID, wsSOM; | 1439 CFX_WideString wsUseVal = wsValue, wsID, wsSOM; |
1445 CXFA_Node* pTemplateNode = | 1440 CXFA_Node* pTemplateNode = |
1446 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); | 1441 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Template)); |
1447 CXFA_Node* pProtoRoot = | 1442 CXFA_Node* pProtoRoot = |
1448 pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Subform) | 1443 pTemplateNode->GetFirstChildByClass(XFA_ELEMENT_Subform) |
1449 ->GetFirstChildByClass(XFA_ELEMENT_Proto); | 1444 ->GetFirstChildByClass(XFA_ELEMENT_Proto); |
1450 if (!wsUseVal.IsEmpty()) { | 1445 if (!wsUseVal.IsEmpty()) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 InsertChild(pHeadChild); | 1481 InsertChild(pHeadChild); |
1487 pHeadChild = pSibling; | 1482 pHeadChild = pSibling; |
1488 } | 1483 } |
1489 m_pDocument->RemovePurgeNode(pProtoForm); | 1484 m_pDocument->RemovePurgeNode(pProtoForm); |
1490 delete pProtoForm; | 1485 delete pProtoForm; |
1491 } | 1486 } |
1492 } | 1487 } |
1493 } else { | 1488 } else { |
1494 CFX_WideString wsValue; | 1489 CFX_WideString wsValue; |
1495 GetAttribute(eAttribute, wsValue); | 1490 GetAttribute(eAttribute, wsValue); |
1496 FXJSE_Value_SetUTF8String( | 1491 pValue->SetString( |
1497 pValue, | |
1498 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); | 1492 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); |
1499 } | 1493 } |
1500 } | 1494 } |
1501 void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, | 1495 void CXFA_Node::Script_Attribute_StringRead(CFXJSE_Value* pValue, |
1502 FX_BOOL bSetting, | 1496 FX_BOOL bSetting, |
1503 XFA_ATTRIBUTE eAttribute) { | 1497 XFA_ATTRIBUTE eAttribute) { |
1504 if (!bSetting) { | 1498 if (!bSetting) { |
1505 CFX_WideString wsValue; | 1499 CFX_WideString wsValue; |
1506 GetAttribute(eAttribute, wsValue); | 1500 GetAttribute(eAttribute, wsValue); |
1507 FXJSE_Value_SetUTF8String( | 1501 pValue->SetString( |
1508 pValue, | |
1509 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); | 1502 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); |
1510 } else { | 1503 } else { |
1511 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1504 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1512 } | 1505 } |
1513 } | 1506 } |
1514 void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { | 1507 void CXFA_Node::Script_WsdlConnection_Execute(CFXJSE_Arguments* pArguments) { |
1515 int32_t argc = pArguments->GetLength(); | 1508 int32_t argc = pArguments->GetLength(); |
1516 if ((argc == 0) || (argc == 1)) { | 1509 if ((argc == 0) || (argc == 1)) { |
1517 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 1510 pArguments->GetReturnValue()->SetBoolean(FALSE); |
1518 } else { | 1511 } else { |
1519 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute"); | 1512 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execute"); |
1520 } | 1513 } |
1521 } | 1514 } |
1522 void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { | 1515 void CXFA_Node::Script_Delta_Restore(CFXJSE_Arguments* pArguments) { |
1523 int32_t argc = pArguments->GetLength(); | 1516 int32_t argc = pArguments->GetLength(); |
1524 if (argc == 0) { | 1517 if (argc == 0) { |
1525 } else { | 1518 } else { |
1526 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore"); | 1519 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"restore"); |
1527 } | 1520 } |
(...skipping 15 matching lines...) Expand all Loading... |
1543 return; | 1536 return; |
1544 } | 1537 } |
1545 FX_BOOL bNew = FALSE; | 1538 FX_BOOL bNew = FALSE; |
1546 CXFA_Validate validate = pWidgetData->GetValidate(); | 1539 CXFA_Validate validate = pWidgetData->GetValidate(); |
1547 if (!validate) { | 1540 if (!validate) { |
1548 validate = pWidgetData->GetValidate(TRUE); | 1541 validate = pWidgetData->GetValidate(TRUE); |
1549 bNew = TRUE; | 1542 bNew = TRUE; |
1550 } | 1543 } |
1551 if (bSetting) { | 1544 if (bSetting) { |
1552 CFX_ByteString bsMessage; | 1545 CFX_ByteString bsMessage; |
1553 FXJSE_Value_ToUTF8String(pValue, bsMessage); | 1546 pValue->ToString(bsMessage); |
1554 switch (iMessageType) { | 1547 switch (iMessageType) { |
1555 case XFA_SOM_ValidationMessage: | 1548 case XFA_SOM_ValidationMessage: |
1556 validate.SetScriptMessageText( | 1549 validate.SetScriptMessageText( |
1557 CFX_WideString::FromUTF8(bsMessage.AsStringC())); | 1550 CFX_WideString::FromUTF8(bsMessage.AsStringC())); |
1558 break; | 1551 break; |
1559 case XFA_SOM_FormatMessage: | 1552 case XFA_SOM_FormatMessage: |
1560 validate.SetFormatMessageText( | 1553 validate.SetFormatMessageText( |
1561 CFX_WideString::FromUTF8(bsMessage.AsStringC())); | 1554 CFX_WideString::FromUTF8(bsMessage.AsStringC())); |
1562 break; | 1555 break; |
1563 case XFA_SOM_MandatoryMessage: | 1556 case XFA_SOM_MandatoryMessage: |
(...skipping 18 matching lines...) Expand all Loading... |
1582 break; | 1575 break; |
1583 case XFA_SOM_FormatMessage: | 1576 case XFA_SOM_FormatMessage: |
1584 validate.GetFormatMessageText(wsMessage); | 1577 validate.GetFormatMessageText(wsMessage); |
1585 break; | 1578 break; |
1586 case XFA_SOM_MandatoryMessage: | 1579 case XFA_SOM_MandatoryMessage: |
1587 validate.GetNullMessageText(wsMessage); | 1580 validate.GetNullMessageText(wsMessage); |
1588 break; | 1581 break; |
1589 default: | 1582 default: |
1590 break; | 1583 break; |
1591 } | 1584 } |
1592 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsMessage).AsStringC()); | 1585 pValue->SetString(FX_UTF8Encode(wsMessage).AsStringC()); |
1593 } | 1586 } |
1594 } | 1587 } |
1595 void CXFA_Node::Script_Som_ValidationMessage(CFXJSE_Value* pValue, | 1588 void CXFA_Node::Script_Som_ValidationMessage(CFXJSE_Value* pValue, |
1596 FX_BOOL bSetting, | 1589 FX_BOOL bSetting, |
1597 XFA_ATTRIBUTE eAttribute) { | 1590 XFA_ATTRIBUTE eAttribute) { |
1598 Script_Som_Message(pValue, bSetting, XFA_SOM_ValidationMessage); | 1591 Script_Som_Message(pValue, bSetting, XFA_SOM_ValidationMessage); |
1599 } | 1592 } |
1600 void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue, | 1593 void CXFA_Node::Script_Field_Length(CFXJSE_Value* pValue, |
1601 FX_BOOL bSetting, | 1594 FX_BOOL bSetting, |
1602 XFA_ATTRIBUTE eAttribute) { | 1595 XFA_ATTRIBUTE eAttribute) { |
1603 if (bSetting) { | 1596 if (bSetting) { |
1604 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1597 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1605 } else { | 1598 } else { |
1606 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1599 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1607 if (!pWidgetData) { | 1600 if (!pWidgetData) { |
1608 FXJSE_Value_SetInteger(pValue, 0); | 1601 pValue->SetInteger(0); |
1609 return; | 1602 return; |
1610 } | 1603 } |
1611 FXJSE_Value_SetInteger(pValue, pWidgetData->CountChoiceListItems(TRUE)); | 1604 pValue->SetInteger(pWidgetData->CountChoiceListItems(TRUE)); |
1612 } | 1605 } |
1613 } | 1606 } |
1614 void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, | 1607 void CXFA_Node::Script_Som_DefaultValue(CFXJSE_Value* pValue, |
1615 FX_BOOL bSetting, | 1608 FX_BOOL bSetting, |
1616 XFA_ATTRIBUTE eAttribute) { | 1609 XFA_ATTRIBUTE eAttribute) { |
1617 XFA_ELEMENT classID = GetClassID(); | 1610 XFA_ELEMENT classID = GetClassID(); |
1618 if (classID == XFA_ELEMENT_Field) { | 1611 if (classID == XFA_ELEMENT_Field) { |
1619 Script_Field_DefaultValue(pValue, bSetting, eAttribute); | 1612 Script_Field_DefaultValue(pValue, bSetting, eAttribute); |
1620 return; | 1613 return; |
1621 } else if (classID == XFA_ELEMENT_Draw) { | 1614 } else if (classID == XFA_ELEMENT_Draw) { |
1622 Script_Draw_DefaultValue(pValue, bSetting, eAttribute); | 1615 Script_Draw_DefaultValue(pValue, bSetting, eAttribute); |
1623 return; | 1616 return; |
1624 } else if (classID == XFA_ELEMENT_Boolean) { | 1617 } else if (classID == XFA_ELEMENT_Boolean) { |
1625 Script_Boolean_Value(pValue, bSetting, eAttribute); | 1618 Script_Boolean_Value(pValue, bSetting, eAttribute); |
1626 return; | 1619 return; |
1627 } | 1620 } |
1628 if (bSetting) { | 1621 if (bSetting) { |
1629 CFX_ByteString newValue; | 1622 CFX_ByteString newValue; |
1630 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) { | 1623 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) |
1631 FXJSE_Value_ToUTF8String(pValue, newValue); | 1624 pValue->ToString(newValue); |
1632 } | 1625 |
1633 CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC()); | 1626 CFX_WideString wsNewValue = CFX_WideString::FromUTF8(newValue.AsStringC()); |
1634 CFX_WideString wsFormatValue(wsNewValue); | 1627 CFX_WideString wsFormatValue(wsNewValue); |
1635 CXFA_WidgetData* pContainerWidgetData = nullptr; | 1628 CXFA_WidgetData* pContainerWidgetData = nullptr; |
1636 if (GetPacketID() == XFA_XDPPACKET_Datasets) { | 1629 if (GetPacketID() == XFA_XDPPACKET_Datasets) { |
1637 CXFA_NodeArray formNodes; | 1630 CXFA_NodeArray formNodes; |
1638 GetBindItems(formNodes); | 1631 GetBindItems(formNodes); |
1639 CFX_WideString wsPicture; | 1632 CFX_WideString wsPicture; |
1640 for (int32_t i = 0; i < formNodes.GetSize(); i++) { | 1633 for (int32_t i = 0; i < formNodes.GetSize(); i++) { |
1641 CXFA_Node* pFormNode = formNodes.GetAt(i); | 1634 CXFA_Node* pFormNode = formNodes.GetAt(i); |
1642 if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { | 1635 if (!pFormNode || pFormNode->HasFlag(XFA_NODEFLAG_HasRemoved)) { |
(...skipping 13 matching lines...) Expand all Loading... |
1656 pContainerWidgetData = GetContainerWidgetData(); | 1649 pContainerWidgetData = GetContainerWidgetData(); |
1657 } | 1650 } |
1658 if (pContainerWidgetData) { | 1651 if (pContainerWidgetData) { |
1659 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); | 1652 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); |
1660 } | 1653 } |
1661 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); | 1654 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); |
1662 } else { | 1655 } else { |
1663 CFX_WideString content = GetScriptContent(TRUE); | 1656 CFX_WideString content = GetScriptContent(TRUE); |
1664 if (content.IsEmpty() && classID != XFA_ELEMENT_Text && | 1657 if (content.IsEmpty() && classID != XFA_ELEMENT_Text && |
1665 classID != XFA_ELEMENT_SubmitUrl) { | 1658 classID != XFA_ELEMENT_SubmitUrl) { |
1666 FXJSE_Value_SetNull(pValue); | 1659 pValue->SetNull(); |
1667 } else if (classID == XFA_ELEMENT_Integer) { | 1660 } else if (classID == XFA_ELEMENT_Integer) { |
1668 FXJSE_Value_SetInteger(pValue, FXSYS_wtoi(content.c_str())); | 1661 pValue->SetInteger(FXSYS_wtoi(content.c_str())); |
1669 } else if (classID == XFA_ELEMENT_Float || classID == XFA_ELEMENT_Decimal) { | 1662 } else if (classID == XFA_ELEMENT_Float || classID == XFA_ELEMENT_Decimal) { |
1670 CFX_Decimal decimal(content.AsStringC()); | 1663 CFX_Decimal decimal(content.AsStringC()); |
1671 FXJSE_Value_SetFloat(pValue, (FX_FLOAT)(double)decimal); | 1664 pValue->SetFloat((FX_FLOAT)(double)decimal); |
1672 } else { | 1665 } else { |
1673 FXJSE_Value_SetUTF8String( | 1666 pValue->SetString( |
1674 pValue, | |
1675 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 1667 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
1676 } | 1668 } |
1677 } | 1669 } |
1678 } | 1670 } |
1679 void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, | 1671 void CXFA_Node::Script_Som_DefaultValue_Read(CFXJSE_Value* pValue, |
1680 FX_BOOL bSetting, | 1672 FX_BOOL bSetting, |
1681 XFA_ATTRIBUTE eAttribute) { | 1673 XFA_ATTRIBUTE eAttribute) { |
1682 if (bSetting) { | 1674 if (bSetting) { |
1683 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1675 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1684 return; | 1676 return; |
1685 } | 1677 } |
1686 CFX_WideString content = GetScriptContent(TRUE); | 1678 CFX_WideString content = GetScriptContent(TRUE); |
1687 if (content.IsEmpty()) { | 1679 if (content.IsEmpty()) { |
1688 FXJSE_Value_SetNull(pValue); | 1680 pValue->SetNull(); |
1689 } else { | 1681 } else { |
1690 FXJSE_Value_SetUTF8String( | 1682 pValue->SetString( |
1691 pValue, | |
1692 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 1683 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
1693 } | 1684 } |
1694 } | 1685 } |
1695 void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue, | 1686 void CXFA_Node::Script_Boolean_Value(CFXJSE_Value* pValue, |
1696 FX_BOOL bSetting, | 1687 FX_BOOL bSetting, |
1697 XFA_ATTRIBUTE eAttribute) { | 1688 XFA_ATTRIBUTE eAttribute) { |
1698 if (bSetting) { | 1689 if (bSetting) { |
1699 CFX_ByteString newValue; | 1690 CFX_ByteString newValue; |
1700 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) { | 1691 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) |
1701 FXJSE_Value_ToUTF8String(pValue, newValue); | 1692 pValue->ToString(newValue); |
1702 } | 1693 |
1703 int32_t iValue = FXSYS_atoi(newValue.c_str()); | 1694 int32_t iValue = FXSYS_atoi(newValue.c_str()); |
1704 CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1"); | 1695 CFX_WideString wsNewValue(iValue == 0 ? L"0" : L"1"); |
1705 CFX_WideString wsFormatValue(wsNewValue); | 1696 CFX_WideString wsFormatValue(wsNewValue); |
1706 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); | 1697 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); |
1707 if (pContainerWidgetData) { | 1698 if (pContainerWidgetData) { |
1708 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); | 1699 pContainerWidgetData->GetFormatDataValue(wsNewValue, wsFormatValue); |
1709 } | 1700 } |
1710 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); | 1701 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); |
1711 } else { | 1702 } else { |
1712 CFX_WideString wsValue = GetScriptContent(TRUE); | 1703 CFX_WideString wsValue = GetScriptContent(TRUE); |
1713 FXJSE_Value_SetBoolean(pValue, wsValue == FX_WSTRC(L"1")); | 1704 pValue->SetBoolean(wsValue == FX_WSTRC(L"1")); |
1714 } | 1705 } |
1715 } | 1706 } |
1716 struct XFA_ExecEventParaInfo { | 1707 struct XFA_ExecEventParaInfo { |
1717 public: | 1708 public: |
1718 uint32_t m_uHash; | 1709 uint32_t m_uHash; |
1719 const FX_WCHAR* m_lpcEventName; | 1710 const FX_WCHAR* m_lpcEventName; |
1720 XFA_EVENTTYPE m_eventType; | 1711 XFA_EVENTTYPE m_eventType; |
1721 uint32_t m_validFlags; | 1712 uint32_t m_validFlags; |
1722 }; | 1713 }; |
1723 static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { | 1714 static const XFA_ExecEventParaInfo gs_eventParaInfos[] = { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1805 XFA_ATTRIBUTE eAttribute) { | 1796 XFA_ATTRIBUTE eAttribute) { |
1806 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1797 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1807 if (!pWidgetData) { | 1798 if (!pWidgetData) { |
1808 return; | 1799 return; |
1809 } | 1800 } |
1810 CXFA_Border border = pWidgetData->GetBorder(TRUE); | 1801 CXFA_Border border = pWidgetData->GetBorder(TRUE); |
1811 int32_t iSize = border.CountEdges(); | 1802 int32_t iSize = border.CountEdges(); |
1812 CFX_WideString strColor; | 1803 CFX_WideString strColor; |
1813 if (bSetting) { | 1804 if (bSetting) { |
1814 CFX_ByteString bsValue; | 1805 CFX_ByteString bsValue; |
1815 FXJSE_Value_ToUTF8String(pValue, bsValue); | 1806 pValue->ToString(bsValue); |
1816 strColor = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 1807 strColor = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
1817 int32_t r = 0, g = 0, b = 0; | 1808 int32_t r = 0, g = 0, b = 0; |
1818 XFA_STRING_TO_RGB(strColor, r, g, b); | 1809 XFA_STRING_TO_RGB(strColor, r, g, b); |
1819 FX_ARGB rgb = ArgbEncode(100, r, g, b); | 1810 FX_ARGB rgb = ArgbEncode(100, r, g, b); |
1820 for (int32_t i = 0; i < iSize; ++i) { | 1811 for (int32_t i = 0; i < iSize; ++i) { |
1821 CXFA_Edge edge = border.GetEdge(i); | 1812 CXFA_Edge edge = border.GetEdge(i); |
1822 edge.SetColor(rgb); | 1813 edge.SetColor(rgb); |
1823 } | 1814 } |
1824 } else { | 1815 } else { |
1825 CXFA_Edge edge = border.GetEdge(0); | 1816 CXFA_Edge edge = border.GetEdge(0); |
1826 FX_ARGB color = edge.GetColor(); | 1817 FX_ARGB color = edge.GetColor(); |
1827 int32_t a, r, g, b; | 1818 int32_t a, r, g, b; |
1828 ArgbDecode(color, a, r, g, b); | 1819 ArgbDecode(color, a, r, g, b); |
1829 strColor.Format(L"%d,%d,%d", r, g, b); | 1820 strColor.Format(L"%d,%d,%d", r, g, b); |
1830 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(strColor).AsStringC()); | 1821 pValue->SetString(FX_UTF8Encode(strColor).AsStringC()); |
1831 } | 1822 } |
1832 } | 1823 } |
1833 void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, | 1824 void CXFA_Node::Script_Som_BorderWidth(CFXJSE_Value* pValue, |
1834 FX_BOOL bSetting, | 1825 FX_BOOL bSetting, |
1835 XFA_ATTRIBUTE eAttribute) { | 1826 XFA_ATTRIBUTE eAttribute) { |
1836 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1827 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1837 if (!pWidgetData) { | 1828 if (!pWidgetData) { |
1838 return; | 1829 return; |
1839 } | 1830 } |
1840 CXFA_Border border = pWidgetData->GetBorder(TRUE); | 1831 CXFA_Border border = pWidgetData->GetBorder(TRUE); |
1841 int32_t iSize = border.CountEdges(); | 1832 int32_t iSize = border.CountEdges(); |
1842 CFX_WideString wsThickness; | 1833 CFX_WideString wsThickness; |
1843 if (bSetting) { | 1834 if (bSetting) { |
1844 CFX_ByteString bsValue; | 1835 CFX_ByteString bsValue; |
1845 FXJSE_Value_ToUTF8String(pValue, bsValue); | 1836 pValue->ToString(bsValue); |
1846 wsThickness = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 1837 wsThickness = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
1847 for (int32_t i = 0; i < iSize; ++i) { | 1838 for (int32_t i = 0; i < iSize; ++i) { |
1848 CXFA_Edge edge = border.GetEdge(i); | 1839 CXFA_Edge edge = border.GetEdge(i); |
1849 CXFA_Measurement thickness(wsThickness.AsStringC()); | 1840 CXFA_Measurement thickness(wsThickness.AsStringC()); |
1850 edge.SetMSThickness(thickness); | 1841 edge.SetMSThickness(thickness); |
1851 } | 1842 } |
1852 } else { | 1843 } else { |
1853 CXFA_Edge edge = border.GetEdge(0); | 1844 CXFA_Edge edge = border.GetEdge(0); |
1854 CXFA_Measurement thickness = edge.GetMSThickness(); | 1845 CXFA_Measurement thickness = edge.GetMSThickness(); |
1855 thickness.ToString(wsThickness); | 1846 thickness.ToString(wsThickness); |
1856 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsThickness).AsStringC()); | 1847 pValue->SetString(FX_UTF8Encode(wsThickness).AsStringC()); |
1857 } | 1848 } |
1858 } | 1849 } |
1859 void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue, | 1850 void CXFA_Node::Script_Som_FillColor(CFXJSE_Value* pValue, |
1860 FX_BOOL bSetting, | 1851 FX_BOOL bSetting, |
1861 XFA_ATTRIBUTE eAttribute) { | 1852 XFA_ATTRIBUTE eAttribute) { |
1862 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1853 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1863 if (!pWidgetData) { | 1854 if (!pWidgetData) { |
1864 return; | 1855 return; |
1865 } | 1856 } |
1866 CXFA_Border border = pWidgetData->GetBorder(TRUE); | 1857 CXFA_Border border = pWidgetData->GetBorder(TRUE); |
1867 CXFA_Fill borderfill = border.GetFill(TRUE); | 1858 CXFA_Fill borderfill = border.GetFill(TRUE); |
1868 CXFA_Node* pNode = borderfill.GetNode(); | 1859 CXFA_Node* pNode = borderfill.GetNode(); |
1869 if (!pNode) { | 1860 if (!pNode) { |
1870 return; | 1861 return; |
1871 } | 1862 } |
1872 CFX_WideString wsColor; | 1863 CFX_WideString wsColor; |
1873 if (bSetting) { | 1864 if (bSetting) { |
1874 CFX_ByteString bsValue; | 1865 CFX_ByteString bsValue; |
1875 FXJSE_Value_ToUTF8String(pValue, bsValue); | 1866 pValue->ToString(bsValue); |
1876 wsColor = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 1867 wsColor = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
1877 int32_t r, g, b; | 1868 int32_t r, g, b; |
1878 XFA_STRING_TO_RGB(wsColor, r, g, b); | 1869 XFA_STRING_TO_RGB(wsColor, r, g, b); |
1879 FX_ARGB color = ArgbEncode(0xff, r, g, b); | 1870 FX_ARGB color = ArgbEncode(0xff, r, g, b); |
1880 borderfill.SetColor(color); | 1871 borderfill.SetColor(color); |
1881 } else { | 1872 } else { |
1882 FX_ARGB color = borderfill.GetColor(); | 1873 FX_ARGB color = borderfill.GetColor(); |
1883 int32_t a, r, g, b; | 1874 int32_t a, r, g, b; |
1884 ArgbDecode(color, a, r, g, b); | 1875 ArgbDecode(color, a, r, g, b); |
1885 wsColor.Format(L"%d,%d,%d", r, g, b); | 1876 wsColor.Format(L"%d,%d,%d", r, g, b); |
1886 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsColor).AsStringC()); | 1877 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); |
1887 } | 1878 } |
1888 } | 1879 } |
1889 void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue, | 1880 void CXFA_Node::Script_Som_DataNode(CFXJSE_Value* pValue, |
1890 FX_BOOL bSetting, | 1881 FX_BOOL bSetting, |
1891 XFA_ATTRIBUTE eAttribute) { | 1882 XFA_ATTRIBUTE eAttribute) { |
1892 if (!bSetting) { | 1883 if (!bSetting) { |
1893 CXFA_Node* pDataNode = GetBindData(); | 1884 CXFA_Node* pDataNode = GetBindData(); |
1894 if (pDataNode) { | 1885 if (pDataNode) { |
1895 FXJSE_Value_Set( | 1886 pValue->Assign( |
1896 pValue, | |
1897 m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode)); | 1887 m_pDocument->GetScriptContext()->GetJSValueFromMap(pDataNode)); |
1898 } else { | 1888 } else { |
1899 FXJSE_Value_SetNull(pValue); | 1889 pValue->SetNull(); |
1900 } | 1890 } |
1901 } else { | 1891 } else { |
1902 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 1892 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
1903 } | 1893 } |
1904 } | 1894 } |
1905 void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, | 1895 void CXFA_Node::Script_Draw_DefaultValue(CFXJSE_Value* pValue, |
1906 FX_BOOL bSetting, | 1896 FX_BOOL bSetting, |
1907 XFA_ATTRIBUTE eAttribute) { | 1897 XFA_ATTRIBUTE eAttribute) { |
1908 if (bSetting) { | 1898 if (bSetting) { |
1909 if (FXJSE_Value_IsUTF8String(pValue)) { | 1899 if (FXJSE_Value_IsUTF8String(pValue)) { |
1910 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1900 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1911 ASSERT(pWidgetData); | 1901 ASSERT(pWidgetData); |
1912 XFA_ELEMENT uiType = pWidgetData->GetUIType(); | 1902 XFA_ELEMENT uiType = pWidgetData->GetUIType(); |
1913 if (uiType == XFA_ELEMENT_Text) { | 1903 if (uiType == XFA_ELEMENT_Text) { |
1914 CFX_ByteString newValue; | 1904 CFX_ByteString newValue; |
1915 FXJSE_Value_ToUTF8String(pValue, newValue); | 1905 pValue->ToString(newValue); |
1916 CFX_WideString wsNewValue = | 1906 CFX_WideString wsNewValue = |
1917 CFX_WideString::FromUTF8(newValue.AsStringC()); | 1907 CFX_WideString::FromUTF8(newValue.AsStringC()); |
1918 CFX_WideString wsFormatValue(wsNewValue); | 1908 CFX_WideString wsFormatValue(wsNewValue); |
1919 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); | 1909 SetScriptContent(wsNewValue, wsFormatValue, true, TRUE); |
1920 } else if (uiType != XFA_ELEMENT_Image) { | 1910 } else if (uiType != XFA_ELEMENT_Image) { |
1921 } | 1911 } |
1922 } | 1912 } |
1923 } else { | 1913 } else { |
1924 CFX_WideString content = GetScriptContent(TRUE); | 1914 CFX_WideString content = GetScriptContent(TRUE); |
1925 if (content.IsEmpty()) { | 1915 if (content.IsEmpty()) { |
1926 FXJSE_Value_SetNull(pValue); | 1916 pValue->SetNull(); |
1927 } else { | 1917 } else { |
1928 FXJSE_Value_SetUTF8String( | 1918 pValue->SetString( |
1929 pValue, | |
1930 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 1919 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
1931 } | 1920 } |
1932 } | 1921 } |
1933 } | 1922 } |
1934 void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, | 1923 void CXFA_Node::Script_Field_DefaultValue(CFXJSE_Value* pValue, |
1935 FX_BOOL bSetting, | 1924 FX_BOOL bSetting, |
1936 XFA_ATTRIBUTE eAttribute) { | 1925 XFA_ATTRIBUTE eAttribute) { |
1937 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1926 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
1938 if (!pWidgetData) { | 1927 if (!pWidgetData) { |
1939 return; | 1928 return; |
1940 } | 1929 } |
1941 if (bSetting) { | 1930 if (bSetting) { |
1942 if (FXJSE_Value_IsNull(pValue)) { | 1931 if (FXJSE_Value_IsNull(pValue)) { |
1943 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; | 1932 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; |
1944 pWidgetData->m_bIsNull = TRUE; | 1933 pWidgetData->m_bIsNull = TRUE; |
1945 } else { | 1934 } else { |
1946 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; | 1935 pWidgetData->m_bPreNull = pWidgetData->m_bIsNull; |
1947 pWidgetData->m_bIsNull = FALSE; | 1936 pWidgetData->m_bIsNull = FALSE; |
1948 } | 1937 } |
1949 CFX_ByteString newValue; | 1938 CFX_ByteString newValue; |
1950 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) { | 1939 if (!(FXJSE_Value_IsNull(pValue) || FXJSE_Value_IsUndefined(pValue))) |
1951 FXJSE_Value_ToUTF8String(pValue, newValue); | 1940 pValue->ToString(newValue); |
1952 } | 1941 |
1953 CFX_WideString wsNewText = CFX_WideString::FromUTF8(newValue.AsStringC()); | 1942 CFX_WideString wsNewText = CFX_WideString::FromUTF8(newValue.AsStringC()); |
1954 CXFA_Node* pUIChild = pWidgetData->GetUIChild(); | 1943 CXFA_Node* pUIChild = pWidgetData->GetUIChild(); |
1955 if (pUIChild->GetClassID() == XFA_ELEMENT_NumericEdit) { | 1944 if (pUIChild->GetClassID() == XFA_ELEMENT_NumericEdit) { |
1956 int32_t iLeadDigits = 0; | 1945 int32_t iLeadDigits = 0; |
1957 int32_t iFracDigits = 0; | 1946 int32_t iFracDigits = 0; |
1958 pWidgetData->GetLeadDigits(iLeadDigits); | 1947 pWidgetData->GetLeadDigits(iLeadDigits); |
1959 pWidgetData->GetFracDigits(iFracDigits); | 1948 pWidgetData->GetFracDigits(iFracDigits); |
1960 wsNewText = | 1949 wsNewText = |
1961 pWidgetData->NumericLimit(wsNewText, iLeadDigits, iFracDigits); | 1950 pWidgetData->NumericLimit(wsNewText, iLeadDigits, iFracDigits); |
1962 } | 1951 } |
1963 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); | 1952 CXFA_WidgetData* pContainerWidgetData = GetContainerWidgetData(); |
1964 CFX_WideString wsFormatText(wsNewText); | 1953 CFX_WideString wsFormatText(wsNewText); |
1965 if (pContainerWidgetData) { | 1954 if (pContainerWidgetData) { |
1966 pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText); | 1955 pContainerWidgetData->GetFormatDataValue(wsNewText, wsFormatText); |
1967 } | 1956 } |
1968 SetScriptContent(wsNewText, wsFormatText, true, TRUE); | 1957 SetScriptContent(wsNewText, wsFormatText, true, TRUE); |
1969 } else { | 1958 } else { |
1970 CFX_WideString content = GetScriptContent(TRUE); | 1959 CFX_WideString content = GetScriptContent(TRUE); |
1971 if (content.IsEmpty()) { | 1960 if (content.IsEmpty()) { |
1972 FXJSE_Value_SetNull(pValue); | 1961 pValue->SetNull(); |
1973 } else { | 1962 } else { |
1974 CXFA_Node* pUIChild = pWidgetData->GetUIChild(); | 1963 CXFA_Node* pUIChild = pWidgetData->GetUIChild(); |
1975 XFA_ELEMENT eUI = pUIChild->GetClassID(); | 1964 XFA_ELEMENT eUI = pUIChild->GetClassID(); |
1976 CXFA_Value defVal = pWidgetData->GetFormValue(); | 1965 CXFA_Value defVal = pWidgetData->GetFormValue(); |
1977 CXFA_Node* pNode = defVal.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild); | 1966 CXFA_Node* pNode = defVal.GetNode()->GetNodeItem(XFA_NODEITEM_FirstChild); |
1978 if (pNode && pNode->GetClassID() == XFA_ELEMENT_Decimal) { | 1967 if (pNode && pNode->GetClassID() == XFA_ELEMENT_Decimal) { |
1979 if (eUI == XFA_ELEMENT_NumericEdit && | 1968 if (eUI == XFA_ELEMENT_NumericEdit && |
1980 (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) { | 1969 (pNode->GetInteger(XFA_ATTRIBUTE_FracDigits) == -1)) { |
1981 FXJSE_Value_SetUTF8String( | 1970 pValue->SetString( |
1982 pValue, | |
1983 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 1971 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
1984 } else { | 1972 } else { |
1985 CFX_Decimal decimal(content.AsStringC()); | 1973 CFX_Decimal decimal(content.AsStringC()); |
1986 FXJSE_Value_SetFloat(pValue, (FX_FLOAT)(double)decimal); | 1974 pValue->SetFloat((FX_FLOAT)(double)decimal); |
1987 } | 1975 } |
1988 } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Integer) { | 1976 } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Integer) { |
1989 FXJSE_Value_SetInteger(pValue, FXSYS_wtoi(content.c_str())); | 1977 pValue->SetInteger(FXSYS_wtoi(content.c_str())); |
1990 } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Boolean) { | 1978 } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Boolean) { |
1991 FXJSE_Value_SetBoolean(pValue, | 1979 pValue->SetBoolean(FXSYS_wtoi(content.c_str()) == 0 ? FALSE : TRUE); |
1992 FXSYS_wtoi(content.c_str()) == 0 ? FALSE : TRUE); | |
1993 } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Float) { | 1980 } else if (pNode && pNode->GetClassID() == XFA_ELEMENT_Float) { |
1994 CFX_Decimal decimal(content.AsStringC()); | 1981 CFX_Decimal decimal(content.AsStringC()); |
1995 FXJSE_Value_SetFloat(pValue, (FX_FLOAT)(double)decimal); | 1982 pValue->SetFloat((FX_FLOAT)(double)decimal); |
1996 } else { | 1983 } else { |
1997 FXJSE_Value_SetUTF8String( | 1984 pValue->SetString( |
1998 pValue, | |
1999 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); | 1985 FX_UTF8Encode(content.c_str(), content.GetLength()).AsStringC()); |
2000 } | 1986 } |
2001 } | 1987 } |
2002 } | 1988 } |
2003 } | 1989 } |
2004 void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue, | 1990 void CXFA_Node::Script_Field_EditValue(CFXJSE_Value* pValue, |
2005 FX_BOOL bSetting, | 1991 FX_BOOL bSetting, |
2006 XFA_ATTRIBUTE eAttribute) { | 1992 XFA_ATTRIBUTE eAttribute) { |
2007 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 1993 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2008 if (!pWidgetData) { | 1994 if (!pWidgetData) { |
2009 return; | 1995 return; |
2010 } | 1996 } |
2011 CFX_WideString wsValue; | 1997 CFX_WideString wsValue; |
2012 if (bSetting) { | 1998 if (bSetting) { |
2013 CFX_ByteString bsValue; | 1999 CFX_ByteString bsValue; |
2014 FXJSE_Value_ToUTF8String(pValue, bsValue); | 2000 pValue->ToString(bsValue); |
2015 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 2001 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
2016 pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Edit); | 2002 pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Edit); |
2017 } else { | 2003 } else { |
2018 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit); | 2004 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Edit); |
2019 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsValue).AsStringC()); | 2005 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
2020 } | 2006 } |
2021 } | 2007 } |
2022 void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue, | 2008 void CXFA_Node::Script_Som_FontColor(CFXJSE_Value* pValue, |
2023 FX_BOOL bSetting, | 2009 FX_BOOL bSetting, |
2024 XFA_ATTRIBUTE eAttribute) { | 2010 XFA_ATTRIBUTE eAttribute) { |
2025 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2011 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2026 if (!pWidgetData) { | 2012 if (!pWidgetData) { |
2027 return; | 2013 return; |
2028 } | 2014 } |
2029 CXFA_Font font = pWidgetData->GetFont(TRUE); | 2015 CXFA_Font font = pWidgetData->GetFont(TRUE); |
2030 CXFA_Node* pNode = font.GetNode(); | 2016 CXFA_Node* pNode = font.GetNode(); |
2031 if (!pNode) { | 2017 if (!pNode) { |
2032 return; | 2018 return; |
2033 } | 2019 } |
2034 CFX_WideString wsColor; | 2020 CFX_WideString wsColor; |
2035 if (bSetting) { | 2021 if (bSetting) { |
2036 CFX_ByteString bsValue; | 2022 CFX_ByteString bsValue; |
2037 FXJSE_Value_ToUTF8String(pValue, bsValue); | 2023 pValue->ToString(bsValue); |
2038 wsColor = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 2024 wsColor = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
2039 int32_t r, g, b; | 2025 int32_t r, g, b; |
2040 XFA_STRING_TO_RGB(wsColor, r, g, b); | 2026 XFA_STRING_TO_RGB(wsColor, r, g, b); |
2041 FX_ARGB color = ArgbEncode(0xff, r, g, b); | 2027 FX_ARGB color = ArgbEncode(0xff, r, g, b); |
2042 font.SetColor(color); | 2028 font.SetColor(color); |
2043 } else { | 2029 } else { |
2044 FX_ARGB color = font.GetColor(); | 2030 FX_ARGB color = font.GetColor(); |
2045 int32_t a, r, g, b; | 2031 int32_t a, r, g, b; |
2046 ArgbDecode(color, a, r, g, b); | 2032 ArgbDecode(color, a, r, g, b); |
2047 wsColor.Format(L"%d,%d,%d", r, g, b); | 2033 wsColor.Format(L"%d,%d,%d", r, g, b); |
2048 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsColor).AsStringC()); | 2034 pValue->SetString(FX_UTF8Encode(wsColor).AsStringC()); |
2049 } | 2035 } |
2050 } | 2036 } |
2051 void CXFA_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue, | 2037 void CXFA_Node::Script_Field_FormatMessage(CFXJSE_Value* pValue, |
2052 FX_BOOL bSetting, | 2038 FX_BOOL bSetting, |
2053 XFA_ATTRIBUTE eAttribute) { | 2039 XFA_ATTRIBUTE eAttribute) { |
2054 Script_Som_Message(pValue, bSetting, XFA_SOM_FormatMessage); | 2040 Script_Som_Message(pValue, bSetting, XFA_SOM_FormatMessage); |
2055 } | 2041 } |
2056 void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, | 2042 void CXFA_Node::Script_Field_FormattedValue(CFXJSE_Value* pValue, |
2057 FX_BOOL bSetting, | 2043 FX_BOOL bSetting, |
2058 XFA_ATTRIBUTE eAttribute) { | 2044 XFA_ATTRIBUTE eAttribute) { |
2059 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2045 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2060 if (!pWidgetData) { | 2046 if (!pWidgetData) { |
2061 return; | 2047 return; |
2062 } | 2048 } |
2063 CFX_WideString wsValue; | 2049 CFX_WideString wsValue; |
2064 if (bSetting) { | 2050 if (bSetting) { |
2065 CFX_ByteString bsValue; | 2051 CFX_ByteString bsValue; |
2066 FXJSE_Value_ToUTF8String(pValue, bsValue); | 2052 pValue->ToString(bsValue); |
2067 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 2053 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
2068 pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Display); | 2054 pWidgetData->SetValue(wsValue, XFA_VALUEPICTURE_Display); |
2069 } else { | 2055 } else { |
2070 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display); | 2056 pWidgetData->GetValue(wsValue, XFA_VALUEPICTURE_Display); |
2071 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsValue).AsStringC()); | 2057 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
2072 } | 2058 } |
2073 } | 2059 } |
2074 void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue, | 2060 void CXFA_Node::Script_Som_Mandatory(CFXJSE_Value* pValue, |
2075 FX_BOOL bSetting, | 2061 FX_BOOL bSetting, |
2076 XFA_ATTRIBUTE eAttribute) { | 2062 XFA_ATTRIBUTE eAttribute) { |
2077 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2063 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2078 if (!pWidgetData) { | 2064 if (!pWidgetData) { |
2079 return; | 2065 return; |
2080 } | 2066 } |
2081 CXFA_Validate validate = pWidgetData->GetValidate(TRUE); | 2067 CXFA_Validate validate = pWidgetData->GetValidate(TRUE); |
2082 CFX_WideString wsValue; | 2068 CFX_WideString wsValue; |
2083 if (bSetting) { | 2069 if (bSetting) { |
2084 CFX_ByteString bsValue; | 2070 CFX_ByteString bsValue; |
2085 FXJSE_Value_ToUTF8String(pValue, bsValue); | 2071 pValue->ToString(bsValue); |
2086 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 2072 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
2087 validate.SetNullTest(wsValue); | 2073 validate.SetNullTest(wsValue); |
2088 } else { | 2074 } else { |
2089 int32_t iValue = validate.GetNullTest(); | 2075 int32_t iValue = validate.GetNullTest(); |
2090 const XFA_ATTRIBUTEENUMINFO* pInfo = | 2076 const XFA_ATTRIBUTEENUMINFO* pInfo = |
2091 XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue); | 2077 XFA_GetAttributeEnumByID((XFA_ATTRIBUTEENUM)iValue); |
2092 if (pInfo) { | 2078 if (pInfo) { |
2093 wsValue = pInfo->pName; | 2079 wsValue = pInfo->pName; |
2094 } | 2080 } |
2095 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsValue).AsStringC()); | 2081 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
2096 } | 2082 } |
2097 } | 2083 } |
2098 void CXFA_Node::Script_Som_MandatoryMessage(CFXJSE_Value* pValue, | 2084 void CXFA_Node::Script_Som_MandatoryMessage(CFXJSE_Value* pValue, |
2099 FX_BOOL bSetting, | 2085 FX_BOOL bSetting, |
2100 XFA_ATTRIBUTE eAttribute) { | 2086 XFA_ATTRIBUTE eAttribute) { |
2101 Script_Som_Message(pValue, bSetting, XFA_SOM_MandatoryMessage); | 2087 Script_Som_Message(pValue, bSetting, XFA_SOM_MandatoryMessage); |
2102 } | 2088 } |
2103 void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, | 2089 void CXFA_Node::Script_Field_ParentSubform(CFXJSE_Value* pValue, |
2104 FX_BOOL bSetting, | 2090 FX_BOOL bSetting, |
2105 XFA_ATTRIBUTE eAttribute) { | 2091 XFA_ATTRIBUTE eAttribute) { |
2106 if (bSetting) { | 2092 if (bSetting) { |
2107 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2093 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2108 } else { | 2094 } else { |
2109 FXJSE_Value_SetNull(pValue); | 2095 pValue->SetNull(); |
2110 } | 2096 } |
2111 } | 2097 } |
2112 void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, | 2098 void CXFA_Node::Script_Field_SelectedIndex(CFXJSE_Value* pValue, |
2113 FX_BOOL bSetting, | 2099 FX_BOOL bSetting, |
2114 XFA_ATTRIBUTE eAttribute) { | 2100 XFA_ATTRIBUTE eAttribute) { |
2115 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2101 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2116 if (!pWidgetData) { | 2102 if (!pWidgetData) { |
2117 return; | 2103 return; |
2118 } | 2104 } |
2119 if (bSetting) { | 2105 if (bSetting) { |
2120 int32_t iIndex = FXJSE_Value_ToInteger(pValue); | 2106 int32_t iIndex = pValue->ToInteger(); |
2121 if (iIndex == -1) { | 2107 if (iIndex == -1) { |
2122 pWidgetData->ClearAllSelections(); | 2108 pWidgetData->ClearAllSelections(); |
2123 return; | 2109 return; |
2124 } | 2110 } |
2125 pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE); | 2111 pWidgetData->SetItemState(iIndex, TRUE, true, TRUE, TRUE); |
2126 } else { | 2112 } else { |
2127 FXJSE_Value_SetInteger(pValue, pWidgetData->GetSelectedItem()); | 2113 pValue->SetInteger(pWidgetData->GetSelectedItem()); |
2128 } | 2114 } |
2129 } | 2115 } |
2130 void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { | 2116 void CXFA_Node::Script_Field_ClearItems(CFXJSE_Arguments* pArguments) { |
2131 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2117 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2132 if (!pWidgetData) { | 2118 if (!pWidgetData) { |
2133 return; | 2119 return; |
2134 } | 2120 } |
2135 pWidgetData->DeleteItem(-1, TRUE); | 2121 pWidgetData->DeleteItem(-1, TRUE); |
2136 } | 2122 } |
2137 void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { | 2123 void CXFA_Node::Script_Field_ExecEvent(CFXJSE_Arguments* pArguments) { |
2138 int32_t argc = pArguments->GetLength(); | 2124 int32_t argc = pArguments->GetLength(); |
2139 if (argc == 1) { | 2125 if (argc == 1) { |
2140 CFX_ByteString eventString = pArguments->GetUTF8String(0); | 2126 CFX_ByteString eventString = pArguments->GetUTF8String(0); |
2141 int32_t iRet = execSingleEventByName( | 2127 int32_t iRet = execSingleEventByName( |
2142 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), | 2128 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), |
2143 XFA_ELEMENT_Field); | 2129 XFA_ELEMENT_Field); |
2144 if (eventString == "validate") { | 2130 if (eventString == "validate") { |
2145 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), | 2131 pArguments->GetReturnValue()->SetBoolean( |
2146 ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); | 2132 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
2147 } | 2133 } |
2148 } else { | 2134 } else { |
2149 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); | 2135 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); |
2150 } | 2136 } |
2151 } | 2137 } |
2152 void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { | 2138 void CXFA_Node::Script_Field_ExecInitialize(CFXJSE_Arguments* pArguments) { |
2153 int32_t argc = pArguments->GetLength(); | 2139 int32_t argc = pArguments->GetLength(); |
2154 if (argc == 0) { | 2140 if (argc == 0) { |
2155 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 2141 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
2156 if (!pNotify) { | 2142 if (!pNotify) { |
(...skipping 10 matching lines...) Expand all Loading... |
2167 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem"); | 2153 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"deleteItem"); |
2168 return; | 2154 return; |
2169 } | 2155 } |
2170 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2156 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2171 if (!pWidgetData) { | 2157 if (!pWidgetData) { |
2172 return; | 2158 return; |
2173 } | 2159 } |
2174 int32_t iIndex = pArguments->GetInt32(0); | 2160 int32_t iIndex = pArguments->GetInt32(0); |
2175 FX_BOOL bValue = pWidgetData->DeleteItem(iIndex, TRUE, TRUE); | 2161 FX_BOOL bValue = pWidgetData->DeleteItem(iIndex, TRUE, TRUE); |
2176 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 2162 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
2177 if (pValue) { | 2163 if (pValue) |
2178 FXJSE_Value_SetBoolean(pValue, bValue); | 2164 pValue->SetBoolean(bValue); |
2179 } | |
2180 } | 2165 } |
2181 void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { | 2166 void CXFA_Node::Script_Field_GetSaveItem(CFXJSE_Arguments* pArguments) { |
2182 int32_t iLength = pArguments->GetLength(); | 2167 int32_t iLength = pArguments->GetLength(); |
2183 if (iLength != 1) { | 2168 if (iLength != 1) { |
2184 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem"); | 2169 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getSaveItem"); |
2185 return; | 2170 return; |
2186 } | 2171 } |
2187 int32_t iIndex = pArguments->GetInt32(0); | 2172 int32_t iIndex = pArguments->GetInt32(0); |
2188 if (iIndex < 0) { | 2173 if (iIndex < 0) { |
2189 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2174 pArguments->GetReturnValue()->SetNull(); |
2190 return; | 2175 return; |
2191 } | 2176 } |
2192 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2177 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2193 if (!pWidgetData) { | 2178 if (!pWidgetData) { |
2194 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2179 pArguments->GetReturnValue()->SetNull(); |
2195 return; | 2180 return; |
2196 } | 2181 } |
2197 CFX_WideString wsValue; | 2182 CFX_WideString wsValue; |
2198 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, TRUE); | 2183 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, TRUE); |
2199 if (bHasItem) { | 2184 if (bHasItem) { |
2200 FXJSE_Value_SetUTF8String( | 2185 pArguments->GetReturnValue()->SetString( |
2201 pArguments->GetReturnValue(), | |
2202 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); | 2186 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); |
2203 } else { | 2187 } else { |
2204 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2188 pArguments->GetReturnValue()->SetNull(); |
2205 } | 2189 } |
2206 } | 2190 } |
2207 void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { | 2191 void CXFA_Node::Script_Field_BoundItem(CFXJSE_Arguments* pArguments) { |
2208 int32_t iLength = pArguments->GetLength(); | 2192 int32_t iLength = pArguments->GetLength(); |
2209 if (iLength != 1) { | 2193 if (iLength != 1) { |
2210 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"boundItem"); | 2194 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"boundItem"); |
2211 return; | 2195 return; |
2212 } | 2196 } |
2213 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2197 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2214 if (!pWidgetData) { | 2198 if (!pWidgetData) { |
2215 return; | 2199 return; |
2216 } | 2200 } |
2217 CFX_ByteString bsValue = pArguments->GetUTF8String(0); | 2201 CFX_ByteString bsValue = pArguments->GetUTF8String(0); |
2218 CFX_WideString wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 2202 CFX_WideString wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
2219 CFX_WideString wsBoundValue; | 2203 CFX_WideString wsBoundValue; |
2220 pWidgetData->GetItemValue(wsValue.AsStringC(), wsBoundValue); | 2204 pWidgetData->GetItemValue(wsValue.AsStringC(), wsBoundValue); |
2221 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 2205 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
2222 if (pValue) { | 2206 if (pValue) |
2223 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsBoundValue).AsStringC()); | 2207 pValue->SetString(FX_UTF8Encode(wsBoundValue).AsStringC()); |
2224 } | |
2225 } | 2208 } |
2226 void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { | 2209 void CXFA_Node::Script_Field_GetItemState(CFXJSE_Arguments* pArguments) { |
2227 int32_t iLength = pArguments->GetLength(); | 2210 int32_t iLength = pArguments->GetLength(); |
2228 if (iLength != 1) { | 2211 if (iLength != 1) { |
2229 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getItemState"); | 2212 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getItemState"); |
2230 return; | 2213 return; |
2231 } | 2214 } |
2232 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2215 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2233 if (!pWidgetData) { | 2216 if (!pWidgetData) { |
2234 return; | 2217 return; |
2235 } | 2218 } |
2236 int32_t iIndex = pArguments->GetInt32(0); | 2219 int32_t iIndex = pArguments->GetInt32(0); |
2237 FX_BOOL bValue = pWidgetData->GetItemState(iIndex); | 2220 FX_BOOL bValue = pWidgetData->GetItemState(iIndex); |
2238 CFXJSE_Value* pValue = pArguments->GetReturnValue(); | 2221 CFXJSE_Value* pValue = pArguments->GetReturnValue(); |
2239 if (pValue) { | 2222 if (pValue) |
2240 FXJSE_Value_SetBoolean(pValue, bValue); | 2223 pValue->SetBoolean(bValue); |
2241 } | |
2242 } | 2224 } |
2243 void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { | 2225 void CXFA_Node::Script_Field_ExecCalculate(CFXJSE_Arguments* pArguments) { |
2244 int32_t argc = pArguments->GetLength(); | 2226 int32_t argc = pArguments->GetLength(); |
2245 if (argc == 0) { | 2227 if (argc == 0) { |
2246 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 2228 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
2247 if (!pNotify) { | 2229 if (!pNotify) { |
2248 return; | 2230 return; |
2249 } | 2231 } |
2250 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE); | 2232 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate, FALSE, FALSE); |
2251 } else { | 2233 } else { |
2252 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 2234 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
2253 } | 2235 } |
2254 } | 2236 } |
2255 void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} | 2237 void CXFA_Node::Script_Field_SetItems(CFXJSE_Arguments* pArguments) {} |
2256 void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { | 2238 void CXFA_Node::Script_Field_GetDisplayItem(CFXJSE_Arguments* pArguments) { |
2257 int32_t iLength = pArguments->GetLength(); | 2239 int32_t iLength = pArguments->GetLength(); |
2258 if (iLength != 1) { | 2240 if (iLength != 1) { |
2259 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getDisplayItem"); | 2241 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getDisplayItem"); |
2260 return; | 2242 return; |
2261 } | 2243 } |
2262 int32_t iIndex = pArguments->GetInt32(0); | 2244 int32_t iIndex = pArguments->GetInt32(0); |
2263 if (iIndex < 0) { | 2245 if (iIndex < 0) { |
2264 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2246 pArguments->GetReturnValue()->SetNull(); |
2265 return; | 2247 return; |
2266 } | 2248 } |
2267 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2249 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2268 if (!pWidgetData) { | 2250 if (!pWidgetData) { |
2269 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2251 pArguments->GetReturnValue()->SetNull(); |
2270 return; | 2252 return; |
2271 } | 2253 } |
2272 CFX_WideString wsValue; | 2254 CFX_WideString wsValue; |
2273 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, FALSE); | 2255 FX_BOOL bHasItem = pWidgetData->GetChoiceListItem(wsValue, iIndex, FALSE); |
2274 if (bHasItem) { | 2256 if (bHasItem) { |
2275 FXJSE_Value_SetUTF8String( | 2257 pArguments->GetReturnValue()->SetString( |
2276 pArguments->GetReturnValue(), | |
2277 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); | 2258 FX_UTF8Encode(wsValue.c_str(), wsValue.GetLength()).AsStringC()); |
2278 } else { | 2259 } else { |
2279 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2260 pArguments->GetReturnValue()->SetNull(); |
2280 } | 2261 } |
2281 } | 2262 } |
2282 void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { | 2263 void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { |
2283 int32_t iLength = pArguments->GetLength(); | 2264 int32_t iLength = pArguments->GetLength(); |
2284 if (iLength != 2) { | 2265 if (iLength != 2) { |
2285 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setItemState"); | 2266 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setItemState"); |
2286 return; | 2267 return; |
2287 } | 2268 } |
2288 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2269 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2289 if (!pWidgetData) | 2270 if (!pWidgetData) |
(...skipping 27 matching lines...) Expand all Loading... |
2317 CFX_ByteString bsValue = pArguments->GetUTF8String(1); | 2298 CFX_ByteString bsValue = pArguments->GetUTF8String(1); |
2318 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); | 2299 wsValue = CFX_WideString::FromUTF8(bsValue.AsStringC()); |
2319 } | 2300 } |
2320 pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE); | 2301 pWidgetData->InsertItem(wsLabel, wsValue, -1, TRUE); |
2321 } | 2302 } |
2322 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { | 2303 void CXFA_Node::Script_Field_ExecValidate(CFXJSE_Arguments* pArguments) { |
2323 int32_t argc = pArguments->GetLength(); | 2304 int32_t argc = pArguments->GetLength(); |
2324 if (argc == 0) { | 2305 if (argc == 0) { |
2325 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 2306 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
2326 if (!pNotify) { | 2307 if (!pNotify) { |
2327 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 2308 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2328 } else { | 2309 } else { |
2329 int32_t iRet = | 2310 int32_t iRet = |
2330 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE); | 2311 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate, FALSE, FALSE); |
2331 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), | 2312 pArguments->GetReturnValue()->SetBoolean( |
2332 ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); | 2313 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
2333 } | 2314 } |
2334 } else { | 2315 } else { |
2335 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 2316 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
2336 } | 2317 } |
2337 } | 2318 } |
2338 void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, | 2319 void CXFA_Node::Script_ExclGroup_ErrorText(CFXJSE_Value* pValue, |
2339 FX_BOOL bSetting, | 2320 FX_BOOL bSetting, |
2340 XFA_ATTRIBUTE eAttribute) { | 2321 XFA_ATTRIBUTE eAttribute) { |
2341 if (!bSetting) { | 2322 if (!bSetting) { |
2342 } else { | 2323 } else { |
2343 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2324 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2344 } | 2325 } |
2345 } | 2326 } |
2346 void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, | 2327 void CXFA_Node::Script_ExclGroup_DefaultAndRawValue(CFXJSE_Value* pValue, |
2347 FX_BOOL bSetting, | 2328 FX_BOOL bSetting, |
2348 XFA_ATTRIBUTE eAttribute) { | 2329 XFA_ATTRIBUTE eAttribute) { |
2349 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2330 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2350 if (!pWidgetData) { | 2331 if (!pWidgetData) { |
2351 return; | 2332 return; |
2352 } | 2333 } |
2353 if (bSetting) { | 2334 if (bSetting) { |
2354 CFX_ByteString bsValue; | 2335 CFX_ByteString bsValue; |
2355 FXJSE_Value_ToUTF8String(pValue, bsValue); | 2336 pValue->ToString(bsValue); |
2356 pWidgetData->SetSelectedMemberByValue( | 2337 pWidgetData->SetSelectedMemberByValue( |
2357 CFX_WideString::FromUTF8(bsValue.AsStringC()).AsStringC(), true, TRUE, | 2338 CFX_WideString::FromUTF8(bsValue.AsStringC()).AsStringC(), true, TRUE, |
2358 TRUE); | 2339 TRUE); |
2359 } else { | 2340 } else { |
2360 CFX_WideString wsValue = GetScriptContent(TRUE); | 2341 CFX_WideString wsValue = GetScriptContent(TRUE); |
2361 XFA_VERSION curVersion = GetDocument()->GetCurVersionMode(); | 2342 XFA_VERSION curVersion = GetDocument()->GetCurVersionMode(); |
2362 if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { | 2343 if (wsValue.IsEmpty() && curVersion >= XFA_VERSION_300) { |
2363 FXJSE_Value_SetNull(pValue); | 2344 pValue->SetNull(); |
2364 } else { | 2345 } else { |
2365 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(wsValue).AsStringC()); | 2346 pValue->SetString(FX_UTF8Encode(wsValue).AsStringC()); |
2366 } | 2347 } |
2367 } | 2348 } |
2368 } | 2349 } |
2369 void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue, | 2350 void CXFA_Node::Script_ExclGroup_Transient(CFXJSE_Value* pValue, |
2370 FX_BOOL bSetting, | 2351 FX_BOOL bSetting, |
2371 XFA_ATTRIBUTE eAttribute) {} | 2352 XFA_ATTRIBUTE eAttribute) {} |
2372 void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { | 2353 void CXFA_Node::Script_ExclGroup_ExecEvent(CFXJSE_Arguments* pArguments) { |
2373 int32_t argc = pArguments->GetLength(); | 2354 int32_t argc = pArguments->GetLength(); |
2374 if (argc == 1) { | 2355 if (argc == 1) { |
2375 CFX_ByteString eventString = pArguments->GetUTF8String(0); | 2356 CFX_ByteString eventString = pArguments->GetUTF8String(0); |
2376 execSingleEventByName( | 2357 execSingleEventByName( |
2377 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), | 2358 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), |
2378 XFA_ELEMENT_ExclGroup); | 2359 XFA_ELEMENT_ExclGroup); |
2379 } else { | 2360 } else { |
2380 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); | 2361 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execEvent"); |
2381 } | 2362 } |
2382 } | 2363 } |
2383 | 2364 |
2384 void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) { | 2365 void CXFA_Node::Script_ExclGroup_SelectedMember(CFXJSE_Arguments* pArguments) { |
2385 int32_t argc = pArguments->GetLength(); | 2366 int32_t argc = pArguments->GetLength(); |
2386 if (argc < 0 || argc > 1) { | 2367 if (argc < 0 || argc > 1) { |
2387 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"selectedMember"); | 2368 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"selectedMember"); |
2388 return; | 2369 return; |
2389 } | 2370 } |
2390 | 2371 |
2391 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2372 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2392 if (!pWidgetData) { | 2373 if (!pWidgetData) { |
2393 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2374 pArguments->GetReturnValue()->SetNull(); |
2394 return; | 2375 return; |
2395 } | 2376 } |
2396 | 2377 |
2397 CXFA_Node* pReturnNode = nullptr; | 2378 CXFA_Node* pReturnNode = nullptr; |
2398 if (argc == 0) { | 2379 if (argc == 0) { |
2399 pReturnNode = pWidgetData->GetSelectedMember(); | 2380 pReturnNode = pWidgetData->GetSelectedMember(); |
2400 } else { | 2381 } else { |
2401 CFX_ByteString szName; | 2382 CFX_ByteString szName; |
2402 szName = pArguments->GetUTF8String(0); | 2383 szName = pArguments->GetUTF8String(0); |
2403 pReturnNode = pWidgetData->SetSelectedMember( | 2384 pReturnNode = pWidgetData->SetSelectedMember( |
2404 CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC(), true); | 2385 CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC(), true); |
2405 } | 2386 } |
2406 if (!pReturnNode) { | 2387 if (!pReturnNode) { |
2407 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2388 pArguments->GetReturnValue()->SetNull(); |
2408 return; | 2389 return; |
2409 } | 2390 } |
2410 FXJSE_Value_Set( | 2391 pArguments->GetReturnValue()->Assign( |
2411 pArguments->GetReturnValue(), | |
2412 m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode)); | 2392 m_pDocument->GetScriptContext()->GetJSValueFromMap(pReturnNode)); |
2413 } | 2393 } |
2414 | 2394 |
2415 void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) { | 2395 void CXFA_Node::Script_ExclGroup_ExecInitialize(CFXJSE_Arguments* pArguments) { |
2416 int32_t argc = pArguments->GetLength(); | 2396 int32_t argc = pArguments->GetLength(); |
2417 if (argc == 0) { | 2397 if (argc == 0) { |
2418 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 2398 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
2419 if (!pNotify) { | 2399 if (!pNotify) { |
2420 return; | 2400 return; |
2421 } | 2401 } |
(...skipping 12 matching lines...) Expand all Loading... |
2434 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); | 2414 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); |
2435 } else { | 2415 } else { |
2436 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 2416 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
2437 } | 2417 } |
2438 } | 2418 } |
2439 void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { | 2419 void CXFA_Node::Script_ExclGroup_ExecValidate(CFXJSE_Arguments* pArguments) { |
2440 int32_t argc = pArguments->GetLength(); | 2420 int32_t argc = pArguments->GetLength(); |
2441 if (argc == 0) { | 2421 if (argc == 0) { |
2442 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 2422 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
2443 if (!pNotify) { | 2423 if (!pNotify) { |
2444 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 2424 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2445 } else { | 2425 } else { |
2446 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); | 2426 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); |
2447 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), | 2427 pArguments->GetReturnValue()->SetBoolean( |
2448 ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); | 2428 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
2449 } | 2429 } |
2450 } else { | 2430 } else { |
2451 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 2431 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
2452 } | 2432 } |
2453 } | 2433 } |
2454 static CXFA_Node* XFA_ScriptInstanceManager_GetItem(CXFA_Node* pInstMgrNode, | 2434 static CXFA_Node* XFA_ScriptInstanceManager_GetItem(CXFA_Node* pInstMgrNode, |
2455 int32_t iIndex) { | 2435 int32_t iIndex) { |
2456 ASSERT(pInstMgrNode); | 2436 ASSERT(pInstMgrNode); |
2457 int32_t iCount = 0; | 2437 int32_t iCount = 0; |
2458 uint32_t dwNameHash = 0; | 2438 uint32_t dwNameHash = 0; |
(...skipping 23 matching lines...) Expand all Loading... |
2482 if (iCount > iIndex) { | 2462 if (iCount > iIndex) { |
2483 return pNode; | 2463 return pNode; |
2484 } | 2464 } |
2485 } | 2465 } |
2486 return nullptr; | 2466 return nullptr; |
2487 } | 2467 } |
2488 void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, | 2468 void CXFA_Node::Script_Som_InstanceIndex(CFXJSE_Value* pValue, |
2489 FX_BOOL bSetting, | 2469 FX_BOOL bSetting, |
2490 XFA_ATTRIBUTE eAttribute) { | 2470 XFA_ATTRIBUTE eAttribute) { |
2491 if (bSetting) { | 2471 if (bSetting) { |
2492 int32_t iTo = FXJSE_Value_ToInteger(pValue); | 2472 int32_t iTo = pValue->ToInteger(); |
2493 int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); | 2473 int32_t iFrom = Subform_and_SubformSet_InstanceIndex(); |
2494 CXFA_Node* pManagerNode = nullptr; | 2474 CXFA_Node* pManagerNode = nullptr; |
2495 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 2475 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
2496 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 2476 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
2497 if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { | 2477 if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { |
2498 pManagerNode = pNode; | 2478 pManagerNode = pNode; |
2499 break; | 2479 break; |
2500 } | 2480 } |
2501 } | 2481 } |
2502 if (pManagerNode) { | 2482 if (pManagerNode) { |
2503 pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); | 2483 pManagerNode->InstanceManager_MoveInstance(iTo, iFrom); |
2504 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 2484 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
2505 if (!pNotify) { | 2485 if (!pNotify) { |
2506 return; | 2486 return; |
2507 } | 2487 } |
2508 CXFA_Node* pToInstance = | 2488 CXFA_Node* pToInstance = |
2509 XFA_ScriptInstanceManager_GetItem(pManagerNode, iTo); | 2489 XFA_ScriptInstanceManager_GetItem(pManagerNode, iTo); |
2510 if (pToInstance && pToInstance->GetClassID() == XFA_ELEMENT_Subform) { | 2490 if (pToInstance && pToInstance->GetClassID() == XFA_ELEMENT_Subform) { |
2511 pNotify->RunSubformIndexChange(pToInstance); | 2491 pNotify->RunSubformIndexChange(pToInstance); |
2512 } | 2492 } |
2513 CXFA_Node* pFromInstance = | 2493 CXFA_Node* pFromInstance = |
2514 XFA_ScriptInstanceManager_GetItem(pManagerNode, iFrom); | 2494 XFA_ScriptInstanceManager_GetItem(pManagerNode, iFrom); |
2515 if (pFromInstance && pFromInstance->GetClassID() == XFA_ELEMENT_Subform) { | 2495 if (pFromInstance && pFromInstance->GetClassID() == XFA_ELEMENT_Subform) { |
2516 pNotify->RunSubformIndexChange(pFromInstance); | 2496 pNotify->RunSubformIndexChange(pFromInstance); |
2517 } | 2497 } |
2518 } | 2498 } |
2519 } else { | 2499 } else { |
2520 FXJSE_Value_SetInteger(pValue, Subform_and_SubformSet_InstanceIndex()); | 2500 pValue->SetInteger(Subform_and_SubformSet_InstanceIndex()); |
2521 } | 2501 } |
2522 } | 2502 } |
2523 void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, | 2503 void CXFA_Node::Script_Subform_InstanceManager(CFXJSE_Value* pValue, |
2524 FX_BOOL bSetting, | 2504 FX_BOOL bSetting, |
2525 XFA_ATTRIBUTE eAttribute) { | 2505 XFA_ATTRIBUTE eAttribute) { |
2526 if (!bSetting) { | 2506 if (!bSetting) { |
2527 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); | 2507 CFX_WideStringC wsName = GetCData(XFA_ATTRIBUTE_Name); |
2528 CXFA_Node* pInstanceMgr = nullptr; | 2508 CXFA_Node* pInstanceMgr = nullptr; |
2529 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 2509 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
2530 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 2510 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
2531 if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { | 2511 if (pNode->GetClassID() == XFA_ELEMENT_InstanceManager) { |
2532 CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); | 2512 CFX_WideStringC wsInstMgrName = pNode->GetCData(XFA_ATTRIBUTE_Name); |
2533 if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && | 2513 if (wsInstMgrName.GetLength() >= 1 && wsInstMgrName.GetAt(0) == '_' && |
2534 wsInstMgrName.Mid(1) == wsName) { | 2514 wsInstMgrName.Mid(1) == wsName) { |
2535 pInstanceMgr = pNode; | 2515 pInstanceMgr = pNode; |
2536 } | 2516 } |
2537 break; | 2517 break; |
2538 } | 2518 } |
2539 } | 2519 } |
2540 if (pInstanceMgr) { | 2520 if (pInstanceMgr) { |
2541 FXJSE_Value_Set( | 2521 pValue->Assign( |
2542 pValue, | |
2543 m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); | 2522 m_pDocument->GetScriptContext()->GetJSValueFromMap(pInstanceMgr)); |
2544 } else { | 2523 } else { |
2545 FXJSE_Value_SetNull(pValue); | 2524 pValue->SetNull(); |
2546 } | 2525 } |
2547 } else { | 2526 } else { |
2548 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2527 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2549 } | 2528 } |
2550 } | 2529 } |
2551 void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue, | 2530 void CXFA_Node::Script_Subform_Locale(CFXJSE_Value* pValue, |
2552 FX_BOOL bSetting, | 2531 FX_BOOL bSetting, |
2553 XFA_ATTRIBUTE eAttribute) { | 2532 XFA_ATTRIBUTE eAttribute) { |
2554 if (bSetting) { | 2533 if (bSetting) { |
2555 CFX_ByteString bsLocaleName; | 2534 CFX_ByteString bsLocaleName; |
2556 FXJSE_Value_ToUTF8String(pValue, bsLocaleName); | 2535 pValue->ToString(bsLocaleName); |
2557 SetCData(XFA_ATTRIBUTE_Locale, | 2536 SetCData(XFA_ATTRIBUTE_Locale, |
2558 CFX_WideString::FromUTF8(bsLocaleName.AsStringC()), true, TRUE); | 2537 CFX_WideString::FromUTF8(bsLocaleName.AsStringC()), true, TRUE); |
2559 } else { | 2538 } else { |
2560 CFX_WideString wsLocaleName; | 2539 CFX_WideString wsLocaleName; |
2561 GetLocaleName(wsLocaleName); | 2540 GetLocaleName(wsLocaleName); |
2562 FXJSE_Value_SetUTF8String( | 2541 pValue->SetString( |
2563 pValue, FX_UTF8Encode(wsLocaleName.c_str(), wsLocaleName.GetLength()) | 2542 FX_UTF8Encode(wsLocaleName.c_str(), wsLocaleName.GetLength()) |
2564 .AsStringC()); | 2543 .AsStringC()); |
2565 } | 2544 } |
2566 } | 2545 } |
2567 void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { | 2546 void CXFA_Node::Script_Subform_ExecEvent(CFXJSE_Arguments* pArguments) { |
2568 int32_t argc = pArguments->GetLength(); | 2547 int32_t argc = pArguments->GetLength(); |
2569 if (argc == 1) { | 2548 if (argc == 1) { |
2570 CFX_ByteString eventString = pArguments->GetUTF8String(0); | 2549 CFX_ByteString eventString = pArguments->GetUTF8String(0); |
2571 execSingleEventByName( | 2550 execSingleEventByName( |
2572 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), | 2551 CFX_WideString::FromUTF8(eventString.AsStringC()).AsStringC(), |
2573 XFA_ELEMENT_Subform); | 2552 XFA_ELEMENT_Subform); |
2574 } else { | 2553 } else { |
(...skipping 22 matching lines...) Expand all Loading... |
2597 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); | 2576 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); |
2598 } else { | 2577 } else { |
2599 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 2578 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
2600 } | 2579 } |
2601 } | 2580 } |
2602 void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { | 2581 void CXFA_Node::Script_Subform_ExecValidate(CFXJSE_Arguments* pArguments) { |
2603 int32_t argc = pArguments->GetLength(); | 2582 int32_t argc = pArguments->GetLength(); |
2604 if (argc == 0) { | 2583 if (argc == 0) { |
2605 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 2584 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
2606 if (!pNotify) { | 2585 if (!pNotify) { |
2607 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 2586 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2608 } else { | 2587 } else { |
2609 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); | 2588 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); |
2610 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), | 2589 pArguments->GetReturnValue()->SetBoolean( |
2611 ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); | 2590 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
2612 } | 2591 } |
2613 } else { | 2592 } else { |
2614 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 2593 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
2615 } | 2594 } |
2616 } | 2595 } |
2617 void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { | 2596 void CXFA_Node::Script_Subform_GetInvalidObjects(CFXJSE_Arguments* pArguments) { |
2618 int32_t argc = pArguments->GetLength(); | 2597 int32_t argc = pArguments->GetLength(); |
2619 if (argc == 0) { | 2598 if (argc == 0) { |
2620 } else { | 2599 } else { |
2621 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getInvalidObjects"); | 2600 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getInvalidObjects"); |
2622 } | 2601 } |
2623 } | 2602 } |
2624 int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() { | 2603 int32_t CXFA_Node::Subform_and_SubformSet_InstanceIndex() { |
2625 int32_t index = 0; | 2604 int32_t index = 0; |
2626 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; | 2605 for (CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_PrevSibling); pNode; |
2627 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { | 2606 pNode = pNode->GetNodeItem(XFA_NODEITEM_PrevSibling)) { |
2628 if ((pNode->GetClassID() == XFA_ELEMENT_Subform) || | 2607 if ((pNode->GetClassID() == XFA_ELEMENT_Subform) || |
2629 (pNode->GetClassID() == XFA_ELEMENT_SubformSet)) { | 2608 (pNode->GetClassID() == XFA_ELEMENT_SubformSet)) { |
2630 index++; | 2609 index++; |
2631 } else { | 2610 } else { |
2632 break; | 2611 break; |
2633 } | 2612 } |
2634 } | 2613 } |
2635 return index; | 2614 return index; |
2636 } | 2615 } |
2637 void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { | 2616 void CXFA_Node::Script_Template_FormNodes(CFXJSE_Arguments* pArguments) { |
2638 int32_t argc = pArguments->GetLength(); | 2617 int32_t argc = pArguments->GetLength(); |
2639 if (argc == 1) { | 2618 if (argc == 1) { |
2640 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); | 2619 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2641 } else { | 2620 } else { |
2642 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); | 2621 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); |
2643 } | 2622 } |
2644 } | 2623 } |
2645 void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { | 2624 void CXFA_Node::Script_Template_Remerge(CFXJSE_Arguments* pArguments) { |
2646 int32_t argc = pArguments->GetLength(); | 2625 int32_t argc = pArguments->GetLength(); |
2647 if (argc == 0) { | 2626 if (argc == 0) { |
2648 m_pDocument->DoDataRemerge(TRUE); | 2627 m_pDocument->DoDataRemerge(TRUE); |
2649 } else { | 2628 } else { |
2650 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); | 2629 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remerge"); |
2651 } | 2630 } |
2652 } | 2631 } |
2653 void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { | 2632 void CXFA_Node::Script_Template_ExecInitialize(CFXJSE_Arguments* pArguments) { |
2654 int32_t argc = pArguments->GetLength(); | 2633 int32_t argc = pArguments->GetLength(); |
2655 if (argc == 0) { | 2634 if (argc == 0) { |
2656 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2635 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2657 if (!pWidgetData) { | 2636 if (!pWidgetData) { |
2658 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 2637 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2659 } else { | 2638 } else { |
2660 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); | 2639 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2661 } | 2640 } |
2662 } else { | 2641 } else { |
2663 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); | 2642 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execInitialize"); |
2664 } | 2643 } |
2665 } | 2644 } |
2666 void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { | 2645 void CXFA_Node::Script_Template_CreateNode(CFXJSE_Arguments* pArguments) { |
2667 int32_t argc = pArguments->GetLength(); | 2646 int32_t argc = pArguments->GetLength(); |
2668 if ((argc > 0) && (argc < 4)) { | 2647 if ((argc > 0) && (argc < 4)) { |
2669 CFX_WideString strTagName; | 2648 CFX_WideString strTagName; |
2670 CFX_WideString strName; | 2649 CFX_WideString strName; |
2671 CFX_WideString strNameSpace; | 2650 CFX_WideString strNameSpace; |
2672 CFX_ByteString bsTagName = pArguments->GetUTF8String(0); | 2651 CFX_ByteString bsTagName = pArguments->GetUTF8String(0); |
2673 strTagName = CFX_WideString::FromUTF8(bsTagName.AsStringC()); | 2652 strTagName = CFX_WideString::FromUTF8(bsTagName.AsStringC()); |
2674 if (argc > 1) { | 2653 if (argc > 1) { |
2675 CFX_ByteString bsName = pArguments->GetUTF8String(1); | 2654 CFX_ByteString bsName = pArguments->GetUTF8String(1); |
2676 strName = CFX_WideString::FromUTF8(bsName.AsStringC()); | 2655 strName = CFX_WideString::FromUTF8(bsName.AsStringC()); |
2677 if (argc == 3) { | 2656 if (argc == 3) { |
2678 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2); | 2657 CFX_ByteString bsNameSpace = pArguments->GetUTF8String(2); |
2679 strNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC()); | 2658 strNameSpace = CFX_WideString::FromUTF8(bsNameSpace.AsStringC()); |
2680 } | 2659 } |
2681 } | 2660 } |
2682 const XFA_ELEMENTINFO* pElement = | 2661 const XFA_ELEMENTINFO* pElement = |
2683 XFA_GetElementByName(strTagName.AsStringC()); | 2662 XFA_GetElementByName(strTagName.AsStringC()); |
2684 CXFA_Node* pNewNode = CreateSamePacketNode(pElement->eName); | 2663 CXFA_Node* pNewNode = CreateSamePacketNode(pElement->eName); |
2685 if (!pNewNode) { | 2664 if (!pNewNode) { |
2686 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 2665 pArguments->GetReturnValue()->SetNull(); |
2687 } else { | 2666 } else { |
2688 if (!strName.IsEmpty()) { | 2667 if (!strName.IsEmpty()) { |
2689 if (XFA_GetAttributeOfElement(pElement->eName, XFA_ATTRIBUTE_Name, | 2668 if (XFA_GetAttributeOfElement(pElement->eName, XFA_ATTRIBUTE_Name, |
2690 XFA_XDPPACKET_UNKNOWN)) { | 2669 XFA_XDPPACKET_UNKNOWN)) { |
2691 pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName.AsStringC(), true); | 2670 pNewNode->SetAttribute(XFA_ATTRIBUTE_Name, strName.AsStringC(), true); |
2692 if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) { | 2671 if (pNewNode->GetPacketID() == XFA_XDPPACKET_Datasets) { |
2693 pNewNode->CreateXMLMappingNode(); | 2672 pNewNode->CreateXMLMappingNode(); |
2694 } | 2673 } |
2695 FXJSE_Value_Set( | 2674 pArguments->GetReturnValue()->Assign( |
2696 pArguments->GetReturnValue(), | |
2697 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); | 2675 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); |
2698 } else { | 2676 } else { |
2699 ThrowException(XFA_IDS_NOT_HAVE_PROPERTY, strTagName.c_str(), | 2677 ThrowException(XFA_IDS_NOT_HAVE_PROPERTY, strTagName.c_str(), |
2700 L"name"); | 2678 L"name"); |
2701 } | 2679 } |
2702 } else { | 2680 } else { |
2703 FXJSE_Value_Set( | 2681 pArguments->GetReturnValue()->Assign( |
2704 pArguments->GetReturnValue(), | |
2705 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); | 2682 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewNode)); |
2706 } | 2683 } |
2707 } | 2684 } |
2708 } else { | 2685 } else { |
2709 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode"); | 2686 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"createNode"); |
2710 } | 2687 } |
2711 } | 2688 } |
2712 void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { | 2689 void CXFA_Node::Script_Template_Recalculate(CFXJSE_Arguments* pArguments) { |
2713 if (pArguments->GetLength() == 1) { | 2690 if (pArguments->GetLength() == 1) { |
2714 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); | 2691 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2715 } else { | 2692 } else { |
2716 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); | 2693 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"recalculate"); |
2717 } | 2694 } |
2718 } | 2695 } |
2719 void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { | 2696 void CXFA_Node::Script_Template_ExecCalculate(CFXJSE_Arguments* pArguments) { |
2720 int32_t argc = pArguments->GetLength(); | 2697 int32_t argc = pArguments->GetLength(); |
2721 if (argc == 0) { | 2698 if (argc == 0) { |
2722 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2699 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2723 if (!pWidgetData) { | 2700 if (!pWidgetData) { |
2724 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 2701 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2725 } else { | 2702 } else { |
2726 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); | 2703 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2727 } | 2704 } |
2728 } else { | 2705 } else { |
2729 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 2706 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
2730 } | 2707 } |
2731 } | 2708 } |
2732 void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { | 2709 void CXFA_Node::Script_Template_ExecValidate(CFXJSE_Arguments* pArguments) { |
2733 int32_t argc = pArguments->GetLength(); | 2710 int32_t argc = pArguments->GetLength(); |
2734 if (argc == 0) { | 2711 if (argc == 0) { |
2735 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2712 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2736 if (!pWidgetData) { | 2713 if (!pWidgetData) { |
2737 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 2714 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2738 } else { | 2715 } else { |
2739 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); | 2716 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2740 } | 2717 } |
2741 } else { | 2718 } else { |
2742 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 2719 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
2743 } | 2720 } |
2744 } | 2721 } |
2745 void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { | 2722 void CXFA_Node::Script_Manifest_Evaluate(CFXJSE_Arguments* pArguments) { |
2746 int32_t argc = pArguments->GetLength(); | 2723 int32_t argc = pArguments->GetLength(); |
2747 if (argc == 0) { | 2724 if (argc == 0) { |
2748 CXFA_WidgetData* pWidgetData = GetWidgetData(); | 2725 CXFA_WidgetData* pWidgetData = GetWidgetData(); |
2749 if (!pWidgetData) { | 2726 if (!pWidgetData) { |
2750 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 2727 pArguments->GetReturnValue()->SetBoolean(FALSE); |
2751 } else { | 2728 } else { |
2752 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), TRUE); | 2729 pArguments->GetReturnValue()->SetBoolean(TRUE); |
2753 } | 2730 } |
2754 } else { | 2731 } else { |
2755 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate"); | 2732 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"evaluate"); |
2756 } | 2733 } |
2757 } | 2734 } |
2758 void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue, | 2735 void CXFA_Node::Script_InstanceManager_Max(CFXJSE_Value* pValue, |
2759 FX_BOOL bSetting, | 2736 FX_BOOL bSetting, |
2760 XFA_ATTRIBUTE eAttribute) { | 2737 XFA_ATTRIBUTE eAttribute) { |
2761 if (bSetting) { | 2738 if (bSetting) { |
2762 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2739 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2763 return; | 2740 return; |
2764 } | 2741 } |
2765 CXFA_Occur nodeOccur(GetOccurNode()); | 2742 CXFA_Occur nodeOccur(GetOccurNode()); |
2766 FXJSE_Value_SetInteger(pValue, nodeOccur.GetMax()); | 2743 pValue->SetInteger(nodeOccur.GetMax()); |
2767 } | 2744 } |
2768 void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue, | 2745 void CXFA_Node::Script_InstanceManager_Min(CFXJSE_Value* pValue, |
2769 FX_BOOL bSetting, | 2746 FX_BOOL bSetting, |
2770 XFA_ATTRIBUTE eAttribute) { | 2747 XFA_ATTRIBUTE eAttribute) { |
2771 if (bSetting) { | 2748 if (bSetting) { |
2772 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 2749 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
2773 return; | 2750 return; |
2774 } | 2751 } |
2775 CXFA_Occur nodeOccur(GetOccurNode()); | 2752 CXFA_Occur nodeOccur(GetOccurNode()); |
2776 FXJSE_Value_SetInteger(pValue, nodeOccur.GetMin()); | 2753 pValue->SetInteger(nodeOccur.GetMin()); |
2777 } | 2754 } |
2778 static int32_t XFA_ScriptInstanceManager_GetCount(CXFA_Node* pInstMgrNode) { | 2755 static int32_t XFA_ScriptInstanceManager_GetCount(CXFA_Node* pInstMgrNode) { |
2779 ASSERT(pInstMgrNode); | 2756 ASSERT(pInstMgrNode); |
2780 int32_t iCount = 0; | 2757 int32_t iCount = 0; |
2781 uint32_t dwNameHash = 0; | 2758 uint32_t dwNameHash = 0; |
2782 for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); | 2759 for (CXFA_Node* pNode = pInstMgrNode->GetNodeItem(XFA_NODEITEM_NextSibling); |
2783 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { | 2760 pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { |
2784 XFA_ELEMENT eCurType = pNode->GetClassID(); | 2761 XFA_ELEMENT eCurType = pNode->GetClassID(); |
2785 if (eCurType == XFA_ELEMENT_InstanceManager) { | 2762 if (eCurType == XFA_ELEMENT_InstanceManager) { |
2786 break; | 2763 break; |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3045 if (pInstance) { | 3022 if (pInstance) { |
3046 pDocument->DataMerge_UpdateBindingRelations(pInstance); | 3023 pDocument->DataMerge_UpdateBindingRelations(pInstance); |
3047 pFormParent->RemoveChild(pInstance); | 3024 pFormParent->RemoveChild(pInstance); |
3048 } | 3025 } |
3049 return pInstance; | 3026 return pInstance; |
3050 } | 3027 } |
3051 void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue, | 3028 void CXFA_Node::Script_InstanceManager_Count(CFXJSE_Value* pValue, |
3052 FX_BOOL bSetting, | 3029 FX_BOOL bSetting, |
3053 XFA_ATTRIBUTE eAttribute) { | 3030 XFA_ATTRIBUTE eAttribute) { |
3054 if (bSetting) { | 3031 if (bSetting) { |
3055 int32_t iDesired = FXJSE_Value_ToInteger(pValue); | 3032 int32_t iDesired = pValue->ToInteger(); |
3056 InstanceManager_SetInstances(iDesired); | 3033 InstanceManager_SetInstances(iDesired); |
3057 } else { | 3034 } else { |
3058 FXJSE_Value_SetInteger(pValue, XFA_ScriptInstanceManager_GetCount(this)); | 3035 pValue->SetInteger(XFA_ScriptInstanceManager_GetCount(this)); |
3059 } | 3036 } |
3060 } | 3037 } |
3061 void CXFA_Node::Script_InstanceManager_MoveInstance( | 3038 void CXFA_Node::Script_InstanceManager_MoveInstance( |
3062 CFXJSE_Arguments* pArguments) { | 3039 CFXJSE_Arguments* pArguments) { |
3063 int32_t argc = pArguments->GetLength(); | 3040 int32_t argc = pArguments->GetLength(); |
3064 if (argc != 2) { | 3041 if (argc != 2) { |
3065 FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); | 3042 pArguments->GetReturnValue()->SetUndefined(); |
3066 return; | 3043 return; |
3067 } | 3044 } |
3068 int32_t iFrom = pArguments->GetInt32(0); | 3045 int32_t iFrom = pArguments->GetInt32(0); |
3069 int32_t iTo = pArguments->GetInt32(1); | 3046 int32_t iTo = pArguments->GetInt32(1); |
3070 InstanceManager_MoveInstance(iTo, iFrom); | 3047 InstanceManager_MoveInstance(iTo, iFrom); |
3071 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 3048 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
3072 if (!pNotify) { | 3049 if (!pNotify) { |
3073 return; | 3050 return; |
3074 } | 3051 } |
3075 CXFA_Node* pToInstance = XFA_ScriptInstanceManager_GetItem(this, iTo); | 3052 CXFA_Node* pToInstance = XFA_ScriptInstanceManager_GetItem(this, iTo); |
3076 if (pToInstance && pToInstance->GetClassID() == XFA_ELEMENT_Subform) { | 3053 if (pToInstance && pToInstance->GetClassID() == XFA_ELEMENT_Subform) { |
3077 pNotify->RunSubformIndexChange(pToInstance); | 3054 pNotify->RunSubformIndexChange(pToInstance); |
3078 } | 3055 } |
3079 CXFA_Node* pFromInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); | 3056 CXFA_Node* pFromInstance = XFA_ScriptInstanceManager_GetItem(this, iFrom); |
3080 if (pFromInstance && pFromInstance->GetClassID() == XFA_ELEMENT_Subform) { | 3057 if (pFromInstance && pFromInstance->GetClassID() == XFA_ELEMENT_Subform) { |
3081 pNotify->RunSubformIndexChange(pFromInstance); | 3058 pNotify->RunSubformIndexChange(pFromInstance); |
3082 } | 3059 } |
3083 } | 3060 } |
3084 void CXFA_Node::Script_InstanceManager_RemoveInstance( | 3061 void CXFA_Node::Script_InstanceManager_RemoveInstance( |
3085 CFXJSE_Arguments* pArguments) { | 3062 CFXJSE_Arguments* pArguments) { |
3086 int32_t argc = pArguments->GetLength(); | 3063 int32_t argc = pArguments->GetLength(); |
3087 if (argc != 1) { | 3064 if (argc != 1) { |
3088 FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); | 3065 pArguments->GetReturnValue()->SetUndefined(); |
3089 return; | 3066 return; |
3090 } | 3067 } |
3091 int32_t iIndex = pArguments->GetInt32(0); | 3068 int32_t iIndex = pArguments->GetInt32(0); |
3092 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); | 3069 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); |
3093 if (iIndex < 0 || iIndex >= iCount) { | 3070 if (iIndex < 0 || iIndex >= iCount) { |
3094 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); | 3071 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); |
3095 return; | 3072 return; |
3096 } | 3073 } |
3097 CXFA_Occur nodeOccur(GetOccurNode()); | 3074 CXFA_Occur nodeOccur(GetOccurNode()); |
3098 int32_t iMin = nodeOccur.GetMin(); | 3075 int32_t iMin = nodeOccur.GetMin(); |
(...skipping 17 matching lines...) Expand all Loading... |
3116 if (!pLayoutPro) { | 3093 if (!pLayoutPro) { |
3117 return; | 3094 return; |
3118 } | 3095 } |
3119 pLayoutPro->AddChangedContainer( | 3096 pLayoutPro->AddChangedContainer( |
3120 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); | 3097 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); |
3121 } | 3098 } |
3122 void CXFA_Node::Script_InstanceManager_SetInstances( | 3099 void CXFA_Node::Script_InstanceManager_SetInstances( |
3123 CFXJSE_Arguments* pArguments) { | 3100 CFXJSE_Arguments* pArguments) { |
3124 int32_t argc = pArguments->GetLength(); | 3101 int32_t argc = pArguments->GetLength(); |
3125 if (argc != 1) { | 3102 if (argc != 1) { |
3126 FXJSE_Value_SetUndefined(pArguments->GetReturnValue()); | 3103 pArguments->GetReturnValue()->SetUndefined(); |
3127 return; | 3104 return; |
3128 } | 3105 } |
3129 int32_t iDesired = pArguments->GetInt32(0); | 3106 int32_t iDesired = pArguments->GetInt32(0); |
3130 InstanceManager_SetInstances(iDesired); | 3107 InstanceManager_SetInstances(iDesired); |
3131 } | 3108 } |
3132 void CXFA_Node::Script_InstanceManager_AddInstance( | 3109 void CXFA_Node::Script_InstanceManager_AddInstance( |
3133 CFXJSE_Arguments* pArguments) { | 3110 CFXJSE_Arguments* pArguments) { |
3134 int32_t argc = pArguments->GetLength(); | 3111 int32_t argc = pArguments->GetLength(); |
3135 if ((argc != 0) && (argc != 1)) { | 3112 if ((argc != 0) && (argc != 1)) { |
3136 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance"); | 3113 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"addInstance"); |
3137 return; | 3114 return; |
3138 } | 3115 } |
3139 FX_BOOL fFlags = TRUE; | 3116 FX_BOOL fFlags = TRUE; |
3140 if (argc == 1) { | 3117 if (argc == 1) { |
3141 fFlags = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; | 3118 fFlags = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; |
3142 } | 3119 } |
3143 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); | 3120 int32_t iCount = XFA_ScriptInstanceManager_GetCount(this); |
3144 CXFA_Occur nodeOccur(GetOccurNode()); | 3121 CXFA_Occur nodeOccur(GetOccurNode()); |
3145 int32_t iMax = nodeOccur.GetMax(); | 3122 int32_t iMax = nodeOccur.GetMax(); |
3146 if (iMax >= 0 && iCount >= iMax) { | 3123 if (iMax >= 0 && iCount >= iMax) { |
3147 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); | 3124 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); |
3148 return; | 3125 return; |
3149 } | 3126 } |
3150 CXFA_Node* pNewInstance = | 3127 CXFA_Node* pNewInstance = |
3151 XFA_ScriptInstanceManager_CreateInstance(this, fFlags); | 3128 XFA_ScriptInstanceManager_CreateInstance(this, fFlags); |
3152 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, | 3129 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iCount, iCount, |
3153 FALSE); | 3130 FALSE); |
3154 FXJSE_Value_Set( | 3131 pArguments->GetReturnValue()->Assign( |
3155 pArguments->GetReturnValue(), | |
3156 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); | 3132 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); |
3157 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 3133 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
3158 if (!pNotify) { | 3134 if (!pNotify) { |
3159 return; | 3135 return; |
3160 } | 3136 } |
3161 pNotify->RunNodeInitialize(pNewInstance); | 3137 pNotify->RunNodeInitialize(pNewInstance); |
3162 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 3138 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
3163 if (!pLayoutPro) { | 3139 if (!pLayoutPro) { |
3164 return; | 3140 return; |
3165 } | 3141 } |
(...skipping 20 matching lines...) Expand all Loading... |
3186 } | 3162 } |
3187 int32_t iMax = nodeOccur.GetMax(); | 3163 int32_t iMax = nodeOccur.GetMax(); |
3188 if (iMax >= 0 && iCount >= iMax) { | 3164 if (iMax >= 0 && iCount >= iMax) { |
3189 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); | 3165 ThrowException(XFA_IDS_VIOLATE_BOUNDARY, L"max"); |
3190 return; | 3166 return; |
3191 } | 3167 } |
3192 CXFA_Node* pNewInstance = | 3168 CXFA_Node* pNewInstance = |
3193 XFA_ScriptInstanceManager_CreateInstance(this, bBind); | 3169 XFA_ScriptInstanceManager_CreateInstance(this, bBind); |
3194 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iIndex, iCount, | 3170 XFA_ScriptInstanceManager_InsertItem(this, pNewInstance, iIndex, iCount, |
3195 TRUE); | 3171 TRUE); |
3196 FXJSE_Value_Set( | 3172 pArguments->GetReturnValue()->Assign( |
3197 pArguments->GetReturnValue(), | |
3198 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); | 3173 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNewInstance)); |
3199 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 3174 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
3200 if (!pNotify) { | 3175 if (!pNotify) { |
3201 return; | 3176 return; |
3202 } | 3177 } |
3203 pNotify->RunNodeInitialize(pNewInstance); | 3178 pNotify->RunNodeInitialize(pNewInstance); |
3204 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); | 3179 CXFA_LayoutProcessor* pLayoutPro = m_pDocument->GetLayoutProcessor(); |
3205 if (!pLayoutPro) { | 3180 if (!pLayoutPro) { |
3206 return; | 3181 return; |
3207 } | 3182 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3289 pLayoutPro->AddChangedContainer( | 3264 pLayoutPro->AddChangedContainer( |
3290 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); | 3265 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form))); |
3291 } | 3266 } |
3292 return 0; | 3267 return 0; |
3293 } | 3268 } |
3294 void CXFA_Node::Script_Occur_Max(CFXJSE_Value* pValue, | 3269 void CXFA_Node::Script_Occur_Max(CFXJSE_Value* pValue, |
3295 FX_BOOL bSetting, | 3270 FX_BOOL bSetting, |
3296 XFA_ATTRIBUTE eAttribute) { | 3271 XFA_ATTRIBUTE eAttribute) { |
3297 CXFA_Occur occur(this); | 3272 CXFA_Occur occur(this); |
3298 if (bSetting) { | 3273 if (bSetting) { |
3299 int32_t iMax = FXJSE_Value_ToInteger(pValue); | 3274 int32_t iMax = pValue->ToInteger(); |
3300 occur.SetMax(iMax); | 3275 occur.SetMax(iMax); |
3301 } else { | 3276 } else { |
3302 FXJSE_Value_SetInteger(pValue, occur.GetMax()); | 3277 pValue->SetInteger(occur.GetMax()); |
3303 } | 3278 } |
3304 } | 3279 } |
3305 void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue, | 3280 void CXFA_Node::Script_Occur_Min(CFXJSE_Value* pValue, |
3306 FX_BOOL bSetting, | 3281 FX_BOOL bSetting, |
3307 XFA_ATTRIBUTE eAttribute) { | 3282 XFA_ATTRIBUTE eAttribute) { |
3308 CXFA_Occur occur(this); | 3283 CXFA_Occur occur(this); |
3309 if (bSetting) { | 3284 if (bSetting) { |
3310 int32_t iMin = FXJSE_Value_ToInteger(pValue); | 3285 int32_t iMin = pValue->ToInteger(); |
3311 occur.SetMin(iMin); | 3286 occur.SetMin(iMin); |
3312 } else { | 3287 } else { |
3313 FXJSE_Value_SetInteger(pValue, occur.GetMin()); | 3288 pValue->SetInteger(occur.GetMin()); |
3314 } | 3289 } |
3315 } | 3290 } |
3316 void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { | 3291 void CXFA_Node::Script_Desc_Metadata(CFXJSE_Arguments* pArguments) { |
3317 int32_t argc = pArguments->GetLength(); | 3292 int32_t argc = pArguments->GetLength(); |
3318 if ((argc == 0) || (argc == 1)) { | 3293 if ((argc == 0) || (argc == 1)) { |
3319 FXJSE_Value_SetUTF8String(pArguments->GetReturnValue(), ""); | 3294 pArguments->GetReturnValue()->SetString(""); |
3320 } else { | 3295 } else { |
3321 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"metadata"); | 3296 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"metadata"); |
3322 } | 3297 } |
3323 } | 3298 } |
3324 void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) { | 3299 void CXFA_Node::Script_Form_FormNodes(CFXJSE_Arguments* pArguments) { |
3325 int32_t argc = pArguments->GetLength(); | 3300 int32_t argc = pArguments->GetLength(); |
3326 if (argc == 1) { | 3301 if (argc == 1) { |
3327 CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); | 3302 CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); |
3328 if (pDataNode) { | 3303 if (pDataNode) { |
3329 CXFA_NodeArray formItems; | 3304 CXFA_NodeArray formItems; |
3330 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); | 3305 CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(m_pDocument); |
3331 pFormNodes->SetArrayNodeList(formItems); | 3306 pFormNodes->SetArrayNodeList(formItems); |
3332 FXJSE_Value_SetObject( | 3307 pArguments->GetReturnValue()->SetObject( |
3333 pArguments->GetReturnValue(), (CXFA_Object*)pFormNodes, | 3308 pFormNodes, m_pDocument->GetScriptContext()->GetJseNormalClass()); |
3334 m_pDocument->GetScriptContext()->GetJseNormalClass()); | |
3335 } else { | 3309 } else { |
3336 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); | 3310 ThrowException(XFA_IDS_ARGUMENT_MISMATCH); |
3337 } | 3311 } |
3338 } else { | 3312 } else { |
3339 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); | 3313 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"formNodes"); |
3340 } | 3314 } |
3341 } | 3315 } |
3342 void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { | 3316 void CXFA_Node::Script_Form_Remerge(CFXJSE_Arguments* pArguments) { |
3343 int32_t argc = pArguments->GetLength(); | 3317 int32_t argc = pArguments->GetLength(); |
3344 if (argc == 0) { | 3318 if (argc == 0) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3393 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); | 3367 pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Calculate); |
3394 } else { | 3368 } else { |
3395 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); | 3369 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execCalculate"); |
3396 } | 3370 } |
3397 } | 3371 } |
3398 void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { | 3372 void CXFA_Node::Script_Form_ExecValidate(CFXJSE_Arguments* pArguments) { |
3399 int32_t argc = pArguments->GetLength(); | 3373 int32_t argc = pArguments->GetLength(); |
3400 if (argc == 0) { | 3374 if (argc == 0) { |
3401 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 3375 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
3402 if (!pNotify) { | 3376 if (!pNotify) { |
3403 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), FALSE); | 3377 pArguments->GetReturnValue()->SetBoolean(FALSE); |
3404 } else { | 3378 } else { |
3405 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); | 3379 int32_t iRet = pNotify->ExecEventByDeepFirst(this, XFA_EVENT_Validate); |
3406 FXJSE_Value_SetBoolean(pArguments->GetReturnValue(), | 3380 pArguments->GetReturnValue()->SetBoolean( |
3407 ((iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE)); | 3381 (iRet == XFA_EVENTERROR_Error) ? FALSE : TRUE); |
3408 } | 3382 } |
3409 } else { | 3383 } else { |
3410 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); | 3384 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"execValidate"); |
3411 } | 3385 } |
3412 } | 3386 } |
3413 void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue, | 3387 void CXFA_Node::Script_Form_Checksum(CFXJSE_Value* pValue, |
3414 FX_BOOL bSetting, | 3388 FX_BOOL bSetting, |
3415 XFA_ATTRIBUTE eAttribute) { | 3389 XFA_ATTRIBUTE eAttribute) { |
3416 if (bSetting) { | 3390 if (bSetting) { |
3417 CFX_ByteString bsChecksum; | 3391 CFX_ByteString bsChecksum; |
3418 FXJSE_Value_ToUTF8String(pValue, bsChecksum); | 3392 pValue->ToString(bsChecksum); |
3419 SetAttribute(XFA_ATTRIBUTE_Checksum, | 3393 SetAttribute(XFA_ATTRIBUTE_Checksum, |
3420 CFX_WideString::FromUTF8(bsChecksum.AsStringC()).AsStringC()); | 3394 CFX_WideString::FromUTF8(bsChecksum.AsStringC()).AsStringC()); |
3421 } else { | 3395 } else { |
3422 CFX_WideString wsChecksum; | 3396 CFX_WideString wsChecksum; |
3423 GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE); | 3397 GetAttribute(XFA_ATTRIBUTE_Checksum, wsChecksum, FALSE); |
3424 FXJSE_Value_SetUTF8String( | 3398 pValue->SetString( |
3425 pValue, | |
3426 FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC()); | 3399 FX_UTF8Encode(wsChecksum.c_str(), wsChecksum.GetLength()).AsStringC()); |
3427 } | 3400 } |
3428 } | 3401 } |
3429 void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { | 3402 void CXFA_Node::Script_Packet_GetAttribute(CFXJSE_Arguments* pArguments) { |
3430 int32_t argc = pArguments->GetLength(); | 3403 int32_t argc = pArguments->GetLength(); |
3431 if (argc == 1) { | 3404 if (argc == 1) { |
3432 CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); | 3405 CFX_ByteString bsAttributeName = pArguments->GetUTF8String(0); |
3433 CFX_WideString wsAttributeValue; | 3406 CFX_WideString wsAttributeValue; |
3434 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3407 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3435 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3408 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3436 static_cast<CFDE_XMLElement*>(pXMLNode)->GetString( | 3409 static_cast<CFDE_XMLElement*>(pXMLNode)->GetString( |
3437 CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(), | 3410 CFX_WideString::FromUTF8(bsAttributeName.AsStringC()).c_str(), |
3438 wsAttributeValue); | 3411 wsAttributeValue); |
3439 } | 3412 } |
3440 FXJSE_Value_SetUTF8String( | 3413 pArguments->GetReturnValue()->SetString( |
3441 pArguments->GetReturnValue(), | |
3442 FX_UTF8Encode(wsAttributeValue.c_str(), wsAttributeValue.GetLength()) | 3414 FX_UTF8Encode(wsAttributeValue.c_str(), wsAttributeValue.GetLength()) |
3443 .AsStringC()); | 3415 .AsStringC()); |
3444 } else { | 3416 } else { |
3445 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getAttribute"); | 3417 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"getAttribute"); |
3446 } | 3418 } |
3447 } | 3419 } |
3448 void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { | 3420 void CXFA_Node::Script_Packet_SetAttribute(CFXJSE_Arguments* pArguments) { |
3449 int32_t argc = pArguments->GetLength(); | 3421 int32_t argc = pArguments->GetLength(); |
3450 if (argc == 2) { | 3422 if (argc == 2) { |
3451 CFX_ByteString bsValue = pArguments->GetUTF8String(0); | 3423 CFX_ByteString bsValue = pArguments->GetUTF8String(0); |
3452 CFX_ByteString bsName = pArguments->GetUTF8String(1); | 3424 CFX_ByteString bsName = pArguments->GetUTF8String(1); |
3453 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3425 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3454 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3426 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3455 static_cast<CFDE_XMLElement*>(pXMLNode) | 3427 static_cast<CFDE_XMLElement*>(pXMLNode) |
3456 ->SetString(CFX_WideString::FromUTF8(bsName.AsStringC()), | 3428 ->SetString(CFX_WideString::FromUTF8(bsName.AsStringC()), |
3457 CFX_WideString::FromUTF8(bsValue.AsStringC())); | 3429 CFX_WideString::FromUTF8(bsValue.AsStringC())); |
3458 } | 3430 } |
3459 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 3431 pArguments->GetReturnValue()->SetNull(); |
3460 } else { | 3432 } else { |
3461 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setAttribute"); | 3433 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"setAttribute"); |
3462 } | 3434 } |
3463 } | 3435 } |
3464 void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) { | 3436 void CXFA_Node::Script_Packet_RemoveAttribute(CFXJSE_Arguments* pArguments) { |
3465 int32_t argc = pArguments->GetLength(); | 3437 int32_t argc = pArguments->GetLength(); |
3466 if (argc == 1) { | 3438 if (argc == 1) { |
3467 CFX_ByteString bsName = pArguments->GetUTF8String(0); | 3439 CFX_ByteString bsName = pArguments->GetUTF8String(0); |
3468 CFX_WideString wsName = CFX_WideString::FromUTF8(bsName.AsStringC()); | 3440 CFX_WideString wsName = CFX_WideString::FromUTF8(bsName.AsStringC()); |
3469 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3441 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3470 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3442 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3471 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 3443 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
3472 if (pXMLElement->HasAttribute(wsName.c_str())) { | 3444 if (pXMLElement->HasAttribute(wsName.c_str())) { |
3473 pXMLElement->RemoveAttribute(wsName.c_str()); | 3445 pXMLElement->RemoveAttribute(wsName.c_str()); |
3474 } | 3446 } |
3475 } | 3447 } |
3476 FXJSE_Value_SetNull(pArguments->GetReturnValue()); | 3448 pArguments->GetReturnValue()->SetNull(); |
3477 } else { | 3449 } else { |
3478 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"removeAttribute"); | 3450 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"removeAttribute"); |
3479 } | 3451 } |
3480 } | 3452 } |
3481 void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue, | 3453 void CXFA_Node::Script_Packet_Content(CFXJSE_Value* pValue, |
3482 FX_BOOL bSetting, | 3454 FX_BOOL bSetting, |
3483 XFA_ATTRIBUTE eAttribute) { | 3455 XFA_ATTRIBUTE eAttribute) { |
3484 if (bSetting) { | 3456 if (bSetting) { |
3485 CFX_ByteString bsNewContent; | 3457 CFX_ByteString bsNewContent; |
3486 FXJSE_Value_ToUTF8String(pValue, bsNewContent); | 3458 pValue->ToString(bsNewContent); |
3487 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3459 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3488 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3460 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3489 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 3461 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
3490 pXMLElement->SetTextData( | 3462 pXMLElement->SetTextData( |
3491 CFX_WideString::FromUTF8(bsNewContent.AsStringC())); | 3463 CFX_WideString::FromUTF8(bsNewContent.AsStringC())); |
3492 } | 3464 } |
3493 } else { | 3465 } else { |
3494 CFX_WideString wsTextData; | 3466 CFX_WideString wsTextData; |
3495 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); | 3467 CFDE_XMLNode* pXMLNode = GetXMLMappingNode(); |
3496 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { | 3468 if (pXMLNode && pXMLNode->GetType() == FDE_XMLNODE_Element) { |
3497 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 3469 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
3498 pXMLElement->GetTextData(wsTextData); | 3470 pXMLElement->GetTextData(wsTextData); |
3499 } | 3471 } |
3500 FXJSE_Value_SetUTF8String( | 3472 pValue->SetString( |
3501 pValue, | |
3502 FX_UTF8Encode(wsTextData.c_str(), wsTextData.GetLength()).AsStringC()); | 3473 FX_UTF8Encode(wsTextData.c_str(), wsTextData.GetLength()).AsStringC()); |
3503 } | 3474 } |
3504 } | 3475 } |
3505 void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) { | 3476 void CXFA_Node::Script_Source_Next(CFXJSE_Arguments* pArguments) { |
3506 int32_t argc = pArguments->GetLength(); | 3477 int32_t argc = pArguments->GetLength(); |
3507 if (argc == 0) { | 3478 if (argc == 0) { |
3508 } else { | 3479 } else { |
3509 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"next"); | 3480 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"next"); |
3510 } | 3481 } |
3511 } | 3482 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3623 } | 3594 } |
3624 void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue, | 3595 void CXFA_Node::Script_Source_Db(CFXJSE_Value* pValue, |
3625 FX_BOOL bSetting, | 3596 FX_BOOL bSetting, |
3626 XFA_ATTRIBUTE eAttribute) {} | 3597 XFA_ATTRIBUTE eAttribute) {} |
3627 void CXFA_Node::Script_Xfa_This(CFXJSE_Value* pValue, | 3598 void CXFA_Node::Script_Xfa_This(CFXJSE_Value* pValue, |
3628 FX_BOOL bSetting, | 3599 FX_BOOL bSetting, |
3629 XFA_ATTRIBUTE eAttribute) { | 3600 XFA_ATTRIBUTE eAttribute) { |
3630 if (!bSetting) { | 3601 if (!bSetting) { |
3631 CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject(); | 3602 CXFA_Object* pThis = m_pDocument->GetScriptContext()->GetThisObject(); |
3632 ASSERT(pThis); | 3603 ASSERT(pThis); |
3633 FXJSE_Value_Set(pValue, | 3604 pValue->Assign(m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis)); |
3634 m_pDocument->GetScriptContext()->GetJSValueFromMap(pThis)); | |
3635 } | 3605 } |
3636 } | 3606 } |
3637 void CXFA_Node::Script_Handler_Version(CFXJSE_Value* pValue, | 3607 void CXFA_Node::Script_Handler_Version(CFXJSE_Value* pValue, |
3638 FX_BOOL bSetting, | 3608 FX_BOOL bSetting, |
3639 XFA_ATTRIBUTE eAttribute) {} | 3609 XFA_ATTRIBUTE eAttribute) {} |
3640 void CXFA_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue, | 3610 void CXFA_Node::Script_SubmitFormat_Mode(CFXJSE_Value* pValue, |
3641 FX_BOOL bSetting, | 3611 FX_BOOL bSetting, |
3642 XFA_ATTRIBUTE eAttribute) {} | 3612 XFA_ATTRIBUTE eAttribute) {} |
3643 void CXFA_Node::Script_Extras_Type(CFXJSE_Value* pValue, | 3613 void CXFA_Node::Script_Extras_Type(CFXJSE_Value* pValue, |
3644 FX_BOOL bSetting, | 3614 FX_BOOL bSetting, |
3645 XFA_ATTRIBUTE eAttribute) {} | 3615 XFA_ATTRIBUTE eAttribute) {} |
3646 void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue, | 3616 void CXFA_Node::Script_Script_Stateless(CFXJSE_Value* pValue, |
3647 FX_BOOL bSetting, | 3617 FX_BOOL bSetting, |
3648 XFA_ATTRIBUTE eAttribute) { | 3618 XFA_ATTRIBUTE eAttribute) { |
3649 if (bSetting) { | 3619 if (bSetting) { |
3650 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 3620 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
3651 return; | 3621 return; |
3652 } | 3622 } |
3653 FXJSE_Value_SetUTF8String(pValue, FX_UTF8Encode(FX_WSTRC(L"0")).AsStringC()); | 3623 pValue->SetString(FX_UTF8Encode(FX_WSTRC(L"0")).AsStringC()); |
3654 } | 3624 } |
3655 void CXFA_Node::Script_Encrypt_Format(CFXJSE_Value* pValue, | 3625 void CXFA_Node::Script_Encrypt_Format(CFXJSE_Value* pValue, |
3656 FX_BOOL bSetting, | 3626 FX_BOOL bSetting, |
3657 XFA_ATTRIBUTE eAttribute) {} | 3627 XFA_ATTRIBUTE eAttribute) {} |
3658 enum XFA_KEYTYPE { | 3628 enum XFA_KEYTYPE { |
3659 XFA_KEYTYPE_Custom, | 3629 XFA_KEYTYPE_Custom, |
3660 XFA_KEYTYPE_Element, | 3630 XFA_KEYTYPE_Element, |
3661 }; | 3631 }; |
3662 void* XFA_GetMapKey_Custom(const CFX_WideStringC& wsKey) { | 3632 void* XFA_GetMapKey_Custom(const CFX_WideStringC& wsKey) { |
3663 uint32_t dwKey = FX_HashCode_GetW(wsKey, false); | 3633 uint32_t dwKey = FX_HashCode_GetW(wsKey, false); |
(...skipping 1534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5198 } | 5168 } |
5199 } else { | 5169 } else { |
5200 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remove"); | 5170 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"remove"); |
5201 } | 5171 } |
5202 } | 5172 } |
5203 void CXFA_NodeList::Script_ListClass_Item(CFXJSE_Arguments* pArguments) { | 5173 void CXFA_NodeList::Script_ListClass_Item(CFXJSE_Arguments* pArguments) { |
5204 int32_t argc = pArguments->GetLength(); | 5174 int32_t argc = pArguments->GetLength(); |
5205 if (argc == 1) { | 5175 if (argc == 1) { |
5206 int32_t iIndex = pArguments->GetInt32(0); | 5176 int32_t iIndex = pArguments->GetInt32(0); |
5207 if ((iIndex >= 0) && (iIndex + 1 <= GetLength())) { | 5177 if ((iIndex >= 0) && (iIndex + 1 <= GetLength())) { |
5208 FXJSE_Value_Set( | 5178 pArguments->GetReturnValue()->Assign( |
5209 pArguments->GetReturnValue(), | |
5210 m_pDocument->GetScriptContext()->GetJSValueFromMap(Item(iIndex))); | 5179 m_pDocument->GetScriptContext()->GetJSValueFromMap(Item(iIndex))); |
5211 } else { | 5180 } else { |
5212 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); | 5181 ThrowException(XFA_IDS_INDEX_OUT_OF_BOUNDS); |
5213 } | 5182 } |
5214 } else { | 5183 } else { |
5215 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"item"); | 5184 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"item"); |
5216 } | 5185 } |
5217 } | 5186 } |
5218 void CXFA_NodeList::Script_TreelistClass_NamedItem( | 5187 void CXFA_NodeList::Script_TreelistClass_NamedItem( |
5219 CFXJSE_Arguments* pArguments) { | 5188 CFXJSE_Arguments* pArguments) { |
5220 int32_t argc = pArguments->GetLength(); | 5189 int32_t argc = pArguments->GetLength(); |
5221 if (argc == 1) { | 5190 if (argc == 1) { |
5222 CFX_ByteString szName = pArguments->GetUTF8String(0); | 5191 CFX_ByteString szName = pArguments->GetUTF8String(0); |
5223 CXFA_Node* pNode = | 5192 CXFA_Node* pNode = |
5224 NamedItem(CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC()); | 5193 NamedItem(CFX_WideString::FromUTF8(szName.AsStringC()).AsStringC()); |
5225 if (!pNode) { | 5194 if (!pNode) { |
5226 return; | 5195 return; |
5227 } | 5196 } |
5228 FXJSE_Value_Set(pArguments->GetReturnValue(), | 5197 pArguments->GetReturnValue()->Assign( |
5229 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); | 5198 m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); |
5230 } else { | 5199 } else { |
5231 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"namedItem"); | 5200 ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"namedItem"); |
5232 } | 5201 } |
5233 } | 5202 } |
5234 void CXFA_NodeList::Script_ListClass_Length(CFXJSE_Value* pValue, | 5203 void CXFA_NodeList::Script_ListClass_Length(CFXJSE_Value* pValue, |
5235 FX_BOOL bSetting, | 5204 FX_BOOL bSetting, |
5236 XFA_ATTRIBUTE eAttribute) { | 5205 XFA_ATTRIBUTE eAttribute) { |
5237 if (!bSetting) { | 5206 if (!bSetting) { |
5238 FXJSE_Value_SetInteger(pValue, GetLength()); | 5207 pValue->SetInteger(GetLength()); |
5239 } else { | 5208 } else { |
5240 ThrowException(XFA_IDS_INVAlID_PROP_SET); | 5209 ThrowException(XFA_IDS_INVAlID_PROP_SET); |
5241 } | 5210 } |
5242 } | 5211 } |
5243 CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) | 5212 CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument) |
5244 : CXFA_NodeList(pDocument) {} | 5213 : CXFA_NodeList(pDocument) {} |
5245 void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) { | 5214 void CXFA_ArrayNodeList::SetArrayNodeList(const CXFA_NodeArray& srcArray) { |
5246 if (srcArray.GetSize() > 0) { | 5215 if (srcArray.GetSize() > 0) { |
5247 m_array.Copy(srcArray); | 5216 m_array.Copy(srcArray); |
5248 } | 5217 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5311 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); | 5280 return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); |
5312 } | 5281 } |
5313 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { | 5282 FX_BOOL CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { |
5314 return m_pAttachNode->RemoveChild(pNode); | 5283 return m_pAttachNode->RemoveChild(pNode); |
5315 } | 5284 } |
5316 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { | 5285 CXFA_Node* CXFA_AttachNodeList::Item(int32_t iIndex) { |
5317 return m_pAttachNode->GetChild( | 5286 return m_pAttachNode->GetChild( |
5318 iIndex, XFA_ELEMENT_UNKNOWN, | 5287 iIndex, XFA_ELEMENT_UNKNOWN, |
5319 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); | 5288 m_pAttachNode->GetClassID() == XFA_ELEMENT_Subform); |
5320 } | 5289 } |
OLD | NEW |