From 540c436dc8e7d7b700b448acc8536f5cf68d4b74 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 24 Nov 2015 13:33:57 -0800 Subject: XFA: more underlying type changes to match master R=thestig@chromium.org Review URL: https://codereview.chromium.org/1474663004 . --- fpdfsdk/src/fpdfformfill.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'fpdfsdk/src/fpdfformfill.cpp') diff --git a/fpdfsdk/src/fpdfformfill.cpp b/fpdfsdk/src/fpdfformfill.cpp index a1e807224d..5dcfb47890 100644 --- a/fpdfsdk/src/fpdfformfill.cpp +++ b/fpdfsdk/src/fpdfformfill.cpp @@ -28,11 +28,12 @@ CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, FPDF_PAGE page) { - if (!page) + UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); + if (!pPage) return nullptr; CPDFSDK_Document* pSDKDoc = FormHandleToSDKDoc(hHandle); - return pSDKDoc ? pSDKDoc->GetPageView((CPDFXFA_Page*)page, TRUE) : nullptr; + return pSDKDoc ? pSDKDoc->GetPageView(pPage, TRUE) : nullptr; } } // namespace @@ -128,16 +129,19 @@ DLLEXPORT int STDCALL FPDFPage_FormFieldZOrderAtPoint(FPDF_FORMHANDLE hHandle, DLLEXPORT FPDF_FORMHANDLE STDCALL FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document, FPDF_FORMFILLINFO* formInfo) { - if (!document || !formInfo || formInfo->version != 2) + const int kRequiredVersion = 2; + if (!formInfo || formInfo->version != kRequiredVersion) + return nullptr; + + UnderlyingDocumentType* pDocument = UnderlyingFromFPDFDocument(document); + if (!pDocument) return nullptr; - CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; CPDFDoc_Environment* pEnv = new CPDFDoc_Environment(pDocument, formInfo); pEnv->SetSDKDocument(pDocument->GetSDKDocument(pEnv)); CPDFXFA_App* pApp = CPDFXFA_App::GetInstance(); pApp->AddFormFillEnv(pEnv); - return pEnv; } @@ -600,14 +604,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; - CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; + UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); + if (!pPage) + return; + CPDFSDK_PageView* pPageView = pSDKDoc->GetPageView(pPage, FALSE); if (pPageView) { pPageView->SetValid(FALSE); @@ -653,11 +660,11 @@ 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(); - CPDFXFA_Page* pPage = (CPDFXFA_Page*)page; - CPDF_Page* pPDFPage = pPage->GetPDFPage(); + UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); + CPDF_Page* pPDFPage = CPDFPageFromFPDFPage(page); if (!pPDFPage) return; if (pSDKDoc->GetPageView(pPage, FALSE)) { -- cgit v1.2.3