summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-01-29 02:13:10 +0100
committerJay Berkenbilt <ejb@ql.org>2019-01-29 02:29:58 +0100
commit52f9d326a56e6409a1487c724241f91de33e3ba6 (patch)
treea45d1cc452d3d61a940b16cc6a6bb524b55f302b /include
parent9e01c8bd996a15934f58979f447bea359e857875 (diff)
downloadqpdf-52f9d326a56e6409a1487c724241f91de33e3ba6.tar.zst
Resolve duplicated page objects (fixes #268)
When linearizing a file or getting the list of all pages in a file, detect if the pages tree contains a duplicated page object and, if so, shallow copy it. This makes it possible to have a one to one mapping of page positions to page objects.
Diffstat (limited to 'include')
-rw-r--r--include/qpdf/QPDF.hh23
1 files changed, 14 insertions, 9 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh
index ef0f0eb7..cfb10aac 100644
--- a/include/qpdf/QPDF.hh
+++ b/include/qpdf/QPDF.hh
@@ -527,15 +527,16 @@ class QPDF
void optimize(std::map<int, int> const& object_stream_data,
bool allow_changes = true);
- // Traverse page tree return all /Page objects. For efficiency,
- // this method returns a const reference to an internal vector of
- // pages. Calls to addPage, addPageAt, and removePage safely
- // update this, but directly manipulation of the pages three or
- // pushing inheritable objects to the page level may invalidate
- // it. See comments for updateAllPagesCache() for additional
- // notes. Newer code should use
- // QPDFPageDocumentHelper::getAllPages instead. The decision to
- // expose this internal cache was arguably incorrect, but it is
+ // Traverse page tree return all /Page objects. It also detects
+ // and resolves cases in which the same /Page object is
+ // duplicated. For efficiency, this method returns a const
+ // reference to an internal vector of pages. Calls to addPage,
+ // addPageAt, and removePage safely update this, but directly
+ // manipulation of the pages three or pushing inheritable objects
+ // to the page level may invalidate it. See comments for
+ // updateAllPagesCache() for additional notes. Newer code should
+ // use QPDFPageDocumentHelper::getAllPages instead. The decision
+ // to expose this internal cache was arguably incorrect, but it is
// being left here for compatibility. It is, however, completely
// safe to use this for files that you are not modifying.
QPDF_DLL
@@ -895,6 +896,10 @@ class QPDF
void getAllPagesInternal2(QPDFObjectHandle cur_pages,
std::vector<QPDFObjectHandle>& result,
std::set<QPDFObjGen>& visited);
+ void getAllPagesInternal3(QPDFObjectHandle cur_pages,
+ std::vector<QPDFObjectHandle>& result,
+ std::set<QPDFObjGen>& visited,
+ std::set<QPDFObjGen>& seen);
void insertPage(QPDFObjectHandle newpage, int pos);
int findPage(QPDFObjGen const& og);
int findPage(QPDFObjectHandle& page);