Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Unified Diff: fpdfsdk/fsdk_actionhandler.cpp

Issue 2397933003: Convert CPDFSDK_ActionHandler to CPDFSDK_FormFillEnvironment (Closed)
Patch Set: Rebase to master Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/fsdk_actionhandler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/fsdk_actionhandler.cpp
diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp
index 8a2b1fa768001b7fead92c205f24221aa6983b15..a7a7940b898b09839f9ecdb46fb7d138e39aa076 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;
}
« no previous file with comments | « fpdfsdk/fsdk_actionhandler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698