summaryrefslogtreecommitdiff
path: root/core/fpdfdoc
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-08-30 14:19:26 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-08-30 22:17:09 +0000
commit0158106c1c77c6af4f7195d086cb0f2d129de838 (patch)
treeaed97db22abfaab6424378436c925a37d832c0e7 /core/fpdfdoc
parent4793f3474f2778dbbd225d797f011db0f45e0953 (diff)
downloadpdfium-0158106c1c77c6af4f7195d086cb0f2d129de838.tar.xz
Add truly const versions of CPDF_Document getters.
Instead of only having CPDF_Dictionary* GetRoot() const, provide const CPDF_Dictionary* GetRoot() const and CPDF_Dictionary* GetRoot(). Do the same for GetInfo(). Change-Id: I6eae1208d38327fcdc7d0cd75069a01c95f4a92a Reviewed-on: https://pdfium-review.googlesource.com/11671 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfdoc')
-rw-r--r--core/fpdfdoc/cpdf_action.cpp4
-rw-r--r--core/fpdfdoc/cpdf_action.h2
-rw-r--r--core/fpdfdoc/cpdf_annotlist.cpp2
-rw-r--r--core/fpdfdoc/cpdf_bookmarktree.cpp2
-rw-r--r--core/fpdfdoc/cpdf_metadata.cpp4
-rw-r--r--core/fpdfdoc/cpdf_metadata.h2
-rw-r--r--core/fpdfdoc/cpdf_nametree.cpp4
-rw-r--r--core/fpdfdoc/cpdf_nametree.h2
-rw-r--r--core/fpdfdoc/cpdf_pagelabel.cpp4
-rw-r--r--core/fpdfdoc/cpdf_structtree.cpp4
-rw-r--r--core/fpdfdoc/cpdf_viewerpreferences.cpp2
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp8
12 files changed, 21 insertions, 19 deletions
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp
index 557fbdafa9..4d9e630d97 100644
--- a/core/fpdfdoc/cpdf_action.cpp
+++ b/core/fpdfdoc/cpdf_action.cpp
@@ -85,7 +85,7 @@ CFX_WideString CPDF_Action::GetFilePath() const {
return CFX_WideString();
}
-CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const {
+CFX_ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const {
CFX_ByteString csURI;
if (!m_pDict)
return csURI;
@@ -93,7 +93,7 @@ CFX_ByteString CPDF_Action::GetURI(CPDF_Document* pDoc) const {
return csURI;
csURI = m_pDict->GetStringFor("URI");
- CPDF_Dictionary* pRoot = pDoc->GetRoot();
+ const CPDF_Dictionary* pRoot = pDoc->GetRoot();
CPDF_Dictionary* pURI = pRoot->GetDictFor("URI");
if (pURI) {
auto result = csURI.Find(":");
diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h
index bd1ce58ec6..be4d461867 100644
--- a/core/fpdfdoc/cpdf_action.h
+++ b/core/fpdfdoc/cpdf_action.h
@@ -46,7 +46,7 @@ class CPDF_Action {
ActionType GetType() const;
CPDF_Dest GetDest(CPDF_Document* pDoc) const;
CFX_WideString GetFilePath() const;
- CFX_ByteString GetURI(CPDF_Document* pDoc) const;
+ CFX_ByteString GetURI(const CPDF_Document* pDoc) const;
bool GetHideStatus() const { return m_pDict->GetBooleanFor("H", true); }
CFX_ByteString GetNamedAction() const { return m_pDict->GetStringFor("N"); }
uint32_t GetFlags() const { return m_pDict->GetIntegerFor("Flags"); }
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index 34c8d3a869..df3b631626 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -85,7 +85,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
if (!pAnnots)
return;
- CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
+ const CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
bool bRegenerateAP = pAcroForm && pAcroForm->GetBooleanFor("NeedAppearances");
for (size_t i = 0; i < pAnnots->GetCount(); ++i) {
diff --git a/core/fpdfdoc/cpdf_bookmarktree.cpp b/core/fpdfdoc/cpdf_bookmarktree.cpp
index b5dfe4f45f..33c9f3d15b 100644
--- a/core/fpdfdoc/cpdf_bookmarktree.cpp
+++ b/core/fpdfdoc/cpdf_bookmarktree.cpp
@@ -18,7 +18,7 @@ CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild(
if (pParentDict)
return CPDF_Bookmark(pParentDict->GetDictFor("First"));
- CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
+ const CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
if (!pRoot)
return CPDF_Bookmark();
diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
index 5379275544..b31348aa0b 100644
--- a/core/fpdfdoc/cpdf_metadata.cpp
+++ b/core/fpdfdoc/cpdf_metadata.cpp
@@ -11,8 +11,8 @@
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/xml/cxml_element.h"
-CPDF_Metadata::CPDF_Metadata(CPDF_Document* pDoc) {
- CPDF_Dictionary* pRoot = pDoc->GetRoot();
+CPDF_Metadata::CPDF_Metadata(const CPDF_Document* pDoc) {
+ const CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot)
return;
diff --git a/core/fpdfdoc/cpdf_metadata.h b/core/fpdfdoc/cpdf_metadata.h
index dd68dda713..fa958153fc 100644
--- a/core/fpdfdoc/cpdf_metadata.h
+++ b/core/fpdfdoc/cpdf_metadata.h
@@ -14,7 +14,7 @@ class CXML_Element;
class CPDF_Metadata {
public:
- explicit CPDF_Metadata(CPDF_Document* pDoc);
+ explicit CPDF_Metadata(const CPDF_Document* pDoc);
~CPDF_Metadata();
const CXML_Element* GetRoot() const;
diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp
index dc5b6e526d..d225d3f0bf 100644
--- a/core/fpdfdoc/cpdf_nametree.cpp
+++ b/core/fpdfdoc/cpdf_nametree.cpp
@@ -299,10 +299,10 @@ size_t CountNames(CPDF_Dictionary* pNode, int nLevel = 0) {
CPDF_NameTree::CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
-CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc,
+CPDF_NameTree::CPDF_NameTree(const CPDF_Document* pDoc,
const CFX_ByteString& category)
: m_pRoot(nullptr) {
- CPDF_Dictionary* pRoot = pDoc->GetRoot();
+ const CPDF_Dictionary* pRoot = pDoc->GetRoot();
if (!pRoot)
return;
diff --git a/core/fpdfdoc/cpdf_nametree.h b/core/fpdfdoc/cpdf_nametree.h
index 8c26c9380e..4dc43fc3ac 100644
--- a/core/fpdfdoc/cpdf_nametree.h
+++ b/core/fpdfdoc/cpdf_nametree.h
@@ -20,7 +20,7 @@ class CPDF_Object;
class CPDF_NameTree {
public:
explicit CPDF_NameTree(CPDF_Dictionary* pRoot);
- CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteString& category);
+ CPDF_NameTree(const CPDF_Document* pDoc, const CFX_ByteString& category);
~CPDF_NameTree();
bool AddValueAndName(std::unique_ptr<CPDF_Object> pObj,
diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp
index 41cbb8974e..7b5e66e585 100644
--- a/core/fpdfdoc/cpdf_pagelabel.cpp
+++ b/core/fpdfdoc/cpdf_pagelabel.cpp
@@ -84,7 +84,7 @@ bool CPDF_PageLabel::GetLabel(int nPage, CFX_WideString* wsLabel) const {
if (nPage < 0 || nPage >= m_pDocument->GetPageCount())
return false;
- CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
+ const CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
if (!pPDFRoot)
return false;
@@ -124,7 +124,7 @@ int32_t CPDF_PageLabel::GetPageByLabel(const CFX_ByteStringC& bsLabel) const {
if (!m_pDocument)
return -1;
- CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
+ const CPDF_Dictionary* pPDFRoot = m_pDocument->GetRoot();
if (!pPDFRoot)
return -1;
diff --git a/core/fpdfdoc/cpdf_structtree.cpp b/core/fpdfdoc/cpdf_structtree.cpp
index 62500ac155..9168a4f01a 100644
--- a/core/fpdfdoc/cpdf_structtree.cpp
+++ b/core/fpdfdoc/cpdf_structtree.cpp
@@ -19,8 +19,8 @@ namespace {
const int nMaxRecursion = 32;
bool IsTagged(const CPDF_Document* pDoc) {
- CPDF_Dictionary* pCatalog = pDoc->GetRoot();
- CPDF_Dictionary* pMarkInfo = pCatalog->GetDictFor("MarkInfo");
+ const CPDF_Dictionary* pCatalog = pDoc->GetRoot();
+ const CPDF_Dictionary* pMarkInfo = pCatalog->GetDictFor("MarkInfo");
return pMarkInfo && pMarkInfo->GetIntegerFor("Marked");
}
diff --git a/core/fpdfdoc/cpdf_viewerpreferences.cpp b/core/fpdfdoc/cpdf_viewerpreferences.cpp
index f1fc4b0347..e25316b6fb 100644
--- a/core/fpdfdoc/cpdf_viewerpreferences.cpp
+++ b/core/fpdfdoc/cpdf_viewerpreferences.cpp
@@ -55,6 +55,6 @@ bool CPDF_ViewerPreferences::GenericName(const CFX_ByteString& bsKey,
}
CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const {
- CPDF_Dictionary* pDict = m_pDoc->GetRoot();
+ const CPDF_Dictionary* pDict = m_pDoc->GetRoot();
return pDict ? pDict->GetDictFor("ViewerPreferences") : nullptr;
}
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 90d5d94f7f..132e771d47 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -34,9 +34,11 @@ namespace {
bool GenerateWidgetAP(CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict,
const int32_t& nWidgetType) {
- CPDF_Dictionary* pFormDict = nullptr;
- if (CPDF_Dictionary* pRootDict = pDoc->GetRoot())
- pFormDict = pRootDict->GetDictFor("AcroForm");
+ const CPDF_Dictionary* pRootDict = pDoc->GetRoot();
+ if (!pRootDict)
+ return false;
+
+ const CPDF_Dictionary* pFormDict = pRootDict->GetDictFor("AcroForm");
if (!pFormDict)
return false;