mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-15 17:17:08 +00:00
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.
This commit is contained in:
parent
823926f8bf
commit
710d2e54f0
@ -507,15 +507,9 @@ bool
|
|||||||
QPDFObjectHandle::isDictionaryOfType(std::string const& type,
|
QPDFObjectHandle::isDictionaryOfType(std::string const& type,
|
||||||
std::string const& subtype)
|
std::string const& subtype)
|
||||||
{
|
{
|
||||||
if (isDictionary() && getKey("/Type").isNameAndEquals(type))
|
return isDictionary() &&
|
||||||
{
|
(type.empty() || getKey("/Type").isNameAndEquals(type)) &&
|
||||||
return (subtype == "") ||
|
(subtype.empty() || getKey("/Subtype").isNameAndEquals(subtype));
|
||||||
(hasKey("/Subtype") && getKey("/Subtype").isNameAndEquals(subtype));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -724,7 +724,7 @@ static void test25(char const* infile,
|
|||||||
assert(qpdf_oh_is_dictionary_of_type(qpdf, new_dict, "/Test", "/Marvin"));
|
assert(qpdf_oh_is_dictionary_of_type(qpdf, new_dict, "/Test", "/Marvin"));
|
||||||
assert(! qpdf_oh_is_dictionary_of_type(qpdf, new_dict, "/Test2", ""));
|
assert(! qpdf_oh_is_dictionary_of_type(qpdf, new_dict, "/Test2", ""));
|
||||||
assert(! qpdf_oh_is_dictionary_of_type(qpdf, new_dict, "/Test", "/M"));
|
assert(! qpdf_oh_is_dictionary_of_type(qpdf, new_dict, "/Test", "/M"));
|
||||||
assert(! qpdf_oh_is_dictionary_of_type(qpdf, new_dict, "", ""));
|
assert(qpdf_oh_is_dictionary_of_type(qpdf, new_dict, "", ""));
|
||||||
qpdf_oh new_array = qpdf_oh_new_array(qpdf);
|
qpdf_oh new_array = qpdf_oh_new_array(qpdf);
|
||||||
qpdf_oh_replace_or_remove_key(
|
qpdf_oh_replace_or_remove_key(
|
||||||
qpdf, new_dict, "/A", qpdf_oh_new_null(qpdf));
|
qpdf, new_dict, "/A", qpdf_oh_new_null(qpdf));
|
||||||
|
@ -3110,11 +3110,12 @@ static void test_82(QPDF& pdf, char const* arg2)
|
|||||||
assert(dict.isDictionaryOfType( "/Test", ""));
|
assert(dict.isDictionaryOfType( "/Test", ""));
|
||||||
assert(dict.isDictionaryOfType("/Test"));
|
assert(dict.isDictionaryOfType("/Test"));
|
||||||
assert(dict.isDictionaryOfType("/Test", "/Marvin"));
|
assert(dict.isDictionaryOfType("/Test", "/Marvin"));
|
||||||
|
assert(dict.isDictionaryOfType("", "/Marvin"));
|
||||||
|
assert(dict.isDictionaryOfType("", ""));
|
||||||
assert(! dict.isDictionaryOfType("/Test2", ""));
|
assert(! dict.isDictionaryOfType("/Test2", ""));
|
||||||
assert(! dict.isDictionaryOfType("/Test2", "/Marvin"));
|
assert(! dict.isDictionaryOfType("/Test2", "/Marvin"));
|
||||||
assert(! dict.isDictionaryOfType("/Test", "/M"));
|
assert(! dict.isDictionaryOfType("/Test", "/M"));
|
||||||
assert(! dict.isDictionaryOfType("", "/Marvin"));
|
assert(! name.isDictionaryOfType("", ""));
|
||||||
assert(! dict.isDictionaryOfType("", ""));
|
|
||||||
dict = QPDFObjectHandle::parse("<</A 1 /Type null /Subtype /Marvin>>");
|
dict = QPDFObjectHandle::parse("<</A 1 /Type null /Subtype /Marvin>>");
|
||||||
assert(! dict.isDictionaryOfType("/Test"));
|
assert(! dict.isDictionaryOfType("/Test"));
|
||||||
dict = QPDFObjectHandle::parse("<</A 1 /Type (Test) /Subtype /Marvin>>");
|
dict = QPDFObjectHandle::parse("<</A 1 /Type (Test) /Subtype /Marvin>>");
|
||||||
|
Loading…
Reference in New Issue
Block a user