diff options
Diffstat (limited to 'libqpdf/QPDFPageDocumentHelper.cc')
-rw-r--r-- | libqpdf/QPDFPageDocumentHelper.cc | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/libqpdf/QPDFPageDocumentHelper.cc b/libqpdf/QPDFPageDocumentHelper.cc index 3eec789b..58d6ed22 100644 --- a/libqpdf/QPDFPageDocumentHelper.cc +++ b/libqpdf/QPDFPageDocumentHelper.cc @@ -155,35 +155,15 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage( { QTC::TC("qpdf", "QPDFPageDocumentHelper non-widget annotation"); } - std::set<std::string> names = resources.getResourceNames(); - std::string name; - int max_fx = next_fx + names.size() + 1; - while (next_fx <= max_fx) - { - std::string candidate = "/Fxo" + QUtil::int_to_string(next_fx); - if (names.count(candidate) == 0) - { - name = candidate; - break; - } - ++next_fx; - } - if (name.empty()) - { - // This could only happen if there is a coding error. - // The number of candidates we test is more than the - // number of keys we're checking against. - name = "/FxConflict"; - } + std::string name = resources.getUniqueResourceName( + "/Fxo", next_fx); std::string content = aoh.getPageContentForAppearance( name, rotate, required_flags, forbidden_flags); if (! content.empty()) { resources.mergeResources( - QPDFObjectHandle::parse( - "<< /XObject << " + name + " null >> >>")); + QPDFObjectHandle::parse("<< /XObject << >> >>")); resources.getKey("/XObject").replaceKey(name, as); - names.insert(name); ++next_fx; } new_content += content; |