Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(722)

Unified Diff: fpdfsdk/src/fpdfview.cpp

Issue 1415803002: XFA: add CPDFDocumentToFPDFDocument() (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Address comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/src/fpdfeditpage.cpp ('k') | fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/src/fpdfview.cpp
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index e58c53646baadd2cd6b67e69d22d0196663ceb15..bd7741d1e8e2598ba5f8370f319f13149d57f628 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;
« no previous file with comments | « fpdfsdk/src/fpdfeditpage.cpp ('k') | fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698