summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfppo.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-14 16:34:46 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-14 16:34:46 -0700
commitbb51c4fb6bc6095984c303c95e5336f83e66bc67 (patch)
treeaa95c7948b60a9935c0d83e449d2aef5658e1ff2 /fpdfsdk/src/fpdfppo.cpp
parenteca866c64ec0319d4723798290a3155957fa733e (diff)
downloadpdfium-bb51c4fb6bc6095984c303c95e5336f83e66bc67.tar.xz
Introduce CPDF_Document::FromFPDFDocument().
This will be used to abstract one major difference between master and XFA, namely that the CPDF_Document is not a direct cast in XFA. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1395493007 .
Diffstat (limited to 'fpdfsdk/src/fpdfppo.cpp')
-rw-r--r--fpdfsdk/src/fpdfppo.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index a37772492f..50ed6607d5 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -369,11 +369,15 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
FPDF_DOCUMENT src_doc,
FPDF_BYTESTRING pagerange,
int index) {
- if (!dest_doc || !src_doc)
+ CPDF_Document* pDestDoc = CPDF_Document::FromFPDFDocument(dest_doc);
+ if (!dest_doc)
+ return FALSE;
+
+ CPDF_Document* pSrcDoc = CPDF_Document::FromFPDFDocument(src_doc);
+ if (!pSrcDoc)
return FALSE;
CFX_WordArray pageArray;
- CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc;
int nCount = pSrcDoc->GetPageCount();
if (pagerange) {
if (!ParserPageRangeString(pagerange, &pageArray, nCount))
@@ -384,30 +388,30 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
}
}
- CPDF_Document* pDestDoc = (CPDF_Document*)dest_doc;
CPDF_PageOrganizer pageOrg;
-
pageOrg.PDFDocInit(pDestDoc, pSrcDoc);
-
return pageOrg.ExportPage(pSrcDoc, &pageArray, pDestDoc, index);
}
DLLEXPORT FPDF_BOOL STDCALL FPDF_CopyViewerPreferences(FPDF_DOCUMENT dest_doc,
FPDF_DOCUMENT src_doc) {
- if (!src_doc || !dest_doc)
- return false;
+ CPDF_Document* pDstDoc = CPDF_Document::FromFPDFDocument(dest_doc);
+ if (!pDstDoc)
+ return FALSE;
+
+ CPDF_Document* pSrcDoc = CPDF_Document::FromFPDFDocument(src_doc);
+ if (!pSrcDoc)
+ return FALSE;
- CPDF_Document* pSrcDoc = (CPDF_Document*)src_doc;
CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot();
pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences"));
- ;
if (!pSrcDict)
return FALSE;
- CPDF_Document* pDstDoc = (CPDF_Document*)dest_doc;
CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
if (!pDstDict)
return FALSE;
+
pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE));
return TRUE;
}