Commit 218f069a69ef74d0b0cc9c7ba0796e9360cef379
Committed by
Jay Berkenbilt
1 parent
d03ca882
Add new method QPDFObject::setDefaultDescription
Showing
3 changed files
with
17 additions
and
9 deletions
libqpdf/QPDF.cc
| @@ -1848,9 +1848,7 @@ QPDF::resolve(QPDFObjGen og) | @@ -1848,9 +1848,7 @@ QPDF::resolve(QPDFObjGen og) | ||
| 1848 | } | 1848 | } |
| 1849 | 1849 | ||
| 1850 | auto result(this->m->obj_cache[og].object); | 1850 | auto result(this->m->obj_cache[og].object); |
| 1851 | - if (!result->hasDescription()) { | ||
| 1852 | - result->setDescription(this, ("object " + og.unparse(' '))); | ||
| 1853 | - } | 1851 | + result->setDefaultDescription(this, og); |
| 1854 | } | 1852 | } |
| 1855 | 1853 | ||
| 1856 | void | 1854 | void |
| @@ -1946,10 +1944,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) | @@ -1946,10 +1944,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) | ||
| 1946 | QPDFObjectHandle | 1944 | QPDFObjectHandle |
| 1947 | QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj) | 1945 | QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj) |
| 1948 | { | 1946 | { |
| 1949 | - obj->setObjGen(this, og); | ||
| 1950 | - if (!obj->hasDescription()) { | ||
| 1951 | - obj->setDescription(this, "object " + og.unparse(' ')); | ||
| 1952 | - } | 1947 | + obj->setDefaultDescription(this, og); |
| 1953 | return QPDFObjectHandle::Factory::newIndirect(obj); | 1948 | return QPDFObjectHandle::Factory::newIndirect(obj); |
| 1954 | } | 1949 | } |
| 1955 | 1950 |
libqpdf/qpdf/QPDFObject_private.hh
| @@ -68,7 +68,6 @@ class QPDFObject | @@ -68,7 +68,6 @@ class QPDFObject | ||
| 68 | { | 68 | { |
| 69 | return value->og; | 69 | return value->og; |
| 70 | } | 70 | } |
| 71 | - | ||
| 72 | void | 71 | void |
| 73 | setDescription( | 72 | setDescription( |
| 74 | QPDF* qpdf, std::string const& description, qpdf_offset_t offset = -1) | 73 | QPDF* qpdf, std::string const& description, qpdf_offset_t offset = -1) |
| @@ -112,9 +111,14 @@ class QPDFObject | @@ -112,9 +111,14 @@ class QPDFObject | ||
| 112 | } | 111 | } |
| 113 | 112 | ||
| 114 | void | 113 | void |
| 115 | - setObjGen(QPDF* qpdf, QPDFObjGen const& og) | 114 | + setDefaultDescription(QPDF* qpdf, QPDFObjGen const& og) |
| 116 | { | 115 | { |
| 117 | // Intended for use by the QPDF class | 116 | // Intended for use by the QPDF class |
| 117 | + value->setDefaultDescription(qpdf, og); | ||
| 118 | + } | ||
| 119 | + void | ||
| 120 | + setObjGen(QPDF* qpdf, QPDFObjGen const& og) | ||
| 121 | + { | ||
| 118 | value->qpdf = qpdf; | 122 | value->qpdf = qpdf; |
| 119 | value->og = og; | 123 | value->og = og; |
| 120 | } | 124 | } |
libqpdf/qpdf/QPDFValue.hh
| @@ -31,6 +31,15 @@ class QPDFValue | @@ -31,6 +31,15 @@ class QPDFValue | ||
| 31 | object_description = description; | 31 | object_description = description; |
| 32 | setParsedOffset(offset); | 32 | setParsedOffset(offset); |
| 33 | } | 33 | } |
| 34 | + void | ||
| 35 | + setDefaultDescription(QPDF* a_qpdf, QPDFObjGen const& a_og) | ||
| 36 | + { | ||
| 37 | + if (object_description.empty()) { | ||
| 38 | + object_description = "object " + a_og.unparse(' '); | ||
| 39 | + } | ||
| 40 | + qpdf = a_qpdf; | ||
| 41 | + og = a_og; | ||
| 42 | + } | ||
| 34 | bool | 43 | bool |
| 35 | getDescription(QPDF*& qpdf_p, std::string& description) | 44 | getDescription(QPDF*& qpdf_p, std::string& description) |
| 36 | { | 45 | { |