summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdfppo.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-15 16:17:18 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-15 16:17:18 -0700
commit471a1034e70ddcfc93ce2a93b28a8385109e83de (patch)
treec845fb1b73b936023be1fc2e7699ff4768aec652 /fpdfsdk/src/fpdfppo.cpp
parentdfbf8e7ba55695c4e6cb30eadbe9c6a2955815ba (diff)
downloadpdfium-471a1034e70ddcfc93ce2a93b28a8385109e83de.tar.xz
Merge to XFA: Introduce CPDF_DocumentFromFPDFDocument().
Manual merges everywhere. Original Review URL: https://codereview.chromium.org/1395493007 . (cherry picked from commit bb51c4fb6bc6095984c303c95e5336f83e66bc67) Original Review URL: https://codereview.chromium.org/1396283006 . (cherry picked from commit 86adb658843658969041a13bf6cf0cc950ffe8ed) R=thestig@chromium.org Review URL: https://codereview.chromium.org/1395353004 .
Diffstat (limited to 'fpdfsdk/src/fpdfppo.cpp')
-rw-r--r--fpdfsdk/src/fpdfppo.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/fpdfsdk/src/fpdfppo.cpp b/fpdfsdk/src/fpdfppo.cpp
index d3899156a2..ed2446471e 100644
--- a/fpdfsdk/src/fpdfppo.cpp
+++ b/fpdfsdk/src/fpdfppo.cpp
@@ -380,12 +380,15 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
FPDF_DOCUMENT src_doc,
FPDF_BYTESTRING pagerange,
int index) {
- if (dest_doc == NULL || src_doc == NULL)
+ CPDF_Document* pDestDoc = CPDFDocumentFromFPDFDocument(dest_doc);
+ if (!dest_doc)
+ return FALSE;
+
+ CPDF_Document* pSrcDoc = CPDFDocumentFromFPDFDocument(src_doc);
+ if (!pSrcDoc)
return FALSE;
CFX_WordArray pageArray;
- CPDFXFA_Document* pSrcDoc = (CPDFXFA_Document*)src_doc;
- CPDF_Document* pSrcPDFDoc = pSrcDoc->GetPDFDoc();
- int nCount = pSrcPDFDoc->GetPageCount();
+ int nCount = pSrcDoc->GetPageCount();
if (pagerange) {
if (ParserPageRangeString(pagerange, &pageArray, nCount) == FALSE)
return FALSE;
@@ -395,32 +398,30 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
}
}
- CPDFXFA_Document* pDestDoc = (CPDFXFA_Document*)dest_doc;
- CPDF_Document* pDestPDFDoc = pDestDoc->GetPDFDoc();
CPDF_PageOrganizer pageOrg;
-
- pageOrg.PDFDocInit(pDestPDFDoc, pSrcPDFDoc);
-
- if (pageOrg.ExportPage(pSrcPDFDoc, &pageArray, pDestPDFDoc, index))
- return TRUE;
- return FALSE;
+ 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 == NULL || dest_doc == NULL)
- return false;
- CPDFXFA_Document* pSrcDoc = (CPDFXFA_Document*)src_doc;
- CPDF_Document* pSrcPDFDoc = pSrcDoc->GetPDFDoc();
- CPDF_Dictionary* pSrcDict = pSrcPDFDoc->GetRoot();
+ CPDF_Document* pDstDoc = CPDFDocumentFromFPDFDocument(dest_doc);
+ if (!pDstDoc)
+ return FALSE;
+
+ CPDF_Document* pSrcDoc = CPDFDocumentFromFPDFDocument(src_doc);
+ if (!pSrcDoc)
+ return FALSE;
+
+ CPDF_Dictionary* pSrcDict = pSrcDoc->GetRoot();
pSrcDict = pSrcDict->GetDict(FX_BSTRC("ViewerPreferences"));
if (!pSrcDict)
return FALSE;
- CPDFXFA_Document* pDstDoc = (CPDFXFA_Document*)dest_doc;
- CPDF_Document* pDstPDFDoc = pDstDoc->GetPDFDoc();
- CPDF_Dictionary* pDstDict = pDstPDFDoc->GetRoot();
+
+ CPDF_Dictionary* pDstDict = pDstDoc->GetRoot();
if (!pDstDict)
return FALSE;
+
pDstDict->SetAt(FX_BSTRC("ViewerPreferences"), pSrcDict->Clone(TRUE));
return TRUE;
}