summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/page/cpdf_function.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.cpp10
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.h3
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp6
4 files changed, 13 insertions, 8 deletions
diff --git a/core/fpdfapi/page/cpdf_function.cpp b/core/fpdfapi/page/cpdf_function.cpp
index ad3b666a1f..b9753abeef 100644
--- a/core/fpdfapi/page/cpdf_function.cpp
+++ b/core/fpdfapi/page/cpdf_function.cpp
@@ -100,7 +100,7 @@ bool CPDF_Function::Init(const CPDF_Object* pObj,
m_pDomains[i] = pDomains->GetFloatAt(i);
}
- CPDF_Array* pRanges = pDict->GetArrayFor("Range");
+ const CPDF_Array* pRanges = pDict->GetArrayFor("Range");
m_nOutputs = pRanges ? pRanges->GetCount() / 2 : 0;
// Ranges are required for type 0 and type 4 functions. A non-zero
diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp
index 0bdb8a8b16..1ede5e707a 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.cpp
+++ b/core/fpdfapi/parser/cpdf_dictionary.cpp
@@ -141,7 +141,11 @@ CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const ByteString& key) const {
return nullptr;
}
-CPDF_Array* CPDF_Dictionary::GetArrayFor(const ByteString& key) const {
+const CPDF_Array* CPDF_Dictionary::GetArrayFor(const ByteString& key) const {
+ return ToArray(GetDirectObjectFor(key));
+}
+
+CPDF_Array* CPDF_Dictionary::GetArrayFor(const ByteString& key) {
return ToArray(GetDirectObjectFor(key));
}
@@ -155,7 +159,7 @@ CPDF_Stream* CPDF_Dictionary::GetStreamFor(const ByteString& key) {
CFX_FloatRect CPDF_Dictionary::GetRectFor(const ByteString& key) const {
CFX_FloatRect rect;
- CPDF_Array* pArray = GetArrayFor(key);
+ const CPDF_Array* pArray = GetArrayFor(key);
if (pArray)
rect = pArray->GetRect();
return rect;
@@ -163,7 +167,7 @@ CFX_FloatRect CPDF_Dictionary::GetRectFor(const ByteString& key) const {
CFX_Matrix CPDF_Dictionary::GetMatrixFor(const ByteString& key) const {
CFX_Matrix matrix;
- CPDF_Array* pArray = GetArrayFor(key);
+ const CPDF_Array* pArray = GetArrayFor(key);
if (pArray)
matrix = pArray->GetMatrix();
return matrix;
diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h
index f2ee588dab..df789aa7b4 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.h
+++ b/core/fpdfapi/parser/cpdf_dictionary.h
@@ -54,7 +54,8 @@ class CPDF_Dictionary : public CPDF_Object {
CPDF_Dictionary* GetDictFor(const ByteString& key) const;
const CPDF_Stream* GetStreamFor(const ByteString& key) const;
CPDF_Stream* GetStreamFor(const ByteString& key);
- CPDF_Array* GetArrayFor(const ByteString& key) const;
+ const CPDF_Array* GetArrayFor(const ByteString& key) const;
+ CPDF_Array* GetArrayFor(const ByteString& key);
CFX_FloatRect GetRectFor(const ByteString& key) const;
CFX_Matrix GetMatrixFor(const ByteString& key) const;
float GetFloatFor(const ByteString& key) const { return GetNumberFor(key); }
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index b2ebc74279..e9de5289a4 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -359,7 +359,7 @@ bool CPDF_DIBSource::LoadColorInfo(const CPDF_Dictionary* pFormResources,
}
m_bImageMask = true;
m_bpc = m_nComponents = 1;
- CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode");
+ const CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode");
m_bDefaultDecode = !pDecode || !pDecode->GetIntegerAt(0);
return true;
}
@@ -398,7 +398,7 @@ bool CPDF_DIBSource::GetDecodeAndMaskArray(bool* bDefaultDecode,
m_CompData.resize(m_nComponents);
int max_data = (1 << m_bpc) - 1;
- CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode");
+ const CPDF_Array* pDecode = m_pDict->GetArrayFor("Decode");
if (pDecode) {
for (uint32_t i = 0; i < m_nComponents; i++) {
m_CompData[i].m_DecodeMin = pDecode->GetNumberAt(i * 2);
@@ -658,7 +658,7 @@ CPDF_DIBSource::LoadState CPDF_DIBSource::StartLoadMask() {
return m_pMaskStream ? StartLoadMaskDIB() : LoadState::kSuccess;
}
- CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArrayFor("Matte");
+ const CPDF_Array* pMatte = m_pMaskStream->GetDict()->GetArrayFor("Matte");
if (pMatte && m_pColorSpace && m_Family != PDFCS_PATTERN &&
m_pColorSpace->CountComponents() <= m_nComponents) {
std::vector<float> colors(m_nComponents);