2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-10-31 19:02:30 +00:00

Add method QPDFObject::resolve

This commit is contained in:
m-holger 2022-08-14 10:50:30 +01:00
parent 56e9bcabe9
commit 4a8515912c
4 changed files with 21 additions and 5 deletions

View File

@ -843,7 +843,7 @@ class QPDF
// it can resolve indirect references. // it can resolve indirect references.
class Resolver class Resolver
{ {
friend class QPDFObjectHandle; friend class QPDFObject;
private: private:
static void static void

View File

@ -153,10 +153,19 @@ class QPDFObject
} }
bool bool
isUnresolved() isUnresolved() const
{ {
return value->type_code == ::ot_unresolved; return value->type_code == ::ot_unresolved;
} }
void
resolve()
{
if (isUnresolved()) {
doResolve();
}
}
void doResolve();
template <typename T> template <typename T>
T* T*
as() as()

View File

@ -1 +1,10 @@
#include <qpdf/QPDFObject.hh> #include <qpdf/QPDFObject.hh>
#include <qpdf/QPDF.hh>
void
QPDFObject::doResolve()
{
auto og = value->og;
QPDF::Resolver::resolve(value->qpdf, og);
}

View File

@ -2595,9 +2595,7 @@ QPDFObjectHandle::dereference()
if (!isInitialized()) { if (!isInitialized()) {
return false; return false;
} }
if (this->obj->isUnresolved()) { this->obj->resolve();
QPDF::Resolver::resolve(this->qpdf, getObjGen());
}
return true; return true;
} }