diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFObjectHandle.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index 53d9414c..4e28c405 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -663,6 +663,38 @@ QPDFObjectHandle::newStream(QPDF* qpdf, PointerHolder<Buffer> data) return result; } +QPDFObjectHandle +QPDFObjectHandle::shallowCopy() +{ + assertInitialized(); + + if (isStream()) + { + QTC::TC("qpdf", "QPDFObjectHandle ERR shallow copy stream"); + throw std::runtime_error( + "attempt to make a shallow copy of a stream"); + } + + QPDFObjectHandle new_obj; + if (isArray()) + { + QTC::TC("qpdf", "QPDFObjectHandle shallow copy array"); + new_obj = newArray(getArrayAsVector()); + } + else if (isDictionary()) + { + QTC::TC("qpdf", "QPDFObjectHandle shallow copy dictionary"); + new_obj = newDictionary(getDictAsMap()); + } + else + { + QTC::TC("qpdf", "QPDFObjectHandle shallow copy scalar"); + new_obj = *this; + } + + return new_obj; +} + void QPDFObjectHandle::makeDirectInternal(std::set<int>& visited) { |