summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfformfill.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-15 16:34:32 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-15 16:34:32 -0700
commit943ea142b6a7e6edc91fe3c307013129e6eb0ef3 (patch)
tree8de4aaa7bb8eb3d463246d2a2f400006e60bae99 /fpdfsdk/src/fpdfformfill.cpp
parentb456ba7f62fa416f456ef78750c18fd2bdf837be (diff)
downloadpdfium-943ea142b6a7e6edc91fe3c307013129e6eb0ef3.tar.xz
Introduce CPDFPageFromFPFDPage()
Abstracts the way that pages are passed to the embedder between XFA and master. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1406543004 .
Diffstat (limited to 'fpdfsdk/src/fpdfformfill.cpp')
-rw-r--r--fpdfsdk/src/fpdfformfill.cpp44
1 files changed, 26 insertions, 18 deletions
diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp
index 02f906f513..7c2c350501 100644
--- a/fpdfsdk/src/fpdfformfill.cpp
+++ b/fpdfsdk/src/fpdfformfill.cpp
@@ -24,11 +24,12 @@ CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) {
CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page) {
- if (!page)
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return nullptr;
CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle);
- return pSDKDoc ? pSDKDoc->GetPageView((CPDF_Page*)page, TRUE) : nullptr;
+ return pSDKDoc ? pSDKDoc->GetPageView(pPage, TRUE) : nullptr;
}
} // namespace
@@ -37,10 +38,11 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page,
double page_x,
double page_y) {
- if (!page || !hHandle)
+ if (!hHandle)
+ return -1;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return -1;
-
- CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_InterForm interform(pPage->m_pDocument, FALSE);
CPDF_FormControl* pFormCtrl = interform.GetControlAtPoint(
pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y, nullptr);
@@ -48,10 +50,7 @@ DLLEXPORT int STDCALL FPDFPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
return -1;
CPDF_FormField* pFormField = pFormCtrl->GetField();
- if (!pFormField)
- return -1;
-
- return pFormField->GetFieldType();
+ return pFormField ? pFormField->GetFieldType() : -1;
}
DLLEXPORT int STDCALL FPDPage_HasFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
@@ -65,10 +64,11 @@ DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle,
FPDF_PAGE page,
double page_x,
double page_y) {
- if (!page || !hHandle)
+ if (!hHandle)
+ return -1;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return -1;
-
- CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_InterForm interform(pPage->m_pDocument, FALSE);
int z_order = -1;
(void)interform.GetControlAtPoint(pPage, (FX_FLOAT)page_x, (FX_FLOAT)page_y,
@@ -192,10 +192,13 @@ DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
int size_y,
int rotate,
int flags) {
- if (!hHandle || !page)
+ if (!hHandle)
+ return;
+
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_RenderOptions options;
if (flags & FPDF_LCD_TEXT)
options.m_Flags |= RENDER_CLEARTYPE;
@@ -263,14 +266,17 @@ DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page,
DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page,
FPDF_FORMHANDLE hHandle) {
- if (!hHandle || !page)
+ if (!hHandle)
return;
CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
if (!pSDKDoc)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
+ return;
+
CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
if (pPageView) {
pPageView->SetValid(FALSE);
@@ -316,10 +322,12 @@ DLLEXPORT void STDCALL FORM_DoDocumentAAction(FPDF_FORMHANDLE hHandle,
DLLEXPORT void STDCALL FORM_DoPageAAction(FPDF_PAGE page,
FPDF_FORMHANDLE hHandle,
int aaType) {
- if (!hHandle || !page)
+ if (!hHandle)
return;
CPDFSDK_Document* pSDKDoc = ((CPDFDoc_Environment*)hHandle)->GetSDKDocument();
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
+ return;
CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE);
if (pPageView) {
CPDFDoc_Environment* pEnv = pSDKDoc->GetEnv();