summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfformfill.cpp
diff options
context:
space:
mode:
authortonikitoo <tonikitoo@igalia.com>2016-08-10 11:37:45 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-10 11:37:45 -0700
commit401d4f235114d7857c9c284a70cbb53a3e49bca1 (patch)
treede6517b79518c675658b13c98b106b331074de0f /fpdfsdk/fpdfformfill.cpp
parent4e62b5c7c5a35c7020d581fb65de4b3fc5ad3c1a (diff)
downloadpdfium-401d4f235114d7857c9c284a70cbb53a3e49bca1.tar.xz
Use CPDFSDK_Document::FromFPDFFormHandle in ::FORM_DoPageAAction
... rather then doing c-style type cast. CL also tweaks the method body a bit to have more early-returns rather than too-nested-if blocks. No behavior change is expected, so no new tests are being added. Review-Url: https://codereview.chromium.org/2230983003
Diffstat (limited to 'fpdfsdk/fpdfformfill.cpp')
-rw-r--r--fpdfsdk/fpdfformfill.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index 253091789c..8d5b4b789d 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -704,26 +704,32 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
int aaType) {
if (!hHandle)
return;
- CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
+
+ CPDFSDK_Document* pSDKDoc = CPDFSDK_Document::FromFPDFFormHandle(hHandle);
+ if (!pSDKDoc)
+ return;
+
UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page);
if (!pPDFPage)
return;
- if (pSDKDoc->GetPageView(pPage, false)) {
- CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();
- CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
- CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict;
- CPDF_AAction aa(pPageDict->GetDictBy("AA"));
- 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);
- }
- } else {
- if (aa.ActionExist(CPDF_AAction::ClosePage)) {
- CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
- pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
- }
+
+ if (!pSDKDoc->GetPageView(pPage, false))
+ return;
+
+ CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();
+ CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
+ CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict;
+ CPDF_AAction aa(pPageDict->GetDictBy("AA"));
+ 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);
+ }
+ } else {
+ if (aa.ActionExist(CPDF_AAction::ClosePage)) {
+ CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
+ pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, pSDKDoc);
}
}
}