summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdfppo.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/fpdfsdk/fpdfppo.cpp b/fpdfsdk/fpdfppo.cpp
index d88f9102b9..836d5723ca 100644
--- a/fpdfsdk/fpdfppo.cpp
+++ b/fpdfsdk/fpdfppo.cpp
@@ -70,8 +70,8 @@ bool CopyInheritable(CPDF_Dictionary* pCurPageDict,
}
bool ParserPageRangeString(ByteString rangstring,
- std::vector<uint16_t>* pageArray,
- int nCount) {
+ int nCount,
+ std::vector<uint16_t>* pageArray) {
if (rangstring.IsEmpty())
return true;
@@ -124,6 +124,21 @@ bool ParserPageRangeString(ByteString rangstring,
return true;
}
+bool GetPageNumbers(ByteString pageRange,
+ CPDF_Document* pSrcDoc,
+ std::vector<uint16_t>* pageArray) {
+ uint16_t nCount = pSrcDoc->GetPageCount();
+ if (!pageRange.IsEmpty()) {
+ if (!ParserPageRangeString(pageRange, nCount, pageArray))
+ return false;
+ } else {
+ for (uint16_t i = 1; i <= nCount; ++i) {
+ pageArray->push_back(i);
+ }
+ }
+ return true;
+}
+
} // namespace
class CPDF_PageOrganizer {
@@ -358,18 +373,15 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_ImportPages(FPDF_DOCUMENT dest_doc,
return false;
std::vector<uint16_t> pageArray;
- int nCount = pSrcDoc->GetPageCount();
- if (pagerange) {
- if (!ParserPageRangeString(pagerange, &pageArray, nCount))
- return false;
- } else {
- for (int i = 1; i <= nCount; ++i) {
- pageArray.push_back(i);
- }
- }
+ if (!GetPageNumbers(pagerange, pSrcDoc, &pageArray))
+ return false;
CPDF_PageOrganizer pageOrg(pDestDoc, pSrcDoc);
- return pageOrg.PDFDocInit() && pageOrg.ExportPage(pageArray, index);
+
+ if (!pageOrg.PDFDocInit())
+ return false;
+
+ return pageOrg.ExportPage(pageArray, index);
}
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV