diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-06-08 18:23:05 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-06-08 18:23:05 +0000 |
commit | 1699982f45d01cb18585eba80cce5326a63d3b67 (patch) | |
tree | 537d81d989632bab75fda37f5b587e1309e60d5d /fxjs | |
parent | f29479d47156d180c0b71f6c98aa4de37c2a7ee2 (diff) | |
download | pdfium-1699982f45d01cb18585eba80cce5326a63d3b67.tar.xz |
Ensure CJS_Return() with error always includes a message.
Change the signature of the constructors to make it impossible to
do this otherwise.
Change-Id: I14e88d98a1128f2d599459ce9337cd6d079469fe
Reviewed-on: https://pdfium-review.googlesource.com/34531
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
38 files changed, 819 insertions, 749 deletions
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index 21aed7002b..78b152b9dd 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -438,7 +438,7 @@ CJS_Return CFXJSE_Engine::NormalMethodCall( const WideString& functionName) { CXFA_Object* pObject = ToObject(info); if (!pObject) - return CJS_Return(false); + return CJS_Return(L"no Holder() present."); CFXJSE_Engine* lpScriptContext = pObject->GetDocument()->GetScriptContext(); pObject = lpScriptContext->GetVariablesThis(pObject); diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp index b226621dd6..e47d189576 100644 --- a/fxjs/cjs_annot.cpp +++ b/fxjs/cjs_annot.cpp @@ -47,7 +47,7 @@ CJS_Annot::~CJS_Annot() = default; CJS_Return CJS_Annot::get_hidden(CJS_Runtime* pRuntime) { if (!m_pAnnot) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); CPDF_Annot* pPDFAnnot = ToBAAnnot(m_pAnnot.Get())->GetPDFAnnot(); return CJS_Return(pRuntime->NewBoolean( @@ -59,7 +59,7 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime, // May invalidate m_pAnnot. bool bHidden = pRuntime->ToBoolean(vp); if (!m_pAnnot) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); uint32_t flags = ToBAAnnot(m_pAnnot.Get())->GetFlags(); if (bHidden) { @@ -75,12 +75,12 @@ CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime, } ToBAAnnot(m_pAnnot.Get())->SetFlags(flags); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Annot::get_name(CJS_Runtime* pRuntime) { if (!m_pAnnot) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return( pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str())); } @@ -89,15 +89,15 @@ CJS_Return CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { // May invalidate m_pAnnot. WideString annotName = pRuntime->ToWideString(vp); if (!m_pAnnot) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); ToBAAnnot(m_pAnnot.Get())->SetAnnotName(annotName); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) { if (!m_pAnnot) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewString( WideString::FromLocal(CPDF_Annot::AnnotSubtypeToString( ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype()) @@ -106,5 +106,5 @@ CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) { } CJS_Return CJS_Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp index 1997e9afe9..e953f6bf14 100644 --- a/fxjs/cjs_app.cpp +++ b/fxjs/cjs_app.cpp @@ -115,7 +115,7 @@ CJS_Return CJS_App::get_active_docs(CJS_Runtime* pRuntime) { CJS_Return CJS_App::set_active_docs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::get_calculate(CJS_Runtime* pRuntime) { @@ -126,7 +126,7 @@ CJS_Return CJS_App::set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { m_bCalculate = pRuntime->ToBoolean(vp); pRuntime->GetFormFillEnv()->GetInterForm()->EnableCalculate(m_bCalculate); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::get_forms_version(CJS_Runtime* pRuntime) { @@ -135,7 +135,7 @@ CJS_Return CJS_App::get_forms_version(CJS_Runtime* pRuntime) { CJS_Return CJS_App::set_forms_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::get_viewer_type(CJS_Runtime* pRuntime) { @@ -144,7 +144,7 @@ CJS_Return CJS_App::get_viewer_type(CJS_Runtime* pRuntime) { CJS_Return CJS_App::set_viewer_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::get_viewer_variation(CJS_Runtime* pRuntime) { @@ -153,7 +153,7 @@ CJS_Return CJS_App::get_viewer_variation(CJS_Runtime* pRuntime) { CJS_Return CJS_App::set_viewer_variation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::get_viewer_version(CJS_Runtime* pRuntime) { @@ -167,14 +167,14 @@ CJS_Return CJS_App::get_viewer_version(CJS_Runtime* pRuntime) { CJS_Return CJS_App::set_viewer_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::get_platform(CJS_Runtime* pRuntime) { #ifdef PDF_ENABLE_XFA CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); if (!pFormFillEnv) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); WideString platfrom = pFormFillEnv->GetPlatform(); if (!platfrom.IsEmpty()) @@ -185,14 +185,14 @@ CJS_Return CJS_App::get_platform(CJS_Runtime* pRuntime) { CJS_Return CJS_App::set_platform(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::get_language(CJS_Runtime* pRuntime) { #ifdef PDF_ENABLE_XFA CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); if (!pFormFillEnv) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); WideString language = pFormFillEnv->GetLanguage(); if (!language.IsEmpty()) @@ -203,7 +203,7 @@ CJS_Return CJS_App::get_language(CJS_Runtime* pRuntime) { CJS_Return CJS_App::set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } // creates a new fdf object that contains no data @@ -212,7 +212,7 @@ CJS_Return CJS_App::set_language(CJS_Runtime* pRuntime, // CFDF_Document * CPDFSDK_FormFillEnvironment::NewFDF(); CJS_Return CJS_App::newFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } // opens a specified pdf document and returns its document object @@ -224,7 +224,7 @@ CJS_Return CJS_App::newFDF(CJS_Runtime* pRuntime, CJS_Return CJS_App::openFDF(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::alert(CJS_Runtime* pRuntime, @@ -233,7 +233,7 @@ CJS_Return CJS_App::alert(CJS_Runtime* pRuntime, pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle"); if (!IsTypeKnown(newParams[0])) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); if (!pFormFillEnv) @@ -280,41 +280,41 @@ CJS_Return CJS_App::alert(CJS_Runtime* pRuntime, CJS_Return CJS_App::beep(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); pRuntime->GetFormFillEnv()->JS_appBeep(pRuntime->ToInt32(params[0])); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::findComponent( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::popUpMenuEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::get_fs(CJS_Runtime* pRuntime) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::setInterval( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() == 0 || params.size() > 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); WideString script = pRuntime->ToWideString(params[0]); if (script.IsEmpty()) - return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError)); + return CJS_Return(JSMessage::kInvalidInputError); uint32_t dwInterval = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000; auto timerRef = pdfium::MakeUnique<GlobalTimer>( @@ -325,7 +325,7 @@ CJS_Return CJS_App::setInterval( v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(CJS_TimerObj::GetObjDefnID()); if (pRetObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJS_TimerObj = static_cast<CJS_TimerObj*>(CFXJS_Engine::GetObjectPrivate(pRetObj)); @@ -338,11 +338,11 @@ CJS_Return CJS_App::setTimeOut( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() == 0 || params.size() > 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); WideString script = pRuntime->ToWideString(params[0]); if (script.IsEmpty()) - return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError)); + return CJS_Return(JSMessage::kInvalidInputError); uint32_t dwTimeOut = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000; auto timerRef = pdfium::MakeUnique<GlobalTimer>( @@ -354,7 +354,7 @@ CJS_Return CJS_App::setTimeOut( v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(CJS_TimerObj::GetObjDefnID()); if (pRetObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJS_TimerObj = static_cast<CJS_TimerObj*>(CFXJS_Engine::GetObjectPrivate(pRetObj)); @@ -367,20 +367,20 @@ CJS_Return CJS_App::clearTimeOut( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_App::ClearTimerCommon(pRuntime, params[0]); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::clearInterval( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_App::ClearTimerCommon(pRuntime, params[0]); - return CJS_Return(true); + return CJS_Return(); } void CJS_App::ClearTimerCommon(CJS_Runtime* pRuntime, @@ -402,7 +402,7 @@ void CJS_App::ClearTimerCommon(CJS_Runtime* pRuntime, CJS_Return CJS_App::execMenuItem( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } void CJS_App::TimerProc(GlobalTimer* pTimer) { @@ -427,13 +427,13 @@ void CJS_App::RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript) { CJS_Return CJS_App::goBack(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::goForward(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime, @@ -443,7 +443,7 @@ CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime, L"cSubject", L"cMsg"); if (!IsTypeKnown(newParams[0])) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); bool bUI = pRuntime->ToBoolean(newParams[0]); WideString cTo; @@ -452,7 +452,7 @@ CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime, } else { // cTo parameter required when UI not invoked. if (!bUI) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); } WideString cCc; @@ -475,13 +475,13 @@ CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime, pRuntime->GetFormFillEnv()->JS_docmailForm(nullptr, 0, bUI, cTo, cSubject, cCc, cBcc, cMsg); pRuntime->EndBlock(); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::launchURL(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::get_runtime_highlight(CJS_Runtime* pRuntime) { @@ -491,28 +491,28 @@ CJS_Return CJS_App::get_runtime_highlight(CJS_Runtime* pRuntime) { CJS_Return CJS_App::set_runtime_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { m_bRuntimeHighLight = pRuntime->ToBoolean(vp); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_App::get_fullscreen(CJS_Runtime* pRuntime) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::set_fullscreen(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::popUpMenu(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::browseForDoc( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } WideString CJS_App::SysPathToPDFPath(const WideString& sOldPath) { @@ -526,12 +526,12 @@ WideString CJS_App::SysPathToPDFPath(const WideString& sOldPath) { CJS_Return CJS_App::newDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::openDoc(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::response(CJS_Runtime* pRuntime, @@ -541,7 +541,7 @@ CJS_Return CJS_App::response(CJS_Runtime* pRuntime, L"cDefault", L"bPassword", L"cLabel"); if (!IsTypeKnown(newParams[0])) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); WideString swQuestion = pRuntime->ToWideString(newParams[0]); WideString swTitle = L"PDF"; @@ -567,7 +567,7 @@ CJS_Return CJS_App::response(CJS_Runtime* pRuntime, MAX_INPUT_BYTES); if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES) - return CJS_Return(JSGetStringFromID(JSMessage::kParamTooLongError)); + return CJS_Return(JSMessage::kParamTooLongError); return CJS_Return(pRuntime->NewString( WideString::FromUTF16LE(reinterpret_cast<uint16_t*>(pBuff.data()), @@ -576,15 +576,15 @@ CJS_Return CJS_App::response(CJS_Runtime* pRuntime, } CJS_Return CJS_App::get_media(CJS_Runtime* pRuntime) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_App::execDialog( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp index e46ddce69d..282c58f927 100644 --- a/fxjs/cjs_color.cpp +++ b/fxjs/cjs_color.cpp @@ -253,19 +253,17 @@ CJS_Return CJS_Color::SetPropertyHelper(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp, CFX_Color* var) { if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(false); + return CJS_Return(JSMessage::kParamError); *var = ConvertArrayToPWLColor(pRuntime, pRuntime->ToArray(vp)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { int iSize = params.size(); - if (iSize < 2) - return CJS_Return(false); - if (params[0].IsEmpty() || !params[0]->IsArray()) - return CJS_Return(false); + if (iSize < 2 || params[0].IsEmpty() || !params[0]->IsArray()) + return CJS_Return(JSMessage::kParamError); WideString sDestSpace = pRuntime->ToWideString(params[1]); int nColorType = CFX_Color::kTransparent; @@ -290,11 +288,9 @@ CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime, CJS_Return CJS_Color::equal(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - if (params.size() < 2) - return CJS_Return(false); - if (params[0].IsEmpty() || !params[0]->IsArray() || params[1].IsEmpty() || - !params[1]->IsArray()) { - return CJS_Return(false); + if (params.size() < 2 || params[0].IsEmpty() || !params[0]->IsArray() || + params[1].IsEmpty() || !params[1]->IsArray()) { + return CJS_Return(JSMessage::kParamError); } CFX_Color color1 = diff --git a/fxjs/cjs_console.cpp b/fxjs/cjs_console.cpp index 867913ca6f..02babea19e 100644 --- a/fxjs/cjs_console.cpp +++ b/fxjs/cjs_console.cpp @@ -35,21 +35,21 @@ CJS_Console::~CJS_Console() = default; CJS_Return CJS_Console::clear(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Console::hide(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Console::println( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(params.size() > 0); + return CJS_Return(); } CJS_Return CJS_Console::show(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index d6dc4d6020..a259767560 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -135,7 +135,7 @@ void CJS_Document::InitInstance() { // The total number of fields in document. CJS_Return CJS_Document::get_num_fields(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); @@ -145,23 +145,23 @@ CJS_Return CJS_Document::get_num_fields(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_num_fields(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Document::get_dirty(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark())); } CJS_Return CJS_Document::set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); pRuntime->ToBoolean(vp) ? m_pFormFillEnv->SetChangeMark() : m_pFormFillEnv->ClearChangeMark(); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_ADBE(CJS_Runtime* pRuntime) { @@ -170,12 +170,12 @@ CJS_Return CJS_Document::get_ADBE(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_page_num(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView(); if (!pPageView) @@ -186,7 +186,7 @@ CJS_Return CJS_Document::get_page_num(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); int iPageCount = m_pFormFillEnv->GetPageCount(); int iPageNum = pRuntime->ToInt32(vp); @@ -197,51 +197,51 @@ CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime, else if (iPageNum < 0) m_pFormFillEnv->JS_docgotoPage(0); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::addAnnot( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::addField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::exportAsText( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::exportAsFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::exportAsXFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::getField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty()) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); WideString wideName = pRuntime->ToWideString(params[0]); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); @@ -252,12 +252,12 @@ CJS_Return CJS_Document::getField( v8::Local<v8::Object> pFieldObj = pRuntime->NewFXJSBoundObject(CJS_Field::GetObjDefnID()); if (pFieldObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJSField = static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pFieldObj)); if (!pJSField) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); pJSField->AttachField(this, wideName); return CJS_Return(pJSField->ToV8Object()); @@ -268,19 +268,19 @@ CJS_Return CJS_Document::getNthFieldName( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); int nIndex = pRuntime->ToInt32(params[0]); if (nIndex < 0) - return CJS_Return(JSGetStringFromID(JSMessage::kValueError)); + return CJS_Return(JSMessage::kValueError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); CPDF_FormField* pField = pPDFForm->GetField(nIndex, WideString()); if (!pField) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewString(pField->GetFullName().c_str())); } @@ -288,21 +288,21 @@ CJS_Return CJS_Document::importAnFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::importAnXFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::importTextData( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } // exports the form data and mails the resulting fdf file as an attachment to @@ -312,14 +312,14 @@ CJS_Return CJS_Document::mailForm( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError)); + return CJS_Return(JSMessage::kPermissionError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); ByteString sTextBuf = pInterForm->ExportFormToFDFTextBuf(); if (sTextBuf.GetLength() == 0) - return CJS_Return(false); + return CJS_Return(L"Bad FDF format."); size_t nLength = params.size(); bool bUI = nLength > 0 ? pRuntime->ToBoolean(params[0]) : true; @@ -338,14 +338,14 @@ CJS_Return CJS_Document::mailForm( pFormFillEnv->JS_docmailForm(pMutableBuf.get(), nBufSize, bUI, cTo, cSubject, cCc, cBcc, cMsg); pRuntime->EndBlock(); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::print( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); bool bUI = true; int nStart = 0; @@ -397,11 +397,11 @@ CJS_Return CJS_Document::print( } if (!m_pFormFillEnv) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); m_pFormFillEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations); - return CJS_Return(true); + return CJS_Return(); } // removes the specified field from the document. @@ -412,20 +412,20 @@ CJS_Return CJS_Document::removeField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM))) - return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError)); + return CJS_Return(JSMessage::kPermissionError); WideString sFieldName = pRuntime->ToWideString(params[0]); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); std::vector<CPDFSDK_Annot::ObservedPtr> widgets; pInterForm->GetWidgets(sFieldName, &widgets); if (widgets.empty()) - return CJS_Return(true); + return CJS_Return(); for (const auto& pAnnot : widgets) { CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get()); @@ -455,7 +455,7 @@ CJS_Return CJS_Document::removeField( } m_pFormFillEnv->SetChangeMark(); - return CJS_Return(true); + return CJS_Return(); } // reset filed values within a document. @@ -466,11 +466,11 @@ CJS_Return CJS_Document::resetForm( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) { - return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError)); + return CJS_Return(JSMessage::kPermissionError); } CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); @@ -478,7 +478,7 @@ CJS_Return CJS_Document::resetForm( if (params.empty()) { pPDFForm->ResetForm(true); m_pFormFillEnv->SetChangeMark(); - return CJS_Return(true); + return CJS_Return(); } v8::Local<v8::Array> array; @@ -502,20 +502,20 @@ CJS_Return CJS_Document::resetForm( m_pFormFillEnv->SetChangeMark(); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::saveAs( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::syncAnnotScan( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::submitForm( @@ -523,9 +523,9 @@ CJS_Return CJS_Document::submitForm( const std::vector<v8::Local<v8::Value>>& params) { size_t nSize = params.size(); if (nSize < 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); v8::Local<v8::Array> aFields; WideString strURL; @@ -559,7 +559,7 @@ CJS_Return CJS_Document::submitForm( pInterForm->SubmitForm(strURL, false); pRuntime->EndBlock(); } - return CJS_Return(true); + return CJS_Return(); } std::vector<CPDF_FormField*> fieldObjects; @@ -581,7 +581,7 @@ CJS_Return CJS_Document::submitForm( pInterForm->SubmitFields(strURL, fieldObjects, true, !bFDF); pRuntime->EndBlock(); } - return CJS_Return(true); + return CJS_Return(); } void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) { @@ -589,12 +589,12 @@ void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) { } CJS_Return CJS_Document::get_bookmark_root(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_bookmark_root(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::mailDoc( @@ -637,7 +637,7 @@ CJS_Return CJS_Document::mailDoc( CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); pFormFillEnv->JS_docmailForm(nullptr, 0, bUI, cTo, cSubject, cCc, cBcc, cMsg); pRuntime->EndBlock(); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_author(CJS_Runtime* pRuntime) { @@ -651,11 +651,11 @@ CJS_Return CJS_Document::set_author(CJS_Runtime* pRuntime, CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); const auto* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); WideString cwAuthor = pDictionary->GetUnicodeTextFor("Author"); WideString cwTitle = pDictionary->GetUnicodeTextFor("Title"); @@ -710,17 +710,17 @@ CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime, const ByteString& propName) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return( pRuntime->NewString(pDictionary->GetUnicodeTextFor(propName).c_str())); } @@ -729,20 +729,20 @@ CJS_Return CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp, const ByteString& propName) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) - return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError)); + return CJS_Return(JSMessage::kPermissionError); WideString csProperty = pRuntime->ToWideString(vp); pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty), false); m_pFormFillEnv->SetChangeMark(); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_creation_date(CJS_Runtime* pRuntime) { @@ -765,21 +765,21 @@ CJS_Return CJS_Document::set_creator(CJS_Runtime* pRuntime, CJS_Return CJS_Document::get_delay(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewBoolean(m_bDelay)); } CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) - return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError)); + return CJS_Return(JSMessage::kPermissionError); m_bDelay = pRuntime->ToBoolean(vp); if (m_bDelay) { m_DelayData.clear(); - return CJS_Return(true); + return CJS_Return(); } std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess; @@ -787,7 +787,7 @@ CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime, for (const auto& pData : DelayDataToProcess) CJS_Field::DoDelay(m_pFormFillEnv.Get(), pData.get()); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_keywords(CJS_Runtime* pRuntime) { @@ -828,26 +828,26 @@ CJS_Return CJS_Document::set_subject(CJS_Runtime* pRuntime, CJS_Return CJS_Document::get_title(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument()) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return getPropertyInternal(pRuntime, "Title"); } CJS_Return CJS_Document::set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument()) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return setPropertyInternal(pRuntime, vp, "Title"); } CJS_Return CJS_Document::get_num_pages(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount())); } CJS_Return CJS_Document::set_num_pages(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Document::get_external(CJS_Runtime* pRuntime) { @@ -857,7 +857,7 @@ CJS_Return CJS_Document::get_external(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_external(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_filesize(CJS_Runtime* pRuntime) { @@ -866,37 +866,37 @@ CJS_Return CJS_Document::get_filesize(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_filesize(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Document::get_mouse_x(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_mouse_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_mouse_y(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_mouse_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_URL(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return( pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str())); } CJS_Return CJS_Document::set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) { @@ -906,12 +906,12 @@ CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_base_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { m_cwBaseURL = pRuntime->ToWideString(vp); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_calculate(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); return CJS_Return(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled())); @@ -920,16 +920,16 @@ CJS_Return CJS_Document::get_calculate(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); pInterForm->EnableCalculate(pRuntime->ToBoolean(vp)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath(); size_t i = wsFilePath.GetLength(); @@ -945,70 +945,70 @@ CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_document_file_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Document::get_path(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewString( CJS_App::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str())); } CJS_Return CJS_Document::set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Document::get_page_window_rect(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_page_window_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_layout(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_layout(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::addLink( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::closeDoc( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::getPageBox( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::getAnnot( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); int nPageNo = pRuntime->ToInt32(params[0]); WideString swAnnotName = pRuntime->ToWideString(params[1]); CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(nPageNo); if (!pPageView) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_AnnotIteration annotIteration(pPageView, false); CPDFSDK_BAAnnot* pSDKBAAnnot = nullptr; @@ -1020,17 +1020,17 @@ CJS_Return CJS_Document::getAnnot( } } if (!pSDKBAAnnot) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(CJS_Annot::GetObjDefnID()); if (pObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJS_Annot = static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj)); if (!pJS_Annot) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); pJS_Annot->SetSDKAnnot(pSDKBAAnnot); return CJS_Return(pJS_Annot->ToV8Object()); @@ -1040,7 +1040,7 @@ CJS_Return CJS_Document::getAnnots( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); // TODO(tonikitoo): Add support supported parameters as per // the PDF spec. @@ -1050,17 +1050,17 @@ CJS_Return CJS_Document::getAnnots( for (int i = 0; i < nPageNo; ++i) { CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(i); if (!pPageView) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_AnnotIteration annotIteration(pPageView, false); for (const auto& pSDKAnnotCur : annotIteration) { if (!pSDKAnnotCur) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(CJS_Annot::GetObjDefnID()); if (pObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJS_Annot = static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -1083,19 +1083,19 @@ CJS_Return CJS_Document::getAnnot3D( CJS_Return CJS_Document::getAnnots3D( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::getOCGs( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::getLinks( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect, @@ -1108,23 +1108,23 @@ CJS_Return CJS_Document::addIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); if (!params[1]->IsObject()) - return CJS_Return(JSGetStringFromID(JSMessage::kTypeError)); + return CJS_Return(JSMessage::kTypeError); v8::Local<v8::Object> pJSIcon = pRuntime->ToObject(params[1]); if (CFXJS_Engine::GetObjDefnID(pJSIcon) != CJS_Icon::GetObjDefnID()) - return CJS_Return(JSGetStringFromID(JSMessage::kTypeError)); + return CJS_Return(JSMessage::kTypeError); v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]); CJS_Object* obj = CFXJS_Engine::GetObjectPrivate(pObj); if (!obj) - return CJS_Return(JSGetStringFromID(JSMessage::kTypeError)); + return CJS_Return(JSMessage::kTypeError); WideString swIconName = pRuntime->ToWideString(params[0]); m_IconNames.push_back(swIconName); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) { @@ -1137,7 +1137,7 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) { v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(CJS_Icon::GetObjDefnID()); if (pObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJS_Icon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -1152,28 +1152,28 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) { CJS_Return CJS_Document::set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Document::getIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); WideString swIconName = pRuntime->ToWideString(params[0]); auto it = std::find(m_IconNames.begin(), m_IconNames.end(), swIconName); if (it == m_IconNames.end()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(CJS_Icon::GetObjDefnID()); if (pObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJSIcon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); if (!pJSIcon) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); pJSIcon->SetIconName(*it); return CJS_Return(pJSIcon->ToV8Object()); @@ -1183,57 +1183,57 @@ CJS_Return CJS_Document::removeIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, no supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::createDataObject( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not implemented. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_media(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::calculateNow( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) { - return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError)); + return CJS_Return(JSMessage::kPermissionError); } m_pFormFillEnv->GetInterForm()->OnCalculate(); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_collab(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_collab(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::getPageNthWord( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError)); + return CJS_Return(JSMessage::kPermissionError); // TODO(tsepez): check maximum allowable params. @@ -1243,14 +1243,14 @@ CJS_Return CJS_Document::getPageNthWord( CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument(); if (!pDocument) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) - return CJS_Return(JSGetStringFromID(JSMessage::kValueError)); + return CJS_Return(JSMessage::kValueError); CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo); if (!pPageDict) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true); page->ParseContent(); @@ -1278,28 +1278,28 @@ CJS_Return CJS_Document::getPageNthWordQuads( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Document::getPageNumWords( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError)); + return CJS_Return(JSMessage::kPermissionError); int nPageNo = params.size() > 0 ? pRuntime->ToInt32(params[0]) : 0; CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument(); if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) - return CJS_Return(JSGetStringFromID(JSMessage::kValueError)); + return CJS_Return(JSMessage::kValueError); CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo); if (!pPageDict) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true); page->ParseContent(); @@ -1319,11 +1319,8 @@ CJS_Return CJS_Document::getPrintParams( v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject(CJS_PrintParamsObj::GetObjDefnID()); if (pRetObj.IsEmpty()) - return CJS_Return(false); - - // Not implemented yet. - - return CJS_Return(pRetObj); + return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return(JSMessage::kNotSupportedError); } #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) @@ -1332,14 +1329,12 @@ int CJS_Document::CountWords(CPDF_TextObject* pTextObj) { if (!pTextObj) return 0; - int nWords = 0; - CPDF_Font* pFont = pTextObj->GetFont(); if (!pFont) return 0; bool bIsLatin = false; - + int nWords = 0; for (size_t i = 0, sz = pTextObj->CountChars(); i < sz; ++i) { uint32_t charcode = CPDF_Font::kInvalidCharCode; float kerning; @@ -1399,75 +1394,76 @@ WideString CJS_Document::GetObjWordStr(CPDF_TextObject* pTextObj, } CJS_Return CJS_Document::get_zoom(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::get_zoom_type(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::set_zoom_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::deletePages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::extractPages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::insertPages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::replacePages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::getURL( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Document::gotoNamedDest( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); + if (!m_pFormFillEnv) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument(); if (!pDocument) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_NameTree nameTree(pDocument, "Dests"); CPDF_Array* destArray = nameTree.LookupNamedDest(pDocument, pRuntime->ToWideString(params[0])); if (!destArray) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_Dest dest(destArray); const CPDF_Array* arrayObject = ToArray(dest.GetObject()); @@ -1481,7 +1477,7 @@ CJS_Return CJS_Document::gotoNamedDest( dest.GetZoomMode(), scrollPositionArray.data(), scrollPositionArray.size()); pRuntime->EndBlock(); - return CJS_Return(true); + return CJS_Return(); } void CJS_Document::AddDelayData(std::unique_ptr<CJS_DelayData> pData) { diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp index de22ab8488..841d9001cb 100644 --- a/fxjs/cjs_event.cpp +++ b/fxjs/cjs_event.cpp @@ -68,7 +68,7 @@ CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime, WideString& wChange = pEvent->Change(); wChange = pRuntime->ToWideString(vp); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) { @@ -82,7 +82,7 @@ CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_commit_key(CJS_Runtime* pRuntime) { @@ -96,7 +96,7 @@ CJS_Return CJS_Event::get_commit_key(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_commit_key(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_field_full(CJS_Runtime* pRuntime) { @@ -106,14 +106,14 @@ CJS_Return CJS_Event::get_field_full(CJS_Runtime* pRuntime) { pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) - return CJS_Return(false); + return CJS_Return(L"unrecognized event"); return CJS_Return(pRuntime->NewBoolean(pEvent->FieldFull())); } CJS_Return CJS_Event::set_field_full(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_key_down(CJS_Runtime* pRuntime) { @@ -124,7 +124,7 @@ CJS_Return CJS_Event::get_key_down(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_modifier(CJS_Runtime* pRuntime) { @@ -135,7 +135,7 @@ CJS_Return CJS_Event::get_modifier(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_name(CJS_Runtime* pRuntime) { @@ -145,7 +145,7 @@ CJS_Return CJS_Event::get_name(CJS_Runtime* pRuntime) { } CJS_Return CJS_Event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_rc(CJS_Runtime* pRuntime) { @@ -158,34 +158,34 @@ CJS_Return CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); pEvent->Rc() = pRuntime->ToBoolean(vp); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::get_rich_change(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::set_rich_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::get_rich_change_ex(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::set_rich_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::get_rich_value(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::get_sel_end(CJS_Runtime* pRuntime) { @@ -193,7 +193,7 @@ CJS_Return CJS_Event::get_sel_end(CJS_Runtime* pRuntime) { pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) - return CJS_Return(true); + return CJS_Return(); return CJS_Return(pRuntime->NewNumber(pEvent->SelEnd())); } @@ -204,10 +204,10 @@ CJS_Return CJS_Event::set_sel_end(CJS_Runtime* pRuntime, pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) - return CJS_Return(true); + return CJS_Return(); pEvent->SetSelEnd(pRuntime->ToInt32(vp)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::get_sel_start(CJS_Runtime* pRuntime) { @@ -215,7 +215,7 @@ CJS_Return CJS_Event::get_sel_start(CJS_Runtime* pRuntime) { pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) - return CJS_Return(true); + return CJS_Return(); return CJS_Return(pRuntime->NewNumber(pEvent->SelStart())); } @@ -226,10 +226,10 @@ CJS_Return CJS_Event::set_sel_start(CJS_Runtime* pRuntime, pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) - return CJS_Return(true); + return CJS_Return(); pEvent->SetSelStart(pRuntime->ToInt32(vp)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::get_shift(CJS_Runtime* pRuntime) { @@ -240,7 +240,7 @@ CJS_Return CJS_Event::get_shift(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_source(CJS_Runtime* pRuntime) { @@ -251,7 +251,7 @@ CJS_Return CJS_Event::get_source(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) { @@ -264,7 +264,7 @@ CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) { @@ -277,7 +277,7 @@ CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_target_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_type(CJS_Runtime* pRuntime) { @@ -289,7 +289,7 @@ CJS_Return CJS_Event::get_type(CJS_Runtime* pRuntime) { } CJS_Return CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) { @@ -299,10 +299,10 @@ CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) { pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0) - return CJS_Return(false); + return CJS_Return(L"Bad event type."); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewString(pEvent->Value().c_str())); } @@ -315,13 +315,13 @@ CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime, pRuntime->GetCurrentEventContext()->GetEventHandler(); if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0) - return CJS_Return(false); + return CJS_Return(L"Bad event type."); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); pEvent->Value() = pRuntime->ToWideString(vp); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) { @@ -334,5 +334,5 @@ CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) { CJS_Return CJS_Event::set_will_commit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp index cdbe0dfc4d..b3a9f537d0 100644 --- a/fxjs/cjs_field.cpp +++ b/fxjs/cjs_field.cpp @@ -379,15 +379,15 @@ CJS_Return CJS_Field::get_alignment(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); switch (pFormControl->GetControlAlignment()) { case 0: @@ -403,7 +403,9 @@ CJS_Return CJS_Field::get_alignment(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_alignment(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) { @@ -411,16 +413,16 @@ CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (!pFormField) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_Widget* pWidget = GetWidget(m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); switch (pWidget->GetBorderStyle()) { case BorderStyle::SOLID: @@ -440,9 +442,8 @@ CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); ByteString byte_str = ByteString::FromUnicode(pRuntime->ToWideString(vp)); if (m_bDelay) { @@ -451,7 +452,7 @@ CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime, CJS_Field::SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, byte_str); } - return CJS_Return(true); + return CJS_Return(); } void CJS_Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv, @@ -511,29 +512,30 @@ CJS_Return CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); float fLeft; float fBottom; IconFit.GetIconPosition(fLeft, fBottom); - return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fLeft))); } CJS_Return CJS_Field::set_button_align_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { @@ -541,15 +543,15 @@ CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); @@ -563,7 +565,9 @@ CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_button_align_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) { @@ -571,15 +575,15 @@ CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return( pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds())); @@ -588,7 +592,9 @@ CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_button_fit_bounds(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) { @@ -596,15 +602,15 @@ CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewNumber(pFormControl->GetTextPosition())); } @@ -612,7 +618,9 @@ CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_button_position(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return(); } CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) { @@ -620,15 +628,15 @@ CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewBoolean( pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1)); @@ -637,7 +645,9 @@ CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_button_scale_how(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) { @@ -645,15 +655,15 @@ CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_IconFit IconFit = pFormControl->GetIconFit(); int ScaleM = IconFit.GetScaleMethod(); @@ -671,13 +681,15 @@ CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) { return CJS_Return( pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Smaller))); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::set_button_scale_when(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) { @@ -685,12 +697,12 @@ CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kComboBox && pFormField->GetFieldType() != FormFieldType::kTextField) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm(); @@ -702,7 +714,9 @@ CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_calc_order_index(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) { @@ -710,11 +724,11 @@ CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return( pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen()))); } @@ -722,7 +736,9 @@ CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_char_limit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) { @@ -730,11 +746,11 @@ CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return( pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB))); @@ -742,7 +758,9 @@ CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) { @@ -750,12 +768,12 @@ CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kComboBox && pFormField->GetFieldType() != FormFieldType::kListBox) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } return CJS_Return(pRuntime->NewBoolean( @@ -765,18 +783,20 @@ CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_commit_on_sel_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kComboBox && pFormField->GetFieldType() != FormFieldType::kListBox) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } int count = pFormField->CountSelectedItems(); @@ -798,7 +818,7 @@ CJS_Return CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); std::vector<uint32_t> array; if (vp->IsNumber()) { @@ -817,7 +837,7 @@ CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime, CJS_Field::SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, array); } - return CJS_Return(true); + return CJS_Return(); } void CJS_Field::SetCurrentValueIndices( @@ -849,12 +869,12 @@ void CJS_Field::SetCurrentValueIndices( } CJS_Return CJS_Field::get_default_style(CJS_Runtime* pRuntime) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::set_default_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) { @@ -862,12 +882,12 @@ CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() == FormFieldType::kPushButton || pFormField->GetFieldType() == FormFieldType::kSignature) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } return CJS_Return(pRuntime->NewString(pFormField->GetDefaultValue().c_str())); @@ -876,7 +896,9 @@ CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_default_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) { @@ -884,11 +906,11 @@ CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL))); @@ -897,7 +919,9 @@ CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_do_not_scroll(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) { @@ -905,12 +929,12 @@ CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField && pFormField->GetFieldType() != FormFieldType::kComboBox) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } return CJS_Return(pRuntime->NewBoolean( @@ -920,7 +944,9 @@ CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_do_not_spell_check(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } void CJS_Field::SetDelay(bool bDelay) { @@ -939,16 +965,16 @@ CJS_Return CJS_Field::get_delay(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); SetDelay(pRuntime->ToBoolean(vp)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::get_display(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; ASSERT(pFormField); @@ -957,7 +983,7 @@ CJS_Return CJS_Field::get_display(CJS_Runtime* pRuntime) { CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); uint32_t dwFlag = pWidget->GetFlags(); if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) @@ -974,7 +1000,7 @@ CJS_Return CJS_Field::get_display(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_display(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Int(FP_DISPLAY, pRuntime->ToInt32(vp)); @@ -982,7 +1008,7 @@ CJS_Return CJS_Field::set_display(CJS_Runtime* pRuntime, CJS_Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, pRuntime->ToInt32(vp)); } - return CJS_Return(true); + return CJS_Return(); } void CJS_Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv, @@ -1026,17 +1052,17 @@ CJS_Return CJS_Field::get_doc(CJS_Runtime* pRuntime) { } CJS_Return CJS_Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_editable(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kComboBox) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return( pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT))); @@ -1044,18 +1070,20 @@ CJS_Return CJS_Field::get_editable(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_editable(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kCheckBox && pFormField->GetFieldType() != FormFieldType::kRadioButton) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } v8::Local<v8::Array> ExportValuesArray = pRuntime->NewArray(); @@ -1068,12 +1096,12 @@ CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) { } } else { if (m_nFormControlIndex >= pFormField->CountControls()) - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); pRuntime->PutArrayElement( ExportValuesArray, 0, @@ -1086,25 +1114,31 @@ CJS_Return CJS_Field::set_export_values(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kCheckBox && pFormField->GetFieldType() != FormFieldType::kRadioButton) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } - return CJS_Return(m_bCanSet && !vp.IsEmpty() && vp->IsArray()); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + + if (vp.IsEmpty() || !vp->IsArray()) + return CJS_Return(JSMessage::kBadObjectError); + + return CJS_Return(); } CJS_Return CJS_Field::get_file_select(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT))); @@ -1114,24 +1148,28 @@ CJS_Return CJS_Field::set_file_select(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); - return CJS_Return(m_bCanSet); + return CJS_Return(JSMessage::kObjectTypeError); + + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + + return CJS_Return(); } CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; ASSERT(pFormField); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); int iColorType; pFormControl->GetBackgroundColor(iColorType); @@ -1154,7 +1192,7 @@ CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) { pFormControl->GetOriginalBackgroundColor(2), pFormControl->GetOriginalBackgroundColor(3)); } else { - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); } v8::Local<v8::Value> array = @@ -1168,18 +1206,18 @@ CJS_Return CJS_Field::set_fill_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(false); - return CJS_Return(true); + return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return(); } CJS_Return CJS_Field::get_hidden(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; ASSERT(pFormField); @@ -1188,7 +1226,7 @@ CJS_Return CJS_Field::get_hidden(CJS_Runtime* pRuntime) { CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); uint32_t dwFlags = pWidget->GetFlags(); return CJS_Return(pRuntime->NewBoolean(ANNOTFLAG_INVISIBLE & dwFlags || @@ -1198,7 +1236,7 @@ CJS_Return CJS_Field::get_hidden(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Bool(FP_HIDDEN, pRuntime->ToBoolean(vp)); @@ -1206,7 +1244,7 @@ CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime, CJS_Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, pRuntime->ToBoolean(vp)); } - return CJS_Return(true); + return CJS_Return(); } void CJS_Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv, @@ -1222,15 +1260,15 @@ CJS_Return CJS_Field::get_highlight(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); int eHM = pFormControl->GetHighlightingMode(); switch (eHM) { @@ -1245,34 +1283,36 @@ CJS_Return CJS_Field::get_highlight(CJS_Runtime* pRuntime) { case CPDF_FormControl::Toggle: return CJS_Return(pRuntime->NewString(L"toggle")); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::set_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_line_width(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; ASSERT(pFormField); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); if (!pFormField->CountControls()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0)); if (!pWidget) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewNumber(pWidget->GetBorderWidth())); } @@ -1280,7 +1320,7 @@ CJS_Return CJS_Field::get_line_width(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); if (m_bDelay) { AddDelay_Int(FP_LINEWIDTH, pRuntime->ToInt32(vp)); @@ -1288,7 +1328,7 @@ CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime, CJS_Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, pRuntime->ToInt32(vp)); } - return CJS_Return(true); + return CJS_Return(); } void CJS_Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv, @@ -1335,11 +1375,11 @@ CJS_Return CJS_Field::get_multiline(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE))); @@ -1348,18 +1388,20 @@ CJS_Return CJS_Field::get_multiline(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_multiline(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_multiple_selection(CJS_Runtime* pRuntime) { ASSERT(m_pFormFillEnv); std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kListBox) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT))); @@ -1368,30 +1410,32 @@ CJS_Return CJS_Field::get_multiple_selection(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_multiple_selection(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_name(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewString(m_FieldName.c_str())); } CJS_Return CJS_Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_num_items(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kComboBox && pFormField->GetFieldType() != FormFieldType::kListBox) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } return CJS_Return(pRuntime->NewNumber(pFormField->CountOptions())); @@ -1399,17 +1443,17 @@ CJS_Return CJS_Field::get_num_items(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_num_items(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_page(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (!pFormField) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); std::vector<CPDFSDK_Annot::ObservedPtr> widgets; m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets); @@ -1420,12 +1464,12 @@ CJS_Return CJS_Field::get_page(CJS_Runtime* pRuntime) { int i = 0; for (const auto& pObserved : widgets) { if (!pObserved) - return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError)); + return CJS_Return(JSMessage::kBadObjectError); auto* pWidget = static_cast<CPDFSDK_Widget*>(pObserved.Get()); CPDFSDK_PageView* pPageView = pWidget->GetPageView(); if (!pPageView) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); pRuntime->PutArrayElement( PageArray, i, @@ -1436,7 +1480,7 @@ CJS_Return CJS_Field::get_page(CJS_Runtime* pRuntime) { } CJS_Return CJS_Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError)); + return CJS_Return(JSMessage::kReadOnlyError); } CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) { @@ -1444,11 +1488,11 @@ CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD))); @@ -1457,20 +1501,22 @@ CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_password(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_print(CJS_Runtime* pRuntime) { CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return( pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT))); @@ -1481,10 +1527,10 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); for (CPDF_FormField* pFormField : FieldArray) { if (m_nFormControlIndex < 0) { @@ -1512,7 +1558,7 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, } if (m_nFormControlIndex >= pFormField->CountControls()) - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); if (CPDF_FormControl* pFormControl = pFormField->GetControl(m_nFormControlIndex)) { @@ -1532,17 +1578,17 @@ CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime, } } } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::get_radios_in_unison(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kRadioButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON))); @@ -1552,14 +1598,16 @@ CJS_Return CJS_Field::set_radios_in_unison(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); - return CJS_Return(m_bCanSet); + return CJS_Return(JSMessage::kBadObjectError); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_readonly(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewBoolean( !!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY))); @@ -1569,21 +1617,23 @@ CJS_Return CJS_Field::set_readonly(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); - return CJS_Return(m_bCanSet); + return CJS_Return(JSMessage::kBadObjectError); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_rect(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = pInterForm->GetWidget(GetSmartFieldControl(pFormField)); if (!pWidget) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CFX_FloatRect crRect = pWidget->GetRect(); v8::Local<v8::Array> rcArray = pRuntime->NewArray(); @@ -1601,13 +1651,13 @@ CJS_Return CJS_Field::get_rect(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); v8::Local<v8::Array> rcArray = pRuntime->ToArray(vp); if (pRuntime->GetArrayLength(rcArray) < 4) - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); float pArray[4]; pArray[0] = static_cast<float>( @@ -1626,7 +1676,7 @@ CJS_Return CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { CJS_Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, crRect); } - return CJS_Return(true); + return CJS_Return(); } void CJS_Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv, @@ -1690,11 +1740,11 @@ void CJS_Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv, CJS_Return CJS_Field::get_required(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() == FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED))); @@ -1704,8 +1754,10 @@ CJS_Return CJS_Field::set_required(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); - return CJS_Return(m_bCanSet); + return CJS_Return(JSMessage::kBadObjectError); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) { @@ -1713,11 +1765,11 @@ CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kTextField) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); return CJS_Return(pRuntime->NewBoolean( !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT))); @@ -1726,16 +1778,18 @@ CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_rich_text(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_rich_value(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) { @@ -1743,12 +1797,12 @@ CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewNumber(pFormControl->GetRotation())); } @@ -1756,18 +1810,20 @@ CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_rotation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); int iColorType; pFormControl->GetBorderColor(iColorType); @@ -1788,7 +1844,7 @@ CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) { pFormControl->GetOriginalBorderColor(2), pFormControl->GetOriginalBorderColor(3)); } else { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } v8::Local<v8::Value> array = @@ -1801,10 +1857,10 @@ CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_stroke_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(false); - return CJS_Return(true); + return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return(); } CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) { @@ -1812,17 +1868,17 @@ CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kRadioButton && pFormField->GetFieldType() != FormFieldType::kCheckBox) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); WideString csWCaption = pFormControl->GetNormalCaption(); ByteString csBCaption; @@ -1854,27 +1910,29 @@ CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_submit_name(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::set_submit_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); Optional<CFX_Color::Type> iColorType; FX_ARGB color; @@ -1903,10 +1961,10 @@ CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); if (vp.IsEmpty() || !vp->IsArray()) - return CJS_Return(false); - return CJS_Return(true); + return CJS_Return(JSMessage::kBadObjectError); + return CJS_Return(); } CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) { @@ -1914,25 +1972,25 @@ CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; ASSERT(pFormField); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); FormFieldType fieldType = pFormField->GetFieldType(); if (fieldType != FormFieldType::kPushButton && fieldType != FormFieldType::kComboBox && fieldType != FormFieldType::kListBox && fieldType != FormFieldType::kTextField) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } CPDF_Font* pFont = pFormControl->GetDefaultControlFont(); if (!pFont) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewString( WideString::FromLocal(pFont->GetBaseFont().c_str()).c_str())); @@ -1943,9 +2001,10 @@ CJS_Return CJS_Field::set_text_font(CJS_Runtime* pRuntime, ASSERT(m_pFormFillEnv); if (!m_bCanSet) - return CJS_Return(false); - return CJS_Return( - !ByteString::FromUnicode(pRuntime->ToWideString(vp)).IsEmpty()); + return CJS_Return(JSMessage::kReadOnlyError); + if (ByteString::FromUnicode(pRuntime->ToWideString(vp)).IsEmpty()) + return CJS_Return(JSMessage::kValueError); + return CJS_Return(); } CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) { @@ -1953,13 +2012,13 @@ CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; ASSERT(pFormField); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); float fFontSize; CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance(); @@ -1970,13 +2029,15 @@ CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_text_size(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_type(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; switch (pFormField->GetFieldType()) { @@ -2002,7 +2063,7 @@ CJS_Return CJS_Field::get_type(CJS_Runtime* pRuntime) { } CJS_Return CJS_Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) { @@ -2010,7 +2071,7 @@ CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return( pRuntime->NewString(FieldArray[0]->GetAlternateName().c_str())); @@ -2019,20 +2080,22 @@ CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_user_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { ASSERT(m_pFormFillEnv); - return CJS_Return(m_bCanSet); + if (!m_bCanSet) + return CJS_Return(JSMessage::kReadOnlyError); + return CJS_Return(); } CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); v8::Local<v8::Value> ret; CPDF_FormField* pFormField = FieldArray[0]; switch (pFormField->GetFieldType()) { case FormFieldType::kPushButton: - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); case FormFieldType::kComboBox: case FormFieldType::kTextField: ret = pRuntime->NewString(pFormField->GetValue().c_str()); @@ -2084,7 +2147,7 @@ CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); std::vector<WideString> strArray; if (!vp.IsEmpty() && vp->IsArray()) { @@ -2103,7 +2166,7 @@ CJS_Return CJS_Field::set_value(CJS_Runtime* pRuntime, CJS_Field::SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, strArray); } - return CJS_Return(true); + return CJS_Return(); } void CJS_Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv, @@ -2164,15 +2227,15 @@ void CJS_Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv, CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() == FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); if (pFormField->GetFieldType() == FormFieldType::kCheckBox) { if (!pFormField->CountControls()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); return CJS_Return(pRuntime->NewString( pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off")); } @@ -2197,7 +2260,7 @@ CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) { CJS_Return CJS_Field::set_value_as_string(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::browseForFileToSubmit( @@ -2205,7 +2268,7 @@ CJS_Return CJS_Field::browseForFileToSubmit( const std::vector<v8::Local<v8::Value>>& params) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) && @@ -2215,9 +2278,9 @@ CJS_Return CJS_Field::browseForFileToSubmit( pFormField->SetValue(wsFileName); UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true); } - return CJS_Return(true); + return CJS_Return(); } - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } CJS_Return CJS_Field::buttonGetCaption( @@ -2230,15 +2293,15 @@ CJS_Return CJS_Field::buttonGetCaption( std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); if (nface == 0) { return CJS_Return( @@ -2250,7 +2313,7 @@ CJS_Return CJS_Field::buttonGetCaption( return CJS_Return( pRuntime->NewString(pFormControl->GetRolloverCaption().c_str())); } - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); } CJS_Return CJS_Field::buttonGetIcon( @@ -2259,46 +2322,47 @@ CJS_Return CJS_Field::buttonGetIcon( if (params.size() >= 1) { int nFace = pRuntime->ToInt32(params[0]); if (nFace < 0 || nFace > 2) - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); } std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kPushButton) - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); if (!pFormControl) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(CJS_Icon::GetObjDefnID()); if (pObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJS_Icon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); - return pJS_Icon ? CJS_Return(pJS_Icon->ToV8Object()) : CJS_Return(false); + return pJS_Icon ? CJS_Return(pJS_Icon->ToV8Object()) + : CJS_Return(JSMessage::kBadObjectError); } CJS_Return CJS_Field::buttonImportIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::buttonSetCaption( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::buttonSetIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::checkThisBox( @@ -2306,10 +2370,10 @@ CJS_Return CJS_Field::checkThisBox( const std::vector<v8::Local<v8::Value>>& params) { int iSize = params.size(); if (iSize < 1) - return CJS_Return(false); + return CJS_Return(JSMessage::kParamError); if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); int nWidget = pRuntime->ToInt32(params[0]); bool bCheckit = true; @@ -2318,48 +2382,48 @@ CJS_Return CJS_Field::checkThisBox( std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (pFormField->GetFieldType() != FormFieldType::kCheckBox && pFormField->GetFieldType() != FormFieldType::kRadioButton) { - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } if (nWidget < 0 || nWidget >= pFormField->CountControls()) - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); // TODO(weili): Check whether anything special needed for radio button. // (When pFormField->GetFieldType() == FormFieldType::kRadioButton.) pFormField->CheckControl(nWidget, bCheckit, true); UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::clearItems( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::defaultIsChecked( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_bCanSet) - return CJS_Return(false); + return CJS_Return(JSMessage::kReadOnlyError); int iSize = params.size(); if (iSize < 1) - return CJS_Return(false); + return CJS_Return(JSMessage::kParamError); int nWidget = pRuntime->ToInt32(params[0]); std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (nWidget < 0 || nWidget >= pFormField->CountControls()) - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); return CJS_Return(pRuntime->NewBoolean( pFormField->GetFieldType() == FormFieldType::kCheckBox || @@ -2369,7 +2433,7 @@ CJS_Return CJS_Field::defaultIsChecked( CJS_Return CJS_Field::deleteItemAt( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::getArray( @@ -2377,7 +2441,7 @@ CJS_Return CJS_Field::getArray( const std::vector<v8::Local<v8::Value>>& params) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); std::vector<std::unique_ptr<WideString>> swSort; for (CPDF_FormField* pFormField : FieldArray) { @@ -2395,7 +2459,7 @@ CJS_Return CJS_Field::getArray( v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject(CJS_Field::GetObjDefnID()); if (pObj.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); auto* pJSField = static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -2422,7 +2486,7 @@ CJS_Return CJS_Field::getItemAt( std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if ((pFormField->GetFieldType() == FormFieldType::kListBox) || @@ -2440,18 +2504,18 @@ CJS_Return CJS_Field::getItemAt( return CJS_Return( pRuntime->NewString(pFormField->GetOptionLabel(nIdx).c_str())); } - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } CJS_Return CJS_Field::getLock(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::insertItemAt( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::isBoxChecked( @@ -2463,11 +2527,11 @@ CJS_Return CJS_Field::isBoxChecked( std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (nIndex < 0 || nIndex >= pFormField->CountControls()) - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); return CJS_Return(pRuntime->NewBoolean( ((pFormField->GetFieldType() == FormFieldType::kCheckBox || @@ -2484,11 +2548,11 @@ CJS_Return CJS_Field::isDefaultChecked( std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; if (nIndex < 0 || nIndex >= pFormField->CountControls()) - return CJS_Return(false); + return CJS_Return(JSMessage::kValueError); return CJS_Return(pRuntime->NewBoolean( ((pFormField->GetFieldType() == FormFieldType::kCheckBox || @@ -2499,7 +2563,7 @@ CJS_Return CJS_Field::isDefaultChecked( CJS_Return CJS_Field::setAction( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::setFocus( @@ -2507,12 +2571,12 @@ CJS_Return CJS_Field::setFocus( const std::vector<v8::Local<v8::Value>>& params) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDF_FormField* pFormField = FieldArray[0]; int32_t nCount = pFormField->CountControls(); if (nCount < 1) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDFSDK_Widget* pWidget = nullptr; @@ -2522,7 +2586,7 @@ CJS_Return CJS_Field::setFocus( UnderlyingPageType* pPage = UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage()); if (!pPage) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); if (CPDFSDK_PageView* pCurPageView = m_pFormFillEnv->GetPageView(pPage, true)) { for (int32_t i = 0; i < nCount; i++) { @@ -2542,63 +2606,63 @@ CJS_Return CJS_Field::setFocus( m_pFormFillEnv->SetFocusAnnot(&pObserved); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::setItems( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::setLock(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureGetModifications( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureGetSeedValue( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureInfo( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureSetSeedValue( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureSign( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::signatureValidate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } CJS_Return CJS_Field::get_source(CJS_Runtime* pRuntime) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Field::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(true); + return CJS_Return(); } void CJS_Field::AddDelay_Int(FIELD_PROP prop, int32_t n) { diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp index 1e01f96aee..5d5bc3ccf0 100644 --- a/fxjs/cjs_global.cpp +++ b/fxjs/cjs_global.cpp @@ -218,28 +218,30 @@ void CJS_Global::Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv) { } CJS_Return CJS_Global::QueryProperty(const wchar_t* propname) { - return CJS_Return(WideString(propname) != L"setPersistent"); + if (WideString(propname) != L"setPersistent") + return CJS_Return(JSMessage::kUnknownProperty); + return CJS_Return(); } CJS_Return CJS_Global::DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname) { auto it = m_MapGlobal.find(ByteString::FromUnicode(propname)); if (it == m_MapGlobal.end()) - return CJS_Return(false); + return CJS_Return(JSMessage::kUnknownProperty); it->second->bDeleted = true; - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Global::GetProperty(CJS_Runtime* pRuntime, const wchar_t* propname) { auto it = m_MapGlobal.find(ByteString::FromUnicode(propname)); if (it == m_MapGlobal.end()) - return CJS_Return(true); + return CJS_Return(); JSGlobalData* pData = it->second.get(); if (pData->bDeleted) - return CJS_Return(true); + return CJS_Return(); switch (pData->nType) { case JS_GlobalDataType::NUMBER: @@ -257,7 +259,7 @@ CJS_Return CJS_Global::GetProperty(CJS_Runtime* pRuntime, default: break; } - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } CJS_Return CJS_Global::SetProperty(CJS_Runtime* pRuntime, @@ -290,24 +292,24 @@ CJS_Return CJS_Global::SetProperty(CJS_Runtime* pRuntime, } if (vp->IsUndefined()) { DelProperty(pRuntime, propname); - return CJS_Return(true); + return CJS_Return(); } - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } CJS_Return CJS_Global::setPersistent( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); auto it = m_MapGlobal.find( ByteString::FromUnicode(pRuntime->ToWideString(params[0]))); if (it == m_MapGlobal.end() || it->second->bDeleted) - return CJS_Return(JSGetStringFromID(JSMessage::kGlobalNotFoundError)); + return CJS_Return(JSMessage::kGlobalNotFoundError); it->second->bPersistent = pRuntime->ToBoolean(params[1]); - return CJS_Return(true); + return CJS_Return(); } void CJS_Global::UpdateGlobalPersistentVariables() { @@ -498,7 +500,7 @@ CJS_Return CJS_Global::SetGlobalVariables(const ByteString& propname, v8::Local<v8::Object> pData, bool bDefaultPersistent) { if (propname.IsEmpty()) - return CJS_Return(false); + return CJS_Return(JSMessage::kUnknownProperty); auto it = m_MapGlobal.find(propname); if (it != m_MapGlobal.end()) { @@ -526,9 +528,9 @@ CJS_Return CJS_Global::SetGlobalVariables(const ByteString& propname, case JS_GlobalDataType::NULLOBJ: break; default: - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } - return CJS_Return(true); + return CJS_Return(); } auto pNewData = pdfium::MakeUnique<JSGlobalData>(); @@ -558,8 +560,8 @@ CJS_Return CJS_Global::SetGlobalVariables(const ByteString& propname, pNewData->bPersistent = bDefaultPersistent; break; default: - return CJS_Return(false); + return CJS_Return(JSMessage::kObjectTypeError); } m_MapGlobal[propname] = std::move(pNewData); - return CJS_Return(true); + return CJS_Return(); } diff --git a/fxjs/cjs_icon.cpp b/fxjs/cjs_icon.cpp index 786d19ca35..89b42f1e02 100644 --- a/fxjs/cjs_icon.cpp +++ b/fxjs/cjs_icon.cpp @@ -34,5 +34,5 @@ CJS_Return CJS_Icon::get_name(CJS_Runtime* pRuntime) { } CJS_Return CJS_Icon::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return(false); + return CJS_Return(JSMessage::kNotSupportedError); } diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp index 678aca5317..908611b0d6 100644 --- a/fxjs/cjs_publicmethods.cpp +++ b/fxjs/cjs_publicmethods.cpp @@ -872,17 +872,17 @@ CJS_Return CJS_PublicMethods::AFNumber_Format( const std::vector<v8::Local<v8::Value>>& params) { #if _FX_OS_ != _FX_OS_ANDROID_ if (params.size() != 6) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(L"No event handler"); WideString& Value = pEvent->Value(); ByteString strValue = StrTrim(ByteString::FromUnicode(Value)); if (strValue.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); int iDec = abs(pRuntime->ToInt32(params[0])); int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32(params[1])); @@ -970,7 +970,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Format( } } #endif - return CJS_Return(true); + return CJS_Return(); } // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency, @@ -979,12 +979,12 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 2) - return CJS_Return(false); + return CJS_Return(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); WideString& val = pEvent->Value(); WideString& wstrChange = pEvent->Change(); @@ -993,7 +993,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( if (pEvent->WillCommit()) { WideString swTemp = StrTrim(wstrValue); if (swTemp.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); NormalizeDecimalMarkW(&swTemp); if (!IsNumber(swTemp.c_str())) { @@ -1003,7 +1003,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( return CJS_Return(sError); } // It happens after the last keystroke and before validating, - return CJS_Return(true); + return CJS_Return(); } WideString wstrSelected; @@ -1017,7 +1017,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( // can't insert "change" in front of sign position. if (!wstrSelected.IsEmpty() && pEvent->SelStart() == 0) { pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } } @@ -1029,7 +1029,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( if (wstrChange[i] == cSep) { if (bHasSep) { pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } bHasSep = true; continue; @@ -1037,16 +1037,16 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( if (wstrChange[i] == L'-') { if (bHasSign) { pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } // sign's position is not correct if (i != 0) { pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } if (pEvent->SelStart() != 0) { pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } bHasSign = true; continue; @@ -1054,12 +1054,12 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke( if (!std::iswdigit(wstrChange[i])) { pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } } val = CalcMergedString(pEvent, wstrValue, wstrChange); - return CJS_Return(true); + return CJS_Return(); } // function AFPercent_Format(nDec, sepStyle) @@ -1068,17 +1068,17 @@ CJS_Return CJS_PublicMethods::AFPercent_Format( const std::vector<v8::Local<v8::Value>>& params) { #if _FX_OS_ != _FX_OS_ANDROID_ if (params.size() != 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); WideString& Value = pEvent->Value(); ByteString strValue = StrTrim(ByteString::FromUnicode(Value)); if (strValue.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); int iDec = abs(pRuntime->ToInt32(params[0])); int iSepStyle = ValidStyleOrZero(pRuntime->ToInt32(params[1])); @@ -1139,7 +1139,7 @@ CJS_Return CJS_PublicMethods::AFPercent_Format( strValue += '%'; Value = WideString::FromLocal(strValue.AsStringView()); #endif - return CJS_Return(true); + return CJS_Return(); } // AFPercent_Keystroke(nDec, sepStyle) @@ -1154,17 +1154,17 @@ CJS_Return CJS_PublicMethods::AFDate_FormatEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); WideString& val = pEvent->Value(); WideString strValue = val; if (strValue.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); WideString sFormat = pRuntime->ToWideString(params[0]); double dDate; @@ -1180,11 +1180,11 @@ CJS_Return CJS_PublicMethods::AFDate_FormatEx( WideString swMsg = WideString::Format( JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str()); AlertIfPossible(pContext, swMsg.c_str()); - return CJS_Return(false); + return CJS_Return(JSMessage::kParseDateError); } val = MakeFormatDate(dDate, sFormat); - return CJS_Return(true); + return CJS_Return(); } double CJS_PublicMethods::MakeInterDate(const WideString& strValue) { @@ -1237,11 +1237,11 @@ CJS_Return CJS_PublicMethods::AFDate_KeystrokeEx( CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (pEvent->WillCommit()) { if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); const WideString& strValue = pEvent->Value(); if (strValue.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); WideString sFormat = pRuntime->ToWideString(params[0]); bool bWrongFormat = false; @@ -1252,17 +1252,17 @@ CJS_Return CJS_PublicMethods::AFDate_KeystrokeEx( sFormat.c_str()); AlertIfPossible(pContext, swMsg.c_str()); pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_PublicMethods::AFDate_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); static constexpr const wchar_t* cFormats[] = {L"m/d", L"m/d/yy", @@ -1291,7 +1291,7 @@ CJS_Return CJS_PublicMethods::AFDate_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); static constexpr const wchar_t* cFormats[] = {L"m/d", L"m/d/yy", @@ -1320,7 +1320,7 @@ CJS_Return CJS_PublicMethods::AFTime_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); static constexpr const wchar_t* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"}; @@ -1336,7 +1336,7 @@ CJS_Return CJS_PublicMethods::AFTime_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); static constexpr const wchar_t* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss", L"h:MM:ss tt"}; @@ -1365,12 +1365,12 @@ CJS_Return CJS_PublicMethods::AFSpecial_Format( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); const WideString& wsSource = pEvent->Value(); WideString wsFormat; @@ -1393,7 +1393,7 @@ CJS_Return CJS_PublicMethods::AFSpecial_Format( } pEvent->Value() = CJS_Util::printx(wsFormat, wsSource); - return CJS_Return(true); + return CJS_Return(); } // function AFSpecial_KeystrokeEx(mask) @@ -1401,21 +1401,21 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); const WideString& valEvent = pEvent->Value(); WideString wstrMask = pRuntime->ToWideString(params[0]); if (wstrMask.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); if (pEvent->WillCommit()) { if (valEvent.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); size_t iIndexMask = 0; for (; iIndexMask < valEvent.GetLength(); ++iIndexMask) { @@ -1429,12 +1429,12 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( JSGetStringFromID(JSMessage::kInvalidInputError).c_str()); pEvent->Rc() = false; } - return CJS_Return(true); + return CJS_Return(); } WideString& wideChange = pEvent->Change(); if (wideChange.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); WideString wChange = wideChange; size_t iIndexMask = pEvent->SelStart(); @@ -1444,14 +1444,14 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( AlertIfPossible(pContext, JSGetStringFromID(JSMessage::kParamTooLongError).c_str()); pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) { AlertIfPossible(pContext, JSGetStringFromID(JSMessage::kParamTooLongError).c_str()); pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } for (size_t i = 0; i < wChange.GetLength(); ++i) { @@ -1459,7 +1459,7 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( AlertIfPossible(pContext, JSGetStringFromID(JSMessage::kParamTooLongError).c_str()); pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } wchar_t wMask = wstrMask[iIndexMask]; if (!IsReservedMaskChar(wMask)) @@ -1467,12 +1467,12 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx( if (!MaskSatisfied(wChange[i], wMask)) { pEvent->Rc() = false; - return CJS_Return(true); + return CJS_Return(); } iIndexMask++; } wideChange = wChange; - return CJS_Return(true); + return CJS_Return(); } // function AFSpecial_Keystroke(psf) @@ -1480,12 +1480,12 @@ CJS_Return CJS_PublicMethods::AFSpecial_Keystroke( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); const char* cFormat = ""; switch (pRuntime->ToInt32(params[0])) { @@ -1515,7 +1515,7 @@ CJS_Return CJS_PublicMethods::AFMergeChange( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_EventHandler* pEventHandler = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -1536,7 +1536,7 @@ CJS_Return CJS_PublicMethods::AFParseDateEx( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); WideString sValue = pRuntime->ToWideString(params[0]); WideString sFormat = pRuntime->ToWideString(params[1]); @@ -1545,7 +1545,7 @@ CJS_Return CJS_PublicMethods::AFParseDateEx( WideString swMsg = WideString::Format( JSGetStringFromID(JSMessage::kParseDateError).c_str(), sFormat.c_str()); AlertIfPossible(pRuntime->GetCurrentEventContext(), swMsg.c_str()); - return CJS_Return(false); + return CJS_Return(JSMessage::kParseDateError); } return CJS_Return(pRuntime->NewNumber(dDate)); } @@ -1554,7 +1554,7 @@ CJS_Return CJS_PublicMethods::AFSimple( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 3) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); return CJS_Return(pRuntime->NewNumber(static_cast<double>(AF_Simple( pRuntime->ToWideString(params[0]).c_str(), pRuntime->ToDouble(params[1]), @@ -1565,7 +1565,7 @@ CJS_Return CJS_PublicMethods::AFMakeNumber( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); WideString ws = pRuntime->ToWideString(params[0]); NormalizeDecimalMarkW(&ws); @@ -1581,10 +1581,10 @@ CJS_Return CJS_PublicMethods::AFSimple_Calculate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); if ((params[1].IsEmpty() || !params[1]->IsArray()) && !params[1]->IsString()) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CPDFSDK_InterForm* pReaderInterForm = pRuntime->GetFormFillEnv()->GetInterForm(); @@ -1665,7 +1665,7 @@ CJS_Return CJS_PublicMethods::AFSimple_Calculate( pRuntime->ToWideString(pRuntime->NewNumber(dValue)); } - return CJS_Return(true); + return CJS_Return(); } /* This function validates the current event to ensure that its value is @@ -1674,15 +1674,15 @@ CJS_Return CJS_PublicMethods::AFRange_Validate( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 4) - CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); CJS_EventContext* pContext = pRuntime->GetCurrentEventContext(); CJS_EventHandler* pEvent = pContext->GetEventHandler(); if (!pEvent->m_pValue) - return CJS_Return(false); + return CJS_Return(JSMessage::kBadObjectError); if (pEvent->Value().IsEmpty()) - return CJS_Return(true); + return CJS_Return(); double dEentValue = atof(ByteString::FromUnicode(pEvent->Value()).c_str()); bool bGreaterThan = pRuntime->ToBoolean(params[0]); @@ -1713,14 +1713,14 @@ CJS_Return CJS_PublicMethods::AFRange_Validate( AlertIfPossible(pContext, swMsg.c_str()); pEvent->Rc() = false; } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_PublicMethods::AFExtractNums( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); WideString str = pRuntime->ToWideString(params[0]); if (str.GetLength() > 0 && IsDigitSeparatorOrDecimalMark(str[0])) diff --git a/fxjs/cjs_report.cpp b/fxjs/cjs_report.cpp index 3a912765f6..eccba07a99 100644 --- a/fxjs/cjs_report.cpp +++ b/fxjs/cjs_report.cpp @@ -34,11 +34,11 @@ CJS_Return CJS_Report::writeText( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJS_Report::save(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return(true); + return CJS_Return(); } diff --git a/fxjs/cjs_return.cpp b/fxjs/cjs_return.cpp index adfd1c5c9f..53ac5c0a28 100644 --- a/fxjs/cjs_return.cpp +++ b/fxjs/cjs_return.cpp @@ -6,13 +6,15 @@ #include "fxjs/cjs_return.h" -CJS_Return::CJS_Return(bool result) : is_error_(!result) {} - -CJS_Return::CJS_Return(const WideString& err) : is_error_(true), error_(err) {} +CJS_Return::CJS_Return() : is_error_(false) {} CJS_Return::CJS_Return(v8::Local<v8::Value> ret) : is_error_(false), return_(ret) {} +CJS_Return::CJS_Return(const WideString& err) : is_error_(true), error_(err) {} + +CJS_Return::CJS_Return(JSMessage id) : CJS_Return(JSGetStringFromID(id)) {} + CJS_Return::CJS_Return(const CJS_Return&) = default; CJS_Return::~CJS_Return() = default; diff --git a/fxjs/cjs_return.h b/fxjs/cjs_return.h index 37c91caafe..df3c8519bd 100644 --- a/fxjs/cjs_return.h +++ b/fxjs/cjs_return.h @@ -8,12 +8,14 @@ #define FXJS_CJS_RETURN_H_ #include "fxjs/cfxjs_engine.h" +#include "fxjs/js_resources.h" class CJS_Return { public: - explicit CJS_Return(bool); - explicit CJS_Return(const WideString&); - explicit CJS_Return(v8::Local<v8::Value>); + CJS_Return(); // Successful but empty return. + explicit CJS_Return(v8::Local<v8::Value>); // Successful return with value. + explicit CJS_Return(const WideString&); // Error with custom message. + explicit CJS_Return(JSMessage id); // Error with stock message. CJS_Return(const CJS_Return&); ~CJS_Return(); @@ -24,8 +26,6 @@ class CJS_Return { v8::Local<v8::Value> Return() const { return return_; } private: - CJS_Return() = delete; - bool is_error_ = false; WideString error_; v8::Local<v8::Value> return_; diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp index 8da9a07a45..0ff408349f 100644 --- a/fxjs/cjs_util.cpp +++ b/fxjs/cjs_util.cpp @@ -83,7 +83,7 @@ CJS_Return CJS_Util::printf(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { const size_t iSize = params.size(); if (iSize < 1) - return CJS_Return(false); + return CJS_Return(JSMessage::kParamError); std::wstring unsafe_fmt_string(pRuntime->ToWideString(params[0]).c_str()); std::vector<std::wstring> unsafe_conversion_specifiers; @@ -145,10 +145,10 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { const size_t iSize = params.size(); if (iSize < 2) - return CJS_Return(false); + return CJS_Return(JSMessage::kParamError); if (params[1].IsEmpty() || !params[1]->IsDate()) - return CJS_Return(JSGetStringFromID(JSMessage::kSecondParamNotDateError)); + return CJS_Return(JSMessage::kSecondParamNotDateError); v8::Local<v8::Date> v8_date = params[1].As<v8::Date>(); if (v8_date.IsEmpty() || std::isnan(pRuntime->ToDouble(v8_date))) { @@ -180,7 +180,7 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime, month, day, hour, min, sec); break; default: - return CJS_Return(JSGetStringFromID(JSMessage::kValueError)); + return CJS_Return(JSMessage::kValueError); } return CJS_Return(pRuntime->NewString(swResult.c_str())); @@ -189,7 +189,7 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime, if (params[0]->IsString()) { // We don't support XFAPicture at the moment. if (iSize > 2 && pRuntime->ToBoolean(params[2])) - return CJS_Return(JSGetStringFromID(JSMessage::kNotSupportedError)); + return CJS_Return(JSMessage::kNotSupportedError); // Convert PDF-style format specifiers to wcsftime specifiers. Remove any // pre-existing %-directives before inserting our own. @@ -210,7 +210,7 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime, } if (year < 0) - return CJS_Return(JSGetStringFromID(JSMessage::kValueError)); + return CJS_Return(JSMessage::kValueError); const TbConvertAdditional cTableAd[] = { {L"m", month}, {L"d", day}, @@ -248,13 +248,13 @@ CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime, return CJS_Return(pRuntime->NewString(cFormat.c_str())); } - return CJS_Return(JSGetStringFromID(JSMessage::kTypeError)); + return CJS_Return(JSMessage::kTypeError); } CJS_Return CJS_Util::printx(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 2) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); return CJS_Return( pRuntime->NewString(printx(pRuntime->ToWideString(params[0]), @@ -363,7 +363,7 @@ WideString CJS_Util::printx(const WideString& wsFormat, CJS_Return CJS_Util::scand(CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 2) - return CJS_Return(false); + return CJS_Return(JSMessage::kParamError); WideString sFormat = pRuntime->ToWideString(params[0]); WideString sDate = pRuntime->ToWideString(params[1]); @@ -380,11 +380,11 @@ CJS_Return CJS_Util::byteToChar( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() < 1) - return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); + return CJS_Return(JSMessage::kParamError); int arg = pRuntime->ToInt32(params[0]); if (arg < 0 || arg > 255) - return CJS_Return(JSGetStringFromID(JSMessage::kValueError)); + return CJS_Return(JSMessage::kValueError); WideString wStr(static_cast<wchar_t>(arg)); return CJS_Return(pRuntime->NewString(wStr.c_str())); diff --git a/fxjs/js_resources.cpp b/fxjs/js_resources.cpp index bfffbc3714..ec20b1e9b5 100644 --- a/fxjs/js_resources.cpp +++ b/fxjs/js_resources.cpp @@ -49,8 +49,14 @@ WideString JSGetStringFromID(JSMessage msg) { return L"Permission denied."; case JSMessage::kBadObjectError: return L"Object no longer exists."; + case JSMessage::kObjectTypeError: + return L"Object is of the wrong type."; case JSMessage::kTooManyOccurances: - return L"Too many occurances"; + return L"Too many occurances."; + case JSMessage::kUnknownProperty: + return L"Unknown property."; + case JSMessage::kUnknownMethod: + return L"Unknown method."; } NOTREACHED(); return L""; diff --git a/fxjs/js_resources.h b/fxjs/js_resources.h index 0b664c997c..10bbcb8fed 100644 --- a/fxjs/js_resources.h +++ b/fxjs/js_resources.h @@ -30,7 +30,10 @@ enum class JSMessage { kValueError, kPermissionError, kBadObjectError, - kTooManyOccurances + kObjectTypeError, + kTooManyOccurances, + kUnknownProperty, + kUnknownMethod, }; WideString JSGetStringFromID(JSMessage msg); diff --git a/fxjs/xfa/cjx_container.cpp b/fxjs/xfa/cjx_container.cpp index e5dbfe8258..0e58a7ea22 100644 --- a/fxjs/xfa/cjx_container.cpp +++ b/fxjs/xfa/cjx_container.cpp @@ -27,7 +27,7 @@ CJX_Container::~CJX_Container() {} CJS_Return CJX_Container::getDelta( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Container::getDeltas( diff --git a/fxjs/xfa/cjx_datawindow.cpp b/fxjs/xfa/cjx_datawindow.cpp index cdb6aab207..1f5b6ec7b6 100644 --- a/fxjs/xfa/cjx_datawindow.cpp +++ b/fxjs/xfa/cjx_datawindow.cpp @@ -27,25 +27,25 @@ CJX_DataWindow::~CJX_DataWindow() {} CJS_Return CJX_DataWindow::moveCurrentRecord( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_DataWindow::record( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_DataWindow::gotoRecord( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_DataWindow::isRecordGroup( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } void CJX_DataWindow::recordsBefore(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_delta.cpp b/fxjs/xfa/cjx_delta.cpp index 1da5953ea1..9732f4eecb 100644 --- a/fxjs/xfa/cjx_delta.cpp +++ b/fxjs/xfa/cjx_delta.cpp @@ -24,7 +24,7 @@ CJS_Return CJX_Delta::restore(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } void CJX_Delta::currentValue(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_eventpseudomodel.cpp b/fxjs/xfa/cjx_eventpseudomodel.cpp index d2364c8f32..a6c5560b03 100644 --- a/fxjs/xfa/cjx_eventpseudomodel.cpp +++ b/fxjs/xfa/cjx_eventpseudomodel.cpp @@ -174,22 +174,22 @@ CJS_Return CJX_EventPseudoModel::emit( const std::vector<v8::Local<v8::Value>>& params) { CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return(true); + return CJS_Return(); CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); if (!pEventParam) - return CJS_Return(true); + return CJS_Return(); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); CXFA_FFWidgetHandler* pWidgetHandler = pNotify->GetWidgetHandler(); if (!pWidgetHandler) - return CJS_Return(true); + return CJS_Return(); pWidgetHandler->ProcessEvent(pEventParam->m_pTarget, pEventParam); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_EventPseudoModel::reset( @@ -197,14 +197,14 @@ CJS_Return CJX_EventPseudoModel::reset( const std::vector<v8::Local<v8::Value>>& params) { CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return(true); + return CJS_Return(); CXFA_EventParam* pEventParam = pScriptContext->GetEventParam(); if (!pEventParam) - return CJS_Return(true); + return CJS_Return(); pEventParam->Reset(); - return CJS_Return(true); + return CJS_Return(); } void CJX_EventPseudoModel::Property(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_exclgroup.cpp b/fxjs/xfa/cjx_exclgroup.cpp index 2b66484073..6e44e56079 100644 --- a/fxjs/xfa/cjx_exclgroup.cpp +++ b/fxjs/xfa/cjx_exclgroup.cpp @@ -38,7 +38,7 @@ CJS_Return CJX_ExclGroup::execEvent( execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(), XFA_Element::ExclGroup); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_ExclGroup::execInitialize( @@ -51,7 +51,7 @@ CJS_Return CJX_ExclGroup::execInitialize( if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_ExclGroup::execCalculate( @@ -64,7 +64,7 @@ CJS_Return CJX_ExclGroup::execCalculate( if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_ExclGroup::execValidate( diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp index d3f0280d3f..3beb868f1d 100644 --- a/fxjs/xfa/cjx_field.cpp +++ b/fxjs/xfa/cjx_field.cpp @@ -44,7 +44,7 @@ CJS_Return CJX_Field::clearItems( CXFA_Node* node = GetXFANode(); if (node->IsWidgetReady()) node->DeleteItem(-1, true, false); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Field::execEvent( @@ -57,7 +57,7 @@ CJS_Return CJX_Field::execEvent( int32_t iRet = execSingleEventByName(eventString.AsStringView(), XFA_Element::Field); if (eventString != L"validate") - return CJS_Return(true); + return CJS_Return(); return CJS_Return(runtime->NewBoolean(iRet != XFA_EVENTERROR_Error)); } @@ -73,7 +73,7 @@ CJS_Return CJX_Field::execInitialize( pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, false); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Field::deleteItem( @@ -84,7 +84,7 @@ CJS_Return CJX_Field::deleteItem( CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return(true); + return CJS_Return(); bool bValue = node->DeleteItem(runtime->ToInt32(params[0]), true, true); return CJS_Return(runtime->NewBoolean(bValue)); @@ -119,7 +119,7 @@ CJS_Return CJX_Field::boundItem( CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return(true); + return CJS_Return(); WideString value = runtime->ToWideString(params[0]); WideString boundValue = node->GetItemValue(value.AsStringView()); @@ -134,7 +134,7 @@ CJS_Return CJX_Field::getItemState( CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return(true); + return CJS_Return(); int32_t state = node->GetItemState(runtime->ToInt32(params[0])); return CJS_Return(runtime->NewBoolean(state != 0)); @@ -151,7 +151,7 @@ CJS_Return CJX_Field::execCalculate( pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, false); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Field::getDisplayItem( @@ -183,17 +183,17 @@ CJS_Return CJX_Field::setItemState( CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return(true); + return CJS_Return(); int32_t iIndex = runtime->ToInt32(params[0]); if (runtime->ToInt32(params[1]) != 0) { node->SetItemState(iIndex, true, true, true, true); - return CJS_Return(true); + return CJS_Return(); } if (node->GetItemState(iIndex)) node->SetItemState(iIndex, false, true, true, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Field::addItem(CFX_V8* runtime, @@ -203,7 +203,7 @@ CJS_Return CJX_Field::addItem(CFX_V8* runtime, CXFA_Node* node = GetXFANode(); if (!node->IsWidgetReady()) - return CJS_Return(true); + return CJS_Return(); WideString label; if (params.size() >= 1) @@ -214,7 +214,7 @@ CJS_Return CJX_Field::addItem(CFX_V8* runtime, value = runtime->ToWideString(params[1]); node->InsertItem(label, value, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Field::execValidate( diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp index fa244b3af6..d1d50ad8f3 100644 --- a/fxjs/xfa/cjx_form.cpp +++ b/fxjs/xfa/cjx_form.cpp @@ -59,7 +59,7 @@ CJS_Return CJX_Form::remerge(CFX_V8* runtime, return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); GetDocument()->DoDataRemerge(true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Form::execInitialize( @@ -72,7 +72,7 @@ CJS_Return CJX_Form::execInitialize( if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Form::recalculate( @@ -82,19 +82,19 @@ CJS_Return CJX_Form::recalculate( GetDocument()->GetScriptContext()->GetEventParam(); if (pEventParam->m_eType == XFA_EVENT_Calculate || pEventParam->m_eType == XFA_EVENT_InitCalculate) { - return CJS_Return(true); + return CJS_Return(); } if (params.size() != 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify || runtime->ToInt32(params[0]) != 0) - return CJS_Return(true); + return CJS_Return(); pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true); pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Validate, false, true); pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Ready, true, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Form::execCalculate( @@ -107,7 +107,7 @@ CJS_Return CJX_Form::execCalculate( if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Form::execValidate( diff --git a/fxjs/xfa/cjx_hostpseudomodel.cpp b/fxjs/xfa/cjx_hostpseudomodel.cpp index fe26d3161d..2d9b1bf712 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(true); + return CJS_Return(); if (params.size() != 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); CXFA_FFDoc* hDoc = pNotify->GetHDOC(); WideString URL = runtime->ToWideString(params[0]); hDoc->GetDocEnvironment()->GotoURL(hDoc, URL); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::openList( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return(true); + return CJS_Return(); if (params.size() != 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); 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(true); + return CJS_Return(); CXFA_Object* pObject = pScriptContext->GetThisObject(); if (!pObject) - return CJS_Return(true); + return CJS_Return(); uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; @@ -291,24 +291,24 @@ CJS_Return CJX_HostPseudoModel::openList( pObject, runtime->ToWideString(params[0]).AsStringView(), &resolveNodeRS, dwFlag, nullptr); if (!iRet || !resolveNodeRS.objects.front()->IsNode()) - return CJS_Return(true); + return CJS_Return(); pNode = resolveNodeRS.objects.front()->AsNode(); } CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return(true); + return CJS_Return(); CXFA_FFWidget* hWidget = XFA_GetWidgetFromLayoutItem(pDocLayout->GetLayoutItem(pNode)); if (!hWidget) - return CJS_Return(true); + return CJS_Return(); CXFA_FFDoc* hDoc = pNotify->GetHDOC(); hDoc->GetDocEnvironment()->SetFocusWidget(hDoc, hWidget); pNotify->OpenDropDownList(hWidget); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::response( @@ -319,7 +319,7 @@ CJS_Return CJX_HostPseudoModel::response( CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); WideString question; if (params.size() >= 1) @@ -356,7 +356,7 @@ CJS_Return CJX_HostPseudoModel::resetData( CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); WideString expression; if (params.size() >= 1) @@ -364,7 +364,7 @@ CJS_Return CJX_HostPseudoModel::resetData( if (expression.IsEmpty()) { pNotify->ResetData(nullptr); - return CJS_Return(true); + return CJS_Return(); } int32_t iStart = 0; @@ -375,11 +375,11 @@ CJS_Return CJX_HostPseudoModel::resetData( iStart = FilterName(expression.AsStringView(), iStart, wsName); CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return(true); + return CJS_Return(); CXFA_Object* pObject = pScriptContext->GetThisObject(); if (!pObject) - return CJS_Return(true); + return CJS_Return(); uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; @@ -395,42 +395,42 @@ CJS_Return CJX_HostPseudoModel::resetData( if (!pNode) pNotify->ResetData(nullptr); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::beep( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return(true); + return CJS_Return(); if (params.size() > 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); uint32_t dwType = 4; if (params.size() >= 1) dwType = runtime->ToInt32(params[0]); pNotify->GetAppProvider()->Beep(dwType); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::setFocus( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return(true); + return CJS_Return(); if (params.size() != 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); CXFA_Node* pNode = nullptr; if (params.size() >= 1) { @@ -440,11 +440,11 @@ CJS_Return CJX_HostPseudoModel::setFocus( } else if (params[0]->IsString()) { CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return(true); + return CJS_Return(); CXFA_Object* pObject = pScriptContext->GetThisObject(); if (!pObject) - return CJS_Return(true); + return CJS_Return(); uint32_t dwFlag = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Parent | XFA_RESOLVENODE_Siblings; @@ -453,13 +453,13 @@ CJS_Return CJX_HostPseudoModel::setFocus( pObject, runtime->ToWideString(params[0]).AsStringView(), &resolveNodeRS, dwFlag, nullptr); if (!iRet || !resolveNodeRS.objects.front()->IsNode()) - return CJS_Return(true); + return CJS_Return(); pNode = resolveNodeRS.objects.front()->AsNode(); } } pNotify->SetFocusWidgetNode(pNode); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::getFocus( @@ -467,11 +467,11 @@ CJS_Return CJX_HostPseudoModel::getFocus( const std::vector<v8::Local<v8::Value>>& params) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); CXFA_Node* pNode = pNotify->GetFocusWidgetNode(); if (!pNode) - return CJS_Return(true); + return CJS_Return(); CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode); @@ -485,14 +485,14 @@ CJS_Return CJX_HostPseudoModel::messageBox( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return(true); + return CJS_Return(); if (params.empty() || params.size() > 4) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); WideString message; if (params.size() >= 1) @@ -531,14 +531,14 @@ CJS_Return CJX_HostPseudoModel::print( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!GetDocument()->GetScriptContext()->IsRunAtClient()) - return CJS_Return(true); + return CJS_Return(); if (params.size() != 8) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); uint32_t dwOptions = 0; if (runtime->ToBoolean(params[0])) @@ -559,7 +559,7 @@ CJS_Return CJX_HostPseudoModel::print( CXFA_FFDoc* hDoc = pNotify->GetHDOC(); hDoc->GetDocEnvironment()->Print(hDoc, nStartPage, nEndPage, dwOptions); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::importData( @@ -568,7 +568,7 @@ CJS_Return CJX_HostPseudoModel::importData( if (params.empty() || params.size() > 1) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::exportData( @@ -579,7 +579,7 @@ CJS_Return CJX_HostPseudoModel::exportData( CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); WideString filePath; if (params.size() >= 1) @@ -591,7 +591,7 @@ CJS_Return CJX_HostPseudoModel::exportData( CXFA_FFDoc* hDoc = pNotify->GetHDOC(); hDoc->GetDocEnvironment()->ExportData(hDoc, filePath, XDP); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::pageUp( @@ -599,17 +599,17 @@ CJS_Return CJX_HostPseudoModel::pageUp( const std::vector<v8::Local<v8::Value>>& params) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); CXFA_FFDoc* hDoc = pNotify->GetHDOC(); int32_t nCurPage = hDoc->GetDocEnvironment()->GetCurrentPage(hDoc); int32_t nNewPage = 0; if (nCurPage <= 1) - return CJS_Return(true); + return CJS_Return(); nNewPage = nCurPage - 1; hDoc->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_HostPseudoModel::pageDown( @@ -617,13 +617,13 @@ CJS_Return CJX_HostPseudoModel::pageDown( const std::vector<v8::Local<v8::Value>>& params) { CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); 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(true); + return CJS_Return(); int32_t nNewPage = 0; if (nCurPage >= nPageCount) @@ -632,5 +632,5 @@ CJS_Return CJX_HostPseudoModel::pageDown( nNewPage = nCurPage + 1; hDoc->GetDocEnvironment()->SetCurrentPage(hDoc, nNewPage); - return CJS_Return(true); + return CJS_Return(); } diff --git a/fxjs/xfa/cjx_instancemanager.cpp b/fxjs/xfa/cjx_instancemanager.cpp index 081b685efa..f8df62cdbc 100644 --- a/fxjs/xfa/cjx_instancemanager.cpp +++ b/fxjs/xfa/cjx_instancemanager.cpp @@ -144,7 +144,7 @@ CJS_Return CJX_InstanceManager::moveInstance( CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); CXFA_Node* pToInstance = GetXFANode()->GetItemIfExists(iTo); if (pToInstance && pToInstance->GetElementType() == XFA_Element::Subform) @@ -156,7 +156,7 @@ CJS_Return CJX_InstanceManager::moveInstance( pNotify->RunSubformIndexChange(pFromInstance); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_InstanceManager::removeInstance( @@ -196,7 +196,7 @@ CJS_Return CJX_InstanceManager::removeInstance( pLayoutPro->AddChangedContainer( ToNode(GetDocument()->GetXFAObject(XFA_HASHCODE_Form))); } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_InstanceManager::setInstances( @@ -206,7 +206,7 @@ CJS_Return CJX_InstanceManager::setInstances( return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); SetInstances(runtime->ToInt32(params[0])); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_InstanceManager::addInstance( diff --git a/fxjs/xfa/cjx_layoutpseudomodel.cpp b/fxjs/xfa/cjx_layoutpseudomodel.cpp index 6a01d2914e..0ae4871d09 100644 --- a/fxjs/xfa/cjx_layoutpseudomodel.cpp +++ b/fxjs/xfa/cjx_layoutpseudomodel.cpp @@ -78,7 +78,7 @@ CJS_Return CJX_LayoutPseudoModel::HWXY( CXFA_Node* pNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pNode) - return CJS_Return(true); + return CJS_Return(); WideString unit(L"pt"); if (params.size() >= 2) { @@ -90,11 +90,11 @@ CJS_Return CJX_LayoutPseudoModel::HWXY( CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return(true); + return CJS_Return(); CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); if (!pLayoutItem) - return CJS_Return(true); + return CJS_Return(); while (iIndex > 0 && pLayoutItem) { pLayoutItem = pLayoutItem->GetNext(); @@ -154,7 +154,7 @@ CJS_Return CJX_LayoutPseudoModel::NumberedPageCount(CFX_V8* runtime, bool bNumbered) { CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return(true); + return CJS_Return(); int32_t iPageCount = 0; int32_t iPageNum = pDocLayout->CountPages(); @@ -189,11 +189,11 @@ CJS_Return CJX_LayoutPseudoModel::pageSpan( CXFA_Node* pNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[0])); if (!pNode) - return CJS_Return(true); + return CJS_Return(); CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return(true); + return CJS_Return(); CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); if (!pLayoutItem) @@ -365,11 +365,11 @@ CJS_Return CJX_LayoutPseudoModel::pageContent( CXFA_FFNotify* pNotify = GetDocument()->GetNotify(); if (!pNotify) - return CJS_Return(true); + return CJS_Return(); CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return(true); + return CJS_Return(); auto pArrayNodeList = pdfium::MakeUnique<CXFA_ArrayNodeList>(GetDocument()); pArrayNodeList->SetArrayNodeList( @@ -411,7 +411,7 @@ CJS_Return CJX_LayoutPseudoModel::relayout( pLayoutProcessor->AddChangedContainer(pContentRootNode); pLayoutProcessor->SetForceReLayout(true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_LayoutPseudoModel::absPageSpan( @@ -445,7 +445,7 @@ CJS_Return CJX_LayoutPseudoModel::sheet( CJS_Return CJX_LayoutPseudoModel::relayoutPageArea( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_LayoutPseudoModel::sheetCount( @@ -474,7 +474,7 @@ CJS_Return CJX_LayoutPseudoModel::PageInternals( CXFA_LayoutProcessor* pDocLayout = GetDocument()->GetLayoutProcessor(); if (!pDocLayout) - return CJS_Return(true); + return CJS_Return(); CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); if (!pLayoutItem) diff --git a/fxjs/xfa/cjx_list.cpp b/fxjs/xfa/cjx_list.cpp index 4340e3b089..b6ac47ec79 100644 --- a/fxjs/xfa/cjx_list.cpp +++ b/fxjs/xfa/cjx_list.cpp @@ -42,7 +42,7 @@ CJS_Return CJX_List::append(CFX_V8* runtime, return CJS_Return(JSGetStringFromID(JSMessage::kValueError)); GetXFAList()->Append(pNode); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_List::insert(CFX_V8* runtime, @@ -58,7 +58,7 @@ CJS_Return CJX_List::insert(CFX_V8* runtime, auto* pBeforeNode = ToNode(static_cast<CFXJSE_Engine*>(runtime)->ToXFAObject(params[1])); GetXFAList()->Insert(pNewNode, pBeforeNode); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_List::remove(CFX_V8* runtime, @@ -72,7 +72,7 @@ CJS_Return CJX_List::remove(CFX_V8* runtime, return CJS_Return(JSGetStringFromID(JSMessage::kValueError)); GetXFAList()->Remove(pNode); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_List::item(CFX_V8* runtime, diff --git a/fxjs/xfa/cjx_logpseudomodel.cpp b/fxjs/xfa/cjx_logpseudomodel.cpp index 18093f5263..93772ed03d 100644 --- a/fxjs/xfa/cjx_logpseudomodel.cpp +++ b/fxjs/xfa/cjx_logpseudomodel.cpp @@ -35,29 +35,29 @@ CJS_Return CJX_LogPseudoModel::message( // fprintf(stderr, " %ls\n", WideString::FromUTF8(*str).c_str()); // } - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_LogPseudoModel::traceEnabled( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_LogPseudoModel::traceActivate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_LogPseudoModel::traceDeactivate( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_LogPseudoModel::trace( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp index 857d6a4b01..688b30350a 100644 --- a/fxjs/xfa/cjx_model.cpp +++ b/fxjs/xfa/cjx_model.cpp @@ -28,7 +28,7 @@ CJX_Model::~CJX_Model() {} CJS_Return CJX_Model::clearErrorList( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Model::createNode( diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp index a07aa4cb2c..7c472db6c9 100644 --- a/fxjs/xfa/cjx_node.cpp +++ b/fxjs/xfa/cjx_node.cpp @@ -117,7 +117,7 @@ CJS_Return CJX_Node::applyXSL(CFX_V8* runtime, return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); // TODO(weili): check whether we need to implement this, pdfium:501. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Node::assignNode( @@ -127,7 +127,7 @@ CJS_Return CJX_Node::assignNode( return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); // TODO(weili): check whether we need to implement this, pdfium:501. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Node::clone(CFX_V8* runtime, @@ -206,7 +206,7 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime, ByteString expression = runtime->ToByteString(params[0]); if (expression.IsEmpty()) - return CJS_Return(true); + return CJS_Return(); bool bIgnoreRoot = true; if (params.size() >= 2) @@ -218,11 +218,11 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime, auto pParser = pdfium::MakeUnique<CXFA_DocumentParser>(GetDocument()); if (!pParser) - return CJS_Return(true); + return CJS_Return(); CFX_XMLNode* pXMLNode = pParser->ParseXMLData(expression); if (!pXMLNode) - return CJS_Return(true); + return CJS_Return(); if (bIgnoreRoot && (pXMLNode->GetType() != FX_XMLNODE_Element || @@ -278,7 +278,7 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime, pParser->ConstructXFANode(pFakeRoot, pFakeXMLRoot); pFakeRoot = pParser->GetRootNode(); if (!pFakeRoot) - return CJS_Return(true); + return CJS_Return(); if (bOverwrite) { CXFA_Node* pChild = GetXFANode()->GetFirstChild(); @@ -326,14 +326,14 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime, } pFakeRoot->SetFlag(XFA_NodeFlag_HasRemovedChildren); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Node::saveFilteredXML( CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { // TODO(weili): Check whether we need to implement this, pdfium:501. - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Node::saveXML(CFX_V8* runtime, @@ -383,7 +383,7 @@ CJS_Return CJX_Node::setAttribute( WideString attributeValue = runtime->ToWideString(params[0]); WideString attribute = runtime->ToWideString(params[1]); SetAttribute(attribute.AsStringView(), attributeValue.AsStringView(), true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Node::setElement( @@ -393,7 +393,7 @@ CJS_Return CJX_Node::setElement( return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); // TODO(weili): check whether we need to implement this, pdfium:501. - return CJS_Return(true); + return CJS_Return(); } void CJX_Node::id(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index ba914221bd..d357c56091 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -172,7 +172,8 @@ CJS_Return CJX_Object::RunMethod( const std::vector<v8::Local<v8::Value>>& params) { auto it = method_specs_.find(func.UTF8Encode()); if (it == method_specs_.end()) - return CJS_Return(false); + return CJS_Return(JSMessage::kUnknownMethod); + return it->second(this, GetXFAObject()->GetDocument()->GetScriptContext(), params); } diff --git a/fxjs/xfa/cjx_signaturepseudomodel.cpp b/fxjs/xfa/cjx_signaturepseudomodel.cpp index 304177884b..0e4d560da3 100644 --- a/fxjs/xfa/cjx_signaturepseudomodel.cpp +++ b/fxjs/xfa/cjx_signaturepseudomodel.cpp @@ -47,7 +47,7 @@ CJS_Return CJX_SignaturePseudoModel::enumerate( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_SignaturePseudoModel::clear( diff --git a/fxjs/xfa/cjx_source.cpp b/fxjs/xfa/cjx_source.cpp index 7576e7718d..98772b5acf 100644 --- a/fxjs/xfa/cjx_source.cpp +++ b/fxjs/xfa/cjx_source.cpp @@ -41,7 +41,7 @@ CJS_Return CJX_Source::next(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::cancelBatch( @@ -49,14 +49,14 @@ CJS_Return CJX_Source::cancelBatch( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::first(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::updateBatch( @@ -64,7 +64,7 @@ CJS_Return CJX_Source::updateBatch( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::previous( @@ -72,42 +72,42 @@ CJS_Return CJX_Source::previous( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::isBOF(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::isEOF(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::cancel(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::update(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::open(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::deleteItem( @@ -115,14 +115,14 @@ CJS_Return CJX_Source::deleteItem( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::addNew(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::requery( @@ -130,28 +130,28 @@ CJS_Return CJX_Source::requery( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::resync(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::close(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::last(CFX_V8* runtime, const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Source::hasDataChanged( @@ -159,7 +159,7 @@ CJS_Return CJX_Source::hasDataChanged( const std::vector<v8::Local<v8::Value>>& params) { if (!params.empty()) return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); - return CJS_Return(true); + return CJS_Return(); } void CJX_Source::db(CFXJSE_Value* pValue, diff --git a/fxjs/xfa/cjx_subform.cpp b/fxjs/xfa/cjx_subform.cpp index 52f08655ca..042bd85119 100644 --- a/fxjs/xfa/cjx_subform.cpp +++ b/fxjs/xfa/cjx_subform.cpp @@ -36,7 +36,7 @@ CJS_Return CJX_Subform::execEvent( execSingleEventByName(runtime->ToWideString(params[0]).AsStringView(), XFA_Element::Subform); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Subform::execInitialize( @@ -49,7 +49,7 @@ CJS_Return CJX_Subform::execInitialize( if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Initialize, false, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Subform::execCalculate( @@ -62,7 +62,7 @@ CJS_Return CJX_Subform::execCalculate( if (pNotify) pNotify->ExecEventByDeepFirst(GetXFANode(), XFA_EVENT_Calculate, false, true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Subform::execValidate( diff --git a/fxjs/xfa/cjx_template.cpp b/fxjs/xfa/cjx_template.cpp index 6612a7c5c2..0b9c3b2472 100644 --- a/fxjs/xfa/cjx_template.cpp +++ b/fxjs/xfa/cjx_template.cpp @@ -42,7 +42,7 @@ CJS_Return CJX_Template::remerge( return CJS_Return(JSGetStringFromID(JSMessage::kParamError)); GetDocument()->DoDataRemerge(true); - return CJS_Return(true); + return CJS_Return(); } CJS_Return CJX_Template::execInitialize( diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp index 219953d1d4..442a82d1e6 100644 --- a/fxjs/xfa/cjx_tree.cpp +++ b/fxjs/xfa/cjx_tree.cpp @@ -38,7 +38,7 @@ CJS_Return CJX_Tree::resolveNode( WideString expression = runtime->ToWideString(params[0]); CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return(true); + return CJS_Return(); CXFA_Object* refNode = GetXFAObject(); if (refNode->GetElementType() == XFA_Element::Xfa) @@ -90,7 +90,7 @@ CJS_Return CJX_Tree::resolveNodes( CFXJSE_Engine* pScriptContext = GetDocument()->GetScriptContext(); if (!pScriptContext) - return CJS_Return(true); + return CJS_Return(); auto pValue = pdfium::MakeUnique<CFXJSE_Value>(pScriptContext->GetIsolate()); ResolveNodeList(pValue.get(), runtime->ToWideString(params[0]), diff --git a/fxjs/xfa/cjx_treelist.cpp b/fxjs/xfa/cjx_treelist.cpp index 904e09370f..b608734e3c 100644 --- a/fxjs/xfa/cjx_treelist.cpp +++ b/fxjs/xfa/cjx_treelist.cpp @@ -37,7 +37,7 @@ CJS_Return CJX_TreeList::namedItem( CXFA_Node* pNode = GetXFATreeList()->NamedItem( runtime->ToWideString(params[0]).AsStringView()); if (!pNode) - return CJS_Return(true); + return CJS_Return(); CFXJSE_Value* value = GetDocument()->GetScriptContext()->GetJSValueFromMap(pNode); |