summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorxlou <xlou@chromium.org>2018-01-26 20:06:39 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-26 20:06:39 +0000
commit6e8a3e62e1718c3739f44e94c128123276d85682 (patch)
treef5bf9361747f16304b722ce3ace42cd7e98138f5 /fpdfsdk
parent636e82c0a73ea6eb67074887f065d20e455bda97 (diff)
downloadpdfium-6e8a3e62e1718c3739f44e94c128123276d85682.tar.xz
Code cleanup - create a new function GetPageNumberschromium/3334
The functionality to get page numbers in FPDF_ImportPages will be used in other functions too. So create a new function which can be reused easily. Change-Id: Iad7726f086168e70c8b7988b07f1c18c758ef303 Reviewed-on: https://pdfium-review.googlesource.com/24250 Commit-Queue: Shirleen Lou <xlou@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
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