mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
Add methods QPDFObject::setObjGen and QPDFObject::resetObjGen
Also, modify QPDFObject::swapWith to update the ObjGens of the swapped objects. Modify QPDF::newIndirect and QPDF::updateCache to keep object ObjGens up to date.
This commit is contained in:
parent
89061d5b33
commit
56e9bcabe9
@ -133,7 +133,25 @@ class QPDFObject
|
|||||||
auto v = value;
|
auto v = value;
|
||||||
value = o->value;
|
value = o->value;
|
||||||
o->value = v;
|
o->value = v;
|
||||||
|
auto og = value->og;
|
||||||
|
value->og = o->value->og;
|
||||||
|
o->value->og = og;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The following two methods are for use by class QPDF only
|
||||||
|
void
|
||||||
|
setObjGen(QPDF* qpdf, QPDFObjGen const& og)
|
||||||
|
{
|
||||||
|
value->qpdf = qpdf;
|
||||||
|
value->og = og;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
resetObjGen()
|
||||||
|
{
|
||||||
|
value->qpdf = nullptr;
|
||||||
|
value->og = QPDFObjGen();
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
isUnresolved()
|
isUnresolved()
|
||||||
{
|
{
|
||||||
|
@ -2109,6 +2109,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
|
|||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj)
|
QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj)
|
||||||
{
|
{
|
||||||
|
obj->setObjGen(this, og);
|
||||||
if (!obj->hasDescription()) {
|
if (!obj->hasDescription()) {
|
||||||
obj->setDescription(this, "object " + og.unparse(' '));
|
obj->setDescription(this, "object " + og.unparse(' '));
|
||||||
}
|
}
|
||||||
@ -2122,8 +2123,10 @@ QPDF::updateCache(
|
|||||||
qpdf_offset_t end_before_space,
|
qpdf_offset_t end_before_space,
|
||||||
qpdf_offset_t end_after_space)
|
qpdf_offset_t end_after_space)
|
||||||
{
|
{
|
||||||
|
object->setObjGen(this, og);
|
||||||
if (isCached(og)) {
|
if (isCached(og)) {
|
||||||
auto& cache = m->obj_cache[og];
|
auto& cache = m->obj_cache[og];
|
||||||
|
cache.object->resetObjGen();
|
||||||
cache.object->assign(object);
|
cache.object->assign(object);
|
||||||
cache.end_before_space = end_before_space;
|
cache.end_before_space = end_before_space;
|
||||||
cache.end_after_space = end_after_space;
|
cache.end_after_space = end_after_space;
|
||||||
|
Loading…
Reference in New Issue
Block a user