From dae73f540c2aac24d94794f63a2142b1a9c91574 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 13 Jun 2018 17:54:57 +0000 Subject: Tidy FFLCommon() The polymorphic IPDF_Page::GetDocument() allows getting the document without special cases. The subsequent retrieval of the page view via the helper function is equivalent to the inline code in the other branch of the ifdef. Change-Id: I8c7008c18610e11e7dcc4151fa7369cfc3625049 Reviewed-on: https://pdfium-review.googlesource.com/35070 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fpdfsdk/fpdf_formfill.cpp | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp index cd4a8c5c32..01bea1cf0a 100644 --- a/fpdfsdk/fpdf_formfill.cpp +++ b/fpdfsdk/fpdf_formfill.cpp @@ -110,8 +110,8 @@ CPDFSDK_InterForm* FormHandleToInterForm(FPDF_FORMHANDLE hHandle) { } CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, - FPDF_PAGE page) { - IPDF_Page* pPage = IPDFPageFromFPDFPage(page); + FPDF_PAGE fpdf_page) { + IPDF_Page* pPage = IPDFPageFromFPDFPage(fpdf_page); if (!pPage) return nullptr; @@ -123,7 +123,7 @@ CPDFSDK_PageView* FormHandleToPageView(FPDF_FORMHANDLE hHandle, void FFLCommon(FPDF_FORMHANDLE hHandle, FPDF_BITMAP bitmap, FPDF_RECORDER recorder, - FPDF_PAGE page, + FPDF_PAGE fpdf_page, int start_x, int start_y, int size_x, @@ -133,25 +133,12 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, if (!hHandle) return; - IPDF_Page* pPage = IPDFPageFromFPDFPage(page); + IPDF_Page* pPage = IPDFPageFromFPDFPage(fpdf_page); if (!pPage) return; -#ifdef PDF_ENABLE_XFA - CPDF_Document::Extension* pExtension = - pPage->AsXFAPage()->GetDocumentExtension(); - if (!pExtension) - return; - CPDF_Document* pPDFDoc = pExtension->GetPDFDoc(); - if (!pPDFDoc) - return; - CPDFSDK_FormFillEnvironment* pFormFillEnv = - HandleToCPDFSDKEnvironment(hHandle); - if (!pFormFillEnv) - return; -#else // PDF_ENABLE_XFA CPDF_Document* pPDFDoc = pPage->GetDocument(); -#endif // PDF_ENABLE_XFA + CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, fpdf_page); const FX_RECT rect(start_x, start_y, start_x + size_x, start_y + size_y); CFX_Matrix matrix = pPage->GetDisplayMatrix(rect, rotate); @@ -160,6 +147,7 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, #ifdef _SKIA_SUPPORT_ pDevice->AttachRecorder(static_cast(recorder)); #endif + RetainPtr holder(CFXDIBitmapFromFPDFBitmap(bitmap)); pDevice->Attach(holder, false, nullptr, false); { @@ -182,16 +170,10 @@ void FFLCommon(FPDF_FORMHANDLE hHandle, options.SetOCContext( pdfium::MakeRetain(pPDFDoc, CPDF_OCContext::View)); -#ifdef PDF_ENABLE_XFA - CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, true); -#else // PDF_ENABLE_XFA - CPDFSDK_PageView* pPageView = - FormHandleToPageView(hHandle, FPDFPageFromIPDFPage(pPage)); -#endif // PDF_ENABLE_XFA - if (pPageView) pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options, rect); } + #ifdef _SKIA_SUPPORT_PATHS_ pDevice->Flush(true); holder->UnPreMultiply(); -- cgit v1.2.3