diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-08-17 19:28:52 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-17 19:28:52 +0000 |
commit | 3a6d058740a9908a06efb9e9362df01acdee6ff8 (patch) | |
tree | 9bc645b0cb3442749458fc63e2feb04c0cb813ef /fxjs/cjs_document.cpp | |
parent | 0a2328e0eff7a11aa49b7da8f013e658153a7b1a (diff) | |
download | pdfium-3a6d058740a9908a06efb9e9362df01acdee6ff8.tar.xz |
Rename CJS_Return to CJS_Result.
"Return" is a verb, and "return" is a reserved-word at that,
so avoid using it as part of a class name.
Fully mechanical change apart from rename.
Change-Id: I120e453e8ba001c4ab74a39e2da6aa6eb590835f
Reviewed-on: https://pdfium-review.googlesource.com/40532
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cjs_document.cpp')
-rw-r--r-- | fxjs/cjs_document.cpp | 574 |
1 files changed, 287 insertions, 287 deletions
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp index b842c150bf..486da1159c 100644 --- a/fxjs/cjs_document.cpp +++ b/fxjs/cjs_document.cpp @@ -131,63 +131,63 @@ CJS_Document::CJS_Document(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime) CJS_Document::~CJS_Document() = default; // The total number of fields in document. -CJS_Return CJS_Document::get_num_fields(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_num_fields(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); - return CJS_Return::Success(pRuntime->NewNumber( + return CJS_Result::Success(pRuntime->NewNumber( static_cast<int>(pPDFForm->CountFields(WideString())))); } -CJS_Return CJS_Document::set_num_fields(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_num_fields(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_dirty(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_dirty(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark())); } -CJS_Return CJS_Document::set_dirty(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pRuntime->ToBoolean(vp) ? m_pFormFillEnv->SetChangeMark() : m_pFormFillEnv->ClearChangeMark(); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_ADBE(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewUndefined()); +CJS_Result CJS_Document::get_ADBE(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewUndefined()); } -CJS_Return CJS_Document::set_ADBE(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_page_num(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_page_num(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView(); if (!pPageView) - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); - return CJS_Return::Success(pRuntime->NewNumber(pPageView->GetPageIndex())); + return CJS_Result::Success(pRuntime->NewNumber(pPageView->GetPageIndex())); } -CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_page_num(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int iPageCount = m_pFormFillEnv->GetPageCount(); int iPageNum = pRuntime->ToInt32(vp); @@ -198,131 +198,131 @@ CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime, else if (iPageNum < 0) m_pFormFillEnv->JS_docgotoPage(0); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::addAnnot( +CJS_Result CJS_Document::addAnnot( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::addField( +CJS_Result CJS_Document::addField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::exportAsText( +CJS_Result CJS_Document::exportAsText( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::exportAsFDF( +CJS_Result CJS_Document::exportAsFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::exportAsXFDF( +CJS_Result CJS_Document::exportAsXFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported, but do not return an error. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getField( +CJS_Result CJS_Document::getField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.empty()) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString wideName = pRuntime->ToWideString(params[0]); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); if (pPDFForm->CountFields(wideName) <= 0) - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); v8::Local<v8::Object> pFieldObj = pRuntime->NewFXJSBoundObject( CJS_Field::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pFieldObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJSField = static_cast<CJS_Field*>(CFXJS_Engine::GetObjectPrivate(pFieldObj)); if (!pJSField) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pJSField->AttachField(this, wideName); - return CJS_Return::Success(pJSField->ToV8Object()); + return CJS_Result::Success(pJSField->ToV8Object()); } // Gets the name of the nth field in the document -CJS_Return CJS_Document::getNthFieldName( +CJS_Result CJS_Document::getNthFieldName( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); int nIndex = pRuntime->ToInt32(params[0]); if (nIndex < 0) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(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::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success( pRuntime->NewString(pField->GetFullName().AsStringView())); } -CJS_Return CJS_Document::importAnFDF( +CJS_Result CJS_Document::importAnFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::importAnXFDF( +CJS_Result CJS_Document::importAnXFDF( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::importTextData( +CJS_Result CJS_Document::importTextData( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } // exports the form data and mails the resulting fdf file as an attachment to // all recipients. // comment: need reader supports -CJS_Return CJS_Document::mailForm( +CJS_Result CJS_Document::mailForm( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); ByteString sTextBuf = pInterForm->ExportFormToFDFTextBuf(); if (sTextBuf.GetLength() == 0) - return CJS_Return::Failure(L"Bad FDF format."); + return CJS_Result::Failure(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(mutable_buf.data(), mutable_buf.size(), bUI, cTo, cSubject, cCc, cBcc, cMsg); pRuntime->EndBlock(); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::print( +CJS_Result CJS_Document::print( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); bool bUI = true; int nStart = 0; @@ -391,35 +391,35 @@ CJS_Return CJS_Document::print( } if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); m_pFormFillEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPrintAsImage, bReverse, bAnnotations); - return CJS_Return::Success(); + return CJS_Result::Success(); } // removes the specified field from the document. // comment: // note: if the filed name is not rational, adobe is dumb for it. -CJS_Return CJS_Document::removeField( +CJS_Result CJS_Document::removeField( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM))) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(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::Success(); + return CJS_Result::Success(); for (const auto& pAnnot : widgets) { CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot.Get()); @@ -449,22 +449,22 @@ CJS_Return CJS_Document::removeField( } m_pFormFillEnv->SetChangeMark(); - return CJS_Return::Success(); + return CJS_Result::Success(); } // reset filed values within a document. // comment: // note: if the fields names r not rational, aodbe is dumb for it. -CJS_Return CJS_Document::resetForm( +CJS_Result CJS_Document::resetForm( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) { - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); } CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); @@ -472,7 +472,7 @@ CJS_Return CJS_Document::resetForm( if (params.empty()) { pPDFForm->ResetForm(NotificationOption::kNotify); m_pFormFillEnv->SetChangeMark(); - return CJS_Return::Success(); + return CJS_Result::Success(); } v8::Local<v8::Array> array; @@ -496,30 +496,30 @@ CJS_Return CJS_Document::resetForm( m_pFormFillEnv->SetChangeMark(); } - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::saveAs( +CJS_Result CJS_Document::saveAs( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::syncAnnotScan( +CJS_Result CJS_Document::syncAnnotScan( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::submitForm( +CJS_Result CJS_Document::submitForm( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { size_t nSize = params.size(); if (nSize < 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Array> aFields; WideString strURL; @@ -553,7 +553,7 @@ CJS_Return CJS_Document::submitForm( pInterForm->SubmitForm(strURL, false); pRuntime->EndBlock(); } - return CJS_Return::Success(); + return CJS_Result::Success(); } std::vector<CPDF_FormField*> fieldObjects; @@ -575,23 +575,23 @@ CJS_Return CJS_Document::submitForm( pInterForm->SubmitFields(strURL, fieldObjects, true, !bFDF); pRuntime->EndBlock(); } - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) { m_pFormFillEnv.Reset(pFormFillEnv); } -CJS_Return CJS_Document::get_bookmark_root(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_bookmark_root(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_bookmark_root(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_bookmark_root(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::mailDoc( +CJS_Result CJS_Document::mailDoc( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // TODO(tsepez): Check maximum number of allowed params. @@ -631,25 +631,25 @@ 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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_author(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_author(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Author"); } -CJS_Return CJS_Document::set_author(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_author(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Author"); } -CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_info(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); const auto* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString cwAuthor = pDictionary->GetUnicodeTextFor("Author"); WideString cwTitle = pDictionary->GetUnicodeTextFor("Title"); @@ -699,81 +699,81 @@ CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) { pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger())); } } - return CJS_Return::Success(pObj); + return CJS_Result::Success(pObj); } -CJS_Return CJS_Document::set_info(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime, const ByteString& propName) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(pRuntime->NewString( pDictionary->GetUnicodeTextFor(propName).AsStringView())); } -CJS_Return CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp, const ByteString& propName) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Dictionary* pDictionary = m_pFormFillEnv->GetPDFDocument()->GetInfo(); if (!pDictionary) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); WideString csProperty = pRuntime->ToWideString(vp); pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty), false); m_pFormFillEnv->SetChangeMark(); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_creation_date(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_creation_date(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "CreationDate"); } -CJS_Return CJS_Document::set_creation_date(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_creation_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "CreationDate"); } -CJS_Return CJS_Document::get_creator(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_creator(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Creator"); } -CJS_Return CJS_Document::set_creator(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_creator(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Creator"); } -CJS_Return CJS_Document::get_delay(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_delay(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewBoolean(m_bDelay)); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(pRuntime->NewBoolean(m_bDelay)); } -CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); m_bDelay = pRuntime->ToBoolean(vp); if (m_bDelay) { m_DelayData.clear(); - return CJS_Return::Success(); + return CJS_Result::Success(); } std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess; @@ -781,151 +781,151 @@ 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::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_keywords(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_keywords(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Keywords"); } -CJS_Return CJS_Document::set_keywords(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_keywords(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Keywords"); } -CJS_Return CJS_Document::get_mod_date(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_mod_date(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "ModDate"); } -CJS_Return CJS_Document::set_mod_date(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_mod_date(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "ModDate"); } -CJS_Return CJS_Document::get_producer(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_producer(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Producer"); } -CJS_Return CJS_Document::set_producer(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_producer(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Producer"); } -CJS_Return CJS_Document::get_subject(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_subject(CJS_Runtime* pRuntime) { return getPropertyInternal(pRuntime, "Subject"); } -CJS_Return CJS_Document::set_subject(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_subject(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { return setPropertyInternal(pRuntime, vp, "Subject"); } -CJS_Return CJS_Document::get_title(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_title(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); return getPropertyInternal(pRuntime, "Title"); } -CJS_Return CJS_Document::set_title(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv || !m_pFormFillEnv->GetPDFDocument()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); return setPropertyInternal(pRuntime, vp, "Title"); } -CJS_Return CJS_Document::get_num_pages(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_num_pages(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success( pRuntime->NewNumber(m_pFormFillEnv->GetPageCount())); } -CJS_Return CJS_Document::set_num_pages(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_num_pages(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_external(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_external(CJS_Runtime* pRuntime) { // In Chrome case, should always return true. - return CJS_Return::Success(pRuntime->NewBoolean(true)); + return CJS_Result::Success(pRuntime->NewBoolean(true)); } -CJS_Return CJS_Document::set_external(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_external(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_filesize(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewNumber(0)); +CJS_Result CJS_Document::get_filesize(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewNumber(0)); } -CJS_Return CJS_Document::set_filesize(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_filesize(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_mouse_x(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_mouse_x(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_mouse_x(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_mouse_x(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_mouse_y(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_mouse_y(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_mouse_y(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_mouse_y(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_URL(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_URL(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success( pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().AsStringView())); } -CJS_Return CJS_Document::set_URL(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) { - return CJS_Return::Success(pRuntime->NewString(m_cwBaseURL.AsStringView())); +CJS_Result CJS_Document::get_base_URL(CJS_Runtime* pRuntime) { + return CJS_Result::Success(pRuntime->NewString(m_cwBaseURL.AsStringView())); } -CJS_Return CJS_Document::set_base_URL(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_base_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { m_cwBaseURL = pRuntime->ToWideString(vp); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_calculate(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_calculate(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - return CJS_Return::Success( + return CJS_Result::Success( pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled())); } -CJS_Return CJS_Document::set_calculate(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); pInterForm->EnableCalculate(pRuntime->ToBoolean(vp)); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); WideString wsFilePath = m_pFormFillEnv->JS_docGetFilePath(); size_t i = wsFilePath.GetLength(); @@ -934,78 +934,78 @@ CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) { break; } if (i > 0 && i < wsFilePath.GetLength()) - return CJS_Return::Success(pRuntime->NewString(wsFilePath.c_str() + i)); + return CJS_Result::Success(pRuntime->NewString(wsFilePath.c_str() + i)); - return CJS_Return::Success(pRuntime->NewString(L"")); + return CJS_Result::Success(pRuntime->NewString(L"")); } -CJS_Return CJS_Document::set_document_file_name(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_document_file_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_path(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_path(CJS_Runtime* pRuntime) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Success(pRuntime->NewString( + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Success(pRuntime->NewString( CJS_App::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()) .AsStringView())); } -CJS_Return CJS_Document::set_path(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::get_page_window_rect(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_page_window_rect(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_page_window_rect(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_page_window_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_layout(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_layout(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_layout(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_layout(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::addLink( +CJS_Result CJS_Document::addLink( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::closeDoc( +CJS_Result CJS_Document::closeDoc( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getPageBox( +CJS_Result CJS_Document::getPageBox( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getAnnot( +CJS_Result CJS_Document::getAnnot( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_AnnotIteration annotIteration(pPageView, false); CPDFSDK_BAAnnot* pSDKBAAnnot = nullptr; @@ -1017,27 +1017,27 @@ CJS_Return CJS_Document::getAnnot( } } if (!pSDKBAAnnot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Annot::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_Annot = static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj)); if (!pJS_Annot) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pJS_Annot->SetSDKAnnot(pSDKBAAnnot); - return CJS_Return::Success(pJS_Annot->ToV8Object()); + return CJS_Result::Success(pJS_Annot->ToV8Object()); } -CJS_Return CJS_Document::getAnnots( +CJS_Result CJS_Document::getAnnots( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); // TODO(tonikitoo): Add support supported parameters as per // the PDF spec. @@ -1047,17 +1047,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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDFSDK_AnnotIteration annotIteration(pPageView, false); for (const auto& pSDKAnnotCur : annotIteration) { if (!pSDKAnnotCur) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Annot::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_Annot = static_cast<CJS_Annot*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -1068,31 +1068,31 @@ CJS_Return CJS_Document::getAnnots( : v8::Local<v8::Value>()); } } - return CJS_Return::Success(annots); + return CJS_Result::Success(annots); } -CJS_Return CJS_Document::getAnnot3D( +CJS_Result CJS_Document::getAnnot3D( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); } -CJS_Return CJS_Document::getAnnots3D( +CJS_Result CJS_Document::getAnnots3D( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getOCGs( +CJS_Result CJS_Document::getOCGs( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getLinks( +CJS_Result CJS_Document::getLinks( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { - return CJS_Return::Success(); + return CJS_Result::Success(); } bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect, @@ -1101,27 +1101,27 @@ bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect, rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom); } -CJS_Return CJS_Document::addIcon( +CJS_Result CJS_Document::addIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 2) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!params[1]->IsObject()) - return CJS_Return::Failure(JSMessage::kTypeError); + return CJS_Result::Failure(JSMessage::kTypeError); v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]); if (!JSGetObject<CJS_Icon>(pObj)) - return CJS_Return::Failure(JSMessage::kTypeError); + return CJS_Result::Failure(JSMessage::kTypeError); WideString swIconName = pRuntime->ToWideString(params[0]); m_IconNames.push_back(swIconName); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) { +CJS_Result CJS_Document::get_icons(CJS_Runtime* pRuntime) { if (m_IconNames.empty()) - return CJS_Return::Success(pRuntime->NewUndefined()); + return CJS_Result::Success(pRuntime->NewUndefined()); v8::Local<v8::Array> Icons = pRuntime->NewArray(); int i = 0; @@ -1129,7 +1129,7 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) { v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJS_Icon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); @@ -1139,93 +1139,93 @@ CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) { ? v8::Local<v8::Value>(pJS_Icon->ToV8Object()) : v8::Local<v8::Value>()); } - return CJS_Return::Success(Icons); + return CJS_Result::Success(Icons); } -CJS_Return CJS_Document::set_icons(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Failure(JSMessage::kReadOnlyError); + return CJS_Result::Failure(JSMessage::kReadOnlyError); } -CJS_Return CJS_Document::getIcon( +CJS_Result CJS_Document::getIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(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::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); v8::Local<v8::Object> pObj = pRuntime->NewFXJSBoundObject( CJS_Icon::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto* pJSIcon = static_cast<CJS_Icon*>(CFXJS_Engine::GetObjectPrivate(pObj)); if (!pJSIcon) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); pJSIcon->SetIconName(*it); - return CJS_Return::Success(pJSIcon->ToV8Object()); + return CJS_Result::Success(pJSIcon->ToV8Object()); } -CJS_Return CJS_Document::removeIcon( +CJS_Result CJS_Document::removeIcon( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, no supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::createDataObject( +CJS_Result CJS_Document::createDataObject( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not implemented. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_media(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_media(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_media(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::calculateNow( +CJS_Result CJS_Document::calculateNow( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!(m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY) || m_pFormFillEnv->GetPermissions(FPDFPERM_ANNOT_FORM) || m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM))) { - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); } m_pFormFillEnv->GetInterForm()->OnCalculate(nullptr); - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_collab(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_collab(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_collab(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_collab(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getPageNthWord( +CJS_Result CJS_Document::getPageNthWord( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(JSMessage::kPermissionError); // TODO(tsepez): check maximum allowable params. @@ -1235,14 +1235,14 @@ CJS_Return CJS_Document::getPageNthWord( CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument(); if (!pDocument) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) - return CJS_Return::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo); if (!pPageDict) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true); page->ParseContent(); @@ -1263,35 +1263,35 @@ CJS_Return CJS_Document::getPageNthWord( if (bStrip) swRet.Trim(); - return CJS_Return::Success(pRuntime->NewString(swRet.AsStringView())); + return CJS_Result::Success(pRuntime->NewString(swRet.AsStringView())); } -CJS_Return CJS_Document::getPageNthWordQuads( +CJS_Result CJS_Document::getPageNthWordQuads( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } -CJS_Return CJS_Document::getPageNumWords( +CJS_Result CJS_Document::getPageNumWords( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) - return CJS_Return::Failure(JSMessage::kPermissionError); + return CJS_Result::Failure(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::Failure(JSMessage::kValueError); + return CJS_Result::Failure(JSMessage::kValueError); CPDF_Dictionary* pPageDict = pDocument->GetPageDictionary(nPageNo); if (!pPageDict) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); auto page = pdfium::MakeRetain<CPDF_Page>(pDocument, pPageDict, true); page->ParseContent(); @@ -1302,17 +1302,17 @@ CJS_Return CJS_Document::getPageNumWords( nWords += CountWords(pPageObj->AsText()); } - return CJS_Return::Success(pRuntime->NewNumber(nWords)); + return CJS_Result::Success(pRuntime->NewNumber(nWords)); } -CJS_Return CJS_Document::getPrintParams( +CJS_Result CJS_Document::getPrintParams( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { v8::Local<v8::Object> pRetObj = pRuntime->NewFXJSBoundObject( CJS_PrintParamsObj::GetObjDefnID(), FXJSOBJTYPE_DYNAMIC); if (pRetObj.IsEmpty()) - return CJS_Return::Failure(JSMessage::kBadObjectError); - return CJS_Return::Failure(JSMessage::kNotSupportedError); + return CJS_Result::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kNotSupportedError); } #define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF) @@ -1385,77 +1385,77 @@ WideString CJS_Document::GetObjWordStr(CPDF_TextObject* pTextObj, return swRet; } -CJS_Return CJS_Document::get_zoom(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_zoom(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_zoom(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::get_zoom_type(CJS_Runtime* pRuntime) { - return CJS_Return::Success(); +CJS_Result CJS_Document::get_zoom_type(CJS_Runtime* pRuntime) { + return CJS_Result::Success(); } -CJS_Return CJS_Document::set_zoom_type(CJS_Runtime* pRuntime, +CJS_Result CJS_Document::set_zoom_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) { - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::deletePages( +CJS_Result CJS_Document::deletePages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::extractPages( +CJS_Result CJS_Document::extractPages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::insertPages( +CJS_Result CJS_Document::insertPages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::replacePages( +CJS_Result CJS_Document::replacePages( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::getURL( +CJS_Result CJS_Document::getURL( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { // Unsafe, not supported. - return CJS_Return::Success(); + return CJS_Result::Success(); } -CJS_Return CJS_Document::gotoNamedDest( +CJS_Result CJS_Document::gotoNamedDest( CJS_Runtime* pRuntime, const std::vector<v8::Local<v8::Value>>& params) { if (params.size() != 1) - return CJS_Return::Failure(JSMessage::kParamError); + return CJS_Result::Failure(JSMessage::kParamError); if (!m_pFormFillEnv) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument(); if (!pDocument) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_NameTree nameTree(pDocument, "Dests"); CPDF_Array* destArray = nameTree.LookupNamedDest(pDocument, pRuntime->ToWideString(params[0])); if (!destArray) - return CJS_Return::Failure(JSMessage::kBadObjectError); + return CJS_Result::Failure(JSMessage::kBadObjectError); CPDF_Dest dest(destArray); const CPDF_Array* arrayObject = ToArray(dest.GetObject()); @@ -1469,7 +1469,7 @@ CJS_Return CJS_Document::gotoNamedDest( dest.GetZoomMode(), scrollPositionArray.data(), scrollPositionArray.size()); pRuntime->EndBlock(); - return CJS_Return::Success(); + return CJS_Result::Success(); } void CJS_Document::AddDelayData(std::unique_ptr<CJS_DelayData> pData) { |