summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-01 18:48:17 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-01 18:48:17 +0000
commit46ad7f84cfeef009a4f5e4bc13f8b3435f789f30 (patch)
tree12b2778ecd88257be897dbb8bce203f2e6d689de /fxjs
parent778f2feb328ac4321762b8dcf94ebc0a1bac79f5 (diff)
downloadpdfium-46ad7f84cfeef009a4f5e4bc13f8b3435f789f30.tar.xz
Convert CScript classes to have CJX objects
This CL moves the JS methods from the CScript classes into CJX representations. The methods are proxied to the CJX versions. Change-Id: Ic5f380228614a60238fbcf9e0d04d942fae395be Reviewed-on: https://pdfium-review.googlesource.com/17313 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cjx_datawindow.cpp40
-rw-r--r--fxjs/cjx_datawindow.h38
-rw-r--r--fxjs/cjx_eventpseudomodel.cpp250
-rw-r--r--fxjs/cjx_eventpseudomodel.h75
-rw-r--r--fxjs/cjx_hostpseudomodel.cpp724
-rw-r--r--fxjs/cjx_hostpseudomodel.h64
-rw-r--r--fxjs/cjx_layoutpseudomodel.cpp473
-rw-r--r--fxjs/cjx_layoutpseudomodel.h66
-rw-r--r--fxjs/cjx_logpseudomodel.cpp26
-rw-r--r--fxjs/cjx_logpseudomodel.h28
-rw-r--r--fxjs/cjx_signaturepseudomodel.cpp61
-rw-r--r--fxjs/cjx_signaturepseudomodel.h27
12 files changed, 1872 insertions, 0 deletions
diff --git a/fxjs/cjx_datawindow.cpp b/fxjs/cjx_datawindow.cpp
new file mode 100644
index 0000000000..9b98dfb512
--- /dev/null
+++ b/fxjs/cjx_datawindow.cpp
@@ -0,0 +1,40 @@
+// 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/cjx_datawindow.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cscript_datawindow.h"
+
+CJX_DataWindow::CJX_DataWindow(CScript_DataWindow* window)
+ : CJX_Object(window) {}
+
+CJX_DataWindow::~CJX_DataWindow() {}
+
+void CJX_DataWindow::MoveCurrentRecord(CFXJSE_Arguments* pArguments) {}
+
+void CJX_DataWindow::Record(CFXJSE_Arguments* pArguments) {}
+
+void CJX_DataWindow::GotoRecord(CFXJSE_Arguments* pArguments) {}
+
+void CJX_DataWindow::IsRecordGroup(CFXJSE_Arguments* pArguments) {}
+
+void CJX_DataWindow::RecordsBefore(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {}
+
+void CJX_DataWindow::CurrentRecordNumber(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {}
+
+void CJX_DataWindow::RecordsAfter(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {}
+
+void CJX_DataWindow::IsDefined(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {}
diff --git a/fxjs/cjx_datawindow.h b/fxjs/cjx_datawindow.h
new file mode 100644
index 0000000000..054f5237d2
--- /dev/null
+++ b/fxjs/cjx_datawindow.h
@@ -0,0 +1,38 @@
+// 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_CJX_DATAWINDOW_H_
+#define FXJS_CJX_DATAWINDOW_H_
+
+#include "fxjs/cjx_object.h"
+#include "xfa/fxfa/fxfa_basic.h"
+
+class CFXJSE_Arguments;
+class CFXJSE_Value;
+class CScript_DataWindow;
+
+class CJX_DataWindow : public CJX_Object {
+ public:
+ explicit CJX_DataWindow(CScript_DataWindow* window);
+ ~CJX_DataWindow() override;
+
+ void MoveCurrentRecord(CFXJSE_Arguments* pArguments);
+ void Record(CFXJSE_Arguments* pArguments);
+ void GotoRecord(CFXJSE_Arguments* pArguments);
+ void IsRecordGroup(CFXJSE_Arguments* pArguments);
+ void RecordsBefore(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void CurrentRecordNumber(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void RecordsAfter(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void IsDefined(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+};
+
+#endif // FXJS_CJX_DATAWINDOW_H_
diff --git a/fxjs/cjx_eventpseudomodel.cpp b/fxjs/cjx_eventpseudomodel.cpp
new file mode 100644
index 0000000000..62b4ec848a
--- /dev/null
+++ b/fxjs/cjx_eventpseudomodel.cpp
@@ -0,0 +1,250 @@
+// 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/cjx_eventpseudomodel.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/cxfa_ffwidgethandler.h"
+#include "xfa/fxfa/parser/cscript_eventpseudomodel.h"
+
+namespace {
+
+void StringProperty(CFXJSE_Value* pValue, WideString& wsValue, bool bSetting) {
+ if (bSetting) {
+ wsValue = pValue->ToWideString();
+ return;
+ }
+ pValue->SetString(wsValue.UTF8Encode().AsStringView());
+}
+
+void InterProperty(CFXJSE_Value* pValue, int32_t& iValue, bool bSetting) {
+ if (bSetting) {
+ iValue = pValue->ToInteger();
+ return;
+ }
+ pValue->SetInteger(iValue);
+}
+
+void BooleanProperty(CFXJSE_Value* pValue, bool& bValue, bool bSetting) {
+ if (bSetting) {
+ bValue = pValue->ToBoolean();
+ return;
+ }
+ pValue->SetBoolean(bValue);
+}
+
+} // namespace
+
+CJX_EventPseudoModel::CJX_EventPseudoModel(CScript_EventPseudoModel* model)
+ : CJX_Object(model) {}
+
+CJX_EventPseudoModel::~CJX_EventPseudoModel() {}
+
+CScript_EventPseudoModel* CJX_EventPseudoModel::GetXFAEventPseudoModel() {
+ return static_cast<CScript_EventPseudoModel*>(GetXFAObject());
+}
+
+void CJX_EventPseudoModel::Change(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::Change, bSetting);
+}
+
+void CJX_EventPseudoModel::CommitKey(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::CommitKey, bSetting);
+}
+
+void CJX_EventPseudoModel::FullText(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::FullText, bSetting);
+}
+
+void CJX_EventPseudoModel::KeyDown(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::Keydown, bSetting);
+}
+
+void CJX_EventPseudoModel::Modifier(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::Modifier, bSetting);
+}
+
+void CJX_EventPseudoModel::NewContentType(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::NewContentType, bSetting);
+}
+
+void CJX_EventPseudoModel::NewText(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::NewText, bSetting);
+}
+
+void CJX_EventPseudoModel::PrevContentType(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::PreviousContentType, bSetting);
+}
+
+void CJX_EventPseudoModel::PrevText(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::PreviousText, bSetting);
+}
+
+void CJX_EventPseudoModel::Reenter(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::Reenter, bSetting);
+}
+
+void CJX_EventPseudoModel::SelEnd(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::SelectionEnd, bSetting);
+}
+
+void CJX_EventPseudoModel::SelStart(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::SelectionStart, bSetting);
+}
+
+void CJX_EventPseudoModel::Shift(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::Shift, bSetting);
+}
+
+void CJX_EventPseudoModel::SoapFaultCode(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::SoapFaultCode, bSetting);
+}
+
+void CJX_EventPseudoModel::SoapFaultString(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::SoapFaultString, bSetting);
+}
+
+void CJX_EventPseudoModel::Target(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ Property(pValue, XFA_Event::Target, bSetting);
+}
+
+void CJX_EventPseudoModel::Emit(CFXJSE_Arguments* pArguments) {
+ CFXJSE_Engine* pScriptContext =
+ GetXFAEventPseudoModel()->GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+
+ CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
+ if (!pEventParam)
+ return;
+
+ CXFA_FFNotify* pNotify = GetXFAEventPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFWidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler();
+ if (!pWidgetHandler)
+ return;
+
+ pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam);
+}
+
+void CJX_EventPseudoModel::Reset(CFXJSE_Arguments* pArguments) {
+ CFXJSE_Engine* pScriptContext =
+ GetXFAEventPseudoModel()->GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+
+ CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
+ if (!pEventParam)
+ return;
+
+ pEventParam->Reset();
+}
+
+void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue,
+ XFA_Event dwFlag,
+ bool bSetting) {
+ CFXJSE_Engine* pScriptContext =
+ GetXFAEventPseudoModel()->GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+
+ CXFA_EventParam* pEventParam = pScriptContext->GetEventParam();
+ if (!pEventParam)
+ return;
+
+ switch (dwFlag) {
+ case XFA_Event::CancelAction:
+ BooleanProperty(pValue, pEventParam->m_bCancelAction, bSetting);
+ break;
+ case XFA_Event::Change:
+ StringProperty(pValue, pEventParam->m_wsChange, bSetting);
+ break;
+ case XFA_Event::CommitKey:
+ InterProperty(pValue, pEventParam->m_iCommitKey, bSetting);
+ break;
+ case XFA_Event::FullText:
+ StringProperty(pValue, pEventParam->m_wsFullText, bSetting);
+ break;
+ case XFA_Event::Keydown:
+ BooleanProperty(pValue, pEventParam->m_bKeyDown, bSetting);
+ break;
+ case XFA_Event::Modifier:
+ BooleanProperty(pValue, pEventParam->m_bModifier, bSetting);
+ break;
+ case XFA_Event::NewContentType:
+ StringProperty(pValue, pEventParam->m_wsNewContentType, bSetting);
+ break;
+ case XFA_Event::NewText:
+ StringProperty(pValue, pEventParam->m_wsNewText, bSetting);
+ break;
+ case XFA_Event::PreviousContentType:
+ StringProperty(pValue, pEventParam->m_wsPrevContentType, bSetting);
+ break;
+ case XFA_Event::PreviousText:
+ StringProperty(pValue, pEventParam->m_wsPrevText, bSetting);
+ break;
+ case XFA_Event::Reenter:
+ BooleanProperty(pValue, pEventParam->m_bReenter, bSetting);
+ break;
+ case XFA_Event::SelectionEnd:
+ InterProperty(pValue, pEventParam->m_iSelEnd, bSetting);
+ break;
+ case XFA_Event::SelectionStart:
+ InterProperty(pValue, pEventParam->m_iSelStart, bSetting);
+ break;
+ case XFA_Event::Shift:
+ BooleanProperty(pValue, pEventParam->m_bShift, bSetting);
+ break;
+ case XFA_Event::SoapFaultCode:
+ StringProperty(pValue, pEventParam->m_wsSoapFaultCode, bSetting);
+ break;
+ case XFA_Event::SoapFaultString:
+ StringProperty(pValue, pEventParam->m_wsSoapFaultString, bSetting);
+ break;
+ case XFA_Event::Target:
+ break;
+ default:
+ break;
+ }
+}
diff --git a/fxjs/cjx_eventpseudomodel.h b/fxjs/cjx_eventpseudomodel.h
new file mode 100644
index 0000000000..10bacaebbe
--- /dev/null
+++ b/fxjs/cjx_eventpseudomodel.h
@@ -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
+
+#ifndef FXJS_CJX_EVENTPSEUDOMODEL_H_
+#define FXJS_CJX_EVENTPSEUDOMODEL_H_
+
+#include "fxjs/cjx_object.h"
+
+class CFXJSE_Arguments;
+class CFXJSE_Value;
+class CScript_EventPseudoModel;
+
+enum class XFA_Event {
+ Change = 0,
+ CommitKey,
+ FullText,
+ Keydown,
+ Modifier,
+ NewContentType,
+ NewText,
+ PreviousContentType,
+ PreviousText,
+ Reenter,
+ SelectionEnd,
+ SelectionStart,
+ Shift,
+ SoapFaultCode,
+ SoapFaultString,
+ Target,
+ CancelAction
+};
+
+class CJX_EventPseudoModel : public CJX_Object {
+ public:
+ explicit CJX_EventPseudoModel(CScript_EventPseudoModel* model);
+ ~CJX_EventPseudoModel() override;
+
+ CScript_EventPseudoModel* GetXFAEventPseudoModel();
+
+ void Change(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void CommitKey(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void FullText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void KeyDown(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void Modifier(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void NewContentType(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void NewText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void PrevContentType(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void PrevText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void Reenter(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void SelEnd(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void SelStart(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void Shift(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void SoapFaultCode(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void SoapFaultString(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void Target(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+
+ void Emit(CFXJSE_Arguments* pArguments);
+ void Reset(CFXJSE_Arguments* pArguments);
+
+ private:
+ void Property(CFXJSE_Value* pValue, XFA_Event dwFlag, bool bSetting);
+};
+
+#endif // FXJS_CJX_EVENTPSEUDOMODEL_H_
diff --git a/fxjs/cjx_hostpseudomodel.cpp b/fxjs/cjx_hostpseudomodel.cpp
new file mode 100644
index 0000000000..e18fddf317
--- /dev/null
+++ b/fxjs/cjx_hostpseudomodel.cpp
@@ -0,0 +1,724 @@
+// 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/cjx_hostpseudomodel.h"
+
+#include <memory>
+
+#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/cscript_hostpseudomodel.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
+
+namespace {
+
+CXFA_Node* ToNode(CFXJSE_Value* pValue, CFXJSE_Class* pClass) {
+ return static_cast<CXFA_Node*>(pValue->ToHostObject(pClass));
+}
+
+int32_t FilterName(const WideStringView& wsExpression,
+ int32_t nStart,
+ WideString& wsFilter) {
+ ASSERT(nStart > -1);
+ int32_t iLength = wsExpression.GetLength();
+ if (nStart >= iLength)
+ return iLength;
+
+ wchar_t* pBuf = wsFilter.GetBuffer(iLength - nStart);
+ int32_t nCount = 0;
+ const wchar_t* pSrc = wsExpression.unterminated_c_str();
+ wchar_t wCur;
+ while (nStart < iLength) {
+ wCur = pSrc[nStart++];
+ if (wCur == ',')
+ break;
+
+ pBuf[nCount++] = wCur;
+ }
+ wsFilter.ReleaseBuffer(nCount);
+ wsFilter.TrimLeft();
+ wsFilter.TrimRight();
+ return nStart;
+}
+
+} // namespace
+
+CJX_HostPseudoModel::CJX_HostPseudoModel(CScript_HostPseudoModel* model)
+ : CJX_Object(model) {}
+
+CJX_HostPseudoModel::~CJX_HostPseudoModel() {}
+
+CScript_HostPseudoModel* CJX_HostPseudoModel::GetXFAHostPseudoModel() {
+ return static_cast<CScript_HostPseudoModel*>(GetXFAObject());
+}
+
+void CJX_HostPseudoModel::AppType(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+ pValue->SetString("Exchange");
+}
+
+void CJX_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ if (bSetting) {
+ pNotify->GetDocEnvironment()->SetCalculationsEnabled(hDoc,
+ pValue->ToBoolean());
+ return;
+ }
+ pValue->SetBoolean(pNotify->GetDocEnvironment()->IsCalculationsEnabled(hDoc));
+}
+
+void CJX_HostPseudoModel::CurrentPage(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ if (bSetting) {
+ pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, pValue->ToInteger());
+ return;
+ }
+ pValue->SetInteger(pNotify->GetDocEnvironment()->GetCurrentPage(hDoc));
+}
+
+void CJX_HostPseudoModel::Language(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ if (bSetting) {
+ ThrowException(L"Unable to set language value.");
+ return;
+ }
+ pValue->SetString(
+ pNotify->GetAppProvider()->GetLanguage().UTF8Encode().AsStringView());
+}
+
+void CJX_HostPseudoModel::NumPages(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ if (bSetting) {
+ ThrowException(L"Unable to set numPages value.");
+ return;
+ }
+ pValue->SetInteger(pNotify->GetDocEnvironment()->CountPages(hDoc));
+}
+
+void CJX_HostPseudoModel::Platform(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ if (bSetting) {
+ ThrowException(L"Unable to set platform value.");
+ return;
+ }
+ pValue->SetString(
+ pNotify->GetAppProvider()->GetPlatform().UTF8Encode().AsStringView());
+}
+
+void CJX_HostPseudoModel::Title(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ if (!GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->IsRunAtClient())
+ return;
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ if (bSetting) {
+ pNotify->GetDocEnvironment()->SetTitle(hDoc, pValue->ToWideString());
+ return;
+ }
+
+ WideString wsTitle;
+ pNotify->GetDocEnvironment()->GetTitle(hDoc, wsTitle);
+ pValue->SetString(wsTitle.UTF8Encode().AsStringView());
+}
+
+void CJX_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ if (bSetting) {
+ pNotify->GetDocEnvironment()->SetValidationsEnabled(hDoc,
+ pValue->ToBoolean());
+ return;
+ }
+
+ bool bEnabled = pNotify->GetDocEnvironment()->IsValidationsEnabled(hDoc);
+ pValue->SetBoolean(bEnabled);
+}
+
+void CJX_HostPseudoModel::Variation(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ if (!GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->IsRunAtClient())
+ return;
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ if (bSetting) {
+ ThrowException(L"Unable to set variation value.");
+ return;
+ }
+ pValue->SetString("Full");
+}
+
+void CJX_HostPseudoModel::Version(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ if (bSetting) {
+ ThrowException(L"Unable to set version value.");
+ return;
+ }
+ pValue->SetString("11");
+}
+
+void CJX_HostPseudoModel::Name(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ if (bSetting) {
+ ThrowInvalidPropertyException();
+ return;
+ }
+ pValue->SetString(
+ pNotify->GetAppProvider()->GetAppName().UTF8Encode().AsStringView());
+}
+
+void CJX_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) {
+ if (!GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->IsRunAtClient())
+ return;
+
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"gotoURL");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ WideString wsURL;
+ if (iLength >= 1) {
+ ByteString bsURL = pArguments->GetUTF8String(0);
+ wsURL = WideString::FromUTF8(bsURL.AsStringView());
+ }
+ pNotify->GetDocEnvironment()->GotoURL(hDoc, wsURL);
+}
+
+void CJX_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) {
+ if (!GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->IsRunAtClient())
+ return;
+
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"openList");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_Node* pNode = nullptr;
+ if (iLength >= 1) {
+ std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
+ if (pValue->IsObject()) {
+ pNode = ToNode(pValue.get(), nullptr);
+ } else if (pValue->IsString()) {
+ CFXJSE_Engine* pScriptContext =
+ GetXFAHostPseudoModel()->GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+
+ CXFA_Object* pObject = pScriptContext->GetThisObject();
+ if (!pObject)
+ return;
+
+ uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
+ XFA_RESOLVENODE_RS resoveNodeRS;
+ int32_t iRet = pScriptContext->ResolveObjects(
+ pObject, pValue->ToWideString().AsStringView(), resoveNodeRS, dwFlag);
+ if (iRet < 1 || !resoveNodeRS.objects.front()->IsNode())
+ return;
+
+ pNode = resoveNodeRS.objects.front()->AsNode();
+ }
+ }
+
+ CXFA_LayoutProcessor* pDocLayout =
+ GetXFAHostPseudoModel()->GetDocument()->GetDocLayout();
+ if (!pDocLayout)
+ return;
+
+ CXFA_FFWidget* hWidget =
+ pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode));
+ if (!hWidget)
+ return;
+
+ pNotify->GetDocEnvironment()->SetFocusWidget(pNotify->GetHDOC(), hWidget);
+ pNotify->OpenDropDownList(hWidget);
+}
+
+void CJX_HostPseudoModel::Response(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 1 || iLength > 4) {
+ ThrowParamCountMismatchException(L"response");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ WideString wsQuestion;
+ WideString wsTitle;
+ WideString wsDefaultAnswer;
+ bool bMark = false;
+ if (iLength >= 1) {
+ ByteString bsQuestion = pArguments->GetUTF8String(0);
+ wsQuestion = WideString::FromUTF8(bsQuestion.AsStringView());
+ }
+ if (iLength >= 2) {
+ ByteString bsTitle = pArguments->GetUTF8String(1);
+ wsTitle = WideString::FromUTF8(bsTitle.AsStringView());
+ }
+ if (iLength >= 3) {
+ ByteString bsDefaultAnswer = pArguments->GetUTF8String(2);
+ wsDefaultAnswer = WideString::FromUTF8(bsDefaultAnswer.AsStringView());
+ }
+ if (iLength >= 4) {
+ bMark = pArguments->GetInt32(3) == 0 ? false : true;
+ }
+
+ WideString wsAnswer = pNotify->GetAppProvider()->Response(
+ wsQuestion, wsTitle, wsDefaultAnswer, bMark);
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetString(wsAnswer.UTF8Encode().AsStringView());
+}
+
+void CJX_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) {
+ if (CFXJSE_Value* pValue = pArguments->GetReturnValue())
+ pValue->SetInteger(0);
+}
+
+void CJX_HostPseudoModel::ResetData(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 0 || iLength > 1) {
+ ThrowParamCountMismatchException(L"resetData");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ WideString wsExpression;
+ if (iLength >= 1) {
+ ByteString bsExpression = pArguments->GetUTF8String(0);
+ wsExpression = WideString::FromUTF8(bsExpression.AsStringView());
+ }
+ if (wsExpression.IsEmpty()) {
+ pNotify->ResetData();
+ return;
+ }
+
+ int32_t iStart = 0;
+ WideString wsName;
+ CXFA_Node* pNode = nullptr;
+ int32_t iExpLength = wsExpression.GetLength();
+ while (iStart < iExpLength) {
+ iStart = FilterName(wsExpression.AsStringView(), iStart, wsName);
+ CFXJSE_Engine* pScriptContext =
+ GetXFAHostPseudoModel()->GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+
+ CXFA_Object* pObject = pScriptContext->GetThisObject();
+ if (!pObject)
+ return;
+
+ uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
+ XFA_RESOLVENODE_RS resoveNodeRS;
+ int32_t iRet = pScriptContext->ResolveObjects(
+ pObject, wsName.AsStringView(), resoveNodeRS, dwFlag);
+ if (iRet < 1 || !resoveNodeRS.objects.front()->IsNode())
+ continue;
+
+ pNode = resoveNodeRS.objects.front()->AsNode();
+ pNotify->ResetData(pNode->GetWidgetData());
+ }
+ if (!pNode)
+ pNotify->ResetData();
+}
+
+void CJX_HostPseudoModel::Beep(CFXJSE_Arguments* pArguments) {
+ if (!GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->IsRunAtClient())
+ return;
+
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 0 || iLength > 1) {
+ ThrowParamCountMismatchException(L"beep");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ uint32_t dwType = 4;
+ if (iLength >= 1)
+ dwType = pArguments->GetInt32(0);
+
+ pNotify->GetAppProvider()->Beep(dwType);
+}
+
+void CJX_HostPseudoModel::SetFocus(CFXJSE_Arguments* pArguments) {
+ if (!GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->IsRunAtClient())
+ return;
+
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"setFocus");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_Node* pNode = nullptr;
+ if (iLength >= 1) {
+ std::unique_ptr<CFXJSE_Value> pValue(pArguments->GetValue(0));
+ if (pValue->IsObject()) {
+ pNode = ToNode(pValue.get(), nullptr);
+ } else if (pValue->IsString()) {
+ CFXJSE_Engine* pScriptContext =
+ GetXFAHostPseudoModel()->GetDocument()->GetScriptContext();
+ if (!pScriptContext)
+ return;
+
+ CXFA_Object* pObject = pScriptContext->GetThisObject();
+ if (!pObject)
+ return;
+
+ uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
+ XFA_RESOLVENODE_Siblings;
+ XFA_RESOLVENODE_RS resoveNodeRS;
+ int32_t iRet = pScriptContext->ResolveObjects(
+ pObject, pValue->ToWideString().AsStringView(), resoveNodeRS, dwFlag);
+ if (iRet < 1 || !resoveNodeRS.objects.front()->IsNode())
+ return;
+
+ pNode = resoveNodeRS.objects.front()->AsNode();
+ }
+ }
+ pNotify->SetFocusWidgetNode(pNode);
+}
+
+void CJX_HostPseudoModel::GetFocus(CFXJSE_Arguments* pArguments) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_Node* pNode = pNotify->GetFocusWidgetNode();
+ if (!pNode)
+ return;
+
+ pArguments->GetReturnValue()->Assign(GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->GetJSValueFromMap(pNode));
+}
+
+void CJX_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) {
+ if (!GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->IsRunAtClient())
+ return;
+
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 1 || iLength > 4) {
+ ThrowParamCountMismatchException(L"messageBox");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ WideString wsMessage;
+ WideString bsTitle;
+ uint32_t dwMessageType = XFA_MBICON_Error;
+ uint32_t dwButtonType = XFA_MB_OK;
+ if (iLength >= 1) {
+ if (!ValidateArgsForMsg(pArguments, 0, wsMessage))
+ return;
+ }
+ if (iLength >= 2) {
+ if (!ValidateArgsForMsg(pArguments, 1, bsTitle))
+ return;
+ }
+ if (iLength >= 3) {
+ dwMessageType = pArguments->GetInt32(2);
+ if (dwMessageType > XFA_MBICON_Status)
+ dwMessageType = XFA_MBICON_Error;
+ }
+ if (iLength >= 4) {
+ dwButtonType = pArguments->GetInt32(3);
+ if (dwButtonType > XFA_MB_YesNoCancel)
+ dwButtonType = XFA_MB_OK;
+ }
+
+ int32_t iValue = pNotify->GetAppProvider()->MsgBox(
+ wsMessage, bsTitle, dwMessageType, dwButtonType);
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetInteger(iValue);
+}
+
+bool CJX_HostPseudoModel::ValidateArgsForMsg(CFXJSE_Arguments* pArguments,
+ int32_t iArgIndex,
+ WideString& wsValue) {
+ if (!pArguments || iArgIndex < 0)
+ return false;
+
+ bool bIsJsType = false;
+ if (GetXFAHostPseudoModel()->GetDocument()->GetScriptContext()->GetType() ==
+ XFA_SCRIPTLANGTYPE_Javascript) {
+ bIsJsType = true;
+ }
+
+ std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex));
+ if (!pValueArg->IsString() && bIsJsType) {
+ ThrowArgumentMismatchException();
+ return false;
+ }
+ wsValue = pValueArg->IsNull() ? L"" : pValueArg->ToWideString();
+ return true;
+}
+
+void CJX_HostPseudoModel::DocumentCountInBatch(CFXJSE_Arguments* pArguments) {
+ if (CFXJSE_Value* pValue = pArguments->GetReturnValue())
+ pValue->SetInteger(0);
+}
+
+void CJX_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) {
+ if (!GetXFAHostPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->IsRunAtClient())
+ return;
+
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 8) {
+ ThrowParamCountMismatchException(L"print");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ uint32_t dwOptions = 0;
+ bool bShowDialog = true;
+ if (iLength >= 1)
+ bShowDialog = pArguments->GetInt32(0) == 0 ? false : true;
+ if (bShowDialog)
+ dwOptions |= XFA_PRINTOPT_ShowDialog;
+
+ int32_t nStartPage = 0;
+ if (iLength >= 2)
+ nStartPage = pArguments->GetInt32(1);
+
+ int32_t nEndPage = 0;
+ if (iLength >= 3)
+ nEndPage = pArguments->GetInt32(2);
+
+ bool bCanCancel = true;
+ if (iLength >= 4)
+ bCanCancel = pArguments->GetInt32(3) == 0 ? false : true;
+ if (bCanCancel)
+ dwOptions |= XFA_PRINTOPT_CanCancel;
+
+ bool bShrinkPage = true;
+ if (iLength >= 5)
+ bShrinkPage = pArguments->GetInt32(4) == 0 ? false : true;
+ if (bShrinkPage)
+ dwOptions |= XFA_PRINTOPT_ShrinkPage;
+
+ bool bAsImage = true;
+ if (iLength >= 6)
+ bAsImage = pArguments->GetInt32(5) == 0 ? false : true;
+ if (bAsImage)
+ dwOptions |= XFA_PRINTOPT_AsImage;
+
+ bool bReverseOrder = true;
+ if (iLength >= 7)
+ bAsImage = pArguments->GetInt32(5) == 0 ? false : true;
+
+ bReverseOrder = pArguments->GetInt32(6) == 0 ? false : true;
+ if (bReverseOrder)
+ dwOptions |= XFA_PRINTOPT_ReverseOrder;
+
+ bool bPrintAnnot = true;
+ if (iLength >= 8)
+ bPrintAnnot = pArguments->GetInt32(7) == 0 ? false : true;
+ if (bPrintAnnot)
+ dwOptions |= XFA_PRINTOPT_PrintAnnot;
+
+ pNotify->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions);
+}
+
+void CJX_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 0 || iLength > 1) {
+ ThrowParamCountMismatchException(L"importData");
+ return;
+ }
+ // Not implemented.
+}
+
+void CJX_HostPseudoModel::ExportData(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 0 || iLength > 2) {
+ ThrowParamCountMismatchException(L"exportData");
+ return;
+ }
+
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ WideString wsFilePath;
+ bool bXDP = true;
+ if (iLength >= 1) {
+ ByteString bsFilePath = pArguments->GetUTF8String(0);
+ wsFilePath = WideString::FromUTF8(bsFilePath.AsStringView());
+ }
+ if (iLength >= 2)
+ bXDP = pArguments->GetInt32(1) == 0 ? false : true;
+
+ pNotify->GetDocEnvironment()->ExportData(hDoc, wsFilePath, bXDP);
+}
+
+void CJX_HostPseudoModel::PageUp(CFXJSE_Arguments* pArguments) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ int32_t nCurPage = pNotify->GetDocEnvironment()->GetCurrentPage(hDoc);
+ int32_t nNewPage = 0;
+ if (nCurPage <= 1)
+ return;
+
+ nNewPage = nCurPage - 1;
+ pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
+}
+
+void CJX_HostPseudoModel::PageDown(CFXJSE_Arguments* pArguments) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_FFDoc* hDoc = pNotify->GetHDOC();
+ int32_t nCurPage = pNotify->GetDocEnvironment()->GetCurrentPage(hDoc);
+ int32_t nPageCount = pNotify->GetDocEnvironment()->CountPages(hDoc);
+ if (!nPageCount || nCurPage == nPageCount)
+ return;
+
+ int32_t nNewPage = 0;
+ if (nCurPage >= nPageCount)
+ nNewPage = nPageCount - 1;
+ else
+ nNewPage = nCurPage + 1;
+
+ pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
+}
+
+void CJX_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) {
+ CXFA_FFNotify* pNotify = GetXFAHostPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ WideString wsDataTime = pNotify->GetCurrentDateTime();
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetString(wsDataTime.UTF8Encode().AsStringView());
+}
diff --git a/fxjs/cjx_hostpseudomodel.h b/fxjs/cjx_hostpseudomodel.h
new file mode 100644
index 0000000000..83497077c8
--- /dev/null
+++ b/fxjs/cjx_hostpseudomodel.h
@@ -0,0 +1,64 @@
+// 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_CJX_HOSTPSEUDOMODEL_H_
+#define FXJS_CJX_HOSTPSEUDOMODEL_H_
+
+#include "fxjs/cjx_object.h"
+#include "xfa/fxfa/fxfa_basic.h"
+
+class CFXJSE_Arguments;
+class CFXJSE_Value;
+class CScript_HostPseudoModel;
+
+class CJX_HostPseudoModel : public CJX_Object {
+ public:
+ explicit CJX_HostPseudoModel(CScript_HostPseudoModel* model);
+ ~CJX_HostPseudoModel() override;
+
+ CScript_HostPseudoModel* GetXFAHostPseudoModel();
+
+ void AppType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void CalculationsEnabled(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void CurrentPage(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void Language(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void NumPages(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void Platform(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void Title(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void ValidationsEnabled(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute);
+ void Variation(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void Version(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void Name(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+ void GotoURL(CFXJSE_Arguments* pArguments);
+ void OpenList(CFXJSE_Arguments* pArguments);
+ void Response(CFXJSE_Arguments* pArguments);
+ void DocumentInBatch(CFXJSE_Arguments* pArguments);
+ void ResetData(CFXJSE_Arguments* pArguments);
+ void Beep(CFXJSE_Arguments* pArguments);
+ void SetFocus(CFXJSE_Arguments* pArguments);
+ void GetFocus(CFXJSE_Arguments* pArguments);
+ void MessageBox(CFXJSE_Arguments* pArguments);
+ void DocumentCountInBatch(CFXJSE_Arguments* pArguments);
+ void Print(CFXJSE_Arguments* pArguments);
+ void ImportData(CFXJSE_Arguments* pArguments);
+ void ExportData(CFXJSE_Arguments* pArguments);
+ void PageUp(CFXJSE_Arguments* pArguments);
+ void PageDown(CFXJSE_Arguments* pArguments);
+ void CurrentDateTime(CFXJSE_Arguments* pArguments);
+
+ private:
+ bool ValidateArgsForMsg(CFXJSE_Arguments* pArguments,
+ int32_t iArgIndex,
+ WideString& wsValue);
+};
+
+#endif // FXJS_CJX_HOSTPSEUDOMODEL_H_
diff --git a/fxjs/cjx_layoutpseudomodel.cpp b/fxjs/cjx_layoutpseudomodel.cpp
new file mode 100644
index 0000000000..671e8aa7d0
--- /dev/null
+++ b/fxjs/cjx_layoutpseudomodel.cpp
@@ -0,0 +1,473 @@
+// 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/cjx_layoutpseudomodel.h"
+
+#include <set>
+
+#include "core/fxcrt/fx_coordinates.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/cscript_layoutpseudomodel.h"
+#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
+#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
+#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_layoutitem.h"
+#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
+#include "xfa/fxfa/parser/cxfa_measurement.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+#include "xfa/fxfa/parser/cxfa_traversestrategy_contentlayoutitem.h"
+#include "xfa/fxfa/parser/xfa_utils.h"
+
+CJX_LayoutPseudoModel::CJX_LayoutPseudoModel(CScript_LayoutPseudoModel* model)
+ : CJX_Object(model) {}
+
+CJX_LayoutPseudoModel::~CJX_LayoutPseudoModel() {}
+
+CScript_LayoutPseudoModel* CJX_LayoutPseudoModel::GetXFALayoutPseudoModel() {
+ return static_cast<CScript_LayoutPseudoModel*>(GetXFAObject());
+}
+
+void CJX_LayoutPseudoModel::Ready(CFXJSE_Value* pValue,
+ bool bSetting,
+ XFA_ATTRIBUTE eAttribute) {
+ CXFA_FFNotify* pNotify =
+ GetXFALayoutPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+ if (bSetting) {
+ ThrowException(L"Unable to set ready value.");
+ return;
+ }
+
+ int32_t iStatus = pNotify->GetLayoutStatus();
+ pValue->SetBoolean(iStatus >= 2);
+}
+
+void CJX_LayoutPseudoModel::HWXY(CFXJSE_Arguments* pArguments,
+ XFA_LAYOUTMODEL_HWXY layoutModel) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 1 || iLength > 3) {
+ const wchar_t* methodName = nullptr;
+ switch (layoutModel) {
+ case XFA_LAYOUTMODEL_H:
+ methodName = L"h";
+ break;
+ case XFA_LAYOUTMODEL_W:
+ methodName = L"w";
+ break;
+ case XFA_LAYOUTMODEL_X:
+ methodName = L"x";
+ break;
+ case XFA_LAYOUTMODEL_Y:
+ methodName = L"y";
+ break;
+ }
+ ThrowParamCountMismatchException(methodName);
+ return;
+ }
+
+ CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ if (!pNode)
+ return;
+
+ WideString wsUnit(L"pt");
+ if (iLength >= 2) {
+ ByteString bsUnit = pArguments->GetUTF8String(1);
+ if (!bsUnit.IsEmpty())
+ wsUnit = WideString::FromUTF8(bsUnit.AsStringView());
+ }
+
+ int32_t iIndex = iLength >= 3 ? pArguments->GetInt32(2) : 0;
+
+ CXFA_LayoutProcessor* pDocLayout =
+ GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+ if (!pDocLayout)
+ return;
+
+ CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
+ if (!pLayoutItem)
+ return;
+
+ while (iIndex > 0 && pLayoutItem) {
+ pLayoutItem = pLayoutItem->GetNext();
+ iIndex--;
+ }
+
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (!pLayoutItem) {
+ pValue->SetFloat(0);
+ return;
+ }
+
+ CXFA_Measurement measure;
+ CFX_RectF rtRect = pLayoutItem->GetRect(true);
+ switch (layoutModel) {
+ case XFA_LAYOUTMODEL_H:
+ measure.Set(rtRect.height, XFA_UNIT_Pt);
+ break;
+ case XFA_LAYOUTMODEL_W:
+ measure.Set(rtRect.width, XFA_UNIT_Pt);
+ break;
+ case XFA_LAYOUTMODEL_X:
+ measure.Set(rtRect.left, XFA_UNIT_Pt);
+ break;
+ case XFA_LAYOUTMODEL_Y:
+ measure.Set(rtRect.top, XFA_UNIT_Pt);
+ break;
+ }
+
+ float fValue = measure.ToUnit(
+ CXFA_Measurement::GetUnitFromString(wsUnit.AsStringView()));
+ fValue = FXSYS_round(fValue * 1000) / 1000.0f;
+ pValue->SetFloat(fValue);
+}
+
+void CJX_LayoutPseudoModel::H(CFXJSE_Arguments* pArguments) {
+ HWXY(pArguments, XFA_LAYOUTMODEL_H);
+}
+
+void CJX_LayoutPseudoModel::W(CFXJSE_Arguments* pArguments) {
+ HWXY(pArguments, XFA_LAYOUTMODEL_W);
+}
+
+void CJX_LayoutPseudoModel::X(CFXJSE_Arguments* pArguments) {
+ HWXY(pArguments, XFA_LAYOUTMODEL_X);
+}
+
+void CJX_LayoutPseudoModel::Y(CFXJSE_Arguments* pArguments) {
+ HWXY(pArguments, XFA_LAYOUTMODEL_Y);
+}
+
+void CJX_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments,
+ bool bNumbered) {
+ CXFA_LayoutProcessor* pDocLayout =
+ GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+ if (!pDocLayout)
+ return;
+
+ int32_t iPageCount = 0;
+ int32_t iPageNum = pDocLayout->CountPages();
+ if (bNumbered) {
+ for (int32_t i = 0; i < iPageNum; i++) {
+ CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(i);
+ if (!pLayoutPage)
+ continue;
+
+ CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage();
+ if (pMasterPage->JSNode()->GetInteger(XFA_ATTRIBUTE_Numbered))
+ iPageCount++;
+ }
+ } else {
+ iPageCount = iPageNum;
+ }
+
+ pArguments->GetReturnValue()->SetInteger(iPageCount);
+}
+
+void CJX_LayoutPseudoModel::PageCount(CFXJSE_Arguments* pArguments) {
+ NumberedPageCount(pArguments, true);
+}
+
+void CJX_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(L"pageSpan");
+ return;
+ }
+
+ CXFA_Node* pNode = nullptr;
+ if (iLength >= 1)
+ pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ if (!pNode)
+ return;
+
+ CXFA_LayoutProcessor* pDocLayout =
+ GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+ if (!pDocLayout)
+ return;
+
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
+ if (!pLayoutItem) {
+ pValue->SetInteger(-1);
+ return;
+ }
+
+ int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex();
+ int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
+ int32_t iPageSpan = iLast - iFirst + 1;
+ pValue->SetInteger(iPageSpan);
+}
+
+void CJX_LayoutPseudoModel::Page(CFXJSE_Arguments* pArguments) {
+ PageInternals(pArguments, false);
+}
+
+std::vector<CXFA_Node*> CJX_LayoutPseudoModel::GetObjArray(
+ CXFA_LayoutProcessor* pDocLayout,
+ int32_t iPageNo,
+ const WideString& wsType,
+ bool bOnPageArea) {
+ CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(iPageNo);
+ if (!pLayoutPage)
+ return std::vector<CXFA_Node*>();
+
+ std::vector<CXFA_Node*> retArray;
+ if (wsType == L"pageArea") {
+ if (pLayoutPage->m_pFormNode)
+ retArray.push_back(pLayoutPage->m_pFormNode);
+ return retArray;
+ }
+ if (wsType == L"contentArea") {
+ for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
+ pItem = pItem->m_pNextSibling) {
+ if (pItem->m_pFormNode->GetElementType() == XFA_Element::ContentArea)
+ retArray.push_back(pItem->m_pFormNode);
+ }
+ return retArray;
+ }
+ std::set<CXFA_Node*> formItems;
+ if (wsType.IsEmpty()) {
+ if (pLayoutPage->m_pFormNode)
+ retArray.push_back(pLayoutPage->m_pFormNode);
+
+ for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
+ pItem = pItem->m_pNextSibling) {
+ if (pItem->m_pFormNode->GetElementType() == XFA_Element::ContentArea) {
+ retArray.push_back(pItem->m_pFormNode);
+ if (!bOnPageArea) {
+ CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
+ CXFA_TraverseStrategy_ContentLayoutItem>
+ iterator(static_cast<CXFA_ContentLayoutItem*>(pItem->m_pFirstChild));
+ for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent();
+ pItemChild; pItemChild = iterator.MoveToNext()) {
+ if (!pItemChild->IsContentLayoutItem()) {
+ continue;
+ }
+ XFA_Element eType = pItemChild->m_pFormNode->GetElementType();
+ if (eType != XFA_Element::Field && eType != XFA_Element::Draw &&
+ eType != XFA_Element::Subform && eType != XFA_Element::Area) {
+ continue;
+ }
+ if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode))
+ continue;
+
+ formItems.insert(pItemChild->m_pFormNode);
+ retArray.push_back(pItemChild->m_pFormNode);
+ }
+ }
+ } else {
+ if (bOnPageArea) {
+ CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
+ CXFA_TraverseStrategy_ContentLayoutItem>
+ iterator(static_cast<CXFA_ContentLayoutItem*>(pItem));
+ for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent();
+ pItemChild; pItemChild = iterator.MoveToNext()) {
+ if (!pItemChild->IsContentLayoutItem()) {
+ continue;
+ }
+ XFA_Element eType = pItemChild->m_pFormNode->GetElementType();
+ if (eType != XFA_Element::Field && eType != XFA_Element::Draw &&
+ eType != XFA_Element::Subform && eType != XFA_Element::Area) {
+ continue;
+ }
+ if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode))
+ continue;
+ formItems.insert(pItemChild->m_pFormNode);
+ retArray.push_back(pItemChild->m_pFormNode);
+ }
+ }
+ }
+ }
+ return retArray;
+ }
+
+ XFA_Element eType = XFA_Element::Unknown;
+ if (wsType == L"field")
+ eType = XFA_Element::Field;
+ else if (wsType == L"draw")
+ eType = XFA_Element::Draw;
+ else if (wsType == L"subform")
+ eType = XFA_Element::Subform;
+ else if (wsType == L"area")
+ eType = XFA_Element::Area;
+
+ if (eType != XFA_Element::Unknown) {
+ for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem;
+ pItem = pItem->m_pNextSibling) {
+ if (pItem->m_pFormNode->GetElementType() == XFA_Element::ContentArea) {
+ if (!bOnPageArea) {
+ CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
+ CXFA_TraverseStrategy_ContentLayoutItem>
+ iterator(static_cast<CXFA_ContentLayoutItem*>(pItem->m_pFirstChild));
+ for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent();
+ pItemChild; pItemChild = iterator.MoveToNext()) {
+ if (!pItemChild->IsContentLayoutItem())
+ continue;
+ if (pItemChild->m_pFormNode->GetElementType() != eType)
+ continue;
+ if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode))
+ continue;
+
+ formItems.insert(pItemChild->m_pFormNode);
+ retArray.push_back(pItemChild->m_pFormNode);
+ }
+ }
+ } else {
+ if (bOnPageArea) {
+ CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem,
+ CXFA_TraverseStrategy_ContentLayoutItem>
+ iterator(static_cast<CXFA_ContentLayoutItem*>(pItem));
+ for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent();
+ pItemChild; pItemChild = iterator.MoveToNext()) {
+ if (!pItemChild->IsContentLayoutItem())
+ continue;
+ if (pItemChild->m_pFormNode->GetElementType() != eType)
+ continue;
+ if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode))
+ continue;
+
+ formItems.insert(pItemChild->m_pFormNode);
+ retArray.push_back(pItemChild->m_pFormNode);
+ }
+ }
+ }
+ }
+ }
+ return retArray;
+}
+
+void CJX_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 1 || iLength > 3) {
+ ThrowParamCountMismatchException(L"pageContent");
+ return;
+ }
+
+ int32_t iIndex = 0;
+ WideString wsType;
+ bool bOnPageArea = false;
+ if (iLength >= 1)
+ iIndex = pArguments->GetInt32(0);
+
+ if (iLength >= 2) {
+ ByteString bsType = pArguments->GetUTF8String(1);
+ wsType = WideString::FromUTF8(bsType.AsStringView());
+ }
+ if (iLength >= 3)
+ bOnPageArea = pArguments->GetInt32(2) == 0 ? false : true;
+
+ CXFA_FFNotify* pNotify =
+ GetXFALayoutPseudoModel()->GetDocument()->GetNotify();
+ if (!pNotify)
+ return;
+
+ CXFA_LayoutProcessor* pDocLayout =
+ GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+ if (!pDocLayout)
+ return;
+
+ auto pArrayNodeList = pdfium::MakeUnique<CXFA_ArrayNodeList>(
+ GetXFALayoutPseudoModel()->GetDocument());
+ pArrayNodeList->SetArrayNodeList(
+ GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea));
+ pArguments->GetReturnValue()->SetObject(pArrayNodeList.release(),
+ GetXFALayoutPseudoModel()
+ ->GetDocument()
+ ->GetScriptContext()
+ ->GetJseNormalClass());
+}
+
+void CJX_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) {
+ NumberedPageCount(pArguments, false);
+}
+
+void CJX_LayoutPseudoModel::AbsPageCountInBatch(CFXJSE_Arguments* pArguments) {
+ pArguments->GetReturnValue()->SetInteger(0);
+}
+
+void CJX_LayoutPseudoModel::SheetCountInBatch(CFXJSE_Arguments* pArguments) {
+ pArguments->GetReturnValue()->SetInteger(0);
+}
+
+void CJX_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) {
+ CXFA_Node* pRootNode = GetXFALayoutPseudoModel()->GetDocument()->GetRoot();
+ CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form);
+ CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild);
+ CXFA_LayoutProcessor* pLayoutProcessor =
+ GetXFALayoutPseudoModel()->GetDocument()->GetLayoutProcessor();
+ if (pContentRootNode)
+ pLayoutProcessor->AddChangedContainer(pContentRootNode);
+
+ pLayoutProcessor->SetForceReLayout(true);
+}
+
+void CJX_LayoutPseudoModel::AbsPageSpan(CFXJSE_Arguments* pArguments) {
+ PageSpan(pArguments);
+}
+
+void CJX_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"absPageInBatch");
+ return;
+ }
+
+ pArguments->GetReturnValue()->SetInteger(0);
+}
+
+void CJX_LayoutPseudoModel::SheetInBatch(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 1) {
+ ThrowParamCountMismatchException(L"sheetInBatch");
+ return;
+ }
+
+ pArguments->GetReturnValue()->SetInteger(0);
+}
+
+void CJX_LayoutPseudoModel::Sheet(CFXJSE_Arguments* pArguments) {
+ PageInternals(pArguments, true);
+}
+
+void CJX_LayoutPseudoModel::RelayoutPageArea(CFXJSE_Arguments* pArguments) {}
+
+void CJX_LayoutPseudoModel::SheetCount(CFXJSE_Arguments* pArguments) {
+ NumberedPageCount(pArguments, false);
+}
+
+void CJX_LayoutPseudoModel::AbsPage(CFXJSE_Arguments* pArguments) {
+ PageInternals(pArguments, true);
+}
+
+void CJX_LayoutPseudoModel::PageInternals(CFXJSE_Arguments* pArguments,
+ bool bAbsPage) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength != 1) {
+ ThrowParamCountMismatchException(bAbsPage ? L"absPage" : L"page");
+ return;
+ }
+
+ CXFA_Node* pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0));
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (!pNode)
+ pValue->SetInteger(0);
+
+ CXFA_LayoutProcessor* pDocLayout =
+ GetXFALayoutPseudoModel()->GetDocument()->GetDocLayout();
+ if (!pDocLayout)
+ return;
+
+ CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode);
+ if (!pLayoutItem) {
+ pValue->SetInteger(-1);
+ return;
+ }
+
+ int32_t iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex();
+ pValue->SetInteger(bAbsPage ? iPage : iPage + 1);
+}
diff --git a/fxjs/cjx_layoutpseudomodel.h b/fxjs/cjx_layoutpseudomodel.h
new file mode 100644
index 0000000000..276eff8a2c
--- /dev/null
+++ b/fxjs/cjx_layoutpseudomodel.h
@@ -0,0 +1,66 @@
+// 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_CJX_LAYOUTPSEUDOMODEL_H_
+#define FXJS_CJX_LAYOUTPSEUDOMODEL_H_
+
+#include <vector>
+
+#include "fxjs/cjx_object.h"
+
+enum XFA_LAYOUTMODEL_HWXY {
+ XFA_LAYOUTMODEL_H,
+ XFA_LAYOUTMODEL_W,
+ XFA_LAYOUTMODEL_X,
+ XFA_LAYOUTMODEL_Y
+};
+
+class CFXJSE_Arguments;
+class CFXJSE_Value;
+class CScript_LayoutPseudoModel;
+class CXFA_LayoutProcessor;
+class CXFA_Node;
+
+class CJX_LayoutPseudoModel : public CJX_Object {
+ public:
+ explicit CJX_LayoutPseudoModel(CScript_LayoutPseudoModel* model);
+ ~CJX_LayoutPseudoModel() override;
+
+ CScript_LayoutPseudoModel* GetXFALayoutPseudoModel();
+
+ void Ready(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute);
+
+ void H(CFXJSE_Arguments* pArguments);
+ void W(CFXJSE_Arguments* pArguments);
+ void X(CFXJSE_Arguments* pArguments);
+ void Y(CFXJSE_Arguments* pArguments);
+ void PageCount(CFXJSE_Arguments* pArguments);
+ void PageSpan(CFXJSE_Arguments* pArguments);
+ void Page(CFXJSE_Arguments* pArguments);
+ void PageContent(CFXJSE_Arguments* pArguments);
+ void AbsPageCount(CFXJSE_Arguments* pArguments);
+ void AbsPageCountInBatch(CFXJSE_Arguments* pArguments);
+ void SheetCountInBatch(CFXJSE_Arguments* pArguments);
+ void Relayout(CFXJSE_Arguments* pArguments);
+ void AbsPageSpan(CFXJSE_Arguments* pArguments);
+ void AbsPageInBatch(CFXJSE_Arguments* pArguments);
+ void SheetInBatch(CFXJSE_Arguments* pArguments);
+ void Sheet(CFXJSE_Arguments* pArguments);
+ void RelayoutPageArea(CFXJSE_Arguments* pArguments);
+ void SheetCount(CFXJSE_Arguments* pArguments);
+ void AbsPage(CFXJSE_Arguments* pArguments);
+
+ private:
+ void NumberedPageCount(CFXJSE_Arguments* pArguments, bool bNumbered);
+ void HWXY(CFXJSE_Arguments* pArguments, XFA_LAYOUTMODEL_HWXY layoutModel);
+ std::vector<CXFA_Node*> GetObjArray(CXFA_LayoutProcessor* pDocLayout,
+ int32_t iPageNo,
+ const WideString& wsType,
+ bool bOnPageArea);
+ void PageInternals(CFXJSE_Arguments* pArguments, bool bAbsPage);
+};
+
+#endif // FXJS_CJX_LAYOUTPSEUDOMODEL_H_
diff --git a/fxjs/cjx_logpseudomodel.cpp b/fxjs/cjx_logpseudomodel.cpp
new file mode 100644
index 0000000000..815f1a8a98
--- /dev/null
+++ b/fxjs/cjx_logpseudomodel.cpp
@@ -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
+
+#include "fxjs/cjx_logpseudomodel.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cscript_logpseudomodel.h"
+
+CJX_LogPseudoModel::CJX_LogPseudoModel(CScript_LogPseudoModel* model)
+ : CJX_Object(model) {}
+
+CJX_LogPseudoModel::~CJX_LogPseudoModel() {}
+
+void CJX_LogPseudoModel::Message(CFXJSE_Arguments* pArguments) {}
+
+void CJX_LogPseudoModel::TraceEnabled(CFXJSE_Arguments* pArguments) {}
+
+void CJX_LogPseudoModel::TraceActivate(CFXJSE_Arguments* pArguments) {}
+
+void CJX_LogPseudoModel::TraceDeactivate(CFXJSE_Arguments* pArguments) {}
+
+void CJX_LogPseudoModel::Trace(CFXJSE_Arguments* pArguments) {}
diff --git a/fxjs/cjx_logpseudomodel.h b/fxjs/cjx_logpseudomodel.h
new file mode 100644
index 0000000000..26a47026e7
--- /dev/null
+++ b/fxjs/cjx_logpseudomodel.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_CJX_LOGPSEUDOMODEL_H_
+#define FXJS_CJX_LOGPSEUDOMODEL_H_
+
+#include "fxjs/cjx_object.h"
+
+class CFXJSE_Arguments;
+class CFXJSE_Value;
+class CScript_LogPseudoModel;
+
+class CJX_LogPseudoModel : public CJX_Object {
+ public:
+ explicit CJX_LogPseudoModel(CScript_LogPseudoModel* model);
+ ~CJX_LogPseudoModel() override;
+
+ void Message(CFXJSE_Arguments* pArguments);
+ void TraceEnabled(CFXJSE_Arguments* pArguments);
+ void TraceActivate(CFXJSE_Arguments* pArguments);
+ void TraceDeactivate(CFXJSE_Arguments* pArguments);
+ void Trace(CFXJSE_Arguments* pArguments);
+};
+
+#endif // FXJS_CJX_LOGPSEUDOMODEL_H_
diff --git a/fxjs/cjx_signaturepseudomodel.cpp b/fxjs/cjx_signaturepseudomodel.cpp
new file mode 100644
index 0000000000..76cf989b7f
--- /dev/null
+++ b/fxjs/cjx_signaturepseudomodel.cpp
@@ -0,0 +1,61 @@
+// 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/cjx_signaturepseudomodel.h"
+
+#include "fxjs/cfxjse_arguments.h"
+#include "fxjs/cfxjse_value.h"
+#include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
+
+CJX_SignaturePseudoModel::CJX_SignaturePseudoModel(
+ CScript_SignaturePseudoModel* model)
+ : CJX_Object(model) {}
+
+CJX_SignaturePseudoModel::~CJX_SignaturePseudoModel() {}
+
+void CJX_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 1 || iLength > 4) {
+ ThrowParamCountMismatchException(L"verify");
+ return;
+ }
+
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetInteger(0);
+}
+
+void CJX_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 3 || iLength > 7) {
+ ThrowParamCountMismatchException(L"sign");
+ return;
+ }
+
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetBoolean(false);
+}
+
+void CJX_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) {
+ if (pArguments->GetLength() != 0) {
+ ThrowParamCountMismatchException(L"enumerate");
+ return;
+ }
+ return;
+}
+
+void CJX_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) {
+ int32_t iLength = pArguments->GetLength();
+ if (iLength < 1 || iLength > 2) {
+ ThrowParamCountMismatchException(L"clear");
+ return;
+ }
+
+ CFXJSE_Value* pValue = pArguments->GetReturnValue();
+ if (pValue)
+ pValue->SetBoolean(false);
+}
diff --git a/fxjs/cjx_signaturepseudomodel.h b/fxjs/cjx_signaturepseudomodel.h
new file mode 100644
index 0000000000..e0e1f09dd2
--- /dev/null
+++ b/fxjs/cjx_signaturepseudomodel.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_CJX_SIGNATUREPSEUDOMODEL_H_
+#define FXJS_CJX_SIGNATUREPSEUDOMODEL_H_
+
+#include "fxjs/cjx_object.h"
+
+class CFXJSE_Arguments;
+class CFXJSE_Value;
+class CScript_SignaturePseudoModel;
+
+class CJX_SignaturePseudoModel : public CJX_Object {
+ public:
+ explicit CJX_SignaturePseudoModel(CScript_SignaturePseudoModel* model);
+ ~CJX_SignaturePseudoModel() override;
+
+ void Verify(CFXJSE_Arguments* pArguments);
+ void Sign(CFXJSE_Arguments* pArguments);
+ void Enumerate(CFXJSE_Arguments* pArguments);
+ void Clear(CFXJSE_Arguments* pArguments);
+};
+
+#endif // FXJS_CJX_SIGNATUREPSEUDOMODEL_H_