summaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDF.cc
diff options
context:
space:
mode:
authorm-holger <m-holger@kubitscheck.org>2022-01-26 09:00:23 +0100
committerJay Berkenbilt <jberkenbilt@users.noreply.github.com>2022-01-27 14:31:12 +0100
commit07db3200cb0ef058b8a66ece8d9757adfba49fd1 (patch)
tree084c94a5778581451bb42e5cd38fffeb36a12e2b /libqpdf/QPDF.cc
parent710d2e54f0762b7702640766d33b7e0977ba69de (diff)
downloadqpdf-07db3200cb0ef058b8a66ece8d9757adfba49fd1.tar.zst
Remove some if statements and simplify some boolean expressions
Use QPDFObjectHandle::isNameAndEquals, isDictionaryOfType and isStreamOfType.
Diffstat (limited to 'libqpdf/QPDF.cc')
-rw-r--r--libqpdf/QPDF.cc17
1 files changed, 5 insertions, 12 deletions
diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc
index b90c213e..7f6f7801 100644
--- a/libqpdf/QPDF.cc
+++ b/libqpdf/QPDF.cc
@@ -1100,10 +1100,7 @@ QPDF::read_xrefStream(qpdf_offset_t xref_offset)
{
// ignore -- report error below
}
- if (xref_obj.isInitialized() &&
- xref_obj.isStream() &&
- xref_obj.getDict().getKey("/Type").isName() &&
- xref_obj.getDict().getKey("/Type").getName() == "/XRef")
+ if (xref_obj.isStreamOfType("/XRef"))
{
QTC::TC("qpdf", "QPDF found xref stream");
found = true;
@@ -2202,8 +2199,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
this->m->obj_cache[stream_og].end_after_space;
QPDFObjectHandle dict = obj_stream.getDict();
- if (! (dict.getKey("/Type").isName() &&
- dict.getKey("/Type").getName() == "/ObjStm"))
+ if (! dict.isDictionaryOfType("/ObjStm"))
{
QTC::TC("qpdf", "QPDF ERR object stream with wrong type");
warn(QPDFExc(qpdf_e_damaged_pdf, this->m->file->getName(),
@@ -2849,13 +2845,10 @@ QPDF::getCompressibleObjGens()
{
QTC::TC("qpdf", "QPDF exclude encryption dictionary");
}
- else if ((! obj.isStream()) &&
- (! (obj.isDictionary() &&
+ else if (! (obj.isStream() ||
+ (obj.isDictionaryOfType("/Sig") &&
obj.hasKey("/ByteRange") &&
- obj.hasKey("/Contents") &&
- obj.hasKey("/Type") &&
- obj.getKey("/Type").isName() &&
- obj.getKey("/Type").getName() == "/Sig")))
+ obj.hasKey("/Contents"))))
{
result.push_back(og);
}