diff options
author | Tobias Hoffmann <thobi@worker> | 2012-06-22 18:11:25 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2012-07-07 23:45:10 +0200 |
commit | 39bbaa86e3d7dcf77f42a36b78b727c142fcadee (patch) | |
tree | 13ee45290d8826f43d8701a712f0e05ebc4aec49 /libqpdf/QPDF_optimization.cc | |
parent | e2dedde4bdb5fa68c86d412e534a4b2750739988 (diff) | |
download | qpdf-39bbaa86e3d7dcf77f42a36b78b727c142fcadee.tar.zst |
Build this->all_pages while traversing with pushInheritedAttributesToPage
Diffstat (limited to 'libqpdf/QPDF_optimization.cc')
-rw-r--r-- | libqpdf/QPDF_optimization.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libqpdf/QPDF_optimization.cc b/libqpdf/QPDF_optimization.cc index 7f7049a4..e6ad2750 100644 --- a/libqpdf/QPDF_optimization.cc +++ b/libqpdf/QPDF_optimization.cc @@ -166,9 +166,8 @@ QPDF::optimize(std::map<int, int> const& object_stream_data, } // Traverse pages tree pushing all inherited resources down to the - // page level. + // page level. This also initializes this->all_pages. pushInheritedAttributesToPage(allow_changes, false); - getAllPages(); // Traverse pages int n = this->all_pages.size(); @@ -236,9 +235,10 @@ QPDF::pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys) // key_ancestors is a mapping of page attribute keys to a stack of // Pages nodes that contain values for them. std::map<std::string, std::vector<QPDFObjectHandle> > key_ancestors; + this->all_pages.clear(); pushInheritedAttributesToPageInternal( this->trailer.getKey("/Root").getKey("/Pages"), - key_ancestors, allow_changes, warn_skipped_keys); + key_ancestors, this->all_pages, allow_changes, warn_skipped_keys); assert(key_ancestors.empty()); } @@ -246,6 +246,7 @@ void QPDF::pushInheritedAttributesToPageInternal( QPDFObjectHandle cur_pages, std::map<std::string, std::vector<QPDFObjectHandle> >& key_ancestors, + std::vector<QPDFObjectHandle>& pages, bool allow_changes, bool warn_skipped_keys) { // Extract the underlying dictionary object @@ -336,7 +337,7 @@ QPDF::pushInheritedAttributesToPageInternal( for (int i = 0; i < n; ++i) { pushInheritedAttributesToPageInternal( - kids.getArrayItem(i), key_ancestors, + kids.getArrayItem(i), key_ancestors, pages, allow_changes, warn_skipped_keys); } @@ -385,6 +386,7 @@ QPDF::pushInheritedAttributesToPageInternal( QTC::TC("qpdf", "QPDF opt page resource hides ancestor"); } } + pages.push_back(cur_pages); } else { |