summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp1
-rw-r--r--core/fpdfapi/font/cpdf_font.h3
-rw-r--r--core/fpdfapi/page/cpdf_docpagedata.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_docpagedata.h5
-rw-r--r--core/fpdfapi/page/cpdf_pattern.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_pattern.h3
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.cpp6
-rw-r--r--core/fpdfapi/page/cpdf_shadingpattern.h4
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_tilingpattern.cpp2
-rw-r--r--core/fxge/skia/fx_skia_device.cpp6
-rw-r--r--fpdfsdk/fpdf_edit_embeddertest.cpp10
12 files changed, 27 insertions, 23 deletions
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index ad7eeea264..2201e390ff 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -315,6 +315,7 @@ CPDF_Font* CPDF_Font::GetStockFont(CPDF_Document* pDoc,
return pFontGlobals->Set(pDoc, font_id, CPDF_Font::Create(nullptr, pDict));
}
+// static
std::unique_ptr<CPDF_Font> CPDF_Font::Create(CPDF_Document* pDoc,
CPDF_Dictionary* pFontDict) {
ByteString type = pFontDict->GetStringFor("Subtype");
diff --git a/core/fpdfapi/font/cpdf_font.h b/core/fpdfapi/font/cpdf_font.h
index 588fb66163..cda86e6ea3 100644
--- a/core/fpdfapi/font/cpdf_font.h
+++ b/core/fpdfapi/font/cpdf_font.h
@@ -66,7 +66,8 @@ class CPDF_Font {
const ByteString& GetBaseFont() const { return m_BaseFont; }
CFX_SubstFont* GetSubstFont() const { return m_Font.GetSubstFont(); }
bool IsEmbedded() const { return IsType3Font() || m_pFontFile != nullptr; }
- CPDF_Dictionary* GetFontDict() const { return m_pFontDict; }
+ const CPDF_Dictionary* GetFontDict() const { return m_pFontDict; }
+ CPDF_Dictionary* GetFontDict() { return m_pFontDict; }
bool IsStandardFont() const;
FXFT_Face GetFace() const { return m_Font.GetFace(); }
void AppendChar(ByteString* str, uint32_t charcode) const;
diff --git a/core/fpdfapi/page/cpdf_docpagedata.cpp b/core/fpdfapi/page/cpdf_docpagedata.cpp
index 79e148c72a..92dca138cf 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.cpp
+++ b/core/fpdfapi/page/cpdf_docpagedata.cpp
@@ -457,13 +457,13 @@ void CPDF_DocPageData::MaybePurgeIccProfile(const CPDF_Stream* pProfileStream) {
}
RetainPtr<CPDF_StreamAcc> CPDF_DocPageData::GetFontFileStreamAcc(
- CPDF_Stream* pFontStream) {
+ const CPDF_Stream* pFontStream) {
ASSERT(pFontStream);
auto it = m_FontFileMap.find(pFontStream);
if (it != m_FontFileMap.end())
return it->second;
- CPDF_Dictionary* pFontDict = pFontStream->GetDict();
+ const CPDF_Dictionary* pFontDict = pFontStream->GetDict();
int32_t org_size = pFontDict->GetIntegerFor("Length1") +
pFontDict->GetIntegerFor("Length2") +
pFontDict->GetIntegerFor("Length3");
@@ -495,7 +495,7 @@ CPDF_CountedColorSpace* CPDF_DocPageData::FindColorSpacePtr(
}
CPDF_CountedPattern* CPDF_DocPageData::FindPatternPtr(
- CPDF_Object* pPatternObj) const {
+ const CPDF_Object* pPatternObj) const {
if (!pPatternObj)
return nullptr;
diff --git a/core/fpdfapi/page/cpdf_docpagedata.h b/core/fpdfapi/page/cpdf_docpagedata.h
index 04b77cf3ed..41a5cd68be 100644
--- a/core/fpdfapi/page/cpdf_docpagedata.h
+++ b/core/fpdfapi/page/cpdf_docpagedata.h
@@ -64,11 +64,12 @@ class CPDF_DocPageData {
RetainPtr<CPDF_IccProfile> GetIccProfile(const CPDF_Stream* pProfileStream);
void MaybePurgeIccProfile(const CPDF_Stream* pProfileStream);
- RetainPtr<CPDF_StreamAcc> GetFontFileStreamAcc(CPDF_Stream* pFontStream);
+ RetainPtr<CPDF_StreamAcc> GetFontFileStreamAcc(
+ const CPDF_Stream* pFontStream);
void MaybePurgeFontFileStreamAcc(const CPDF_Stream* pFontStream);
CPDF_CountedColorSpace* FindColorSpacePtr(const CPDF_Object* pCSObj) const;
- CPDF_CountedPattern* FindPatternPtr(CPDF_Object* pPatternObj) const;
+ CPDF_CountedPattern* FindPatternPtr(const CPDF_Object* pPatternObj) const;
private:
using CPDF_CountedFont = CPDF_CountedObject<CPDF_Font>;
diff --git a/core/fpdfapi/page/cpdf_pattern.cpp b/core/fpdfapi/page/cpdf_pattern.cpp
index 88e5dee35c..e2dc4f4f77 100644
--- a/core/fpdfapi/page/cpdf_pattern.cpp
+++ b/core/fpdfapi/page/cpdf_pattern.cpp
@@ -16,7 +16,7 @@ CPDF_Pattern::CPDF_Pattern(CPDF_Document* pDoc,
CPDF_Pattern::~CPDF_Pattern() {}
void CPDF_Pattern::SetPatternToFormMatrix() {
- CPDF_Dictionary* pDict = pattern_obj()->GetDict();
+ const CPDF_Dictionary* pDict = pattern_obj()->GetDict();
m_Pattern2Form = pDict->GetMatrixFor("Matrix");
m_Pattern2Form.Concat(m_ParentMatrix);
}
diff --git a/core/fpdfapi/page/cpdf_pattern.h b/core/fpdfapi/page/cpdf_pattern.h
index 307c677775..f1d98922c7 100644
--- a/core/fpdfapi/page/cpdf_pattern.h
+++ b/core/fpdfapi/page/cpdf_pattern.h
@@ -28,7 +28,8 @@ class CPDF_Pattern {
// All the getters that return pointers return non-NULL pointers.
CPDF_Document* document() const { return m_pDocument.Get(); }
- CPDF_Object* pattern_obj() const { return m_pPatternObj.Get(); }
+ CPDF_Object* pattern_obj() { return m_pPatternObj.Get(); }
+ const CPDF_Object* pattern_obj() const { return m_pPatternObj.Get(); }
CFX_Matrix* pattern_to_form() { return &m_Pattern2Form; }
const CFX_Matrix& parent_matrix() const { return m_ParentMatrix; }
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.cpp b/core/fpdfapi/page/cpdf_shadingpattern.cpp
index 76f201f767..52f4e1e10a 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_shadingpattern.cpp
@@ -63,15 +63,15 @@ bool CPDF_ShadingPattern::Load() {
if (m_ShadingType != kInvalidShading)
return true;
- CPDF_Dictionary* pShadingDict =
+ const CPDF_Dictionary* pShadingDict =
m_pShadingObj ? m_pShadingObj->GetDict() : nullptr;
if (!pShadingDict)
return false;
m_pFunctions.clear();
- CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function");
+ const CPDF_Object* pFunc = pShadingDict->GetDirectObjectFor("Function");
if (pFunc) {
- if (CPDF_Array* pArray = pFunc->AsArray()) {
+ if (const CPDF_Array* pArray = pFunc->AsArray()) {
m_pFunctions.resize(std::min<size_t>(pArray->GetCount(), 4));
for (size_t i = 0; i < m_pFunctions.size(); ++i)
m_pFunctions[i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i));
diff --git a/core/fpdfapi/page/cpdf_shadingpattern.h b/core/fpdfapi/page/cpdf_shadingpattern.h
index bb633f9a4d..3c68c818ea 100644
--- a/core/fpdfapi/page/cpdf_shadingpattern.h
+++ b/core/fpdfapi/page/cpdf_shadingpattern.h
@@ -54,7 +54,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
ShadingType GetShadingType() const { return m_ShadingType; }
bool IsShadingObject() const { return m_bShadingObj; }
- CPDF_Object* GetShadingObject() const { return m_pShadingObj.Get(); }
+ const CPDF_Object* GetShadingObject() const { return m_pShadingObj.Get(); }
CPDF_ColorSpace* GetCS() const { return m_pCS.Get(); }
const std::vector<std::unique_ptr<CPDF_Function>>& GetFuncs() const {
return m_pFunctions;
@@ -69,7 +69,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
ShadingType m_ShadingType = kInvalidShading;
const bool m_bShadingObj;
- UnownedPtr<CPDF_Object> m_pShadingObj;
+ UnownedPtr<const CPDF_Object> m_pShadingObj;
// Still keep |m_pCS| as some CPDF_ColorSpace (name object) are not managed
// as counted objects. Refer to CPDF_DocPageData::GetColorSpace.
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index 5f4bdf794d..9dd66f673b 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -75,7 +75,7 @@ class CPDF_StreamParserAutoClearer {
CFX_FloatRect GetShadingBBox(CPDF_ShadingPattern* pShading,
const CFX_Matrix& matrix) {
ShadingType type = pShading->GetShadingType();
- CPDF_Stream* pStream = ToStream(pShading->GetShadingObject());
+ const CPDF_Stream* pStream = ToStream(pShading->GetShadingObject());
CPDF_ColorSpace* pCS = pShading->GetCS();
if (!pStream || !pCS)
return CFX_FloatRect();
diff --git a/core/fpdfapi/page/cpdf_tilingpattern.cpp b/core/fpdfapi/page/cpdf_tilingpattern.cpp
index 5a71baaf7b..3cbfa07fa4 100644
--- a/core/fpdfapi/page/cpdf_tilingpattern.cpp
+++ b/core/fpdfapi/page/cpdf_tilingpattern.cpp
@@ -35,7 +35,7 @@ bool CPDF_TilingPattern::Load() {
if (m_pForm)
return true;
- CPDF_Dictionary* pDict = pattern_obj()->GetDict();
+ const CPDF_Dictionary* pDict = pattern_obj()->GetDict();
if (!pDict)
return false;
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index c0cc4e43d5..b922e49e4a 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -1996,8 +1996,8 @@ bool CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern,
int nFuncs = pFuncs.size();
if (nFuncs > 1) // TODO(caryclark) remove this restriction
return false;
- CPDF_Dictionary* pDict = pPattern->GetShadingObject()->GetDict();
- CPDF_Array* pCoords = pDict->GetArrayFor("Coords");
+ const CPDF_Dictionary* pDict = pPattern->GetShadingObject()->GetDict();
+ const CPDF_Array* pCoords = pDict->GetArrayFor("Coords");
if (!pCoords && kCoonsPatchMeshShading != shadingType)
return false;
// TODO(caryclark) Respect Domain[0], Domain[1]. (Don't know what they do
@@ -2106,7 +2106,7 @@ bool CFX_SkiaDeviceDriver::DrawShading(const CPDF_ShadingPattern* pPattern,
skPath.transform(inverse);
} else {
ASSERT(kCoonsPatchMeshShading == shadingType);
- CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject());
+ const CPDF_Stream* pStream = ToStream(pPattern->GetShadingObject());
if (!pStream)
return false;
CPDF_MeshStream stream(shadingType, pPattern->GetFuncs(), pStream,
diff --git a/fpdfsdk/fpdf_edit_embeddertest.cpp b/fpdfsdk/fpdf_edit_embeddertest.cpp
index 2a3a7768ff..d162f16883 100644
--- a/fpdfsdk/fpdf_edit_embeddertest.cpp
+++ b/fpdfsdk/fpdf_edit_embeddertest.cpp
@@ -32,7 +32,7 @@ class FPDFEditEmbeddertest : public EmbedderTest {
return document_;
}
- void CheckFontDescriptor(CPDF_Dictionary* font_dict,
+ void CheckFontDescriptor(const CPDF_Dictionary* font_dict,
int font_type,
bool bold,
bool italic,
@@ -1003,7 +1003,7 @@ TEST_F(FPDFEditEmbeddertest, LoadSimpleType1Font) {
CPDF_Font* typed_font = CPDFFontFromFPDFFont(font.get());
EXPECT_TRUE(typed_font->IsType1Font());
- CPDF_Dictionary* font_dict = typed_font->GetFontDict();
+ const CPDF_Dictionary* font_dict = typed_font->GetFontDict();
EXPECT_EQ("Font", font_dict->GetStringFor("Type"));
EXPECT_EQ("Type1", font_dict->GetStringFor("Subtype"));
EXPECT_EQ("Times New Roman Bold", font_dict->GetStringFor("BaseFont"));
@@ -1032,7 +1032,7 @@ TEST_F(FPDFEditEmbeddertest, LoadSimpleTrueTypeFont) {
CPDF_Font* typed_font = CPDFFontFromFPDFFont(font.get());
EXPECT_TRUE(typed_font->IsTrueTypeFont());
- CPDF_Dictionary* font_dict = typed_font->GetFontDict();
+ const CPDF_Dictionary* font_dict = typed_font->GetFontDict();
EXPECT_EQ("Font", font_dict->GetStringFor("Type"));
EXPECT_EQ("TrueType", font_dict->GetStringFor("Subtype"));
EXPECT_EQ("Courier New", font_dict->GetStringFor("BaseFont"));
@@ -1063,7 +1063,7 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType0Font) {
EXPECT_TRUE(typed_font->IsCIDFont());
// Check font dictionary entries
- CPDF_Dictionary* font_dict = typed_font->GetFontDict();
+ const CPDF_Dictionary* font_dict = typed_font->GetFontDict();
EXPECT_EQ("Font", font_dict->GetStringFor("Type"));
EXPECT_EQ("Type0", font_dict->GetStringFor("Subtype"));
EXPECT_EQ("Times New Roman-Identity-H", font_dict->GetStringFor("BaseFont"));
@@ -1105,7 +1105,7 @@ TEST_F(FPDFEditEmbeddertest, LoadCIDType2Font) {
EXPECT_TRUE(typed_font->IsCIDFont());
// Check font dictionary entries
- CPDF_Dictionary* font_dict = typed_font->GetFontDict();
+ const CPDF_Dictionary* font_dict = typed_font->GetFontDict();
EXPECT_EQ("Font", font_dict->GetStringFor("Type"));
EXPECT_EQ("Type0", font_dict->GetStringFor("Subtype"));
EXPECT_EQ("Arial Italic", font_dict->GetStringFor("BaseFont"));