summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_dictionary.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-10-10 14:06:44 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-10 14:06:44 -0700
commit381fc833ac9e6ea58762b7e7ac8b7f2129e8477f (patch)
tree3ea0596bee1c45fe49bbbad0559d6e505ccf0fee /core/fpdfapi/parser/cpdf_dictionary.cpp
parent5609f39c9d4534733f04a2be631da56948c2e96f (diff)
downloadpdfium-381fc833ac9e6ea58762b7e7ac8b7f2129e8477f.tar.xz
Add method to convert to an indirect object in a dictionary.
Avoid an assert which previously could only be overcome by removing/re-inserting. Back-fill a unit test for the equivalent Array method. BUG=654387 Review-Url: https://codereview.chromium.org/2403143002
Diffstat (limited to 'core/fpdfapi/parser/cpdf_dictionary.cpp')
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp
index 7ef5a53551..54aafd43b1 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.cpp
+++ b/core/fpdfapi/parser/cpdf_dictionary.cpp
@@ -192,6 +192,17 @@ void CPDF_Dictionary::SetFor(const CFX_ByteString& key, CPDF_Object* pObj) {
m_Map.erase(it);
}
+void CPDF_Dictionary::ConvertToIndirectObjectFor(
+ const CFX_ByteString& key,
+ CPDF_IndirectObjectHolder* pHolder) {
+ auto it = m_Map.find(key);
+ if (it == m_Map.end() || it->second->IsReference())
+ return;
+
+ uint32_t objnum = pHolder->AddIndirectObject(it->second);
+ it->second = new CPDF_Reference(pHolder, objnum);
+}
+
void CPDF_Dictionary::RemoveFor(const CFX_ByteString& key) {
auto it = m_Map.find(key);
if (it == m_Map.end())