From b1eb1a958438025efbf90f7a7f45dbe33c746d91 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 14 Nov 2022 22:06:04 +0000 Subject: Refactor QPDFObjectHandle::copyObject1 --- libqpdf/QPDF_Dictionary.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libqpdf/QPDF_Dictionary.cc') diff --git a/libqpdf/QPDF_Dictionary.cc b/libqpdf/QPDF_Dictionary.cc index 5b1e03d8..1df4f8f0 100644 --- a/libqpdf/QPDF_Dictionary.cc +++ b/libqpdf/QPDF_Dictionary.cc @@ -18,7 +18,17 @@ QPDF_Dictionary::create(std::map const& items) std::shared_ptr QPDF_Dictionary::copy(bool shallow) { - return create(items); + if (shallow) { + return create(items); + } else { + std::map new_items; + for (auto const& item: this->items) { + auto value = item.second; + new_items[item.first] = + value.isIndirect() ? value : value.shallowCopy(); + } + return create(new_items); + } } void -- cgit v1.2.3-70-g09d2