diff options
author | Lei Zhang <thestig@chromium.org> | 2018-05-25 21:55:24 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-25 21:55:24 +0000 |
commit | b1ec280837cc6e1932754ef40de26d12b77aa910 (patch) | |
tree | b1af6fdc4174eaf671cbd23f8f59b9bbf2428fb7 /core/fpdfapi/parser/cpdf_dictionary.cpp | |
parent | de579ab0092d43fe037c381710da998b9ff823e9 (diff) | |
download | pdfium-b1ec280837cc6e1932754ef40de26d12b77aa910.tar.xz |
Add proper const/non-const versions of CPDF_Dictionary::GetDictFor().
BUG=pdfium:234
Change-Id: I6fde00c976ad4bb9cab632f465cf292f5b1da3d2
Reviewed-on: https://pdfium-review.googlesource.com/32914
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_dictionary.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_dictionary.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp index 1ede5e707a..5257a20586 100644 --- a/core/fpdfapi/parser/cpdf_dictionary.cpp +++ b/core/fpdfapi/parser/cpdf_dictionary.cpp @@ -130,7 +130,19 @@ bool CPDF_Dictionary::GetBooleanFor(const ByteString& key, return ToBoolean(p) ? p->GetInteger() != 0 : bDefault; } -CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const ByteString& key) const { +const CPDF_Dictionary* CPDF_Dictionary::GetDictFor( + const ByteString& key) const { + CPDF_Object* p = GetDirectObjectFor(key); + if (!p) + return nullptr; + if (CPDF_Dictionary* pDict = p->AsDictionary()) + return pDict; + if (CPDF_Stream* pStream = p->AsStream()) + return pStream->GetDict(); + return nullptr; +} + +CPDF_Dictionary* CPDF_Dictionary::GetDictFor(const ByteString& key) { CPDF_Object* p = GetDirectObjectFor(key); if (!p) return nullptr; |