aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFAcroFormDocumentHelper.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-30 19:23:18 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-30 19:27:18 +0200
commit4f24617e1ea4ba7a6627a9c44304c6e0a0114249 (patch)
tree65c02e9e31cac60bac6f6aec165e8397dcde70e2 /libqpdf/QPDFAcroFormDocumentHelper.cc
parent7f023701dd843749cf878baabeb3d33917fda62f (diff)
downloadqpdf-4f24617e1ea4ba7a6627a9c44304c6e0a0114249.tar.zst
Code clean up: use range-style for loops wherever possible
Where not possible, use "auto" to get the iterator type. Editorial note: I have avoid this change for a long time because of not wanting to make gratuitous changes to version history, which can obscure when certain changes were made, but with having recently touched every single file to apply automatic code formatting and with making several broad changes to the API, I decided it was time to take the plunge and get rid of the older (pre-C++11) verbose iterator syntax. The new code is just easier to read and understand, and in many cases, it will be more effecient as fewer temporary copies are being made. m-holger, if you're reading, you can see that I've finally come around. :-)
Diffstat (limited to 'libqpdf/QPDFAcroFormDocumentHelper.cc')
-rw-r--r--libqpdf/QPDFAcroFormDocumentHelper.cc31
1 files changed, 8 insertions, 23 deletions
diff --git a/libqpdf/QPDFAcroFormDocumentHelper.cc b/libqpdf/QPDFAcroFormDocumentHelper.cc
index 435c7666..4e9f08b9 100644
--- a/libqpdf/QPDFAcroFormDocumentHelper.cc
+++ b/libqpdf/QPDFAcroFormDocumentHelper.cc
@@ -182,11 +182,8 @@ QPDFAcroFormDocumentHelper::getFormFields()
{
analyze();
std::vector<QPDFFormFieldObjectHelper> result;
- for (std::map<QPDFObjGen, std::vector<QPDFAnnotationObjectHelper>>::iterator
- iter = this->m->field_to_annotations.begin();
- iter != this->m->field_to_annotations.end();
- ++iter) {
- result.push_back(this->qpdf.getObjectByObjGen((*iter).first));
+ for (auto const& iter: this->m->field_to_annotations) {
+ result.push_back(this->qpdf.getObjectByObjGen(iter.first));
}
return result;
}
@@ -299,17 +296,11 @@ QPDFAcroFormDocumentHelper::analyze()
QPDFPageDocumentHelper dh(this->qpdf);
std::vector<QPDFPageObjectHelper> pages = dh.getAllPages();
- for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
- iter != pages.end();
- ++iter) {
- QPDFPageObjectHelper ph(*iter);
+ for (auto const& ph: pages) {
std::vector<QPDFAnnotationObjectHelper> annots =
getWidgetAnnotationsForPage(ph);
- for (std::vector<QPDFAnnotationObjectHelper>::iterator i2 =
- annots.begin();
- i2 != annots.end();
- ++i2) {
- QPDFObjectHandle annot((*i2).getObjectHandle());
+ for (auto const& iter: annots) {
+ QPDFObjectHandle annot(iter.getObjectHandle());
QPDFObjGen og(annot.getObjGen());
if (this->m->annotation_to_field.count(og) == 0) {
QTC::TC("qpdf", "QPDFAcroFormDocumentHelper orphaned widget");
@@ -462,16 +453,10 @@ QPDFAcroFormDocumentHelper::generateAppearancesIfNeeded()
QPDFPageDocumentHelper pdh(this->qpdf);
std::vector<QPDFPageObjectHelper> pages = pdh.getAllPages();
- for (std::vector<QPDFPageObjectHelper>::iterator page_iter = pages.begin();
- page_iter != pages.end();
- ++page_iter) {
+ for (auto const& page: pages) {
std::vector<QPDFAnnotationObjectHelper> annotations =
- getWidgetAnnotationsForPage(*page_iter);
- for (std::vector<QPDFAnnotationObjectHelper>::iterator annot_iter =
- annotations.begin();
- annot_iter != annotations.end();
- ++annot_iter) {
- QPDFAnnotationObjectHelper& aoh = *annot_iter;
+ getWidgetAnnotationsForPage(page);
+ for (auto& aoh: annotations) {
QPDFFormFieldObjectHelper ffh = getFieldForAnnotation(aoh);
if (ffh.getFieldType() == "/Btn") {
// Rather than generating appearances for button