diff options
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cscript_datawindow.cpp | 36 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_datawindow.h | 5 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_eventpseudomodel.cpp | 180 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_eventpseudomodel.h | 30 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_hostpseudomodel.cpp | 600 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_hostpseudomodel.h | 10 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_layoutpseudomodel.cpp | 399 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_layoutpseudomodel.h | 24 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_logpseudomodel.cpp | 26 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_logpseudomodel.h | 5 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_signaturepseudomodel.cpp | 44 | ||||
-rw-r--r-- | xfa/fxfa/parser/cscript_signaturepseudomodel.h | 5 |
12 files changed, 166 insertions, 1198 deletions
diff --git a/xfa/fxfa/parser/cscript_datawindow.cpp b/xfa/fxfa/parser/cscript_datawindow.cpp index 80b31f7ca9..aff1d22bda 100644 --- a/xfa/fxfa/parser/cscript_datawindow.cpp +++ b/xfa/fxfa/parser/cscript_datawindow.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cscript_datawindow.h" #include "fxjs/cfxjse_arguments.h" -#include "fxjs/cjx_object.h" +#include "fxjs/cjx_datawindow.h" #include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" @@ -18,30 +18,46 @@ CScript_DataWindow::CScript_DataWindow(CXFA_Document* pDocument) XFA_ObjectType::Object, XFA_Element::DataWindow, WideStringView(L"dataWindow"), - pdfium::MakeUnique<CJX_Object>(this)) {} + pdfium::MakeUnique<CJX_DataWindow>(this)) {} CScript_DataWindow::~CScript_DataWindow() {} -void CScript_DataWindow::MoveCurrentRecord(CFXJSE_Arguments* pArguments) {} +void CScript_DataWindow::MoveCurrentRecord(CFXJSE_Arguments* pArguments) { + JSDataWindow()->MoveCurrentRecord(pArguments); +} -void CScript_DataWindow::Record(CFXJSE_Arguments* pArguments) {} +void CScript_DataWindow::Record(CFXJSE_Arguments* pArguments) { + JSDataWindow()->Record(pArguments); +} -void CScript_DataWindow::GotoRecord(CFXJSE_Arguments* pArguments) {} +void CScript_DataWindow::GotoRecord(CFXJSE_Arguments* pArguments) { + JSDataWindow()->GotoRecord(pArguments); +} -void CScript_DataWindow::IsRecordGroup(CFXJSE_Arguments* pArguments) {} +void CScript_DataWindow::IsRecordGroup(CFXJSE_Arguments* pArguments) { + JSDataWindow()->IsRecordGroup(pArguments); +} void CScript_DataWindow::RecordsBefore(CFXJSE_Value* pValue, bool bSetting, - XFA_ATTRIBUTE eAttribute) {} + XFA_ATTRIBUTE eAttribute) { + JSDataWindow()->RecordsBefore(pValue, bSetting, eAttribute); +} void CScript_DataWindow::CurrentRecordNumber(CFXJSE_Value* pValue, bool bSetting, - XFA_ATTRIBUTE eAttribute) {} + XFA_ATTRIBUTE eAttribute) { + JSDataWindow()->CurrentRecordNumber(pValue, bSetting, eAttribute); +} void CScript_DataWindow::RecordsAfter(CFXJSE_Value* pValue, bool bSetting, - XFA_ATTRIBUTE eAttribute) {} + XFA_ATTRIBUTE eAttribute) { + JSDataWindow()->RecordsAfter(pValue, bSetting, eAttribute); +} void CScript_DataWindow::IsDefined(CFXJSE_Value* pValue, bool bSetting, - XFA_ATTRIBUTE eAttribute) {} + XFA_ATTRIBUTE eAttribute) { + JSDataWindow()->IsDefined(pValue, bSetting, eAttribute); +} diff --git a/xfa/fxfa/parser/cscript_datawindow.h b/xfa/fxfa/parser/cscript_datawindow.h index ae12316891..b7468ce3d0 100644 --- a/xfa/fxfa/parser/cscript_datawindow.h +++ b/xfa/fxfa/parser/cscript_datawindow.h @@ -7,6 +7,7 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_DATAWINDOW_H_ #define XFA_FXFA_PARSER_CSCRIPT_DATAWINDOW_H_ +#include "fxjs/cjx_datawindow.h" #include "xfa/fxfa/parser/cxfa_object.h" class CFXJSE_Arguments; @@ -16,6 +17,10 @@ class CScript_DataWindow : public CXFA_Object { explicit CScript_DataWindow(CXFA_Document* pDocument); ~CScript_DataWindow() override; + CJX_DataWindow* JSDataWindow() { + return static_cast<CJX_DataWindow*>(JSObject()); + } + void MoveCurrentRecord(CFXJSE_Arguments* pArguments); void Record(CFXJSE_Arguments* pArguments); void GotoRecord(CFXJSE_Arguments* pArguments); diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp index 633ee9b7d2..806a318d8c 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.cpp @@ -7,226 +7,118 @@ #include "xfa/fxfa/parser/cscript_eventpseudomodel.h" #include "fxjs/cfxjse_arguments.h" -#include "fxjs/cfxjse_engine.h" #include "fxjs/cjx_object.h" #include "third_party/base/ptr_util.h" -#include "xfa/fxfa/cxfa_eventparam.h" -#include "xfa/fxfa/cxfa_ffnotify.h" -#include "xfa/fxfa/cxfa_ffwidgethandler.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_utils.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 CScript_EventPseudoModel::CScript_EventPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::EventPseudoModel, WideStringView(L"eventPseudoModel"), - pdfium::MakeUnique<CJX_Object>(this)) {} + pdfium::MakeUnique<CJX_EventPseudoModel>(this)) {} CScript_EventPseudoModel::~CScript_EventPseudoModel() {} -void CScript_EventPseudoModel::Property(CFXJSE_Value* pValue, - XFA_Event dwFlag, - bool bSetting) { - CFXJSE_Engine* pScriptContext = m_pDocument->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; - } -} void CScript_EventPseudoModel::Change(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Change, bSetting); + JSEventPseudoModel()->Change(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::CommitKey(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::CommitKey, bSetting); + JSEventPseudoModel()->CommitKey(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::FullText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::FullText, bSetting); + JSEventPseudoModel()->FullText(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::KeyDown(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Keydown, bSetting); + JSEventPseudoModel()->KeyDown(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Modifier(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Modifier, bSetting); + JSEventPseudoModel()->Modifier(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::NewContentType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::NewContentType, bSetting); + JSEventPseudoModel()->NewContentType(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::NewText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::NewText, bSetting); + JSEventPseudoModel()->NewText(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::PrevContentType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::PreviousContentType, bSetting); + JSEventPseudoModel()->PrevContentType(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::PrevText(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::PreviousText, bSetting); + JSEventPseudoModel()->PrevText(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Reenter(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Reenter, bSetting); + JSEventPseudoModel()->Reenter(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::SelEnd(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::SelectionEnd, bSetting); + JSEventPseudoModel()->SelEnd(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::SelStart(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::SelectionStart, bSetting); + JSEventPseudoModel()->SelStart(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Shift(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Shift, bSetting); + JSEventPseudoModel()->Shift(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::SoapFaultCode(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::SoapFaultCode, bSetting); + JSEventPseudoModel()->SoapFaultString(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::SoapFaultString(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::SoapFaultString, bSetting); + JSEventPseudoModel()->SoapFaultString(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Target(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - Property(pValue, XFA_Event::Target, bSetting); + JSEventPseudoModel()->Target(pValue, bSetting, eAttribute); } + void CScript_EventPseudoModel::Emit(CFXJSE_Arguments* pArguments) { - CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) { - return; - } - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - CXFA_FFWidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler(); - if (!pWidgetHandler) { - return; - } - pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam); + JSEventPseudoModel()->Emit(pArguments); } + void CScript_EventPseudoModel::Reset(CFXJSE_Arguments* pArguments) { - CFXJSE_Engine* pScriptContext = m_pDocument->GetScriptContext(); - if (!pScriptContext) { - return; - } - CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); - if (!pEventParam) { - return; - } - pEventParam->Reset(); + JSEventPseudoModel()->Reset(pArguments); } diff --git a/xfa/fxfa/parser/cscript_eventpseudomodel.h b/xfa/fxfa/parser/cscript_eventpseudomodel.h index dfad255d7e..20458f8fab 100644 --- a/xfa/fxfa/parser/cscript_eventpseudomodel.h +++ b/xfa/fxfa/parser/cscript_eventpseudomodel.h @@ -7,34 +7,21 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_EVENTPSEUDOMODEL_H_ #define XFA_FXFA_PARSER_CSCRIPT_EVENTPSEUDOMODEL_H_ -#include "fxjs/cfxjse_arguments.h" +#include "fxjs/cjx_eventpseudomodel.h" #include "xfa/fxfa/parser/cxfa_object.h" -enum class XFA_Event { - Change = 0, - CommitKey, - FullText, - Keydown, - Modifier, - NewContentType, - NewText, - PreviousContentType, - PreviousText, - Reenter, - SelectionEnd, - SelectionStart, - Shift, - SoapFaultCode, - SoapFaultString, - Target, - CancelAction -}; +class CFXJSE_Arguments; +class CFXJSE_Value; class CScript_EventPseudoModel : public CXFA_Object { public: explicit CScript_EventPseudoModel(CXFA_Document* pDocument); ~CScript_EventPseudoModel() override; + CJX_EventPseudoModel* JSEventPseudoModel() { + return static_cast<CJX_EventPseudoModel*>(JSObject()); + } + 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); @@ -62,9 +49,6 @@ class CScript_EventPseudoModel : public CXFA_Object { void Emit(CFXJSE_Arguments* pArguments); void Reset(CFXJSE_Arguments* pArguments); - - private: - void Property(CFXJSE_Value* pValue, XFA_Event dwFlag, bool bSetting); }; #endif // XFA_FXFA_PARSER_CSCRIPT_EVENTPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp index 75227cfe79..c9fa8e30a7 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.cpp @@ -6,685 +6,145 @@ #include "xfa/fxfa/parser/cscript_hostpseudomodel.h" -#include <memory> - #include "fxjs/cfxjse_arguments.h" -#include "fxjs/cfxjse_engine.h" -#include "fxjs/cjx_object.h" #include "third_party/base/ptr_util.h" -#include "xfa/fxfa/cxfa_ffnotify.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_layoutprocessor.h" -#include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/cxfa_node.h" -#include "xfa/fxfa/parser/xfa_resolvenode_rs.h" -#include "xfa/fxfa/parser/xfa_utils.h" - -namespace { - -CXFA_Node* ToNode(CFXJSE_Value* pValue, CFXJSE_Class* pClass) { - return static_cast<CXFA_Node*>(pValue->ToHostObject(pClass)); -} - -} // namespace CScript_HostPseudoModel::CScript_HostPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::HostPseudoModel, WideStringView(L"hostPseudoModel"), - pdfium::MakeUnique<CJX_Object>(this)) {} + pdfium::MakeUnique<CJX_HostPseudoModel>(this)) {} CScript_HostPseudoModel::~CScript_HostPseudoModel() {} void CScript_HostPseudoModel::AppType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) - return; - if (bSetting) { - JSObject()->ThrowInvalidPropertyException(); - return; - } - pValue->SetString("Exchange"); + JSHostPseudoModel()->AppType(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::CalculationsEnabled(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - CXFA_FFDoc* hDoc = pNotify->GetHDOC(); - if (bSetting) { - pNotify->GetDocEnvironment()->SetCalculationsEnabled(hDoc, - pValue->ToBoolean()); - return; - } - pValue->SetBoolean(pNotify->GetDocEnvironment()->IsCalculationsEnabled(hDoc)); + JSHostPseudoModel()->CalculationsEnabled(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::CurrentPage(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - CXFA_FFDoc* hDoc = pNotify->GetHDOC(); - if (bSetting) { - pNotify->GetDocEnvironment()->SetCurrentPage(hDoc, pValue->ToInteger()); - return; - } - pValue->SetInteger(pNotify->GetDocEnvironment()->GetCurrentPage(hDoc)); + JSHostPseudoModel()->CurrentPage(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::Language(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) - return; - if (bSetting) { - JSObject()->ThrowException(L"Unable to set language value."); - return; - } - pValue->SetString( - pNotify->GetAppProvider()->GetLanguage().UTF8Encode().AsStringView()); + JSHostPseudoModel()->Language(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::NumPages(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - CXFA_FFDoc* hDoc = pNotify->GetHDOC(); - if (bSetting) { - JSObject()->ThrowException(L"Unable to set numPages value."); - return; - } - pValue->SetInteger(pNotify->GetDocEnvironment()->CountPages(hDoc)); + JSHostPseudoModel()->NumPages(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::Platform(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) - return; - if (bSetting) { - JSObject()->ThrowException(L"Unable to set platform value."); - return; - } - pValue->SetString( - pNotify->GetAppProvider()->GetPlatform().UTF8Encode().AsStringView()); + JSHostPseudoModel()->Platform(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::Title(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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()); + JSHostPseudoModel()->Title(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::ValidationsEnabled(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->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); + JSHostPseudoModel()->ValidationsEnabled(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::Variation(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) - return; - - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) - return; - if (bSetting) { - JSObject()->ThrowException(L"Unable to set variation value."); - return; - } - pValue->SetString("Full"); + JSHostPseudoModel()->Variation(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::Version(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - JSObject()->ThrowException(L"Unable to set version value."); - return; - } - pValue->SetString("11"); + JSHostPseudoModel()->Version(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::Name(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - JSObject()->ThrowInvalidPropertyException(); - return; - } - pValue->SetString( - pNotify->GetAppProvider()->GetAppName().UTF8Encode().AsStringView()); + JSHostPseudoModel()->Name(pValue, bSetting, eAttribute); } void CScript_HostPseudoModel::GotoURL(CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - JSObject()->ThrowParamCountMismatchException(L"gotoURL"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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); + JSHostPseudoModel()->GotoURL(pArguments); } void CScript_HostPseudoModel::OpenList(CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - JSObject()->ThrowParamCountMismatchException(L"openList"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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 = m_pDocument->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 = m_pDocument->GetDocLayout(); - if (!pDocLayout) { - return; - } - CXFA_FFWidget* hWidget = - pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); - if (!hWidget) { - return; - } - pNotify->GetDocEnvironment()->SetFocusWidget(pNotify->GetHDOC(), hWidget); - pNotify->OpenDropDownList(hWidget); + JSHostPseudoModel()->OpenList(pArguments); } + void CScript_HostPseudoModel::Response(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 4) { - JSObject()->ThrowParamCountMismatchException(L"response"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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()); + JSHostPseudoModel()->Response(pArguments); } void CScript_HostPseudoModel::DocumentInBatch(CFXJSE_Arguments* pArguments) { - if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) - pValue->SetInteger(0); -} - -static int32_t XFA_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; + JSHostPseudoModel()->DocumentInBatch(pArguments); } void CScript_HostPseudoModel::ResetData(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 1) { - JSObject()->ThrowParamCountMismatchException(L"resetData"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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 = XFA_FilterName(wsExpression.AsStringView(), iStart, wsName); - CFXJSE_Engine* pScriptContext = m_pDocument->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(); - } + JSHostPseudoModel()->ResetData(pArguments); } void CScript_HostPseudoModel::Beep(CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 1) { - JSObject()->ThrowParamCountMismatchException(L"beep"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - uint32_t dwType = 4; - if (iLength >= 1) { - dwType = pArguments->GetInt32(0); - } - pNotify->GetAppProvider()->Beep(dwType); + JSHostPseudoModel()->Beep(pArguments); } void CScript_HostPseudoModel::SetFocus(CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - JSObject()->ThrowParamCountMismatchException(L"setFocus"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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 = m_pDocument->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); + JSHostPseudoModel()->SetFocus(pArguments); } void CScript_HostPseudoModel::GetFocus(CFXJSE_Arguments* pArguments) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - CXFA_Node* pNode = pNotify->GetFocusWidgetNode(); - if (!pNode) { - return; - } - pArguments->GetReturnValue()->Assign( - m_pDocument->GetScriptContext()->GetJSValueFromMap(pNode)); -} -void CScript_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 4) { - JSObject()->ThrowParamCountMismatchException(L"messageBox"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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); + JSHostPseudoModel()->GetFocus(pArguments); } -bool CScript_HostPseudoModel::ValidateArgsForMsg(CFXJSE_Arguments* pArguments, - int32_t iArgIndex, - WideString& wsValue) { - if (!pArguments || iArgIndex < 0) { - return false; - } - bool bIsJsType = false; - if (m_pDocument->GetScriptContext()->GetType() == - XFA_SCRIPTLANGTYPE_Javascript) { - bIsJsType = true; - } - std::unique_ptr<CFXJSE_Value> pValueArg(pArguments->GetValue(iArgIndex)); - if (!pValueArg->IsString() && bIsJsType) { - JSObject()->ThrowArgumentMismatchException(); - return false; - } - if (pValueArg->IsNull()) { - wsValue = L""; - } else { - wsValue = pValueArg->ToWideString(); - } - return true; +void CScript_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) { + JSHostPseudoModel()->MessageBox(pArguments); } void CScript_HostPseudoModel::DocumentCountInBatch( CFXJSE_Arguments* pArguments) { - if (CFXJSE_Value* pValue = pArguments->GetReturnValue()) - pValue->SetInteger(0); + JSHostPseudoModel()->DocumentCountInBatch(pArguments); } void CScript_HostPseudoModel::Print(CFXJSE_Arguments* pArguments) { - if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { - return; - } - int32_t iLength = pArguments->GetLength(); - if (iLength != 8) { - JSObject()->ThrowParamCountMismatchException(L"print"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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); + JSHostPseudoModel()->Print(pArguments); } void CScript_HostPseudoModel::ImportData(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 1) { - JSObject()->ThrowParamCountMismatchException(L"importData"); - return; - } - // Not implemented. + JSHostPseudoModel()->ImportData(pArguments); } void CScript_HostPseudoModel::ExportData(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 0 || iLength > 2) { - JSObject()->ThrowParamCountMismatchException(L"exportData"); - return; - } - CXFA_FFNotify* pNotify = m_pDocument->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); + JSHostPseudoModel()->ExportData(pArguments); } void CScript_HostPseudoModel::PageUp(CFXJSE_Arguments* pArguments) { - CXFA_FFNotify* pNotify = m_pDocument->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); + JSHostPseudoModel()->PageUp(pArguments); } void CScript_HostPseudoModel::PageDown(CFXJSE_Arguments* pArguments) { - CXFA_FFNotify* pNotify = m_pDocument->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); + JSHostPseudoModel()->PageDown(pArguments); } void CScript_HostPseudoModel::CurrentDateTime(CFXJSE_Arguments* pArguments) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - WideString wsDataTime = pNotify->GetCurrentDateTime(); - CFXJSE_Value* pValue = pArguments->GetReturnValue(); - if (pValue) - pValue->SetString(wsDataTime.UTF8Encode().AsStringView()); + JSHostPseudoModel()->CurrentDateTime(pArguments); } diff --git a/xfa/fxfa/parser/cscript_hostpseudomodel.h b/xfa/fxfa/parser/cscript_hostpseudomodel.h index de07b1cd45..05e859f499 100644 --- a/xfa/fxfa/parser/cscript_hostpseudomodel.h +++ b/xfa/fxfa/parser/cscript_hostpseudomodel.h @@ -7,6 +7,7 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_HOSTPSEUDOMODEL_H_ #define XFA_FXFA_PARSER_CSCRIPT_HOSTPSEUDOMODEL_H_ +#include "fxjs/cjx_hostpseudomodel.h" #include "xfa/fxfa/parser/cxfa_object.h" class CFXJSE_Arguments; @@ -17,6 +18,10 @@ class CScript_HostPseudoModel : public CXFA_Object { explicit CScript_HostPseudoModel(CXFA_Document* pDocument); ~CScript_HostPseudoModel() override; + CJX_HostPseudoModel* JSHostPseudoModel() { + return static_cast<CJX_HostPseudoModel*>(JSObject()); + } + void AppType(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute); void CalculationsEnabled(CFXJSE_Value* pValue, bool bSetting, @@ -50,11 +55,6 @@ class CScript_HostPseudoModel : public CXFA_Object { 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 // XFA_FXFA_PARSER_CSCRIPT_HOSTPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp index 4c7d7f2006..8714d54684 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.cpp @@ -6,455 +6,98 @@ #include "xfa/fxfa/parser/cscript_layoutpseudomodel.h" -#include <set> - #include "fxjs/cfxjse_arguments.h" -#include "fxjs/cfxjse_engine.h" -#include "fxjs/cjx_object.h" #include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -#include "xfa/fxfa/cxfa_ffnotify.h" -#include "xfa/fxfa/parser/cxfa_arraynodelist.h" -#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" -#include "xfa/fxfa/parser/cxfa_contentlayoutitem.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_localemgr.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" CScript_LayoutPseudoModel::CScript_LayoutPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::LayoutPseudoModel, WideStringView(L"layoutPseudoModel"), - pdfium::MakeUnique<CJX_Object>(this)) {} + pdfium::MakeUnique<CJX_LayoutPseudoModel>(this)) {} CScript_LayoutPseudoModel::~CScript_LayoutPseudoModel() {} void CScript_LayoutPseudoModel::Ready(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute) { - CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); - if (!pNotify) { - return; - } - if (bSetting) { - JSObject()->ThrowException(L"Unable to set ready value."); - return; - } - int32_t iStatus = pNotify->GetLayoutStatus(); - pValue->SetBoolean(iStatus >= 2); -} - -void CScript_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; - } - JSObject()->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 = m_pDocument->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); + JSLayoutPseudoModel()->Ready(pValue, bSetting, eAttribute); } void CScript_LayoutPseudoModel::H(CFXJSE_Arguments* pArguments) { - HWXY(pArguments, XFA_LAYOUTMODEL_H); + JSLayoutPseudoModel()->H(pArguments); } void CScript_LayoutPseudoModel::W(CFXJSE_Arguments* pArguments) { - HWXY(pArguments, XFA_LAYOUTMODEL_W); + JSLayoutPseudoModel()->W(pArguments); } void CScript_LayoutPseudoModel::X(CFXJSE_Arguments* pArguments) { - HWXY(pArguments, XFA_LAYOUTMODEL_X); + JSLayoutPseudoModel()->X(pArguments); } void CScript_LayoutPseudoModel::Y(CFXJSE_Arguments* pArguments) { - HWXY(pArguments, XFA_LAYOUTMODEL_Y); -} - -void CScript_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments, - bool bNumbered) { - CXFA_LayoutProcessor* pDocLayout = m_pDocument->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); + JSLayoutPseudoModel()->Y(pArguments); } void CScript_LayoutPseudoModel::PageCount(CFXJSE_Arguments* pArguments) { - NumberedPageCount(pArguments, true); + JSLayoutPseudoModel()->PageCount(pArguments); } void CScript_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - JSObject()->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 = m_pDocument->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); + JSLayoutPseudoModel()->PageSpan(pArguments); } void CScript_LayoutPseudoModel::Page(CFXJSE_Arguments* pArguments) { - PageInternals(pArguments, false); -} - -std::vector<CXFA_Node*> CScript_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; + JSLayoutPseudoModel()->Page(pArguments); } void CScript_LayoutPseudoModel::PageContent(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 3) { - JSObject()->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 = m_pDocument->GetNotify(); - if (!pNotify) - return; - - CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); - if (!pDocLayout) - return; - - auto pArrayNodeList = - pdfium::MakeUnique<CXFA_ArrayNodeList>(m_pDocument.Get()); - pArrayNodeList->SetArrayNodeList( - GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea)); - pArguments->GetReturnValue()->SetObject( - pArrayNodeList.release(), - m_pDocument->GetScriptContext()->GetJseNormalClass()); + JSLayoutPseudoModel()->PageContent(pArguments); } void CScript_LayoutPseudoModel::AbsPageCount(CFXJSE_Arguments* pArguments) { - NumberedPageCount(pArguments, false); + JSLayoutPseudoModel()->AbsPageCount(pArguments); } void CScript_LayoutPseudoModel::AbsPageCountInBatch( CFXJSE_Arguments* pArguments) { - pArguments->GetReturnValue()->SetInteger(0); + JSLayoutPseudoModel()->AbsPageCountInBatch(pArguments); } void CScript_LayoutPseudoModel::SheetCountInBatch( CFXJSE_Arguments* pArguments) { - pArguments->GetReturnValue()->SetInteger(0); + JSLayoutPseudoModel()->SheetCountInBatch(pArguments); } void CScript_LayoutPseudoModel::Relayout(CFXJSE_Arguments* pArguments) { - CXFA_Node* pRootNode = m_pDocument->GetRoot(); - CXFA_Node* pFormRoot = pRootNode->GetFirstChildByClass(XFA_Element::Form); - CXFA_Node* pContentRootNode = pFormRoot->GetNodeItem(XFA_NODEITEM_FirstChild); - CXFA_LayoutProcessor* pLayoutProcessor = m_pDocument->GetLayoutProcessor(); - if (pContentRootNode) - pLayoutProcessor->AddChangedContainer(pContentRootNode); - - pLayoutProcessor->SetForceReLayout(true); + JSLayoutPseudoModel()->Relayout(pArguments); } void CScript_LayoutPseudoModel::AbsPageSpan(CFXJSE_Arguments* pArguments) { - PageSpan(pArguments); + JSLayoutPseudoModel()->AbsPageSpan(pArguments); } void CScript_LayoutPseudoModel::AbsPageInBatch(CFXJSE_Arguments* pArguments) { - if (pArguments->GetLength() != 1) { - JSObject()->ThrowParamCountMismatchException(L"absPageInBatch"); - return; - } - - pArguments->GetReturnValue()->SetInteger(0); + JSLayoutPseudoModel()->AbsPageInBatch(pArguments); } void CScript_LayoutPseudoModel::SheetInBatch(CFXJSE_Arguments* pArguments) { - if (pArguments->GetLength() != 1) { - JSObject()->ThrowParamCountMismatchException(L"sheetInBatch"); - return; - } - - pArguments->GetReturnValue()->SetInteger(0); + JSLayoutPseudoModel()->SheetInBatch(pArguments); } void CScript_LayoutPseudoModel::Sheet(CFXJSE_Arguments* pArguments) { - PageInternals(pArguments, true); + JSLayoutPseudoModel()->Sheet(pArguments); } void CScript_LayoutPseudoModel::RelayoutPageArea(CFXJSE_Arguments* pArguments) { + JSLayoutPseudoModel()->RelayoutPageArea(pArguments); } void CScript_LayoutPseudoModel::SheetCount(CFXJSE_Arguments* pArguments) { - NumberedPageCount(pArguments, false); + JSLayoutPseudoModel()->SheetCount(pArguments); } void CScript_LayoutPseudoModel::AbsPage(CFXJSE_Arguments* pArguments) { - PageInternals(pArguments, true); -} - -void CScript_LayoutPseudoModel::PageInternals(CFXJSE_Arguments* pArguments, - bool bAbsPage) { - int32_t iLength = pArguments->GetLength(); - if (iLength != 1) { - JSObject()->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 = m_pDocument->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); + JSLayoutPseudoModel()->AbsPage(pArguments); } diff --git a/xfa/fxfa/parser/cscript_layoutpseudomodel.h b/xfa/fxfa/parser/cscript_layoutpseudomodel.h index c38871ab95..8faa9e56ed 100644 --- a/xfa/fxfa/parser/cscript_layoutpseudomodel.h +++ b/xfa/fxfa/parser/cscript_layoutpseudomodel.h @@ -7,17 +7,9 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_LAYOUTPSEUDOMODEL_H_ #define XFA_FXFA_PARSER_CSCRIPT_LAYOUTPSEUDOMODEL_H_ -#include <vector> - +#include "fxjs/cjx_layoutpseudomodel.h" #include "xfa/fxfa/parser/cxfa_object.h" -enum XFA_LAYOUTMODEL_HWXY { - XFA_LAYOUTMODEL_H, - XFA_LAYOUTMODEL_W, - XFA_LAYOUTMODEL_X, - XFA_LAYOUTMODEL_Y -}; - class CFXJSE_Arguments; class CXFA_LayoutProcessor; @@ -26,14 +18,16 @@ class CScript_LayoutPseudoModel : public CXFA_Object { explicit CScript_LayoutPseudoModel(CXFA_Document* pDocument); ~CScript_LayoutPseudoModel() override; + CJX_LayoutPseudoModel* JSLayoutPseudoModel() { + return static_cast<CJX_LayoutPseudoModel*>(JSObject()); + } + void Ready(CFXJSE_Value* pValue, bool bSetting, XFA_ATTRIBUTE eAttribute); - void HWXY(CFXJSE_Arguments* pArguments, XFA_LAYOUTMODEL_HWXY layoutModel); void H(CFXJSE_Arguments* pArguments); void W(CFXJSE_Arguments* pArguments); void X(CFXJSE_Arguments* pArguments); void Y(CFXJSE_Arguments* pArguments); - void NumberedPageCount(CFXJSE_Arguments* pArguments, bool bNumbered); void PageCount(CFXJSE_Arguments* pArguments); void PageSpan(CFXJSE_Arguments* pArguments); void Page(CFXJSE_Arguments* pArguments); @@ -49,14 +43,6 @@ class CScript_LayoutPseudoModel : public CXFA_Object { void RelayoutPageArea(CFXJSE_Arguments* pArguments); void SheetCount(CFXJSE_Arguments* pArguments); void AbsPage(CFXJSE_Arguments* pArguments); - - private: - std::vector<CXFA_Node*> GetObjArray(CXFA_LayoutProcessor* pDocLayout, - int32_t iPageNo, - const WideString& wsType, - bool bOnPageArea); - - void PageInternals(CFXJSE_Arguments* pArguments, bool bAbsPage); }; #endif // XFA_FXFA_PARSER_CSCRIPT_LAYOUTPSEUDOMODEL_H_ diff --git a/xfa/fxfa/parser/cscript_logpseudomodel.cpp b/xfa/fxfa/parser/cscript_logpseudomodel.cpp index 2c99972042..07c84de8e1 100644 --- a/xfa/fxfa/parser/cscript_logpseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_logpseudomodel.cpp @@ -7,27 +7,33 @@ #include "xfa/fxfa/parser/cscript_logpseudomodel.h" #include "fxjs/cfxjse_arguments.h" -#include "fxjs/cjx_object.h" #include "third_party/base/ptr_util.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_utils.h" CScript_LogPseudoModel::CScript_LogPseudoModel(CXFA_Document* pDocument) : CXFA_Object(pDocument, XFA_ObjectType::Object, XFA_Element::LogPseudoModel, WideStringView(L"logPseudoModel"), - pdfium::MakeUnique<CJX_Object>(this)) {} + pdfium::MakeUnique<CJX_LogPseudoModel>(this)) {} CScript_LogPseudoModel::~CScript_LogPseudoModel() {} -void CScript_LogPseudoModel::Message(CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::Message(CFXJSE_Arguments* pArguments) { + JSLogPseudoModel()->Message(pArguments); +} -void CScript_LogPseudoModel::TraceEnabled(CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::TraceEnabled(CFXJSE_Arguments* pArguments) { + JSLogPseudoModel()->TraceEnabled(pArguments); +} -void CScript_LogPseudoModel::TraceActivate(CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::TraceActivate(CFXJSE_Arguments* pArguments) { + JSLogPseudoModel()->TraceActivate(pArguments); +} -void CScript_LogPseudoModel::TraceDeactivate(CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::TraceDeactivate(CFXJSE_Arguments* pArguments) { + JSLogPseudoModel()->TraceDeactivate(pArguments); +} -void CScript_LogPseudoModel::Trace(CFXJSE_Arguments* pArguments) {} +void CScript_LogPseudoModel::Trace(CFXJSE_Arguments* pArguments) { + JSLogPseudoModel()->Trace(pArguments); +} diff --git a/xfa/fxfa/parser/cscript_logpseudomodel.h b/xfa/fxfa/parser/cscript_logpseudomodel.h index 2e465e851b..2501316a0e 100644 --- a/xfa/fxfa/parser/cscript_logpseudomodel.h +++ b/xfa/fxfa/parser/cscript_logpseudomodel.h @@ -7,6 +7,7 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_LOGPSEUDOMODEL_H_ #define XFA_FXFA_PARSER_CSCRIPT_LOGPSEUDOMODEL_H_ +#include "fxjs/cjx_logpseudomodel.h" #include "xfa/fxfa/parser/cxfa_object.h" class CFXJSE_Arguments; @@ -16,6 +17,10 @@ class CScript_LogPseudoModel : public CXFA_Object { explicit CScript_LogPseudoModel(CXFA_Document* pDocument); ~CScript_LogPseudoModel() override; + CJX_LogPseudoModel* JSLogPseudoModel() { + return static_cast<CJX_LogPseudoModel*>(JSObject()); + } + void Message(CFXJSE_Arguments* pArguments); void TraceEnabled(CFXJSE_Arguments* pArguments); void TraceActivate(CFXJSE_Arguments* pArguments); diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp index c08c166ec4..ef95e6b298 100644 --- a/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp +++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.cpp @@ -7,13 +7,7 @@ #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h" #include "fxjs/cfxjse_arguments.h" -#include "fxjs/cfxjse_engine.h" -#include "fxjs/cjx_object.h" #include "third_party/base/ptr_util.h" -#include "xfa/fxfa/cxfa_ffnotify.h" -#include "xfa/fxfa/parser/cxfa_document.h" -#include "xfa/fxfa/parser/cxfa_localemgr.h" -#include "xfa/fxfa/parser/xfa_utils.h" CScript_SignaturePseudoModel::CScript_SignaturePseudoModel( CXFA_Document* pDocument) @@ -21,50 +15,22 @@ CScript_SignaturePseudoModel::CScript_SignaturePseudoModel( XFA_ObjectType::Object, XFA_Element::SignaturePseudoModel, WideStringView(L"signaturePseudoModel"), - pdfium::MakeUnique<CJX_Object>(this)) {} + pdfium::MakeUnique<CJX_SignaturePseudoModel>(this)) {} CScript_SignaturePseudoModel::~CScript_SignaturePseudoModel() {} void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 4) { - JSObject()->ThrowParamCountMismatchException(L"verify"); - return; - } - - CFXJSE_Value* pValue = pArguments->GetReturnValue(); - if (pValue) - pValue->SetInteger(0); + JSSignaturePseudoModel()->Verify(pArguments); } void CScript_SignaturePseudoModel::Sign(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 3 || iLength > 7) { - JSObject()->ThrowParamCountMismatchException(L"sign"); - return; - } - - CFXJSE_Value* pValue = pArguments->GetReturnValue(); - if (pValue) - pValue->SetBoolean(false); + JSSignaturePseudoModel()->Sign(pArguments); } void CScript_SignaturePseudoModel::Enumerate(CFXJSE_Arguments* pArguments) { - if (pArguments->GetLength() != 0) { - JSObject()->ThrowParamCountMismatchException(L"enumerate"); - return; - } - return; + JSSignaturePseudoModel()->Enumerate(pArguments); } void CScript_SignaturePseudoModel::Clear(CFXJSE_Arguments* pArguments) { - int32_t iLength = pArguments->GetLength(); - if (iLength < 1 || iLength > 2) { - JSObject()->ThrowParamCountMismatchException(L"clear"); - return; - } - - CFXJSE_Value* pValue = pArguments->GetReturnValue(); - if (pValue) - pValue->SetBoolean(false); + JSSignaturePseudoModel()->Clear(pArguments); } diff --git a/xfa/fxfa/parser/cscript_signaturepseudomodel.h b/xfa/fxfa/parser/cscript_signaturepseudomodel.h index ee52744320..37d686c9d5 100644 --- a/xfa/fxfa/parser/cscript_signaturepseudomodel.h +++ b/xfa/fxfa/parser/cscript_signaturepseudomodel.h @@ -7,6 +7,7 @@ #ifndef XFA_FXFA_PARSER_CSCRIPT_SIGNATUREPSEUDOMODEL_H_ #define XFA_FXFA_PARSER_CSCRIPT_SIGNATUREPSEUDOMODEL_H_ +#include "fxjs/cjx_signaturepseudomodel.h" #include "xfa/fxfa/parser/cxfa_object.h" class CFXJSE_Arguments; @@ -16,6 +17,10 @@ class CScript_SignaturePseudoModel : public CXFA_Object { explicit CScript_SignaturePseudoModel(CXFA_Document* pDocument); ~CScript_SignaturePseudoModel() override; + CJX_SignaturePseudoModel* JSSignaturePseudoModel() { + return static_cast<CJX_SignaturePseudoModel*>(JSObject()); + } + void Verify(CFXJSE_Arguments* pArguments); void Sign(CFXJSE_Arguments* pArguments); void Enumerate(CFXJSE_Arguments* pArguments); |