diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-10-23 09:44:30 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-10-23 17:57:28 +0000 |
commit | 33d13f2231a07e7b32ff25da6a6a28cb619d18a9 (patch) | |
tree | 8be1d6a857dff58d8aacbc1dc722fceac8343235 | |
parent | c970895f94cf76eb738d0a583ae139fecdd85268 (diff) | |
download | pdfium-33d13f2231a07e7b32ff25da6a6a28cb619d18a9.tar.xz |
Remove CJS_PropValue
This CL removes the CJS_PropValue class and uses CJS_Value directly. The
various Set methods have been moved to CJS_Value and the runtime provided as
needed.
Change-Id: Ib5d3b9efc9b6cf8182be8f19af98599379c3d7db
Reviewed-on: https://pdfium-review.googlesource.com/16431
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r-- | fpdfsdk/javascript/Annot.cpp | 28 | ||||
-rw-r--r-- | fpdfsdk/javascript/Annot.h | 16 | ||||
-rw-r--r-- | fpdfsdk/javascript/Document.cpp | 182 | ||||
-rw-r--r-- | fpdfsdk/javascript/Document.h | 172 | ||||
-rw-r--r-- | fpdfsdk/javascript/Field.cpp | 451 | ||||
-rw-r--r-- | fpdfsdk/javascript/Field.h | 258 | ||||
-rw-r--r-- | fpdfsdk/javascript/Icon.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/javascript/Icon.h | 6 | ||||
-rw-r--r-- | fpdfsdk/javascript/JS_Define.h | 27 | ||||
-rw-r--r-- | fpdfsdk/javascript/JS_Value.cpp | 189 | ||||
-rw-r--r-- | fpdfsdk/javascript/JS_Value.h | 67 | ||||
-rw-r--r-- | fpdfsdk/javascript/PublicMethods.cpp | 16 | ||||
-rw-r--r-- | fpdfsdk/javascript/app.cpp | 80 | ||||
-rw-r--r-- | fpdfsdk/javascript/app.h | 58 | ||||
-rw-r--r-- | fpdfsdk/javascript/color.cpp | 80 | ||||
-rw-r--r-- | fpdfsdk/javascript/color.h | 68 | ||||
-rw-r--r-- | fpdfsdk/javascript/event.cpp | 132 | ||||
-rw-r--r-- | fpdfsdk/javascript/event.h | 102 | ||||
-rw-r--r-- | fpdfsdk/javascript/global.cpp | 34 | ||||
-rw-r--r-- | fpdfsdk/javascript/global.h | 4 |
20 files changed, 837 insertions, 1141 deletions
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp index 0fb83e051b..867cfc49bf 100644 --- a/fpdfsdk/javascript/Annot.cpp +++ b/fpdfsdk/javascript/Annot.cpp @@ -36,7 +36,7 @@ Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {} Annot::~Annot() {} bool Annot::get_hidden(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pAnnot) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -44,14 +44,14 @@ bool Annot::get_hidden(CJS_Runtime* pRuntime, } CPDF_Annot* pPDFAnnot = ToBAAnnot(m_pAnnot.Get())->GetPDFAnnot(); - vp->Set(CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict())); + vp->Set(pRuntime, CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict())); return true; } bool Annot::set_hidden(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { - bool bHidden = vp.ToBool(); // May invalidate m_pAnnot. + bool bHidden = vp.ToBool(pRuntime); // May invalidate m_pAnnot. if (!m_pAnnot) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; @@ -74,22 +74,20 @@ bool Annot::set_hidden(CJS_Runtime* pRuntime, return true; } -bool Annot::get_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool Annot::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { if (!m_pAnnot) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; } - vp->Set(ToBAAnnot(m_pAnnot.Get())->GetAnnotName()); + vp->Set(pRuntime, ToBAAnnot(m_pAnnot.Get())->GetAnnotName()); return true; } bool Annot::set_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { - WideString annotName = vp.ToWideString(); // May invalidate m_pAnnot. + WideString annotName = vp.ToWideString(pRuntime); // May invalidate m_pAnnot. if (!m_pAnnot) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; @@ -99,21 +97,19 @@ bool Annot::set_name(CJS_Runtime* pRuntime, return true; } -bool Annot::get_type(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool Annot::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { if (!m_pAnnot) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; } - vp->Set(CPDF_Annot::AnnotSubtypeToString( - ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype())); + vp->Set(pRuntime, CPDF_Annot::AnnotSubtypeToString( + ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype())); return true; } bool Annot::set_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; diff --git a/fpdfsdk/javascript/Annot.h b/fpdfsdk/javascript/Annot.h index c5fb3f2e1e..5e06ae8070 100644 --- a/fpdfsdk/javascript/Annot.h +++ b/fpdfsdk/javascript/Annot.h @@ -17,20 +17,16 @@ class Annot : public CJS_EmbedObj { explicit Annot(CJS_Object* pJSObject); ~Annot() override; - bool get_hidden(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_hidden(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_hidden(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_name(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_name(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_type(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_type(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); void SetSDKAnnot(CPDFSDK_BAAnnot* annot); diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp index 5d8f5528f7..30375ba41f 100644 --- a/fpdfsdk/javascript/Document.cpp +++ b/fpdfsdk/javascript/Document.cpp @@ -163,7 +163,7 @@ Document::~Document() {} // the total number of fields in document. bool Document::get_num_fields(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -172,58 +172,58 @@ bool Document::get_num_fields(CJS_Runtime* pRuntime, CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); - vp->Set(static_cast<int>(pPDFForm->CountFields(WideString()))); + vp->Set(pRuntime, static_cast<int>(pPDFForm->CountFields(WideString()))); return true; } bool Document::set_num_fields(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; } bool Document::get_dirty(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; } - vp->Set(!!m_pFormFillEnv->GetChangeMark()); + vp->Set(pRuntime, !!m_pFormFillEnv->GetChangeMark()); return true; } bool Document::set_dirty(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; } - vp.ToBool() ? m_pFormFillEnv->SetChangeMark() - : m_pFormFillEnv->ClearChangeMark(); + vp.ToBool(pRuntime) ? m_pFormFillEnv->SetChangeMark() + : m_pFormFillEnv->ClearChangeMark(); return true; } bool Document::get_ADBE(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->GetJSValue()->SetNull(pRuntime); + vp->SetNull(pRuntime); return true; } bool Document::set_ADBE(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool Document::get_page_num(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -231,12 +231,12 @@ bool Document::get_page_num(CJS_Runtime* pRuntime, } if (CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView()) - vp->Set(pPageView->GetPageIndex()); + vp->Set(pRuntime, pPageView->GetPageIndex()); return true; } bool Document::set_page_num(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -244,7 +244,7 @@ bool Document::set_page_num(CJS_Runtime* pRuntime, } int iPageCount = m_pFormFillEnv->GetPageCount(); - int iPageNum = vp.ToInt(); + int iPageNum = vp.ToInt(pRuntime); if (iPageNum >= 0 && iPageNum < iPageCount) m_pFormFillEnv->JS_docgotoPage(iPageNum); else if (iPageNum >= iPageCount) @@ -694,13 +694,13 @@ void Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) { } bool Document::get_bookmark_root(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_bookmark_root(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } @@ -761,19 +761,19 @@ bool Document::mailDoc(CJS_Runtime* pRuntime, } bool Document::get_author(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return getPropertyInternal(pRuntime, vp, "Author", sError); } bool Document::set_author(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return setPropertyInternal(pRuntime, vp, "Author", sError); } bool Document::get_info(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -832,19 +832,19 @@ bool Document::get_info(CJS_Runtime* pRuntime, pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger())); } } - vp->Set(pObj); + vp->Set(pRuntime, pObj); return true; } bool Document::set_info(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; } bool Document::getPropertyInternal(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, const ByteString& propName, WideString* sError) { if (!m_pFormFillEnv) { @@ -856,12 +856,12 @@ bool Document::getPropertyInternal(CJS_Runtime* pRuntime, if (!pDictionary) return false; - vp->Set(pDictionary->GetUnicodeTextFor(propName)); + vp->Set(pRuntime, pDictionary->GetUnicodeTextFor(propName)); return true; } bool Document::setPropertyInternal(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, const ByteString& propName, WideString* sError) { if (!m_pFormFillEnv) { @@ -877,7 +877,7 @@ bool Document::setPropertyInternal(CJS_Runtime* pRuntime, *sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION); return false; } - WideString csProperty = vp.ToWideString(); + WideString csProperty = vp.ToWideString(pRuntime); pDictionary->SetNewFor<CPDF_String>(propName, PDF_EncodeText(csProperty), false); m_pFormFillEnv->SetChangeMark(); @@ -885,42 +885,42 @@ bool Document::setPropertyInternal(CJS_Runtime* pRuntime, } bool Document::get_creation_date(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return getPropertyInternal(pRuntime, vp, "CreationDate", sError); } bool Document::set_creation_date(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return setPropertyInternal(pRuntime, vp, "CreationDate", sError); } bool Document::get_creator(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return getPropertyInternal(pRuntime, vp, "Creator", sError); } bool Document::set_creator(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return setPropertyInternal(pRuntime, vp, "Creator", sError); } bool Document::get_delay(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; } - vp->Set(m_bDelay); + vp->Set(pRuntime, m_bDelay); return true; } bool Document::set_delay(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -932,7 +932,7 @@ bool Document::set_delay(CJS_Runtime* pRuntime, return false; } - m_bDelay = vp.ToBool(); + m_bDelay = vp.ToBool(pRuntime); if (m_bDelay) { m_DelayData.clear(); return true; @@ -947,55 +947,55 @@ bool Document::set_delay(CJS_Runtime* pRuntime, } bool Document::get_keywords(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return getPropertyInternal(pRuntime, vp, "Keywords", sError); } bool Document::set_keywords(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return setPropertyInternal(pRuntime, vp, "Keywords", sError); } bool Document::get_mod_date(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return getPropertyInternal(pRuntime, vp, "ModDate", sError); } bool Document::set_mod_date(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return setPropertyInternal(pRuntime, vp, "ModDate", sError); } bool Document::get_producer(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return getPropertyInternal(pRuntime, vp, "Producer", sError); } bool Document::set_producer(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return setPropertyInternal(pRuntime, vp, "Producer", sError); } bool Document::get_subject(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return getPropertyInternal(pRuntime, vp, "Subject", sError); } bool Document::set_subject(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return setPropertyInternal(pRuntime, vp, "Subject", sError); } bool Document::get_title(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument()) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -1005,7 +1005,7 @@ bool Document::get_title(CJS_Runtime* pRuntime, } bool Document::set_title(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument()) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -1015,109 +1015,109 @@ bool Document::set_title(CJS_Runtime* pRuntime, } bool Document::get_num_pages(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; } - vp->Set(m_pFormFillEnv->GetPageCount()); + vp->Set(pRuntime, m_pFormFillEnv->GetPageCount()); return true; } bool Document::set_num_pages(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; } bool Document::get_external(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { // In Chrome case, should always return true. - vp->Set(true); + vp->Set(pRuntime, true); return true; } bool Document::set_external(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool Document::get_filesize(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(0); + vp->Set(pRuntime, 0); return true; } bool Document::set_filesize(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; } bool Document::get_mouse_x(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_mouse_x(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool Document::get_mouse_y(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_mouse_y(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool Document::get_URL(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; } - vp->Set(m_pFormFillEnv->JS_docGetFilePath()); + vp->Set(pRuntime, m_pFormFillEnv->JS_docGetFilePath()); return true; } bool Document::set_URL(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; } bool Document::get_base_URL(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(m_cwBaseURL); + vp->Set(pRuntime, m_cwBaseURL); return true; } bool Document::set_base_URL(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { - m_cwBaseURL = vp.ToWideString(); + m_cwBaseURL = vp.ToWideString(pRuntime); return true; } bool Document::get_calculate(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -1125,12 +1125,12 @@ bool Document::get_calculate(CJS_Runtime* pRuntime, } CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - vp->Set(!!pInterForm->IsCalculateEnabled()); + vp->Set(pRuntime, !!pInterForm->IsCalculateEnabled()); return true; } bool Document::set_calculate(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -1138,12 +1138,12 @@ bool Document::set_calculate(CJS_Runtime* pRuntime, } CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); - pInterForm->EnableCalculate(vp.ToBool()); + pInterForm->EnableCalculate(vp.ToBool(pRuntime)); return true; } bool Document::get_document_file_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); @@ -1158,58 +1158,58 @@ bool Document::get_document_file_name(CJS_Runtime* pRuntime, } if (i > 0 && i < wsFilePath.GetLength()) - vp->Set(wsFilePath.GetBuffer(wsFilePath.GetLength()) + i); + vp->Set(pRuntime, wsFilePath.GetBuffer(wsFilePath.GetLength()) + i); else - vp->Set(L""); + vp->Set(pRuntime, L""); return true; } bool Document::set_document_file_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; } bool Document::get_path(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (!m_pFormFillEnv) { *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT); return false; } - vp->Set(app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath())); + vp->Set(pRuntime, app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath())); return true; } bool Document::set_path(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; } bool Document::get_page_window_rect(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_page_window_rect(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool Document::get_layout(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_layout(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } @@ -1385,10 +1385,10 @@ bool Document::addIcon(CJS_Runtime* pRuntime, } bool Document::get_icons(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { if (m_IconNames.empty()) { - vp->GetJSValue()->SetNull(pRuntime); + vp->SetNull(pRuntime); return true; } @@ -1407,12 +1407,12 @@ bool Document::get_icons(CJS_Runtime* pRuntime, Icons.SetElement(pRuntime, i++, CJS_Value(pRuntime, pJS_Icon)); } - vp->Set(Icons); + vp->Set(pRuntime, Icons); return true; } bool Document::set_icons(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; @@ -1461,13 +1461,13 @@ bool Document::createDataObject(CJS_Runtime* pRuntime, } bool Document::get_media(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_media(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } @@ -1491,13 +1491,13 @@ bool Document::calculateNow(CJS_Runtime* pRuntime, } bool Document::get_collab(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_collab(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } @@ -1698,24 +1698,24 @@ WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex) { } bool Document::get_zoom(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_zoom(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool Document::get_zoom_type(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Document::set_zoom_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } diff --git a/fpdfsdk/javascript/Document.h b/fpdfsdk/javascript/Document.h index 8535cd0fd8..49ac75b746 100644 --- a/fpdfsdk/javascript/Document.h +++ b/fpdfsdk/javascript/Document.h @@ -50,203 +50,163 @@ class Document : public CJS_EmbedObj { explicit Document(CJS_Object* pJSObject); ~Document() override; - bool get_ADBE(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_ADBE(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_ADBE(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_ADBE(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_author(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_author(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_author(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_base_URL(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_base_URL(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_base_URL(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_bookmark_root(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_bookmark_root(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_calculate(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_calculate(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_calculate(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_collab(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_collab(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_collab(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_creation_date(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_creation_date(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_creator(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_creator(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_creator(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_delay(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_delay(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_delay(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_dirty(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_dirty(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_dirty(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_document_file_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_document_file_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_external(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_external(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_external(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_filesize(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_filesize(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_filesize(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_icons(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_icons(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_icons(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_info(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_info(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_info(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_info(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_keywords(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_keywords(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_keywords(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_layout(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_layout(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_layout(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_media(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_media(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_media(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_mod_date(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_mod_date(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_mod_date(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_mouse_x(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_mouse_x(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_mouse_x(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_mouse_y(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_mouse_y(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_mouse_y(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_num_fields(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_num_fields(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_num_fields(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_num_pages(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_num_pages(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_num_pages(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_page_num(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_page_num(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_page_num(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_page_window_rect(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_page_window_rect(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_path(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_path(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_path(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_path(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_producer(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_producer(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_producer(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_subject(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_subject(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_subject(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_title(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_title(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_title(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_zoom(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_zoom(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_zoom(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_zoom(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_zoom_type(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_zoom_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_zoom_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_URL(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_URL(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_URL(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_URL(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); bool addAnnot(CJS_Runtime* pRuntime, const std::vector<CJS_Value>& params, @@ -431,11 +391,11 @@ class Document : public CJS_EmbedObj { WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex); bool getPropertyInternal(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, const ByteString& propName, WideString* sError); bool setPropertyInternal(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, const ByteString& propName, WideString* sError); diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp index d3923141da..f315301164 100644 --- a/fpdfsdk/javascript/Field.cpp +++ b/fpdfsdk/javascript/Field.cpp @@ -382,7 +382,7 @@ CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) { } bool Field::get_alignment(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -400,30 +400,30 @@ bool Field::get_alignment(CJS_Runtime* pRuntime, switch (pFormControl->GetControlAlignment()) { case 1: - vp->Set(L"center"); + vp->Set(pRuntime, L"center"); break; case 0: - vp->Set(L"left"); + vp->Set(pRuntime, L"left"); break; case 2: - vp->Set(L"right"); + vp->Set(pRuntime, L"right"); break; default: - vp->Set(L""); + vp->Set(pRuntime, L""); } return true; } bool Field::set_alignment(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_border_style(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -442,29 +442,29 @@ bool Field::get_border_style(CJS_Runtime* pRuntime, switch (pWidget->GetBorderStyle()) { case BorderStyle::SOLID: - vp->Set(L"solid"); + vp->Set(pRuntime, L"solid"); break; case BorderStyle::DASH: - vp->Set(L"dashed"); + vp->Set(pRuntime, L"dashed"); break; case BorderStyle::BEVELED: - vp->Set(L"beveled"); + vp->Set(pRuntime, L"beveled"); break; case BorderStyle::INSET: - vp->Set(L"inset"); + vp->Set(pRuntime, L"inset"); break; case BorderStyle::UNDERLINE: - vp->Set(L"underline"); + vp->Set(pRuntime, L"underline"); break; default: - vp->Set(L""); + vp->Set(pRuntime, L""); break; } return true; } bool Field::set_border_style(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -472,10 +472,10 @@ bool Field::set_border_style(CJS_Runtime* pRuntime, return false; if (m_bDelay) { - AddDelay_String(FP_BORDERSTYLE, vp.ToByteString()); + AddDelay_String(FP_BORDERSTYLE, vp.ToByteString(pRuntime)); } else { Field::SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName, - m_nFormControlIndex, vp.ToByteString()); + m_nFormControlIndex, vp.ToByteString(pRuntime)); } return true; } @@ -533,7 +533,7 @@ void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv, } bool Field::get_button_align_x(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -555,19 +555,19 @@ bool Field::get_button_align_x(CJS_Runtime* pRuntime, float fBottom; IconFit.GetIconPosition(fLeft, fBottom); - vp->Set(static_cast<int32_t>(fLeft)); + vp->Set(pRuntime, static_cast<int32_t>(fLeft)); return true; } bool Field::set_button_align_x(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_button_align_y(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -589,19 +589,19 @@ bool Field::get_button_align_y(CJS_Runtime* pRuntime, float fBottom; IconFit.GetIconPosition(fLeft, fBottom); - vp->Set(static_cast<int32_t>(fBottom)); + vp->Set(pRuntime, static_cast<int32_t>(fBottom)); return true; } bool Field::set_button_align_y(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_button_fit_bounds(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -617,19 +617,19 @@ bool Field::get_button_fit_bounds(CJS_Runtime* pRuntime, if (!pFormControl) return false; - vp->Set(pFormControl->GetIconFit().GetFittingBounds()); + vp->Set(pRuntime, pFormControl->GetIconFit().GetFittingBounds()); return true; } bool Field::set_button_fit_bounds(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_button_position(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -645,19 +645,19 @@ bool Field::get_button_position(CJS_Runtime* pRuntime, if (!pFormControl) return false; - vp->Set(pFormControl->GetTextPosition()); + vp->Set(pRuntime, pFormControl->GetTextPosition()); return true; } bool Field::set_button_position(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_button_scale_how(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -673,19 +673,19 @@ bool Field::get_button_scale_how(CJS_Runtime* pRuntime, if (!pFormControl) return false; - vp->Set(pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1); + vp->Set(pRuntime, pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1); return true; } bool Field::set_button_scale_how(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_button_scale_when(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -705,30 +705,30 @@ bool Field::get_button_scale_when(CJS_Runtime* pRuntime, int ScaleM = IconFit.GetScaleMethod(); switch (ScaleM) { case CPDF_IconFit::Always: - vp->Set(static_cast<int32_t>(CPDF_IconFit::Always)); + vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Always)); break; case CPDF_IconFit::Bigger: - vp->Set(static_cast<int32_t>(CPDF_IconFit::Bigger)); + vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Bigger)); break; case CPDF_IconFit::Never: - vp->Set(static_cast<int32_t>(CPDF_IconFit::Never)); + vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Never)); break; case CPDF_IconFit::Smaller: - vp->Set(static_cast<int32_t>(CPDF_IconFit::Smaller)); + vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Smaller)); break; } return true; } bool Field::set_button_scale_when(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_calc_order_index(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -744,20 +744,20 @@ bool Field::get_calc_order_index(CJS_Runtime* pRuntime, CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm(); CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm(); - vp->Set(static_cast<int32_t>( - pInterForm->FindFieldInCalculationOrder(pFormField))); + vp->Set(pRuntime, static_cast<int32_t>( + pInterForm->FindFieldInCalculationOrder(pFormField))); return true; } bool Field::set_calc_order_index(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_char_limit(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -769,20 +769,18 @@ bool Field::get_char_limit(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) return false; - vp->Set(static_cast<int32_t>(pFormField->GetMaxLen())); + vp->Set(pRuntime, static_cast<int32_t>(pFormField->GetMaxLen())); return true; } bool Field::set_char_limit(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } -bool Field::get_comb(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool Field::get_comb(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); @@ -793,19 +791,19 @@ bool Field::get_comb(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_COMB)); return true; } bool Field::set_comb(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_commit_on_sel_change(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -819,19 +817,20 @@ bool Field::get_commit_on_sel_change(CJS_Runtime* pRuntime, return false; } - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)); + vp->Set(pRuntime, + !!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)); return true; } bool Field::set_commit_on_sel_change(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_current_value_indices(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -845,11 +844,11 @@ bool Field::get_current_value_indices(CJS_Runtime* pRuntime, int count = pFormField->CountSelectedItems(); if (count <= 0) { - vp->Set(-1); + vp->Set(pRuntime, -1); return true; } if (count == 1) { - vp->Set(pFormField->GetSelectedIndex(0)); + vp->Set(pRuntime, pFormField->GetSelectedIndex(0)); return true; } @@ -858,22 +857,22 @@ bool Field::get_current_value_indices(CJS_Runtime* pRuntime, SelArray.SetElement(pRuntime, i, CJS_Value(pRuntime, pFormField->GetSelectedIndex(i))); } - vp->Set(SelArray); + vp->Set(pRuntime, SelArray); return true; } bool Field::set_current_value_indices(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; std::vector<uint32_t> array; - if (vp.GetJSValue()->GetType() == CJS_Value::VT_number) { - array.push_back(vp.ToInt()); - } else if (vp.GetJSValue()->IsArrayObject()) { - CJS_Array SelArray = vp.ToArray(); + if (vp.GetType() == CJS_Value::VT_number) { + array.push_back(vp.ToInt(pRuntime)); + } else if (vp.IsArrayObject()) { + CJS_Array SelArray = vp.ToArray(pRuntime); for (int i = 0, sz = SelArray.GetLength(pRuntime); i < sz; i++) array.push_back(SelArray.GetElement(pRuntime, i).ToInt(pRuntime)); } @@ -914,19 +913,19 @@ void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv, } bool Field::get_default_style(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return false; } bool Field::set_default_style(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool Field::get_default_value(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -940,19 +939,19 @@ bool Field::get_default_value(CJS_Runtime* pRuntime, return false; } - vp->Set(pFormField->GetDefaultValue()); + vp->Set(pRuntime, pFormField->GetDefaultValue()); return true; } bool Field::set_default_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_do_not_scroll(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -964,19 +963,19 @@ bool Field::get_do_not_scroll(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)); return true; } bool Field::set_do_not_scroll(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_do_not_spell_check(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -990,12 +989,13 @@ bool Field::get_do_not_spell_check(CJS_Runtime* pRuntime, return false; } - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)); + vp->Set(pRuntime, + !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)); return true; } bool Field::set_do_not_spell_check(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; @@ -1011,24 +1011,24 @@ void Field::SetDelay(bool bDelay) { } bool Field::get_delay(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(m_bDelay); + vp->Set(pRuntime, m_bDelay); return true; } bool Field::set_delay(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; - SetDelay(vp.ToBool()); + SetDelay(vp.ToBool(pRuntime)); return true; } bool Field::get_display(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1045,31 +1045,31 @@ bool Field::get_display(CJS_Runtime* pRuntime, uint32_t dwFlag = pWidget->GetFlags(); if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) { - vp->Set(1); + vp->Set(pRuntime, 1); return true; } if (ANNOTFLAG_PRINT & dwFlag) { if (ANNOTFLAG_NOVIEW & dwFlag) - vp->Set(3); + vp->Set(pRuntime, 3); else - vp->Set(0); + vp->Set(pRuntime, 0); } else { - vp->Set(2); + vp->Set(pRuntime, 2); } return true; } bool Field::set_display(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; if (m_bDelay) { - AddDelay_Int(FP_DISPLAY, vp.ToInt()); + AddDelay_Int(FP_DISPLAY, vp.ToInt(pRuntime)); } else { Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, - vp.ToInt()); + vp.ToInt(pRuntime)); } return true; } @@ -1110,21 +1110,19 @@ void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv, } } -bool Field::get_doc(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { - vp->Set(m_pJSDoc->GetCJSDoc()); +bool Field::get_doc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { + vp->Set(pRuntime, m_pJSDoc->GetCJSDoc()); return true; } bool Field::set_doc(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool Field::get_editable(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1134,18 +1132,18 @@ bool Field::get_editable(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT)); return true; } bool Field::set_editable(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return m_bCanSet; } bool Field::get_export_values(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1179,12 +1177,12 @@ bool Field::get_export_values(CJS_Runtime* pRuntime, CJS_Value(pRuntime, pFormControl->GetExportValue().c_str())); } - vp->Set(ExportValusArray); + vp->Set(pRuntime, ExportValusArray); return true; } bool Field::set_export_values(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1196,11 +1194,11 @@ bool Field::set_export_values(CJS_Runtime* pRuntime, return false; } - return m_bCanSet && vp.GetJSValue()->IsArrayObject(); + return m_bCanSet && vp.IsArrayObject(); } bool Field::get_file_select(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1210,12 +1208,12 @@ bool Field::get_file_select(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)); return true; } bool Field::set_file_select(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1229,7 +1227,7 @@ bool Field::set_file_select(CJS_Runtime* pRuntime, } bool Field::get_fill_color(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_Array crArray; std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); @@ -1267,25 +1265,25 @@ bool Field::get_fill_color(CJS_Runtime* pRuntime, } color::ConvertPWLColorToArray(pRuntime, color, &crArray); - vp->Set(crArray); + vp->Set(pRuntime, crArray); return true; } bool Field::set_fill_color(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return false; if (!m_bCanSet) return false; - if (!vp.GetJSValue()->IsArrayObject()) + if (!vp.IsArrayObject()) return false; return true; } bool Field::get_hidden(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1301,21 +1299,22 @@ bool Field::get_hidden(CJS_Runtime* pRuntime, return false; uint32_t dwFlags = pWidget->GetFlags(); - vp->Set(ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags); + vp->Set(pRuntime, + ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags); return true; } bool Field::set_hidden(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; if (m_bDelay) { - AddDelay_Bool(FP_HIDDEN, vp.ToBool()); + AddDelay_Bool(FP_HIDDEN, vp.ToBool(pRuntime)); } else { Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, - vp.ToBool()); + vp.ToBool(pRuntime)); } return true; } @@ -1329,7 +1328,7 @@ void Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv, } bool Field::get_highlight(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -1348,33 +1347,33 @@ bool Field::get_highlight(CJS_Runtime* pRuntime, int eHM = pFormControl->GetHighlightingMode(); switch (eHM) { case CPDF_FormControl::None: - vp->Set(L"none"); + vp->Set(pRuntime, L"none"); break; case CPDF_FormControl::Push: - vp->Set(L"push"); + vp->Set(pRuntime, L"push"); break; case CPDF_FormControl::Invert: - vp->Set(L"invert"); + vp->Set(pRuntime, L"invert"); break; case CPDF_FormControl::Outline: - vp->Set(L"outline"); + vp->Set(pRuntime, L"outline"); break; case CPDF_FormControl::Toggle: - vp->Set(L"toggle"); + vp->Set(pRuntime, L"toggle"); break; } return true; } bool Field::set_highlight(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_line_width(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1395,21 +1394,21 @@ bool Field::get_line_width(CJS_Runtime* pRuntime, if (!pWidget) return false; - vp->Set(pWidget->GetBorderWidth()); + vp->Set(pRuntime, pWidget->GetBorderWidth()); return true; } bool Field::set_line_width(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; if (m_bDelay) { - AddDelay_Int(FP_LINEWIDTH, vp.ToInt()); + AddDelay_Int(FP_LINEWIDTH, vp.ToInt(pRuntime)); } else { Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex, - vp.ToInt()); + vp.ToInt(pRuntime)); } return true; } @@ -1454,7 +1453,7 @@ void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv, } bool Field::get_multiline(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -1466,19 +1465,19 @@ bool Field::get_multiline(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)); return true; } bool Field::set_multiline(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_multiple_selection(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); @@ -1489,36 +1488,34 @@ bool Field::get_multiple_selection(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)); return true; } bool Field::set_multiple_selection(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } -bool Field::get_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool Field::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return false; - vp->Set(m_FieldName); + vp->Set(pRuntime, m_FieldName); return true; } bool Field::set_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool Field::get_num_items(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1530,19 +1527,17 @@ bool Field::get_num_items(CJS_Runtime* pRuntime, return false; } - vp->Set(pFormField->CountOptions()); + vp->Set(pRuntime, pFormField->CountOptions()); return true; } bool Field::set_num_items(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } -bool Field::get_page(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool Field::get_page(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return false; @@ -1554,7 +1549,7 @@ bool Field::get_page(CJS_Runtime* pRuntime, std::vector<CPDFSDK_Annot::ObservedPtr> widgets; m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets); if (widgets.empty()) { - vp->Set(-1); + vp->Set(pRuntime, -1); return true; } @@ -1576,19 +1571,19 @@ bool Field::get_page(CJS_Runtime* pRuntime, ++i; } - vp->Set(PageArray); + vp->Set(pRuntime, PageArray); return true; } bool Field::set_page(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { *sError = JSGetStringFromID(IDS_STRING_JSREADONLY); return false; } bool Field::get_password(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -1600,19 +1595,19 @@ bool Field::get_password(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)); return true; } bool Field::set_password(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_print(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); @@ -1625,12 +1620,12 @@ bool Field::get_print(CJS_Runtime* pRuntime, if (!pWidget) return false; - vp->Set(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT)); + vp->Set(pRuntime, !!(pWidget->GetFlags() & ANNOTFLAG_PRINT)); return true; } bool Field::set_print(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm(); std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); @@ -1647,7 +1642,7 @@ bool Field::set_print(CJS_Runtime* pRuntime, if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(i))) { uint32_t dwFlags = pWidget->GetFlags(); - if (vp.ToBool()) + if (vp.ToBool(pRuntime)) dwFlags |= ANNOTFLAG_PRINT; else dwFlags &= ~ANNOTFLAG_PRINT; @@ -1671,7 +1666,7 @@ bool Field::set_print(CJS_Runtime* pRuntime, pFormField->GetControl(m_nFormControlIndex)) { if (CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormControl)) { uint32_t dwFlags = pWidget->GetFlags(); - if (vp.ToBool()) + if (vp.ToBool(pRuntime)) dwFlags |= ANNOTFLAG_PRINT; else dwFlags &= ~ANNOTFLAG_PRINT; @@ -1689,7 +1684,7 @@ bool Field::set_print(CJS_Runtime* pRuntime, } bool Field::get_radios_in_unison(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1699,12 +1694,12 @@ bool Field::get_radios_in_unison(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)); return true; } bool Field::set_radios_in_unison(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1713,18 +1708,18 @@ bool Field::set_radios_in_unison(CJS_Runtime* pRuntime, } bool Field::get_readonly(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return false; - vp->Set(!!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY)); + vp->Set(pRuntime, !!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY)); return true; } bool Field::set_readonly(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1732,9 +1727,7 @@ bool Field::set_readonly(CJS_Runtime* pRuntime, return m_bCanSet; } -bool Field::get_rect(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool Field::get_rect(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return false; @@ -1756,19 +1749,19 @@ bool Field::get_rect(CJS_Runtime* pRuntime, CJS_Value(pRuntime, static_cast<int32_t>(crRect.right))); rcArray.SetElement(pRuntime, 3, CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom))); - vp->Set(rcArray); + vp->Set(pRuntime, rcArray); return true; } bool Field::set_rect(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; - if (!vp.GetJSValue()->IsArrayObject()) + if (!vp.IsArrayObject()) return false; - CJS_Array rcArray = vp.ToArray(); + CJS_Array rcArray = vp.ToArray(pRuntime); CJS_Value Upper_Leftx = rcArray.GetElement(pRuntime, 0); CJS_Value Upper_Lefty = rcArray.GetElement(pRuntime, 1); CJS_Value Lower_Rightx = rcArray.GetElement(pRuntime, 2); @@ -1851,7 +1844,7 @@ void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv, } bool Field::get_required(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1861,12 +1854,12 @@ bool Field::get_required(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)); return true; } bool Field::set_required(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1876,7 +1869,7 @@ bool Field::set_required(CJS_Runtime* pRuntime, } bool Field::get_rich_text(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -1888,31 +1881,31 @@ bool Field::get_rich_text(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) return false; - vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)); + vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)); return true; } bool Field::set_rich_text(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_rich_value(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Field::set_rich_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool Field::get_rotation(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -1925,19 +1918,19 @@ bool Field::get_rotation(CJS_Runtime* pRuntime, if (!pFormControl) return false; - vp->Set(pFormControl->GetRotation()); + vp->Set(pRuntime, pFormControl->GetRotation()); return true; } bool Field::set_rotation(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_stroke_color(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -1972,22 +1965,22 @@ bool Field::get_stroke_color(CJS_Runtime* pRuntime, CJS_Array crArray; color::ConvertPWLColorToArray(pRuntime, color, &crArray); - vp->Set(crArray); + vp->Set(pRuntime, crArray); return true; } bool Field::set_stroke_color(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; - if (!vp.GetJSValue()->IsArrayObject()) + if (!vp.IsArrayObject()) return false; return true; } bool Field::get_style(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -2028,31 +2021,31 @@ bool Field::get_style(CJS_Runtime* pRuntime, csBCaption = "check"; break; } - vp->Set(csBCaption); + vp->Set(pRuntime, csBCaption); return true; } bool Field::set_style(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_submit_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool Field::set_submit_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool Field::get_text_color(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -2082,22 +2075,22 @@ bool Field::get_text_color(CJS_Runtime* pRuntime, CJS_Array crArray; color::ConvertPWLColorToArray(pRuntime, crRet, &crArray); - vp->Set(crArray); + vp->Set(pRuntime, crArray); return true; } bool Field::set_text_color(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; - if (!vp.GetJSValue()->IsArrayObject()) + if (!vp.IsArrayObject()) return false; return true; } bool Field::get_text_font(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -2120,24 +2113,24 @@ bool Field::get_text_font(CJS_Runtime* pRuntime, if (!pFont) return false; - vp->Set(pFont->GetBaseFont()); + vp->Set(pRuntime, pFont->GetBaseFont()); return true; } bool Field::set_text_font(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); if (!m_bCanSet) return false; - ByteString fontName = vp.ToByteString(); + ByteString fontName = vp.ToByteString(pRuntime); return !fontName.IsEmpty(); } bool Field::get_text_size(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -2154,20 +2147,18 @@ bool Field::get_text_size(CJS_Runtime* pRuntime, float fFontSize; CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance(); FieldAppearance.GetFont(&fFontSize); - vp->Set(static_cast<int>(fFontSize)); + vp->Set(pRuntime, static_cast<int>(fFontSize)); return true; } bool Field::set_text_size(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } -bool Field::get_type(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool Field::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) return false; @@ -2175,44 +2166,44 @@ bool Field::get_type(CJS_Runtime* pRuntime, CPDF_FormField* pFormField = FieldArray[0]; switch (pFormField->GetFieldType()) { case FIELDTYPE_UNKNOWN: - vp->Set(L"unknown"); + vp->Set(pRuntime, L"unknown"); break; case FIELDTYPE_PUSHBUTTON: - vp->Set(L"button"); + vp->Set(pRuntime, L"button"); break; case FIELDTYPE_CHECKBOX: - vp->Set(L"checkbox"); + vp->Set(pRuntime, L"checkbox"); break; case FIELDTYPE_RADIOBUTTON: - vp->Set(L"radiobutton"); + vp->Set(pRuntime, L"radiobutton"); break; case FIELDTYPE_COMBOBOX: - vp->Set(L"combobox"); + vp->Set(pRuntime, L"combobox"); break; case FIELDTYPE_LISTBOX: - vp->Set(L"listbox"); + vp->Set(pRuntime, L"listbox"); break; case FIELDTYPE_TEXTFIELD: - vp->Set(L"text"); + vp->Set(pRuntime, L"text"); break; case FIELDTYPE_SIGNATURE: - vp->Set(L"signature"); + vp->Set(pRuntime, L"signature"); break; default: - vp->Set(L"unknown"); + vp->Set(pRuntime, L"unknown"); break; } return true; } bool Field::set_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool Field::get_user_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { ASSERT(m_pFormFillEnv); @@ -2220,19 +2211,19 @@ bool Field::get_user_name(CJS_Runtime* pRuntime, if (FieldArray.empty()) return false; - vp->Set(FieldArray[0]->GetAlternateName()); + vp->Set(pRuntime, FieldArray[0]->GetAlternateName()); return true; } bool Field::set_user_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { ASSERT(m_pFormFillEnv); return m_bCanSet; } bool Field::get_value(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -2244,7 +2235,7 @@ bool Field::get_value(CJS_Runtime* pRuntime, return false; case FIELDTYPE_COMBOBOX: case FIELDTYPE_TEXTFIELD: - vp->Set(pFormField->GetValue()); + vp->Set(pRuntime, pFormField->GetValue()); break; case FIELDTYPE_LISTBOX: { if (pFormField->CountSelectedItems() > 1) { @@ -2261,9 +2252,9 @@ bool Field::get_value(CJS_Runtime* pRuntime, } ValueArray.SetElement(pRuntime, i, ElementValue); } - vp->Set(ValueArray); + vp->Set(pRuntime, ValueArray); } else { - vp->Set(pFormField->GetValue()); + vp->Set(pRuntime, pFormField->GetValue()); } break; } @@ -2272,39 +2263,39 @@ 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(pFormField->GetControl(i)->GetExportValue()); + vp->Set(pRuntime, pFormField->GetControl(i)->GetExportValue()); bFind = true; break; } } if (!bFind) - vp->Set(L"Off"); + vp->Set(pRuntime, L"Off"); break; } default: - vp->Set(pFormField->GetValue()); + vp->Set(pRuntime, pFormField->GetValue()); break; } - vp->GetJSValue()->MaybeCoerceToNumber(pRuntime); + vp->MaybeCoerceToNumber(pRuntime); return true; } bool Field::set_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { if (!m_bCanSet) return false; std::vector<WideString> strArray; - if (vp.GetJSValue()->IsArrayObject()) { - CJS_Array ValueArray = vp.ToArray(); + if (vp.IsArrayObject()) { + CJS_Array ValueArray = vp.ToArray(pRuntime); for (int i = 0, sz = ValueArray.GetLength(pRuntime); i < sz; i++) { CJS_Value ElementValue = ValueArray.GetElement(pRuntime, i); strArray.push_back(ElementValue.ToWideString(pRuntime)); } } else { - strArray.push_back(vp.ToWideString()); + strArray.push_back(vp.ToWideString(pRuntime)); } if (m_bDelay) { @@ -2371,7 +2362,7 @@ void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv, } bool Field::get_value_as_string(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName); if (FieldArray.empty()) @@ -2385,7 +2376,7 @@ bool Field::get_value_as_string(CJS_Runtime* pRuntime, if (!pFormField->CountControls()) return false; - vp->Set(pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off"); + vp->Set(pRuntime, pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off"); return true; } @@ -2393,10 +2384,10 @@ bool Field::get_value_as_string(CJS_Runtime* pRuntime, !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) { for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { if (pFormField->GetControl(i)->IsChecked()) { - vp->Set(pFormField->GetControl(i)->GetExportValue().c_str()); + vp->Set(pRuntime, pFormField->GetControl(i)->GetExportValue().c_str()); break; } else { - vp->Set(L"Off"); + vp->Set(pRuntime, L"Off"); } } return true; @@ -2404,16 +2395,16 @@ bool Field::get_value_as_string(CJS_Runtime* pRuntime, if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX && (pFormField->CountSelectedItems() > 1)) { - vp->Set(L""); + vp->Set(pRuntime, L""); } else { - vp->Set(pFormField->GetValue().c_str()); + vp->Set(pRuntime, pFormField->GetValue().c_str()); } return true; } bool Field::set_value_as_string(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } @@ -2848,14 +2839,14 @@ bool Field::signatureValidate(CJS_Runtime* pRuntime, } bool Field::get_source(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(static_cast<CJS_Object*>(nullptr)); + vp->Set(pRuntime, static_cast<CJS_Object*>(nullptr)); return true; } bool Field::set_source(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h index 27e5cc326d..8dcdbc6618 100644 --- a/fpdfsdk/javascript/Field.h +++ b/fpdfsdk/javascript/Field.h @@ -53,344 +53,294 @@ class Field : public CJS_EmbedObj { explicit Field(CJS_Object* pJSObject); ~Field() override; - bool get_alignment(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_alignment(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_alignment(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_border_style(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_border_style(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_button_align_x(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_button_align_x(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_button_align_y(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_button_align_y(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_button_fit_bounds(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_button_fit_bounds(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_button_position(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_button_position(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_button_scale_how(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_button_scale_how(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_button_scale_when(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_button_scale_when(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_calc_order_index(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_calc_order_index(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_char_limit(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_char_limit(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_char_limit(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_comb(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_comb(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_comb(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_comb(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); bool get_commit_on_sel_change(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_commit_on_sel_change(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_current_value_indices(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_current_value_indices(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_default_style(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_default_style(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_default_value(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_default_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_do_not_scroll(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_do_not_scroll(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_do_not_spell_check(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_do_not_spell_check(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_delay(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_delay(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_delay(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_display(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_display(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_display(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_doc(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_doc(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_doc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_doc(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_editable(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_editable(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_editable(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_export_values(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_export_values(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_file_select(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_file_select(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_fill_color(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_fill_color(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_fill_color(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_hidden(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_hidden(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_hidden(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_highlight(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_highlight(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_highlight(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_line_width(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_line_width(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_line_width(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_multiline(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_multiline(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_multiline(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_multiple_selection(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_multiple_selection(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_name(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_name(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_num_items(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_num_items(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_num_items(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_page(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_page(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_page(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_page(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_password(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_password(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_password(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_print(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_print(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_print(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_radios_in_unison(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_radios_in_unison(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_readonly(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_readonly(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_readonly(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_rect(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_rect(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_rect(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_rect(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_required(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_required(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_required(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_rich_text(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_rich_text(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_rich_text(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_rich_value(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_rich_value(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_rich_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_rotation(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_rotation(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_rotation(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_stroke_color(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_stroke_color(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_style(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_style(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_style(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_submit_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_submit_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_text_color(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_text_color(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_text_color(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_text_font(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_text_font(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_text_font(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_text_size(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_text_size(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_text_size(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_type(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_type(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_user_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_user_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_user_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_value(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_value(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_value_as_string(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_value_as_string(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_source(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_source(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_source(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool browseForFileToSubmit(CJS_Runtime* pRuntime, diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp index 6083307931..7c340af0d2 100644 --- a/fpdfsdk/javascript/Icon.cpp +++ b/fpdfsdk/javascript/Icon.cpp @@ -25,15 +25,13 @@ Icon::Icon(CJS_Object* pJSObject) Icon::~Icon() {} -bool Icon::get_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { - vp->Set(m_swIconName); +bool Icon::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { + vp->Set(pRuntime, m_swIconName); return true; } bool Icon::set_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } diff --git a/fpdfsdk/javascript/Icon.h b/fpdfsdk/javascript/Icon.h index df2e4bdcc3..261ad639f9 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_PropValue* vp, WideString* sError); - bool set_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_name(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); 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 24ce23d64d..e6a9303a62 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_PropValue*, WideString*)> +template <class C, bool (C::*M)(CJS_Runtime*, CJS_Value*, WideString*)> void JSPropGetter(const char* prop_name_string, const char* class_name_string, v8::Local<v8::String> property, @@ -52,18 +52,16 @@ void JSPropGetter(const char* prop_name_string, C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); WideString sError; - CJS_PropValue value(pRuntime); - value.StartGetting(); - if (!(pObj->*M)(pRuntime, &value, &sError)) { + CJS_Value prop_value(pRuntime); + if (!(pObj->*M)(pRuntime, &prop_value, &sError)) { pRuntime->Error( JSFormatErrorString(class_name_string, prop_name_string, sError)); return; } - info.GetReturnValue().Set(value.GetJSValue()->ToV8Value(pRuntime)); + info.GetReturnValue().Set(prop_value.ToV8Value(pRuntime)); } -template <class C, - bool (C::*M)(CJS_Runtime*, const CJS_PropValue&, WideString*)> +template <class C, bool (C::*M)(CJS_Runtime*, const CJS_Value&, WideString*)> void JSPropSetter(const char* prop_name_string, const char* class_name_string, v8::Local<v8::String> property, @@ -82,9 +80,8 @@ void JSPropSetter(const char* prop_name_string, C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject()); WideString sError; - CJS_PropValue propValue(pRuntime, CJS_Value(pRuntime, value)); - propValue.StartSetting(); - if (!(pObj->*M)(pRuntime, propValue, &sError)) { + CJS_Value prop_value(pRuntime, value); + if (!(pObj->*M)(pRuntime, prop_value, &sError)) { pRuntime->Error( JSFormatErrorString(class_name_string, prop_name_string, sError)); } @@ -357,13 +354,12 @@ void JSSpecialPropGet(const char* class_name, WideString propname = WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length())); - CJS_PropValue value(pRuntime); - value.StartGetting(); + CJS_Value value(pRuntime); if (!pObj->GetProperty(pRuntime, propname.c_str(), &value)) { pRuntime->Error(JSFormatErrorString(class_name, "GetProperty", L"")); return; } - info.GetReturnValue().Set(value.GetJSValue()->ToV8Value(pRuntime)); + info.GetReturnValue().Set(value.ToV8Value(pRuntime)); } template <class Alt> @@ -385,9 +381,8 @@ void JSSpecialPropPut(const char* class_name, v8::String::Utf8Value utf8_value(property); WideString propname = WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length())); - CJS_PropValue PropValue(pRuntime, CJS_Value(pRuntime, value)); - PropValue.StartSetting(); - if (!pObj->SetProperty(pRuntime, propname.c_str(), PropValue)) { + CJS_Value prop_value(pRuntime, value); + if (!pObj->SetProperty(pRuntime, propname.c_str(), prop_value)) { pRuntime->Error(JSFormatErrorString(class_name, "PutProperty", L"")); } } diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index 6205b48e6f..fb38e8cbb1 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -184,16 +184,13 @@ CJS_Value::CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue) : m_pValue(pValue) {} CJS_Value::CJS_Value(CJS_Runtime* pRuntime, int iValue) - : m_pValue(pRuntime->NewNumber(iValue)) {} + : CJS_Value(pRuntime, pRuntime->NewNumber(iValue)) {} CJS_Value::CJS_Value(CJS_Runtime* pRuntime, bool bValue) - : m_pValue(pRuntime->NewBoolean(bValue)) {} - -CJS_Value::CJS_Value(CJS_Runtime* pRuntime, float fValue) - : m_pValue(pRuntime->NewNumber(fValue)) {} + : CJS_Value(pRuntime, pRuntime->NewBoolean(bValue)) {} CJS_Value::CJS_Value(CJS_Runtime* pRuntime, double dValue) - : m_pValue(pRuntime->NewNumber(dValue)) {} + : CJS_Value(pRuntime, pRuntime->NewNumber(dValue)) {} CJS_Value::CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj) { if (pObj) @@ -201,25 +198,70 @@ CJS_Value::CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj) { } CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const wchar_t* pWstr) - : m_pValue(pRuntime->NewString(pWstr)) {} + : CJS_Value(pRuntime, pRuntime->NewString(pWstr)) {} CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const char* pStr) - : m_pValue(pRuntime->NewString(WideString::FromLocal(pStr).c_str())) {} + : CJS_Value(pRuntime, + pRuntime->NewString(WideString::FromLocal(pStr).c_str())) {} CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const CJS_Array& array) - : m_pValue(array.ToV8Array(pRuntime)) {} + : CJS_Value(pRuntime, array.ToV8Array(pRuntime)) {} CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const CJS_Date& date) - : m_pValue(date.ToV8Date(pRuntime)) {} + : CJS_Value(pRuntime, date.ToV8Date(pRuntime)) {} CJS_Value::~CJS_Value() {} CJS_Value::CJS_Value(const CJS_Value& other) = default; -void CJS_Value::Set(v8::Local<v8::Value> pValue) { +void CJS_Value::SetNull(CJS_Runtime* pRuntime) { + m_pValue = pRuntime->NewNull(); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue) { m_pValue = pValue; } +void CJS_Value::Set(CJS_Runtime* pRuntime, int val) { + m_pValue = pRuntime->NewNumber(val); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, bool val) { + m_pValue = pRuntime->NewBoolean(val); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, double val) { + m_pValue = pRuntime->NewNumber(val); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, CJS_Object* pObj) { + m_pValue = pObj->ToV8Object(); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, CJS_Document* pJsDoc) { + m_pValue = pJsDoc->ToV8Object(); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, const ByteString& str) { + m_pValue = pRuntime->NewString(WideString::FromLocal(str.c_str()).c_str()); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, const WideString& str) { + m_pValue = pRuntime->NewString(str.c_str()); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, const wchar_t* c_string) { + m_pValue = pRuntime->NewString(c_string); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, const CJS_Array& array) { + m_pValue = array.ToV8Array(pRuntime); +} + +void CJS_Value::Set(CJS_Runtime* pRuntime, const CJS_Date& date) { + m_pValue = date.ToV8Date(pRuntime); +} + int CJS_Value::ToInt(CJS_Runtime* pRuntime) const { return pRuntime->ToInt32(m_pValue); } @@ -241,6 +283,10 @@ CJS_Object* CJS_Value::ToObject(CJS_Runtime* pRuntime) const { return static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(pObj)); } +CJS_Document* CJS_Value::ToDocument(CJS_Runtime* pRuntime) const { + return static_cast<CJS_Document*>(ToObject(pRuntime)); +} + CJS_Array CJS_Value::ToArray(CJS_Runtime* pRuntime) const { ASSERT(IsArrayObject()); return CJS_Array(pRuntime->ToArray(m_pValue)); @@ -272,10 +318,6 @@ v8::Local<v8::Array> CJS_Value::ToV8Array(CJS_Runtime* pRuntime) const { return pRuntime->ToArray(m_pValue); } -void CJS_Value::SetNull(CJS_Runtime* pRuntime) { - m_pValue = pRuntime->NewNull(); -} - void CJS_Value::MaybeCoerceToNumber(CJS_Runtime* pRuntime) { bool bAllowNaN = false; if (GetType() == VT_string) { @@ -326,123 +368,6 @@ bool CJS_Value::IsDateObject() const { return !m_pValue.IsEmpty() && m_pValue->IsDate(); } -CJS_PropValue::CJS_PropValue(CJS_Runtime* pRuntime) - : m_bIsSetting(0), m_Value(pRuntime), m_pJSRuntime(pRuntime) {} - -CJS_PropValue::CJS_PropValue(CJS_Runtime* pRuntime, const CJS_Value& value) - : m_bIsSetting(0), m_Value(value), m_pJSRuntime(pRuntime) {} - -CJS_PropValue::~CJS_PropValue() {} - -void CJS_PropValue::Set(int iValue) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), iValue); -} - -int CJS_PropValue::ToInt() const { - ASSERT(m_bIsSetting); - return m_Value.ToInt(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(bool bValue) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), bValue); -} - -bool CJS_PropValue::ToBool() const { - ASSERT(m_bIsSetting); - return m_Value.ToBool(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(double dValue) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), dValue); -} - -double CJS_PropValue::ToDouble() const { - ASSERT(m_bIsSetting); - return m_Value.ToDouble(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(CJS_Object* pObj) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), pObj); -} - -CJS_Object* CJS_PropValue::ToObject() const { - ASSERT(m_bIsSetting); - return m_Value.ToObject(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(CJS_Document* pJsDoc) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), pJsDoc); -} - -CJS_Document* CJS_PropValue::ToDocument() const { - ASSERT(m_bIsSetting); - return static_cast<CJS_Document*>(m_Value.ToObject(m_pJSRuntime.Get())); -} - -void CJS_PropValue::Set(v8::Local<v8::Object> pObj) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), pObj); -} - -v8::Local<v8::Object> CJS_PropValue::ToV8Object() const { - ASSERT(m_bIsSetting); - return m_Value.ToV8Object(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(const ByteString& str) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), str.c_str()); -} - -ByteString CJS_PropValue::ToByteString() const { - ASSERT(m_bIsSetting); - return m_Value.ToByteString(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(const wchar_t* str) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), str); -} - -WideString CJS_PropValue::ToWideString() const { - ASSERT(m_bIsSetting); - return m_Value.ToWideString(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(const WideString& wide_string) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), wide_string.c_str()); -} - -CJS_Array CJS_PropValue::ToArray() const { - ASSERT(m_bIsSetting); - if (!m_Value.IsArrayObject()) - return CJS_Array(); - return m_Value.ToArray(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(const CJS_Array& array) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), array); -} - -CJS_Date CJS_PropValue::ToDate() const { - ASSERT(m_bIsSetting); - if (!m_Value.IsDateObject()) - return CJS_Date(); - return m_Value.ToDate(m_pJSRuntime.Get()); -} - -void CJS_PropValue::Set(const CJS_Date& date) { - ASSERT(!m_bIsSetting); - m_Value = CJS_Value(m_pJSRuntime.Get(), date); -} - CJS_Array::CJS_Array() {} CJS_Array::CJS_Array(v8::Local<v8::Array> pArray) : m_pArray(pArray) {} diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h index 3631dbe6a1..49dd2492da 100644 --- a/fpdfsdk/javascript/JS_Value.h +++ b/fpdfsdk/javascript/JS_Value.h @@ -36,7 +36,6 @@ class CJS_Value { CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue); CJS_Value(CJS_Runtime* pRuntime, int iValue); CJS_Value(CJS_Runtime* pRuntime, double dValue); - CJS_Value(CJS_Runtime* pRuntime, float fValue); CJS_Value(CJS_Runtime* pRuntime, bool bValue); CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj); CJS_Value(CJS_Runtime* pRuntime, const char* pStr); @@ -48,8 +47,19 @@ class CJS_Value { ~CJS_Value(); + // These calls may re-enter JS (and hence invalidate objects). + void Set(CJS_Runtime* pRuntime, int val); + void Set(CJS_Runtime* pRuntime, bool val); + void Set(CJS_Runtime* pRuntime, double val); + void Set(CJS_Runtime* pRuntime, CJS_Object* pObj); + void Set(CJS_Runtime* pRuntime, CJS_Document* pJsDoc); + void Set(CJS_Runtime* pRuntime, const ByteString&); + void Set(CJS_Runtime* pRuntime, const WideString&); + void Set(CJS_Runtime* pRuntime, const wchar_t* c_string); + void Set(CJS_Runtime* pRuntime, const CJS_Array& array); + void Set(CJS_Runtime* pRuntime, const CJS_Date& date); + void Set(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue); void SetNull(CJS_Runtime* pRuntime); - void Set(v8::Local<v8::Value> pValue); Type GetType() const { return GetValueType(m_pValue); } @@ -58,6 +68,7 @@ class CJS_Value { double ToDouble(CJS_Runtime* pRuntime) const; float ToFloat(CJS_Runtime* pRuntime) const; CJS_Object* ToObject(CJS_Runtime* pRuntime) const; + CJS_Document* ToDocument(CJS_Runtime* pRuntime) const; CJS_Array ToArray(CJS_Runtime* pRuntime) const; CJS_Date ToDate(CJS_Runtime* pRuntime) const; WideString ToWideString(CJS_Runtime* pRuntime) const; @@ -77,58 +88,6 @@ class CJS_Value { v8::Local<v8::Value> m_pValue; }; -class CJS_PropValue { - public: - explicit CJS_PropValue(CJS_Runtime* pRuntime); - CJS_PropValue(CJS_Runtime* pRuntime, const CJS_Value&); - ~CJS_PropValue(); - - void StartSetting() { m_bIsSetting = true; } - void StartGetting() { m_bIsSetting = false; } - bool IsSetting() const { return m_bIsSetting; } - bool IsGetting() const { return !m_bIsSetting; } - CJS_Runtime* GetJSRuntime() const { return m_pJSRuntime.Get(); } - CJS_Value* GetJSValue() { return &m_Value; } - const CJS_Value* GetJSValue() const { return &m_Value; } - - // These calls may re-enter JS (and hence invalidate objects). - void Set(int val); - int ToInt() const; - - void Set(bool val); - bool ToBool() const; - - void Set(double val); - double ToDouble() const; - - void Set(CJS_Object* pObj); - CJS_Object* ToObject() const; - - void Set(CJS_Document* pJsDoc); - CJS_Document* ToDocument() const; - - void Set(const ByteString&); - ByteString ToByteString() const; - - void Set(const WideString&); - void Set(const wchar_t* c_string); - WideString ToWideString() const; - - void Set(v8::Local<v8::Object>); - v8::Local<v8::Object> ToV8Object() const; - - void Set(const CJS_Array& array); - CJS_Array ToArray() const; - - void Set(const CJS_Date& date); - CJS_Date ToDate() const; - - private: - bool m_bIsSetting; - CJS_Value m_Value; - UnownedPtr<CJS_Runtime> const m_pJSRuntime; -}; - class CJS_Array { public: CJS_Array(); diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp index 6e0ebef0e8..a48f647b77 100644 --- a/fpdfsdk/javascript/PublicMethods.cpp +++ b/fpdfsdk/javascript/PublicMethods.cpp @@ -847,10 +847,7 @@ bool CJS_PublicMethods::AFNumber_Format(CJS_Runtime* pRuntime, arColor.SetElement(pRuntime, 2, vColElm); arColor.SetElement(pRuntime, 3, vColElm); - CJS_PropValue vProp(pRuntime); - vProp.StartGetting(); - vProp.Set(arColor); - vProp.StartSetting(); + CJS_Value vProp(pRuntime, arColor); fTarget->set_text_color(pRuntime, vProp, &sError); // red } } @@ -866,21 +863,18 @@ bool CJS_PublicMethods::AFNumber_Format(CJS_Runtime* pRuntime, arColor.SetElement(pRuntime, 2, vColElm); arColor.SetElement(pRuntime, 3, vColElm); - CJS_PropValue vProp(pRuntime); - vProp.StartGetting(); + CJS_Value vProp(pRuntime); fTarget->get_text_color(pRuntime, &vProp, &sError); - CJS_Array aProp = vProp.GetJSValue()->ToArray(pRuntime); + CJS_Array aProp = vProp.ToArray(pRuntime); CFX_Color crProp; CFX_Color crColor; color::ConvertArrayToPWLColor(pRuntime, aProp, &crProp); color::ConvertArrayToPWLColor(pRuntime, arColor, &crColor); if (crColor != crProp) { - CJS_PropValue vProp2(pRuntime); - vProp2.StartGetting(); - vProp2.Set(arColor); - vProp2.StartSetting(); + CJS_Value vProp2(pRuntime, arColor); + fTarget->set_text_color(pRuntime, vProp2, &sError); } } diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp index 86dc7c5673..0567f5a544 100644 --- a/fpdfsdk/javascript/app.cpp +++ b/fpdfsdk/javascript/app.cpp @@ -209,7 +209,7 @@ app::~app() { } bool app::get_active_docs(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_Document* pJSDocument = nullptr; v8::Local<v8::Object> pObj = pRuntime->GetThisObj(); @@ -219,95 +219,95 @@ bool app::get_active_docs(CJS_Runtime* pRuntime, CJS_Array aDocs; aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument)); if (aDocs.GetLength(pRuntime) > 0) - vp->Set(aDocs); + vp->Set(pRuntime, aDocs); else - vp->GetJSValue()->SetNull(pRuntime); + vp->SetNull(pRuntime); return true; } bool app::set_active_docs(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool app::get_calculate(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(m_bCalculate); + vp->Set(pRuntime, m_bCalculate); return true; } bool app::set_calculate(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { - m_bCalculate = vp.ToBool(); + m_bCalculate = vp.ToBool(pRuntime); pRuntime->GetFormFillEnv()->GetInterForm()->EnableCalculate(m_bCalculate); return true; } bool app::get_forms_version(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(JS_NUM_FORMSVERSION); + vp->Set(pRuntime, JS_NUM_FORMSVERSION); return true; } bool app::set_forms_version(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool app::get_viewer_type(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(JS_STR_VIEWERTYPE); + vp->Set(pRuntime, JS_STR_VIEWERTYPE); return true; } bool app::set_viewer_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool app::get_viewer_variation(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(JS_STR_VIEWERVARIATION); + vp->Set(pRuntime, JS_STR_VIEWERVARIATION); return true; } bool app::set_viewer_variation(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool app::get_viewer_version(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { #ifdef PDF_ENABLE_XFA CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext(); if (pXFAContext->ContainsXFAForm()) { - vp->Set(JS_NUM_VIEWERVERSION_XFA); + vp->Set(pRuntime, JS_NUM_VIEWERVERSION_XFA); return true; } #endif // PDF_ENABLE_XFA - vp->Set(JS_NUM_VIEWERVERSION); + vp->Set(pRuntime, JS_NUM_VIEWERVERSION); return true; } bool app::set_viewer_version(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool app::get_platform(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { #ifdef PDF_ENABLE_XFA CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); @@ -316,22 +316,22 @@ bool app::get_platform(CJS_Runtime* pRuntime, WideString platfrom = pFormFillEnv->GetPlatform(); if (!platfrom.IsEmpty()) { - vp->Set(platfrom); + vp->Set(pRuntime, platfrom); return true; } #endif - vp->Set(JS_STR_PLATFORM); + vp->Set(pRuntime, JS_STR_PLATFORM); return true; } bool app::set_platform(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool app::get_language(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { #ifdef PDF_ENABLE_XFA CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv(); @@ -340,16 +340,16 @@ bool app::get_language(CJS_Runtime* pRuntime, WideString language = pFormFillEnv->GetLanguage(); if (!language.IsEmpty()) { - vp->Set(language); + vp->Set(pRuntime, language); return true; } #endif - vp->Set(JS_STR_LANGUAGE); + vp->Set(pRuntime, JS_STR_LANGUAGE); return true; } bool app::set_language(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } @@ -466,12 +466,12 @@ bool app::popUpMenuEx(CJS_Runtime* pRuntime, return false; } -bool app::get_fs(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError) { +bool app::get_fs(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { return false; } bool app::set_fs(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } @@ -692,27 +692,27 @@ bool app::launchURL(CJS_Runtime* pRuntime, } bool app::get_runtime_highlight(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { - vp->Set(m_bRuntimeHighLight); + vp->Set(pRuntime, m_bRuntimeHighLight); return true; } bool app::set_runtime_highlight(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { - m_bRuntimeHighLight = vp.ToBool(); + m_bRuntimeHighLight = vp.ToBool(pRuntime); return true; } bool app::get_fullscreen(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return false; } bool app::set_fullscreen(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } @@ -804,14 +804,12 @@ bool app::response(CJS_Runtime* pRuntime, return true; } -bool app::get_media(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool app::get_media(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { return false; } bool app::set_media(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } diff --git a/fpdfsdk/javascript/app.h b/fpdfsdk/javascript/app.h index 8c0ac3aefb..666ee12606 100644 --- a/fpdfsdk/javascript/app.h +++ b/fpdfsdk/javascript/app.h @@ -42,83 +42,73 @@ class app : public CJS_EmbedObj { ~app() override; bool get_active_docs(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_active_docs(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_calculate(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_calculate(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_calculate(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_forms_version(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_forms_version(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_fs(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_fs(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_fs(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_fs(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_fullscreen(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_fullscreen(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_fullscreen(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_language(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_language(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_language(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_media(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_media(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_media(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_platform(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_platform(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_platform(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_runtime_highlight(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_runtime_highlight(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_viewer_type(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_viewer_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_viewer_variation(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_viewer_variation(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_viewer_version(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_viewer_version(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool alert(CJS_Runtime* pRuntime, diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp index 575a86c4e6..5d8282de4f 100644 --- a/fpdfsdk/javascript/color.cpp +++ b/fpdfsdk/javascript/color.cpp @@ -115,165 +115,157 @@ void color::ConvertArrayToPWLColor(CJS_Runtime* pRuntime, } bool color::get_transparent(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crTransparent); } bool color::set_transparent(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crTransparent); } bool color::get_black(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crBlack); } bool color::set_black(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crBlack); } bool color::get_white(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crWhite); } bool color::set_white(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crWhite); } -bool color::get_red(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool color::get_red(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crRed); } bool color::set_red(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crRed); } bool color::get_green(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crGreen); } bool color::set_green(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crGreen); } -bool color::get_blue(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool color::get_blue(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crBlue); } bool color::set_blue(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crBlue); } -bool color::get_cyan(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool color::get_cyan(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crCyan); } bool color::set_cyan(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crCyan); } bool color::get_magenta(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crMagenta); } bool color::set_magenta(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crMagenta); } bool color::get_yellow(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crYellow); } bool color::set_yellow(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crYellow); } bool color::get_dark_gray(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crDKGray); } bool color::set_dark_gray(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crDKGray); } -bool color::get_gray(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool color::get_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crGray); } bool color::set_gray(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crGray); } bool color::get_light_gray(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return GetPropertyHelper(pRuntime, vp, &m_crLTGray); } bool color::set_light_gray(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return SetPropertyHelper(pRuntime, vp, &m_crLTGray); } bool color::GetPropertyHelper(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, CFX_Color* var) { CJS_Array array; - ConvertPWLColorToArray(pRuntime, *var, &array); - vp->Set(array); - return true; + ConvertPWLColorToArray(pRuntime, *var, &array); + vp->Set(pRuntime, array); + return true; } bool color::SetPropertyHelper(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, CFX_Color* var) { - if (!vp.GetJSValue()->IsArrayObject()) + if (!vp.IsArrayObject()) return false; - ConvertArrayToPWLColor(pRuntime, vp.GetJSValue()->ToArray(pRuntime), var); + ConvertArrayToPWLColor(pRuntime, vp.ToArray(pRuntime), var); return true; } @@ -293,16 +285,14 @@ bool color::convert(CJS_Runtime* pRuntime, ByteString sDestSpace = params[1].ToByteString(pRuntime); int nColorType = CFX_Color::kTransparent; - - if (sDestSpace == "T") { + if (sDestSpace == "T") nColorType = CFX_Color::kTransparent; - } else if (sDestSpace == "G") { + else if (sDestSpace == "G") nColorType = CFX_Color::kGray; - } else if (sDestSpace == "RGB") { + else if (sDestSpace == "RGB") nColorType = CFX_Color::kRGB; - } else if (sDestSpace == "CMYK") { + else if (sDestSpace == "CMYK") nColorType = CFX_Color::kCMYK; - } CJS_Array aDest; CFX_Color crDest = crSource.ConvertColorType(nColorType); diff --git a/fpdfsdk/javascript/color.h b/fpdfsdk/javascript/color.h index d4ca43a878..08da346377 100644 --- a/fpdfsdk/javascript/color.h +++ b/fpdfsdk/javascript/color.h @@ -17,72 +17,58 @@ class color : public CJS_EmbedObj { explicit color(CJS_Object* pJSObject); ~color() override; - bool get_black(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_black(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_black(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_blue(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_blue(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_blue(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_blue(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_cyan(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_cyan(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_cyan(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_cyan(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_dark_gray(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_dark_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_dark_gray(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_gray(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_gray(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_gray(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_green(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_green(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_green(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_light_gray(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_light_gray(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_light_gray(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_magenta(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_magenta(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_magenta(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_red(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_red(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_red(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_red(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); bool get_transparent(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_transparent(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_white(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_white(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_white(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_yellow(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_yellow(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_yellow(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool convert(CJS_Runtime* pRuntime, @@ -102,11 +88,9 @@ class color : public CJS_EmbedObj { CFX_Color* color); private: - bool GetPropertyHelper(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - CFX_Color* val); + bool GetPropertyHelper(CJS_Runtime* pRuntime, CJS_Value* vp, CFX_Color* val); bool SetPropertyHelper(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, CFX_Color* val); CFX_Color m_crTransparent; diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp index 9c2e3f490e..34504d5aa4 100644 --- a/fpdfsdk/javascript/event.cpp +++ b/fpdfsdk/javascript/event.cpp @@ -47,61 +47,61 @@ event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {} event::~event() {} bool event::get_change(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->Change()); + vp->Set(pRuntime, pEvent->Change()); return true; } bool event::set_change(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - if (vp.GetJSValue()->GetType() == CJS_Value::VT_string) { + if (vp.GetType() == CJS_Value::VT_string) { WideString& wChange = pEvent->Change(); - wChange = vp.ToWideString(); + wChange = vp.ToWideString(pRuntime); } return true; } bool event::get_change_ex(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->ChangeEx()); + vp->Set(pRuntime, pEvent->ChangeEx()); return true; } bool event::set_change_ex(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool event::get_commit_key(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->CommitKey()); + vp->Set(pRuntime, pEvent->CommitKey()); return true; } bool event::set_commit_key(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool event::get_field_full(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -109,117 +109,113 @@ bool event::get_field_full(CJS_Runtime* pRuntime, if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) return false; - vp->Set(pEvent->FieldFull()); + vp->Set(pRuntime, pEvent->FieldFull()); return true; } bool event::set_field_full(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool event::get_key_down(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->KeyDown()); + vp->Set(pRuntime, pEvent->KeyDown()); return true; } bool event::set_key_down(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool event::get_modifier(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->Modifier()); + vp->Set(pRuntime, pEvent->Modifier()); return true; } bool event::set_modifier(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } -bool event::get_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool event::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->Name()); + vp->Set(pRuntime, pEvent->Name()); return true; } bool event::set_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } -bool event::get_rc(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool event::get_rc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->Rc()); + vp->Set(pRuntime, pEvent->Rc()); return true; } bool event::set_rc(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - pEvent->Rc() = vp.ToBool(); + pEvent->Rc() = vp.ToBool(pRuntime); return true; } bool event::get_rich_change(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool event::set_rich_change(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool event::get_rich_change_ex(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool event::set_rich_change_ex(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool event::get_rich_value(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { return true; } bool event::set_rich_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return true; } bool event::get_sel_end(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -227,12 +223,12 @@ bool event::get_sel_end(CJS_Runtime* pRuntime, if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) return true; - vp->Set(pEvent->SelEnd()); + vp->Set(pRuntime, pEvent->SelEnd()); return true; } bool event::set_sel_end(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -240,12 +236,12 @@ bool event::set_sel_end(CJS_Runtime* pRuntime, if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) return true; - pEvent->SelEnd() = vp.ToInt(); + pEvent->SelEnd() = vp.ToInt(pRuntime); return true; } bool event::get_sel_start(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -253,12 +249,12 @@ bool event::get_sel_start(CJS_Runtime* pRuntime, if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) return true; - vp->Set(pEvent->SelStart()); + vp->Set(pRuntime, pEvent->SelStart()); return true; } bool event::set_sel_start(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -266,87 +262,85 @@ bool event::set_sel_start(CJS_Runtime* pRuntime, if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) return true; - pEvent->SelStart() = vp.ToInt(); + pEvent->SelStart() = vp.ToInt(pRuntime); return true; } bool event::get_shift(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->Shift()); + vp->Set(pRuntime, pEvent->Shift()); return true; } bool event::set_shift(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool event::get_source(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->Source()->GetJSObject()); + vp->Set(pRuntime, pEvent->Source()->GetJSObject()); return true; } bool event::set_source(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool event::get_target(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->Target_Field()->GetJSObject()); + vp->Set(pRuntime, pEvent->Target_Field()->GetJSObject()); return true; } bool event::set_target(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool event::get_target_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->TargetName()); + vp->Set(pRuntime, pEvent->TargetName()); return true; } bool event::set_target_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } -bool event::get_type(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError) { +bool event::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->Type()); + vp->Set(pRuntime, pEvent->Type()); return true; } bool event::set_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } bool event::get_value(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -357,12 +351,12 @@ bool event::get_value(CJS_Runtime* pRuntime, if (!pEvent->m_pValue) return false; - vp->Set(pEvent->Value()); + vp->Set(pRuntime, pEvent->Value()); return true; } bool event::set_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); @@ -373,21 +367,21 @@ bool event::set_value(CJS_Runtime* pRuntime, if (!pEvent->m_pValue) return false; - pEvent->Value() = vp.ToWideString(); + pEvent->Value() = vp.ToWideString(pRuntime); return true; } bool event::get_will_commit(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError) { CJS_EventHandler* pEvent = pRuntime->GetCurrentEventContext()->GetEventHandler(); - vp->Set(pEvent->WillCommit()); + vp->Set(pRuntime, pEvent->WillCommit()); return true; } bool event::set_will_commit(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError) { return false; } diff --git a/fpdfsdk/javascript/event.h b/fpdfsdk/javascript/event.h index e67aa2b8af..f622443f3a 100644 --- a/fpdfsdk/javascript/event.h +++ b/fpdfsdk/javascript/event.h @@ -15,128 +15,106 @@ class event : public CJS_EmbedObj { ~event() override; public: - bool get_change(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_change(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_change(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_change_ex(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_change_ex(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_change_ex(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_commit_key(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_commit_key(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_commit_key(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_field_full(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_field_full(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_field_full(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_key_down(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_key_down(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_key_down(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_modifier(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_modifier(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_modifier(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_name(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_name(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_rc(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_rc(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_rc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_rc(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); bool get_rich_change(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_rich_change(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_rich_change_ex(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_rich_change_ex(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_rich_value(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_rich_value(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_rich_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_sel_end(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_sel_end(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_sel_end(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_sel_start(CJS_Runtime* pRuntime, - CJS_PropValue* vp, - WideString* sError); + bool get_sel_start(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_sel_start(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_shift(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_shift(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_shift(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_source(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_source(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_source(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_target(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_target(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_target(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_target_name(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_target_name(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); - bool get_type(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); - bool set_type(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, - WideString* sError); + bool get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); + bool set_type(CJS_Runtime* pRuntime, const CJS_Value& vp, WideString* sError); - bool get_value(CJS_Runtime* pRuntime, CJS_PropValue* vp, WideString* sError); + bool get_value(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError); bool set_value(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); bool get_will_commit(CJS_Runtime* pRuntime, - CJS_PropValue* vp, + CJS_Value* vp, WideString* sError); bool set_will_commit(CJS_Runtime* pRuntime, - const CJS_PropValue& vp, + const CJS_Value& vp, WideString* sError); }; diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp index 4635f1c84c..7c82e4d542 100644 --- a/fpdfsdk/javascript/global.cpp +++ b/fpdfsdk/javascript/global.cpp @@ -77,36 +77,36 @@ bool JSGlobalAlternate::DelProperty(CJS_Runtime* pRuntime, bool JSGlobalAlternate::GetProperty(CJS_Runtime* pRuntime, const wchar_t* propname, - CJS_PropValue* vp) { + CJS_Value* vp) { auto it = m_MapGlobal.find(ByteString::FromUnicode(propname)); if (it == m_MapGlobal.end()) { - vp->GetJSValue()->SetNull(pRuntime); + vp->SetNull(pRuntime); return true; } JSGlobalData* pData = it->second.get(); if (pData->bDeleted) { - vp->GetJSValue()->SetNull(pRuntime); + vp->SetNull(pRuntime); return true; } switch (pData->nType) { case JS_GlobalDataType::NUMBER: - vp->Set(pData->dData); + vp->Set(pRuntime, pData->dData); return true; case JS_GlobalDataType::BOOLEAN: - vp->Set(pData->bData); + vp->Set(pRuntime, pData->bData); return true; case JS_GlobalDataType::STRING: - vp->Set(pData->sData); + vp->Set(pRuntime, pData->sData); return true; case JS_GlobalDataType::OBJECT: { - vp->Set(v8::Local<v8::Object>::New(vp->GetJSRuntime()->GetIsolate(), - pData->pData)); + vp->Set(pRuntime, + v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData)); return true; } case JS_GlobalDataType::NULLOBJ: - vp->GetJSValue()->SetNull(pRuntime); + vp->SetNull(pRuntime); return true; default: break; @@ -116,24 +116,24 @@ bool JSGlobalAlternate::GetProperty(CJS_Runtime* pRuntime, bool JSGlobalAlternate::SetProperty(CJS_Runtime* pRuntime, const wchar_t* propname, - const CJS_PropValue& vp) { + const CJS_Value& vp) { ByteString sPropName = ByteString::FromUnicode(propname); - switch (vp.GetJSValue()->GetType()) { + switch (vp.GetType()) { case CJS_Value::VT_number: return SetGlobalVariables(sPropName, JS_GlobalDataType::NUMBER, - vp.ToDouble(), false, "", + vp.ToDouble(pRuntime), false, "", v8::Local<v8::Object>(), false); case CJS_Value::VT_boolean: return SetGlobalVariables(sPropName, JS_GlobalDataType::BOOLEAN, 0, - vp.ToBool(), "", v8::Local<v8::Object>(), - false); + vp.ToBool(pRuntime), "", + v8::Local<v8::Object>(), false); case CJS_Value::VT_string: return SetGlobalVariables(sPropName, JS_GlobalDataType::STRING, 0, false, - vp.ToByteString(), v8::Local<v8::Object>(), - false); + vp.ToByteString(pRuntime), + v8::Local<v8::Object>(), false); case CJS_Value::VT_object: return SetGlobalVariables(sPropName, JS_GlobalDataType::OBJECT, 0, false, - "", vp.ToV8Object(), false); + "", vp.ToV8Object(pRuntime), false); case CJS_Value::VT_null: return SetGlobalVariables(sPropName, JS_GlobalDataType::NULLOBJ, 0, false, "", v8::Local<v8::Object>(), false); diff --git a/fpdfsdk/javascript/global.h b/fpdfsdk/javascript/global.h index c741a1a20f..e9c6f67018 100644 --- a/fpdfsdk/javascript/global.h +++ b/fpdfsdk/javascript/global.h @@ -43,10 +43,10 @@ class JSGlobalAlternate : public CJS_EmbedObj { bool QueryProperty(const wchar_t* propname); bool GetProperty(CJS_Runtime* pRuntime, const wchar_t* propname, - CJS_PropValue* vp); + CJS_Value* vp); bool SetProperty(CJS_Runtime* pRuntime, const wchar_t* propname, - const CJS_PropValue& vp); + const CJS_Value& vp); bool DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname); void Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv); |