diff options
Diffstat (limited to 'libqpdf/QPDF_Dictionary.cc')
-rw-r--r-- | libqpdf/QPDF_Dictionary.cc | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index 1655f53a..0423f41f 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -115,11 +115,16 @@ QPDF_Dictionary::getAsMap() const } void -QPDF_Dictionary::replaceKey( - std::string const& key, QPDFObjectHandle const& value) +QPDF_Dictionary::replaceKey(std::string const& key, QPDFObjectHandle value) { - // add or replace value - this->items[key] = value; + if (value.isNull()) { + // The PDF spec doesn't distinguish between keys with null + // values and missing keys. + removeKey(key); + } else { + // add or replace value + this->items[key] = value; + } } void @@ -128,14 +133,3 @@ QPDF_Dictionary::removeKey(std::string const& key) // no-op if key does not exist this->items.erase(key); } - -void -QPDF_Dictionary::replaceOrRemoveKey( - std::string const& key, QPDFObjectHandle value) -{ - if (value.isNull()) { - removeKey(key); - } else { - replaceKey(key, value); - } -} |