mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-07 00:53:56 +00:00
Remove QPDFObjectHandle::reserved
This commit is contained in:
parent
7248cab71b
commit
07b66eb0b6
@ -1609,7 +1609,6 @@ class QPDFObjectHandle
|
|||||||
QPDF* qpdf;
|
QPDF* qpdf;
|
||||||
QPDFObjGen og;
|
QPDFObjGen og;
|
||||||
std::shared_ptr<QPDFObject> obj;
|
std::shared_ptr<QPDFObject> obj;
|
||||||
bool reserved;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifndef QPDF_NO_QPDF_STRING
|
#ifndef QPDF_NO_QPDF_STRING
|
||||||
|
@ -236,24 +236,21 @@ LastChar::getLastChar()
|
|||||||
|
|
||||||
QPDFObjectHandle::QPDFObjectHandle() :
|
QPDFObjectHandle::QPDFObjectHandle() :
|
||||||
initialized(false),
|
initialized(false),
|
||||||
qpdf(nullptr),
|
qpdf(nullptr)
|
||||||
reserved(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, QPDFObjGen const& og) :
|
QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, QPDFObjGen const& og) :
|
||||||
initialized(true),
|
initialized(true),
|
||||||
qpdf(qpdf),
|
qpdf(qpdf),
|
||||||
og(og),
|
og(og)
|
||||||
reserved(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) :
|
QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) :
|
||||||
initialized(true),
|
initialized(true),
|
||||||
qpdf(nullptr),
|
qpdf(nullptr),
|
||||||
obj(data),
|
obj(data)
|
||||||
reserved(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,7 +409,7 @@ bool
|
|||||||
QPDFObjectHandle::isReserved()
|
QPDFObjectHandle::isReserved()
|
||||||
{
|
{
|
||||||
// dereference will clear reserved if this has been replaced
|
// dereference will clear reserved if this has been replaced
|
||||||
return dereference() && this->reserved;
|
return dereference() && QPDFObjectTypeAccessor<QPDF_Reserved>::check(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -1648,7 +1645,7 @@ QPDFObjectHandle::unparseResolved()
|
|||||||
if (!dereference()) {
|
if (!dereference()) {
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"attempted to dereference an uninitialized QPDFObjectHandle");
|
"attempted to dereference an uninitialized QPDFObjectHandle");
|
||||||
} else if (this->reserved) {
|
} else if (isReserved()) {
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"QPDFObjectHandle: attempting to unparse a reserved object");
|
"QPDFObjectHandle: attempting to unparse a reserved object");
|
||||||
}
|
}
|
||||||
@ -1680,7 +1677,7 @@ QPDFObjectHandle::getJSON(int json_version, bool dereference_indirect)
|
|||||||
} else if (!dereference()) {
|
} else if (!dereference()) {
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"attempted to dereference an uninitialized QPDFObjectHandle");
|
"attempted to dereference an uninitialized QPDFObjectHandle");
|
||||||
} else if (this->reserved) {
|
} else if (isReserved()) {
|
||||||
throw std::logic_error(
|
throw std::logic_error(
|
||||||
"QPDFObjectHandle: attempting to unparse a reserved object");
|
"QPDFObjectHandle: attempting to unparse a reserved object");
|
||||||
} else {
|
} else {
|
||||||
@ -2159,7 +2156,6 @@ QPDFObjectHandle::newReserved(QPDF* qpdf)
|
|||||||
// number, but then return an unresolved handle to the object.
|
// number, but then return an unresolved handle to the object.
|
||||||
QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved());
|
QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved());
|
||||||
QPDFObjectHandle result = newIndirect(qpdf, reserved.getObjGen());
|
QPDFObjectHandle result = newIndirect(qpdf, reserved.getObjGen());
|
||||||
result.reserved = true;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2567,24 +2563,10 @@ QPDFObjectHandle::dereference()
|
|||||||
if (!this->initialized) {
|
if (!this->initialized) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this->obj.get() && getObjectID() &&
|
if (this->obj() == nullptr ||
|
||||||
QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj)) {
|
(getObjectID() &&
|
||||||
this->obj = nullptr;
|
QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj))) {
|
||||||
}
|
obj = QPDF::Resolver::resolve(this->qpdf, getObjGen());
|
||||||
if (this->obj == nullptr) {
|
|
||||||
std::shared_ptr<QPDFObject> obj =
|
|
||||||
QPDF::Resolver::resolve(this->qpdf, getObjGen());
|
|
||||||
if (obj == nullptr) {
|
|
||||||
// QPDF::resolve never returns an uninitialized object, but
|
|
||||||
// check just in case.
|
|
||||||
this->obj = QPDF_Null::create();
|
|
||||||
} else if (dynamic_cast<QPDF_Reserved*>(obj.get())) {
|
|
||||||
// Do not resolve
|
|
||||||
this->reserved = true;
|
|
||||||
} else {
|
|
||||||
this->reserved = false;
|
|
||||||
this->obj = obj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user