diff options
author | Jay Berkenbilt <jberkenbilt@users.noreply.github.com> | 2022-07-24 20:41:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-24 20:41:33 +0200 |
commit | 5696a507b6dacf34d066810a3f2fca3525eb02f5 (patch) | |
tree | b0009760e0f76c28aa99581e4bc6087adf93749f /libqpdf/QPDF_Stream.cc | |
parent | 6f1041afb8e6d1f57169cd4c79f42a7c1ce94da8 (diff) | |
parent | 8b4afa428e9caa1a34cad434dfe8a3e01e5a24d3 (diff) | |
download | qpdf-5696a507b6dacf34d066810a3f2fca3525eb02f5.tar.zst |
Merge pull request #731 from m-holger/og_unparse
Tidy QPDFObjGen related code
Diffstat (limited to 'libqpdf/QPDF_Stream.cc')
-rw-r--r-- | libqpdf/QPDF_Stream.cc | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc index 0b06a7f5..84965102 100644 --- a/libqpdf/QPDF_Stream.cc +++ b/libqpdf/QPDF_Stream.cc @@ -110,14 +110,12 @@ StreamBlobProvider::operator()(Pipeline* p) QPDF_Stream::QPDF_Stream( QPDF* qpdf, - int objid, - int generation, + QPDFObjGen const& og, QPDFObjectHandle stream_dict, qpdf_offset_t offset, size_t length) : qpdf(qpdf), - objid(objid), - generation(generation), + og(og), filter_on_write(true), stream_dict(stream_dict), offset(offset), @@ -128,23 +126,18 @@ QPDF_Stream::QPDF_Stream( "object for dictionary"); } setDescription( - this->qpdf, - this->qpdf->getFilename() + ", stream object " + - QUtil::int_to_string(this->objid) + " " + - QUtil::int_to_string(this->generation)); + qpdf, qpdf->getFilename() + ", stream object " + og.unparse(' ')); } std::shared_ptr<QPDFObject> QPDF_Stream::create( QPDF* qpdf, - int objid, - int generation, + QPDFObjGen const& og, QPDFObjectHandle stream_dict, qpdf_offset_t offset, size_t length) { - return do_create( - new QPDF_Stream(qpdf, objid, generation, stream_dict, offset, length)); + return do_create(new QPDF_Stream(qpdf, og, stream_dict, offset, length)); } std::shared_ptr<QPDFObject> @@ -181,23 +174,21 @@ QPDF_Stream::releaseResolved() } void -QPDF_Stream::setObjGen(int objid, int generation) +QPDF_Stream::setObjGen(QPDFObjGen const& og) { - if (!((this->objid == 0) && (this->generation == 0))) { + if (this->og.isIndirect()) { throw std::logic_error( "attempt to set object ID and generation of a stream" " that already has them"); } - this->objid = objid; - this->generation = generation; + this->og = og; } std::string QPDF_Stream::unparse() { // Unparse stream objects as indirect references - return QUtil::int_to_string(this->objid) + " " + - QUtil::int_to_string(this->generation) + " R"; + return og.unparse(' ') + " R"; } JSON @@ -619,17 +610,12 @@ QPDF_Stream::pipeStreamData( Pl_Count count("stream provider count", pipeline); if (this->stream_provider->supportsRetry()) { if (!this->stream_provider->provideStreamData( - this->objid, - this->generation, - &count, - suppress_warnings, - will_retry)) { + og, &count, suppress_warnings, will_retry)) { filter = false; success = false; } } else { - this->stream_provider->provideStreamData( - this->objid, this->generation, &count); + this->stream_provider->provideStreamData(og, &count); } qpdf_offset_t actual_length = count.getCount(); qpdf_offset_t desired_length = 0; @@ -642,10 +628,8 @@ QPDF_Stream::pipeStreamData( // This would be caused by programmer error on the // part of a library user, not by invalid input data. throw std::runtime_error( - "stream data provider for " + - QUtil::int_to_string(this->objid) + " " + - QUtil::int_to_string(this->generation) + " provided " + - QUtil::int_to_string(actual_length) + + "stream data provider for " + og.unparse(' ') + + " provided " + QUtil::int_to_string(actual_length) + " bytes instead of expected " + QUtil::int_to_string(desired_length) + " bytes"); } @@ -661,8 +645,7 @@ QPDF_Stream::pipeStreamData( QTC::TC("qpdf", "QPDF_Stream pipe original stream data"); if (!QPDF::Pipe::pipeStreamData( this->qpdf, - this->objid, - this->generation, + og, this->offset, this->length, this->stream_dict, |