diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc index e4c40e5..113e98d 100644 --- a/libqpdf/QPDFFormFieldObjectHelper.cc +++ b/libqpdf/QPDFFormFieldObjectHelper.cc @@ -281,7 +281,7 @@ QPDFFormFieldObjectHelper::getChoices() for (auto const& item: getInheritableFieldValue("/Opt").as_array()) { if (item.isString()) { result.emplace_back(item.getUTF8Value()); - } else if (item.isArray() && item.getArrayNItems() == 2) { + } else if (item.size() == 2) { auto display = item.getArrayItem(1); if (display.isString()) { result.emplace_back(display.getUTF8Value()); diff --git a/libqpdf/QPDFOutlineObjectHelper.cc b/libqpdf/QPDFOutlineObjectHelper.cc index 8d561f8..640826a 100644 --- a/libqpdf/QPDFOutlineObjectHelper.cc +++ b/libqpdf/QPDFOutlineObjectHelper.cc @@ -75,7 +75,7 @@ QPDFObjectHandle QPDFOutlineObjectHelper::getDestPage() { QPDFObjectHandle dest = getDest(); - if ((dest.isArray()) && (dest.getArrayNItems() > 0)) { + if (!dest.empty() && dest.isArray()) { return dest.getArrayItem(0); } return QPDFObjectHandle::newNull(); diff --git a/libqpdf/QPDFPageObjectHelper.cc b/libqpdf/QPDFPageObjectHelper.cc index b4fa720..1a0098c 100644 --- a/libqpdf/QPDFPageObjectHelper.cc +++ b/libqpdf/QPDFPageObjectHelper.cc @@ -445,14 +445,9 @@ std::vector QPDFPageObjectHelper::getAnnotations(std::string const& only_subtype) { std::vector result; - QPDFObjectHandle annots = oh().getKey("/Annots"); - if (annots.isArray()) { - int nannots = annots.getArrayNItems(); - for (int i = 0; i < nannots; ++i) { - QPDFObjectHandle annot = annots.getArrayItem(i); - if (annot.isDictionaryOfType("", only_subtype)) { - result.emplace_back(annot); - } + for (auto const& annot: oh().getKey("/Annots").as_array()) { + if (annot.isDictionaryOfType("", only_subtype)) { + result.emplace_back(annot); } } return result;