summaryrefslogtreecommitdiff
path: root/fxjs/xfa/cjx_hostpseudomodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs/xfa/cjx_hostpseudomodel.cpp')
-rw-r--r--fxjs/xfa/cjx_hostpseudomodel.cpp118
1 files changed, 60 insertions, 58 deletions
diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp
index 37bc99ad47..8cf82b30d4 100644
--- a/fxjs/xfa/cjx_hostpseudomodel.cpp
+++ b/fxjs/xfa/cjx_hostpseudomodel.cpp
@@ -243,33 +243,33 @@ CJS_Return CJX_HostPseudoModel::gotoURL(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
WideString URL = runtime->ToWideString(params[0]);
hDoc->GetDocEnvironment()->GotoURL(hDoc, URL);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::openList(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Node* pNode = nullptr;
if (params[0]->IsObject()) {
@@ -278,11 +278,11 @@ CJS_Return CJX_HostPseudoModel::openList(
} else if (params[0]->IsString()) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Object* pObject = pScriptContext->GetThisObject();
if (!pObject)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
@@ -291,35 +291,35 @@ CJS_Return CJX_HostPseudoModel::openList(
pObject, runtime->ToWideString(params[0]).AsStringView(),
&resolveNodeRS, dwFlag, nullptr);
if (!iRet || !resolveNodeRS.objects.front()->IsNode())
- return CJS_Return();
+ return CJS_Return::Success();
pNode = resolveNodeRS.objects.front()->AsNode();
}
CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor();
if (!pDocLayout)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFWidget* hWidget =
XFA_GetWidgetFromLayoutItem(pDocLayout->GetLayoutItem(pNode));
if (!hWidget)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
hDoc->GetDocEnvironment()->SetFocusWidget(hDoc, hWidget);
pNotify->OpenDropDownList(hWidget);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::response(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty() || params.size() > 4)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
WideString question;
if (params.size() >= 1)
@@ -339,24 +339,25 @@ CJS_Return CJX_HostPseudoModel::response(
WideString answer =
pNotify->GetAppProvider()->Response(question, title, defaultAnswer, mark);
- return CJS_Return(runtime->NewString(answer.UTF8Encode().AsStringView()));
+ return CJS_Return::Success(
+ runtime->NewString(answer.UTF8Encode().AsStringView()));
}
CJS_Return CJX_HostPseudoModel::documentInBatch(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(runtime->NewNumber(0));
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_HostPseudoModel::resetData(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() > 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
WideString expression;
if (params.size() >= 1)
@@ -364,7 +365,7 @@ CJS_Return CJX_HostPseudoModel::resetData(
if (expression.IsEmpty()) {
pNotify->ResetData(nullptr);
- return CJS_Return();
+ return CJS_Return::Success();
}
int32_t iStart = 0;
@@ -375,11 +376,11 @@ CJS_Return CJX_HostPseudoModel::resetData(
iStart = FilterName(expression.AsStringView(), iStart, wsName);
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Object* pObject = pScriptContext->GetThisObject();
if (!pObject)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
@@ -395,42 +396,42 @@ CJS_Return CJX_HostPseudoModel::resetData(
if (!pNode)
pNotify->ResetData(nullptr);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::beep(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() > 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwType = 4;
if (params.size() >= 1)
dwType = runtime->ToInt32(params[0]);
pNotify->GetAppProvider()->Beep(dwType);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::setFocus(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Node* pNode = nullptr;
if (params.size() >= 1) {
@@ -440,11 +441,11 @@ CJS_Return CJX_HostPseudoModel::setFocus(
} else if (params[0]->IsString()) {
CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext();
if (!pScriptContext)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Object* pObject = pScriptContext->GetThisObject();
if (!pObject)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent |
XFA_RESOLVENODE_Siblings;
@@ -453,13 +454,13 @@ CJS_Return CJX_HostPseudoModel::setFocus(
pObject, runtime->ToWideString(params[0]).AsStringView(),
&resolveNodeRS, dwFlag, nullptr);
if (!iRet || !resolveNodeRS.objects.front()->IsNode())
- return CJS_Return();
+ return CJS_Return::Success();
pNode = resolveNodeRS.objects.front()->AsNode();
}
}
pNotify->SetFocusWidgetNode(pNode);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::getFocus(
@@ -467,32 +468,33 @@ CJS_Return CJX_HostPseudoModel::getFocus(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_Node* pNode = pNotify->GetFocusWidgetNode();
if (!pNode)
- return CJS_Return();
+ return CJS_Return::Success();
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode);
if (!value)
- return CJS_Return(runtime->NewNull());
+ return CJS_Return::Success(runtime->NewNull());
- return CJS_Return(value->DirectGetValue().Get(runtime->GetIsolate()));
+ return CJS_Return::Success(
+ value->DirectGetValue().Get(runtime->GetIsolate()));
}
CJS_Return CJX_HostPseudoModel::messageBox(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.empty() || params.size() > 4)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
WideString message;
if (params.size() >= 1)
@@ -518,27 +520,27 @@ CJS_Return CJX_HostPseudoModel::messageBox(
int32_t iValue = pNotify->GetAppProvider()->MsgBox(message, title,
messageType, buttonType);
- return CJS_Return(runtime->NewNumber(iValue));
+ return CJS_Return::Success(runtime->NewNumber(iValue));
}
CJS_Return CJX_HostPseudoModel::documentCountInBatch(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(runtime->NewNumber(0));
+ return CJS_Return::Success(runtime->NewNumber(0));
}
CJS_Return CJX_HostPseudoModel::print(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!GetDocument()->GetScriptContext()->IsRunAtClient())
- return CJS_Return();
+ return CJS_Return::Success();
if (params.size() != 8)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
uint32_t dwOptions = 0;
if (runtime->ToBoolean(params[0]))
@@ -559,27 +561,27 @@ CJS_Return CJX_HostPseudoModel::print(
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
hDoc->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::importData(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty() || params.size() > 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::exportData(
CFX_V8* runtime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty() || params.size() > 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return::Failure(JSMessage::kParamError);
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
WideString filePath;
if (params.size() >= 1)
@@ -591,7 +593,7 @@ CJS_Return CJX_HostPseudoModel::exportData(
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
hDoc->GetDocEnvironment()->ExportData(hDoc, filePath, XDP);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::pageUp(
@@ -599,17 +601,17 @@ CJS_Return CJX_HostPseudoModel::pageUp(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
int32_t nCurPage = hDoc->GetDocEnvironment()->GetCurrentPage(hDoc);
int32_t nNewPage = 0;
if (nCurPage <= 1)
- return CJS_Return();
+ return CJS_Return::Success();
nNewPage = nCurPage - 1;
hDoc->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
- return CJS_Return();
+ return CJS_Return::Success();
}
CJS_Return CJX_HostPseudoModel::pageDown(
@@ -617,13 +619,13 @@ CJS_Return CJX_HostPseudoModel::pageDown(
const std::vector<v8::Local<v8::Value>>& params) {
CXFA_FFNotify* pNotify = GetDocument()->GetNotify();
if (!pNotify)
- return CJS_Return();
+ return CJS_Return::Success();
CXFA_FFDoc* hDoc = pNotify->GetHDOC();
int32_t nCurPage = hDoc->GetDocEnvironment()->GetCurrentPage(hDoc);
int32_t nPageCount = hDoc->GetDocEnvironment()->CountPages(hDoc);
if (!nPageCount || nCurPage == nPageCount)
- return CJS_Return();
+ return CJS_Return::Success();
int32_t nNewPage = 0;
if (nCurPage >= nPageCount)
@@ -632,5 +634,5 @@ CJS_Return CJX_HostPseudoModel::pageDown(
nNewPage = nCurPage + 1;
hDoc->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage);
- return CJS_Return();
+ return CJS_Return::Success();
}