summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-10-25 13:30:31 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-10-25 18:40:45 +0000
commit8f524d6ff9c5c5e07388438e58aca7dc39f43a1f (patch)
treeec73d24ebdfb84e0c9a254a35912edc5ab54dae7 /fpdfsdk
parent2474a3b2d9fe987dac58813771f1fa66427e124f (diff)
downloadpdfium-8f524d6ff9c5c5e07388438e58aca7dc39f43a1f.tar.xz
Refactor JS method parameters and return values.
This CL removes the out parameters from the JS methods and changes the return from a |bool| to a |CJS_Return| value. The return value holds the returned v8 object, error string and a status code. Change-Id: I82488ff0d916475d7e3c8e51ed868639806181c9 Reviewed-on: https://pdfium-review.googlesource.com/16751 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/javascript/Annot.cpp68
-rw-r--r--fpdfsdk/javascript/Annot.h22
-rw-r--r--fpdfsdk/javascript/Document.cpp1275
-rw-r--r--fpdfsdk/javascript/Document.h532
-rw-r--r--fpdfsdk/javascript/Field.cpp1577
-rw-r--r--fpdfsdk/javascript/Field.h628
-rw-r--r--fpdfsdk/javascript/Icon.cpp11
-rw-r--r--fpdfsdk/javascript/Icon.h6
-rw-r--r--fpdfsdk/javascript/JS_Define.h57
-rw-r--r--fpdfsdk/javascript/JS_Value.cpp11
-rw-r--r--fpdfsdk/javascript/JS_Value.h22
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp459
-rw-r--r--fpdfsdk/javascript/PublicMethods.h160
-rw-r--r--fpdfsdk/javascript/app.cpp453
-rw-r--r--fpdfsdk/javascript/app.h236
-rw-r--r--fpdfsdk/javascript/color.cpp165
-rw-r--r--fpdfsdk/javascript/color.h118
-rw-r--r--fpdfsdk/javascript/console.cpp35
-rw-r--r--fpdfsdk/javascript/console.h24
-rw-r--r--fpdfsdk/javascript/event.cpp278
-rw-r--r--fpdfsdk/javascript/event.h167
-rw-r--r--fpdfsdk/javascript/global.cpp185
-rw-r--r--fpdfsdk/javascript/report.cpp16
-rw-r--r--fpdfsdk/javascript/report.h12
-rw-r--r--fpdfsdk/javascript/util.cpp119
-rw-r--r--fpdfsdk/javascript/util.h30
26 files changed, 2542 insertions, 4124 deletions
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp
index a068e28008..4240bbc974 100644
--- a/fpdfsdk/javascript/Annot.cpp
+++ b/fpdfsdk/javascript/Annot.cpp
@@ -35,29 +35,20 @@ Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
Annot::~Annot() {}
-bool Annot::get_hidden(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pAnnot) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Annot::get_hidden(CJS_Runtime* pRuntime) {
+ if (!m_pAnnot)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
CPDF_Annot* pPDFAnnot = ToBAAnnot(m_pAnnot.Get())->GetPDFAnnot();
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict())));
- return true;
}
-bool Annot::set_hidden(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+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) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+ if (!m_pAnnot)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
uint32_t flags = ToBAAnnot(m_pAnnot.Get())->GetFlags();
if (bHidden) {
@@ -73,53 +64,38 @@ bool Annot::set_hidden(CJS_Runtime* pRuntime,
}
ToBAAnnot(m_pAnnot.Get())->SetFlags(flags);
- return true;
+ return CJS_Return(true);
}
-bool Annot::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- if (!m_pAnnot) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
-
- vp->Set(
+CJS_Return Annot::get_name(CJS_Runtime* pRuntime) {
+ if (!m_pAnnot)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(
pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str()));
- return true;
}
-bool Annot::set_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+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) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+ if (!m_pAnnot)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
ToBAAnnot(m_pAnnot.Get())->SetAnnotName(annotName);
- return true;
+ return CJS_Return(true);
}
-bool Annot::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- if (!m_pAnnot) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
-
- vp->Set(pRuntime->NewString(
+CJS_Return Annot::get_type(CJS_Runtime* pRuntime) {
+ if (!m_pAnnot)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(pRuntime->NewString(
WideString::FromLocal(CPDF_Annot::AnnotSubtypeToString(
ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype())
.c_str())
.c_str()));
- return true;
}
-bool Annot::set_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) {
diff --git a/fpdfsdk/javascript/Annot.h b/fpdfsdk/javascript/Annot.h
index 94b67622e5..b7c951b310 100644
--- a/fpdfsdk/javascript/Annot.h
+++ b/fpdfsdk/javascript/Annot.h
@@ -15,20 +15,14 @@ class Annot : public CJS_EmbedObj {
explicit Annot(CJS_Object* pJSObject);
~Annot() override;
- bool get_hidden(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_hidden(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
+ CJS_Return get_hidden(CJS_Runtime* pRuntime);
+ CJS_Return set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_name(CJS_Runtime* pRuntime);
+ CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_type(CJS_Runtime* pRuntime);
+ CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
void SetSDKAnnot(CPDFSDK_BAAnnot* annot);
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 2217f448f2..fbd7763201 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -161,88 +161,59 @@ Document::Document(CJS_Object* pJSObject)
Document::~Document() {}
-// the total number of fields in document.
-bool Document::get_num_fields(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+// 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));
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- vp->Set(pRuntime->NewNumber(
+ return CJS_Return(pRuntime->NewNumber(
static_cast<int>(pPDFForm->CountFields(WideString()))));
- return true;
}
-bool Document::set_num_fields(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Document::set_num_fields(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Document::get_dirty(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
-
- vp->Set(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
- return true;
+CJS_Return Document::get_dirty(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
}
-bool Document::set_dirty(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Document::set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
pRuntime->ToBoolean(vp) ? m_pFormFillEnv->SetChangeMark()
: m_pFormFillEnv->ClearChangeMark();
-
- return true;
+ return CJS_Return(true);
}
-bool Document::get_ADBE(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewUndefined());
- return true;
+CJS_Return Document::get_ADBE(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewUndefined());
}
-bool Document::set_ADBE(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::get_page_num(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Document::get_page_num(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
- if (CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView())
- vp->Set(pRuntime->NewNumber(pPageView->GetPageIndex()));
- return true;
+ CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView();
+ if (!pPageView)
+ return CJS_Return(pRuntime->NewUndefined());
+ return CJS_Return(pRuntime->NewNumber(pPageView->GetPageIndex()));
}
-bool Document::set_page_num(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Document::set_page_num(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
int iPageCount = m_pFormFillEnv->GetPageCount();
int iPageNum = pRuntime->ToInt32(vp);
@@ -253,152 +224,122 @@ bool Document::set_page_num(CJS_Runtime* pRuntime,
else if (iPageNum < 0)
m_pFormFillEnv->JS_docgotoPage(0);
- return true;
+ return CJS_Return(true);
}
-bool Document::addAnnot(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::addAnnot(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::addField(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::addField(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::exportAsText(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::exportAsText(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::exportAsFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::exportAsFDF(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::exportAsXFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::exportAsXFDF(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::getField(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() < 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+
WideString wideName = pRuntime->ToWideString(params[0]);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- if (pPDFForm->CountFields(wideName) <= 0) {
- vRet.Set(pRuntime->NewUndefined());
- return true;
- }
+ if (pPDFForm->CountFields(wideName) <= 0)
+ return CJS_Return(pRuntime->NewUndefined());
v8::Local<v8::Object> pFieldObj =
pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
if (pFieldObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_Field* pJSField =
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
pField->AttachField(this, wideName);
+ if (!pJSField)
+ return CJS_Return(false);
- if (pJSField)
- vRet = CJS_Value(pJSField->ToV8Object());
- return true;
+ return CJS_Return(pJSField->ToV8Object());
}
// Gets the name of the nth field in the document
-bool Document::getNthFieldName(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+
int nIndex = pRuntime->ToInt32(params[0]);
+ if (nIndex < 0)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
- if (nIndex < 0) {
- sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
- return false;
- }
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
CPDF_FormField* pField = pPDFForm->GetField(nIndex, WideString());
if (!pField)
- return false;
-
- vRet = CJS_Value(pRuntime->NewString(pField->GetFullName().c_str()));
- return true;
+ return CJS_Return(false);
+ return CJS_Return(pRuntime->NewString(pField->GetFullName().c_str()));
}
-bool Document::importAnFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::importAnFDF(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::importAnXFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::importAnXFDF(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::importTextData(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::importTextData(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
// exports the form data and mails the resulting fdf file as an attachment to
// all recipients.
// comment: need reader supports
-bool Document::mailForm(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) {
- sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
- return false;
- }
+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));
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+
int iLength = params.size();
bool bUI = iLength > 0 ? pRuntime->ToBoolean(params[0]) : true;
WideString cTo = iLength > 1 ? pRuntime->ToWideString(params[1]) : L"";
@@ -409,7 +350,7 @@ bool Document::mailForm(CJS_Runtime* pRuntime,
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
ByteString sTextBuf = pInterForm->ExportFormToFDFTextBuf();
if (sTextBuf.GetLength() == 0)
- return false;
+ return CJS_Return(false);
size_t nBufSize = sTextBuf.GetLength();
char* pMutableBuf = FX_Alloc(char, nBufSize);
@@ -422,17 +363,14 @@ bool Document::mailForm(CJS_Runtime* pRuntime,
cMsg.c_str());
pRuntime->EndBlock();
FX_Free(pMutableBuf);
- return true;
+ return CJS_Return(true);
}
-bool Document::print(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
+
bool bUI = true;
int nStart = 0;
int nEnd = 0;
@@ -484,41 +422,36 @@ bool Document::print(CJS_Runtime* pRuntime,
bAnnotations = pRuntime->ToBoolean(params[7]);
}
- if (m_pFormFillEnv) {
- m_pFormFillEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit,
- bPrintAsImage, bReverse, bAnnotations);
- return true;
- }
- return false;
+ if (!m_pFormFillEnv)
+ return CJS_Return(false);
+
+ m_pFormFillEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit,
+ bPrintAsImage, bReverse, bAnnotations);
+ return CJS_Return(true);
}
// removes the specified field from the document.
// comment:
// note: if the filed name is not rational, adobe is dumb for it.
-bool Document::removeField(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
- m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM))) {
- sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
- return false;
- }
+ m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM)))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+
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 true;
+ return CJS_Return(true);
for (const auto& pAnnot : widgets) {
CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
@@ -548,38 +481,33 @@ bool Document::removeField(CJS_Runtime* pRuntime,
}
m_pFormFillEnv->SetChangeMark();
- return true;
+ return CJS_Return(true);
}
// reset filed values within a document.
// comment:
// note: if the fields names r not rational, aodbe is dumb for it.
-bool Document::resetForm(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
- sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
- return false;
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
}
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
- CJS_Array aName;
-
if (params.empty()) {
pPDFForm->ResetForm(true);
m_pFormFillEnv->SetChangeMark();
- return true;
+ return CJS_Return(true);
}
+ CJS_Array aName;
if (params[0]->IsString())
aName.SetElement(pRuntime, 0, params[0]);
else
@@ -597,37 +525,29 @@ bool Document::resetForm(CJS_Runtime* pRuntime,
m_pFormFillEnv->SetChangeMark();
}
- return true;
+ return CJS_Return(true);
}
-bool Document::saveAs(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::saveAs(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::syncAnnotScan(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Document::syncAnnotScan(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Document::submitForm(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::submitForm(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int nSize = params.size();
- if (nSize < 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+ if (nSize < 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
CJS_Array aFields;
WideString strURL;
@@ -661,7 +581,7 @@ bool Document::submitForm(CJS_Runtime* pRuntime,
pInterForm->SubmitForm(strURL, false);
pRuntime->EndBlock();
}
- return true;
+ return CJS_Return(true);
}
std::vector<CPDF_FormField*> fieldObjects;
@@ -682,29 +602,24 @@ bool Document::submitForm(CJS_Runtime* pRuntime,
pInterForm->SubmitFields(strURL, fieldObjects, true, !bFDF);
pRuntime->EndBlock();
}
- return true;
+ return CJS_Return(true);
}
void Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
m_pFormFillEnv.Reset(pFormFillEnv);
}
-bool Document::get_bookmark_root(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_bookmark_root(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_bookmark_root(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_bookmark_root(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::mailDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::mailDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// TODO(tsepez): Check maximum number of allowed params.
bool bUI = true;
WideString cTo = L"";
@@ -742,32 +657,25 @@ bool Document::mailDoc(CJS_Runtime* pRuntime,
pFormFillEnv->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), cSubject.c_str(),
cCc.c_str(), cBcc.c_str(), cMsg.c_str());
pRuntime->EndBlock();
- return true;
+ return CJS_Return(true);
}
-bool Document::get_author(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return getPropertyInternal(pRuntime, vp, "Author", sError);
+CJS_Return Document::get_author(CJS_Runtime* pRuntime) {
+ return getPropertyInternal(pRuntime, "Author");
}
-bool Document::set_author(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return setPropertyInternal(pRuntime, vp, "Author", sError);
+CJS_Return Document::set_author(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return setPropertyInternal(pRuntime, vp, "Author");
}
-bool Document::get_info(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Document::get_info(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
const auto* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return false;
+ return CJS_Return(false);
WideString cwAuthor = pDictionary->GetUnicodeTextFor("Author");
WideString cwTitle = pDictionary->GetUnicodeTextFor("Title");
@@ -817,111 +725,79 @@ bool Document::get_info(CJS_Runtime* pRuntime,
pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger()));
}
}
- vp->Set(pObj);
- return true;
+ return CJS_Return(pObj);
}
-bool Document::set_info(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Document::set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Document::getPropertyInternal(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- const ByteString& propName,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Document::getPropertyInternal(CJS_Runtime* pRuntime,
+ const ByteString& propName) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return false;
-
- vp->Set(
+ return CJS_Return(false);
+ return CJS_Return(
pRuntime->NewString(pDictionary->GetUnicodeTextFor(propName).c_str()));
- return true;
}
-bool Document::setPropertyInternal(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- const ByteString& propName,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return false;
+ return CJS_Return(false);
+
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
- if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) {
- *sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
- return false;
- }
WideString csProperty = pRuntime->ToWideString(vp);
pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty),
false);
m_pFormFillEnv->SetChangeMark();
- return true;
+ return CJS_Return(true);
}
-bool Document::get_creation_date(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return getPropertyInternal(pRuntime, vp, "CreationDate", sError);
+CJS_Return Document::get_creation_date(CJS_Runtime* pRuntime) {
+ return getPropertyInternal(pRuntime, "CreationDate");
}
-bool Document::set_creation_date(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return setPropertyInternal(pRuntime, vp, "CreationDate", sError);
+CJS_Return Document::set_creation_date(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return setPropertyInternal(pRuntime, vp, "CreationDate");
}
-bool Document::get_creator(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return getPropertyInternal(pRuntime, vp, "Creator", sError);
+CJS_Return Document::get_creator(CJS_Runtime* pRuntime) {
+ return getPropertyInternal(pRuntime, "Creator");
}
-bool Document::set_creator(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return setPropertyInternal(pRuntime, vp, "Creator", sError);
+CJS_Return Document::set_creator(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return setPropertyInternal(pRuntime, vp, "Creator");
}
-bool Document::get_delay(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- vp->Set(pRuntime->NewBoolean(m_bDelay));
- return true;
+CJS_Return Document::get_delay(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(pRuntime->NewBoolean(m_bDelay));
}
-bool Document::set_delay(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
-
- if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) {
- *sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
- return false;
- }
+CJS_Return Document::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
m_bDelay = pRuntime->ToBoolean(vp);
if (m_bDelay) {
m_DelayData.clear();
- return true;
+ return CJS_Return(true);
}
std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess;
@@ -929,212 +805,147 @@ bool Document::set_delay(CJS_Runtime* pRuntime,
for (const auto& pData : DelayDataToProcess)
Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
- return true;
+ return CJS_Return(true);
}
-bool Document::get_keywords(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return getPropertyInternal(pRuntime, vp, "Keywords", sError);
+CJS_Return Document::get_keywords(CJS_Runtime* pRuntime) {
+ return getPropertyInternal(pRuntime, "Keywords");
}
-bool Document::set_keywords(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return setPropertyInternal(pRuntime, vp, "Keywords", sError);
+CJS_Return Document::set_keywords(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return setPropertyInternal(pRuntime, vp, "Keywords");
}
-bool Document::get_mod_date(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return getPropertyInternal(pRuntime, vp, "ModDate", sError);
+CJS_Return Document::get_mod_date(CJS_Runtime* pRuntime) {
+ return getPropertyInternal(pRuntime, "ModDate");
}
-bool Document::set_mod_date(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return setPropertyInternal(pRuntime, vp, "ModDate", sError);
+CJS_Return Document::set_mod_date(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return setPropertyInternal(pRuntime, vp, "ModDate");
}
-bool Document::get_producer(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return getPropertyInternal(pRuntime, vp, "Producer", sError);
+CJS_Return Document::get_producer(CJS_Runtime* pRuntime) {
+ return getPropertyInternal(pRuntime, "Producer");
}
-bool Document::set_producer(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return setPropertyInternal(pRuntime, vp, "Producer", sError);
+CJS_Return Document::set_producer(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return setPropertyInternal(pRuntime, vp, "Producer");
}
-bool Document::get_subject(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return getPropertyInternal(pRuntime, vp, "Subject", sError);
+CJS_Return Document::get_subject(CJS_Runtime* pRuntime) {
+ return getPropertyInternal(pRuntime, "Subject");
}
-bool Document::set_subject(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return setPropertyInternal(pRuntime, vp, "Subject", sError);
+CJS_Return Document::set_subject(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return setPropertyInternal(pRuntime, vp, "Subject");
}
-bool Document::get_title(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument()) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- return getPropertyInternal(pRuntime, vp, "Title", sError);
+CJS_Return Document::get_title(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return getPropertyInternal(pRuntime, "Title");
}
-bool Document::set_title(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument()) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- return setPropertyInternal(pRuntime, vp, "Title", sError);
+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 setPropertyInternal(pRuntime, vp, "Title");
}
-bool Document::get_num_pages(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- vp->Set(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
- return true;
+CJS_Return Document::get_num_pages(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
}
-bool Document::set_num_pages(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Document::set_num_pages(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Document::get_external(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Document::get_external(CJS_Runtime* pRuntime) {
// In Chrome case, should always return true.
- vp->Set(pRuntime->NewBoolean(true));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(true));
}
-bool Document::set_external(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_external(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::get_filesize(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewNumber(0));
- return true;
+CJS_Return Document::get_filesize(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewNumber(0));
}
-bool Document::set_filesize(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Document::set_filesize(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Document::get_mouse_x(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_mouse_x(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_mouse_x(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_mouse_x(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::get_mouse_y(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_mouse_y(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_mouse_y(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_mouse_y(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::get_URL(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- vp->Set(pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str()));
- return true;
+CJS_Return Document::get_URL(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(
+ pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str()));
}
-bool Document::set_URL(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Document::set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Document::get_base_URL(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewString(m_cwBaseURL.c_str()));
- return true;
+CJS_Return Document::get_base_URL(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewString(m_cwBaseURL.c_str()));
}
-bool Document::set_base_URL(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Document::set_base_URL(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
m_cwBaseURL = pRuntime->ToWideString(vp);
- return true;
+ return CJS_Return(true);
}
-bool Document::get_calculate(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Document::get_calculate(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
- vp->Set(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
}
-bool Document::set_calculate(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Document::set_calculate(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
pInterForm->EnableCalculate(pRuntime->ToBoolean(vp));
- return true;
+ return CJS_Return(true);
}
-bool Document::get_document_file_name(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+CJS_Return Document::get_document_file_name(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath();
size_t i = wsFilePath.GetLength();
@@ -1143,104 +954,75 @@ bool Document::get_document_file_name(CJS_Runtime* pRuntime,
break;
}
- if (i > 0 && i < wsFilePath.GetLength())
- vp->Set(
+ if (i > 0 && i < wsFilePath.GetLength()) {
+ return CJS_Return(
pRuntime->NewString(wsFilePath.GetBuffer(wsFilePath.GetLength()) + i));
- else
- vp->Set(pRuntime->NewString(L""));
-
- return true;
+ }
+ return CJS_Return(pRuntime->NewString(L""));
}
-bool Document::set_document_file_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Document::set_document_file_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Document::get_path(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (!m_pFormFillEnv) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- vp->Set(pRuntime->NewString(
+CJS_Return Document::get_path(CJS_Runtime* pRuntime) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(pRuntime->NewString(
app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str()));
- return true;
}
-bool Document::set_path(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Document::set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Document::get_page_window_rect(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_page_window_rect(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_page_window_rect(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_page_window_rect(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::get_layout(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_layout(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_layout(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_layout(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::addLink(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Document::addLink(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Document::closeDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Document::closeDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Document::getPageBox(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Document::getPageBox(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Document::getAnnot(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 2) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
int nPageNo = pRuntime->ToInt32(params[0]);
WideString swAnnotName = pRuntime->ToWideString(params[1]);
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(nPageNo);
if (!pPageView)
- return false;
+ return CJS_Return(false);
CPDFSDK_AnnotIteration annotIteration(pPageView, false);
CPDFSDK_BAAnnot* pSDKBAAnnot = nullptr;
@@ -1253,31 +1035,30 @@ bool Document::getAnnot(CJS_Runtime* pRuntime,
}
}
if (!pSDKBAAnnot)
- return false;
+ return CJS_Return(false);
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Annot::g_nObjDefnID);
if (pObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_Annot* pJS_Annot =
static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
+ if (!pJS_Annot)
+ return CJS_Return(false);
+
Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
pAnnot->SetSDKAnnot(pSDKBAAnnot);
- if (pJS_Annot)
- vRet = CJS_Value(pJS_Annot->ToV8Object());
- return true;
+ return CJS_Return(pJS_Annot->ToV8Object());
}
-bool Document::getAnnots(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
+
// TODO(tonikitoo): Add support supported parameters as per
// the PDF spec.
@@ -1287,18 +1068,17 @@ bool Document::getAnnots(CJS_Runtime* pRuntime,
for (int i = 0; i < nPageNo; ++i) {
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(i);
if (!pPageView)
- return false;
+ return CJS_Return(false);
CPDFSDK_AnnotIteration annotIteration(pPageView, false);
for (const auto& pSDKAnnotCur : annotIteration) {
- if (!pSDKAnnotCur) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+ if (!pSDKAnnotCur)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Annot::g_nObjDefnID);
if (pObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_Annot* pJS_Annot =
static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
@@ -1311,39 +1091,30 @@ bool Document::getAnnots(CJS_Runtime* pRuntime,
}
}
if (annots.ToV8Value().IsEmpty())
- vRet = CJS_Value(pRuntime->NewArray());
- else
- vRet = CJS_Value(annots.ToV8Value());
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(annots.ToV8Value());
}
-bool Document::getAnnot3D(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- vRet.Set(pRuntime->NewUndefined());
- return true;
+CJS_Return Document::getAnnot3D(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(pRuntime->NewUndefined());
}
-bool Document::getAnnots3D(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Document::getAnnots3D(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Document::getOCGs(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Document::getOCGs(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Document::getLinks(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Document::getLinks(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) {
@@ -1351,45 +1122,31 @@ bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) {
rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom);
}
-bool Document::addIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 2) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+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));
WideString swIconName = pRuntime->ToWideString(params[0]);
- if (!params[1]->IsObject()) {
- sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
- return false;
- }
+ if (!params[1]->IsObject())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
v8::Local<v8::Object> pJSIcon = pRuntime->ToObject(params[1]);
- if (CFXJS_Engine::GetObjDefnID(pJSIcon) != CJS_Icon::g_nObjDefnID) {
- sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
- return false;
- }
+ if (CFXJS_Engine::GetObjDefnID(pJSIcon) != CJS_Icon::g_nObjDefnID)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]);
CJS_Object* obj = static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(pObj));
- if (!obj->GetEmbedObject()) {
- sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
- return false;
- }
+ if (!obj->GetEmbedObject())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
m_IconNames.push_back(swIconName);
- return true;
+ return CJS_Return(true);
}
-bool Document::get_icons(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- if (m_IconNames.empty()) {
- vp->Set(pRuntime->NewUndefined());
- return true;
- }
+CJS_Return Document::get_icons(CJS_Runtime* pRuntime) {
+ if (m_IconNames.empty())
+ return CJS_Return(pRuntime->NewUndefined());
CJS_Array Icons;
int i = 0;
@@ -1397,7 +1154,7 @@ bool Document::get_icons(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
if (pObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_Icon* pJS_Icon =
static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
@@ -1409,118 +1166,92 @@ bool Document::get_icons(CJS_Runtime* pRuntime,
}
if (Icons.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(Icons.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(Icons.ToV8Value());
}
-bool Document::set_icons(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Document::set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Document::getIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+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));
WideString swIconName = pRuntime->ToWideString(params[0]);
auto it = std::find(m_IconNames.begin(), m_IconNames.end(), swIconName);
if (it == m_IconNames.end())
- return false;
+ return CJS_Return(false);
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
if (pObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
+ if (!pJS_Icon)
+ return CJS_Return(false);
+
Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
pIcon->SetIconName(*it);
- if (pJS_Icon)
- vRet = CJS_Value(pJS_Icon->ToV8Object());
-
- return true;
+ return CJS_Return(pJS_Icon->ToV8Object());
}
-bool Document::removeIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::removeIcon(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, no supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::createDataObject(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::createDataObject(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not implemented.
- return true;
+ return CJS_Return(true);
}
-bool Document::get_media(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_media(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_media(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::calculateNow(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
+
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
- sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
- return false;
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
}
+
m_pFormFillEnv->GetInterForm()->OnCalculate();
- return true;
+ return CJS_Return(true);
}
-bool Document::get_collab(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_collab(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_collab(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_collab(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::getPageNthWord(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) {
- sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
- return false;
- }
+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));
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
// TODO(tsepez): check maximum allowable params.
@@ -1530,16 +1261,14 @@ bool Document::getPageNthWord(CJS_Runtime* pRuntime,
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (!pDocument)
- return false;
+ return CJS_Return(false);
- if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
- sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
- return false;
- }
+ if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
if (!pPageDict)
- return false;
+ return CJS_Return(false);
CPDF_Page page(pDocument, pPageDict, true);
page.ParseContent();
@@ -1562,49 +1291,35 @@ bool Document::getPageNthWord(CJS_Runtime* pRuntime,
swRet.TrimLeft();
swRet.TrimRight();
}
-
- vRet = CJS_Value(pRuntime->NewString(swRet.c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(swRet.c_str()));
}
-bool Document::getPageNthWordQuads(
+CJS_Return Document::getPageNthWordQuads(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- return false;
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
+ return CJS_Return(false);
}
-bool Document::getPageNumWords(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
- if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) {
- sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
- return false;
- }
+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));
+ if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOPERMISSION));
+
int nPageNo = params.size() > 0 ? pRuntime->ToInt32(params[0]) : 0;
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
- if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
- sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
- return false;
- }
+ if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
CPDF_Dictionary* pPageDict = pDocument->GetPage(nPageNo);
if (!pPageDict)
- return false;
+ return CJS_Return(false);
CPDF_Page page(pDocument, pPageDict, true);
page.ParseContent();
@@ -1615,23 +1330,20 @@ bool Document::getPageNumWords(CJS_Runtime* pRuntime,
nWords += CountWords(pPageObj->AsText());
}
- vRet = CJS_Value(pRuntime->NewNumber(nWords));
- return true;
+ return CJS_Return(pRuntime->NewNumber(nWords));
}
-bool Document::getPrintParams(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::getPrintParams(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
v8::Local<v8::Object> pRetObj =
pRuntime->NewFxDynamicObj(CJS_PrintParamsObj::g_nObjDefnID);
if (pRetObj.IsEmpty())
- return false;
+ return CJS_Return(false);
// Not implemented yet.
- vRet = CJS_Value(pRetObj);
- return true;
+ return CJS_Return(pRetObj);
}
#define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF)
@@ -1705,91 +1417,74 @@ WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex) {
return swRet;
}
-bool Document::get_zoom(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_zoom(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_zoom(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Document::set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::get_zoom_type(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Document::get_zoom_type(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Document::set_zoom_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+
+CJS_Return Document::set_zoom_type(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Document::deletePages(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- // Unsafe, no supported.
- return true;
+CJS_Return Document::deletePages(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ // Unsafe, not supported.
+ return CJS_Return(true);
}
-bool Document::extractPages(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::extractPages(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::insertPages(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::insertPages(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::replacePages(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::replacePages(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::getURL(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Document::getURL(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Document::gotoNamedDest(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
- if (!m_pFormFillEnv) {
- sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+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));
+ if (!m_pFormFillEnv)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
WideString wideName = pRuntime->ToWideString(params[0]);
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (!pDocument)
- return false;
+ return CJS_Return(false);
CPDF_NameTree nameTree(pDocument, "Dests");
CPDF_Array* destArray = nameTree.LookupNamedDest(pDocument, wideName);
if (!destArray)
- return false;
+ return CJS_Return(false);
CPDF_Dest dest(destArray);
const CPDF_Array* arrayObject = ToArray(dest.GetObject());
@@ -1803,7 +1498,7 @@ bool Document::gotoNamedDest(CJS_Runtime* pRuntime,
scrollPositionArray.data(),
scrollPositionArray.size());
pRuntime->EndBlock();
- return true;
+ return CJS_Return(true);
}
void Document::AddDelayData(CJS_DelayData* pData) {
diff --git a/fpdfsdk/javascript/Document.h b/fpdfsdk/javascript/Document.h
index 4b49d7f616..18469b0ae6 100644
--- a/fpdfsdk/javascript/Document.h
+++ b/fpdfsdk/javascript/Document.h
@@ -50,342 +50,189 @@ class Document : public CJS_EmbedObj {
explicit Document(CJS_Object* pJSObject);
~Document() override;
- bool get_ADBE(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_ADBE(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_author(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_author(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_base_URL(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_base_URL(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_bookmark_root(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_bookmark_root(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_calculate(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_calculate(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_collab(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_collab(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_creation_date(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_creation_date(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_creator(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_creator(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_delay(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_delay(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_dirty(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_dirty(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_document_file_name(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_document_file_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_external(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_external(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_filesize(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_filesize(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_icons(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_icons(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_info(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_info(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_keywords(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_keywords(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_layout(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_layout(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_media(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_media(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_mod_date(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_mod_date(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_mouse_x(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_mouse_x(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_mouse_y(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_mouse_y(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_num_fields(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_num_fields(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_num_pages(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_num_pages(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_page_num(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_page_num(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_page_window_rect(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_page_window_rect(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_path(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_path(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_producer(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_producer(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_subject(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_subject(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_title(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_title(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_zoom(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_zoom(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_zoom_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_zoom_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_URL(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_URL(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool addAnnot(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool addField(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool addLink(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool addIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool calculateNow(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool closeDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool createDataObject(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool deletePages(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool exportAsText(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool exportAsFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool exportAsXFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool extractPages(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getAnnot(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getAnnots(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getAnnot3D(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getAnnots3D(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getField(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getLinks(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getNthFieldName(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getOCGs(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getPageBox(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getPageNthWord(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getPageNthWordQuads(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getPageNumWords(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getPrintParams(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getURL(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool gotoNamedDest(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool importAnFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool importAnXFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool importTextData(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool insertPages(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool mailForm(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool print(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool removeField(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool replacePages(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool resetForm(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool saveAs(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool submitForm(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool syncAnnotScan(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool mailDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool removeIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
+ CJS_Return get_ADBE(CJS_Runtime* pRuntime);
+ CJS_Return set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_author(CJS_Runtime* pRuntime);
+ CJS_Return set_author(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_base_URL(CJS_Runtime* pRuntime);
+ CJS_Return set_base_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_bookmark_root(CJS_Runtime* pRuntime);
+ CJS_Return set_bookmark_root(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_calculate(CJS_Runtime* pRuntime);
+ CJS_Return set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_collab(CJS_Runtime* pRuntime);
+ CJS_Return set_collab(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_creation_date(CJS_Runtime* pRuntime);
+ CJS_Return set_creation_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_creator(CJS_Runtime* pRuntime);
+ CJS_Return set_creator(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_delay(CJS_Runtime* pRuntime);
+ CJS_Return set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_dirty(CJS_Runtime* pRuntime);
+ CJS_Return set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_document_file_name(CJS_Runtime* pRuntime);
+ CJS_Return set_document_file_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_external(CJS_Runtime* pRuntime);
+ CJS_Return set_external(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_filesize(CJS_Runtime* pRuntime);
+ CJS_Return set_filesize(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_icons(CJS_Runtime* pRuntime);
+ CJS_Return set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_info(CJS_Runtime* pRuntime);
+ CJS_Return set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_keywords(CJS_Runtime* pRuntime);
+ CJS_Return set_keywords(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_layout(CJS_Runtime* pRuntime);
+ CJS_Return set_layout(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_media(CJS_Runtime* pRuntime);
+ CJS_Return set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_mod_date(CJS_Runtime* pRuntime);
+ CJS_Return set_mod_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_mouse_x(CJS_Runtime* pRuntime);
+ CJS_Return set_mouse_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_mouse_y(CJS_Runtime* pRuntime);
+ CJS_Return set_mouse_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_num_fields(CJS_Runtime* pRuntime);
+ CJS_Return set_num_fields(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_num_pages(CJS_Runtime* pRuntime);
+ CJS_Return set_num_pages(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_page_num(CJS_Runtime* pRuntime);
+ CJS_Return set_page_num(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_page_window_rect(CJS_Runtime* pRuntime);
+ CJS_Return set_page_window_rect(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_path(CJS_Runtime* pRuntime);
+ CJS_Return set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_producer(CJS_Runtime* pRuntime);
+ CJS_Return set_producer(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_subject(CJS_Runtime* pRuntime);
+ CJS_Return set_subject(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_title(CJS_Runtime* pRuntime);
+ CJS_Return set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_zoom(CJS_Runtime* pRuntime);
+ CJS_Return set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_zoom_type(CJS_Runtime* pRuntime);
+ CJS_Return set_zoom_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_URL(CJS_Runtime* pRuntime);
+ CJS_Return set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return addAnnot(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return addField(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return addLink(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return addIcon(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return calculateNow(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return closeDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return createDataObject(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return deletePages(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return exportAsText(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return exportAsFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return exportAsXFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return extractPages(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getAnnot(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getAnnots(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getAnnot3D(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getAnnots3D(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getField(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getIcon(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getLinks(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getNthFieldName(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getOCGs(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getPageBox(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getPageNthWord(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getPageNthWordQuads(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getPageNumWords(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getPrintParams(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getURL(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return gotoNamedDest(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return importAnFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return importAnXFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return importTextData(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return insertPages(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return mailForm(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return print(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return removeField(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return replacePages(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return resetForm(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return saveAs(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return submitForm(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return syncAnnotScan(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return mailDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return removeIcon(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv);
CPDFSDK_FormFillEnvironment* GetFormFillEnv() const {
@@ -400,14 +247,11 @@ class Document : public CJS_EmbedObj {
int CountWords(CPDF_TextObject* pTextObj);
WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex);
- bool getPropertyInternal(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- const ByteString& propName,
- WideString* sError);
- bool setPropertyInternal(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- const ByteString& propName,
- WideString* sError);
+ CJS_Return getPropertyInternal(CJS_Runtime* pRuntime,
+ const ByteString& propName);
+ CJS_Return setPropertyInternal(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp,
+ const ByteString& propName);
CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
WideString m_cwBaseURL;
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index d530ef8f56..e79462ff42 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -381,95 +381,75 @@ CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) {
return pFormField->GetControl(m_nFormControlIndex);
}
-bool Field::get_alignment(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_alignment(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
switch (pFormControl->GetControlAlignment()) {
- case 1:
- vp->Set(pRuntime->NewString(L"center"));
- break;
case 0:
- vp->Set(pRuntime->NewString(L"left"));
- break;
+ return CJS_Return(pRuntime->NewString(L"left"));
+ case 1:
+ return CJS_Return(pRuntime->NewString(L"center"));
case 2:
- vp->Set(pRuntime->NewString(L"right"));
- break;
- default:
- vp->Set(pRuntime->NewString(L""));
+ return CJS_Return(pRuntime->NewString(L"right"));
}
-
- return true;
+ return CJS_Return(pRuntime->NewString(L""));
}
-bool Field::set_alignment(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_alignment(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_border_style(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_border_style(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (!pFormField)
- return false;
+ return CJS_Return(false);
CPDFSDK_Widget* pWidget =
GetWidget(m_pFormFillEnv.Get(), GetSmartFieldControl(pFormField));
if (!pWidget)
- return false;
+ return CJS_Return(false);
switch (pWidget->GetBorderStyle()) {
case BorderStyle::SOLID:
- vp->Set(pRuntime->NewString(L"solid"));
- break;
+ return CJS_Return(pRuntime->NewString(L"solid"));
case BorderStyle::DASH:
- vp->Set(pRuntime->NewString(L"dashed"));
- break;
+ return CJS_Return(pRuntime->NewString(L"dashed"));
case BorderStyle::BEVELED:
- vp->Set(pRuntime->NewString(L"beveled"));
- break;
+ return CJS_Return(pRuntime->NewString(L"beveled"));
case BorderStyle::INSET:
- vp->Set(pRuntime->NewString(L"inset"));
- break;
+ return CJS_Return(pRuntime->NewString(L"inset"));
case BorderStyle::UNDERLINE:
- vp->Set(pRuntime->NewString(L"underline"));
- break;
- default:
- vp->Set(pRuntime->NewString(L""));
- break;
+ return CJS_Return(pRuntime->NewString(L"underline"));
}
- return true;
+ return CJS_Return(pRuntime->NewString(L""));
}
-bool Field::set_border_style(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_border_style(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
ByteString byte_str = ByteString::FromUnicode(pRuntime->ToWideString(vp));
if (m_bDelay) {
@@ -478,7 +458,7 @@ bool Field::set_border_style(CJS_Runtime* pRuntime,
Field::SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName,
m_nFormControlIndex, byte_str);
}
- return true;
+ return CJS_Return(true);
}
void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -533,22 +513,20 @@ void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-bool Field::get_button_align_x(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_button_align_x(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
CPDF_IconFit IconFit = pFormControl->GetIconFit();
@@ -556,33 +534,29 @@ bool Field::get_button_align_x(CJS_Runtime* pRuntime,
float fBottom;
IconFit.GetIconPosition(fLeft, fBottom);
- vp->Set(pRuntime->NewNumber(static_cast<int32_t>(fLeft)));
- return true;
+ return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fLeft)));
}
-bool Field::set_button_align_x(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_button_align_x(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_button_align_y(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_button_align_y(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
CPDF_IconFit IconFit = pFormControl->GetIconFit();
@@ -590,270 +564,233 @@ bool Field::get_button_align_y(CJS_Runtime* pRuntime,
float fBottom;
IconFit.GetIconPosition(fLeft, fBottom);
- vp->Set(pRuntime->NewNumber(static_cast<int32_t>(fBottom)));
- return true;
+ return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fBottom)));
}
-bool Field::set_button_align_y(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_button_align_y(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_button_fit_bounds(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_button_fit_bounds(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds()));
- return true;
+ return CJS_Return(
+ pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds()));
}
-bool Field::set_button_fit_bounds(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_button_fit_bounds(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_button_position(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_button_position(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewNumber(pFormControl->GetTextPosition()));
- return true;
+ return CJS_Return(pRuntime->NewNumber(pFormControl->GetTextPosition()));
}
-bool Field::set_button_position(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_button_position(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_button_scale_how(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_button_scale_how(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1));
- return true;
}
-bool Field::set_button_scale_how(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_button_scale_how(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_button_scale_when(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_button_scale_when(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
CPDF_IconFit IconFit = pFormControl->GetIconFit();
int ScaleM = IconFit.GetScaleMethod();
switch (ScaleM) {
case CPDF_IconFit::Always:
- vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Always)));
- break;
+ return CJS_Return(
+ pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Always)));
case CPDF_IconFit::Bigger:
- vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Bigger)));
- break;
+ return CJS_Return(
+ pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Bigger)));
case CPDF_IconFit::Never:
- vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Never)));
- break;
+ return CJS_Return(
+ pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Never)));
case CPDF_IconFit::Smaller:
- vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Smaller)));
- break;
+ return CJS_Return(
+ pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Smaller)));
}
- return true;
+ return CJS_Return(true);
}
-bool Field::set_button_scale_when(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_button_scale_when(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_calc_order_index(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_calc_order_index(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) {
- return false;
+ return CJS_Return(false);
}
CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
- vp->Set(pRuntime->NewNumber(static_cast<int32_t>(
+ return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(
pInterForm->FindFieldInCalculationOrder(pFormField))));
- return true;
}
-bool Field::set_calc_order_index(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_calc_order_index(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_char_limit(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_char_limit(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
-
- vp->Set(pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen())));
- return true;
+ return CJS_Return(false);
+ return CJS_Return(
+ pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen())));
}
-bool Field::set_char_limit(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_char_limit(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_comb(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
+CJS_Return Field::get_comb(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
+ return CJS_Return(false);
- vp->Set(
+ return CJS_Return(
pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB)));
- return true;
}
-bool Field::set_comb(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_commit_on_sel_change(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
- return false;
+ return CJS_Return(false);
}
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)));
- return true;
}
-bool Field::set_commit_on_sel_change(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_commit_on_sel_change(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_current_value_indices(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_current_value_indices(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
- return false;
+ return CJS_Return(false);
}
int count = pFormField->CountSelectedItems();
- if (count <= 0) {
- vp->Set(pRuntime->NewNumber(-1));
- return true;
- }
- if (count == 1) {
- vp->Set(pRuntime->NewNumber(pFormField->GetSelectedIndex(0)));
- return true;
- }
+ if (count <= 0)
+ return CJS_Return(pRuntime->NewNumber(-1));
+ if (count == 1)
+ return CJS_Return(pRuntime->NewNumber(pFormField->GetSelectedIndex(0)));
CJS_Array SelArray;
for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
@@ -861,18 +798,14 @@ bool Field::get_current_value_indices(CJS_Runtime* pRuntime,
pRuntime->NewNumber(pFormField->GetSelectedIndex(i)));
}
if (SelArray.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(SelArray.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(SelArray.ToV8Value());
}
-bool Field::set_current_value_indices(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_current_value_indices(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
std::vector<uint32_t> array;
if (vp->IsNumber()) {
@@ -889,7 +822,7 @@ bool Field::set_current_value_indices(CJS_Runtime* pRuntime,
Field::SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName,
m_nFormControlIndex, array);
}
- return true;
+ return CJS_Return(true);
}
void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -918,94 +851,79 @@ void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-bool Field::get_default_style(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return false;
+CJS_Return Field::get_default_style(CJS_Runtime* pRuntime) {
+ return CJS_Return(false);
}
-bool Field::set_default_style(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return Field::set_default_style(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool Field::get_default_value(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_default_value(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
- std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
- if (FieldArray.empty())
- return false;
+ std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+ if (FieldArray.empty())
+ return CJS_Return(false);
- CPDF_FormField* pFormField = FieldArray[0];
- if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON ||
- pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) {
- return false;
- }
+ CPDF_FormField* pFormField = FieldArray[0];
+ if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON ||
+ pFormField->GetFieldType() == FIELDTYPE_SIGNATURE) {
+ return CJS_Return(false);
+ }
- vp->Set(pRuntime->NewString(pFormField->GetDefaultValue().c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(pFormField->GetDefaultValue().c_str()));
}
-bool Field::set_default_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_default_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_do_not_scroll(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_do_not_scroll(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)));
- return true;
}
-bool Field::set_do_not_scroll(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_do_not_scroll(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_do_not_spell_check(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_do_not_spell_check(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD &&
pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) {
- return false;
+ return CJS_Return(false);
}
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)));
- return true;
}
-bool Field::set_do_not_spell_check(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_do_not_spell_check(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
void Field::SetDelay(bool bDelay) {
@@ -1017,29 +935,22 @@ void Field::SetDelay(bool bDelay) {
m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex);
}
-bool Field::get_delay(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewBoolean(m_bDelay));
- return true;
+CJS_Return Field::get_delay(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewBoolean(m_bDelay));
}
-bool Field::set_delay(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
SetDelay(pRuntime->ToBoolean(vp));
- return true;
+ return CJS_Return(true);
}
-bool Field::get_display(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_display(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
ASSERT(pFormField);
@@ -1048,29 +959,23 @@ bool Field::get_display(CJS_Runtime* pRuntime,
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
- return false;
+ return CJS_Return(false);
uint32_t dwFlag = pWidget->GetFlags();
- if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
- vp->Set(pRuntime->NewNumber(1));
- return true;
- }
+ if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag)
+ return CJS_Return(pRuntime->NewNumber(1));
+
if (ANNOTFLAG_PRINT & dwFlag) {
if (ANNOTFLAG_NOVIEW & dwFlag)
- vp->Set(pRuntime->NewNumber(3));
- else
- vp->Set(pRuntime->NewNumber(0));
- } else {
- vp->Set(pRuntime->NewNumber(2));
+ return CJS_Return(pRuntime->NewNumber(3));
+ return CJS_Return(pRuntime->NewNumber(0));
}
- return true;
+ return CJS_Return(pRuntime->NewNumber(2));
}
-bool Field::set_display(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_display(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
if (m_bDelay) {
AddDelay_Int(FP_DISPLAY, pRuntime->ToInt32(vp));
@@ -1078,7 +983,7 @@ bool Field::set_display(CJS_Runtime* pRuntime,
Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
pRuntime->ToInt32(vp));
}
- return true;
+ return CJS_Return(true);
}
void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -1117,50 +1022,40 @@ void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-bool Field::get_doc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- vp->Set(m_pJSDoc->GetCJSDoc()->ToV8Object());
- return true;
+CJS_Return Field::get_doc(CJS_Runtime* pRuntime) {
+ return CJS_Return(m_pJSDoc->GetCJSDoc()->ToV8Object());
}
-bool Field::set_doc(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool Field::get_editable(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_editable(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
- return false;
+ return CJS_Return(false);
- vp->Set(
+ return CJS_Return(
pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT)));
- return true;
}
-bool Field::set_editable(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return m_bCanSet;
+CJS_Return Field::set_editable(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_export_values(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_export_values(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX &&
pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) {
- return false;
+ return CJS_Return(false);
}
CJS_Array ExportValuesArray;
@@ -1173,12 +1068,12 @@ bool Field::get_export_values(CJS_Runtime* pRuntime,
}
} else {
if (m_nFormControlIndex >= pFormField->CountControls())
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl =
pFormField->GetControl(m_nFormControlIndex);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
ExportValuesArray.SetElement(
pRuntime, 0,
@@ -1186,71 +1081,60 @@ bool Field::get_export_values(CJS_Runtime* pRuntime,
}
if (ExportValuesArray.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(ExportValuesArray.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(ExportValuesArray.ToV8Value());
}
-bool Field::set_export_values(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_export_values(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX &&
pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) {
- return false;
+ return CJS_Return(false);
}
- return m_bCanSet && !vp.IsEmpty() && vp->IsArray();
+ return CJS_Return(m_bCanSet && !vp.IsEmpty() && vp->IsArray());
}
-bool Field::get_file_select(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_file_select(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)));
- return true;
}
-bool Field::set_file_select(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_file_select(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
-
- return m_bCanSet;
+ return CJS_Return(false);
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_fill_color(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_fill_color(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
ASSERT(pFormField);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
int iColorType;
pFormControl->GetBackgroundColor(iColorType);
@@ -1273,37 +1157,31 @@ bool Field::get_fill_color(CJS_Runtime* pRuntime,
pFormControl->GetOriginalBackgroundColor(2),
pFormControl->GetOriginalBackgroundColor(3));
} else {
- return false;
+ return CJS_Return(false);
}
CJS_Array array = color::ConvertPWLColorToArray(pRuntime, color);
if (array.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(array.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(array.ToV8Value());
}
-bool Field::set_fill_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_fill_color(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
if (vp.IsEmpty() || !vp->IsArray())
- return false;
- return true;
+ return CJS_Return(false);
+ return CJS_Return(true);
}
-bool Field::get_hidden(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_hidden(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
ASSERT(pFormField);
@@ -1312,19 +1190,16 @@ bool Field::get_hidden(CJS_Runtime* pRuntime,
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
- return false;
+ return CJS_Return(false);
uint32_t dwFlags = pWidget->GetFlags();
- vp->Set(pRuntime->NewBoolean(ANNOTFLAG_INVISIBLE & dwFlags ||
- ANNOTFLAG_HIDDEN & dwFlags));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(ANNOTFLAG_INVISIBLE & dwFlags ||
+ ANNOTFLAG_HIDDEN & dwFlags));
}
-bool Field::set_hidden(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
if (m_bDelay) {
AddDelay_Bool(FP_HIDDEN, pRuntime->ToBoolean(vp));
@@ -1332,7 +1207,7 @@ bool Field::set_hidden(CJS_Runtime* pRuntime,
Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
pRuntime->ToBoolean(vp));
}
- return true;
+ return CJS_Return(true);
}
void Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -1343,82 +1218,70 @@ void Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
SetDisplay(pFormFillEnv, swFieldName, nControlIndex, display);
}
-bool Field::get_highlight(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_highlight(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
int eHM = pFormControl->GetHighlightingMode();
switch (eHM) {
case CPDF_FormControl::None:
- vp->Set(pRuntime->NewString(L"none"));
- break;
+ return CJS_Return(pRuntime->NewString(L"none"));
case CPDF_FormControl::Push:
- vp->Set(pRuntime->NewString(L"push"));
- break;
+ return CJS_Return(pRuntime->NewString(L"push"));
case CPDF_FormControl::Invert:
- vp->Set(pRuntime->NewString(L"invert"));
- break;
+ return CJS_Return(pRuntime->NewString(L"invert"));
case CPDF_FormControl::Outline:
- vp->Set(pRuntime->NewString(L"outline"));
- break;
+ return CJS_Return(pRuntime->NewString(L"outline"));
case CPDF_FormControl::Toggle:
- vp->Set(pRuntime->NewString(L"toggle"));
- break;
+ return CJS_Return(pRuntime->NewString(L"toggle"));
}
- return true;
+ return CJS_Return(true);
}
-bool Field::set_highlight(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_highlight(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_line_width(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_line_width(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
ASSERT(pFormField);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
if (!pFormField->CountControls())
- return false;
+ return CJS_Return(false);
CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
if (!pWidget)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewNumber(pWidget->GetBorderWidth()));
- return true;
+ return CJS_Return(pRuntime->NewNumber(pWidget->GetBorderWidth()));
}
-bool Field::set_line_width(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_line_width(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
if (m_bDelay) {
AddDelay_Int(FP_LINEWIDTH, pRuntime->ToInt32(vp));
@@ -1426,7 +1289,7 @@ bool Field::set_line_width(CJS_Runtime* pRuntime,
Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
pRuntime->ToInt32(vp));
}
- return true;
+ return CJS_Return(true);
}
void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -1468,121 +1331,102 @@ void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-bool Field::get_multiline(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_multiline(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)));
- return true;
}
-bool Field::set_multiline(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_multiline(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_multiple_selection(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_multiple_selection(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)));
- return true;
}
-bool Field::set_multiple_selection(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_multiple_selection(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
+CJS_Return Field::get_name(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewString(m_FieldName.c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(m_FieldName.c_str()));
}
-bool Field::set_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool Field::get_num_items(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_num_items(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
- return false;
+ return CJS_Return(false);
}
- vp->Set(pRuntime->NewNumber(pFormField->CountOptions()));
- return true;
+ return CJS_Return(pRuntime->NewNumber(pFormField->CountOptions()));
}
-bool Field::set_num_items(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return Field::set_num_items(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool Field::get_page(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
+CJS_Return Field::get_page(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (!pFormField)
- return false;
+ return CJS_Return(false);
std::vector<CPDFSDK_Annot::ObservedPtr> widgets;
m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets);
- if (widgets.empty()) {
- vp->Set(pRuntime->NewNumber(-1));
- return true;
- }
+ if (widgets.empty())
+ return CJS_Return(pRuntime->NewNumber(-1));
CJS_Array PageArray;
int i = 0;
for (const auto& pObserved : widgets) {
- if (!pObserved) {
- *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
- return false;
- }
+ if (!pObserved)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
auto* pWidget = static_cast<CPDFSDK_Widget*>(pObserved.Get());
CPDFSDK_PageView* pPageView = pWidget->GetPageView();
if (!pPageView)
- return false;
+ return CJS_Return(false);
PageArray.SetElement(
pRuntime, i,
@@ -1591,104 +1435,65 @@ bool Field::get_page(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
}
if (PageArray.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(PageArray.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(PageArray.ToV8Value());
}
-bool Field::set_page(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- *sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
- return false;
+CJS_Return Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSREADONLY));
}
-bool Field::get_password(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_password(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)));
- return true;
}
-bool Field::set_password(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_password(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_print(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_print(CJS_Runtime* pRuntime) {
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT)));
- return true;
+ return CJS_Return(
+ pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT)));
}
-bool Field::set_print(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_print(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
-
- if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
- for (CPDF_FormField* pFormField : FieldArray) {
- if (m_nFormControlIndex < 0) {
- bool bSet = false;
- for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
- if (CPDFSDK_Widget* pWidget =
- pInterForm->GetWidget(pFormField->GetControl(i))) {
- uint32_t dwFlags = pWidget->GetFlags();
- if (pRuntime->ToBoolean(vp))
- dwFlags |= ANNOTFLAG_PRINT;
- else
- dwFlags &= ~ANNOTFLAG_PRINT;
-
- if (dwFlags != pWidget->GetFlags()) {
- pWidget->SetFlags(dwFlags);
- bSet = true;
- }
- }
- }
-
- if (bSet)
- UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, false, true);
-
- continue;
- }
+ if (!m_bCanSet)
+ return CJS_Return(false);
- if (m_nFormControlIndex >= pFormField->CountControls())
- return false;
- if (CPDF_FormControl* pFormControl =
- pFormField->GetControl(m_nFormControlIndex)) {
- if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
+ for (CPDF_FormField* pFormField : FieldArray) {
+ if (m_nFormControlIndex < 0) {
+ bool bSet = false;
+ for (int i = 0, sz = pFormField->CountControls(); i < sz; ++i) {
+ if (CPDFSDK_Widget* pWidget =
+ pInterForm->GetWidget(pFormField->GetControl(i))) {
uint32_t dwFlags = pWidget->GetFlags();
if (pRuntime->ToBoolean(vp))
dwFlags |= ANNOTFLAG_PRINT;
@@ -1697,73 +1502,89 @@ bool Field::set_print(CJS_Runtime* pRuntime,
if (dwFlags != pWidget->GetFlags()) {
pWidget->SetFlags(dwFlags);
- UpdateFormControl(m_pFormFillEnv.Get(),
- pFormField->GetControl(m_nFormControlIndex), true,
- false, true);
+ bSet = true;
}
}
}
+
+ if (bSet)
+ UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, false, true);
+
+ continue;
}
- return true;
+
+ if (m_nFormControlIndex >= pFormField->CountControls())
+ return CJS_Return(false);
+
+ if (CPDF_FormControl* pFormControl =
+ pFormField->GetControl(m_nFormControlIndex)) {
+ if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) {
+ uint32_t dwFlags = pWidget->GetFlags();
+ if (pRuntime->ToBoolean(vp))
+ dwFlags |= ANNOTFLAG_PRINT;
+ else
+ dwFlags &= ~ANNOTFLAG_PRINT;
+
+ if (dwFlags != pWidget->GetFlags()) {
+ pWidget->SetFlags(dwFlags);
+ UpdateFormControl(m_pFormFillEnv.Get(),
+ pFormField->GetControl(m_nFormControlIndex), true,
+ false, true);
+ }
+ }
+ }
+ }
+ return CJS_Return(true);
}
-bool Field::get_radios_in_unison(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_radios_in_unison(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)));
- return true;
}
-bool Field::set_radios_in_unison(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return 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 false;
- return m_bCanSet;
+ return CJS_Return(false);
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_readonly(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_readonly(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY)));
- return true;
}
-bool Field::set_readonly(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_readonly(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
- return m_bCanSet;
+ return CJS_Return(false);
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_rect(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
+CJS_Return Field::get_rect(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget =
pInterForm->GetWidget(GetSmartFieldControl(pFormField));
if (!pWidget)
- return false;
+ return CJS_Return(false);
CFX_FloatRect crRect = pWidget->GetRect();
CJS_Array rcArray;
@@ -1777,20 +1598,15 @@ bool Field::get_rect(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
pRuntime->NewNumber(static_cast<int32_t>(crRect.bottom)));
if (rcArray.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(rcArray.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(rcArray.ToV8Value());
}
-bool Field::set_rect(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
if (vp.IsEmpty() || !vp->IsArray())
- return false;
+ return CJS_Return(false);
CJS_Array rcArray(pRuntime->ToArray(vp));
float pArray[4];
@@ -1810,7 +1626,7 @@ bool Field::set_rect(CJS_Runtime* pRuntime,
Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
crRect);
}
- return true;
+ return CJS_Return(true);
}
void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -1873,105 +1689,85 @@ void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-bool Field::get_required(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_required(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)));
- return true;
}
-bool Field::set_required(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_required(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
-
- return m_bCanSet;
+ return CJS_Return(false);
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_rich_text(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_rich_text(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
!!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)));
- return true;
}
-bool Field::set_rich_text(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_rich_text(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_rich_value(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Field::get_rich_value(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Field::set_rich_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Field::set_rich_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Field::get_rotation(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_rotation(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewNumber(pFormControl->GetRotation()));
- return true;
+ return CJS_Return(pRuntime->NewNumber(pFormControl->GetRotation()));
}
-bool Field::set_rotation(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_rotation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_stroke_color(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_stroke_color(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
int iColorType;
pFormControl->GetBorderColor(iColorType);
@@ -1992,46 +1788,40 @@ bool Field::get_stroke_color(CJS_Runtime* pRuntime,
pFormControl->GetOriginalBorderColor(2),
pFormControl->GetOriginalBorderColor(3));
} else {
- return false;
+ return CJS_Return(false);
}
CJS_Array array = color::ConvertPWLColorToArray(pRuntime, color);
if (array.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(array.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(array.ToV8Value());
}
-bool Field::set_stroke_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_stroke_color(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
if (vp.IsEmpty() || !vp->IsArray())
- return false;
- return true;
+ return CJS_Return(false);
+ return CJS_Return(true);
}
-bool Field::get_style(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_style(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON &&
pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) {
- return false;
+ return CJS_Return(false);
}
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
WideString csWCaption = pFormControl->GetNormalCaption();
ByteString csBCaption;
@@ -2056,41 +1846,33 @@ bool Field::get_style(CJS_Runtime* pRuntime,
csBCaption = "check";
break;
}
- vp->Set(
+ return CJS_Return(
pRuntime->NewString(WideString::FromLocal(csBCaption.c_str()).c_str()));
- return true;
}
-bool Field::set_style(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_submit_name(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return Field::get_submit_name(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Field::set_submit_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Field::set_submit_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool Field::get_text_color(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_text_color(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
int iColorType;
FX_ARGB color;
@@ -2111,169 +1893,143 @@ bool Field::get_text_color(CJS_Runtime* pRuntime,
CJS_Array array = color::ConvertPWLColorToArray(pRuntime, crRet);
if (array.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(array.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(array.ToV8Value());
}
-bool Field::set_text_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_text_color(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
if (vp.IsEmpty() || !vp->IsArray())
- return false;
- return true;
+ return CJS_Return(false);
+ return CJS_Return(true);
}
-bool Field::get_text_font(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_text_font(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
ASSERT(pFormField);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
int nFieldType = pFormField->GetFieldType();
if (nFieldType != FIELDTYPE_PUSHBUTTON && nFieldType != FIELDTYPE_COMBOBOX &&
nFieldType != FIELDTYPE_LISTBOX && nFieldType != FIELDTYPE_TEXTFIELD) {
- return false;
+ return CJS_Return(false);
}
+
CPDF_Font* pFont = pFormControl->GetDefaultControlFont();
if (!pFont)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewString(
+ return CJS_Return(pRuntime->NewString(
WideString::FromLocal(pFont->GetBaseFont().c_str()).c_str()));
- return true;
}
-bool Field::set_text_font(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_text_font(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
- return false;
- return !ByteString::FromUnicode(pRuntime->ToWideString(vp)).IsEmpty();
+ return CJS_Return(false);
+ return CJS_Return(
+ !ByteString::FromUnicode(pRuntime->ToWideString(vp)).IsEmpty());
}
-bool Field::get_text_size(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_text_size(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
ASSERT(pFormField);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
float fFontSize;
CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
FieldAppearance.GetFont(&fFontSize);
- vp->Set(pRuntime->NewNumber(static_cast<int>(fFontSize)));
- return true;
+ return CJS_Return(pRuntime->NewNumber(static_cast<int>(fFontSize)));
}
-bool Field::set_text_size(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_text_size(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
+CJS_Return Field::get_type(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
switch (pFormField->GetFieldType()) {
case FIELDTYPE_UNKNOWN:
- vp->Set(pRuntime->NewString(L"unknown"));
- break;
+ return CJS_Return(pRuntime->NewString(L"unknown"));
case FIELDTYPE_PUSHBUTTON:
- vp->Set(pRuntime->NewString(L"button"));
- break;
+ return CJS_Return(pRuntime->NewString(L"button"));
case FIELDTYPE_CHECKBOX:
- vp->Set(pRuntime->NewString(L"checkbox"));
- break;
+ return CJS_Return(pRuntime->NewString(L"checkbox"));
case FIELDTYPE_RADIOBUTTON:
- vp->Set(pRuntime->NewString(L"radiobutton"));
- break;
+ return CJS_Return(pRuntime->NewString(L"radiobutton"));
case FIELDTYPE_COMBOBOX:
- vp->Set(pRuntime->NewString(L"combobox"));
- break;
+ return CJS_Return(pRuntime->NewString(L"combobox"));
case FIELDTYPE_LISTBOX:
- vp->Set(pRuntime->NewString(L"listbox"));
- break;
+ return CJS_Return(pRuntime->NewString(L"listbox"));
case FIELDTYPE_TEXTFIELD:
- vp->Set(pRuntime->NewString(L"text"));
- break;
+ return CJS_Return(pRuntime->NewString(L"text"));
case FIELDTYPE_SIGNATURE:
- vp->Set(pRuntime->NewString(L"signature"));
- break;
- default:
- vp->Set(pRuntime->NewString(L"unknown"));
- break;
+ return CJS_Return(pRuntime->NewString(L"signature"));
}
- return true;
+ return CJS_Return(pRuntime->NewString(L"unknown"));
}
-bool Field::set_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool Field::get_user_name(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_user_name(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewString(FieldArray[0]->GetAlternateName().c_str()));
- return true;
+ return CJS_Return(
+ pRuntime->NewString(FieldArray[0]->GetAlternateName().c_str()));
}
-bool Field::set_user_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_user_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
- return m_bCanSet;
+ return CJS_Return(m_bCanSet);
}
-bool Field::get_value(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_value(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
+
+ v8::Local<v8::Value> ret;
CPDF_FormField* pFormField = FieldArray[0];
switch (pFormField->GetFieldType()) {
case FIELDTYPE_PUSHBUTTON:
- return false;
+ return CJS_Return(false);
case FIELDTYPE_COMBOBOX:
case FIELDTYPE_TEXTFIELD:
- vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
+ ret = pRuntime->NewString(pFormField->GetValue().c_str());
break;
case FIELDTYPE_LISTBOX: {
if (pFormField->CountSelectedItems() > 1) {
@@ -2292,11 +2048,11 @@ bool Field::get_value(CJS_Runtime* pRuntime,
}
if (ValueArray.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
+ ret = pRuntime->NewArray();
else
- vp->Set(ValueArray.ToV8Value());
+ ret = ValueArray.ToV8Value();
} else {
- vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
+ ret = pRuntime->NewString(pFormField->GetValue().c_str());
}
break;
}
@@ -2305,30 +2061,27 @@ bool Field::get_value(CJS_Runtime* pRuntime,
bool bFind = false;
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
if (pFormField->GetControl(i)->IsChecked()) {
- vp->Set(pRuntime->NewString(
- pFormField->GetControl(i)->GetExportValue().c_str()));
+ ret = pRuntime->NewString(
+ pFormField->GetControl(i)->GetExportValue().c_str());
bFind = true;
break;
}
}
if (!bFind)
- vp->Set(pRuntime->NewString(L"Off"));
+ ret = pRuntime->NewString(L"Off");
break;
}
default:
- vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
+ ret = pRuntime->NewString(pFormField->GetValue().c_str());
break;
}
- vp->Set(pRuntime->MaybeCoerceToNumber(vp->ToV8Value()));
- return true;
+ return CJS_Return(pRuntime->MaybeCoerceToNumber(ret));
}
-bool Field::set_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return Field::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
std::vector<WideString> strArray;
if (!vp.IsEmpty() && vp->IsArray()) {
@@ -2347,7 +2100,7 @@ bool Field::set_value(CJS_Runtime* pRuntime,
Field::SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
strArray);
}
- return true;
+ return CJS_Return(true);
}
void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -2374,12 +2127,12 @@ void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
break;
case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON: {
+ case FIELDTYPE_RADIOBUTTON:
if (pFormField->GetValue() != strArray[0]) {
pFormField->SetValue(strArray[0], true);
UpdateFormField(pFormFillEnv, pFormField, true, false, true);
}
- } break;
+ break;
case FIELDTYPE_LISTBOX: {
bool bModified = false;
for (const auto& str : strArray) {
@@ -2397,71 +2150,59 @@ void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
UpdateFormField(pFormFillEnv, pFormField, true, false, true);
}
- } break;
+ break;
+ }
default:
break;
}
}
}
-bool Field::get_value_as_string(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return Field::get_value_as_string(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
if (pFormField->GetFieldType() == FIELDTYPE_CHECKBOX) {
if (!pFormField->CountControls())
- return false;
-
- vp->Set(pRuntime->NewString(
+ return CJS_Return(false);
+ return CJS_Return(pRuntime->NewString(
pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off"));
- return true;
}
if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON &&
!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) {
for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
if (pFormField->GetControl(i)->IsChecked()) {
- vp->Set(pRuntime->NewString(
+ return CJS_Return(pRuntime->NewString(
pFormField->GetControl(i)->GetExportValue().c_str()));
- break;
- } else {
- vp->Set(pRuntime->NewString(L"Off"));
}
}
- return true;
+ return CJS_Return(pRuntime->NewString(L"Off"));
}
if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX &&
(pFormField->CountSelectedItems() > 1)) {
- vp->Set(pRuntime->NewString(L""));
- } else {
- vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
+ return CJS_Return(pRuntime->NewString(L""));
}
-
- return true;
+ return CJS_Return(pRuntime->NewString(pFormField->GetValue().c_str()));
}
-bool Field::set_value_as_string(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return Field::set_value_as_string(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool Field::browseForFileToSubmit(
+CJS_Return Field::browseForFileToSubmit(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) &&
@@ -2471,15 +2212,14 @@ bool Field::browseForFileToSubmit(
pFormField->SetValue(wsFileName);
UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true);
}
- return true;
+ return CJS_Return(true);
}
- return false;
+ return CJS_Return(false);
}
-bool Field::buttonGetCaption(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::buttonGetCaption(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int nface = 0;
int iSize = params.size();
if (iSize >= 1)
@@ -2487,96 +2227,88 @@ bool Field::buttonGetCaption(CJS_Runtime* pRuntime,
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
- if (nface == 0)
- vRet = CJS_Value(
+ if (nface == 0) {
+ return CJS_Return(
pRuntime->NewString(pFormControl->GetNormalCaption().c_str()));
- else if (nface == 1)
- vRet =
- CJS_Value(pRuntime->NewString(pFormControl->GetDownCaption().c_str()));
- else if (nface == 2)
- vRet = CJS_Value(
+ } else if (nface == 1) {
+ return CJS_Return(
+ pRuntime->NewString(pFormControl->GetDownCaption().c_str()));
+ } else if (nface == 2) {
+ return CJS_Return(
pRuntime->NewString(pFormControl->GetRolloverCaption().c_str()));
- else
- return false;
-
- return true;
+ }
+ return CJS_Return(false);
}
-bool Field::buttonGetIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::buttonGetIcon(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() >= 1) {
int nFace = pRuntime->ToInt32(params[0]);
if (nFace < 0 || nFace > 2)
- return false;
+ return CJS_Return(false);
}
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
- return false;
+ return CJS_Return(false);
CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
if (!pFormControl)
- return false;
+ return CJS_Return(false);
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
if (pObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
- if (pJS_Icon)
- vRet = CJS_Value(pJS_Icon->ToV8Object());
-
- return true;
+ if (!pJS_Icon)
+ return CJS_Return(false);
+ return CJS_Return(pJS_Icon->ToV8Object());
}
-bool Field::buttonImportIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Field::buttonImportIcon(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Field::buttonSetCaption(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return Field::buttonSetCaption(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::buttonSetIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return Field::buttonSetIcon(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::checkThisBox(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::checkThisBox(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
if (iSize < 1)
- return false;
+ return CJS_Return(false);
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
int nWidget = pRuntime->ToInt32(params[0]);
bool bCheckit = true;
@@ -2585,14 +2317,15 @@ bool Field::checkThisBox(CJS_Runtime* pRuntime,
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (pFormField->GetFieldType() != FIELDTYPE_CHECKBOX &&
- pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
- return false;
+ pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) {
+ return CJS_Return(false);
+ }
if (nWidget < 0 || nWidget >= pFormField->CountControls())
- return false;
+ return CJS_Return(false);
// TODO(weili): Check whether anything special needed for radio button,
// otherwise merge these branches.
if (pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON)
@@ -2601,57 +2334,49 @@ bool Field::checkThisBox(CJS_Runtime* pRuntime,
pFormField->CheckControl(nWidget, bCheckit, true);
UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true);
- return true;
+ return CJS_Return(true);
}
-bool Field::clearItems(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Field::clearItems(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Field::defaultIsChecked(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::defaultIsChecked(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!m_bCanSet)
- return false;
+ return CJS_Return(false);
int iSize = params.size();
if (iSize < 1)
- return false;
+ return CJS_Return(false);
int nWidget = pRuntime->ToInt32(params[0]);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (nWidget < 0 || nWidget >= pFormField->CountControls())
- return false;
+ return CJS_Return(false);
- vRet = CJS_Value(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
pFormField->GetFieldType() == FIELDTYPE_CHECKBOX ||
pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON));
-
- return true;
}
-bool Field::deleteItemAt(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Field::deleteItemAt(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Field::getArray(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::getArray(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
std::vector<std::unique_ptr<WideString>> swSort;
for (CPDF_FormField* pFormField : FieldArray) {
@@ -2670,7 +2395,7 @@ bool Field::getArray(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pObj =
pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
if (pObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_Field* pJSField =
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pObj));
@@ -2683,17 +2408,12 @@ bool Field::getArray(CJS_Runtime* pRuntime,
}
if (FormFieldArray.ToV8Value().IsEmpty())
- vRet = CJS_Value(pRuntime->NewArray());
- else
- vRet = CJS_Value(FormFieldArray.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(FormFieldArray.ToV8Value());
}
-bool Field::getItemAt(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::getItemAt(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
int nIdx = -1;
if (iSize >= 1)
@@ -2705,7 +2425,7 @@ bool Field::getItemAt(CJS_Runtime* pRuntime,
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) ||
@@ -2714,101 +2434,86 @@ bool Field::getItemAt(CJS_Runtime* pRuntime,
nIdx = pFormField->CountOptions() - 1;
if (bExport) {
WideString strval = pFormField->GetOptionValue(nIdx);
- if (strval.IsEmpty())
- vRet = CJS_Value(
+ if (strval.IsEmpty()) {
+ return CJS_Return(
pRuntime->NewString(pFormField->GetOptionLabel(nIdx).c_str()));
- else
- vRet = CJS_Value(pRuntime->NewString(strval.c_str()));
- } else {
- vRet = CJS_Value(
- pRuntime->NewString(pFormField->GetOptionLabel(nIdx).c_str()));
+ }
+ return CJS_Return(pRuntime->NewString(strval.c_str()));
}
- } else {
- return false;
+ return CJS_Return(
+ pRuntime->NewString(pFormField->GetOptionLabel(nIdx).c_str()));
}
-
- return true;
+ return CJS_Return(false);
}
-bool Field::getLock(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return Field::getLock(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::insertItemAt(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Field::insertItemAt(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Field::isBoxChecked(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::isBoxChecked(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int nIndex = -1;
if (params.size() >= 1)
nIndex = pRuntime->ToInt32(params[0]);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (nIndex < 0 || nIndex >= pFormField->CountControls())
- return false;
+ return CJS_Return(false);
- vRet = CJS_Value(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX ||
pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) &&
pFormField->GetControl(nIndex)->IsChecked() != 0)));
- return true;
}
-bool Field::isDefaultChecked(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::isDefaultChecked(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int nIndex = -1;
if (params.size() >= 1)
nIndex = pRuntime->ToInt32(params[0]);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
if (nIndex < 0 || nIndex >= pFormField->CountControls())
- return false;
+ return CJS_Return(false);
- vRet = CJS_Value(pRuntime->NewBoolean(
+ return CJS_Return(pRuntime->NewBoolean(
((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX ||
pFormField->GetFieldType() == FIELDTYPE_RADIOBUTTON) &&
pFormField->GetControl(nIndex)->IsDefaultChecked() != 0)));
- return true;
}
-bool Field::setAction(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Field::setAction(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Field::setFocus(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Field::setFocus(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
- return false;
+ return CJS_Return(false);
CPDF_FormField* pFormField = FieldArray[0];
int32_t nCount = pFormField->CountControls();
if (nCount < 1)
- return false;
+ return CJS_Return(false);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDFSDK_Widget* pWidget = nullptr;
@@ -2819,7 +2524,7 @@ bool Field::setFocus(CJS_Runtime* pRuntime,
UnderlyingFromFPDFPage(m_pFormFillEnv->GetCurrentPage(
m_pFormFillEnv->GetUnderlyingDocument()));
if (!pPage)
- return false;
+ return CJS_Return(false);
if (CPDFSDK_PageView* pCurPageView =
m_pFormFillEnv->GetPageView(pPage, true)) {
for (int32_t i = 0; i < nCount; i++) {
@@ -2839,79 +2544,61 @@ bool Field::setFocus(CJS_Runtime* pRuntime,
m_pFormFillEnv->SetFocusAnnot(&pObserved);
}
- return true;
+ return CJS_Return(true);
}
-bool Field::setItems(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return Field::setItems(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool Field::setLock(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return Field::setLock(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::signatureGetModifications(
+CJS_Return Field::signatureGetModifications(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::signatureGetSeedValue(
+CJS_Return Field::signatureGetSeedValue(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::signatureInfo(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return Field::signatureInfo(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::signatureSetSeedValue(
+CJS_Return Field::signatureSetSeedValue(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::signatureSign(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return Field::signatureSign(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::signatureValidate(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return Field::signatureValidate(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool Field::get_source(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(v8::Local<v8::Value>());
- return true;
+CJS_Return Field::get_source(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool Field::set_source(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return Field::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
void Field::AddDelay_Int(FIELD_PROP prop, int32_t n) {
diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h
index 8ea8459866..37c7d4200e 100644
--- a/fpdfsdk/javascript/Field.h
+++ b/fpdfsdk/javascript/Field.h
@@ -53,413 +53,229 @@ class Field : public CJS_EmbedObj {
explicit Field(CJS_Object* pJSObject);
~Field() override;
- bool get_alignment(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_alignment(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_border_style(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_border_style(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_button_align_x(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_button_align_x(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_button_align_y(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_button_align_y(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_button_fit_bounds(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_button_fit_bounds(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_button_position(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_button_position(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_button_scale_how(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_button_scale_how(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_button_scale_when(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_button_scale_when(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_calc_order_index(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_calc_order_index(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_char_limit(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_char_limit(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_comb(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_comb(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_commit_on_sel_change(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_commit_on_sel_change(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_current_value_indices(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_current_value_indices(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_default_style(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_default_style(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_default_value(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_default_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_do_not_scroll(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_do_not_scroll(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_do_not_spell_check(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_do_not_spell_check(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_delay(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_delay(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_display(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_display(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_doc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_doc(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_editable(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_editable(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_export_values(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_export_values(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_file_select(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_file_select(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_fill_color(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_fill_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_hidden(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_hidden(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_highlight(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_highlight(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_line_width(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_line_width(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_multiline(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_multiline(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_multiple_selection(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_multiple_selection(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_num_items(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_num_items(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_page(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_page(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_password(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_password(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_print(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_print(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_radios_in_unison(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_radios_in_unison(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_readonly(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_readonly(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_rect(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_rect(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_required(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_required(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_rich_text(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_rich_text(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_rich_value(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_rich_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_rotation(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_rotation(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_stroke_color(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_stroke_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_style(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_style(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_submit_name(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_submit_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_text_color(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_text_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_text_font(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_text_font(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_text_size(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_text_size(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_user_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_user_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_value(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_value_as_string(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_value_as_string(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_source(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_source(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool browseForFileToSubmit(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool buttonGetCaption(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool buttonGetIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool buttonImportIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool buttonSetCaption(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool buttonSetIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool checkThisBox(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool clearItems(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool defaultIsChecked(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool deleteItemAt(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getArray(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getItemAt(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool getLock(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool insertItemAt(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool isBoxChecked(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool isDefaultChecked(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool setAction(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool setFocus(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool setItems(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool setLock(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool signatureGetModifications(
+ CJS_Return get_alignment(CJS_Runtime* pRuntime);
+ CJS_Return set_alignment(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_border_style(CJS_Runtime* pRuntime);
+ CJS_Return set_border_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_button_align_x(CJS_Runtime* pRuntime);
+ CJS_Return set_button_align_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_button_align_y(CJS_Runtime* pRuntime);
+ CJS_Return set_button_align_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_button_fit_bounds(CJS_Runtime* pRuntime);
+ CJS_Return set_button_fit_bounds(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_button_position(CJS_Runtime* pRuntime);
+ CJS_Return set_button_position(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_button_scale_how(CJS_Runtime* pRuntime);
+ CJS_Return set_button_scale_how(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_button_scale_when(CJS_Runtime* pRuntime);
+ CJS_Return set_button_scale_when(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_calc_order_index(CJS_Runtime* pRuntime);
+ CJS_Return set_calc_order_index(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_char_limit(CJS_Runtime* pRuntime);
+ CJS_Return set_char_limit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_comb(CJS_Runtime* pRuntime);
+ CJS_Return set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_commit_on_sel_change(CJS_Runtime* pRuntime);
+ CJS_Return set_commit_on_sel_change(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_current_value_indices(CJS_Runtime* pRuntime);
+ CJS_Return set_current_value_indices(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_default_style(CJS_Runtime* pRuntime);
+ CJS_Return set_default_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_default_value(CJS_Runtime* pRuntime);
+ CJS_Return set_default_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_do_not_scroll(CJS_Runtime* pRuntime);
+ CJS_Return set_do_not_scroll(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_do_not_spell_check(CJS_Runtime* pRuntime);
+ CJS_Return set_do_not_spell_check(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_delay(CJS_Runtime* pRuntime);
+ CJS_Return set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_display(CJS_Runtime* pRuntime);
+ CJS_Return set_display(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_doc(CJS_Runtime* pRuntime);
+ CJS_Return set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_editable(CJS_Runtime* pRuntime);
+ CJS_Return set_editable(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_export_values(CJS_Runtime* pRuntime);
+ CJS_Return set_export_values(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_file_select(CJS_Runtime* pRuntime);
+ CJS_Return set_file_select(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_fill_color(CJS_Runtime* pRuntime);
+ CJS_Return set_fill_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_hidden(CJS_Runtime* pRuntime);
+ CJS_Return set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_highlight(CJS_Runtime* pRuntime);
+ CJS_Return set_highlight(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_line_width(CJS_Runtime* pRuntime);
+ CJS_Return set_line_width(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_multiline(CJS_Runtime* pRuntime);
+ CJS_Return set_multiline(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_multiple_selection(CJS_Runtime* pRuntime);
+ CJS_Return set_multiple_selection(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_name(CJS_Runtime* pRuntime);
+ CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_num_items(CJS_Runtime* pRuntime);
+ CJS_Return set_num_items(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_page(CJS_Runtime* pRuntime);
+ CJS_Return set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_password(CJS_Runtime* pRuntime);
+ CJS_Return set_password(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_print(CJS_Runtime* pRuntime);
+ CJS_Return set_print(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_radios_in_unison(CJS_Runtime* pRuntime);
+ CJS_Return set_radios_in_unison(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_readonly(CJS_Runtime* pRuntime);
+ CJS_Return set_readonly(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_rect(CJS_Runtime* pRuntime);
+ CJS_Return set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_required(CJS_Runtime* pRuntime);
+ CJS_Return set_required(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_rich_text(CJS_Runtime* pRuntime);
+ CJS_Return set_rich_text(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_rich_value(CJS_Runtime* pRuntime);
+ CJS_Return set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_rotation(CJS_Runtime* pRuntime);
+ CJS_Return set_rotation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_stroke_color(CJS_Runtime* pRuntime);
+ CJS_Return set_stroke_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_style(CJS_Runtime* pRuntime);
+ CJS_Return set_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_submit_name(CJS_Runtime* pRuntime);
+ CJS_Return set_submit_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_text_color(CJS_Runtime* pRuntime);
+ CJS_Return set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_text_font(CJS_Runtime* pRuntime);
+ CJS_Return set_text_font(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_text_size(CJS_Runtime* pRuntime);
+ CJS_Return set_text_size(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_type(CJS_Runtime* pRuntime);
+ CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_user_name(CJS_Runtime* pRuntime);
+ CJS_Return set_user_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_value(CJS_Runtime* pRuntime);
+ CJS_Return set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_value_as_string(CJS_Runtime* pRuntime);
+ CJS_Return set_value_as_string(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_source(CJS_Runtime* pRuntime);
+ CJS_Return set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return browseForFileToSubmit(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return buttonGetCaption(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return buttonGetIcon(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return buttonImportIcon(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return buttonSetCaption(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return buttonSetIcon(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return checkThisBox(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return clearItems(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return defaultIsChecked(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return deleteItemAt(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getArray(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getItemAt(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return getLock(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return insertItemAt(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return isBoxChecked(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return isDefaultChecked(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return setAction(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return setFocus(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return setItems(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return setLock(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return signatureGetModifications(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return signatureGetSeedValue(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return signatureInfo(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return signatureSetSeedValue(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool signatureGetSeedValue(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool signatureInfo(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool signatureSetSeedValue(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool signatureSign(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool signatureValidate(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return signatureSign(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return signatureValidate(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
bool AttachField(Document* pDocument, const WideString& csFieldName);
diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp
index dbd3e64cb1..2eefaf113c 100644
--- a/fpdfsdk/javascript/Icon.cpp
+++ b/fpdfsdk/javascript/Icon.cpp
@@ -25,13 +25,10 @@ Icon::Icon(CJS_Object* pJSObject)
Icon::~Icon() {}
-bool Icon::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- vp->Set(pRuntime->NewString(m_swIconName.c_str()));
- return true;
+CJS_Return Icon::get_name(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewString(m_swIconName.c_str()));
}
-bool Icon::set_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return Icon::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
diff --git a/fpdfsdk/javascript/Icon.h b/fpdfsdk/javascript/Icon.h
index 89c185a56d..704ecbdb45 100644
--- a/fpdfsdk/javascript/Icon.h
+++ b/fpdfsdk/javascript/Icon.h
@@ -16,10 +16,8 @@ class Icon : public CJS_EmbedObj {
explicit Icon(CJS_Object* pJSObject);
~Icon() override;
- bool get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
+ CJS_Return get_name(CJS_Runtime* pRuntime);
+ CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
WideString GetIconName() const { return m_swIconName; }
void SetIconName(WideString name) { m_swIconName = name; }
diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h
index 39346135c5..b5afc95e51 100644
--- a/fpdfsdk/javascript/JS_Define.h
+++ b/fpdfsdk/javascript/JS_Define.h
@@ -34,7 +34,7 @@ struct JSMethodSpec {
v8::FunctionCallback pMethodCall;
};
-template <class C, bool (C::*M)(CJS_Runtime*, CJS_Value*, WideString*)>
+template <class C, CJS_Return (C::*M)(CJS_Runtime*)>
void JSPropGetter(const char* prop_name_string,
const char* class_name_string,
v8::Local<v8::String> property,
@@ -50,20 +50,18 @@ void JSPropGetter(const char* prop_name_string,
return;
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
- WideString sError;
-
- CJS_Value prop_value;
- if (!(pObj->*M)(pRuntime, &prop_value, &sError)) {
- pRuntime->Error(
- JSFormatErrorString(class_name_string, prop_name_string, sError));
+ CJS_Return result = (pObj->*M)(pRuntime);
+ if (result.HasError()) {
+ pRuntime->Error(JSFormatErrorString(class_name_string, prop_name_string,
+ result.Error()));
return;
}
- if (!prop_value.ToV8Value().IsEmpty())
- info.GetReturnValue().Set(prop_value.ToV8Value());
+
+ if (result.HasReturn())
+ info.GetReturnValue().Set(result.Return());
}
-template <class C,
- bool (C::*M)(CJS_Runtime*, v8::Local<v8::Value>, WideString*)>
+template <class C, CJS_Return (C::*M)(CJS_Runtime*, v8::Local<v8::Value>)>
void JSPropSetter(const char* prop_name_string,
const char* class_name_string,
v8::Local<v8::String> property,
@@ -80,11 +78,10 @@ void JSPropSetter(const char* prop_name_string,
return;
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
- WideString sError;
-
- if (!(pObj->*M)(pRuntime, value, &sError)) {
- pRuntime->Error(
- JSFormatErrorString(class_name_string, prop_name_string, sError));
+ CJS_Return result = (pObj->*M)(pRuntime, value);
+ if (result.HasError()) {
+ pRuntime->Error(JSFormatErrorString(class_name_string, prop_name_string,
+ result.Error()));
}
}
@@ -103,10 +100,8 @@ void JSPropSetter(const char* prop_name_string,
}
template <class C,
- bool (C::*M)(CJS_Runtime*,
- const std::vector<v8::Local<v8::Value>>&,
- CJS_Value&,
- WideString&)>
+ CJS_Return (C::*M)(CJS_Runtime*,
+ const std::vector<v8::Local<v8::Value>>&)>
void JSMethod(const char* method_name_string,
const char* class_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
@@ -115,25 +110,25 @@ void JSMethod(const char* method_name_string,
if (!pRuntime)
return;
- std::vector<v8::Local<v8::Value>> parameters;
- for (unsigned int i = 0; i < (unsigned int)info.Length(); i++)
- parameters.push_back(info[i]);
-
CJS_Object* pJSObj =
static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(info.Holder()));
if (!pJSObj)
return;
+ std::vector<v8::Local<v8::Value>> parameters;
+ for (unsigned int i = 0; i < (unsigned int)info.Length(); i++)
+ parameters.push_back(info[i]);
+
C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
- WideString sError;
- CJS_Value valueRes;
- if (!(pObj->*M)(pRuntime, parameters, valueRes, sError)) {
- pRuntime->Error(
- JSFormatErrorString(class_name_string, method_name_string, sError));
+ CJS_Return result = (pObj->*M)(pRuntime, parameters);
+ if (result.HasError()) {
+ pRuntime->Error(JSFormatErrorString(class_name_string, method_name_string,
+ result.Error()));
return;
}
- if (!valueRes.ToV8Value().IsEmpty())
- info.GetReturnValue().Set(valueRes.ToV8Value());
+
+ if (result.HasReturn())
+ info.GetReturnValue().Set(result.Return());
}
#define JS_STATIC_METHOD(method_name, class_name) \
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp
index bac338ad66..a8b6ad6bcd 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Value.cpp
@@ -178,6 +178,17 @@ double JS_LocalTime(double d) {
} // namespace
+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(v8::Local<v8::Value> ret)
+ : is_error_(false), return_(ret) {}
+
+CJS_Return::CJS_Return(const CJS_Return&) = default;
+
+CJS_Return::~CJS_Return() = default;
+
CJS_Value::CJS_Value() {}
CJS_Value::CJS_Value(v8::Local<v8::Value> pValue) : m_pValue(pValue) {}
diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h
index b97a7061e3..c508fe80d7 100644
--- a/fpdfsdk/javascript/JS_Value.h
+++ b/fpdfsdk/javascript/JS_Value.h
@@ -17,6 +17,28 @@ class CJS_Document;
class CJS_Object;
class CJS_Runtime;
+class CJS_Return {
+ public:
+ explicit CJS_Return(bool);
+ explicit CJS_Return(const WideString&);
+ explicit CJS_Return(v8::Local<v8::Value>);
+ CJS_Return(const CJS_Return&);
+ ~CJS_Return();
+
+ bool HasError() const { return is_error_; }
+ WideString Error() const { return error_; }
+
+ bool HasReturn() const { return !return_.IsEmpty(); }
+ v8::Local<v8::Value> Return() const { return return_; }
+
+ private:
+ CJS_Return() = delete;
+
+ bool is_error_ = false;
+ WideString error_;
+ v8::Local<v8::Value> return_;
+};
+
class CJS_Value {
public:
CJS_Value();
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 667127fe88..1cf63dc298 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -111,11 +111,8 @@ ByteString CalculateString(double dValue,
}
#endif
-// NOLINTNEXTLINE(whitespace/parens)
-template <bool (*F)(CJS_Runtime*,
- const std::vector<v8::Local<v8::Value>>&,
- CJS_Value&,
- WideString&)>
+template <CJS_Return (*F)(CJS_Runtime*,
+ const std::vector<v8::Local<v8::Value>>&)>
void JSGlobalFunc(const char* func_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
CJS_Runtime* pRuntime =
@@ -127,13 +124,15 @@ void JSGlobalFunc(const char* func_name_string,
for (unsigned int i = 0; i < (unsigned int)info.Length(); i++)
parameters.push_back(info[i]);
- CJS_Value valueRes;
- WideString sError;
- if (!(*F)(pRuntime, parameters, valueRes, sError)) {
- pRuntime->Error(JSFormatErrorString(func_name_string, nullptr, sError));
+ CJS_Return result = (*F)(pRuntime, parameters);
+ if (result.HasError()) {
+ pRuntime->Error(
+ JSFormatErrorString(func_name_string, nullptr, result.Error()));
return;
}
- info.GetReturnValue().Set(valueRes.ToV8Value());
+
+ if (result.HasReturn())
+ info.GetReturnValue().Set(result.Return());
}
} // namespace
@@ -808,26 +807,22 @@ WideString CJS_PublicMethods::MakeFormatDate(double dDate,
// function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency,
// bCurrencyPrepend)
-bool CJS_PublicMethods::AFNumber_Format(
+CJS_Return CJS_PublicMethods::AFNumber_Format(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+ const std::vector<v8::Local<v8::Value>>& params) {
#if _FX_OS_ != _FX_OS_ANDROID_
- if (params.size() != 6) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ if (params.size() != 6)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
WideString& Value = pEvent->Value();
ByteString strValue = StrTrim(ByteString::FromUnicode(Value));
if (strValue.IsEmpty())
- return true;
+ return CJS_Return(true);
int iDec = pRuntime->ToInt32(params[0]);
int iSepStyle = pRuntime->ToInt32(params[1]);
@@ -885,7 +880,6 @@ bool CJS_PublicMethods::AFNumber_Format(
// Processing currency string
Value = WideString::FromLocal(strValue.AsStringView());
-
if (bCurrencyPrepend)
Value = wstrCurrency + Value;
else
@@ -904,7 +898,7 @@ bool CJS_PublicMethods::AFNumber_Format(
arColor.SetElement(pRuntime, 1, pRuntime->NewNumber(1));
arColor.SetElement(pRuntime, 2, pRuntime->NewNumber(0));
arColor.SetElement(pRuntime, 3, pRuntime->NewNumber(0));
- fTarget->set_text_color(pRuntime, arColor.ToV8Value(), &sError); // red
+ fTarget->set_text_color(pRuntime, arColor.ToV8Value());
}
}
} else {
@@ -916,35 +910,31 @@ bool CJS_PublicMethods::AFNumber_Format(
arColor.SetElement(pRuntime, 2, pRuntime->NewNumber(0));
arColor.SetElement(pRuntime, 3, pRuntime->NewNumber(0));
- CJS_Value vProp;
- fTarget->get_text_color(pRuntime, &vProp, &sError);
-
+ CJS_Return result = fTarget->get_text_color(pRuntime);
CFX_Color crProp = color::ConvertArrayToPWLColor(
- pRuntime, CJS_Array(pRuntime->ToArray(vProp.ToV8Value())));
+ pRuntime, CJS_Array(pRuntime->ToArray(result.Return())));
CFX_Color crColor = color::ConvertArrayToPWLColor(pRuntime, arColor);
if (crColor != crProp)
- fTarget->set_text_color(pRuntime, arColor.ToV8Value(), &sError);
+ fTarget->set_text_color(pRuntime, arColor.ToV8Value());
}
}
}
#endif
- return true;
+ return CJS_Return(true);
}
// function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
// bCurrencyPrepend)
-bool CJS_PublicMethods::AFNumber_Keystroke(
+CJS_Return CJS_PublicMethods::AFNumber_Keystroke(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return false;
+ return CJS_Return(false);
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
WideString& val = pEvent->Value();
WideString& wstrChange = pEvent->Change();
@@ -953,15 +943,17 @@ bool CJS_PublicMethods::AFNumber_Keystroke(
if (pEvent->WillCommit()) {
WideString swTemp = StrTrim(wstrValue);
if (swTemp.IsEmpty())
- return true;
+ return CJS_Return(true);
swTemp.Replace(L",", L".");
if (!IsNumber(swTemp.c_str())) {
pEvent->Rc() = false;
- sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE);
+ WideString sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE);
AlertIfPossible(pContext, sError.c_str());
+ return CJS_Return(sError);
}
- return true; // it happens after the last keystroke and before validating,
+ // It happens after the last keystroke and before validating,
+ return CJS_Return(true);
}
WideString wstrSelected;
@@ -975,7 +967,7 @@ bool CJS_PublicMethods::AFNumber_Keystroke(
// can't insert "change" in front to sign postion.
if (pEvent->SelStart() == 0) {
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
}
@@ -989,7 +981,7 @@ bool CJS_PublicMethods::AFNumber_Keystroke(
if (wstrChange[i] == cSep) {
if (bHasSep) {
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
bHasSep = true;
continue;
@@ -997,16 +989,16 @@ bool CJS_PublicMethods::AFNumber_Keystroke(
if (wstrChange[i] == L'-') {
if (bHasSign) {
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
// sign's position is not correct
if (i != 0) {
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
if (pEvent->SelStart() != 0) {
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
bHasSign = true;
continue;
@@ -1014,7 +1006,7 @@ bool CJS_PublicMethods::AFNumber_Keystroke(
if (!std::iswdigit(wstrChange[i])) {
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
}
@@ -1025,30 +1017,26 @@ bool CJS_PublicMethods::AFNumber_Keystroke(
wpostfix = wstrValue.Right(wstrValue.GetLength() -
static_cast<size_t>(pEvent->SelEnd()));
val = wprefix + wstrChange + wpostfix;
- return true;
+ return CJS_Return(true);
}
// function AFPercent_Format(nDec, sepStyle)
-bool CJS_PublicMethods::AFPercent_Format(
+CJS_Return CJS_PublicMethods::AFPercent_Format(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+ const std::vector<v8::Local<v8::Value>>& params) {
#if _FX_OS_ != _FX_OS_ANDROID_
- if (params.size() != 2) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
WideString& Value = pEvent->Value();
ByteString strValue = StrTrim(ByteString::FromUnicode(Value));
if (strValue.IsEmpty())
- return true;
+ return CJS_Return(true);
int iDec = pRuntime->ToInt32(params[0]);
if (iDec < 0)
@@ -1073,16 +1061,16 @@ bool CJS_PublicMethods::AFPercent_Format(
}
if (iDec2 < 0) {
- for (int iNum = 0; iNum < abs(iDec2); iNum++) {
+ for (int iNum = 0; iNum < abs(iDec2); iNum++)
strValue = "0" + strValue;
- }
+
iDec2 = 0;
}
int iMax = strValue.GetLength();
if (iDec2 > iMax) {
- for (int iNum = 0; iNum <= iDec2 - iMax; iNum++) {
+ for (int iNum = 0; iNum <= iDec2 - iMax; iNum++)
strValue += "0";
- }
+
iMax = iDec2 + 1;
}
@@ -1115,40 +1103,36 @@ bool CJS_PublicMethods::AFPercent_Format(
// negative mark
if (iNegative)
strValue = "-" + strValue;
+
strValue += "%";
Value = WideString::FromLocal(strValue.AsStringView());
#endif
- return true;
+ return CJS_Return(true);
}
+
// AFPercent_Keystroke(nDec, sepStyle)
-bool CJS_PublicMethods::AFPercent_Keystroke(
+CJS_Return CJS_PublicMethods::AFPercent_Keystroke(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return AFNumber_Keystroke(pRuntime, params, vRet, sError);
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return AFNumber_Keystroke(pRuntime, params);
}
// function AFDate_FormatEx(cFormat)
-bool CJS_PublicMethods::AFDate_FormatEx(
+CJS_Return CJS_PublicMethods::AFDate_FormatEx(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
WideString& val = pEvent->Value();
WideString strValue = val;
if (strValue.IsEmpty())
- return true;
+ return CJS_Return(true);
WideString sFormat = pRuntime->ToWideString(params[0]);
double dDate = 0.0f;
@@ -1166,11 +1150,11 @@ bool CJS_PublicMethods::AFDate_FormatEx(
swMsg.Format(JSGetStringFromID(IDS_STRING_JSPARSEDATE).c_str(),
sFormat.c_str());
AlertIfPossible(pContext, swMsg.c_str());
- return false;
+ return CJS_Return(false);
}
val = MakeFormatDate(dDate, sFormat);
- return true;
+ return CJS_Return(true);
}
double CJS_PublicMethods::MakeInterDate(const WideString& strValue) {
@@ -1229,25 +1213,22 @@ double CJS_PublicMethods::MakeInterDate(const WideString& strValue) {
}
// AFDate_KeystrokeEx(cFormat)
-bool CJS_PublicMethods::AFDate_KeystrokeEx(
+CJS_Return CJS_PublicMethods::AFDate_KeystrokeEx(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = L"AFDate_KeystrokeEx's parameters' size r not correct";
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(
+ WideString(L"AFDate_KeystrokeEx's parameters' size r not correct"));
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (pEvent->WillCommit()) {
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
WideString strValue = pEvent->Value();
if (strValue.IsEmpty())
- return true;
+ return CJS_Return(true);
WideString sFormat = pRuntime->ToWideString(params[0]);
bool bWrongFormat = false;
@@ -1258,21 +1239,17 @@ bool CJS_PublicMethods::AFDate_KeystrokeEx(
sFormat.c_str());
AlertIfPossible(pContext, swMsg.c_str());
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
}
- return true;
+ return CJS_Return(true);
}
-bool CJS_PublicMethods::AFDate_Format(
+CJS_Return CJS_PublicMethods::AFDate_Format(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
int iIndex = pRuntime->ToInt32(params[0]);
const wchar_t* cFormats[] = {L"m/d",
@@ -1295,19 +1272,15 @@ bool CJS_PublicMethods::AFDate_Format(
std::vector<v8::Local<v8::Value>> newParams;
newParams.push_back(pRuntime->NewString(cFormats[iIndex]));
- return AFDate_FormatEx(pRuntime, newParams, vRet, sError);
+ return AFDate_FormatEx(pRuntime, newParams);
}
// AFDate_KeystrokeEx(cFormat)
-bool CJS_PublicMethods::AFDate_Keystroke(
+CJS_Return CJS_PublicMethods::AFDate_Keystroke(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
int iIndex = pRuntime->ToInt32(params[0]);
const wchar_t* cFormats[] = {L"m/d",
@@ -1330,19 +1303,15 @@ bool CJS_PublicMethods::AFDate_Keystroke(
std::vector<v8::Local<v8::Value>> newParams;
newParams.push_back(pRuntime->NewString(cFormats[iIndex]));
- return AFDate_KeystrokeEx(pRuntime, newParams, vRet, sError);
+ return AFDate_KeystrokeEx(pRuntime, newParams);
}
// function AFTime_Format(ptf)
-bool CJS_PublicMethods::AFTime_Format(
+CJS_Return CJS_PublicMethods::AFTime_Format(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
int iIndex = pRuntime->ToInt32(params[0]);
const wchar_t* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
@@ -1353,18 +1322,14 @@ bool CJS_PublicMethods::AFTime_Format(
std::vector<v8::Local<v8::Value>> newParams;
newParams.push_back(pRuntime->NewString(cFormats[iIndex]));
- return AFDate_FormatEx(pRuntime, newParams, vRet, sError);
+ return AFDate_FormatEx(pRuntime, newParams);
}
-bool CJS_PublicMethods::AFTime_Keystroke(
+CJS_Return CJS_PublicMethods::AFTime_Keystroke(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
int iIndex = pRuntime->ToInt32(params[0]);
const wchar_t* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
@@ -1375,40 +1340,32 @@ bool CJS_PublicMethods::AFTime_Keystroke(
std::vector<v8::Local<v8::Value>> newParams;
newParams.push_back(pRuntime->NewString(cFormats[iIndex]));
- return AFDate_KeystrokeEx(pRuntime, newParams, vRet, sError);
+ return AFDate_KeystrokeEx(pRuntime, newParams);
}
-bool CJS_PublicMethods::AFTime_FormatEx(
+CJS_Return CJS_PublicMethods::AFTime_FormatEx(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return AFDate_FormatEx(pRuntime, params, vRet, sError);
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return AFDate_FormatEx(pRuntime, params);
}
-bool CJS_PublicMethods::AFTime_KeystrokeEx(
+CJS_Return CJS_PublicMethods::AFTime_KeystrokeEx(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return AFDate_KeystrokeEx(pRuntime, params, vRet, sError);
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return AFDate_KeystrokeEx(pRuntime, params);
}
// function AFSpecial_Format(psf)
-bool CJS_PublicMethods::AFSpecial_Format(
+CJS_Return CJS_PublicMethods::AFSpecial_Format(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
WideString wsSource = pEvent->Value();
WideString wsFormat;
@@ -1431,33 +1388,29 @@ bool CJS_PublicMethods::AFSpecial_Format(
}
pEvent->Value() = util::printx(wsFormat, wsSource);
- return true;
+ return CJS_Return(true);
}
// function AFSpecial_KeystrokeEx(mask)
-bool CJS_PublicMethods::AFSpecial_KeystrokeEx(
+CJS_Return CJS_PublicMethods::AFSpecial_KeystrokeEx(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() < 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() < 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
WideString& valEvent = pEvent->Value();
WideString wstrMask = pRuntime->ToWideString(params[0]);
if (wstrMask.IsEmpty())
- return true;
+ return CJS_Return(true);
if (pEvent->WillCommit()) {
if (valEvent.IsEmpty())
- return true;
+ return CJS_Return(true);
size_t iIndexMask = 0;
for (; iIndexMask < valEvent.GetLength(); ++iIndexMask) {
@@ -1471,12 +1424,12 @@ bool CJS_PublicMethods::AFSpecial_KeystrokeEx(
pContext, JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE).c_str());
pEvent->Rc() = false;
}
- return true;
+ return CJS_Return(true);
}
WideString& wideChange = pEvent->Change();
if (wideChange.IsEmpty())
- return true;
+ return CJS_Return(true);
WideString wChange = wideChange;
size_t iIndexMask = pEvent->SelStart();
@@ -1486,14 +1439,14 @@ bool CJS_PublicMethods::AFSpecial_KeystrokeEx(
AlertIfPossible(pContext,
JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
if (iIndexMask >= wstrMask.GetLength() && !wChange.IsEmpty()) {
AlertIfPossible(pContext,
JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
for (size_t i = 0; i < wChange.GetLength(); ++i) {
@@ -1501,7 +1454,7 @@ bool CJS_PublicMethods::AFSpecial_KeystrokeEx(
AlertIfPossible(pContext,
JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG).c_str());
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
wchar_t wMask = wstrMask[iIndexMask];
if (!isReservedMaskChar(wMask))
@@ -1509,29 +1462,25 @@ bool CJS_PublicMethods::AFSpecial_KeystrokeEx(
if (!maskSatisfied(wChange[i], wMask)) {
pEvent->Rc() = false;
- return true;
+ return CJS_Return(true);
}
iIndexMask++;
}
wideChange = wChange;
- return true;
+ return CJS_Return(true);
}
// function AFSpecial_Keystroke(psf)
-bool CJS_PublicMethods::AFSpecial_Keystroke(
+CJS_Return CJS_PublicMethods::AFSpecial_Keystroke(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
const char* cFormat = "";
switch (pRuntime->ToInt32(params[0])) {
@@ -1554,18 +1503,14 @@ bool CJS_PublicMethods::AFSpecial_Keystroke(
std::vector<v8::Local<v8::Value>> params2;
params2.push_back(pRuntime->NewString(cFormat));
- return AFSpecial_KeystrokeEx(pRuntime, params2, vRet, sError);
+ return AFSpecial_KeystrokeEx(pRuntime, params2);
}
-bool CJS_PublicMethods::AFMergeChange(
+CJS_Return CJS_PublicMethods::AFMergeChange(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CJS_EventHandler* pEventHandler =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -1574,13 +1519,11 @@ bool CJS_PublicMethods::AFMergeChange(
if (pEventHandler->m_pValue)
swValue = pEventHandler->Value();
- if (pEventHandler->WillCommit()) {
- vRet = CJS_Value(pRuntime->NewString(swValue.c_str()));
- return true;
- }
-
- WideString prefix, postfix;
+ if (pEventHandler->WillCommit())
+ return CJS_Return(pRuntime->NewString(swValue.c_str()));
+ WideString prefix;
+ WideString postfix;
if (pEventHandler->SelStart() >= 0)
prefix = swValue.Left(pEventHandler->SelStart());
else
@@ -1593,20 +1536,15 @@ bool CJS_PublicMethods::AFMergeChange(
else
postfix = L"";
- vRet = CJS_Value(pRuntime->NewString(
+ return CJS_Return(pRuntime->NewString(
(prefix + pEventHandler->Change() + postfix).c_str()));
- return true;
}
-bool CJS_PublicMethods::AFParseDateEx(
+CJS_Return CJS_PublicMethods::AFParseDateEx(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 2) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
WideString sValue = pRuntime->ToWideString(params[0]);
WideString sFormat = pRuntime->ToWideString(params[1]);
@@ -1616,64 +1554,46 @@ bool CJS_PublicMethods::AFParseDateEx(
swMsg.Format(JSGetStringFromID(IDS_STRING_JSPARSEDATE).c_str(),
sFormat.c_str());
AlertIfPossible(pRuntime->GetCurrentEventContext(), swMsg.c_str());
- return false;
+ return CJS_Return(false);
}
-
- vRet = CJS_Value(pRuntime->NewNumber(dDate));
- return true;
+ return CJS_Return(pRuntime->NewNumber(dDate));
}
-bool CJS_PublicMethods::AFSimple(
+CJS_Return CJS_PublicMethods::AFSimple(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 3) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 3)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
- vRet = CJS_Value(pRuntime->NewNumber(static_cast<double>(AF_Simple(
+ return CJS_Return(pRuntime->NewNumber(static_cast<double>(AF_Simple(
pRuntime->ToWideString(params[0]).c_str(), pRuntime->ToDouble(params[1]),
pRuntime->ToDouble(params[2])))));
-
- return true;
}
-bool CJS_PublicMethods::AFMakeNumber(
+CJS_Return CJS_PublicMethods::AFMakeNumber(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
WideString ws = pRuntime->ToWideString(params[0]);
ws.Replace(L",", L".");
- vRet =
- CJS_Value(pRuntime->MaybeCoerceToNumber(pRuntime->NewString(ws.c_str())));
- if (!vRet.ToV8Value()->IsNumber())
- vRet = CJS_Value(pRuntime->NewNumber(0));
- return true;
+
+ v8::Local<v8::Value> val =
+ pRuntime->MaybeCoerceToNumber(pRuntime->NewString(ws.c_str()));
+ if (!val->IsNumber())
+ return CJS_Return(pRuntime->NewNumber(0));
+ return CJS_Return(val);
}
-bool CJS_PublicMethods::AFSimple_Calculate(
+CJS_Return CJS_PublicMethods::AFSimple_Calculate(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 2) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
- if ((params[1].IsEmpty() || !params[1]->IsArray()) &&
- !params[1]->IsString()) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ if ((params[1].IsEmpty() || !params[1]->IsArray()) && !params[1]->IsString())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CPDFSDK_InterForm* pReaderInterForm =
pRuntime->GetFormFillEnv()->GetInterForm();
@@ -1699,12 +1619,13 @@ bool CJS_PublicMethods::AFSimple_Calculate(
trimmed.TrimRight();
trimmed.TrimLeft();
dTemp = FX_atof(trimmed.AsStringView());
- } break;
- case FIELDTYPE_PUSHBUTTON: {
+ break;
+ }
+ case FIELDTYPE_PUSHBUTTON:
dTemp = 0.0;
- } break;
+ break;
case FIELDTYPE_CHECKBOX:
- case FIELDTYPE_RADIOBUTTON: {
+ case FIELDTYPE_RADIOBUTTON:
dTemp = 0.0;
for (int c = 0, csz = pFormField->CountControls(); c < csz; c++) {
if (CPDF_FormControl* pFormCtrl = pFormField->GetControl(c)) {
@@ -1717,23 +1638,24 @@ bool CJS_PublicMethods::AFSimple_Calculate(
}
}
}
- } break;
- case FIELDTYPE_LISTBOX: {
+ break;
+ case FIELDTYPE_LISTBOX:
if (pFormField->CountSelectedItems() <= 1) {
WideString trimmed = pFormField->GetValue();
trimmed.TrimRight();
trimmed.TrimLeft();
dTemp = FX_atof(trimmed.AsStringView());
}
- } break;
+ break;
default:
break;
}
- if (i == 0 && j == 0 && (wcscmp(sFunction.c_str(), L"MIN") == 0 ||
- wcscmp(sFunction.c_str(), L"MAX") == 0))
+ if (i == 0 && j == 0 &&
+ (wcscmp(sFunction.c_str(), L"MIN") == 0 ||
+ wcscmp(sFunction.c_str(), L"MAX") == 0)) {
dValue = dTemp;
-
+ }
dValue = AF_Simple(sFunction.c_str(), dValue, dTemp);
nFieldsCount++;
@@ -1753,28 +1675,25 @@ bool CJS_PublicMethods::AFSimple_Calculate(
pRuntime->ToWideString(pRuntime->NewNumber(dValue));
}
- return true;
+ return CJS_Return(true);
}
/* This function validates the current event to ensure that its value is
** within the specified range. */
-bool CJS_PublicMethods::AFRange_Validate(
+CJS_Return CJS_PublicMethods::AFRange_Validate(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 4) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 4)
+ CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+
CJS_EventContext* pContext = pRuntime->GetCurrentEventContext();
CJS_EventHandler* pEvent = pContext->GetEventHandler();
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
if (pEvent->Value().IsEmpty())
- return true;
+ return CJS_Return(true);
double dEentValue = atof(ByteString::FromUnicode(pEvent->Value()).c_str());
bool bGreaterThan = pRuntime->ToBoolean(params[0]);
@@ -1802,18 +1721,14 @@ bool CJS_PublicMethods::AFRange_Validate(
AlertIfPossible(pContext, swMsg.c_str());
pEvent->Rc() = false;
}
- return true;
+ return CJS_Return(true);
}
-bool CJS_PublicMethods::AFExtractNums(
+CJS_Return CJS_PublicMethods::AFExtractNums(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 1)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
WideString str = pRuntime->ToWideString(params[0]);
if (str.GetLength() > 0 && (str[0] == L'.' || str[0] == L','))
@@ -1836,12 +1751,8 @@ bool CJS_PublicMethods::AFExtractNums(
if (nums.GetLength(pRuntime) > 0) {
if (nums.ToV8Value().IsEmpty())
- vRet = CJS_Value(pRuntime->NewArray());
- else
- vRet = CJS_Value(nums.ToV8Value());
- } else {
- vRet.Set(pRuntime->NewUndefined());
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(nums.ToV8Value());
}
-
- return true;
+ return CJS_Return(pRuntime->NewUndefined());
}
diff --git a/fpdfsdk/javascript/PublicMethods.h b/fpdfsdk/javascript/PublicMethods.h
index 60659bad0d..11fe342e5d 100644
--- a/fpdfsdk/javascript/PublicMethods.h
+++ b/fpdfsdk/javascript/PublicMethods.h
@@ -18,101 +18,71 @@ class CJS_PublicMethods : public CJS_Object {
: CJS_Object(pObject) {}
~CJS_PublicMethods() override {}
- static bool AFNumber_Format(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFNumber_Keystroke(
- CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFPercent_Format(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFPercent_Keystroke(
- CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFDate_FormatEx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFDate_KeystrokeEx(
- CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFDate_Format(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFDate_Keystroke(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFTime_FormatEx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFTime_KeystrokeEx(
- CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFTime_Format(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFTime_Keystroke(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFSpecial_Format(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFSpecial_Keystroke(
- CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFSpecial_KeystrokeEx(
- CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError); //
- static bool AFSimple(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFMakeNumber(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFSimple_Calculate(
- CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFRange_Validate(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFMergeChange(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFParseDateEx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- static bool AFExtractNums(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
+ static CJS_Return AFNumber_Format(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFNumber_Keystroke(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFPercent_Format(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFPercent_Keystroke(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFDate_FormatEx(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFDate_KeystrokeEx(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFDate_Format(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFDate_Keystroke(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFTime_FormatEx(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFTime_KeystrokeEx(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFTime_Format(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFTime_Keystroke(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFSpecial_Format(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFSpecial_Keystroke(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFSpecial_KeystrokeEx(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFSimple(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFMakeNumber(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFSimple_Calculate(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFRange_Validate(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFMergeChange(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFParseDateEx(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ static CJS_Return AFExtractNums(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
static void AFNumber_Format_static(
const v8::FunctionCallbackInfo<v8::Value>& info);
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index cbc3145b0f..79e4c588df 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -216,12 +216,9 @@ IMPLEMENT_JS_CLASS(CJS_App, app, app)
app::app(CJS_Object* pJSObject)
: CJS_EmbedObj(pJSObject), m_bCalculate(true), m_bRuntimeHighLight(false) {}
-app::~app() {
-}
+app::~app() {}
-bool app::get_active_docs(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return app::get_active_docs(CJS_Runtime* pRuntime) {
CJS_Document* pJSDocument = nullptr;
v8::Local<v8::Object> pObj = pRuntime->GetThisObj();
if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID)
@@ -233,154 +230,111 @@ bool app::get_active_docs(CJS_Runtime* pRuntime,
: v8::Local<v8::Value>());
if (aDocs.GetLength(pRuntime) > 0) {
if (aDocs.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(aDocs.ToV8Value());
- } else {
- vp->Set(pRuntime->NewUndefined());
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(aDocs.ToV8Value());
}
-
- return true;
+ return CJS_Return(pRuntime->NewUndefined());
}
-bool app::set_active_docs(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_active_docs(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::get_calculate(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewBoolean(m_bCalculate));
- return true;
+CJS_Return app::get_calculate(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewBoolean(m_bCalculate));
}
-bool app::set_calculate(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return app::set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
m_bCalculate = pRuntime->ToBoolean(vp);
pRuntime->GetFormFillEnv()->GetInterForm()->EnableCalculate(m_bCalculate);
- return true;
+ return CJS_Return(true);
}
-bool app::get_forms_version(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewNumber(JS_NUM_FORMSVERSION));
- return true;
+CJS_Return app::get_forms_version(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewNumber(JS_NUM_FORMSVERSION));
}
-bool app::set_forms_version(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_forms_version(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::get_viewer_type(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewString(JS_STR_VIEWERTYPE));
- return true;
+CJS_Return app::get_viewer_type(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewString(JS_STR_VIEWERTYPE));
}
-bool app::set_viewer_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_viewer_type(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::get_viewer_variation(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewString(JS_STR_VIEWERVARIATION));
- return true;
+CJS_Return app::get_viewer_variation(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewString(JS_STR_VIEWERVARIATION));
}
-bool app::set_viewer_variation(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_viewer_variation(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::get_viewer_version(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return app::get_viewer_version(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext();
- if (pXFAContext->ContainsXFAForm()) {
- vp->Set(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA));
- return true;
- }
+ if (pXFAContext->ContainsXFAForm())
+ return CJS_Return(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA));
#endif // PDF_ENABLE_XFA
- vp->Set(pRuntime->NewNumber(JS_NUM_VIEWERVERSION));
- return true;
+ return CJS_Return(pRuntime->NewNumber(JS_NUM_VIEWERVERSION));
}
-bool app::set_viewer_version(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_viewer_version(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::get_platform(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return app::get_platform(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
if (!pFormFillEnv)
- return false;
+ return CJS_Return(false);
WideString platfrom = pFormFillEnv->GetPlatform();
- if (!platfrom.IsEmpty()) {
- vp->Set(pRuntime->NewString(platfrom.c_str()));
- return true;
- }
+ if (!platfrom.IsEmpty())
+ return CJS_Return(pRuntime->NewString(platfrom.c_str()));
#endif
- vp->Set(pRuntime->NewString(JS_STR_PLATFORM));
- return true;
+ return CJS_Return(pRuntime->NewString(JS_STR_PLATFORM));
}
-bool app::set_platform(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_platform(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::get_language(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return app::get_language(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
if (!pFormFillEnv)
- return false;
+ return CJS_Return(false);
WideString language = pFormFillEnv->GetLanguage();
- if (!language.IsEmpty()) {
- vp->Set(pRuntime->NewString(language.c_str()));
- return true;
- }
+ if (!language.IsEmpty())
+ return CJS_Return(pRuntime->NewString(language.c_str()));
#endif
- vp->Set(pRuntime->NewString(JS_STR_LANGUAGE));
- return true;
+ return CJS_Return(pRuntime->NewString(JS_STR_LANGUAGE));
}
-bool app::set_language(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
// creates a new fdf object that contains no data
// comment: need reader support
// note:
// CFDF_Document * CPDFSDK_FormFillEnvironment::NewFDF();
-bool app::newFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return app::newFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
+
// opens a specified pdf document and returns its document object
// comment:need reader support
// note: as defined in js reference, the proto of this function's fourth
@@ -388,30 +342,22 @@ bool app::newFDF(CJS_Runtime* pRuntime,
// CFDF_Document * CPDFSDK_FormFillEnvironment::OpenFDF(string strPath,bool
// bUserConv);
-bool app::openFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return app::openFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool app::alert(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return app::alert(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(
pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle");
- if (!IsTypeKnown(newParams[0])) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ if (!IsTypeKnown(newParams[0]))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
- if (!pFormFillEnv) {
- vRet = CJS_Value(pRuntime->NewNumber(0));
- return true;
- }
+ if (!pFormFillEnv)
+ return CJS_Return(pRuntime->NewNumber(0));
WideString swMsg;
if (newParams[0]->IsArray()) {
@@ -445,67 +391,51 @@ bool app::alert(CJS_Runtime* pRuntime,
pRuntime->BeginBlock();
pFormFillEnv->KillFocusAnnot(0);
- vRet = CJS_Value(pRuntime->NewNumber(
- pFormFillEnv->JS_appAlert(swMsg.c_str(), swTitle.c_str(), iType, iIcon)));
+ v8::Local<v8::Value> ret = pRuntime->NewNumber(
+ pFormFillEnv->JS_appAlert(swMsg.c_str(), swTitle.c_str(), iType, iIcon));
pRuntime->EndBlock();
- return true;
+
+ return CJS_Return(ret);
}
-bool app::beep(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return app::beep(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() == 1) {
pRuntime->GetFormFillEnv()->JS_appBeep(pRuntime->ToInt32(params[0]));
- return true;
+ return CJS_Return(true);
}
-
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
}
-bool app::findComponent(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return app::findComponent(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool app::popUpMenuEx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return app::popUpMenuEx(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool app::get_fs(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return false;
+CJS_Return app::get_fs(CJS_Runtime* pRuntime) {
+ return CJS_Return(false);
}
-bool app::set_fs(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::setInterval(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() > 2 || params.size() == 0) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+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));
WideString script =
params.size() > 0 ? pRuntime->ToWideString(params[0]) : L"";
- if (script.IsEmpty()) {
- sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE);
- return true;
- }
+ if (script.IsEmpty())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE));
uint32_t dwInterval = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000;
-
GlobalTimer* timerRef = new GlobalTimer(this, pRuntime->GetFormFillEnv(),
pRuntime, 0, script, dwInterval, 0);
m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef));
@@ -513,31 +443,24 @@ bool app::setInterval(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pRetObj =
pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID);
if (pRetObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_TimerObj* pJS_TimerObj =
static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj));
TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
pTimerObj->SetTimer(timerRef);
- vRet = CJS_Value(pRetObj);
- return true;
+ return CJS_Return(pRetObj);
}
-bool app::setTimeOut(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() > 2 || params.size() == 0) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+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));
WideString script = pRuntime->ToWideString(params[0]);
- if (script.IsEmpty()) {
- sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE);
- return true;
- }
+ if (script.IsEmpty())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE));
uint32_t dwTimeOut = params.size() > 1 ? pRuntime->ToInt32(params[1]) : 1000;
GlobalTimer* timerRef =
@@ -548,40 +471,32 @@ bool app::setTimeOut(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pRetObj =
pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID);
if (pRetObj.IsEmpty())
- return false;
+ return CJS_Return(false);
CJS_TimerObj* pJS_TimerObj =
static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj));
TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
pTimerObj->SetTimer(timerRef);
- vRet = CJS_Value(pRetObj);
- return true;
+
+ return CJS_Return(pRetObj);
}
-bool app::clearTimeOut(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+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));
app::ClearTimerCommon(pRuntime, params[0]);
- return true;
+ return CJS_Return(true);
}
-bool app::clearInterval(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+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));
app::ClearTimerCommon(pRuntime, params[0]);
- return true;
+ return CJS_Return(true);
}
void app::ClearTimerCommon(CJS_Runtime* pRuntime, v8::Local<v8::Value> param) {
@@ -604,11 +519,9 @@ void app::ClearTimerCommon(CJS_Runtime* pRuntime, v8::Local<v8::Value> param) {
GlobalTimer::Cancel(pTimerObj->GetTimerID());
}
-bool app::execMenuItem(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return app::execMenuItem(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
void app::TimerProc(GlobalTimer* pTimer) {
@@ -631,45 +544,35 @@ void app::RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript) {
}
}
-bool app::goBack(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return app::goBack(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
- return true;
+ return CJS_Return(true);
}
-bool app::goForward(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return app::goForward(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
- return true;
+ return CJS_Return(true);
}
-bool app::mailMsg(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return app::mailMsg(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<v8::Local<v8::Value>> newParams =
ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc", L"cBcc",
L"cSubject", L"cMsg");
- if (!IsTypeKnown(newParams[0])) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
- bool bUI = pRuntime->ToBoolean(newParams[0]);
+ if (!IsTypeKnown(newParams[0]))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ bool bUI = pRuntime->ToBoolean(newParams[0]);
WideString cTo;
if (IsTypeKnown(newParams[1])) {
cTo = pRuntime->ToWideString(newParams[1]);
} else {
- if (!bUI) {
- // cTo parameter required when UI not invoked.
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ // cTo parameter required when UI not invoked.
+ if (!bUI)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
}
WideString cCc;
@@ -693,56 +596,42 @@ bool app::mailMsg(CJS_Runtime* pRuntime,
cSubject.c_str(), cCc.c_str(),
cBcc.c_str(), cMsg.c_str());
pRuntime->EndBlock();
- return true;
+ return CJS_Return(true);
}
-bool app::launchURL(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return app::launchURL(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool app::get_runtime_highlight(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- vp->Set(pRuntime->NewBoolean(m_bRuntimeHighLight));
- return true;
+CJS_Return app::get_runtime_highlight(CJS_Runtime* pRuntime) {
+ return CJS_Return(pRuntime->NewBoolean(m_bRuntimeHighLight));
}
-bool app::set_runtime_highlight(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return app::set_runtime_highlight(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
m_bRuntimeHighLight = pRuntime->ToBoolean(vp);
- return true;
+ return CJS_Return(true);
}
-bool app::get_fullscreen(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return false;
+CJS_Return app::get_fullscreen(CJS_Runtime* pRuntime) {
+ return CJS_Return(false);
}
-bool app::set_fullscreen(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_fullscreen(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::popUpMenu(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return app::popUpMenu(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool app::browseForDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return app::browseForDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
WideString app::SysPathToPDFPath(const WideString& sOldPath) {
@@ -754,34 +643,26 @@ WideString app::SysPathToPDFPath(const WideString& sOldPath) {
return sRet;
}
-bool app::newDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return app::newDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool app::openDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return false;
+CJS_Return app::openDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(false);
}
-bool app::response(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return app::response(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<v8::Local<v8::Value>> newParams =
ExpandKeywordParams(pRuntime, params, 5, L"cQuestion", L"cTitle",
L"cDefault", L"bPassword", L"cLabel");
- if (!IsTypeKnown(newParams[0])) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
- WideString swQuestion = pRuntime->ToWideString(newParams[0]);
+ if (!IsTypeKnown(newParams[0]))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+ WideString swQuestion = pRuntime->ToWideString(newParams[0]);
WideString swTitle = L"PDF";
if (IsTypeKnown(newParams[1]))
swTitle = pRuntime->ToWideString(newParams[1]);
@@ -804,32 +685,24 @@ bool app::response(CJS_Runtime* pRuntime,
swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(),
bPassword, pBuff.data(), MAX_INPUT_BYTES);
- if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG);
- return false;
- }
+ if (nLengthBytes < 0 || nLengthBytes > MAX_INPUT_BYTES)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAM_TOOLONG));
- vRet = CJS_Value(pRuntime->NewString(
+ return CJS_Return(pRuntime->NewString(
WideString::FromUTF16LE(reinterpret_cast<uint16_t*>(pBuff.data()),
nLengthBytes / sizeof(uint16_t))
.c_str()));
-
- return true;
}
-bool app::get_media(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return false;
+CJS_Return app::get_media(CJS_Runtime* pRuntime) {
+ return CJS_Return(false);
}
-bool app::set_media(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return app::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool app::execDialog(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return app::execDialog(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
diff --git a/fpdfsdk/javascript/app.h b/fpdfsdk/javascript/app.h
index 967e9d7526..b88e0feac8 100644
--- a/fpdfsdk/javascript/app.h
+++ b/fpdfsdk/javascript/app.h
@@ -41,162 +41,86 @@ class app : public CJS_EmbedObj {
explicit app(CJS_Object* pJSObject);
~app() override;
- bool get_active_docs(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_active_docs(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_calculate(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_calculate(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_forms_version(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_forms_version(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_fs(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_fs(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_fullscreen(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_fullscreen(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_language(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_language(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_media(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_media(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_platform(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_platform(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_runtime_highlight(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_runtime_highlight(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_viewer_type(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_viewer_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_viewer_variation(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_viewer_variation(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_viewer_version(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_viewer_version(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool alert(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool beep(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool browseForDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool clearInterval(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool clearTimeOut(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool execDialog(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool execMenuItem(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool findComponent(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool goBack(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool goForward(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool launchURL(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool mailMsg(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool newFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool newDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool openDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool openFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool popUpMenuEx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool popUpMenu(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool response(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool setInterval(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool setTimeOut(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
+ CJS_Return get_active_docs(CJS_Runtime* pRuntime);
+ CJS_Return set_active_docs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_calculate(CJS_Runtime* pRuntime);
+ CJS_Return set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_forms_version(CJS_Runtime* pRuntime);
+ CJS_Return set_forms_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_fs(CJS_Runtime* pRuntime);
+ CJS_Return set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_fullscreen(CJS_Runtime* pRuntime);
+ CJS_Return set_fullscreen(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_language(CJS_Runtime* pRuntime);
+ CJS_Return set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_media(CJS_Runtime* pRuntime);
+ CJS_Return set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_platform(CJS_Runtime* pRuntime);
+ CJS_Return set_platform(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_runtime_highlight(CJS_Runtime* pRuntime);
+ CJS_Return set_runtime_highlight(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_viewer_type(CJS_Runtime* pRuntime);
+ CJS_Return set_viewer_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_viewer_variation(CJS_Runtime* pRuntime);
+ CJS_Return set_viewer_variation(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp);
+
+ CJS_Return get_viewer_version(CJS_Runtime* pRuntime);
+ CJS_Return set_viewer_version(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return alert(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return beep(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return browseForDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return clearInterval(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return clearTimeOut(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return execDialog(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return execMenuItem(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return findComponent(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return goBack(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return goForward(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return launchURL(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return mailMsg(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return newFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return newDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return openDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return openFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return popUpMenuEx(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return popUpMenu(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return response(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return setInterval(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return setTimeOut(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
void TimerProc(GlobalTimer* pTimer);
void CancelProc(GlobalTimer* pTimer);
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 97d10b978d..621fe6b752 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -122,172 +122,129 @@ color::color(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {
color::~color() {}
-bool color::get_transparent(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crTransparent);
+CJS_Return color::get_transparent(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crTransparent);
}
-bool color::set_transparent(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_transparent(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crTransparent);
}
-bool color::get_black(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crBlack);
+CJS_Return color::get_black(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crBlack);
}
-bool color::set_black(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crBlack);
}
-bool color::get_white(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crWhite);
+CJS_Return color::get_white(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crWhite);
}
-bool color::set_white(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crWhite);
}
-bool color::get_red(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crRed);
+CJS_Return color::get_red(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crRed);
}
-bool color::set_red(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crRed);
}
-bool color::get_green(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crGreen);
+CJS_Return color::get_green(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crGreen);
}
-bool color::set_green(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crGreen);
}
-bool color::get_blue(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crBlue);
+CJS_Return color::get_blue(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crBlue);
}
-bool color::set_blue(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crBlue);
}
-bool color::get_cyan(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crCyan);
+CJS_Return color::get_cyan(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crCyan);
}
-bool color::set_cyan(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crCyan);
}
-bool color::get_magenta(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crMagenta);
+CJS_Return color::get_magenta(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crMagenta);
}
-bool color::set_magenta(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crMagenta);
}
-bool color::get_yellow(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crYellow);
+CJS_Return color::get_yellow(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crYellow);
}
-bool color::set_yellow(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crYellow);
}
-bool color::get_dark_gray(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crDKGray);
+CJS_Return color::get_dark_gray(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crDKGray);
}
-bool color::set_dark_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_dark_gray(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crDKGray);
}
-bool color::get_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crGray);
+CJS_Return color::get_gray(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crGray);
}
-bool color::set_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crGray);
}
-bool color::get_light_gray(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return GetPropertyHelper(pRuntime, vp, &m_crLTGray);
+CJS_Return color::get_light_gray(CJS_Runtime* pRuntime) {
+ return GetPropertyHelper(pRuntime, &m_crLTGray);
}
-bool color::set_light_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return color::set_light_gray(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crLTGray);
}
-bool color::GetPropertyHelper(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- CFX_Color* var) {
+CJS_Return color::GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* var) {
CJS_Array array = ConvertPWLColorToArray(pRuntime, *var);
if (array.ToV8Value().IsEmpty())
- vp->Set(pRuntime->NewArray());
- else
- vp->Set(array.ToV8Value());
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(array.ToV8Value());
}
-bool color::SetPropertyHelper(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- CFX_Color* var) {
+CJS_Return color::SetPropertyHelper(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp,
+ CFX_Color* var) {
if (vp.IsEmpty() || !vp->IsArray())
- return false;
+ return CJS_Return(false);
*var = ConvertArrayToPWLColor(pRuntime, CJS_Array(pRuntime->ToArray(vp)));
- return true;
+ return CJS_Return(true);
}
-bool color::convert(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return color::convert(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
if (iSize < 2)
- return false;
+ return CJS_Return(false);
if (params[0].IsEmpty() || !params[0]->IsArray())
- return false;
+ return CJS_Return(false);
WideString sDestSpace = pRuntime->ToWideString(params[1]);
int nColorType = CFX_Color::kTransparent;
@@ -306,22 +263,17 @@ bool color::convert(CJS_Runtime* pRuntime,
CJS_Array array =
ConvertPWLColorToArray(pRuntime, color.ConvertColorType(nColorType));
if (array.ToV8Value().IsEmpty())
- vRet = CJS_Value(pRuntime->NewArray());
- else
- vRet = CJS_Value(array.ToV8Value());
-
- return true;
+ return CJS_Return(pRuntime->NewArray());
+ return CJS_Return(array.ToV8Value());
}
-bool color::equal(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return color::equal(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return false;
+ return CJS_Return(false);
if (params[0].IsEmpty() || !params[0]->IsArray() || params[1].IsEmpty() ||
!params[1]->IsArray()) {
- return false;
+ return CJS_Return(false);
}
CFX_Color color1 =
@@ -330,6 +282,5 @@ bool color::equal(CJS_Runtime* pRuntime,
ConvertArrayToPWLColor(pRuntime, CJS_Array(pRuntime->ToArray(params[1])));
color1 = color1.ConvertColorType(color2.nColorType);
- vRet = CJS_Value(pRuntime->NewBoolean(color1 == color2));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(color1 == color2));
}
diff --git a/fpdfsdk/javascript/color.h b/fpdfsdk/javascript/color.h
index de784e57b2..454de57e72 100644
--- a/fpdfsdk/javascript/color.h
+++ b/fpdfsdk/javascript/color.h
@@ -22,82 +22,52 @@ class color : public CJS_EmbedObj {
explicit color(CJS_Object* pJSObject);
~color() override;
- bool get_black(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_black(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_blue(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_blue(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_cyan(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_cyan(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_dark_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_dark_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_green(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_green(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_light_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_light_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_magenta(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_magenta(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_red(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_red(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_transparent(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_transparent(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_white(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_white(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_yellow(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_yellow(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool convert(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool equal(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
+ CJS_Return get_black(CJS_Runtime* pRuntime);
+ CJS_Return set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_blue(CJS_Runtime* pRuntime);
+ CJS_Return set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_cyan(CJS_Runtime* pRuntime);
+ CJS_Return set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_dark_gray(CJS_Runtime* pRuntime);
+ CJS_Return set_dark_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_gray(CJS_Runtime* pRuntime);
+ CJS_Return set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_green(CJS_Runtime* pRuntime);
+ CJS_Return set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_light_gray(CJS_Runtime* pRuntime);
+ CJS_Return set_light_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_magenta(CJS_Runtime* pRuntime);
+ CJS_Return set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_red(CJS_Runtime* pRuntime);
+ CJS_Return set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_transparent(CJS_Runtime* pRuntime);
+ CJS_Return set_transparent(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_white(CJS_Runtime* pRuntime);
+ CJS_Return set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_yellow(CJS_Runtime* pRuntime);
+ CJS_Return set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return convert(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return equal(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
private:
- bool GetPropertyHelper(CJS_Runtime* pRuntime, CJS_Value* vp, CFX_Color* val);
- bool SetPropertyHelper(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- CFX_Color* val);
+ CJS_Return GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* val);
+ CJS_Return SetPropertyHelper(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp,
+ CFX_Color* val);
CFX_Color m_crTransparent;
CFX_Color m_crBlack;
diff --git a/fpdfsdk/javascript/console.cpp b/fpdfsdk/javascript/console.cpp
index ba46fea7da..af2bb3e9ea 100644
--- a/fpdfsdk/javascript/console.cpp
+++ b/fpdfsdk/javascript/console.cpp
@@ -30,33 +30,22 @@ console::console(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
console::~console() {}
-bool console::clear(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return console::clear(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool console::hide(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return console::hide(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
-bool console::println(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() < 1) {
- return false;
- }
- return true;
+CJS_Return console::println(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(params.size() > 0);
}
-bool console::show(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- return true;
+CJS_Return console::show(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
+ return CJS_Return(true);
}
diff --git a/fpdfsdk/javascript/console.h b/fpdfsdk/javascript/console.h
index d7d1793dde..4ed66c1c05 100644
--- a/fpdfsdk/javascript/console.h
+++ b/fpdfsdk/javascript/console.h
@@ -17,22 +17,14 @@ class console : public CJS_EmbedObj {
~console() override;
public:
- bool clear(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool hide(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool println(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool show(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
+ CJS_Return clear(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return hide(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return println(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return show(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
};
class CJS_Console : public CJS_Object {
diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp
index eb9d6441bc..401148c551 100644
--- a/fpdfsdk/javascript/event.cpp
+++ b/fpdfsdk/javascript/event.cpp
@@ -46,18 +46,13 @@ event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {}
event::~event() {}
-bool event::get_change(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_change(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewString(pEvent->Change().c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(pEvent->Change().c_str()));
}
-bool event::set_change(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return event::set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -65,323 +60,246 @@ bool event::set_change(CJS_Runtime* pRuntime,
WideString& wChange = pEvent->Change();
wChange = pRuntime->ToWideString(vp);
}
- return true;
+ return CJS_Return(true);
}
-bool event::get_change_ex(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_change_ex(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewString(pEvent->ChangeEx().c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().c_str()));
}
-bool event::set_change_ex(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_change_ex(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_commit_key(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_commit_key(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewNumber(pEvent->CommitKey()));
- return true;
+ return CJS_Return(pRuntime->NewNumber(pEvent->CommitKey()));
}
-bool event::set_commit_key(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_commit_key(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_field_full(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_field_full(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewBoolean(pEvent->FieldFull()));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(pEvent->FieldFull()));
}
-bool event::set_field_full(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_field_full(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_key_down(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_key_down(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewBoolean(pEvent->KeyDown()));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(pEvent->KeyDown()));
}
-bool event::set_key_down(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_modifier(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_modifier(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewBoolean(pEvent->Modifier()));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(pEvent->Modifier()));
}
-bool event::set_modifier(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
+CJS_Return event::get_name(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewString(pEvent->Name()));
- return true;
+ return CJS_Return(pRuntime->NewString(pEvent->Name()));
}
-bool event::set_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_rc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
+CJS_Return event::get_rc(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewBoolean(pEvent->Rc()));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(pEvent->Rc()));
}
-bool event::set_rc(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
pEvent->Rc() = pRuntime->ToBoolean(vp);
- return true;
+ return CJS_Return(true);
}
-bool event::get_rich_change(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return event::get_rich_change(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool event::set_rich_change(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return event::set_rich_change(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool event::get_rich_change_ex(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return event::get_rich_change_ex(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool event::set_rich_change_ex(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return event::set_rich_change_ex(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool event::get_rich_value(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
- return true;
+CJS_Return event::get_rich_value(CJS_Runtime* pRuntime) {
+ return CJS_Return(true);
}
-bool event::set_rich_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return true;
+CJS_Return event::set_rich_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(true);
}
-bool event::get_sel_end(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_sel_end(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return true;
+ return CJS_Return(true);
- vp->Set(pRuntime->NewNumber(pEvent->SelEnd()));
- return true;
+ return CJS_Return(pRuntime->NewNumber(pEvent->SelEnd()));
}
-bool event::set_sel_end(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return event::set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return true;
+ return CJS_Return(true);
pEvent->SelEnd() = pRuntime->ToInt32(vp);
- return true;
+ return CJS_Return(true);
}
-bool event::get_sel_start(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_sel_start(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return true;
+ return CJS_Return(true);
- vp->Set(pRuntime->NewNumber(pEvent->SelStart()));
- return true;
+ return CJS_Return(pRuntime->NewNumber(pEvent->SelStart()));
}
-bool event::set_sel_start(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return event::set_sel_start(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
- return true;
+ return CJS_Return(true);
pEvent->SelStart() = pRuntime->ToInt32(vp);
- return true;
+ return CJS_Return(true);
}
-bool event::get_shift(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_shift(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewBoolean(pEvent->Shift()));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(pEvent->Shift()));
}
-bool event::set_shift(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_source(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_source(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pEvent->Source()->GetJSObject()->ToV8Object());
- return true;
+ return CJS_Return(pEvent->Source()->GetJSObject()->ToV8Object());
}
-bool event::set_source(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_target(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_target(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pEvent->Target_Field()->GetJSObject()->ToV8Object());
- return true;
+ return CJS_Return(pEvent->Target_Field()->GetJSObject()->ToV8Object());
}
-bool event::set_target(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_target_name(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_target_name(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewString(pEvent->TargetName().c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(pEvent->TargetName().c_str()));
}
-bool event::set_target_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_target_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
+CJS_Return event::get_type(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewString(pEvent->Type()));
- return true;
+ return CJS_Return(pRuntime->NewString(pEvent->Type()));
}
-bool event::set_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
-bool event::get_value(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_value(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
- return false;
+ return CJS_Return(false);
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
- vp->Set(pRuntime->NewString(pEvent->Value().c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(pEvent->Value().c_str()));
}
-bool event::set_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
+CJS_Return event::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
- return false;
+ return CJS_Return(false);
if (!pEvent->m_pValue)
- return false;
+ return CJS_Return(false);
pEvent->Value() = pRuntime->ToWideString(vp);
- return true;
+ return CJS_Return(true);
}
-bool event::get_will_commit(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError) {
+CJS_Return event::get_will_commit(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- vp->Set(pRuntime->NewBoolean(pEvent->WillCommit()));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(pEvent->WillCommit()));
}
-bool event::set_will_commit(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError) {
- return false;
+CJS_Return event::set_will_commit(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
+ return CJS_Return(false);
}
diff --git a/fpdfsdk/javascript/event.h b/fpdfsdk/javascript/event.h
index 90b9126c89..ad19e7866f 100644
--- a/fpdfsdk/javascript/event.h
+++ b/fpdfsdk/javascript/event.h
@@ -14,114 +14,65 @@ class event : public CJS_EmbedObj {
explicit event(CJS_Object* pJSObject);
~event() override;
- public:
- bool get_change(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_change(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_change_ex(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_change_ex(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_commit_key(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_commit_key(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_field_full(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_field_full(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_key_down(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_key_down(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_modifier(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_modifier(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_rc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_rc(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_rich_change(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_rich_change(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_rich_change_ex(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_rich_change_ex(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_rich_value(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_rich_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_sel_end(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_sel_end(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_sel_start(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_sel_start(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_shift(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_shift(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_source(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_source(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_target(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_target(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_target_name(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_target_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_value(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError);
- bool set_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
-
- bool get_will_commit(CJS_Runtime* pRuntime,
- CJS_Value* vp,
- WideString* sError);
- bool set_will_commit(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- WideString* sError);
+ CJS_Return get_change(CJS_Runtime* pRuntime);
+ CJS_Return set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_change_ex(CJS_Runtime* pRuntime);
+ CJS_Return set_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_commit_key(CJS_Runtime* pRuntime);
+ CJS_Return set_commit_key(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_field_full(CJS_Runtime* pRuntime);
+ CJS_Return set_field_full(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_key_down(CJS_Runtime* pRuntime);
+ CJS_Return set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_modifier(CJS_Runtime* pRuntime);
+ CJS_Return set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_name(CJS_Runtime* pRuntime);
+ CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_rc(CJS_Runtime* pRuntime);
+ CJS_Return set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_rich_change(CJS_Runtime* pRuntime);
+ CJS_Return set_rich_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_rich_change_ex(CJS_Runtime* pRuntime);
+ CJS_Return set_rich_change_ex(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_rich_value(CJS_Runtime* pRuntime);
+ CJS_Return set_rich_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_sel_end(CJS_Runtime* pRuntime);
+ CJS_Return set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_sel_start(CJS_Runtime* pRuntime);
+ CJS_Return set_sel_start(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_shift(CJS_Runtime* pRuntime);
+ CJS_Return set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_source(CJS_Runtime* pRuntime);
+ CJS_Return set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_target(CJS_Runtime* pRuntime);
+ CJS_Return set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_target_name(CJS_Runtime* pRuntime);
+ CJS_Return set_target_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_type(CJS_Runtime* pRuntime);
+ CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_value(CJS_Runtime* pRuntime);
+ CJS_Return set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ CJS_Return get_will_commit(CJS_Runtime* pRuntime);
+ CJS_Return set_will_commit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
};
class CJS_Event : public CJS_Object {
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index 5dc6ac9d78..df7927b116 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -63,6 +63,11 @@
namespace {
+WideString PropFromV8Prop(v8::Local<v8::String> property) {
+ v8::String::Utf8Value utf8_value(property);
+ return WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
+}
+
template <class Alt>
void JSSpecialPropQuery(const char*,
v8::Local<v8::String> property,
@@ -78,11 +83,8 @@ void JSSpecialPropQuery(const char*,
return;
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
- v8::String::Utf8Value utf8_value(property);
- WideString propname =
- WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
- bool bRet = pObj->QueryProperty(propname.c_str());
- info.GetReturnValue().Set(bRet ? 4 : 0);
+ CJS_Return result = pObj->QueryProperty(PropFromV8Prop(property).c_str());
+ info.GetReturnValue().Set(!result.HasError() ? 4 : 0);
}
template <class Alt>
@@ -100,17 +102,16 @@ void JSSpecialPropGet(const char* class_name,
return;
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
- v8::String::Utf8Value utf8_value(property);
- WideString propname =
- WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
-
- CJS_Value value;
- if (!pObj->GetProperty(pRuntime, propname.c_str(), &value)) {
- pRuntime->Error(JSFormatErrorString(class_name, "GetProperty", L""));
+ CJS_Return result =
+ pObj->GetProperty(pRuntime, PropFromV8Prop(property).c_str());
+ if (result.HasError()) {
+ pRuntime->Error(
+ JSFormatErrorString(class_name, "GetProperty", result.Error()));
return;
}
- if (!value.ToV8Value().IsEmpty())
- info.GetReturnValue().Set(value.ToV8Value());
+
+ if (result.HasReturn())
+ info.GetReturnValue().Set(result.Return());
}
template <class Alt>
@@ -129,11 +130,12 @@ void JSSpecialPropPut(const char* class_name,
return;
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
- v8::String::Utf8Value utf8_value(property);
- WideString propname =
- WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
- if (!pObj->SetProperty(pRuntime, propname.c_str(), value))
- pRuntime->Error(JSFormatErrorString(class_name, "PutProperty", L""));
+ CJS_Return result =
+ pObj->SetProperty(pRuntime, PropFromV8Prop(property).c_str(), value);
+ if (result.HasError()) {
+ pRuntime->Error(
+ JSFormatErrorString(class_name, "PutProperty", result.Error()));
+ }
}
template <class Alt>
@@ -151,13 +153,12 @@ void JSSpecialPropDel(const char* class_name,
return;
Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
- v8::String::Utf8Value utf8_value(property);
- WideString propname =
- WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
- if (!pObj->DelProperty(pRuntime, propname.c_str())) {
- ByteString cbName;
- cbName.Format("%s.%s", class_name, "DelProperty");
- // Probably a missing call to JSFX_Error().
+ CJS_Return result =
+ pObj->DelProperty(pRuntime, PropFromV8Prop(property).c_str());
+ if (result.HasError()) {
+ // TODO(dsinclair): Should this set the pRuntime->Error result?
+ // ByteString cbName;
+ // cbName.Format("%s.%s", class_name, "DelProperty");
}
}
@@ -179,31 +180,27 @@ class JSGlobalAlternate : public CJS_EmbedObj {
explicit JSGlobalAlternate(CJS_Object* pJSObject);
~JSGlobalAlternate() override;
- bool setPersistent(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool QueryProperty(const wchar_t* propname);
- bool GetProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname,
- CJS_Value* vp);
- bool SetProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname,
- v8::Local<v8::Value> vp);
- bool DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname);
+ CJS_Return setPersistent(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return QueryProperty(const wchar_t* propname);
+ CJS_Return GetProperty(CJS_Runtime* pRuntime, const wchar_t* propname);
+ CJS_Return SetProperty(CJS_Runtime* pRuntime,
+ const wchar_t* propname,
+ v8::Local<v8::Value> vp);
+ CJS_Return DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname);
void Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv);
private:
void UpdateGlobalPersistentVariables();
void CommitGlobalPersisitentVariables(CJS_Runtime* pRuntime);
void DestroyGlobalPersisitentVariables();
- bool SetGlobalVariables(const ByteString& propname,
- JS_GlobalDataType nType,
- double dData,
- bool bData,
- const ByteString& sData,
- v8::Local<v8::Object> pData,
- bool bDefaultPersistent);
+ CJS_Return SetGlobalVariables(const ByteString& propname,
+ JS_GlobalDataType nType,
+ double dData,
+ bool bData,
+ const ByteString& sData,
+ v8::Local<v8::Object> pData,
+ bool bDefaultPersistent);
void ObjectToArray(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pObj,
CJS_GlobalVariableArray& array);
@@ -267,58 +264,52 @@ void JSGlobalAlternate::Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
UpdateGlobalPersistentVariables();
}
-bool JSGlobalAlternate::QueryProperty(const wchar_t* propname) {
- return WideString(propname) != L"setPersistent";
+CJS_Return JSGlobalAlternate::QueryProperty(const wchar_t* propname) {
+ return CJS_Return(WideString(propname) != L"setPersistent");
}
-bool JSGlobalAlternate::DelProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname) {
+CJS_Return JSGlobalAlternate::DelProperty(CJS_Runtime* pRuntime,
+ const wchar_t* propname) {
auto it = m_MapGlobal.find(ByteString::FromUnicode(propname));
if (it == m_MapGlobal.end())
- return false;
+ return CJS_Return(false);
it->second->bDeleted = true;
- return true;
+ return CJS_Return(true);
}
-bool JSGlobalAlternate::GetProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname,
- CJS_Value* vp) {
+CJS_Return JSGlobalAlternate::GetProperty(CJS_Runtime* pRuntime,
+ const wchar_t* propname) {
auto it = m_MapGlobal.find(ByteString::FromUnicode(propname));
if (it == m_MapGlobal.end())
- return true;
+ return CJS_Return(true);
JSGlobalData* pData = it->second.get();
if (pData->bDeleted)
- return true;
+ return CJS_Return(true);
switch (pData->nType) {
case JS_GlobalDataType::NUMBER:
- vp->Set(pRuntime->NewNumber(pData->dData));
- return true;
+ return CJS_Return(pRuntime->NewNumber(pData->dData));
case JS_GlobalDataType::BOOLEAN:
- vp->Set(pRuntime->NewBoolean(pData->bData));
- return true;
+ return CJS_Return(pRuntime->NewBoolean(pData->bData));
case JS_GlobalDataType::STRING:
- vp->Set(pRuntime->NewString(
+ return CJS_Return(pRuntime->NewString(
WideString::FromLocal(pData->sData.c_str()).c_str()));
- return true;
- case JS_GlobalDataType::OBJECT: {
- vp->Set(v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
- return true;
- }
+ case JS_GlobalDataType::OBJECT:
+ return CJS_Return(
+ v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
case JS_GlobalDataType::NULLOBJ:
- vp->Set(pRuntime->NewNull());
- return true;
+ return CJS_Return(pRuntime->NewNull());
default:
break;
}
- return false;
+ return CJS_Return(false);
}
-bool JSGlobalAlternate::SetProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname,
- v8::Local<v8::Value> vp) {
+CJS_Return JSGlobalAlternate::SetProperty(CJS_Runtime* pRuntime,
+ const wchar_t* propname,
+ v8::Local<v8::Value> vp) {
ByteString sPropName = ByteString::FromUnicode(propname);
if (vp->IsNumber()) {
return SetGlobalVariables(sPropName, JS_GlobalDataType::NUMBER,
@@ -346,28 +337,24 @@ bool JSGlobalAlternate::SetProperty(CJS_Runtime* pRuntime,
}
if (vp->IsUndefined()) {
DelProperty(pRuntime, propname);
- return true;
+ return CJS_Return(true);
}
- return false;
+ return CJS_Return(false);
}
-bool JSGlobalAlternate::setPersistent(
+CJS_Return JSGlobalAlternate::setPersistent(
CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() != 2) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+ const std::vector<v8::Local<v8::Value>>& params) {
+ if (params.size() != 2)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPARAMERROR));
+
auto it = m_MapGlobal.find(
ByteString::FromUnicode(pRuntime->ToWideString(params[0])));
- if (it == m_MapGlobal.end() || it->second->bDeleted) {
- sError = JSGetStringFromID(IDS_STRING_JSNOGLOBAL);
- return false;
- }
+ if (it == m_MapGlobal.end() || it->second->bDeleted)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOGLOBAL));
+
it->second->bPersistent = pRuntime->ToBoolean(params[1]);
- return true;
+ return CJS_Return(true);
}
void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
@@ -552,15 +539,15 @@ void JSGlobalAlternate::DestroyGlobalPersisitentVariables() {
m_MapGlobal.clear();
}
-bool JSGlobalAlternate::SetGlobalVariables(const ByteString& propname,
- JS_GlobalDataType nType,
- double dData,
- bool bData,
- const ByteString& sData,
- v8::Local<v8::Object> pData,
- bool bDefaultPersistent) {
+CJS_Return JSGlobalAlternate::SetGlobalVariables(const ByteString& propname,
+ JS_GlobalDataType nType,
+ double dData,
+ bool bData,
+ const ByteString& sData,
+ v8::Local<v8::Object> pData,
+ bool bDefaultPersistent) {
if (propname.IsEmpty())
- return false;
+ return CJS_Return(false);
auto it = m_MapGlobal.find(propname);
if (it != m_MapGlobal.end()) {
@@ -588,9 +575,9 @@ bool JSGlobalAlternate::SetGlobalVariables(const ByteString& propname,
case JS_GlobalDataType::NULLOBJ:
break;
default:
- return false;
+ return CJS_Return(false);
}
- return true;
+ return CJS_Return(true);
}
auto pNewData = pdfium::MakeUnique<JSGlobalData>();
@@ -620,8 +607,8 @@ bool JSGlobalAlternate::SetGlobalVariables(const ByteString& propname,
pNewData->bPersistent = bDefaultPersistent;
break;
default:
- return false;
+ return CJS_Return(false);
}
m_MapGlobal[propname] = std::move(pNewData);
- return true;
+ return CJS_Return(true);
}
diff --git a/fpdfsdk/javascript/report.cpp b/fpdfsdk/javascript/report.cpp
index adbe7d8f7b..043a68e09e 100644
--- a/fpdfsdk/javascript/report.cpp
+++ b/fpdfsdk/javascript/report.cpp
@@ -26,18 +26,14 @@ Report::Report(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
Report::~Report() {}
-bool Report::writeText(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Report::writeText(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
-bool Report::save(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return Report::save(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return true;
+ return CJS_Return(true);
}
diff --git a/fpdfsdk/javascript/report.h b/fpdfsdk/javascript/report.h
index b5f8ef3cc1..da5f1799cd 100644
--- a/fpdfsdk/javascript/report.h
+++ b/fpdfsdk/javascript/report.h
@@ -17,14 +17,10 @@ class Report : public CJS_EmbedObj {
~Report() override;
public:
- bool save(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool writeText(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
+ CJS_Return save(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return writeText(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
};
class CJS_Report : public CJS_Object {
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 202a1ead7f..3accaa265c 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -73,13 +73,11 @@ util::util(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
util::~util() {}
-bool util::printf(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return util::printf(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
const size_t iSize = params.size();
if (iSize < 1)
- return false;
+ return CJS_Return(false);
std::wstring unsafe_fmt_string(pRuntime->ToWideString(params[0]).c_str());
std::vector<std::wstring> unsafe_conversion_specifiers;
@@ -133,28 +131,21 @@ bool util::printf(CJS_Runtime* pRuntime,
}
c_strResult.erase(c_strResult.begin());
- vRet = CJS_Value(pRuntime->NewString(c_strResult.c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(c_strResult.c_str()));
}
-bool util::printd(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return util::printd(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
const size_t iSize = params.size();
if (iSize < 2)
- return false;
+ return CJS_Return(false);
- if (params[1].IsEmpty() || !params[1]->IsDate()) {
- sError = JSGetStringFromID(IDS_STRING_JSPRINT1);
- return false;
- }
+ if (params[1].IsEmpty() || !params[1]->IsDate())
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPRINT1));
CJS_Date jsDate(params[1].As<v8::Date>());
- if (!jsDate.IsValidDate(pRuntime)) {
- sError = JSGetStringFromID(IDS_STRING_JSPRINT2);
- return false;
- }
+ if (!jsDate.IsValidDate(pRuntime))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSPRINT2));
if (params[0]->IsNumber()) {
WideString swResult;
@@ -180,19 +171,16 @@ bool util::printd(CJS_Runtime* pRuntime,
jsDate.GetSeconds(pRuntime));
break;
default:
- sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
- return false;
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
}
- vRet = CJS_Value(pRuntime->NewString(swResult.c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(swResult.c_str()));
}
if (params[0]->IsString()) {
- if (iSize > 2 && pRuntime->ToBoolean(params[2])) {
- sError = JSGetStringFromID(IDS_STRING_JSNOTSUPPORT);
- return false; // currently, it doesn't support XFAPicture.
- }
+ // We don't support XFAPicture at the moment.
+ if (iSize > 2 && pRuntime->ToBoolean(params[2]))
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSNOTSUPPORT));
// Convert PDF-style format specifiers to wcsftime specifiers. Remove any
// pre-existing %-directives before inserting our own.
@@ -213,10 +201,8 @@ bool util::printd(CJS_Runtime* pRuntime,
}
int iYear = jsDate.GetYear(pRuntime);
- if (iYear < 0) {
- sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
- return false;
- }
+ if (iYear < 0)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
int iMonth = jsDate.GetMonth(pRuntime);
int iDay = jsDate.GetDay(pRuntime);
@@ -259,28 +245,21 @@ bool util::printd(CJS_Runtime* pRuntime,
wchar_t buf[64] = {};
FXSYS_wcsftime(buf, 64, cFormat.c_str(), &time);
cFormat = buf;
- vRet = CJS_Value(pRuntime->NewString(cFormat.c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(cFormat.c_str()));
}
- sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
- return false;
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
}
-bool util::printx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() < 2) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
-
- vRet = CJS_Value(pRuntime->NewString(printx(pRuntime->ToWideString(params[0]),
- pRuntime->ToWideString(params[1]))
- .c_str()));
+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 true;
+ return CJS_Return(
+ pRuntime->NewString(printx(pRuntime->ToWideString(params[0]),
+ pRuntime->ToWideString(params[1]))
+ .c_str()));
}
enum CaseMode { kPreserveCase, kUpperCase, kLowerCase };
@@ -381,47 +360,33 @@ WideString util::printx(const WideString& wsFormat,
return wsResult;
}
-bool util::scand(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
+CJS_Return util::scand(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
- return false;
+ return CJS_Return(false);
WideString sFormat = pRuntime->ToWideString(params[0]);
WideString sDate = pRuntime->ToWideString(params[1]);
double dDate = JS_GetDateTime();
- if (sDate.GetLength() > 0) {
+ if (sDate.GetLength() > 0)
dDate = CJS_PublicMethods::MakeRegularDate(sDate, sFormat, nullptr);
- }
-
- if (!std::isnan(dDate)) {
- vRet = CJS_Value(CJS_Date(pRuntime, dDate).ToV8Value());
- } else {
- vRet.Set(pRuntime->NewUndefined());
- }
- return true;
+ if (std::isnan(dDate))
+ return CJS_Return(pRuntime->NewUndefined());
+ return CJS_Return(CJS_Date(pRuntime, dDate).ToV8Value());
}
-bool util::byteToChar(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError) {
- if (params.size() < 1) {
- sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
- return false;
- }
+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));
int arg = pRuntime->ToInt32(params[0]);
- if (arg < 0 || arg > 255) {
- sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
- return false;
- }
+ if (arg < 0 || arg > 255)
+ return CJS_Return(JSGetStringFromID(IDS_STRING_JSVALUEERROR));
WideString wStr(static_cast<wchar_t>(arg));
- vRet = CJS_Value(pRuntime->NewString(wStr.c_str()));
- return true;
+ return CJS_Return(pRuntime->NewString(wStr.c_str()));
}
// Ensure that sFormat contains at most one well-understood printf formatting
diff --git a/fpdfsdk/javascript/util.h b/fpdfsdk/javascript/util.h
index d40db96527..d71897db99 100644
--- a/fpdfsdk/javascript/util.h
+++ b/fpdfsdk/javascript/util.h
@@ -22,26 +22,16 @@ class util : public CJS_EmbedObj {
explicit util(CJS_Object* pJSObject);
~util() override;
- bool printd(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool printf(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool printx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool scand(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
- bool byteToChar(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params,
- CJS_Value& vRet,
- WideString& sError);
+ CJS_Return printd(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return printf(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return printx(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return scand(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return byteToChar(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
static WideString printx(const WideString& cFormat,
const WideString& cSource);