summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfformfill.cpp60
1 files changed, 18 insertions, 42 deletions
diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp
index fb12967bde..00b8300095 100644
--- a/fpdfsdk/fpdfformfill.cpp
+++ b/fpdfsdk/fpdfformfill.cpp
@@ -201,11 +201,7 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
CFX_RectF rcBBox = pXFAAnnot->GetBBox(0);
CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width,
rcBBox.top + rcBBox.height);
- rcWidget.left -= 1.0f;
- rcWidget.right += 1.0f;
- rcWidget.bottom -= 1.0f;
- rcWidget.top += 1.0f;
-
+ rcWidget.Inflate(1.0f, 1.0f);
if (rcWidget.Contains(CFX_PointF(static_cast<float>(page_x),
static_cast<float>(page_y)))) {
return FPDF_FORMFIELD_XFA;
@@ -275,11 +271,10 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
DLLEXPORT void STDCALL
FPDFDOC_ExitFormFillEnvironment(FPDF_FORMHANDLE hHandle) {
- if (!hHandle)
- return;
-
CPDFSDK_FormFillEnvironment* pFormFillEnv =
HandleToCPDFSDKEnvironment(hHandle);
+ if (!pFormFillEnv)
+ return;
#ifdef PDF_ENABLE_XFA
// Reset the focused annotations and remove the SDK document from the
@@ -324,9 +319,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
if (!pPageView)
return false;
-
- CFX_PointF pt((float)page_x, (float)page_y);
- return pPageView->OnLButtonUp(pt, modifier);
+ return pPageView->OnLButtonUp(CFX_PointF(page_x, page_y), modifier);
}
#ifdef PDF_ENABLE_XFA
@@ -349,9 +342,7 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle,
CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
if (!pPageView)
return false;
-
- CFX_PointF pt((float)page_x, (float)page_y);
- return pPageView->OnRButtonUp(pt, modifier);
+ return pPageView->OnRButtonUp(CFX_PointF(page_x, page_y), modifier);
}
#endif // PDF_ENABLE_XFA
@@ -362,7 +353,6 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,
CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
if (!pPageView)
return false;
-
return pPageView->OnKeyDown(nKeyCode, modifier);
}
@@ -373,7 +363,6 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle,
CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
if (!pPageView)
return false;
-
return pPageView->OnKeyUp(nKeyCode, modifier);
}
@@ -384,7 +373,6 @@ DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle,
CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
if (!pPageView)
return false;
-
return pPageView->OnChar(nChar, modifier);
}
@@ -665,9 +653,6 @@ DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page,
DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page,
FPDF_FORMHANDLE hHandle) {
- if (!hHandle)
- return;
-
CPDFSDK_FormFillEnvironment* pFormFillEnv =
HandleToCPDFSDKEnvironment(hHandle);
if (!pFormFillEnv)
@@ -707,26 +692,23 @@ DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
return;
CPDF_Document* pDoc = pFormFillEnv->GetPDFDocument();
- CPDF_Dictionary* pDic = pDoc->GetRoot();
- if (!pDic)
+ CPDF_Dictionary* pDict = pDoc->GetRoot();
+ if (!pDict)
return;
- CPDF_AAction aa(pDic->GetDictFor("AA"));
- if (aa.ActionExist((CPDF_AAction::AActionType)aaType)) {
- CPDF_Action action = aa.GetAction((CPDF_AAction::AActionType)aaType);
+ CPDF_AAction aa(pDict->GetDictFor("AA"));
+ auto type = static_cast<CPDF_AAction::AActionType>(aaType);
+ if (aa.ActionExist(type)) {
+ CPDF_Action action = aa.GetAction(type);
CPDFSDK_ActionHandler* pActionHandler =
HandleToCPDFSDKEnvironment(hHandle)->GetActionHander();
- pActionHandler->DoAction_Document(action, (CPDF_AAction::AActionType)aaType,
- pFormFillEnv);
+ pActionHandler->DoAction_Document(action, type, pFormFillEnv);
}
}
DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
FPDF_FORMHANDLE hHandle,
int aaType) {
- if (!hHandle)
- return;
-
CPDFSDK_FormFillEnvironment* pFormFillEnv =
HandleToCPDFSDKEnvironment(hHandle);
if (!pFormFillEnv)
@@ -743,17 +725,11 @@ DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
CPDFSDK_ActionHandler* pActionHandler = pFormFillEnv->GetActionHander();
CPDF_Dictionary* pPageDict = pPDFPage->m_pFormDict.Get();
CPDF_AAction aa(pPageDict->GetDictFor("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,
- pFormFillEnv);
- }
- } else {
- if (aa.ActionExist(CPDF_AAction::ClosePage)) {
- CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
- pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage,
- pFormFillEnv);
- }
+ CPDF_AAction::AActionType type = aaType == FPDFPAGE_AACTION_OPEN
+ ? CPDF_AAction::OpenPage
+ : CPDF_AAction::ClosePage;
+ if (aa.ActionExist(type)) {
+ CPDF_Action action = aa.GetAction(type);
+ pActionHandler->DoAction_Page(action, type, pFormFillEnv);
}
}