summaryrefslogtreecommitdiff
path: root/fxjs/cjs_document.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs/cjs_document.cpp')
-rw-r--r--fxjs/cjs_document.cpp312
1 files changed, 154 insertions, 158 deletions
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index d6dc4d6020..a259767560 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -135,7 +135,7 @@ void CJS_Document::InitInstance() {
// The total number of fields in document.
CJS_Return CJS_Document::get_num_fields(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
@@ -145,23 +145,23 @@ CJS_Return CJS_Document::get_num_fields(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_num_fields(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
+ return CJS_Return(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_dirty(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
}
CJS_Return CJS_Document::set_dirty(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
pRuntime->ToBoolean(vp) ? m_pFormFillEnv->SetChangeMark()
: m_pFormFillEnv->ClearChangeMark();
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_ADBE(CJS_Runtime* pRuntime) {
@@ -170,12 +170,12 @@ CJS_Return CJS_Document::get_ADBE(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_ADBE(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_page_num(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView();
if (!pPageView)
@@ -186,7 +186,7 @@ CJS_Return CJS_Document::get_page_num(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
int iPageCount = m_pFormFillEnv->GetPageCount();
int iPageNum = pRuntime->ToInt32(vp);
@@ -197,51 +197,51 @@ CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime,
else if (iPageNum < 0)
m_pFormFillEnv->JS_docgotoPage(0);
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::addAnnot(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::addField(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::exportAsText(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::exportAsFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::exportAsXFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::getField(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.empty())
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
WideString wideName = pRuntime->ToWideString(params[0]);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
@@ -252,12 +252,12 @@ CJS_Return CJS_Document::getField(
v8::Local<v8::Object> pFieldObj =
pRuntime->NewFXJSBoundObject(CJS_Field::GetObjDefnID());
if (pFieldObj.IsEmpty())
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
auto* pJSField =
static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pFieldObj));
if (!pJSField)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
pJSField->AttachField(this, wideName);
return CJS_Return(pJSField->ToV8Object());
@@ -268,19 +268,19 @@ CJS_Return CJS_Document::getNthFieldName(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
int nIndex = pRuntime->ToInt32(params[0]);
if (nIndex < 0)
- return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+ return CJS_Return(JSMessage::kValueError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
CPDF_FormField* pField = pPDFForm->GetField(nIndex, WideString());
if (!pField)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(pRuntime->NewString(pField->GetFullName().c_str()));
}
@@ -288,21 +288,21 @@ CJS_Return CJS_Document::importAnFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::importAnXFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::importTextData(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
// exports the form data and mails the resulting fdf file as an attachment to
@@ -312,14 +312,14 @@ CJS_Return CJS_Document::mailForm(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
+ return CJS_Return(JSMessage::kPermissionError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
ByteString sTextBuf = pInterForm->ExportFormToFDFTextBuf();
if (sTextBuf.GetLength() == 0)
- return CJS_Return(false);
+ return CJS_Return(L"Bad FDF format.");
size_t nLength = params.size();
bool bUI = nLength > 0 ? pRuntime->ToBoolean(params[0]) : true;
@@ -338,14 +338,14 @@ CJS_Return CJS_Document::mailForm(
pFormFillEnv->JS_docmailForm(pMutableBuf.get(), nBufSize, bUI, cTo, cSubject,
cCc, cBcc, cMsg);
pRuntime->EndBlock();
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::print(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
bool bUI = true;
int nStart = 0;
@@ -397,11 +397,11 @@ CJS_Return CJS_Document::print(
}
if (!m_pFormFillEnv)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
m_pFormFillEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit,
bPrintAsImage, bReverse, bAnnotations);
- return CJS_Return(true);
+ return CJS_Return();
}
// removes the specified field from the document.
@@ -412,20 +412,20 @@ CJS_Return CJS_Document::removeField(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM)))
- return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
+ return CJS_Return(JSMessage::kPermissionError);
WideString sFieldName = pRuntime->ToWideString(params[0]);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDFSDK_Annot::ObservedPtr> widgets;
pInterForm->GetWidgets(sFieldName, &widgets);
if (widgets.empty())
- return CJS_Return(true);
+ return CJS_Return();
for (const auto& pAnnot : widgets) {
CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot.Get());
@@ -455,7 +455,7 @@ CJS_Return CJS_Document::removeField(
}
m_pFormFillEnv->SetChangeMark();
- return CJS_Return(true);
+ return CJS_Return();
}
// reset filed values within a document.
@@ -466,11 +466,11 @@ CJS_Return CJS_Document::resetForm(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
- return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
+ return CJS_Return(JSMessage::kPermissionError);
}
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
@@ -478,7 +478,7 @@ CJS_Return CJS_Document::resetForm(
if (params.empty()) {
pPDFForm->ResetForm(true);
m_pFormFillEnv->SetChangeMark();
- return CJS_Return(true);
+ return CJS_Return();
}
v8::Local<v8::Array> array;
@@ -502,20 +502,20 @@ CJS_Return CJS_Document::resetForm(
m_pFormFillEnv->SetChangeMark();
}
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::saveAs(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::syncAnnotScan(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::submitForm(
@@ -523,9 +523,9 @@ CJS_Return CJS_Document::submitForm(
const std::vector<v8::Local<v8::Value>>& params) {
size_t nSize = params.size();
if (nSize < 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
v8::Local<v8::Array> aFields;
WideString strURL;
@@ -559,7 +559,7 @@ CJS_Return CJS_Document::submitForm(
pInterForm->SubmitForm(strURL, false);
pRuntime->EndBlock();
}
- return CJS_Return(true);
+ return CJS_Return();
}
std::vector<CPDF_FormField*> fieldObjects;
@@ -581,7 +581,7 @@ CJS_Return CJS_Document::submitForm(
pInterForm->SubmitFields(strURL, fieldObjects, true, !bFDF);
pRuntime->EndBlock();
}
- return CJS_Return(true);
+ return CJS_Return();
}
void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
@@ -589,12 +589,12 @@ void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
}
CJS_Return CJS_Document::get_bookmark_root(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_bookmark_root(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::mailDoc(
@@ -637,7 +637,7 @@ CJS_Return CJS_Document::mailDoc(
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
pFormFillEnv->JS_docmailForm(nullptr, 0, bUI, cTo, cSubject, cCc, cBcc, cMsg);
pRuntime->EndBlock();
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_author(CJS_Runtime* pRuntime) {
@@ -651,11 +651,11 @@ CJS_Return CJS_Document::set_author(CJS_Runtime* pRuntime,
CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
const auto* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
WideString cwAuthor = pDictionary->GetUnicodeTextFor("Author");
WideString cwTitle = pDictionary->GetUnicodeTextFor("Title");
@@ -710,17 +710,17 @@ CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_info(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
+ return CJS_Return(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime,
const ByteString& propName) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(
pRuntime->NewString(pDictionary->GetUnicodeTextFor(propName).c_str()));
}
@@ -729,20 +729,20 @@ CJS_Return CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp,
const ByteString& propName) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo();
if (!pDictionary)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
- return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
+ return CJS_Return(JSMessage::kPermissionError);
WideString csProperty = pRuntime->ToWideString(vp);
pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty),
false);
m_pFormFillEnv->SetChangeMark();
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_creation_date(CJS_Runtime* pRuntime) {
@@ -765,21 +765,21 @@ CJS_Return CJS_Document::set_creator(CJS_Runtime* pRuntime,
CJS_Return CJS_Document::get_delay(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(pRuntime->NewBoolean(m_bDelay));
}
CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
- return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
+ return CJS_Return(JSMessage::kPermissionError);
m_bDelay = pRuntime->ToBoolean(vp);
if (m_bDelay) {
m_DelayData.clear();
- return CJS_Return(true);
+ return CJS_Return();
}
std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess;
@@ -787,7 +787,7 @@ CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime,
for (const auto& pData : DelayDataToProcess)
CJS_Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_keywords(CJS_Runtime* pRuntime) {
@@ -828,26 +828,26 @@ CJS_Return CJS_Document::set_subject(CJS_Runtime* pRuntime,
CJS_Return CJS_Document::get_title(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument())
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
return getPropertyInternal(pRuntime, "Title");
}
CJS_Return CJS_Document::set_title(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument())
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
return setPropertyInternal(pRuntime, vp, "Title");
}
CJS_Return CJS_Document::get_num_pages(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
}
CJS_Return CJS_Document::set_num_pages(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
+ return CJS_Return(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_external(CJS_Runtime* pRuntime) {
@@ -857,7 +857,7 @@ CJS_Return CJS_Document::get_external(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_external(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_filesize(CJS_Runtime* pRuntime) {
@@ -866,37 +866,37 @@ CJS_Return CJS_Document::get_filesize(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_filesize(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
+ return CJS_Return(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_mouse_x(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_mouse_x(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_mouse_y(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_mouse_y(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_URL(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(
pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str()));
}
CJS_Return CJS_Document::set_URL(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
+ return CJS_Return(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) {
@@ -906,12 +906,12 @@ CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_base_URL(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
m_cwBaseURL = pRuntime->ToWideString(vp);
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_calculate(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
return CJS_Return(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
@@ -920,16 +920,16 @@ CJS_Return CJS_Document::get_calculate(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_calculate(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
pInterForm->EnableCalculate(pRuntime->ToBoolean(vp));
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath();
size_t i = wsFilePath.GetLength();
@@ -945,70 +945,70 @@ CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_document_file_name(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
+ return CJS_Return(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_path(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
return CJS_Return(pRuntime->NewString(
CJS_App::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str()));
}
CJS_Return CJS_Document::set_path(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
+ return CJS_Return(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::get_page_window_rect(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_page_window_rect(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_layout(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_layout(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::addLink(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::closeDoc(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::getPageBox(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::getAnnot(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(JSMessage::kParamError);
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
int nPageNo = pRuntime->ToInt32(params[0]);
WideString swAnnotName = pRuntime->ToWideString(params[1]);
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(nPageNo);
if (!pPageView)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
CPDFSDK_AnnotIteration annotIteration(pPageView, false);
CPDFSDK_BAAnnot* pSDKBAAnnot = nullptr;
@@ -1020,17 +1020,17 @@ CJS_Return CJS_Document::getAnnot(
}
}
if (!pSDKBAAnnot)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
v8::Local<v8::Object> pObj =
pRuntime->NewFXJSBoundObject(CJS_Annot::GetObjDefnID());
if (pObj.IsEmpty())
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
auto* pJS_Annot =
static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj));
if (!pJS_Annot)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
pJS_Annot->SetSDKAnnot(pSDKBAAnnot);
return CJS_Return(pJS_Annot->ToV8Object());
@@ -1040,7 +1040,7 @@ CJS_Return CJS_Document::getAnnots(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
// TODO(tonikitoo): Add support supported parameters as per
// the PDF spec.
@@ -1050,17 +1050,17 @@ CJS_Return CJS_Document::getAnnots(
for (int i = 0; i < nPageNo; ++i) {
CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(i);
if (!pPageView)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
CPDFSDK_AnnotIteration annotIteration(pPageView, false);
for (const auto& pSDKAnnotCur : annotIteration) {
if (!pSDKAnnotCur)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
v8::Local<v8::Object> pObj =
pRuntime->NewFXJSBoundObject(CJS_Annot::GetObjDefnID());
if (pObj.IsEmpty())
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
auto* pJS_Annot =
static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj));
@@ -1083,19 +1083,19 @@ CJS_Return CJS_Document::getAnnot3D(
CJS_Return CJS_Document::getAnnots3D(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::getOCGs(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::getLinks(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
- return CJS_Return(true);
+ return CJS_Return();
}
bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect,
@@ -1108,23 +1108,23 @@ CJS_Return CJS_Document::addIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(JSMessage::kParamError);
if (!params[1]->IsObject())
- return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
+ return CJS_Return(JSMessage::kTypeError);
v8::Local<v8::Object> pJSIcon = pRuntime->ToObject(params[1]);
if (CFXJS_Engine::GetObjDefnID(pJSIcon) != CJS_Icon::GetObjDefnID())
- return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
+ return CJS_Return(JSMessage::kTypeError);
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]);
CJS_Object* obj = CFXJS_Engine::GetObjectPrivate(pObj);
if (!obj)
- return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
+ return CJS_Return(JSMessage::kTypeError);
WideString swIconName = pRuntime->ToWideString(params[0]);
m_IconNames.push_back(swIconName);
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) {
@@ -1137,7 +1137,7 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) {
v8::Local<v8::Object> pObj =
pRuntime->NewFXJSBoundObject(CJS_Icon::GetObjDefnID());
if (pObj.IsEmpty())
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
auto* pJS_Icon =
static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj));
@@ -1152,28 +1152,28 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) {
CJS_Return CJS_Document::set_icons(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
+ return CJS_Return(JSMessage::kReadOnlyError);
}
CJS_Return CJS_Document::getIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(JSMessage::kParamError);
WideString swIconName = pRuntime->ToWideString(params[0]);
auto it = std::find(m_IconNames.begin(), m_IconNames.end(), swIconName);
if (it == m_IconNames.end())
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
v8::Local<v8::Object> pObj =
pRuntime->NewFXJSBoundObject(CJS_Icon::GetObjDefnID());
if (pObj.IsEmpty())
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
auto* pJSIcon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj));
if (!pJSIcon)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
pJSIcon->SetIconName(*it);
return CJS_Return(pJSIcon->ToV8Object());
@@ -1183,57 +1183,57 @@ CJS_Return CJS_Document::removeIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, no supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::createDataObject(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not implemented.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_media(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_media(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::calculateNow(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) ||
m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) {
- return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
+ return CJS_Return(JSMessage::kPermissionError);
}
m_pFormFillEnv->GetInterForm()->OnCalculate();
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_collab(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_collab(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::getPageNthWord(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
+ return CJS_Return(JSMessage::kPermissionError);
// TODO(tsepez): check maximum allowable params.
@@ -1243,14 +1243,14 @@ CJS_Return CJS_Document::getPageNthWord(
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (!pDocument)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
- return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+ return CJS_Return(JSMessage::kValueError);
CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo);
if (!pPageDict)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true);
page->ParseContent();
@@ -1278,28 +1278,28 @@ CJS_Return CJS_Document::getPageNthWordQuads(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return(JSMessage::kNotSupportedError);
}
CJS_Return CJS_Document::getPageNumWords(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
- return CJS_Return(JSGetStringFromID(JSMessage::kPermissionError));
+ return CJS_Return(JSMessage::kPermissionError);
int nPageNo = params.size() > 0 ? pRuntime->ToInt32(params[0]) : 0;
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount())
- return CJS_Return(JSGetStringFromID(JSMessage::kValueError));
+ return CJS_Return(JSMessage::kValueError);
CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo);
if (!pPageDict)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true);
page->ParseContent();
@@ -1319,11 +1319,8 @@ CJS_Return CJS_Document::getPrintParams(
v8::Local<v8::Object> pRetObj =
pRuntime->NewFXJSBoundObject(CJS_PrintParamsObj::GetObjDefnID());
if (pRetObj.IsEmpty())
- return CJS_Return(false);
-
- // Not implemented yet.
-
- return CJS_Return(pRetObj);
+ return CJS_Return(JSMessage::kBadObjectError);
+ return CJS_Return(JSMessage::kNotSupportedError);
}
#define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF)
@@ -1332,14 +1329,12 @@ int CJS_Document::CountWords(CPDF_TextObject* pTextObj) {
if (!pTextObj)
return 0;
- int nWords = 0;
-
CPDF_Font* pFont = pTextObj->GetFont();
if (!pFont)
return 0;
bool bIsLatin = false;
-
+ int nWords = 0;
for (size_t i = 0, sz = pTextObj->CountChars(); i < sz; ++i) {
uint32_t charcode = CPDF_Font::kInvalidCharCode;
float kerning;
@@ -1399,75 +1394,76 @@ WideString CJS_Document::GetObjWordStr(CPDF_TextObject* pTextObj,
}
CJS_Return CJS_Document::get_zoom(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_zoom(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::get_zoom_type(CJS_Runtime* pRuntime) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::set_zoom_type(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp) {
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::deletePages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::extractPages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::insertPages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::replacePages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::getURL(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
- return CJS_Return(true);
+ return CJS_Return();
}
CJS_Return CJS_Document::gotoNamedDest(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
- return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
+ return CJS_Return(JSMessage::kParamError);
+
if (!m_pFormFillEnv)
- return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
+ return CJS_Return(JSMessage::kBadObjectError);
CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
if (!pDocument)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
CPDF_NameTree nameTree(pDocument, "Dests");
CPDF_Array* destArray =
nameTree.LookupNamedDest(pDocument, pRuntime->ToWideString(params[0]));
if (!destArray)
- return CJS_Return(false);
+ return CJS_Return(JSMessage::kBadObjectError);
CPDF_Dest dest(destArray);
const CPDF_Array* arrayObject = ToArray(dest.GetObject());
@@ -1481,7 +1477,7 @@ CJS_Return CJS_Document::gotoNamedDest(
dest.GetZoomMode(), scrollPositionArray.data(),
scrollPositionArray.size());
pRuntime->EndBlock();
- return CJS_Return(true);
+ return CJS_Return();
}
void CJS_Document::AddDelayData(std::unique_ptr<CJS_DelayData> pData) {