mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Add private methods for reserving specific objects
This commit is contained in:
parent
7fa5d1773b
commit
9064542b5f
@ -1079,6 +1079,7 @@ class QPDF
|
||||
std::shared_ptr<QPDFObject> resolve(int objid, int generation);
|
||||
void resolveObjectsInStream(int obj_stream_number);
|
||||
void stopOnError(std::string const& message);
|
||||
QPDFObjectHandle reserveObjectIfNotExists(int objid, int gen);
|
||||
|
||||
// Calls finish() on the pipeline when done but does not delete it
|
||||
bool pipeStreamData(
|
||||
|
@ -1444,6 +1444,12 @@ class QPDFObjectHandle
|
||||
return QPDFObjectHandle::newStream(
|
||||
qpdf, objid, generation, stream_dict, offset, length);
|
||||
}
|
||||
// Reserve an object with a specific ID
|
||||
static QPDFObjectHandle
|
||||
makeReserved()
|
||||
{
|
||||
return QPDFObjectHandle::makeReserved();
|
||||
}
|
||||
};
|
||||
friend class Factory;
|
||||
|
||||
@ -1561,6 +1567,7 @@ class QPDFObjectHandle
|
||||
QPDFObjectHandle stream_dict,
|
||||
qpdf_offset_t offset,
|
||||
size_t length);
|
||||
static QPDFObjectHandle makeReserved();
|
||||
|
||||
void typeWarning(char const* expected_type, std::string const& warning);
|
||||
void objectWarning(std::string const& warning);
|
||||
|
@ -2155,6 +2155,17 @@ QPDF::makeIndirectObject(QPDFObjectHandle oh)
|
||||
this, next.getObj(), next.getGen());
|
||||
}
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDF::reserveObjectIfNotExists(int objid, int gen)
|
||||
{
|
||||
QPDFObjGen og(objid, gen);
|
||||
if ((!this->m->obj_cache.count(og)) && (!this->m->xref_table.count(og))) {
|
||||
resolve(objid, gen);
|
||||
replaceObject(objid, gen, QPDFObjectHandle::Factory::makeReserved());
|
||||
}
|
||||
return getObjectByID(objid, gen);
|
||||
}
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDF::getObjectByObjGen(QPDFObjGen const& og)
|
||||
{
|
||||
|
@ -2775,14 +2775,19 @@ QPDFObjectHandle::newReserved(QPDF* qpdf)
|
||||
{
|
||||
// Reserve a spot for this object by assigning it an object
|
||||
// number, but then return an unresolved handle to the object.
|
||||
QPDFObjectHandle reserved =
|
||||
qpdf->makeIndirectObject(QPDFObjectHandle(new QPDF_Reserved()));
|
||||
QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved());
|
||||
QPDFObjectHandle result =
|
||||
newIndirect(qpdf, reserved.objid, reserved.generation);
|
||||
result.reserved = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDFObjectHandle::makeReserved()
|
||||
{
|
||||
return QPDFObjectHandle(new QPDF_Reserved());
|
||||
}
|
||||
|
||||
void
|
||||
QPDFObjectHandle::setObjectDescription(
|
||||
QPDF* owning_qpdf, std::string const& object_description)
|
||||
|
Loading…
Reference in New Issue
Block a user