Commit b776dcd2d3180becef8f58158873a91004e324ee
1 parent
8d229e07
Clean up some private functions
Showing
4 changed files
with
15 additions
and
53 deletions
TODO
| @@ -16,9 +16,6 @@ Do these things next time we have to break binary compatibility | @@ -16,9 +16,6 @@ Do these things next time we have to break binary compatibility | ||
| 16 | * Rename QUtil::strcasecmp since strcasecmp is a macro on some | 16 | * Rename QUtil::strcasecmp since strcasecmp is a macro on some |
| 17 | platforms. See #242. | 17 | platforms. See #242. |
| 18 | 18 | ||
| 19 | - * Collapse QPDF::pushInheritedAttributesToPageInternal* and | ||
| 20 | - QPDF::getAllPagesInternal* into QPDF::*Internal. | ||
| 21 | - | ||
| 22 | * Get rid of the version of QPDF::copyForeignObject with the bool | 19 | * Get rid of the version of QPDF::copyForeignObject with the bool |
| 23 | unused parameter. | 20 | unused parameter. |
| 24 | 21 |
include/qpdf/QPDF.hh
| @@ -898,14 +898,9 @@ class QPDF | @@ -898,14 +898,9 @@ class QPDF | ||
| 898 | // methods to support page handling | 898 | // methods to support page handling |
| 899 | 899 | ||
| 900 | void getAllPagesInternal(QPDFObjectHandle cur_pages, | 900 | void getAllPagesInternal(QPDFObjectHandle cur_pages, |
| 901 | - std::vector<QPDFObjectHandle>& result); | ||
| 902 | - void getAllPagesInternal2(QPDFObjectHandle cur_pages, | ||
| 903 | - std::vector<QPDFObjectHandle>& result, | ||
| 904 | - std::set<QPDFObjGen>& visited); | ||
| 905 | - void getAllPagesInternal3(QPDFObjectHandle cur_pages, | ||
| 906 | - std::vector<QPDFObjectHandle>& result, | ||
| 907 | - std::set<QPDFObjGen>& visited, | ||
| 908 | - std::set<QPDFObjGen>& seen); | 901 | + std::vector<QPDFObjectHandle>& result, |
| 902 | + std::set<QPDFObjGen>& visited, | ||
| 903 | + std::set<QPDFObjGen>& seen); | ||
| 909 | void insertPage(QPDFObjectHandle newpage, int pos); | 904 | void insertPage(QPDFObjectHandle newpage, int pos); |
| 910 | int findPage(QPDFObjGen const& og); | 905 | int findPage(QPDFObjGen const& og); |
| 911 | int findPage(QPDFObjectHandle& page); | 906 | int findPage(QPDFObjectHandle& page); |
| @@ -1293,11 +1288,6 @@ class QPDF | @@ -1293,11 +1288,6 @@ class QPDF | ||
| 1293 | QPDFObjectHandle, | 1288 | QPDFObjectHandle, |
| 1294 | std::map<std::string, std::vector<QPDFObjectHandle> >&, | 1289 | std::map<std::string, std::vector<QPDFObjectHandle> >&, |
| 1295 | std::vector<QPDFObjectHandle>& all_pages, | 1290 | std::vector<QPDFObjectHandle>& all_pages, |
| 1296 | - bool allow_changes, bool warn_skipped_keys); | ||
| 1297 | - void pushInheritedAttributesToPageInternal2( | ||
| 1298 | - QPDFObjectHandle, | ||
| 1299 | - std::map<std::string, std::vector<QPDFObjectHandle> >&, | ||
| 1300 | - std::vector<QPDFObjectHandle>& all_pages, | ||
| 1301 | bool allow_changes, bool warn_skipped_keys, | 1291 | bool allow_changes, bool warn_skipped_keys, |
| 1302 | std::set<QPDFObjGen>& visited); | 1292 | std::set<QPDFObjGen>& visited); |
| 1303 | void updateObjectMaps(ObjUser const& ou, QPDFObjectHandle oh); | 1293 | void updateObjectMaps(ObjUser const& ou, QPDFObjectHandle oh); |
libqpdf/QPDF_optimization.cc
| @@ -163,9 +163,11 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys) | @@ -163,9 +163,11 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys) | ||
| 163 | // Pages nodes that contain values for them. | 163 | // Pages nodes that contain values for them. |
| 164 | std::map<std::string, std::vector<QPDFObjectHandle> > key_ancestors; | 164 | std::map<std::string, std::vector<QPDFObjectHandle> > key_ancestors; |
| 165 | this->m->all_pages.clear(); | 165 | this->m->all_pages.clear(); |
| 166 | + std::set<QPDFObjGen> visited; | ||
| 166 | pushInheritedAttributesToPageInternal( | 167 | pushInheritedAttributesToPageInternal( |
| 167 | this->m->trailer.getKey("/Root").getKey("/Pages"), | 168 | this->m->trailer.getKey("/Root").getKey("/Pages"), |
| 168 | - key_ancestors, this->m->all_pages, allow_changes, warn_skipped_keys); | 169 | + key_ancestors, this->m->all_pages, allow_changes, warn_skipped_keys, |
| 170 | + visited); | ||
| 169 | if (! key_ancestors.empty()) | 171 | if (! key_ancestors.empty()) |
| 170 | { | 172 | { |
| 171 | throw std::logic_error( | 173 | throw std::logic_error( |
| @@ -180,19 +182,6 @@ QPDF::pushInheritedAttributesToPageInternal( | @@ -180,19 +182,6 @@ QPDF::pushInheritedAttributesToPageInternal( | ||
| 180 | QPDFObjectHandle cur_pages, | 182 | QPDFObjectHandle cur_pages, |
| 181 | std::map<std::string, std::vector<QPDFObjectHandle> >& key_ancestors, | 183 | std::map<std::string, std::vector<QPDFObjectHandle> >& key_ancestors, |
| 182 | std::vector<QPDFObjectHandle>& pages, | 184 | std::vector<QPDFObjectHandle>& pages, |
| 183 | - bool allow_changes, bool warn_skipped_keys) | ||
| 184 | -{ | ||
| 185 | - std::set<QPDFObjGen> visited; | ||
| 186 | - pushInheritedAttributesToPageInternal2( | ||
| 187 | - cur_pages, key_ancestors, pages, allow_changes, | ||
| 188 | - warn_skipped_keys, visited); | ||
| 189 | -} | ||
| 190 | - | ||
| 191 | -void | ||
| 192 | -QPDF::pushInheritedAttributesToPageInternal2( | ||
| 193 | - QPDFObjectHandle cur_pages, | ||
| 194 | - std::map<std::string, std::vector<QPDFObjectHandle> >& key_ancestors, | ||
| 195 | - std::vector<QPDFObjectHandle>& pages, | ||
| 196 | bool allow_changes, bool warn_skipped_keys, | 185 | bool allow_changes, bool warn_skipped_keys, |
| 197 | std::set<QPDFObjGen>& visited) | 186 | std::set<QPDFObjGen>& visited) |
| 198 | { | 187 | { |
| @@ -291,7 +280,7 @@ QPDF::pushInheritedAttributesToPageInternal2( | @@ -291,7 +280,7 @@ QPDF::pushInheritedAttributesToPageInternal2( | ||
| 291 | int n = kids.getArrayNItems(); | 280 | int n = kids.getArrayNItems(); |
| 292 | for (int i = 0; i < n; ++i) | 281 | for (int i = 0; i < n; ++i) |
| 293 | { | 282 | { |
| 294 | - pushInheritedAttributesToPageInternal2( | 283 | + pushInheritedAttributesToPageInternal( |
| 295 | kids.getArrayItem(i), key_ancestors, pages, | 284 | kids.getArrayItem(i), key_ancestors, pages, |
| 296 | allow_changes, warn_skipped_keys, visited); | 285 | allow_changes, warn_skipped_keys, visited); |
| 297 | } | 286 | } |
libqpdf/QPDF_pages.cc
| @@ -47,33 +47,19 @@ QPDF::getAllPages() | @@ -47,33 +47,19 @@ QPDF::getAllPages() | ||
| 47 | // initialize this->m->all_pages. | 47 | // initialize this->m->all_pages. |
| 48 | if (this->m->all_pages.empty()) | 48 | if (this->m->all_pages.empty()) |
| 49 | { | 49 | { |
| 50 | - getAllPagesInternal(getRoot().getKey("/Pages"), this->m->all_pages); | 50 | + std::set<QPDFObjGen> visited; |
| 51 | + std::set<QPDFObjGen> seen; | ||
| 52 | + getAllPagesInternal(getRoot().getKey("/Pages"), this->m->all_pages, | ||
| 53 | + visited, seen); | ||
| 51 | } | 54 | } |
| 52 | return this->m->all_pages; | 55 | return this->m->all_pages; |
| 53 | } | 56 | } |
| 54 | 57 | ||
| 55 | void | 58 | void |
| 56 | QPDF::getAllPagesInternal(QPDFObjectHandle cur_pages, | 59 | QPDF::getAllPagesInternal(QPDFObjectHandle cur_pages, |
| 57 | - std::vector<QPDFObjectHandle>& result) | ||
| 58 | -{ | ||
| 59 | - std::set<QPDFObjGen> visited; | ||
| 60 | - getAllPagesInternal2(cur_pages, result, visited); | ||
| 61 | -} | ||
| 62 | - | ||
| 63 | -void | ||
| 64 | -QPDF::getAllPagesInternal2(QPDFObjectHandle cur_pages, | ||
| 65 | - std::vector<QPDFObjectHandle>& result, | ||
| 66 | - std::set<QPDFObjGen>& visited) | ||
| 67 | -{ | ||
| 68 | - std::set<QPDFObjGen> seen; | ||
| 69 | - getAllPagesInternal3(cur_pages, result, visited, seen); | ||
| 70 | -} | ||
| 71 | - | ||
| 72 | -void | ||
| 73 | -QPDF::getAllPagesInternal3(QPDFObjectHandle cur_pages, | ||
| 74 | - std::vector<QPDFObjectHandle>& result, | ||
| 75 | - std::set<QPDFObjGen>& visited, | ||
| 76 | - std::set<QPDFObjGen>& seen) | 60 | + std::vector<QPDFObjectHandle>& result, |
| 61 | + std::set<QPDFObjGen>& visited, | ||
| 62 | + std::set<QPDFObjGen>& seen) | ||
| 77 | { | 63 | { |
| 78 | QPDFObjGen this_og = cur_pages.getObjGen(); | 64 | QPDFObjGen this_og = cur_pages.getObjGen(); |
| 79 | if (visited.count(this_og) > 0) | 65 | if (visited.count(this_og) > 0) |
| @@ -119,7 +105,7 @@ QPDF::getAllPagesInternal3(QPDFObjectHandle cur_pages, | @@ -119,7 +105,7 @@ QPDF::getAllPagesInternal3(QPDFObjectHandle cur_pages, | ||
| 119 | kid = makeIndirectObject(QPDFObjectHandle(kid).shallowCopy()); | 105 | kid = makeIndirectObject(QPDFObjectHandle(kid).shallowCopy()); |
| 120 | kids.setArrayItem(i, kid); | 106 | kids.setArrayItem(i, kid); |
| 121 | } | 107 | } |
| 122 | - getAllPagesInternal3(kid, result, visited, seen); | 108 | + getAllPagesInternal(kid, result, visited, seen); |
| 123 | } | 109 | } |
| 124 | } | 110 | } |
| 125 | else if (type == "/Page") | 111 | else if (type == "/Page") |