From 12f1eb15ca3fed6310402847559a7c99d3c77847 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 2 Apr 2022 17:14:10 -0400 Subject: Programmatically apply new formatting to code Run this: for i in **/*.cc **/*.c **/*.h **/*.hh; do clang-format < $i >| $i.new && mv $i.new $i done --- examples/pdf-set-form-values.cc | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) (limited to 'examples/pdf-set-form-values.cc') diff --git a/examples/pdf-set-form-values.cc b/examples/pdf-set-form-values.cc index eab24e4f..10394c7b 100644 --- a/examples/pdf-set-form-values.cc +++ b/examples/pdf-set-form-values.cc @@ -1,16 +1,17 @@ -#include -#include -#include -#include #include -#include #include +#include #include #include +#include +#include +#include +#include static char const* whoami = 0; -void usage() +void +usage() { std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf value" << std::endl @@ -19,13 +20,12 @@ void usage() exit(2); } - -int main(int argc, char* argv[]) +int +main(int argc, char* argv[]) { whoami = QUtil::getWhoami(argv[0]); - if (argc != 4) - { + if (argc != 4) { usage(); } @@ -39,8 +39,7 @@ int main(int argc, char* argv[]) // to illustrate use of the helper classes around interactive // forms. - try - { + try { QPDF qpdf; qpdf.processFile(infilename); @@ -55,8 +54,8 @@ int main(int argc, char* argv[]) std::vector pages = pdh.getAllPages(); for (std::vector::iterator page_iter = pages.begin(); - page_iter != pages.end(); ++page_iter) - { + page_iter != pages.end(); + ++page_iter) { // Get all widget annotations for each page. Widget // annotations are the ones that contain the details of // what's in a form field. @@ -64,14 +63,13 @@ int main(int argc, char* argv[]) afdh.getWidgetAnnotationsForPage(*page_iter); for (std::vector::iterator annot_iter = annotations.begin(); - annot_iter != annotations.end(); ++annot_iter) - { + annot_iter != annotations.end(); + ++annot_iter) { // For each annotation, find its associated field. If // it's a text field, set its value. QPDFFormFieldObjectHelper ffh = afdh.getFieldForAnnotation(*annot_iter); - if (ffh.getFieldType() == "/Tx") - { + if (ffh.getFieldType() == "/Tx") { // Set the value. Passing false as the second // value prevents qpdf from setting // /NeedAppearances to true (but will not turn it @@ -92,9 +90,7 @@ int main(int argc, char* argv[]) QPDFWriter w(qpdf, outfilename); w.setStaticID(true); // for testing only w.write(); - } - catch (std::exception &e) - { + } catch (std::exception& e) { std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl; exit(2); -- cgit v1.2.3-54-g00ecf