summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_document.cpp
diff options
context:
space:
mode:
authorArtem Strygin <art-snake@yandex-team.ru>2018-06-26 16:38:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-26 16:38:49 +0000
commit2d868435f4c0d47ded1ea405ad2af6b9d83b6651 (patch)
tree7e2e931e05b962b049879def3e6793a7c43ee95a /core/fpdfapi/parser/cpdf_document.cpp
parent20582f797f3fdc6308141dbed5eed7d3f84619c9 (diff)
downloadpdfium-2d868435f4c0d47ded1ea405ad2af6b9d83b6651.tar.xz
Unify CPDF_Document loading methods.
Change-Id: Ibf7aee942027adace7ec0831aefe0fe8c28e41cc Reviewed-on: https://pdfium-review.googlesource.com/35610 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_document.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp37
1 files changed, 16 insertions, 21 deletions
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 393a6f6785..8f727ed14a 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -191,9 +191,6 @@ CPDF_Document::CPDF_Document(std::unique_ptr<CPDF_Parser> pParser)
m_pRootDict(nullptr),
m_iNextPageToTraverse(0),
m_bReachedMaxPageLevel(false),
- m_bLinearized(false),
- m_iFirstPageNo(0),
- m_dwFirstPageObjNum(0),
m_pDocPage(pdfium::MakeUnique<CPDF_DocPageData>(this)),
m_pDocRender(pdfium::MakeUnique<CPDF_DocRenderData>(this)) {
if (pParser)
@@ -226,17 +223,18 @@ void CPDF_Document::LoadDoc() {
LoadPages();
}
-void CPDF_Document::LoadLinearizedDoc(
- const CPDF_LinearizedHeader* pLinearizationParams) {
- m_bLinearized = true;
- LoadDocInternal();
- m_PageList.resize(pLinearizationParams->GetPageCount());
- m_iFirstPageNo = pLinearizationParams->GetFirstPageNo();
- m_dwFirstPageObjNum = pLinearizationParams->GetFirstPageObjNum();
-}
-
void CPDF_Document::LoadPages() {
- m_PageList.resize(RetrievePageCount());
+ const CPDF_LinearizedHeader* linearized_header =
+ m_pParser->GetLinearizedHeader();
+ if (!linearized_header) {
+ m_PageList.resize(RetrievePageCount());
+ return;
+ }
+
+ m_PageList.resize(linearized_header->GetPageCount());
+ DCHECK(linearized_header->GetFirstPageNo() < m_PageList.size());
+ m_PageList[linearized_header->GetFirstPageNo()] =
+ linearized_header->GetFirstPageObjNum();
}
CPDF_Dictionary* CPDF_Document::TraversePDFPages(int iPage,
@@ -329,15 +327,12 @@ CPDF_Dictionary* CPDF_Document::GetPageDictionary(int iPage) {
if (!pdfium::IndexInBounds(m_PageList, iPage))
return nullptr;
- if (m_bLinearized && iPage == m_iFirstPageNo) {
- if (CPDF_Dictionary* pDict =
- ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) {
- return pDict;
- }
+ const uint32_t objnum = m_PageList[iPage];
+ if (objnum) {
+ CPDF_Dictionary* result = ToDictionary(GetOrParseIndirectObject(objnum));
+ if (result)
+ return result;
}
- uint32_t objnum = m_PageList[iPage];
- if (objnum)
- return ToDictionary(GetOrParseIndirectObject(objnum));
CPDF_Dictionary* pPages = GetPagesDict();
if (!pPages)