Commit 54753f37aa4cbd7f1aded18929436a52c5e58b5e
1 parent
0dad57c5
Refactor: replace `QPDFObjectHandle` with `Dictionary` in `QPDF::readHintStream`…
…, remove redundant `QTC::TC` call, and simplify type usage.
Showing
3 changed files
with
13 additions
and
13 deletions
include/qpdf/QPDF.hh
| @@ -46,10 +46,15 @@ | @@ -46,10 +46,15 @@ | ||
| 46 | #include <qpdf/QPDFWriter.hh> | 46 | #include <qpdf/QPDFWriter.hh> |
| 47 | #include <qpdf/QPDFXRefEntry.hh> | 47 | #include <qpdf/QPDFXRefEntry.hh> |
| 48 | 48 | ||
| 49 | -namespace qpdf::is | 49 | +namespace qpdf |
| 50 | { | 50 | { |
| 51 | - class OffsetBuffer; | ||
| 52 | -} | 51 | + class Dictionary; |
| 52 | + | ||
| 53 | + namespace is | ||
| 54 | + { | ||
| 55 | + class OffsetBuffer; | ||
| 56 | + } | ||
| 57 | +} // namespace qpdf | ||
| 53 | 58 | ||
| 54 | class QPDF_Stream; | 59 | class QPDF_Stream; |
| 55 | class BitStream; | 60 | class BitStream; |
| @@ -1006,7 +1011,7 @@ class QPDF | @@ -1006,7 +1011,7 @@ class QPDF | ||
| 1006 | void checkLinearizationInternal(); | 1011 | void checkLinearizationInternal(); |
| 1007 | void dumpLinearizationDataInternal(); | 1012 | void dumpLinearizationDataInternal(); |
| 1008 | void linearizationWarning(std::string_view); | 1013 | void linearizationWarning(std::string_view); |
| 1009 | - QPDFObjectHandle readHintStream(Pipeline&, qpdf_offset_t offset, size_t length); | 1014 | + qpdf::Dictionary readHintStream(Pipeline&, qpdf_offset_t offset, size_t length); |
| 1010 | void readHPageOffset(BitStream); | 1015 | void readHPageOffset(BitStream); |
| 1011 | void readHSharedObject(BitStream); | 1016 | void readHSharedObject(BitStream); |
| 1012 | void readHGeneric(BitStream, HGeneric&); | 1017 | void readHGeneric(BitStream, HGeneric&); |
libqpdf/QPDF_linearization.cc
| @@ -262,7 +262,7 @@ QPDF::readLinearizationData() | @@ -262,7 +262,7 @@ QPDF::readLinearizationData() | ||
| 262 | } | 262 | } |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | -QPDFObjectHandle | 265 | +Dictionary |
| 266 | QPDF::readHintStream(Pipeline& pl, qpdf_offset_t offset, size_t length) | 266 | QPDF::readHintStream(Pipeline& pl, qpdf_offset_t offset, size_t length) |
| 267 | { | 267 | { |
| 268 | auto H = readObjectAtOffset(offset, "linearization hint stream", false); | 268 | auto H = readObjectAtOffset(offset, "linearization hint stream", false); |
| @@ -273,18 +273,14 @@ QPDF::readHintStream(Pipeline& pl, qpdf_offset_t offset, size_t length) | @@ -273,18 +273,14 @@ QPDF::readHintStream(Pipeline& pl, qpdf_offset_t offset, size_t length) | ||
| 273 | throw damagedPDF("linearization dictionary", "hint table is not a stream"); | 273 | throw damagedPDF("linearization dictionary", "hint table is not a stream"); |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | - QPDFObjectHandle Hdict = H.getDict(); | 276 | + Dictionary Hdict = H.getDict(); |
| 277 | 277 | ||
| 278 | // Some versions of Acrobat make /Length indirect and place it immediately after the stream, | 278 | // Some versions of Acrobat make /Length indirect and place it immediately after the stream, |
| 279 | // increasing length to cover it, even though the specification says all objects in the | 279 | // increasing length to cover it, even though the specification says all objects in the |
| 280 | // linearization parameter dictionary must be direct. We have to get the file position of the | 280 | // linearization parameter dictionary must be direct. We have to get the file position of the |
| 281 | // end of length in this case. | 281 | // end of length in this case. |
| 282 | - QPDFObjectHandle length_obj = Hdict.getKey("/Length"); | ||
| 283 | - if (length_obj.isIndirect()) { | ||
| 284 | - QTC::TC("qpdf", "QPDF hint table length indirect"); | ||
| 285 | - // Force resolution | ||
| 286 | - (void)length_obj.getIntValue(); | ||
| 287 | - ObjCache& oc2 = m->obj_cache[length_obj.getObjGen()]; | 282 | + if (Hdict["/Length"].indirect()) { |
| 283 | + ObjCache& oc2 = m->obj_cache[Hdict["/Length"]]; | ||
| 288 | min_end_offset = oc2.end_before_space; | 284 | min_end_offset = oc2.end_before_space; |
| 289 | max_end_offset = oc2.end_after_space; | 285 | max_end_offset = oc2.end_after_space; |
| 290 | } else { | 286 | } else { |
qpdf/qpdf.testcov
| @@ -7,7 +7,6 @@ QPDF check obj 1 | @@ -7,7 +7,6 @@ QPDF check obj 1 | ||
| 7 | QPDF object stream offsets not increasing 0 | 7 | QPDF object stream offsets not increasing 0 |
| 8 | QPDF ignore self-referential object stream 0 | 8 | QPDF ignore self-referential object stream 0 |
| 9 | QPDF object stream contains id < 1 0 | 9 | QPDF object stream contains id < 1 0 |
| 10 | -QPDF hint table length indirect 0 | ||
| 11 | QPDF hint table length direct 0 | 10 | QPDF hint table length direct 0 |
| 12 | QPDF P absent in lindict 0 | 11 | QPDF P absent in lindict 0 |
| 13 | QPDF P present in lindict 0 | 12 | QPDF P present in lindict 0 |