Commit ec35156ab0fef078600e6d3551178adf73b87b3b

Authored by m-holger
Committed by Jay Berkenbilt
1 parent 0ef2def8

Refactor QPDFValue::getDescription

Remove parameters and return the description.
libqpdf/QPDF_Dictionary.cc
@@ -84,12 +84,10 @@ QPDF_Dictionary::getKey(std::string const& key) @@ -84,12 +84,10 @@ QPDF_Dictionary::getKey(std::string const& key)
84 // May be a null object 84 // May be a null object
85 return item->second; 85 return item->second;
86 } else { 86 } else {
87 - QPDFObjectHandle null = QPDFObjectHandle::newNull();  
88 - QPDF* qpdf = nullptr;  
89 - std::string description;  
90 - if (getDescription(qpdf, description)) { 87 + auto null = QPDFObjectHandle::newNull();
  88 + if (qpdf != nullptr) {
91 null.setObjectDescription( 89 null.setObjectDescription(
92 - qpdf, description + " -> dictionary key " + key); 90 + qpdf, getDescription() + " -> dictionary key " + key);
93 } 91 }
94 return null; 92 return null;
95 } 93 }
libqpdf/QPDF_Stream.cc
@@ -292,12 +292,9 @@ QPDF_Stream::setDescription( @@ -292,12 +292,9 @@ QPDF_Stream::setDescription(
292 void 292 void
293 QPDF_Stream::setDictDescription() 293 QPDF_Stream::setDictDescription()
294 { 294 {
295 - QPDF* qpdf = nullptr;  
296 - std::string description;  
297 - if ((!this->stream_dict.hasObjectDescription()) &&  
298 - getDescription(qpdf, description)) { 295 + if (!this->stream_dict.hasObjectDescription()) {
299 this->stream_dict.setObjectDescription( 296 this->stream_dict.setObjectDescription(
300 - qpdf, description + " -> stream dictionary"); 297 + qpdf, getDescription() + " -> stream dictionary");
301 } 298 }
302 } 299 }
303 300
libqpdf/qpdf/QPDFObject_private.hh
@@ -79,7 +79,9 @@ class QPDFObject @@ -79,7 +79,9 @@ class QPDFObject
79 bool 79 bool
80 getDescription(QPDF*& qpdf, std::string& description) 80 getDescription(QPDF*& qpdf, std::string& description)
81 { 81 {
82 - return value->getDescription(qpdf, description); 82 + qpdf = value->qpdf;
  83 + description = value->getDescription();
  84 + return qpdf != nullptr;
83 } 85 }
84 bool 86 bool
85 hasDescription() 87 hasDescription()
libqpdf/qpdf/QPDFValue.hh
@@ -44,11 +44,10 @@ class QPDFValue @@ -44,11 +44,10 @@ class QPDFValue
44 qpdf = a_qpdf; 44 qpdf = a_qpdf;
45 og = a_og; 45 og = a_og;
46 } 46 }
47 - bool  
48 - getDescription(QPDF*& qpdf_p, std::string& description) 47 + std::string
  48 + getDescription()
49 { 49 {
50 - qpdf_p = qpdf;  
51 - description = object_description ? *object_description : ""; 50 + auto description = object_description ? *object_description : "";
52 if (auto pos = description.find("$OG"); pos != std::string::npos) { 51 if (auto pos = description.find("$OG"); pos != std::string::npos) {
53 description.replace(pos, 3, og.unparse(' ')); 52 description.replace(pos, 3, og.unparse(' '));
54 } 53 }
@@ -59,7 +58,7 @@ class QPDFValue @@ -59,7 +58,7 @@ class QPDFValue
59 58
60 description.replace(pos, 3, std::to_string(parsed_offset + shift)); 59 description.replace(pos, 3, std::to_string(parsed_offset + shift));
61 } 60 }
62 - return qpdf != nullptr; 61 + return description;
63 } 62 }
64 bool 63 bool
65 hasDescription() 64 hasDescription()