Commit 6fc982b71a31fd70581f826bff5df6333d094797

Authored by m-holger
1 parent 8ad1ea34

Move QPDFObjectHandle::setObjectDescriptionFromInput to QPDFParser

Part of #729
include/qpdf/QPDFObjectHandle.hh
... ... @@ -1587,12 +1587,6 @@ class QPDFObjectHandle
1587 1587 bool stop_at_streams);
1588 1588 void shallowCopyInternal(QPDFObjectHandle& oh, bool first_level_only);
1589 1589 void releaseResolved();
1590   - static void setObjectDescriptionFromInput(
1591   - QPDFObjectHandle,
1592   - QPDF*,
1593   - std::string const&,
1594   - std::shared_ptr<InputSource>,
1595   - qpdf_offset_t);
1596 1590  
1597 1591 void setParsedOffset(qpdf_offset_t offset);
1598 1592 void parseContentStream_internal(
... ...
libqpdf/QPDFObjectHandle.cc
... ... @@ -273,20 +273,6 @@ QPDFObjectHandle::releaseResolved()
273 273 }
274 274 }
275 275  
276   -void
277   -QPDFObjectHandle::setObjectDescriptionFromInput(
278   - QPDFObjectHandle object,
279   - QPDF* context,
280   - std::string const& description,
281   - std::shared_ptr<InputSource> input,
282   - qpdf_offset_t offset)
283   -{
284   - object.setObjectDescription(
285   - context,
286   - (input->getName() + ", " + description + " at offset " +
287   - QUtil::int_to_string(offset)));
288   -}
289   -
290 276 QPDFObject::object_type_e
291 277 QPDFObjectHandle::getTypeCode()
292 278 {
... ...
libqpdf/QPDFParser.cc
... ... @@ -263,12 +263,7 @@ QPDFParser::parse(bool&amp; empty, bool content_stream)
263 263  
264 264 case st_dictionary:
265 265 case st_array:
266   - QPDFObjectHandle::setObjectDescriptionFromInput(
267   - object,
268   - context,
269   - object_description,
270   - input,
271   - input->getLastOffset());
  266 + setDescriptionFromInput(object, input->getLastOffset());
272 267 object.setParsedOffset(input->getLastOffset());
273 268 set_offset = true;
274 269 olist.append(object);
... ... @@ -293,8 +288,7 @@ QPDFParser::parse(bool&amp; empty, bool content_stream)
293 288 // There's no newArray(SparseOHArray) since
294 289 // SparseOHArray is not part of the public API.
295 290 object = QPDFObjectHandle(QPDF_Array::create(olist));
296   - QPDFObjectHandle::setObjectDescriptionFromInput(
297   - object, context, object_description, input, offset);
  291 + setDescriptionFromInput(object, offset);
298 292 // The `offset` points to the next of "[". Set the
299 293 // rewind offset to point to the beginning of "[".
300 294 // This has been explicitly tested with whitespace
... ... @@ -347,8 +341,7 @@ QPDFParser::parse(bool&amp; empty, bool content_stream)
347 341 "dictionary ended prematurely; "
348 342 "using null as value for last key");
349 343 val = QPDFObjectHandle::newNull();
350   - QPDFObjectHandle::setObjectDescriptionFromInput(
351   - val, context, object_description, input, offset);
  344 + setDescriptionFromInput(val, offset);
352 345 } else {
353 346 val = olist.at(++i);
354 347 }
... ... @@ -372,8 +365,7 @@ QPDFParser::parse(bool&amp; empty, bool content_stream)
372 365 dict["/Contents"].setParsedOffset(contents_offset);
373 366 }
374 367 object = QPDFObjectHandle::newDictionary(dict);
375   - QPDFObjectHandle::setObjectDescriptionFromInput(
376   - object, context, object_description, input, offset);
  368 + setDescriptionFromInput(object, offset);
377 369 // The `offset` points to the next of "<<". Set the
378 370 // rewind offset to point to the beginning of "<<".
379 371 // This has been explicitly tested with whitespace
... ... @@ -396,14 +388,23 @@ QPDFParser::parse(bool&amp; empty, bool content_stream)
396 388 }
397 389  
398 390 if (!set_offset) {
399   - QPDFObjectHandle::setObjectDescriptionFromInput(
400   - object, context, object_description, input, offset);
  391 + setDescriptionFromInput(object, offset);
401 392 object.setParsedOffset(offset);
402 393 }
403 394 return object;
404 395 }
405 396  
406 397 void
  398 +QPDFParser::setDescriptionFromInput(
  399 + QPDFObjectHandle oh, qpdf_offset_t offset) const
  400 +{
  401 + oh.setObjectDescription(
  402 + context,
  403 + (input->getName() + ", " + object_description + " at offset " +
  404 + QUtil::int_to_string(offset)));
  405 +}
  406 +
  407 +void
407 408 QPDFParser::warn(QPDF* qpdf, QPDFExc const& e)
408 409 {
409 410 // If parsing on behalf of a QPDF object and want to give a
... ...
libqpdf/qpdf/QPDFParser.hh
... ... @@ -41,7 +41,8 @@ class QPDFParser
41 41 void warn(std::string const& msg) const;
42 42 static void warn(QPDF*, QPDFExc const&);
43 43 void setParsedOffset(qpdf_offset_t offset);
44   -
  44 + void
  45 + setDescriptionFromInput(QPDFObjectHandle oh, qpdf_offset_t offset) const;
45 46 std::shared_ptr<InputSource> input;
46 47 std::string const& object_description;
47 48 QPDFTokenizer& tokenizer;
... ...