diff options
Diffstat (limited to 'core/fpdfapi/parser/cpdf_reference.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_reference.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/core/fpdfapi/parser/cpdf_reference.cpp b/core/fpdfapi/parser/cpdf_reference.cpp index 2ca0bddc4f..3f45a96c6b 100644 --- a/core/fpdfapi/parser/cpdf_reference.cpp +++ b/core/fpdfapi/parser/cpdf_reference.cpp @@ -21,25 +21,30 @@ CPDF_Object::Type CPDF_Reference::GetType() const { } ByteString CPDF_Reference::GetString() const { - CPDF_Object* obj = SafeGetDirect(); + const CPDF_Object* obj = SafeGetDirect(); return obj ? obj->GetString() : ByteString(); } float CPDF_Reference::GetNumber() const { - CPDF_Object* obj = SafeGetDirect(); + const CPDF_Object* obj = SafeGetDirect(); return obj ? obj->GetNumber() : 0; } int CPDF_Reference::GetInteger() const { - CPDF_Object* obj = SafeGetDirect(); + const CPDF_Object* obj = SafeGetDirect(); return obj ? obj->GetInteger() : 0; } -CPDF_Dictionary* CPDF_Reference::GetDict() const { +CPDF_Dictionary* CPDF_Reference::GetDict() { CPDF_Object* obj = SafeGetDirect(); return obj ? obj->GetDict() : nullptr; } +const CPDF_Dictionary* CPDF_Reference::GetDict() const { + const CPDF_Object* obj = SafeGetDirect(); + return obj ? obj->GetDict() : nullptr; +} + bool CPDF_Reference::IsReference() const { return true; } @@ -69,17 +74,27 @@ std::unique_ptr<CPDF_Object> CPDF_Reference::CloneNonCyclic( return pdfium::MakeUnique<CPDF_Reference>(m_pObjList.Get(), m_RefObjNum); } -CPDF_Object* CPDF_Reference::SafeGetDirect() const { +CPDF_Object* CPDF_Reference::SafeGetDirect() { CPDF_Object* obj = GetDirect(); return (obj && !obj->IsReference()) ? obj : nullptr; } +const CPDF_Object* CPDF_Reference::SafeGetDirect() const { + const CPDF_Object* obj = GetDirect(); + return (obj && !obj->IsReference()) ? obj : nullptr; +} + void CPDF_Reference::SetRef(CPDF_IndirectObjectHolder* pDoc, uint32_t objnum) { m_pObjList = pDoc; m_RefObjNum = objnum; } -CPDF_Object* CPDF_Reference::GetDirect() const { +CPDF_Object* CPDF_Reference::GetDirect() { + return m_pObjList ? m_pObjList->GetOrParseIndirectObject(m_RefObjNum) + : nullptr; +} + +const CPDF_Object* CPDF_Reference::GetDirect() const { return m_pObjList ? m_pObjList->GetOrParseIndirectObject(m_RefObjNum) : nullptr; } |