summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--core/fxge/skia/fx_skia_device.cpp2
-rw-r--r--fpdfsdk/cpdfsdk_formfillenvironment.cpp4
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp24
7 files changed, 29 insertions, 22 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);
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index b922e49e4a..c68fd57798 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -2027,7 +2027,7 @@ bool CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern,
return false;
}
}
- CPDF_Array* pArray = pDict->GetArrayFor("Extend");
+ const CPDF_Array* pArray = pDict->GetArrayFor("Extend");
bool clipStart = !pArray || !pArray->GetIntegerAt(0);
bool clipEnd = !pArray || !pArray->GetIntegerAt(1);
SkPaint paint;
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
index 599aed3cf2..49a4a601d5 100644
--- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp
+++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp
@@ -581,7 +581,7 @@ bool CPDFSDK_FormFillEnvironment::ProcOpenAction() {
if (!pRoot)
return false;
- CPDF_Object* pOpenAction = pRoot->GetDictFor("OpenAction");
+ const CPDF_Object* pOpenAction = pRoot->GetDictFor("OpenAction");
if (!pOpenAction)
pOpenAction = pRoot->GetArrayFor("OpenAction");
if (!pOpenAction)
@@ -590,7 +590,7 @@ bool CPDFSDK_FormFillEnvironment::ProcOpenAction() {
if (pOpenAction->IsArray())
return true;
- CPDF_Dictionary* pDict = pOpenAction->AsDictionary();
+ const CPDF_Dictionary* pDict = pOpenAction->AsDictionary();
if (!pDict)
return false;
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index d162f16883..ebf356af45 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -86,7 +86,7 @@ class FPDFEditEmbeddertest : public EmbedderTest {
EXPECT_EQ(data[j], stream_data[j]) << " at byte " << j;
}
- void CheckCompositeFontWidths(CPDF_Array* widths_array,
+ void CheckCompositeFontWidths(const CPDF_Array* widths_array,
CPDF_Font* typed_font) {
// Check that W array is in a format that conforms to PDF spec 1.7 section
// "Glyph Metrics in CIDFonts" (these checks are not
@@ -98,10 +98,10 @@ class FPDFEditEmbeddertest : public EmbedderTest {
int cid = widths_array->GetNumberAt(idx);
EXPECT_GE(cid, cur_cid);
ASSERT_FALSE(++idx == widths_array->GetCount());
- CPDF_Object* next = widths_array->GetObjectAt(idx);
+ const CPDF_Object* next = widths_array->GetObjectAt(idx);
if (next->IsArray()) {
// We are in the c [w1 w2 ...] case
- CPDF_Array* arr = next->AsArray();
+ const CPDF_Array* arr = next->AsArray();
int cnt = static_cast<int>(arr->GetCount());
size_t inner_idx = 0;
for (cur_cid = cid; cur_cid < cid + cnt; cur_cid++) {
@@ -1012,7 +1012,7 @@ TEST_F(FPDFEditEmbeddertest, LoadSimpleType1Font) {
EXPECT_EQ(32, font_dict->GetIntegerFor("FirstChar"));
EXPECT_EQ(255, font_dict->GetIntegerFor("LastChar"));
- CPDF_Array* widths_array = font_dict->GetArrayFor("Widths");
+ const CPDF_Array* widths_array = font_dict->GetArrayFor("Widths");
ASSERT_TRUE(widths_array);
ASSERT_EQ(224U, widths_array->GetCount());
EXPECT_EQ(250, widths_array->GetNumberAt(0));
@@ -1041,7 +1041,7 @@ TEST_F(FPDFEditEmbeddertest, LoadSimpleTrueTypeFont) {
EXPECT_EQ(32, font_dict->GetIntegerFor("FirstChar"));
EXPECT_EQ(255, font_dict->GetIntegerFor("LastChar"));
- CPDF_Array* widths_array = font_dict->GetArrayFor("Widths");
+ const CPDF_Array* widths_array = font_dict->GetArrayFor("Widths");
ASSERT_TRUE(widths_array);
ASSERT_EQ(224U, widths_array->GetCount());
EXPECT_EQ(600, widths_array->GetNumberAt(33));
@@ -1068,12 +1068,13 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType0Font) {
EXPECT_EQ("Type0", font_dict->GetStringFor("Subtype"));
EXPECT_EQ("Times New Roman-Identity-H", font_dict->GetStringFor("BaseFont"));
EXPECT_EQ("Identity-H", font_dict->GetStringFor("Encoding"));
- CPDF_Array* descendant_array = font_dict->GetArrayFor("DescendantFonts");
+ const CPDF_Array* descendant_array =
+ font_dict->GetArrayFor("DescendantFonts");
ASSERT_TRUE(descendant_array);
EXPECT_EQ(1U, descendant_array->GetCount());
// Check the CIDFontDict
- CPDF_Dictionary* cidfont_dict = descendant_array->GetDictAt(0);
+ const CPDF_Dictionary* cidfont_dict = descendant_array->GetDictAt(0);
EXPECT_EQ("Font", cidfont_dict->GetStringFor("Type"));
EXPECT_EQ("CIDFontType0", cidfont_dict->GetStringFor("Subtype"));
EXPECT_EQ("Times New Roman", cidfont_dict->GetStringFor("BaseFont"));
@@ -1085,7 +1086,7 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType0Font) {
CheckFontDescriptor(cidfont_dict, FPDF_FONT_TYPE1, false, false, size, data);
// Check widths
- CPDF_Array* widths_array = cidfont_dict->GetArrayFor("W");
+ const CPDF_Array* widths_array = cidfont_dict->GetArrayFor("W");
ASSERT_TRUE(widths_array);
EXPECT_GT(widths_array->GetCount(), 1U);
CheckCompositeFontWidths(widths_array, typed_font);
@@ -1110,12 +1111,13 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType2Font) {
EXPECT_EQ("Type0", font_dict->GetStringFor("Subtype"));
EXPECT_EQ("Arial Italic", font_dict->GetStringFor("BaseFont"));
EXPECT_EQ("Identity-H", font_dict->GetStringFor("Encoding"));
- CPDF_Array* descendant_array = font_dict->GetArrayFor("DescendantFonts");
+ const CPDF_Array* descendant_array =
+ font_dict->GetArrayFor("DescendantFonts");
ASSERT_TRUE(descendant_array);
EXPECT_EQ(1U, descendant_array->GetCount());
// Check the CIDFontDict
- CPDF_Dictionary* cidfont_dict = descendant_array->GetDictAt(0);
+ const CPDF_Dictionary* cidfont_dict = descendant_array->GetDictAt(0);
EXPECT_EQ("Font", cidfont_dict->GetStringFor("Type"));
EXPECT_EQ("CIDFontType2", cidfont_dict->GetStringFor("Subtype"));
EXPECT_EQ("Arial Italic", cidfont_dict->GetStringFor("BaseFont"));
@@ -1128,7 +1130,7 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType2Font) {
data);
// Check widths
- CPDF_Array* widths_array = cidfont_dict->GetArrayFor("W");
+ const CPDF_Array* widths_array = cidfont_dict->GetArrayFor("W");
ASSERT_TRUE(widths_array);
CheckCompositeFontWidths(widths_array, typed_font);
}