Commit 4cfe44a4186b54494b7370e247295cd47a3fd158

Authored by m-holger
1 parent 78fc0d1b

Refactor `QPDF_Stream`: replace `getKey` and `getName` with `Name`, `Dictionary`…

…, and `Array` for improved clarity and consistency, and simplify `/Filter` and `/DecodeParms` handling.
Showing 1 changed file with 8 additions and 9 deletions
libqpdf/QPDF_Stream.cc
... ... @@ -38,11 +38,10 @@ namespace
38 38 setDecodeParms(QPDFObjectHandle decode_parms) final
39 39 {
40 40 // we only validate here - processing happens in decryptStream
41   - if (auto dict = decode_parms.as_dictionary(optional)) {
  41 + if (Dictionary dict = decode_parms) {
42 42 for (auto const& [key, value]: dict) {
43 43 if (key == "/Type" &&
44   - (value.null() ||
45   - (value.isName() && value.getName() == "/CryptFilterDecodeParms"))) {
  44 + (value.null() || Name(value) == "/CryptFilterDecodeParms")) {
46 45 continue;
47 46 }
48 47 if (key == "/Name") {
... ... @@ -54,7 +53,7 @@ namespace
54 53 }
55 54 return true;
56 55 }
57   - return false;
  56 + return decode_parms.null();
58 57 }
59 58  
60 59 Pipeline*
... ... @@ -374,7 +373,7 @@ Stream::filterable(
374 373 auto s = stream();
375 374 // Check filters
376 375  
377   - auto filter_obj = s->stream_dict.getKey("/Filter");
  376 + auto const& filter_obj = s->stream_dict["/Filter"];
378 377  
379 378 if (filter_obj.null()) {
380 379 // No filters
... ... @@ -387,14 +386,14 @@ Stream::filterable(
387 386 return false;
388 387 }
389 388 filters.emplace_back(ff());
390   - } else if (auto array = filter_obj.as_array(strict)) {
  389 + } else if (Array array = filter_obj) {
391 390 // Potentially multiple filters
392   - for (auto const& item: array) {
393   - if (!item.isName()) {
  391 + for (Name item: array) {
  392 + if (!item) {
394 393 warn("stream filter type is not name or array");
395 394 return false;
396 395 }
397   - auto ff = s->filter_factory(item.getName());
  396 + auto ff = s->filter_factory(item);
398 397 if (!ff) {
399 398 filters.clear();
400 399 return false;
... ...