mirror of
https://github.com/qpdf/qpdf.git
synced 2025-03-31 22:01:32 +00:00
Use QPDFObjGen::set in QPDFAcroFormDocumentHelper::transformAnnotations
This commit is contained in:
parent
c12a6d06fc
commit
e37ce44186
@ -882,7 +882,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
|
||||
|
||||
// Now do the actual copies.
|
||||
|
||||
std::set<QPDFObjGen> added_new_fields;
|
||||
QPDFObjGen::set added_new_fields;
|
||||
for (auto annot: old_annots.aitems()) {
|
||||
if (annot.isStream()) {
|
||||
annot.warnIfPossible("ignoring annotation that's a stream");
|
||||
@ -964,19 +964,13 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
|
||||
// Traverse the field, copying kids, and preserving
|
||||
// integrity.
|
||||
std::list<QPDFObjectHandle> queue;
|
||||
QPDFObjGen::set seen;
|
||||
if (maybe_copy_object(top_field)) {
|
||||
queue.push_back(top_field);
|
||||
}
|
||||
std::set<QPDFObjGen> seen;
|
||||
while (!queue.empty()) {
|
||||
QPDFObjectHandle obj = queue.front();
|
||||
queue.pop_front();
|
||||
auto orig_og = obj.getObjGen();
|
||||
if (seen.count(orig_og)) {
|
||||
// loop
|
||||
break;
|
||||
}
|
||||
seen.insert(orig_og);
|
||||
for (; !queue.empty(); queue.pop_front()) {
|
||||
auto& obj = queue.front();
|
||||
if (seen.add(obj)) {
|
||||
auto parent = obj.getKey("/Parent");
|
||||
if (parent.isIndirect()) {
|
||||
auto parent_og = parent.getObjGen();
|
||||
@ -985,8 +979,8 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
|
||||
} else {
|
||||
parent.warnIfPossible(
|
||||
"while traversing field " +
|
||||
obj.getObjGen().unparse(',') + ", found parent (" +
|
||||
parent_og.unparse(',') +
|
||||
obj.getObjGen().unparse(',') +
|
||||
", found parent (" + parent_og.unparse(',') +
|
||||
") that had not been seen, indicating likely"
|
||||
" invalid field structure");
|
||||
}
|
||||
@ -1033,6 +1027,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
|
||||
adjustDefaultAppearances(obj, dr_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now switch to copies. We already switched for top_field
|
||||
maybe_copy_object(ffield_oh);
|
||||
@ -1058,9 +1053,8 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
|
||||
maybe_copy_object(annot);
|
||||
|
||||
// Now we have copies, so we can safely mutate.
|
||||
if (have_field && !added_new_fields.count(top_field.getObjGen())) {
|
||||
if (have_field && added_new_fields.add(top_field)) {
|
||||
new_fields.push_back(top_field);
|
||||
added_new_fields.insert(top_field.getObjGen());
|
||||
}
|
||||
new_annots.push_back(annot);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user