summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfview.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/fpdfview.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/fpdfview.cpp')
-rw-r--r--fpdfsdk/src/fpdfview.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 17f52ec263..b2c5618a52 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -20,6 +20,10 @@ CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) {
return static_cast<CPDF_Document*>(doc);
}
+CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
+ return static_cast<CPDF_Page*>(page);
+}
+
CPDF_CustomAccess::CPDF_CustomAccess(FPDF_FILEACCESS* pFileAccess) {
if (pFileAccess)
m_FileAccess = *pFileAccess;
@@ -284,15 +288,13 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
}
DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) {
- if (!page)
- return 0.0;
- return ((CPDF_Page*)page)->GetPageWidth();
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ return pPage ? pPage->GetPageWidth() : 0.0;
}
DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) {
- if (!page)
- return 0.0;
- return ((CPDF_Page*)page)->GetPageHeight();
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ return pPage ? pPage->GetPageHeight() : 0.0;
}
void DropContext(void* data) {
@@ -312,9 +314,9 @@ DLLEXPORT void STDCALL FPDF_RenderPage(HDC dc,
int size_y,
int rotate,
int flags) {
- if (page == NULL)
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
CRenderContext* pContext = new CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
@@ -472,10 +474,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 = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
-
CRenderContext* pContext = new CRenderContext;
pPage->SetPrivateData((void*)1, pContext, DropContext);
#ifdef _SKIA_SUPPORT_
@@ -570,10 +573,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;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
-
CPDF_Matrix page2device;
pPage->GetDisplayMatrix(page2device, start_x, start_y, size_x, size_y,
rotate);
@@ -681,8 +685,8 @@ void FPDF_RenderPage_Retail(CRenderContext* pContext,
int flags,
FX_BOOL bNeedToRestore,
IFSDK_PAUSE_Adapter* pause) {
- CPDF_Page* pPage = (CPDF_Page*)page;
- if (pPage == NULL)
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
if (!pContext->m_pOptions)