mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Remove redundant parameter first_level_only from QPDFObjectHandle::shallowCopyInternal2 and copyObject2
This commit is contained in:
parent
0827b1096e
commit
15e8d3a763
@ -1634,8 +1634,8 @@ class QPDFObjectHandle
|
||||
bool first_level_only,
|
||||
bool stop_at_streams);
|
||||
void shallowCopyInternal1(QPDFObjectHandle& oh, bool first_level_only);
|
||||
void copyObject2(std::set<QPDFObjGen>& visited, bool first_level_only);
|
||||
void shallowCopyInternal2(QPDFObjectHandle& oh, bool first_level_only);
|
||||
void copyObject2(std::set<QPDFObjGen>& visited);
|
||||
void shallowCopyInternal2(QPDFObjectHandle& oh);
|
||||
void copyObject(
|
||||
std::set<QPDFObjGen>& visited,
|
||||
bool cross_indirect,
|
||||
|
@ -2299,13 +2299,12 @@ QPDFObjectHandle
|
||||
QPDFObjectHandle::unsafeShallowCopy()
|
||||
{
|
||||
QPDFObjectHandle result;
|
||||
shallowCopyInternal2(result, true);
|
||||
shallowCopyInternal2(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
QPDFObjectHandle::shallowCopyInternal2(
|
||||
QPDFObjectHandle& new_obj, bool first_level_only)
|
||||
QPDFObjectHandle::shallowCopyInternal2(QPDFObjectHandle& new_obj)
|
||||
{
|
||||
assertInitialized();
|
||||
|
||||
@ -2315,16 +2314,16 @@ QPDFObjectHandle::shallowCopyInternal2(
|
||||
new_obj = QPDFObjectHandle(obj->copy(true));
|
||||
|
||||
std::set<QPDFObjGen> visited;
|
||||
new_obj.copyObject2(visited, first_level_only);
|
||||
new_obj.copyObject2(visited);
|
||||
}
|
||||
|
||||
void
|
||||
QPDFObjectHandle::copyObject2(
|
||||
std::set<QPDFObjGen>& visited, bool first_level_only)
|
||||
QPDFObjectHandle::copyObject2(std::set<QPDFObjGen>& visited)
|
||||
{
|
||||
assertInitialized();
|
||||
|
||||
if (isStream()) {
|
||||
// same as obj->copy(true)
|
||||
throw std::runtime_error(
|
||||
"attempt to make a stream into a direct object");
|
||||
}
|
||||
@ -2340,6 +2339,7 @@ QPDFObjectHandle::copyObject2(
|
||||
}
|
||||
|
||||
if (isReserved()) {
|
||||
// same as obj->copy(true)
|
||||
throw std::logic_error("QPDFObjectHandle: attempting to make a"
|
||||
" reserved object handle direct");
|
||||
}
|
||||
@ -2350,26 +2350,20 @@ QPDFObjectHandle::copyObject2(
|
||||
isString()) {
|
||||
new_obj = obj->copy(true);
|
||||
} else if (isArray()) {
|
||||
// same as obj->copy(true)
|
||||
std::vector<QPDFObjectHandle> items;
|
||||
auto array = asArray();
|
||||
int n = array->getNItems();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
items.push_back(array->getItem(i));
|
||||
if ((!first_level_only) && !items.back().isIndirect())
|
||||
{
|
||||
items.back().copyObject2(visited, first_level_only);
|
||||
}
|
||||
}
|
||||
new_obj = QPDF_Array::create(items);
|
||||
} else if (isDictionary()) {
|
||||
// same as obj->copy(true)
|
||||
std::map<std::string, QPDFObjectHandle> items;
|
||||
auto dict = asDictionary();
|
||||
for (auto const& key: getKeys()) {
|
||||
items[key] = dict->getKey(key);
|
||||
if ((!first_level_only) && !items[key].isIndirect())
|
||||
{
|
||||
items[key].copyObject2(visited, first_level_only);
|
||||
}
|
||||
}
|
||||
new_obj = QPDF_Dictionary::create(items);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user