summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfview.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-16 14:00:21 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-16 14:00:21 -0700
commitdb0be96179f0cd5f1787564cbccf86320a4d54ae (patch)
tree447ba797f172bfffa2d21dacc7dbf6fb2900bfd7 /fpdfsdk/src/fpdfview.cpp
parentcebdda5a686251087f14e8df19b7f988dfae46de (diff)
downloadpdfium-db0be96179f0cd5f1787564cbccf86320a4d54ae.tar.xz
Merge to XFA: Introduce CPDFPageFromFPFDPage()
Original Review URL: https://codereview.chromium.org/1406543004 . (cherry picked from commit 943ea142b6a7e6edc91fe3c307013129e6eb0ef3) R=thestig@chromium.org Review URL: https://codereview.chromium.org/1411623002 .
Diffstat (limited to 'fpdfsdk/src/fpdfview.cpp')
-rw-r--r--fpdfsdk/src/fpdfview.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 5d9bf4b252..6254eb2b67 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -26,6 +26,10 @@ CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) {
return doc ? static_cast<CPDFXFA_Document*>(doc)->GetPDFDoc() : nullptr;
}
+CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
+ return page ? static_cast<CPDFXFA_Page*>(page)->GetPDFPage() : nullptr;
+}
+
CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) {
m_pFS = pFS;
m_nCurPos = 0;
@@ -436,13 +440,11 @@ DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) {
if (!page)
return 0.0;
return ((CPDFXFA_Page*)page)->GetPageWidth();
- // return ((CPDF_Page*)page)->GetPageWidth();
}
DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) {
if (!page)
return 0.0;
- // return ((CPDF_Page*)page)->GetPageHeight();
return ((CPDFXFA_Page*)page)->GetPageHeight();
}
@@ -463,9 +465,7 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
int size_y,
int rotate,
int flags) {
- if (page == NULL)
- return;
- CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
@@ -625,12 +625,11 @@ DLLEXPORT void STDCALL FPDF_RenderPageBitmap(FPDF_BITMAP bitmap,
int size_y,
int rotate,
int flags) {
- if (bitmap == NULL || page == NULL)
+ if (!bitmap)
return;
- CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return;
-
CRenderContext* pContext = new CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
#ifdef _SKIA_SUPPORT_
@@ -702,9 +701,11 @@ DLLEXPORT void STDCALL FPDF_PageToDevice(FPDF_PAGE page,
double page_y,
int* device_x,
int* device_y) {
- if (page == NULL || device_x == NULL || device_y == NULL)
+ if (!device_x || !device_y)
return;
CPDFXFA_Page* pPage = (CPDFXFA_Page*)page;
+ if (!pPage)
+ return;
pPage->PageToDevice(start_x, start_y, size_x, size_y, rotate, page_x, page_y,
device_x, device_y);
}
@@ -804,8 +805,8 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext,
int flags,
FX_BOOL bNeedToRestore,
IFSDK_PAUSE_Adapter* pause) {
- CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
- if (pPage == NULL)
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
if (!pContext->m_pOptions)