diff --git a/include/qpdf/QPDFObjectHandle.hh b/include/qpdf/QPDFObjectHandle.hh index 804b76c7..fa96c4b0 100644 --- a/include/qpdf/QPDFObjectHandle.hh +++ b/include/qpdf/QPDFObjectHandle.hh @@ -1550,7 +1550,7 @@ class QPDFObjectHandle bool isImage(bool exclude_imagemask = true); private: - QPDFObjectHandle(QPDF*, int objid, int generation); + QPDFObjectHandle(QPDF*, QPDFObjGen const& og); QPDFObjectHandle(std::shared_ptr const&); enum parser_state_e { @@ -1617,8 +1617,7 @@ class QPDFObjectHandle // a substantial performance penalty since QPDFObjectHandle // objects are copied around so frequently. QPDF* qpdf; - int objid; // 0 for direct object - int generation; + QPDFObjGen og; std::shared_ptr obj; bool reserved; }; diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index b01deb6a..880e44bd 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -218,27 +218,22 @@ LastChar::getLastChar() QPDFObjectHandle::QPDFObjectHandle() : initialized(false), - qpdf(0), - objid(0), - generation(0), + qpdf(nullptr), reserved(false) { } -QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, int objid, int generation) : +QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, QPDFObjGen const& og) : initialized(true), qpdf(qpdf), - objid(objid), - generation(generation), + og(og), reserved(false) { } QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr const& data) : initialized(true), - qpdf(0), - objid(0), - generation(0), + qpdf(nullptr), obj(data), reserved(false) { @@ -1481,19 +1476,19 @@ QPDFObjectHandle::replaceStreamData( QPDFObjGen QPDFObjectHandle::getObjGen() const { - return QPDFObjGen(this->objid, this->generation); + return og; } int QPDFObjectHandle::getObjectID() const { - return this->objid; + return og.getObj(); } int QPDFObjectHandle::getGeneration() const { - return this->generation; + return og.getGen(); } std::map @@ -2485,7 +2480,7 @@ QPDFObjectHandle::newIndirect(QPDF* qpdf, int objid, int generation) return newNull(); } - return QPDFObjectHandle(qpdf, objid, generation); + return QPDFObjectHandle(qpdf, QPDFObjGen(objid, generation)); } QPDFObjectHandle @@ -2689,7 +2684,7 @@ QPDFObjectHandle::newReserved(QPDF* qpdf) // number, but then return an unresolved handle to the object. QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved()); QPDFObjectHandle result = - newIndirect(qpdf, reserved.objid, reserved.generation); + newIndirect(qpdf, reserved.getObjectID(), reserved.getGeneration()); result.reserved = true; return result; } @@ -2789,9 +2784,8 @@ QPDFObjectHandle::copyObject( " reserved object handle direct"); } - this->qpdf = 0; - this->objid = 0; - this->generation = 0; + qpdf = nullptr; + og = QPDFObjGen(); std::shared_ptr new_obj;