From 39bbaa86e3d7dcf77f42a36b78b727c142fcadee Mon Sep 17 00:00:00 2001 From: Tobias Hoffmann Date: Fri, 22 Jun 2012 18:11:25 +0200 Subject: Build this->all_pages while traversing with pushInheritedAttributesToPage --- libqpdf/QPDF_optimization.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'libqpdf/QPDF_optimization.cc') 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 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 > 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 >& key_ancestors, + std::vector& 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 { -- cgit v1.2.3-70-g09d2