summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-30 21:19:42 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-10-30 21:19:42 +0000
commitd6e9cfaab0555c34783dd05261329866b4da1b9f (patch)
treef123e3ee82017c1e14a07306f54381ea9bf2966c
parentcaee9596e926a41a23fa0ddebd10d509db4b23ab (diff)
downloadpdfium-d6e9cfaab0555c34783dd05261329866b4da1b9f.tar.xz
Convert JS resource into enum classchromium/3254
This CL converts the #defines into an enum class. Change-Id: I895e29e1d46a7a82d7be896f5776eb00d28559f5 Reviewed-on: https://pdfium-review.googlesource.com/17091 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--fxjs/cjs_annot.cpp12
-rw-r--r--fxjs/cjs_app.cpp26
-rw-r--r--fxjs/cjs_document.cpp128
-rw-r--r--fxjs/cjs_event_context.cpp6
-rw-r--r--fxjs/cjs_field.cpp4
-rw-r--r--fxjs/cjs_global.cpp4
-rw-r--r--fxjs/cjs_publicmethods.cpp60
-rw-r--r--fxjs/cjs_util.cpp22
-rw-r--r--fxjs/js_resources.cpp48
-rw-r--r--fxjs/js_resources.h44
10 files changed, 179 insertions, 175 deletions
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp
index f4f9669eff..62fdfb8b76 100644
--- a/fxjs/cjs_annot.cpp
+++ b/fxjs/cjs_annot.cpp
@@ -46,7 +46,7 @@ Annot::~Annot() {}
CJS_Return Annot::get_hidden(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
CPDF_Annot* pPDFAnnot = ToBAAnnot(m_pAnnot.Get())->GetPDFAnnot();
return CJS_Return(pRuntime->NewBoolean(
@@ -57,7 +57,7 @@ CJS_Return Annot::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
// May invalidate m_pAnnot.
bool bHidden = pRuntime->ToBoolean(vp);
if (!m_pAnnot)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
uint32_t flags = ToBAAnnot(m_pAnnot.Get())->GetFlags();
if (bHidden) {
@@ -78,7 +78,7 @@ CJS_Return Annot::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_Return Annot::get_name(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(
pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str()));
}
@@ -87,7 +87,7 @@ CJS_Return 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(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
ToBAAnnot(m_pAnnot.Get())->SetAnnotName(annotName);
return CJS_Return(true);
@@ -95,7 +95,7 @@ CJS_Return Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_Return Annot::get_type(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewString(
WideString::FromLocal(CPDF_Annot::AnnotSubtypeToString(
ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype())
@@ -104,7 +104,7 @@ CJS_Return Annot::get_type(CJS_Runtime* pRuntime) {
}
CJS_Return Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) {
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index f013e7eaa8..e89fb2a2c7 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -224,7 +224,7 @@ CJS_Return app::alert(CJS_Runtime* pRuntime,
pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle");
if (!IsTypeKnown(newParams[0]))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
if (!pFormFillEnv)
@@ -257,7 +257,7 @@ CJS_Return app::alert(CJS_Runtime* pRuntime,
if (IsTypeKnown(newParams[3]))
swTitle = pRuntime->ToWideString(newParams[3]);
else
- swTitle = JSGetStringFromID(IDS_STRING_JSALERT);
+ swTitle = JSGetStringFromID(JSMessage::kAlert);
pRuntime->BeginBlock();
pFormFillEnv->KillFocusAnnot(0);
@@ -275,7 +275,7 @@ CJS_Return app::beep(CJS_Runtime* pRuntime,
pRuntime->GetFormFillEnv()->JS_appBeep(pRuntime->ToInt32(params[0]));
return CJS_Return(true);
}
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
}
CJS_Return app::findComponent(CJS_Runtime* pRuntime,
@@ -299,12 +299,12 @@ CJS_Return app::set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_Return app::setInterval(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() > 2 || params.size() == 0)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
WideString script =
params.size() > 0 ? pRuntime->ToWideString(params[0]) : L"";
if (script.IsEmpty())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE));
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
uint32_t dwInterval = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000;
GlobalTimer* timerRef = new GlobalTimer(this, pRuntime->GetFormFillEnv(),
@@ -327,11 +327,11 @@ CJS_Return app::setInterval(CJS_Runtime* pRuntime,
CJS_Return app::setTimeOut(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() > 2 || params.size() == 0)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
WideString script = pRuntime->ToWideString(params[0]);
if (script.IsEmpty())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE));
+ return CJS_Return(JSGetStringFromID(JSMessage::kInvalidInputError));
uint32_t dwTimeOut = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000;
GlobalTimer* timerRef =
@@ -355,7 +355,7 @@ CJS_Return app::setTimeOut(CJS_Runtime* pRuntime,
CJS_Return app::clearTimeOut(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
app::ClearTimerCommon(pRuntime, params[0]);
return CJS_Return(true);
@@ -364,7 +364,7 @@ CJS_Return app::clearTimeOut(CJS_Runtime* pRuntime,
CJS_Return app::clearInterval(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
app::ClearTimerCommon(pRuntime, params[0]);
return CJS_Return(true);
@@ -434,7 +434,7 @@ CJS_Return app::mailMsg(CJS_Runtime* pRuntime,
L"cSubject", L"cMsg");
if (!IsTypeKnown(newParams[0]))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
bool bUI = pRuntime->ToBoolean(newParams[0]);
WideString cTo;
@@ -443,7 +443,7 @@ CJS_Return app::mailMsg(CJS_Runtime* pRuntime,
} else {
// cTo parameter required when UI not invoked.
if (!bUI)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
}
WideString cCc;
@@ -531,7 +531,7 @@ CJS_Return app::response(CJS_Runtime* pRuntime,
L"cDefault", L"bPassword", L"cLabel");
if (!IsTypeKnown(newParams[0]))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
WideString swQuestion = pRuntime->ToWideString(newParams[0]);
WideString swTitle = L"PDF";
@@ -557,7 +557,7 @@ CJS_Return app::response(CJS_Runtime* pRuntime,
bPassword, pBuff.data(), MAX_INPUT_BYTES);
if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamTooLongError));
return CJS_Return(pRuntime->NewString(
WideString::FromUTF16LE(reinterpret_cast<uint16_t*>(pBuff.data()),
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index 5383c9e45e..862055a7ff 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -142,7 +142,7 @@ Document::~Document() {}
// The total number of fields in document.
CJS_Return Document::get_num_fields(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
@@ -152,18 +152,18 @@ CJS_Return Document::get_num_fields(CJS_Runtime* pRuntime) {
CJS_Return Document::set_num_fields(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Document::get_dirty(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
}
CJS_Return Document::set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
pRuntime->ToBoolean(vp) ? m_pFormFillEnv->SetChangeMark()
: m_pFormFillEnv->ClearChangeMark();
@@ -180,7 +180,7 @@ CJS_Return Document::set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_Return Document::get_page_num(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView();
if (!pPageView)
@@ -191,7 +191,7 @@ CJS_Return Document::get_page_num(CJS_Runtime* pRuntime) {
CJS_Return Document::set_page_num(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
int iPageCount = m_pFormFillEnv->GetPageCount();
int iPageNum = pRuntime->ToInt32(vp);
@@ -241,9 +241,9 @@ CJS_Return Document::exportAsXFDF(
CJS_Return Document::getField(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
WideString wideName = pRuntime->ToWideString(params[0]);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
@@ -271,13 +271,13 @@ CJS_Return Document::getNthFieldName(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
int nIndex = pRuntime->ToInt32(params[0]);
if (nIndex < 0)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
@@ -314,9 +314,9 @@ CJS_Return Document::importTextData(
CJS_Return Document::mailForm(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+ return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
int iLength = params.size();
bool bUI = iLength > 0 ? pRuntime->ToBoolean(params[0]) : true;
@@ -347,7 +347,7 @@ CJS_Return Document::mailForm(CJS_Runtime* pRuntime,
CJS_Return Document::print(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
bool bUI = true;
int nStart = 0;
@@ -416,13 +416,13 @@ CJS_Return Document::removeField(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM)))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+ return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
WideString sFieldName = pRuntime->ToWideString(params[0]);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
@@ -470,11 +470,11 @@ CJS_Return Document::resetForm(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+ return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
}
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
@@ -526,9 +526,9 @@ CJS_Return Document::submitForm(
const std::vector<v8::Local<v8::Value>>& params) {
int nSize = params.size();
if (nSize < 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
v8::Local<v8::Array> aFields;
WideString strURL;
@@ -653,7 +653,7 @@ CJS_Return Document::set_author(CJS_Runtime* pRuntime,
CJS_Return Document::get_info(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
const auto* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
@@ -711,13 +711,13 @@ CJS_Return Document::get_info(CJS_Runtime* pRuntime) {
}
CJS_Return Document::set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Document::getPropertyInternal(CJS_Runtime* pRuntime,
const ByteString& propName) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
@@ -730,14 +730,14 @@ CJS_Return Document::setPropertyInternal(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp,
const ByteString& propName) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
return CJS_Return(false);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+ return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
WideString csProperty = pRuntime->ToWideString(vp);
pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty),
@@ -766,15 +766,15 @@ CJS_Return Document::set_creator(CJS_Runtime* pRuntime,
CJS_Return Document::get_delay(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewBoolean(m_bDelay));
}
CJS_Return Document::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+ return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
m_bDelay = pRuntime->ToBoolean(vp);
if (m_bDelay) {
@@ -828,25 +828,25 @@ CJS_Return Document::set_subject(CJS_Runtime* pRuntime,
CJS_Return Document::get_title(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return getPropertyInternal(pRuntime, "Title");
}
CJS_Return Document::set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return setPropertyInternal(pRuntime, vp, "Title");
}
CJS_Return Document::get_num_pages(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
}
CJS_Return Document::set_num_pages(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Document::get_external(CJS_Runtime* pRuntime) {
@@ -865,7 +865,7 @@ CJS_Return Document::get_filesize(CJS_Runtime* pRuntime) {
CJS_Return Document::set_filesize(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Document::get_mouse_x(CJS_Runtime* pRuntime) {
@@ -888,13 +888,13 @@ CJS_Return Document::set_mouse_y(CJS_Runtime* pRuntime,
CJS_Return Document::get_URL(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(
pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str()));
}
CJS_Return Document::set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Document::get_base_URL(CJS_Runtime* pRuntime) {
@@ -909,7 +909,7 @@ CJS_Return Document::set_base_URL(CJS_Runtime* pRuntime,
CJS_Return Document::get_calculate(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
return CJS_Return(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
@@ -918,7 +918,7 @@ CJS_Return Document::get_calculate(CJS_Runtime* pRuntime) {
CJS_Return Document::set_calculate(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
pInterForm->EnableCalculate(pRuntime->ToBoolean(vp));
@@ -927,7 +927,7 @@ CJS_Return Document::set_calculate(CJS_Runtime* pRuntime,
CJS_Return Document::get_document_file_name(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath();
size_t i = wsFilePath.GetLength();
@@ -945,18 +945,18 @@ CJS_Return Document::get_document_file_name(CJS_Runtime* pRuntime) {
CJS_Return Document::set_document_file_name(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Document::get_path(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewString(
app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str()));
}
CJS_Return Document::set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Document::get_page_window_rect(CJS_Runtime* pRuntime) {
@@ -996,9 +996,9 @@ CJS_Return Document::getPageBox(
CJS_Return Document::getAnnot(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
int nPageNo = pRuntime->ToInt32(params[0]);
WideString swAnnotName = pRuntime->ToWideString(params[1]);
@@ -1039,7 +1039,7 @@ CJS_Return Document::getAnnots(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
// TODO(tonikitoo): Add support supported parameters as per
// the PDF spec.
@@ -1054,7 +1054,7 @@ CJS_Return Document::getAnnots(
CPDFSDK_AnnotIteration annotIteration(pPageView, false);
for (const auto& pSDKAnnotCur : annotIteration) {
if (!pSDKAnnotCur)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Annot::GetObjDefnID());
@@ -1104,20 +1104,20 @@ bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) {
CJS_Return Document::addIcon(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
WideString swIconName = pRuntime->ToWideString(params[0]);
if (!params[1]->IsObject())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
v8::Local<v8::Object> pJSIcon = pRuntime->ToObject(params[1]);
if (CFXJS_Engine::GetObjDefnID(pJSIcon) != CJS_Icon::GetObjDefnID())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]);
CJS_Object* obj = static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(pObj));
if (!obj->GetEmbedObject())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
m_IconNames.push_back(swIconName);
return CJS_Return(true);
@@ -1148,13 +1148,13 @@ CJS_Return Document::get_icons(CJS_Runtime* pRuntime) {
}
CJS_Return Document::set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Document::getIcon(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
WideString swIconName = pRuntime->ToWideString(params[0]);
auto it = std::find(m_IconNames.begin(), m_IconNames.end(), swIconName);
@@ -1201,12 +1201,12 @@ CJS_Return Document::calculateNow(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+ return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
}
m_pFormFillEnv->GetInterForm()->OnCalculate();
@@ -1226,9 +1226,9 @@ CJS_Return Document::getPageNthWord(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+ return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
// TODO(tsepez): check maximum allowable params.
@@ -1241,7 +1241,7 @@ CJS_Return Document::getPageNthWord(
return CJS_Return(false);
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
if (!pPageDict)
@@ -1275,9 +1275,9 @@ CJS_Return Document::getPageNthWordQuads(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(false);
}
@@ -1285,14 +1285,14 @@ CJS_Return Document::getPageNumWords(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+ return CJS_Return(JSGetStringFromID(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(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
if (!pPageDict)
@@ -1449,9 +1449,9 @@ CJS_Return Document::gotoNamedDest(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
WideString wideName = pRuntime->ToWideString(params[0]);
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
diff --git a/fxjs/cjs_event_context.cpp b/fxjs/cjs_event_context.cpp
index bc908a5db2..d2f270b1c4 100644
--- a/fxjs/cjs_event_context.cpp
+++ b/fxjs/cjs_event_context.cpp
@@ -32,7 +32,7 @@ bool CJS_EventContext::RunScript(const WideString& script, WideString* info) {
v8::Context::Scope context_scope(context);
if (m_bBusy) {
- *info = JSGetStringFromID(IDS_STRING_JSBUSY);
+ *info = JSGetStringFromID(JSMessage::kBusyError);
return false;
}
@@ -43,7 +43,7 @@ bool CJS_EventContext::RunScript(const WideString& script, WideString* info) {
CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(),
m_pEventHandler->EventType());
if (!m_pRuntime->AddEventToSet(event)) {
- *info = JSGetStringFromID(IDS_STRING_JSEVENT);
+ *info = JSGetStringFromID(JSMessage::kDuplicateEventError);
return false;
}
@@ -55,7 +55,7 @@ bool CJS_EventContext::RunScript(const WideString& script, WideString* info) {
if (nRet < 0)
*info += sErrorMessage;
else
- *info = JSGetStringFromID(IDS_STRING_RUN);
+ *info = JSGetStringFromID(JSMessage::kRunSuccess);
m_pRuntime->RemoveEventFromSet(event);
m_pEventHandler->Destroy();
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 51f8c5aafc..cb8eb6bfcb 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -1418,7 +1418,7 @@ CJS_Return Field::get_page(CJS_Runtime* pRuntime) {
int i = 0;
for (const auto& pObserved : widgets) {
if (!pObserved)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
auto* pWidget = static_cast<CPDFSDK_Widget*>(pObserved.Get());
CPDFSDK_PageView* pPageView = pWidget->GetPageView();
@@ -1434,7 +1434,7 @@ CJS_Return Field::get_page(CJS_Runtime* pRuntime) {
}
CJS_Return Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
+ return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
CJS_Return Field::get_password(CJS_Runtime* pRuntime) {
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 3c5c51b794..0fef8d5334 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -346,12 +346,12 @@ CJS_Return JSGlobalAlternate::setPersistent(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(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(IDS_STRING_JSNOGLOBAL));
+ return CJS_Return(JSGetStringFromID(JSMessage::kGlobalNotFoundError));
it->second->bPersistent = pRuntime->ToBoolean(params[1]);
return CJS_Return(true);
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 8c5ab07a2e..8bcfd3c39b 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -814,7 +814,7 @@ 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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -950,7 +950,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Keystroke(
swTemp.Replace(L",", L".");
if (!IsNumber(swTemp.c_str())) {
pEvent->Rc() = false;
- WideString sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE);
+ WideString sError = JSGetStringFromID(JSMessage::kInvalidInputError);
AlertIfPossible(pContext, sError.c_str());
return CJS_Return(sError);
}
@@ -1028,7 +1028,7 @@ 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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -1124,7 +1124,7 @@ 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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
@@ -1149,7 +1149,7 @@ CJS_Return CJS_PublicMethods::AFDate_FormatEx(
if (std::isnan(dDate)) {
WideString swMsg;
- swMsg.Format(JSGetStringFromID(IDS_STRING_JSPARSEDATE).c_str(),
+ swMsg.Format(JSGetStringFromID(JSMessage::kParseDateError).c_str(),
sFormat.c_str());
AlertIfPossible(pContext, swMsg.c_str());
return CJS_Return(false);
@@ -1237,7 +1237,7 @@ CJS_Return CJS_PublicMethods::AFDate_KeystrokeEx(
double dRet = MakeRegularDate(strValue, sFormat, &bWrongFormat);
if (bWrongFormat || std::isnan(dRet)) {
WideString swMsg;
- swMsg.Format(JSGetStringFromID(IDS_STRING_JSPARSEDATE).c_str(),
+ swMsg.Format(JSGetStringFromID(JSMessage::kParseDateError).c_str(),
sFormat.c_str());
AlertIfPossible(pContext, swMsg.c_str());
pEvent->Rc() = false;
@@ -1251,7 +1251,7 @@ 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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
int iIndex = pRuntime->ToInt32(params[0]);
const wchar_t* cFormats[] = {L"m/d",
@@ -1282,7 +1282,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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
int iIndex = pRuntime->ToInt32(params[0]);
const wchar_t* cFormats[] = {L"m/d",
@@ -1313,7 +1313,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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
int iIndex = pRuntime->ToInt32(params[0]);
const wchar_t* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
@@ -1331,7 +1331,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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
int iIndex = pRuntime->ToInt32(params[0]);
const wchar_t* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
@@ -1362,7 +1362,7 @@ 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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -1398,7 +1398,7 @@ 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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
@@ -1422,8 +1422,8 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx(
if (iIndexMask != wstrMask.GetLength() ||
(iIndexMask != valEvent.GetLength() && wstrMask.GetLength() != 0)) {
- AlertIfPossible(
- pContext, JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
+ AlertIfPossible(pContext,
+ JSGetStringFromID(JSMessage::kInvalidInputError).c_str());
pEvent->Rc() = false;
}
return CJS_Return(true);
@@ -1439,14 +1439,14 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx(
pEvent->SelStart() - pEvent->SelEnd();
if (combined_len > wstrMask.GetLength()) {
AlertIfPossible(pContext,
- JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str());
+ JSGetStringFromID(JSMessage::kParamTooLongError).c_str());
pEvent->Rc() = false;
return CJS_Return(true);
}
if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
AlertIfPossible(pContext,
- JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str());
+ JSGetStringFromID(JSMessage::kParamTooLongError).c_str());
pEvent->Rc() = false;
return CJS_Return(true);
}
@@ -1454,7 +1454,7 @@ CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx(
for (size_t i = 0; i < wChange.GetLength(); ++i) {
if (iIndexMask >= wstrMask.GetLength()) {
AlertIfPossible(pContext,
- JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str());
+ JSGetStringFromID(JSMessage::kParamTooLongError).c_str());
pEvent->Rc() = false;
return CJS_Return(true);
}
@@ -1477,7 +1477,7 @@ 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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -1512,7 +1512,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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CJS_EventHandler* pEventHandler =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -1546,14 +1546,14 @@ CJS_Return CJS_PublicMethods::AFParseDateEx(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
WideString sValue = pRuntime->ToWideString(params[0]);
WideString sFormat = pRuntime->ToWideString(params[1]);
double dDate = MakeRegularDate(sValue, sFormat, nullptr);
if (std::isnan(dDate)) {
WideString swMsg;
- swMsg.Format(JSGetStringFromID(IDS_STRING_JSPARSEDATE).c_str(),
+ swMsg.Format(JSGetStringFromID(JSMessage::kParseDateError).c_str(),
sFormat.c_str());
AlertIfPossible(pRuntime->GetCurrentEventContext(), swMsg.c_str());
return CJS_Return(false);
@@ -1565,7 +1565,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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
return CJS_Return(pRuntime->NewNumber(static_cast<double>(AF_Simple(
pRuntime->ToWideString(params[0]).c_str(), pRuntime->ToDouble(params[1]),
@@ -1576,7 +1576,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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
WideString ws = pRuntime->ToWideString(params[0]);
ws.Replace(L",", L".");
@@ -1592,10 +1592,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(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if ((params[1].IsEmpty() || !params[1]->IsArray()) && !params[1]->IsString())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CPDFSDK_InterForm* pReaderInterForm =
pRuntime->GetFormFillEnv()->GetInterForm();
@@ -1687,7 +1687,7 @@ CJS_Return CJS_PublicMethods::AFRange_Validate(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 4)
- CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ CJS_Return(JSGetStringFromID(JSMessage::kParamError));
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
@@ -1706,16 +1706,16 @@ CJS_Return CJS_PublicMethods::AFRange_Validate(
if (bGreaterThan && bLessThan) {
if (dEentValue < dGreaterThan || dEentValue > dLessThan)
- swMsg.Format(JSGetStringFromID(IDS_STRING_JSRANGE1).c_str(),
+ swMsg.Format(JSGetStringFromID(JSMessage::kRangeBetweenError).c_str(),
pRuntime->ToWideString(params[1]).c_str(),
pRuntime->ToWideString(params[3]).c_str());
} else if (bGreaterThan) {
if (dEentValue < dGreaterThan)
- swMsg.Format(JSGetStringFromID(IDS_STRING_JSRANGE2).c_str(),
+ swMsg.Format(JSGetStringFromID(JSMessage::kRangeGreaterError).c_str(),
pRuntime->ToWideString(params[1]).c_str());
} else if (bLessThan) {
if (dEentValue > dLessThan)
- swMsg.Format(JSGetStringFromID(IDS_STRING_JSRANGE3).c_str(),
+ swMsg.Format(JSGetStringFromID(JSMessage::kRangeLessError).c_str(),
pRuntime->ToWideString(params[3]).c_str());
}
@@ -1730,7 +1730,7 @@ CJS_Return CJS_PublicMethods::AFExtractNums(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
WideString str = pRuntime->ToWideString(params[0]);
if (str.GetLength() > 0 && (str[0] == L'.' || str[0] == L','))
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 7a80700e7d..9fc1093158 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -144,11 +144,13 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
return CJS_Return(false);
if (params[1].IsEmpty() || !params[1]->IsDate())
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPRINT1));
+ return CJS_Return(JSGetStringFromID(JSMessage::kSecondParamNotDateError));
v8::Local<v8::Date> v8_date = params[1].As<v8::Date>();
- if (v8_date.IsEmpty() || std::isnan(pRuntime->ToDouble(v8_date)))
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPRINT2));
+ if (v8_date.IsEmpty() || std::isnan(pRuntime->ToDouble(v8_date))) {
+ return CJS_Return(
+ JSGetStringFromID(JSMessage::kSecondParamInvalidDateError));
+ }
double date = JS_LocalTime(pRuntime->ToDouble(v8_date));
int year = JS_GetYearFromTime(date);
@@ -174,7 +176,7 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
hour, min, sec);
break;
default:
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
}
return CJS_Return(pRuntime->NewString(swResult.c_str()));
@@ -183,7 +185,7 @@ CJS_Return 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(IDS_STRING_JSNOTSUPPORT));
+ return CJS_Return(JSGetStringFromID(JSMessage::kNotSupportedError));
// Convert PDF-style format specifiers to wcsftime specifiers. Remove any
// pre-existing %-directives before inserting our own.
@@ -204,7 +206,7 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
}
if (year < 0)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
static const TbConvertAdditional cTableAd[] = {
{L"m", month}, {L"d", day},
@@ -244,13 +246,13 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
return CJS_Return(pRuntime->NewString(cFormat.c_str()));
}
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
}
CJS_Return util::printx(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
return CJS_Return(
pRuntime->NewString(printx(pRuntime->ToWideString(params[0]),
@@ -375,11 +377,11 @@ CJS_Return util::scand(CJS_Runtime* pRuntime,
CJS_Return util::byteToChar(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 1)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
int arg = pRuntime->ToInt32(params[0]);
if (arg < 0 || arg > 255)
- return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
+ return CJS_Return(JSGetStringFromID(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 c7ed06f274..b23103ab76 100644
--- a/fxjs/js_resources.cpp
+++ b/fxjs/js_resources.cpp
@@ -6,52 +6,52 @@
#include "fxjs/js_resources.h"
-WideString JSGetStringFromID(uint32_t id) {
- switch (id) {
- case IDS_STRING_JSALERT:
+WideString JSGetStringFromID(JSMessage msg) {
+ switch (msg) {
+ case JSMessage::kAlert:
return L"Alert";
- case IDS_STRING_JSPARAMERROR:
+ case JSMessage::kParamError:
return L"Incorrect number of parameters passed to function.";
- case IDS_STRING_JSAFNUMBER_KEYSTROKE:
+ case JSMessage::kInvalidInputError:
return L"The input value is invalid.";
- case IDS_STRING_JSPARAM_TOOLONG:
+ case JSMessage::kParamTooLongError:
return L"The input value is too long.";
- case IDS_STRING_JSPARSEDATE:
+ case JSMessage::kParseDateError:
return L"The input value can't be parsed as a valid date/time (%s).";
- case IDS_STRING_JSRANGE1:
+ case JSMessage::kRangeBetweenError:
return L"The input value must be greater than or equal to %s"
L" and less than or equal to %s.";
- case IDS_STRING_JSRANGE2:
+ case JSMessage::kRangeGreaterError:
return L"The input value must be greater than or equal to %s.";
- case IDS_STRING_JSRANGE3:
+ case JSMessage::kRangeLessError:
return L"The input value must be less than or equal to %s.";
- case IDS_STRING_JSNOTSUPPORT:
+ case JSMessage::kNotSupportedError:
return L"Operation not supported.";
- case IDS_STRING_JSBUSY:
+ case JSMessage::kBusyError:
return L"System is busy.";
- case IDS_STRING_JSEVENT:
+ case JSMessage::kDuplicateEventError:
return L"Duplicate formfield event found.";
- case IDS_STRING_RUN:
+ case JSMessage::kRunSuccess:
return L"Script ran successfully.";
- case IDS_STRING_JSPRINT1:
+ case JSMessage::kSecondParamNotDateError:
return L"The second parameter can't be converted to a Date.";
- case IDS_STRING_JSPRINT2:
+ case JSMessage::kSecondParamInvalidDateError:
return L"The second parameter is an invalid Date!";
- case IDS_STRING_JSNOGLOBAL:
+ case JSMessage::kGlobalNotFoundError:
return L"Global value not found.";
- case IDS_STRING_JSREADONLY:
+ case JSMessage::kReadOnlyError:
return L"Cannot assign to readonly property.";
- case IDS_STRING_JSTYPEERROR:
+ case JSMessage::kTypeError:
return L"Incorrect parameter type.";
- case IDS_STRING_JSVALUEERROR:
+ case JSMessage::kValueError:
return L"Incorrect parameter value.";
- case IDS_STRING_JSNOPERMISSION:
+ case JSMessage::kPermissionError:
return L"Permission denied.";
- case IDS_STRING_JSBADOBJECT:
+ case JSMessage::kBadObjectError:
return L"Object no longer exists.";
- default:
- return L"";
}
+ NOTREACHED();
+ return L"";
}
WideString JSFormatErrorString(const char* class_name,
diff --git a/fxjs/js_resources.h b/fxjs/js_resources.h
index 9f655487ba..728ec22126 100644
--- a/fxjs/js_resources.h
+++ b/fxjs/js_resources.h
@@ -9,28 +9,30 @@
#include "core/fxcrt/widestring.h"
-#define IDS_STRING_JSALERT 25613
-#define IDS_STRING_JSPARAMERROR 25614
-#define IDS_STRING_JSAFNUMBER_KEYSTROKE 25615
-#define IDS_STRING_JSPARAM_TOOLONG 25617
-#define IDS_STRING_JSPARSEDATE 25618
-#define IDS_STRING_JSRANGE1 25619
-#define IDS_STRING_JSRANGE2 25620
-#define IDS_STRING_JSRANGE3 25621
-#define IDS_STRING_JSNOTSUPPORT 25627
-#define IDS_STRING_JSBUSY 25628
-#define IDS_STRING_JSEVENT 25629
-#define IDS_STRING_RUN 25630
-#define IDS_STRING_JSPRINT1 25632
-#define IDS_STRING_JSPRINT2 25633
-#define IDS_STRING_JSNOGLOBAL 25635
-#define IDS_STRING_JSREADONLY 25636
-#define IDS_STRING_JSTYPEERROR 25637
-#define IDS_STRING_JSVALUEERROR 25638
-#define IDS_STRING_JSNOPERMISSION 25639
-#define IDS_STRING_JSBADOBJECT 25640
+enum class JSMessage {
+ kRunSuccess = 0,
+ kAlert,
+ kParamError,
+ kInvalidInputError,
+ kParamTooLongError,
+ kParseDateError,
+ kRangeBetweenError,
+ kRangeGreaterError,
+ kRangeLessError,
+ kNotSupportedError,
+ kBusyError,
+ kDuplicateEventError,
+ kSecondParamNotDateError,
+ kSecondParamInvalidDateError,
+ kGlobalNotFoundError,
+ kReadOnlyError,
+ kTypeError,
+ kValueError,
+ kPermissionError,
+ kBadObjectError
+};
-WideString JSGetStringFromID(uint32_t id);
+WideString JSGetStringFromID(JSMessage msg);
WideString JSFormatErrorString(const char* class_name,
const char* property_name,
const WideString& details);