diff options
Diffstat (limited to 'core/fpdfapi/parser/cpdf_dictionary.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_dictionary.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp index 5257a20586..ae7239efdf 100644 --- a/core/fpdfapi/parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/parser/cpdf_dictionary.cpp @@ -81,63 +81,74 @@ std::unique_ptr<CPDF_Object> CPDF_Dictionary::CloneNonCyclic( return std::move(pCopy); } -CPDF_Object* CPDF_Dictionary::GetObjectFor(const ByteString& key) const { +const CPDF_Object* CPDF_Dictionary::GetObjectFor(const ByteString& key) const { auto it = m_Map.find(key); return it != m_Map.end() ? it->second.get() : nullptr; } -CPDF_Object* CPDF_Dictionary::GetDirectObjectFor(const ByteString& key) const { +CPDF_Object* CPDF_Dictionary::GetObjectFor(const ByteString& key) { + auto it = m_Map.find(key); + return it != m_Map.end() ? it->second.get() : nullptr; +} + +const CPDF_Object* CPDF_Dictionary::GetDirectObjectFor( + const ByteString& key) const { + const CPDF_Object* p = GetObjectFor(key); + return p ? p->GetDirect() : nullptr; +} + +CPDF_Object* CPDF_Dictionary::GetDirectObjectFor(const ByteString& key) { CPDF_Object* p = GetObjectFor(key); return p ? p->GetDirect() : nullptr; } ByteString CPDF_Dictionary::GetStringFor(const ByteString& key) const { - CPDF_Object* p = GetObjectFor(key); + const CPDF_Object* p = GetObjectFor(key); return p ? p->GetString() : ByteString(); } WideString CPDF_Dictionary::GetUnicodeTextFor(const ByteString& key) const { - CPDF_Object* p = GetObjectFor(key); - if (CPDF_Reference* pRef = ToReference(p)) + const CPDF_Object* p = GetObjectFor(key); + if (const CPDF_Reference* pRef = ToReference(p)) p = pRef->GetDirect(); return p ? p->GetUnicodeText() : WideString(); } ByteString CPDF_Dictionary::GetStringFor(const ByteString& key, const ByteString& def) const { - CPDF_Object* p = GetObjectFor(key); + const CPDF_Object* p = GetObjectFor(key); return p ? p->GetString() : ByteString(def); } int CPDF_Dictionary::GetIntegerFor(const ByteString& key) const { - CPDF_Object* p = GetObjectFor(key); + const CPDF_Object* p = GetObjectFor(key); return p ? p->GetInteger() : 0; } int CPDF_Dictionary::GetIntegerFor(const ByteString& key, int def) const { - CPDF_Object* p = GetObjectFor(key); + const CPDF_Object* p = GetObjectFor(key); return p ? p->GetInteger() : def; } float CPDF_Dictionary::GetNumberFor(const ByteString& key) const { - CPDF_Object* p = GetObjectFor(key); + const CPDF_Object* p = GetObjectFor(key); return p ? p->GetNumber() : 0; } bool CPDF_Dictionary::GetBooleanFor(const ByteString& key, bool bDefault) const { - CPDF_Object* p = GetObjectFor(key); + const CPDF_Object* p = GetObjectFor(key); return ToBoolean(p) ? p->GetInteger() != 0 : bDefault; } const CPDF_Dictionary* CPDF_Dictionary::GetDictFor( const ByteString& key) const { - CPDF_Object* p = GetDirectObjectFor(key); + const CPDF_Object* p = GetDirectObjectFor(key); if (!p) return nullptr; - if (CPDF_Dictionary* pDict = p->AsDictionary()) + if (const CPDF_Dictionary* pDict = p->AsDictionary()) return pDict; - if (CPDF_Stream* pStream = p->AsStream()) + if (const CPDF_Stream* pStream = p->AsStream()) return pStream->GetDict(); return nullptr; } |