summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfeditpage.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/fpdfeditpage.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/fpdfeditpage.cpp')
-rw-r--r--fpdfsdk/src/fpdfeditpage.cpp28
1 files changed, 10 insertions, 18 deletions
diff --git a/fpdfsdk/src/fpdfeditpage.cpp b/fpdfsdk/src/fpdfeditpage.cpp
index 6e1b852a47..f2d13d6ba1 100644
--- a/fpdfsdk/src/fpdfeditpage.cpp
+++ b/fpdfsdk/src/fpdfeditpage.cpp
@@ -85,7 +85,7 @@ DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document,
}
DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
!pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
@@ -129,7 +129,7 @@ DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page) {
DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
FPDF_PAGEOBJECT page_obj) {
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
!pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
@@ -171,13 +171,10 @@ DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page,
default:
break;
}
-
- // pPage->ParseContent();
- // pPage->GenerateContent();
}
DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) {
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
!pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
@@ -185,27 +182,22 @@ DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page) {
return -1;
}
return pPage->CountObjects();
- // return 0;
}
DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page,
int index) {
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
"Page")) {
return NULL;
}
return pPage->GetObjectByIndex(index);
- // return NULL;
}
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page) {
- if (!page)
- return FALSE;
- CPDF_Page* pPage = (CPDF_Page*)page;
-
- return pPage->BackgroundAlphaNeeded();
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ return pPage && pPage->BackgroundAlphaNeeded();
}
DLLEXPORT FPDF_BOOL STDCALL
@@ -247,7 +239,7 @@ FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject) {
}
DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page) {
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
!pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(
@@ -282,9 +274,9 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
double d,
double e,
double f) {
- if (page == NULL)
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
+ if (!pPage)
return;
- CPDF_Page* pPage = (CPDF_Page*)page;
CPDF_AnnotList AnnotList(pPage);
for (int i = 0; i < AnnotList.Count(); i++) {
CPDF_Annot* pAnnot = AnnotList.GetAt(i);
@@ -310,7 +302,7 @@ DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
}
DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate) {
- CPDF_Page* pPage = (CPDF_Page*)page;
+ CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage || !pPage->m_pFormDict || !pPage->m_pFormDict->KeyExist("Type") ||
!pPage->m_pFormDict->GetElement("Type")->GetDirect() ||
pPage->m_pFormDict->GetElement("Type")->GetDirect()->GetString().Compare(