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

Unified Diff: fpdfsdk/src/fpdfview.cpp

Issue 1473503002: Introduce "underlying types" to abstract XFA differences. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month 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
Index: fpdfsdk/src/fpdfview.cpp
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 8da56dc3b6a00eefc48a1c7994b96e9e06cb8218..7dc17262c63d02b2b4677246a9d154e9fe3710a4 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -23,16 +23,30 @@
#include "third_party/base/nonstd_unique_ptr.h"
#include "third_party/base/numerics/safe_conversions_impl.h"
+UnderlyingDocumentType* UnderlyingFromFPDFDocument(FPDF_DOCUMENT doc) {
+ return static_cast<UnderlyingDocumentType*>(doc);
+}
+
+FPDF_DOCUMENT FPDFDocumentFromUnderlying(UnderlyingDocumentType* doc) {
+ return static_cast<FPDF_DOCUMENT>(doc);
+}
+
+UnderlyingPageType* UnderlyingFromFPDFPage(FPDF_PAGE page) {
+ return static_cast<UnderlyingPageType*>(page);
+}
+
CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc) {
- return doc ? static_cast<CPDFXFA_Document*>(doc)->GetPDFDoc() : nullptr;
+ return doc ? UnderlyingFromFPDFDocument(doc)->GetPDFDoc() : nullptr;
}
FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc) {
- return doc ? new CPDFXFA_Document(doc, CPDFXFA_App::GetInstance()) : nullptr;
+ return doc ? FPDFDocumentFromUnderlying(
+ new CPDFXFA_Document(doc, CPDFXFA_App::GetInstance()))
+ : nullptr;
}
CPDF_Page* CPDFPageFromFPDFPage(FPDF_PAGE page) {
- return page ? static_cast<CPDFXFA_Page*>(page)->GetPDFPage() : nullptr;
+ return page ? UnderlyingFromFPDFPage(page)->GetPDFPage() : nullptr;
}
CFPDF_FileStream::CFPDF_FileStream(FPDF_FILEHANDLER* pFS) {

Powered by Google App Engine
This is Rietveld 408576698