summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp4
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_document.cpp8
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_document.h7
3 files changed, 15 insertions, 4 deletions
diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
index 7a9b704f53..a8cbeaf5d4 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
@@ -1399,7 +1399,7 @@ FX_BOOL CPDF_DataAvail::CheckPageNode(CPDF_DataAvail::PageNode& pageNodes,
case PDF_PAGENODE_PAGE:
iCount++;
if (iPage == iCount && m_pDocument)
- m_pDocument->m_PageList.SetAt(iPage, pNode->m_dwPageNo);
+ m_pDocument->SetPageObjNum(iPage, pNode->m_dwPageNo);
break;
case PDF_PAGENODE_PAGES:
if (!CheckPageNode(*pNode, iPage, iCount, pHints, level + 1))
@@ -1424,7 +1424,7 @@ FX_BOOL CPDF_DataAvail::LoadDocPage(uint32_t dwPage, DownloadHints* pHints) {
FX_SAFE_INT32 safePage = pdfium::base::checked_cast<int32_t>(dwPage);
int32_t iPage = safePage.ValueOrDie();
if (m_pDocument->GetPageCount() <= iPage ||
- m_pDocument->m_PageList.GetAt(iPage)) {
+ m_pDocument->IsPageLoaded(iPage)) {
m_docStatus = PDF_DATAAVAIL_DONE;
return TRUE;
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_document.cpp b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
index d3909ceaec..020e3544e9 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_document.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_document.cpp
@@ -512,6 +512,10 @@ CPDF_Dictionary* CPDF_Document::GetPagesDict() const {
return pRoot ? pRoot->GetDictFor("Pages") : nullptr;
}
+bool CPDF_Document::IsPageLoaded(int iPage) const {
+ return !!m_PageList.GetAt(iPage);
+}
+
CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
if (iPage < 0 || iPage >= m_PageList.GetSize())
return nullptr;
@@ -541,6 +545,10 @@ CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
return pPage;
}
+void CPDF_Document::SetPageObjNum(int iPage, uint32_t objNum) {
+ m_PageList.SetAt(iPage, objNum);
+}
+
int CPDF_Document::FindPageIndex(CPDF_Dictionary* pNode,
uint32_t& skip_count,
uint32_t objnum,
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_document.h b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
index 5f3b2d277a..83567cd85a 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_document.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_document.h
@@ -51,11 +51,14 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
void DeletePage(int iPage);
int GetPageCount() const;
+ bool IsPageLoaded(int iPage) const;
CPDF_Dictionary* GetPage(int iPage);
int GetPageIndex(uint32_t objnum);
uint32_t GetUserPermissions() const;
CPDF_DocPageData* GetPageData() const { return m_pDocPage; }
+ void SetPageObjNum(int iPage, uint32_t objNum);
+
std::unique_ptr<JBig2_DocumentContext>* CodecContext() {
return &m_pCodecContext;
}
@@ -97,7 +100,6 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
protected:
friend class CPDF_Creator;
friend class CPDF_Parser;
- friend class CPDF_DataAvail;
friend class CPDF_OCContext;
// Retrieve page count information by getting count value from the tree nodes
@@ -119,7 +121,6 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
bool m_bLinearized;
int m_iFirstPageNo;
uint32_t m_dwFirstPageObjNum;
- CFX_ArrayTemplate<uint32_t> m_PageList;
// TODO(thestig): Figure out why this cannot be a std::unique_ptr.
CPDF_DocPageData* m_pDocPage;
std::unique_ptr<CPDF_DocRenderData> m_pDocRender;
@@ -136,6 +137,8 @@ class CPDF_Document : public CPDF_IndirectObjectHolder {
FX_BOOL bVert,
CFX_ByteString basefont,
std::function<void(FX_WCHAR, FX_WCHAR, CPDF_Array*)> Insert);
+
+ CFX_ArrayTemplate<uint32_t> m_PageList;
};
#endif // CORE_FPDFAPI_FPDF_PARSER_INCLUDE_CPDF_DOCUMENT_H_