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