summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_actionfields.cpp
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 /core/fpdfdoc/cpdf_actionfields.cpp
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>
Diffstat (limited to 'core/fpdfdoc/cpdf_actionfields.cpp')
-rw-r--r--core/fpdfdoc/cpdf_actionfields.cpp31
1 files changed, 15 insertions, 16 deletions
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;