Commit 6350cf16e622d12ec2f68d0aa39132731dc7c73f

Authored by m-holger
Committed by Jay Berkenbilt
1 parent 3a86b893

Remove QPDF_Stream::offset

libqpdf/QPDF.cc
... ... @@ -1534,10 +1534,9 @@ QPDF::readObject(
1534 1534 throw e;
1535 1535 }
1536 1536 }
1537   - auto stream =
1538   - QPDF_Stream::create(this, og, object, stream_offset, length);
1539   - stream->setParsedOffset(stream_offset);
1540   - object = newIndirect(og, stream);
  1537 + object = newIndirect(
  1538 + og,
  1539 + QPDF_Stream::create(this, og, object, stream_offset, length));
1541 1540 } else {
1542 1541 input->seek(cur_offset, SEEK_SET);
1543 1542 }
... ...
libqpdf/QPDF_Stream.cc
... ... @@ -117,7 +117,6 @@ QPDF_Stream::QPDF_Stream(
117 117 QPDFValue(::ot_stream, "stream"),
118 118 filter_on_write(true),
119 119 stream_dict(stream_dict),
120   - offset(offset),
121 120 length(length)
122 121 {
123 122 if (!stream_dict.isDictionary()) {
... ... @@ -126,6 +125,7 @@ QPDF_Stream::QPDF_Stream(
126 125 }
127 126 setDescription(
128 127 qpdf, qpdf->getFilename() + ", stream object " + og.unparse(' '));
  128 + this->parsed_offset = offset;
129 129 }
130 130  
131 131 std::shared_ptr<QPDFObject>
... ... @@ -325,7 +325,7 @@ QPDF_Stream::isDataModified() const
325 325 qpdf_offset_t
326 326 QPDF_Stream::getOffset() const
327 327 {
328   - return this->offset;
  328 + return this->parsed_offset;
329 329 }
330 330  
331 331 size_t
... ... @@ -357,7 +357,7 @@ QPDF_Stream::getStreamData(qpdf_stream_decode_level_e decode_level)
357 357 qpdf_e_unsupported,
358 358 qpdf->getFilename(),
359 359 "",
360   - this->offset,
  360 + this->parsed_offset,
361 361 "getStreamData called on unfilterable stream");
362 362 }
363 363 QTC::TC("qpdf", "QPDF_Stream getStreamData");
... ... @@ -373,7 +373,7 @@ QPDF_Stream::getRawStreamData()
373 373 qpdf_e_unsupported,
374 374 qpdf->getFilename(),
375 375 "",
376   - this->offset,
  376 + this->parsed_offset,
377 377 "error getting raw stream data");
378 378 }
379 379 QTC::TC("qpdf", "QPDF_Stream getRawStreamData");
... ... @@ -618,7 +618,7 @@ QPDF_Stream::pipeStreamData(
618 618 this->stream_dict.replaceKey(
619 619 "/Length", QPDFObjectHandle::newInteger(actual_length));
620 620 }
621   - } else if (this->offset == 0) {
  621 + } else if (this->parsed_offset == 0) {
622 622 QTC::TC("qpdf", "QPDF_Stream pipe no stream data");
623 623 throw std::logic_error("pipeStreamData called for stream with no data");
624 624 } else {
... ... @@ -626,7 +626,7 @@ QPDF_Stream::pipeStreamData(
626 626 if (!QPDF::Pipe::pipeStreamData(
627 627 this->qpdf,
628 628 og,
629   - this->offset,
  629 + this->parsed_offset,
630 630 this->length,
631 631 this->stream_dict,
632 632 pipeline,
... ... @@ -716,5 +716,5 @@ QPDF_Stream::replaceDict(QPDFObjectHandle const&amp; new_dict)
716 716 void
717 717 QPDF_Stream::warn(std::string const& message)
718 718 {
719   - this->qpdf->warn(qpdf_e_damaged_pdf, "", this->offset, message);
  719 + this->qpdf->warn(qpdf_e_damaged_pdf, "", this->parsed_offset, message);
720 720 }
... ...
libqpdf/qpdf/QPDFValue.hh
... ... @@ -69,11 +69,8 @@ class QPDFValue
69 69 }
70 70  
71 71 protected:
72   - QPDFValue() :
73   - type_code(::ot_uninitialized),
74   - type_name("uninitialized")
75   - {
76   - }
  72 + QPDFValue() = default;
  73 +
77 74 QPDFValue(qpdf_object_type_e type_code, char const* type_name) :
78 75 type_code(type_code),
79 76 type_name(type_name)
... ... @@ -97,13 +94,14 @@ class QPDFValue
97 94 QPDFValue(QPDFValue const&) = delete;
98 95 QPDFValue& operator=(QPDFValue const&) = delete;
99 96 std::string object_description;
100   - qpdf_offset_t parsed_offset{-1};
101   - const qpdf_object_type_e type_code;
102   - char const* type_name;
  97 +
  98 + const qpdf_object_type_e type_code{::ot_uninitialized};
  99 + char const* type_name{"uninitialized"};
103 100  
104 101 protected:
105 102 QPDF* qpdf{nullptr};
106   - QPDFObjGen og;
  103 + QPDFObjGen og{};
  104 + qpdf_offset_t parsed_offset{-1};
107 105 };
108 106  
109 107 #endif // QPDFVALUE_HH
... ...
libqpdf/qpdf/QPDF_Stream.hh
... ... @@ -103,7 +103,6 @@ class QPDF_Stream: public QPDFValue
103 103  
104 104 bool filter_on_write;
105 105 QPDFObjectHandle stream_dict;
106   - qpdf_offset_t offset;
107 106 size_t length;
108 107 std::shared_ptr<Buffer> stream_data;
109 108 std::shared_ptr<QPDFObjectHandle::StreamDataProvider> stream_provider;
... ...