Commit 3ddc51a9dcdf924f2c74963dbd74698689a64f46

Authored by m-holger
1 parent ad468886

Move QPDF::resolveXRefTable to QPDF::Xref_table

include/qpdf/QPDF.hh
... ... @@ -759,7 +759,6 @@ class QPDF
759 759  
760 760 void parse(char const* password);
761 761 void inParse(bool);
762   - bool resolveXRefTable();
763 762 void setLastObjectDescription(std::string const& description, QPDFObjGen const& og);
764 763 QPDFObjectHandle readTrailer();
765 764 QPDFObjectHandle readObject(std::string const& description, QPDFObjGen og);
... ...
libqpdf/QPDF.cc
... ... @@ -1385,13 +1385,13 @@ QPDF::Xref_table::show()
1385 1385 // Resolve all objects in the xref table. If this triggers a xref table reconstruction abort and
1386 1386 // return false. Otherwise return true.
1387 1387 bool
1388   -QPDF::resolveXRefTable()
  1388 +QPDF::Xref_table::resolve()
1389 1389 {
1390   - bool may_change = !m->xref_table.reconstructed;
1391   - for (auto& iter: m->xref_table) {
1392   - if (isUnresolved(iter.first)) {
1393   - resolve(iter.first);
1394   - if (may_change && m->xref_table.reconstructed) {
  1390 + bool may_change = !reconstructed;
  1391 + for (auto& iter: *this) {
  1392 + if (qpdf.isUnresolved(iter.first)) {
  1393 + qpdf.resolve(iter.first);
  1394 + if (may_change && reconstructed) {
1395 1395 return false;
1396 1396 }
1397 1397 }
... ... @@ -1407,9 +1407,9 @@ QPDF::fixDanglingReferences(bool force)
1407 1407 if (m->fixed_dangling_refs) {
1408 1408 return;
1409 1409 }
1410   - if (!resolveXRefTable()) {
  1410 + if (!m->xref_table.resolve()) {
1411 1411 QTC::TC("qpdf", "QPDF fix dangling triggered xref reconstruction");
1412   - resolveXRefTable();
  1412 + m->xref_table.resolve();
1413 1413 }
1414 1414 m->fixed_dangling_refs = true;
1415 1415 }
... ...
libqpdf/qpdf/QPDF_private.hh
... ... @@ -17,6 +17,7 @@ class QPDF::Xref_table: public std::map<QPDFObjGen, QPDFXRefEntry>
17 17 void initialize();
18 18 void reconstruct(QPDFExc& e);
19 19 void show();
  20 + bool resolve();
20 21  
21 22 QPDFObjectHandle trailer;
22 23 bool reconstructed{false};
... ...