summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-10-11 10:54:49 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-11 10:54:49 -0700
commit4526faf9d62b64729a232c20ada67690f590abd2 (patch)
tree76dfeaac09b49fcff44a57da0aa51ead16c515c2 /fpdfsdk
parent3a7741a2d9391fdbc54900695a980344dddf1692 (diff)
downloadpdfium-4526faf9d62b64729a232c20ada67690f590abd2.tar.xz
Remove CPDFSDK_Document from IJS_Context
This CL converts the IJS_Context and implementations over to use CPDFSDK_FormFillEnvironment instead of CPDFSDK_Document. Review-Url: https://codereview.chromium.org/2399943002
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fsdk_actionhandler.cpp30
-rw-r--r--fpdfsdk/javascript/Document.cpp2
-rw-r--r--fpdfsdk/javascript/JS_EventHandler.cpp92
-rw-r--r--fpdfsdk/javascript/JS_EventHandler.h32
-rw-r--r--fpdfsdk/javascript/JS_Runtime_Stub.cpp27
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp6
-rw-r--r--fpdfsdk/javascript/app.cpp28
-rw-r--r--fpdfsdk/javascript/cjs_context.cpp58
-rw-r--r--fpdfsdk/javascript/cjs_context.h29
-rw-r--r--fpdfsdk/javascript/ijs_context.h28
10 files changed, 163 insertions, 169 deletions
diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp
index 08a03edafe..f6ba4c9d9c 100644
--- a/fpdfsdk/fsdk_actionhandler.cpp
+++ b/fpdfsdk/fsdk_actionhandler.cpp
@@ -148,17 +148,17 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(
visited->insert(pDict);
- CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = pDocument->GetEnv();
+ ASSERT(pFormFillEnv);
if (action.GetType() == CPDF_Action::JavaScript) {
- if (pEnv->IsJSInitiated()) {
+ if (pFormFillEnv->IsJSInitiated()) {
CFX_WideString swJS = action.GetJavaScript();
if (!swJS.IsEmpty()) {
- IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
+ IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
pRuntime->SetReaderDocument(pDocument);
IJS_Context* pContext = pRuntime->NewContext();
- pContext->OnLink_MouseUp(pDocument);
+ pContext->OnLink_MouseUp(pFormFillEnv);
CFX_WideString csInfo;
FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
@@ -534,7 +534,7 @@ void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(
IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
pRuntime->SetReaderDocument(pDocument);
IJS_Context* pContext = pRuntime->NewContext();
- pContext->OnDoc_Open(pDocument, sScriptName);
+ pContext->OnDoc_Open(pDocument->GetEnv(), sScriptName);
CFX_WideString csInfo;
FX_BOOL bRet = pContext->RunScript(script, &csInfo);
@@ -555,31 +555,31 @@ void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(
IJS_Context* pContext = pRuntime->NewContext();
switch (type) {
case CPDF_AAction::OpenPage:
- pContext->OnPage_Open(pDocument);
+ pContext->OnPage_Open(pDocument->GetEnv());
break;
case CPDF_AAction::ClosePage:
- pContext->OnPage_Close(pDocument);
+ pContext->OnPage_Close(pDocument->GetEnv());
break;
case CPDF_AAction::CloseDocument:
- pContext->OnDoc_WillClose(pDocument);
+ pContext->OnDoc_WillClose(pDocument->GetEnv());
break;
case CPDF_AAction::SaveDocument:
- pContext->OnDoc_WillSave(pDocument);
+ pContext->OnDoc_WillSave(pDocument->GetEnv());
break;
case CPDF_AAction::DocumentSaved:
- pContext->OnDoc_DidSave(pDocument);
+ pContext->OnDoc_DidSave(pDocument->GetEnv());
break;
case CPDF_AAction::PrintDocument:
- pContext->OnDoc_WillPrint(pDocument);
+ pContext->OnDoc_WillPrint(pDocument->GetEnv());
break;
case CPDF_AAction::DocumentPrinted:
- pContext->OnDoc_DidPrint(pDocument);
+ pContext->OnDoc_DidPrint(pDocument->GetEnv());
break;
case CPDF_AAction::PageVisible:
- pContext->OnPage_InView(pDocument);
+ pContext->OnPage_InView(pDocument->GetEnv());
break;
case CPDF_AAction::PageInvisible:
- pContext->OnPage_OutView(pDocument);
+ pContext->OnPage_OutView(pDocument->GetEnv());
break;
default:
ASSERT(FALSE);
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index bd9e540cf3..f8edf97247 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -408,7 +408,7 @@ FX_BOOL Document::mailForm(IJS_Context* cc,
return FALSE;
pRuntime->BeginBlock();
- CPDFSDK_FormFillEnvironment* pEnv = pContext->GetReaderEnv();
+ CPDFSDK_FormFillEnvironment* pEnv = pContext->GetFormFillEnv();
pEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI,
cTo.c_str(), cSubject.c_str(), cCc.c_str(), cBcc.c_str(),
cMsg.c_str());
diff --git a/fpdfsdk/javascript/JS_EventHandler.cpp b/fpdfsdk/javascript/JS_EventHandler.cpp
index fe9a909dc9..731d803d2c 100644
--- a/fpdfsdk/javascript/JS_EventHandler.cpp
+++ b/fpdfsdk/javascript/JS_EventHandler.cpp
@@ -32,9 +32,8 @@ CJS_EventHandler::CJS_EventHandler(CJS_Context* pContext)
m_bFieldFull(FALSE),
m_pbRc(nullptr),
m_bRcDu(FALSE),
- m_pSourceDoc(nullptr),
m_pTargetBookMark(nullptr),
- m_pTargetDoc(nullptr),
+ m_pTargetFormFillEnv(nullptr),
m_pTargetAnnot(nullptr) {}
CJS_EventHandler::~CJS_EventHandler() {}
@@ -43,65 +42,63 @@ void CJS_EventHandler::OnApp_Init() {
Initial(JET_APP_INIT);
}
-void CJS_EventHandler::OnDoc_Open(CPDFSDK_Document* pDoc,
+void CJS_EventHandler::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName) {
Initial(JET_DOC_OPEN);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
m_strTargetName = strTargetName;
}
-void CJS_EventHandler::OnDoc_WillPrint(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnDoc_WillPrint(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_WILLPRINT);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
-void CJS_EventHandler::OnDoc_DidPrint(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnDoc_DidPrint(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_DIDPRINT);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
-void CJS_EventHandler::OnDoc_WillSave(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnDoc_WillSave(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_WILLSAVE);
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
-void CJS_EventHandler::OnDoc_DidSave(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnDoc_DidSave(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_DIDSAVE);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
-void CJS_EventHandler::OnDoc_WillClose(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnDoc_WillClose(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_DOC_WILLCLOSE);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
-void CJS_EventHandler::OnPage_Open(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_PAGE_OPEN);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
-void CJS_EventHandler::OnPage_Close(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_PAGE_CLOSE);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
-void CJS_EventHandler::OnPage_InView(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnPage_InView(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_PAGE_INVIEW);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
-void CJS_EventHandler::OnPage_OutView(CPDFSDK_Document* pDoc) {
+void CJS_EventHandler::OnPage_OutView(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
Initial(JET_PAGE_OUTVIEW);
-
- m_pTargetDoc = pDoc;
+ m_pTargetFormFillEnv = pFormFillEnv;
}
void CJS_EventHandler::OnField_MouseEnter(FX_BOOL bModifier,
@@ -343,10 +340,10 @@ void CJS_EventHandler::OnScreen_OutView(FX_BOOL bModifier,
m_pTargetAnnot = pScreen;
}
-void CJS_EventHandler::OnLink_MouseUp(CPDFSDK_Document* pTarget) {
+void CJS_EventHandler::OnLink_MouseUp(
+ CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
Initial(JET_LINK_MOUSEUP);
-
- m_pTargetDoc = pTarget;
+ m_pTargetFormFillEnv = pTargetFormFillEnv;
}
void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
@@ -355,11 +352,11 @@ void CJS_EventHandler::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
m_pTargetBookMark = pBookMark;
}
-void CJS_EventHandler::OnMenu_Exec(CPDFSDK_Document* pTarget,
- const CFX_WideString& strTargetName) {
+void CJS_EventHandler::OnMenu_Exec(
+ CPDFSDK_FormFillEnvironment* pTargetFormFillEnv,
+ const CFX_WideString& strTargetName) {
Initial(JET_MENU_EXEC);
-
- m_pTargetDoc = pTarget;
+ m_pTargetFormFillEnv = pTargetFormFillEnv;
m_strTargetName = strTargetName;
}
@@ -367,10 +364,10 @@ void CJS_EventHandler::OnExternal_Exec() {
Initial(JET_EXTERNAL_EXEC);
}
-void CJS_EventHandler::OnBatchExec(CPDFSDK_Document* pTarget) {
+void CJS_EventHandler::OnBatchExec(
+ CPDFSDK_FormFillEnvironment* pTargetFormFillEnv) {
Initial(JET_BATCH_EXEC);
-
- m_pTargetDoc = pTarget;
+ m_pTargetFormFillEnv = pTargetFormFillEnv;
}
void CJS_EventHandler::OnConsole_Exec() {
@@ -399,9 +396,8 @@ void CJS_EventHandler::Initial(JS_EVENT_T type) {
m_pbRc = nullptr;
m_bRcDu = FALSE;
- m_pSourceDoc = nullptr;
m_pTargetBookMark = nullptr;
- m_pTargetDoc = nullptr;
+ m_pTargetFormFillEnv = nullptr;
m_pTargetAnnot = nullptr;
m_bValid = TRUE;
@@ -606,8 +602,9 @@ Field* CJS_EventHandler::Source() {
CJS_Document* pJSDocument =
static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
- pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc
- : m_pJSContext->GetReaderDocument());
+ pDocument->AttachDoc(m_pTargetFormFillEnv
+ ? m_pTargetFormFillEnv->GetSDKDocument()
+ : m_pJSContext->GetFormFillEnv()->GetSDKDocument());
CJS_Field* pJSField =
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
@@ -629,8 +626,9 @@ Field* CJS_EventHandler::Target_Field() {
CJS_Document* pJSDocument =
static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pDocObj));
Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
- pDocument->AttachDoc(m_pTargetDoc ? m_pTargetDoc
- : m_pJSContext->GetReaderDocument());
+ pDocument->AttachDoc(m_pTargetFormFillEnv
+ ? m_pTargetFormFillEnv->GetSDKDocument()
+ : m_pJSContext->GetFormFillEnv()->GetSDKDocument());
CJS_Field* pJSField =
static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
diff --git a/fpdfsdk/javascript/JS_EventHandler.h b/fpdfsdk/javascript/JS_EventHandler.h
index 02d5e82595..666ef8410d 100644
--- a/fpdfsdk/javascript/JS_EventHandler.h
+++ b/fpdfsdk/javascript/JS_EventHandler.h
@@ -12,7 +12,7 @@
class CJS_Context;
class CPDFSDK_Annot;
-class CPDFSDK_Document;
+class CPDFSDK_FormFillEnvironment;
class CPDF_Bookmark;
class CPDF_FormField;
class Field;
@@ -65,17 +65,18 @@ class CJS_EventHandler {
void OnApp_Init();
- void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName);
- void OnDoc_WillPrint(CPDFSDK_Document* pDoc);
- void OnDoc_DidPrint(CPDFSDK_Document* pDoc);
- void OnDoc_WillSave(CPDFSDK_Document* pDoc);
- void OnDoc_DidSave(CPDFSDK_Document* pDoc);
- void OnDoc_WillClose(CPDFSDK_Document* pDoc);
+ void OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CFX_WideString& strTargetName);
+ void OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ void OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ void OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ void OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ void OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv);
- void OnPage_Open(CPDFSDK_Document* pDoc);
- void OnPage_Close(CPDFSDK_Document* pDoc);
- void OnPage_InView(CPDFSDK_Document* pTarget);
- void OnPage_OutView(CPDFSDK_Document* pTarget);
+ void OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ void OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ void OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ void OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv);
void OnField_Calculate(CPDF_FormField* pSource,
CPDF_FormField* pTarget,
@@ -154,11 +155,11 @@ class CJS_EventHandler {
CPDFSDK_Annot* pScreen);
void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark);
- void OnLink_MouseUp(CPDFSDK_Document* pTarget);
+ void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv);
- void OnMenu_Exec(CPDFSDK_Document* pTarget,
+ void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName);
- void OnBatchExec(CPDFSDK_Document* pTarget);
+ void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv);
void OnConsole_Exec();
void OnExternal_Exec();
@@ -211,9 +212,8 @@ class CJS_EventHandler {
FX_BOOL* m_pbRc;
FX_BOOL m_bRcDu;
- CPDFSDK_Document* m_pSourceDoc;
CPDF_Bookmark* m_pTargetBookMark;
- CPDFSDK_Document* m_pTargetDoc;
+ CPDFSDK_FormFillEnvironment* m_pTargetFormFillEnv;
CPDFSDK_Annot* m_pTargetAnnot;
};
diff --git a/fpdfsdk/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/javascript/JS_Runtime_Stub.cpp
index ec52a8b6a0..904ee12cca 100644
--- a/fpdfsdk/javascript/JS_Runtime_Stub.cpp
+++ b/fpdfsdk/javascript/JS_Runtime_Stub.cpp
@@ -22,17 +22,17 @@ class CJS_ContextStub final : public IJS_Context {
}
void OnApp_Init() override {}
- void OnDoc_Open(CPDFSDK_Document* pDoc,
+ void OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName) override {}
- void OnDoc_WillPrint(CPDFSDK_Document* pDoc) override {}
- void OnDoc_DidPrint(CPDFSDK_Document* pDoc) override {}
- void OnDoc_WillSave(CPDFSDK_Document* pDoc) override {}
- void OnDoc_DidSave(CPDFSDK_Document* pDoc) override {}
- void OnDoc_WillClose(CPDFSDK_Document* pDoc) override {}
- void OnPage_Open(CPDFSDK_Document* pTarget) override {}
- void OnPage_Close(CPDFSDK_Document* pTarget) override {}
- void OnPage_InView(CPDFSDK_Document* pTarget) override {}
- void OnPage_OutView(CPDFSDK_Document* pTarget) override {}
+ void OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
void OnField_MouseDown(FX_BOOL bModifier,
FX_BOOL bShift,
CPDF_FormField* pTarget) override {}
@@ -111,9 +111,10 @@ class CJS_ContextStub final : public IJS_Context {
FX_BOOL bShift,
CPDFSDK_Annot* pScreen) override {}
void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) override {}
- void OnLink_MouseUp(CPDFSDK_Document* pTarget) override {}
- void OnMenu_Exec(CPDFSDK_Document* pTarget, const CFX_WideString&) override {}
- void OnBatchExec(CPDFSDK_Document* pTarget) override {}
+ void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
+ void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CFX_WideString&) override {}
+ void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) override {}
void OnConsole_Exec() override {}
void OnExternal_Exec() override {}
};
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 3e2bc06f23..d4f17a8b2e 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -80,7 +80,7 @@ CFX_WideString StrTrim(const CFX_WideString& pStr) {
}
void AlertIfPossible(CJS_Context* pContext, const FX_WCHAR* swMsg) {
- CPDFSDK_FormFillEnvironment* pEnv = pContext->GetReaderEnv();
+ CPDFSDK_FormFillEnvironment* pEnv = pContext->GetFormFillEnv();
if (pEnv)
pEnv->JS_appAlert(swMsg, nullptr, 0, 3);
}
@@ -1659,8 +1659,8 @@ FX_BOOL CJS_PublicMethods::AFSimple_Calculate(
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
- CPDFSDK_Document* pReaderDoc = pContext->GetReaderDocument();
- CPDFSDK_InterForm* pReaderInterForm = pReaderDoc->GetInterForm();
+ CPDFSDK_InterForm* pReaderInterForm =
+ pContext->GetFormFillEnv()->GetSDKDocument()->GetInterForm();
CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
CFX_WideString sFunction = params[0].ToCFXWideString(pRuntime);
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index d4f06af144..048bea73c6 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -217,11 +217,11 @@ FX_BOOL app::activeDocs(IJS_Context* cc,
return FALSE;
CJS_Context* pContext = (CJS_Context*)cc;
- CPDFSDK_FormFillEnvironment* pEnv = pContext->GetReaderEnv();
+ CPDFSDK_FormFillEnvironment* pFormFillEnv = pContext->GetFormFillEnv();
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
+ CPDFSDK_Document* pCurDoc = pContext->GetJSRuntime()->GetReaderDocument();
CJS_Array aDocs;
- if (CPDFSDK_Document* pDoc = pEnv->GetSDKDocument()) {
+ if (CPDFSDK_Document* pDoc = pFormFillEnv->GetSDKDocument()) {
CJS_Document* pJSDocument = nullptr;
if (pDoc == pCurDoc) {
v8::Local<v8::Object> pObj = pRuntime->GetThisObj();
@@ -255,9 +255,10 @@ FX_BOOL app::calculate(IJS_Context* cc,
m_bCalculate = (FX_BOOL)bVP;
CJS_Context* pContext = (CJS_Context*)cc;
- CPDFSDK_FormFillEnvironment* pEnv = pContext->GetReaderEnv();
- if (CPDFSDK_Document* pDoc = pEnv->GetSDKDocument())
- pDoc->GetInterForm()->EnableCalculate((FX_BOOL)m_bCalculate);
+ pContext->GetFormFillEnv()
+ ->GetSDKDocument()
+ ->GetInterForm()
+ ->EnableCalculate((FX_BOOL)m_bCalculate);
} else {
vp << (bool)m_bCalculate;
}
@@ -304,8 +305,8 @@ FX_BOOL app::viewerVersion(IJS_Context* cc,
return FALSE;
#ifdef PDF_ENABLE_XFA
CJS_Context* pContext = (CJS_Context*)cc;
- CPDFSDK_Document* pCurDoc = pContext->GetReaderDocument();
- CPDFXFA_Document* pDoc = pCurDoc->GetXFADocument();
+ CPDFXFA_Document* pDoc =
+ pContext->GetFormFillEnv()->GetSDKDocument()->GetXFADocument();
if (pDoc->GetDocType() == 1 || pDoc->GetDocType() == 2) {
vp << JS_NUM_VIEWERVERSION_XFA;
return TRUE;
@@ -433,8 +434,7 @@ FX_BOOL app::alert(IJS_Context* cc,
swTitle = JSGetStringFromID(IDS_STRING_JSALERT);
pRuntime->BeginBlock();
- if (CPDFSDK_Document* pDoc = pEnv->GetSDKDocument())
- pDoc->KillFocusAnnot(0);
+ pEnv->GetSDKDocument()->KillFocusAnnot(0);
vRet = CJS_Value(pRuntime, pEnv->JS_appAlert(swMsg.c_str(), swTitle.c_str(),
iType, iIcon));
@@ -678,9 +678,9 @@ FX_BOOL app::mailMsg(IJS_Context* cc,
pRuntime->BeginBlock();
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- pContext->GetReaderEnv()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(),
- cSubject.c_str(), cCc.c_str(),
- cBcc.c_str(), cMsg.c_str());
+ pContext->GetFormFillEnv()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(),
+ cSubject.c_str(), cCc.c_str(),
+ cBcc.c_str(), cMsg.c_str());
pRuntime->EndBlock();
return TRUE;
}
@@ -793,7 +793,7 @@ FX_BOOL app::response(IJS_Context* cc,
memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2);
CJS_Context* pContext = static_cast<CJS_Context*>(cc);
- int nLengthBytes = pContext->GetReaderEnv()->JS_appResponse(
+ int nLengthBytes = pContext->GetFormFillEnv()->JS_appResponse(
swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(),
bPassword, pBuff.get(), MAX_INPUT_BYTES);
diff --git a/fpdfsdk/javascript/cjs_context.cpp b/fpdfsdk/javascript/cjs_context.cpp
index 89a8a34fd4..d50bc1dd16 100644
--- a/fpdfsdk/javascript/cjs_context.cpp
+++ b/fpdfsdk/javascript/cjs_context.cpp
@@ -17,11 +17,7 @@ CJS_Context::CJS_Context(CJS_Runtime* pRuntime)
CJS_Context::~CJS_Context() {}
-CPDFSDK_Document* CJS_Context::GetReaderDocument() {
- return m_pRuntime->GetReaderDocument();
-}
-
-CPDFSDK_FormFillEnvironment* CJS_Context::GetReaderEnv() {
+CPDFSDK_FormFillEnvironment* CJS_Context::GetFormFillEnv() {
return m_pRuntime->GetReaderEnv();
}
@@ -69,45 +65,45 @@ void CJS_Context::OnApp_Init() {
m_pEventHandler->OnApp_Init();
}
-void CJS_Context::OnDoc_Open(CPDFSDK_Document* pDoc,
+void CJS_Context::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName) {
- m_pEventHandler->OnDoc_Open(pDoc, strTargetName);
+ m_pEventHandler->OnDoc_Open(pFormFillEnv, strTargetName);
}
-void CJS_Context::OnDoc_WillPrint(CPDFSDK_Document* pDoc) {
- m_pEventHandler->OnDoc_WillPrint(pDoc);
+void CJS_Context::OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnDoc_WillPrint(pFormFillEnv);
}
-void CJS_Context::OnDoc_DidPrint(CPDFSDK_Document* pDoc) {
- m_pEventHandler->OnDoc_DidPrint(pDoc);
+void CJS_Context::OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnDoc_DidPrint(pFormFillEnv);
}
-void CJS_Context::OnDoc_WillSave(CPDFSDK_Document* pDoc) {
- m_pEventHandler->OnDoc_WillSave(pDoc);
+void CJS_Context::OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnDoc_WillSave(pFormFillEnv);
}
-void CJS_Context::OnDoc_DidSave(CPDFSDK_Document* pDoc) {
- m_pEventHandler->OnDoc_DidSave(pDoc);
+void CJS_Context::OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnDoc_DidSave(pFormFillEnv);
}
-void CJS_Context::OnDoc_WillClose(CPDFSDK_Document* pDoc) {
- m_pEventHandler->OnDoc_WillClose(pDoc);
+void CJS_Context::OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnDoc_WillClose(pFormFillEnv);
}
-void CJS_Context::OnPage_Open(CPDFSDK_Document* pTarget) {
- m_pEventHandler->OnPage_Open(pTarget);
+void CJS_Context::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnPage_Open(pFormFillEnv);
}
-void CJS_Context::OnPage_Close(CPDFSDK_Document* pTarget) {
- m_pEventHandler->OnPage_Close(pTarget);
+void CJS_Context::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnPage_Close(pFormFillEnv);
}
-void CJS_Context::OnPage_InView(CPDFSDK_Document* pTarget) {
- m_pEventHandler->OnPage_InView(pTarget);
+void CJS_Context::OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnPage_InView(pFormFillEnv);
}
-void CJS_Context::OnPage_OutView(CPDFSDK_Document* pTarget) {
- m_pEventHandler->OnPage_OutView(pTarget);
+void CJS_Context::OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnPage_OutView(pFormFillEnv);
}
void CJS_Context::OnField_MouseDown(FX_BOOL bModifier,
@@ -254,8 +250,8 @@ void CJS_Context::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
m_pEventHandler->OnBookmark_MouseUp(pBookMark);
}
-void CJS_Context::OnLink_MouseUp(CPDFSDK_Document* pTarget) {
- m_pEventHandler->OnLink_MouseUp(pTarget);
+void CJS_Context::OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnLink_MouseUp(pFormFillEnv);
}
void CJS_Context::OnConsole_Exec() {
@@ -266,11 +262,11 @@ void CJS_Context::OnExternal_Exec() {
m_pEventHandler->OnExternal_Exec();
}
-void CJS_Context::OnBatchExec(CPDFSDK_Document* pTarget) {
- m_pEventHandler->OnBatchExec(pTarget);
+void CJS_Context::OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ m_pEventHandler->OnBatchExec(pFormFillEnv);
}
-void CJS_Context::OnMenu_Exec(CPDFSDK_Document* pTarget,
+void CJS_Context::OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName) {
- m_pEventHandler->OnMenu_Exec(pTarget, strTargetName);
+ m_pEventHandler->OnMenu_Exec(pFormFillEnv, strTargetName);
}
diff --git a/fpdfsdk/javascript/cjs_context.h b/fpdfsdk/javascript/cjs_context.h
index 74d4e661c3..b845f8b3d3 100644
--- a/fpdfsdk/javascript/cjs_context.h
+++ b/fpdfsdk/javascript/cjs_context.h
@@ -26,17 +26,17 @@ class CJS_Context : public IJS_Context {
FX_BOOL RunScript(const CFX_WideString& script,
CFX_WideString* info) override;
void OnApp_Init() override;
- void OnDoc_Open(CPDFSDK_Document* pDoc,
+ void OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName) override;
- void OnDoc_WillPrint(CPDFSDK_Document* pDoc) override;
- void OnDoc_DidPrint(CPDFSDK_Document* pDoc) override;
- void OnDoc_WillSave(CPDFSDK_Document* pDoc) override;
- void OnDoc_DidSave(CPDFSDK_Document* pDoc) override;
- void OnDoc_WillClose(CPDFSDK_Document* pDoc) override;
- void OnPage_Open(CPDFSDK_Document* pTarget) override;
- void OnPage_Close(CPDFSDK_Document* pTarget) override;
- void OnPage_InView(CPDFSDK_Document* pTarget) override;
- void OnPage_OutView(CPDFSDK_Document* pTarget) override;
+ void OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
void OnField_MouseDown(FX_BOOL bModifier,
FX_BOOL bShift,
CPDF_FormField* pTarget) override;
@@ -115,18 +115,17 @@ class CJS_Context : public IJS_Context {
FX_BOOL bShift,
CPDFSDK_Annot* pScreen) override;
void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) override;
- void OnLink_MouseUp(CPDFSDK_Document* pTarget) override;
- void OnMenu_Exec(CPDFSDK_Document* pTarget,
+ void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
+ void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName) override;
- void OnBatchExec(CPDFSDK_Document* pTarget) override;
+ void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) override;
void OnConsole_Exec() override;
void OnExternal_Exec() override;
CJS_Runtime* GetJSRuntime() const { return m_pRuntime; }
CJS_EventHandler* GetEventHandler() const { return m_pEventHandler.get(); }
- CPDFSDK_FormFillEnvironment* GetReaderEnv();
- CPDFSDK_Document* GetReaderDocument();
+ CPDFSDK_FormFillEnvironment* GetFormFillEnv();
private:
CJS_Runtime* const m_pRuntime;
diff --git a/fpdfsdk/javascript/ijs_context.h b/fpdfsdk/javascript/ijs_context.h
index cfeed3050d..859d09524b 100644
--- a/fpdfsdk/javascript/ijs_context.h
+++ b/fpdfsdk/javascript/ijs_context.h
@@ -13,7 +13,7 @@
class CPDF_Bookmark;
class CPDF_FormField;
class CPDFSDK_Annot;
-class CPDFSDK_Document;
+class CPDFSDK_FormFillEnvironment;
// Records the details of an event and triggers JS execution for it.
class IJS_Context {
@@ -23,18 +23,18 @@ class IJS_Context {
virtual void OnApp_Init() = 0;
- virtual void OnDoc_Open(CPDFSDK_Document* pDoc,
+ virtual void OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& strTargetName) = 0;
- virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0;
- virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0;
- virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0;
- virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0;
- virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0;
+ virtual void OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
+ virtual void OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
+ virtual void OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
+ virtual void OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
+ virtual void OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
- virtual void OnPage_Open(CPDFSDK_Document* pTarget) = 0;
- virtual void OnPage_Close(CPDFSDK_Document* pTarget) = 0;
- virtual void OnPage_InView(CPDFSDK_Document* pTarget) = 0;
- virtual void OnPage_OutView(CPDFSDK_Document* pTarget) = 0;
+ virtual void OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
+ virtual void OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
+ virtual void OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
+ virtual void OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
virtual void OnField_MouseDown(FX_BOOL bModifier,
FX_BOOL bShift,
@@ -117,11 +117,11 @@ class IJS_Context {
CPDFSDK_Annot* pScreen) = 0;
virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0;
- virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget) = 0;
+ virtual void OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
- virtual void OnMenu_Exec(CPDFSDK_Document* pTarget,
+ virtual void OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString&) = 0;
- virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0;
+ virtual void OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) = 0;
virtual void OnConsole_Exec() = 0;
virtual void OnExternal_Exec() = 0;