From 6c69a747b9f7a801be2ad58985f35886bd38239e Mon Sep 17 00:00:00 2001 From: m-holger Date: Sat, 21 May 2022 15:18:15 +0100 Subject: Code clean up: use range-style for loops wherever possible Remove variables obsoleted by commit 4f24617. --- examples/pdf-filter-tokens.cc | 4 +--- examples/pdf-invert-images.cc | 7 ++----- examples/pdf-overlay-page.cc | 4 +--- examples/pdf-set-form-values.cc | 8 ++------ 4 files changed, 6 insertions(+), 17 deletions(-) (limited to 'examples') diff --git a/examples/pdf-filter-tokens.cc b/examples/pdf-filter-tokens.cc index 3d4bad8b..ccacc8c2 100644 --- a/examples/pdf-filter-tokens.cc +++ b/examples/pdf-filter-tokens.cc @@ -191,9 +191,7 @@ main(int argc, char* argv[]) try { QPDF pdf; pdf.processFile(infilename); - std::vector pages = - QPDFPageDocumentHelper(pdf).getAllPages(); - for (auto& page: pages) { + for (auto& page: QPDFPageDocumentHelper(pdf).getAllPages()) { // Attach two token filters to each page of this file. // When the file is written, or when the pages' contents // are retrieved in any other way, the filters will be diff --git a/examples/pdf-invert-images.cc b/examples/pdf-invert-images.cc index b784c8e3..2c9a88e7 100644 --- a/examples/pdf-invert-images.cc +++ b/examples/pdf-invert-images.cc @@ -129,12 +129,9 @@ main(int argc, char* argv[]) auto p = std::shared_ptr(inv); // For each page... - std::vector pages = - QPDFPageDocumentHelper(qpdf).getAllPages(); - for (auto& page: pages) { + for (auto& page: QPDFPageDocumentHelper(qpdf).getAllPages()) { // Get all images on the page. - std::map images = page.getImages(); - for (auto& iter: images) { + for (auto& iter: page.getImages()) { QPDFObjectHandle& image = iter.second; QPDFObjectHandle image_dict = image.getDict(); QPDFObjectHandle color_space = image_dict.getKey("/ColorSpace"); diff --git a/examples/pdf-overlay-page.cc b/examples/pdf-overlay-page.cc index f9603d9c..594f139e 100644 --- a/examples/pdf-overlay-page.cc +++ b/examples/pdf-overlay-page.cc @@ -40,9 +40,7 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile) QPDFObjectHandle stamp_fo = inpdf.copyForeignObject(foreign_fo); // For each page... - std::vector pages = - QPDFPageDocumentHelper(inpdf).getAllPages(); - for (auto& ph: pages) { + for (auto& ph: QPDFPageDocumentHelper(inpdf).getAllPages()) { // Find a unique resource name for the new form XObject QPDFObjectHandle resources = ph.getAttribute("/Resources", true); int min_suffix = 1; diff --git a/examples/pdf-set-form-values.cc b/examples/pdf-set-form-values.cc index c28149ad..cc328cf3 100644 --- a/examples/pdf-set-form-values.cc +++ b/examples/pdf-set-form-values.cc @@ -50,15 +50,11 @@ main(int argc, char* argv[]) // illustrates how we can map from annotations to fields. QPDFAcroFormDocumentHelper afdh(qpdf); - QPDFPageDocumentHelper pdh(qpdf); - std::vector pages = pdh.getAllPages(); - for (auto const& page: pages) { + for (auto const& page: QPDFPageDocumentHelper(qpdf).getAllPages()) { // Get all widget annotations for each page. Widget // annotations are the ones that contain the details of // what's in a form field. - std::vector annotations = - afdh.getWidgetAnnotationsForPage(page); - for (auto& annot: annotations) { + for (auto& annot: afdh.getWidgetAnnotationsForPage(page)) { // For each annotation, find its associated field. If // it's a text field, set its value. QPDFFormFieldObjectHelper ffh = -- cgit v1.2.3-54-g00ecf