mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-08 22:58:25 +00:00
Remove parameter overwrite from QPDF::processXRefStream
This commit is contained in:
parent
769a4915e8
commit
250a736482
@ -1002,7 +1002,7 @@ class QPDF
|
|||||||
qpdf_offset_t read_xrefTable(qpdf_offset_t offset);
|
qpdf_offset_t read_xrefTable(qpdf_offset_t offset);
|
||||||
qpdf_offset_t read_xrefStream(qpdf_offset_t offset);
|
qpdf_offset_t read_xrefStream(qpdf_offset_t offset);
|
||||||
qpdf_offset_t processXRefStream(qpdf_offset_t offset, QPDFObjectHandle& xref_stream);
|
qpdf_offset_t processXRefStream(qpdf_offset_t offset, QPDFObjectHandle& xref_stream);
|
||||||
void insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite = false);
|
void insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2);
|
||||||
void insertReconstructedXrefEntry(int obj, qpdf_offset_t f1, int f2);
|
void insertReconstructedXrefEntry(int obj, qpdf_offset_t f1, int f2);
|
||||||
void setLastObjectDescription(std::string const& description, QPDFObjGen const& og);
|
void setLastObjectDescription(std::string const& description, QPDFObjGen const& og);
|
||||||
QPDFObjectHandle readObject(
|
QPDFObjectHandle readObject(
|
||||||
|
@ -1112,31 +1112,23 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle& xref_obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite)
|
QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2)
|
||||||
{
|
{
|
||||||
// Populate the xref table in such a way that the first reference to an object that we see,
|
// Populate the xref table in such a way that the first reference to an object that we see,
|
||||||
// which is the one in the latest xref table in which it appears, is the one that gets stored.
|
// which is the one in the latest xref table in which it appears, is the one that gets stored.
|
||||||
// This works because we are reading more recent appends before older ones. Exception: if
|
// This works because we are reading more recent appends before older ones.
|
||||||
// overwrite is true, then replace any existing object. This is used in xref recovery mode,
|
|
||||||
// which reads the file from beginning to end.
|
|
||||||
|
|
||||||
// If there is already an entry for this object and generation in the table, it means that a
|
// If there is already an entry for this object and generation in the table, it means that a
|
||||||
// later xref table has registered this object. Disregard this one.
|
// later xref table has registered this object. Disregard this one.
|
||||||
{ // private scope
|
|
||||||
int gen = (f0 == 2 ? 0 : f2);
|
QPDFObjGen og(obj, (f0 == 2 ? 0 : f2));
|
||||||
QPDFObjGen og(obj, gen);
|
if (m->xref_table.count(og)) {
|
||||||
if (m->xref_table.count(og)) {
|
QTC::TC("qpdf", "QPDF xref reused object");
|
||||||
if (overwrite) {
|
return;
|
||||||
m->xref_table.erase(og);
|
}
|
||||||
} else {
|
if (m->deleted_objects.count(obj)) {
|
||||||
QTC::TC("qpdf", "QPDF xref reused object");
|
QTC::TC("qpdf", "QPDF xref deleted object");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
|
||||||
if (m->deleted_objects.count(obj)) {
|
|
||||||
QTC::TC("qpdf", "QPDF xref deleted object");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (f0) {
|
switch (f0) {
|
||||||
@ -1147,11 +1139,11 @@ QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite)
|
|||||||
case 1:
|
case 1:
|
||||||
// f2 is generation
|
// f2 is generation
|
||||||
QTC::TC("qpdf", "QPDF xref gen > 0", ((f2 > 0) ? 1 : 0));
|
QTC::TC("qpdf", "QPDF xref gen > 0", ((f2 > 0) ? 1 : 0));
|
||||||
m->xref_table[QPDFObjGen(obj, f2)] = QPDFXRefEntry(f1);
|
m->xref_table[og] = QPDFXRefEntry(f1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
m->xref_table[QPDFObjGen(obj, 0)] = QPDFXRefEntry(toI(f1), f2);
|
m->xref_table[og] = QPDFXRefEntry(toI(f1), f2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user