mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-10 23:20:58 +00:00
Tidy QPDFXRefEntry creation
This commit is contained in:
parent
e4e0f40fc0
commit
e8cdc46286
@ -34,10 +34,26 @@ class QPDFXRefEntry
|
||||
// 1 = "uncompressed"; field 1 = offset
|
||||
// 2 = "compressed"; field 1 = object stream number, field 2 = index
|
||||
|
||||
// Create a type 0 "free" entry.
|
||||
QPDF_DLL
|
||||
QPDFXRefEntry();
|
||||
QPDF_DLL
|
||||
QPDFXRefEntry(int type, qpdf_offset_t field1, int field2);
|
||||
// Create a type 1 "uncompressed" entry.
|
||||
QPDF_DLL
|
||||
QPDFXRefEntry(qpdf_offset_t offset) :
|
||||
type(1),
|
||||
field1(offset)
|
||||
{
|
||||
}
|
||||
// Create a type 2 "compressed" entry.
|
||||
QPDF_DLL
|
||||
QPDFXRefEntry(int stream_number, int index) :
|
||||
type(2),
|
||||
field1(stream_number),
|
||||
field2(index)
|
||||
{
|
||||
}
|
||||
|
||||
QPDF_DLL
|
||||
int getType() const;
|
||||
@ -51,9 +67,9 @@ class QPDFXRefEntry
|
||||
private:
|
||||
// This class does not use the Members pattern to avoid a memory
|
||||
// allocation for every one of these. A lot of these get created.
|
||||
int type;
|
||||
qpdf_offset_t field1;
|
||||
int field2;
|
||||
int type{0};
|
||||
qpdf_offset_t field1{0};
|
||||
int field2{0};
|
||||
};
|
||||
|
||||
#endif // QPDFXREFENTRY_HH
|
||||
|
@ -1249,11 +1249,11 @@ QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite)
|
||||
case 1:
|
||||
// f2 is generation
|
||||
QTC::TC("qpdf", "QPDF xref gen > 0", ((f2 > 0) ? 1 : 0));
|
||||
this->m->xref_table[QPDFObjGen(obj, f2)] = QPDFXRefEntry(f0, f1, f2);
|
||||
this->m->xref_table[QPDFObjGen(obj, f2)] = QPDFXRefEntry(f1);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
this->m->xref_table[QPDFObjGen(obj, 0)] = QPDFXRefEntry(f0, f1, f2);
|
||||
this->m->xref_table[QPDFObjGen(obj, 0)] = QPDFXRefEntry(toI(f1), f2);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1156,7 +1156,7 @@ QPDFWriter::openObject(int objid)
|
||||
if (objid == 0) {
|
||||
objid = this->m->next_objid++;
|
||||
}
|
||||
this->m->xref[objid] = QPDFXRefEntry(1, this->m->pipeline->getCount(), 0);
|
||||
this->m->xref[objid] = QPDFXRefEntry(m->pipeline->getCount());
|
||||
writeString(std::to_string(objid));
|
||||
writeString(" 0 obj\n");
|
||||
return objid;
|
||||
@ -1905,7 +1905,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object)
|
||||
}
|
||||
writeObject(obj_to_write, count);
|
||||
|
||||
this->m->xref[new_obj] = QPDFXRefEntry(2, new_id, count);
|
||||
this->m->xref[new_obj] = QPDFXRefEntry(new_id, count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2686,7 +2686,7 @@ QPDFWriter::writeXRefStream(
|
||||
|
||||
// Must store in xref table in advance of writing the actual data
|
||||
// rather than waiting for openObject to do it.
|
||||
this->m->xref[xref_id] = QPDFXRefEntry(1, this->m->pipeline->getCount(), 0);
|
||||
this->m->xref[xref_id] = QPDFXRefEntry(m->pipeline->getCount());
|
||||
|
||||
Pipeline* p = pushPipeline(new Pl_Buffer("xref stream"));
|
||||
bool compressed = false;
|
||||
@ -3112,7 +3112,7 @@ QPDFWriter::writeLinearized()
|
||||
}
|
||||
if (pass == 1) {
|
||||
this->m->xref[hint_id] =
|
||||
QPDFXRefEntry(1, this->m->pipeline->getCount(), 0);
|
||||
QPDFXRefEntry(m->pipeline->getCount());
|
||||
} else {
|
||||
// Part 5: hint stream
|
||||
writeBuffer(hint_buffer);
|
||||
@ -3216,7 +3216,7 @@ QPDFWriter::writeLinearized()
|
||||
hint_length = QIntC::to_offset(hint_buffer->getSize());
|
||||
|
||||
// Restore hint offset
|
||||
this->m->xref[hint_id] = QPDFXRefEntry(1, hint_offset1, 0);
|
||||
this->m->xref[hint_id] = QPDFXRefEntry(hint_offset1);
|
||||
if (lin_pass1_file) {
|
||||
// Write some debugging information
|
||||
fprintf(
|
||||
|
@ -4,10 +4,7 @@
|
||||
#include <qpdf/QPDFExc.hh>
|
||||
#include <qpdf/QUtil.hh>
|
||||
|
||||
QPDFXRefEntry::QPDFXRefEntry() :
|
||||
type(0),
|
||||
field1(0),
|
||||
field2(0)
|
||||
QPDFXRefEntry::QPDFXRefEntry()
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user