summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/cpdfsdk_document.cpp4
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp6
-rw-r--r--fpdfsdk/cpdfsdk_widget.cpp4
-rw-r--r--fpdfsdk/fpdfformfill.cpp6
-rw-r--r--fpdfsdk/fsdk_actionhandler.cpp302
-rw-r--r--fpdfsdk/fsdk_actionhandler.h72
6 files changed, 208 insertions, 186 deletions
diff --git a/fpdfsdk/cpdfsdk_document.cpp b/fpdfsdk/cpdfsdk_document.cpp
index a3d2680f91..37d977ec4c 100644
--- a/fpdfsdk/cpdfsdk_document.cpp
+++ b/fpdfsdk/cpdfsdk_document.cpp
@@ -97,7 +97,7 @@ void CPDFSDK_Document::ProcJavascriptFun() {
CPDF_Action jsAction = docJS.GetJSAction(i, csJSName);
if (m_pEnv->GetActionHander())
m_pEnv->GetActionHander()->DoAction_JavaScript(
- jsAction, CFX_WideString::FromLocal(csJSName.AsStringC()), this);
+ jsAction, CFX_WideString::FromLocal(csJSName.AsStringC()), GetEnv());
}
}
@@ -122,7 +122,7 @@ FX_BOOL CPDFSDK_Document::ProcOpenAction() {
if (CPDF_Dictionary* pDict = pOpenAction->AsDictionary()) {
CPDF_Action action(pDict);
if (m_pEnv->GetActionHander())
- m_pEnv->GetActionHander()->DoAction_DocOpen(action, this);
+ m_pEnv->GetActionHander()->DoAction_DocOpen(action, GetEnv());
return TRUE;
}
return FALSE;
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index 69698ea421..005079dda9 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -363,8 +363,7 @@ FX_BOOL CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField,
fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0);
fa.sValue = csValue;
pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::KeyStroke,
- m_pFormFillEnv->GetSDKDocument(),
- pFormField, fa);
+ m_pFormFillEnv, pFormField, fa);
return fa.bRC;
}
@@ -384,8 +383,7 @@ FX_BOOL CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField,
fa.bShift = m_pFormFillEnv->IsSHIFTKeyDown(0);
fa.sValue = csValue;
pActionHandler->DoAction_FieldJavaScript(action, CPDF_AAction::Validate,
- m_pFormFillEnv->GetSDKDocument(),
- pFormField, fa);
+ m_pFormFillEnv, pFormField, fa);
return fa.bRC;
}
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index 12f915802d..4ce7d9a48a 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -1875,8 +1875,8 @@ FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type,
CPDF_Action action = GetAAction(type);
if (action.GetDict() && action.GetType() != CPDF_Action::Unknown) {
CPDFSDK_ActionHandler* pActionHandler = pFormFillEnv->GetActionHander();
- return pActionHandler->DoAction_Field(
- action, type, pFormFillEnv->GetSDKDocument(), GetFormField(), data);
+ return pActionHandler->DoAction_Field(action, type, pFormFillEnv,
+ GetFormField(), data);
}
return FALSE;
}
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index fd083c9dcd..050a401f02 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -708,7 +708,7 @@ DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
CPDFSDK_ActionHandler* pActionHandler =
HandleToCPDFSDKEnvironment(hHandle)->GetActionHander();
pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType,
- pSDKDoc);
+ pSDKDoc->GetEnv());
}
}
@@ -737,12 +737,12 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
if (FPDFPAGE_AACTION_OPEN == aaType) {
if (aa.ActionExist(CPDF_AAction::OpenPage)) {
CPDF_Action action = aa.GetAction(CPDF_AAction::OpenPage);
- pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pSDKDoc);
+ pActionHandler->DoAction_Page(action, CPDF_AAction::OpenPage, pEnv);
}
} else {
if (aa.ActionExist(CPDF_AAction::ClosePage)) {
CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
- pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
+ pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pEnv);
}
}
}
diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp
index 8a2b1fa768..a7a7940b89 100644
--- a/fpdfsdk/fsdk_actionhandler.cpp
+++ b/fpdfsdk/fsdk_actionhandler.cpp
@@ -19,20 +19,21 @@
#include "fpdfsdk/javascript/ijs_runtime.h"
#include "third_party/base/stl_util.h"
-FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(const CPDF_Action& action,
- CPDFSDK_Document* pDocument) {
+FX_BOOL CPDFSDK_ActionHandler::DoAction_DocOpen(
+ const CPDF_Action& action,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
std::set<CPDF_Dictionary*> visited;
- return ExecuteDocumentOpenAction(action, pDocument, &visited);
+ return ExecuteDocumentOpenAction(action, pFormFillEnv, &visited);
}
FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript(
const CPDF_Action& JsAction,
CFX_WideString csJSName,
- CPDFSDK_Document* pDocument) {
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
if (JsAction.GetType() == CPDF_Action::JavaScript) {
CFX_WideString swJS = JsAction.GetJavaScript();
if (!swJS.IsEmpty()) {
- RunDocumentOpenJavaScript(pDocument, csJSName, swJS);
+ RunDocumentOpenJavaScript(pFormFillEnv, csJSName, swJS);
return TRUE;
}
}
@@ -43,15 +44,15 @@ FX_BOOL CPDFSDK_ActionHandler::DoAction_JavaScript(
FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript(
const CPDF_Action& JsAction,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
PDFSDK_FieldAction& data) {
- CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv);
- if (pEnv->IsJSInitiated() && JsAction.GetType() == CPDF_Action::JavaScript) {
+ ASSERT(pFormFillEnv);
+ if (pFormFillEnv->IsJSInitiated() &&
+ JsAction.GetType() == CPDF_Action::JavaScript) {
CFX_WideString swJS = JsAction.GetJavaScript();
if (!swJS.IsEmpty()) {
- RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
+ RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS);
return TRUE;
}
}
@@ -61,54 +62,58 @@ FX_BOOL CPDFSDK_ActionHandler::DoAction_FieldJavaScript(
FX_BOOL CPDFSDK_ActionHandler::DoAction_Page(
const CPDF_Action& action,
enum CPDF_AAction::AActionType eType,
- CPDFSDK_Document* pDocument) {
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
std::set<CPDF_Dictionary*> visited;
- return ExecuteDocumentPageAction(action, eType, pDocument, &visited);
+ return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited);
}
FX_BOOL CPDFSDK_ActionHandler::DoAction_Document(
const CPDF_Action& action,
enum CPDF_AAction::AActionType eType,
- CPDFSDK_Document* pDocument) {
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
std::set<CPDF_Dictionary*> visited;
- return ExecuteDocumentPageAction(action, eType, pDocument, &visited);
+ return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited);
}
-FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(CPDF_Bookmark* pBookMark,
- const CPDF_Action& action,
- CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument) {
+FX_BOOL CPDFSDK_ActionHandler::DoAction_BookMark(
+ CPDF_Bookmark* pBookMark,
+ const CPDF_Action& action,
+ CPDF_AAction::AActionType type,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
std::set<CPDF_Dictionary*> visited;
- return ExecuteBookMark(action, pDocument, pBookMark, &visited);
+ return ExecuteBookMark(action, pFormFillEnv, pBookMark, &visited);
}
-FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(const CPDF_Action& action,
- CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
- CPDFSDK_Annot* pScreen) {
+FX_BOOL CPDFSDK_ActionHandler::DoAction_Screen(
+ const CPDF_Action& action,
+ CPDF_AAction::AActionType type,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDFSDK_Annot* pScreen) {
std::set<CPDF_Dictionary*> visited;
- return ExecuteScreenAction(action, type, pDocument, pScreen, &visited);
+ return ExecuteScreenAction(action, type, pFormFillEnv, pScreen, &visited);
}
-FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(const CPDF_Action& action,
- CPDFSDK_Document* pDocument) {
+FX_BOOL CPDFSDK_ActionHandler::DoAction_Link(
+ const CPDF_Action& action,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
std::set<CPDF_Dictionary*> visited;
- return ExecuteLinkAction(action, pDocument, &visited);
+ return ExecuteLinkAction(action, pFormFillEnv, &visited);
}
-FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(const CPDF_Action& action,
- CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
- CPDF_FormField* pFormField,
- PDFSDK_FieldAction& data) {
+FX_BOOL CPDFSDK_ActionHandler::DoAction_Field(
+ const CPDF_Action& action,
+ CPDF_AAction::AActionType type,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_FormField* pFormField,
+ PDFSDK_FieldAction& data) {
std::set<CPDF_Dictionary*> visited;
- return ExecuteFieldAction(action, type, pDocument, pFormField, data,
+ return ExecuteFieldAction(action, type, pFormFillEnv, pFormField, data,
&visited);
}
FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
const CPDF_Action& action,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
std::set<CPDF_Dictionary*>* visited) {
CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
@@ -116,22 +121,21 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
visited->insert(pDict);
- CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv);
+ ASSERT(pFormFillEnv);
if (action.GetType() == CPDF_Action::JavaScript) {
- if (pEnv->IsJSInitiated()) {
+ if (pFormFillEnv->IsJSInitiated()) {
CFX_WideString swJS = action.GetJavaScript();
if (!swJS.IsEmpty()) {
- RunDocumentOpenJavaScript(pDocument, L"", swJS);
+ RunDocumentOpenJavaScript(pFormFillEnv, L"", swJS);
}
}
} else {
- DoAction_NoJs(action, pDocument);
+ DoAction_NoJs(action, pFormFillEnv);
}
for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
CPDF_Action subaction = action.GetSubAction(i);
- if (!ExecuteDocumentOpenAction(subaction, pDocument, visited))
+ if (!ExecuteDocumentOpenAction(subaction, pFormFillEnv, visited))
return FALSE;
}
@@ -140,7 +144,7 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(
const CPDF_Action& action,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
std::set<CPDF_Dictionary*>* visited) {
CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
@@ -148,7 +152,6 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(
visited->insert(pDict);
- CPDFSDK_FormFillEnvironment* pFormFillEnv = pDocument->GetEnv();
ASSERT(pFormFillEnv);
if (action.GetType() == CPDF_Action::JavaScript) {
if (pFormFillEnv->IsJSInitiated()) {
@@ -168,12 +171,12 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(
}
}
} else {
- DoAction_NoJs(action, pDocument);
+ DoAction_NoJs(action, pFormFillEnv);
}
for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
CPDF_Action subaction = action.GetSubAction(i);
- if (!ExecuteLinkAction(subaction, pDocument, visited))
+ if (!ExecuteLinkAction(subaction, pFormFillEnv, visited))
return FALSE;
}
@@ -183,7 +186,7 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteLinkAction(
FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction(
const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
std::set<CPDF_Dictionary*>* visited) {
CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
@@ -191,36 +194,37 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteDocumentPageAction(
visited->insert(pDict);
- CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv);
+ ASSERT(pFormFillEnv);
if (action.GetType() == CPDF_Action::JavaScript) {
- if (pEnv->IsJSInitiated()) {
+ if (pFormFillEnv->IsJSInitiated()) {
CFX_WideString swJS = action.GetJavaScript();
if (!swJS.IsEmpty()) {
- RunDocumentPageJavaScript(pDocument, type, swJS);
+ RunDocumentPageJavaScript(pFormFillEnv, type, swJS);
}
}
} else {
- DoAction_NoJs(action, pDocument);
+ DoAction_NoJs(action, pFormFillEnv);
}
- if (!IsValidDocView(pDocument))
+ if (!IsValidDocView(pFormFillEnv))
return FALSE;
for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
CPDF_Action subaction = action.GetSubAction(i);
- if (!ExecuteDocumentPageAction(subaction, type, pDocument, visited))
+ if (!ExecuteDocumentPageAction(subaction, type, pFormFillEnv, visited))
return FALSE;
}
return TRUE;
}
-FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument,
- CPDF_Dictionary* pFieldDict) {
+FX_BOOL CPDFSDK_ActionHandler::IsValidField(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_Dictionary* pFieldDict) {
ASSERT(pFieldDict);
- CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
+ CPDFSDK_InterForm* pInterForm =
+ pFormFillEnv->GetSDKDocument()->GetInterForm();
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
return !!pPDFInterForm->GetFieldByDict(pFieldDict);
}
@@ -228,7 +232,7 @@ FX_BOOL CPDFSDK_ActionHandler::IsValidField(CPDFSDK_Document* pDocument,
FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction(
const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
PDFSDK_FieldAction& data,
std::set<CPDF_Dictionary*>* visited) {
@@ -238,24 +242,23 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction(
visited->insert(pDict);
- CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv);
+ ASSERT(pFormFillEnv);
if (action.GetType() == CPDF_Action::JavaScript) {
- if (pEnv->IsJSInitiated()) {
+ if (pFormFillEnv->IsJSInitiated()) {
CFX_WideString swJS = action.GetJavaScript();
if (!swJS.IsEmpty()) {
- RunFieldJavaScript(pDocument, pFormField, type, data, swJS);
- if (!IsValidField(pDocument, pFormField->GetFieldDict()))
+ RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS);
+ if (!IsValidField(pFormFillEnv, pFormField->GetFieldDict()))
return FALSE;
}
}
} else {
- DoAction_NoJs(action, pDocument);
+ DoAction_NoJs(action, pFormFillEnv);
}
for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
CPDF_Action subaction = action.GetSubAction(i);
- if (!ExecuteFieldAction(subaction, type, pDocument, pFormField, data,
+ if (!ExecuteFieldAction(subaction, type, pFormFillEnv, pFormField, data,
visited))
return FALSE;
}
@@ -266,7 +269,7 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteFieldAction(
FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(
const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDFSDK_Annot* pScreen,
std::set<CPDF_Dictionary*>* visited) {
CPDF_Dictionary* pDict = action.GetDict();
@@ -275,13 +278,12 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(
visited->insert(pDict);
- CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv);
+ 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();
IJS_Context* pContext = pRuntime->NewContext();
CFX_WideString csInfo;
FX_BOOL bRet = pContext->RunScript(swJS, &csInfo);
@@ -293,12 +295,12 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(
}
}
} else {
- DoAction_NoJs(action, pDocument);
+ DoAction_NoJs(action, pFormFillEnv);
}
for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
CPDF_Action subaction = action.GetSubAction(i);
- if (!ExecuteScreenAction(subaction, type, pDocument, pScreen, visited))
+ if (!ExecuteScreenAction(subaction, type, pFormFillEnv, pScreen, visited))
return FALSE;
}
@@ -307,7 +309,7 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteScreenAction(
FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(
const CPDF_Action& action,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_Bookmark* pBookmark,
std::set<CPDF_Dictionary*>* visited) {
CPDF_Dictionary* pDict = action.GetDict();
@@ -316,13 +318,12 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(
visited->insert(pDict);
- CPDFSDK_FormFillEnvironment* pEnv = pDocument->GetEnv();
- ASSERT(pEnv);
+ 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();
IJS_Context* pContext = pRuntime->NewContext();
pContext->OnBookmark_MouseUp(pBookmark);
@@ -336,63 +337,64 @@ FX_BOOL CPDFSDK_ActionHandler::ExecuteBookMark(
}
}
} else {
- DoAction_NoJs(action, pDocument);
+ DoAction_NoJs(action, pFormFillEnv);
}
for (int32_t i = 0, sz = action.GetSubActionsCount(); i < sz; i++) {
CPDF_Action subaction = action.GetSubAction(i);
- if (!ExecuteBookMark(subaction, pDocument, pBookmark, visited))
+ if (!ExecuteBookMark(subaction, pFormFillEnv, pBookmark, visited))
return FALSE;
}
return TRUE;
}
-void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action,
- CPDFSDK_Document* pDocument) {
- ASSERT(pDocument);
+void CPDFSDK_ActionHandler::DoAction_NoJs(
+ const CPDF_Action& action,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ ASSERT(pFormFillEnv);
switch (action.GetType()) {
case CPDF_Action::GoTo:
- DoAction_GoTo(pDocument, action);
+ DoAction_GoTo(pFormFillEnv, action);
break;
case CPDF_Action::GoToR:
- DoAction_GoToR(pDocument, action);
+ DoAction_GoToR(pFormFillEnv, action);
break;
case CPDF_Action::GoToE:
break;
case CPDF_Action::Launch:
- DoAction_Launch(pDocument, action);
+ DoAction_Launch(pFormFillEnv, action);
break;
case CPDF_Action::Thread:
break;
case CPDF_Action::URI:
- DoAction_URI(pDocument, action);
+ DoAction_URI(pFormFillEnv, action);
break;
case CPDF_Action::Sound:
break;
case CPDF_Action::Movie:
break;
case CPDF_Action::Hide:
- DoAction_Hide(action, pDocument);
+ DoAction_Hide(action, pFormFillEnv);
break;
case CPDF_Action::Named:
- DoAction_Named(pDocument, action);
+ DoAction_Named(pFormFillEnv, action);
break;
case CPDF_Action::SubmitForm:
- DoAction_SubmitForm(action, pDocument);
+ DoAction_SubmitForm(action, pFormFillEnv);
break;
case CPDF_Action::ResetForm:
- DoAction_ResetForm(action, pDocument);
+ DoAction_ResetForm(action, pFormFillEnv);
break;
case CPDF_Action::ImportData:
- DoAction_ImportData(action, pDocument);
+ DoAction_ImportData(action, pFormFillEnv);
break;
case CPDF_Action::JavaScript:
ASSERT(FALSE);
break;
case CPDF_Action::SetOCGState:
- DoAction_SetOCGState(pDocument, action);
+ DoAction_SetOCGState(pFormFillEnv, action);
break;
case CPDF_Action::Rendition:
break;
@@ -405,16 +407,19 @@ void CPDFSDK_ActionHandler::DoAction_NoJs(const CPDF_Action& action,
}
}
-FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(CPDFSDK_Document* pDocument) {
- ASSERT(pDocument);
+FX_BOOL CPDFSDK_ActionHandler::IsValidDocView(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ ASSERT(pFormFillEnv);
return TRUE;
}
-void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
- const CPDF_Action& action) {
+void CPDFSDK_ActionHandler::DoAction_GoTo(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action) {
ASSERT(action.GetDict());
- CPDF_Document* pPDFDocument = pDocument->GetPDFDocument();
+ CPDF_Document* pPDFDocument =
+ pFormFillEnv->GetSDKDocument()->GetPDFDocument();
ASSERT(pPDFDocument);
CPDF_Dest MyDest = action.GetDest(pPDFDocument);
@@ -432,46 +437,51 @@ void CPDFSDK_ActionHandler::DoAction_GoTo(CPDFSDK_Document* pDocument,
sizeOfAry = j;
}
- CPDFSDK_FormFillEnvironment* pApp = pDocument->GetEnv();
- pApp->DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
+ pFormFillEnv->DoGoToAction(nPageIndex, nFitType, pPosAry, sizeOfAry);
delete[] pPosAry;
}
-void CPDFSDK_ActionHandler::DoAction_GoToR(CPDFSDK_Document* pDocument,
- const CPDF_Action& action) {}
+void CPDFSDK_ActionHandler::DoAction_GoToR(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action) {}
-void CPDFSDK_ActionHandler::DoAction_Launch(CPDFSDK_Document* pDocument,
- const CPDF_Action& action) {}
+void CPDFSDK_ActionHandler::DoAction_Launch(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action) {}
-void CPDFSDK_ActionHandler::DoAction_URI(CPDFSDK_Document* pDocument,
- const CPDF_Action& action) {
+void CPDFSDK_ActionHandler::DoAction_URI(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action) {
ASSERT(action.GetDict());
- CPDFSDK_FormFillEnvironment* pApp = pDocument->GetEnv();
- CFX_ByteString sURI = action.GetURI(pDocument->GetPDFDocument());
- pApp->DoURIAction(sURI.c_str());
+ CFX_ByteString sURI =
+ action.GetURI(pFormFillEnv->GetSDKDocument()->GetPDFDocument());
+ pFormFillEnv->DoURIAction(sURI.c_str());
}
-void CPDFSDK_ActionHandler::DoAction_Named(CPDFSDK_Document* pDocument,
- const CPDF_Action& action) {
+void CPDFSDK_ActionHandler::DoAction_Named(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action) {
ASSERT(action.GetDict());
CFX_ByteString csName = action.GetNamedAction();
- pDocument->GetEnv()->ExecuteNamedAction(csName.c_str());
+ pFormFillEnv->ExecuteNamedAction(csName.c_str());
}
-void CPDFSDK_ActionHandler::DoAction_SetOCGState(CPDFSDK_Document* pDocument,
- const CPDF_Action& action) {}
+void CPDFSDK_ActionHandler::DoAction_SetOCGState(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action) {}
-void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument,
- CPDF_FormField* pFormField,
- CPDF_AAction::AActionType type,
- PDFSDK_FieldAction& data,
- const CFX_WideString& script) {
+void CPDFSDK_ActionHandler::RunFieldJavaScript(
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ CPDF_FormField* pFormField,
+ CPDF_AAction::AActionType type,
+ PDFSDK_FieldAction& data,
+ const CFX_WideString& script) {
ASSERT(type != CPDF_AAction::Calculate);
ASSERT(type != CPDF_AAction::Format);
- IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
+ IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
IJS_Context* pContext = pRuntime->NewContext();
switch (type) {
case CPDF_AAction::CursorEnter:
@@ -520,12 +530,12 @@ void CPDFSDK_ActionHandler::RunFieldJavaScript(CPDFSDK_Document* pDocument,
}
void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& sScriptName,
const CFX_WideString& script) {
- IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
+ IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
IJS_Context* pContext = pRuntime->NewContext();
- pContext->OnDoc_Open(pDocument->GetEnv(), sScriptName);
+ pContext->OnDoc_Open(pFormFillEnv, sScriptName);
CFX_WideString csInfo;
FX_BOOL bRet = pContext->RunScript(script, &csInfo);
@@ -537,38 +547,38 @@ void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(
}
void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_AAction::AActionType type,
const CFX_WideString& script) {
- IJS_Runtime* pRuntime = pDocument->GetJsRuntime();
+ IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
IJS_Context* pContext = pRuntime->NewContext();
switch (type) {
case CPDF_AAction::OpenPage:
- pContext->OnPage_Open(pDocument->GetEnv());
+ pContext->OnPage_Open(pFormFillEnv);
break;
case CPDF_AAction::ClosePage:
- pContext->OnPage_Close(pDocument->GetEnv());
+ pContext->OnPage_Close(pFormFillEnv);
break;
case CPDF_AAction::CloseDocument:
- pContext->OnDoc_WillClose(pDocument->GetEnv());
+ pContext->OnDoc_WillClose(pFormFillEnv);
break;
case CPDF_AAction::SaveDocument:
- pContext->OnDoc_WillSave(pDocument->GetEnv());
+ pContext->OnDoc_WillSave(pFormFillEnv);
break;
case CPDF_AAction::DocumentSaved:
- pContext->OnDoc_DidSave(pDocument->GetEnv());
+ pContext->OnDoc_DidSave(pFormFillEnv);
break;
case CPDF_AAction::PrintDocument:
- pContext->OnDoc_WillPrint(pDocument->GetEnv());
+ pContext->OnDoc_WillPrint(pFormFillEnv);
break;
case CPDF_AAction::DocumentPrinted:
- pContext->OnDoc_DidPrint(pDocument->GetEnv());
+ pContext->OnDoc_DidPrint(pFormFillEnv);
break;
case CPDF_AAction::PageVisible:
- pContext->OnPage_InView(pDocument->GetEnv());
+ pContext->OnPage_InView(pFormFillEnv);
break;
case CPDF_AAction::PageInvisible:
- pContext->OnPage_OutView(pDocument->GetEnv());
+ pContext->OnPage_OutView(pFormFillEnv);
break;
default:
ASSERT(FALSE);
@@ -584,11 +594,13 @@ void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(
pRuntime->ReleaseContext(pContext);
}
-FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide(const CPDF_Action& action,
- CPDFSDK_Document* pDocument) {
- CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
+FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide(
+ const CPDF_Action& action,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ CPDFSDK_InterForm* pInterForm =
+ pFormFillEnv->GetSDKDocument()->GetInterForm();
if (pInterForm->DoAction_Hide(action)) {
- pDocument->SetChangeMark();
+ pFormFillEnv->GetSDKDocument()->SetChangeMark();
return TRUE;
}
@@ -597,23 +609,27 @@ FX_BOOL CPDFSDK_ActionHandler::DoAction_Hide(const CPDF_Action& action,
FX_BOOL CPDFSDK_ActionHandler::DoAction_SubmitForm(
const CPDF_Action& action,
- CPDFSDK_Document* pDocument) {
- CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ CPDFSDK_InterForm* pInterForm =
+ pFormFillEnv->GetSDKDocument()->GetInterForm();
return pInterForm->DoAction_SubmitForm(action);
}
-FX_BOOL CPDFSDK_ActionHandler::DoAction_ResetForm(const CPDF_Action& action,
- CPDFSDK_Document* pDocument) {
- CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
+FX_BOOL CPDFSDK_ActionHandler::DoAction_ResetForm(
+ const CPDF_Action& action,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ CPDFSDK_InterForm* pInterForm =
+ pFormFillEnv->GetSDKDocument()->GetInterForm();
return pInterForm->DoAction_ResetForm(action);
}
FX_BOOL CPDFSDK_ActionHandler::DoAction_ImportData(
const CPDF_Action& action,
- CPDFSDK_Document* pDocument) {
- CPDFSDK_InterForm* pInterForm = pDocument->GetInterForm();
+ CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ CPDFSDK_InterForm* pInterForm =
+ pFormFillEnv->GetSDKDocument()->GetInterForm();
if (pInterForm->DoAction_ImportData(action)) {
- pDocument->SetChangeMark();
+ pFormFillEnv->GetSDKDocument()->SetChangeMark();
return TRUE;
}
diff --git a/fpdfsdk/fsdk_actionhandler.h b/fpdfsdk/fsdk_actionhandler.h
index 0745fa32f8..6eff835c5d 100644
--- a/fpdfsdk/fsdk_actionhandler.h
+++ b/fpdfsdk/fsdk_actionhandler.h
@@ -16,7 +16,7 @@
#include "fpdfsdk/pdfsdk_fieldaction.h"
class CPDFSDK_Annot;
-class CPDFSDK_Document;
+class CPDFSDK_FormFillEnvironment;
class CPDF_Bookmark;
class CPDF_Dictionary;
class CPDF_FormField;
@@ -24,95 +24,103 @@ class CPDF_FormField;
class CPDFSDK_ActionHandler {
public:
FX_BOOL DoAction_DocOpen(const CPDF_Action& action,
- CPDFSDK_Document* pDocument);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_JavaScript(const CPDF_Action& JsAction,
CFX_WideString csJSName,
- CPDFSDK_Document* pDocument);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_Page(const CPDF_Action& action,
enum CPDF_AAction::AActionType eType,
- CPDFSDK_Document* pDocument);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_Document(const CPDF_Action& action,
enum CPDF_AAction::AActionType eType,
- CPDFSDK_Document* pDocument);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_BookMark(CPDF_Bookmark* pBookMark,
const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_Screen(const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDFSDK_Annot* pScreen);
- FX_BOOL DoAction_Link(const CPDF_Action& action, CPDFSDK_Document* pDocument);
+ FX_BOOL DoAction_Link(const CPDF_Action& action,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_Field(const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
PDFSDK_FieldAction& data);
FX_BOOL DoAction_FieldJavaScript(const CPDF_Action& JsAction,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
PDFSDK_FieldAction& data);
private:
FX_BOOL ExecuteDocumentOpenAction(const CPDF_Action& action,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
std::set<CPDF_Dictionary*>* visited);
FX_BOOL ExecuteDocumentPageAction(const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
std::set<CPDF_Dictionary*>* visited);
FX_BOOL ExecuteFieldAction(const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
PDFSDK_FieldAction& data,
std::set<CPDF_Dictionary*>* visited);
FX_BOOL ExecuteScreenAction(const CPDF_Action& action,
CPDF_AAction::AActionType type,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDFSDK_Annot* pScreen,
std::set<CPDF_Dictionary*>* visited);
FX_BOOL ExecuteBookMark(const CPDF_Action& action,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_Bookmark* pBookmark,
std::set<CPDF_Dictionary*>* visited);
FX_BOOL ExecuteLinkAction(const CPDF_Action& action,
- CPDFSDK_Document* pDocument,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv,
std::set<CPDF_Dictionary*>* visited);
- void DoAction_NoJs(const CPDF_Action& action, CPDFSDK_Document* pDocument);
- void RunDocumentPageJavaScript(CPDFSDK_Document* pDocument,
+ void DoAction_NoJs(const CPDF_Action& action,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
+ void RunDocumentPageJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_AAction::AActionType type,
const CFX_WideString& script);
- void RunDocumentOpenJavaScript(CPDFSDK_Document* pDocument,
+ void RunDocumentOpenJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CFX_WideString& sScriptName,
const CFX_WideString& script);
- void RunFieldJavaScript(CPDFSDK_Document* pDocument,
+ void RunFieldJavaScript(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
CPDF_AAction::AActionType type,
PDFSDK_FieldAction& data,
const CFX_WideString& script);
- FX_BOOL IsValidField(CPDFSDK_Document* pDocument,
+ FX_BOOL IsValidField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_Dictionary* pFieldDict);
- FX_BOOL IsValidDocView(CPDFSDK_Document* pDocument);
+ FX_BOOL IsValidDocView(CPDFSDK_FormFillEnvironment* pFormFillEnv);
- void DoAction_GoTo(CPDFSDK_Document* pDocument, const CPDF_Action& action);
- void DoAction_GoToR(CPDFSDK_Document* pDocument, const CPDF_Action& action);
- void DoAction_Launch(CPDFSDK_Document* pDocument, const CPDF_Action& action);
- void DoAction_URI(CPDFSDK_Document* pDocument, const CPDF_Action& action);
- void DoAction_Named(CPDFSDK_Document* pDocument, const CPDF_Action& action);
- void DoAction_SetOCGState(CPDFSDK_Document* pDocument,
+ void DoAction_GoTo(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action);
+ void DoAction_GoToR(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action);
+ void DoAction_Launch(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action);
+ void DoAction_URI(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action);
+ void DoAction_Named(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+ const CPDF_Action& action);
+ void DoAction_SetOCGState(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const CPDF_Action& action);
- FX_BOOL DoAction_Hide(const CPDF_Action& action, CPDFSDK_Document* pDocument);
+ FX_BOOL DoAction_Hide(const CPDF_Action& action,
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_SubmitForm(const CPDF_Action& action,
- CPDFSDK_Document* pDocument);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_ResetForm(const CPDF_Action& action,
- CPDFSDK_Document* pDocument);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
FX_BOOL DoAction_ImportData(const CPDF_Action& action,
- CPDFSDK_Document* pDocument);
+ CPDFSDK_FormFillEnvironment* pFormFillEnv);
};
#endif // FPDFSDK_FSDK_ACTIONHANDLER_H_