summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfview.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-21 14:07:23 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-21 14:07:23 -0700
commitbf59a070593d079256161f6ff47148df309668c7 (patch)
tree0c105507a20881f8f025127183510fefb851c3ce /fpdfsdk/src/fpdfview.cpp
parent63dfaab17af7121653749bc86d11fc77b5353dca (diff)
downloadpdfium-bf59a070593d079256161f6ff47148df309668c7.tar.xz
XFA: add CPDFDocumentToFPDFDocument()
Abstracts away that master returns CPDF_Documents directly, but XFA wraps them with a CPDFXFA_Document. Tidy dead code along the way. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1415803002 .
Diffstat (limited to 'fpdfsdk/src/fpdfview.cpp')
-rw-r--r--fpdfsdk/src/fpdfview.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index e58c53646b..bd7741d1e8 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;
}
+FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) {
+ return doc ? new CPDFXFA_Document(doc, CPDFXFA_App::GetInstance()) : nullptr;
+}
+
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
return page ? static_cast<CPDFXFA_Page*>(page)->GetPDFPage() : nullptr;
}
@@ -351,12 +355,7 @@ DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf,
CPDF_Document* pDoc = NULL;
pDoc = pParser ? pParser->GetDocument() : NULL;
CheckUnSupportError(pDoc, err_code);
- CPDF_Document* pPDFDoc = pParser->GetDocument();
- if (!pPDFDoc)
- return NULL;
-
- CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance();
- return new CPDFXFA_Document(pPDFDoc, pProvider);
+ return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}
DLLEXPORT FPDF_DOCUMENT STDCALL
@@ -374,12 +373,7 @@ FPDF_LoadCustomDocument(FPDF_FILEACCESS* pFileAccess,
CPDF_Document* pDoc = NULL;
pDoc = pParser ? pParser->GetDocument() : NULL;
CheckUnSupportError(pDoc, err_code);
- CPDF_Document* pPDFDoc = pParser->GetDocument();
- if (!pPDFDoc)
- return NULL;
-
- CPDFXFA_App* pProvider = CPDFXFA_App::GetInstance();
- return new CPDFXFA_Document(pPDFDoc, pProvider);
+ return FPDFDocumentFromCPDFDocument(pParser->GetDocument());
}
DLLEXPORT FPDF_BOOL STDCALL FPDF_GetFileVersion(FPDF_DOCUMENT doc,
@@ -437,15 +431,13 @@ DLLEXPORT FPDF_PAGE STDCALL FPDF_LoadPage(FPDF_DOCUMENT document,
}
DLLEXPORT double STDCALL FPDF_GetPageWidth(FPDF_PAGE page) {
- if (!page)
- return 0.0;
- return ((CPDFXFA_Page*)page)->GetPageWidth();
+ CPDFXFA_Page* pPage = static_cast<CPDFXFA_Page*>(page);
+ return pPage ? pPage->GetPageWidth() : 0.0;
}
DLLEXPORT double STDCALL FPDF_GetPageHeight(FPDF_PAGE page) {
- if (!page)
- return 0.0;
- return ((CPDFXFA_Page*)page)->GetPageHeight();
+ CPDFXFA_Page* pPage = static_cast<CPDFXFA_Page*>(page);
+ return pPage ? pPage->GetPageHeight() : 0.0;
}
void DropContext(void* data) {
@@ -1018,8 +1010,8 @@ DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDest(FPDF_DOCUMENT document,
*buflen = 0;
if (!document || index < 0)
return NULL;
- CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
+ CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot)
return NULL;