From 710d2e54f0762b7702640766d33b7e0977ba69de Mon Sep 17 00:00:00 2001 From: m-holger Date: Wed, 26 Jan 2022 01:28:53 +0000 Subject: Allow testing for subtype without specifying type in isDictionaryOfType etc Accept empty string as type parameter in QPDFObjectHandle::isDictionaryOfType and isStreamOfType to allow for dictionaries with optional type. --- libqpdf/QPDFObjectHandle.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFObjectHandle.cc b/libqpdf/QPDFObjectHandle.cc index f2c77dca..2713eb95 100644 --- a/libqpdf/QPDFObjectHandle.cc +++ b/libqpdf/QPDFObjectHandle.cc @@ -507,15 +507,9 @@ bool QPDFObjectHandle::isDictionaryOfType(std::string const& type, std::string const& subtype) { - if (isDictionary() && getKey("/Type").isNameAndEquals(type)) - { - return (subtype == "") || - (hasKey("/Subtype") && getKey("/Subtype").isNameAndEquals(subtype)); - } - else - { - return false; - } + return isDictionary() && + (type.empty() || getKey("/Type").isNameAndEquals(type)) && + (subtype.empty() || getKey("/Subtype").isNameAndEquals(subtype)); } bool -- cgit v1.2.3-54-g00ecf