summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/JS_Define.h20
-rw-r--r--fxjs/cjs_annot.cpp29
-rw-r--r--fxjs/cjs_annot.h40
-rw-r--r--fxjs/cjs_app.cpp200
-rw-r--r--fxjs/cjs_app.h110
-rw-r--r--fxjs/cjs_color.cpp124
-rw-r--r--fxjs/cjs_color.h59
-rw-r--r--fxjs/cjs_console.cpp28
-rw-r--r--fxjs/cjs_console.h36
-rw-r--r--fxjs/cjs_document.cpp408
-rw-r--r--fxjs/cjs_document.h203
-rw-r--r--fxjs/cjs_embedobj.cpp13
-rw-r--r--fxjs/cjs_embedobj.h25
-rw-r--r--fxjs/cjs_event.cpp121
-rw-r--r--fxjs/cjs_event.h67
-rw-r--r--fxjs/cjs_eventhandler.cpp28
-rw-r--r--fxjs/cjs_eventhandler.h6
-rw-r--r--fxjs/cjs_field.cpp572
-rw-r--r--fxjs/cjs_field.h308
-rw-r--r--fxjs/cjs_global.cpp187
-rw-r--r--fxjs/cjs_global.h53
-rw-r--r--fxjs/cjs_icon.cpp17
-rw-r--r--fxjs/cjs_icon.h28
-rw-r--r--fxjs/cjs_object.h5
-rw-r--r--fxjs/cjs_printparamsobj.cpp16
-rw-r--r--fxjs/cjs_printparamsobj.h36
-rw-r--r--fxjs/cjs_publicmethods.cpp13
-rw-r--r--fxjs/cjs_report.cpp22
-rw-r--r--fxjs/cjs_report.h24
-rw-r--r--fxjs/cjs_runtime.cpp6
-rw-r--r--fxjs/cjs_timerobj.cpp11
-rw-r--r--fxjs/cjs_timerobj.h19
-rw-r--r--fxjs/cjs_util.cpp38
-rw-r--r--fxjs/cjs_util.h52
-rw-r--r--fxjs/cjs_util_unittest.cpp2
-rw-r--r--fxjs/global_timer.cpp12
-rw-r--r--fxjs/global_timer.h4
37 files changed, 1415 insertions, 1527 deletions
diff --git a/fxjs/JS_Define.h b/fxjs/JS_Define.h
index 540746afd5..61ad9efc1f 100644
--- a/fxjs/JS_Define.h
+++ b/fxjs/JS_Define.h
@@ -72,7 +72,7 @@ void JSPropGetter(const char* prop_name_string,
if (!pJSObj)
return;
- C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
+ C* pObj = static_cast<C*>(pJSObj);
CJS_Return result = (pObj->*M)(pRuntime);
if (result.HasError()) {
pRuntime->Error(JSFormatErrorString(class_name_string, prop_name_string,
@@ -99,7 +99,7 @@ void JSPropSetter(const char* prop_name_string,
if (!pJSObj)
return;
- C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
+ C* pObj = static_cast<C*>(pJSObj);
CJS_Return result = (pObj->*M)(pRuntime, value);
if (result.HasError()) {
pRuntime->Error(JSFormatErrorString(class_name_string, prop_name_string,
@@ -126,7 +126,7 @@ void JSMethod(const char* method_name_string,
for (unsigned int i = 0; i < (unsigned int)info.Length(); i++)
parameters.push_back(info[i]);
- C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
+ C* pObj = static_cast<C*>(pJSObj);
CJS_Return result = (pObj->*M)(pRuntime, parameters);
if (result.HasError()) {
pRuntime->Error(JSFormatErrorString(class_name_string, method_name_string,
@@ -143,20 +143,20 @@ void JSMethod(const char* method_name_string,
v8::Local<v8::String> property, \
const v8::PropertyCallbackInfo<v8::Value>& info) { \
JSPropGetter<class_name, &class_name::get_##prop_name>( \
- #err_name, #class_name, property, info); \
+ #err_name, class_name::kName, property, info); \
} \
static void set_##prop_name##_static( \
v8::Local<v8::String> property, v8::Local<v8::Value> value, \
const v8::PropertyCallbackInfo<void>& info) { \
JSPropSetter<class_name, &class_name::set_##prop_name>( \
- #err_name, #class_name, property, value, info); \
+ #err_name, class_name::kName, property, value, info); \
}
-#define JS_STATIC_METHOD(method_name, class_name) \
- static void method_name##_static( \
- const v8::FunctionCallbackInfo<v8::Value>& info) { \
- JSMethod<class_name, &class_name::method_name>(#method_name, #class_name, \
- info); \
+#define JS_STATIC_METHOD(method_name, class_name) \
+ static void method_name##_static( \
+ const v8::FunctionCallbackInfo<v8::Value>& info) { \
+ JSMethod<class_name, &class_name::method_name>(#method_name, \
+ class_name::kName, info); \
}
#endif // FXJS_JS_DEFINE_H_
diff --git a/fxjs/cjs_annot.cpp b/fxjs/cjs_annot.cpp
index 34084a9091..fc38e11c2f 100644
--- a/fxjs/cjs_annot.cpp
+++ b/fxjs/cjs_annot.cpp
@@ -26,6 +26,8 @@ const JSPropertySpec CJS_Annot::PropertySpecs[] = {
int CJS_Annot::ObjDefnID = -1;
+const char CJS_Annot::kName[] = "Annot";
+
// static
int CJS_Annot::GetObjDefnID() {
return ObjDefnID;
@@ -33,20 +35,16 @@ int CJS_Annot::GetObjDefnID() {
// static
void CJS_Annot::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("Annot", FXJSOBJTYPE_DYNAMIC,
+ ObjDefnID = pEngine->DefineObj(CJS_Annot::kName, FXJSOBJTYPE_DYNAMIC,
JSConstructor<CJS_Annot>, JSDestructor);
DefineProps(pEngine, ObjDefnID, PropertySpecs, FX_ArraySize(PropertySpecs));
}
-CJS_Annot::CJS_Annot(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<Annot>(this);
-}
-
-Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
+CJS_Annot::CJS_Annot(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
-Annot::~Annot() = default;
+CJS_Annot::~CJS_Annot() = default;
-CJS_Return Annot::get_hidden(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Annot::get_hidden(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -55,7 +53,8 @@ CJS_Return Annot::get_hidden(CJS_Runtime* pRuntime) {
CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict())));
}
-CJS_Return Annot::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Annot::set_hidden(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
// May invalidate m_pAnnot.
bool bHidden = pRuntime->ToBoolean(vp);
if (!m_pAnnot)
@@ -78,14 +77,14 @@ CJS_Return Annot::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Annot::get_name(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Annot::get_name(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(
pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str()));
}
-CJS_Return Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
// May invalidate m_pAnnot.
WideString annotName = pRuntime->ToWideString(vp);
if (!m_pAnnot)
@@ -95,7 +94,7 @@ CJS_Return Annot::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Annot::get_type(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Annot::get_type(CJS_Runtime* pRuntime) {
if (!m_pAnnot)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewString(
@@ -105,10 +104,6 @@ CJS_Return Annot::get_type(CJS_Runtime* pRuntime) {
.c_str()));
}
-CJS_Return Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Annot::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-
-void Annot::SetSDKAnnot(CPDFSDK_BAAnnot* annot) {
- m_pAnnot.Reset(annot);
-}
diff --git a/fxjs/cjs_annot.h b/fxjs/cjs_annot.h
index 9f0d771a44..bbcf4ac178 100644
--- a/fxjs/cjs_annot.h
+++ b/fxjs/cjs_annot.h
@@ -10,10 +10,24 @@
#include "fpdfsdk/cpdfsdk_baannot.h"
#include "fxjs/JS_Define.h"
-class Annot : public CJS_EmbedObj {
+class CJS_Annot : public CJS_Object {
public:
- explicit Annot(CJS_Object* pJSObject);
- ~Annot() override;
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine);
+
+ explicit CJS_Annot(v8::Local<v8::Object> pObject);
+ ~CJS_Annot() override;
+
+ void SetSDKAnnot(CPDFSDK_BAAnnot* annot) { m_pAnnot.Reset(annot); }
+
+ JS_STATIC_PROP(hidden, hidden, CJS_Annot);
+ JS_STATIC_PROP(name, name, CJS_Annot);
+ JS_STATIC_PROP(type, type, CJS_Annot);
+
+ private:
+ static int ObjDefnID;
+ static const char kName[];
+ static const JSPropertySpec PropertySpecs[];
CJS_Return get_hidden(CJS_Runtime* pRuntime);
CJS_Return set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
@@ -24,27 +38,7 @@ class Annot : public CJS_EmbedObj {
CJS_Return get_type(CJS_Runtime* pRuntime);
CJS_Return set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
- void SetSDKAnnot(CPDFSDK_BAAnnot* annot);
-
- private:
CPDFSDK_Annot::ObservedPtr m_pAnnot;
};
-class CJS_Annot : public CJS_Object {
- public:
- static int GetObjDefnID();
- static void DefineJSObjects(CFXJS_Engine* pEngine);
-
- explicit CJS_Annot(v8::Local<v8::Object> pObject);
- ~CJS_Annot() override = default;
-
- JS_STATIC_PROP(hidden, hidden, Annot);
- JS_STATIC_PROP(name, name, Annot);
- JS_STATIC_PROP(type, type, Annot);
-
- private:
- static int ObjDefnID;
- static const JSPropertySpec PropertySpecs[];
-};
-
#endif // FXJS_CJS_ANNOT_H_
diff --git a/fxjs/cjs_app.cpp b/fxjs/cjs_app.cpp
index 6a540f9beb..1df0146a58 100644
--- a/fxjs/cjs_app.cpp
+++ b/fxjs/cjs_app.cpp
@@ -75,24 +75,22 @@ const JSMethodSpec CJS_App::MethodSpecs[] = {
int CJS_App::ObjDefnID = -1;
+const char CJS_App::kName[] = "app";
+
// static
void CJS_App::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("app", FXJSOBJTYPE_STATIC,
+ ObjDefnID = pEngine->DefineObj(CJS_App::kName, FXJSOBJTYPE_STATIC,
JSConstructor<CJS_App>, JSDestructor);
DefineProps(pEngine, ObjDefnID, PropertySpecs, FX_ArraySize(PropertySpecs));
DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
}
-CJS_App::CJS_App(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<app>(this);
-}
-
-app::app(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject), m_bCalculate(true), m_bRuntimeHighLight(false) {}
+CJS_App::CJS_App(v8::Local<v8::Object> pObject)
+ : CJS_Object(pObject), m_bCalculate(true), m_bRuntimeHighLight(false) {}
-app::~app() = default;
+CJS_App::~CJS_App() = default;
-CJS_Return app::get_active_docs(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_active_docs(CJS_Runtime* pRuntime) {
CJS_Document* pJSDocument = nullptr;
v8::Local<v8::Object> pObj = pRuntime->GetThisObj();
if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::GetObjDefnID())
@@ -108,49 +106,50 @@ CJS_Return app::get_active_docs(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewUndefined());
}
-CJS_Return app::set_active_docs(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_active_docs(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::get_calculate(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_calculate(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewBoolean(m_bCalculate));
}
-CJS_Return app::set_calculate(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_calculate(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
m_bCalculate = pRuntime->ToBoolean(vp);
pRuntime->GetFormFillEnv()->GetInterForm()->EnableCalculate(m_bCalculate);
return CJS_Return(true);
}
-CJS_Return app::get_forms_version(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_forms_version(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(JS_NUM_FORMSVERSION));
}
-CJS_Return app::set_forms_version(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_forms_version(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::get_viewer_type(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_viewer_type(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(JS_STR_VIEWERTYPE));
}
-CJS_Return app::set_viewer_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_viewer_type(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::get_viewer_variation(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_viewer_variation(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(JS_STR_VIEWERVARIATION));
}
-CJS_Return app::set_viewer_variation(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_viewer_variation(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::get_viewer_version(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_viewer_version(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext();
if (pXFAContext->ContainsXFAForm())
@@ -159,12 +158,12 @@ CJS_Return app::get_viewer_version(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(JS_NUM_VIEWERVERSION));
}
-CJS_Return app::set_viewer_version(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_viewer_version(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::get_platform(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_platform(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
if (!pFormFillEnv)
@@ -177,11 +176,12 @@ CJS_Return app::get_platform(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(JS_STR_PLATFORM));
}
-CJS_Return app::set_platform(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_platform(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::get_language(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_language(CJS_Runtime* pRuntime) {
#ifdef PDF_ENABLE_XFA
CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
if (!pFormFillEnv)
@@ -194,7 +194,8 @@ CJS_Return app::get_language(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(JS_STR_LANGUAGE));
}
-CJS_Return app::set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_language(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
@@ -202,8 +203,8 @@ CJS_Return app::set_language(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
// comment: need reader support
// note:
// CFDF_Document * CPDFSDK_FormFillEnvironment::NewFDF();
-CJS_Return app::newFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::newFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
@@ -214,13 +215,13 @@ CJS_Return app::newFDF(CJS_Runtime* pRuntime,
// CFDF_Document * CPDFSDK_FormFillEnvironment::OpenFDF(string strPath,bool
// bUserConv);
-CJS_Return app::openFDF(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::openFDF(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return app::alert(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::alert(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<v8::Local<v8::Value>> newParams = ExpandKeywordParams(
pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle");
@@ -270,8 +271,8 @@ CJS_Return app::alert(CJS_Runtime* pRuntime,
return CJS_Return(ret);
}
-CJS_Return app::beep(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::beep(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() == 1) {
pRuntime->GetFormFillEnv()->JS_appBeep(pRuntime->ToInt32(params[0]));
return CJS_Return(true);
@@ -279,26 +280,29 @@ CJS_Return app::beep(CJS_Runtime* pRuntime,
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
}
-CJS_Return app::findComponent(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::findComponent(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return app::popUpMenuEx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::popUpMenuEx(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return app::get_fs(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_fs(CJS_Runtime* pRuntime) {
return CJS_Return(false);
}
-CJS_Return app::set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_fs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::setInterval(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::setInterval(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() > 2 || params.size() == 0)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
@@ -319,14 +323,13 @@ CJS_Return app::setInterval(CJS_Runtime* pRuntime,
CJS_TimerObj* pJS_TimerObj =
static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj));
- TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
- pTimerObj->SetTimer(timerRef);
-
+ pJS_TimerObj->SetTimer(timerRef);
return CJS_Return(pRetObj);
}
-CJS_Return app::setTimeOut(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::setTimeOut(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() > 2 || params.size() == 0)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
@@ -347,31 +350,33 @@ CJS_Return app::setTimeOut(CJS_Runtime* pRuntime,
CJS_TimerObj* pJS_TimerObj =
static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj));
- TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
- pTimerObj->SetTimer(timerRef);
+ pJS_TimerObj->SetTimer(timerRef);
return CJS_Return(pRetObj);
}
-CJS_Return app::clearTimeOut(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::clearTimeOut(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- app::ClearTimerCommon(pRuntime, params[0]);
+ CJS_App::ClearTimerCommon(pRuntime, params[0]);
return CJS_Return(true);
}
-CJS_Return app::clearInterval(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::clearInterval(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
- app::ClearTimerCommon(pRuntime, params[0]);
+ CJS_App::ClearTimerCommon(pRuntime, params[0]);
return CJS_Return(true);
}
-void app::ClearTimerCommon(CJS_Runtime* pRuntime, v8::Local<v8::Value> param) {
+void CJS_App::ClearTimerCommon(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> param) {
if (!param->IsObject())
return;
@@ -383,29 +388,27 @@ void app::ClearTimerCommon(CJS_Runtime* pRuntime, v8::Local<v8::Value> param) {
if (!pJSObj)
return;
- TimerObj* pTimerObj = static_cast<TimerObj*>(pJSObj->GetEmbedObject());
- if (!pTimerObj)
- return;
-
- GlobalTimer::Cancel(pTimerObj->GetTimerID());
+ CJS_TimerObj* pJS_TimerObj = static_cast<CJS_TimerObj*>(pJSObj);
+ GlobalTimer::Cancel(pJS_TimerObj->GetTimerID());
}
-CJS_Return app::execMenuItem(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::execMenuItem(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-void app::TimerProc(GlobalTimer* pTimer) {
+void CJS_App::TimerProc(GlobalTimer* pTimer) {
CJS_Runtime* pRuntime = pTimer->GetRuntime();
if (pRuntime && (!pTimer->IsOneShot() || pTimer->GetTimeOut() > 0))
RunJsScript(pRuntime, pTimer->GetJScript());
}
-void app::CancelProc(GlobalTimer* pTimer) {
+void CJS_App::CancelProc(GlobalTimer* pTimer) {
m_Timers.erase(pdfium::FakeUniquePtr<GlobalTimer>(pTimer));
}
-void app::RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript) {
+void CJS_App::RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript) {
if (!pRuntime->IsBlocking()) {
IJS_EventContext* pContext = pRuntime->NewEventContext();
pContext->OnExternal_Exec();
@@ -415,20 +418,20 @@ void app::RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript) {
}
}
-CJS_Return app::goBack(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::goBack(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
return CJS_Return(true);
}
-CJS_Return app::goForward(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::goForward(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
return CJS_Return(true);
}
-CJS_Return app::mailMsg(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::mailMsg(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<v8::Local<v8::Value>> newParams =
ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc", L"cBcc",
L"cSubject", L"cMsg");
@@ -470,42 +473,44 @@ CJS_Return app::mailMsg(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return app::launchURL(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::launchURL(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return app::get_runtime_highlight(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_runtime_highlight(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewBoolean(m_bRuntimeHighLight));
}
-CJS_Return app::set_runtime_highlight(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_runtime_highlight(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
m_bRuntimeHighLight = pRuntime->ToBoolean(vp);
return CJS_Return(true);
}
-CJS_Return app::get_fullscreen(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_fullscreen(CJS_Runtime* pRuntime) {
return CJS_Return(false);
}
-CJS_Return app::set_fullscreen(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_fullscreen(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::popUpMenu(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::popUpMenu(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return app::browseForDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::browseForDoc(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-WideString app::SysPathToPDFPath(const WideString& sOldPath) {
+WideString CJS_App::SysPathToPDFPath(const WideString& sOldPath) {
WideString sRet = L"/";
for (const wchar_t& c : sOldPath) {
if (c != L':')
@@ -514,18 +519,18 @@ WideString app::SysPathToPDFPath(const WideString& sOldPath) {
return sRet;
}
-CJS_Return app::newDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::newDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return app::openDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::openDoc(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return app::response(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::response(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<v8::Local<v8::Value>> newParams =
ExpandKeywordParams(pRuntime, params, 5, L"cQuestion", L"cTitle",
L"cDefault", L"bPassword", L"cLabel");
@@ -565,15 +570,16 @@ CJS_Return app::response(CJS_Runtime* pRuntime,
.c_str()));
}
-CJS_Return app::get_media(CJS_Runtime* pRuntime) {
+CJS_Return CJS_App::get_media(CJS_Runtime* pRuntime) {
return CJS_Return(false);
}
-CJS_Return app::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_App::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return app::execDialog(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_App::execDialog(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
diff --git a/fxjs/cjs_app.h b/fxjs/cjs_app.h
index 33b61a017b..e195c6db24 100644
--- a/fxjs/cjs_app.h
+++ b/fxjs/cjs_app.h
@@ -16,10 +16,58 @@
class CJS_Runtime;
class GlobalTimer;
-class app : public CJS_EmbedObj {
+class CJS_App : public CJS_Object {
public:
- explicit app(CJS_Object* pJSObject);
- ~app() override;
+ static void DefineJSObjects(CFXJS_Engine* pEngine);
+
+ explicit CJS_App(v8::Local<v8::Object> pObject);
+ ~CJS_App() override;
+
+ void TimerProc(GlobalTimer* pTimer);
+ void CancelProc(GlobalTimer* pTimer);
+
+ static WideString SysPathToPDFPath(const WideString& sOldPath);
+
+ JS_STATIC_PROP(activeDocs, active_docs, CJS_App);
+ JS_STATIC_PROP(calculate, calculate, CJS_App);
+ JS_STATIC_PROP(formsVersion, forms_version, CJS_App);
+ JS_STATIC_PROP(fs, fs, CJS_App);
+ JS_STATIC_PROP(fullscreen, fullscreen, CJS_App);
+ JS_STATIC_PROP(language, language, CJS_App);
+ JS_STATIC_PROP(media, media, CJS_App);
+ JS_STATIC_PROP(platform, platform, CJS_App);
+ JS_STATIC_PROP(runtimeHighlight, runtime_highlight, CJS_App);
+ JS_STATIC_PROP(viewerType, viewer_type, CJS_App);
+ JS_STATIC_PROP(viewerVariation, viewer_variation, CJS_App);
+ JS_STATIC_PROP(viewerVersion, viewer_version, CJS_App);
+
+ JS_STATIC_METHOD(alert, CJS_App);
+ JS_STATIC_METHOD(beep, CJS_App);
+ JS_STATIC_METHOD(browseForDoc, CJS_App);
+ JS_STATIC_METHOD(clearInterval, CJS_App);
+ JS_STATIC_METHOD(clearTimeOut, CJS_App);
+ JS_STATIC_METHOD(execDialog, CJS_App);
+ JS_STATIC_METHOD(execMenuItem, CJS_App);
+ JS_STATIC_METHOD(findComponent, CJS_App);
+ JS_STATIC_METHOD(goBack, CJS_App);
+ JS_STATIC_METHOD(goForward, CJS_App);
+ JS_STATIC_METHOD(launchURL, CJS_App);
+ JS_STATIC_METHOD(mailMsg, CJS_App);
+ JS_STATIC_METHOD(newFDF, CJS_App);
+ JS_STATIC_METHOD(newDoc, CJS_App);
+ JS_STATIC_METHOD(openDoc, CJS_App);
+ JS_STATIC_METHOD(openFDF, CJS_App);
+ JS_STATIC_METHOD(popUpMenuEx, CJS_App);
+ JS_STATIC_METHOD(popUpMenu, CJS_App);
+ JS_STATIC_METHOD(response, CJS_App);
+ JS_STATIC_METHOD(setInterval, CJS_App);
+ JS_STATIC_METHOD(setTimeOut, CJS_App);
+
+ private:
+ static int ObjDefnID;
+ static const char kName[];
+ static const JSPropertySpec PropertySpecs[];
+ static const JSMethodSpec MethodSpecs[];
CJS_Return get_active_docs(CJS_Runtime* pRuntime);
CJS_Return set_active_docs(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
@@ -102,15 +150,7 @@ class app : public CJS_EmbedObj {
CJS_Return setTimeOut(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params);
- void TimerProc(GlobalTimer* pTimer);
- void CancelProc(GlobalTimer* pTimer);
-
- static WideString SysPathToPDFPath(const WideString& sOldPath);
-
- private:
- // CJS_EmbedObj
void RunJsScript(CJS_Runtime* pRuntime, const WideString& wsScript);
-
void ClearTimerCommon(CJS_Runtime* pRuntime, v8::Local<v8::Value> param);
bool m_bCalculate;
@@ -118,52 +158,4 @@ class app : public CJS_EmbedObj {
std::set<std::unique_ptr<GlobalTimer>> m_Timers;
};
-class CJS_App : public CJS_Object {
- public:
- static void DefineJSObjects(CFXJS_Engine* pEngine);
-
- explicit CJS_App(v8::Local<v8::Object> pObject);
- ~CJS_App() override = default;
-
- JS_STATIC_PROP(activeDocs, active_docs, app);
- JS_STATIC_PROP(calculate, calculate, app);
- JS_STATIC_PROP(formsVersion, forms_version, app);
- JS_STATIC_PROP(fs, fs, app);
- JS_STATIC_PROP(fullscreen, fullscreen, app);
- JS_STATIC_PROP(language, language, app);
- JS_STATIC_PROP(media, media, app);
- JS_STATIC_PROP(platform, platform, app);
- JS_STATIC_PROP(runtimeHighlight, runtime_highlight, app);
- JS_STATIC_PROP(viewerType, viewer_type, app);
- JS_STATIC_PROP(viewerVariation, viewer_variation, app);
- JS_STATIC_PROP(viewerVersion, viewer_version, app);
-
- JS_STATIC_METHOD(alert, app);
- JS_STATIC_METHOD(beep, app);
- JS_STATIC_METHOD(browseForDoc, app);
- JS_STATIC_METHOD(clearInterval, app);
- JS_STATIC_METHOD(clearTimeOut, app);
- JS_STATIC_METHOD(execDialog, app);
- JS_STATIC_METHOD(execMenuItem, app);
- JS_STATIC_METHOD(findComponent, app);
- JS_STATIC_METHOD(goBack, app);
- JS_STATIC_METHOD(goForward, app);
- JS_STATIC_METHOD(launchURL, app);
- JS_STATIC_METHOD(mailMsg, app);
- JS_STATIC_METHOD(newFDF, app);
- JS_STATIC_METHOD(newDoc, app);
- JS_STATIC_METHOD(openDoc, app);
- JS_STATIC_METHOD(openFDF, app);
- JS_STATIC_METHOD(popUpMenuEx, app);
- JS_STATIC_METHOD(popUpMenu, app);
- JS_STATIC_METHOD(response, app);
- JS_STATIC_METHOD(setInterval, app);
- JS_STATIC_METHOD(setTimeOut, app);
-
- private:
- static int ObjDefnID;
- static const JSPropertySpec PropertySpecs[];
- static const JSMethodSpec MethodSpecs[];
-};
-
#endif // FXJS_CJS_APP_H_
diff --git a/fxjs/cjs_color.cpp b/fxjs/cjs_color.cpp
index 35747f91dc..a0cb02a99c 100644
--- a/fxjs/cjs_color.cpp
+++ b/fxjs/cjs_color.cpp
@@ -32,22 +32,19 @@ const JSMethodSpec CJS_Color::MethodSpecs[] = {{"convert", convert_static},
{"equal", equal_static}};
int CJS_Color::ObjDefnID = -1;
+const char CJS_Color::kName[] = "color";
// static
void CJS_Color::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("color", FXJSOBJTYPE_STATIC,
+ ObjDefnID = pEngine->DefineObj(CJS_Color::kName, FXJSOBJTYPE_STATIC,
JSConstructor<CJS_Color>, JSDestructor);
DefineProps(pEngine, ObjDefnID, PropertySpecs, FX_ArraySize(PropertySpecs));
DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
}
-CJS_Color::CJS_Color(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<color>(this);
-}
-
// static
-v8::Local<v8::Array> color::ConvertPWLColorToArray(CJS_Runtime* pRuntime,
- const CFX_Color& color) {
+v8::Local<v8::Array> CJS_Color::ConvertPWLColorToArray(CJS_Runtime* pRuntime,
+ const CFX_Color& color) {
v8::Local<v8::Array> array;
switch (color.nColorType) {
case CFX_Color::kTransparent:
@@ -79,8 +76,8 @@ v8::Local<v8::Array> color::ConvertPWLColorToArray(CJS_Runtime* pRuntime,
}
// static
-CFX_Color color::ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
- v8::Local<v8::Array> array) {
+CFX_Color CJS_Color::ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
+ v8::Local<v8::Array> array) {
int nArrayLen = pRuntime->GetArrayLength(array);
if (nArrayLen < 1)
return CFX_Color();
@@ -124,132 +121,137 @@ CFX_Color color::ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
return CFX_Color();
}
-color::color(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {
- m_crTransparent = CFX_Color(CFX_Color::kTransparent);
- m_crBlack = CFX_Color(CFX_Color::kGray, 0);
- m_crWhite = CFX_Color(CFX_Color::kGray, 1);
- m_crRed = CFX_Color(CFX_Color::kRGB, 1, 0, 0);
- m_crGreen = CFX_Color(CFX_Color::kRGB, 0, 1, 0);
- m_crBlue = CFX_Color(CFX_Color::kRGB, 0, 0, 1);
- m_crCyan = CFX_Color(CFX_Color::kCMYK, 1, 0, 0, 0);
- m_crMagenta = CFX_Color(CFX_Color::kCMYK, 0, 1, 0, 0);
- m_crYellow = CFX_Color(CFX_Color::kCMYK, 0, 0, 1, 0);
- m_crDKGray = CFX_Color(CFX_Color::kGray, 0.25);
- m_crGray = CFX_Color(CFX_Color::kGray, 0.5);
- m_crLTGray = CFX_Color(CFX_Color::kGray, 0.75);
-}
-
-color::~color() {}
-
-CJS_Return color::get_transparent(CJS_Runtime* pRuntime) {
+CJS_Color::CJS_Color(v8::Local<v8::Object> pObject)
+ : CJS_Object(pObject),
+ m_crTransparent(CFX_Color::kTransparent),
+ m_crBlack(CFX_Color::kGray, 0),
+ m_crWhite(CFX_Color::kGray, 1),
+ m_crRed(CFX_Color::kRGB, 1, 0, 0),
+ m_crGreen(CFX_Color::kRGB, 0, 1, 0),
+ m_crBlue(CFX_Color::kRGB, 0, 0, 1),
+ m_crCyan(CFX_Color::kCMYK, 1, 0, 0, 0),
+ m_crMagenta(CFX_Color::kCMYK, 0, 1, 0, 0),
+ m_crYellow(CFX_Color::kCMYK, 0, 0, 1, 0),
+ m_crDKGray(CFX_Color::kGray, 0.25),
+ m_crGray(CFX_Color::kGray, 0.5),
+ m_crLTGray(CFX_Color::kGray, 0.75) {}
+
+CJS_Color::~CJS_Color() = default;
+
+CJS_Return CJS_Color::get_transparent(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crTransparent);
}
-CJS_Return color::set_transparent(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_transparent(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crTransparent);
}
-CJS_Return color::get_black(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_black(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crBlack);
}
-CJS_Return color::set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_black(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crBlack);
}
-CJS_Return color::get_white(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_white(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crWhite);
}
-CJS_Return color::set_white(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_white(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crWhite);
}
-CJS_Return color::get_red(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_red(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crRed);
}
-CJS_Return color::set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_red(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crRed);
}
-CJS_Return color::get_green(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_green(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crGreen);
}
-CJS_Return color::set_green(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_green(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crGreen);
}
-CJS_Return color::get_blue(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_blue(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crBlue);
}
-CJS_Return color::set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_blue(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crBlue);
}
-CJS_Return color::get_cyan(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_cyan(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crCyan);
}
-CJS_Return color::set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_cyan(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crCyan);
}
-CJS_Return color::get_magenta(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_magenta(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crMagenta);
}
-CJS_Return color::set_magenta(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_magenta(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crMagenta);
}
-CJS_Return color::get_yellow(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_yellow(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crYellow);
}
-CJS_Return color::set_yellow(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_yellow(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crYellow);
}
-CJS_Return color::get_dark_gray(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_dark_gray(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crDKGray);
}
-CJS_Return color::set_dark_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_dark_gray(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crDKGray);
}
-CJS_Return color::get_gray(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_gray(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crGray);
}
-CJS_Return color::set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_gray(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crGray);
}
-CJS_Return color::get_light_gray(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Color::get_light_gray(CJS_Runtime* pRuntime) {
return GetPropertyHelper(pRuntime, &m_crLTGray);
}
-CJS_Return color::set_light_gray(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Color::set_light_gray(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return SetPropertyHelper(pRuntime, vp, &m_crLTGray);
}
-CJS_Return color::GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* var) {
+CJS_Return CJS_Color::GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* var) {
v8::Local<v8::Value> array = ConvertPWLColorToArray(pRuntime, *var);
if (array.IsEmpty())
return CJS_Return(pRuntime->NewArray());
return CJS_Return(array);
}
-CJS_Return color::SetPropertyHelper(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- CFX_Color* var) {
+CJS_Return CJS_Color::SetPropertyHelper(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp,
+ CFX_Color* var) {
if (vp.IsEmpty() || !vp->IsArray())
return CJS_Return(false);
@@ -257,8 +259,8 @@ CJS_Return color::SetPropertyHelper(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return color::convert(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Color::convert(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
if (iSize < 2)
return CJS_Return(false);
@@ -286,8 +288,8 @@ CJS_Return color::convert(CJS_Runtime* pRuntime,
return CJS_Return(array);
}
-CJS_Return color::equal(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Color::equal(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
return CJS_Return(false);
if (params[0].IsEmpty() || !params[0]->IsArray() || params[1].IsEmpty() ||
diff --git a/fxjs/cjs_color.h b/fxjs/cjs_color.h
index fab035db21..667a13c21a 100644
--- a/fxjs/cjs_color.h
+++ b/fxjs/cjs_color.h
@@ -12,15 +12,38 @@
#include "fpdfsdk/pwl/cpwl_wnd.h"
#include "fxjs/JS_Define.h"
-class color : public CJS_EmbedObj {
+class CJS_Color : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine);
static v8::Local<v8::Array> ConvertPWLColorToArray(CJS_Runtime* pRuntime,
const CFX_Color& color);
static CFX_Color ConvertArrayToPWLColor(CJS_Runtime* pRuntime,
v8::Local<v8::Array> array);
- explicit color(CJS_Object* pJSObject);
- ~color() override;
+ explicit CJS_Color(v8::Local<v8::Object> pObject);
+ ~CJS_Color() override;
+
+ JS_STATIC_PROP(black, black, CJS_Color);
+ JS_STATIC_PROP(blue, blue, CJS_Color);
+ JS_STATIC_PROP(cyan, cyan, CJS_Color);
+ JS_STATIC_PROP(dkGray, dark_gray, CJS_Color);
+ JS_STATIC_PROP(gray, gray, CJS_Color);
+ JS_STATIC_PROP(green, green, CJS_Color);
+ JS_STATIC_PROP(ltGray, light_gray, CJS_Color);
+ JS_STATIC_PROP(magenta, magenta, CJS_Color);
+ JS_STATIC_PROP(red, red, CJS_Color);
+ JS_STATIC_PROP(transparent, transparent, CJS_Color);
+ JS_STATIC_PROP(white, white, CJS_Color);
+ JS_STATIC_PROP(yellow, yellow, CJS_Color);
+
+ JS_STATIC_METHOD(convert, CJS_Color);
+ JS_STATIC_METHOD(equal, CJS_Color);
+
+ private:
+ static int ObjDefnID;
+ static const char kName[];
+ static const JSPropertySpec PropertySpecs[];
+ static const JSMethodSpec MethodSpecs[];
CJS_Return get_black(CJS_Runtime* pRuntime);
CJS_Return set_black(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
@@ -63,7 +86,6 @@ class color : public CJS_EmbedObj {
CJS_Return equal(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params);
- private:
CJS_Return GetPropertyHelper(CJS_Runtime* pRuntime, CFX_Color* val);
CJS_Return SetPropertyHelper(CJS_Runtime* pRuntime,
v8::Local<v8::Value> vp,
@@ -83,33 +105,4 @@ class color : public CJS_EmbedObj {
CFX_Color m_crLTGray;
};
-class CJS_Color : public CJS_Object {
- public:
- static void DefineJSObjects(CFXJS_Engine* pEngine);
-
- explicit CJS_Color(v8::Local<v8::Object> pObject);
- ~CJS_Color() override = default;
-
- JS_STATIC_PROP(black, black, color);
- JS_STATIC_PROP(blue, blue, color);
- JS_STATIC_PROP(cyan, cyan, color);
- JS_STATIC_PROP(dkGray, dark_gray, color);
- JS_STATIC_PROP(gray, gray, color);
- JS_STATIC_PROP(green, green, color);
- JS_STATIC_PROP(ltGray, light_gray, color);
- JS_STATIC_PROP(magenta, magenta, color);
- JS_STATIC_PROP(red, red, color);
- JS_STATIC_PROP(transparent, transparent, color);
- JS_STATIC_PROP(white, white, color);
- JS_STATIC_PROP(yellow, yellow, color);
-
- JS_STATIC_METHOD(convert, color);
- JS_STATIC_METHOD(equal, color);
-
- private:
- static int ObjDefnID;
- static const JSPropertySpec PropertySpecs[];
- static const JSMethodSpec MethodSpecs[];
-};
-
#endif // FXJS_CJS_COLOR_H_
diff --git a/fxjs/cjs_console.cpp b/fxjs/cjs_console.cpp
index 2b4dd27977..2b7c84ad78 100644
--- a/fxjs/cjs_console.cpp
+++ b/fxjs/cjs_console.cpp
@@ -19,38 +19,36 @@ const JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static},
{"show", show_static}};
int CJS_Console::ObjDefnID = -1;
+const char CJS_Console::kName[] = "console";
// static
void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("console", FXJSOBJTYPE_STATIC,
+ ObjDefnID = pEngine->DefineObj(CJS_Console::kName, FXJSOBJTYPE_STATIC,
JSConstructor<CJS_Console>, JSDestructor);
DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
}
-CJS_Console::CJS_Console(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<console>(this);
-}
-
-console::console(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
+CJS_Console::CJS_Console(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
-console::~console() = default;
+CJS_Console::~CJS_Console() = default;
-CJS_Return console::clear(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Console::clear(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return console::hide(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Console::hide(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return console::println(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Console::println(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(params.size() > 0);
}
-CJS_Return console::show(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Console::show(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
diff --git a/fxjs/cjs_console.h b/fxjs/cjs_console.h
index 22c18dec12..56243cf6a5 100644
--- a/fxjs/cjs_console.h
+++ b/fxjs/cjs_console.h
@@ -11,37 +11,31 @@
#include "fxjs/JS_Define.h"
-class console : public CJS_EmbedObj {
- public:
- explicit console(CJS_Object* pJSObject);
- ~console() override;
-
- public:
- CJS_Return clear(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params);
- CJS_Return hide(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params);
- CJS_Return println(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params);
- CJS_Return show(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params);
-};
-
class CJS_Console : public CJS_Object {
public:
static void DefineJSObjects(CFXJS_Engine* pEngine);
explicit CJS_Console(v8::Local<v8::Object> pObject);
- ~CJS_Console() override = default;
+ ~CJS_Console() override;
- JS_STATIC_METHOD(clear, console);
- JS_STATIC_METHOD(hide, console);
- JS_STATIC_METHOD(println, console);
- JS_STATIC_METHOD(show, console);
+ JS_STATIC_METHOD(clear, CJS_Console);
+ JS_STATIC_METHOD(hide, CJS_Console);
+ JS_STATIC_METHOD(println, CJS_Console);
+ JS_STATIC_METHOD(show, CJS_Console);
private:
static int ObjDefnID;
+ static const char kName[];
static const JSMethodSpec MethodSpecs[];
+
+ CJS_Return clear(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return hide(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return println(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return show(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
};
#endif // FXJS_CJS_CONSOLE_H_
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index f8bdecda79..c4a5ff4091 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -108,6 +108,7 @@ const JSMethodSpec CJS_Document::MethodSpecs[] = {
{"mailDoc", mailDoc_static}};
int CJS_Document::ObjDefnID = -1;
+const char CJS_Document::kName[] = "Document";
// static
int CJS_Document::GetObjDefnID() {
@@ -116,33 +117,27 @@ int CJS_Document::GetObjDefnID() {
// static
void CJS_Document::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("Document", FXJSOBJTYPE_GLOBAL,
+ ObjDefnID = pEngine->DefineObj(CJS_Document::kName, FXJSOBJTYPE_GLOBAL,
JSConstructor<CJS_Document>, JSDestructor);
DefineProps(pEngine, ObjDefnID, PropertySpecs, FX_ArraySize(PropertySpecs));
DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
}
CJS_Document::CJS_Document(v8::Local<v8::Object> pObject)
- : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<Document>(this);
-}
-
-void CJS_Document::InitInstance(IJS_Runtime* pIRuntime) {
- CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime);
- Document* pDoc = static_cast<Document*>(GetEmbedObject());
- pDoc->SetFormFillEnv(pRuntime->GetFormFillEnv());
-}
-
-Document::Document(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject),
+ : CJS_Object(pObject),
m_pFormFillEnv(nullptr),
m_cwBaseURL(L""),
m_bDelay(false) {}
-Document::~Document() = default;
+CJS_Document::~CJS_Document() = default;
+
+void CJS_Document::InitInstance(IJS_Runtime* pIRuntime) {
+ CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime);
+ SetFormFillEnv(pRuntime->GetFormFillEnv());
+}
// The total number of fields in document.
-CJS_Return Document::get_num_fields(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_num_fields(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -152,18 +147,19 @@ CJS_Return Document::get_num_fields(CJS_Runtime* pRuntime) {
static_cast<int>(pPDFForm->CountFields(WideString()))));
}
-CJS_Return Document::set_num_fields(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_num_fields(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Document::get_dirty(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_dirty(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
}
-CJS_Return Document::set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_dirty(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -172,15 +168,16 @@ CJS_Return Document::set_dirty(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::get_ADBE(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_ADBE(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewUndefined());
}
-CJS_Return Document::set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_ADBE(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::get_page_num(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_page_num(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -190,8 +187,8 @@ CJS_Return Document::get_page_num(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(pPageView->GetPageIndex()));
}
-CJS_Return Document::set_page_num(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_page_num(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -207,41 +204,44 @@ CJS_Return Document::set_page_num(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Document::addAnnot(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::addAnnot(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
return CJS_Return(true);
}
-CJS_Return Document::addField(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::addField(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Not supported.
return CJS_Return(true);
}
-CJS_Return Document::exportAsText(
+CJS_Return CJS_Document::exportAsText(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::exportAsFDF(
+CJS_Return CJS_Document::exportAsFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::exportAsXFDF(
+CJS_Return CJS_Document::exportAsXFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::getField(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::getField(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 1)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if (!m_pFormFillEnv)
@@ -260,8 +260,7 @@ CJS_Return Document::getField(CJS_Runtime* pRuntime,
CJS_Field* pJSField =
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
- Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
- pField->AttachField(this, wideName);
+ pJSField->AttachField(this, wideName);
if (!pJSField)
return CJS_Return(false);
@@ -269,7 +268,7 @@ CJS_Return Document::getField(CJS_Runtime* pRuntime,
}
// Gets the name of the nth field in the document
-CJS_Return Document::getNthFieldName(
+CJS_Return CJS_Document::getNthFieldName(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
@@ -289,21 +288,21 @@ CJS_Return Document::getNthFieldName(
return CJS_Return(pRuntime->NewString(pField->GetFullName().c_str()));
}
-CJS_Return Document::importAnFDF(
+CJS_Return CJS_Document::importAnFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::importAnXFDF(
+CJS_Return CJS_Document::importAnXFDF(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::importTextData(
+CJS_Return CJS_Document::importTextData(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
@@ -313,8 +312,9 @@ CJS_Return Document::importTextData(
// exports the form data and mails the resulting fdf file as an attachment to
// all recipients.
// comment: need reader supports
-CJS_Return Document::mailForm(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::mailForm(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_EXTRACT_ACCESS))
@@ -346,8 +346,9 @@ CJS_Return Document::mailForm(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Document::print(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::print(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -368,17 +369,16 @@ CJS_Return Document::print(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[8]);
CJS_Object* pJSObj = pRuntime->GetObjectPrivate(pObj);
if (pJSObj) {
- if (PrintParamsObj* pprintparamsObj =
- static_cast<PrintParamsObj*>(pJSObj->GetEmbedObject())) {
- bUI = pprintparamsObj->bUI;
- nStart = pprintparamsObj->nStart;
- nEnd = pprintparamsObj->nEnd;
- bSilent = pprintparamsObj->bSilent;
- bShrinkToFit = pprintparamsObj->bShrinkToFit;
- bPrintAsImage = pprintparamsObj->bPrintAsImage;
- bReverse = pprintparamsObj->bReverse;
- bAnnotations = pprintparamsObj->bAnnotations;
- }
+ CJS_PrintParamsObj* printObj =
+ static_cast<CJS_PrintParamsObj*>(pJSObj);
+ bUI = printObj->GetUI();
+ nStart = printObj->GetStart();
+ nEnd = printObj->GetEnd();
+ bSilent = printObj->GetSilent();
+ bShrinkToFit = printObj->GetShrinkToFit();
+ bPrintAsImage = printObj->GetPrintAsImage();
+ bReverse = printObj->GetReverse();
+ bAnnotations = printObj->GetAnnotations();
}
}
}
@@ -413,7 +413,7 @@ CJS_Return Document::print(CJS_Runtime* pRuntime,
// comment:
// note: if the filed name is not rational, adobe is dumb for it.
-CJS_Return Document::removeField(
+CJS_Return CJS_Document::removeField(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
@@ -467,7 +467,7 @@ CJS_Return Document::removeField(
// comment:
// note: if the fields names r not rational, aodbe is dumb for it.
-CJS_Return Document::resetForm(
+CJS_Return CJS_Document::resetForm(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
@@ -510,19 +510,20 @@ CJS_Return Document::resetForm(
return CJS_Return(true);
}
-CJS_Return Document::saveAs(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::saveAs(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::syncAnnotScan(
+CJS_Return CJS_Document::syncAnnotScan(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Document::submitForm(
+CJS_Return CJS_Document::submitForm(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
int nSize = params.size();
@@ -588,21 +589,22 @@ CJS_Return Document::submitForm(
return CJS_Return(true);
}
-void Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+void CJS_Document::SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
m_pFormFillEnv.Reset(pFormFillEnv);
}
-CJS_Return Document::get_bookmark_root(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_bookmark_root(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_bookmark_root(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_bookmark_root(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::mailDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::mailDoc(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// TODO(tsepez): Check maximum number of allowed params.
bool bUI = true;
WideString cTo = L"";
@@ -643,16 +645,16 @@ CJS_Return Document::mailDoc(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Document::get_author(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_author(CJS_Runtime* pRuntime) {
return getPropertyInternal(pRuntime, "Author");
}
-CJS_Return Document::set_author(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_author(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return setPropertyInternal(pRuntime, vp, "Author");
}
-CJS_Return Document::get_info(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_info(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -711,12 +713,13 @@ CJS_Return Document::get_info(CJS_Runtime* pRuntime) {
return CJS_Return(pObj);
}
-CJS_Return Document::set_info(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_info(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Document::getPropertyInternal(CJS_Runtime* pRuntime,
- const ByteString& propName) {
+CJS_Return CJS_Document::getPropertyInternal(CJS_Runtime* pRuntime,
+ const ByteString& propName) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -727,9 +730,9 @@ CJS_Return Document::getPropertyInternal(CJS_Runtime* pRuntime,
pRuntime->NewString(pDictionary->GetUnicodeTextFor(propName).c_str()));
}
-CJS_Return Document::setPropertyInternal(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp,
- const ByteString& propName) {
+CJS_Return CJS_Document::setPropertyInternal(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp,
+ const ByteString& propName) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -747,31 +750,32 @@ CJS_Return Document::setPropertyInternal(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Document::get_creation_date(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_creation_date(CJS_Runtime* pRuntime) {
return getPropertyInternal(pRuntime, "CreationDate");
}
-CJS_Return Document::set_creation_date(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_creation_date(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return setPropertyInternal(pRuntime, vp, "CreationDate");
}
-CJS_Return Document::get_creator(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_creator(CJS_Runtime* pRuntime) {
return getPropertyInternal(pRuntime, "Creator");
}
-CJS_Return Document::set_creator(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_creator(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return setPropertyInternal(pRuntime, vp, "Creator");
}
-CJS_Return Document::get_delay(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_delay(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewBoolean(m_bDelay));
}
-CJS_Return Document::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_delay(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY))
@@ -786,129 +790,131 @@ CJS_Return Document::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess;
DelayDataToProcess.swap(m_DelayData);
for (const auto& pData : DelayDataToProcess)
- Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
+ CJS_Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
return CJS_Return(true);
}
-CJS_Return Document::get_keywords(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_keywords(CJS_Runtime* pRuntime) {
return getPropertyInternal(pRuntime, "Keywords");
}
-CJS_Return Document::set_keywords(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_keywords(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return setPropertyInternal(pRuntime, vp, "Keywords");
}
-CJS_Return Document::get_mod_date(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_mod_date(CJS_Runtime* pRuntime) {
return getPropertyInternal(pRuntime, "ModDate");
}
-CJS_Return Document::set_mod_date(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_mod_date(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return setPropertyInternal(pRuntime, vp, "ModDate");
}
-CJS_Return Document::get_producer(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_producer(CJS_Runtime* pRuntime) {
return getPropertyInternal(pRuntime, "Producer");
}
-CJS_Return Document::set_producer(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_producer(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return setPropertyInternal(pRuntime, vp, "Producer");
}
-CJS_Return Document::get_subject(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_subject(CJS_Runtime* pRuntime) {
return getPropertyInternal(pRuntime, "Subject");
}
-CJS_Return Document::set_subject(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_subject(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return setPropertyInternal(pRuntime, vp, "Subject");
}
-CJS_Return Document::get_title(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_title(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument())
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return getPropertyInternal(pRuntime, "Title");
}
-CJS_Return Document::set_title(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_title(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument())
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return setPropertyInternal(pRuntime, vp, "Title");
}
-CJS_Return Document::get_num_pages(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_num_pages(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
}
-CJS_Return Document::set_num_pages(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_num_pages(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Document::get_external(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_external(CJS_Runtime* pRuntime) {
// In Chrome case, should always return true.
return CJS_Return(pRuntime->NewBoolean(true));
}
-CJS_Return Document::set_external(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_external(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::get_filesize(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_filesize(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(0));
}
-CJS_Return Document::set_filesize(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_filesize(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Document::get_mouse_x(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_mouse_x(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_mouse_x(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_mouse_x(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::get_mouse_y(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_mouse_y(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_mouse_y(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_mouse_y(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::get_URL(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_URL(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(
pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str()));
}
-CJS_Return Document::set_URL(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_URL(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Document::get_base_URL(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_base_URL(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(m_cwBaseURL.c_str()));
}
-CJS_Return Document::set_base_URL(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_base_URL(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
m_cwBaseURL = pRuntime->ToWideString(vp);
return CJS_Return(true);
}
-CJS_Return Document::get_calculate(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_calculate(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -916,8 +922,8 @@ CJS_Return Document::get_calculate(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
}
-CJS_Return Document::set_calculate(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_calculate(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -926,7 +932,7 @@ CJS_Return Document::set_calculate(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Document::get_document_file_name(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_document_file_name(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
@@ -944,58 +950,62 @@ CJS_Return Document::get_document_file_name(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(L""));
}
-CJS_Return Document::set_document_file_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_document_file_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Document::get_path(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_path(CJS_Runtime* pRuntime) {
if (!m_pFormFillEnv)
return CJS_Return(JSGetStringFromID(JSMessage::kBadObjectError));
return CJS_Return(pRuntime->NewString(
- app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str()));
+ CJS_App::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str()));
}
-CJS_Return Document::set_path(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_path(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Document::get_page_window_rect(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_page_window_rect(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_page_window_rect(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_page_window_rect(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::get_layout(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_layout(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_layout(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_layout(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::addLink(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::addLink(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Document::closeDoc(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::closeDoc(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Document::getPageBox(
+CJS_Return CJS_Document::getPageBox(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Document::getAnnot(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::getAnnot(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
if (!m_pFormFillEnv)
@@ -1030,13 +1040,11 @@ CJS_Return Document::getAnnot(CJS_Runtime* pRuntime,
if (!pJS_Annot)
return CJS_Return(false);
- Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
- pAnnot->SetSDKAnnot(pSDKBAAnnot);
-
+ pJS_Annot->SetSDKAnnot(pSDKBAAnnot);
return CJS_Return(pJS_Annot->ToV8Object());
}
-CJS_Return Document::getAnnots(
+CJS_Return CJS_Document::getAnnots(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
@@ -1064,8 +1072,7 @@ CJS_Return Document::getAnnots(
CJS_Annot* pJS_Annot =
static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
- Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
- pAnnot->SetSDKAnnot(static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur.Get()));
+ pJS_Annot->SetSDKAnnot(static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur.Get()));
pRuntime->PutArrayElement(
annots, i,
pJS_Annot ? v8::Local<v8::Value>(pJS_Annot->ToV8Object())
@@ -1075,35 +1082,39 @@ CJS_Return Document::getAnnots(
return CJS_Return(annots);
}
-CJS_Return Document::getAnnot3D(
+CJS_Return CJS_Document::getAnnot3D(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(pRuntime->NewUndefined());
}
-CJS_Return Document::getAnnots3D(
+CJS_Return CJS_Document::getAnnots3D(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Document::getOCGs(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::getOCGs(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Document::getLinks(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::getLinks(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) {
+bool CJS_Document::IsEnclosedInRect(CFX_FloatRect rect,
+ CFX_FloatRect LinkRect) {
return (rect.left <= LinkRect.left && rect.top <= LinkRect.top &&
rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom);
}
-CJS_Return Document::addIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::addIcon(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
@@ -1117,14 +1128,14 @@ CJS_Return Document::addIcon(CJS_Runtime* pRuntime,
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]);
CJS_Object* obj = pRuntime->GetObjectPrivate(pObj);
- if (!obj->GetEmbedObject())
+ if (!obj)
return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
m_IconNames.push_back(swIconName);
return CJS_Return(true);
}
-CJS_Return Document::get_icons(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_icons(CJS_Runtime* pRuntime) {
if (m_IconNames.empty())
return CJS_Return(pRuntime->NewUndefined());
@@ -1138,8 +1149,7 @@ CJS_Return Document::get_icons(CJS_Runtime* pRuntime) {
CJS_Icon* pJS_Icon =
static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
- Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
- pIcon->SetIconName(name);
+ pJS_Icon->SetIconName(name);
pRuntime->PutArrayElement(Icons, i++,
pJS_Icon
? v8::Local<v8::Value>(pJS_Icon->ToV8Object())
@@ -1148,12 +1158,14 @@ CJS_Return Document::get_icons(CJS_Runtime* pRuntime) {
return CJS_Return(Icons);
}
-CJS_Return Document::set_icons(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_icons(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Document::getIcon(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::getIcon(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
@@ -1171,34 +1183,34 @@ CJS_Return Document::getIcon(CJS_Runtime* pRuntime,
if (!pJS_Icon)
return CJS_Return(false);
- Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
- pIcon->SetIconName(*it);
+ pJS_Icon->SetIconName(*it);
return CJS_Return(pJS_Icon->ToV8Object());
}
-CJS_Return Document::removeIcon(
+CJS_Return CJS_Document::removeIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, no supported.
return CJS_Return(true);
}
-CJS_Return Document::createDataObject(
+CJS_Return CJS_Document::createDataObject(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not implemented.
return CJS_Return(true);
}
-CJS_Return Document::get_media(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_media(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_media(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_media(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::calculateNow(
+CJS_Return CJS_Document::calculateNow(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
@@ -1214,16 +1226,16 @@ CJS_Return Document::calculateNow(
return CJS_Return(true);
}
-CJS_Return Document::get_collab(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_collab(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_collab(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_collab(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::getPageNthWord(
+CJS_Return CJS_Document::getPageNthWord(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
@@ -1270,7 +1282,7 @@ CJS_Return Document::getPageNthWord(
return CJS_Return(pRuntime->NewString(swRet.c_str()));
}
-CJS_Return Document::getPageNthWordQuads(
+CJS_Return CJS_Document::getPageNthWordQuads(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
@@ -1280,7 +1292,7 @@ CJS_Return Document::getPageNthWordQuads(
return CJS_Return(false);
}
-CJS_Return Document::getPageNumWords(
+CJS_Return CJS_Document::getPageNumWords(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_pFormFillEnv)
@@ -1309,7 +1321,7 @@ CJS_Return Document::getPageNumWords(
return CJS_Return(pRuntime->NewNumber(nWords));
}
-CJS_Return Document::getPrintParams(
+CJS_Return CJS_Document::getPrintParams(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
v8::Local<v8::Object> pRetObj =
@@ -1324,7 +1336,7 @@ CJS_Return Document::getPrintParams(
#define ISLATINWORD(u) (u != 0x20 && u <= 0x28FF)
-int Document::CountWords(CPDF_TextObject* pTextObj) {
+int CJS_Document::CountWords(CPDF_TextObject* pTextObj) {
if (!pTextObj)
return 0;
@@ -1358,7 +1370,8 @@ int Document::CountWords(CPDF_TextObject* pTextObj) {
return nWords;
}
-WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex) {
+WideString CJS_Document::GetObjWordStr(CPDF_TextObject* pTextObj,
+ int nWordIndex) {
WideString swRet;
CPDF_Font* pFont = pTextObj->GetFont();
@@ -1393,58 +1406,60 @@ WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex) {
return swRet;
}
-CJS_Return Document::get_zoom(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_zoom(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_zoom(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_zoom(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::get_zoom_type(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Document::get_zoom_type(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Document::set_zoom_type(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Document::set_zoom_type(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Document::deletePages(
+CJS_Return CJS_Document::deletePages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::extractPages(
+CJS_Return CJS_Document::extractPages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::insertPages(
+CJS_Return CJS_Document::insertPages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::replacePages(
+CJS_Return CJS_Document::replacePages(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::getURL(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Document::getURL(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Document::gotoNamedDest(
+CJS_Return CJS_Document::gotoNamedDest(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 1)
@@ -1477,11 +1492,12 @@ CJS_Return Document::gotoNamedDest(
return CJS_Return(true);
}
-void Document::AddDelayData(std::unique_ptr<CJS_DelayData> pData) {
+void CJS_Document::AddDelayData(std::unique_ptr<CJS_DelayData> pData) {
m_DelayData.push_back(std::move(pData));
}
-void Document::DoFieldDelay(const WideString& sFieldName, int nControlIndex) {
+void CJS_Document::DoFieldDelay(const WideString& sFieldName,
+ int nControlIndex) {
std::vector<std::unique_ptr<CJS_DelayData>> delayed_data;
auto iter = m_DelayData.begin();
while (iter != m_DelayData.end()) {
@@ -1494,9 +1510,5 @@ void Document::DoFieldDelay(const WideString& sFieldName, int nControlIndex) {
}
for (const auto& pData : delayed_data)
- Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
-}
-
-CJS_Document* Document::GetCJSDoc() const {
- return static_cast<CJS_Document*>(m_pJSObject.Get());
+ CJS_Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
}
diff --git a/fxjs/cjs_document.h b/fxjs/cjs_document.h
index 0b0a158864..179b8eff4c 100644
--- a/fxjs/cjs_document.h
+++ b/fxjs/cjs_document.h
@@ -18,10 +18,105 @@ class CPDF_TextObject;
struct CJS_DelayData;
-class Document : public CJS_EmbedObj {
+class CJS_Document : public CJS_Object {
public:
- explicit Document(CJS_Object* pJSObject);
- ~Document() override;
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine);
+
+ explicit CJS_Document(v8::Local<v8::Object> pObject);
+ ~CJS_Document() override;
+
+ // CJS_Object
+ void InitInstance(IJS_Runtime* pIRuntime) override;
+
+ void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ CPDFSDK_FormFillEnvironment* GetFormFillEnv() const {
+ return m_pFormFillEnv.Get();
+ }
+ void AddDelayData(std::unique_ptr<CJS_DelayData> pData);
+ void DoFieldDelay(const WideString& sFieldName, int nControlIndex);
+
+ JS_STATIC_PROP(ADBE, ADBE, CJS_Document);
+ JS_STATIC_PROP(author, author, CJS_Document);
+ JS_STATIC_PROP(baseURL, base_URL, CJS_Document);
+ JS_STATIC_PROP(bookmarkRoot, bookmark_root, CJS_Document);
+ JS_STATIC_PROP(calculate, calculate, CJS_Document);
+ JS_STATIC_PROP(Collab, collab, CJS_Document);
+ JS_STATIC_PROP(creationDate, creation_date, CJS_Document);
+ JS_STATIC_PROP(creator, creator, CJS_Document);
+ JS_STATIC_PROP(delay, delay, CJS_Document);
+ JS_STATIC_PROP(dirty, dirty, CJS_Document);
+ JS_STATIC_PROP(documentFileName, document_file_name, CJS_Document);
+ JS_STATIC_PROP(external, external, CJS_Document);
+ JS_STATIC_PROP(filesize, filesize, CJS_Document);
+ JS_STATIC_PROP(icons, icons, CJS_Document);
+ JS_STATIC_PROP(info, info, CJS_Document);
+ JS_STATIC_PROP(keywords, keywords, CJS_Document);
+ JS_STATIC_PROP(layout, layout, CJS_Document);
+ JS_STATIC_PROP(media, media, CJS_Document);
+ JS_STATIC_PROP(modDate, mod_date, CJS_Document);
+ JS_STATIC_PROP(mouseX, mouse_x, CJS_Document);
+ JS_STATIC_PROP(mouseY, mouse_y, CJS_Document);
+ JS_STATIC_PROP(numFields, num_fields, CJS_Document);
+ JS_STATIC_PROP(numPages, num_pages, CJS_Document);
+ JS_STATIC_PROP(pageNum, page_num, CJS_Document);
+ JS_STATIC_PROP(pageWindowRect, page_window_rect, CJS_Document);
+ JS_STATIC_PROP(path, path, CJS_Document);
+ JS_STATIC_PROP(producer, producer, CJS_Document);
+ JS_STATIC_PROP(subject, subject, CJS_Document);
+ JS_STATIC_PROP(title, title, CJS_Document);
+ JS_STATIC_PROP(URL, URL, CJS_Document);
+ JS_STATIC_PROP(zoom, zoom, CJS_Document);
+ JS_STATIC_PROP(zoomType, zoom_type, CJS_Document);
+
+ JS_STATIC_METHOD(addAnnot, CJS_Document);
+ JS_STATIC_METHOD(addField, CJS_Document);
+ JS_STATIC_METHOD(addLink, CJS_Document);
+ JS_STATIC_METHOD(addIcon, CJS_Document);
+ JS_STATIC_METHOD(calculateNow, CJS_Document);
+ JS_STATIC_METHOD(closeDoc, CJS_Document);
+ JS_STATIC_METHOD(createDataObject, CJS_Document);
+ JS_STATIC_METHOD(deletePages, CJS_Document);
+ JS_STATIC_METHOD(exportAsText, CJS_Document);
+ JS_STATIC_METHOD(exportAsFDF, CJS_Document);
+ JS_STATIC_METHOD(exportAsXFDF, CJS_Document);
+ JS_STATIC_METHOD(extractPages, CJS_Document);
+ JS_STATIC_METHOD(getAnnot, CJS_Document);
+ JS_STATIC_METHOD(getAnnots, CJS_Document);
+ JS_STATIC_METHOD(getAnnot3D, CJS_Document);
+ JS_STATIC_METHOD(getAnnots3D, CJS_Document);
+ JS_STATIC_METHOD(getField, CJS_Document);
+ JS_STATIC_METHOD(getIcon, CJS_Document);
+ JS_STATIC_METHOD(getLinks, CJS_Document);
+ JS_STATIC_METHOD(getNthFieldName, CJS_Document);
+ JS_STATIC_METHOD(getOCGs, CJS_Document);
+ JS_STATIC_METHOD(getPageBox, CJS_Document);
+ JS_STATIC_METHOD(getPageNthWord, CJS_Document);
+ JS_STATIC_METHOD(getPageNthWordQuads, CJS_Document);
+ JS_STATIC_METHOD(getPageNumWords, CJS_Document);
+ JS_STATIC_METHOD(getPrintParams, CJS_Document);
+ JS_STATIC_METHOD(getURL, CJS_Document);
+ JS_STATIC_METHOD(gotoNamedDest, CJS_Document);
+ JS_STATIC_METHOD(importAnFDF, CJS_Document);
+ JS_STATIC_METHOD(importAnXFDF, CJS_Document);
+ JS_STATIC_METHOD(importTextData, CJS_Document);
+ JS_STATIC_METHOD(insertPages, CJS_Document);
+ JS_STATIC_METHOD(mailForm, CJS_Document);
+ JS_STATIC_METHOD(print, CJS_Document);
+ JS_STATIC_METHOD(removeField, CJS_Document);
+ JS_STATIC_METHOD(replacePages, CJS_Document);
+ JS_STATIC_METHOD(removeIcon, CJS_Document);
+ JS_STATIC_METHOD(resetForm, CJS_Document);
+ JS_STATIC_METHOD(saveAs, CJS_Document);
+ JS_STATIC_METHOD(submitForm, CJS_Document);
+ JS_STATIC_METHOD(syncAnnotScan, CJS_Document);
+ JS_STATIC_METHOD(mailDoc, CJS_Document);
+
+ private:
+ static int ObjDefnID;
+ static const char kName[];
+ static const JSPropertySpec PropertySpecs[];
+ static const JSMethodSpec MethodSpecs[];
CJS_Return get_ADBE(CJS_Runtime* pRuntime);
CJS_Return set_ADBE(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
@@ -207,15 +302,6 @@ class Document : public CJS_EmbedObj {
CJS_Return removeIcon(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params);
- void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv);
- CPDFSDK_FormFillEnvironment* GetFormFillEnv() const {
- return m_pFormFillEnv.Get();
- }
- void AddDelayData(std::unique_ptr<CJS_DelayData> pData);
- void DoFieldDelay(const WideString& sFieldName, int nControlIndex);
- CJS_Document* GetCJSDoc() const;
-
- private:
bool IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect);
int CountWords(CPDF_TextObject* pTextObj);
WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex);
@@ -234,97 +320,4 @@ class Document : public CJS_EmbedObj {
bool m_bDelay;
};
-class CJS_Document : public CJS_Object {
- public:
- static int GetObjDefnID();
- static void DefineJSObjects(CFXJS_Engine* pEngine);
-
- explicit CJS_Document(v8::Local<v8::Object> pObject);
- ~CJS_Document() override = default;
-
- // CJS_Object
- void InitInstance(IJS_Runtime* pIRuntime) override;
-
- JS_STATIC_PROP(ADBE, ADBE, Document);
- JS_STATIC_PROP(author, author, Document);
- JS_STATIC_PROP(baseURL, base_URL, Document);
- JS_STATIC_PROP(bookmarkRoot, bookmark_root, Document);
- JS_STATIC_PROP(calculate, calculate, Document);
- JS_STATIC_PROP(Collab, collab, Document);
- JS_STATIC_PROP(creationDate, creation_date, Document);
- JS_STATIC_PROP(creator, creator, Document);
- JS_STATIC_PROP(delay, delay, Document);
- JS_STATIC_PROP(dirty, dirty, Document);
- JS_STATIC_PROP(documentFileName, document_file_name, Document);
- JS_STATIC_PROP(external, external, Document);
- JS_STATIC_PROP(filesize, filesize, Document);
- JS_STATIC_PROP(icons, icons, Document);
- JS_STATIC_PROP(info, info, Document);
- JS_STATIC_PROP(keywords, keywords, Document);
- JS_STATIC_PROP(layout, layout, Document);
- JS_STATIC_PROP(media, media, Document);
- JS_STATIC_PROP(modDate, mod_date, Document);
- JS_STATIC_PROP(mouseX, mouse_x, Document);
- JS_STATIC_PROP(mouseY, mouse_y, Document);
- JS_STATIC_PROP(numFields, num_fields, Document);
- JS_STATIC_PROP(numPages, num_pages, Document);
- JS_STATIC_PROP(pageNum, page_num, Document);
- JS_STATIC_PROP(pageWindowRect, page_window_rect, Document);
- JS_STATIC_PROP(path, path, Document);
- JS_STATIC_PROP(producer, producer, Document);
- JS_STATIC_PROP(subject, subject, Document);
- JS_STATIC_PROP(title, title, Document);
- JS_STATIC_PROP(URL, URL, Document);
- JS_STATIC_PROP(zoom, zoom, Document);
- JS_STATIC_PROP(zoomType, zoom_type, Document);
-
- JS_STATIC_METHOD(addAnnot, Document);
- JS_STATIC_METHOD(addField, Document);
- JS_STATIC_METHOD(addLink, Document);
- JS_STATIC_METHOD(addIcon, Document);
- JS_STATIC_METHOD(calculateNow, Document);
- JS_STATIC_METHOD(closeDoc, Document);
- JS_STATIC_METHOD(createDataObject, Document);
- JS_STATIC_METHOD(deletePages, Document);
- JS_STATIC_METHOD(exportAsText, Document);
- JS_STATIC_METHOD(exportAsFDF, Document);
- JS_STATIC_METHOD(exportAsXFDF, Document);
- JS_STATIC_METHOD(extractPages, Document);
- JS_STATIC_METHOD(getAnnot, Document);
- JS_STATIC_METHOD(getAnnots, Document);
- JS_STATIC_METHOD(getAnnot3D, Document);
- JS_STATIC_METHOD(getAnnots3D, Document);
- JS_STATIC_METHOD(getField, Document);
- JS_STATIC_METHOD(getIcon, Document);
- JS_STATIC_METHOD(getLinks, Document);
- JS_STATIC_METHOD(getNthFieldName, Document);
- JS_STATIC_METHOD(getOCGs, Document);
- JS_STATIC_METHOD(getPageBox, Document);
- JS_STATIC_METHOD(getPageNthWord, Document);
- JS_STATIC_METHOD(getPageNthWordQuads, Document);
- JS_STATIC_METHOD(getPageNumWords, Document);
- JS_STATIC_METHOD(getPrintParams, Document);
- JS_STATIC_METHOD(getURL, Document);
- JS_STATIC_METHOD(gotoNamedDest, Document);
- JS_STATIC_METHOD(importAnFDF, Document);
- JS_STATIC_METHOD(importAnXFDF, Document);
- JS_STATIC_METHOD(importTextData, Document);
- JS_STATIC_METHOD(insertPages, Document);
- JS_STATIC_METHOD(mailForm, Document);
- JS_STATIC_METHOD(print, Document);
- JS_STATIC_METHOD(removeField, Document);
- JS_STATIC_METHOD(replacePages, Document);
- JS_STATIC_METHOD(removeIcon, Document);
- JS_STATIC_METHOD(resetForm, Document);
- JS_STATIC_METHOD(saveAs, Document);
- JS_STATIC_METHOD(submitForm, Document);
- JS_STATIC_METHOD(syncAnnotScan, Document);
- JS_STATIC_METHOD(mailDoc, Document);
-
- private:
- static int ObjDefnID;
- static const JSPropertySpec PropertySpecs[];
- static const JSMethodSpec MethodSpecs[];
-};
-
#endif // FXJS_CJS_DOCUMENT_H_
diff --git a/fxjs/cjs_embedobj.cpp b/fxjs/cjs_embedobj.cpp
deleted file mode 100644
index cbebd6311b..0000000000
--- a/fxjs/cjs_embedobj.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2017 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fxjs/cjs_embedobj.h"
-
-#include "fxjs/cjs_object.h"
-
-CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) : m_pJSObject(pJSObject) {}
-
-CJS_EmbedObj::~CJS_EmbedObj() {}
diff --git a/fxjs/cjs_embedobj.h b/fxjs/cjs_embedobj.h
deleted file mode 100644
index 82e549e321..0000000000
--- a/fxjs/cjs_embedobj.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2017 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef FXJS_CJS_EMBEDOBJ_H_
-#define FXJS_CJS_EMBEDOBJ_H_
-
-#include "core/fxcrt/unowned_ptr.h"
-
-class CJS_Object;
-
-class CJS_EmbedObj {
- public:
- explicit CJS_EmbedObj(CJS_Object* pJSObject);
- virtual ~CJS_EmbedObj();
-
- CJS_Object* GetJSObject() const { return m_pJSObject.Get(); }
-
- protected:
- UnownedPtr<CJS_Object> const m_pJSObject;
-};
-
-#endif // FXJS_CJS_EMBEDOBJ_H_
diff --git a/fxjs/cjs_event.cpp b/fxjs/cjs_event.cpp
index 7736f0dda4..341bcc4147 100644
--- a/fxjs/cjs_event.cpp
+++ b/fxjs/cjs_event.cpp
@@ -35,29 +35,27 @@ const JSPropertySpec CJS_Event::PropertySpecs[] = {
{"willCommit", get_will_commit_static, set_will_commit_static}};
int CJS_Event::ObjDefnID = -1;
+const char CJS_Event::kName[] = "event";
// static
void CJS_Event::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("event", FXJSOBJTYPE_STATIC,
+ ObjDefnID = pEngine->DefineObj(CJS_Event::kName, FXJSOBJTYPE_STATIC,
JSConstructor<CJS_Event>, JSDestructor);
DefineProps(pEngine, ObjDefnID, PropertySpecs, FX_ArraySize(PropertySpecs));
}
-CJS_Event::CJS_Event(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<event>(this);
-}
-
-event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {}
+CJS_Event::CJS_Event(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
-event::~event() = default;
+CJS_Event::~CJS_Event() = default;
-CJS_Return event::get_change(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_change(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewString(pEvent->Change().c_str()));
}
-CJS_Return event::set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_change(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -68,31 +66,31 @@ CJS_Return event::set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return event::get_change_ex(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_change_ex(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewString(pEvent->ChangeEx().c_str()));
}
-CJS_Return event::set_change_ex(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_change_ex(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_commit_key(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_commit_key(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewNumber(pEvent->CommitKey()));
}
-CJS_Return event::set_commit_key(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_commit_key(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_field_full(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_field_full(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -102,82 +100,84 @@ CJS_Return event::get_field_full(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewBoolean(pEvent->FieldFull()));
}
-CJS_Return event::set_field_full(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_field_full(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_key_down(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_key_down(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewBoolean(pEvent->KeyDown()));
}
-CJS_Return event::set_key_down(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_key_down(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_modifier(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_modifier(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewBoolean(pEvent->Modifier()));
}
-CJS_Return event::set_modifier(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_modifier(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_name(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_name(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewString(pEvent->Name()));
}
-CJS_Return event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_rc(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_rc(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewBoolean(pEvent->Rc()));
}
-CJS_Return event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_rc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
pEvent->Rc() = pRuntime->ToBoolean(vp);
return CJS_Return(true);
}
-CJS_Return event::get_rich_change(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_rich_change(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return event::set_rich_change(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_rich_change(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return event::get_rich_change_ex(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_rich_change_ex(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return event::set_rich_change_ex(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_rich_change_ex(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return event::get_rich_value(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_rich_value(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return event::set_rich_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_rich_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return event::get_sel_end(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_sel_end(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -187,7 +187,8 @@ CJS_Return event::get_sel_end(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(pEvent->SelEnd()));
}
-CJS_Return event::set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_sel_end(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -198,7 +199,7 @@ CJS_Return event::set_sel_end(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return event::get_sel_start(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_sel_start(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -208,8 +209,8 @@ CJS_Return event::get_sel_start(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(pEvent->SelStart()));
}
-CJS_Return event::set_sel_start(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_sel_start(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -220,58 +221,61 @@ CJS_Return event::set_sel_start(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return event::get_shift(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_shift(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewBoolean(pEvent->Shift()));
}
-CJS_Return event::set_shift(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_shift(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_source(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_source(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pEvent->Source()->GetJSObject()->ToV8Object());
+ return CJS_Return(pEvent->Source()->ToV8Object());
}
-CJS_Return event::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_source(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_target(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_target(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
- return CJS_Return(pEvent->Target_Field()->GetJSObject()->ToV8Object());
+ return CJS_Return(pEvent->Target_Field()->ToV8Object());
}
-CJS_Return event::set_target(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_target(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_target_name(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_target_name(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewString(pEvent->TargetName().c_str()));
}
-CJS_Return event::set_target_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_target_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_type(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_type(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewString(pEvent->Type()));
}
-CJS_Return event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return event::get_value(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_value(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -284,7 +288,8 @@ CJS_Return event::get_value(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(pEvent->Value().c_str()));
}
-CJS_Return event::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
@@ -298,13 +303,13 @@ CJS_Return event::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return event::get_will_commit(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Event::get_will_commit(CJS_Runtime* pRuntime) {
CJS_EventHandler* pEvent =
pRuntime->GetCurrentEventContext()->GetEventHandler();
return CJS_Return(pRuntime->NewBoolean(pEvent->WillCommit()));
}
-CJS_Return event::set_will_commit(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Event::set_will_commit(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
diff --git a/fxjs/cjs_event.h b/fxjs/cjs_event.h
index fa8c40b5ee..291b6eb3cc 100644
--- a/fxjs/cjs_event.h
+++ b/fxjs/cjs_event.h
@@ -9,10 +9,38 @@
#include "fxjs/JS_Define.h"
-class event : public CJS_EmbedObj {
+class CJS_Event : public CJS_Object {
public:
- explicit event(CJS_Object* pJSObject);
- ~event() override;
+ static void DefineJSObjects(CFXJS_Engine* pEngine);
+
+ explicit CJS_Event(v8::Local<v8::Object> pObject);
+ ~CJS_Event() override;
+
+ JS_STATIC_PROP(change, change, CJS_Event);
+ JS_STATIC_PROP(changeEx, change_ex, CJS_Event);
+ JS_STATIC_PROP(commitKey, commit_key, CJS_Event);
+ JS_STATIC_PROP(fieldFull, field_full, CJS_Event);
+ JS_STATIC_PROP(keyDown, key_down, CJS_Event);
+ JS_STATIC_PROP(modifier, modifier, CJS_Event);
+ JS_STATIC_PROP(name, name, CJS_Event);
+ JS_STATIC_PROP(rc, rc, CJS_Event);
+ JS_STATIC_PROP(richChange, rich_change, CJS_Event);
+ JS_STATIC_PROP(richChangeEx, rich_change_ex, CJS_Event);
+ JS_STATIC_PROP(richValue, rich_value, CJS_Event);
+ JS_STATIC_PROP(selEnd, sel_end, CJS_Event);
+ JS_STATIC_PROP(selStart, sel_start, CJS_Event);
+ JS_STATIC_PROP(shift, shift, CJS_Event);
+ JS_STATIC_PROP(source, source, CJS_Event);
+ JS_STATIC_PROP(target, target, CJS_Event);
+ JS_STATIC_PROP(targetName, target_name, CJS_Event);
+ JS_STATIC_PROP(type, type, CJS_Event);
+ JS_STATIC_PROP(value, value, CJS_Event);
+ JS_STATIC_PROP(willCommit, will_commit, CJS_Event);
+
+ private:
+ static int ObjDefnID;
+ static const char kName[];
+ static const JSPropertySpec PropertySpecs[];
CJS_Return get_change(CJS_Runtime* pRuntime);
CJS_Return set_change(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
@@ -75,37 +103,4 @@ class event : public CJS_EmbedObj {
CJS_Return set_will_commit(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
};
-class CJS_Event : public CJS_Object {
- public:
- static void DefineJSObjects(CFXJS_Engine* pEngine);
-
- explicit CJS_Event(v8::Local<v8::Object> pObject);
- ~CJS_Event() override = default;
-
- JS_STATIC_PROP(change, change, event);
- JS_STATIC_PROP(changeEx, change_ex, event);
- JS_STATIC_PROP(commitKey, commit_key, event);
- JS_STATIC_PROP(fieldFull, field_full, event);
- JS_STATIC_PROP(keyDown, key_down, event);
- JS_STATIC_PROP(modifier, modifier, event);
- JS_STATIC_PROP(name, name, event);
- JS_STATIC_PROP(rc, rc, event);
- JS_STATIC_PROP(richChange, rich_change, event);
- JS_STATIC_PROP(richChangeEx, rich_change_ex, event);
- JS_STATIC_PROP(richValue, rich_value, event);
- JS_STATIC_PROP(selEnd, sel_end, event);
- JS_STATIC_PROP(selStart, sel_start, event);
- JS_STATIC_PROP(shift, shift, event);
- JS_STATIC_PROP(source, source, event);
- JS_STATIC_PROP(target, target, event);
- JS_STATIC_PROP(targetName, target_name, event);
- JS_STATIC_PROP(type, type, event);
- JS_STATIC_PROP(value, value, event);
- JS_STATIC_PROP(willCommit, will_commit, event);
-
- private:
- static int ObjDefnID;
- static const JSPropertySpec PropertySpecs[];
-};
-
#endif // FXJS_CJS_EVENT_H_
diff --git a/fxjs/cjs_eventhandler.cpp b/fxjs/cjs_eventhandler.cpp
index eb150b247b..6e7e840250 100644
--- a/fxjs/cjs_eventhandler.cpp
+++ b/fxjs/cjs_eventhandler.cpp
@@ -587,7 +587,7 @@ bool CJS_EventHandler::Shift() const {
return m_bShift;
}
-Field* CJS_EventHandler::Source() {
+CJS_Field* CJS_EventHandler::Source() {
CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
v8::Local<v8::Object> pDocObj =
pRuntime->NewFxDynamicObj(CJS_Document::GetObjDefnID());
@@ -604,17 +604,15 @@ Field* CJS_EventHandler::Source() {
CJS_Field* pJSField =
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
- Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject());
- pDocument->SetFormFillEnv(m_pTargetFormFillEnv
- ? m_pTargetFormFillEnv.Get()
- : m_pJSEventContext->GetFormFillEnv());
+ pJSDocument->SetFormFillEnv(m_pTargetFormFillEnv
+ ? m_pTargetFormFillEnv.Get()
+ : m_pJSEventContext->GetFormFillEnv());
- Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
- pField->AttachField(pDocument, m_strSourceName);
- return pField;
+ pJSField->AttachField(pJSDocument, m_strSourceName);
+ return pJSField;
}
-Field* CJS_EventHandler::Target_Field() {
+CJS_Field* CJS_EventHandler::Target_Field() {
CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
v8::Local<v8::Object> pDocObj =
pRuntime->NewFxDynamicObj(CJS_Document::GetObjDefnID());
@@ -631,14 +629,12 @@ Field* CJS_EventHandler::Target_Field() {
CJS_Field* pJSField =
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
- Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject());
- pDocument->SetFormFillEnv(m_pTargetFormFillEnv
- ? m_pTargetFormFillEnv.Get()
- : m_pJSEventContext->GetFormFillEnv());
+ pJSDocument->SetFormFillEnv(m_pTargetFormFillEnv
+ ? m_pTargetFormFillEnv.Get()
+ : m_pJSEventContext->GetFormFillEnv());
- Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
- pField->AttachField(pDocument, m_strTargetName);
- return pField;
+ pJSField->AttachField(pJSDocument, m_strTargetName);
+ return pJSField;
}
WideString& CJS_EventHandler::Value() {
diff --git a/fxjs/cjs_eventhandler.h b/fxjs/cjs_eventhandler.h
index 87ce1dcca0..4087355405 100644
--- a/fxjs/cjs_eventhandler.h
+++ b/fxjs/cjs_eventhandler.h
@@ -13,10 +13,10 @@
#include "fpdfsdk/cpdfsdk_formfillenvironment.h"
class CJS_EventContext;
+class CJS_Field;
class CPDFSDK_Annot;
class CPDF_Bookmark;
class CPDF_FormField;
-class Field;
enum JS_EVENT_T {
JET_UNKNOWN,
@@ -158,8 +158,8 @@ class CJS_EventHandler {
void SetSelEnd(int value);
void SetSelStart(int value);
bool Shift() const;
- Field* Source();
- Field* Target_Field();
+ CJS_Field* Source();
+ CJS_Field* Target_Field();
WideString& Value();
bool WillCommit() const;
const WideString& TargetName() const;
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 7882a85c80..9138d93590 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -156,6 +156,7 @@ const JSMethodSpec CJS_Field::MethodSpecs[] = {
{"signatureValidate", signatureValidate_static}};
int CJS_Field::ObjDefnID = -1;
+const char CJS_Field::kName[] = "Field";
// static
int CJS_Field::GetObjDefnID() {
@@ -164,32 +165,28 @@ int CJS_Field::GetObjDefnID() {
// static
void CJS_Field::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("Field", FXJSOBJTYPE_DYNAMIC,
+ ObjDefnID = pEngine->DefineObj(CJS_Field::kName, FXJSOBJTYPE_DYNAMIC,
JSConstructor<CJS_Field>, JSDestructor);
DefineProps(pEngine, ObjDefnID, PropertySpecs, FX_ArraySize(PropertySpecs));
DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
}
-CJS_Field::CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<Field>(this);
-}
-
-void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) {}
-
-Field::Field(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject),
+CJS_Field::CJS_Field(v8::Local<v8::Object> pObject)
+ : CJS_Object(pObject),
m_pJSDoc(nullptr),
m_pFormFillEnv(nullptr),
m_nFormControlIndex(-1),
m_bCanSet(false),
m_bDelay(false) {}
-Field::~Field() = default;
+CJS_Field::~CJS_Field() = default;
+
+void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) {}
// note: iControlNo = -1, means not a widget.
-void Field::ParseFieldName(const std::wstring& strFieldNameParsed,
- std::wstring& strFieldName,
- int& iControlNo) {
+void CJS_Field::ParseFieldName(const std::wstring& strFieldNameParsed,
+ std::wstring& strFieldName,
+ int& iControlNo) {
int iStart = strFieldNameParsed.find_last_of(L'.');
if (iStart == -1) {
strFieldName = strFieldNameParsed;
@@ -213,7 +210,8 @@ void Field::ParseFieldName(const std::wstring& strFieldNameParsed,
strFieldName = strFieldNameParsed.substr(0, iStart);
}
-bool Field::AttachField(Document* pDocument, const WideString& csFieldName) {
+bool CJS_Field::AttachField(CJS_Document* pDocument,
+ const WideString& csFieldName) {
m_pJSDoc = pDocument;
m_pFormFillEnv.Reset(pDocument->GetFormFillEnv());
m_bCanSet = m_pFormFillEnv->GetPermissions(FPDFPERM_FILL_FORM) ||
@@ -243,7 +241,7 @@ bool Field::AttachField(Document* pDocument, const WideString& csFieldName) {
return true;
}
-std::vector<CPDF_FormField*> Field::GetFormFields(
+std::vector<CPDF_FormField*> CJS_Field::GetFormFields(
CPDFSDK_FormFillEnvironment* pFormFillEnv,
const WideString& csFieldName) {
std::vector<CPDF_FormField*> fields;
@@ -256,16 +254,16 @@ std::vector<CPDF_FormField*> Field::GetFormFields(
return fields;
}
-std::vector<CPDF_FormField*> Field::GetFormFields(
+std::vector<CPDF_FormField*> CJS_Field::GetFormFields(
const WideString& csFieldName) const {
- return Field::GetFormFields(m_pFormFillEnv.Get(), csFieldName);
+ return CJS_Field::GetFormFields(m_pFormFillEnv.Get(), csFieldName);
}
-void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormField* pFormField,
- bool bChangeMark,
- bool bResetAP,
- bool bRefresh) {
+void CJS_Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_FormField* pFormField,
+ bool bChangeMark,
+ bool bResetAP,
+ bool bRefresh) {
CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
if (bResetAP) {
@@ -319,11 +317,11 @@ void Field::UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
pFormFillEnv->SetChangeMark();
}
-void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormControl* pFormControl,
- bool bChangeMark,
- bool bResetAP,
- bool bRefresh) {
+void CJS_Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_FormControl* pFormControl,
+ bool bChangeMark,
+ bool bResetAP,
+ bool bRefresh) {
ASSERT(pFormControl);
CPDFSDK_InterForm* pForm = pFormFillEnv->GetInterForm();
@@ -357,14 +355,15 @@ void Field::UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
pFormFillEnv->SetChangeMark();
}
-CPDFSDK_Widget* Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormControl* pFormControl) {
+CPDFSDK_Widget* CJS_Field::GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_FormControl* pFormControl) {
CPDFSDK_InterForm* pInterForm =
static_cast<CPDFSDK_InterForm*>(pFormFillEnv->GetInterForm());
return pInterForm ? pInterForm->GetWidget(pFormControl) : nullptr;
}
-bool Field::ValueIsOccur(CPDF_FormField* pFormField, WideString csOptLabel) {
+bool CJS_Field::ValueIsOccur(CPDF_FormField* pFormField,
+ WideString csOptLabel) {
for (int i = 0, sz = pFormField->CountOptions(); i < sz; i++) {
if (csOptLabel.Compare(pFormField->GetOptionLabel(i)) == 0)
return true;
@@ -373,7 +372,7 @@ bool Field::ValueIsOccur(CPDF_FormField* pFormField, WideString csOptLabel) {
return false;
}
-CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) {
+CPDF_FormControl* CJS_Field::GetSmartFieldControl(CPDF_FormField* pFormField) {
if (!pFormField->CountControls() ||
m_nFormControlIndex >= pFormField->CountControls())
return nullptr;
@@ -382,7 +381,7 @@ CPDF_FormControl* Field::GetSmartFieldControl(CPDF_FormField* pFormField) {
return pFormField->GetControl(m_nFormControlIndex);
}
-CJS_Return Field::get_alignment(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_alignment(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -408,13 +407,13 @@ CJS_Return Field::get_alignment(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(L""));
}
-CJS_Return Field::set_alignment(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_alignment(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_border_style(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_border_style(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -445,8 +444,8 @@ CJS_Return Field::get_border_style(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(L""));
}
-CJS_Return Field::set_border_style(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_border_style(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
@@ -456,16 +455,16 @@ CJS_Return Field::set_border_style(CJS_Runtime* pRuntime,
if (m_bDelay) {
AddDelay_String(FP_BORDERSTYLE, byte_str);
} else {
- Field::SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName,
- m_nFormControlIndex, byte_str);
+ CJS_Field::SetBorderStyle(m_pFormFillEnv.Get(), m_FieldName,
+ m_nFormControlIndex, byte_str);
}
return CJS_Return(true);
}
-void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- const ByteString& string) {
+void CJS_Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ const ByteString& string) {
ASSERT(pFormFillEnv);
BorderStyle nBorderStyle = BorderStyle::SOLID;
@@ -514,7 +513,7 @@ void Field::SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-CJS_Return Field::get_button_align_x(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_button_align_x(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -538,13 +537,13 @@ CJS_Return Field::get_button_align_x(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fLeft)));
}
-CJS_Return Field::set_button_align_x(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_button_align_x(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_button_align_y(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_button_align_y(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -568,13 +567,13 @@ CJS_Return Field::get_button_align_y(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(static_cast<int32_t>(fBottom)));
}
-CJS_Return Field::set_button_align_y(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_button_align_y(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_button_fit_bounds(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_button_fit_bounds(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -593,13 +592,13 @@ CJS_Return Field::get_button_fit_bounds(CJS_Runtime* pRuntime) {
pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds()));
}
-CJS_Return Field::set_button_fit_bounds(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_button_fit_bounds(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_button_position(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_button_position(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -617,13 +616,13 @@ CJS_Return Field::get_button_position(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(pFormControl->GetTextPosition()));
}
-CJS_Return Field::set_button_position(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_button_position(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_button_scale_how(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_button_scale_how(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -642,13 +641,13 @@ CJS_Return Field::get_button_scale_how(CJS_Runtime* pRuntime) {
pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1));
}
-CJS_Return Field::set_button_scale_how(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_button_scale_how(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_button_scale_when(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_button_scale_when(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -682,13 +681,13 @@ CJS_Return Field::get_button_scale_when(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Field::set_button_scale_when(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_button_scale_when(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_calc_order_index(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_calc_order_index(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -707,13 +706,13 @@ CJS_Return Field::get_calc_order_index(CJS_Runtime* pRuntime) {
pInterForm->FindFieldInCalculationOrder(pFormField))));
}
-CJS_Return Field::set_calc_order_index(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_calc_order_index(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_char_limit(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_char_limit(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -727,13 +726,13 @@ CJS_Return Field::get_char_limit(CJS_Runtime* pRuntime) {
pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen())));
}
-CJS_Return Field::set_char_limit(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_char_limit(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_comb(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_comb(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -748,12 +747,12 @@ CJS_Return Field::get_comb(CJS_Runtime* pRuntime) {
pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB)));
}
-CJS_Return Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -770,13 +769,13 @@ CJS_Return Field::get_commit_on_sel_change(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)));
}
-CJS_Return Field::set_commit_on_sel_change(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_commit_on_sel_change(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_current_value_indices(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_current_value_indices(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -803,8 +802,8 @@ CJS_Return Field::get_current_value_indices(CJS_Runtime* pRuntime) {
return CJS_Return(SelArray);
}
-CJS_Return Field::set_current_value_indices(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_current_value_indices(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
@@ -822,16 +821,17 @@ CJS_Return Field::set_current_value_indices(CJS_Runtime* pRuntime,
if (m_bDelay) {
AddDelay_WordArray(FP_CURRENTVALUEINDICES, array);
} else {
- Field::SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName,
- m_nFormControlIndex, array);
+ CJS_Field::SetCurrentValueIndices(m_pFormFillEnv.Get(), m_FieldName,
+ m_nFormControlIndex, array);
}
return CJS_Return(true);
}
-void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- const std::vector<uint32_t>& array) {
+void CJS_Field::SetCurrentValueIndices(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ const std::vector<uint32_t>& array) {
ASSERT(pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray =
GetFormFields(pFormFillEnv, swFieldName);
@@ -855,16 +855,16 @@ void Field::SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-CJS_Return Field::get_default_style(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_default_style(CJS_Runtime* pRuntime) {
return CJS_Return(false);
}
-CJS_Return Field::set_default_style(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_default_style(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return Field::get_default_value(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_default_value(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -880,13 +880,13 @@ CJS_Return Field::get_default_value(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(pFormField->GetDefaultValue().c_str()));
}
-CJS_Return Field::set_default_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_default_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_do_not_scroll(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_do_not_scroll(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -901,13 +901,13 @@ CJS_Return Field::get_do_not_scroll(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)));
}
-CJS_Return Field::set_do_not_scroll(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_do_not_scroll(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_do_not_spell_check(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_do_not_spell_check(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -924,13 +924,13 @@ CJS_Return Field::get_do_not_spell_check(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)));
}
-CJS_Return Field::set_do_not_spell_check(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_do_not_spell_check(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-void Field::SetDelay(bool bDelay) {
+void CJS_Field::SetDelay(bool bDelay) {
m_bDelay = bDelay;
if (m_bDelay)
@@ -939,11 +939,12 @@ void Field::SetDelay(bool bDelay) {
m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex);
}
-CJS_Return Field::get_delay(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_delay(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewBoolean(m_bDelay));
}
-CJS_Return Field::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_delay(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
@@ -951,7 +952,7 @@ CJS_Return Field::set_delay(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Field::get_display(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_display(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -977,23 +978,24 @@ CJS_Return Field::get_display(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(2));
}
-CJS_Return Field::set_display(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_display(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
if (m_bDelay) {
AddDelay_Int(FP_DISPLAY, pRuntime->ToInt32(vp));
} else {
- Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
- pRuntime->ToInt32(vp));
+ CJS_Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName,
+ m_nFormControlIndex, pRuntime->ToInt32(vp));
}
return CJS_Return(true);
}
-void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- int number) {
+void CJS_Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ int number) {
CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray =
GetFormFields(pFormFillEnv, swFieldName);
@@ -1026,15 +1028,15 @@ void Field::SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-CJS_Return Field::get_doc(CJS_Runtime* pRuntime) {
- return CJS_Return(m_pJSDoc->GetCJSDoc()->ToV8Object());
+CJS_Return CJS_Field::get_doc(CJS_Runtime* pRuntime) {
+ return CJS_Return(m_pJSDoc->ToV8Object());
}
-CJS_Return Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_doc(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return Field::get_editable(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_editable(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1047,11 +1049,12 @@ CJS_Return Field::get_editable(CJS_Runtime* pRuntime) {
pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT)));
}
-CJS_Return Field::set_editable(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_editable(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_export_values(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_export_values(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1086,8 +1089,8 @@ CJS_Return Field::get_export_values(CJS_Runtime* pRuntime) {
return CJS_Return(ExportValuesArray);
}
-CJS_Return Field::set_export_values(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_export_values(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1101,7 +1104,7 @@ CJS_Return Field::set_export_values(CJS_Runtime* pRuntime,
return CJS_Return(m_bCanSet && !vp.IsEmpty() && vp->IsArray());
}
-CJS_Return Field::get_file_select(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_file_select(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1114,8 +1117,8 @@ CJS_Return Field::get_file_select(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)));
}
-CJS_Return Field::set_file_select(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_file_select(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1126,7 +1129,7 @@ CJS_Return Field::set_file_select(CJS_Runtime* pRuntime,
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_fill_color(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_fill_color(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1161,14 +1164,15 @@ CJS_Return Field::get_fill_color(CJS_Runtime* pRuntime) {
return CJS_Return(false);
}
- v8::Local<v8::Value> array = color::ConvertPWLColorToArray(pRuntime, color);
+ v8::Local<v8::Value> array =
+ CJS_Color::ConvertPWLColorToArray(pRuntime, color);
if (array.IsEmpty())
return CJS_Return(pRuntime->NewArray());
return CJS_Return(array);
}
-CJS_Return Field::set_fill_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_fill_color(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1179,7 +1183,7 @@ CJS_Return Field::set_fill_color(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Field::get_hidden(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_hidden(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1198,28 +1202,29 @@ CJS_Return Field::get_hidden(CJS_Runtime* pRuntime) {
ANNOTFLAG_HIDDEN & dwFlags));
}
-CJS_Return Field::set_hidden(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_hidden(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
if (m_bDelay) {
AddDelay_Bool(FP_HIDDEN, pRuntime->ToBoolean(vp));
} else {
- Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
- pRuntime->ToBoolean(vp));
+ CJS_Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
+ pRuntime->ToBoolean(vp));
}
return CJS_Return(true);
}
-void Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- bool b) {
+void CJS_Field::SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ bool b) {
int display = b ? 1 /*Hidden*/ : 0 /*Visible*/;
SetDisplay(pFormFillEnv, swFieldName, nControlIndex, display);
}
-CJS_Return Field::get_highlight(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_highlight(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1250,13 +1255,13 @@ CJS_Return Field::get_highlight(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Field::set_highlight(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_highlight(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_line_width(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_line_width(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1279,24 +1284,24 @@ CJS_Return Field::get_line_width(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(pWidget->GetBorderWidth()));
}
-CJS_Return Field::set_line_width(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_line_width(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
if (m_bDelay) {
AddDelay_Int(FP_LINEWIDTH, pRuntime->ToInt32(vp));
} else {
- Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
- pRuntime->ToInt32(vp));
+ CJS_Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName,
+ m_nFormControlIndex, pRuntime->ToInt32(vp));
}
return CJS_Return(true);
}
-void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- int number) {
+void CJS_Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ int number) {
CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray =
GetFormFields(pFormFillEnv, swFieldName);
@@ -1332,7 +1337,7 @@ void Field::SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-CJS_Return Field::get_multiline(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_multiline(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1347,13 +1352,13 @@ CJS_Return Field::get_multiline(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)));
}
-CJS_Return Field::set_multiline(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_multiline(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_multiple_selection(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_multiple_selection(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
@@ -1367,13 +1372,13 @@ CJS_Return Field::get_multiple_selection(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)));
}
-CJS_Return Field::set_multiple_selection(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_multiple_selection(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_name(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_name(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1381,11 +1386,11 @@ CJS_Return Field::get_name(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(m_FieldName.c_str()));
}
-CJS_Return Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return Field::get_num_items(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_num_items(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1399,12 +1404,12 @@ CJS_Return Field::get_num_items(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(pFormField->CountOptions()));
}
-CJS_Return Field::set_num_items(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_num_items(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return Field::get_page(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_page(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1437,11 +1442,11 @@ CJS_Return Field::get_page(CJS_Runtime* pRuntime) {
return CJS_Return(PageArray);
}
-CJS_Return Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_page(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(JSGetStringFromID(JSMessage::kReadOnlyError));
}
-CJS_Return Field::get_password(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_password(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1456,12 +1461,13 @@ CJS_Return Field::get_password(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)));
}
-CJS_Return Field::set_password(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_password(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_print(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_print(CJS_Runtime* pRuntime) {
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
@@ -1477,7 +1483,8 @@ CJS_Return Field::get_print(CJS_Runtime* pRuntime) {
pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT)));
}
-CJS_Return Field::set_print(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_print(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
@@ -1535,7 +1542,7 @@ CJS_Return Field::set_print(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Field::get_radios_in_unison(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_radios_in_unison(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1548,15 +1555,15 @@ CJS_Return Field::get_radios_in_unison(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)));
}
-CJS_Return Field::set_radios_in_unison(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_radios_in_unison(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_readonly(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_readonly(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1565,14 +1572,15 @@ CJS_Return Field::get_readonly(CJS_Runtime* pRuntime) {
!!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY)));
}
-CJS_Return Field::set_readonly(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_readonly(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_rect(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_rect(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1598,7 +1606,7 @@ CJS_Return Field::get_rect(CJS_Runtime* pRuntime) {
return CJS_Return(rcArray);
}
-CJS_Return Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
if (vp.IsEmpty() || !vp->IsArray())
@@ -1622,16 +1630,16 @@ CJS_Return Field::set_rect(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (m_bDelay) {
AddDelay_Rect(FP_RECT, crRect);
} else {
- Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
- crRect);
+ CJS_Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
+ crRect);
}
return CJS_Return(true);
}
-void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- const CFX_FloatRect& rect) {
+void CJS_Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ const CFX_FloatRect& rect) {
CPDFSDK_InterForm* pInterForm = pFormFillEnv->GetInterForm();
std::vector<CPDF_FormField*> FieldArray =
GetFormFields(pFormFillEnv, swFieldName);
@@ -1688,7 +1696,7 @@ void Field::SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-CJS_Return Field::get_required(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_required(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1701,14 +1709,15 @@ CJS_Return Field::get_required(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)));
}
-CJS_Return Field::set_required(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_required(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_rich_text(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_rich_text(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1723,22 +1732,22 @@ CJS_Return Field::get_rich_text(CJS_Runtime* pRuntime) {
!!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)));
}
-CJS_Return Field::set_rich_text(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_rich_text(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_rich_value(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_rich_value(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Field::set_rich_value(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_rich_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Field::get_rotation(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_rotation(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1753,12 +1762,13 @@ CJS_Return Field::get_rotation(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(pFormControl->GetRotation()));
}
-CJS_Return Field::set_rotation(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_rotation(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_stroke_color(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_stroke_color(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1790,14 +1800,15 @@ CJS_Return Field::get_stroke_color(CJS_Runtime* pRuntime) {
return CJS_Return(false);
}
- v8::Local<v8::Value> array = color::ConvertPWLColorToArray(pRuntime, color);
+ v8::Local<v8::Value> array =
+ CJS_Color::ConvertPWLColorToArray(pRuntime, color);
if (array.IsEmpty())
return CJS_Return(pRuntime->NewArray());
return CJS_Return(array);
}
-CJS_Return Field::set_stroke_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_stroke_color(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
if (vp.IsEmpty() || !vp->IsArray())
@@ -1805,7 +1816,7 @@ CJS_Return Field::set_stroke_color(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Field::get_style(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_style(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1849,21 +1860,22 @@ CJS_Return Field::get_style(CJS_Runtime* pRuntime) {
pRuntime->NewString(WideString::FromLocal(csBCaption.c_str()).c_str()));
}
-CJS_Return Field::set_style(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_style(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_submit_name(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_submit_name(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Field::set_submit_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_submit_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-CJS_Return Field::get_text_color(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_text_color(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1890,14 +1902,15 @@ CJS_Return Field::get_text_color(CJS_Runtime* pRuntime) {
if (iColorType == CFX_Color::kTransparent)
crRet = CFX_Color(CFX_Color::kTransparent);
- v8::Local<v8::Value> array = color::ConvertPWLColorToArray(pRuntime, crRet);
+ v8::Local<v8::Value> array =
+ CJS_Color::ConvertPWLColorToArray(pRuntime, crRet);
if (array.IsEmpty())
return CJS_Return(pRuntime->NewArray());
return CJS_Return(array);
}
-CJS_Return Field::set_text_color(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_text_color(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
if (vp.IsEmpty() || !vp->IsArray())
@@ -1905,7 +1918,7 @@ CJS_Return Field::set_text_color(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Field::get_text_font(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_text_font(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1934,8 +1947,8 @@ CJS_Return Field::get_text_font(CJS_Runtime* pRuntime) {
WideString::FromLocal(pFont->GetBaseFont().c_str()).c_str()));
}
-CJS_Return Field::set_text_font(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_text_font(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
if (!m_bCanSet)
@@ -1944,7 +1957,7 @@ CJS_Return Field::set_text_font(CJS_Runtime* pRuntime,
!ByteString::FromUnicode(pRuntime->ToWideString(vp)).IsEmpty());
}
-CJS_Return Field::get_text_size(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_text_size(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1963,13 +1976,13 @@ CJS_Return Field::get_text_size(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewNumber(static_cast<int>(fFontSize)));
}
-CJS_Return Field::set_text_size(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_text_size(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_type(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_type(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -1997,11 +2010,11 @@ CJS_Return Field::get_type(CJS_Runtime* pRuntime) {
}
}
-CJS_Return Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_type(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return Field::get_user_name(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_user_name(CJS_Runtime* pRuntime) {
ASSERT(m_pFormFillEnv);
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -2012,13 +2025,13 @@ CJS_Return Field::get_user_name(CJS_Runtime* pRuntime) {
pRuntime->NewString(FieldArray[0]->GetAlternateName().c_str()));
}
-CJS_Return Field::set_user_name(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_user_name(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
ASSERT(m_pFormFillEnv);
return CJS_Return(m_bCanSet);
}
-CJS_Return Field::get_value(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_value(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -2077,7 +2090,8 @@ CJS_Return Field::get_value(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->MaybeCoerceToNumber(ret));
}
-CJS_Return Field::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_value(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
if (!m_bCanSet)
return CJS_Return(false);
@@ -2095,16 +2109,16 @@ CJS_Return Field::set_value(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
if (m_bDelay) {
AddDelay_WideStringArray(FP_VALUE, strArray);
} else {
- Field::SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
- strArray);
+ CJS_Field::SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
+ strArray);
}
return CJS_Return(true);
}
-void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- const std::vector<WideString>& strArray) {
+void CJS_Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ const std::vector<WideString>& strArray) {
ASSERT(pFormFillEnv);
if (strArray.empty())
return;
@@ -2156,7 +2170,7 @@ void Field::SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
}
}
-CJS_Return Field::get_value_as_string(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_value_as_string(CJS_Runtime* pRuntime) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -2190,12 +2204,12 @@ CJS_Return Field::get_value_as_string(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(pFormField->GetValue().c_str()));
}
-CJS_Return Field::set_value_as_string(CJS_Runtime* pRuntime,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_value_as_string(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
-CJS_Return Field::browseForFileToSubmit(
+CJS_Return CJS_Field::browseForFileToSubmit(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -2215,7 +2229,7 @@ CJS_Return Field::browseForFileToSubmit(
return CJS_Return(false);
}
-CJS_Return Field::buttonGetCaption(
+CJS_Return CJS_Field::buttonGetCaption(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
int nface = 0;
@@ -2248,7 +2262,7 @@ CJS_Return Field::buttonGetCaption(
return CJS_Return(false);
}
-CJS_Return Field::buttonGetIcon(
+CJS_Return CJS_Field::buttonGetIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() >= 1) {
@@ -2280,25 +2294,25 @@ CJS_Return Field::buttonGetIcon(
return CJS_Return(pJS_Icon->ToV8Object());
}
-CJS_Return Field::buttonImportIcon(
+CJS_Return CJS_Field::buttonImportIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Field::buttonSetCaption(
+CJS_Return CJS_Field::buttonSetCaption(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::buttonSetIcon(
+CJS_Return CJS_Field::buttonSetIcon(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::checkThisBox(
+CJS_Return CJS_Field::checkThisBox(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
@@ -2333,12 +2347,13 @@ CJS_Return Field::checkThisBox(
return CJS_Return(true);
}
-CJS_Return Field::clearItems(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Field::clearItems(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Field::defaultIsChecked(
+CJS_Return CJS_Field::defaultIsChecked(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (!m_bCanSet)
@@ -2362,14 +2377,15 @@ CJS_Return Field::defaultIsChecked(
pFormField->GetFieldType() == FormFieldType::kRadioButton));
}
-CJS_Return Field::deleteItemAt(
+CJS_Return CJS_Field::deleteItemAt(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Field::getArray(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Field::getArray(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -2394,8 +2410,7 @@ CJS_Return Field::getArray(CJS_Runtime* pRuntime,
CJS_Field* pJSField =
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pObj));
- Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
- pField->AttachField(m_pJSDoc, *pStr);
+ pJSField->AttachField(m_pJSDoc, *pStr);
pRuntime->PutArrayElement(FormFieldArray, j++,
pJSField
? v8::Local<v8::Value>(pJSField->ToV8Object())
@@ -2404,8 +2419,9 @@ CJS_Return Field::getArray(CJS_Runtime* pRuntime,
return CJS_Return(FormFieldArray);
}
-CJS_Return Field::getItemAt(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Field::getItemAt(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
int iSize = params.size();
int nIdx = -1;
if (iSize >= 1)
@@ -2438,18 +2454,18 @@ CJS_Return Field::getItemAt(CJS_Runtime* pRuntime,
return CJS_Return(false);
}
-CJS_Return Field::getLock(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Field::getLock(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::insertItemAt(
+CJS_Return CJS_Field::insertItemAt(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Field::isBoxChecked(
+CJS_Return CJS_Field::isBoxChecked(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
int nIndex = -1;
@@ -2470,7 +2486,7 @@ CJS_Return Field::isBoxChecked(
pFormField->GetControl(nIndex)->IsChecked() != 0)));
}
-CJS_Return Field::isDefaultChecked(
+CJS_Return CJS_Field::isDefaultChecked(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
int nIndex = -1;
@@ -2491,13 +2507,15 @@ CJS_Return Field::isDefaultChecked(
pFormField->GetControl(nIndex)->IsDefaultChecked() != 0)));
}
-CJS_Return Field::setAction(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Field::setAction(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Field::setFocus(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Field::setFocus(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
if (FieldArray.empty())
return CJS_Return(false);
@@ -2539,135 +2557,137 @@ CJS_Return Field::setFocus(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return Field::setItems(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Field::setItems(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(true);
}
-CJS_Return Field::setLock(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Field::setLock(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::signatureGetModifications(
+CJS_Return CJS_Field::signatureGetModifications(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::signatureGetSeedValue(
+CJS_Return CJS_Field::signatureGetSeedValue(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::signatureInfo(
+CJS_Return CJS_Field::signatureInfo(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::signatureSetSeedValue(
+CJS_Return CJS_Field::signatureSetSeedValue(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::signatureSign(
+CJS_Return CJS_Field::signatureSign(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::signatureValidate(
+CJS_Return CJS_Field::signatureValidate(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
return CJS_Return(false);
}
-CJS_Return Field::get_source(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Field::get_source(CJS_Runtime* pRuntime) {
return CJS_Return(true);
}
-CJS_Return Field::set_source(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Field::set_source(CJS_Runtime* pRuntime,
+ v8::Local<v8::Value> vp) {
return CJS_Return(true);
}
-void Field::AddDelay_Int(FIELD_PROP prop, int32_t n) {
+void CJS_Field::AddDelay_Int(FIELD_PROP prop, int32_t n) {
auto pNewData =
pdfium::MakeUnique<CJS_DelayData>(prop, m_nFormControlIndex, m_FieldName);
pNewData->num = n;
m_pJSDoc->AddDelayData(std::move(pNewData));
}
-void Field::AddDelay_Bool(FIELD_PROP prop, bool b) {
+void CJS_Field::AddDelay_Bool(FIELD_PROP prop, bool b) {
auto pNewData =
pdfium::MakeUnique<CJS_DelayData>(prop, m_nFormControlIndex, m_FieldName);
pNewData->b = b;
m_pJSDoc->AddDelayData(std::move(pNewData));
}
-void Field::AddDelay_String(FIELD_PROP prop, const ByteString& string) {
+void CJS_Field::AddDelay_String(FIELD_PROP prop, const ByteString& string) {
auto pNewData =
pdfium::MakeUnique<CJS_DelayData>(prop, m_nFormControlIndex, m_FieldName);
pNewData->string = string;
m_pJSDoc->AddDelayData(std::move(pNewData));
}
-void Field::AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect) {
+void CJS_Field::AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect) {
auto pNewData =
pdfium::MakeUnique<CJS_DelayData>(prop, m_nFormControlIndex, m_FieldName);
pNewData->rect = rect;
m_pJSDoc->AddDelayData(std::move(pNewData));
}
-void Field::AddDelay_WordArray(FIELD_PROP prop,
- const std::vector<uint32_t>& array) {
+void CJS_Field::AddDelay_WordArray(FIELD_PROP prop,
+ const std::vector<uint32_t>& array) {
auto pNewData =
pdfium::MakeUnique<CJS_DelayData>(prop, m_nFormControlIndex, m_FieldName);
pNewData->wordarray = array;
m_pJSDoc->AddDelayData(std::move(pNewData));
}
-void Field::AddDelay_WideStringArray(FIELD_PROP prop,
- const std::vector<WideString>& array) {
+void CJS_Field::AddDelay_WideStringArray(FIELD_PROP prop,
+ const std::vector<WideString>& array) {
auto pNewData =
pdfium::MakeUnique<CJS_DelayData>(prop, m_nFormControlIndex, m_FieldName);
pNewData->widestringarray = array;
m_pJSDoc->AddDelayData(std::move(pNewData));
}
-void Field::DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CJS_DelayData* pData) {
+void CJS_Field::DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CJS_DelayData* pData) {
ASSERT(pFormFillEnv);
switch (pData->eProp) {
case FP_BORDERSTYLE:
- Field::SetBorderStyle(pFormFillEnv, pData->sFieldName,
- pData->nControlIndex, pData->string);
+ CJS_Field::SetBorderStyle(pFormFillEnv, pData->sFieldName,
+ pData->nControlIndex, pData->string);
break;
case FP_CURRENTVALUEINDICES:
- Field::SetCurrentValueIndices(pFormFillEnv, pData->sFieldName,
- pData->nControlIndex, pData->wordarray);
+ CJS_Field::SetCurrentValueIndices(pFormFillEnv, pData->sFieldName,
+ pData->nControlIndex, pData->wordarray);
break;
case FP_DISPLAY:
- Field::SetDisplay(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
- pData->num);
+ CJS_Field::SetDisplay(pFormFillEnv, pData->sFieldName,
+ pData->nControlIndex, pData->num);
break;
case FP_HIDDEN:
- Field::SetHidden(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
- pData->b);
+ CJS_Field::SetHidden(pFormFillEnv, pData->sFieldName,
+ pData->nControlIndex, pData->b);
break;
case FP_LINEWIDTH:
- Field::SetLineWidth(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
- pData->num);
+ CJS_Field::SetLineWidth(pFormFillEnv, pData->sFieldName,
+ pData->nControlIndex, pData->num);
break;
case FP_RECT:
- Field::SetRect(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
- pData->rect);
+ CJS_Field::SetRect(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
+ pData->rect);
break;
case FP_VALUE:
- Field::SetValue(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
- pData->widestringarray);
+ CJS_Field::SetValue(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
+ pData->widestringarray);
break;
default:
NOTREACHED();
diff --git a/fxjs/cjs_field.h b/fxjs/cjs_field.h
index 7c470f5a04..51cc530efa 100644
--- a/fxjs/cjs_field.h
+++ b/fxjs/cjs_field.h
@@ -14,7 +14,7 @@
class CPDF_FormControl;
class CPDFSDK_Widget;
-class Document;
+class CJS_Document;
struct CJS_DelayData;
enum FIELD_PROP {
@@ -27,13 +27,159 @@ enum FIELD_PROP {
FP_VALUE
};
-class Field : public CJS_EmbedObj {
+class CJS_Field : public CJS_Object {
public:
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine);
static void DoDelay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CJS_DelayData* pData);
- explicit Field(CJS_Object* pJSObject);
- ~Field() override;
+ explicit CJS_Field(v8::Local<v8::Object> pObject);
+ ~CJS_Field() override;
+
+ // CJS_Object
+ void InitInstance(IJS_Runtime* pIRuntime) override;
+
+ bool AttachField(CJS_Document* pDocument, const WideString& csFieldName);
+
+ JS_STATIC_PROP(alignment, alignment, CJS_Field);
+ JS_STATIC_PROP(borderStyle, border_style, CJS_Field);
+ JS_STATIC_PROP(buttonAlignX, button_align_x, CJS_Field);
+ JS_STATIC_PROP(buttonAlignY, button_align_y, CJS_Field);
+ JS_STATIC_PROP(buttonFitBounds, button_fit_bounds, CJS_Field);
+ JS_STATIC_PROP(buttonPosition, button_position, CJS_Field);
+ JS_STATIC_PROP(buttonScaleHow, button_scale_how, CJS_Field);
+ JS_STATIC_PROP(ButtonScaleWhen, button_scale_when, CJS_Field);
+ JS_STATIC_PROP(calcOrderIndex, calc_order_index, CJS_Field);
+ JS_STATIC_PROP(charLimit, char_limit, CJS_Field);
+ JS_STATIC_PROP(comb, comb, CJS_Field);
+ JS_STATIC_PROP(commitOnSelChange, commit_on_sel_change, CJS_Field);
+ JS_STATIC_PROP(currentValueIndices, current_value_indices, CJS_Field);
+ JS_STATIC_PROP(defaultStyle, default_style, CJS_Field);
+ JS_STATIC_PROP(defaultValue, default_value, CJS_Field);
+ JS_STATIC_PROP(doNotScroll, do_not_scroll, CJS_Field);
+ JS_STATIC_PROP(doNotSpellCheck, do_not_spell_check, CJS_Field);
+ JS_STATIC_PROP(delay, delay, CJS_Field);
+ JS_STATIC_PROP(display, display, CJS_Field);
+ JS_STATIC_PROP(doc, doc, CJS_Field);
+ JS_STATIC_PROP(editable, editable, CJS_Field);
+ JS_STATIC_PROP(exportValues, export_values, CJS_Field);
+ JS_STATIC_PROP(fileSelect, file_select, CJS_Field);
+ JS_STATIC_PROP(fillColor, fill_color, CJS_Field);
+ JS_STATIC_PROP(hidden, hidden, CJS_Field);
+ JS_STATIC_PROP(highlight, highlight, CJS_Field);
+ JS_STATIC_PROP(lineWidth, line_width, CJS_Field);
+ JS_STATIC_PROP(multiline, multiline, CJS_Field);
+ JS_STATIC_PROP(multipleSelection, multiple_selection, CJS_Field);
+ JS_STATIC_PROP(name, name, CJS_Field);
+ JS_STATIC_PROP(numItems, num_items, CJS_Field);
+ JS_STATIC_PROP(page, page, CJS_Field);
+ JS_STATIC_PROP(password, password, CJS_Field);
+ JS_STATIC_PROP(print, print, CJS_Field);
+ JS_STATIC_PROP(radiosInUnison, radios_in_unison, CJS_Field);
+ JS_STATIC_PROP(readonly, readonly, CJS_Field);
+ JS_STATIC_PROP(rect, rect, CJS_Field);
+ JS_STATIC_PROP(required, required, CJS_Field);
+ JS_STATIC_PROP(richText, rich_text, CJS_Field);
+ JS_STATIC_PROP(richValue, rich_value, CJS_Field);
+ JS_STATIC_PROP(rotation, rotation, CJS_Field);
+ JS_STATIC_PROP(strokeColor, stroke_color, CJS_Field);
+ JS_STATIC_PROP(style, style, CJS_Field);
+ JS_STATIC_PROP(submitName, submit_name, CJS_Field);
+ JS_STATIC_PROP(textColor, text_color, CJS_Field);
+ JS_STATIC_PROP(textFont, text_font, CJS_Field);
+ JS_STATIC_PROP(textSize, text_size, CJS_Field);
+ JS_STATIC_PROP(type, type, CJS_Field);
+ JS_STATIC_PROP(userName, user_name, CJS_Field);
+ JS_STATIC_PROP(value, value, CJS_Field);
+ JS_STATIC_PROP(valueAsString, value_as_string, CJS_Field);
+ JS_STATIC_PROP(source, source, CJS_Field);
+
+ JS_STATIC_METHOD(browseForFileToSubmit, CJS_Field);
+ JS_STATIC_METHOD(buttonGetCaption, CJS_Field);
+ JS_STATIC_METHOD(buttonGetIcon, CJS_Field);
+ JS_STATIC_METHOD(buttonImportIcon, CJS_Field);
+ JS_STATIC_METHOD(buttonSetCaption, CJS_Field);
+ JS_STATIC_METHOD(buttonSetIcon, CJS_Field);
+ JS_STATIC_METHOD(checkThisBox, CJS_Field);
+ JS_STATIC_METHOD(clearItems, CJS_Field);
+ JS_STATIC_METHOD(defaultIsChecked, CJS_Field);
+ JS_STATIC_METHOD(deleteItemAt, CJS_Field);
+ JS_STATIC_METHOD(getArray, CJS_Field);
+ JS_STATIC_METHOD(getItemAt, CJS_Field);
+ JS_STATIC_METHOD(getLock, CJS_Field);
+ JS_STATIC_METHOD(insertItemAt, CJS_Field);
+ JS_STATIC_METHOD(isBoxChecked, CJS_Field);
+ JS_STATIC_METHOD(isDefaultChecked, CJS_Field);
+ JS_STATIC_METHOD(setAction, CJS_Field);
+ JS_STATIC_METHOD(setFocus, CJS_Field);
+ JS_STATIC_METHOD(setItems, CJS_Field);
+ JS_STATIC_METHOD(setLock, CJS_Field);
+ JS_STATIC_METHOD(signatureGetModifications, CJS_Field);
+ JS_STATIC_METHOD(signatureGetSeedValue, CJS_Field);
+ JS_STATIC_METHOD(signatureInfo, CJS_Field);
+ JS_STATIC_METHOD(signatureSetSeedValue, CJS_Field);
+ JS_STATIC_METHOD(signatureSign, CJS_Field);
+ JS_STATIC_METHOD(signatureValidate, CJS_Field);
+
+ CJS_Return get_text_color(CJS_Runtime* pRuntime);
+ CJS_Return set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ private:
+ static int ObjDefnID;
+ static const char kName[];
+ static const JSPropertySpec PropertySpecs[];
+ static const JSMethodSpec MethodSpecs[];
+
+ static void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ const ByteString& string);
+ static void SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ const std::vector<uint32_t>& array);
+ static void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ int number);
+ static void SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ bool b);
+ static void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ int number);
+ static void SetMultiline(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ bool b);
+ static void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ const CFX_FloatRect& rect);
+ static void SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& swFieldName,
+ int nControlIndex,
+ const std::vector<WideString>& strArray);
+
+ static void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_FormField* pFormField,
+ bool bChangeMark,
+ bool bResetAP,
+ bool bRefresh);
+ static void UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_FormControl* pFormControl,
+ bool bChangeMark,
+ bool bResetAP,
+ bool bRefresh);
+
+ static CPDFSDK_Widget* GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_FormControl* pFormControl);
+ static std::vector<CPDF_FormField*> GetFormFields(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const WideString& csFieldName);
CJS_Return get_alignment(CJS_Runtime* pRuntime);
CJS_Return set_alignment(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
@@ -177,9 +323,6 @@ class Field : public CJS_EmbedObj {
CJS_Return get_submit_name(CJS_Runtime* pRuntime);
CJS_Return set_submit_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
- CJS_Return get_text_color(CJS_Runtime* pRuntime);
- CJS_Return set_text_color(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
-
CJS_Return get_text_font(CJS_Runtime* pRuntime);
CJS_Return set_text_font(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
@@ -259,59 +402,6 @@ class Field : public CJS_EmbedObj {
CJS_Return signatureValidate(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params);
- bool AttachField(Document* pDocument, const WideString& csFieldName);
-
- private:
- static void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- const ByteString& string);
- static void SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- const std::vector<uint32_t>& array);
- static void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- int number);
- static void SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- bool b);
- static void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- int number);
- static void SetMultiline(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- bool b);
- static void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- const CFX_FloatRect& rect);
- static void SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& swFieldName,
- int nControlIndex,
- const std::vector<WideString>& strArray);
-
- static void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormField* pFormField,
- bool bChangeMark,
- bool bResetAP,
- bool bRefresh);
- static void UpdateFormControl(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormControl* pFormControl,
- bool bChangeMark,
- bool bResetAP,
- bool bRefresh);
-
- static CPDFSDK_Widget* GetWidget(CPDFSDK_FormFillEnvironment* pFormFillEnv,
- CPDF_FormControl* pFormControl);
- static std::vector<CPDF_FormField*> GetFormFields(
- CPDFSDK_FormFillEnvironment* pFormFillEnv,
- const WideString& csFieldName);
-
void SetDelay(bool bDelay);
void ParseFieldName(const std::wstring& strFieldNameParsed,
std::wstring& strFieldName,
@@ -331,7 +421,7 @@ class Field : public CJS_EmbedObj {
void DoDelay();
- Document* m_pJSDoc;
+ CJS_Document* m_pJSDoc;
CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
WideString m_FieldName;
int m_nFormControlIndex;
@@ -339,100 +429,4 @@ class Field : public CJS_EmbedObj {
bool m_bDelay;
};
-class CJS_Field : public CJS_Object {
- public:
- static int GetObjDefnID();
- static void DefineJSObjects(CFXJS_Engine* pEngine);
-
- explicit CJS_Field(v8::Local<v8::Object> pObject);
- ~CJS_Field() override = default;
-
- void InitInstance(IJS_Runtime* pIRuntime) override;
-
- JS_STATIC_PROP(alignment, alignment, Field);
- JS_STATIC_PROP(borderStyle, border_style, Field);
- JS_STATIC_PROP(buttonAlignX, button_align_x, Field);
- JS_STATIC_PROP(buttonAlignY, button_align_y, Field);
- JS_STATIC_PROP(buttonFitBounds, button_fit_bounds, Field);
- JS_STATIC_PROP(buttonPosition, button_position, Field);
- JS_STATIC_PROP(buttonScaleHow, button_scale_how, Field);
- JS_STATIC_PROP(ButtonScaleWhen, button_scale_when, Field);
- JS_STATIC_PROP(calcOrderIndex, calc_order_index, Field);
- JS_STATIC_PROP(charLimit, char_limit, Field);
- JS_STATIC_PROP(comb, comb, Field);
- JS_STATIC_PROP(commitOnSelChange, commit_on_sel_change, Field);
- JS_STATIC_PROP(currentValueIndices, current_value_indices, Field);
- JS_STATIC_PROP(defaultStyle, default_style, Field);
- JS_STATIC_PROP(defaultValue, default_value, Field);
- JS_STATIC_PROP(doNotScroll, do_not_scroll, Field);
- JS_STATIC_PROP(doNotSpellCheck, do_not_spell_check, Field);
- JS_STATIC_PROP(delay, delay, Field);
- JS_STATIC_PROP(display, display, Field);
- JS_STATIC_PROP(doc, doc, Field);
- JS_STATIC_PROP(editable, editable, Field);
- JS_STATIC_PROP(exportValues, export_values, Field);
- JS_STATIC_PROP(fileSelect, file_select, Field);
- JS_STATIC_PROP(fillColor, fill_color, Field);
- JS_STATIC_PROP(hidden, hidden, Field);
- JS_STATIC_PROP(highlight, highlight, Field);
- JS_STATIC_PROP(lineWidth, line_width, Field);
- JS_STATIC_PROP(multiline, multiline, Field);
- JS_STATIC_PROP(multipleSelection, multiple_selection, Field);
- JS_STATIC_PROP(name, name, Field);
- JS_STATIC_PROP(numItems, num_items, Field);
- JS_STATIC_PROP(page, page, Field);
- JS_STATIC_PROP(password, password, Field);
- JS_STATIC_PROP(print, print, Field);
- JS_STATIC_PROP(radiosInUnison, radios_in_unison, Field);
- JS_STATIC_PROP(readonly, readonly, Field);
- JS_STATIC_PROP(rect, rect, Field);
- JS_STATIC_PROP(required, required, Field);
- JS_STATIC_PROP(richText, rich_text, Field);
- JS_STATIC_PROP(richValue, rich_value, Field);
- JS_STATIC_PROP(rotation, rotation, Field);
- JS_STATIC_PROP(strokeColor, stroke_color, Field);
- JS_STATIC_PROP(style, style, Field);
- JS_STATIC_PROP(submitName, submit_name, Field);
- JS_STATIC_PROP(textColor, text_color, Field);
- JS_STATIC_PROP(textFont, text_font, Field);
- JS_STATIC_PROP(textSize, text_size, Field);
- JS_STATIC_PROP(type, type, Field);
- JS_STATIC_PROP(userName, user_name, Field);
- JS_STATIC_PROP(value, value, Field);
- JS_STATIC_PROP(valueAsString, value_as_string, Field);
- JS_STATIC_PROP(source, source, Field);
-
- JS_STATIC_METHOD(browseForFileToSubmit, Field);
- JS_STATIC_METHOD(buttonGetCaption, Field);
- JS_STATIC_METHOD(buttonGetIcon, Field);
- JS_STATIC_METHOD(buttonImportIcon, Field);
- JS_STATIC_METHOD(buttonSetCaption, Field);
- JS_STATIC_METHOD(buttonSetIcon, Field);
- JS_STATIC_METHOD(checkThisBox, Field);
- JS_STATIC_METHOD(clearItems, Field);
- JS_STATIC_METHOD(defaultIsChecked, Field);
- JS_STATIC_METHOD(deleteItemAt, Field);
- JS_STATIC_METHOD(getArray, Field);
- JS_STATIC_METHOD(getItemAt, Field);
- JS_STATIC_METHOD(getLock, Field);
- JS_STATIC_METHOD(insertItemAt, Field);
- JS_STATIC_METHOD(isBoxChecked, Field);
- JS_STATIC_METHOD(isDefaultChecked, Field);
- JS_STATIC_METHOD(setAction, Field);
- JS_STATIC_METHOD(setFocus, Field);
- JS_STATIC_METHOD(setItems, Field);
- JS_STATIC_METHOD(setLock, Field);
- JS_STATIC_METHOD(signatureGetModifications, Field);
- JS_STATIC_METHOD(signatureGetSeedValue, Field);
- JS_STATIC_METHOD(signatureInfo, Field);
- JS_STATIC_METHOD(signatureSetSeedValue, Field);
- JS_STATIC_METHOD(signatureSign, Field);
- JS_STATIC_METHOD(signatureValidate, Field);
-
- private:
- static int ObjDefnID;
- static const JSPropertySpec PropertySpecs[];
- static const JSMethodSpec MethodSpecs[];
-};
-
#endif // FXJS_CJS_FIELD_H_
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 8816cf1b07..fbc6bf94e8 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -41,7 +41,7 @@ void JSSpecialPropQuery(const char*,
if (!pJSObj)
return;
- Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
+ Alt* pObj = static_cast<Alt*>(pJSObj);
CJS_Return result =
pObj->QueryProperty(PropFromV8Prop(info.GetIsolate(), property).c_str());
info.GetReturnValue().Set(!result.HasError() ? 4 : 0);
@@ -60,7 +60,7 @@ void JSSpecialPropGet(const char* class_name,
if (!pJSObj)
return;
- Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
+ Alt* pObj = static_cast<Alt*>(pJSObj);
CJS_Return result = pObj->GetProperty(
pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str());
if (result.HasError()) {
@@ -87,7 +87,7 @@ void JSSpecialPropPut(const char* class_name,
if (!pJSObj)
return;
- Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
+ Alt* pObj = static_cast<Alt*>(pJSObj);
CJS_Return result = pObj->SetProperty(
pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str(), value);
if (result.HasError()) {
@@ -109,7 +109,7 @@ void JSSpecialPropDel(const char* class_name,
if (!pJSObj)
return;
- Alt* pObj = reinterpret_cast<Alt*>(pJSObj->GetEmbedObject());
+ Alt* pObj = static_cast<Alt*>(pJSObj);
CJS_Return result = pObj->DelProperty(
pRuntime, PropFromV8Prop(info.GetIsolate(), property).c_str());
if (result.HasError()) {
@@ -119,58 +119,20 @@ void JSSpecialPropDel(const char* class_name,
}
}
-struct JSGlobalData {
- JSGlobalData();
- ~JSGlobalData();
-
- JS_GlobalDataType nType;
- double dData;
- bool bData;
- ByteString sData;
- v8::Global<v8::Object> pData;
- bool bPersistent;
- bool bDeleted;
-};
-
-class JSGlobalAlternate : public CJS_EmbedObj {
- public:
- explicit JSGlobalAlternate(CJS_Object* pJSObject);
- ~JSGlobalAlternate() override;
-
- CJS_Return setPersistent(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params);
- CJS_Return QueryProperty(const wchar_t* propname);
- CJS_Return GetProperty(CJS_Runtime* pRuntime, const wchar_t* propname);
- CJS_Return SetProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname,
- v8::Local<v8::Value> vp);
- CJS_Return DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname);
- void Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv);
-
- private:
- void UpdateGlobalPersistentVariables();
- void CommitGlobalPersisitentVariables(CJS_Runtime* pRuntime);
- void DestroyGlobalPersisitentVariables();
- CJS_Return SetGlobalVariables(const ByteString& propname,
- JS_GlobalDataType nType,
- double dData,
- bool bData,
- const ByteString& sData,
- v8::Local<v8::Object> pData,
- bool bDefaultPersistent);
- void ObjectToArray(CJS_Runtime* pRuntime,
- v8::Local<v8::Object> pObj,
- CJS_GlobalVariableArray& array);
- void PutObjectProperty(v8::Local<v8::Object> obj, CJS_KeyValue* pData);
-
- std::map<ByteString, std::unique_ptr<JSGlobalData>> m_MapGlobal;
- WideString m_sFilePath;
- CJS_GlobalData* m_pGlobalData;
- CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
-};
-
} // namespace
+CJS_Global::JSGlobalData::JSGlobalData()
+ : nType(JS_GlobalDataType::NUMBER),
+ dData(0),
+ bData(false),
+ sData(""),
+ bPersistent(false),
+ bDeleted(false) {}
+
+CJS_Global::JSGlobalData::~JSGlobalData() {
+ pData.Reset();
+}
+
const JSMethodSpec CJS_Global::MethodSpecs[] = {
{"setPersistent", setPersistent_static}};
@@ -179,22 +141,22 @@ int CJS_Global::ObjDefnID = -1;
// static
void CJS_Global::setPersistent_static(
const v8::FunctionCallbackInfo<v8::Value>& info) {
- JSMethod<JSGlobalAlternate, &JSGlobalAlternate::setPersistent>(
- "setPersistent", "global", info);
+ JSMethod<CJS_Global, &CJS_Global::setPersistent>("setPersistent", "global",
+ info);
}
// static
void CJS_Global::queryprop_static(
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
- JSSpecialPropQuery<JSGlobalAlternate>("global", property, info);
+ JSSpecialPropQuery<CJS_Global>("global", property, info);
}
// static
void CJS_Global::getprop_static(
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- JSSpecialPropGet<JSGlobalAlternate>("global", property, info);
+ JSSpecialPropGet<CJS_Global>("global", property, info);
}
// static
@@ -202,14 +164,14 @@ void CJS_Global::putprop_static(
v8::Local<v8::String> property,
v8::Local<v8::Value> value,
const v8::PropertyCallbackInfo<v8::Value>& info) {
- JSSpecialPropPut<JSGlobalAlternate>("global", property, value, info);
+ JSSpecialPropPut<CJS_Global>("global", property, value, info);
}
// static
void CJS_Global::delprop_static(
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
- JSSpecialPropDel<JSGlobalAlternate>("global", property, info);
+ JSSpecialPropDel<CJS_Global>("global", property, info);
}
// static
@@ -227,49 +189,31 @@ void CJS_Global::DefineJSObjects(CFXJS_Engine* pEngine) {
DefineAllProperties(pEngine);
}
-CJS_Global::CJS_Global(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<JSGlobalAlternate>(this);
+CJS_Global::CJS_Global(v8::Local<v8::Object> pObject)
+ : CJS_Object(pObject), m_pFormFillEnv(nullptr) {}
+
+CJS_Global::~CJS_Global() {
+ DestroyGlobalPersisitentVariables();
+ m_pGlobalData->Release();
}
void CJS_Global::InitInstance(IJS_Runtime* pIRuntime) {
CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime);
- JSGlobalAlternate* pGlobal =
- static_cast<JSGlobalAlternate*>(GetEmbedObject());
- pGlobal->Initial(pRuntime->GetFormFillEnv());
-}
-
-JSGlobalData::JSGlobalData()
- : nType(JS_GlobalDataType::NUMBER),
- dData(0),
- bData(false),
- sData(""),
- bPersistent(false),
- bDeleted(false) {}
-
-JSGlobalData::~JSGlobalData() {
- pData.Reset();
+ Initial(pRuntime->GetFormFillEnv());
}
-JSGlobalAlternate::JSGlobalAlternate(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject), m_pFormFillEnv(nullptr) {}
-
-JSGlobalAlternate::~JSGlobalAlternate() {
- DestroyGlobalPersisitentVariables();
- m_pGlobalData->Release();
-}
-
-void JSGlobalAlternate::Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+void CJS_Global::Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
m_pFormFillEnv.Reset(pFormFillEnv);
m_pGlobalData = CJS_GlobalData::GetRetainedInstance(pFormFillEnv);
UpdateGlobalPersistentVariables();
}
-CJS_Return JSGlobalAlternate::QueryProperty(const wchar_t* propname) {
+CJS_Return CJS_Global::QueryProperty(const wchar_t* propname) {
return CJS_Return(WideString(propname) != L"setPersistent");
}
-CJS_Return JSGlobalAlternate::DelProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname) {
+CJS_Return CJS_Global::DelProperty(CJS_Runtime* pRuntime,
+ const wchar_t* propname) {
auto it = m_MapGlobal.find(ByteString::FromUnicode(propname));
if (it == m_MapGlobal.end())
return CJS_Return(false);
@@ -278,8 +222,8 @@ CJS_Return JSGlobalAlternate::DelProperty(CJS_Runtime* pRuntime,
return CJS_Return(true);
}
-CJS_Return JSGlobalAlternate::GetProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname) {
+CJS_Return CJS_Global::GetProperty(CJS_Runtime* pRuntime,
+ const wchar_t* propname) {
auto it = m_MapGlobal.find(ByteString::FromUnicode(propname));
if (it == m_MapGlobal.end())
return CJS_Return(true);
@@ -307,9 +251,9 @@ CJS_Return JSGlobalAlternate::GetProperty(CJS_Runtime* pRuntime,
return CJS_Return(false);
}
-CJS_Return JSGlobalAlternate::SetProperty(CJS_Runtime* pRuntime,
- const wchar_t* propname,
- v8::Local<v8::Value> vp) {
+CJS_Return CJS_Global::SetProperty(CJS_Runtime* pRuntime,
+ const wchar_t* propname,
+ v8::Local<v8::Value> vp) {
ByteString sPropName = ByteString::FromUnicode(propname);
if (vp->IsNumber()) {
return SetGlobalVariables(sPropName, JS_GlobalDataType::NUMBER,
@@ -342,7 +286,7 @@ CJS_Return JSGlobalAlternate::SetProperty(CJS_Runtime* pRuntime,
return CJS_Return(false);
}
-CJS_Return JSGlobalAlternate::setPersistent(
+CJS_Return CJS_Global::setPersistent(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() != 2)
@@ -357,10 +301,10 @@ CJS_Return JSGlobalAlternate::setPersistent(
return CJS_Return(true);
}
-void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
+void CJS_Global::UpdateGlobalPersistentVariables() {
CJS_Runtime* pRuntime =
static_cast<CJS_Runtime*>(CFXJS_Engine::EngineFromIsolateCurrentContext(
- m_pJSObject->ToV8Object()->GetIsolate()));
+ ToV8Object()->GetIsolate()));
for (int i = 0, sz = m_pGlobalData->GetSize(); i < sz; i++) {
CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i);
@@ -369,8 +313,7 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
SetGlobalVariables(pData->data.sKey, JS_GlobalDataType::NUMBER,
pData->data.dData, false, "",
v8::Local<v8::Object>(), pData->bPersistent == 1);
- pRuntime->PutObjectProperty(m_pJSObject->ToV8Object(),
- pData->data.sKey.UTF8Decode(),
+ pRuntime->PutObjectProperty(ToV8Object(), pData->data.sKey.UTF8Decode(),
pRuntime->NewNumber(pData->data.dData));
break;
case JS_GlobalDataType::BOOLEAN:
@@ -378,7 +321,7 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
pData->data.bData == 1, "", v8::Local<v8::Object>(),
pData->bPersistent == 1);
pRuntime->PutObjectProperty(
- m_pJSObject->ToV8Object(), pData->data.sKey.UTF8Decode(),
+ ToV8Object(), pData->data.sKey.UTF8Decode(),
pRuntime->NewBoolean(pData->data.bData == 1));
break;
case JS_GlobalDataType::STRING:
@@ -386,7 +329,7 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
false, pData->data.sData, v8::Local<v8::Object>(),
pData->bPersistent == 1);
pRuntime->PutObjectProperty(
- m_pJSObject->ToV8Object(), pData->data.sKey.UTF8Decode(),
+ ToV8Object(), pData->data.sKey.UTF8Decode(),
pRuntime->NewString(pData->data.sData.UTF8Decode().AsStringView()));
break;
case JS_GlobalDataType::OBJECT: {
@@ -395,7 +338,7 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
PutObjectProperty(pObj, &pData->data);
SetGlobalVariables(pData->data.sKey, JS_GlobalDataType::OBJECT, 0,
false, "", pObj, pData->bPersistent == 1);
- pRuntime->PutObjectProperty(m_pJSObject->ToV8Object(),
+ pRuntime->PutObjectProperty(ToV8Object(),
pData->data.sKey.UTF8Decode(), pObj);
}
} break;
@@ -403,16 +346,14 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
SetGlobalVariables(pData->data.sKey, JS_GlobalDataType::NULLOBJ, 0,
false, "", v8::Local<v8::Object>(),
pData->bPersistent == 1);
- pRuntime->PutObjectProperty(m_pJSObject->ToV8Object(),
- pData->data.sKey.UTF8Decode(),
+ pRuntime->PutObjectProperty(ToV8Object(), pData->data.sKey.UTF8Decode(),
pRuntime->NewNull());
break;
}
}
}
-void JSGlobalAlternate::CommitGlobalPersisitentVariables(
- CJS_Runtime* pRuntime) {
+void CJS_Global::CommitGlobalPersisitentVariables(CJS_Runtime* pRuntime) {
for (const auto& iter : m_MapGlobal) {
ByteString name = iter.first;
JSGlobalData* pData = iter.second.get();
@@ -435,8 +376,8 @@ void JSGlobalAlternate::CommitGlobalPersisitentVariables(
break;
case JS_GlobalDataType::OBJECT: {
CJS_GlobalVariableArray array;
- v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(
- GetJSObject()->GetIsolate(), pData->pData);
+ v8::Local<v8::Object> obj =
+ v8::Local<v8::Object>::New(GetIsolate(), pData->pData);
ObjectToArray(pRuntime, obj, array);
m_pGlobalData->SetGlobalVariableObject(name, array);
m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
@@ -449,9 +390,9 @@ void JSGlobalAlternate::CommitGlobalPersisitentVariables(
}
}
-void JSGlobalAlternate::ObjectToArray(CJS_Runtime* pRuntime,
- v8::Local<v8::Object> pObj,
- CJS_GlobalVariableArray& array) {
+void CJS_Global::ObjectToArray(CJS_Runtime* pRuntime,
+ v8::Local<v8::Object> pObj,
+ CJS_GlobalVariableArray& array) {
std::vector<WideString> pKeyList = pRuntime->GetObjectPropertyNames(pObj);
for (const auto& ws : pKeyList) {
ByteString sKey = ws.UTF8Encode();
@@ -498,10 +439,10 @@ void JSGlobalAlternate::ObjectToArray(CJS_Runtime* pRuntime,
}
}
-void JSGlobalAlternate::PutObjectProperty(v8::Local<v8::Object> pObj,
- CJS_KeyValue* pData) {
- CJS_Runtime* pRuntime = CJS_Runtime::RuntimeFromIsolateCurrentContext(
- m_pJSObject->ToV8Object()->GetIsolate());
+void CJS_Global::PutObjectProperty(v8::Local<v8::Object> pObj,
+ CJS_KeyValue* pData) {
+ CJS_Runtime* pRuntime =
+ CJS_Runtime::RuntimeFromIsolateCurrentContext(ToV8Object()->GetIsolate());
for (int i = 0, sz = pData->objData.Count(); i < sz; i++) {
CJS_KeyValue* pObjData = pData->objData.GetAt(i);
@@ -535,17 +476,17 @@ void JSGlobalAlternate::PutObjectProperty(v8::Local<v8::Object> pObj,
}
}
-void JSGlobalAlternate::DestroyGlobalPersisitentVariables() {
+void CJS_Global::DestroyGlobalPersisitentVariables() {
m_MapGlobal.clear();
}
-CJS_Return JSGlobalAlternate::SetGlobalVariables(const ByteString& propname,
- JS_GlobalDataType nType,
- double dData,
- bool bData,
- const ByteString& sData,
- v8::Local<v8::Object> pData,
- bool bDefaultPersistent) {
+CJS_Return CJS_Global::SetGlobalVariables(const ByteString& propname,
+ JS_GlobalDataType nType,
+ double dData,
+ bool bData,
+ const ByteString& sData,
+ v8::Local<v8::Object> pData,
+ bool bDefaultPersistent) {
if (propname.IsEmpty())
return CJS_Return(false);
diff --git a/fxjs/cjs_global.h b/fxjs/cjs_global.h
index 719f4b4044..ab905bcdd2 100644
--- a/fxjs/cjs_global.h
+++ b/fxjs/cjs_global.h
@@ -7,7 +7,14 @@
#ifndef FXJS_CJS_GLOBAL_H_
#define FXJS_CJS_GLOBAL_H_
+#include <map>
+#include <memory>
+#include <vector>
+
#include "fxjs/JS_Define.h"
+#include "fxjs/cjs_keyvalue.h"
+
+class CJS_GlobalData;
class CJS_Global : public CJS_Object {
public:
@@ -29,14 +36,58 @@ class CJS_Global : public CJS_Object {
const v8::FunctionCallbackInfo<v8::Value>& info);
explicit CJS_Global(v8::Local<v8::Object> pObject);
- ~CJS_Global() override = default;
+ ~CJS_Global() override;
// CJS_Object
void InitInstance(IJS_Runtime* pIRuntime) override;
+ CJS_Return DelProperty(CJS_Runtime* pRuntime, const wchar_t* propname);
+ void Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+
+ CJS_Return setPersistent(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return QueryProperty(const wchar_t* propname);
+ CJS_Return GetProperty(CJS_Runtime* pRuntime, const wchar_t* propname);
+ CJS_Return SetProperty(CJS_Runtime* pRuntime,
+ const wchar_t* propname,
+ v8::Local<v8::Value> vp);
+
private:
+ struct JSGlobalData {
+ JSGlobalData();
+ ~JSGlobalData();
+
+ JS_GlobalDataType nType;
+ double dData;
+ bool bData;
+ ByteString sData;
+ v8::Global<v8::Object> pData;
+ bool bPersistent;
+ bool bDeleted;
+ };
+
static int ObjDefnID;
static const JSMethodSpec MethodSpecs[];
+
+ void UpdateGlobalPersistentVariables();
+ void CommitGlobalPersisitentVariables(CJS_Runtime* pRuntime);
+ void DestroyGlobalPersisitentVariables();
+ CJS_Return SetGlobalVariables(const ByteString& propname,
+ JS_GlobalDataType nType,
+ double dData,
+ bool bData,
+ const ByteString& sData,
+ v8::Local<v8::Object> pData,
+ bool bDefaultPersistent);
+ void ObjectToArray(CJS_Runtime* pRuntime,
+ v8::Local<v8::Object> pObj,
+ CJS_GlobalVariableArray& array);
+ void PutObjectProperty(v8::Local<v8::Object> obj, CJS_KeyValue* pData);
+
+ std::map<ByteString, std::unique_ptr<JSGlobalData>> m_MapGlobal;
+ WideString m_sFilePath;
+ CJS_GlobalData* m_pGlobalData;
+ CPDFSDK_FormFillEnvironment::ObservedPtr m_pFormFillEnv;
};
#endif // FXJS_CJS_GLOBAL_H_
diff --git a/fxjs/cjs_icon.cpp b/fxjs/cjs_icon.cpp
index 69a6d45557..40a2936d95 100644
--- a/fxjs/cjs_icon.cpp
+++ b/fxjs/cjs_icon.cpp
@@ -10,6 +10,7 @@ const JSPropertySpec CJS_Icon::PropertySpecs[] = {
{"name", get_name_static, set_name_static}};
int CJS_Icon::ObjDefnID = -1;
+const char CJS_Icon::kName[] = "Icon";
// static
int CJS_Icon::GetObjDefnID() {
@@ -18,24 +19,20 @@ int CJS_Icon::GetObjDefnID() {
// static
void CJS_Icon::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("Icon", FXJSOBJTYPE_DYNAMIC,
+ ObjDefnID = pEngine->DefineObj(CJS_Icon::kName, FXJSOBJTYPE_DYNAMIC,
JSConstructor<CJS_Icon>, JSDestructor);
DefineProps(pEngine, ObjDefnID, PropertySpecs, FX_ArraySize(PropertySpecs));
}
-CJS_Icon::CJS_Icon(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<Icon>(this);
-}
-
-Icon::Icon(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject), m_swIconName(L"") {}
+CJS_Icon::CJS_Icon(v8::Local<v8::Object> pObject)
+ : CJS_Object(pObject), m_swIconName(L"") {}
-Icon::~Icon() = default;
+CJS_Icon::~CJS_Icon() = default;
-CJS_Return Icon::get_name(CJS_Runtime* pRuntime) {
+CJS_Return CJS_Icon::get_name(CJS_Runtime* pRuntime) {
return CJS_Return(pRuntime->NewString(m_swIconName.c_str()));
}
-CJS_Return Icon::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
+CJS_Return CJS_Icon::set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
return CJS_Return(false);
}
diff --git a/fxjs/cjs_icon.h b/fxjs/cjs_icon.h
index 3ded32f83a..a346d69e73 100644
--- a/fxjs/cjs_icon.h
+++ b/fxjs/cjs_icon.h
@@ -9,34 +9,28 @@
#include "fxjs/JS_Define.h"
-class Icon : public CJS_EmbedObj {
- public:
- explicit Icon(CJS_Object* pJSObject);
- ~Icon() override;
-
- CJS_Return get_name(CJS_Runtime* pRuntime);
- CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
-
- WideString GetIconName() const { return m_swIconName; }
- void SetIconName(WideString name) { m_swIconName = name; }
-
- private:
- WideString m_swIconName;
-};
-
class CJS_Icon : public CJS_Object {
public:
static int GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
explicit CJS_Icon(v8::Local<v8::Object> pObject);
- ~CJS_Icon() override = default;
+ ~CJS_Icon() override;
+
+ WideString GetIconName() const { return m_swIconName; }
+ void SetIconName(WideString name) { m_swIconName = name; }
- JS_STATIC_PROP(name, name, Icon);
+ JS_STATIC_PROP(name, name, CJS_Icon);
private:
static int ObjDefnID;
+ static const char kName[];
static const JSPropertySpec PropertySpecs[];
+
+ CJS_Return get_name(CJS_Runtime* pRuntime);
+ CJS_Return set_name(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp);
+
+ WideString m_swIconName;
};
#endif // FXJS_CJS_ICON_H_
diff --git a/fxjs/cjs_object.h b/fxjs/cjs_object.h
index 67389f59e6..22a5e1625a 100644
--- a/fxjs/cjs_object.h
+++ b/fxjs/cjs_object.h
@@ -11,7 +11,6 @@
#include <utility>
#include "fpdfsdk/fsdk_define.h"
-#include "fxjs/cjs_embedobj.h"
#include "fxjs/cjs_runtime.h"
#include "fxjs/fxjs_v8.h"
@@ -56,13 +55,9 @@ class CJS_Object {
virtual void InitInstance(IJS_Runtime* pIRuntime);
v8::Local<v8::Object> ToV8Object() { return m_pV8Object.Get(m_pIsolate); }
-
- CJS_EmbedObj* GetEmbedObject() const { return m_pEmbedObj.get(); }
-
v8::Isolate* GetIsolate() const { return m_pIsolate; }
protected:
- std::unique_ptr<CJS_EmbedObj> m_pEmbedObj;
v8::Global<v8::Object> m_pV8Object;
v8::Isolate* m_pIsolate;
};
diff --git a/fxjs/cjs_printparamsobj.cpp b/fxjs/cjs_printparamsobj.cpp
index 91d02201b1..b85925de44 100644
--- a/fxjs/cjs_printparamsobj.cpp
+++ b/fxjs/cjs_printparamsobj.cpp
@@ -21,18 +21,6 @@ void CJS_PrintParamsObj::DefineJSObjects(CFXJS_Engine* pEngine) {
}
CJS_PrintParamsObj::CJS_PrintParamsObj(v8::Local<v8::Object> pObject)
- : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<PrintParamsObj>(this);
-}
+ : CJS_Object(pObject) {}
-PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject) {
- bUI = true;
- nStart = 0;
- nEnd = 0;
- bSilent = false;
- bShrinkToFit = false;
- bPrintAsImage = false;
- bReverse = false;
- bAnnotations = true;
-}
+CJS_PrintParamsObj::~CJS_PrintParamsObj() = default;
diff --git a/fxjs/cjs_printparamsobj.h b/fxjs/cjs_printparamsobj.h
index aa2b365888..97028dd557 100644
--- a/fxjs/cjs_printparamsobj.h
+++ b/fxjs/cjs_printparamsobj.h
@@ -9,32 +9,34 @@
#include "fxjs/JS_Define.h"
-class PrintParamsObj : public CJS_EmbedObj {
- public:
- explicit PrintParamsObj(CJS_Object* pJSObject);
- ~PrintParamsObj() override {}
-
- public:
- bool bUI;
- int nStart;
- int nEnd;
- bool bSilent;
- bool bShrinkToFit;
- bool bPrintAsImage;
- bool bReverse;
- bool bAnnotations;
-};
-
class CJS_PrintParamsObj : public CJS_Object {
public:
static int GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
explicit CJS_PrintParamsObj(v8::Local<v8::Object> pObject);
- ~CJS_PrintParamsObj() override = default;
+ ~CJS_PrintParamsObj() override;
+
+ bool GetUI() const { return bUI; }
+ int GetStart() const { return nStart; }
+ int GetEnd() const { return nEnd; }
+ bool GetSilent() const { return bSilent; }
+ bool GetShrinkToFit() const { return bShrinkToFit; }
+ bool GetPrintAsImage() const { return bPrintAsImage; }
+ bool GetReverse() const { return bReverse; }
+ bool GetAnnotations() const { return bAnnotations; }
private:
static int ObjDefnID;
+
+ bool bUI = true;
+ int nStart = 0;
+ int nEnd = 0;
+ bool bSilent = false;
+ bool bShrinkToFit = false;
+ bool bPrintAsImage = false;
+ bool bReverse = false;
+ bool bAnnotations = true;
};
#endif // FXJS_CJS_PRINTPARAMSOBJ_H_
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index 9fcfc5f291..30927beac2 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -936,7 +936,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Format(
Value += L')';
}
if (iNegStyle == 1 || iNegStyle == 3) {
- if (Field* fTarget = pEvent->Target_Field()) {
+ if (CJS_Field* fTarget = pEvent->Target_Field()) {
v8::Local<v8::Array> arColor = pRuntime->NewArray();
pRuntime->PutArrayElement(arColor, 0, pRuntime->NewString(L"RGB"));
pRuntime->PutArrayElement(arColor, 1, pRuntime->NewNumber(1));
@@ -947,7 +947,7 @@ CJS_Return CJS_PublicMethods::AFNumber_Format(
}
} else {
if (iNegStyle == 1 || iNegStyle == 3) {
- if (Field* fTarget = pEvent->Target_Field()) {
+ if (CJS_Field* fTarget = pEvent->Target_Field()) {
v8::Local<v8::Array> arColor = pRuntime->NewArray();
pRuntime->PutArrayElement(arColor, 0, pRuntime->NewString(L"RGB"));
pRuntime->PutArrayElement(arColor, 1, pRuntime->NewNumber(0));
@@ -955,9 +955,10 @@ CJS_Return CJS_PublicMethods::AFNumber_Format(
pRuntime->PutArrayElement(arColor, 3, pRuntime->NewNumber(0));
CJS_Return result = fTarget->get_text_color(pRuntime);
- CFX_Color crProp = color::ConvertArrayToPWLColor(
+ CFX_Color crProp = CJS_Color::ConvertArrayToPWLColor(
pRuntime, pRuntime->ToArray(result.Return()));
- CFX_Color crColor = color::ConvertArrayToPWLColor(pRuntime, arColor);
+ CFX_Color crColor =
+ CJS_Color::ConvertArrayToPWLColor(pRuntime, arColor);
if (crColor != crProp)
fTarget->set_text_color(pRuntime, arColor);
}
@@ -1374,7 +1375,7 @@ CJS_Return CJS_PublicMethods::AFSpecial_Format(
wsFormat = L"99999-9999";
break;
case 2:
- if (util::printx(L"9999999999", wsSource).GetLength() >= 10)
+ if (CJS_Util::printx(L"9999999999", wsSource).GetLength() >= 10)
wsFormat = L"(999) 999-9999";
else
wsFormat = L"999-9999";
@@ -1384,7 +1385,7 @@ CJS_Return CJS_PublicMethods::AFSpecial_Format(
break;
}
- pEvent->Value() = util::printx(wsFormat, wsSource);
+ pEvent->Value() = CJS_Util::printx(wsFormat, wsSource);
return CJS_Return(true);
}
diff --git a/fxjs/cjs_report.cpp b/fxjs/cjs_report.cpp
index a5e544151e..2f5490c472 100644
--- a/fxjs/cjs_report.cpp
+++ b/fxjs/cjs_report.cpp
@@ -16,30 +16,28 @@ const JSMethodSpec CJS_Report::MethodSpecs[] = {
{"writeText", writeText_static}};
int CJS_Report::ObjDefnID = -1;
+const char CJS_Report::kName[] = "Report";
// static
void CJS_Report::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- ObjDefnID = pEngine->DefineObj("Report", eObjType, JSConstructor<CJS_Report>,
- JSDestructor);
+ ObjDefnID = pEngine->DefineObj(CJS_Report::kName, eObjType,
+ JSConstructor<CJS_Report>, JSDestructor);
DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
}
-CJS_Report::CJS_Report(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<Report>(this);
-}
-
-Report::Report(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
+CJS_Report::CJS_Report(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
-Report::~Report() = default;
+CJS_Report::~CJS_Report() = default;
-CJS_Return Report::writeText(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Report::writeText(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
-CJS_Return Report::save(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Report::save(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
// Unsafe, not supported.
return CJS_Return(true);
}
diff --git a/fxjs/cjs_report.h b/fxjs/cjs_report.h
index 168df7946b..2a59206410 100644
--- a/fxjs/cjs_report.h
+++ b/fxjs/cjs_report.h
@@ -11,31 +11,25 @@
#include "fxjs/JS_Define.h"
-class Report : public CJS_EmbedObj {
- public:
- explicit Report(CJS_Object* pJSObject);
- ~Report() override;
-
- public:
- CJS_Return save(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params);
- CJS_Return writeText(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params);
-};
-
class CJS_Report : public CJS_Object {
public:
static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
explicit CJS_Report(v8::Local<v8::Object> pObject);
- ~CJS_Report() override = default;
+ ~CJS_Report() override;
- JS_STATIC_METHOD(save, Report)
- JS_STATIC_METHOD(writeText, Report);
+ JS_STATIC_METHOD(save, CJS_Report);
+ JS_STATIC_METHOD(writeText, CJS_Report);
private:
static int ObjDefnID;
+ static const char kName[];
static const JSMethodSpec MethodSpecs[];
+
+ CJS_Return save(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
+ CJS_Return writeText(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params);
};
#endif // FXJS_CJS_REPORT_H_
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index 662269514a..6da52ad7ef 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -195,11 +195,7 @@ void CJS_Runtime::SetFormFillEnvToDocument() {
if (!pJSDocument)
return;
- Document* pDocument = static_cast<Document*>(pJSDocument->GetEmbedObject());
- if (!pDocument)
- return;
-
- pDocument->SetFormFillEnv(m_pFormFillEnv.Get());
+ pJSDocument->SetFormFillEnv(m_pFormFillEnv.Get());
}
CPDFSDK_FormFillEnvironment* CJS_Runtime::GetFormFillEnv() const {
diff --git a/fxjs/cjs_timerobj.cpp b/fxjs/cjs_timerobj.cpp
index 172ee5c04e..59d38423af 100644
--- a/fxjs/cjs_timerobj.cpp
+++ b/fxjs/cjs_timerobj.cpp
@@ -22,15 +22,10 @@ void CJS_TimerObj::DefineJSObjects(CFXJS_Engine* pEngine) {
}
CJS_TimerObj::CJS_TimerObj(v8::Local<v8::Object> pObject)
- : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<TimerObj>(this);
-}
-
-TimerObj::TimerObj(CJS_Object* pJSObject)
- : CJS_EmbedObj(pJSObject), m_nTimerID(0) {}
+ : CJS_Object(pObject), m_nTimerID(0) {}
-TimerObj::~TimerObj() = default;
+CJS_TimerObj::~CJS_TimerObj() = default;
-void TimerObj::SetTimer(GlobalTimer* pTimer) {
+void CJS_TimerObj::SetTimer(GlobalTimer* pTimer) {
m_nTimerID = pTimer->GetTimerID();
}
diff --git a/fxjs/cjs_timerobj.h b/fxjs/cjs_timerobj.h
index b4938c4ece..edc3def952 100644
--- a/fxjs/cjs_timerobj.h
+++ b/fxjs/cjs_timerobj.h
@@ -11,28 +11,21 @@
class GlobalTimer;
-class TimerObj : public CJS_EmbedObj {
- public:
- explicit TimerObj(CJS_Object* pJSObject);
- ~TimerObj() override;
-
- void SetTimer(GlobalTimer* pTimer);
- int GetTimerID() const { return m_nTimerID; }
-
- private:
- int m_nTimerID; // Weak reference to GlobalTimer through global map.
-};
-
class CJS_TimerObj : public CJS_Object {
public:
static int GetObjDefnID();
static void DefineJSObjects(CFXJS_Engine* pEngine);
explicit CJS_TimerObj(v8::Local<v8::Object> pObject);
- ~CJS_TimerObj() override = default;
+ ~CJS_TimerObj() override;
+
+ void SetTimer(GlobalTimer* pTimer);
+ int GetTimerID() const { return m_nTimerID; }
private:
static int ObjDefnID;
+
+ int m_nTimerID; // Weak reference to GlobalTimer through global map.
};
#endif // FXJS_CJS_TIMEROBJ_H_
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index db03dbdb82..fd064b33a6 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -65,24 +65,21 @@ const JSMethodSpec CJS_Util::MethodSpecs[] = {
{"byteToChar", byteToChar_static}};
int CJS_Util::ObjDefnID = -1;
+const char CJS_Util::kName[] = "util";
// static
void CJS_Util::DefineJSObjects(CFXJS_Engine* pEngine) {
- ObjDefnID = pEngine->DefineObj("util", FXJSOBJTYPE_STATIC,
+ ObjDefnID = pEngine->DefineObj(CJS_Util::kName, FXJSOBJTYPE_STATIC,
JSConstructor<CJS_Util>, JSDestructor);
DefineMethods(pEngine, ObjDefnID, MethodSpecs, FX_ArraySize(MethodSpecs));
}
-CJS_Util::CJS_Util(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {
- m_pEmbedObj = pdfium::MakeUnique<util>(this);
-}
-
-util::util(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
+CJS_Util::CJS_Util(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
-util::~util() = default;
+CJS_Util::~CJS_Util() = default;
-CJS_Return util::printf(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Util::printf(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
const size_t iSize = params.size();
if (iSize < 1)
return CJS_Return(false);
@@ -143,8 +140,8 @@ CJS_Return util::printf(CJS_Runtime* pRuntime,
return CJS_Return(pRuntime->NewString(c_strResult.c_str()));
}
-CJS_Return util::printd(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Util::printd(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
const size_t iSize = params.size();
if (iSize < 2)
return CJS_Return(false);
@@ -253,8 +250,8 @@ CJS_Return util::printd(CJS_Runtime* pRuntime,
return CJS_Return(JSGetStringFromID(JSMessage::kTypeError));
}
-CJS_Return util::printx(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Util::printx(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
@@ -274,8 +271,8 @@ static wchar_t TranslateCase(wchar_t input, CaseMode eMode) {
return input;
}
-WideString util::printx(const WideString& wsFormat,
- const WideString& wsSource) {
+WideString CJS_Util::printx(const WideString& wsFormat,
+ const WideString& wsSource) {
WideString wsResult;
size_t iSourceIdx = 0;
size_t iFormatIdx = 0;
@@ -362,8 +359,8 @@ WideString util::printx(const WideString& wsFormat,
return wsResult;
}
-CJS_Return util::scand(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Util::scand(CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 2)
return CJS_Return(false);
@@ -378,8 +375,9 @@ CJS_Return util::scand(CJS_Runtime* pRuntime,
return CJS_Return(pRuntime->NewDate(dDate));
}
-CJS_Return util::byteToChar(CJS_Runtime* pRuntime,
- const std::vector<v8::Local<v8::Value>>& params) {
+CJS_Return CJS_Util::byteToChar(
+ CJS_Runtime* pRuntime,
+ const std::vector<v8::Local<v8::Value>>& params) {
if (params.size() < 1)
return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
@@ -395,7 +393,7 @@ CJS_Return util::byteToChar(CJS_Runtime* pRuntime,
// directive which is safe to use with a single argument, and return the type
// of argument expected, or -1 otherwise. If -1 is returned, it is NOT safe
// to use sFormat with printf() and it must be copied byte-by-byte.
-int util::ParseDataType(std::wstring* sFormat) {
+int CJS_Util::ParseDataType(std::wstring* sFormat) {
enum State { BEFORE, FLAGS, WIDTH, PRECISION, SPECIFIER, AFTER };
int result = -1;
diff --git a/fxjs/cjs_util.h b/fxjs/cjs_util.h
index 1ed8405d46..0ad0fa101c 100644
--- a/fxjs/cjs_util.h
+++ b/fxjs/cjs_util.h
@@ -17,10 +17,30 @@
#define UTIL_DOUBLE 1
#define UTIL_STRING 2
-class util : public CJS_EmbedObj {
+class CJS_Util : public CJS_Object {
public:
- explicit util(CJS_Object* pJSObject);
- ~util() override;
+ static void DefineJSObjects(CFXJS_Engine* pEngine);
+
+ explicit CJS_Util(v8::Local<v8::Object> pObject);
+ ~CJS_Util() override;
+
+ static WideString printx(const WideString& cFormat,
+ const WideString& cSource);
+
+ JS_STATIC_METHOD(printd, CJS_Util);
+ JS_STATIC_METHOD(printf, CJS_Util);
+ JS_STATIC_METHOD(printx, CJS_Util);
+ JS_STATIC_METHOD(scand, CJS_Util);
+ JS_STATIC_METHOD(byteToChar, CJS_Util);
+
+ private:
+ friend class CJS_Util_ParseDataType_Test;
+
+ static int ObjDefnID;
+ static const char kName[];
+ static const JSMethodSpec MethodSpecs[];
+
+ static int ParseDataType(std::wstring* sFormat);
CJS_Return printd(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params);
@@ -32,32 +52,6 @@ class util : public CJS_EmbedObj {
const std::vector<v8::Local<v8::Value>>& params);
CJS_Return byteToChar(CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params);
-
- static WideString printx(const WideString& cFormat,
- const WideString& cSource);
-
- private:
- friend class CJS_Util_ParseDataType_Test;
-
- static int ParseDataType(std::wstring* sFormat);
-};
-
-class CJS_Util : public CJS_Object {
- public:
- static void DefineJSObjects(CFXJS_Engine* pEngine);
-
- explicit CJS_Util(v8::Local<v8::Object> pObject);
- ~CJS_Util() override = default;
-
- JS_STATIC_METHOD(printd, util);
- JS_STATIC_METHOD(printf, util);
- JS_STATIC_METHOD(printx, util);
- JS_STATIC_METHOD(scand, util);
- JS_STATIC_METHOD(byteToChar, util);
-
- private:
- static int ObjDefnID;
- static const JSMethodSpec MethodSpecs[];
};
#endif // FXJS_CJS_UTIL_H_
diff --git a/fxjs/cjs_util_unittest.cpp b/fxjs/cjs_util_unittest.cpp
index 6f43f0fcb6..4e25ca1485 100644
--- a/fxjs/cjs_util_unittest.cpp
+++ b/fxjs/cjs_util_unittest.cpp
@@ -107,7 +107,7 @@ TEST(CJS_Util, ParseDataType) {
for (size_t i = 0; i < FX_ArraySize(cases); i++) {
std::wstring input(cases[i].input_string);
- EXPECT_EQ(cases[i].expected, util::ParseDataType(&input))
+ EXPECT_EQ(cases[i].expected, CJS_Util::ParseDataType(&input))
<< cases[i].input_string;
}
}
diff --git a/fxjs/global_timer.cpp b/fxjs/global_timer.cpp
index 6f7f09c673..9c69ac2ea9 100644
--- a/fxjs/global_timer.cpp
+++ b/fxjs/global_timer.cpp
@@ -6,7 +6,7 @@
#include "fxjs/global_timer.h"
-GlobalTimer::GlobalTimer(app* pObj,
+GlobalTimer::GlobalTimer(CJS_App* pObj,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CJS_Runtime* pRuntime,
int nType,
@@ -14,7 +14,7 @@ GlobalTimer::GlobalTimer(app* pObj,
uint32_t dwElapse,
uint32_t dwTimeOut)
: m_nTimerID(0),
- m_pEmbedObj(pObj),
+ m_pEmbedApp(pObj),
m_bProcessing(false),
m_nType(nType),
m_dwTimeOut(dwTimeOut),
@@ -48,8 +48,8 @@ void GlobalTimer::Trigger(int nTimerID) {
return;
pTimer->m_bProcessing = true;
- if (pTimer->m_pEmbedObj)
- pTimer->m_pEmbedObj->TimerProc(pTimer);
+ if (pTimer->m_pEmbedApp)
+ pTimer->m_pEmbedApp->TimerProc(pTimer);
// Timer proc may have destroyed timer, find it again.
it = GetGlobalTimerMap()->find(nTimerID);
@@ -59,7 +59,7 @@ void GlobalTimer::Trigger(int nTimerID) {
pTimer = it->second;
pTimer->m_bProcessing = false;
if (pTimer->IsOneShot())
- pTimer->m_pEmbedObj->CancelProc(pTimer);
+ pTimer->m_pEmbedApp->CancelProc(pTimer);
}
// static
@@ -69,7 +69,7 @@ void GlobalTimer::Cancel(int nTimerID) {
return;
GlobalTimer* pTimer = it->second;
- pTimer->m_pEmbedObj->CancelProc(pTimer);
+ pTimer->m_pEmbedApp->CancelProc(pTimer);
}
// static
diff --git a/fxjs/global_timer.h b/fxjs/global_timer.h
index ec8806b9a1..63bda57be4 100644
--- a/fxjs/global_timer.h
+++ b/fxjs/global_timer.h
@@ -13,7 +13,7 @@
class GlobalTimer {
public:
- GlobalTimer(app* pObj,
+ GlobalTimer(CJS_App* pObj,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CJS_Runtime* pRuntime,
int nType,
@@ -36,7 +36,7 @@ class GlobalTimer {
static TimerMap* GetGlobalTimerMap();
uint32_t m_nTimerID;
- app* const m_pEmbedObj;
+ CJS_App* const m_pEmbedApp;
bool m_bProcessing;
// data