diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index 5e0b96d0..cfb790d1 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -759,7 +759,6 @@ class QPDF void parse(char const* password); void inParse(bool); - bool resolveXRefTable(); void setLastObjectDescription(std::string const& description, QPDFObjGen const& og); QPDFObjectHandle readTrailer(); QPDFObjectHandle readObject(std::string const& description, QPDFObjGen og); diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc index fd23753b..00ab1ce0 100644 --- a/libqpdf/QPDF.cc +++ b/libqpdf/QPDF.cc @@ -1385,13 +1385,13 @@ QPDF::Xref_table::show() // Resolve all objects in the xref table. If this triggers a xref table reconstruction abort and // return false. Otherwise return true. bool -QPDF::resolveXRefTable() +QPDF::Xref_table::resolve() { - bool may_change = !m->xref_table.reconstructed; - for (auto& iter: m->xref_table) { - if (isUnresolved(iter.first)) { - resolve(iter.first); - if (may_change && m->xref_table.reconstructed) { + bool may_change = !reconstructed; + for (auto& iter: *this) { + if (qpdf.isUnresolved(iter.first)) { + qpdf.resolve(iter.first); + if (may_change && reconstructed) { return false; } } @@ -1407,9 +1407,9 @@ QPDF::fixDanglingReferences(bool force) if (m->fixed_dangling_refs) { return; } - if (!resolveXRefTable()) { + if (!m->xref_table.resolve()) { QTC::TC("qpdf", "QPDF fix dangling triggered xref reconstruction"); - resolveXRefTable(); + m->xref_table.resolve(); } m->fixed_dangling_refs = true; } diff --git a/libqpdf/qpdf/QPDF_private.hh b/libqpdf/qpdf/QPDF_private.hh index c1659340..9beaa29d 100644 --- a/libqpdf/qpdf/QPDF_private.hh +++ b/libqpdf/qpdf/QPDF_private.hh @@ -17,6 +17,7 @@ class QPDF::Xref_table: public std::map void initialize(); void reconstruct(QPDFExc& e); void show(); + bool resolve(); QPDFObjectHandle trailer; bool reconstructed{false};