Commit 54753f37aa4cbd7f1aded18929436a52c5e58b5e

Authored by m-holger
1 parent 0dad57c5

Refactor: replace `QPDFObjectHandle` with `Dictionary` in `QPDF::readHintStream`…

…, remove redundant `QTC::TC` call, and simplify type usage.
include/qpdf/QPDF.hh
... ... @@ -46,10 +46,15 @@
46 46 #include <qpdf/QPDFWriter.hh>
47 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 59 class QPDF_Stream;
55 60 class BitStream;
... ... @@ -1006,7 +1011,7 @@ class QPDF
1006 1011 void checkLinearizationInternal();
1007 1012 void dumpLinearizationDataInternal();
1008 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 1015 void readHPageOffset(BitStream);
1011 1016 void readHSharedObject(BitStream);
1012 1017 void readHGeneric(BitStream, HGeneric&);
... ...
libqpdf/QPDF_linearization.cc
... ... @@ -262,7 +262,7 @@ QPDF::readLinearizationData()
262 262 }
263 263 }
264 264  
265   -QPDFObjectHandle
  265 +Dictionary
266 266 QPDF::readHintStream(Pipeline& pl, qpdf_offset_t offset, size_t length)
267 267 {
268 268 auto H = readObjectAtOffset(offset, "linearization hint stream", false);
... ... @@ -273,18 +273,14 @@ QPDF::readHintStream(Pipeline&amp; pl, qpdf_offset_t offset, size_t length)
273 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 278 // Some versions of Acrobat make /Length indirect and place it immediately after the stream,
279 279 // increasing length to cover it, even though the specification says all objects in the
280 280 // linearization parameter dictionary must be direct. We have to get the file position of the
281 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 284 min_end_offset = oc2.end_before_space;
289 285 max_end_offset = oc2.end_after_space;
290 286 } else {
... ...
qpdf/qpdf.testcov
... ... @@ -7,7 +7,6 @@ QPDF check obj 1
7 7 QPDF object stream offsets not increasing 0
8 8 QPDF ignore self-referential object stream 0
9 9 QPDF object stream contains id < 1 0
10   -QPDF hint table length indirect 0
11 10 QPDF hint table length direct 0
12 11 QPDF P absent in lindict 0
13 12 QPDF P present in lindict 0
... ...