summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-09-20 12:35:36 -0700
committerCommit bot <commit-bot@chromium.org>2016-09-20 12:35:36 -0700
commit23e173ad2c48e2683cd6e5f76da3fa188d85bcb8 (patch)
tree15eb27d28b96713b49974d1d2fd9428874c11346
parent9f206f05eccf51089fe8a30bf52dc063ea5e2633 (diff)
downloadpdfium-23e173ad2c48e2683cd6e5f76da3fa188d85bcb8.tar.xz
CPDF_Document and CPDF_DataAvail are no longer friends
Remove the friendship between these two classes and replace with accessor methods. Review-Url: https://codereview.chromium.org/2355813002
-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_