summaryrefslogtreecommitdiff
path: root/fxjs/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs/xfa')
-rw-r--r--fxjs/xfa/cjx_container.cpp33
-rw-r--r--fxjs/xfa/cjx_container.h27
-rw-r--r--fxjs/xfa/cjx_content.cpp15
-rw-r--r--fxjs/xfa/cjx_content.h21
-rw-r--r--fxjs/xfa/cjx_delta.cpp25
-rw-r--r--fxjs/xfa/cjx_delta.h26
-rw-r--r--fxjs/xfa/cjx_desc.cpp29
-rw-r--r--fxjs/xfa/cjx_desc.h26
-rw-r--r--fxjs/xfa/cjx_exclgroup.cpp118
-rw-r--r--fxjs/xfa/cjx_exclgroup.h30
-rw-r--r--fxjs/xfa/cjx_field.cpp263
-rw-r--r--fxjs/xfa/cjx_field.h37
-rw-r--r--fxjs/xfa/cjx_form.cpp128
-rw-r--r--fxjs/xfa/cjx_form.h31
-rw-r--r--fxjs/xfa/cjx_instancemanager.cpp180
-rw-r--r--fxjs/xfa/cjx_instancemanager.h30
-rw-r--r--fxjs/xfa/cjx_list.cpp103
-rw-r--r--fxjs/xfa/cjx_list.h33
-rw-r--r--fxjs/xfa/cjx_manifest.cpp35
-rw-r--r--fxjs/xfa/cjx_manifest.h26
-rw-r--r--fxjs/xfa/cjx_model.cpp94
-rw-r--r--fxjs/xfa/cjx_model.h28
-rw-r--r--fxjs/xfa/cjx_packet.cpp75
-rw-r--r--fxjs/xfa/cjx_packet.h28
-rw-r--r--fxjs/xfa/cjx_source.cpp122
-rw-r--r--fxjs/xfa/cjx_source.h42
-rw-r--r--fxjs/xfa/cjx_subform.cpp84
-rw-r--r--fxjs/xfa/cjx_subform.h29
-rw-r--r--fxjs/xfa/cjx_template.cpp87
-rw-r--r--fxjs/xfa/cjx_template.h34
-rw-r--r--fxjs/xfa/cjx_textnode.cpp15
-rw-r--r--fxjs/xfa/cjx_textnode.h21
-rw-r--r--fxjs/xfa/cjx_tree.cpp230
-rw-r--r--fxjs/xfa/cjx_tree.h45
-rw-r--r--fxjs/xfa/cjx_treelist.cpp45
-rw-r--r--fxjs/xfa/cjx_treelist.h28
-rw-r--r--fxjs/xfa/cjx_wsdlconnection.cpp31
-rw-r--r--fxjs/xfa/cjx_wsdlconnection.h26
38 files changed, 2280 insertions, 0 deletions
diff --git a/fxjs/xfa/cjx_container.cpp b/fxjs/xfa/cjx_container.cpp
new file mode 100644
index 0000000000..517fb86f98
--- /dev/null
+++ b/fxjs/xfa/cjx_container.cpp
@@ -0,0 +1,33 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_container.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_field.h"
+
+const CJX_MethodSpec CJX_Container::MethodSpecs[] = {
+ {"getDelta", getDelta_static},
+ {"getDeltas", getDeltas_static},
+ {"", nullptr}};
+
+CJX_Container::CJX_Container(CXFA_Node* node) : CJX_Node(node) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Container::~CJX_Container() {}
+
+void CJX_Container::getDelta(CFXJSE_Arguments* pArguments) {}
+
+void CJX_Container::getDeltas(CFXJSE_Arguments* pArguments) {
+ CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
+ pArguments->GetReturnValue()->SetObject(
+ pFormNodes, GetDocument()->GetScriptContext()->GetJseNormalClass());
+}
diff --git a/fxjs/xfa/cjx_container.h b/fxjs/xfa/cjx_container.h
new file mode 100644
index 0000000000..41d11cfd69
--- /dev/null
+++ b/fxjs/xfa/cjx_container.h
@@ -0,0 +1,27 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_CONTAINER_H_
+#define FXJS_XFA_CJX_CONTAINER_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_Node;
+
+class CJX_Container : public CJX_Node {
+ public:
+ explicit CJX_Container(CXFA_Node* node);
+ ~CJX_Container() override;
+
+ JS_METHOD(getDelta, CJX_Container);
+ JS_METHOD(getDeltas, CJX_Container);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_CONTAINER_H_
diff --git a/fxjs/xfa/cjx_content.cpp b/fxjs/xfa/cjx_content.cpp
new file mode 100644
index 0000000000..87ddf63d86
--- /dev/null
+++ b/fxjs/xfa/cjx_content.cpp
@@ -0,0 +1,15 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_content.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_object.h"
+
+CJX_Content::CJX_Content(CXFA_Object* obj) : CJX_Object(obj) {}
+
+CJX_Content::~CJX_Content() {}
diff --git a/fxjs/xfa/cjx_content.h b/fxjs/xfa/cjx_content.h
new file mode 100644
index 0000000000..cd2e71a776
--- /dev/null
+++ b/fxjs/xfa/cjx_content.h
@@ -0,0 +1,21 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_CONTENT_H_
+#define FXJS_XFA_CJX_CONTENT_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_object.h"
+
+class CXFA_Content;
+
+class CJX_Content : public CJX_Object {
+ public:
+ explicit CJX_Content(CXFA_Object* obj);
+ ~CJX_Content() override;
+};
+
+#endif // FXJS_XFA_CJX_CONTENT_H_
diff --git a/fxjs/xfa/cjx_delta.cpp b/fxjs/xfa/cjx_delta.cpp
new file mode 100644
index 0000000000..b661ae9ffd
--- /dev/null
+++ b/fxjs/xfa/cjx_delta.cpp
@@ -0,0 +1,25 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_delta.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_delta.h"
+
+const CJX_MethodSpec CJX_Delta::MethodSpecs[] = {{"restore", restore_static},
+ {"", nullptr}};
+
+CJX_Delta::CJX_Delta(CXFA_Delta* delta) : CJX_Object(delta) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Delta::~CJX_Delta() {}
+
+void CJX_Delta::restore(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"restore");
+}
diff --git a/fxjs/xfa/cjx_delta.h b/fxjs/xfa/cjx_delta.h
new file mode 100644
index 0000000000..d9a2c6290e
--- /dev/null
+++ b/fxjs/xfa/cjx_delta.h
@@ -0,0 +1,26 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_DELTA_H_
+#define FXJS_XFA_CJX_DELTA_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_object.h"
+
+class CXFA_Delta;
+
+class CJX_Delta : public CJX_Object {
+ public:
+ explicit CJX_Delta(CXFA_Delta* delta);
+ ~CJX_Delta() override;
+
+ JS_METHOD(restore, CJX_Delta);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_DELTA_H_
diff --git a/fxjs/xfa/cjx_desc.cpp b/fxjs/xfa/cjx_desc.cpp
new file mode 100644
index 0000000000..4efd1dde0e
--- /dev/null
+++ b/fxjs/xfa/cjx_desc.cpp
@@ -0,0 +1,29 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_desc.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_desc.h"
+
+const CJX_MethodSpec CJX_Desc::MethodSpecs[] = {{"metadata", metadata_static},
+ {"", nullptr}};
+
+CJX_Desc::CJX_Desc(CXFA_Desc* desc) : CJX_Node(desc) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Desc::~CJX_Desc() {}
+
+void CJX_Desc::metadata(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 0 && argc != 1) {
+ ThrowParamCountMismatchException(L"metadata");
+ return;
+ }
+ pArguments->GetReturnValue()->SetString("");
+}
diff --git a/fxjs/xfa/cjx_desc.h b/fxjs/xfa/cjx_desc.h
new file mode 100644
index 0000000000..602633d482
--- /dev/null
+++ b/fxjs/xfa/cjx_desc.h
@@ -0,0 +1,26 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_DESC_H_
+#define FXJS_XFA_CJX_DESC_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_Desc;
+
+class CJX_Desc : public CJX_Node {
+ public:
+ explicit CJX_Desc(CXFA_Desc* desc);
+ ~CJX_Desc() override;
+
+ JS_METHOD(metadata, CJX_Desc);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_DESC_H_
diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp
new file mode 100644
index 0000000000..c84ec94793
--- /dev/null
+++ b/fxjs/xfa/cjx_exclgroup.cpp
@@ -0,0 +1,118 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_exclgroup.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/cxfa_eventparam.h"
+#include "xfa/fxfa/cxfa_ffnotify.h"
+#include "xfa/fxfa/fxfa.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_exclgroup.h"
+#include "xfa/fxfa/parser/cxfa_widgetdata.h"
+
+const CJX_MethodSpec CJX_ExclGroup::MethodSpecs[] = {
+ {"execCalculate", execCalculate_static},
+ {"execEvent", execEvent_static},
+ {"execInitialize", execInitialize_static},
+ {"execValidate", execValidate_static},
+ {"selectedMember", selectedMember_static},
+ {"", nullptr}};
+
+CJX_ExclGroup::CJX_ExclGroup(CXFA_ExclGroup* group) : CJX_Node(group) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_ExclGroup::~CJX_ExclGroup() {}
+
+void CJX_ExclGroup::execEvent(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"execEvent");
+ return;
+ }
+
+ ByteString eventString = pArguments->GetUTF8String(0);
+ execSingleEventByName(
+ WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
+ XFA_Element::ExclGroup);
+}
+
+void CJX_ExclGroup::execInitialize(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+}
+
+void CJX_ExclGroup::execCalculate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+}
+
+void CJX_ExclGroup::execValidate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+
+ int32_t iRet =
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
+}
+
+void CJX_ExclGroup::selectedMember(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc < 0 || argc > 1) {
+ ThrowParamCountMismatchException(L"selectedMember");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+
+ CXFA_Node* pReturnNode = nullptr;
+ if (argc == 0) {
+ pReturnNode = pWidgetData->GetSelectedMember();
+ } else {
+ ByteString szName;
+ szName = pArguments->GetUTF8String(0);
+ pReturnNode = pWidgetData->SetSelectedMember(
+ WideString::FromUTF8(szName.AsStringView()).AsStringView(), true);
+ }
+ if (!pReturnNode) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+
+ pArguments->GetReturnValue()->Assign(
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pReturnNode));
+}
diff --git a/fxjs/xfa/cjx_exclgroup.h b/fxjs/xfa/cjx_exclgroup.h
new file mode 100644
index 0000000000..2ef280e17a
--- /dev/null
+++ b/fxjs/xfa/cjx_exclgroup.h
@@ -0,0 +1,30 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_EXCLGROUP_H_
+#define FXJS_XFA_CJX_EXCLGROUP_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_ExclGroup;
+
+class CJX_ExclGroup : public CJX_Node {
+ public:
+ explicit CJX_ExclGroup(CXFA_ExclGroup* group);
+ ~CJX_ExclGroup() override;
+
+ JS_METHOD(execCalculate, CJX_ExclGroup);
+ JS_METHOD(execEvent, CJX_ExclGroup);
+ JS_METHOD(execInitialize, CJX_ExclGroup);
+ JS_METHOD(execValidate, CJX_ExclGroup);
+ JS_METHOD(selectedMember, CJX_ExclGroup);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_EXCLGROUP_H_
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
new file mode 100644
index 0000000000..f0dbc78c78
--- /dev/null
+++ b/fxjs/xfa/cjx_field.cpp
@@ -0,0 +1,263 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_field.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/cxfa_eventparam.h"
+#include "xfa/fxfa/cxfa_ffnotify.h"
+#include "xfa/fxfa/fxfa.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_field.h"
+#include "xfa/fxfa/parser/cxfa_widgetdata.h"
+
+const CJX_MethodSpec CJX_Field::MethodSpecs[] = {
+ {"addItem", addItem_static},
+ {"boundItem", boundItem_static},
+ {"clearItems", clearItems_static},
+ {"deleteItem", deleteItem_static},
+ {"execCalculate", execCalculate_static},
+ {"execEvent", execEvent_static},
+ {"execInitialize", execInitialize_static},
+ {"execValidate", execValidate_static},
+ {"getDisplayItem", getDisplayItem_static},
+ {"getItemState", getItemState_static},
+ {"getSaveItem", getSaveItem_static},
+ {"setItemState", setItemState_static},
+ {"", nullptr}};
+
+CJX_Field::CJX_Field(CXFA_Field* field) : CJX_Container(field) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Field::~CJX_Field() {}
+
+void CJX_Field::clearItems(CFXJSE_Arguments* pArguments) {
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData)
+ return;
+
+ pWidgetData->DeleteItem(-1, true, false);
+}
+
+void CJX_Field::execEvent(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"execEvent");
+ return;
+ }
+
+ ByteString eventString = pArguments->GetUTF8String(0);
+ int32_t iRet = execSingleEventByName(
+ WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
+ XFA_Element::Field);
+ if (eventString != "validate")
+ return;
+
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
+}
+
+void CJX_Field::execInitialize(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false,
+ false);
+}
+
+void CJX_Field::deleteItem(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"deleteItem");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData)
+ return;
+
+ int32_t iIndex = pArguments->GetInt32(0);
+ bool bValue = pWidgetData->DeleteItem(iIndex, true, true);
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetBoolean(bValue);
+}
+
+void CJX_Field::getSaveItem(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"getSaveItem");
+ return;
+ }
+
+ int32_t iIndex = pArguments->GetInt32(0);
+ if (iIndex < 0) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+
+ pdfium::Optional<WideString> value =
+ pWidgetData->GetChoiceListItem(iIndex, true);
+ if (!value) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+ pArguments->GetReturnValue()->SetString(value->UTF8Encode().AsStringView());
+}
+
+void CJX_Field::boundItem(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"boundItem");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData)
+ return;
+
+ ByteString bsValue = pArguments->GetUTF8String(0);
+ WideString wsValue = WideString::FromUTF8(bsValue.AsStringView());
+ WideString wsBoundValue = pWidgetData->GetItemValue(wsValue.AsStringView());
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetString(wsBoundValue.UTF8Encode().AsStringView());
+}
+
+void CJX_Field::getItemState(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"getItemState");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData)
+ return;
+
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetBoolean(pWidgetData->GetItemState(pArguments->GetInt32(0)));
+}
+
+void CJX_Field::execCalculate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false,
+ false);
+}
+
+void CJX_Field::getDisplayItem(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"getDisplayItem");
+ return;
+ }
+
+ int32_t iIndex = pArguments->GetInt32(0);
+ if (iIndex < 0) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+
+ pdfium::Optional<WideString> value =
+ pWidgetData->GetChoiceListItem(iIndex, false);
+ if (!value) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+ pArguments->GetReturnValue()->SetString(value->UTF8Encode().AsStringView());
+}
+
+void CJX_Field::setItemState(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 2) {
+ ThrowParamCountMismatchException(L"setItemState");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData)
+ return;
+
+ int32_t iIndex = pArguments->GetInt32(0);
+ if (pArguments->GetInt32(1) != 0) {
+ pWidgetData->SetItemState(iIndex, true, true, true, true);
+ return;
+ }
+
+ if (pWidgetData->GetItemState(iIndex))
+ pWidgetData->SetItemState(iIndex, false, true, true, true);
+}
+
+void CJX_Field::addItem(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 1 || iLength > 2) {
+ ThrowParamCountMismatchException(L"addItem");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData)
+ return;
+
+ WideString wsLabel;
+ if (iLength >= 1) {
+ ByteString bsLabel = pArguments->GetUTF8String(0);
+ wsLabel = WideString::FromUTF8(bsLabel.AsStringView());
+ }
+
+ WideString wsValue;
+ if (iLength >= 2) {
+ ByteString bsValue = pArguments->GetUTF8String(1);
+ wsValue = WideString::FromUTF8(bsValue.AsStringView());
+ }
+
+ pWidgetData->InsertItem(wsLabel, wsValue, true);
+}
+
+void CJX_Field::execValidate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+
+ int32_t iRet = pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate,
+ false, false);
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
+}
diff --git a/fxjs/xfa/cjx_field.h b/fxjs/xfa/cjx_field.h
new file mode 100644
index 0000000000..524a6afdaa
--- /dev/null
+++ b/fxjs/xfa/cjx_field.h
@@ -0,0 +1,37 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_FIELD_H_
+#define FXJS_XFA_CJX_FIELD_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/xfa/cjx_container.h"
+
+class CXFA_Field;
+
+class CJX_Field : public CJX_Container {
+ public:
+ explicit CJX_Field(CXFA_Field* field);
+ ~CJX_Field() override;
+
+ JS_METHOD(addItem, CJX_Field);
+ JS_METHOD(boundItem, CJX_Field);
+ JS_METHOD(clearItems, CJX_Field);
+ JS_METHOD(deleteItem, CJX_Field);
+ JS_METHOD(execCalculate, CJX_Field);
+ JS_METHOD(execEvent, CJX_Field);
+ JS_METHOD(execInitialize, CJX_Field);
+ JS_METHOD(execValidate, CJX_Field);
+ JS_METHOD(getDisplayItem, CJX_Field);
+ JS_METHOD(getItemState, CJX_Field);
+ JS_METHOD(getSaveItem, CJX_Field);
+ JS_METHOD(setItemState, CJX_Field);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_FIELD_H_
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp
new file mode 100644
index 0000000000..106910c6c1
--- /dev/null
+++ b/fxjs/xfa/cjx_form.cpp
@@ -0,0 +1,128 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_form.h"
+
+#include <vector>
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/cxfa_eventparam.h"
+#include "xfa/fxfa/cxfa_ffnotify.h"
+#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_form.h"
+
+const CJX_MethodSpec CJX_Form::MethodSpecs[] = {
+ {"execCalculate", execCalculate_static},
+ {"execInitialize", execInitialize_static},
+ {"execValidate", execValidate_static},
+ {"formNodes", formNodes_static},
+ {"recalculate", recalculate_static},
+ {"remerge", remerge_static},
+ {"", nullptr}};
+
+CJX_Form::CJX_Form(CXFA_Form* form) : CJX_Model(form) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Form::~CJX_Form() {}
+
+void CJX_Form::formNodes(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"formNodes");
+ return;
+ }
+
+ CXFA_Node* pDataNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ if (!pDataNode) {
+ ThrowArgumentMismatchException();
+ return;
+ }
+
+ std::vector<CXFA_Node*> formItems;
+ CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
+ pFormNodes->SetArrayNodeList(formItems);
+ pArguments->GetReturnValue()->SetObject(
+ pFormNodes, GetDocument()->GetScriptContext()->GetJseNormalClass());
+}
+
+void CJX_Form::remerge(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"remerge");
+ return;
+ }
+
+ GetDocument()->DoDataRemerge(true);
+}
+
+void CJX_Form::execInitialize(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+}
+
+void CJX_Form::recalculate(CFXJSE_Arguments* pArguments) {
+ CXFA_EventParam* pEventParam =
+ GetDocument()->GetScriptContext()->GetEventParam();
+ if (pEventParam->m_eType == XFA_EVENT_Calculate ||
+ pEventParam->m_eType == XFA_EVENT_InitCalculate) {
+ return;
+ }
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"recalculate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+ if (pArguments->GetInt32(0) != 0)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Ready, true);
+}
+
+void CJX_Form::execCalculate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+}
+
+void CJX_Form::execValidate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+
+ int32_t iRet =
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
+}
diff --git a/fxjs/xfa/cjx_form.h b/fxjs/xfa/cjx_form.h
new file mode 100644
index 0000000000..e4d64daca0
--- /dev/null
+++ b/fxjs/xfa/cjx_form.h
@@ -0,0 +1,31 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_FORM_H_
+#define FXJS_XFA_CJX_FORM_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/xfa/cjx_model.h"
+
+class CXFA_Form;
+
+class CJX_Form : public CJX_Model {
+ public:
+ explicit CJX_Form(CXFA_Form* form);
+ ~CJX_Form() override;
+
+ JS_METHOD(execCalculate, CJX_Form);
+ JS_METHOD(execInitialize, CJX_Form);
+ JS_METHOD(execValidate, CJX_Form);
+ JS_METHOD(formNodes, CJX_Form);
+ JS_METHOD(recalculate, CJX_Form);
+ JS_METHOD(remerge, CJX_Form);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_FORM_H_
diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp
new file mode 100644
index 0000000000..da8422ea35
--- /dev/null
+++ b/fxjs/xfa/cjx_instancemanager.cpp
@@ -0,0 +1,180 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_instancemanager.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/cxfa_ffnotify.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_instancemanager.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
+#include "xfa/fxfa/parser/cxfa_occurdata.h"
+
+const CJX_MethodSpec CJX_InstanceManager::MethodSpecs[] = {
+ {"addInstance", addInstance_static},
+ {"insertInstance", insertInstance_static},
+ {"moveInstance", moveInstance_static},
+ {"removeInstance", removeInstance_static},
+ {"setInstances", setInstances_static},
+ {"", nullptr}};
+
+CJX_InstanceManager::CJX_InstanceManager(CXFA_InstanceManager* mgr)
+ : CJX_Node(mgr) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_InstanceManager::~CJX_InstanceManager() {}
+
+void CJX_InstanceManager::moveInstance(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 2) {
+ pArguments->GetReturnValue()->SetUndefined();
+ return;
+ }
+
+ int32_t iFrom = pArguments->GetInt32(0);
+ int32_t iTo = pArguments->GetInt32(1);
+ InstanceManager_MoveInstance(iTo, iFrom);
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_Node* pToInstance = GetXFANode()->GetItem(iTo);
+ if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform)
+ pNotify->RunSubformIndexChange(pToInstance);
+
+ CXFA_Node* pFromInstance = GetXFANode()->GetItem(iFrom);
+ if (pFromInstance &&
+ pFromInstance->GetElementType() == XFA_Element::Subform) {
+ pNotify->RunSubformIndexChange(pFromInstance);
+ }
+}
+
+void CJX_InstanceManager::removeInstance(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ pArguments->GetReturnValue()->SetUndefined();
+ return;
+ }
+
+ int32_t iIndex = pArguments->GetInt32(0);
+ int32_t iCount = GetXFANode()->GetCount();
+ if (iIndex < 0 || iIndex >= iCount) {
+ ThrowIndexOutOfBoundsException();
+ return;
+ }
+
+ int32_t iMin = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMin();
+ if (iCount - 1 < iMin) {
+ ThrowTooManyOccurancesException(L"min");
+ return;
+ }
+
+ CXFA_Node* pRemoveInstance = GetXFANode()->GetItem(iIndex);
+ GetXFANode()->RemoveItem(pRemoveInstance, true);
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (pNotify) {
+ for (int32_t i = iIndex; i < iCount - 1; i++) {
+ CXFA_Node* pSubformInstance = GetXFANode()->GetItem(i);
+ if (pSubformInstance &&
+ pSubformInstance->GetElementType() == XFA_Element::Subform) {
+ pNotify->RunSubformIndexChange(pSubformInstance);
+ }
+ }
+ }
+ CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
+ if (!pLayoutPro)
+ return;
+
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+}
+
+void CJX_InstanceManager::setInstances(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ pArguments->GetReturnValue()->SetUndefined();
+ return;
+ }
+
+ int32_t iDesired = pArguments->GetInt32(0);
+ InstanceManager_SetInstances(iDesired);
+}
+
+void CJX_InstanceManager::addInstance(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 0 && argc != 1) {
+ ThrowParamCountMismatchException(L"addInstance");
+ return;
+ }
+
+ bool fFlags = true;
+ if (argc == 1)
+ fFlags = pArguments->GetInt32(0) == 0 ? false : true;
+
+ int32_t iCount = GetXFANode()->GetCount();
+ int32_t iMax = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax();
+ if (iMax >= 0 && iCount >= iMax) {
+ ThrowTooManyOccurancesException(L"max");
+ return;
+ }
+
+ CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(fFlags);
+ GetXFANode()->InsertItem(pNewInstance, iCount, iCount, false);
+ pArguments->GetReturnValue()->Assign(
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance));
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->RunNodeInitialize(pNewInstance);
+ CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
+ if (!pLayoutPro)
+ return;
+
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+}
+
+void CJX_InstanceManager::insertInstance(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 1 && argc != 2) {
+ ThrowParamCountMismatchException(L"insertInstance");
+ return;
+ }
+
+ int32_t iIndex = pArguments->GetInt32(0);
+ bool bBind = false;
+ if (argc == 2)
+ bBind = pArguments->GetInt32(1) == 0 ? false : true;
+
+ int32_t iCount = GetXFANode()->GetCount();
+ if (iIndex < 0 || iIndex > iCount) {
+ ThrowIndexOutOfBoundsException();
+ return;
+ }
+
+ int32_t iMax = CXFA_OccurData(GetXFANode()->GetOccurNode()).GetMax();
+ if (iMax >= 0 && iCount >= iMax) {
+ ThrowTooManyOccurancesException(L"max");
+ return;
+ }
+
+ CXFA_Node* pNewInstance = GetXFANode()->CreateInstance(bBind);
+ GetXFANode()->InsertItem(pNewInstance, iIndex, iCount, true);
+ pArguments->GetReturnValue()->Assign(
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewInstance));
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->RunNodeInitialize(pNewInstance);
+ CXFA_LayoutProcessor* pLayoutPro = GetDocument()->GetLayoutProcessor();
+ if (!pLayoutPro)
+ return;
+
+ pLayoutPro->AddChangedContainer(
+ ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form)));
+}
diff --git a/fxjs/xfa/cjx_instancemanager.h b/fxjs/xfa/cjx_instancemanager.h
new file mode 100644
index 0000000000..a312366b3b
--- /dev/null
+++ b/fxjs/xfa/cjx_instancemanager.h
@@ -0,0 +1,30 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_INSTANCEMANAGER_H_
+#define FXJS_XFA_CJX_INSTANCEMANAGER_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_InstanceManager;
+
+class CJX_InstanceManager : public CJX_Node {
+ public:
+ explicit CJX_InstanceManager(CXFA_InstanceManager* mgr);
+ ~CJX_InstanceManager() override;
+
+ JS_METHOD(addInstance, CJX_InstanceManager);
+ JS_METHOD(insertInstance, CJX_InstanceManager);
+ JS_METHOD(moveInstance, CJX_InstanceManager);
+ JS_METHOD(removeInstance, CJX_InstanceManager);
+ JS_METHOD(setInstances, CJX_InstanceManager);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_INSTANCEMANAGER_H_
diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp
new file mode 100644
index 0000000000..34cf9da7a5
--- /dev/null
+++ b/fxjs/xfa/cjx_list.cpp
@@ -0,0 +1,103 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_list.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_list.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+
+const CJX_MethodSpec CJX_List::MethodSpecs[] = {{"append", append_static},
+ {"insert", insert_static},
+ {"item", item_static},
+ {"remove", remove_static},
+ {"", nullptr}};
+
+CJX_List::CJX_List(CXFA_List* list) : CJX_Object(list) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_List::~CJX_List() {}
+
+CXFA_List* CJX_List::GetXFAList() {
+ return static_cast<CXFA_List*>(GetXFAObject());
+}
+
+void CJX_List::append(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 1) {
+ ThrowParamCountMismatchException(L"append");
+ return;
+ }
+
+ auto* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ if (!pNode) {
+ ThrowArgumentMismatchException();
+ return;
+ }
+ GetXFAList()->Append(pNode);
+}
+
+void CJX_List::insert(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 2) {
+ ThrowParamCountMismatchException(L"insert");
+ return;
+ }
+
+ auto* pNewNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ auto* pBeforeNode = static_cast<CXFA_Node*>(pArguments->GetObject(1));
+ if (!pNewNode) {
+ ThrowArgumentMismatchException();
+ return;
+ }
+ GetXFAList()->Insert(pNewNode, pBeforeNode);
+}
+
+void CJX_List::remove(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 1) {
+ ThrowParamCountMismatchException(L"remove");
+ return;
+ }
+
+ auto* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ if (!pNode) {
+ ThrowArgumentMismatchException();
+ return;
+ }
+ GetXFAList()->Remove(pNode);
+}
+
+void CJX_List::item(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 1) {
+ ThrowParamCountMismatchException(L"item");
+ return;
+ }
+
+ int32_t iIndex = pArguments->GetInt32(0);
+ if (iIndex < 0 || iIndex >= GetXFAList()->GetLength()) {
+ ThrowIndexOutOfBoundsException();
+ return;
+ }
+ pArguments->GetReturnValue()->Assign(
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(
+ GetXFAList()->Item(iIndex)));
+}
+
+void CJX_List::length(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute) {
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+ pValue->SetInteger(GetXFAList()->GetLength());
+}
diff --git a/fxjs/xfa/cjx_list.h b/fxjs/xfa/cjx_list.h
new file mode 100644
index 0000000000..b4a002551a
--- /dev/null
+++ b/fxjs/xfa/cjx_list.h
@@ -0,0 +1,33 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_LIST_H_
+#define FXJS_XFA_CJX_LIST_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_object.h"
+
+class CXFA_List;
+
+class CJX_List : public CJX_Object {
+ public:
+ explicit CJX_List(CXFA_List* list);
+ ~CJX_List() override;
+
+ JS_METHOD(append, CJX_List);
+ JS_METHOD(insert, CJX_List);
+ JS_METHOD(item, CJX_List);
+ JS_METHOD(remove, CJX_List);
+
+ void length(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute);
+
+ private:
+ CXFA_List* GetXFAList();
+
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_LIST_H_
diff --git a/fxjs/xfa/cjx_manifest.cpp b/fxjs/xfa/cjx_manifest.cpp
new file mode 100644
index 0000000000..066ba29e15
--- /dev/null
+++ b/fxjs/xfa/cjx_manifest.cpp
@@ -0,0 +1,35 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_manifest.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_manifest.h"
+
+const CJX_MethodSpec CJX_Manifest::MethodSpecs[] = {
+ {"evaluate", evaluate_static},
+ {"", nullptr}};
+
+CJX_Manifest::CJX_Manifest(CXFA_Manifest* manifest) : CJX_Node(manifest) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Manifest::~CJX_Manifest() {}
+
+void CJX_Manifest::evaluate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"evaluate");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(true);
+}
diff --git a/fxjs/xfa/cjx_manifest.h b/fxjs/xfa/cjx_manifest.h
new file mode 100644
index 0000000000..167ef46b6e
--- /dev/null
+++ b/fxjs/xfa/cjx_manifest.h
@@ -0,0 +1,26 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_MANIFEST_H_
+#define FXJS_XFA_CJX_MANIFEST_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_Manifest;
+
+class CJX_Manifest : public CJX_Node {
+ public:
+ explicit CJX_Manifest(CXFA_Manifest* manifest);
+ ~CJX_Manifest() override;
+
+ JS_METHOD(evaluate, CJX_Manifest);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_MANIFEST_H_
diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp
new file mode 100644
index 0000000000..cd738b0018
--- /dev/null
+++ b/fxjs/xfa/cjx_model.cpp
@@ -0,0 +1,94 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_model.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_delta.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+
+const CJX_MethodSpec CJX_Model::MethodSpecs[] = {
+ {"clearErrorList", clearErrorList_static},
+ {"createNode", createNode_static},
+ {"isCompatibleNS", isCompatibleNS_static},
+ {"", nullptr}};
+
+CJX_Model::CJX_Model(CXFA_Node* node) : CJX_Node(node) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Model::~CJX_Model() {}
+
+void CJX_Model::clearErrorList(CFXJSE_Arguments* pArguments) {}
+
+void CJX_Model::createNode(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc <= 0 || argc >= 4) {
+ ThrowParamCountMismatchException(L"createNode");
+ return;
+ }
+
+ WideString strName;
+ WideString strNameSpace;
+ if (argc > 1) {
+ ByteString bsName = pArguments->GetUTF8String(1);
+ strName = WideString::FromUTF8(bsName.AsStringView());
+ if (argc == 3) {
+ ByteString bsNameSpace = pArguments->GetUTF8String(2);
+ strNameSpace = WideString::FromUTF8(bsNameSpace.AsStringView());
+ }
+ }
+
+ ByteString bsTagName = pArguments->GetUTF8String(0);
+ WideString strTagName = WideString::FromUTF8(bsTagName.AsStringView());
+ XFA_Element eType = CXFA_Node::NameToElement(strTagName);
+ CXFA_Node* pNewNode = GetXFANode()->CreateSamePacketNode(eType);
+ if (!pNewNode) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+
+ if (strName.IsEmpty()) {
+ pArguments->GetReturnValue()->Assign(
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode));
+ return;
+ }
+
+ if (!pNewNode->HasAttribute(XFA_Attribute::Name)) {
+ ThrowMissingPropertyException(strTagName, L"name");
+ return;
+ }
+
+ pNewNode->JSNode()->SetAttribute(XFA_Attribute::Name, strName.AsStringView(),
+ true);
+ if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
+ pNewNode->CreateXMLMappingNode();
+
+ pArguments->GetReturnValue()->Assign(
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNewNode));
+}
+
+void CJX_Model::isCompatibleNS(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 1) {
+ ThrowParamCountMismatchException(L"isCompatibleNS");
+ return;
+ }
+
+ WideString wsNameSpace;
+ if (iLength >= 1) {
+ ByteString bsNameSpace = pArguments->GetUTF8String(0);
+ wsNameSpace = WideString::FromUTF8(bsNameSpace.AsStringView());
+ }
+
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (!pValue)
+ return;
+
+ pValue->SetBoolean(TryNamespace().value_or(WideString()) == wsNameSpace);
+}
diff --git a/fxjs/xfa/cjx_model.h b/fxjs/xfa/cjx_model.h
new file mode 100644
index 0000000000..f4e6ac9406
--- /dev/null
+++ b/fxjs/xfa/cjx_model.h
@@ -0,0 +1,28 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_MODEL_H_
+#define FXJS_XFA_CJX_MODEL_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_Node;
+
+class CJX_Model : public CJX_Node {
+ public:
+ explicit CJX_Model(CXFA_Node* obj);
+ ~CJX_Model() override;
+
+ JS_METHOD(clearErrorList, CJX_Model);
+ JS_METHOD(createNode, CJX_Model);
+ JS_METHOD(isCompatibleNS, CJX_Model);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_MODEL_H_
diff --git a/fxjs/xfa/cjx_packet.cpp b/fxjs/xfa/cjx_packet.cpp
new file mode 100644
index 0000000000..b1424d27e7
--- /dev/null
+++ b/fxjs/xfa/cjx_packet.cpp
@@ -0,0 +1,75 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_packet.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_packet.h"
+
+const CJX_MethodSpec CJX_Packet::MethodSpecs[] = {
+ {"getAttribute", getAttribute_static},
+ {"removeAttribute", removeAttribute_static},
+ {"setAttribute", setAttribute_static},
+ {"", nullptr}};
+
+CJX_Packet::CJX_Packet(CXFA_Packet* packet) : CJX_Node(packet) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Packet::~CJX_Packet() {}
+
+void CJX_Packet::getAttribute(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"getAttribute");
+ return;
+ }
+
+ WideString wsAttributeValue;
+ CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
+ if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
+ ByteString bsAttributeName = pArguments->GetUTF8String(0);
+ wsAttributeValue = static_cast<CFX_XMLElement*>(pXMLNode)->GetString(
+ WideString::FromUTF8(bsAttributeName.AsStringView()).c_str());
+ }
+
+ pArguments->GetReturnValue()->SetString(
+ wsAttributeValue.UTF8Encode().AsStringView());
+}
+
+void CJX_Packet::setAttribute(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 2) {
+ ThrowParamCountMismatchException(L"setAttribute");
+ return;
+ }
+
+ CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
+ if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
+ ByteString bsValue = pArguments->GetUTF8String(0);
+ ByteString bsName = pArguments->GetUTF8String(1);
+ static_cast<CFX_XMLElement*>(pXMLNode)->SetString(
+ WideString::FromUTF8(bsName.AsStringView()),
+ WideString::FromUTF8(bsValue.AsStringView()));
+ }
+ pArguments->GetReturnValue()->SetNull();
+}
+
+void CJX_Packet::removeAttribute(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"removeAttribute");
+ return;
+ }
+
+ CFX_XMLNode* pXMLNode = GetXFANode()->GetXMLMappingNode();
+ if (pXMLNode && pXMLNode->GetType() == FX_XMLNODE_Element) {
+ ByteString bsName = pArguments->GetUTF8String(0);
+ WideString wsName = WideString::FromUTF8(bsName.AsStringView());
+ CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
+ if (pXMLElement->HasAttribute(wsName.c_str()))
+ pXMLElement->RemoveAttribute(wsName.c_str());
+ }
+ pArguments->GetReturnValue()->SetNull();
+}
diff --git a/fxjs/xfa/cjx_packet.h b/fxjs/xfa/cjx_packet.h
new file mode 100644
index 0000000000..80520e2751
--- /dev/null
+++ b/fxjs/xfa/cjx_packet.h
@@ -0,0 +1,28 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_PACKET_H_
+#define FXJS_XFA_CJX_PACKET_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_Packet;
+
+class CJX_Packet : public CJX_Node {
+ public:
+ explicit CJX_Packet(CXFA_Packet* packet);
+ ~CJX_Packet() override;
+
+ JS_METHOD(getAttribute, CJX_Packet);
+ JS_METHOD(removeAttribute, CJX_Packet);
+ JS_METHOD(setAttribute, CJX_Packet);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_PACKET_H_
diff --git a/fxjs/xfa/cjx_source.cpp b/fxjs/xfa/cjx_source.cpp
new file mode 100644
index 0000000000..3197231811
--- /dev/null
+++ b/fxjs/xfa/cjx_source.cpp
@@ -0,0 +1,122 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_source.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_source.h"
+
+const CJX_MethodSpec CJX_Source::MethodSpecs[] = {
+ {"addNew", addNew_static},
+ {"cancel", cancel_static},
+ {"cancelBatch", cancelBatch_static},
+ {"close", close_static},
+ {"delete", deleteItem_static},
+ {"first", first_static},
+ {"hasDataChanged", hasDataChanged_static},
+ {"isBOF", isBOF_static},
+ {"isEOF", isEOF_static},
+ {"last", last_static},
+ {"next", next_static},
+ {"open", open_static},
+ {"previous", previous_static},
+ {"requery", requery_static},
+ {"resync", resync_static},
+ {"update", update_static},
+ {"updateBatch", updateBatch_static},
+ {"", nullptr}};
+
+CJX_Source::CJX_Source(CXFA_Source* src) : CJX_Node(src) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Source::~CJX_Source() {}
+
+void CJX_Source::next(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"next");
+}
+
+void CJX_Source::cancelBatch(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"cancelBatch");
+}
+
+void CJX_Source::first(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"first");
+}
+
+void CJX_Source::updateBatch(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"updateBatch");
+}
+
+void CJX_Source::previous(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"previous");
+}
+
+void CJX_Source::isBOF(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"isBOF");
+}
+
+void CJX_Source::isEOF(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"isEOF");
+}
+
+void CJX_Source::cancel(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"cancel");
+}
+
+void CJX_Source::update(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"update");
+}
+
+void CJX_Source::open(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"open");
+}
+
+void CJX_Source::deleteItem(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"delete");
+}
+
+void CJX_Source::addNew(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"addNew");
+}
+
+void CJX_Source::requery(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"requery");
+}
+
+void CJX_Source::resync(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"resync");
+}
+
+void CJX_Source::close(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"close");
+}
+
+void CJX_Source::last(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"last");
+}
+
+void CJX_Source::hasDataChanged(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0)
+ ThrowParamCountMismatchException(L"hasDataChanged");
+}
diff --git a/fxjs/xfa/cjx_source.h b/fxjs/xfa/cjx_source.h
new file mode 100644
index 0000000000..1502e0e807
--- /dev/null
+++ b/fxjs/xfa/cjx_source.h
@@ -0,0 +1,42 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_SOURCE_H_
+#define FXJS_XFA_CJX_SOURCE_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_Source;
+
+class CJX_Source : public CJX_Node {
+ public:
+ explicit CJX_Source(CXFA_Source* src);
+ ~CJX_Source() override;
+
+ JS_METHOD(addNew, CJX_Source);
+ JS_METHOD(cancel, CJX_Source);
+ JS_METHOD(cancelBatch, CJX_Source);
+ JS_METHOD(close, CJX_Source);
+ JS_METHOD(deleteItem /*delete*/, CJX_Source);
+ JS_METHOD(first, CJX_Source);
+ JS_METHOD(hasDataChanged, CJX_Source);
+ JS_METHOD(isBOF, CJX_Source);
+ JS_METHOD(isEOF, CJX_Source);
+ JS_METHOD(last, CJX_Source);
+ JS_METHOD(next, CJX_Source);
+ JS_METHOD(open, CJX_Source);
+ JS_METHOD(previous, CJX_Source);
+ JS_METHOD(requery, CJX_Source);
+ JS_METHOD(resync, CJX_Source);
+ JS_METHOD(update, CJX_Source);
+ JS_METHOD(updateBatch, CJX_Source);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_SOURCE_H_
diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp
new file mode 100644
index 0000000000..32de182e7b
--- /dev/null
+++ b/fxjs/xfa/cjx_subform.cpp
@@ -0,0 +1,84 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_subform.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/cxfa_eventparam.h"
+#include "xfa/fxfa/cxfa_ffnotify.h"
+#include "xfa/fxfa/fxfa.h"
+#include "xfa/fxfa/parser/cxfa_delta.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+
+const CJX_MethodSpec CJX_Subform::MethodSpecs[] = {
+ {"execCalculate", execCalculate_static},
+ {"execEvent", execEvent_static},
+ {"execInitialize", execInitialize_static},
+ {"execValidate", execValidate_static},
+ {"", nullptr}};
+
+CJX_Subform::CJX_Subform(CXFA_Node* node) : CJX_Container(node) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Subform::~CJX_Subform() {}
+
+void CJX_Subform::execEvent(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"execEvent");
+ return;
+ }
+
+ ByteString eventString = pArguments->GetUTF8String(0);
+ execSingleEventByName(
+ WideString::FromUTF8(eventString.AsStringView()).AsStringView(),
+ XFA_Element::Subform);
+}
+
+void CJX_Subform::execInitialize(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize);
+}
+
+void CJX_Subform::execCalculate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate);
+}
+
+void CJX_Subform::execValidate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
+ if (!pNotify) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+
+ int32_t iRet =
+ pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate);
+ pArguments->GetReturnValue()->SetBoolean(
+ (iRet == XFA_EVENTERROR_Error) ? false : true);
+}
diff --git a/fxjs/xfa/cjx_subform.h b/fxjs/xfa/cjx_subform.h
new file mode 100644
index 0000000000..a0227f08dd
--- /dev/null
+++ b/fxjs/xfa/cjx_subform.h
@@ -0,0 +1,29 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_SUBFORM_H_
+#define FXJS_XFA_CJX_SUBFORM_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/xfa/cjx_container.h"
+
+class CXFA_Delta;
+
+class CJX_Subform : public CJX_Container {
+ public:
+ explicit CJX_Subform(CXFA_Node* container);
+ ~CJX_Subform() override;
+
+ JS_METHOD(execCalculate, CJX_Subform);
+ JS_METHOD(execEvent, CJX_Subform);
+ JS_METHOD(execInitialize, CJX_Subform);
+ JS_METHOD(execValidate, CJX_Subform);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_SUBFORM_H_
diff --git a/fxjs/xfa/cjx_template.cpp b/fxjs/xfa/cjx_template.cpp
new file mode 100644
index 0000000000..99db4ea69a
--- /dev/null
+++ b/fxjs/xfa/cjx_template.cpp
@@ -0,0 +1,87 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_template.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_template.h"
+
+const CJX_MethodSpec CJX_Template::MethodSpecs[] = {
+ {"execCalculate", execCalculate_static},
+ {"execInitialize", execInitialize_static},
+ {"execValidate", execValidate_static},
+ {"formNodes", formNodes_static},
+ {"recalculate", recalculate_static},
+ {"remerge", remerge_static},
+ {"", nullptr}};
+
+CJX_Template::CJX_Template(CXFA_Template* tmpl) : CJX_Model(tmpl) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Template::~CJX_Template() {}
+
+void CJX_Template::formNodes(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"formNodes");
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(true);
+}
+
+void CJX_Template::remerge(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"remerge");
+ return;
+ }
+ GetDocument()->DoDataRemerge(true);
+}
+
+void CJX_Template::execInitialize(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execInitialize");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(true);
+}
+
+void CJX_Template::recalculate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"recalculate");
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(true);
+}
+
+void CJX_Template::execCalculate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execCalculate");
+ return;
+ }
+
+ CXFA_WidgetData* pWidgetData = GetXFANode()->GetWidgetData();
+ if (!pWidgetData) {
+ pArguments->GetReturnValue()->SetBoolean(false);
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(true);
+}
+
+void CJX_Template::execValidate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"execValidate");
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(!!GetXFANode()->GetWidgetData());
+}
diff --git a/fxjs/xfa/cjx_template.h b/fxjs/xfa/cjx_template.h
new file mode 100644
index 0000000000..2c82788153
--- /dev/null
+++ b/fxjs/xfa/cjx_template.h
@@ -0,0 +1,34 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_TEMPLATE_H_
+#define FXJS_XFA_CJX_TEMPLATE_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/xfa/cjx_model.h"
+
+class CXFA_Template;
+
+class CJX_Template : public CJX_Model {
+ public:
+ explicit CJX_Template(CXFA_Template* tmpl);
+ ~CJX_Template() override;
+
+ /* The docs list a |createNode| method on Template but that method already
+ * exists on Model, also the |createNode| docs say it exists on Model not
+ * on Template so I'm leaving |createNode| out of the template methods. */
+ JS_METHOD(execCalculate, CJX_Template);
+ JS_METHOD(execInitialize, CJX_Template);
+ JS_METHOD(execValidate, CJX_Template);
+ JS_METHOD(formNodes, CJX_Template);
+ JS_METHOD(recalculate, CJX_Template);
+ JS_METHOD(remerge, CJX_Template);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_TEMPLATE_H_
diff --git a/fxjs/xfa/cjx_textnode.cpp b/fxjs/xfa/cjx_textnode.cpp
new file mode 100644
index 0000000000..4ebf3ce472
--- /dev/null
+++ b/fxjs/xfa/cjx_textnode.cpp
@@ -0,0 +1,15 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_textnode.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+
+CJX_TextNode::CJX_TextNode(CXFA_Node* node) : CJX_Node(node) {}
+
+CJX_TextNode::~CJX_TextNode() {}
diff --git a/fxjs/xfa/cjx_textnode.h b/fxjs/xfa/cjx_textnode.h
new file mode 100644
index 0000000000..1fa84d8d52
--- /dev/null
+++ b/fxjs/xfa/cjx_textnode.h
@@ -0,0 +1,21 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_TEXTNODE_H_
+#define FXJS_XFA_CJX_TEXTNODE_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_Node;
+
+class CJX_TextNode : public CJX_Node {
+ public:
+ explicit CJX_TextNode(CXFA_Node* node);
+ ~CJX_TextNode() override;
+};
+
+#endif // FXJS_XFA_CJX_TEXTNODE_H_
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
new file mode 100644
index 0000000000..69cbfa0652
--- /dev/null
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -0,0 +1,230 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_tree.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cfxjse_value.h"
+#include "third_party/base/ptr_util.h"
+#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
+#include "xfa/fxfa/parser/cxfa_attachnodelist.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_object.h"
+#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
+
+const CJX_MethodSpec CJX_Tree::MethodSpecs[] = {
+ {"resolveNode", resolveNode_static},
+ {"resolveNodes", resolveNodes_static},
+ {"", nullptr}};
+
+CJX_Tree::CJX_Tree(CXFA_Object* obj) : CJX_Object(obj) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_Tree::~CJX_Tree() {}
+
+void CJX_Tree::resolveNode(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"resolveNode");
+ return;
+ }
+ WideString wsExpression =
+ WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
+ CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+ CXFA_Object* refNode = GetXFAObject();
+ if (refNode->GetElementType() == XFA_Element::Xfa)
+ refNode = pScriptContext->GetThisObject();
+ uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
+ XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
+ XFA_RESOLVENODE_RS resolveNodeRS;
+ if (!pScriptContext->ResolveObjects(ToNode(refNode),
+ wsExpression.AsStringView(),
+ &resolveNodeRS, dwFlag, nullptr)) {
+ pArguments->GetReturnValue()->SetNull();
+ return;
+ }
+ if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) {
+ CXFA_Object* pObject = resolveNodeRS.objects.front();
+ pArguments->GetReturnValue()->Assign(
+ pScriptContext->GetJSValueFromMap(pObject));
+ } else {
+ const XFA_SCRIPTATTRIBUTEINFO* lpAttributeInfo =
+ resolveNodeRS.pScriptAttribute;
+ if (lpAttributeInfo &&
+ lpAttributeInfo->eValueType == XFA_ScriptType::Object) {
+ auto pValue =
+ pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetRuntime());
+ CJX_Object* jsObject = resolveNodeRS.objects.front()->JSObject();
+ (jsObject->*(lpAttributeInfo->callback))(pValue.get(), false,
+ lpAttributeInfo->attribute);
+ pArguments->GetReturnValue()->Assign(pValue.get());
+ } else {
+ pArguments->GetReturnValue()->SetNull();
+ }
+ }
+}
+
+void CJX_Tree::resolveNodes(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"resolveNodes");
+ return;
+ }
+
+ WideString wsExpression =
+ WideString::FromUTF8(pArguments->GetUTF8String(0).AsStringView());
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (!pValue)
+ return;
+
+ CXFA_Object* refNode = GetXFAObject();
+ if (refNode->GetElementType() == XFA_Element::Xfa)
+ refNode = GetDocument()->GetScriptContext()->GetThisObject();
+
+ ResolveNodeList(pValue, wsExpression,
+ XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Attributes |
+ XFA_RESOLVENODE_Properties | XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings,
+ ToNode(refNode));
+}
+
+void CJX_Tree::all(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute) {
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+
+ uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
+ WideString wsExpression = GetAttribute(XFA_Attribute::Name) + L"[*]";
+ ResolveNodeList(pValue, wsExpression, dwFlag, nullptr);
+}
+
+void CJX_Tree::classAll(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute) {
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+
+ WideString wsExpression = L"#" + GetXFAObject()->GetClassName() + L"[*]";
+ ResolveNodeList(pValue, wsExpression,
+ XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL, nullptr);
+}
+
+void CJX_Tree::nodes(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute) {
+ CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+
+ if (bSetting) {
+ WideString wsMessage = L"Unable to set ";
+ FXJSE_ThrowMessage(wsMessage.UTF8Encode().AsStringView());
+ return;
+ }
+
+ CXFA_AttachNodeList* pNodeList =
+ new CXFA_AttachNodeList(GetDocument(), ToNode(GetXFAObject()));
+ pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass());
+}
+
+void CJX_Tree::parent(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute) {
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+
+ CXFA_Node* pParent = ToNode(GetXFAObject())->GetNodeItem(XFA_NODEITEM_Parent);
+ if (!pParent) {
+ pValue->SetNull();
+ return;
+ }
+
+ pValue->Assign(GetDocument()->GetScriptContext()->GetJSValueFromMap(pParent));
+}
+
+void CJX_Tree::index(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute) {
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+ pValue->SetInteger(ToNode(GetXFAObject())->GetNodeSameNameIndex());
+}
+
+void CJX_Tree::classIndex(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute) {
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+ pValue->SetInteger(ToNode(GetXFAObject())->GetNodeSameClassIndex());
+}
+
+void CJX_Tree::somExpression(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute) {
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+
+ WideString wsSOMExpression;
+ GetXFAObject()->GetSOMExpression(wsSOMExpression);
+ pValue->SetString(wsSOMExpression.UTF8Encode().AsStringView());
+}
+
+void CJX_Tree::ResolveNodeList(CFXJSE_Value* pValue,
+ WideString wsExpression,
+ uint32_t dwFlag,
+ CXFA_Node* refNode) {
+ CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+ if (!refNode)
+ refNode = ToNode(GetXFAObject());
+
+ XFA_RESOLVENODE_RS resolveNodeRS;
+ pScriptContext->ResolveObjects(refNode, wsExpression.AsStringView(),
+ &resolveNodeRS, dwFlag, nullptr);
+ CXFA_ArrayNodeList* pNodeList = new CXFA_ArrayNodeList(GetDocument());
+ if (resolveNodeRS.dwFlags == XFA_ResolveNode_RSType_Nodes) {
+ for (CXFA_Object* pObject : resolveNodeRS.objects) {
+ if (pObject->IsNode())
+ pNodeList->Append(pObject->AsNode());
+ }
+ } else {
+ if (resolveNodeRS.pScriptAttribute &&
+ resolveNodeRS.pScriptAttribute->eValueType == XFA_ScriptType::Object) {
+ for (CXFA_Object* pObject : resolveNodeRS.objects) {
+ auto pValue =
+ pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetRuntime());
+ CJX_Object* jsObject = pObject->JSObject();
+ (jsObject->*(resolveNodeRS.pScriptAttribute->callback))(
+ pValue.get(), false, resolveNodeRS.pScriptAttribute->attribute);
+
+ CXFA_Object* obj = CFXJSE_Engine::ToObject(pValue.get(), nullptr);
+ if (obj->IsNode())
+ pNodeList->Append(obj->AsNode());
+ }
+ }
+ }
+ pValue->SetObject(pNodeList, pScriptContext->GetJseNormalClass());
+}
diff --git a/fxjs/xfa/cjx_tree.h b/fxjs/xfa/cjx_tree.h
new file mode 100644
index 0000000000..30081122a5
--- /dev/null
+++ b/fxjs/xfa/cjx_tree.h
@@ -0,0 +1,45 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_TREE_H_
+#define FXJS_XFA_CJX_TREE_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_object.h"
+
+class CXFA_Object;
+class CXFA_Node;
+
+class CJX_Tree : public CJX_Object {
+ public:
+ explicit CJX_Tree(CXFA_Object* obj);
+ ~CJX_Tree() override;
+
+ JS_METHOD(resolveNode, CJX_Tree);
+ JS_METHOD(resolveNodes, CJX_Tree);
+
+ void all(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute);
+ void nodes(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute);
+ void classAll(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute);
+ void parent(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute);
+ void index(CFXJSE_Value* pValue, bool bSetting, XFA_Attribute eAttribute);
+ void classIndex(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute);
+ void somExpression(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_Attribute eAttribute);
+
+ private:
+ void ResolveNodeList(CFXJSE_Value* pValue,
+ WideString wsExpression,
+ uint32_t dwFlag,
+ CXFA_Node* refNode);
+
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_TREE_H_
diff --git a/fxjs/xfa/cjx_treelist.cpp b/fxjs/xfa/cjx_treelist.cpp
new file mode 100644
index 0000000000..f82f30db29
--- /dev/null
+++ b/fxjs/xfa/cjx_treelist.cpp
@@ -0,0 +1,45 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_treelist.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_engine.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_treelist.h"
+
+const CJX_MethodSpec CJX_TreeList::MethodSpecs[] = {
+ {"namedItem", namedItem_static},
+ {"", nullptr}};
+
+CJX_TreeList::CJX_TreeList(CXFA_TreeList* list) : CJX_List(list) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_TreeList::~CJX_TreeList() {}
+
+CXFA_TreeList* CJX_TreeList::GetXFATreeList() {
+ return static_cast<CXFA_TreeList*>(GetXFAObject());
+}
+
+void CJX_TreeList::namedItem(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 1) {
+ ThrowParamCountMismatchException(L"namedItem");
+ return;
+ }
+
+ ByteString szName = pArguments->GetUTF8String(0);
+ CXFA_Node* pNode = GetXFATreeList()->NamedItem(
+ WideString::FromUTF8(szName.AsStringView()).AsStringView());
+ if (!pNode)
+ return;
+
+ pArguments->GetReturnValue()->Assign(
+ GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode));
+}
diff --git a/fxjs/xfa/cjx_treelist.h b/fxjs/xfa/cjx_treelist.h
new file mode 100644
index 0000000000..29a95e6d74
--- /dev/null
+++ b/fxjs/xfa/cjx_treelist.h
@@ -0,0 +1,28 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_TREELIST_H_
+#define FXJS_XFA_CJX_TREELIST_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/xfa/cjx_list.h"
+
+class CXFA_TreeList;
+
+class CJX_TreeList : public CJX_List {
+ public:
+ explicit CJX_TreeList(CXFA_TreeList* list);
+ ~CJX_TreeList() override;
+
+ JS_METHOD(namedItem, CJX_TreeList);
+
+ private:
+ CXFA_TreeList* GetXFATreeList();
+
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_TREELIST_H_
diff --git a/fxjs/xfa/cjx_wsdlconnection.cpp b/fxjs/xfa/cjx_wsdlconnection.cpp
new file mode 100644
index 0000000000..8a684f4341
--- /dev/null
+++ b/fxjs/xfa/cjx_wsdlconnection.cpp
@@ -0,0 +1,31 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fxjs/xfa/cjx_wsdlconnection.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cxfa_wsdlconnection.h"
+
+const CJX_MethodSpec CJX_WsdlConnection::MethodSpecs[] = {
+ {"execute", execute_static},
+ {"", nullptr}};
+
+CJX_WsdlConnection::CJX_WsdlConnection(CXFA_WsdlConnection* connection)
+ : CJX_Node(connection) {
+ DefineMethods(MethodSpecs);
+}
+
+CJX_WsdlConnection::~CJX_WsdlConnection() {}
+
+void CJX_WsdlConnection::execute(CFXJSE_Arguments* pArguments) {
+ int32_t argc = pArguments->GetLength();
+ if (argc != 0 && argc != 1) {
+ ThrowParamCountMismatchException(L"execute");
+ return;
+ }
+ pArguments->GetReturnValue()->SetBoolean(false);
+}
diff --git a/fxjs/xfa/cjx_wsdlconnection.h b/fxjs/xfa/cjx_wsdlconnection.h
new file mode 100644
index 0000000000..76533ce658
--- /dev/null
+++ b/fxjs/xfa/cjx_wsdlconnection.h
@@ -0,0 +1,26 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef FXJS_XFA_CJX_WSDLCONNECTION_H_
+#define FXJS_XFA_CJX_WSDLCONNECTION_H_
+
+#include "fxjs/CJX_Define.h"
+#include "fxjs/cjx_node.h"
+
+class CXFA_WsdlConnection;
+
+class CJX_WsdlConnection : public CJX_Node {
+ public:
+ explicit CJX_WsdlConnection(CXFA_WsdlConnection* connection);
+ ~CJX_WsdlConnection() override;
+
+ JS_METHOD(execute, CJX_WsdlConnection);
+
+ private:
+ static const CJX_MethodSpec MethodSpecs[];
+};
+
+#endif // FXJS_XFA_CJX_WSDLCONNECTION_H_