summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-05-25 21:48:49 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-25 21:48:49 +0000
commit5cee3f28ead05cb336377483e24664c004af8b0a (patch)
tree8fb5db3232e1359831682c809be3ec10de1ce1e0
parent1f17bd73afa6b1b79ec4a2f81c995b43d15a9814 (diff)
downloadpdfium-5cee3f28ead05cb336377483e24664c004af8b0a.tar.xz
Mark more CPDF_Objects as const in action and bookmark code.
Change-Id: Ib5f4cdb9c7f9c33561028a85029649ba68f4a6e5 Reviewed-on: https://pdfium-review.googlesource.com/32912 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--core/fpdfdoc/cpdf_action.cpp6
-rw-r--r--core/fpdfdoc/cpdf_action.h6
-rw-r--r--core/fpdfdoc/cpdf_actionfields.cpp31
-rw-r--r--core/fpdfdoc/cpdf_actionfields.h4
-rw-r--r--core/fpdfdoc/cpdf_annot.cpp11
-rw-r--r--core/fpdfdoc/cpdf_annotlist.cpp2
-rw-r--r--core/fpdfdoc/cpdf_bookmark.cpp4
-rw-r--r--core/fpdfdoc/cpdf_bookmark.h6
-rw-r--r--core/fpdfdoc/cpdf_bookmarktree.cpp8
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp2
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp6
-rw-r--r--core/fpdfdoc/cpdf_interform.h2
-rw-r--r--core/fpdfdoc/cpdf_numbertree.cpp17
-rw-r--r--core/fpdfdoc/cpdf_numbertree.h6
-rw-r--r--core/fpdfdoc/cpdf_occontext.cpp20
-rw-r--r--core/fpdfdoc/cpdf_occontext.h2
-rw-r--r--core/fpdfdoc/cpdf_pagelabel.cpp6
-rw-r--r--core/fpdfdoc/cpdf_structelement.cpp9
-rw-r--r--core/fpdfdoc/cpdf_structelement.h10
-rw-r--r--core/fpdfdoc/cpdf_structtree.cpp16
-rw-r--r--core/fpdfdoc/cpdf_structtree.h12
-rw-r--r--core/fpdfdoc/cpvt_fontmap.cpp3
-rw-r--r--core/fpdfdoc/cpvt_fontmap.h2
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp16
-rw-r--r--fpdfsdk/cpdfsdk_actionhandler.cpp38
-rw-r--r--fpdfsdk/cpdfsdk_actionhandler.h12
-rw-r--r--fpdfsdk/cpdfsdk_helpers.cpp14
-rw-r--r--fpdfsdk/cpdfsdk_helpers.h17
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp14
-rw-r--r--fpdfsdk/cpdfsdk_interform.h2
-rw-r--r--fpdfsdk/fpdf_doc.cpp4
-rw-r--r--public/fpdfview.h4
32 files changed, 162 insertions, 150 deletions
diff --git a/core/fpdfdoc/cpdf_action.cpp b/core/fpdfdoc/cpdf_action.cpp
index 4ac86fe104..4a89a7d9ff 100644
--- a/core/fpdfdoc/cpdf_action.cpp
+++ b/core/fpdfdoc/cpdf_action.cpp
@@ -22,7 +22,7 @@ const char* const g_sATypes[] = {
} // namespace
-CPDF_Action::CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+CPDF_Action::CPDF_Action(const CPDF_Dictionary* pDict) : m_pDict(pDict) {}
CPDF_Action::CPDF_Action(const CPDF_Action& that) = default;
@@ -76,7 +76,7 @@ WideString CPDF_Action::GetFilePath() const {
return CPDF_FileSpec(pFile).GetFileName();
if (type == "Launch") {
- CPDF_Dictionary* pWinDict = m_pDict->GetDictFor("Win");
+ const CPDF_Dictionary* pWinDict = m_pDict->GetDictFor("Win");
if (pWinDict) {
return WideString::FromLocal(
pWinDict->GetStringFor(pdfium::stream::kF).AsStringView());
@@ -94,7 +94,7 @@ ByteString CPDF_Action::GetURI(const CPDF_Document* pDoc) const {
csURI = m_pDict->GetStringFor("URI");
const CPDF_Dictionary* pRoot = pDoc->GetRoot();
- CPDF_Dictionary* pURI = pRoot->GetDictFor("URI");
+ const CPDF_Dictionary* pURI = pRoot->GetDictFor("URI");
if (pURI) {
auto result = csURI.Find(":");
if (!result.has_value() || result.value() == 0)
diff --git a/core/fpdfdoc/cpdf_action.h b/core/fpdfdoc/cpdf_action.h
index 1d9b722f40..43bf123b71 100644
--- a/core/fpdfdoc/cpdf_action.h
+++ b/core/fpdfdoc/cpdf_action.h
@@ -37,11 +37,11 @@ class CPDF_Action {
GoTo3DView
};
- explicit CPDF_Action(CPDF_Dictionary* pDict);
+ explicit CPDF_Action(const CPDF_Dictionary* pDict);
CPDF_Action(const CPDF_Action& that);
~CPDF_Action();
- CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
+ const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
ActionType GetType() const;
CPDF_Dest GetDest(CPDF_Document* pDoc) const;
WideString GetFilePath() const;
@@ -54,7 +54,7 @@ class CPDF_Action {
CPDF_Action GetSubAction(size_t iIndex) const;
private:
- UnownedPtr<CPDF_Dictionary> const m_pDict;
+ UnownedPtr<const CPDF_Dictionary> const m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_ACTION_H_
diff --git a/core/fpdfdoc/cpdf_actionfields.cpp b/core/fpdfdoc/cpdf_actionfields.cpp
index cee256d3fb..89636bfc23 100644
--- a/core/fpdfdoc/cpdf_actionfields.cpp
+++ b/core/fpdfdoc/cpdf_actionfields.cpp
@@ -19,12 +19,12 @@ size_t CPDF_ActionFields::GetFieldsCount() const {
if (!m_pAction)
return 0;
- CPDF_Dictionary* pDict = m_pAction->GetDict();
+ const CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict)
return 0;
ByteString csType = pDict->GetStringFor("S");
- CPDF_Object* pFields = nullptr;
+ const CPDF_Object* pFields;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
else
@@ -36,22 +36,21 @@ size_t CPDF_ActionFields::GetFieldsCount() const {
return 1;
if (pFields->IsString())
return 1;
- if (CPDF_Array* pArray = pFields->AsArray())
- return pArray->GetCount();
- return 0;
+ const CPDF_Array* pArray = pFields->AsArray();
+ return pArray ? pArray->GetCount() : 0;
}
-std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
- std::vector<CPDF_Object*> fields;
+std::vector<const CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
+ std::vector<const CPDF_Object*> fields;
if (!m_pAction)
return fields;
- CPDF_Dictionary* pDict = m_pAction->GetDict();
+ const CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict)
return fields;
ByteString csType = pDict->GetStringFor("S");
- CPDF_Object* pFields;
+ const CPDF_Object* pFields;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
else
@@ -62,9 +61,9 @@ std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
if (pFields->IsDictionary() || pFields->IsString()) {
fields.push_back(pFields);
- } else if (CPDF_Array* pArray = pFields->AsArray()) {
+ } else if (const CPDF_Array* pArray = pFields->AsArray()) {
for (size_t i = 0; i < pArray->GetCount(); ++i) {
- CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
+ const CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
if (pObj)
fields.push_back(pObj);
}
@@ -72,16 +71,16 @@ std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
return fields;
}
-CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const {
+const CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const {
if (!m_pAction)
return nullptr;
- CPDF_Dictionary* pDict = m_pAction->GetDict();
+ const CPDF_Dictionary* pDict = m_pAction->GetDict();
if (!pDict)
return nullptr;
ByteString csType = pDict->GetStringFor("S");
- CPDF_Object* pFields = nullptr;
+ const CPDF_Object* pFields;
if (csType == "Hide")
pFields = pDict->GetDirectObjectFor("T");
else
@@ -90,11 +89,11 @@ CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const {
if (!pFields)
return nullptr;
- CPDF_Object* pFindObj = nullptr;
+ const CPDF_Object* pFindObj = nullptr;
if (pFields->IsDictionary() || pFields->IsString()) {
if (iIndex == 0)
pFindObj = pFields;
- } else if (CPDF_Array* pArray = pFields->AsArray()) {
+ } else if (const CPDF_Array* pArray = pFields->AsArray()) {
pFindObj = pArray->GetDirectObjectAt(iIndex);
}
return pFindObj;
diff --git a/core/fpdfdoc/cpdf_actionfields.h b/core/fpdfdoc/cpdf_actionfields.h
index 83c70f6375..affc03cfec 100644
--- a/core/fpdfdoc/cpdf_actionfields.h
+++ b/core/fpdfdoc/cpdf_actionfields.h
@@ -22,8 +22,8 @@ class CPDF_ActionFields {
~CPDF_ActionFields();
size_t GetFieldsCount() const;
- std::vector<CPDF_Object*> GetAllFields() const;
- CPDF_Object* GetField(size_t iIndex) const;
+ std::vector<const CPDF_Object*> GetAllFields() const;
+ const CPDF_Object* GetField(size_t iIndex) const;
private:
UnownedPtr<const CPDF_Action> const m_pAction;
diff --git a/core/fpdfdoc/cpdf_annot.cpp b/core/fpdfdoc/cpdf_annot.cpp
index dc2e8acfdf..5734e192e3 100644
--- a/core/fpdfdoc/cpdf_annot.cpp
+++ b/core/fpdfdoc/cpdf_annot.cpp
@@ -64,7 +64,7 @@ CPDF_Form* AnnotGetMatrix(const CPDF_Page* pPage,
CPDF_Stream* FPDFDOC_GetAnnotAPInternal(const CPDF_Dictionary* pAnnotDict,
CPDF_Annot::AppearanceMode eMode,
bool bFallbackToNormal) {
- CPDF_Dictionary* pAP = pAnnotDict->GetDictFor("AP");
+ const CPDF_Dictionary* pAP = pAnnotDict->GetDictFor("AP");
if (!pAP)
return nullptr;
@@ -90,7 +90,7 @@ CPDF_Stream* FPDFDOC_GetAnnotAPInternal(const CPDF_Dictionary* pAnnotDict,
if (as.IsEmpty()) {
ByteString value = pAnnotDict->GetStringFor("V");
if (value.IsEmpty()) {
- CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent");
+ const CPDF_Dictionary* pParentDict = pAnnotDict->GetDictFor("Parent");
value = pParentDict ? pParentDict->GetStringFor("V") : ByteString();
}
as = (!value.IsEmpty() && pDict->KeyExist(value)) ? value : "Off";
@@ -230,11 +230,12 @@ CFX_FloatRect CPDF_Annot::RectFromQuadPointsArray(const CPDF_Array* pArray,
// static
CFX_FloatRect CPDF_Annot::BoundingRectFromQuadPoints(
const CPDF_Dictionary* pAnnotDict) {
- CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints");
+ CFX_FloatRect ret;
+ const CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints");
if (!pArray)
- return CFX_FloatRect();
+ return ret;
- CFX_FloatRect ret = RectFromQuadPointsArray(pArray, 0);
+ ret = RectFromQuadPointsArray(pArray, 0);
size_t nQuadPointCount = QuadPointCount(pArray);
for (size_t i = 1; i < nQuadPointCount; ++i) {
CFX_FloatRect rect = RectFromQuadPointsArray(pArray, i);
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index 77a2d0c2af..e364a72d35 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -129,7 +129,7 @@ CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage)
return;
const CPDF_Dictionary* pRoot = m_pDocument->GetRoot();
- CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
+ const CPDF_Dictionary* pAcroForm = pRoot->GetDictFor("AcroForm");
bool bRegenerateAP = pAcroForm && pAcroForm->GetBooleanFor("NeedAppearances");
for (size_t i = 0; i < pAnnots->GetCount(); ++i) {
CPDF_Dictionary* pDict = ToDictionary(pAnnots->GetDirectObjectAt(i));
diff --git a/core/fpdfdoc/cpdf_bookmark.cpp b/core/fpdfdoc/cpdf_bookmark.cpp
index 5f8997d647..32375808a6 100644
--- a/core/fpdfdoc/cpdf_bookmark.cpp
+++ b/core/fpdfdoc/cpdf_bookmark.cpp
@@ -24,7 +24,7 @@ CPDF_Bookmark::CPDF_Bookmark() {}
CPDF_Bookmark::CPDF_Bookmark(const CPDF_Bookmark& that) = default;
-CPDF_Bookmark::CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {}
+CPDF_Bookmark::CPDF_Bookmark(const CPDF_Dictionary* pDict) : m_pDict(pDict) {}
CPDF_Bookmark::~CPDF_Bookmark() {}
@@ -32,7 +32,7 @@ uint32_t CPDF_Bookmark::GetColorRef() const {
if (!m_pDict)
return kBlackBGR;
- CPDF_Array* pColor = m_pDict->GetArrayFor("C");
+ const CPDF_Array* pColor = m_pDict->GetArrayFor("C");
if (!pColor)
return kBlackBGR;
diff --git a/core/fpdfdoc/cpdf_bookmark.h b/core/fpdfdoc/cpdf_bookmark.h
index 60c86dd7b0..ff31af1149 100644
--- a/core/fpdfdoc/cpdf_bookmark.h
+++ b/core/fpdfdoc/cpdf_bookmark.h
@@ -19,10 +19,10 @@ class CPDF_Bookmark {
public:
CPDF_Bookmark();
CPDF_Bookmark(const CPDF_Bookmark& that);
- explicit CPDF_Bookmark(CPDF_Dictionary* pDict);
+ explicit CPDF_Bookmark(const CPDF_Dictionary* pDict);
~CPDF_Bookmark();
- CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
+ const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
uint32_t GetColorRef() const;
uint32_t GetFontStyle() const;
WideString GetTitle() const;
@@ -30,7 +30,7 @@ class CPDF_Bookmark {
CPDF_Action GetAction() const;
private:
- UnownedPtr<CPDF_Dictionary> m_pDict;
+ UnownedPtr<const CPDF_Dictionary> m_pDict;
};
#endif // CORE_FPDFDOC_CPDF_BOOKMARK_H_
diff --git a/core/fpdfdoc/cpdf_bookmarktree.cpp b/core/fpdfdoc/cpdf_bookmarktree.cpp
index 33c9f3d15b..3b178f01b1 100644
--- a/core/fpdfdoc/cpdf_bookmarktree.cpp
+++ b/core/fpdfdoc/cpdf_bookmarktree.cpp
@@ -14,7 +14,7 @@ CPDF_BookmarkTree::~CPDF_BookmarkTree() {}
CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild(
const CPDF_Bookmark& parent) const {
- CPDF_Dictionary* pParentDict = parent.GetDict();
+ const CPDF_Dictionary* pParentDict = parent.GetDict();
if (pParentDict)
return CPDF_Bookmark(pParentDict->GetDictFor("First"));
@@ -22,17 +22,17 @@ CPDF_Bookmark CPDF_BookmarkTree::GetFirstChild(
if (!pRoot)
return CPDF_Bookmark();
- CPDF_Dictionary* pOutlines = pRoot->GetDictFor("Outlines");
+ const CPDF_Dictionary* pOutlines = pRoot->GetDictFor("Outlines");
return pOutlines ? CPDF_Bookmark(pOutlines->GetDictFor("First"))
: CPDF_Bookmark();
}
CPDF_Bookmark CPDF_BookmarkTree::GetNextSibling(
const CPDF_Bookmark& bookmark) const {
- CPDF_Dictionary* pDict = bookmark.GetDict();
+ const CPDF_Dictionary* pDict = bookmark.GetDict();
if (!pDict)
return CPDF_Bookmark();
- CPDF_Dictionary* pNext = pDict->GetDictFor("Next");
+ const CPDF_Dictionary* pNext = pDict->GetDictFor("Next");
return pNext == pDict ? CPDF_Bookmark() : CPDF_Bookmark(pNext);
}
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index bfc39b08f1..acad073b17 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -64,7 +64,7 @@ CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict,
if (pAttr)
return pAttr;
- CPDF_Dictionary* pParent = pFieldDict->GetDictFor("Parent");
+ const CPDF_Dictionary* pParent = pFieldDict->GetDictFor("Parent");
return pParent ? FPDF_GetFieldAttr(pParent, name, nLevel + 1) : nullptr;
}
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index 0c548d8e0b..83df36b39b 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -690,7 +690,7 @@ ByteString CPDF_InterForm::GenerateNewResourceName(
if (!pResDict)
return csTmp;
- CPDF_Dictionary* pDict = pResDict->GetDictFor(csType);
+ const CPDF_Dictionary* pDict = pResDict->GetDictFor(csType);
if (!pDict)
return csTmp;
@@ -963,8 +963,8 @@ bool CPDF_InterForm::HasXFAForm() const {
return m_pFormDict && m_pFormDict->GetArrayFor("XFA");
}
-void CPDF_InterForm::FixPageFields(const CPDF_Page* pPage) {
- const CPDF_Dictionary* pPageDict = pPage->GetFormDict();
+void CPDF_InterForm::FixPageFields(CPDF_Page* pPage) {
+ CPDF_Dictionary* pPageDict = pPage->GetFormDict();
if (!pPageDict)
return;
diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h
index 2f60bf77b5..796c336ea0 100644
--- a/core/fpdfdoc/cpdf_interform.h
+++ b/core/fpdfdoc/cpdf_interform.h
@@ -87,7 +87,7 @@ class CPDF_InterForm {
void SetFormNotify(IPDF_FormNotify* pNotify);
bool HasXFAForm() const;
- void FixPageFields(const CPDF_Page* pPage);
+ void FixPageFields(CPDF_Page* pPage);
IPDF_FormNotify* GetFormNotify() const { return m_pFormNotify.Get(); }
CPDF_Document* GetDocument() const { return m_pDocument.Get(); }
diff --git a/core/fpdfdoc/cpdf_numbertree.cpp b/core/fpdfdoc/cpdf_numbertree.cpp
index 952fb4ef1d..74aeb67e85 100644
--- a/core/fpdfdoc/cpdf_numbertree.cpp
+++ b/core/fpdfdoc/cpdf_numbertree.cpp
@@ -11,13 +11,13 @@
namespace {
-CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) {
- CPDF_Array* pLimits = pNode->GetArrayFor("Limits");
+const CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) {
+ const CPDF_Array* pLimits = pNode->GetArrayFor("Limits");
if (pLimits &&
(num < pLimits->GetIntegerAt(0) || num > pLimits->GetIntegerAt(1))) {
return nullptr;
}
- CPDF_Array* pNumbers = pNode->GetArrayFor("Nums");
+ const CPDF_Array* pNumbers = pNode->GetArrayFor("Nums");
if (pNumbers) {
for (size_t i = 0; i < pNumbers->GetCount() / 2; i++) {
int index = pNumbers->GetIntegerAt(i * 2);
@@ -29,16 +29,16 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) {
return nullptr;
}
- CPDF_Array* pKids = pNode->GetArrayFor("Kids");
+ const CPDF_Array* pKids = pNode->GetArrayFor("Kids");
if (!pKids)
return nullptr;
for (size_t i = 0; i < pKids->GetCount(); i++) {
- CPDF_Dictionary* pKid = pKids->GetDictAt(i);
+ const CPDF_Dictionary* pKid = pKids->GetDictAt(i);
if (!pKid)
continue;
- CPDF_Object* pFound = SearchNumberNode(pKid, num);
+ const CPDF_Object* pFound = SearchNumberNode(pKid, num);
if (pFound)
return pFound;
}
@@ -47,10 +47,11 @@ CPDF_Object* SearchNumberNode(const CPDF_Dictionary* pNode, int num) {
} // namespace
-CPDF_NumberTree::CPDF_NumberTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {}
+CPDF_NumberTree::CPDF_NumberTree(const CPDF_Dictionary* pRoot)
+ : m_pRoot(pRoot) {}
CPDF_NumberTree::~CPDF_NumberTree() {}
-CPDF_Object* CPDF_NumberTree::LookupValue(int num) const {
+const CPDF_Object* CPDF_NumberTree::LookupValue(int num) const {
return SearchNumberNode(m_pRoot.Get(), num);
}
diff --git a/core/fpdfdoc/cpdf_numbertree.h b/core/fpdfdoc/cpdf_numbertree.h
index 47c40b93d3..1c65fd2cae 100644
--- a/core/fpdfdoc/cpdf_numbertree.h
+++ b/core/fpdfdoc/cpdf_numbertree.h
@@ -14,13 +14,13 @@ class CPDF_Object;
class CPDF_NumberTree {
public:
- explicit CPDF_NumberTree(CPDF_Dictionary* pRoot);
+ explicit CPDF_NumberTree(const CPDF_Dictionary* pRoot);
~CPDF_NumberTree();
- CPDF_Object* LookupValue(int num) const;
+ const CPDF_Object* LookupValue(int num) const;
protected:
- UnownedPtr<CPDF_Dictionary> const m_pRoot;
+ UnownedPtr<const CPDF_Dictionary> const m_pRoot;
};
#endif // CORE_FPDFDOC_CPDF_NUMBERTREE_H_
diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp
index e59690996c..192a254329 100644
--- a/core/fpdfdoc/cpdf_occontext.cpp
+++ b/core/fpdfdoc/cpdf_occontext.cpp
@@ -150,9 +150,9 @@ bool CPDF_OCContext::LoadOCGState(const CPDF_Dictionary* pOCGDict) const {
return true;
ByteString csState = GetUsageTypeString(m_eUsageType);
- CPDF_Dictionary* pUsage = pOCGDict->GetDictFor("Usage");
+ const CPDF_Dictionary* pUsage = pOCGDict->GetDictFor("Usage");
if (pUsage) {
- CPDF_Dictionary* pState = pUsage->GetDictFor(csState);
+ const CPDF_Dictionary* pState = pUsage->GetDictFor(csState);
if (pState) {
ByteString csFind = csState + "State";
if (pState->KeyExist(csFind))
@@ -192,18 +192,18 @@ bool CPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) {
return true;
}
-bool CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, int nLevel) {
+bool CPDF_OCContext::GetOCGVE(const CPDF_Array* pExpression, int nLevel) {
if (nLevel > 32 || !pExpression)
return false;
ByteString csOperator = pExpression->GetStringAt(0);
if (csOperator == "Not") {
- CPDF_Object* pOCGObj = pExpression->GetDirectObjectAt(1);
+ const CPDF_Object* pOCGObj = pExpression->GetDirectObjectAt(1);
if (!pOCGObj)
return false;
- if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
+ if (const CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
return !GetOCGVisible(pDict);
- if (CPDF_Array* pArray = pOCGObj->AsArray())
+ if (const CPDF_Array* pArray = pOCGObj->AsArray())
return !GetOCGVE(pArray, nLevel + 1);
return false;
}
@@ -213,14 +213,14 @@ bool CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, int nLevel) {
bool bValue = false;
for (size_t i = 1; i < pExpression->GetCount(); i++) {
- CPDF_Object* pOCGObj = pExpression->GetDirectObjectAt(1);
+ const CPDF_Object* pOCGObj = pExpression->GetDirectObjectAt(1);
if (!pOCGObj)
continue;
bool bItem = false;
- if (CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
+ if (const CPDF_Dictionary* pDict = pOCGObj->AsDictionary())
bItem = GetOCGVisible(pDict);
- else if (CPDF_Array* pArray = pOCGObj->AsArray())
+ else if (const CPDF_Array* pArray = pOCGObj->AsArray())
bItem = GetOCGVE(pArray, nLevel + 1);
if (i == 1) {
@@ -237,7 +237,7 @@ bool CPDF_OCContext::GetOCGVE(CPDF_Array* pExpression, int nLevel) {
}
bool CPDF_OCContext::LoadOCMDState(const CPDF_Dictionary* pOCMDDict) {
- CPDF_Array* pVE = pOCMDDict->GetArrayFor("VE");
+ const CPDF_Array* pVE = pOCMDDict->GetArrayFor("VE");
if (pVE)
return GetOCGVE(pVE, 0);
diff --git a/core/fpdfdoc/cpdf_occontext.h b/core/fpdfdoc/cpdf_occontext.h
index c47b93311d..67763610f4 100644
--- a/core/fpdfdoc/cpdf_occontext.h
+++ b/core/fpdfdoc/cpdf_occontext.h
@@ -35,7 +35,7 @@ class CPDF_OCContext : public Retainable {
const CPDF_Dictionary* pOCGDict) const;
bool LoadOCGState(const CPDF_Dictionary* pOCGDict) const;
bool GetOCGVisible(const CPDF_Dictionary* pOCGDict);
- bool GetOCGVE(CPDF_Array* pExpression, int nLevel);
+ bool GetOCGVE(const CPDF_Array* pExpression, int nLevel);
bool LoadOCMDState(const CPDF_Dictionary* pOCMDDict);
UnownedPtr<CPDF_Document> const m_pDocument;
diff --git a/core/fpdfdoc/cpdf_pagelabel.cpp b/core/fpdfdoc/cpdf_pagelabel.cpp
index f06e4018bb..e6a7780a95 100644
--- a/core/fpdfdoc/cpdf_pagelabel.cpp
+++ b/core/fpdfdoc/cpdf_pagelabel.cpp
@@ -89,12 +89,12 @@ Optional<WideString> CPDF_PageLabel::GetLabel(int nPage) const {
if (!pPDFRoot)
return {};
- CPDF_Dictionary* pLabels = pPDFRoot->GetDictFor("PageLabels");
+ const CPDF_Dictionary* pLabels = pPDFRoot->GetDictFor("PageLabels");
if (!pLabels)
return {};
CPDF_NumberTree numberTree(pLabels);
- CPDF_Object* pValue = nullptr;
+ const CPDF_Object* pValue = nullptr;
int n = nPage;
while (n >= 0) {
pValue = numberTree.LookupValue(n);
@@ -106,7 +106,7 @@ Optional<WideString> CPDF_PageLabel::GetLabel(int nPage) const {
WideString label;
if (pValue) {
pValue = pValue->GetDirect();
- if (CPDF_Dictionary* pLabel = pValue->AsDictionary()) {
+ if (const CPDF_Dictionary* pLabel = pValue->AsDictionary()) {
if (pLabel->KeyExist("P"))
label += pLabel->GetUnicodeTextFor("P");
diff --git a/core/fpdfdoc/cpdf_structelement.cpp b/core/fpdfdoc/cpdf_structelement.cpp
index 13985b8fed..ed5c8c7366 100644
--- a/core/fpdfdoc/cpdf_structelement.cpp
+++ b/core/fpdfdoc/cpdf_structelement.cpp
@@ -17,7 +17,6 @@
CPDF_StructKid::CPDF_StructKid()
: m_Type(Invalid),
- m_pDict(nullptr),
m_PageObjNum(0),
m_RefObjNum(0),
m_ContentId(0) {}
@@ -28,7 +27,7 @@ CPDF_StructKid::~CPDF_StructKid() = default;
CPDF_StructElement::CPDF_StructElement(CPDF_StructTree* pTree,
CPDF_StructElement* pParent,
- CPDF_Dictionary* pDict)
+ const CPDF_Dictionary* pDict)
: m_pTree(pTree),
m_pParent(pParent),
m_pDict(pDict),
@@ -54,10 +53,10 @@ CPDF_StructElement* CPDF_StructElement::GetKidIfElement(size_t index) const {
: nullptr;
}
-void CPDF_StructElement::LoadKids(CPDF_Dictionary* pDict) {
- CPDF_Object* pObj = pDict->GetObjectFor("Pg");
+void CPDF_StructElement::LoadKids(const CPDF_Dictionary* pDict) {
+ const CPDF_Object* pObj = pDict->GetObjectFor("Pg");
uint32_t PageObjNum = 0;
- if (CPDF_Reference* pRef = ToReference(pObj))
+ if (const CPDF_Reference* pRef = ToReference(pObj))
PageObjNum = pRef->GetRefObjNum();
CPDF_Object* pKids = pDict->GetDirectObjectFor("K");
diff --git a/core/fpdfdoc/cpdf_structelement.h b/core/fpdfdoc/cpdf_structelement.h
index 51ee93bd54..2586d9ca13 100644
--- a/core/fpdfdoc/cpdf_structelement.h
+++ b/core/fpdfdoc/cpdf_structelement.h
@@ -28,7 +28,7 @@ class CPDF_StructKid {
enum { Invalid, Element, PageContent, StreamContent, Object } m_Type;
RetainPtr<CPDF_StructElement> m_pElement; // For Element.
- UnownedPtr<CPDF_Dictionary> m_pDict; // For Element.
+ UnownedPtr<const CPDF_Dictionary> m_pDict; // For Element.
uint32_t m_PageObjNum; // For PageContent, StreamContent, Object.
uint32_t m_RefObjNum; // For StreamContent, Object.
uint32_t m_ContentId; // For PageContent, StreamContent.
@@ -41,7 +41,7 @@ class CPDF_StructElement : public Retainable {
const ByteString& GetType() const { return m_Type; }
const ByteString& GetTitle() const { return m_Title; }
- CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
+ const CPDF_Dictionary* GetDict() const { return m_pDict.Get(); }
size_t CountKids() const;
CPDF_StructElement* GetKidIfElement(size_t index) const;
@@ -50,15 +50,15 @@ class CPDF_StructElement : public Retainable {
private:
CPDF_StructElement(CPDF_StructTree* pTree,
CPDF_StructElement* pParent,
- CPDF_Dictionary* pDict);
+ const CPDF_Dictionary* pDict);
~CPDF_StructElement() override;
- void LoadKids(CPDF_Dictionary* pDict);
+ void LoadKids(const CPDF_Dictionary* pDict);
void LoadKid(uint32_t PageObjNum, CPDF_Object* pObj, CPDF_StructKid* pKid);
UnownedPtr<CPDF_StructTree> const m_pTree;
UnownedPtr<CPDF_StructElement> const m_pParent;
- UnownedPtr<CPDF_Dictionary> const m_pDict;
+ UnownedPtr<const CPDF_Dictionary> const m_pDict;
ByteString m_Type;
ByteString m_Title;
std::vector<CPDF_StructKid> m_Kids;
diff --git a/core/fpdfdoc/cpdf_structtree.cpp b/core/fpdfdoc/cpdf_structtree.cpp
index 97db691425..1e4d08aa3c 100644
--- a/core/fpdfdoc/cpdf_structtree.cpp
+++ b/core/fpdfdoc/cpdf_structtree.cpp
@@ -61,7 +61,7 @@ void CPDF_StructTree::LoadPageTree(const CPDF_Dictionary* pPageDict) {
m_Kids.clear();
m_Kids.resize(dwKids);
- CPDF_Dictionary* pParentTree = m_pTreeRoot->GetDictFor("ParentTree");
+ const CPDF_Dictionary* pParentTree = m_pTreeRoot->GetDictFor("ParentTree");
if (!pParentTree)
return;
@@ -70,20 +70,20 @@ void CPDF_StructTree::LoadPageTree(const CPDF_Dictionary* pPageDict) {
if (parents_id < 0)
return;
- CPDF_Array* pParentArray = ToArray(parent_tree.LookupValue(parents_id));
+ const CPDF_Array* pParentArray = ToArray(parent_tree.LookupValue(parents_id));
if (!pParentArray)
return;
- std::map<CPDF_Dictionary*, RetainPtr<CPDF_StructElement>> element_map;
+ StructElementMap element_map;
for (size_t i = 0; i < pParentArray->GetCount(); i++) {
- if (CPDF_Dictionary* pParent = pParentArray->GetDictAt(i))
+ if (const CPDF_Dictionary* pParent = pParentArray->GetDictAt(i))
AddPageNode(pParent, &element_map, 0);
}
}
RetainPtr<CPDF_StructElement> CPDF_StructTree::AddPageNode(
- CPDF_Dictionary* pDict,
- std::map<CPDF_Dictionary*, RetainPtr<CPDF_StructElement>>* map,
+ const CPDF_Dictionary* pDict,
+ StructElementMap* map,
int nLevel) {
static constexpr int kStructTreeMaxRecursion = 32;
if (nLevel > kStructTreeMaxRecursion)
@@ -95,7 +95,7 @@ RetainPtr<CPDF_StructElement> CPDF_StructTree::AddPageNode(
auto pElement = pdfium::MakeRetain<CPDF_StructElement>(this, nullptr, pDict);
(*map)[pDict] = pElement;
- CPDF_Dictionary* pParent = pDict->GetDictFor("P");
+ const CPDF_Dictionary* pParent = pDict->GetDictFor("P");
if (!pParent || pParent->GetStringFor("Type") == "StructTreeRoot") {
if (!AddTopLevelNode(pDict, pElement))
map->erase(pDict);
@@ -117,7 +117,7 @@ RetainPtr<CPDF_StructElement> CPDF_StructTree::AddPageNode(
}
bool CPDF_StructTree::AddTopLevelNode(
- CPDF_Dictionary* pDict,
+ const CPDF_Dictionary* pDict,
const RetainPtr<CPDF_StructElement>& pElement) {
CPDF_Object* pObj = m_pTreeRoot->GetDirectObjectFor("K");
if (!pObj)
diff --git a/core/fpdfdoc/cpdf_structtree.h b/core/fpdfdoc/cpdf_structtree.h
index 99342fb6de..13bf148677 100644
--- a/core/fpdfdoc/cpdf_structtree.h
+++ b/core/fpdfdoc/cpdf_structtree.h
@@ -34,12 +34,14 @@ class CPDF_StructTree {
const CPDF_Dictionary* GetTreeRoot() const { return m_pTreeRoot.Get(); }
private:
+ using StructElementMap =
+ std::map<const CPDF_Dictionary*, RetainPtr<CPDF_StructElement>>;
+
void LoadPageTree(const CPDF_Dictionary* pPageDict);
- RetainPtr<CPDF_StructElement> AddPageNode(
- CPDF_Dictionary* pElement,
- std::map<CPDF_Dictionary*, RetainPtr<CPDF_StructElement>>* map,
- int nLevel);
- bool AddTopLevelNode(CPDF_Dictionary* pDict,
+ RetainPtr<CPDF_StructElement> AddPageNode(const CPDF_Dictionary* pElement,
+ StructElementMap* map,
+ int nLevel);
+ bool AddTopLevelNode(const CPDF_Dictionary* pDict,
const RetainPtr<CPDF_StructElement>& pElement);
UnownedPtr<const CPDF_Dictionary> const m_pTreeRoot;
diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp
index aaf8661f1e..6164062164 100644
--- a/core/fpdfdoc/cpvt_fontmap.cpp
+++ b/core/fpdfdoc/cpvt_fontmap.cpp
@@ -25,8 +25,9 @@ CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc,
CPVT_FontMap::~CPVT_FontMap() {}
+// static
CPDF_Font* CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc,
- const CPDF_Dictionary* pResDict,
+ CPDF_Dictionary* pResDict,
ByteString* sSysFontAlias) {
if (!pDoc || !pResDict)
return nullptr;
diff --git a/core/fpdfdoc/cpvt_fontmap.h b/core/fpdfdoc/cpvt_fontmap.h
index a0b94cf25a..f1a27753ac 100644
--- a/core/fpdfdoc/cpvt_fontmap.h
+++ b/core/fpdfdoc/cpvt_fontmap.h
@@ -35,7 +35,7 @@ class CPVT_FontMap : public IPVT_FontMap {
int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override;
static CPDF_Font* GetAnnotSysPDFFont(CPDF_Document* pDoc,
- const CPDF_Dictionary* pResDict,
+ CPDF_Dictionary* pResDict,
ByteString* sSysFontAlias);
private:
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 22f7c8f5d9..e395fbfa4a 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -313,12 +313,12 @@ ByteString GetColorStringWithDefault(CPDF_Array* pColor,
}
float GetBorderWidth(const CPDF_Dictionary& pAnnotDict) {
- if (CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictFor("BS")) {
+ if (const CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictFor("BS")) {
if (pBorderStyleDict->KeyExist("W"))
return pBorderStyleDict->GetNumberFor("W");
}
- if (CPDF_Array* pBorderArray = pAnnotDict.GetArrayFor("Border")) {
+ if (const CPDF_Array* pBorderArray = pAnnotDict.GetArrayFor("Border")) {
if (pBorderArray->GetCount() > 2)
return pBorderArray->GetNumberAt(2);
}
@@ -326,13 +326,13 @@ float GetBorderWidth(const CPDF_Dictionary& pAnnotDict) {
return 1;
}
-CPDF_Array* GetDashArray(const CPDF_Dictionary& pAnnotDict) {
- if (CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictFor("BS")) {
+const CPDF_Array* GetDashArray(const CPDF_Dictionary& pAnnotDict) {
+ if (const CPDF_Dictionary* pBorderStyleDict = pAnnotDict.GetDictFor("BS")) {
if (pBorderStyleDict->GetStringFor("S") == "D")
return pBorderStyleDict->GetArrayFor("D");
}
- if (CPDF_Array* pBorderArray = pAnnotDict.GetArrayFor("Border")) {
+ if (const CPDF_Array* pBorderArray = pAnnotDict.GetArrayFor("Border")) {
if (pBorderArray->GetCount() == 4)
return pBorderArray->GetArrayAt(3);
}
@@ -341,7 +341,7 @@ CPDF_Array* GetDashArray(const CPDF_Dictionary& pAnnotDict) {
}
ByteString GetDashPatternString(const CPDF_Dictionary& pAnnotDict) {
- CPDF_Array* pDashArray = GetDashArray(pAnnotDict);
+ const CPDF_Array* pDashArray = GetDashArray(pAnnotDict);
if (!pDashArray || pDashArray->IsEmpty())
return ByteString();
@@ -907,11 +907,11 @@ bool GenerateStrikeOutAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict) {
void CPVT_GenerateAP::GenerateFormAP(Type type,
CPDF_Document* pDoc,
CPDF_Dictionary* pAnnotDict) {
- const CPDF_Dictionary* pRootDict = pDoc->GetRoot();
+ CPDF_Dictionary* pRootDict = pDoc->GetRoot();
if (!pRootDict)
return;
- const CPDF_Dictionary* pFormDict = pRootDict->GetDictFor("AcroForm");
+ CPDF_Dictionary* pFormDict = pRootDict->GetDictFor("AcroForm");
if (!pFormDict)
return;
diff --git a/fpdfsdk/cpdfsdk_actionhandler.cpp b/fpdfsdk/cpdfsdk_actionhandler.cpp
index 660b09c515..d7bcd7f350 100644
--- a/fpdfsdk/cpdfsdk_actionhandler.cpp
+++ b/fpdfsdk/cpdfsdk_actionhandler.cpp
@@ -23,7 +23,7 @@
bool CPDFSDK_ActionHandler::DoAction_DocOpen(
const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- std::set<CPDF_Dictionary*> visited;
+ std::set<const CPDF_Dictionary*> visited;
return ExecuteDocumentOpenAction(action, pFormFillEnv, &visited);
}
@@ -64,7 +64,7 @@ bool CPDFSDK_ActionHandler::DoAction_Page(
const CPDF_Action& action,
enum CPDF_AAction::AActionType eType,
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- std::set<CPDF_Dictionary*> visited;
+ std::set<const CPDF_Dictionary*> visited;
return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited);
}
@@ -72,7 +72,7 @@ bool CPDFSDK_ActionHandler::DoAction_Document(
const CPDF_Action& action,
enum CPDF_AAction::AActionType eType,
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- std::set<CPDF_Dictionary*> visited;
+ std::set<const CPDF_Dictionary*> visited;
return ExecuteDocumentPageAction(action, eType, pFormFillEnv, &visited);
}
@@ -81,7 +81,7 @@ bool CPDFSDK_ActionHandler::DoAction_BookMark(
const CPDF_Action& action,
CPDF_AAction::AActionType type,
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- std::set<CPDF_Dictionary*> visited;
+ std::set<const CPDF_Dictionary*> visited;
return ExecuteBookMark(action, pFormFillEnv, pBookMark, &visited);
}
@@ -90,14 +90,14 @@ bool CPDFSDK_ActionHandler::DoAction_Screen(
CPDF_AAction::AActionType type,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDFSDK_Annot* pScreen) {
- std::set<CPDF_Dictionary*> visited;
+ std::set<const CPDF_Dictionary*> visited;
return ExecuteScreenAction(action, type, pFormFillEnv, pScreen, &visited);
}
bool CPDFSDK_ActionHandler::DoAction_Link(
const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv) {
- std::set<CPDF_Dictionary*> visited;
+ std::set<const CPDF_Dictionary*> visited;
return ExecuteLinkAction(action, pFormFillEnv, &visited);
}
@@ -107,7 +107,7 @@ bool CPDFSDK_ActionHandler::DoAction_Field(
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
CPDFSDK_FieldAction* data) {
- std::set<CPDF_Dictionary*> visited;
+ std::set<const CPDF_Dictionary*> visited;
return ExecuteFieldAction(action, type, pFormFillEnv, pFormField, data,
&visited);
}
@@ -115,8 +115,8 @@ bool CPDFSDK_ActionHandler::DoAction_Field(
bool CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
- std::set<CPDF_Dictionary*>* visited) {
- CPDF_Dictionary* pDict = action.GetDict();
+ std::set<const CPDF_Dictionary*>* visited) {
+ const CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
return false;
@@ -145,8 +145,8 @@ bool CPDFSDK_ActionHandler::ExecuteDocumentOpenAction(
bool CPDFSDK_ActionHandler::ExecuteLinkAction(
const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
- std::set<CPDF_Dictionary*>* visited) {
- CPDF_Dictionary* pDict = action.GetDict();
+ std::set<const CPDF_Dictionary*>* visited) {
+ const CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
return false;
@@ -175,8 +175,8 @@ bool CPDFSDK_ActionHandler::ExecuteDocumentPageAction(
const CPDF_Action& action,
CPDF_AAction::AActionType type,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
- std::set<CPDF_Dictionary*>* visited) {
- CPDF_Dictionary* pDict = action.GetDict();
+ std::set<const CPDF_Dictionary*>* visited) {
+ const CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
return false;
@@ -220,8 +220,8 @@ bool CPDFSDK_ActionHandler::ExecuteFieldAction(
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
CPDFSDK_FieldAction* data,
- std::set<CPDF_Dictionary*>* visited) {
- CPDF_Dictionary* pDict = action.GetDict();
+ std::set<const CPDF_Dictionary*>* visited) {
+ const CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
return false;
@@ -256,8 +256,8 @@ bool CPDFSDK_ActionHandler::ExecuteScreenAction(
CPDF_AAction::AActionType type,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDFSDK_Annot* pScreen,
- std::set<CPDF_Dictionary*>* visited) {
- CPDF_Dictionary* pDict = action.GetDict();
+ std::set<const CPDF_Dictionary*>* visited) {
+ const CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
return false;
@@ -282,8 +282,8 @@ bool CPDFSDK_ActionHandler::ExecuteBookMark(
const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_Bookmark* pBookmark,
- std::set<CPDF_Dictionary*>* visited) {
- CPDF_Dictionary* pDict = action.GetDict();
+ std::set<const CPDF_Dictionary*>* visited) {
+ const CPDF_Dictionary* pDict = action.GetDict();
if (pdfium::ContainsKey(*visited, pDict))
return false;
diff --git a/fpdfsdk/cpdfsdk_actionhandler.h b/fpdfsdk/cpdfsdk_actionhandler.h
index 78d3e22e4f..a144504dec 100644
--- a/fpdfsdk/cpdfsdk_actionhandler.h
+++ b/fpdfsdk/cpdfsdk_actionhandler.h
@@ -68,29 +68,29 @@ class CPDFSDK_ActionHandler {
bool ExecuteDocumentOpenAction(const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
- std::set<CPDF_Dictionary*>* visited);
+ std::set<const CPDF_Dictionary*>* visited);
bool ExecuteDocumentPageAction(const CPDF_Action& action,
CPDF_AAction::AActionType type,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
- std::set<CPDF_Dictionary*>* visited);
+ std::set<const CPDF_Dictionary*>* visited);
bool ExecuteFieldAction(const CPDF_Action& action,
CPDF_AAction::AActionType type,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_FormField* pFormField,
CPDFSDK_FieldAction* data,
- std::set<CPDF_Dictionary*>* visited);
+ std::set<const CPDF_Dictionary*>* visited);
bool ExecuteScreenAction(const CPDF_Action& action,
CPDF_AAction::AActionType type,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDFSDK_Annot* pScreen,
- std::set<CPDF_Dictionary*>* visited);
+ std::set<const CPDF_Dictionary*>* visited);
bool ExecuteBookMark(const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
CPDF_Bookmark* pBookmark,
- std::set<CPDF_Dictionary*>* visited);
+ std::set<const CPDF_Dictionary*>* visited);
bool ExecuteLinkAction(const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv,
- std::set<CPDF_Dictionary*>* visited);
+ std::set<const CPDF_Dictionary*>* visited);
void DoAction_NoJs(const CPDF_Action& action,
CPDFSDK_FormFillEnvironment* pFormFillEnv);
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp
index 87ba9e2ec2..eb91bcf9ba 100644
--- a/fpdfsdk/cpdfsdk_helpers.cpp
+++ b/fpdfsdk/cpdfsdk_helpers.cpp
@@ -224,14 +224,15 @@ void CheckUnSupportError(CPDF_Document* pDoc, uint32_t err_code) {
return;
}
if (pRootDict->KeyExist("Names")) {
- CPDF_Dictionary* pNameDict = pRootDict->GetDictFor("Names");
+ const CPDF_Dictionary* pNameDict = pRootDict->GetDictFor("Names");
if (pNameDict && pNameDict->KeyExist("EmbeddedFiles")) {
RaiseUnSupportError(FPDF_UNSP_DOC_ATTACHMENT);
return;
}
if (pNameDict && pNameDict->KeyExist("JavaScript")) {
- CPDF_Dictionary* pJSDict = pNameDict->GetDictFor("JavaScript");
- CPDF_Array* pArray = pJSDict ? pJSDict->GetArrayFor("Names") : nullptr;
+ const CPDF_Dictionary* pJSDict = pNameDict->GetDictFor("JavaScript");
+ const CPDF_Array* pArray =
+ pJSDict ? pJSDict->GetArrayFor("Names") : nullptr;
if (pArray) {
for (size_t i = 0; i < pArray->GetCount(); i++) {
ByteString cbStr = pArray->GetStringAt(i);
@@ -384,7 +385,12 @@ CFX_FloatRect CFXFloatRectFromFSRECTF(const FS_RECTF& rect) {
return CFX_FloatRect(rect.left, rect.bottom, rect.right, rect.top);
}
-CPDF_Array* GetQuadPointsArrayFromDictionary(const CPDF_Dictionary* dict) {
+const CPDF_Array* GetQuadPointsArrayFromDictionary(
+ const CPDF_Dictionary* dict) {
+ return dict ? dict->GetArrayFor("QuadPoints") : nullptr;
+}
+
+CPDF_Array* GetQuadPointsArrayFromDictionary(CPDF_Dictionary* dict) {
return dict ? dict->GetArrayFor("QuadPoints") : nullptr;
}
diff --git a/fpdfsdk/cpdfsdk_helpers.h b/fpdfsdk/cpdfsdk_helpers.h
index d93ecfc89b..10f44e409a 100644
--- a/fpdfsdk/cpdfsdk_helpers.h
+++ b/fpdfsdk/cpdfsdk_helpers.h
@@ -64,11 +64,11 @@ FPDF_DOCUMENT FPDFDocumentFromCPDFDocument(CPDF_Document* doc);
CPDF_Document* CPDFDocumentFromFPDFDocument(FPDF_DOCUMENT doc);
// Conversions to/from incomplete FPDF_ API types.
-inline FPDF_ACTION FPDFActionFromCPDFDictionary(CPDF_Dictionary* action) {
+inline FPDF_ACTION FPDFActionFromCPDFDictionary(const CPDF_Dictionary* action) {
return reinterpret_cast<FPDF_ACTION>(action);
}
-inline CPDF_Dictionary* CPDFDictionaryFromFPDFAction(FPDF_ACTION action) {
- return reinterpret_cast<CPDF_Dictionary*>(action);
+inline const CPDF_Dictionary* CPDFDictionaryFromFPDFAction(FPDF_ACTION action) {
+ return reinterpret_cast<const CPDF_Dictionary*>(action);
}
inline FPDF_ANNOTATION FPDFAnnotationFromCPDFAnnotContext(
@@ -94,11 +94,13 @@ inline CFX_DIBitmap* CFXDIBitmapFromFPDFBitmap(FPDF_BITMAP bitmap) {
return reinterpret_cast<CFX_DIBitmap*>(bitmap);
}
-inline FPDF_BOOKMARK FPDFBookmarkFromCPDFDictionary(CPDF_Dictionary* bookmark) {
+inline FPDF_BOOKMARK FPDFBookmarkFromCPDFDictionary(
+ const CPDF_Dictionary* bookmark) {
return reinterpret_cast<FPDF_BOOKMARK>(bookmark);
}
-inline CPDF_Dictionary* CPDFDictionaryFromFPDFBookmark(FPDF_BOOKMARK bookmark) {
- return reinterpret_cast<CPDF_Dictionary*>(bookmark);
+inline const CPDF_Dictionary* CPDFDictionaryFromFPDFBookmark(
+ FPDF_BOOKMARK bookmark) {
+ return reinterpret_cast<const CPDF_Dictionary*>(bookmark);
}
inline FPDF_CLIPPATH FPDFClipPathFromCPDFClipPath(CPDF_ClipPath* path) {
@@ -220,7 +222,8 @@ RetainPtr<IFX_SeekableStream> MakeSeekableStream(
FPDF_FILEHANDLER* pFileHandler);
#endif // PDF_ENABLE_XFA
-CPDF_Array* GetQuadPointsArrayFromDictionary(const CPDF_Dictionary* dict);
+const CPDF_Array* GetQuadPointsArrayFromDictionary(const CPDF_Dictionary* dict);
+CPDF_Array* GetQuadPointsArrayFromDictionary(CPDF_Dictionary* dict);
CPDF_Array* AddQuadPointsArrayToDictionary(CPDF_Dictionary* dict);
bool IsValidQuadPointsIndex(const CPDF_Array* array, size_t index);
bool GetQuadPointsAtIndex(const CPDF_Array* array,
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index b37562ccf2..638b4dfc07 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -412,7 +412,7 @@ bool CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) {
ASSERT(action.GetDict());
CPDF_ActionFields af(&action);
- std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
+ std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields();
std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
bool bHide = action.GetHideStatus();
@@ -446,11 +446,11 @@ bool CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) {
if (sDestination.IsEmpty())
return false;
- CPDF_Dictionary* pActionDict = action.GetDict();
+ const CPDF_Dictionary* pActionDict = action.GetDict();
if (pActionDict->KeyExist("Fields")) {
CPDF_ActionFields af(&action);
uint32_t dwFlags = action.GetFlags();
- std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
+ std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields();
std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
if (!fields.empty()) {
bool bIncludeOrExclude = !(dwFlags & 0x01);
@@ -590,7 +590,7 @@ ByteString CPDFSDK_InterForm::ExportFormToFDFTextBuf() {
void CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) {
ASSERT(action.GetDict());
- CPDF_Dictionary* pActionDict = action.GetDict();
+ const CPDF_Dictionary* pActionDict = action.GetDict();
if (!pActionDict->KeyExist("Fields")) {
m_pInterForm->ResetForm(true);
return;
@@ -599,15 +599,15 @@ void CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) {
CPDF_ActionFields af(&action);
uint32_t dwFlags = action.GetFlags();
- std::vector<CPDF_Object*> fieldObjects = af.GetAllFields();
+ std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields();
std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true);
}
std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects(
- const std::vector<CPDF_Object*>& objects) const {
+ const std::vector<const CPDF_Object*>& objects) const {
std::vector<CPDF_FormField*> fields;
- for (CPDF_Object* pObject : objects) {
+ for (const CPDF_Object* pObject : objects) {
if (!pObject || !pObject->IsString())
continue;
diff --git a/fpdfsdk/cpdfsdk_interform.h b/fpdfsdk/cpdfsdk_interform.h
index 6195ee9f5f..bb6d7fc260 100644
--- a/fpdfsdk/cpdfsdk_interform.h
+++ b/fpdfsdk/cpdfsdk_interform.h
@@ -80,7 +80,7 @@ class CPDFSDK_InterForm : public IPDF_FormNotify {
void DoAction_ResetForm(const CPDF_Action& action);
std::vector<CPDF_FormField*> GetFieldFromObjects(
- const std::vector<CPDF_Object*>& objects) const;
+ const std::vector<const CPDF_Object*>& objects) const;
bool IsValidField(CPDF_Dictionary* pFieldDict);
bool SubmitFields(const WideString& csDestination,
const std::vector<CPDF_FormField*>& fields,
diff --git a/fpdfsdk/fpdf_doc.cpp b/fpdfsdk/fpdf_doc.cpp
index 3bb89fc48a..6b62227da2 100644
--- a/fpdfsdk/fpdf_doc.cpp
+++ b/fpdfsdk/fpdf_doc.cpp
@@ -26,7 +26,7 @@ namespace {
CPDF_Bookmark FindBookmark(const CPDF_BookmarkTree& tree,
CPDF_Bookmark bookmark,
const WideString& title,
- std::set<CPDF_Dictionary*>* visited) {
+ std::set<const CPDF_Dictionary*>* visited) {
// Return if already checked to avoid circular calling.
if (pdfium::ContainsKey(*visited, bookmark.GetDict()))
return CPDF_Bookmark();
@@ -107,7 +107,7 @@ FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title) {
CPDF_BookmarkTree tree(pDoc);
size_t len = WideString::WStringLength(title);
WideString encodedTitle = WideString::FromUTF16LE(title, len);
- std::set<CPDF_Dictionary*> visited;
+ std::set<const CPDF_Dictionary*> visited;
return FPDFBookmarkFromCPDFDictionary(
FindBookmark(tree, CPDF_Bookmark(), encodedTitle, &visited).GetDict());
}
diff --git a/public/fpdfview.h b/public/fpdfview.h
index 66813d8bb4..a3017b4ca4 100644
--- a/public/fpdfview.h
+++ b/public/fpdfview.h
@@ -35,11 +35,11 @@
#define FPDF_OBJECT_REFERENCE 9
// PDF types - use incomplete types for type safety.
-typedef struct fpdf_action_t__* FPDF_ACTION;
+typedef const struct fpdf_action_t__* FPDF_ACTION;
typedef struct fpdf_annotation_t__* FPDF_ANNOTATION;
typedef struct fpdf_attachment_t__* FPDF_ATTACHMENT;
typedef struct fpdf_bitmap_t__* FPDF_BITMAP;
-typedef struct fpdf_bookmark_t__* FPDF_BOOKMARK;
+typedef const struct fpdf_bookmark_t__* FPDF_BOOKMARK;
typedef struct fpdf_clippath_t__* FPDF_CLIPPATH;
typedef struct fpdf_dest_t__* FPDF_DEST;
typedef struct fpdf_document_t__* FPDF_DOCUMENT;