Commit ca24c235b40b72992c3bd4b26fa83fe40664aeed
Committed by
GitHub
Merge pull request #1579 from m-holger/streams
Refactor Stream factories
Showing
2 changed files
with
6 additions
and
6 deletions
libqpdf/QPDF.cc
| ... | ... | @@ -376,7 +376,7 @@ QPDFObjectHandle |
| 376 | 376 | QPDF::newStream(std::shared_ptr<Buffer> data) |
| 377 | 377 | { |
| 378 | 378 | auto result = newStream(); |
| 379 | - result.replaceStreamData(data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | |
| 379 | + result.replaceStreamData(data, {}, {}); | |
| 380 | 380 | return result; |
| 381 | 381 | } |
| 382 | 382 | |
| ... | ... | @@ -384,14 +384,14 @@ QPDFObjectHandle |
| 384 | 384 | QPDF::newStream(std::string const& data) |
| 385 | 385 | { |
| 386 | 386 | auto result = newStream(); |
| 387 | - result.replaceStreamData(data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); | |
| 387 | + result.replaceStreamData(data, {}, {}); | |
| 388 | 388 | return result; |
| 389 | 389 | } |
| 390 | 390 | |
| 391 | 391 | QPDFObjectHandle |
| 392 | 392 | QPDF::getObject(int objid, int generation) |
| 393 | 393 | { |
| 394 | - return getObject(QPDFObjGen(objid, generation)); | |
| 394 | + return getObject({objid, generation}); | |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | QPDFObjectHandle | ... | ... |
libqpdf/QPDF_Stream.cc
| ... | ... | @@ -311,9 +311,9 @@ Stream::copy_data_to(Stream& dest) |
| 311 | 311 | if (qpdf()->doc().config().immediate_copy_from() && !s->stream_data) { |
| 312 | 312 | // Pull the stream data into a buffer before attempting the copy operation. Do it on the |
| 313 | 313 | // source stream so that if the source stream is copied multiple times, we don't have to |
| 314 | - // keep duplicating the memory. | |
| 315 | - replaceStreamData( | |
| 316 | - getRawStreamData(), s->stream_dict["/Filter"], s->stream_dict["/DecodeParms"]); | |
| 314 | + // keep duplicating the memory. Passing uninitialised object handles will preserve the | |
| 315 | + // existing filters and decode parameters. | |
| 316 | + replaceStreamData(getRawStreamData(), {}, {}); | |
| 317 | 317 | } |
| 318 | 318 | if (s->stream_data) { |
| 319 | 319 | dest.replaceStreamData(s->stream_data, dict["/Filter"], dict["/DecodeParms"]); | ... | ... |