From 4cfe44a4186b54494b7370e247295cd47a3fd158 Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 6 Sep 2025 16:34:10 +0100 Subject: [PATCH] Refactor `QPDF_Stream`: replace `getKey` and `getName` with `Name`, `Dictionary`, and `Array` for improved clarity and consistency, and simplify `/Filter` and `/DecodeParms` handling. --- libqpdf/QPDF_Stream.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libqpdf/QPDF_Stream.cc b/libqpdf/QPDF_Stream.cc index 73a9b38..558b542 100644 --- a/libqpdf/QPDF_Stream.cc +++ b/libqpdf/QPDF_Stream.cc @@ -38,11 +38,10 @@ namespace setDecodeParms(QPDFObjectHandle decode_parms) final { // we only validate here - processing happens in decryptStream - if (auto dict = decode_parms.as_dictionary(optional)) { + if (Dictionary dict = decode_parms) { for (auto const& [key, value]: dict) { if (key == "/Type" && - (value.null() || - (value.isName() && value.getName() == "/CryptFilterDecodeParms"))) { + (value.null() || Name(value) == "/CryptFilterDecodeParms")) { continue; } if (key == "/Name") { @@ -54,7 +53,7 @@ namespace } return true; } - return false; + return decode_parms.null(); } Pipeline* @@ -374,7 +373,7 @@ Stream::filterable( auto s = stream(); // Check filters - auto filter_obj = s->stream_dict.getKey("/Filter"); + auto const& filter_obj = s->stream_dict["/Filter"]; if (filter_obj.null()) { // No filters @@ -387,14 +386,14 @@ Stream::filterable( return false; } filters.emplace_back(ff()); - } else if (auto array = filter_obj.as_array(strict)) { + } else if (Array array = filter_obj) { // Potentially multiple filters - for (auto const& item: array) { - if (!item.isName()) { + for (Name item: array) { + if (!item) { warn("stream filter type is not name or array"); return false; } - auto ff = s->filter_factory(item.getName()); + auto ff = s->filter_factory(item); if (!ff) { filters.clear(); return false; -- libgit2 0.21.4