2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-16 01:27:07 +00:00

Add new method QPDFObject::setDefaultDescription

This commit is contained in:
m-holger 2022-12-16 16:19:15 +00:00 committed by Jay Berkenbilt
parent d03ca88275
commit 218f069a69
3 changed files with 17 additions and 9 deletions

View File

@ -1848,9 +1848,7 @@ QPDF::resolve(QPDFObjGen og)
} }
auto result(this->m->obj_cache[og].object); auto result(this->m->obj_cache[og].object);
if (!result->hasDescription()) { result->setDefaultDescription(this, og);
result->setDescription(this, ("object " + og.unparse(' ')));
}
} }
void void
@ -1946,10 +1944,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); obj->setDefaultDescription(this, og);
if (!obj->hasDescription()) {
obj->setDescription(this, "object " + og.unparse(' '));
}
return QPDFObjectHandle::Factory::newIndirect(obj); return QPDFObjectHandle::Factory::newIndirect(obj);
} }

View File

@ -68,7 +68,6 @@ class QPDFObject
{ {
return value->og; return value->og;
} }
void void
setDescription( setDescription(
QPDF* qpdf, std::string const& description, qpdf_offset_t offset = -1) QPDF* qpdf, std::string const& description, qpdf_offset_t offset = -1)
@ -112,9 +111,14 @@ class QPDFObject
} }
void void
setObjGen(QPDF* qpdf, QPDFObjGen const& og) setDefaultDescription(QPDF* qpdf, QPDFObjGen const& og)
{ {
// Intended for use by the QPDF class // Intended for use by the QPDF class
value->setDefaultDescription(qpdf, og);
}
void
setObjGen(QPDF* qpdf, QPDFObjGen const& og)
{
value->qpdf = qpdf; value->qpdf = qpdf;
value->og = og; value->og = og;
} }

View File

@ -31,6 +31,15 @@ class QPDFValue
object_description = description; object_description = description;
setParsedOffset(offset); setParsedOffset(offset);
} }
void
setDefaultDescription(QPDF* a_qpdf, QPDFObjGen const& a_og)
{
if (object_description.empty()) {
object_description = "object " + a_og.unparse(' ');
}
qpdf = a_qpdf;
og = a_og;
}
bool bool
getDescription(QPDF*& qpdf_p, std::string& description) getDescription(QPDF*& qpdf_p, std::string& description)
{ {