Commit 06d6438ddf7f817d9cc1698c9b4b5e4b8f53e151
1 parent
3e74916c
Minor fixes
Showing
2 changed files
with
11 additions
and
4 deletions
ChangeLog
| 1 | +2019-01-02 Jay Berkenbilt <ejb@ql.org> | ||
| 2 | + | ||
| 3 | + * Add method QPDFObjectHandle::getResourceNames that returns a set | ||
| 4 | + of strings representing all second-level keys in a dictionary | ||
| 5 | + (i.e. all keys of all direct dictionary members). | ||
| 6 | + | ||
| 1 | 2018-12-31 Jay Berkenbilt <ejb@ql.org> | 7 | 2018-12-31 Jay Berkenbilt <ejb@ql.org> |
| 2 | 8 | ||
| 3 | * Add methods for flattening form fields and annotations: | 9 | * Add methods for flattening form fields and annotations: |
libqpdf/QPDFPageDocumentHelper.cc
| @@ -164,7 +164,8 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage( | @@ -164,7 +164,8 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage( | ||
| 164 | } | 164 | } |
| 165 | std::set<std::string> names = resources.getResourceNames(); | 165 | std::set<std::string> names = resources.getResourceNames(); |
| 166 | std::string name; | 166 | std::string name; |
| 167 | - while (next_fx < 1000000) | 167 | + int max_fx = next_fx + names.size() + 1; |
| 168 | + while (next_fx <= max_fx) | ||
| 168 | { | 169 | { |
| 169 | std::string candidate = "/Fxo" + QUtil::int_to_string(next_fx); | 170 | std::string candidate = "/Fxo" + QUtil::int_to_string(next_fx); |
| 170 | ++next_fx; | 171 | ++next_fx; |
| @@ -176,9 +177,9 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage( | @@ -176,9 +177,9 @@ QPDFPageDocumentHelper::flattenAnnotationsForPage( | ||
| 176 | } | 177 | } |
| 177 | if (name.empty()) | 178 | if (name.empty()) |
| 178 | { | 179 | { |
| 179 | - // There are already more than a million /Fxo names. | ||
| 180 | - // Somehow I doubt this is going to actually happen. | ||
| 181 | - // Just pick a name and forget conflicts. | 180 | + // This could only happen if there is a coding error. |
| 181 | + // The number of candidates we test is more than the | ||
| 182 | + // number of keys we're checking against. | ||
| 182 | name = "/FxConflict"; | 183 | name = "/FxConflict"; |
| 183 | } | 184 | } |
| 184 | resources.mergeResources( | 185 | resources.mergeResources( |