Commit 60965d5f4d608bdccc2ffd4e8753e12cbbbd71d2

Authored by Jay Berkenbilt
1 parent 6b077332

Rerun clang-format

Showing 196 changed files with 2596 additions and 5616 deletions

Too many changes.

To preserve performance only 100 of 196 files are displayed.

examples/pdf-attach-file.cc
@@ -71,8 +71,7 @@ process( @@ -71,8 +71,7 @@ process(
71 71
72 // Create a file spec. 72 // Create a file spec.
73 std::string key = QUtil::path_basename(attachment); 73 std::string key = QUtil::path_basename(attachment);
74 - std::cout << whoami << ": attaching " << attachment << " as " << key  
75 - << std::endl; 74 + std::cout << whoami << ": attaching " << attachment << " as " << key << std::endl;
76 auto fs = QPDFFileSpecObjectHelper::createFileSpec(q, key, attachment); 75 auto fs = QPDFFileSpecObjectHelper::createFileSpec(q, key, attachment);
77 76
78 if (mimetype) { 77 if (mimetype) {
examples/pdf-bookmarks.cc
@@ -23,16 +23,12 @@ static std::map&lt;QPDFObjGen, int&gt; page_map; @@ -23,16 +23,12 @@ static std::map&lt;QPDFObjGen, int&gt; page_map;
23 void 23 void
24 usage() 24 usage()
25 { 25 {
26 - std::cerr  
27 - << "Usage: " << whoami << " [options] file.pdf [password]" << std::endl  
28 - << "Options:" << std::endl  
29 - << " --numbers give bookmarks outline-style numbers"  
30 - << std::endl  
31 - << " --lines draw lines to show bookmark hierarchy"  
32 - << std::endl  
33 - << " --show-open indicate whether a bookmark is initially open"  
34 - << std::endl  
35 - << " --show-targets show target if possible" << std::endl; 26 + std::cerr << "Usage: " << whoami << " [options] file.pdf [password]" << std::endl
  27 + << "Options:" << std::endl
  28 + << " --numbers give bookmarks outline-style numbers" << std::endl
  29 + << " --lines draw lines to show bookmark hierarchy" << std::endl
  30 + << " --show-open indicate whether a bookmark is initially open" << std::endl
  31 + << " --show-targets show target if possible" << std::endl;
36 exit(2); 32 exit(2);
37 } 33 }
38 34
@@ -120,16 +116,14 @@ show_bookmark_details(QPDFOutlineObjectHelper outline, std::vector&lt;int&gt; numbers) @@ -120,16 +116,14 @@ show_bookmark_details(QPDFOutlineObjectHelper outline, std::vector&lt;int&gt; numbers)
120 } 116 }
121 117
122 void 118 void
123 -extract_bookmarks(  
124 - std::vector<QPDFOutlineObjectHelper> outlines, std::vector<int>& numbers) 119 +extract_bookmarks(std::vector<QPDFOutlineObjectHelper> outlines, std::vector<int>& numbers)
125 { 120 {
126 // For style == st_numbers, numbers.at(n) contains the numerical 121 // For style == st_numbers, numbers.at(n) contains the numerical
127 // label for the outline, so we count up from 1. 122 // label for the outline, so we count up from 1.
128 // For style == st_lines, numbers.at(n) == 0 indicates the last 123 // For style == st_lines, numbers.at(n) == 0 indicates the last
129 // outline at level n, and we don't otherwise care what the value 124 // outline at level n, and we don't otherwise care what the value
130 // is, so we count up to zero. 125 // is, so we count up to zero.
131 - numbers.push_back(  
132 - (style == st_lines) ? -QIntC::to_int(outlines.size()) : 0); 126 + numbers.push_back((style == st_lines) ? -QIntC::to_int(outlines.size()) : 0);
133 for (auto& outline: outlines) { 127 for (auto& outline: outlines) {
134 ++(numbers.back()); 128 ++(numbers.back());
135 show_bookmark_details(outline, numbers); 129 show_bookmark_details(outline, numbers);
@@ -196,8 +190,7 @@ main(int argc, char* argv[]) @@ -196,8 +190,7 @@ main(int argc, char* argv[])
196 std::cout << filename << " has no bookmarks" << std::endl; 190 std::cout << filename << " has no bookmarks" << std::endl;
197 } 191 }
198 } catch (std::exception& e) { 192 } catch (std::exception& e) {
199 - std::cerr << whoami << " processing file " << filename << ": "  
200 - << e.what() << std::endl; 193 + std::cerr << whoami << " processing file " << filename << ": " << e.what() << std::endl;
201 exit(2); 194 exit(2);
202 } 195 }
203 196
examples/pdf-c-objects.c
@@ -33,8 +33,7 @@ modify_file(qpdf_data qpdf) @@ -33,8 +33,7 @@ modify_file(qpdf_data qpdf)
33 qpdf_oh_remove_key(qpdf, root, "/OpenAction"); 33 qpdf_oh_remove_key(qpdf, root, "/OpenAction");
34 /* 0 is never a valid qpdf_oh */ 34 /* 0 is never a valid qpdf_oh */
35 qpdf_oh pagemode = 0; 35 qpdf_oh pagemode = 0;
36 - if (qpdf_oh_is_dictionary(  
37 - qpdf, qpdf_oh_get_key(qpdf, root, "/PageLabels"))) { 36 + if (qpdf_oh_is_dictionary(qpdf, qpdf_oh_get_key(qpdf, root, "/PageLabels"))) {
38 pagemode = qpdf_oh_new_name(qpdf, "/UseOutlines"); 37 pagemode = qpdf_oh_new_name(qpdf, "/UseOutlines");
39 } else { 38 } else {
40 pagemode = qpdf_oh_new_null(qpdf); 39 pagemode = qpdf_oh_new_null(qpdf);
@@ -71,8 +70,7 @@ main(int argc, char* argv[]) @@ -71,8 +70,7 @@ main(int argc, char* argv[])
71 password = argv[2]; 70 password = argv[2];
72 outfile = argv[3]; 71 outfile = argv[3];
73 72
74 - if (((qpdf_read(qpdf, infile, password) & QPDF_ERRORS) == 0) &&  
75 - modify_file(qpdf) && 73 + if (((qpdf_read(qpdf, infile, password) & QPDF_ERRORS) == 0) && modify_file(qpdf) &&
76 ((qpdf_init_write(qpdf, outfile) & QPDF_ERRORS) == 0)) { 74 ((qpdf_init_write(qpdf, outfile) & QPDF_ERRORS) == 0)) {
77 /* Use static ID for testing only. For production, a 75 /* Use static ID for testing only. For production, a
78 * non-static ID is used. See also 76 * non-static ID is used. See also
@@ -82,15 +80,11 @@ main(int argc, char* argv[]) @@ -82,15 +80,11 @@ main(int argc, char* argv[])
82 } 80 }
83 while (qpdf_more_warnings(qpdf)) { 81 while (qpdf_more_warnings(qpdf)) {
84 warnings = 1; 82 warnings = 1;
85 - printf(  
86 - "warning: %s\n",  
87 - qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf))); 83 + printf("warning: %s\n", qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
88 } 84 }
89 if (qpdf_has_error(qpdf)) { 85 if (qpdf_has_error(qpdf)) {
90 errors = 1; 86 errors = 1;
91 - printf(  
92 - "error: %s\n",  
93 - qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf))); 87 + printf("error: %s\n", qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
94 } 88 }
95 qpdf_cleanup(&qpdf); 89 qpdf_cleanup(&qpdf);
96 if (errors) { 90 if (errors) {
examples/pdf-count-strings.cc
@@ -97,8 +97,7 @@ main(int argc, char* argv[]) @@ -97,8 +97,7 @@ main(int argc, char* argv[])
97 page.filterContents(&counter, &out); 97 page.filterContents(&counter, &out);
98 std::cout << "\n% end " << pageno << std::endl; 98 std::cout << "\n% end " << pageno << std::endl;
99 } 99 }
100 - std::cout << "Page " << pageno  
101 - << ": strings = " << counter.getCount() << std::endl; 100 + std::cout << "Page " << pageno << ": strings = " << counter.getCount() << std::endl;
102 } 101 }
103 } catch (std::exception& e) { 102 } catch (std::exception& e) {
104 std::cerr << whoami << ": " << e.what() << std::endl; 103 std::cerr << whoami << ": " << e.what() << std::endl;
examples/pdf-create.cc
@@ -41,8 +41,7 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider @@ -41,8 +41,7 @@ class ImageProvider: public QPDFObjectHandle::StreamDataProvider
41 J_COLOR_SPACE j_color_space; 41 J_COLOR_SPACE j_color_space;
42 }; 42 };
43 43
44 -ImageProvider::ImageProvider(  
45 - std::string const& color_space, std::string const& filter) : 44 +ImageProvider::ImageProvider(std::string const& color_space, std::string const& filter) :
46 width(400), 45 width(400),
47 stripe_height(80), 46 stripe_height(80),
48 color_space(color_space), 47 color_space(color_space),
@@ -107,8 +106,7 @@ ImageProvider::provideStreamData(QPDFObjGen const&amp;, Pipeline* pipeline) @@ -107,8 +106,7 @@ ImageProvider::provideStreamData(QPDFObjGen const&amp;, Pipeline* pipeline)
107 to_delete.push_back(p_new); 106 to_delete.push_back(p_new);
108 p = p_new.get(); 107 p = p_new.get();
109 } else if (filter == "/RunLengthDecode") { 108 } else if (filter == "/RunLengthDecode") {
110 - p_new = std::make_shared<Pl_RunLength>(  
111 - "image encoder", pipeline, Pl_RunLength::a_encode); 109 + p_new = std::make_shared<Pl_RunLength>("image encoder", pipeline, Pl_RunLength::a_encode);
112 to_delete.push_back(p_new); 110 to_delete.push_back(p_new);
113 p = p_new.get(); 111 p = p_new.get();
114 } 112 }
@@ -184,8 +182,7 @@ add_page( @@ -184,8 +182,7 @@ add_page(
184 image.replaceDict(image_dict); 182 image.replaceDict(image_dict);
185 183
186 // Provide the stream data. 184 // Provide the stream data.
187 - image.replaceStreamData(  
188 - provider, QPDFObjectHandle::parse(filter), QPDFObjectHandle::newNull()); 185 + image.replaceStreamData(provider, QPDFObjectHandle::parse(filter), QPDFObjectHandle::newNull());
189 186
190 // Create direct objects as needed by the page dictionary. 187 // Create direct objects as needed by the page dictionary.
191 QPDFObjectHandle procset = "[/PDF /Text /ImageC]"_qpdf; 188 QPDFObjectHandle procset = "[/PDF /Text /ImageC]"_qpdf;
@@ -202,8 +199,7 @@ add_page( @@ -202,8 +199,7 @@ add_page(
202 resources.replaceKey("/XObject", xobject); 199 resources.replaceKey("/XObject", xobject);
203 200
204 // Create the page content stream 201 // Create the page content stream
205 - QPDFObjectHandle contents =  
206 - createPageContents(pdf, color_space + " with filter " + filter); 202 + QPDFObjectHandle contents = createPageContents(pdf, color_space + " with filter " + filter);
207 203
208 // Create the page dictionary 204 // Create the page dictionary
209 QPDFObjectHandle page = pdf.makeIndirectObject("<<" 205 QPDFObjectHandle page = pdf.makeIndirectObject("<<"
@@ -256,8 +252,7 @@ check( @@ -256,8 +252,7 @@ check(
256 } 252 }
257 253
258 // Check filter and color space. 254 // Check filter and color space.
259 - std::string desired_color_space =  
260 - color_spaces[(pageno - 1) / n_color_spaces]; 255 + std::string desired_color_space = color_spaces[(pageno - 1) / n_color_spaces];
261 std::string desired_filter = filters[(pageno - 1) % n_filters]; 256 std::string desired_filter = filters[(pageno - 1) % n_filters];
262 // In the default mode, QPDFWriter will compress with 257 // In the default mode, QPDFWriter will compress with
263 // /FlateDecode if no filters are provided. 258 // /FlateDecode if no filters are provided.
@@ -271,16 +266,13 @@ check( @@ -271,16 +266,13 @@ check(
271 bool this_errors = false; 266 bool this_errors = false;
272 if (!filter.isNameAndEquals(desired_filter)) { 267 if (!filter.isNameAndEquals(desired_filter)) {
273 this_errors = errors = true; 268 this_errors = errors = true;
274 - std::cout << "page " << pageno << ": expected filter "  
275 - << desired_filter 269 + std::cout << "page " << pageno << ": expected filter " << desired_filter
276 << "; actual filter = " << filter.unparse() << std::endl; 270 << "; actual filter = " << filter.unparse() << std::endl;
277 } 271 }
278 if (!color_space.isNameAndEquals(desired_color_space)) { 272 if (!color_space.isNameAndEquals(desired_color_space)) {
279 this_errors = errors = true; 273 this_errors = errors = true;
280 - std::cout << "page " << pageno << ": expected color space "  
281 - << desired_color_space  
282 - << "; actual color space = " << color_space.unparse()  
283 - << std::endl; 274 + std::cout << "page " << pageno << ": expected color space " << desired_color_space
  275 + << "; actual color space = " << color_space.unparse() << std::endl;
284 } 276 }
285 277
286 if (!this_errors) { 278 if (!this_errors) {
@@ -293,8 +285,7 @@ check( @@ -293,8 +285,7 @@ check(
293 std::shared_ptr<Buffer> desired_data(b_p.getBuffer()); 285 std::shared_ptr<Buffer> desired_data(b_p.getBuffer());
294 286
295 if (desired_data->getSize() != actual_data->getSize()) { 287 if (desired_data->getSize() != actual_data->getSize()) {
296 - std::cout << "page " << pageno << ": image data length mismatch"  
297 - << std::endl; 288 + std::cout << "page " << pageno << ": image data length mismatch" << std::endl;
298 this_errors = errors = true; 289 this_errors = errors = true;
299 } else { 290 } else {
300 // Compare bytes. For JPEG, allow a certain number of 291 // Compare bytes. For JPEG, allow a certain number of
@@ -308,8 +299,7 @@ check( @@ -308,8 +299,7 @@ check(
308 size_t len = actual_data->getSize(); 299 size_t len = actual_data->getSize();
309 unsigned int mismatches = 0; 300 unsigned int mismatches = 0;
310 int tolerance = (desired_filter == "/DCTDecode" ? 10 : 0); 301 int tolerance = (desired_filter == "/DCTDecode" ? 10 : 0);
311 - size_t threshold =  
312 - (desired_filter == "/DCTDecode" ? len / 40U : 0); 302 + size_t threshold = (desired_filter == "/DCTDecode" ? len / 40U : 0);
313 for (size_t i = 0; i < len; ++i) { 303 for (size_t i = 0; i < len; ++i) {
314 int delta = actual_bytes[i] - desired_bytes[i]; 304 int delta = actual_bytes[i] - desired_bytes[i];
315 if ((delta > tolerance) || (delta < -tolerance)) { 305 if ((delta > tolerance) || (delta < -tolerance)) {
@@ -317,9 +307,8 @@ check( @@ -317,9 +307,8 @@ check(
317 } 307 }
318 } 308 }
319 if (mismatches > threshold) { 309 if (mismatches > threshold) {
320 - std::cout << "page " << pageno << ": "  
321 - << desired_color_space << ", " << desired_filter  
322 - << ": mismatches: " << mismatches << " of " << len 310 + std::cout << "page " << pageno << ": " << desired_color_space << ", "
  311 + << desired_filter << ": mismatches: " << mismatches << " of " << len
323 << std::endl; 312 << std::endl;
324 this_errors = errors = true; 313 this_errors = errors = true;
325 } 314 }
examples/pdf-custom-filter.cc
@@ -132,8 +132,7 @@ SF_XORDecode::setDecodeParms(QPDFObjectHandle decode_parms) @@ -132,8 +132,7 @@ SF_XORDecode::setDecodeParms(QPDFObjectHandle decode_parms)
132 this->key = buf->getBuffer()[0]; 132 this->key = buf->getBuffer()[0];
133 return true; 133 return true;
134 } catch (std::exception& e) { 134 } catch (std::exception& e) {
135 - std::cerr << "Error extracting key for /XORDecode: " << e.what()  
136 - << std::endl; 135 + std::cerr << "Error extracting key for /XORDecode: " << e.what() << std::endl;
137 } 136 }
138 return false; 137 return false;
139 } 138 }
@@ -203,8 +202,7 @@ class StreamReplacer: public QPDFObjectHandle::StreamDataProvider @@ -203,8 +202,7 @@ class StreamReplacer: public QPDFObjectHandle::StreamDataProvider
203 void provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override; 202 void provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
204 203
205 void registerStream( 204 void registerStream(
206 - QPDFObjectHandle stream,  
207 - std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self); 205 + QPDFObjectHandle stream, std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self);
208 206
209 private: 207 private:
210 bool maybeReplace( 208 bool maybeReplace(
@@ -300,12 +298,10 @@ StreamReplacer::maybeReplace( @@ -300,12 +298,10 @@ StreamReplacer::maybeReplace(
300 // changes. For example, an image resampler might change the 298 // changes. For example, an image resampler might change the
301 // dimensions or other properties of the image. 299 // dimensions or other properties of the image.
302 dict_updates->replaceKey( 300 dict_updates->replaceKey(
303 - "/OrigLength",  
304 - QPDFObjectHandle::newInteger(QIntC::to_longlong(out->getSize()))); 301 + "/OrigLength", QPDFObjectHandle::newInteger(QIntC::to_longlong(out->getSize())));
305 // We are also storing the "key" that we will access when 302 // We are also storing the "key" that we will access when
306 // writing the data. 303 // writing the data.
307 - this->keys[og] = QIntC::to_uchar(  
308 - (og.getObj() * QIntC::to_int(out->getSize())) & 0xff); 304 + this->keys[og] = QIntC::to_uchar((og.getObj() * QIntC::to_int(out->getSize())) & 0xff);
309 } 305 }
310 306
311 if (pipeline) { 307 if (pipeline) {
@@ -319,8 +315,7 @@ StreamReplacer::maybeReplace( @@ -319,8 +315,7 @@ StreamReplacer::maybeReplace(
319 315
320 void 316 void
321 StreamReplacer::registerStream( 317 StreamReplacer::registerStream(
322 - QPDFObjectHandle stream,  
323 - std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self) 318 + QPDFObjectHandle stream, std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self)
324 { 319 {
325 QPDFObjGen og(stream.getObjGen()); 320 QPDFObjGen og(stream.getObjGen());
326 321
@@ -344,8 +339,7 @@ StreamReplacer::registerStream( @@ -344,8 +339,7 @@ StreamReplacer::registerStream(
344 try { 339 try {
345 should_replace = maybeReplace(og, stream, nullptr, &dict_updates); 340 should_replace = maybeReplace(og, stream, nullptr, &dict_updates);
346 } catch (std::exception& e) { 341 } catch (std::exception& e) {
347 - stream.warnIfPossible(  
348 - std::string("exception while attempting to replace: ") + e.what()); 342 + stream.warnIfPossible(std::string("exception while attempting to replace: ") + e.what());
349 } 343 }
350 344
351 if (should_replace) { 345 if (should_replace) {
@@ -369,8 +363,7 @@ StreamReplacer::registerStream( @@ -369,8 +363,7 @@ StreamReplacer::registerStream(
369 // /XORDecode filter. 363 // /XORDecode filter.
370 QPDFObjectHandle decode_parms = 364 QPDFObjectHandle decode_parms =
371 QPDFObjectHandle::newDictionary({{"/KeyStream", dp_stream}}); 365 QPDFObjectHandle::newDictionary({{"/KeyStream", dp_stream}});
372 - stream.replaceStreamData(  
373 - self, QPDFObjectHandle::newName("/XORDecode"), decode_parms); 366 + stream.replaceStreamData(self, QPDFObjectHandle::newName("/XORDecode"), decode_parms);
374 // Further, if /ProtectXOR = true, we disable filtering on write 367 // Further, if /ProtectXOR = true, we disable filtering on write
375 // so that QPDFWriter will not decode the stream even though we 368 // so that QPDFWriter will not decode the stream even though we
376 // have registered a stream filter for /XORDecode. 369 // have registered a stream filter for /XORDecode.
@@ -393,14 +386,12 @@ StreamReplacer::provideStreamData(QPDFObjGen const&amp; og, Pipeline* pipeline) @@ -393,14 +386,12 @@ StreamReplacer::provideStreamData(QPDFObjGen const&amp; og, Pipeline* pipeline)
393 // Since this only gets called for streams we already 386 // Since this only gets called for streams we already
394 // determined we are replacing, a false return would indicate 387 // determined we are replacing, a false return would indicate
395 // a logic error. 388 // a logic error.
396 - throw std::logic_error(  
397 - "should_replace return false in provideStreamData"); 389 + throw std::logic_error("should_replace return false in provideStreamData");
398 } 390 }
399 } 391 }
400 392
401 static void 393 static void
402 -process(  
403 - char const* infilename, char const* outfilename, bool decode_specialized) 394 +process(char const* infilename, char const* outfilename, bool decode_specialized)
404 { 395 {
405 QPDF qpdf; 396 QPDF qpdf;
406 qpdf.processFile(infilename); 397 qpdf.processFile(infilename);
@@ -434,8 +425,7 @@ static void @@ -434,8 +425,7 @@ static void
434 usage() 425 usage()
435 { 426 {
436 std::cerr << "\n" 427 std::cerr << "\n"
437 - << "Usage: " << whoami  
438 - << " [--decode-specialized] infile outfile\n" 428 + << "Usage: " << whoami << " [--decode-specialized] infile outfile\n"
439 << std::endl; 429 << std::endl;
440 exit(2); 430 exit(2);
441 } 431 }
@@ -468,8 +458,7 @@ main(int argc, char* argv[]) @@ -468,8 +458,7 @@ main(int argc, char* argv[])
468 // decode our streams. This is not a real filter, so no real 458 // decode our streams. This is not a real filter, so no real
469 // PDF reading application would be able to interpret it. This 459 // PDF reading application would be able to interpret it. This
470 // is just for illustrative purposes. 460 // is just for illustrative purposes.
471 - QPDF::registerStreamFilter(  
472 - "/XORDecode", [] { return std::make_shared<SF_XORDecode>(); }); 461 + QPDF::registerStreamFilter("/XORDecode", [] { return std::make_shared<SF_XORDecode>(); });
473 // Do the actual processing. 462 // Do the actual processing.
474 process(infilename, outfilename, decode_specialized); 463 process(infilename, outfilename, decode_specialized);
475 } catch (std::exception& e) { 464 } catch (std::exception& e) {
examples/pdf-double-page-size.cc
@@ -13,8 +13,7 @@ static char const* whoami = nullptr; @@ -13,8 +13,7 @@ static char const* whoami = nullptr;
13 void 13 void
14 usage() 14 usage()
15 { 15 {
16 - std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]"  
17 - << std::endl 16 + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl
18 << "Double size of all pages in infile.pdf;" 17 << "Double size of all pages in infile.pdf;"
19 << " write output to outfile.pdf" << std::endl; 18 << " write output to outfile.pdf" << std::endl;
20 exit(2); 19 exit(2);
@@ -33,16 +32,13 @@ doubleBoxSize(QPDFPageObjectHelper&amp; page, char const* box_name) @@ -33,16 +32,13 @@ doubleBoxSize(QPDFPageObjectHelper&amp; page, char const* box_name)
33 } 32 }
34 if (!box.isRectangle()) { 33 if (!box.isRectangle()) {
35 throw std::runtime_error( 34 throw std::runtime_error(
36 - std::string("box ") + box_name +  
37 - " is not an array of four elements"); 35 + std::string("box ") + box_name + " is not an array of four elements");
38 } 36 }
39 std::vector<QPDFObjectHandle> doubled; 37 std::vector<QPDFObjectHandle> doubled;
40 for (auto& item: box.aitems()) { 38 for (auto& item: box.aitems()) {
41 - doubled.push_back(  
42 - QPDFObjectHandle::newReal(item.getNumericValue() * 2.0, 2)); 39 + doubled.push_back(QPDFObjectHandle::newReal(item.getNumericValue() * 2.0, 2));
43 } 40 }
44 - page.getObjectHandle().replaceKey(  
45 - box_name, QPDFObjectHandle::newArray(doubled)); 41 + page.getObjectHandle().replaceKey(box_name, QPDFObjectHandle::newArray(doubled));
46 } 42 }
47 43
48 int 44 int
@@ -93,11 +89,9 @@ main(int argc, char* argv[]) @@ -93,11 +89,9 @@ main(int argc, char* argv[])
93 w.setStreamDataMode(qpdf_s_uncompress); 89 w.setStreamDataMode(qpdf_s_uncompress);
94 } 90 }
95 w.write(); 91 w.write();
96 - std::cout << whoami << ": new file written to " << outfilename  
97 - << std::endl; 92 + std::cout << whoami << ": new file written to " << outfilename << std::endl;
98 } catch (std::exception& e) { 93 } catch (std::exception& e) {
99 - std::cerr << whoami << " processing file " << infilename << ": "  
100 - << e.what() << std::endl; 94 + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl;
101 exit(2); 95 exit(2);
102 } 96 }
103 97
examples/pdf-filter-tokens.cc
@@ -22,8 +22,7 @@ void @@ -22,8 +22,7 @@ void
22 usage() 22 usage()
23 { 23 {
24 std::cerr << "Usage: " << whoami << " infile outfile" << std::endl 24 std::cerr << "Usage: " << whoami << " infile outfile" << std::endl
25 - << "Applies token filters to infile and writes outfile"  
26 - << std::endl; 25 + << "Applies token filters to infile and writes outfile" << std::endl;
27 exit(2); 26 exit(2);
28 } 27 }
29 28
@@ -82,17 +81,13 @@ class ColorToGray: public QPDFObjectHandle::TokenFilter @@ -82,17 +81,13 @@ class ColorToGray: public QPDFObjectHandle::TokenFilter
82 bool 81 bool
83 ColorToGray::isNumeric(QPDFTokenizer::token_type_e token_type) 82 ColorToGray::isNumeric(QPDFTokenizer::token_type_e token_type)
84 { 83 {
85 - return (  
86 - (token_type == QPDFTokenizer::tt_integer) ||  
87 - (token_type == QPDFTokenizer::tt_real)); 84 + return ((token_type == QPDFTokenizer::tt_integer) || (token_type == QPDFTokenizer::tt_real));
88 } 85 }
89 86
90 bool 87 bool
91 ColorToGray::isIgnorable(QPDFTokenizer::token_type_e token_type) 88 ColorToGray::isIgnorable(QPDFTokenizer::token_type_e token_type)
92 { 89 {
93 - return (  
94 - (token_type == QPDFTokenizer::tt_space) ||  
95 - (token_type == QPDFTokenizer::tt_comment)); 90 + return ((token_type == QPDFTokenizer::tt_space) || (token_type == QPDFTokenizer::tt_comment));
96 } 91 }
97 92
98 double 93 double
@@ -128,8 +123,7 @@ ColorToGray::handleToken(QPDFTokenizer::Token const&amp; token) @@ -128,8 +123,7 @@ ColorToGray::handleToken(QPDFTokenizer::Token const&amp; token)
128 // kinds of operands, replace the command. Flush any additional 123 // kinds of operands, replace the command. Flush any additional
129 // accumulated tokens to keep the stack only four tokens deep. 124 // accumulated tokens to keep the stack only four tokens deep.
130 125
131 - while ((!this->all_stack.empty()) &&  
132 - isIgnorable(this->all_stack.at(0).getType())) { 126 + while ((!this->all_stack.empty()) && isIgnorable(this->all_stack.at(0).getType())) {
133 writeToken(this->all_stack.at(0)); 127 writeToken(this->all_stack.at(0));
134 this->all_stack.pop_front(); 128 this->all_stack.pop_front();
135 } 129 }
@@ -138,8 +132,7 @@ ColorToGray::handleToken(QPDFTokenizer::Token const&amp; token) @@ -138,8 +132,7 @@ ColorToGray::handleToken(QPDFTokenizer::Token const&amp; token)
138 if (!isIgnorable(token_type)) { 132 if (!isIgnorable(token_type)) {
139 this->stack.push_back(token); 133 this->stack.push_back(token);
140 if ((this->stack.size() == 4) && token.isWord("rg") && 134 if ((this->stack.size() == 4) && token.isWord("rg") &&
141 - (isNumeric(this->stack.at(0).getType())) &&  
142 - (isNumeric(this->stack.at(1).getType())) && 135 + (isNumeric(this->stack.at(0).getType())) && (isNumeric(this->stack.at(1).getType())) &&
143 (isNumeric(this->stack.at(2).getType()))) { 136 (isNumeric(this->stack.at(2).getType()))) {
144 double r = numericValue(this->stack.at(0)); 137 double r = numericValue(this->stack.at(0));
145 double g = numericValue(this->stack.at(1)); 138 double g = numericValue(this->stack.at(1));
@@ -195,11 +188,9 @@ main(int argc, char* argv[]) @@ -195,11 +188,9 @@ main(int argc, char* argv[])
195 // applied. See comments on the filters for additional 188 // applied. See comments on the filters for additional
196 // details. 189 // details.
197 page.addContentTokenFilter( 190 page.addContentTokenFilter(
198 - std::shared_ptr<QPDFObjectHandle::TokenFilter>(  
199 - new StringReverser)); 191 + std::shared_ptr<QPDFObjectHandle::TokenFilter>(new StringReverser));
200 page.addContentTokenFilter( 192 page.addContentTokenFilter(
201 - std::shared_ptr<QPDFObjectHandle::TokenFilter>(  
202 - new ColorToGray)); 193 + std::shared_ptr<QPDFObjectHandle::TokenFilter>(new ColorToGray));
203 } 194 }
204 195
205 QPDFWriter w(pdf, outfilename); 196 QPDFWriter w(pdf, outfilename);
examples/pdf-invert-images.cc
@@ -14,8 +14,7 @@ static char const* whoami = nullptr; @@ -14,8 +14,7 @@ static char const* whoami = nullptr;
14 void 14 void
15 usage() 15 usage()
16 { 16 {
17 - std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]"  
18 - << std::endl 17 + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf [in-password]" << std::endl
19 << "Invert some images in infile.pdf;" 18 << "Invert some images in infile.pdf;"
20 << " write output to outfile.pdf" << std::endl; 19 << " write output to outfile.pdf" << std::endl;
21 exit(2); 20 exit(2);
@@ -37,8 +36,7 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider @@ -37,8 +36,7 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider
37 void provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override; 36 void provideStreamData(QPDFObjGen const& og, Pipeline* pipeline) override;
38 37
39 void registerImage( 38 void registerImage(
40 - QPDFObjectHandle image,  
41 - std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self); 39 + QPDFObjectHandle image, std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self);
42 40
43 private: 41 private:
44 std::map<QPDFObjGen, QPDFObjectHandle> copied_images; 42 std::map<QPDFObjGen, QPDFObjectHandle> copied_images;
@@ -46,8 +44,7 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider @@ -46,8 +44,7 @@ class ImageInverter: public QPDFObjectHandle::StreamDataProvider
46 44
47 void 45 void
48 ImageInverter::registerImage( 46 ImageInverter::registerImage(
49 - QPDFObjectHandle image,  
50 - std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self) 47 + QPDFObjectHandle image, std::shared_ptr<QPDFObjectHandle::StreamDataProvider> self)
51 { 48 {
52 // replaceStreamData requires a pointer holder to the stream data 49 // replaceStreamData requires a pointer holder to the stream data
53 // provider, but there's no way for us to generate one ourselves, 50 // provider, but there's no way for us to generate one ourselves,
@@ -76,8 +73,7 @@ ImageInverter::registerImage( @@ -76,8 +73,7 @@ ImageInverter::registerImage(
76 // filterable in the input QPDF object, so we don't have to deal 73 // filterable in the input QPDF object, so we don't have to deal
77 // with it explicitly here. We could explicitly use /DCTDecode and 74 // with it explicitly here. We could explicitly use /DCTDecode and
78 // write through a DCT filter if we wanted. 75 // write through a DCT filter if we wanted.
79 - image.replaceStreamData(  
80 - self, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); 76 + image.replaceStreamData(self, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
81 } 77 }
82 78
83 void 79 void
@@ -86,8 +82,7 @@ ImageInverter::provideStreamData(QPDFObjGen const&amp; og, Pipeline* pipeline) @@ -86,8 +82,7 @@ ImageInverter::provideStreamData(QPDFObjGen const&amp; og, Pipeline* pipeline)
86 // Use the object and generation number supplied to look up the 82 // Use the object and generation number supplied to look up the
87 // image data. Then invert the image data and write the inverted 83 // image data. Then invert the image data and write the inverted
88 // data to the pipeline. 84 // data to the pipeline.
89 - std::shared_ptr<Buffer> data =  
90 - this->copied_images[og].getStreamData(qpdf_dl_all); 85 + std::shared_ptr<Buffer> data = this->copied_images[og].getStreamData(qpdf_dl_all);
91 size_t size = data->getSize(); 86 size_t size = data->getSize();
92 unsigned char* buf = data->getBuffer(); 87 unsigned char* buf = data->getBuffer();
93 unsigned char ch; 88 unsigned char ch;
@@ -133,18 +128,15 @@ main(int argc, char* argv[]) @@ -133,18 +128,15 @@ main(int argc, char* argv[])
133 QPDFObjectHandle& image = iter.second; 128 QPDFObjectHandle& image = iter.second;
134 QPDFObjectHandle image_dict = image.getDict(); 129 QPDFObjectHandle image_dict = image.getDict();
135 QPDFObjectHandle color_space = image_dict.getKey("/ColorSpace"); 130 QPDFObjectHandle color_space = image_dict.getKey("/ColorSpace");
136 - QPDFObjectHandle bits_per_component =  
137 - image_dict.getKey("/BitsPerComponent"); 131 + QPDFObjectHandle bits_per_component = image_dict.getKey("/BitsPerComponent");
138 132
139 // For our example, we can only work with images 8-bit 133 // For our example, we can only work with images 8-bit
140 // grayscale images that we can fully decode. Use 134 // grayscale images that we can fully decode. Use
141 // pipeStreamData with a null pipeline to determine 135 // pipeStreamData with a null pipeline to determine
142 // whether the image is filterable. Directly inspect 136 // whether the image is filterable. Directly inspect
143 // keys to determine the image type. 137 // keys to determine the image type.
144 - if (image.pipeStreamData(  
145 - nullptr, qpdf_ef_compress, qpdf_dl_all) &&  
146 - color_space.isNameAndEquals("/DeviceGray") &&  
147 - bits_per_component.isInteger() && 138 + if (image.pipeStreamData(nullptr, qpdf_ef_compress, qpdf_dl_all) &&
  139 + color_space.isNameAndEquals("/DeviceGray") && bits_per_component.isInteger() &&
148 (bits_per_component.getIntValue() == 8)) { 140 (bits_per_component.getIntValue() == 8)) {
149 inv->registerImage(image, p); 141 inv->registerImage(image, p);
150 } 142 }
@@ -159,11 +151,9 @@ main(int argc, char* argv[]) @@ -159,11 +151,9 @@ main(int argc, char* argv[])
159 w.setStaticID(true); // for testing only 151 w.setStaticID(true); // for testing only
160 } 152 }
161 w.write(); 153 w.write();
162 - std::cout << whoami << ": new file written to " << outfilename  
163 - << std::endl; 154 + std::cout << whoami << ": new file written to " << outfilename << std::endl;
164 } catch (std::exception& e) { 155 } catch (std::exception& e) {
165 - std::cerr << whoami << " processing file " << infilename << ": "  
166 - << e.what() << std::endl; 156 + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl;
167 exit(2); 157 exit(2);
168 } 158 }
169 159
examples/pdf-linearize.c
@@ -61,15 +61,11 @@ main(int argc, char* argv[]) @@ -61,15 +61,11 @@ main(int argc, char* argv[])
61 } 61 }
62 while (qpdf_more_warnings(qpdf)) { 62 while (qpdf_more_warnings(qpdf)) {
63 warnings = 1; 63 warnings = 1;
64 - printf(  
65 - "warning: %s\n",  
66 - qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf))); 64 + printf("warning: %s\n", qpdf_get_error_full_text(qpdf, qpdf_next_warning(qpdf)));
67 } 65 }
68 if (qpdf_has_error(qpdf)) { 66 if (qpdf_has_error(qpdf)) {
69 errors = 1; 67 errors = 1;
70 - printf(  
71 - "error: %s\n",  
72 - qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf))); 68 + printf("error: %s\n", qpdf_get_error_full_text(qpdf, qpdf_get_error(qpdf)));
73 } 69 }
74 qpdf_cleanup(&qpdf); 70 qpdf_cleanup(&qpdf);
75 if (errors) { 71 if (errors) {
examples/pdf-mod-info.cc
@@ -16,8 +16,7 @@ static char const* whoami = nullptr; @@ -16,8 +16,7 @@ static char const* whoami = nullptr;
16 void 16 void
17 usage() 17 usage()
18 { 18 {
19 - std::cerr << "Usage: " << whoami  
20 - << " --in in_file [--out out_file] [--key key [--val val]?]+\n" 19 + std::cerr << "Usage: " << whoami << " --in in_file [--out out_file] [--key key [--val val]?]+\n"
21 << "Modifies/Adds/Removes PDF /Info entries in the in_file\n" 20 << "Modifies/Adds/Removes PDF /Info entries in the in_file\n"
22 << "and stores the result in out_file\n" 21 << "and stores the result in out_file\n"
23 << "Special mode: " << whoami << " --dump file\n" 22 << "Special mode: " << whoami << " --dump file\n"
@@ -26,8 +25,7 @@ usage() @@ -26,8 +25,7 @@ usage()
26 } 25 }
27 26
28 void 27 void
29 -dumpInfoDict(  
30 - QPDF& pdf, std::ostream& os = std::cout, std::string const& sep = ":\t") 28 +dumpInfoDict(QPDF& pdf, std::ostream& os = std::cout, std::string const& sep = ":\t")
31 { 29 {
32 QPDFObjectHandle trailer = pdf.getTrailer(); 30 QPDFObjectHandle trailer = pdf.getTrailer();
33 if (trailer.hasKey("/Info")) { 31 if (trailer.hasKey("/Info")) {
@@ -164,8 +162,7 @@ main(int argc, char* argv[]) @@ -164,8 +162,7 @@ main(int argc, char* argv[])
164 try { 162 try {
165 (void)remove(fl_out); 163 (void)remove(fl_out);
166 QUtil::os_wrapper( 164 QUtil::os_wrapper(
167 - "rename " + fl_tmp + " " + std::string(fl_out),  
168 - rename(fl_tmp.c_str(), fl_out)); 165 + "rename " + fl_tmp + " " + std::string(fl_out), rename(fl_tmp.c_str(), fl_out));
169 } catch (std::exception& e) { 166 } catch (std::exception& e) {
170 std::cerr << e.what() << std::endl; 167 std::cerr << e.what() << std::endl;
171 exit(2); 168 exit(2);
examples/pdf-name-number-tree.cc
@@ -11,8 +11,7 @@ void @@ -11,8 +11,7 @@ void
11 usage() 11 usage()
12 { 12 {
13 std::cerr << "Usage: " << whoami << " outfile.pdf" << std::endl 13 std::cerr << "Usage: " << whoami << " outfile.pdf" << std::endl
14 - << "Create some name/number trees and write to a file"  
15 - << std::endl; 14 + << "Create some name/number trees and write to a file" << std::endl;
16 exit(2); 15 exit(2);
17 } 16 }
18 17
@@ -61,24 +60,19 @@ main(int argc, char* argv[]) @@ -61,24 +60,19 @@ main(int argc, char* argv[])
61 name_tree.insert("R", QPDFObjectHandle::newUnicodeString("rook")); 60 name_tree.insert("R", QPDFObjectHandle::newUnicodeString("rook"));
62 name_tree.insert("B", QPDFObjectHandle::newUnicodeString("bishop")); 61 name_tree.insert("B", QPDFObjectHandle::newUnicodeString("bishop"));
63 name_tree.insert("N", QPDFObjectHandle::newUnicodeString("knight")); 62 name_tree.insert("N", QPDFObjectHandle::newUnicodeString("knight"));
64 - auto iter =  
65 - name_tree.insert("P", QPDFObjectHandle::newUnicodeString("pawn")); 63 + auto iter = name_tree.insert("P", QPDFObjectHandle::newUnicodeString("pawn"));
66 // Look at the iterator 64 // Look at the iterator
67 - std::cout << "just inserted " << iter->first << " -> "  
68 - << iter->second.unparse() << std::endl; 65 + std::cout << "just inserted " << iter->first << " -> " << iter->second.unparse() << std::endl;
69 --iter; 66 --iter;
70 - std::cout << "predecessor: " << iter->first << " -> "  
71 - << iter->second.unparse() << std::endl; 67 + std::cout << "predecessor: " << iter->first << " -> " << iter->second.unparse() << std::endl;
72 ++iter; 68 ++iter;
73 ++iter; 69 ++iter;
74 - std::cout << "successor: " << iter->first << " -> "  
75 - << iter->second.unparse() << std::endl; 70 + std::cout << "successor: " << iter->first << " -> " << iter->second.unparse() << std::endl;
76 71
77 // Use range-for iteration 72 // Use range-for iteration
78 std::cout << "Name tree items:" << std::endl; 73 std::cout << "Name tree items:" << std::endl;
79 for (auto i: name_tree) { 74 for (auto i: name_tree) {
80 - std::cout << " " << i.first << " -> " << i.second.unparse()  
81 - << std::endl; 75 + std::cout << " " << i.first << " -> " << i.second.unparse() << std::endl;
82 } 76 }
83 77
84 // This is a small tree, so everything will be at the root. We can 78 // This is a small tree, so everything will be at the root. We can
@@ -107,14 +101,13 @@ main(int argc, char* argv[]) @@ -107,14 +101,13 @@ main(int argc, char* argv[])
107 101
108 // 10.2 API 102 // 10.2 API
109 iter = name_tree.find("Q"); 103 iter = name_tree.find("Q");
110 - std::cout << "Q: " << iter->first << " -> " << iter->second.unparse()  
111 - << std::endl; 104 + std::cout << "Q: " << iter->first << " -> " << iter->second.unparse() << std::endl;
112 iter = name_tree.find("W"); 105 iter = name_tree.find("W");
113 std::cout << "W found: " << (iter != name_tree.end()) << std::endl; 106 std::cout << "W found: " << (iter != name_tree.end()) << std::endl;
114 // Allow find to return predecessor 107 // Allow find to return predecessor
115 iter = name_tree.find("W", true); 108 iter = name_tree.find("W", true);
116 - std::cout << "W's predecessor: " << iter->first << " -> "  
117 - << iter->second.unparse() << std::endl; 109 + std::cout << "W's predecessor: " << iter->first << " -> " << iter->second.unparse()
  110 + << std::endl;
118 111
119 // We can also remove items 112 // We can also remove items
120 std::cout << "Remove P: " << name_tree.remove("P", &obj) << std::endl; 113 std::cout << "Remove P: " << name_tree.remove("P", &obj) << std::endl;
@@ -124,8 +117,8 @@ main(int argc, char* argv[]) @@ -124,8 +117,8 @@ main(int argc, char* argv[])
124 iter = name_tree.find("K"); 117 iter = name_tree.find("K");
125 std::cout << "Find K: " << iter->second.unparse() << std::endl; 118 std::cout << "Find K: " << iter->second.unparse() << std::endl;
126 iter.remove(); 119 iter.remove();
127 - std::cout << "Iter after removing K: " << iter->first << " -> "  
128 - << iter->second.unparse() << std::endl; 120 + std::cout << "Iter after removing K: " << iter->first << " -> " << iter->second.unparse()
  121 + << std::endl;
129 std::cout << "Has K?: " << name_tree.hasName("K") << std::endl; 122 std::cout << "Has K?: " << name_tree.hasName("K") << std::endl;
130 123
131 // Illustrate some more advanced usage using number trees. These 124 // Illustrate some more advanced usage using number trees. These
@@ -142,8 +135,7 @@ main(int argc, char* argv[]) @@ -142,8 +135,7 @@ main(int argc, char* argv[])
142 example.replaceKey("/NumberTree", number_tree_oh); 135 example.replaceKey("/NumberTree", number_tree_oh);
143 auto iter2 = number_tree.begin(); 136 auto iter2 = number_tree.begin();
144 for (int i = 7; i <= 350; i += 7) { 137 for (int i = 7; i <= 350; i += 7) {
145 - iter2.insertAfter(  
146 - i, QPDFObjectHandle::newString("-" + std::to_string(i) + "-")); 138 + iter2.insertAfter(i, QPDFObjectHandle::newString("-" + std::to_string(i) + "-"));
147 } 139 }
148 std::cout << "Numbers:" << std::endl; 140 std::cout << "Numbers:" << std::endl;
149 int n = 1; 141 int n = 1;
examples/pdf-overlay-page.cc
@@ -31,8 +31,7 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile) @@ -31,8 +31,7 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile)
31 stamppdf.processFile(stampfile); 31 stamppdf.processFile(stampfile);
32 32
33 // Get first page from other file 33 // Get first page from other file
34 - QPDFPageObjectHelper stamp_page_1 =  
35 - QPDFPageDocumentHelper(stamppdf).getAllPages().at(0); 34 + QPDFPageObjectHelper stamp_page_1 = QPDFPageDocumentHelper(stamppdf).getAllPages().at(0);
36 // Convert page to a form XObject 35 // Convert page to a form XObject
37 QPDFObjectHandle foreign_fo = stamp_page_1.getFormXObjectForPage(); 36 QPDFObjectHandle foreign_fo = stamp_page_1.getFormXObjectForPage();
38 // Copy form XObject to the input file 37 // Copy form XObject to the input file
@@ -48,8 +47,8 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile) @@ -48,8 +47,8 @@ stamp_page(char const* infile, char const* stampfile, char const* outfile)
48 // Generate content to place the form XObject centered within 47 // Generate content to place the form XObject centered within
49 // destination page's trim box. 48 // destination page's trim box.
50 QPDFMatrix m; 49 QPDFMatrix m;
51 - std::string content = ph.placeFormXObject(  
52 - stamp_fo, name, ph.getTrimBox().getArrayAsRectangle(), m); 50 + std::string content =
  51 + ph.placeFormXObject(stamp_fo, name, ph.getTrimBox().getArrayAsRectangle(), m);
53 if (!content.empty()) { 52 if (!content.empty()) {
54 // Append the content to the page's content. Surround the 53 // Append the content to the page's content. Surround the
55 // original content with q...Q to the new content from the 54 // original content with q...Q to the new content from the
examples/pdf-parse-content.cc
@@ -35,11 +35,9 @@ ParserCallbacks::contentSize(size_t size) @@ -35,11 +35,9 @@ ParserCallbacks::contentSize(size_t size)
35 } 35 }
36 36
37 void 37 void
38 -ParserCallbacks::handleObject(  
39 - QPDFObjectHandle obj, size_t offset, size_t length) 38 +ParserCallbacks::handleObject(QPDFObjectHandle obj, size_t offset, size_t length)
40 { 39 {
41 - std::cout << obj.getTypeName() << ", offset=" << offset  
42 - << ", length=" << length << ": "; 40 + std::cout << obj.getTypeName() << ", offset=" << offset << ", length=" << length << ": ";
43 if (obj.isInlineImage()) { 41 if (obj.isInlineImage()) {
44 std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << std::endl; 42 std::cout << QUtil::hex_encode(obj.getInlineImageValue()) << std::endl;
45 } else { 43 } else {
@@ -67,8 +65,7 @@ main(int argc, char* argv[]) @@ -67,8 +65,7 @@ main(int argc, char* argv[])
67 try { 65 try {
68 QPDF pdf; 66 QPDF pdf;
69 pdf.processFile(filename); 67 pdf.processFile(filename);
70 - std::vector<QPDFPageObjectHelper> pages =  
71 - QPDFPageDocumentHelper(pdf).getAllPages(); 68 + std::vector<QPDFPageObjectHelper> pages = QPDFPageDocumentHelper(pdf).getAllPages();
72 if ((pageno < 1) || (QIntC::to_size(pageno) > pages.size())) { 69 if ((pageno < 1) || (QIntC::to_size(pageno) > pages.size())) {
73 usage(); 70 usage();
74 } 71 }
examples/pdf-set-form-values.cc
@@ -11,10 +11,8 @@ static char const* whoami = nullptr; @@ -11,10 +11,8 @@ static char const* whoami = nullptr;
11 void 11 void
12 usage() 12 usage()
13 { 13 {
14 - std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf value"  
15 - << std::endl  
16 - << "Set the value of all text fields to a specified value"  
17 - << std::endl; 14 + std::cerr << "Usage: " << whoami << " infile.pdf outfile.pdf value" << std::endl
  15 + << "Set the value of all text fields to a specified value" << std::endl;
18 exit(2); 16 exit(2);
19 } 17 }
20 18
@@ -55,8 +53,7 @@ main(int argc, char* argv[]) @@ -55,8 +53,7 @@ main(int argc, char* argv[])
55 for (auto& annot: afdh.getWidgetAnnotationsForPage(page)) { 53 for (auto& annot: afdh.getWidgetAnnotationsForPage(page)) {
56 // For each annotation, find its associated field. If 54 // For each annotation, find its associated field. If
57 // it's a text field, set its value. 55 // it's a text field, set its value.
58 - QPDFFormFieldObjectHelper ffh =  
59 - afdh.getFieldForAnnotation(annot); 56 + QPDFFormFieldObjectHelper ffh = afdh.getFieldForAnnotation(annot);
60 if (ffh.getFieldType() == "/Tx") { 57 if (ffh.getFieldType() == "/Tx") {
61 // Set the value. Passing false as the second 58 // Set the value. Passing false as the second
62 // value prevents qpdf from setting 59 // value prevents qpdf from setting
@@ -79,8 +76,7 @@ main(int argc, char* argv[]) @@ -79,8 +76,7 @@ main(int argc, char* argv[])
79 w.setStaticID(true); // for testing only 76 w.setStaticID(true); // for testing only
80 w.write(); 77 w.write();
81 } catch (std::exception& e) { 78 } catch (std::exception& e) {
82 - std::cerr << whoami << " processing file " << infilename << ": "  
83 - << e.what() << std::endl; 79 + std::cerr << whoami << " processing file " << infilename << ": " << e.what() << std::endl;
84 exit(2); 80 exit(2);
85 } 81 }
86 82
examples/pdf-split-pages.cc
@@ -22,13 +22,11 @@ process(char const* whoami, char const* infile, std::string outprefix) @@ -22,13 +22,11 @@ process(char const* whoami, char const* infile, std::string outprefix)
22 { 22 {
23 QPDF inpdf; 23 QPDF inpdf;
24 inpdf.processFile(infile); 24 inpdf.processFile(infile);
25 - std::vector<QPDFPageObjectHelper> pages =  
26 - QPDFPageDocumentHelper(inpdf).getAllPages(); 25 + std::vector<QPDFPageObjectHelper> pages = QPDFPageDocumentHelper(inpdf).getAllPages();
27 int pageno_len = QIntC::to_int(std::to_string(pages.size()).length()); 26 int pageno_len = QIntC::to_int(std::to_string(pages.size()).length());
28 int pageno = 0; 27 int pageno = 0;
29 for (auto& page: pages) { 28 for (auto& page: pages) {
30 - std::string outfile =  
31 - outprefix + QUtil::int_to_string(++pageno, pageno_len) + ".pdf"; 29 + std::string outfile = outprefix + QUtil::int_to_string(++pageno, pageno_len) + ".pdf";
32 QPDF outpdf; 30 QPDF outpdf;
33 outpdf.emptyPDF(); 31 outpdf.emptyPDF();
34 QPDFPageDocumentHelper(outpdf).addPage(page, false); 32 QPDFPageDocumentHelper(outpdf).addPage(page, false);
examples/qpdfjob-c-save-attachment.c
@@ -83,8 +83,7 @@ main(int argc, char* argv[]) @@ -83,8 +83,7 @@ main(int argc, char* argv[])
83 * saved data. You can use other qpdf logger functions to capture 83 * saved data. You can use other qpdf logger functions to capture
84 * informational output, warnings, and errors. 84 * informational output, warnings, and errors.
85 */ 85 */
86 - qpdflogger_set_save(  
87 - l, qpdf_log_dest_custom, save_to_file, (void*)outfile, 0); 86 + qpdflogger_set_save(l, qpdf_log_dest_custom, save_to_file, (void*)outfile, 0);
88 qpdflogger_cleanup(&l); 87 qpdflogger_cleanup(&l);
89 j = qpdfjob_init(); 88 j = qpdfjob_init();
90 status = (qpdfjob_initialize_from_argv(j, j_argv) || qpdfjob_run(j)); 89 status = (qpdfjob_initialize_from_argv(j, j_argv) || qpdfjob_run(j));
examples/qpdfjob-remove-annotations.cc
@@ -20,15 +20,10 @@ usageExit(std::string const&amp; msg) @@ -20,15 +20,10 @@ usageExit(std::string const&amp; msg)
20 << whoami << ": " << msg << std::endl 20 << whoami << ": " << msg << std::endl
21 << std::endl 21 << std::endl
22 << "For help:" << std::endl 22 << "For help:" << std::endl
23 - << " " << whoami << " --help=usage usage information"  
24 - << std::endl  
25 - << " " << whoami << " --help=topic help on a topic"  
26 - << std::endl  
27 - << " " << whoami << " --help=--option help on an option"  
28 - << std::endl  
29 - << " " << whoami  
30 - << " --help general help and a topic list"  
31 - << std::endl 23 + << " " << whoami << " --help=usage usage information" << std::endl
  24 + << " " << whoami << " --help=topic help on a topic" << std::endl
  25 + << " " << whoami << " --help=--option help on an option" << std::endl
  26 + << " " << whoami << " --help general help and a topic list" << std::endl
32 << std::endl; 27 << std::endl;
33 exit(QPDFJob::EXIT_ERROR); 28 exit(QPDFJob::EXIT_ERROR);
34 } 29 }
examples/qpdfjob-save-attachment.cc
@@ -14,8 +14,7 @@ main(int argc, char* argv[]) @@ -14,8 +14,7 @@ main(int argc, char* argv[])
14 auto whoami = QUtil::getWhoami(argv[0]); 14 auto whoami = QUtil::getWhoami(argv[0]);
15 15
16 if (argc != 4) { 16 if (argc != 4) {
17 - std::cerr << "Usage: " << whoami << " file attachment-key outfile"  
18 - << std::endl; 17 + std::cerr << "Usage: " << whoami << " file attachment-key outfile" << std::endl;
19 exit(2); 18 exit(2);
20 } 19 }
21 20
fuzz/qpdf_fuzzer.cc
@@ -53,8 +53,8 @@ FuzzHelper::FuzzHelper(unsigned char const* data, size_t size) : @@ -53,8 +53,8 @@ FuzzHelper::FuzzHelper(unsigned char const* data, size_t size) :
53 std::shared_ptr<QPDF> 53 std::shared_ptr<QPDF>
54 FuzzHelper::getQpdf() 54 FuzzHelper::getQpdf()
55 { 55 {
56 - auto is = std::shared_ptr<InputSource>(  
57 - new BufferInputSource("fuzz input", &this->input_buffer)); 56 + auto is =
  57 + std::shared_ptr<InputSource>(new BufferInputSource("fuzz input", &this->input_buffer));
58 auto qpdf = QPDF::create(); 58 auto qpdf = QPDF::create();
59 qpdf->processInputSource(is); 59 qpdf->processInputSource(is);
60 return qpdf; 60 return qpdf;
@@ -99,8 +99,7 @@ FuzzHelper::testWrite() @@ -99,8 +99,7 @@ FuzzHelper::testWrite()
99 w = getWriter(q); 99 w = getWriter(q);
100 w->setStaticID(true); 100 w->setStaticID(true);
101 w->setLinearization(true); 101 w->setLinearization(true);
102 - w->setR6EncryptionParameters(  
103 - "u", "o", true, true, true, true, true, true, qpdf_r3p_full, true); 102 + w->setR6EncryptionParameters("u", "o", true, true, true, true, true, true, qpdf_r3p_full, true);
104 doWrite(w); 103 doWrite(w);
105 104
106 q = getQpdf(); 105 q = getQpdf();
fuzz/standalone_fuzz_target_runner.cc
@@ -11,8 +11,7 @@ main(int argc, char** argv) @@ -11,8 +11,7 @@ main(int argc, char** argv)
11 std::shared_ptr<char> file_buf; 11 std::shared_ptr<char> file_buf;
12 size_t size = 0; 12 size_t size = 0;
13 QUtil::read_file_into_memory(argv[i], file_buf, size); 13 QUtil::read_file_into_memory(argv[i], file_buf, size);
14 - LLVMFuzzerTestOneInput(  
15 - reinterpret_cast<unsigned char*>(file_buf.get()), size); 14 + LLVMFuzzerTestOneInput(reinterpret_cast<unsigned char*>(file_buf.get()), size);
16 std::cout << argv[i] << " successful" << std::endl; 15 std::cout << argv[i] << " successful" << std::endl;
17 } 16 }
18 return 0; 17 return 0;
fuzz/tiffpredictor_fuzzer.cc
@@ -26,8 +26,7 @@ void @@ -26,8 +26,7 @@ void
26 FuzzHelper::doChecks() 26 FuzzHelper::doChecks()
27 { 27 {
28 Pl_Discard discard; 28 Pl_Discard discard;
29 - Pl_TIFFPredictor p(  
30 - "decoder", &discard, Pl_TIFFPredictor::a_decode, 16, 1, 8); 29 + Pl_TIFFPredictor p("decoder", &discard, Pl_TIFFPredictor::a_decode, 16, 1, 8);
31 p.write(const_cast<unsigned char*>(data), size); 30 p.write(const_cast<unsigned char*>(data), size);
32 p.finish(); 31 p.finish();
33 } 32 }
include/qpdf/BufferInputSource.hh
@@ -31,11 +31,9 @@ class QPDF_DLL_CLASS BufferInputSource: public InputSource @@ -31,11 +31,9 @@ class QPDF_DLL_CLASS BufferInputSource: public InputSource
31 // If own_memory is true, BufferInputSource will delete the buffer 31 // If own_memory is true, BufferInputSource will delete the buffer
32 // when finished with it. Otherwise, the caller owns the memory. 32 // when finished with it. Otherwise, the caller owns the memory.
33 QPDF_DLL 33 QPDF_DLL
34 - BufferInputSource(  
35 - std::string const& description, Buffer* buf, bool own_memory = false); 34 + BufferInputSource(std::string const& description, Buffer* buf, bool own_memory = false);
36 QPDF_DLL 35 QPDF_DLL
37 - BufferInputSource(  
38 - std::string const& description, std::string const& contents); 36 + BufferInputSource(std::string const& description, std::string const& contents);
39 QPDF_DLL 37 QPDF_DLL
40 virtual ~BufferInputSource(); 38 virtual ~BufferInputSource();
41 QPDF_DLL 39 QPDF_DLL
include/qpdf/Constants.h
@@ -230,9 +230,6 @@ enum pdf_annotation_flag_e { @@ -230,9 +230,6 @@ enum pdf_annotation_flag_e {
230 }; 230 };
231 231
232 /* Encryption/password status for QPDFJob */ 232 /* Encryption/password status for QPDFJob */
233 -enum qpdf_encryption_status_e {  
234 - qpdf_es_encrypted = 1 << 0,  
235 - qpdf_es_password_incorrect = 1 << 1  
236 -}; 233 +enum qpdf_encryption_status_e { qpdf_es_encrypted = 1 << 0, qpdf_es_password_incorrect = 1 << 1 };
237 234
238 #endif /* QPDFCONSTANTS_H */ 235 #endif /* QPDFCONSTANTS_H */
include/qpdf/InputSource.hh
@@ -69,17 +69,9 @@ class QPDF_DLL_CLASS InputSource @@ -69,17 +69,9 @@ class QPDF_DLL_CLASS InputSource
69 // methods return true and leave the input source positioned 69 // methods return true and leave the input source positioned
70 // wherever check() left it at the end of the matching pattern. 70 // wherever check() left it at the end of the matching pattern.
71 QPDF_DLL 71 QPDF_DLL
72 - bool findFirst(  
73 - char const* start_chars,  
74 - qpdf_offset_t offset,  
75 - size_t len,  
76 - Finder& finder); 72 + bool findFirst(char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder);
77 QPDF_DLL 73 QPDF_DLL
78 - bool findLast(  
79 - char const* start_chars,  
80 - qpdf_offset_t offset,  
81 - size_t len,  
82 - Finder& finder); 74 + bool findLast(char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder);
83 75
84 virtual qpdf_offset_t findAndSkipNextEOL() = 0; 76 virtual qpdf_offset_t findAndSkipNextEOL() = 0;
85 virtual std::string const& getName() const = 0; 77 virtual std::string const& getName() const = 0;
@@ -144,8 +136,7 @@ InputSource::fastTell() @@ -144,8 +136,7 @@ InputSource::fastTell()
144 loadBuffer(); 136 loadBuffer();
145 } else { 137 } else {
146 auto curr = tell(); 138 auto curr = tell();
147 - if (curr < this->buf_start ||  
148 - curr >= (this->buf_start + this->buf_len)) { 139 + if (curr < this->buf_start || curr >= (this->buf_start + this->buf_len)) {
149 loadBuffer(); 140 loadBuffer();
150 } else { 141 } else {
151 this->last_offset = curr; 142 this->last_offset = curr;
include/qpdf/JSON.hh
@@ -104,19 +104,14 @@ class JSON @@ -104,19 +104,14 @@ class JSON
104 // the first item and always set it to false. 104 // the first item and always set it to false.
105 QPDF_DLL 105 QPDF_DLL
106 static void writeDictionaryItem( 106 static void writeDictionaryItem(
107 - Pipeline*,  
108 - bool& first,  
109 - std::string const& key,  
110 - JSON const& value,  
111 - size_t depth = 0); 107 + Pipeline*, bool& first, std::string const& key, JSON const& value, size_t depth = 0);
112 // Write just the key of a new dictionary item, useful if writing 108 // Write just the key of a new dictionary item, useful if writing
113 // nested structures. Calls writeNext. 109 // nested structures. Calls writeNext.
114 QPDF_DLL 110 QPDF_DLL
115 - static void writeDictionaryKey(  
116 - Pipeline* p, bool& first, std::string const& key, size_t depth = 0); 111 + static void
  112 + writeDictionaryKey(Pipeline* p, bool& first, std::string const& key, size_t depth = 0);
117 QPDF_DLL 113 QPDF_DLL
118 - static void writeArrayItem(  
119 - Pipeline*, bool& first, JSON const& element, size_t depth = 0); 114 + static void writeArrayItem(Pipeline*, bool& first, JSON const& element, size_t depth = 0);
120 // If writing nested structures incrementally, call writeNext 115 // If writing nested structures incrementally, call writeNext
121 // before opening a new array or container in the midst of an 116 // before opening a new array or container in the midst of an
122 // existing one. The `first` you pass to writeNext should be the 117 // existing one. The `first` you pass to writeNext should be the
@@ -188,8 +183,7 @@ class JSON @@ -188,8 +183,7 @@ class JSON
188 QPDF_DLL 183 QPDF_DLL
189 bool isNull() const; 184 bool isNull() const;
190 QPDF_DLL 185 QPDF_DLL
191 - bool forEachDictItem(  
192 - std::function<void(std::string const& key, JSON value)> fn) const; 186 + bool forEachDictItem(std::function<void(std::string const& key, JSON value)> fn) const;
193 QPDF_DLL 187 QPDF_DLL
194 bool forEachArrayItem(std::function<void(JSON value)> fn) const; 188 bool forEachArrayItem(std::function<void(JSON value)> fn) const;
195 189
@@ -239,8 +233,7 @@ class JSON @@ -239,8 +233,7 @@ class JSON
239 f_optional = 1 << 0, 233 f_optional = 1 << 0,
240 }; 234 };
241 QPDF_DLL 235 QPDF_DLL
242 - bool checkSchema(  
243 - JSON schema, unsigned long flags, std::list<std::string>& errors); 236 + bool checkSchema(JSON schema, unsigned long flags, std::list<std::string>& errors);
244 237
245 // Same as passing 0 for flags 238 // Same as passing 0 for flags
246 QPDF_DLL 239 QPDF_DLL
@@ -311,8 +304,7 @@ class JSON @@ -311,8 +304,7 @@ class JSON
311 // methods and decrementing on end methods. 304 // methods and decrementing on end methods.
312 305
313 QPDF_DLL 306 QPDF_DLL
314 - virtual bool  
315 - dictionaryItem(std::string const& key, JSON const& value) = 0; 307 + virtual bool dictionaryItem(std::string const& key, JSON const& value) = 0;
316 QPDF_DLL 308 QPDF_DLL
317 virtual bool arrayItem(JSON const& value) = 0; 309 virtual bool arrayItem(JSON const& value) = 0;
318 }; 310 };
@@ -339,8 +331,7 @@ class JSON @@ -339,8 +331,7 @@ class JSON
339 331
340 private: 332 private:
341 static std::string encode_string(std::string const& utf8); 333 static std::string encode_string(std::string const& utf8);
342 - static void  
343 - writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter); 334 + static void writeClose(Pipeline* p, bool first, size_t depth, char const* delimeter);
344 335
345 enum value_type_e { 336 enum value_type_e {
346 vt_none, 337 vt_none,
include/qpdf/Pl_Function.hh
@@ -54,15 +54,10 @@ class QPDF_DLL_CLASS Pl_Function: public Pipeline @@ -54,15 +54,10 @@ class QPDF_DLL_CLASS Pl_Function: public Pipeline
54 // is thrown. 54 // is thrown.
55 typedef int (*writer_c_t)(unsigned char const*, size_t, void*); 55 typedef int (*writer_c_t)(unsigned char const*, size_t, void*);
56 QPDF_DLL 56 QPDF_DLL
57 - Pl_Function(  
58 - char const* identifier, Pipeline* next, writer_c_t fn, void* udata); 57 + Pl_Function(char const* identifier, Pipeline* next, writer_c_t fn, void* udata);
59 typedef int (*writer_c_char_t)(char const*, size_t, void*); 58 typedef int (*writer_c_char_t)(char const*, size_t, void*);
60 QPDF_DLL 59 QPDF_DLL
61 - Pl_Function(  
62 - char const* identifier,  
63 - Pipeline* next,  
64 - writer_c_char_t fn,  
65 - void* udata); 60 + Pl_Function(char const* identifier, Pipeline* next, writer_c_char_t fn, void* udata);
66 61
67 QPDF_DLL 62 QPDF_DLL
68 virtual ~Pl_Function(); 63 virtual ~Pl_Function();
include/qpdf/Pl_QPDFTokenizer.hh
@@ -49,9 +49,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline @@ -49,9 +49,7 @@ class QPDF_DLL_CLASS Pl_QPDFTokenizer: public Pipeline
49 // provided, any output written by the filter will be discarded. 49 // provided, any output written by the filter will be discarded.
50 QPDF_DLL 50 QPDF_DLL
51 Pl_QPDFTokenizer( 51 Pl_QPDFTokenizer(
52 - char const* identifier,  
53 - QPDFObjectHandle::TokenFilter* filter,  
54 - Pipeline* next = nullptr); 52 + char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
55 QPDF_DLL 53 QPDF_DLL
56 virtual ~Pl_QPDFTokenizer(); 54 virtual ~Pl_QPDFTokenizer();
57 QPDF_DLL 55 QPDF_DLL
include/qpdf/QIntC.hh
@@ -78,9 +78,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion @@ -78,9 +78,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion
78 { 78 {
79 std::ostringstream msg; 79 std::ostringstream msg;
80 msg.imbue(std::locale::classic()); 80 msg.imbue(std::locale::classic());
81 - msg << "integer out of range converting " << i << " from a "  
82 - << sizeof(From) << "-byte unsigned type to a " << sizeof(To)  
83 - << "-byte unsigned type"; 81 + msg << "integer out of range converting " << i << " from a " << sizeof(From)
  82 + << "-byte unsigned type to a " << sizeof(To) << "-byte unsigned type";
84 throw std::range_error(msg.str()); 83 throw std::range_error(msg.str());
85 } 84 }
86 }; 85 };
@@ -93,8 +92,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion @@ -93,8 +92,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion
93 convert(From const& i) 92 convert(From const& i)
94 { 93 {
95 // From and To are both signed. 94 // From and To are both signed.
96 - if ((i < std::numeric_limits<To>::min()) ||  
97 - (i > std::numeric_limits<To>::max())) { 95 + if ((i < std::numeric_limits<To>::min()) || (i > std::numeric_limits<To>::max())) {
98 error(i); 96 error(i);
99 } 97 }
100 return static_cast<To>(i); 98 return static_cast<To>(i);
@@ -105,9 +103,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion @@ -105,9 +103,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion
105 { 103 {
106 std::ostringstream msg; 104 std::ostringstream msg;
107 msg.imbue(std::locale::classic()); 105 msg.imbue(std::locale::classic());
108 - msg << "integer out of range converting " << i << " from a "  
109 - << sizeof(From) << "-byte signed type to a " << sizeof(To)  
110 - << "-byte signed type"; 106 + msg << "integer out of range converting " << i << " from a " << sizeof(From)
  107 + << "-byte signed type to a " << sizeof(To) << "-byte signed type";
111 throw std::range_error(msg.str()); 108 throw std::range_error(msg.str());
112 } 109 }
113 }; 110 };
@@ -134,9 +131,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion @@ -134,9 +131,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion
134 { 131 {
135 std::ostringstream msg; 132 std::ostringstream msg;
136 msg.imbue(std::locale::classic()); 133 msg.imbue(std::locale::classic());
137 - msg << "integer out of range converting " << i << " from a "  
138 - << sizeof(From) << "-byte signed type to a " << sizeof(To)  
139 - << "-byte unsigned type"; 134 + msg << "integer out of range converting " << i << " from a " << sizeof(From)
  135 + << "-byte signed type to a " << sizeof(To) << "-byte unsigned type";
140 throw std::range_error(msg.str()); 136 throw std::range_error(msg.str());
141 } 137 }
142 }; 138 };
@@ -150,8 +146,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion @@ -150,8 +146,7 @@ namespace QIntC // QIntC = qpdf Integer Conversion
150 { 146 {
151 // From is unsigned, and to is signed. Convert To's max to the 147 // From is unsigned, and to is signed. Convert To's max to the
152 // unsigned version of To and compare i against that. 148 // unsigned version of To and compare i against that.
153 - auto maxval = static_cast<typename to_u<To>::type>(  
154 - std::numeric_limits<To>::max()); 149 + auto maxval = static_cast<typename to_u<To>::type>(std::numeric_limits<To>::max());
155 if (i > maxval) { 150 if (i > maxval) {
156 error(i); 151 error(i);
157 } 152 }
@@ -163,9 +158,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion @@ -163,9 +158,8 @@ namespace QIntC // QIntC = qpdf Integer Conversion
163 { 158 {
164 std::ostringstream msg; 159 std::ostringstream msg;
165 msg.imbue(std::locale::classic()); 160 msg.imbue(std::locale::classic());
166 - msg << "integer out of range converting " << i << " from a "  
167 - << sizeof(From) << "-byte unsigned type to a " << sizeof(To)  
168 - << "-byte signed type"; 161 + msg << "integer out of range converting " << i << " from a " << sizeof(From)
  162 + << "-byte unsigned type to a " << sizeof(To) << "-byte signed type";
169 throw std::range_error(msg.str()); 163 throw std::range_error(msg.str());
170 } 164 }
171 }; 165 };
@@ -263,15 +257,12 @@ namespace QIntC // QIntC = qpdf Integer Conversion @@ -263,15 +257,12 @@ namespace QIntC // QIntC = qpdf Integer Conversion
263 if ((delta > 0) && ((std::numeric_limits<T>::max() - cur) < delta)) { 257 if ((delta > 0) && ((std::numeric_limits<T>::max() - cur) < delta)) {
264 std::ostringstream msg; 258 std::ostringstream msg;
265 msg.imbue(std::locale::classic()); 259 msg.imbue(std::locale::classic());
266 - msg << "adding " << delta << " to " << cur  
267 - << " would cause an integer overflow"; 260 + msg << "adding " << delta << " to " << cur << " would cause an integer overflow";
268 throw std::range_error(msg.str()); 261 throw std::range_error(msg.str());
269 - } else if (  
270 - (delta < 0) && ((std::numeric_limits<T>::min() - cur) > delta)) { 262 + } else if ((delta < 0) && ((std::numeric_limits<T>::min() - cur) > delta)) {
271 std::ostringstream msg; 263 std::ostringstream msg;
272 msg.imbue(std::locale::classic()); 264 msg.imbue(std::locale::classic());
273 - msg << "adding " << delta << " to " << cur  
274 - << " would cause an integer underflow"; 265 + msg << "adding " << delta << " to " << cur << " would cause an integer underflow";
275 throw std::range_error(msg.str()); 266 throw std::range_error(msg.str());
276 } 267 }
277 } 268 }
@@ -296,12 +287,10 @@ namespace QIntC // QIntC = qpdf Integer Conversion @@ -296,12 +287,10 @@ namespace QIntC // QIntC = qpdf Integer Conversion
296 msg << "subtracting " << delta << " from " << cur 287 msg << "subtracting " << delta << " from " << cur
297 << " would cause an integer underflow"; 288 << " would cause an integer underflow";
298 throw std::range_error(msg.str()); 289 throw std::range_error(msg.str());
299 - } else if (  
300 - (delta < 0) && ((std::numeric_limits<T>::max() + delta) < cur)) { 290 + } else if ((delta < 0) && ((std::numeric_limits<T>::max() + delta) < cur)) {
301 std::ostringstream msg; 291 std::ostringstream msg;
302 msg.imbue(std::locale::classic()); 292 msg.imbue(std::locale::classic());
303 - msg << "subtracting " << delta << " from " << cur  
304 - << " would cause an integer overflow"; 293 + msg << "subtracting " << delta << " from " << cur << " would cause an integer overflow";
305 throw std::range_error(msg.str()); 294 throw std::range_error(msg.str());
306 } 295 }
307 } 296 }
include/qpdf/QPDF.hh
@@ -93,10 +93,7 @@ class QPDF @@ -93,10 +93,7 @@ class QPDF
93 // responsible for closing the file. 93 // responsible for closing the file.
94 QPDF_DLL 94 QPDF_DLL
95 void processFile( 95 void processFile(
96 - char const* description,  
97 - FILE* file,  
98 - bool close_file,  
99 - char const* password = nullptr); 96 + char const* description, FILE* file, bool close_file, char const* password = nullptr);
100 97
101 // Parse a PDF file loaded into a memory buffer. This works 98 // Parse a PDF file loaded into a memory buffer. This works
102 // exactly like processFile except that the PDF file is in memory 99 // exactly like processFile except that the PDF file is in memory
@@ -104,17 +101,13 @@ class QPDF @@ -104,17 +101,13 @@ class QPDF
104 // error message in place of the file name. 101 // error message in place of the file name.
105 QPDF_DLL 102 QPDF_DLL
106 void processMemoryFile( 103 void processMemoryFile(
107 - char const* description,  
108 - char const* buf,  
109 - size_t length,  
110 - char const* password = nullptr); 104 + char const* description, char const* buf, size_t length, char const* password = nullptr);
111 105
112 // Parse a PDF file loaded from a custom InputSource. If you have 106 // Parse a PDF file loaded from a custom InputSource. If you have
113 // your own method of retrieving a PDF file, you can subclass 107 // your own method of retrieving a PDF file, you can subclass
114 // InputSource and use this method. 108 // InputSource and use this method.
115 QPDF_DLL 109 QPDF_DLL
116 - void processInputSource(  
117 - std::shared_ptr<InputSource>, char const* password = nullptr); 110 + void processInputSource(std::shared_ptr<InputSource>, char const* password = nullptr);
118 111
119 // Create a PDF from an input source that contains JSON as written 112 // Create a PDF from an input source that contains JSON as written
120 // by writeJSON (or qpdf --json-output, version 2 or higher). The 113 // by writeJSON (or qpdf --json-output, version 2 or higher). The
@@ -234,8 +227,7 @@ class QPDF @@ -234,8 +227,7 @@ class QPDF
234 // QPDFStreamFilter classes. 227 // QPDFStreamFilter classes.
235 QPDF_DLL 228 QPDF_DLL
236 static void registerStreamFilter( 229 static void registerStreamFilter(
237 - std::string const& filter_name,  
238 - std::function<std::shared_ptr<QPDFStreamFilter>()> factory); 230 + std::string const& filter_name, std::function<std::shared_ptr<QPDFStreamFilter>()> factory);
239 231
240 // Parameter settings 232 // Parameter settings
241 233
@@ -260,8 +252,7 @@ class QPDF @@ -260,8 +252,7 @@ class QPDF
260 // configures a private logger, separating this object from the 252 // configures a private logger, separating this object from the
261 // default logger, and calls setOutputStreams on that logger. See 253 // default logger, and calls setOutputStreams on that logger. See
262 // QPDFLogger.hh for additional details. 254 // QPDFLogger.hh for additional details.
263 - [[deprecated(  
264 - "configure logger from getLogger() or call setLogger()")]] QPDF_DLL void 255 + [[deprecated("configure logger from getLogger() or call setLogger()")]] QPDF_DLL void
265 setOutputStreams(std::ostream* out_stream, std::ostream* err_stream); 256 setOutputStreams(std::ostream* out_stream, std::ostream* err_stream);
266 257
267 // If true, ignore any cross-reference streams in a hybrid file 258 // If true, ignore any cross-reference streams in a hybrid file
@@ -481,8 +472,7 @@ class QPDF @@ -481,8 +472,7 @@ class QPDF
481 // reserved object. After this call, reserved will be a reference 472 // reserved object. After this call, reserved will be a reference
482 // to replacement. 473 // to replacement.
483 QPDF_DLL 474 QPDF_DLL
484 - void  
485 - replaceReserved(QPDFObjectHandle reserved, QPDFObjectHandle replacement); 475 + void replaceReserved(QPDFObjectHandle reserved, QPDFObjectHandle replacement);
486 476
487 // Copy an object from another QPDF to this one. Starting with 477 // Copy an object from another QPDF to this one. Starting with
488 // qpdf version 8.3.0, it is no longer necessary to keep the 478 // qpdf version 8.3.0, it is no longer necessary to keep the
@@ -657,8 +647,8 @@ class QPDF @@ -657,8 +647,8 @@ class QPDF
657 int encryption_V, 647 int encryption_V,
658 int encryption_R); 648 int encryption_R);
659 QPDF_DLL 649 QPDF_DLL
660 - static std::string compute_encryption_key(  
661 - std::string const& password, EncryptionData const& data); 650 + static std::string
  651 + compute_encryption_key(std::string const& password, EncryptionData const& data);
662 652
663 QPDF_DLL 653 QPDF_DLL
664 static void compute_encryption_O_U( 654 static void compute_encryption_O_U(
@@ -843,8 +833,7 @@ class QPDF @@ -843,8 +833,7 @@ class QPDF
843 QPDF_DLL 833 QPDF_DLL
844 void addPage(QPDFObjectHandle newpage, bool first); 834 void addPage(QPDFObjectHandle newpage, bool first);
845 QPDF_DLL 835 QPDF_DLL
846 - void  
847 - addPageAt(QPDFObjectHandle newpage, bool before, QPDFObjectHandle refpage); 836 + void addPageAt(QPDFObjectHandle newpage, bool before, QPDFObjectHandle refpage);
848 QPDF_DLL 837 QPDF_DLL
849 void removePage(QPDFObjectHandle page); 838 void removePage(QPDFObjectHandle page);
850 // End legacy page helpers 839 // End legacy page helpers
@@ -866,8 +855,7 @@ class QPDF @@ -866,8 +855,7 @@ class QPDF
866 std::vector<QPDFObjectHandle>& part8, 855 std::vector<QPDFObjectHandle>& part8,
867 std::vector<QPDFObjectHandle>& part9) 856 std::vector<QPDFObjectHandle>& part9)
868 { 857 {
869 - qpdf.getLinearizedParts(  
870 - object_stream_data, part4, part6, part7, part8, part9); 858 + qpdf.getLinearizedParts(object_stream_data, part4, part6, part7, part8, part9);
871 } 859 }
872 860
873 static void 861 static void
@@ -880,8 +868,7 @@ class QPDF @@ -880,8 +868,7 @@ class QPDF
880 int& S, 868 int& S,
881 int& O) 869 int& O)
882 { 870 {
883 - return qpdf.generateHintStream(  
884 - xref, lengths, obj_renumber, hint_stream, S, O); 871 + return qpdf.generateHintStream(xref, lengths, obj_renumber, hint_stream, S, O);
885 } 872 }
886 873
887 static void 874 static void
@@ -919,10 +906,7 @@ class QPDF @@ -919,10 +906,7 @@ class QPDF
919 906
920 private: 907 private:
921 static void 908 static void
922 - copyStreamData(  
923 - QPDF* qpdf,  
924 - QPDFObjectHandle const& dest,  
925 - QPDFObjectHandle const& src) 909 + copyStreamData(QPDF* qpdf, QPDFObjectHandle const& dest, QPDFObjectHandle const& src)
926 { 910 {
927 qpdf->copyStreamData(dest, src); 911 qpdf->copyStreamData(dest, src);
928 } 912 }
@@ -968,13 +952,7 @@ class QPDF @@ -968,13 +952,7 @@ class QPDF
968 bool will_retry) 952 bool will_retry)
969 { 953 {
970 return qpdf->pipeStreamData( 954 return qpdf->pipeStreamData(
971 - og,  
972 - offset,  
973 - length,  
974 - dict,  
975 - pipeline,  
976 - suppress_warnings,  
977 - will_retry); 955 + og, offset, length, dict, pipeline, suppress_warnings, will_retry);
978 } 956 }
979 }; 957 };
980 958
@@ -1096,16 +1074,13 @@ class QPDF @@ -1096,16 +1074,13 @@ class QPDF
1096 Pipeline* pipeline, 1074 Pipeline* pipeline,
1097 bool suppress_warnings, 1075 bool suppress_warnings,
1098 bool will_retry) override; 1076 bool will_retry) override;
1099 - void registerForeignStream(  
1100 - QPDFObjGen const& local_og, QPDFObjectHandle foreign_stream);  
1101 - void registerForeignStream(  
1102 - QPDFObjGen const& local_og, std::shared_ptr<ForeignStreamData>); 1077 + void registerForeignStream(QPDFObjGen const& local_og, QPDFObjectHandle foreign_stream);
  1078 + void registerForeignStream(QPDFObjGen const& local_og, std::shared_ptr<ForeignStreamData>);
1103 1079
1104 private: 1080 private:
1105 QPDF& destination_qpdf; 1081 QPDF& destination_qpdf;
1106 std::map<QPDFObjGen, QPDFObjectHandle> foreign_streams; 1082 std::map<QPDFObjGen, QPDFObjectHandle> foreign_streams;
1107 - std::map<QPDFObjGen, std::shared_ptr<ForeignStreamData>>  
1108 - foreign_stream_data; 1083 + std::map<QPDFObjGen, std::shared_ptr<ForeignStreamData>> foreign_stream_data;
1109 }; 1084 };
1110 1085
1111 class StringDecrypter: public QPDFObjectHandle::StringDecrypter 1086 class StringDecrypter: public QPDFObjectHandle::StringDecrypter
@@ -1148,29 +1123,21 @@ class QPDF @@ -1148,29 +1123,21 @@ class QPDF
1148 void read_xref(qpdf_offset_t offset); 1123 void read_xref(qpdf_offset_t offset);
1149 bool resolveXRefTable(); 1124 bool resolveXRefTable();
1150 void reconstruct_xref(QPDFExc& e); 1125 void reconstruct_xref(QPDFExc& e);
1151 - bool  
1152 - parse_xrefFirst(std::string const& line, int& obj, int& num, int& bytes);  
1153 - bool parse_xrefEntry(  
1154 - std::string const& line, qpdf_offset_t& f1, int& f2, char& type); 1126 + bool parse_xrefFirst(std::string const& line, int& obj, int& num, int& bytes);
  1127 + bool parse_xrefEntry(std::string const& line, qpdf_offset_t& f1, int& f2, char& type);
1155 qpdf_offset_t read_xrefTable(qpdf_offset_t offset); 1128 qpdf_offset_t read_xrefTable(qpdf_offset_t offset);
1156 qpdf_offset_t read_xrefStream(qpdf_offset_t offset); 1129 qpdf_offset_t read_xrefStream(qpdf_offset_t offset);
1157 - qpdf_offset_t  
1158 - processXRefStream(qpdf_offset_t offset, QPDFObjectHandle& xref_stream);  
1159 - void insertXrefEntry(  
1160 - int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite = false);  
1161 - void setLastObjectDescription(  
1162 - std::string const& description, QPDFObjGen const& og); 1130 + qpdf_offset_t processXRefStream(qpdf_offset_t offset, QPDFObjectHandle& xref_stream);
  1131 + void insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite = false);
  1132 + void setLastObjectDescription(std::string const& description, QPDFObjGen const& og);
1163 QPDFObjectHandle readObject( 1133 QPDFObjectHandle readObject(
1164 std::shared_ptr<InputSource>, 1134 std::shared_ptr<InputSource>,
1165 std::string const& description, 1135 std::string const& description,
1166 QPDFObjGen const& og, 1136 QPDFObjGen const& og,
1167 bool in_object_stream); 1137 bool in_object_stream);
1168 size_t recoverStreamLength( 1138 size_t recoverStreamLength(
1169 - std::shared_ptr<InputSource> input,  
1170 - QPDFObjGen const& og,  
1171 - qpdf_offset_t stream_offset);  
1172 - QPDFTokenizer::Token  
1173 - readToken(std::shared_ptr<InputSource>, size_t max_len = 0); 1139 + std::shared_ptr<InputSource> input, QPDFObjGen const& og, qpdf_offset_t stream_offset);
  1140 + QPDFTokenizer::Token readToken(std::shared_ptr<InputSource>, size_t max_len = 0);
1174 1141
1175 QPDFObjectHandle readObjectAtOffset( 1142 QPDFObjectHandle readObjectAtOffset(
1176 bool attempt_recovery, 1143 bool attempt_recovery,
@@ -1185,10 +1152,8 @@ class QPDF @@ -1185,10 +1152,8 @@ class QPDF
1185 QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og); 1152 QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og);
1186 QPDFObjectHandle reserveStream(QPDFObjGen const& og); 1153 QPDFObjectHandle reserveStream(QPDFObjGen const& og);
1187 QPDFObjGen nextObjGen(); 1154 QPDFObjGen nextObjGen();
1188 - QPDFObjectHandle  
1189 - newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);  
1190 - QPDFObjectHandle  
1191 - makeIndirectFromQPDFObject(std::shared_ptr<QPDFObject> const& obj); 1155 + QPDFObjectHandle newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);
  1156 + QPDFObjectHandle makeIndirectFromQPDFObject(std::shared_ptr<QPDFObject> const& obj);
1192 bool isCached(QPDFObjGen const& og); 1157 bool isCached(QPDFObjGen const& og);
1193 bool isUnresolved(QPDFObjGen const& og); 1158 bool isUnresolved(QPDFObjGen const& og);
1194 void updateCache( 1159 void updateCache(
@@ -1205,10 +1170,7 @@ class QPDF @@ -1205,10 +1170,7 @@ class QPDF
1205 std::shared_ptr<InputSource> const& input, 1170 std::shared_ptr<InputSource> const& input,
1206 qpdf_offset_t offset, 1171 qpdf_offset_t offset,
1207 std::string const& message); 1172 std::string const& message);
1208 - QPDFExc damagedPDF(  
1209 - std::string const& object,  
1210 - qpdf_offset_t offset,  
1211 - std::string const& message); 1173 + QPDFExc damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message);
1212 QPDFExc damagedPDF(std::string const& object, std::string const& message); 1174 QPDFExc damagedPDF(std::string const& object, std::string const& message);
1213 QPDFExc damagedPDF(qpdf_offset_t offset, std::string const& message); 1175 QPDFExc damagedPDF(qpdf_offset_t offset, std::string const& message);
1214 QPDFExc damagedPDF(std::string const& message); 1176 QPDFExc damagedPDF(std::string const& message);
@@ -1223,10 +1185,7 @@ class QPDF @@ -1223,10 +1185,7 @@ class QPDF
1223 bool suppress_warnings, 1185 bool suppress_warnings,
1224 bool will_retry); 1186 bool will_retry);
1225 bool pipeForeignStreamData( 1187 bool pipeForeignStreamData(
1226 - std::shared_ptr<ForeignStreamData>,  
1227 - Pipeline*,  
1228 - bool suppress_warnings,  
1229 - bool will_retry); 1188 + std::shared_ptr<ForeignStreamData>, Pipeline*, bool suppress_warnings, bool will_retry);
1230 static bool pipeStreamData( 1189 static bool pipeStreamData(
1231 std::shared_ptr<QPDF::EncryptionParameters> encp, 1190 std::shared_ptr<QPDF::EncryptionParameters> encp,
1232 std::shared_ptr<InputSource> file, 1191 std::shared_ptr<InputSource> file,
@@ -1269,31 +1228,24 @@ class QPDF @@ -1269,31 +1228,24 @@ class QPDF
1269 // methods to support page handling 1228 // methods to support page handling
1270 1229
1271 void getAllPagesInternal( 1230 void getAllPagesInternal(
1272 - QPDFObjectHandle cur_pages,  
1273 - QPDFObjGen::set& visited,  
1274 - QPDFObjGen::set& seen); 1231 + QPDFObjectHandle cur_pages, QPDFObjGen::set& visited, QPDFObjGen::set& seen);
1275 void insertPage(QPDFObjectHandle newpage, int pos); 1232 void insertPage(QPDFObjectHandle newpage, int pos);
1276 void flattenPagesTree(); 1233 void flattenPagesTree();
1277 - void insertPageobjToPage(  
1278 - QPDFObjectHandle const& obj, int pos, bool check_duplicate); 1234 + void insertPageobjToPage(QPDFObjectHandle const& obj, int pos, bool check_duplicate);
1279 1235
1280 // methods to support encryption -- implemented in QPDF_encryption.cc 1236 // methods to support encryption -- implemented in QPDF_encryption.cc
1281 static encryption_method_e 1237 static encryption_method_e
1282 interpretCF(std::shared_ptr<EncryptionParameters> encp, QPDFObjectHandle); 1238 interpretCF(std::shared_ptr<EncryptionParameters> encp, QPDFObjectHandle);
1283 void initializeEncryption(); 1239 void initializeEncryption();
1284 - static std::string getKeyForObject(  
1285 - std::shared_ptr<EncryptionParameters> encp,  
1286 - QPDFObjGen const& og,  
1287 - bool use_aes); 1240 + static std::string
  1241 + getKeyForObject(std::shared_ptr<EncryptionParameters> encp, QPDFObjGen const& og, bool use_aes);
1288 void decryptString(std::string&, QPDFObjGen const& og); 1242 void decryptString(std::string&, QPDFObjGen const& og);
1289 - static std::string compute_encryption_key_from_password(  
1290 - std::string const& password, EncryptionData const& data);  
1291 - static std::string recover_encryption_key_with_password(  
1292 - std::string const& password, EncryptionData const& data); 1243 + static std::string
  1244 + compute_encryption_key_from_password(std::string const& password, EncryptionData const& data);
  1245 + static std::string
  1246 + recover_encryption_key_with_password(std::string const& password, EncryptionData const& data);
1293 static std::string recover_encryption_key_with_password( 1247 static std::string recover_encryption_key_with_password(
1294 - std::string const& password,  
1295 - EncryptionData const& data,  
1296 - bool& perms_valid); 1248 + std::string const& password, EncryptionData const& data, bool& perms_valid);
1297 static void decryptStream( 1249 static void decryptStream(
1298 std::shared_ptr<EncryptionParameters> encp, 1250 std::shared_ptr<EncryptionParameters> encp,
1299 std::shared_ptr<InputSource> file, 1251 std::shared_ptr<InputSource> file,
@@ -1304,12 +1256,10 @@ class QPDF @@ -1304,12 +1256,10 @@ class QPDF
1304 std::vector<std::shared_ptr<Pipeline>>& heap); 1256 std::vector<std::shared_ptr<Pipeline>>& heap);
1305 1257
1306 // Methods to support object copying 1258 // Methods to support object copying
1307 - void  
1308 - reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);  
1309 - QPDFObjectHandle replaceForeignIndirectObjects(  
1310 - QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);  
1311 - void  
1312 - copyStreamData(QPDFObjectHandle dest_stream, QPDFObjectHandle src_stream); 1259 + void reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);
  1260 + QPDFObjectHandle
  1261 + replaceForeignIndirectObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top);
  1262 + void copyStreamData(QPDFObjectHandle dest_stream, QPDFObjectHandle src_stream);
1313 1263
1314 // Linearization Hint table structures. 1264 // Linearization Hint table structures.
1315 // Naming conventions: 1265 // Naming conventions:
@@ -1538,14 +1488,7 @@ class QPDF @@ -1538,14 +1488,7 @@ class QPDF
1538 class ObjUser 1488 class ObjUser
1539 { 1489 {
1540 public: 1490 public:
1541 - enum user_e {  
1542 - ou_bad,  
1543 - ou_page,  
1544 - ou_thumb,  
1545 - ou_trailer_key,  
1546 - ou_root_key,  
1547 - ou_root  
1548 - }; 1491 + enum user_e { ou_bad, ou_page, ou_thumb, ou_trailer_key, ou_root_key, ou_root };
1549 1492
1550 // type is set to ou_bad 1493 // type is set to ou_bad
1551 ObjUser(); 1494 ObjUser();
@@ -1598,29 +1541,25 @@ class QPDF @@ -1598,29 +1541,25 @@ class QPDF
1598 bool checkLinearizationInternal(); 1541 bool checkLinearizationInternal();
1599 void dumpLinearizationDataInternal(); 1542 void dumpLinearizationDataInternal();
1600 void linearizationWarning(std::string_view); 1543 void linearizationWarning(std::string_view);
1601 - QPDFObjectHandle  
1602 - readHintStream(Pipeline&, qpdf_offset_t offset, size_t length); 1544 + QPDFObjectHandle readHintStream(Pipeline&, qpdf_offset_t offset, size_t length);
1603 void readHPageOffset(BitStream); 1545 void readHPageOffset(BitStream);
1604 void readHSharedObject(BitStream); 1546 void readHSharedObject(BitStream);
1605 void readHGeneric(BitStream, HGeneric&); 1547 void readHGeneric(BitStream, HGeneric&);
1606 qpdf_offset_t maxEnd(ObjUser const& ou); 1548 qpdf_offset_t maxEnd(ObjUser const& ou);
1607 qpdf_offset_t getLinearizationOffset(QPDFObjGen const&); 1549 qpdf_offset_t getLinearizationOffset(QPDFObjGen const&);
1608 - QPDFObjectHandle getUncompressedObject(  
1609 - QPDFObjectHandle&, std::map<int, int> const& object_stream_data); 1550 + QPDFObjectHandle
  1551 + getUncompressedObject(QPDFObjectHandle&, std::map<int, int> const& object_stream_data);
1610 int lengthNextN(int first_object, int n); 1552 int lengthNextN(int first_object, int n);
1611 - void checkHPageOffset(  
1612 - std::vector<QPDFObjectHandle> const& pages,  
1613 - std::map<int, int>& idx_to_obj);  
1614 - void checkHSharedObject(  
1615 - std::vector<QPDFObjectHandle> const& pages,  
1616 - std::map<int, int>& idx_to_obj); 1553 + void
  1554 + checkHPageOffset(std::vector<QPDFObjectHandle> const& pages, std::map<int, int>& idx_to_obj);
  1555 + void
  1556 + checkHSharedObject(std::vector<QPDFObjectHandle> const& pages, std::map<int, int>& idx_to_obj);
1617 void checkHOutlines(); 1557 void checkHOutlines();
1618 void dumpHPageOffset(); 1558 void dumpHPageOffset();
1619 void dumpHSharedObject(); 1559 void dumpHSharedObject();
1620 void dumpHGeneric(HGeneric&); 1560 void dumpHGeneric(HGeneric&);
1621 qpdf_offset_t adjusted_offset(qpdf_offset_t offset); 1561 qpdf_offset_t adjusted_offset(qpdf_offset_t offset);
1622 - void  
1623 - calculateLinearizationData(std::map<int, int> const& object_stream_data); 1562 + void calculateLinearizationData(std::map<int, int> const& object_stream_data);
1624 void pushOutlinesToPart( 1563 void pushOutlinesToPart(
1625 std::vector<QPDFObjectHandle>& part, 1564 std::vector<QPDFObjectHandle>& part,
1626 std::set<QPDFObjGen>& lc_outlines, 1565 std::set<QPDFObjGen>& lc_outlines,
@@ -1648,8 +1587,7 @@ class QPDF @@ -1648,8 +1587,7 @@ class QPDF
1648 1587
1649 // Methods to support optimization 1588 // Methods to support optimization
1650 1589
1651 - void  
1652 - pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys); 1590 + void pushInheritedAttributesToPage(bool allow_changes, bool warn_skipped_keys);
1653 void pushInheritedAttributesToPageInternal( 1591 void pushInheritedAttributesToPageInternal(
1654 QPDFObjectHandle, 1592 QPDFObjectHandle,
1655 std::map<std::string, std::vector<QPDFObjectHandle>>&, 1593 std::map<std::string, std::vector<QPDFObjectHandle>>&,
@@ -1681,11 +1619,7 @@ class QPDF @@ -1681,11 +1619,7 @@ class QPDF
1681 qpdf_json_stream_data_e, 1619 qpdf_json_stream_data_e,
1682 std::string const& file_prefix); 1620 std::string const& file_prefix);
1683 void writeJSONObject( 1621 void writeJSONObject(
1684 - int version,  
1685 - Pipeline* p,  
1686 - bool& first,  
1687 - std::string const& key,  
1688 - QPDFObjectHandle&); 1622 + int version, Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle&);
1689 1623
1690 // Type conversion helper methods 1624 // Type conversion helper methods
1691 template <typename T> 1625 template <typename T>
include/qpdf/QPDFAcroFormDocumentHelper.hh
@@ -148,18 +148,15 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper @@ -148,18 +148,15 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
148 // underlying object will typically be the same as the underlying 148 // underlying object will typically be the same as the underlying
149 // object for the field. 149 // object for the field.
150 QPDF_DLL 150 QPDF_DLL
151 - std::vector<QPDFAnnotationObjectHelper>  
152 - getAnnotationsForField(QPDFFormFieldObjectHelper); 151 + std::vector<QPDFAnnotationObjectHelper> getAnnotationsForField(QPDFFormFieldObjectHelper);
153 152
154 // Return annotations of subtype /Widget for a page. 153 // Return annotations of subtype /Widget for a page.
155 QPDF_DLL 154 QPDF_DLL
156 - std::vector<QPDFAnnotationObjectHelper>  
157 - getWidgetAnnotationsForPage(QPDFPageObjectHelper); 155 + std::vector<QPDFAnnotationObjectHelper> getWidgetAnnotationsForPage(QPDFPageObjectHelper);
158 156
159 // Return top-level form fields for a page. 157 // Return top-level form fields for a page.
160 QPDF_DLL 158 QPDF_DLL
161 - std::vector<QPDFFormFieldObjectHelper>  
162 - getFormFieldsForPage(QPDFPageObjectHelper); 159 + std::vector<QPDFFormFieldObjectHelper> getFormFieldsForPage(QPDFPageObjectHelper);
163 160
164 // Return the terminal field that is associated with this 161 // Return the terminal field that is associated with this
165 // annotation. If the annotation dictionary is merged with the 162 // annotation. If the annotation dictionary is merged with the
@@ -251,10 +248,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper @@ -251,10 +248,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
251 private: 248 private:
252 void analyze(); 249 void analyze();
253 void traverseField( 250 void traverseField(
254 - QPDFObjectHandle field,  
255 - QPDFObjectHandle parent,  
256 - int depth,  
257 - QPDFObjGen::set& visited); 251 + QPDFObjectHandle field, QPDFObjectHandle parent, int depth, QPDFObjGen::set& visited);
258 QPDFObjectHandle getOrCreateAcroForm(); 252 QPDFObjectHandle getOrCreateAcroForm();
259 void adjustInheritedFields( 253 void adjustInheritedFields(
260 QPDFObjectHandle obj, 254 QPDFObjectHandle obj,
@@ -264,11 +258,9 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper @@ -264,11 +258,9 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
264 int from_default_q); 258 int from_default_q);
265 void adjustDefaultAppearances( 259 void adjustDefaultAppearances(
266 QPDFObjectHandle obj, 260 QPDFObjectHandle obj,
267 - std::map<std::string, std::map<std::string, std::string>> const&  
268 - dr_map); 261 + std::map<std::string, std::map<std::string, std::string>> const& dr_map);
269 void adjustAppearanceStream( 262 void adjustAppearanceStream(
270 - QPDFObjectHandle stream,  
271 - std::map<std::string, std::map<std::string, std::string>> dr_map); 263 + QPDFObjectHandle stream, std::map<std::string, std::map<std::string, std::string>> dr_map);
272 264
273 class Members 265 class Members
274 { 266 {
@@ -283,8 +275,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper @@ -283,8 +275,7 @@ class QPDFAcroFormDocumentHelper: public QPDFDocumentHelper
283 Members(Members const&) = delete; 275 Members(Members const&) = delete;
284 276
285 bool cache_valid; 277 bool cache_valid;
286 - std::map<QPDFObjGen, std::vector<QPDFAnnotationObjectHelper>>  
287 - field_to_annotations; 278 + std::map<QPDFObjGen, std::vector<QPDFAnnotationObjectHelper>> field_to_annotations;
288 std::map<QPDFObjGen, QPDFFormFieldObjectHelper> annotation_to_field; 279 std::map<QPDFObjGen, QPDFFormFieldObjectHelper> annotation_to_field;
289 std::map<QPDFObjGen, std::string> field_to_name; 280 std::map<QPDFObjGen, std::string> field_to_name;
290 std::map<std::string, std::set<QPDFObjGen>> name_to_fields; 281 std::map<std::string, std::set<QPDFObjGen>> name_to_fields;
include/qpdf/QPDFAnnotationObjectHelper.hh
@@ -76,8 +76,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper @@ -76,8 +76,7 @@ class QPDFAnnotationObjectHelper: public QPDFObjectHelper
76 // which appearance stream is desired. If not specified, the 76 // which appearance stream is desired. If not specified, the
77 // appearance state in "/AS" will used. 77 // appearance state in "/AS" will used.
78 QPDF_DLL 78 QPDF_DLL
79 - QPDFObjectHandle getAppearanceStream(  
80 - std::string const& which, std::string const& state = ""); 79 + QPDFObjectHandle getAppearanceStream(std::string const& which, std::string const& state = "");
81 80
82 // Generate text suitable for addition to the containing page's 81 // Generate text suitable for addition to the containing page's
83 // content stream that draws this annotation's appearance stream 82 // content stream that draws this annotation's appearance stream
include/qpdf/QPDFCryptoImpl.hh
@@ -77,10 +77,8 @@ class QPDF_DLL_CLASS QPDFCryptoImpl @@ -77,10 +77,8 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
77 virtual void RC4_init(unsigned char const* key_data, int key_len = -1) = 0; 77 virtual void RC4_init(unsigned char const* key_data, int key_len = -1) = 0;
78 // out_data = 0 means to encrypt/decrypt in place 78 // out_data = 0 means to encrypt/decrypt in place
79 QPDF_DLL 79 QPDF_DLL
80 - virtual void RC4_process(  
81 - unsigned char const* in_data,  
82 - size_t len,  
83 - unsigned char* out_data = nullptr) = 0; 80 + virtual void
  81 + RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data = nullptr) = 0;
84 QPDF_DLL 82 QPDF_DLL
85 virtual void RC4_finalize() = 0; 83 virtual void RC4_finalize() = 0;
86 84
@@ -93,8 +91,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl @@ -93,8 +91,7 @@ class QPDF_DLL_CLASS QPDFCryptoImpl
93 bool cbc_mode, 91 bool cbc_mode,
94 unsigned char* cbc_block) = 0; 92 unsigned char* cbc_block) = 0;
95 QPDF_DLL 93 QPDF_DLL
96 - virtual void  
97 - rijndael_process(unsigned char* in_data, unsigned char* out_data) = 0; 94 + virtual void rijndael_process(unsigned char* in_data, unsigned char* out_data) = 0;
98 QPDF_DLL 95 QPDF_DLL
99 virtual void rijndael_finalize() = 0; 96 virtual void rijndael_finalize() = 0;
100 }; 97 };
include/qpdf/QPDFCryptoProvider.hh
@@ -78,8 +78,7 @@ class QPDFCryptoProvider @@ -78,8 +78,7 @@ class QPDFCryptoProvider
78 78
79 static QPDFCryptoProvider& getInstance(); 79 static QPDFCryptoProvider& getInstance();
80 80
81 - std::shared_ptr<QPDFCryptoImpl>  
82 - getImpl_internal(std::string const& name) const; 81 + std::shared_ptr<QPDFCryptoImpl> getImpl_internal(std::string const& name) const;
83 template <typename T> 82 template <typename T>
84 void registerImpl_internal(std::string const& name); 83 void registerImpl_internal(std::string const& name);
85 void setDefaultProvider_internal(std::string const& name); 84 void setDefaultProvider_internal(std::string const& name);
include/qpdf/QPDFEFStreamObjectHelper.hh
@@ -75,11 +75,9 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper @@ -75,11 +75,9 @@ class QPDFEFStreamObjectHelper: public QPDFObjectHelper
75 // checksum and size are computed automatically and stored. Other 75 // checksum and size are computed automatically and stored. Other
76 // parameters may be supplied using setters defined below. 76 // parameters may be supplied using setters defined below.
77 QPDF_DLL 77 QPDF_DLL
78 - static QPDFEFStreamObjectHelper  
79 - createEFStream(QPDF& qpdf, std::shared_ptr<Buffer> data); 78 + static QPDFEFStreamObjectHelper createEFStream(QPDF& qpdf, std::shared_ptr<Buffer> data);
80 QPDF_DLL 79 QPDF_DLL
81 - static QPDFEFStreamObjectHelper  
82 - createEFStream(QPDF& qpdf, std::string const& data); 80 + static QPDFEFStreamObjectHelper createEFStream(QPDF& qpdf, std::string const& data);
83 // The provider function must write the data to the given 81 // The provider function must write the data to the given
84 // pipeline. The function may be called multiple times by the qpdf 82 // pipeline. The function may be called multiple times by the qpdf
85 // library. You can pass QUtil::file_provider(filename) as the 83 // library. You can pass QUtil::file_provider(filename) as the
include/qpdf/QPDFEmbeddedFileDocumentHelper.hh
@@ -48,19 +48,16 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper @@ -48,19 +48,16 @@ class QPDFEmbeddedFileDocumentHelper: public QPDFDocumentHelper
48 bool hasEmbeddedFiles() const; 48 bool hasEmbeddedFiles() const;
49 49
50 QPDF_DLL 50 QPDF_DLL
51 - std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>>  
52 - getEmbeddedFiles(); 51 + std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>> getEmbeddedFiles();
53 52
54 // If an embedded file with the given name exists, return a 53 // If an embedded file with the given name exists, return a
55 // (shared) pointer to it. Otherwise, return nullptr. 54 // (shared) pointer to it. Otherwise, return nullptr.
56 QPDF_DLL 55 QPDF_DLL
57 - std::shared_ptr<QPDFFileSpecObjectHelper>  
58 - getEmbeddedFile(std::string const& name); 56 + std::shared_ptr<QPDFFileSpecObjectHelper> getEmbeddedFile(std::string const& name);
59 57
60 // Add or replace an attachment 58 // Add or replace an attachment
61 QPDF_DLL 59 QPDF_DLL
62 - void replaceEmbeddedFile(  
63 - std::string const& name, QPDFFileSpecObjectHelper const&); 60 + void replaceEmbeddedFile(std::string const& name, QPDFFileSpecObjectHelper const&);
64 61
65 // Remove an embedded file if present. Return value is true if the 62 // Remove an embedded file if present. Return value is true if the
66 // file was present and was removed. This method not only removes 63 // file was present and was removed. This method not only removes
include/qpdf/QPDFFileSpecObjectHelper.hh
@@ -77,16 +77,16 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper @@ -77,16 +77,16 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
77 // filename, and attach the contents of the specified file as data 77 // filename, and attach the contents of the specified file as data
78 // in an embedded file stream. 78 // in an embedded file stream.
79 QPDF_DLL 79 QPDF_DLL
80 - static QPDFFileSpecObjectHelper createFileSpec(  
81 - QPDF& qpdf, std::string const& filename, std::string const& fullpath); 80 + static QPDFFileSpecObjectHelper
  81 + createFileSpec(QPDF& qpdf, std::string const& filename, std::string const& fullpath);
82 82
83 // Create a new filespec as an indirect object with the given 83 // Create a new filespec as an indirect object with the given
84 // unicode filename and embedded file stream. The file name will 84 // unicode filename and embedded file stream. The file name will
85 // be used as both /UF and /F. If you need to override, call 85 // be used as both /UF and /F. If you need to override, call
86 // setFilename. 86 // setFilename.
87 QPDF_DLL 87 QPDF_DLL
88 - static QPDFFileSpecObjectHelper createFileSpec(  
89 - QPDF& qpdf, std::string const& filename, QPDFEFStreamObjectHelper); 88 + static QPDFFileSpecObjectHelper
  89 + createFileSpec(QPDF& qpdf, std::string const& filename, QPDFEFStreamObjectHelper);
90 90
91 QPDF_DLL 91 QPDF_DLL
92 QPDFFileSpecObjectHelper& setDescription(std::string const&); 92 QPDFFileSpecObjectHelper& setDescription(std::string const&);
@@ -96,8 +96,8 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper @@ -96,8 +96,8 @@ class QPDFFileSpecObjectHelper: public QPDFObjectHelper
96 // QPDFObjectHandle literally, preserving whatever encoding it 96 // QPDFObjectHandle literally, preserving whatever encoding it
97 // might happen to have. 97 // might happen to have.
98 QPDF_DLL 98 QPDF_DLL
99 - QPDFFileSpecObjectHelper& setFilename(  
100 - std::string const& unicode_name, std::string const& compat_name = ""); 99 + QPDFFileSpecObjectHelper&
  100 + setFilename(std::string const& unicode_name, std::string const& compat_name = "");
101 101
102 private: 102 private:
103 class Members 103 class Members
include/qpdf/QPDFFormFieldObjectHelper.hh
@@ -183,8 +183,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper @@ -183,8 +183,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
183 // of a field, use QPDFAcroFormDocumentHelper::setFormFieldName 183 // of a field, use QPDFAcroFormDocumentHelper::setFormFieldName
184 // instead. 184 // instead.
185 QPDF_DLL 185 QPDF_DLL
186 - void  
187 - setFieldAttribute(std::string const& key, std::string const& utf8_value); 186 + void setFieldAttribute(std::string const& key, std::string const& utf8_value);
188 187
189 // Set /V (field value) to the given value. If need_appearances is 188 // Set /V (field value) to the given value. If need_appearances is
190 // true and the field type is either /Tx (text) or /Ch (choice), 189 // true and the field type is either /Tx (text) or /Ch (choice),
@@ -218,8 +217,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper @@ -218,8 +217,7 @@ class QPDFFormFieldObjectHelper: public QPDFObjectHelper
218 void setRadioButtonValue(QPDFObjectHandle name); 217 void setRadioButtonValue(QPDFObjectHandle name);
219 void setCheckBoxValue(bool value); 218 void setCheckBoxValue(bool value);
220 void generateTextAppearance(QPDFAnnotationObjectHelper&); 219 void generateTextAppearance(QPDFAnnotationObjectHelper&);
221 - QPDFObjectHandle getFontFromResource(  
222 - QPDFObjectHandle resources, std::string const& font_name); 220 + QPDFObjectHandle getFontFromResource(QPDFObjectHandle resources, std::string const& font_name);
223 221
224 class Members 222 class Members
225 { 223 {
include/qpdf/QPDFJob.hh
@@ -83,8 +83,7 @@ class QPDFJob @@ -83,8 +83,7 @@ class QPDFJob
83 // about converting arguments to UTF-8. This method will mutate 83 // about converting arguments to UTF-8. This method will mutate
84 // arguments that are passed to it. 84 // arguments that are passed to it.
85 QPDF_DLL 85 QPDF_DLL
86 - void initializeFromArgv(  
87 - char const* const argv[], char const* progname_env = nullptr); 86 + void initializeFromArgv(char const* const argv[], char const* progname_env = nullptr);
88 87
89 // Initialize a QPDFJob from json. Passing partial = true prevents 88 // Initialize a QPDFJob from json. Passing partial = true prevents
90 // this method from doing the final checks (calling 89 // this method from doing the final checks (calling
@@ -132,8 +131,7 @@ class QPDFJob @@ -132,8 +131,7 @@ class QPDFJob
132 // configures a private logger, separating this object from the 131 // configures a private logger, separating this object from the
133 // default logger, and calls setOutputStreams on that logger. See 132 // default logger, and calls setOutputStreams on that logger. See
134 // QPDFLogger.hh for additional details. 133 // QPDFLogger.hh for additional details.
135 - [[deprecated(  
136 - "configure logger from getLogger() or call setLogger()")]] QPDF_DLL void 134 + [[deprecated("configure logger from getLogger() or call setLogger()")]] QPDF_DLL void
137 setOutputStreams(std::ostream* out_stream, std::ostream* err_stream); 135 setOutputStreams(std::ostream* out_stream, std::ostream* err_stream);
138 136
139 // You can register a custom progress reporter to be called by 137 // You can register a custom progress reporter to be called by
@@ -187,10 +185,7 @@ class QPDFJob @@ -187,10 +185,7 @@ class QPDFJob
187 185
188 struct PageSpec 186 struct PageSpec
189 { 187 {
190 - PageSpec(  
191 - std::string const& filename,  
192 - char const* password,  
193 - std::string const& range); 188 + PageSpec(std::string const& filename, char const* password, std::string const& range);
194 189
195 std::string filename; 190 std::string filename;
196 std::shared_ptr<char> password; 191 std::shared_ptr<char> password;
@@ -284,9 +279,7 @@ class QPDFJob @@ -284,9 +279,7 @@ class QPDFJob
284 Config* endPages(); 279 Config* endPages();
285 QPDF_DLL 280 QPDF_DLL
286 PagesConfig* pageSpec( 281 PagesConfig* pageSpec(
287 - std::string const& filename,  
288 - std::string const& range,  
289 - char const* password = nullptr); 282 + std::string const& filename, std::string const& range, char const* password = nullptr);
290 283
291 #include <qpdf/auto_job_c_pages.hh> 284 #include <qpdf/auto_job_c_pages.hh>
292 285
@@ -366,10 +359,8 @@ class QPDFJob @@ -366,10 +359,8 @@ class QPDFJob
366 QPDF_DLL 359 QPDF_DLL
367 std::shared_ptr<UOConfig> underlay(); 360 std::shared_ptr<UOConfig> underlay();
368 QPDF_DLL 361 QPDF_DLL
369 - std::shared_ptr<EncConfig> encrypt(  
370 - int keylen,  
371 - std::string const& user_password,  
372 - std::string const& owner_password); 362 + std::shared_ptr<EncConfig>
  363 + encrypt(int keylen, std::string const& user_password, std::string const& owner_password);
373 364
374 #include <qpdf/auto_job_c_main.hh> 365 #include <qpdf/auto_job_c_main.hh>
375 366
@@ -438,8 +429,7 @@ class QPDFJob @@ -438,8 +429,7 @@ class QPDFJob
438 // If in verbose mode, call the given function, passing in the 429 // If in verbose mode, call the given function, passing in the
439 // output stream and message prefix. 430 // output stream and message prefix.
440 QPDF_DLL 431 QPDF_DLL
441 - void  
442 - doIfVerbose(std::function<void(Pipeline&, std::string const& prefix)> fn); 432 + void doIfVerbose(std::function<void(Pipeline&, std::string const& prefix)> fn);
443 433
444 // Provide a string that is the help information ("schema" for the 434 // Provide a string that is the help information ("schema" for the
445 // qpdf-specific JSON object) for the specified version of JSON 435 // qpdf-specific JSON object) for the specified version of JSON
@@ -447,16 +437,14 @@ class QPDFJob @@ -447,16 +437,14 @@ class QPDFJob
447 QPDF_DLL 437 QPDF_DLL
448 static std::string json_out_schema(int version); 438 static std::string json_out_schema(int version);
449 439
450 - [[deprecated("use json_out_schema(version)")]] static std::string QPDF_DLL  
451 - json_out_schema_v1(); 440 + [[deprecated("use json_out_schema(version)")]] static std::string QPDF_DLL json_out_schema_v1();
452 441
453 // Provide a string that is the help information for specified 442 // Provide a string that is the help information for specified
454 // version of JSON format for QPDFJob. 443 // version of JSON format for QPDFJob.
455 QPDF_DLL 444 QPDF_DLL
456 static std::string job_json_schema(int version); 445 static std::string job_json_schema(int version);
457 446
458 - [[deprecated("use job_json_schema(version)")]] static std::string QPDF_DLL  
459 - job_json_schema_v1(); 447 + [[deprecated("use job_json_schema(version)")]] static std::string QPDF_DLL job_json_schema_v1();
460 448
461 private: 449 private:
462 struct RotationSpec 450 struct RotationSpec
@@ -497,10 +485,8 @@ class QPDFJob @@ -497,10 +485,8 @@ class QPDFJob
497 485
498 // Helper functions 486 // Helper functions
499 static void usage(std::string const& msg); 487 static void usage(std::string const& msg);
500 - static JSON  
501 - json_schema(int json_version, std::set<std::string>* keys = nullptr);  
502 - static void parse_object_id(  
503 - std::string const& objspec, bool& trailer, int& obj, int& gen); 488 + static JSON json_schema(int json_version, std::set<std::string>* keys = nullptr);
  489 + static void parse_object_id(std::string const& objspec, bool& trailer, int& obj, int& gen);
504 void parseRotationParameter(std::string const&); 490 void parseRotationParameter(std::string const&);
505 std::vector<int> parseNumrange(char const* range, int max); 491 std::vector<int> parseNumrange(char const* range, int max);
506 492
@@ -533,12 +519,10 @@ class QPDFJob @@ -533,12 +519,10 @@ class QPDFJob
533 519
534 // Transformations 520 // Transformations
535 void setQPDFOptions(QPDF& pdf); 521 void setQPDFOptions(QPDF& pdf);
536 - void  
537 - handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap); 522 + void handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap);
538 bool shouldRemoveUnreferencedResources(QPDF& pdf); 523 bool shouldRemoveUnreferencedResources(QPDF& pdf);
539 void handleRotations(QPDF& pdf); 524 void handleRotations(QPDF& pdf);
540 - void  
541 - getUOPagenos(UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos); 525 + void getUOPagenos(UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos);
542 void handleUnderOverlay(QPDF& pdf); 526 void handleUnderOverlay(QPDF& pdf);
543 std::string doUnderOverlayForPage( 527 std::string doUnderOverlayForPage(
544 QPDF& pdf, 528 QPDF& pdf,
@@ -573,8 +557,7 @@ class QPDFJob @@ -573,8 +557,7 @@ class QPDFJob
573 // JSON 557 // JSON
574 void doJSON(QPDF& pdf, Pipeline*); 558 void doJSON(QPDF& pdf, Pipeline*);
575 QPDFObjGen::set getWantedJSONObjects(); 559 QPDFObjGen::set getWantedJSONObjects();
576 - void doJSONObject(  
577 - Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle&); 560 + void doJSONObject(Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle&);
578 void doJSONObjects(Pipeline* p, bool& first, QPDF& pdf); 561 void doJSONObjects(Pipeline* p, bool& first, QPDF& pdf);
579 void doJSONObjectinfo(Pipeline* p, bool& first, QPDF& pdf); 562 void doJSONObjectinfo(Pipeline* p, bool& first, QPDF& pdf);
580 void doJSONPages(Pipeline* p, bool& first, QPDF& pdf); 563 void doJSONPages(Pipeline* p, bool& first, QPDF& pdf);
include/qpdf/QPDFLogger.hh
@@ -153,8 +153,7 @@ class QPDFLogger @@ -153,8 +153,7 @@ class QPDFLogger
153 153
154 private: 154 private:
155 QPDFLogger(); 155 QPDFLogger();
156 - std::shared_ptr<Pipeline>  
157 - throwIfNull(std::shared_ptr<Pipeline>, bool null_okay); 156 + std::shared_ptr<Pipeline> throwIfNull(std::shared_ptr<Pipeline>, bool null_okay);
158 157
159 class Members 158 class Members
160 { 159 {
include/qpdf/QPDFMatrix.hh
@@ -79,8 +79,7 @@ class QPDFMatrix @@ -79,8 +79,7 @@ class QPDFMatrix
79 // bounds the polygon resulting from transforming the four 79 // bounds the polygon resulting from transforming the four
80 // corners. 80 // corners.
81 QPDF_DLL 81 QPDF_DLL
82 - QPDFObjectHandle::Rectangle  
83 - transformRectangle(QPDFObjectHandle::Rectangle r) const; 82 + QPDFObjectHandle::Rectangle transformRectangle(QPDFObjectHandle::Rectangle r) const;
84 83
85 // operator== tests for exact equality, not considering deltas for 84 // operator== tests for exact equality, not considering deltas for
86 // floating point. 85 // floating point.
include/qpdf/QPDFNameTreeObjectHelper.hh
@@ -156,8 +156,7 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper @@ -156,8 +156,7 @@ class QPDF_DLL_CLASS QPDFNameTreeObjectHelper: public QPDFObjectHelper
156 // Find the entry with the given key. If return_prev_if_not_found 156 // Find the entry with the given key. If return_prev_if_not_found
157 // is true and the item is not found, return the next lower item. 157 // is true and the item is not found, return the next lower item.
158 QPDF_DLL 158 QPDF_DLL
159 - iterator  
160 - find(std::string const& key, bool return_prev_if_not_found = false); 159 + iterator find(std::string const& key, bool return_prev_if_not_found = false);
161 160
162 // Insert a new item. If the key already exists, it is replaced. 161 // Insert a new item. If the key already exists, it is replaced.
163 QPDF_DLL 162 QPDF_DLL
include/qpdf/QPDFNumberTreeObjectHelper.hh
@@ -45,8 +45,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper @@ -45,8 +45,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
45 // The qpdf object is required so that this class can issue 45 // The qpdf object is required so that this class can issue
46 // warnings, attempt repairs, and add indirect objects. 46 // warnings, attempt repairs, and add indirect objects.
47 QPDF_DLL 47 QPDF_DLL
48 - QPDFNumberTreeObjectHelper(  
49 - QPDFObjectHandle, QPDF&, bool auto_repair = true); 48 + QPDFNumberTreeObjectHelper(QPDFObjectHandle, QPDF&, bool auto_repair = true);
50 49
51 QPDF_DLL 50 QPDF_DLL
52 virtual ~QPDFNumberTreeObjectHelper(); 51 virtual ~QPDFNumberTreeObjectHelper();
@@ -82,8 +81,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper @@ -82,8 +81,7 @@ class QPDF_DLL_CLASS QPDFNumberTreeObjectHelper: public QPDFObjectHelper
82 // oh to the value with index 3, and set offset to 2 (5 - 3). See 81 // oh to the value with index 3, and set offset to 2 (5 - 3). See
83 // also find(). 82 // also find().
84 QPDF_DLL 83 QPDF_DLL
85 - bool findObjectAtOrBelow(  
86 - numtree_number idx, QPDFObjectHandle& oh, numtree_number& offset); 84 + bool findObjectAtOrBelow(numtree_number idx, QPDFObjectHandle& oh, numtree_number& offset);
87 85
88 class QPDF_DLL_PRIVATE iterator 86 class QPDF_DLL_PRIVATE iterator
89 { 87 {
include/qpdf/QPDFObjectHandle.hh
@@ -128,22 +128,13 @@ class QPDFObjectHandle @@ -128,22 +128,13 @@ class QPDFObjectHandle
128 // version of the method, which should also return a boolean 128 // version of the method, which should also return a boolean
129 // indicating whether it ran without errors. 129 // indicating whether it ran without errors.
130 QPDF_DLL 130 QPDF_DLL
131 - virtual void  
132 - provideStreamData(QPDFObjGen const& og, Pipeline* pipeline); 131 + virtual void provideStreamData(QPDFObjGen const& og, Pipeline* pipeline);
133 QPDF_DLL 132 QPDF_DLL
134 virtual bool provideStreamData( 133 virtual bool provideStreamData(
135 - QPDFObjGen const& og,  
136 - Pipeline* pipeline,  
137 - bool suppress_warnings,  
138 - bool will_retry);  
139 - QPDF_DLL virtual void  
140 - provideStreamData(int objid, int generation, Pipeline* pipeline); 134 + QPDFObjGen const& og, Pipeline* pipeline, bool suppress_warnings, bool will_retry);
  135 + QPDF_DLL virtual void provideStreamData(int objid, int generation, Pipeline* pipeline);
141 QPDF_DLL virtual bool provideStreamData( 136 QPDF_DLL virtual bool provideStreamData(
142 - int objid,  
143 - int generation,  
144 - Pipeline* pipeline,  
145 - bool suppress_warnings,  
146 - bool will_retry); 137 + int objid, int generation, Pipeline* pipeline, bool suppress_warnings, bool will_retry);
147 QPDF_DLL 138 QPDF_DLL
148 bool supportsRetry(); 139 bool supportsRetry();
149 140
@@ -246,8 +237,7 @@ class QPDFObjectHandle @@ -246,8 +237,7 @@ class QPDFObjectHandle
246 QPDF_DLL 237 QPDF_DLL
247 virtual void handleObject(QPDFObjectHandle); 238 virtual void handleObject(QPDFObjectHandle);
248 QPDF_DLL 239 QPDF_DLL
249 - virtual void  
250 - handleObject(QPDFObjectHandle, size_t offset, size_t length); 240 + virtual void handleObject(QPDFObjectHandle, size_t offset, size_t length);
251 241
252 virtual void handleEOF() = 0; 242 virtual void handleEOF() = 0;
253 243
@@ -408,14 +398,12 @@ class QPDFObjectHandle @@ -408,14 +398,12 @@ class QPDFObjectHandle
408 // True if the object is a dictionary of the specified type and 398 // True if the object is a dictionary of the specified type and
409 // subtype, if any. 399 // subtype, if any.
410 QPDF_DLL 400 QPDF_DLL
411 - bool isDictionaryOfType(  
412 - std::string const& type, std::string const& subtype = ""); 401 + bool isDictionaryOfType(std::string const& type, std::string const& subtype = "");
413 402
414 // True if the object is a stream of the specified type and 403 // True if the object is a stream of the specified type and
415 // subtype, if any. 404 // subtype, if any.
416 QPDF_DLL 405 QPDF_DLL
417 - bool  
418 - isStreamOfType(std::string const& type, std::string const& subtype = ""); 406 + bool isStreamOfType(std::string const& type, std::string const& subtype = "");
419 407
420 // Public factory methods 408 // Public factory methods
421 409
@@ -433,9 +421,8 @@ class QPDFObjectHandle @@ -433,9 +421,8 @@ class QPDFObjectHandle
433 // in the message of any QPDFExc exception thrown for invalid 421 // in the message of any QPDFExc exception thrown for invalid
434 // syntax. See also the global `operator ""_qpdf` defined below. 422 // syntax. See also the global `operator ""_qpdf` defined below.
435 QPDF_DLL 423 QPDF_DLL
436 - static QPDFObjectHandle parse(  
437 - std::string const& object_str,  
438 - std::string const& object_description = ""); 424 + static QPDFObjectHandle
  425 + parse(std::string const& object_str, std::string const& object_description = "");
439 426
440 // Construct an object of any type from a string representation of 427 // Construct an object of any type from a string representation of
441 // the object. Indirect object syntax (obj gen R) is allowed and 428 // the object. Indirect object syntax (obj gen R) is allowed and
@@ -447,10 +434,8 @@ class QPDFObjectHandle @@ -447,10 +434,8 @@ class QPDFObjectHandle
447 // object, which will just be the first number and will report 434 // object, which will just be the first number and will report
448 // that there is trailing data at the end of the string. 435 // that there is trailing data at the end of the string.
449 QPDF_DLL 436 QPDF_DLL
450 - static QPDFObjectHandle parse(  
451 - QPDF* context,  
452 - std::string const& object_str,  
453 - std::string const& object_description = ""); 437 + static QPDFObjectHandle
  438 + parse(QPDF* context, std::string const& object_str, std::string const& object_description = "");
454 439
455 // Construct an object as above by reading from the given 440 // Construct an object as above by reading from the given
456 // InputSource at its current position and using the tokenizer you 441 // InputSource at its current position and using the tokenizer you
@@ -480,8 +465,7 @@ class QPDFObjectHandle @@ -480,8 +465,7 @@ class QPDFObjectHandle
480 // error messages will also be more useful because the page object 465 // error messages will also be more useful because the page object
481 // information will be known. 466 // information will be known.
482 QPDF_DLL 467 QPDF_DLL
483 - static void parseContentStream(  
484 - QPDFObjectHandle stream_or_array, ParserCallbacks* callbacks); 468 + static void parseContentStream(QPDFObjectHandle stream_or_array, ParserCallbacks* callbacks);
485 469
486 // When called on a stream or stream array that is some page's 470 // When called on a stream or stream array that is some page's
487 // content streams, do the same as pipePageContents. This method 471 // content streams, do the same as pipePageContents. This method
@@ -500,10 +484,8 @@ class QPDFObjectHandle @@ -500,10 +484,8 @@ class QPDFObjectHandle
500 // Pl_Concatenate and then call manualFinish() on the 484 // Pl_Concatenate and then call manualFinish() on the
501 // Pl_Concatenate pipeline at the end. 485 // Pl_Concatenate pipeline at the end.
502 QPDF_DLL 486 QPDF_DLL
503 - void pipeContentStreams(  
504 - Pipeline* p,  
505 - std::string const& description,  
506 - std::string& all_description); 487 + void
  488 + pipeContentStreams(Pipeline* p, std::string const& description, std::string& all_description);
507 489
508 // As of qpdf 8, it is possible to add custom token filters to a 490 // As of qpdf 8, it is possible to add custom token filters to a
509 // stream. The tokenized stream data is passed through the token 491 // stream. The tokenized stream data is passed through the token
@@ -554,8 +536,8 @@ class QPDFObjectHandle @@ -554,8 +536,8 @@ class QPDFObjectHandle
554 QPDF_DLL 536 QPDF_DLL
555 static QPDFObjectHandle newReal(std::string const& value); 537 static QPDFObjectHandle newReal(std::string const& value);
556 QPDF_DLL 538 QPDF_DLL
557 - static QPDFObjectHandle newReal(  
558 - double value, int decimal_places = 0, bool trim_trailing_zeroes = true); 539 + static QPDFObjectHandle
  540 + newReal(double value, int decimal_places = 0, bool trim_trailing_zeroes = true);
559 // Note about name objects: qpdf's internal representation of a 541 // Note about name objects: qpdf's internal representation of a
560 // PDF name is a sequence of bytes, excluding the NUL character, 542 // PDF name is a sequence of bytes, excluding the NUL character,
561 // and starting with a slash. Name objects as represented in the 543 // and starting with a slash. Name objects as represented in the
@@ -591,8 +573,7 @@ class QPDFObjectHandle @@ -591,8 +573,7 @@ class QPDFObjectHandle
591 QPDF_DLL 573 QPDF_DLL
592 static QPDFObjectHandle newArray(); 574 static QPDFObjectHandle newArray();
593 QPDF_DLL 575 QPDF_DLL
594 - static QPDFObjectHandle  
595 - newArray(std::vector<QPDFObjectHandle> const& items); 576 + static QPDFObjectHandle newArray(std::vector<QPDFObjectHandle> const& items);
596 QPDF_DLL 577 QPDF_DLL
597 static QPDFObjectHandle newArray(Rectangle const&); 578 static QPDFObjectHandle newArray(Rectangle const&);
598 QPDF_DLL 579 QPDF_DLL
@@ -602,8 +583,7 @@ class QPDFObjectHandle @@ -602,8 +583,7 @@ class QPDFObjectHandle
602 QPDF_DLL 583 QPDF_DLL
603 static QPDFObjectHandle newDictionary(); 584 static QPDFObjectHandle newDictionary();
604 QPDF_DLL 585 QPDF_DLL
605 - static QPDFObjectHandle  
606 - newDictionary(std::map<std::string, QPDFObjectHandle> const& items); 586 + static QPDFObjectHandle newDictionary(std::map<std::string, QPDFObjectHandle> const& items);
607 587
608 // Create an array from a rectangle. Equivalent to the rectangle 588 // Create an array from a rectangle. Equivalent to the rectangle
609 // form of newArray. 589 // form of newArray.
@@ -686,8 +666,7 @@ class QPDFObjectHandle @@ -686,8 +666,7 @@ class QPDFObjectHandle
686 // else. To add objects from another qpdf, use copyForeignObject 666 // else. To add objects from another qpdf, use copyForeignObject
687 // instead. 667 // instead.
688 QPDF_DLL 668 QPDF_DLL
689 - void setObjectDescription(  
690 - QPDF* owning_qpdf, std::string const& object_description); 669 + void setObjectDescription(QPDF* owning_qpdf, std::string const& object_description);
691 QPDF_DLL 670 QPDF_DLL
692 bool hasObjectDescription(); 671 bool hasObjectDescription();
693 672
@@ -964,8 +943,7 @@ class QPDFObjectHandle @@ -964,8 +943,7 @@ class QPDFObjectHandle
964 QPDF_DLL 943 QPDF_DLL
965 void mergeResources( 944 void mergeResources(
966 QPDFObjectHandle other, 945 QPDFObjectHandle other,
967 - std::map<std::string, std::map<std::string, std::string>>* conflicts =  
968 - nullptr); 946 + std::map<std::string, std::map<std::string, std::string>>* conflicts = nullptr);
969 947
970 // Get all resource names from a resource dictionary. If this 948 // Get all resource names from a resource dictionary. If this
971 // object is a dictionary, this method returns a set of all the 949 // object is a dictionary, this method returns a set of all the
@@ -1118,13 +1096,11 @@ class QPDFObjectHandle @@ -1118,13 +1096,11 @@ class QPDFObjectHandle
1118 void replaceKey(std::string const& key, QPDFObjectHandle const& value); 1096 void replaceKey(std::string const& key, QPDFObjectHandle const& value);
1119 // Replace value of key and return the value. 1097 // Replace value of key and return the value.
1120 QPDF_DLL 1098 QPDF_DLL
1121 - QPDFObjectHandle  
1122 - replaceKeyAndGetNew(std::string const& key, QPDFObjectHandle const& value); 1099 + QPDFObjectHandle replaceKeyAndGetNew(std::string const& key, QPDFObjectHandle const& value);
1123 // Replace value of key and return the old value, or null if the 1100 // Replace value of key and return the old value, or null if the
1124 // key was previously not present. 1101 // key was previously not present.
1125 QPDF_DLL 1102 QPDF_DLL
1126 - QPDFObjectHandle  
1127 - replaceKeyAndGetOld(std::string const& key, QPDFObjectHandle const& value); 1103 + QPDFObjectHandle replaceKeyAndGetOld(std::string const& key, QPDFObjectHandle const& value);
1128 // Remove key, doing nothing if key does not exist. 1104 // Remove key, doing nothing if key does not exist.
1129 QPDF_DLL 1105 QPDF_DLL
1130 void removeKey(std::string const& key); 1106 void removeKey(std::string const& key);
@@ -1167,8 +1143,7 @@ class QPDFObjectHandle @@ -1167,8 +1143,7 @@ class QPDFObjectHandle
1167 // Returns filtered (uncompressed) stream data. Throws an 1143 // Returns filtered (uncompressed) stream data. Throws an
1168 // exception if the stream is filtered and we can't decode it. 1144 // exception if the stream is filtered and we can't decode it.
1169 QPDF_DLL 1145 QPDF_DLL
1170 - std::shared_ptr<Buffer>  
1171 - getStreamData(qpdf_stream_decode_level_e level = qpdf_dl_generalized); 1146 + std::shared_ptr<Buffer> getStreamData(qpdf_stream_decode_level_e level = qpdf_dl_generalized);
1172 1147
1173 // Returns unfiltered (raw) stream data. 1148 // Returns unfiltered (raw) stream data.
1174 QPDF_DLL 1149 QPDF_DLL
@@ -1347,8 +1322,7 @@ class QPDFObjectHandle @@ -1347,8 +1322,7 @@ class QPDFObjectHandle
1347 // returning true if it succeeded without errors. 1322 // returning true if it succeeded without errors.
1348 QPDF_DLL 1323 QPDF_DLL
1349 void replaceStreamData( 1324 void replaceStreamData(
1350 - std::function<bool(Pipeline*, bool suppress_warnings, bool will_retry)>  
1351 - provider, 1325 + std::function<bool(Pipeline*, bool suppress_warnings, bool will_retry)> provider,
1352 QPDFObjectHandle const& filter, 1326 QPDFObjectHandle const& filter,
1353 QPDFObjectHandle const& decode_parms); 1327 QPDFObjectHandle const& decode_parms);
1354 1328
@@ -1615,15 +1589,14 @@ class QPDFObjectHandle @@ -1615,15 +1589,14 @@ class QPDFObjectHandle
1615 void makeDirect(QPDFObjGen::set& visited, bool stop_at_streams); 1589 void makeDirect(QPDFObjGen::set& visited, bool stop_at_streams);
1616 void disconnect(); 1590 void disconnect();
1617 void setParsedOffset(qpdf_offset_t offset); 1591 void setParsedOffset(qpdf_offset_t offset);
1618 - void parseContentStream_internal(  
1619 - std::string const& description, ParserCallbacks* callbacks); 1592 + void parseContentStream_internal(std::string const& description, ParserCallbacks* callbacks);
1620 static void parseContentStream_data( 1593 static void parseContentStream_data(
1621 std::shared_ptr<Buffer>, 1594 std::shared_ptr<Buffer>,
1622 std::string const& description, 1595 std::string const& description,
1623 ParserCallbacks* callbacks, 1596 ParserCallbacks* callbacks,
1624 QPDF* context); 1597 QPDF* context);
1625 - std::vector<QPDFObjectHandle> arrayOrStreamToStreamArray(  
1626 - std::string const& description, std::string& all_description); 1598 + std::vector<QPDFObjectHandle>
  1599 + arrayOrStreamToStreamArray(std::string const& description, std::string& all_description);
1627 static void warn(QPDF*, QPDFExc const&); 1600 static void warn(QPDF*, QPDFExc const&);
1628 void checkOwnership(QPDFObjectHandle const&) const; 1601 void checkOwnership(QPDFObjectHandle const&) const;
1629 1602
include/qpdf/QPDFPageDocumentHelper.hh
@@ -104,10 +104,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper @@ -104,10 +104,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
104 // Add new page before or after refpage. See comments for addPage 104 // Add new page before or after refpage. See comments for addPage
105 // for details about what newpage should be. 105 // for details about what newpage should be.
106 QPDF_DLL 106 QPDF_DLL
107 - void addPageAt(  
108 - QPDFPageObjectHelper newpage,  
109 - bool before,  
110 - QPDFPageObjectHelper refpage); 107 + void addPageAt(QPDFPageObjectHelper newpage, bool before, QPDFPageObjectHelper refpage);
111 108
112 // Remove page from the pdf. 109 // Remove page from the pdf.
113 QPDF_DLL 110 QPDF_DLL
@@ -125,8 +122,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper @@ -125,8 +122,7 @@ class QPDFPageDocumentHelper: public QPDFDocumentHelper
125 // comments there in QPDFAnnotationObjectHelper.hh for meanings of 122 // comments there in QPDFAnnotationObjectHelper.hh for meanings of
126 // those flags. 123 // those flags.
127 QPDF_DLL 124 QPDF_DLL
128 - void flattenAnnotations(  
129 - int required_flags = 0, int forbidden_flags = an_invisible | an_hidden); 125 + void flattenAnnotations(int required_flags = 0, int forbidden_flags = an_invisible | an_hidden);
130 126
131 private: 127 private:
132 void flattenAnnotationsForPage( 128 void flattenAnnotationsForPage(
include/qpdf/QPDFPageObjectHelper.hh
@@ -170,26 +170,22 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -170,26 +170,22 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
170 // Return the effective CropBox. If not defined, fall back to 170 // Return the effective CropBox. If not defined, fall back to
171 // MediaBox 171 // MediaBox
172 QPDF_DLL 172 QPDF_DLL
173 - QPDFObjectHandle  
174 - getCropBox(bool copy_if_shared = false, bool copy_if_fallback = false); 173 + QPDFObjectHandle getCropBox(bool copy_if_shared = false, bool copy_if_fallback = false);
175 174
176 // Return the effective BleedBox. If not defined, fall back to 175 // Return the effective BleedBox. If not defined, fall back to
177 // CropBox. 176 // CropBox.
178 QPDF_DLL 177 QPDF_DLL
179 - QPDFObjectHandle  
180 - getBleedBox(bool copy_if_shared = false, bool copy_if_fallback = false); 178 + QPDFObjectHandle getBleedBox(bool copy_if_shared = false, bool copy_if_fallback = false);
181 179
182 // Return the effective TrimBox. If not defined, fall back to 180 // Return the effective TrimBox. If not defined, fall back to
183 // CropBox. 181 // CropBox.
184 QPDF_DLL 182 QPDF_DLL
185 - QPDFObjectHandle  
186 - getTrimBox(bool copy_if_shared = false, bool copy_if_fallback = false); 183 + QPDFObjectHandle getTrimBox(bool copy_if_shared = false, bool copy_if_fallback = false);
187 184
188 // Return the effective ArtBox. If not defined, fall back to 185 // Return the effective ArtBox. If not defined, fall back to
189 // CropBox. 186 // CropBox.
190 QPDF_DLL 187 QPDF_DLL
191 - QPDFObjectHandle  
192 - getArtBox(bool copy_if_shared = false, bool copy_if_fallback = false); 188 + QPDFObjectHandle getArtBox(bool copy_if_shared = false, bool copy_if_fallback = false);
193 189
194 // Iterate through XObjects, possibly recursing into form 190 // Iterate through XObjects, possibly recursing into form
195 // XObjects. This works with pages or form XObjects. Call action 191 // XObjects. This works with pages or form XObjects. Call action
@@ -203,26 +199,20 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -203,26 +199,20 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
203 void forEachXObject( 199 void forEachXObject(
204 bool recursive, 200 bool recursive,
205 std::function<void( 201 std::function<void(
206 - QPDFObjectHandle& obj,  
207 - QPDFObjectHandle& xobj_dict,  
208 - std::string const& key)> action, 202 + QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key)> action,
209 std::function<bool(QPDFObjectHandle)> selector = nullptr); 203 std::function<bool(QPDFObjectHandle)> selector = nullptr);
210 // Only call action for images 204 // Only call action for images
211 QPDF_DLL 205 QPDF_DLL
212 void forEachImage( 206 void forEachImage(
213 bool recursive, 207 bool recursive,
214 std::function<void( 208 std::function<void(
215 - QPDFObjectHandle& obj,  
216 - QPDFObjectHandle& xobj_dict,  
217 - std::string const& key)> action); 209 + QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key)> action);
218 // Only call action for form XObjects 210 // Only call action for form XObjects
219 QPDF_DLL 211 QPDF_DLL
220 void forEachFormXObject( 212 void forEachFormXObject(
221 bool recursive, 213 bool recursive,
222 std::function<void( 214 std::function<void(
223 - QPDFObjectHandle& obj,  
224 - QPDFObjectHandle& xobj_dict,  
225 - std::string const& key)> action); 215 + QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key)> action);
226 216
227 // Returns an empty map if there are no images or no resources. 217 // Returns an empty map if there are no images or no resources.
228 // Prior to qpdf 8.4.0, this function did not support inherited 218 // Prior to qpdf 8.4.0, this function did not support inherited
@@ -258,8 +248,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -258,8 +248,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
258 // only_subtype is non-empty, only include annotations of the 248 // only_subtype is non-empty, only include annotations of the
259 // given subtype. 249 // given subtype.
260 QPDF_DLL 250 QPDF_DLL
261 - std::vector<QPDFAnnotationObjectHelper>  
262 - getAnnotations(std::string const& only_subtype = ""); 251 + std::vector<QPDFAnnotationObjectHelper> getAnnotations(std::string const& only_subtype = "");
263 252
264 // Returns a vector of stream objects representing the content 253 // Returns a vector of stream objects representing the content
265 // streams for the given page. This routine allows the caller to 254 // streams for the given page. This routine allows the caller to
@@ -319,13 +308,11 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -319,13 +308,11 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
319 // contents, as happens with addContentTokenFilter. See 308 // contents, as happens with addContentTokenFilter. See
320 // examples/pdf-count-strings.cc for an example. 309 // examples/pdf-count-strings.cc for an example.
321 QPDF_DLL 310 QPDF_DLL
322 - void filterContents(  
323 - QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr); 311 + void filterContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
324 312
325 // Old name -- calls filterContents() 313 // Old name -- calls filterContents()
326 QPDF_DLL 314 QPDF_DLL
327 - void filterPageContents(  
328 - QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr); 315 + void filterPageContents(QPDFObjectHandle::TokenFilter* filter, Pipeline* next = nullptr);
329 316
330 // Pipe a page's contents through the given pipeline. This method 317 // Pipe a page's contents through the given pipeline. This method
331 // works whether the contents are a single stream or an array of 318 // works whether the contents are a single stream or an array of
@@ -341,8 +328,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -341,8 +328,7 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
341 // The token filter is applied to the page's contents as a single 328 // The token filter is applied to the page's contents as a single
342 // stream. Also works on form XObjects. 329 // stream. Also works on form XObjects.
343 QPDF_DLL 330 QPDF_DLL
344 - void addContentTokenFilter(  
345 - std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter); 331 + void addContentTokenFilter(std::shared_ptr<QPDFObjectHandle::TokenFilter> token_filter);
346 332
347 // A page's resources dictionary maps names to objects elsewhere 333 // A page's resources dictionary maps names to objects elsewhere
348 // in the file. This method walks through a page's contents and 334 // in the file. This method walks through a page's contents and
@@ -500,8 +486,8 @@ class QPDFPageObjectHelper: public QPDFObjectHelper @@ -500,8 +486,8 @@ class QPDFPageObjectHelper: public QPDFObjectHelper
500 bool copy_if_shared, 486 bool copy_if_shared,
501 std::function<QPDFObjectHandle()> get_fallback, 487 std::function<QPDFObjectHandle()> get_fallback,
502 bool copy_if_fallback); 488 bool copy_if_fallback);
503 - static bool removeUnreferencedResourcesHelper(  
504 - QPDFPageObjectHelper ph, std::set<std::string>& unresolved); 489 + static bool
  490 + removeUnreferencedResourcesHelper(QPDFPageObjectHelper ph, std::set<std::string>& unresolved);
505 491
506 class Members 492 class Members
507 { 493 {
include/qpdf/QPDFSystemError.hh
@@ -48,8 +48,7 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error @@ -48,8 +48,7 @@ class QPDF_DLL_CLASS QPDFSystemError: public std::runtime_error
48 48
49 private: 49 private:
50 QPDF_DLL_PRIVATE 50 QPDF_DLL_PRIVATE
51 - static std::string  
52 - createWhat(std::string const& description, int system_errno); 51 + static std::string createWhat(std::string const& description, int system_errno);
53 52
54 // This class does not use the Members pattern to avoid needless 53 // This class does not use the Members pattern to avoid needless
55 // memory allocations during exception handling. 54 // memory allocations during exception handling.
include/qpdf/QPDFTokenizer.hh
@@ -104,8 +104,7 @@ class QPDFTokenizer @@ -104,8 +104,7 @@ class QPDFTokenizer
104 { 104 {
105 // Ignore fields other than type and value 105 // Ignore fields other than type and value
106 return ( 106 return (
107 - (this->type != tt_bad) && (this->type == rhs.type) &&  
108 - (this->value == rhs.value)); 107 + (this->type != tt_bad) && (this->type == rhs.type) && (this->value == rhs.value));
109 } 108 }
110 bool 109 bool
111 isInteger() const 110 isInteger() const
@@ -216,8 +215,7 @@ class QPDFTokenizer @@ -216,8 +215,7 @@ class QPDFTokenizer
216 // beginning of the token. Returns false if the token is bad 215 // beginning of the token. Returns false if the token is bad
217 // or if scanning produced an error message for any reason. 216 // or if scanning produced an error message for any reason.
218 217
219 - bool nextToken(  
220 - InputSource& input, std::string const& context, size_t max_len = 0); 218 + bool nextToken(InputSource& input, std::string const& context, size_t max_len = 0);
221 219
222 // The following methods are only valid after nextToken has been called 220 // The following methods are only valid after nextToken has been called
223 // and until another QPDFTokenizer method is called. They allow the results 221 // and until another QPDFTokenizer method is called. They allow the results
@@ -317,8 +315,7 @@ QPDFTokenizer::getType() const noexcept @@ -317,8 +315,7 @@ QPDFTokenizer::getType() const noexcept
317 inline std::string const& 315 inline std::string const&
318 QPDFTokenizer::getValue() const noexcept 316 QPDFTokenizer::getValue() const noexcept
319 { 317 {
320 - return (this->type == tt_name || this->type == tt_string) ? this->val  
321 - : this->raw_val; 318 + return (this->type == tt_name || this->type == tt_string) ? this->val : this->raw_val;
322 } 319 }
323 inline std::string const& 320 inline std::string const&
324 QPDFTokenizer::getRawValue() const noexcept 321 QPDFTokenizer::getRawValue() const noexcept
include/qpdf/QPDFWriter.hh
@@ -561,16 +561,11 @@ class QPDFWriter @@ -561,16 +561,11 @@ class QPDFWriter
561 void writePad(size_t nspaces); 561 void writePad(size_t nspaces);
562 void assignCompressedObjectNumbers(QPDFObjGen const& og); 562 void assignCompressedObjectNumbers(QPDFObjGen const& og);
563 void enqueueObject(QPDFObjectHandle object); 563 void enqueueObject(QPDFObjectHandle object);
564 - void writeObjectStreamOffsets(  
565 - std::vector<qpdf_offset_t>& offsets, int first_obj); 564 + void writeObjectStreamOffsets(std::vector<qpdf_offset_t>& offsets, int first_obj);
566 void writeObjectStream(QPDFObjectHandle object); 565 void writeObjectStream(QPDFObjectHandle object);
567 void writeObject(QPDFObjectHandle object, int object_stream_index = -1); 566 void writeObject(QPDFObjectHandle object, int object_stream_index = -1);
568 void writeTrailer( 567 void writeTrailer(
569 - trailer_e which,  
570 - int size,  
571 - bool xref_stream,  
572 - qpdf_offset_t prev,  
573 - int linearization_pass); 568 + trailer_e which, int size, bool xref_stream, qpdf_offset_t prev, int linearization_pass);
574 bool willFilterStream( 569 bool willFilterStream(
575 QPDFObjectHandle stream, 570 QPDFObjectHandle stream,
576 bool& compress_stream, 571 bool& compress_stream,
@@ -601,8 +596,7 @@ class QPDFWriter @@ -601,8 +596,7 @@ class QPDFWriter
601 bool allow_modify_other, 596 bool allow_modify_other,
602 qpdf_r3_print_e print, 597 qpdf_r3_print_e print,
603 qpdf_r3_modify_e modify); 598 qpdf_r3_modify_e modify);
604 - void  
605 - disableIncompatibleEncryption(int major, int minor, int extension_level); 599 + void disableIncompatibleEncryption(int major, int minor, int extension_level);
606 void parseVersion(std::string const& version, int& major, int& minor) const; 600 void parseVersion(std::string const& version, int& major, int& minor) const;
607 int compareVersions(int major1, int minor1, int major2, int minor2) const; 601 int compareVersions(int major1, int minor1, int major2, int minor2) const;
608 void setEncryptionParameters( 602 void setEncryptionParameters(
@@ -640,8 +634,7 @@ class QPDFWriter @@ -640,8 +634,7 @@ class QPDFWriter
640 void doWriteSetup(); 634 void doWriteSetup();
641 void writeHeader(); 635 void writeHeader();
642 void writeHintStream(int hint_id); 636 void writeHintStream(int hint_id);
643 - qpdf_offset_t  
644 - writeXRefTable(trailer_e which, int first, int last, int size); 637 + qpdf_offset_t writeXRefTable(trailer_e which, int first, int last, int size);
645 qpdf_offset_t writeXRefTable( 638 qpdf_offset_t writeXRefTable(
646 trailer_e which, 639 trailer_e which,
647 int first, 640 int first,
@@ -693,8 +686,7 @@ class QPDFWriter @@ -693,8 +686,7 @@ class QPDFWriter
693 void pushMD5Pipeline(PipelinePopper&); 686 void pushMD5Pipeline(PipelinePopper&);
694 void computeDeterministicIDData(); 687 void computeDeterministicIDData();
695 688
696 - void discardGeneration(  
697 - std::map<QPDFObjGen, int> const& in, std::map<int, int>& out); 689 + void discardGeneration(std::map<QPDFObjGen, int> const& in, std::map<int, int>& out);
698 690
699 class Members 691 class Members
700 { 692 {
include/qpdf/QUtil.hh
@@ -49,11 +49,9 @@ namespace QUtil @@ -49,11 +49,9 @@ namespace QUtil
49 QPDF_DLL 49 QPDF_DLL
50 std::string int_to_string_base(long long, int base, int length = 0); 50 std::string int_to_string_base(long long, int base, int length = 0);
51 QPDF_DLL 51 QPDF_DLL
52 - std::string  
53 - uint_to_string_base(unsigned long long, int base, int length = 0); 52 + std::string uint_to_string_base(unsigned long long, int base, int length = 0);
54 QPDF_DLL 53 QPDF_DLL
55 - std::string double_to_string(  
56 - double, int decimal_places = 0, bool trim_trailing_zeroes = true); 54 + std::string double_to_string(double, int decimal_places = 0, bool trim_trailing_zeroes = true);
57 55
58 // These string to number methods throw std::runtime_error on 56 // These string to number methods throw std::runtime_error on
59 // underflow/overflow. 57 // underflow/overflow.
@@ -257,14 +255,7 @@ namespace QUtil @@ -257,14 +255,7 @@ namespace QUtil
257 QPDFTime() = default; 255 QPDFTime() = default;
258 QPDFTime(QPDFTime const&) = default; 256 QPDFTime(QPDFTime const&) = default;
259 QPDFTime& operator=(QPDFTime const&) = default; 257 QPDFTime& operator=(QPDFTime const&) = default;
260 - QPDFTime(  
261 - int year,  
262 - int month,  
263 - int day,  
264 - int hour,  
265 - int minute,  
266 - int second,  
267 - int tz_delta) : 258 + QPDFTime(int year, int month, int day, int hour, int minute, int second, int tz_delta) :
268 year(year), 259 year(year),
269 month(month), 260 month(month),
270 day(day), 261 day(day),
@@ -331,8 +322,7 @@ namespace QUtil @@ -331,8 +322,7 @@ namespace QUtil
331 // to pass a value of pos that is greater than or equal to the 322 // to pass a value of pos that is greater than or equal to the
332 // length of the string. 323 // length of the string.
333 QPDF_DLL 324 QPDF_DLL
334 - unsigned long get_next_utf8_codepoint(  
335 - std::string const& utf8_val, size_t& pos, bool& error); 325 + unsigned long get_next_utf8_codepoint(std::string const& utf8_val, size_t& pos, bool& error);
336 326
337 // Test whether this is a UTF-16 string. This is indicated by 327 // Test whether this is a UTF-16 string. This is indicated by
338 // first two bytes being 0xFE 0xFF (big-endian) or 0xFF 0xFE 328 // first two bytes being 0xFE 0xFF (big-endian) or 0xFF 0xFE
@@ -360,30 +350,23 @@ namespace QUtil @@ -360,30 +350,23 @@ namespace QUtil
360 QPDF_DLL 350 QPDF_DLL
361 std::string utf8_to_ascii(std::string const& utf8, char unknown_char = '?'); 351 std::string utf8_to_ascii(std::string const& utf8, char unknown_char = '?');
362 QPDF_DLL 352 QPDF_DLL
363 - std::string  
364 - utf8_to_win_ansi(std::string const& utf8, char unknown_char = '?'); 353 + std::string utf8_to_win_ansi(std::string const& utf8, char unknown_char = '?');
365 QPDF_DLL 354 QPDF_DLL
366 - std::string  
367 - utf8_to_mac_roman(std::string const& utf8, char unknown_char = '?'); 355 + std::string utf8_to_mac_roman(std::string const& utf8, char unknown_char = '?');
368 QPDF_DLL 356 QPDF_DLL
369 - std::string  
370 - utf8_to_pdf_doc(std::string const& utf8, char unknown_char = '?'); 357 + std::string utf8_to_pdf_doc(std::string const& utf8, char unknown_char = '?');
371 358
372 // These versions return true if the conversion was successful and 359 // These versions return true if the conversion was successful and
373 // false if any unrepresentable characters were found and had to 360 // false if any unrepresentable characters were found and had to
374 // be substituted with the unknown character. 361 // be substituted with the unknown character.
375 QPDF_DLL 362 QPDF_DLL
376 - bool utf8_to_ascii(  
377 - std::string const& utf8, std::string& ascii, char unknown_char = '?'); 363 + bool utf8_to_ascii(std::string const& utf8, std::string& ascii, char unknown_char = '?');
378 QPDF_DLL 364 QPDF_DLL
379 - bool utf8_to_win_ansi(  
380 - std::string const& utf8, std::string& win, char unknown_char = '?'); 365 + bool utf8_to_win_ansi(std::string const& utf8, std::string& win, char unknown_char = '?');
381 QPDF_DLL 366 QPDF_DLL
382 - bool utf8_to_mac_roman(  
383 - std::string const& utf8, std::string& mac, char unknown_char = '?'); 367 + bool utf8_to_mac_roman(std::string const& utf8, std::string& mac, char unknown_char = '?');
384 QPDF_DLL 368 QPDF_DLL
385 - bool utf8_to_pdf_doc(  
386 - std::string const& utf8, std::string& pdfdoc, char unknown_char = '?'); 369 + bool utf8_to_pdf_doc(std::string const& utf8, std::string& pdfdoc, char unknown_char = '?');
387 370
388 // Convert a UTF-16 encoded string to UTF-8. Unrepresentable code 371 // Convert a UTF-16 encoded string to UTF-8. Unrepresentable code
389 // points are converted to U+FFFD. 372 // points are converted to U+FFFD.
@@ -412,10 +395,7 @@ namespace QUtil @@ -412,10 +395,7 @@ namespace QUtil
412 // about everything else) accepts UTF-16LE (as of 10.6.2). 395 // about everything else) accepts UTF-16LE (as of 10.6.2).
413 QPDF_DLL 396 QPDF_DLL
414 void analyze_encoding( 397 void analyze_encoding(
415 - std::string const& str,  
416 - bool& has_8bit_chars,  
417 - bool& is_valid_utf8,  
418 - bool& is_utf16); 398 + std::string const& str, bool& has_8bit_chars, bool& is_valid_utf8, bool& is_utf16);
419 399
420 // Try to compensate for previously incorrectly encoded strings. 400 // Try to compensate for previously incorrectly encoded strings.
421 // We want to compensate for the following errors: 401 // We want to compensate for the following errors:
@@ -472,14 +452,11 @@ namespace QUtil @@ -472,14 +452,11 @@ namespace QUtil
472 // Filename is UTF-8 encoded, even on Windows, as described in the 452 // Filename is UTF-8 encoded, even on Windows, as described in the
473 // comments for safe_fopen. 453 // comments for safe_fopen.
474 QPDF_DLL 454 QPDF_DLL
475 - std::list<std::string>  
476 - read_lines_from_file(char const* filename, bool preserve_eol = false); 455 + std::list<std::string> read_lines_from_file(char const* filename, bool preserve_eol = false);
477 QPDF_DLL 456 QPDF_DLL
478 - std::list<std::string>  
479 - read_lines_from_file(std::istream&, bool preserve_eol = false); 457 + std::list<std::string> read_lines_from_file(std::istream&, bool preserve_eol = false);
480 QPDF_DLL 458 QPDF_DLL
481 - std::list<std::string>  
482 - read_lines_from_file(FILE*, bool preserve_eol = false); 459 + std::list<std::string> read_lines_from_file(FILE*, bool preserve_eol = false);
483 QPDF_DLL 460 QPDF_DLL
484 void read_lines_from_file( 461 void read_lines_from_file(
485 std::function<bool(char&)> next_char, 462 std::function<bool(char&)> next_char,
@@ -487,8 +464,7 @@ namespace QUtil @@ -487,8 +464,7 @@ namespace QUtil
487 bool preserve_eol = false); 464 bool preserve_eol = false);
488 465
489 QPDF_DLL 466 QPDF_DLL
490 - void read_file_into_memory(  
491 - char const* filename, std::shared_ptr<char>& file_buf, size_t& size); 467 + void read_file_into_memory(char const* filename, std::shared_ptr<char>& file_buf, size_t& size);
492 468
493 QPDF_DLL 469 QPDF_DLL
494 std::string read_file_into_string(char const* filename); 470 std::string read_file_into_string(char const* filename);
@@ -532,8 +508,7 @@ namespace QUtil @@ -532,8 +508,7 @@ namespace QUtil
532 // invoked, convert all UTF-16 encoded strings to UTF-8, and call 508 // invoked, convert all UTF-16 encoded strings to UTF-8, and call
533 // another main. 509 // another main.
534 QPDF_DLL 510 QPDF_DLL
535 - int call_main_from_wmain(  
536 - int argc, wchar_t* argv[], std::function<int(int, char*[])> realmain); 511 + int call_main_from_wmain(int argc, wchar_t* argv[], std::function<int(int, char*[])> realmain);
537 QPDF_DLL 512 QPDF_DLL
538 int call_main_from_wmain( 513 int call_main_from_wmain(
539 int argc, 514 int argc,
@@ -561,8 +536,7 @@ QUtil::is_hex_digit(char ch) @@ -561,8 +536,7 @@ QUtil::is_hex_digit(char ch)
561 inline bool 536 inline bool
562 QUtil::is_space(char ch) 537 QUtil::is_space(char ch)
563 { 538 {
564 - return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f' ||  
565 - ch == '\v'; 539 + return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t' || ch == '\f' || ch == '\v';
566 } 540 }
567 541
568 inline bool 542 inline bool
@@ -603,8 +577,7 @@ inline std::string @@ -603,8 +577,7 @@ inline std::string
603 QUtil::hex_encode_char(char c) 577 QUtil::hex_encode_char(char c)
604 { 578 {
605 static auto constexpr hexchars = "0123456789abcdef"; 579 static auto constexpr hexchars = "0123456789abcdef";
606 - return {  
607 - '#', hexchars[static_cast<unsigned char>(c) >> 4], hexchars[c & 0x0f]}; 580 + return {'#', hexchars[static_cast<unsigned char>(c) >> 4], hexchars[c & 0x0f]};
608 } 581 }
609 582
610 inline constexpr char 583 inline constexpr char
@@ -612,8 +585,7 @@ QUtil::hex_decode_char(char digit) noexcept @@ -612,8 +585,7 @@ QUtil::hex_decode_char(char digit) noexcept
612 { 585 {
613 return digit <= '9' && digit >= '0' 586 return digit <= '9' && digit >= '0'
614 ? char(digit - '0') 587 ? char(digit - '0')
615 - : (digit >= 'a' ? char(digit - 'a' + 10)  
616 - : (digit >= 'A' ? char(digit - 'A' + 10) : '\20')); 588 + : (digit >= 'a' ? char(digit - 'a' + 10) : (digit >= 'A' ? char(digit - 'A' + 10) : '\20'));
617 } 589 }
618 590
619 #endif // QUTIL_HH 591 #endif // QUTIL_HH
include/qpdf/qpdf-c.h
@@ -326,8 +326,7 @@ extern &quot;C&quot; { @@ -326,8 +326,7 @@ extern &quot;C&quot; {
326 */ 326 */
327 QPDF_DLL 327 QPDF_DLL
328 QPDF_ERROR_CODE 328 QPDF_ERROR_CODE
329 - qpdf_create_from_json_data(  
330 - qpdf_data qpdf, char const* buffer, unsigned long long size); 329 + qpdf_create_from_json_data(qpdf_data qpdf, char const* buffer, unsigned long long size);
331 330
332 /* JSON UPDATE FUNCTIONS */ 331 /* JSON UPDATE FUNCTIONS */
333 332
@@ -341,8 +340,7 @@ extern &quot;C&quot; { @@ -341,8 +340,7 @@ extern &quot;C&quot; {
341 qpdf_update_from_json_file(qpdf_data qpdf, char const* filename); 340 qpdf_update_from_json_file(qpdf_data qpdf, char const* filename);
342 QPDF_DLL 341 QPDF_DLL
343 QPDF_ERROR_CODE 342 QPDF_ERROR_CODE
344 - qpdf_update_from_json_data(  
345 - qpdf_data qpdf, char const* buffer, unsigned long long size); 343 + qpdf_update_from_json_data(qpdf_data qpdf, char const* buffer, unsigned long long size);
346 344
347 /* READ FUNCTIONS */ 345 /* READ FUNCTIONS */
348 346
@@ -492,23 +490,19 @@ extern &quot;C&quot; { @@ -492,23 +490,19 @@ extern &quot;C&quot; {
492 unsigned char const* qpdf_get_buffer(qpdf_data qpdf); 490 unsigned char const* qpdf_get_buffer(qpdf_data qpdf);
493 491
494 QPDF_DLL 492 QPDF_DLL
495 - void  
496 - qpdf_set_object_stream_mode(qpdf_data qpdf, enum qpdf_object_stream_e mode); 493 + void qpdf_set_object_stream_mode(qpdf_data qpdf, enum qpdf_object_stream_e mode);
497 494
498 QPDF_DLL 495 QPDF_DLL
499 - void  
500 - qpdf_set_stream_data_mode(qpdf_data qpdf, enum qpdf_stream_data_e mode); 496 + void qpdf_set_stream_data_mode(qpdf_data qpdf, enum qpdf_stream_data_e mode);
501 497
502 QPDF_DLL 498 QPDF_DLL
503 void qpdf_set_compress_streams(qpdf_data qpdf, QPDF_BOOL value); 499 void qpdf_set_compress_streams(qpdf_data qpdf, QPDF_BOOL value);
504 500
505 QPDF_DLL 501 QPDF_DLL
506 - void qpdf_set_decode_level(  
507 - qpdf_data qpdf, enum qpdf_stream_decode_level_e level); 502 + void qpdf_set_decode_level(qpdf_data qpdf, enum qpdf_stream_decode_level_e level);
508 503
509 QPDF_DLL 504 QPDF_DLL
510 - void  
511 - qpdf_set_preserve_unreferenced_objects(qpdf_data qpdf, QPDF_BOOL value); 505 + void qpdf_set_preserve_unreferenced_objects(qpdf_data qpdf, QPDF_BOOL value);
512 506
513 QPDF_DLL 507 QPDF_DLL
514 void qpdf_set_newline_before_endstream(qpdf_data qpdf, QPDF_BOOL value); 508 void qpdf_set_newline_before_endstream(qpdf_data qpdf, QPDF_BOOL value);
@@ -625,8 +619,8 @@ extern &quot;C&quot; { @@ -625,8 +619,8 @@ extern &quot;C&quot; {
625 void qpdf_force_pdf_version(qpdf_data qpdf, char const* version); 619 void qpdf_force_pdf_version(qpdf_data qpdf, char const* version);
626 620
627 QPDF_DLL 621 QPDF_DLL
628 - void qpdf_force_pdf_version_and_extension(  
629 - qpdf_data qpdf, char const* version, int extension_level); 622 + void
  623 + qpdf_force_pdf_version_and_extension(qpdf_data qpdf, char const* version, int extension_level);
630 624
631 /* During write, your report_progress function will be called with 625 /* During write, your report_progress function will be called with
632 * a value between 0 and 100 representing the approximate write 626 * a value between 0 and 100 representing the approximate write
@@ -640,9 +634,7 @@ extern &quot;C&quot; { @@ -640,9 +634,7 @@ extern &quot;C&quot; {
640 */ 634 */
641 QPDF_DLL 635 QPDF_DLL
642 void qpdf_register_progress_reporter( 636 void qpdf_register_progress_reporter(
643 - qpdf_data qpdf,  
644 - void (*report_progress)(int percent, void* data),  
645 - void* data); 637 + qpdf_data qpdf, void (*report_progress)(int percent, void* data), void* data);
646 638
647 /* Do actual write operation. */ 639 /* Do actual write operation. */
648 QPDF_DLL 640 QPDF_DLL
@@ -733,8 +725,7 @@ extern &quot;C&quot; { @@ -733,8 +725,7 @@ extern &quot;C&quot; {
733 QPDF_DLL 725 QPDF_DLL
734 qpdf_oh qpdf_make_indirect_object(qpdf_data qpdf, qpdf_oh oh); 726 qpdf_oh qpdf_make_indirect_object(qpdf_data qpdf, qpdf_oh oh);
735 QPDF_DLL 727 QPDF_DLL
736 - void  
737 - qpdf_replace_object(qpdf_data qpdf, int objid, int generation, qpdf_oh oh); 728 + void qpdf_replace_object(qpdf_data qpdf, int objid, int generation, qpdf_oh oh);
738 729
739 /* Wrappers around QPDFObjectHandle methods. Be sure to read 730 /* Wrappers around QPDFObjectHandle methods. Be sure to read
740 * corresponding comments in QPDFObjectHandle.hh to understand 731 * corresponding comments in QPDFObjectHandle.hh to understand
@@ -811,8 +802,7 @@ extern &quot;C&quot; { @@ -811,8 +802,7 @@ extern &quot;C&quot; {
811 QPDF_DLL 802 QPDF_DLL
812 unsigned long long qpdf_oh_get_uint_value(qpdf_data qpdf, qpdf_oh oh); 803 unsigned long long qpdf_oh_get_uint_value(qpdf_data qpdf, qpdf_oh oh);
813 QPDF_DLL 804 QPDF_DLL
814 - QPDF_BOOL qpdf_oh_get_value_as_ulonglong(  
815 - qpdf_data qpdf, qpdf_oh oh, unsigned long long* value); 805 + QPDF_BOOL qpdf_oh_get_value_as_ulonglong(qpdf_data qpdf, qpdf_oh oh, unsigned long long* value);
816 QPDF_DLL 806 QPDF_DLL
817 unsigned int qpdf_oh_get_uint_value_as_uint(qpdf_data qpdf, qpdf_oh oh); 807 unsigned int qpdf_oh_get_uint_value_as_uint(qpdf_data qpdf, qpdf_oh oh);
818 QPDF_DLL 808 QPDF_DLL
@@ -822,8 +812,8 @@ extern &quot;C&quot; { @@ -822,8 +812,8 @@ extern &quot;C&quot; {
822 QPDF_DLL 812 QPDF_DLL
823 char const* qpdf_oh_get_real_value(qpdf_data qpdf, qpdf_oh oh); 813 char const* qpdf_oh_get_real_value(qpdf_data qpdf, qpdf_oh oh);
824 QPDF_DLL 814 QPDF_DLL
825 - QPDF_BOOL qpdf_oh_get_value_as_real(  
826 - qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length); 815 + QPDF_BOOL
  816 + qpdf_oh_get_value_as_real(qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
827 817
828 QPDF_DLL 818 QPDF_DLL
829 QPDF_BOOL qpdf_oh_is_number(qpdf_data qpdf, qpdf_oh oh); 819 QPDF_BOOL qpdf_oh_is_number(qpdf_data qpdf, qpdf_oh oh);
@@ -836,8 +826,8 @@ extern &quot;C&quot; { @@ -836,8 +826,8 @@ extern &quot;C&quot; {
836 QPDF_DLL 826 QPDF_DLL
837 char const* qpdf_oh_get_name(qpdf_data qpdf, qpdf_oh oh); 827 char const* qpdf_oh_get_name(qpdf_data qpdf, qpdf_oh oh);
838 QPDF_DLL 828 QPDF_DLL
839 - QPDF_BOOL qpdf_oh_get_value_as_name(  
840 - qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length); 829 + QPDF_BOOL
  830 + qpdf_oh_get_value_as_name(qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
841 831
842 /* Return the length of the last string returned. This enables you 832 /* Return the length of the last string returned. This enables you
843 * to retrieve the entire string for cases in which a char* 833 * to retrieve the entire string for cases in which a char*
@@ -858,19 +848,17 @@ extern &quot;C&quot; { @@ -858,19 +848,17 @@ extern &quot;C&quot; {
858 QPDF_DLL 848 QPDF_DLL
859 char const* qpdf_oh_get_string_value(qpdf_data qpdf, qpdf_oh oh); 849 char const* qpdf_oh_get_string_value(qpdf_data qpdf, qpdf_oh oh);
860 QPDF_DLL 850 QPDF_DLL
861 - QPDF_BOOL qpdf_oh_get_value_as_string(  
862 - qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length); 851 + QPDF_BOOL
  852 + qpdf_oh_get_value_as_string(qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
863 QPDF_DLL 853 QPDF_DLL
864 char const* qpdf_oh_get_utf8_value(qpdf_data qpdf, qpdf_oh oh); 854 char const* qpdf_oh_get_utf8_value(qpdf_data qpdf, qpdf_oh oh);
865 QPDF_DLL 855 QPDF_DLL
866 - QPDF_BOOL qpdf_oh_get_value_as_utf8(  
867 - qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length); 856 + QPDF_BOOL
  857 + qpdf_oh_get_value_as_utf8(qpdf_data qpdf, qpdf_oh oh, char const** value, size_t* length);
868 QPDF_DLL 858 QPDF_DLL
869 - char const*  
870 - qpdf_oh_get_binary_string_value(qpdf_data qpdf, qpdf_oh oh, size_t* length); 859 + char const* qpdf_oh_get_binary_string_value(qpdf_data qpdf, qpdf_oh oh, size_t* length);
871 QPDF_DLL 860 QPDF_DLL
872 - char const*  
873 - qpdf_oh_get_binary_utf8_value(qpdf_data qpdf, qpdf_oh oh, size_t* length); 861 + char const* qpdf_oh_get_binary_utf8_value(qpdf_data qpdf, qpdf_oh oh, size_t* length);
874 862
875 QPDF_DLL 863 QPDF_DLL
876 int qpdf_oh_get_array_n_items(qpdf_data qpdf, qpdf_oh oh); 864 int qpdf_oh_get_array_n_items(qpdf_data qpdf, qpdf_oh oh);
@@ -906,8 +894,7 @@ extern &quot;C&quot; { @@ -906,8 +894,7 @@ extern &quot;C&quot; {
906 QPDF_DLL 894 QPDF_DLL
907 qpdf_oh qpdf_oh_get_key(qpdf_data qpdf, qpdf_oh oh, char const* key); 895 qpdf_oh qpdf_oh_get_key(qpdf_data qpdf, qpdf_oh oh, char const* key);
908 QPDF_DLL 896 QPDF_DLL
909 - qpdf_oh  
910 - qpdf_oh_get_key_if_dict(qpdf_data qpdf, qpdf_oh oh, char const* key); 897 + qpdf_oh qpdf_oh_get_key_if_dict(qpdf_data qpdf, qpdf_oh oh, char const* key);
911 898
912 QPDF_DLL 899 QPDF_DLL
913 QPDF_BOOL 900 QPDF_BOOL
@@ -924,8 +911,7 @@ extern &quot;C&quot; { @@ -924,8 +911,7 @@ extern &quot;C&quot; {
924 QPDF_DLL 911 QPDF_DLL
925 qpdf_oh qpdf_oh_new_real_from_string(qpdf_data qpdf, char const* value); 912 qpdf_oh qpdf_oh_new_real_from_string(qpdf_data qpdf, char const* value);
926 QPDF_DLL 913 QPDF_DLL
927 - qpdf_oh qpdf_oh_new_real_from_double(  
928 - qpdf_data qpdf, double value, int decimal_places); 914 + qpdf_oh qpdf_oh_new_real_from_double(qpdf_data qpdf, double value, int decimal_places);
929 QPDF_DLL 915 QPDF_DLL
930 qpdf_oh qpdf_oh_new_name(qpdf_data qpdf, char const* name); 916 qpdf_oh qpdf_oh_new_name(qpdf_data qpdf, char const* name);
931 QPDF_DLL 917 QPDF_DLL
@@ -936,11 +922,9 @@ extern &quot;C&quot; { @@ -936,11 +922,9 @@ extern &quot;C&quot; {
936 * contain atrbitary binary data including embedded null characters. 922 * contain atrbitary binary data including embedded null characters.
937 */ 923 */
938 QPDF_DLL 924 QPDF_DLL
939 - qpdf_oh  
940 - qpdf_oh_new_binary_string(qpdf_data qpdf, char const* str, size_t length); 925 + qpdf_oh qpdf_oh_new_binary_string(qpdf_data qpdf, char const* str, size_t length);
941 QPDF_DLL 926 QPDF_DLL
942 - qpdf_oh qpdf_oh_new_binary_unicode_string(  
943 - qpdf_data qpdf, char const* str, size_t length); 927 + qpdf_oh qpdf_oh_new_binary_unicode_string(qpdf_data qpdf, char const* str, size_t length);
944 QPDF_DLL 928 QPDF_DLL
945 qpdf_oh qpdf_oh_new_array(qpdf_data qpdf); 929 qpdf_oh qpdf_oh_new_array(qpdf_data qpdf);
946 QPDF_DLL 930 QPDF_DLL
@@ -959,8 +943,7 @@ extern &quot;C&quot; { @@ -959,8 +943,7 @@ extern &quot;C&quot; {
959 void qpdf_oh_make_direct(qpdf_data qpdf, qpdf_oh oh); 943 void qpdf_oh_make_direct(qpdf_data qpdf, qpdf_oh oh);
960 944
961 QPDF_DLL 945 QPDF_DLL
962 - void  
963 - qpdf_oh_set_array_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item); 946 + void qpdf_oh_set_array_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item);
964 QPDF_DLL 947 QPDF_DLL
965 void qpdf_oh_insert_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item); 948 void qpdf_oh_insert_item(qpdf_data qpdf, qpdf_oh oh, int at, qpdf_oh item);
966 QPDF_DLL 949 QPDF_DLL
@@ -969,13 +952,11 @@ extern &quot;C&quot; { @@ -969,13 +952,11 @@ extern &quot;C&quot; {
969 void qpdf_oh_erase_item(qpdf_data qpdf, qpdf_oh oh, int at); 952 void qpdf_oh_erase_item(qpdf_data qpdf, qpdf_oh oh, int at);
970 953
971 QPDF_DLL 954 QPDF_DLL
972 - void qpdf_oh_replace_key(  
973 - qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item); 955 + void qpdf_oh_replace_key(qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item);
974 QPDF_DLL 956 QPDF_DLL
975 void qpdf_oh_remove_key(qpdf_data qpdf, qpdf_oh oh, char const* key); 957 void qpdf_oh_remove_key(qpdf_data qpdf, qpdf_oh oh, char const* key);
976 QPDF_DLL 958 QPDF_DLL
977 - void qpdf_oh_replace_or_remove_key(  
978 - qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item); 959 + void qpdf_oh_replace_or_remove_key(qpdf_data qpdf, qpdf_oh oh, char const* key, qpdf_oh item);
979 960
980 QPDF_DLL 961 QPDF_DLL
981 qpdf_oh qpdf_oh_get_dict(qpdf_data qpdf, qpdf_oh oh); 962 qpdf_oh qpdf_oh_get_dict(qpdf_data qpdf, qpdf_oh oh);
@@ -1005,8 +986,7 @@ extern &quot;C&quot; { @@ -1005,8 +986,7 @@ extern &quot;C&quot; {
1005 * while `foreign_oh` belongs to `other_qpdf`. 986 * while `foreign_oh` belongs to `other_qpdf`.
1006 */ 987 */
1007 QPDF_DLL 988 QPDF_DLL
1008 - qpdf_oh qpdf_oh_copy_foreign_object(  
1009 - qpdf_data qpdf, qpdf_data other_qpdf, qpdf_oh foreign_oh); 989 + qpdf_oh qpdf_oh_copy_foreign_object(qpdf_data qpdf, qpdf_data other_qpdf, qpdf_oh foreign_oh);
1010 990
1011 /* STREAM FUNCTIONS */ 991 /* STREAM FUNCTIONS */
1012 992
@@ -1105,19 +1085,12 @@ extern &quot;C&quot; { @@ -1105,19 +1085,12 @@ extern &quot;C&quot; {
1105 1085
1106 /* addPage() */ 1086 /* addPage() */
1107 QPDF_DLL 1087 QPDF_DLL
1108 - QPDF_ERROR_CODE qpdf_add_page(  
1109 - qpdf_data qpdf,  
1110 - qpdf_data newpage_qpdf,  
1111 - qpdf_oh newpage,  
1112 - QPDF_BOOL first); 1088 + QPDF_ERROR_CODE
  1089 + qpdf_add_page(qpdf_data qpdf, qpdf_data newpage_qpdf, qpdf_oh newpage, QPDF_BOOL first);
1113 /* addPageAt() */ 1090 /* addPageAt() */
1114 QPDF_DLL 1091 QPDF_DLL
1115 QPDF_ERROR_CODE qpdf_add_page_at( 1092 QPDF_ERROR_CODE qpdf_add_page_at(
1116 - qpdf_data qpdf,  
1117 - qpdf_data newpage_qpdf,  
1118 - qpdf_oh newpage,  
1119 - QPDF_BOOL before,  
1120 - qpdf_oh refpage); 1093 + qpdf_data qpdf, qpdf_data newpage_qpdf, qpdf_oh newpage, QPDF_BOOL before, qpdf_oh refpage);
1121 /* removePage() */ 1094 /* removePage() */
1122 QPDF_DLL 1095 QPDF_DLL
1123 QPDF_ERROR_CODE qpdf_remove_page(qpdf_data qpdf, qpdf_oh page); 1096 QPDF_ERROR_CODE qpdf_remove_page(qpdf_data qpdf, qpdf_oh page);
include/qpdf/qpdfjob-c.h
@@ -111,8 +111,7 @@ extern &quot;C&quot; { @@ -111,8 +111,7 @@ extern &quot;C&quot; {
111 * is invalid to call any other functions this job handle. 111 * is invalid to call any other functions this job handle.
112 */ 112 */
113 QPDF_DLL 113 QPDF_DLL
114 - int  
115 - qpdfjob_initialize_from_argv(qpdfjob_handle j, char const* const argv[]); 114 + int qpdfjob_initialize_from_argv(qpdfjob_handle j, char const* const argv[]);
116 115
117 #ifndef QPDF_NO_WCHAR_T 116 #ifndef QPDF_NO_WCHAR_T
118 /* This function is the same as qpdfjob_initialize_from_argv 117 /* This function is the same as qpdfjob_initialize_from_argv
@@ -120,8 +119,7 @@ extern &quot;C&quot; { @@ -120,8 +119,7 @@ extern &quot;C&quot; {
120 * suitable for calling from a Windows wmain function. 119 * suitable for calling from a Windows wmain function.
121 */ 120 */
122 QPDF_DLL 121 QPDF_DLL
123 - int qpdfjob_initialize_from_wide_argv(  
124 - qpdfjob_handle j, wchar_t const* const argv[]); 122 + int qpdfjob_initialize_from_wide_argv(qpdfjob_handle j, wchar_t const* const argv[]);
125 #endif /* QPDF_NO_WCHAR_T */ 123 #endif /* QPDF_NO_WCHAR_T */
126 124
127 /* This function wraps QPDFJob::initializeFromJson. The return 125 /* This function wraps QPDFJob::initializeFromJson. The return
@@ -167,9 +165,7 @@ extern &quot;C&quot; { @@ -167,9 +165,7 @@ extern &quot;C&quot; {
167 */ 165 */
168 QPDF_DLL 166 QPDF_DLL
169 void qpdfjob_register_progress_reporter( 167 void qpdfjob_register_progress_reporter(
170 - qpdfjob_handle j,  
171 - void (*report_progress)(int percent, void* data),  
172 - void* data); 168 + qpdfjob_handle j, void (*report_progress)(int percent, void* data), void* data);
173 169
174 #ifdef __cplusplus 170 #ifdef __cplusplus
175 } 171 }
include/qpdf/qpdflogger-c.h
@@ -76,22 +76,13 @@ extern &quot;C&quot; { @@ -76,22 +76,13 @@ extern &quot;C&quot; {
76 76
77 QPDF_DLL 77 QPDF_DLL
78 void qpdflogger_set_info( 78 void qpdflogger_set_info(
79 - qpdflogger_handle l,  
80 - enum qpdf_log_dest_e dest,  
81 - qpdf_log_fn_t fn,  
82 - void* udata); 79 + qpdflogger_handle l, enum qpdf_log_dest_e dest, qpdf_log_fn_t fn, void* udata);
83 QPDF_DLL 80 QPDF_DLL
84 void qpdflogger_set_warn( 81 void qpdflogger_set_warn(
85 - qpdflogger_handle l,  
86 - enum qpdf_log_dest_e dest,  
87 - qpdf_log_fn_t fn,  
88 - void* udata); 82 + qpdflogger_handle l, enum qpdf_log_dest_e dest, qpdf_log_fn_t fn, void* udata);
89 QPDF_DLL 83 QPDF_DLL
90 void qpdflogger_set_error( 84 void qpdflogger_set_error(
91 - qpdflogger_handle l,  
92 - enum qpdf_log_dest_e dest,  
93 - qpdf_log_fn_t fn,  
94 - void* udata); 85 + qpdflogger_handle l, enum qpdf_log_dest_e dest, qpdf_log_fn_t fn, void* udata);
95 86
96 /* A non-zero value for only_if_not_set means that the save 87 /* A non-zero value for only_if_not_set means that the save
97 * pipeline will only be changed if it is not already set. 88 * pipeline will only be changed if it is not already set.
@@ -104,8 +95,7 @@ extern &quot;C&quot; { @@ -104,8 +95,7 @@ extern &quot;C&quot; {
104 void* udata, 95 void* udata,
105 int only_if_not_set); 96 int only_if_not_set);
106 QPDF_DLL 97 QPDF_DLL
107 - void qpdflogger_save_to_standard_output(  
108 - qpdflogger_handle l, int only_if_not_set); 98 + void qpdflogger_save_to_standard_output(qpdflogger_handle l, int only_if_not_set);
109 99
110 /* For testing */ 100 /* For testing */
111 QPDF_DLL 101 QPDF_DLL
libqpdf/AES_PDF_native.cc
@@ -27,11 +27,9 @@ AES_PDF_native::AES_PDF_native( @@ -27,11 +27,9 @@ AES_PDF_native::AES_PDF_native(
27 std::memcpy(this->key.get(), key, key_bytes); 27 std::memcpy(this->key.get(), key, key_bytes);
28 std::memset(this->rk.get(), 0, rk_bytes); 28 std::memset(this->rk.get(), 0, rk_bytes);
29 if (encrypt) { 29 if (encrypt) {
30 - this->nrounds =  
31 - rijndaelSetupEncrypt(this->rk.get(), this->key.get(), keybits); 30 + this->nrounds = rijndaelSetupEncrypt(this->rk.get(), this->key.get(), keybits);
32 } else { 31 } else {
33 - this->nrounds =  
34 - rijndaelSetupDecrypt(this->rk.get(), this->key.get(), keybits); 32 + this->nrounds = rijndaelSetupDecrypt(this->rk.get(), this->key.get(), keybits);
35 } 33 }
36 } 34 }
37 35
@@ -46,8 +44,7 @@ AES_PDF_native::update(unsigned char* in_data, unsigned char* out_data) @@ -46,8 +44,7 @@ AES_PDF_native::update(unsigned char* in_data, unsigned char* out_data)
46 } 44 }
47 rijndaelEncrypt(this->rk.get(), this->nrounds, in_data, out_data); 45 rijndaelEncrypt(this->rk.get(), this->nrounds, in_data, out_data);
48 if (this->cbc_mode) { 46 if (this->cbc_mode) {
49 - memcpy(  
50 - this->cbc_block, out_data, QPDFCryptoImpl::rijndael_buf_size); 47 + memcpy(this->cbc_block, out_data, QPDFCryptoImpl::rijndael_buf_size);
51 } 48 }
52 } else { 49 } else {
53 rijndaelDecrypt(this->rk.get(), this->nrounds, in_data, out_data); 50 rijndaelDecrypt(this->rk.get(), this->nrounds, in_data, out_data);
libqpdf/BitStream.cc
@@ -33,8 +33,7 @@ BitStream::getBits(size_t nbits) @@ -33,8 +33,7 @@ BitStream::getBits(size_t nbits)
33 long long 33 long long
34 BitStream::getBitsSigned(size_t nbits) 34 BitStream::getBitsSigned(size_t nbits)
35 { 35 {
36 - unsigned long long bits =  
37 - read_bits(this->p, this->bit_offset, this->bits_available, nbits); 36 + unsigned long long bits = read_bits(this->p, this->bit_offset, this->bits_available, nbits);
38 long long result = 0; 37 long long result = 0;
39 if (static_cast<long long>(bits) > 1LL << (nbits - 1)) { 38 if (static_cast<long long>(bits) > 1LL << (nbits - 1)) {
40 result = static_cast<long long>(bits - (1ULL << nbits)); 39 result = static_cast<long long>(bits - (1ULL << nbits));
@@ -49,8 +48,7 @@ BitStream::getBitsInt(size_t nbits) @@ -49,8 +48,7 @@ BitStream::getBitsInt(size_t nbits)
49 { 48 {
50 return static_cast<int>( 49 return static_cast<int>(
51 // line-break 50 // line-break
52 - QIntC::to_uint(  
53 - read_bits(this->p, this->bit_offset, this->bits_available, nbits))); 51 + QIntC::to_uint(read_bits(this->p, this->bit_offset, this->bits_available, nbits)));
54 } 52 }
55 53
56 void 54 void
@@ -59,8 +57,7 @@ BitStream::skipToNextByte() @@ -59,8 +57,7 @@ BitStream::skipToNextByte()
59 if (bit_offset != 7) { 57 if (bit_offset != 7) {
60 size_t bits_to_skip = bit_offset + 1; 58 size_t bits_to_skip = bit_offset + 1;
61 if (bits_available < bits_to_skip) { 59 if (bits_available < bits_to_skip) {
62 - throw std::logic_error(  
63 - "INTERNAL ERROR: overflow skipping to next byte in bitstream"); 60 + throw std::logic_error("INTERNAL ERROR: overflow skipping to next byte in bitstream");
64 } 61 }
65 bit_offset = 7; 62 bit_offset = 7;
66 ++p; 63 ++p;
libqpdf/BufferInputSource.cc
@@ -5,8 +5,7 @@ @@ -5,8 +5,7 @@
5 #include <cstring> 5 #include <cstring>
6 #include <sstream> 6 #include <sstream>
7 7
8 -BufferInputSource::BufferInputSource(  
9 - std::string const& description, Buffer* buf, bool own_memory) : 8 +BufferInputSource::BufferInputSource(std::string const& description, Buffer* buf, bool own_memory) :
10 own_memory(own_memory), 9 own_memory(own_memory),
11 description(description), 10 description(description),
12 buf(buf), 11 buf(buf),
@@ -15,8 +14,7 @@ BufferInputSource::BufferInputSource( @@ -15,8 +14,7 @@ BufferInputSource::BufferInputSource(
15 { 14 {
16 } 15 }
17 16
18 -BufferInputSource::BufferInputSource(  
19 - std::string const& description, std::string const& contents) : 17 +BufferInputSource::BufferInputSource(std::string const& description, std::string const& contents) :
20 own_memory(true), 18 own_memory(true),
21 description(description), 19 description(description),
22 buf(new Buffer(contents.length())), 20 buf(new Buffer(contents.length())),
@@ -100,14 +98,12 @@ BufferInputSource::seek(qpdf_offset_t offset, int whence) @@ -100,14 +98,12 @@ BufferInputSource::seek(qpdf_offset_t offset, int whence)
100 break; 98 break;
101 99
102 default: 100 default:
103 - throw std::logic_error(  
104 - "INTERNAL ERROR: invalid argument to BufferInputSource::seek"); 101 + throw std::logic_error("INTERNAL ERROR: invalid argument to BufferInputSource::seek");
105 break; 102 break;
106 } 103 }
107 104
108 if (this->cur_offset < 0) { 105 if (this->cur_offset < 0) {
109 - throw std::runtime_error(  
110 - this->description + ": seek before beginning of buffer"); 106 + throw std::runtime_error(this->description + ": seek before beginning of buffer");
111 } 107 }
112 } 108 }
113 109
libqpdf/ContentNormalizer.cc
@@ -44,13 +44,11 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const&amp; token) @@ -44,13 +44,11 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const&amp; token)
44 // Replacing string and name tokens in this way normalizes 44 // Replacing string and name tokens in this way normalizes
45 // their representation as this will automatically handle 45 // their representation as this will automatically handle
46 // quoting of unprintable characters, etc. 46 // quoting of unprintable characters, etc.
47 - writeToken(  
48 - QPDFTokenizer::Token(QPDFTokenizer::tt_string, token.getValue())); 47 + writeToken(QPDFTokenizer::Token(QPDFTokenizer::tt_string, token.getValue()));
49 break; 48 break;
50 49
51 case QPDFTokenizer::tt_name: 50 case QPDFTokenizer::tt_name:
52 - writeToken(  
53 - QPDFTokenizer::Token(QPDFTokenizer::tt_name, token.getValue())); 51 + writeToken(QPDFTokenizer::Token(QPDFTokenizer::tt_name, token.getValue()));
54 break; 52 break;
55 53
56 default: 54 default:
@@ -59,10 +57,8 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const&amp; token) @@ -59,10 +57,8 @@ ContentNormalizer::handleToken(QPDFTokenizer::Token const&amp; token)
59 } 57 }
60 58
61 value = token.getRawValue(); 59 value = token.getRawValue();
62 - if (((token_type == QPDFTokenizer::tt_string) ||  
63 - (token_type == QPDFTokenizer::tt_name)) &&  
64 - ((value.find('\r') != std::string::npos) ||  
65 - (value.find('\n') != std::string::npos))) { 60 + if (((token_type == QPDFTokenizer::tt_string) || (token_type == QPDFTokenizer::tt_name)) &&
  61 + ((value.find('\r') != std::string::npos) || (value.find('\n') != std::string::npos))) {
66 write("\n"); 62 write("\n");
67 } 63 }
68 } 64 }
libqpdf/FileInputSource.cc
@@ -18,8 +18,7 @@ FileInputSource::FileInputSource(char const* filename) : @@ -18,8 +18,7 @@ FileInputSource::FileInputSource(char const* filename) :
18 { 18 {
19 } 19 }
20 20
21 -FileInputSource::FileInputSource(  
22 - char const* description, FILE* filep, bool close_file) : 21 +FileInputSource::FileInputSource(char const* description, FILE* filep, bool close_file) :
23 close_file(close_file), 22 close_file(close_file),
24 filename(description), 23 filename(description),
25 file(filep) 24 file(filep)
@@ -104,8 +103,8 @@ FileInputSource::seek(qpdf_offset_t offset, int whence) @@ -104,8 +103,8 @@ FileInputSource::seek(qpdf_offset_t offset, int whence)
104 { 103 {
105 if (QUtil::seek(this->file, offset, whence) == -1) { 104 if (QUtil::seek(this->file, offset, whence) == -1) {
106 QUtil::throw_system_error( 105 QUtil::throw_system_error(
107 - std::string("seek to ") + this->filename + ", offset " +  
108 - std::to_string(offset) + " (" + std::to_string(whence) + ")"); 106 + std::string("seek to ") + this->filename + ", offset " + std::to_string(offset) + " (" +
  107 + std::to_string(whence) + ")");
109 } 108 }
110 } 109 }
111 110
libqpdf/InputSource.cc
@@ -43,8 +43,7 @@ InputSource::readLine(size_t max_line_length) @@ -43,8 +43,7 @@ InputSource::readLine(size_t max_line_length)
43 } 43 }
44 44
45 bool 45 bool
46 -InputSource::findFirst(  
47 - char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder) 46 +InputSource::findFirst(char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder)
48 { 47 {
49 // Basic approach: search for the first character of start_chars 48 // Basic approach: search for the first character of start_chars
50 // starting from offset but not going past len (if len != 0). Once 49 // starting from offset but not going past len (if len != 0). Once
@@ -64,9 +63,8 @@ InputSource::findFirst( @@ -64,9 +63,8 @@ InputSource::findFirst(
64 // so that buf[size] is valid memory. 63 // so that buf[size] is valid memory.
65 size_t size = sizeof(buf) - 1; 64 size_t size = sizeof(buf) - 1;
66 if ((strlen(start_chars) < 1) || (strlen(start_chars) > size)) { 65 if ((strlen(start_chars) < 1) || (strlen(start_chars) > size)) {
67 - throw std::logic_error(  
68 - "InputSource::findSource called with"  
69 - " too small or too large of a character sequence"); 66 + throw std::logic_error("InputSource::findSource called with"
  67 + " too small or too large of a character sequence");
70 } 68 }
71 69
72 char* p = nullptr; 70 char* p = nullptr;
@@ -86,13 +84,10 @@ InputSource::findFirst( @@ -86,13 +84,10 @@ InputSource::findFirst(
86 // If p points to buf[size], since strlen(start_chars) is 84 // If p points to buf[size], since strlen(start_chars) is
87 // always >= 1, this overflow test will be correct for that 85 // always >= 1, this overflow test will be correct for that
88 // case regardless of start_chars. 86 // case regardless of start_chars.
89 - if ((p == nullptr) ||  
90 - ((p + strlen(start_chars)) > (buf + bytes_read))) { 87 + if ((p == nullptr) || ((p + strlen(start_chars)) > (buf + bytes_read))) {
91 if (p) { 88 if (p) {
92 QTC::TC( 89 QTC::TC(
93 - "libtests",  
94 - "InputSource read next block",  
95 - ((p == buf + bytes_read) ? 0 : 1)); 90 + "libtests", "InputSource read next block", ((p == buf + bytes_read) ? 0 : 1));
96 buf_offset += (p - buf); 91 buf_offset += (p - buf);
97 } 92 }
98 this->seek(buf_offset, SEEK_SET); 93 this->seek(buf_offset, SEEK_SET);
@@ -102,10 +97,7 @@ InputSource::findFirst( @@ -102,10 +97,7 @@ InputSource::findFirst(
102 // protection against overrun when using string functions. 97 // protection against overrun when using string functions.
103 bytes_read = this->read(buf, size); 98 bytes_read = this->read(buf, size);
104 if (bytes_read < strlen(start_chars)) { 99 if (bytes_read < strlen(start_chars)) {
105 - QTC::TC(  
106 - "libtests",  
107 - "InputSource find EOF",  
108 - bytes_read == 0 ? 0 : 1); 100 + QTC::TC("libtests", "InputSource find EOF", bytes_read == 0 ? 0 : 1);
109 return false; 101 return false;
110 } 102 }
111 memset(buf + bytes_read, '\0', 1 + (size - bytes_read)); 103 memset(buf + bytes_read, '\0', 1 + (size - bytes_read));
@@ -115,18 +107,14 @@ InputSource::findFirst( @@ -115,18 +107,14 @@ InputSource::findFirst(
115 // Search for the first character. 107 // Search for the first character.
116 if ((p = static_cast<char*>( 108 if ((p = static_cast<char*>(
117 // line-break 109 // line-break
118 - memchr(  
119 - p,  
120 - start_chars[0],  
121 - bytes_read - QIntC::to_size(p - buf)))) != nullptr) { 110 + memchr(p, start_chars[0], bytes_read - QIntC::to_size(p - buf)))) != nullptr) {
122 if (p == buf) { 111 if (p == buf) {
123 QTC::TC("libtests", "InputSource found match at buf[0]"); 112 QTC::TC("libtests", "InputSource found match at buf[0]");
124 } 113 }
125 // Found first letter. 114 // Found first letter.
126 if (len != 0) { 115 if (len != 0) {
127 // Make sure it's in range. 116 // Make sure it's in range.
128 - size_t p_relative_offset =  
129 - QIntC::to_size((p - buf) + (buf_offset - offset)); 117 + size_t p_relative_offset = QIntC::to_size((p - buf) + (buf_offset - offset));
130 if (p_relative_offset >= len) { 118 if (p_relative_offset >= len) {
131 // out of range 119 // out of range
132 QTC::TC("libtests", "InputSource out of range"); 120 QTC::TC("libtests", "InputSource out of range");
@@ -151,14 +139,10 @@ InputSource::findFirst( @@ -151,14 +139,10 @@ InputSource::findFirst(
151 if (finder.check()) { 139 if (finder.check()) {
152 return true; 140 return true;
153 } else { 141 } else {
154 - QTC::TC(  
155 - "libtests",  
156 - "InputSource start_chars matched but not check"); 142 + QTC::TC("libtests", "InputSource start_chars matched but not check");
157 } 143 }
158 } else { 144 } else {
159 - QTC::TC(  
160 - "libtests",  
161 - "InputSource first char matched but not string"); 145 + QTC::TC("libtests", "InputSource first char matched but not string");
162 } 146 }
163 // This occurrence of the first character wasn't a match. 147 // This occurrence of the first character wasn't a match.
164 // Skip over it and keep searching. 148 // Skip over it and keep searching.
@@ -172,8 +156,7 @@ InputSource::findFirst( @@ -172,8 +156,7 @@ InputSource::findFirst(
172 } 156 }
173 157
174 bool 158 bool
175 -InputSource::findLast(  
176 - char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder) 159 +InputSource::findLast(char const* start_chars, qpdf_offset_t offset, size_t len, Finder& finder)
177 { 160 {
178 bool found = false; 161 bool found = false;
179 qpdf_offset_t after_found_offset = 0; 162 qpdf_offset_t after_found_offset = 0;
libqpdf/InsecureRandomDataProvider.cc
@@ -24,8 +24,7 @@ InsecureRandomDataProvider::random() @@ -24,8 +24,7 @@ InsecureRandomDataProvider::random()
24 // Seed the random number generator with something simple, but 24 // Seed the random number generator with something simple, but
25 // just to be interesting, don't use the unmodified current 25 // just to be interesting, don't use the unmodified current
26 // time. It would be better if this were a more secure seed. 26 // time. It would be better if this were a more secure seed.
27 - auto seed =  
28 - static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc); 27 + auto seed = static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc);
29 #ifdef HAVE_RANDOM 28 #ifdef HAVE_RANDOM
30 ::srandom(seed); 29 ::srandom(seed);
31 #else 30 #else
libqpdf/JSON.cc
@@ -73,8 +73,7 @@ JSON::writeArrayClose(Pipeline* p, bool first, size_t depth) @@ -73,8 +73,7 @@ JSON::writeArrayClose(Pipeline* p, bool first, size_t depth)
73 } 73 }
74 74
75 void 75 void
76 -JSON::writeDictionaryKey(  
77 - Pipeline* p, bool& first, std::string const& key, size_t depth) 76 +JSON::writeDictionaryKey(Pipeline* p, bool& first, std::string const& key, size_t depth)
78 { 77 {
79 writeNext(p, first, depth); 78 writeNext(p, first, depth);
80 *p << std::string("\"") + key + "\": "; 79 *p << std::string("\"") + key + "\": ";
@@ -82,19 +81,14 @@ JSON::writeDictionaryKey( @@ -82,19 +81,14 @@ JSON::writeDictionaryKey(
82 81
83 void 82 void
84 JSON::writeDictionaryItem( 83 JSON::writeDictionaryItem(
85 - Pipeline* p,  
86 - bool& first,  
87 - std::string const& key,  
88 - JSON const& value,  
89 - size_t depth) 84 + Pipeline* p, bool& first, std::string const& key, JSON const& value, size_t depth)
90 { 85 {
91 writeDictionaryKey(p, first, key, depth); 86 writeDictionaryKey(p, first, key, depth);
92 value.write(p, depth); 87 value.write(p, depth);
93 } 88 }
94 89
95 void 90 void
96 -JSON::writeArrayItem(  
97 - Pipeline* p, bool& first, JSON const& element, size_t depth) 91 +JSON::writeArrayItem(Pipeline* p, bool& first, JSON const& element, size_t depth)
98 { 92 {
99 writeNext(p, first, depth); 93 writeNext(p, first, depth);
100 element.write(p, depth); 94 element.write(p, depth);
@@ -283,11 +277,9 @@ JSON @@ -283,11 +277,9 @@ JSON
283 JSON::addDictionaryMember(std::string const& key, JSON const& val) 277 JSON::addDictionaryMember(std::string const& key, JSON const& val)
284 { 278 {
285 if (auto* obj = dynamic_cast<JSON_dictionary*>(m->value.get())) { 279 if (auto* obj = dynamic_cast<JSON_dictionary*>(m->value.get())) {
286 - return obj->members[encode_string(key)] =  
287 - val.m->value ? val : makeNull(); 280 + return obj->members[encode_string(key)] = val.m->value ? val : makeNull();
288 } else { 281 } else {
289 - throw std::runtime_error(  
290 - "JSON::addDictionaryMember called on non-dictionary"); 282 + throw std::runtime_error("JSON::addDictionaryMember called on non-dictionary");
291 } 283 }
292 } 284 }
293 285
@@ -296,8 +288,7 @@ JSON::checkDictionaryKeySeen(std::string const&amp; key) @@ -296,8 +288,7 @@ JSON::checkDictionaryKeySeen(std::string const&amp; key)
296 { 288 {
297 auto* obj = dynamic_cast<JSON_dictionary*>(m->value.get()); 289 auto* obj = dynamic_cast<JSON_dictionary*>(m->value.get());
298 if (nullptr == obj) { 290 if (nullptr == obj) {
299 - throw std::logic_error(  
300 - "JSON::checkDictionaryKey called on non-dictionary"); 291 + throw std::logic_error("JSON::checkDictionaryKey called on non-dictionary");
301 } 292 }
302 if (obj->parsed_keys.count(key)) { 293 if (obj->parsed_keys.count(key)) {
303 return true; 294 return true;
@@ -421,8 +412,7 @@ JSON::isNull() const @@ -421,8 +412,7 @@ JSON::isNull() const
421 } 412 }
422 413
423 bool 414 bool
424 -JSON::forEachDictItem(  
425 - std::function<void(std::string const& key, JSON value)> fn) const 415 +JSON::forEachDictItem(std::function<void(std::string const& key, JSON value)> fn) const
426 { 416 {
427 auto v = dynamic_cast<JSON_dictionary const*>(m->value.get()); 417 auto v = dynamic_cast<JSON_dictionary const*>(m->value.get());
428 if (v == nullptr) { 418 if (v == nullptr) {
@@ -450,16 +440,13 @@ JSON::forEachArrayItem(std::function&lt;void(JSON value)&gt; fn) const @@ -450,16 +440,13 @@ JSON::forEachArrayItem(std::function&lt;void(JSON value)&gt; fn) const
450 bool 440 bool
451 JSON::checkSchema(JSON schema, std::list<std::string>& errors) 441 JSON::checkSchema(JSON schema, std::list<std::string>& errors)
452 { 442 {
453 - return checkSchemaInternal(  
454 - m->value.get(), schema.m->value.get(), 0, errors, ""); 443 + return checkSchemaInternal(m->value.get(), schema.m->value.get(), 0, errors, "");
455 } 444 }
456 445
457 bool 446 bool
458 -JSON::checkSchema(  
459 - JSON schema, unsigned long flags, std::list<std::string>& errors) 447 +JSON::checkSchema(JSON schema, unsigned long flags, std::list<std::string>& errors)
460 { 448 {
461 - return checkSchemaInternal(  
462 - m->value.get(), schema.m->value.get(), flags, errors, ""); 449 + return checkSchemaInternal(m->value.get(), schema.m->value.get(), flags, errors, "");
463 } 450 }
464 451
465 bool 452 bool
@@ -495,8 +482,8 @@ JSON::checkSchemaInternal( @@ -495,8 +482,8 @@ JSON::checkSchemaInternal(
495 auto members = sch_dict->members; 482 auto members = sch_dict->members;
496 std::string key; 483 std::string key;
497 if ((members.size() == 1) && 484 if ((members.size() == 1) &&
498 - ((key = members.begin()->first, key.length() > 2) &&  
499 - (key.at(0) == '<') && (key.at(key.length() - 1) == '>'))) { 485 + ((key = members.begin()->first, key.length() > 2) && (key.at(0) == '<') &&
  486 + (key.at(key.length() - 1) == '>'))) {
500 pattern_key = key; 487 pattern_key = key;
501 } 488 }
502 } 489 }
@@ -565,17 +552,12 @@ JSON::checkSchemaInternal( @@ -565,17 +552,12 @@ JSON::checkSchemaInternal(
565 } else { 552 } else {
566 QTC::TC("libtests", "JSON schema array for single item"); 553 QTC::TC("libtests", "JSON schema array for single item");
567 checkSchemaInternal( 554 checkSchemaInternal(
568 - this_v,  
569 - sch_arr->elements.at(0).m->value.get(),  
570 - flags,  
571 - errors,  
572 - prefix); 555 + this_v, sch_arr->elements.at(0).m->value.get(), flags, errors, prefix);
573 } 556 }
574 } else if (!this_arr || (this_arr->elements.size() != n_elements)) { 557 } else if (!this_arr || (this_arr->elements.size() != n_elements)) {
575 QTC::TC("libtests", "JSON schema array length mismatch"); 558 QTC::TC("libtests", "JSON schema array length mismatch");
576 errors.push_back( 559 errors.push_back(
577 - err_prefix + " is supposed to be an array of length " +  
578 - std::to_string(n_elements)); 560 + err_prefix + " is supposed to be an array of length " + std::to_string(n_elements));
579 return false; 561 return false;
580 } else { 562 } else {
581 // A multi-element array in the schema must correspond to 563 // A multi-element array in the schema must correspond to
@@ -595,8 +577,7 @@ JSON::checkSchemaInternal( @@ -595,8 +577,7 @@ JSON::checkSchemaInternal(
595 } 577 }
596 } else if (!sch_str) { 578 } else if (!sch_str) {
597 QTC::TC("libtests", "JSON schema other type"); 579 QTC::TC("libtests", "JSON schema other type");
598 - errors.push_back(  
599 - err_prefix + " schema value is not dictionary, array, or string"); 580 + errors.push_back(err_prefix + " schema value is not dictionary, array, or string");
600 return false; 581 return false;
601 } 582 }
602 583
@@ -736,8 +717,7 @@ JSONParser::handle_u_code( @@ -736,8 +717,7 @@ JSONParser::handle_u_code(
736 " surrogate"); 717 " surrogate");
737 } 718 }
738 high_offset = 0; 719 high_offset = 0;
739 - codepoint =  
740 - 0x10000U + ((high_surrogate & 0x3FFU) << 10U) + (codepoint & 0x3FF); 720 + codepoint = 0x10000U + ((high_surrogate & 0x3FFU) << 10U) + (codepoint & 0x3FF);
741 result += QUtil::toUTF8(codepoint); 721 result += QUtil::toUTF8(codepoint);
742 } else { 722 } else {
743 result += QUtil::toUTF8(codepoint); 723 result += QUtil::toUTF8(codepoint);
@@ -760,8 +740,8 @@ JSONParser::tokenError() @@ -760,8 +740,8 @@ JSONParser::tokenError()
760 } else if (lex_state == ls_alpha) { 740 } else if (lex_state == ls_alpha) {
761 QTC::TC("libtests", "JSON parse keyword bad character"); 741 QTC::TC("libtests", "JSON parse keyword bad character");
762 throw std::runtime_error( 742 throw std::runtime_error(
763 - "JSON: offset " + std::to_string(offset) +  
764 - ": keyword: unexpected character " + std::string(p, 1)); 743 + "JSON: offset " + std::to_string(offset) + ": keyword: unexpected character " +
  744 + std::string(p, 1));
765 } else if (lex_state == ls_string) { 745 } else if (lex_state == ls_string) {
766 QTC::TC("libtests", "JSON parse control char in string"); 746 QTC::TC("libtests", "JSON parse control char in string");
767 throw std::runtime_error( 747 throw std::runtime_error(
@@ -775,8 +755,7 @@ JSONParser::tokenError() @@ -775,8 +755,7 @@ JSONParser::tokenError()
775 } 755 }
776 756
777 if (*p == '.') { 757 if (*p == '.') {
778 - if (lex_state == ls_number || lex_state == ls_number_e ||  
779 - lex_state == ls_number_e_sign) { 758 + if (lex_state == ls_number || lex_state == ls_number_e || lex_state == ls_number_e_sign) {
780 QTC::TC("libtests", "JSON parse point after e"); 759 QTC::TC("libtests", "JSON parse point after e");
781 throw std::runtime_error( 760 throw std::runtime_error(
782 "JSON: offset " + std::to_string(offset) + 761 "JSON: offset " + std::to_string(offset) +
@@ -790,24 +769,21 @@ JSONParser::tokenError() @@ -790,24 +769,21 @@ JSONParser::tokenError()
790 } else if (*p == 'e' || *p == 'E') { 769 } else if (*p == 'e' || *p == 'E') {
791 QTC::TC("libtests", "JSON parse duplicate e"); 770 QTC::TC("libtests", "JSON parse duplicate e");
792 throw std::runtime_error( 771 throw std::runtime_error(
793 - "JSON: offset " + std::to_string(offset) +  
794 - ": numeric literal: e already seen"); 772 + "JSON: offset " + std::to_string(offset) + ": numeric literal: e already seen");
795 } else if ((*p == '+') || (*p == '-')) { 773 } else if ((*p == '+') || (*p == '-')) {
796 QTC::TC("libtests", "JSON parse unexpected sign"); 774 QTC::TC("libtests", "JSON parse unexpected sign");
797 throw std::runtime_error( 775 throw std::runtime_error(
798 - "JSON: offset " + std::to_string(offset) +  
799 - ": numeric literal: unexpected sign"); 776 + "JSON: offset " + std::to_string(offset) + ": numeric literal: unexpected sign");
800 } else if (QUtil::is_space(*p) || strchr("{}[]:,", *p)) { 777 } else if (QUtil::is_space(*p) || strchr("{}[]:,", *p)) {
801 QTC::TC("libtests", "JSON parse incomplete number"); 778 QTC::TC("libtests", "JSON parse incomplete number");
802 throw std::runtime_error( 779 throw std::runtime_error(
803 - "JSON: offset " + std::to_string(offset) +  
804 - ": numeric literal: incomplete number"); 780 + "JSON: offset " + std::to_string(offset) + ": numeric literal: incomplete number");
805 781
806 } else { 782 } else {
807 QTC::TC("libtests", "JSON parse numeric bad character"); 783 QTC::TC("libtests", "JSON parse numeric bad character");
808 throw std::runtime_error( 784 throw std::runtime_error(
809 - "JSON: offset " + std::to_string(offset) +  
810 - ": numeric literal: unexpected character " + std::string(p, 1)); 785 + "JSON: offset " + std::to_string(offset) + ": numeric literal: unexpected character " +
  786 + std::string(p, 1));
811 } 787 }
812 throw std::logic_error("JSON::tokenError : unhandled error"); 788 throw std::logic_error("JSON::tokenError : unhandled error");
813 } 789 }
@@ -884,8 +860,7 @@ JSONParser::getToken() @@ -884,8 +860,7 @@ JSONParser::getToken()
884 } else { 860 } else {
885 QTC::TC("libtests", "JSON parse null character"); 861 QTC::TC("libtests", "JSON parse null character");
886 throw std::runtime_error( 862 throw std::runtime_error(
887 - "JSON: control or null character at offset " +  
888 - std::to_string(offset)); 863 + "JSON: control or null character at offset " + std::to_string(offset));
889 } 864 }
890 } else if (*p == ',') { 865 } else if (*p == ',') {
891 if (lex_state == ls_top) { 866 if (lex_state == ls_top) {
@@ -968,8 +943,8 @@ JSONParser::getToken() @@ -968,8 +943,8 @@ JSONParser::getToken()
968 } else { 943 } else {
969 QTC::TC("libtests", "JSON parse bad character"); 944 QTC::TC("libtests", "JSON parse bad character");
970 throw std::runtime_error( 945 throw std::runtime_error(
971 - "JSON: offset " + std::to_string(offset) +  
972 - ": unexpected character " + std::string(p, 1)); 946 + "JSON: offset " + std::to_string(offset) + ": unexpected character " +
  947 + std::string(p, 1));
973 } 948 }
974 break; 949 break;
975 950
@@ -994,8 +969,7 @@ JSONParser::getToken() @@ -994,8 +969,7 @@ JSONParser::getToken()
994 } else { 969 } else {
995 QTC::TC("libtests", "JSON parse leading zero"); 970 QTC::TC("libtests", "JSON parse leading zero");
996 throw std::runtime_error( 971 throw std::runtime_error(
997 - "JSON: offset " + std::to_string(offset) +  
998 - ": number with leading zero"); 972 + "JSON: offset " + std::to_string(offset) + ": number with leading zero");
999 } 973 }
1000 break; 974 break;
1001 975
@@ -1127,20 +1101,14 @@ JSONParser::getToken() @@ -1127,20 +1101,14 @@ JSONParser::getToken()
1127 tokenError(); 1101 tokenError();
1128 } 1102 }
1129 if (++u_count == 4) { 1103 if (++u_count == 4) {
1130 - handle_u_code(  
1131 - u_value,  
1132 - offset - 5,  
1133 - high_surrogate,  
1134 - high_offset,  
1135 - token); 1104 + handle_u_code(u_value, offset - 5, high_surrogate, high_offset, token);
1136 lex_state = ls_string; 1105 lex_state = ls_string;
1137 } 1106 }
1138 ignore(); 1107 ignore();
1139 break; 1108 break;
1140 1109
1141 default: 1110 default:
1142 - throw std::logic_error(  
1143 - "JSONParser::getToken : trying to handle delimiter state"); 1111 + throw std::logic_error("JSONParser::getToken : trying to handle delimiter state");
1144 } 1112 }
1145 } 1113 }
1146 } 1114 }
@@ -1205,19 +1173,16 @@ JSONParser::handleToken() @@ -1205,19 +1173,16 @@ JSONParser::handleToken()
1205 if (parser_state != ps_dict_after_key) { 1173 if (parser_state != ps_dict_after_key) {
1206 QTC::TC("libtests", "JSON parse unexpected :"); 1174 QTC::TC("libtests", "JSON parse unexpected :");
1207 throw std::runtime_error( 1175 throw std::runtime_error(
1208 - "JSON: offset " + std::to_string(offset) +  
1209 - ": unexpected colon"); 1176 + "JSON: offset " + std::to_string(offset) + ": unexpected colon");
1210 } 1177 }
1211 parser_state = ps_dict_after_colon; 1178 parser_state = ps_dict_after_colon;
1212 return; 1179 return;
1213 1180
1214 case ls_comma: 1181 case ls_comma:
1215 - if (!((parser_state == ps_dict_after_item) ||  
1216 - (parser_state == ps_array_after_item))) { 1182 + if (!((parser_state == ps_dict_after_item) || (parser_state == ps_array_after_item))) {
1217 QTC::TC("libtests", "JSON parse unexpected ,"); 1183 QTC::TC("libtests", "JSON parse unexpected ,");
1218 throw std::runtime_error( 1184 throw std::runtime_error(
1219 - "JSON: offset " + std::to_string(offset) +  
1220 - ": unexpected comma"); 1185 + "JSON: offset " + std::to_string(offset) + ": unexpected comma");
1221 } 1186 }
1222 if (parser_state == ps_dict_after_item) { 1187 if (parser_state == ps_dict_after_item) {
1223 parser_state = ps_dict_after_comma; 1188 parser_state = ps_dict_after_comma;
@@ -1230,12 +1195,10 @@ JSONParser::handleToken() @@ -1230,12 +1195,10 @@ JSONParser::handleToken()
1230 return; 1195 return;
1231 1196
1232 case ls_end_array: 1197 case ls_end_array:
1233 - if (!(parser_state == ps_array_begin ||  
1234 - parser_state == ps_array_after_item)) { 1198 + if (!(parser_state == ps_array_begin || parser_state == ps_array_after_item)) {
1235 QTC::TC("libtests", "JSON parse unexpected ]"); 1199 QTC::TC("libtests", "JSON parse unexpected ]");
1236 throw std::runtime_error( 1200 throw std::runtime_error(
1237 - "JSON: offset " + std::to_string(offset) +  
1238 - ": unexpected array end delimiter"); 1201 + "JSON: offset " + std::to_string(offset) + ": unexpected array end delimiter");
1239 } 1202 }
1240 parser_state = stack.back().state; 1203 parser_state = stack.back().state;
1241 tos.setEnd(offset); 1204 tos.setEnd(offset);
@@ -1248,12 +1211,10 @@ JSONParser::handleToken() @@ -1248,12 +1211,10 @@ JSONParser::handleToken()
1248 return; 1211 return;
1249 1212
1250 case ls_end_dict: 1213 case ls_end_dict:
1251 - if (!((parser_state == ps_dict_begin) ||  
1252 - (parser_state == ps_dict_after_item))) { 1214 + if (!((parser_state == ps_dict_begin) || (parser_state == ps_dict_after_item))) {
1253 QTC::TC("libtests", "JSON parse unexpected }"); 1215 QTC::TC("libtests", "JSON parse unexpected }");
1254 throw std::runtime_error( 1216 throw std::runtime_error(
1255 - "JSON: offset " + std::to_string(offset) +  
1256 - ": unexpected dictionary end delimiter"); 1217 + "JSON: offset " + std::to_string(offset) + ": unexpected dictionary end delimiter");
1257 } 1218 }
1258 parser_state = stack.back().state; 1219 parser_state = stack.back().state;
1259 tos.setEnd(offset); 1220 tos.setEnd(offset);
@@ -1279,14 +1240,12 @@ JSONParser::handleToken() @@ -1279,14 +1240,12 @@ JSONParser::handleToken()
1279 } else { 1240 } else {
1280 QTC::TC("libtests", "JSON parse invalid keyword"); 1241 QTC::TC("libtests", "JSON parse invalid keyword");
1281 throw std::runtime_error( 1242 throw std::runtime_error(
1282 - "JSON: offset " + std::to_string(offset) +  
1283 - ": invalid keyword " + token); 1243 + "JSON: offset " + std::to_string(offset) + ": invalid keyword " + token);
1284 } 1244 }
1285 break; 1245 break;
1286 1246
1287 case ls_string: 1247 case ls_string:
1288 - if (parser_state == ps_dict_begin ||  
1289 - parser_state == ps_dict_after_comma) { 1248 + if (parser_state == ps_dict_begin || parser_state == ps_dict_after_comma) {
1290 dict_key = token; 1249 dict_key = token;
1291 dict_key_offset = token_start; 1250 dict_key_offset = token_start;
1292 parser_state = ps_dict_after_key; 1251 parser_state = ps_dict_after_key;
@@ -1297,8 +1256,7 @@ JSONParser::handleToken() @@ -1297,8 +1256,7 @@ JSONParser::handleToken()
1297 break; 1256 break;
1298 1257
1299 default: 1258 default:
1300 - throw std::logic_error(  
1301 - "JSONParser::handleToken : non-terminal lexer state encountered"); 1259 + throw std::logic_error("JSONParser::handleToken : non-terminal lexer state encountered");
1302 break; 1260 break;
1303 } 1261 }
1304 1262
@@ -1310,16 +1268,14 @@ JSONParser::handleToken() @@ -1310,16 +1268,14 @@ JSONParser::handleToken()
1310 case ps_dict_after_comma: 1268 case ps_dict_after_comma:
1311 QTC::TC("libtests", "JSON parse string as dict key"); 1269 QTC::TC("libtests", "JSON parse string as dict key");
1312 throw std::runtime_error( 1270 throw std::runtime_error(
1313 - "JSON: offset " + std::to_string(offset) +  
1314 - ": expect string as dictionary key"); 1271 + "JSON: offset " + std::to_string(offset) + ": expect string as dictionary key");
1315 break; 1272 break;
1316 1273
1317 case ps_dict_after_colon: 1274 case ps_dict_after_colon:
1318 if (tos.checkDictionaryKeySeen(dict_key)) { 1275 if (tos.checkDictionaryKeySeen(dict_key)) {
1319 QTC::TC("libtests", "JSON parse duplicate key"); 1276 QTC::TC("libtests", "JSON parse duplicate key");
1320 throw std::runtime_error( 1277 throw std::runtime_error(
1321 - "JSON: offset " + std::to_string(dict_key_offset) +  
1322 - ": duplicated dictionary key"); 1278 + "JSON: offset " + std::to_string(dict_key_offset) + ": duplicated dictionary key");
1323 } 1279 }
1324 if (!reactor || !reactor->dictionaryItem(dict_key, item)) { 1280 if (!reactor || !reactor->dictionaryItem(dict_key, item)) {
1325 tos.addDictionaryMember(dict_key, item); 1281 tos.addDictionaryMember(dict_key, item);
@@ -1346,8 +1302,7 @@ JSONParser::handleToken() @@ -1346,8 +1302,7 @@ JSONParser::handleToken()
1346 1302
1347 case ps_dict_after_key: 1303 case ps_dict_after_key:
1348 QTC::TC("libtests", "JSON parse expected colon"); 1304 QTC::TC("libtests", "JSON parse expected colon");
1349 - throw std::runtime_error(  
1350 - "JSON: offset " + std::to_string(offset) + ": expected ':'"); 1305 + throw std::runtime_error("JSON: offset " + std::to_string(offset) + ": expected ':'");
1351 break; 1306 break;
1352 1307
1353 case ps_dict_after_item: 1308 case ps_dict_after_item:
@@ -1363,8 +1318,7 @@ JSONParser::handleToken() @@ -1363,8 +1318,7 @@ JSONParser::handleToken()
1363 break; 1318 break;
1364 1319
1365 case ps_done: 1320 case ps_done:
1366 - throw std::logic_error(  
1367 - "JSONParser::handleToken: unexpected parser state"); 1321 + throw std::logic_error("JSONParser::handleToken: unexpected parser state");
1368 } 1322 }
1369 1323
1370 if (item.isDictionary() || item.isArray()) { 1324 if (item.isDictionary() || item.isArray()) {
@@ -1387,8 +1341,7 @@ JSONParser::handleToken() @@ -1387,8 +1341,7 @@ JSONParser::handleToken()
1387 1341
1388 if (stack.size() > 500) { 1342 if (stack.size() > 500) {
1389 throw std::runtime_error( 1343 throw std::runtime_error(
1390 - "JSON: offset " + std::to_string(offset) +  
1391 - ": maximum object depth exceeded"); 1344 + "JSON: offset " + std::to_string(offset) + ": maximum object depth exceeded");
1392 } 1345 }
1393 } 1346 }
1394 } 1347 }
libqpdf/JSONHandler.cc
@@ -53,8 +53,7 @@ JSONHandler::addDictHandlers(json_handler_t start_fn, void_handler_t end_fn) @@ -53,8 +53,7 @@ JSONHandler::addDictHandlers(json_handler_t start_fn, void_handler_t end_fn)
53 } 53 }
54 54
55 void 55 void
56 -JSONHandler::addDictKeyHandler(  
57 - std::string const& key, std::shared_ptr<JSONHandler> dkh) 56 +JSONHandler::addDictKeyHandler(std::string const& key, std::shared_ptr<JSONHandler> dkh)
58 { 57 {
59 m->h.dict_handlers[key] = dkh; 58 m->h.dict_handlers[key] = dkh;
60 } 59 }
@@ -67,9 +66,7 @@ JSONHandler::addFallbackDictHandler(std::shared_ptr&lt;JSONHandler&gt; fdh) @@ -67,9 +66,7 @@ JSONHandler::addFallbackDictHandler(std::shared_ptr&lt;JSONHandler&gt; fdh)
67 66
68 void 67 void
69 JSONHandler::addArrayHandlers( 68 JSONHandler::addArrayHandlers(
70 - json_handler_t start_fn,  
71 - void_handler_t end_fn,  
72 - std::shared_ptr<JSONHandler> ah) 69 + json_handler_t start_fn, void_handler_t end_fn, std::shared_ptr<JSONHandler> ah)
73 { 70 {
74 m->h.array_start_handler = start_fn; 71 m->h.array_start_handler = start_fn;
75 m->h.array_end_handler = end_fn; 72 m->h.array_end_handler = end_fn;
@@ -108,22 +105,19 @@ JSONHandler::handle(std::string const&amp; path, JSON j) @@ -108,22 +105,19 @@ JSONHandler::handle(std::string const&amp; path, JSON j)
108 if (path_base != ".") { 105 if (path_base != ".") {
109 path_base += "."; 106 path_base += ".";
110 } 107 }
111 - j.forEachDictItem(  
112 - [&path, &path_base, this](std::string const& k, JSON v) {  
113 - auto i = m->h.dict_handlers.find(k);  
114 - if (i == m->h.dict_handlers.end()) {  
115 - if (m->h.fallback_dict_handler.get()) {  
116 - m->h.fallback_dict_handler->handle(path_base + k, v);  
117 - } else {  
118 - QTC::TC("libtests", "JSONHandler unexpected key");  
119 - usage(  
120 - "JSON handler found unexpected key " + k +  
121 - " in object at " + path);  
122 - } 108 + j.forEachDictItem([&path, &path_base, this](std::string const& k, JSON v) {
  109 + auto i = m->h.dict_handlers.find(k);
  110 + if (i == m->h.dict_handlers.end()) {
  111 + if (m->h.fallback_dict_handler.get()) {
  112 + m->h.fallback_dict_handler->handle(path_base + k, v);
123 } else { 113 } else {
124 - i->second->handle(path_base + k, v); 114 + QTC::TC("libtests", "JSONHandler unexpected key");
  115 + usage("JSON handler found unexpected key " + k + " in object at " + path);
125 } 116 }
126 - }); 117 + } else {
  118 + i->second->handle(path_base + k, v);
  119 + }
  120 + });
127 m->h.dict_end_handler(path); 121 m->h.dict_end_handler(path);
128 handled = true; 122 handled = true;
129 } 123 }
@@ -131,8 +125,7 @@ JSONHandler::handle(std::string const&amp; path, JSON j) @@ -131,8 +125,7 @@ JSONHandler::handle(std::string const&amp; path, JSON j)
131 m->h.array_start_handler(path, j); 125 m->h.array_start_handler(path, j);
132 size_t i = 0; 126 size_t i = 0;
133 j.forEachArrayItem([&i, &path, this](JSON v) { 127 j.forEachArrayItem([&i, &path, this](JSON v) {
134 - m->h.array_item_handler->handle(  
135 - path + "[" + std::to_string(i) + "]", v); 128 + m->h.array_item_handler->handle(path + "[" + std::to_string(i) + "]", v);
136 ++i; 129 ++i;
137 }); 130 });
138 m->h.array_end_handler(path); 131 m->h.array_end_handler(path);
libqpdf/MD5.cc
@@ -81,8 +81,7 @@ MD5::encodeFile(char const* filename, qpdf_offset_t up_to_offset) @@ -81,8 +81,7 @@ MD5::encodeFile(char const* filename, qpdf_offset_t up_to_offset)
81 // Assume, perhaps incorrectly, that errno was set by the 81 // Assume, perhaps incorrectly, that errno was set by the
82 // underlying call to read.... 82 // underlying call to read....
83 (void)fclose(file); 83 (void)fclose(file);
84 - QUtil::throw_system_error(  
85 - std::string("MD5: read error on ") + filename); 84 + QUtil::throw_system_error(std::string("MD5: read error on ") + filename);
86 } 85 }
87 (void)fclose(file); 86 (void)fclose(file);
88 87
@@ -115,8 +114,7 @@ MD5::unparse() @@ -115,8 +114,7 @@ MD5::unparse()
115 this->crypto->MD5_finalize(); 114 this->crypto->MD5_finalize();
116 Digest digest_val; 115 Digest digest_val;
117 digest(digest_val); 116 digest(digest_val);
118 - return QUtil::hex_encode(  
119 - std::string(reinterpret_cast<char*>(digest_val), 16)); 117 + return QUtil::hex_encode(std::string(reinterpret_cast<char*>(digest_val), 16));
120 } 118 }
121 119
122 std::string 120 std::string
@@ -143,10 +141,7 @@ MD5::checkDataChecksum(char const* const checksum, char const* buf, size_t len) @@ -143,10 +141,7 @@ MD5::checkDataChecksum(char const* const checksum, char const* buf, size_t len)
143 } 141 }
144 142
145 bool 143 bool
146 -MD5::checkFileChecksum(  
147 - char const* const checksum,  
148 - char const* filename,  
149 - qpdf_offset_t up_to_offset) 144 +MD5::checkFileChecksum(char const* const checksum, char const* filename, qpdf_offset_t up_to_offset)
150 { 145 {
151 bool result = false; 146 bool result = false;
152 try { 147 try {
libqpdf/NNTree.cc
@@ -24,8 +24,7 @@ warn(QPDF&amp; qpdf, QPDFObjectHandle&amp; node, std::string const&amp; msg) @@ -24,8 +24,7 @@ warn(QPDF&amp; qpdf, QPDFObjectHandle&amp; node, std::string const&amp; msg)
24 static void 24 static void
25 error(QPDF& qpdf, QPDFObjectHandle& node, std::string const& msg) 25 error(QPDF& qpdf, QPDFObjectHandle& node, std::string const& msg)
26 { 26 {
27 - throw QPDFExc(  
28 - qpdf_e_damaged_pdf, qpdf.getFilename(), get_description(node), 0, msg); 27 + throw QPDFExc(qpdf_e_damaged_pdf, qpdf.getFilename(), get_description(node), 0, msg);
29 } 28 }
30 29
31 NNTreeIterator::NNTreeIterator(NNTreeImpl& impl) : 30 NNTreeIterator::NNTreeIterator(NNTreeImpl& impl) :
@@ -76,8 +75,7 @@ NNTreeIterator::updateIValue(bool allow_invalid) @@ -76,8 +75,7 @@ NNTreeIterator::updateIValue(bool allow_invalid)
76 } 75 }
77 } 76 }
78 77
79 -NNTreeIterator::PathElement::PathElement(  
80 - QPDFObjectHandle const& node, int kid_number) : 78 +NNTreeIterator::PathElement::PathElement(QPDFObjectHandle const& node, int kid_number) :
81 node(node), 79 node(node),
82 kid_number(kid_number) 80 kid_number(kid_number)
83 { 81 {
@@ -94,16 +92,14 @@ NNTreeIterator::getNextKid(PathElement&amp; pe, bool backward) @@ -94,16 +92,14 @@ NNTreeIterator::getNextKid(PathElement&amp; pe, bool backward)
94 if ((pe.kid_number >= 0) && (pe.kid_number < kids.getArrayNItems())) { 92 if ((pe.kid_number >= 0) && (pe.kid_number < kids.getArrayNItems())) {
95 result = kids.getArrayItem(pe.kid_number); 93 result = kids.getArrayItem(pe.kid_number);
96 if (result.isDictionary() && 94 if (result.isDictionary() &&
97 - (result.hasKey("/Kids") ||  
98 - result.hasKey(impl.details.itemsKey()))) { 95 + (result.hasKey("/Kids") || result.hasKey(impl.details.itemsKey()))) {
99 found = true; 96 found = true;
100 } else { 97 } else {
101 QTC::TC("qpdf", "NNTree skip invalid kid"); 98 QTC::TC("qpdf", "NNTree skip invalid kid");
102 warn( 99 warn(
103 impl.qpdf, 100 impl.qpdf,
104 pe.node, 101 pe.node,
105 - ("skipping over invalid kid at index " +  
106 - std::to_string(pe.kid_number))); 102 + ("skipping over invalid kid at index " + std::to_string(pe.kid_number)));
107 } 103 }
108 } else { 104 } else {
109 result = QPDFObjectHandle::newNull(); 105 result = QPDFObjectHandle::newNull();
@@ -131,8 +127,7 @@ NNTreeIterator::increment(bool backward) @@ -131,8 +127,7 @@ NNTreeIterator::increment(bool backward)
131 while (valid() && (!found_valid_key)) { 127 while (valid() && (!found_valid_key)) {
132 this->item_number += backward ? -2 : 2; 128 this->item_number += backward ? -2 : 2;
133 auto items = this->node.getKey(impl.details.itemsKey()); 129 auto items = this->node.getKey(impl.details.itemsKey());
134 - if ((this->item_number < 0) ||  
135 - (this->item_number >= items.getArrayNItems())) { 130 + if ((this->item_number < 0) || (this->item_number >= items.getArrayNItems())) {
136 bool found = false; 131 bool found = false;
137 setItemNumber(QPDFObjectHandle(), -1); 132 setItemNumber(QPDFObjectHandle(), -1);
138 while (!(found || this->path.empty())) { 133 while (!(found || this->path.empty())) {
@@ -149,18 +144,13 @@ NNTreeIterator::increment(bool backward) @@ -149,18 +144,13 @@ NNTreeIterator::increment(bool backward)
149 items = this->node.getKey(impl.details.itemsKey()); 144 items = this->node.getKey(impl.details.itemsKey());
150 if (this->item_number + 1 >= items.getArrayNItems()) { 145 if (this->item_number + 1 >= items.getArrayNItems()) {
151 QTC::TC("qpdf", "NNTree skip item at end of short items"); 146 QTC::TC("qpdf", "NNTree skip item at end of short items");
152 - warn(  
153 - impl.qpdf,  
154 - this->node,  
155 - "items array doesn't have enough elements");  
156 - } else if (!impl.details.keyValid(  
157 - items.getArrayItem(this->item_number))) { 147 + warn(impl.qpdf, this->node, "items array doesn't have enough elements");
  148 + } else if (!impl.details.keyValid(items.getArrayItem(this->item_number))) {
158 QTC::TC("qpdf", "NNTree skip invalid key"); 149 QTC::TC("qpdf", "NNTree skip invalid key");
159 warn( 150 warn(
160 impl.qpdf, 151 impl.qpdf,
161 this->node, 152 this->node,
162 - ("item " + std::to_string(this->item_number) +  
163 - " has the wrong type")); 153 + ("item " + std::to_string(this->item_number) + " has the wrong type"));
164 } else { 154 } else {
165 found_valid_key = true; 155 found_valid_key = true;
166 } 156 }
@@ -169,8 +159,7 @@ NNTreeIterator::increment(bool backward) @@ -169,8 +159,7 @@ NNTreeIterator::increment(bool backward)
169 } 159 }
170 160
171 void 161 void
172 -NNTreeIterator::resetLimits(  
173 - QPDFObjectHandle node, std::list<PathElement>::iterator parent) 162 +NNTreeIterator::resetLimits(QPDFObjectHandle node, std::list<PathElement>::iterator parent)
174 { 163 {
175 bool done = false; 164 bool done = false;
176 while (!done) { 165 while (!done) {
@@ -197,10 +186,8 @@ NNTreeIterator::resetLimits( @@ -197,10 +186,8 @@ NNTreeIterator::resetLimits(
197 if (first_kid.isDictionary() && last_kid.isDictionary()) { 186 if (first_kid.isDictionary() && last_kid.isDictionary()) {
198 auto first_limits = first_kid.getKey("/Limits"); 187 auto first_limits = first_kid.getKey("/Limits");
199 auto last_limits = last_kid.getKey("/Limits"); 188 auto last_limits = last_kid.getKey("/Limits");
200 - if (first_limits.isArray() &&  
201 - (first_limits.getArrayNItems() >= 2) &&  
202 - last_limits.isArray() &&  
203 - (last_limits.getArrayNItems() >= 2)) { 189 + if (first_limits.isArray() && (first_limits.getArrayNItems() >= 2) &&
  190 + last_limits.isArray() && (last_limits.getArrayNItems() >= 2)) {
204 first = first_limits.getArrayItem(0); 191 first = first_limits.getArrayItem(0);
205 last = last_limits.getArrayItem(1); 192 last = last_limits.getArrayItem(1);
206 } 193 }
@@ -214,8 +201,7 @@ NNTreeIterator::resetLimits( @@ -214,8 +201,7 @@ NNTreeIterator::resetLimits(
214 if (olimits.isArray() && (olimits.getArrayNItems() == 2)) { 201 if (olimits.isArray() && (olimits.getArrayNItems() == 2)) {
215 auto ofirst = olimits.getArrayItem(0); 202 auto ofirst = olimits.getArrayItem(0);
216 auto olast = olimits.getArrayItem(1); 203 auto olast = olimits.getArrayItem(1);
217 - if (impl.details.keyValid(ofirst) &&  
218 - impl.details.keyValid(olast) && 204 + if (impl.details.keyValid(ofirst) && impl.details.keyValid(olast) &&
219 (impl.details.compareKeys(first, ofirst) == 0) && 205 (impl.details.compareKeys(first, ofirst) == 0) &&
220 (impl.details.compareKeys(last, olast) == 0)) { 206 (impl.details.compareKeys(last, olast) == 0)) {
221 QTC::TC("qpdf", "NNTree limits didn't change"); 207 QTC::TC("qpdf", "NNTree limits didn't change");
@@ -240,8 +226,7 @@ NNTreeIterator::resetLimits( @@ -240,8 +226,7 @@ NNTreeIterator::resetLimits(
240 } 226 }
241 227
242 void 228 void
243 -NNTreeIterator::split(  
244 - QPDFObjectHandle to_split, std::list<PathElement>::iterator parent) 229 +NNTreeIterator::split(QPDFObjectHandle to_split, std::list<PathElement>::iterator parent)
245 { 230 {
246 // Split some node along the path to the item pointed to by this 231 // Split some node along the path to the item pointed to by this
247 // iterator, and adjust the iterator so it points to the same 232 // iterator, and adjust the iterator so it points to the same
@@ -272,8 +257,7 @@ NNTreeIterator::split( @@ -272,8 +257,7 @@ NNTreeIterator::split(
272 // item_number: 0 257 // item_number: 0
273 258
274 if (!valid()) { 259 if (!valid()) {
275 - throw std::logic_error(  
276 - "NNTreeIterator::split called an invalid iterator"); 260 + throw std::logic_error("NNTreeIterator::split called an invalid iterator");
277 } 261 }
278 262
279 // Find the array we actually need to split, which is either this 263 // Find the array we actually need to split, which is either this
@@ -335,8 +319,7 @@ NNTreeIterator::split( @@ -335,8 +319,7 @@ NNTreeIterator::split(
335 // non-root case so remaining logic can handle them in the 319 // non-root case so remaining logic can handle them in the
336 // same way. 320 // same way.
337 321
338 - auto first_node =  
339 - impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary()); 322 + auto first_node = impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
340 first_node.replaceKey(key, first_half); 323 first_node.replaceKey(key, first_half);
341 QPDFObjectHandle new_kids = QPDFObjectHandle::newArray(); 324 QPDFObjectHandle new_kids = QPDFObjectHandle::newArray();
342 new_kids.appendItem(first_node); 325 new_kids.appendItem(first_node);
@@ -371,8 +354,7 @@ NNTreeIterator::split( @@ -371,8 +354,7 @@ NNTreeIterator::split(
371 resetLimits(to_split, parent); 354 resetLimits(to_split, parent);
372 355
373 // Create a new node to contain the second half 356 // Create a new node to contain the second half
374 - QPDFObjectHandle second_node =  
375 - impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary()); 357 + QPDFObjectHandle second_node = impl.qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary());
376 second_node.replaceKey(key, second_half); 358 second_node.replaceKey(key, second_half);
377 resetLimits(second_node, parent); 359 resetLimits(second_node, parent);
378 360
@@ -457,10 +439,7 @@ NNTreeIterator::remove() @@ -457,10 +439,7 @@ NNTreeIterator::remove()
457 auto items = this->node.getKey(impl.details.itemsKey()); 439 auto items = this->node.getKey(impl.details.itemsKey());
458 int nitems = items.getArrayNItems(); 440 int nitems = items.getArrayNItems();
459 if (this->item_number + 2 > nitems) { 441 if (this->item_number + 2 > nitems) {
460 - error(  
461 - impl.qpdf,  
462 - this->node,  
463 - "found short items array while removing an item"); 442 + error(impl.qpdf, this->node, "found short items array while removing an item");
464 } 443 }
465 444
466 items.eraseItem(this->item_number); 445 items.eraseItem(this->item_number);
@@ -491,8 +470,7 @@ NNTreeIterator::remove() @@ -491,8 +470,7 @@ NNTreeIterator::remove()
491 } else { 470 } else {
492 // We already checked to ensure this condition would not 471 // We already checked to ensure this condition would not
493 // happen. 472 // happen.
494 - throw std::logic_error(  
495 - "NNTreeIterator::remove: item_number > nitems after erase"); 473 + throw std::logic_error("NNTreeIterator::remove: item_number > nitems after erase");
496 } 474 }
497 return; 475 return;
498 } 476 }
@@ -549,8 +527,7 @@ NNTreeIterator::remove() @@ -549,8 +527,7 @@ NNTreeIterator::remove()
549 // empty items array. 527 // empty items array.
550 QTC::TC("qpdf", "NNTree non-flat tree is empty after remove"); 528 QTC::TC("qpdf", "NNTree non-flat tree is empty after remove");
551 element->node.removeKey("/Kids"); 529 element->node.removeKey("/Kids");
552 - element->node.replaceKey(  
553 - impl.details.itemsKey(), QPDFObjectHandle::newArray()); 530 + element->node.replaceKey(impl.details.itemsKey(), QPDFObjectHandle::newArray());
554 this->path.clear(); 531 this->path.clear();
555 setItemNumber(impl.oh, -1); 532 setItemNumber(impl.oh, -1);
556 done = true; 533 done = true;
@@ -645,20 +622,14 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty) @@ -645,20 +622,14 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
645 while (!failed) { 622 while (!failed) {
646 if (!seen.add(node)) { 623 if (!seen.add(node)) {
647 QTC::TC("qpdf", "NNTree deepen: loop"); 624 QTC::TC("qpdf", "NNTree deepen: loop");
648 - warn(  
649 - impl.qpdf,  
650 - node,  
651 - "loop detected while traversing name/number tree"); 625 + warn(impl.qpdf, node, "loop detected while traversing name/number tree");
652 failed = true; 626 failed = true;
653 break; 627 break;
654 } 628 }
655 629
656 if (!node.isDictionary()) { 630 if (!node.isDictionary()) {
657 QTC::TC("qpdf", "NNTree node is not a dictionary"); 631 QTC::TC("qpdf", "NNTree node is not a dictionary");
658 - warn(  
659 - impl.qpdf,  
660 - node,  
661 - "non-dictionary node while traversing name/number tree"); 632 + warn(impl.qpdf, node, "non-dictionary node while traversing name/number tree");
662 failed = true; 633 failed = true;
663 break; 634 break;
664 } 635 }
@@ -703,8 +674,8 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty) @@ -703,8 +674,8 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
703 warn( 674 warn(
704 impl.qpdf, 675 impl.qpdf,
705 node, 676 node,
706 - ("name/number tree node has neither non-empty " +  
707 - impl.details.itemsKey() + " nor /Kids")); 677 + ("name/number tree node has neither non-empty " + impl.details.itemsKey() +
  678 + " nor /Kids"));
708 failed = true; 679 failed = true;
709 break; 680 break;
710 } 681 }
@@ -717,10 +688,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty) @@ -717,10 +688,7 @@ NNTreeIterator::deepen(QPDFObjectHandle node, bool first, bool allow_empty)
717 } 688 }
718 689
719 NNTreeImpl::NNTreeImpl( 690 NNTreeImpl::NNTreeImpl(
720 - NNTreeDetails const& details,  
721 - QPDF& qpdf,  
722 - QPDFObjectHandle& oh,  
723 - bool auto_repair) : 691 + NNTreeDetails const& details, QPDF& qpdf, QPDFObjectHandle& oh, bool auto_repair) :
724 details(details), 692 details(details),
725 qpdf(qpdf), 693 qpdf(qpdf),
726 split_threshold(32), 694 split_threshold(32),
@@ -763,8 +731,7 @@ NNTreeImpl::withinLimits(QPDFObjectHandle key, QPDFObjectHandle node) @@ -763,8 +731,7 @@ NNTreeImpl::withinLimits(QPDFObjectHandle key, QPDFObjectHandle node)
763 int result = 0; 731 int result = 0;
764 auto limits = node.getKey("/Limits"); 732 auto limits = node.getKey("/Limits");
765 if (limits.isArray() && (limits.getArrayNItems() >= 2) && 733 if (limits.isArray() && (limits.getArrayNItems() >= 2) &&
766 - details.keyValid(limits.getArrayItem(0)) &&  
767 - details.keyValid(limits.getArrayItem(1))) { 734 + details.keyValid(limits.getArrayItem(0)) && details.keyValid(limits.getArrayItem(1))) {
768 if (details.compareKeys(key, limits.getArrayItem(0)) < 0) { 735 if (details.compareKeys(key, limits.getArrayItem(0)) < 0) {
769 result = -1; 736 result = -1;
770 } else if (details.compareKeys(key, limits.getArrayItem(1)) > 0) { 737 } else if (details.compareKeys(key, limits.getArrayItem(1)) > 0) {
@@ -783,8 +750,7 @@ NNTreeImpl::binarySearch( @@ -783,8 +750,7 @@ NNTreeImpl::binarySearch(
783 QPDFObjectHandle items, 750 QPDFObjectHandle items,
784 int num_items, 751 int num_items,
785 bool return_prev_if_not_found, 752 bool return_prev_if_not_found,
786 - int (NNTreeImpl::*compare)(  
787 - QPDFObjectHandle& key, QPDFObjectHandle& arr, int item)) 753 + int (NNTreeImpl::*compare)(QPDFObjectHandle& key, QPDFObjectHandle& arr, int item))
788 { 754 {
789 int max_idx = 1; 755 int max_idx = 1;
790 while (max_idx < num_items) { 756 while (max_idx < num_items) {
@@ -838,8 +804,7 @@ NNTreeImpl::binarySearch( @@ -838,8 +804,7 @@ NNTreeImpl::binarySearch(
838 } 804 }
839 805
840 int 806 int
841 -NNTreeImpl::compareKeyItem(  
842 - QPDFObjectHandle& key, QPDFObjectHandle& items, int idx) 807 +NNTreeImpl::compareKeyItem(QPDFObjectHandle& key, QPDFObjectHandle& items, int idx)
843 { 808 {
844 if (!((items.isArray() && (items.getArrayNItems() > (2 * idx)) && 809 if (!((items.isArray() && (items.getArrayNItems() > (2 * idx)) &&
845 details.keyValid(items.getArrayItem(2 * idx))))) { 810 details.keyValid(items.getArrayItem(2 * idx))))) {
@@ -847,15 +812,13 @@ NNTreeImpl::compareKeyItem( @@ -847,15 +812,13 @@ NNTreeImpl::compareKeyItem(
847 error( 812 error(
848 qpdf, 813 qpdf,
849 this->oh, 814 this->oh,
850 - ("item at index " + std::to_string(2 * idx) +  
851 - " is not the right type")); 815 + ("item at index " + std::to_string(2 * idx) + " is not the right type"));
852 } 816 }
853 return details.compareKeys(key, items.getArrayItem(2 * idx)); 817 return details.compareKeys(key, items.getArrayItem(2 * idx));
854 } 818 }
855 819
856 int 820 int
857 -NNTreeImpl::compareKeyKid(  
858 - QPDFObjectHandle& key, QPDFObjectHandle& kids, int idx) 821 +NNTreeImpl::compareKeyKid(QPDFObjectHandle& key, QPDFObjectHandle& kids, int idx)
859 { 822 {
860 if (!(kids.isArray() && (idx < kids.getArrayNItems()) && 823 if (!(kids.isArray() && (idx < kids.getArrayNItems()) &&
861 kids.getArrayItem(idx).isDictionary())) { 824 kids.getArrayItem(idx).isDictionary())) {
@@ -875,8 +838,7 @@ NNTreeImpl::repair() @@ -875,8 +838,7 @@ NNTreeImpl::repair()
875 repl.insert(i.first, i.second); 838 repl.insert(i.first, i.second);
876 } 839 }
877 this->oh.replaceKey("/Kids", new_node.getKey("/Kids")); 840 this->oh.replaceKey("/Kids", new_node.getKey("/Kids"));
878 - this->oh.replaceKey(  
879 - details.itemsKey(), new_node.getKey(details.itemsKey())); 841 + this->oh.replaceKey(details.itemsKey(), new_node.getKey(details.itemsKey()));
880 } 842 }
881 843
882 NNTreeImpl::iterator 844 NNTreeImpl::iterator
@@ -887,10 +849,7 @@ NNTreeImpl::find(QPDFObjectHandle key, bool return_prev_if_not_found) @@ -887,10 +849,7 @@ NNTreeImpl::find(QPDFObjectHandle key, bool return_prev_if_not_found)
887 } catch (QPDFExc& e) { 849 } catch (QPDFExc& e) {
888 if (this->auto_repair) { 850 if (this->auto_repair) {
889 QTC::TC("qpdf", "NNTree repair"); 851 QTC::TC("qpdf", "NNTree repair");
890 - warn(  
891 - qpdf,  
892 - this->oh,  
893 - std::string("attempting to repair after error: ") + e.what()); 852 + warn(qpdf, this->oh, std::string("attempting to repair after error: ") + e.what());
894 repair(); 853 repair();
895 return findInternal(key, return_prev_if_not_found); 854 return findInternal(key, return_prev_if_not_found);
896 } else { 855 } else {
@@ -939,18 +898,13 @@ NNTreeImpl::findInternal(QPDFObjectHandle key, bool return_prev_if_not_found) @@ -939,18 +898,13 @@ NNTreeImpl::findInternal(QPDFObjectHandle key, bool return_prev_if_not_found)
939 int nitems = items.isArray() ? items.getArrayNItems() : 0; 898 int nitems = items.isArray() ? items.getArrayNItems() : 0;
940 if (nitems > 0) { 899 if (nitems > 0) {
941 int idx = binarySearch( 900 int idx = binarySearch(
942 - key,  
943 - items,  
944 - nitems / 2,  
945 - return_prev_if_not_found,  
946 - &NNTreeImpl::compareKeyItem); 901 + key, items, nitems / 2, return_prev_if_not_found, &NNTreeImpl::compareKeyItem);
947 if (idx >= 0) { 902 if (idx >= 0) {
948 result.setItemNumber(node, 2 * idx); 903 result.setItemNumber(node, 2 * idx);
949 } 904 }
950 break; 905 break;
951 } else if (nkids > 0) { 906 } else if (nkids > 0) {
952 - int idx = binarySearch(  
953 - key, kids, nkids, true, &NNTreeImpl::compareKeyKid); 907 + int idx = binarySearch(key, kids, nkids, true, &NNTreeImpl::compareKeyKid);
954 if (idx == -1) { 908 if (idx == -1) {
955 QTC::TC("qpdf", "NNTree -1 in binary search"); 909 QTC::TC("qpdf", "NNTree -1 in binary search");
956 error( 910 error(
libqpdf/OffsetInputSource.cc
@@ -10,11 +10,9 @@ OffsetInputSource::OffsetInputSource( @@ -10,11 +10,9 @@ OffsetInputSource::OffsetInputSource(
10 global_offset(global_offset) 10 global_offset(global_offset)
11 { 11 {
12 if (global_offset < 0) { 12 if (global_offset < 0) {
13 - throw std::logic_error(  
14 - "OffsetInputSource constructed with negative offset"); 13 + throw std::logic_error("OffsetInputSource constructed with negative offset");
15 } 14 }
16 - this->max_safe_offset =  
17 - std::numeric_limits<qpdf_offset_t>::max() - global_offset; 15 + this->max_safe_offset = std::numeric_limits<qpdf_offset_t>::max() - global_offset;
18 } 16 }
19 17
20 qpdf_offset_t 18 qpdf_offset_t
@@ -51,8 +49,7 @@ OffsetInputSource::seek(qpdf_offset_t offset, int whence) @@ -51,8 +49,7 @@ OffsetInputSource::seek(qpdf_offset_t offset, int whence)
51 this->proxied->seek(offset, whence); 49 this->proxied->seek(offset, whence);
52 } 50 }
53 if (tell() < 0) { 51 if (tell() < 0) {
54 - throw std::runtime_error(  
55 - "offset input source: seek before beginning of file"); 52 + throw std::runtime_error("offset input source: seek before beginning of file");
56 } 53 }
57 } 54 }
58 55
libqpdf/PDFVersion.cc
@@ -7,8 +7,7 @@ PDFVersion::PDFVersion() : @@ -7,8 +7,7 @@ PDFVersion::PDFVersion() :
7 { 7 {
8 } 8 }
9 9
10 -PDFVersion::PDFVersion(  
11 - int major_version, int minor_version, int extension_level) : 10 +PDFVersion::PDFVersion(int major_version, int minor_version, int extension_level) :
12 major_version(major_version), 11 major_version(major_version),
13 minor_version(minor_version), 12 minor_version(minor_version),
14 extension_level(extension_level) 13 extension_level(extension_level)
@@ -31,8 +30,7 @@ bool @@ -31,8 +30,7 @@ bool
31 PDFVersion::operator==(PDFVersion const& rhs) const 30 PDFVersion::operator==(PDFVersion const& rhs) const
32 { 31 {
33 return ( 32 return (
34 - (this->major_version == rhs.major_version) &&  
35 - (this->minor_version == rhs.minor_version) && 33 + (this->major_version == rhs.major_version) && (this->minor_version == rhs.minor_version) &&
36 (this->extension_level == rhs.extension_level)); 34 (this->extension_level == rhs.extension_level));
37 } 35 }
38 36
@@ -48,8 +46,7 @@ void @@ -48,8 +46,7 @@ void
48 PDFVersion::getVersion(std::string& version, int& extension_level) const 46 PDFVersion::getVersion(std::string& version, int& extension_level) const
49 { 47 {
50 extension_level = this->extension_level; 48 extension_level = this->extension_level;
51 - version = std::to_string(this->major_version) + "." +  
52 - std::to_string(this->minor_version); 49 + version = std::to_string(this->major_version) + "." + std::to_string(this->minor_version);
53 } 50 }
54 51
55 int 52 int
libqpdf/Pipeline.cc
@@ -14,8 +14,7 @@ Pipeline::getNext(bool allow_null) @@ -14,8 +14,7 @@ Pipeline::getNext(bool allow_null)
14 { 14 {
15 if ((this->next == nullptr) && (!allow_null)) { 15 if ((this->next == nullptr) && (!allow_null)) {
16 throw std::logic_error( 16 throw std::logic_error(
17 - this->identifier +  
18 - ": Pipeline::getNext() called on pipeline with no next"); 17 + this->identifier + ": Pipeline::getNext() called on pipeline with no next");
19 } 18 }
20 return this->next; 19 return this->next;
21 } 20 }
libqpdf/Pl_AES_PDF.cc
@@ -117,8 +117,7 @@ Pl_AES_PDF::finish() @@ -117,8 +117,7 @@ Pl_AES_PDF::finish()
117 throw std::logic_error("buffer overflow in AES encryption" 117 throw std::logic_error("buffer overflow in AES encryption"
118 " pipeline"); 118 " pipeline");
119 } 119 }
120 - std::memset(  
121 - this->inbuf + this->offset, 0, this->buf_size - this->offset); 120 + std::memset(this->inbuf + this->offset, 0, this->buf_size - this->offset);
122 this->offset = this->buf_size; 121 this->offset = this->buf_size;
123 } 122 }
124 flush(!this->disable_padding); 123 flush(!this->disable_padding);
@@ -149,8 +148,7 @@ void @@ -149,8 +148,7 @@ void
149 Pl_AES_PDF::flush(bool strip_padding) 148 Pl_AES_PDF::flush(bool strip_padding)
150 { 149 {
151 if (this->offset != this->buf_size) { 150 if (this->offset != this->buf_size) {
152 - throw std::logic_error(  
153 - "AES pipeline: flush called when buffer was not full"); 151 + throw std::logic_error("AES pipeline: flush called when buffer was not full");
154 } 152 }
155 153
156 if (first) { 154 if (first) {
@@ -177,11 +175,7 @@ Pl_AES_PDF::flush(bool strip_padding) @@ -177,11 +175,7 @@ Pl_AES_PDF::flush(bool strip_padding)
177 } 175 }
178 } 176 }
179 this->crypto->rijndael_init( 177 this->crypto->rijndael_init(
180 - encrypt,  
181 - this->key.get(),  
182 - key_bytes,  
183 - this->cbc_mode,  
184 - this->cbc_block); 178 + encrypt, this->key.get(), key_bytes, this->cbc_mode, this->cbc_block);
185 if (return_after_init) { 179 if (return_after_init) {
186 return; 180 return;
187 } 181 }
libqpdf/Pl_ASCII85Decoder.cc
@@ -26,8 +26,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len) @@ -26,8 +26,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
26 flush(); 26 flush();
27 eod = 2; 27 eod = 2;
28 } else { 28 } else {
29 - throw std::runtime_error(  
30 - "broken end-of-data sequence in base 85 data"); 29 + throw std::runtime_error("broken end-of-data sequence in base 85 data");
31 } 30 }
32 } else { 31 } else {
33 switch (buf[i]) { 32 switch (buf[i]) {
@@ -47,8 +46,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len) @@ -47,8 +46,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
47 46
48 case 'z': 47 case 'z':
49 if (pos != 0) { 48 if (pos != 0) {
50 - throw std::runtime_error(  
51 - "unexpected z during base 85 decode"); 49 + throw std::runtime_error("unexpected z during base 85 decode");
52 } else { 50 } else {
53 QTC::TC("libtests", "Pl_ASCII85Decoder read z"); 51 QTC::TC("libtests", "Pl_ASCII85Decoder read z");
54 unsigned char zeroes[4]; 52 unsigned char zeroes[4];
@@ -59,8 +57,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len) @@ -59,8 +57,7 @@ Pl_ASCII85Decoder::write(unsigned char const* buf, size_t len)
59 57
60 default: 58 default:
61 if ((buf[i] < 33) || (buf[i] > 117)) { 59 if ((buf[i] < 33) || (buf[i] > 117)) {
62 - throw std::runtime_error(  
63 - "character out of range during base 85 decode"); 60 + throw std::runtime_error("character out of range during base 85 decode");
64 } else { 61 } else {
65 this->inbuf[this->pos++] = buf[i]; 62 this->inbuf[this->pos++] = buf[i];
66 if (pos == 5) { 63 if (pos == 5) {
@@ -93,10 +90,7 @@ Pl_ASCII85Decoder::flush() @@ -93,10 +90,7 @@ Pl_ASCII85Decoder::flush()
93 lval >>= 8; 90 lval >>= 8;
94 } 91 }
95 92
96 - QTC::TC(  
97 - "libtests",  
98 - "Pl_ASCII85Decoder partial flush",  
99 - (this->pos == 5) ? 0 : 1); 93 + QTC::TC("libtests", "Pl_ASCII85Decoder partial flush", (this->pos == 5) ? 0 : 1);
100 // Reset before calling getNext()->write in case that throws an 94 // Reset before calling getNext()->write in case that throws an
101 // exception. 95 // exception.
102 auto t = this->pos - 1; 96 auto t = this->pos - 1;
libqpdf/Pl_ASCIIHexDecoder.cc
@@ -78,10 +78,7 @@ Pl_ASCIIHexDecoder::flush() @@ -78,10 +78,7 @@ Pl_ASCIIHexDecoder::flush()
78 } 78 }
79 auto ch = static_cast<unsigned char>((b[0] << 4) + b[1]); 79 auto ch = static_cast<unsigned char>((b[0] << 4) + b[1]);
80 80
81 - QTC::TC(  
82 - "libtests",  
83 - "Pl_ASCIIHexDecoder partial flush",  
84 - (this->pos == 2) ? 0 : 1); 81 + QTC::TC("libtests", "Pl_ASCIIHexDecoder partial flush", (this->pos == 2) ? 0 : 1);
85 // Reset before calling getNext()->write in case that throws an 82 // Reset before calling getNext()->write in case that throws an
86 // exception. 83 // exception.
87 this->pos = 0; 84 this->pos = 0;
libqpdf/Pl_Base64.cc
@@ -91,8 +91,7 @@ void @@ -91,8 +91,7 @@ void
91 Pl_Base64::flush_decode() 91 Pl_Base64::flush_decode()
92 { 92 {
93 if (this->end_of_data) { 93 if (this->end_of_data) {
94 - throw std::runtime_error(  
95 - getIdentifier() + ": base64 decode: data follows pad characters"); 94 + throw std::runtime_error(getIdentifier() + ": base64 decode: data follows pad characters");
96 } 95 }
97 int pad = 0; 96 int pad = 0;
98 int shift = 18; 97 int shift = 18;
@@ -110,14 +109,12 @@ Pl_Base64::flush_decode() @@ -110,14 +109,12 @@ Pl_Base64::flush_decode()
110 v = 62; 109 v = 62;
111 } else if ((ch == '/') || (ch == '_')) { 110 } else if ((ch == '/') || (ch == '_')) {
112 v = 63; 111 v = 63;
113 - } else if (  
114 - (ch == '=') && ((i == 3) || ((i == 2) && (this->buf[3] == '=')))) { 112 + } else if ((ch == '=') && ((i == 3) || ((i == 2) && (this->buf[3] == '=')))) {
115 ++pad; 113 ++pad;
116 this->end_of_data = true; 114 this->end_of_data = true;
117 v = 0; 115 v = 0;
118 } else { 116 } else {
119 - throw std::runtime_error(  
120 - getIdentifier() + ": base64 decode: invalid input"); 117 + throw std::runtime_error(getIdentifier() + ": base64 decode: invalid input");
121 } 118 }
122 outval |= v << shift; 119 outval |= v << shift;
123 shift -= 6; 120 shift -= 6;
libqpdf/Pl_Buffer.cc
@@ -64,8 +64,7 @@ void @@ -64,8 +64,7 @@ void
64 Pl_Buffer::getMallocBuffer(unsigned char** buf, size_t* len) 64 Pl_Buffer::getMallocBuffer(unsigned char** buf, size_t* len)
65 { 65 {
66 if (!m->ready) { 66 if (!m->ready) {
67 - throw std::logic_error(  
68 - "Pl_Buffer::getMallocBuffer() called when not ready"); 67 + throw std::logic_error("Pl_Buffer::getMallocBuffer() called when not ready");
69 } 68 }
70 auto size = m->data.length(); 69 auto size = m->data.length();
71 *len = size; 70 *len = size;
libqpdf/Pl_DCT.cc
@@ -182,15 +182,12 @@ term_pipeline_destination(j_compress_ptr cinfo) @@ -182,15 +182,12 @@ term_pipeline_destination(j_compress_ptr cinfo)
182 } 182 }
183 183
184 static void 184 static void
185 -jpeg_pipeline_dest(  
186 - j_compress_ptr cinfo, unsigned char* outbuffer, size_t size, Pipeline* next) 185 +jpeg_pipeline_dest(j_compress_ptr cinfo, unsigned char* outbuffer, size_t size, Pipeline* next)
187 { 186 {
188 cinfo->dest = static_cast<struct jpeg_destination_mgr*>( 187 cinfo->dest = static_cast<struct jpeg_destination_mgr*>(
189 // line-break 188 // line-break
190 (*cinfo->mem->alloc_small)( 189 (*cinfo->mem->alloc_small)(
191 - reinterpret_cast<j_common_ptr>(cinfo),  
192 - JPOOL_PERMANENT,  
193 - sizeof(dct_pipeline_dest))); 190 + reinterpret_cast<j_common_ptr>(cinfo), JPOOL_PERMANENT, sizeof(dct_pipeline_dest)));
194 auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest); 191 auto* dest = reinterpret_cast<dct_pipeline_dest*>(cinfo->dest);
195 dest->pub.init_destination = init_pipeline_destination; 192 dest->pub.init_destination = init_pipeline_destination;
196 dest->pub.empty_output_buffer = empty_pipeline_output_buffer; 193 dest->pub.empty_output_buffer = empty_pipeline_output_buffer;
@@ -243,9 +240,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, Buffer* buffer) @@ -243,9 +240,7 @@ jpeg_buffer_src(j_decompress_ptr cinfo, Buffer* buffer)
243 cinfo->src = reinterpret_cast<jpeg_source_mgr*>( 240 cinfo->src = reinterpret_cast<jpeg_source_mgr*>(
244 // line-break 241 // line-break
245 (*cinfo->mem->alloc_small)( 242 (*cinfo->mem->alloc_small)(
246 - reinterpret_cast<j_common_ptr>(cinfo),  
247 - JPOOL_PERMANENT,  
248 - sizeof(jpeg_source_mgr))); 243 + reinterpret_cast<j_common_ptr>(cinfo), JPOOL_PERMANENT, sizeof(jpeg_source_mgr)));
249 244
250 jpeg_source_mgr* src = cinfo->src; 245 jpeg_source_mgr* src = cinfo->src;
251 src->init_source = init_buffer_source; 246 src->init_source = init_buffer_source;
@@ -262,16 +257,12 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b) @@ -262,16 +257,12 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
262 { 257 {
263 auto* cinfo = reinterpret_cast<jpeg_compress_struct*>(cinfo_p); 258 auto* cinfo = reinterpret_cast<jpeg_compress_struct*>(cinfo_p);
264 259
265 -#if ( \  
266 - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \  
267 - defined(__clang__)) 260 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
268 # pragma GCC diagnostic push 261 # pragma GCC diagnostic push
269 # pragma GCC diagnostic ignored "-Wold-style-cast" 262 # pragma GCC diagnostic ignored "-Wold-style-cast"
270 #endif 263 #endif
271 jpeg_create_compress(cinfo); 264 jpeg_create_compress(cinfo);
272 -#if ( \  
273 - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \  
274 - defined(__clang__)) 265 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
275 # pragma GCC diagnostic pop 266 # pragma GCC diagnostic pop
276 #endif 267 #endif
277 static int const BUF_SIZE = 65536; 268 static int const BUF_SIZE = 65536;
@@ -290,11 +281,9 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b) @@ -290,11 +281,9 @@ Pl_DCT::compress(void* cinfo_p, Buffer* b)
290 281
291 jpeg_start_compress(cinfo, TRUE); 282 jpeg_start_compress(cinfo, TRUE);
292 283
293 - unsigned int width =  
294 - cinfo->image_width * QIntC::to_uint(cinfo->input_components); 284 + unsigned int width = cinfo->image_width * QIntC::to_uint(cinfo->input_components);
295 size_t expected_size = QIntC::to_size(cinfo->image_height) * 285 size_t expected_size = QIntC::to_size(cinfo->image_height) *
296 - QIntC::to_size(cinfo->image_width) *  
297 - QIntC::to_size(cinfo->input_components); 286 + QIntC::to_size(cinfo->image_width) * QIntC::to_size(cinfo->input_components);
298 if (b->getSize() != expected_size) { 287 if (b->getSize() != expected_size) {
299 throw std::runtime_error( 288 throw std::runtime_error(
300 "Pl_DCT: image buffer size = " + std::to_string(b->getSize()) + 289 "Pl_DCT: image buffer size = " + std::to_string(b->getSize()) +
@@ -316,16 +305,12 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b) @@ -316,16 +305,12 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b)
316 { 305 {
317 auto* cinfo = reinterpret_cast<jpeg_decompress_struct*>(cinfo_p); 306 auto* cinfo = reinterpret_cast<jpeg_decompress_struct*>(cinfo_p);
318 307
319 -#if ( \  
320 - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \  
321 - defined(__clang__)) 308 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
322 # pragma GCC diagnostic push 309 # pragma GCC diagnostic push
323 # pragma GCC diagnostic ignored "-Wold-style-cast" 310 # pragma GCC diagnostic ignored "-Wold-style-cast"
324 #endif 311 #endif
325 jpeg_create_decompress(cinfo); 312 jpeg_create_decompress(cinfo);
326 -#if ( \  
327 - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \  
328 - defined(__clang__)) 313 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
329 # pragma GCC diagnostic pop 314 # pragma GCC diagnostic pop
330 #endif 315 #endif
331 jpeg_buffer_src(cinfo, b); 316 jpeg_buffer_src(cinfo, b);
@@ -333,10 +318,9 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b) @@ -333,10 +318,9 @@ Pl_DCT::decompress(void* cinfo_p, Buffer* b)
333 (void)jpeg_read_header(cinfo, TRUE); 318 (void)jpeg_read_header(cinfo, TRUE);
334 (void)jpeg_calc_output_dimensions(cinfo); 319 (void)jpeg_calc_output_dimensions(cinfo);
335 320
336 - unsigned int width =  
337 - cinfo->output_width * QIntC::to_uint(cinfo->output_components);  
338 - JSAMPARRAY buffer = (*cinfo->mem->alloc_sarray)(  
339 - reinterpret_cast<j_common_ptr>(cinfo), JPOOL_IMAGE, width, 1); 321 + unsigned int width = cinfo->output_width * QIntC::to_uint(cinfo->output_components);
  322 + JSAMPARRAY buffer =
  323 + (*cinfo->mem->alloc_sarray)(reinterpret_cast<j_common_ptr>(cinfo), JPOOL_IMAGE, width, 1);
340 324
341 (void)jpeg_start_decompress(cinfo); 325 (void)jpeg_start_decompress(cinfo);
342 while (cinfo->output_scanline < cinfo->output_height) { 326 while (cinfo->output_scanline < cinfo->output_height) {
libqpdf/Pl_Flate.cc
@@ -54,10 +54,7 @@ Pl_Flate::Members::~Members() @@ -54,10 +54,7 @@ Pl_Flate::Members::~Members()
54 } 54 }
55 55
56 Pl_Flate::Pl_Flate( 56 Pl_Flate::Pl_Flate(
57 - char const* identifier,  
58 - Pipeline* next,  
59 - action_e action,  
60 - unsigned int out_bufsize_int) : 57 + char const* identifier, Pipeline* next, action_e action, unsigned int out_bufsize_int) :
61 Pipeline(identifier, next), 58 Pipeline(identifier, next),
62 m(new Members(QIntC::to_size(out_bufsize_int), action)) 59 m(new Members(QIntC::to_size(out_bufsize_int), action))
63 { 60 {
@@ -88,8 +85,7 @@ Pl_Flate::write(unsigned char const* data, size_t len) @@ -88,8 +85,7 @@ Pl_Flate::write(unsigned char const* data, size_t len)
88 { 85 {
89 if (m->outbuf == nullptr) { 86 if (m->outbuf == nullptr) {
90 throw std::logic_error( 87 throw std::logic_error(
91 - this->identifier +  
92 - ": Pl_Flate: write() called after finish() called"); 88 + this->identifier + ": Pl_Flate: write() called after finish() called");
93 } 89 }
94 90
95 // Write in chunks in case len is too big to fit in an int. 91 // Write in chunks in case len is too big to fit in an int.
@@ -99,8 +95,7 @@ Pl_Flate::write(unsigned char const* data, size_t len) @@ -99,8 +95,7 @@ Pl_Flate::write(unsigned char const* data, size_t len)
99 unsigned char const* buf = data; 95 unsigned char const* buf = data;
100 while (bytes_left > 0) { 96 while (bytes_left > 0) {
101 size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left); 97 size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left);
102 - handleData(  
103 - buf, bytes, (m->action == a_inflate ? Z_SYNC_FLUSH : Z_NO_FLUSH)); 98 + handleData(buf, bytes, (m->action == a_inflate ? Z_SYNC_FLUSH : Z_NO_FLUSH));
104 bytes_left -= bytes; 99 bytes_left -= bytes;
105 buf += bytes; 100 buf += bytes;
106 } 101 }
@@ -124,9 +119,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush) @@ -124,9 +119,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
124 119
125 // deflateInit and inflateInit are macros that use old-style 120 // deflateInit and inflateInit are macros that use old-style
126 // casts. 121 // casts.
127 -#if ( \  
128 - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \  
129 - defined(__clang__)) 122 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
130 # pragma GCC diagnostic push 123 # pragma GCC diagnostic push
131 # pragma GCC diagnostic ignored "-Wold-style-cast" 124 # pragma GCC diagnostic ignored "-Wold-style-cast"
132 #endif 125 #endif
@@ -135,9 +128,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush) @@ -135,9 +128,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
135 } else { 128 } else {
136 err = inflateInit(&zstream); 129 err = inflateInit(&zstream);
137 } 130 }
138 -#if ( \  
139 - (defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || \  
140 - defined(__clang__)) 131 +#if ((defined(__GNUC__) && ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__))
141 # pragma GCC diagnostic pop 132 # pragma GCC diagnostic pop
142 #endif 133 #endif
143 134
@@ -171,8 +162,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush) @@ -171,8 +162,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
171 // least one in qpdf's test suite). In some cases, we want 162 // least one in qpdf's test suite). In some cases, we want
172 // to know about this, because it indicates incorrect 163 // to know about this, because it indicates incorrect
173 // compression, so call a callback if provided. 164 // compression, so call a callback if provided.
174 - this->warn(  
175 - "input stream is complete but output may still be valid", err); 165 + this->warn("input stream is complete but output may still be valid", err);
176 done = true; 166 done = true;
177 break; 167 break;
178 168
@@ -188,8 +178,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush) @@ -188,8 +178,7 @@ Pl_Flate::handleData(unsigned char const* data, size_t len, int flush)
188 // needed, so we're done for now. 178 // needed, so we're done for now.
189 done = true; 179 done = true;
190 } 180 }
191 - uLong ready =  
192 - QIntC::to_ulong(m->out_bufsize - zstream.avail_out); 181 + uLong ready = QIntC::to_ulong(m->out_bufsize - zstream.avail_out);
193 if (ready > 0) { 182 if (ready > 0) {
194 this->getNext()->write(m->outbuf.get(), ready); 183 this->getNext()->write(m->outbuf.get(), ready);
195 zstream.next_out = m->outbuf.get(); 184 zstream.next_out = m->outbuf.get();
@@ -249,10 +238,8 @@ Pl_Flate::checkError(char const* prefix, int error_code) @@ -249,10 +238,8 @@ Pl_Flate::checkError(char const* prefix, int error_code)
249 { 238 {
250 z_stream& zstream = *(static_cast<z_stream*>(m->zdata)); 239 z_stream& zstream = *(static_cast<z_stream*>(m->zdata));
251 if (error_code != Z_OK) { 240 if (error_code != Z_OK) {
252 - char const* action_str =  
253 - (m->action == a_deflate ? "deflate" : "inflate");  
254 - std::string msg =  
255 - this->identifier + ": " + action_str + ": " + prefix + ": "; 241 + char const* action_str = (m->action == a_deflate ? "deflate" : "inflate");
  242 + std::string msg = this->identifier + ": " + action_str + ": " + prefix + ": ";
256 243
257 if (zstream.msg) { 244 if (zstream.msg) {
258 msg += zstream.msg; 245 msg += zstream.msg;
@@ -283,8 +270,7 @@ Pl_Flate::checkError(char const* prefix, int error_code) @@ -283,8 +270,7 @@ Pl_Flate::checkError(char const* prefix, int error_code)
283 break; 270 break;
284 271
285 default: 272 default:
286 - msg += std::string("zlib unknown error (") +  
287 - std::to_string(error_code) + ")"; 273 + msg += std::string("zlib unknown error (") + std::to_string(error_code) + ")";
288 break; 274 break;
289 } 275 }
290 } 276 }
libqpdf/Pl_Function.cc
@@ -13,8 +13,7 @@ Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_t fn) : @@ -13,8 +13,7 @@ Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_t fn) :
13 { 13 {
14 } 14 }
15 15
16 -Pl_Function::Pl_Function(  
17 - char const* identifier, Pipeline* next, writer_c_t fn, void* udata) : 16 +Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_t fn, void* udata) :
18 Pipeline(identifier, next), 17 Pipeline(identifier, next),
19 m(new Members(nullptr)) 18 m(new Members(nullptr))
20 { 19 {
@@ -22,14 +21,12 @@ Pl_Function::Pl_Function( @@ -22,14 +21,12 @@ Pl_Function::Pl_Function(
22 int code = fn(data, len, udata); 21 int code = fn(data, len, udata);
23 if (code != 0) { 22 if (code != 0) {
24 throw std::runtime_error( 23 throw std::runtime_error(
25 - std::string(identifier) + " function returned code " +  
26 - std::to_string(code)); 24 + std::string(identifier) + " function returned code " + std::to_string(code));
27 } 25 }
28 }; 26 };
29 } 27 }
30 28
31 -Pl_Function::Pl_Function(  
32 - char const* identifier, Pipeline* next, writer_c_char_t fn, void* udata) : 29 +Pl_Function::Pl_Function(char const* identifier, Pipeline* next, writer_c_char_t fn, void* udata) :
33 Pipeline(identifier, next), 30 Pipeline(identifier, next),
34 m(new Members(nullptr)) 31 m(new Members(nullptr))
35 { 32 {
@@ -37,8 +34,7 @@ Pl_Function::Pl_Function( @@ -37,8 +34,7 @@ Pl_Function::Pl_Function(
37 int code = fn(reinterpret_cast<char const*>(data), len, udata); 34 int code = fn(reinterpret_cast<char const*>(data), len, udata);
38 if (code != 0) { 35 if (code != 0) {
39 throw std::runtime_error( 36 throw std::runtime_error(
40 - std::string(identifier) + " function returned code " +  
41 - std::to_string(code)); 37 + std::string(identifier) + " function returned code " + std::to_string(code));
42 } 38 }
43 }; 39 };
44 } 40 }
libqpdf/Pl_LZWDecoder.cc
@@ -6,8 +6,7 @@ @@ -6,8 +6,7 @@
6 #include <cstring> 6 #include <cstring>
7 #include <stdexcept> 7 #include <stdexcept>
8 8
9 -Pl_LZWDecoder::Pl_LZWDecoder(  
10 - char const* identifier, Pipeline* next, bool early_code_change) : 9 +Pl_LZWDecoder::Pl_LZWDecoder(char const* identifier, Pipeline* next, bool early_code_change) :
11 Pipeline(identifier, next), 10 Pipeline(identifier, next),
12 code_size(9), 11 code_size(9),
13 next(0), 12 next(0),
@@ -90,15 +89,13 @@ Pl_LZWDecoder::getFirstChar(unsigned int code) @@ -90,15 +89,13 @@ Pl_LZWDecoder::getFirstChar(unsigned int code)
90 } else if (code > 257) { 89 } else if (code > 257) {
91 unsigned int idx = code - 258; 90 unsigned int idx = code - 258;
92 if (idx >= table.size()) { 91 if (idx >= table.size()) {
93 - throw std::runtime_error(  
94 - "Pl_LZWDecoder::getFirstChar: table overflow"); 92 + throw std::runtime_error("Pl_LZWDecoder::getFirstChar: table overflow");
95 } 93 }
96 Buffer& b = table.at(idx); 94 Buffer& b = table.at(idx);
97 result = b.getBuffer()[0]; 95 result = b.getBuffer()[0];
98 } else { 96 } else {
99 throw std::runtime_error( 97 throw std::runtime_error(
100 - "Pl_LZWDecoder::getFirstChar called with invalid code (" +  
101 - std::to_string(code) + ")"); 98 + "Pl_LZWDecoder::getFirstChar called with invalid code (" + std::to_string(code) + ")");
102 } 99 }
103 return result; 100 return result;
104 } 101 }
@@ -117,8 +114,7 @@ Pl_LZWDecoder::addToTable(unsigned char next) @@ -117,8 +114,7 @@ Pl_LZWDecoder::addToTable(unsigned char next)
117 } else if (this->last_code > 257) { 114 } else if (this->last_code > 257) {
118 unsigned int idx = this->last_code - 258; 115 unsigned int idx = this->last_code - 258;
119 if (idx >= table.size()) { 116 if (idx >= table.size()) {
120 - throw std::runtime_error(  
121 - "Pl_LZWDecoder::addToTable: table overflow"); 117 + throw std::runtime_error("Pl_LZWDecoder::addToTable: table overflow");
122 } 118 }
123 Buffer& b = table.at(idx); 119 Buffer& b = table.at(idx);
124 last_data = b.getBuffer(); 120 last_data = b.getBuffer();
@@ -182,8 +178,7 @@ Pl_LZWDecoder::handleCode(unsigned int code) @@ -182,8 +178,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
182 } 178 }
183 addToTable(next); 179 addToTable(next);
184 unsigned int change_idx = new_idx + code_change_delta; 180 unsigned int change_idx = new_idx + code_change_delta;
185 - if ((change_idx == 511) || (change_idx == 1023) ||  
186 - (change_idx == 2047)) { 181 + if ((change_idx == 511) || (change_idx == 1023) || (change_idx == 2047)) {
187 ++this->code_size; 182 ++this->code_size;
188 } 183 }
189 } 184 }
@@ -194,8 +189,7 @@ Pl_LZWDecoder::handleCode(unsigned int code) @@ -194,8 +189,7 @@ Pl_LZWDecoder::handleCode(unsigned int code)
194 } else { 189 } else {
195 unsigned int idx = code - 258; 190 unsigned int idx = code - 258;
196 if (idx >= table.size()) { 191 if (idx >= table.size()) {
197 - throw std::runtime_error(  
198 - "Pl_LZWDecoder::handleCode: table overflow"); 192 + throw std::runtime_error("Pl_LZWDecoder::handleCode: table overflow");
199 } 193 }
200 Buffer& b = table.at(idx); 194 Buffer& b = table.at(idx);
201 getNext()->write(b.getBuffer(), b.getSize()); 195 getNext()->write(b.getBuffer(), b.getSize());
libqpdf/Pl_MD5.cc
@@ -26,8 +26,7 @@ Pl_MD5::write(unsigned char const* buf, size_t len) @@ -26,8 +26,7 @@ Pl_MD5::write(unsigned char const* buf, size_t len)
26 unsigned char const* data = buf; 26 unsigned char const* data = buf;
27 while (bytes_left > 0) { 27 while (bytes_left > 0) {
28 size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left); 28 size_t bytes = (bytes_left >= max_bytes ? max_bytes : bytes_left);
29 - this->md5.encodeDataIncrementally(  
30 - reinterpret_cast<char const*>(data), bytes); 29 + this->md5.encodeDataIncrementally(reinterpret_cast<char const*>(data), bytes);
31 bytes_left -= bytes; 30 bytes_left -= bytes;
32 data += bytes; 31 data += bytes;
33 } 32 }
libqpdf/Pl_OStream.cc
@@ -22,8 +22,7 @@ Pl_OStream::~Pl_OStream() @@ -22,8 +22,7 @@ Pl_OStream::~Pl_OStream()
22 void 22 void
23 Pl_OStream::write(unsigned char const* buf, size_t len) 23 Pl_OStream::write(unsigned char const* buf, size_t len)
24 { 24 {
25 - m->os.write(  
26 - reinterpret_cast<char const*>(buf), static_cast<std::streamsize>(len)); 25 + m->os.write(reinterpret_cast<char const*>(buf), static_cast<std::streamsize>(len));
27 } 26 }
28 27
29 void 28 void
libqpdf/Pl_PNGFilter.cc
@@ -29,36 +29,28 @@ Pl_PNGFilter::Pl_PNGFilter( @@ -29,36 +29,28 @@ Pl_PNGFilter::Pl_PNGFilter(
29 pos(0) 29 pos(0)
30 { 30 {
31 if (samples_per_pixel < 1) { 31 if (samples_per_pixel < 1) {
32 - throw std::runtime_error(  
33 - "PNGFilter created with invalid samples_per_pixel"); 32 + throw std::runtime_error("PNGFilter created with invalid samples_per_pixel");
34 } 33 }
35 - if (!((bits_per_sample == 1) || (bits_per_sample == 2) ||  
36 - (bits_per_sample == 4) || (bits_per_sample == 8) ||  
37 - (bits_per_sample == 16))) {  
38 - throw std::runtime_error(  
39 - "PNGFilter created with invalid bits_per_sample not"  
40 - " 1, 2, 4, 8, or 16"); 34 + if (!((bits_per_sample == 1) || (bits_per_sample == 2) || (bits_per_sample == 4) ||
  35 + (bits_per_sample == 8) || (bits_per_sample == 16))) {
  36 + throw std::runtime_error("PNGFilter created with invalid bits_per_sample not"
  37 + " 1, 2, 4, 8, or 16");
41 } 38 }
42 this->bytes_per_pixel = ((bits_per_sample * samples_per_pixel) + 7) / 8; 39 this->bytes_per_pixel = ((bits_per_sample * samples_per_pixel) + 7) / 8;
43 - unsigned long long bpr =  
44 - ((columns * bits_per_sample * samples_per_pixel) + 7) / 8; 40 + unsigned long long bpr = ((columns * bits_per_sample * samples_per_pixel) + 7) / 8;
45 if ((bpr == 0) || (bpr > (UINT_MAX - 1))) { 41 if ((bpr == 0) || (bpr > (UINT_MAX - 1))) {
46 - throw std::runtime_error(  
47 - "PNGFilter created with invalid columns value"); 42 + throw std::runtime_error("PNGFilter created with invalid columns value");
48 } 43 }
49 this->bytes_per_row = bpr & UINT_MAX; 44 this->bytes_per_row = bpr & UINT_MAX;
50 - this->buf1 =  
51 - QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);  
52 - this->buf2 =  
53 - QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1); 45 + this->buf1 = QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
  46 + this->buf2 = QUtil::make_shared_array<unsigned char>(this->bytes_per_row + 1);
54 memset(this->buf1.get(), 0, this->bytes_per_row + 1); 47 memset(this->buf1.get(), 0, this->bytes_per_row + 1);
55 memset(this->buf2.get(), 0, this->bytes_per_row + 1); 48 memset(this->buf2.get(), 0, this->bytes_per_row + 1);
56 this->cur_row = this->buf1.get(); 49 this->cur_row = this->buf1.get();
57 this->prev_row = this->buf2.get(); 50 this->prev_row = this->buf2.get();
58 51
59 // number of bytes per incoming row 52 // number of bytes per incoming row
60 - this->incoming =  
61 - (action == a_encode ? this->bytes_per_row : this->bytes_per_row + 1); 53 + this->incoming = (action == a_encode ? this->bytes_per_row : this->bytes_per_row + 1);
62 } 54 }
63 55
64 void 56 void
@@ -197,8 +189,8 @@ Pl_PNGFilter::decodePaeth() @@ -197,8 +189,8 @@ Pl_PNGFilter::decodePaeth()
197 upper_left = above_buffer[i - bpp]; 189 upper_left = above_buffer[i - bpp];
198 } 190 }
199 191
200 - buffer[i] = static_cast<unsigned char>(  
201 - buffer[i] + this->PaethPredictor(left, up, upper_left)); 192 + buffer[i] =
  193 + static_cast<unsigned char>(buffer[i] + this->PaethPredictor(left, up, upper_left));
202 } 194 }
203 } 195 }
204 196
@@ -227,8 +219,7 @@ Pl_PNGFilter::encodeRow() @@ -227,8 +219,7 @@ Pl_PNGFilter::encodeRow()
227 getNext()->write(&ch, 1); 219 getNext()->write(&ch, 1);
228 if (this->prev_row) { 220 if (this->prev_row) {
229 for (unsigned int i = 0; i < this->bytes_per_row; ++i) { 221 for (unsigned int i = 0; i < this->bytes_per_row; ++i) {
230 - ch = static_cast<unsigned char>(  
231 - this->cur_row[i] - this->prev_row[i]); 222 + ch = static_cast<unsigned char>(this->cur_row[i] - this->prev_row[i]);
232 getNext()->write(&ch, 1); 223 getNext()->write(&ch, 1);
233 } 224 }
234 } else { 225 } else {
libqpdf/Pl_QPDFTokenizer.cc
@@ -11,15 +11,12 @@ Pl_QPDFTokenizer::Members::Members() : @@ -11,15 +11,12 @@ Pl_QPDFTokenizer::Members::Members() :
11 } 11 }
12 12
13 Pl_QPDFTokenizer::Pl_QPDFTokenizer( 13 Pl_QPDFTokenizer::Pl_QPDFTokenizer(
14 - char const* identifier,  
15 - QPDFObjectHandle::TokenFilter* filter,  
16 - Pipeline* next) : 14 + char const* identifier, QPDFObjectHandle::TokenFilter* filter, Pipeline* next) :
17 Pipeline(identifier, next), 15 Pipeline(identifier, next),
18 m(new Members) 16 m(new Members)
19 { 17 {
20 m->filter = filter; 18 m->filter = filter;
21 - QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(  
22 - m->filter, next); 19 + QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, next);
23 m->tokenizer.allowEOF(); 20 m->tokenizer.allowEOF();
24 m->tokenizer.includeIgnorable(); 21 m->tokenizer.includeIgnorable();
25 } 22 }
@@ -45,8 +42,8 @@ Pl_QPDFTokenizer::finish() @@ -45,8 +42,8 @@ Pl_QPDFTokenizer::finish()
45 new BufferInputSource("tokenizer data", m->buf.getBuffer(), true)); 42 new BufferInputSource("tokenizer data", m->buf.getBuffer(), true));
46 43
47 while (true) { 44 while (true) {
48 - QPDFTokenizer::Token token = m->tokenizer.readToken(  
49 - input, "offset " + std::to_string(input->tell()), true); 45 + QPDFTokenizer::Token token =
  46 + m->tokenizer.readToken(input, "offset " + std::to_string(input->tell()), true);
50 m->filter->handleToken(token); 47 m->filter->handleToken(token);
51 if (token.getType() == QPDFTokenizer::tt_eof) { 48 if (token.getType() == QPDFTokenizer::tt_eof) {
52 break; 49 break;
@@ -56,15 +53,13 @@ Pl_QPDFTokenizer::finish() @@ -56,15 +53,13 @@ Pl_QPDFTokenizer::finish()
56 input->read(&ch, 1); 53 input->read(&ch, 1);
57 m->filter->handleToken( 54 m->filter->handleToken(
58 // line-break 55 // line-break
59 - QPDFTokenizer::Token(  
60 - QPDFTokenizer::tt_space, std::string(1, ch))); 56 + QPDFTokenizer::Token(QPDFTokenizer::tt_space, std::string(1, ch)));
61 QTC::TC("qpdf", "Pl_QPDFTokenizer found ID"); 57 QTC::TC("qpdf", "Pl_QPDFTokenizer found ID");
62 m->tokenizer.expectInlineImage(input); 58 m->tokenizer.expectInlineImage(input);
63 } 59 }
64 } 60 }
65 m->filter->handleEOF(); 61 m->filter->handleEOF();
66 - QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(  
67 - m->filter, nullptr); 62 + QPDFObjectHandle::TokenFilter::PipelineAccessor::setPipeline(m->filter, nullptr);
68 Pipeline* next = this->getNext(true); 63 Pipeline* next = this->getNext(true);
69 if (next) { 64 if (next) {
70 next->finish(); 65 next->finish();
libqpdf/Pl_RC4.cc
@@ -19,17 +19,14 @@ void @@ -19,17 +19,14 @@ void
19 Pl_RC4::write(unsigned char const* data, size_t len) 19 Pl_RC4::write(unsigned char const* data, size_t len)
20 { 20 {
21 if (this->outbuf == nullptr) { 21 if (this->outbuf == nullptr) {
22 - throw std::logic_error(  
23 - this->identifier +  
24 - ": Pl_RC4: write() called after finish() called"); 22 + throw std::logic_error(this->identifier + ": Pl_RC4: write() called after finish() called");
25 } 23 }
26 24
27 size_t bytes_left = len; 25 size_t bytes_left = len;
28 unsigned char const* p = data; 26 unsigned char const* p = data;
29 27
30 while (bytes_left > 0) { 28 while (bytes_left > 0) {
31 - size_t bytes =  
32 - (bytes_left < this->out_bufsize ? bytes_left : out_bufsize); 29 + size_t bytes = (bytes_left < this->out_bufsize ? bytes_left : out_bufsize);
33 bytes_left -= bytes; 30 bytes_left -= bytes;
34 // lgtm[cpp/weak-cryptographic-algorithm] 31 // lgtm[cpp/weak-cryptographic-algorithm]
35 rc4.process(p, bytes, outbuf.get()); 32 rc4.process(p, bytes, outbuf.get());
libqpdf/Pl_RunLength.cc
@@ -10,8 +10,7 @@ Pl_RunLength::Members::Members(action_e action) : @@ -10,8 +10,7 @@ Pl_RunLength::Members::Members(action_e action) :
10 { 10 {
11 } 11 }
12 12
13 -Pl_RunLength::Pl_RunLength(  
14 - char const* identifier, Pipeline* next, action_e action) : 13 +Pl_RunLength::Pl_RunLength(char const* identifier, Pipeline* next, action_e action) :
15 Pipeline(identifier, next), 14 Pipeline(identifier, next),
16 m(new Members(action)) 15 m(new Members(action))
17 { 16 {
@@ -38,17 +37,12 @@ Pl_RunLength::encode(unsigned char const* data, size_t len) @@ -38,17 +37,12 @@ Pl_RunLength::encode(unsigned char const* data, size_t len)
38 { 37 {
39 for (size_t i = 0; i < len; ++i) { 38 for (size_t i = 0; i < len; ++i) {
40 if ((m->state == st_top) != (m->length <= 1)) { 39 if ((m->state == st_top) != (m->length <= 1)) {
41 - throw std::logic_error(  
42 - "Pl_RunLength::encode: state/length inconsistency"); 40 + throw std::logic_error("Pl_RunLength::encode: state/length inconsistency");
43 } 41 }
44 unsigned char ch = data[i]; 42 unsigned char ch = data[i];
45 - if ((m->length > 0) &&  
46 - ((m->state == st_copying) || (m->length < 128)) && 43 + if ((m->length > 0) && ((m->state == st_copying) || (m->length < 128)) &&
47 (ch == m->buf[m->length - 1])) { 44 (ch == m->buf[m->length - 1])) {
48 - QTC::TC(  
49 - "libtests",  
50 - "Pl_RunLength: switch to run",  
51 - (m->length == 128) ? 0 : 1); 45 + QTC::TC("libtests", "Pl_RunLength: switch to run", (m->length == 128) ? 0 : 1);
52 if (m->state == st_copying) { 46 if (m->state == st_copying) {
53 --m->length; 47 --m->length;
54 flush_encode(); 48 flush_encode();
@@ -124,8 +118,7 @@ Pl_RunLength::flush_encode() @@ -124,8 +118,7 @@ Pl_RunLength::flush_encode()
124 } 118 }
125 if (m->state == st_run) { 119 if (m->state == st_run) {
126 if ((m->length < 2) || (m->length > 128)) { 120 if ((m->length < 2) || (m->length > 128)) {
127 - throw std::logic_error(  
128 - "Pl_RunLength: invalid length in flush_encode for run"); 121 + throw std::logic_error("Pl_RunLength: invalid length in flush_encode for run");
129 } 122 }
130 auto ch = static_cast<unsigned char>(257 - m->length); 123 auto ch = static_cast<unsigned char>(257 - m->length);
131 this->getNext()->write(&ch, 1); 124 this->getNext()->write(&ch, 1);
libqpdf/Pl_SHA2.cc
@@ -51,8 +51,7 @@ void @@ -51,8 +51,7 @@ void
51 Pl_SHA2::resetBits(int bits) 51 Pl_SHA2::resetBits(int bits)
52 { 52 {
53 if (this->in_progress) { 53 if (this->in_progress) {
54 - throw std::logic_error(  
55 - "bit reset requested for in-progress SHA2 Pipeline"); 54 + throw std::logic_error("bit reset requested for in-progress SHA2 Pipeline");
56 } 55 }
57 this->crypto = QPDFCryptoProvider::getImpl(); 56 this->crypto = QPDFCryptoProvider::getImpl();
58 this->crypto->SHA2_init(bits); 57 this->crypto->SHA2_init(bits);
@@ -62,8 +61,7 @@ std::string @@ -62,8 +61,7 @@ std::string
62 Pl_SHA2::getRawDigest() 61 Pl_SHA2::getRawDigest()
63 { 62 {
64 if (this->in_progress) { 63 if (this->in_progress) {
65 - throw std::logic_error(  
66 - "digest requested for in-progress SHA2 Pipeline"); 64 + throw std::logic_error("digest requested for in-progress SHA2 Pipeline");
67 } 65 }
68 return this->crypto->SHA2_digest(); 66 return this->crypto->SHA2_digest();
69 } 67 }
@@ -72,8 +70,7 @@ std::string @@ -72,8 +70,7 @@ std::string
72 Pl_SHA2::getHexDigest() 70 Pl_SHA2::getHexDigest()
73 { 71 {
74 if (this->in_progress) { 72 if (this->in_progress) {
75 - throw std::logic_error(  
76 - "digest requested for in-progress SHA2 Pipeline"); 73 + throw std::logic_error("digest requested for in-progress SHA2 Pipeline");
77 } 74 }
78 return QUtil::hex_encode(getRawDigest()); 75 return QUtil::hex_encode(getRawDigest());
79 } 76 }
libqpdf/Pl_StdioFile.cc
@@ -30,8 +30,7 @@ Pl_StdioFile::write(unsigned char const* buf, size_t len) @@ -30,8 +30,7 @@ Pl_StdioFile::write(unsigned char const* buf, size_t len)
30 while (len > 0) { 30 while (len > 0) {
31 so_far = fwrite(buf, 1, len, m->file); 31 so_far = fwrite(buf, 1, len, m->file);
32 if (so_far == 0) { 32 if (so_far == 0) {
33 - QUtil::throw_system_error(  
34 - this->identifier + ": Pl_StdioFile::write"); 33 + QUtil::throw_system_error(this->identifier + ": Pl_StdioFile::write");
35 } else { 34 } else {
36 buf += so_far; 35 buf += so_far;
37 len -= so_far; 36 len -= so_far;
@@ -43,7 +42,6 @@ void @@ -43,7 +42,6 @@ void
43 Pl_StdioFile::finish() 42 Pl_StdioFile::finish()
44 { 43 {
45 if ((fflush(m->file) == -1) && (errno == EBADF)) { 44 if ((fflush(m->file) == -1) && (errno == EBADF)) {
46 - throw std::logic_error(  
47 - this->identifier + ": Pl_StdioFile::finish: stream already closed"); 45 + throw std::logic_error(this->identifier + ": Pl_StdioFile::finish: stream already closed");
48 } 46 }
49 } 47 }
libqpdf/Pl_TIFFPredictor.cc
@@ -25,23 +25,17 @@ Pl_TIFFPredictor::Pl_TIFFPredictor( @@ -25,23 +25,17 @@ Pl_TIFFPredictor::Pl_TIFFPredictor(
25 pos(0) 25 pos(0)
26 { 26 {
27 if (samples_per_pixel < 1) { 27 if (samples_per_pixel < 1) {
28 - throw std::runtime_error(  
29 - "TIFFPredictor created with invalid samples_per_pixel"); 28 + throw std::runtime_error("TIFFPredictor created with invalid samples_per_pixel");
30 } 29 }
31 - if ((bits_per_sample < 1) ||  
32 - (bits_per_sample > (8 * (sizeof(unsigned long long))))) {  
33 - throw std::runtime_error(  
34 - "TIFFPredictor created with invalid bits_per_sample"); 30 + if ((bits_per_sample < 1) || (bits_per_sample > (8 * (sizeof(unsigned long long))))) {
  31 + throw std::runtime_error("TIFFPredictor created with invalid bits_per_sample");
35 } 32 }
36 - unsigned long long bpr =  
37 - ((columns * bits_per_sample * samples_per_pixel) + 7) / 8; 33 + unsigned long long bpr = ((columns * bits_per_sample * samples_per_pixel) + 7) / 8;
38 if ((bpr == 0) || (bpr > (UINT_MAX - 1))) { 34 if ((bpr == 0) || (bpr > (UINT_MAX - 1))) {
39 - throw std::runtime_error(  
40 - "TIFFPredictor created with invalid columns value"); 35 + throw std::runtime_error("TIFFPredictor created with invalid columns value");
41 } 36 }
42 this->bytes_per_row = bpr & UINT_MAX; 37 this->bytes_per_row = bpr & UINT_MAX;
43 - this->cur_row =  
44 - QUtil::make_shared_array<unsigned char>(this->bytes_per_row); 38 + this->cur_row = QUtil::make_shared_array<unsigned char>(this->bytes_per_row);
45 memset(this->cur_row.get(), 0, this->bytes_per_row); 39 memset(this->cur_row.get(), 0, this->bytes_per_row);
46 } 40 }
47 41
@@ -72,10 +66,7 @@ Pl_TIFFPredictor::write(unsigned char const* data, size_t len) @@ -72,10 +66,7 @@ Pl_TIFFPredictor::write(unsigned char const* data, size_t len)
72 void 66 void
73 Pl_TIFFPredictor::processRow() 67 Pl_TIFFPredictor::processRow()
74 { 68 {
75 - QTC::TC(  
76 - "libtests",  
77 - "Pl_TIFFPredictor processRow",  
78 - (action == a_decode ? 0 : 1)); 69 + QTC::TC("libtests", "Pl_TIFFPredictor processRow", (action == a_decode ? 0 : 1));
79 BitWriter bw(this->getNext()); 70 BitWriter bw(this->getNext());
80 BitStream in(this->cur_row.get(), this->bytes_per_row); 71 BitStream in(this->cur_row.get(), this->bytes_per_row);
81 std::vector<long long> prev; 72 std::vector<long long> prev;
libqpdf/QPDF.cc
@@ -105,11 +105,10 @@ namespace @@ -105,11 +105,10 @@ namespace
105 void 105 void
106 throwException() 106 throwException()
107 { 107 {
108 - throw std::logic_error(  
109 - "QPDF operation attempted on a QPDF object with no input "  
110 - "source."  
111 - " QPDF operations are invalid before processFile (or another"  
112 - " process method) or after closeInputSource"); 108 + throw std::logic_error("QPDF operation attempted on a QPDF object with no input "
  109 + "source."
  110 + " QPDF operations are invalid before processFile (or another"
  111 + " process method) or after closeInputSource");
113 } 112 }
114 }; 113 };
115 } // namespace 114 } // namespace
@@ -130,8 +129,7 @@ QPDF::ForeignStreamData::ForeignStreamData( @@ -130,8 +129,7 @@ QPDF::ForeignStreamData::ForeignStreamData(
130 { 129 {
131 } 130 }
132 131
133 -QPDF::CopiedStreamDataProvider::CopiedStreamDataProvider(  
134 - QPDF& destination_qpdf) : 132 +QPDF::CopiedStreamDataProvider::CopiedStreamDataProvider(QPDF& destination_qpdf) :
135 QPDFObjectHandle::StreamDataProvider(true), 133 QPDFObjectHandle::StreamDataProvider(true),
136 destination_qpdf(destination_qpdf) 134 destination_qpdf(destination_qpdf)
137 { 135 {
@@ -139,10 +137,7 @@ QPDF::CopiedStreamDataProvider::CopiedStreamDataProvider( @@ -139,10 +137,7 @@ QPDF::CopiedStreamDataProvider::CopiedStreamDataProvider(
139 137
140 bool 138 bool
141 QPDF::CopiedStreamDataProvider::provideStreamData( 139 QPDF::CopiedStreamDataProvider::provideStreamData(
142 - QPDFObjGen const& og,  
143 - Pipeline* pipeline,  
144 - bool suppress_warnings,  
145 - bool will_retry) 140 + QPDFObjGen const& og, Pipeline* pipeline, bool suppress_warnings, bool will_retry)
146 { 141 {
147 std::shared_ptr<ForeignStreamData> foreign_data = foreign_stream_data[og]; 142 std::shared_ptr<ForeignStreamData> foreign_data = foreign_stream_data[og];
148 bool result = false; 143 bool result = false;
@@ -154,8 +149,7 @@ QPDF::CopiedStreamDataProvider::provideStreamData( @@ -154,8 +149,7 @@ QPDF::CopiedStreamDataProvider::provideStreamData(
154 auto foreign_stream = foreign_streams[og]; 149 auto foreign_stream = foreign_streams[og];
155 result = foreign_stream.pipeStreamData( 150 result = foreign_stream.pipeStreamData(
156 pipeline, nullptr, 0, qpdf_dl_none, suppress_warnings, will_retry); 151 pipeline, nullptr, 0, qpdf_dl_none, suppress_warnings, will_retry);
157 - QTC::TC(  
158 - "qpdf", "QPDF copy foreign with foreign_stream", result ? 0 : 1); 152 + QTC::TC("qpdf", "QPDF copy foreign with foreign_stream", result ? 0 : 1);
159 } 153 }
160 return result; 154 return result;
161 } 155 }
@@ -169,8 +163,7 @@ QPDF::CopiedStreamDataProvider::registerForeignStream( @@ -169,8 +163,7 @@ QPDF::CopiedStreamDataProvider::registerForeignStream(
169 163
170 void 164 void
171 QPDF::CopiedStreamDataProvider::registerForeignStream( 165 QPDF::CopiedStreamDataProvider::registerForeignStream(
172 - QPDFObjGen const& local_og,  
173 - std::shared_ptr<ForeignStreamData> foreign_stream) 166 + QPDFObjGen const& local_og, std::shared_ptr<ForeignStreamData> foreign_stream)
174 { 167 {
175 this->foreign_stream_data[local_og] = foreign_stream; 168 this->foreign_stream_data[local_og] = foreign_stream;
176 } 169 }
@@ -269,8 +262,7 @@ QPDF::processFile(char const* filename, char const* password) @@ -269,8 +262,7 @@ QPDF::processFile(char const* filename, char const* password)
269 } 262 }
270 263
271 void 264 void
272 -QPDF::processFile(  
273 - char const* description, FILE* filep, bool close_file, char const* password) 265 +QPDF::processFile(char const* description, FILE* filep, bool close_file, char const* password)
274 { 266 {
275 auto* fi = new FileInputSource(description, filep, close_file); 267 auto* fi = new FileInputSource(description, filep, close_file);
276 processInputSource(std::shared_ptr<InputSource>(fi), password); 268 processInputSource(std::shared_ptr<InputSource>(fi), password);
@@ -278,24 +270,18 @@ QPDF::processFile( @@ -278,24 +270,18 @@ QPDF::processFile(
278 270
279 void 271 void
280 QPDF::processMemoryFile( 272 QPDF::processMemoryFile(
281 - char const* description,  
282 - char const* buf,  
283 - size_t length,  
284 - char const* password) 273 + char const* description, char const* buf, size_t length, char const* password)
285 { 274 {
286 processInputSource( 275 processInputSource(
287 std::shared_ptr<InputSource>( 276 std::shared_ptr<InputSource>(
288 // line-break 277 // line-break
289 new BufferInputSource( 278 new BufferInputSource(
290 - description,  
291 - new Buffer(QUtil::unsigned_char_pointer(buf), length),  
292 - true)), 279 + description, new Buffer(QUtil::unsigned_char_pointer(buf), length), true)),
293 password); 280 password);
294 } 281 }
295 282
296 void 283 void
297 -QPDF::processInputSource(  
298 - std::shared_ptr<InputSource> source, char const* password) 284 +QPDF::processInputSource(std::shared_ptr<InputSource> source, char const* password)
299 { 285 {
300 m->file = source; 286 m->file = source;
301 parse(password); 287 parse(password);
@@ -321,8 +307,7 @@ QPDF::emptyPDF() @@ -321,8 +307,7 @@ QPDF::emptyPDF()
321 307
322 void 308 void
323 QPDF::registerStreamFilter( 309 QPDF::registerStreamFilter(
324 - std::string const& filter_name,  
325 - std::function<std::shared_ptr<QPDFStreamFilter>()> factory) 310 + std::string const& filter_name, std::function<std::shared_ptr<QPDFStreamFilter>()> factory)
326 { 311 {
327 QPDF_Stream::registerStreamFilter(filter_name, factory); 312 QPDF_Stream::registerStreamFilter(filter_name, factory);
328 } 313 }
@@ -434,8 +419,7 @@ QPDF::findHeader() @@ -434,8 +419,7 @@ QPDF::findHeader()
434 // offsets in the file are such that 0 points to the 419 // offsets in the file are such that 0 points to the
435 // beginning of the header. 420 // beginning of the header.
436 QTC::TC("qpdf", "QPDF global offset"); 421 QTC::TC("qpdf", "QPDF global offset");
437 - m->file = std::shared_ptr<InputSource>(  
438 - new OffsetInputSource(m->file, global_offset)); 422 + m->file = std::shared_ptr<InputSource>(new OffsetInputSource(m->file, global_offset));
439 } 423 }
440 } 424 }
441 return valid; 425 return valid;
@@ -444,8 +428,7 @@ QPDF::findHeader() @@ -444,8 +428,7 @@ QPDF::findHeader()
444 bool 428 bool
445 QPDF::findStartxref() 429 QPDF::findStartxref()
446 { 430 {
447 - if (readToken(m->file).isWord("startxref") &&  
448 - readToken(m->file).isInteger()) { 431 + if (readToken(m->file).isWord("startxref") && readToken(m->file).isInteger()) {
449 // Position in front of offset token 432 // Position in front of offset token
450 m->file->seek(m->file->getLastOffset(), SEEK_SET); 433 m->file->seek(m->file->getLastOffset(), SEEK_SET);
451 return true; 434 return true;
@@ -479,8 +462,7 @@ QPDF::parse(char const* password) @@ -479,8 +462,7 @@ QPDF::parse(char const* password)
479 PatternFinder sf(*this, &QPDF::findStartxref); 462 PatternFinder sf(*this, &QPDF::findStartxref);
480 qpdf_offset_t xref_offset = 0; 463 qpdf_offset_t xref_offset = 0;
481 if (m->file->findLast("startxref", start_offset, 0, sf)) { 464 if (m->file->findLast("startxref", start_offset, 0, sf)) {
482 - xref_offset =  
483 - QUtil::string_to_ll(readToken(m->file).getValue().c_str()); 465 + xref_offset = QUtil::string_to_ll(readToken(m->file).getValue().c_str());
484 } 466 }
485 467
486 try { 468 try {
@@ -493,8 +475,7 @@ QPDF::parse(char const* password) @@ -493,8 +475,7 @@ QPDF::parse(char const* password)
493 } catch (QPDFExc&) { 475 } catch (QPDFExc&) {
494 throw; 476 throw;
495 } catch (std::exception& e) { 477 } catch (std::exception& e) {
496 - throw damagedPDF(  
497 - "", 0, std::string("error reading xref: ") + e.what()); 478 + throw damagedPDF("", 0, std::string("error reading xref: ") + e.what());
498 } 479 }
499 } catch (QPDFExc& e) { 480 } catch (QPDFExc& e) {
500 if (m->attempt_recovery) { 481 if (m->attempt_recovery) {
@@ -515,9 +496,8 @@ QPDF::inParse(bool v) @@ -515,9 +496,8 @@ QPDF::inParse(bool v)
515 if (m->in_parse == v) { 496 if (m->in_parse == v) {
516 // This happens if QPDFParser::parse tries to 497 // This happens if QPDFParser::parse tries to
517 // resolve an indirect object while it is parsing. 498 // resolve an indirect object while it is parsing.
518 - throw std::logic_error(  
519 - "QPDF: re-entrant parsing detected. This is a qpdf bug."  
520 - " Please report at https://github.com/qpdf/qpdf/issues."); 499 + throw std::logic_error("QPDF: re-entrant parsing detected. This is a qpdf bug."
  500 + " Please report at https://github.com/qpdf/qpdf/issues.");
521 } 501 }
522 m->in_parse = v; 502 m->in_parse = v;
523 } 503 }
@@ -590,22 +570,19 @@ QPDF::reconstruct_xref(QPDFExc&amp; e) @@ -590,22 +570,19 @@ QPDF::reconstruct_xref(QPDFExc&amp; e)
590 qpdf_offset_t next_line_start = m->file->tell(); 570 qpdf_offset_t next_line_start = m->file->tell();
591 m->file->seek(line_start, SEEK_SET); 571 m->file->seek(line_start, SEEK_SET);
592 QPDFTokenizer::Token t1 = readToken(m->file, MAX_LEN); 572 QPDFTokenizer::Token t1 = readToken(m->file, MAX_LEN);
593 - qpdf_offset_t token_start =  
594 - m->file->tell() - toO(t1.getValue().length()); 573 + qpdf_offset_t token_start = m->file->tell() - toO(t1.getValue().length());
595 if (token_start >= next_line_start) { 574 if (token_start >= next_line_start) {
596 // don't process yet -- wait until we get to the line 575 // don't process yet -- wait until we get to the line
597 // containing this token 576 // containing this token
598 } else if (t1.isInteger()) { 577 } else if (t1.isInteger()) {
599 QPDFTokenizer::Token t2 = readToken(m->file, MAX_LEN); 578 QPDFTokenizer::Token t2 = readToken(m->file, MAX_LEN);
600 - if ((t2.isInteger()) &&  
601 - (readToken(m->file, MAX_LEN).isWord("obj"))) { 579 + if ((t2.isInteger()) && (readToken(m->file, MAX_LEN).isWord("obj"))) {
602 int obj = QUtil::string_to_int(t1.getValue().c_str()); 580 int obj = QUtil::string_to_int(t1.getValue().c_str());
603 int gen = QUtil::string_to_int(t2.getValue().c_str()); 581 int gen = QUtil::string_to_int(t2.getValue().c_str());
604 insertXrefEntry(obj, 1, token_start, gen, true); 582 insertXrefEntry(obj, 1, token_start, gen, true);
605 } 583 }
606 } else if (!m->trailer.isInitialized() && t1.isWord("trailer")) { 584 } else if (!m->trailer.isInitialized() && t1.isWord("trailer")) {
607 - QPDFObjectHandle t =  
608 - readObject(m->file, "trailer", QPDFObjGen(), false); 585 + QPDFObjectHandle t = readObject(m->file, "trailer", QPDFObjGen(), false);
609 if (!t.isDictionary()) { 586 if (!t.isDictionary()) {
610 // Oh well. It was worth a try. 587 // Oh well. It was worth a try.
611 } else { 588 } else {
@@ -623,10 +600,7 @@ QPDF::reconstruct_xref(QPDFExc&amp; e) @@ -623,10 +600,7 @@ QPDF::reconstruct_xref(QPDFExc&amp; e)
623 // with bad startxref pointers even when they have object 600 // with bad startxref pointers even when they have object
624 // streams. 601 // streams.
625 602
626 - throw damagedPDF(  
627 - "",  
628 - 0,  
629 - "unable to find trailer dictionary while recovering damaged file"); 603 + throw damagedPDF("", 0, "unable to find trailer dictionary while recovering damaged file");
630 } 604 }
631 605
632 // We could iterate through the objects looking for streams and 606 // We could iterate through the objects looking for streams and
@@ -666,10 +640,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) @@ -666,10 +640,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
666 done = true; 640 done = true;
667 } 641 }
668 } else { 642 } else {
669 - QTC::TC(  
670 - "qpdf",  
671 - "QPDF eof skipping spaces before xref",  
672 - skipped_space ? 0 : 1); 643 + QTC::TC("qpdf", "QPDF eof skipping spaces before xref", skipped_space ? 0 : 1);
673 done = true; 644 done = true;
674 } 645 }
675 } 646 }
@@ -681,8 +652,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) @@ -681,8 +652,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
681 if ((strncmp(buf, "xref", 4) == 0) && QUtil::is_space(buf[4])) { 652 if ((strncmp(buf, "xref", 4) == 0) && QUtil::is_space(buf[4])) {
682 if (skipped_space) { 653 if (skipped_space) {
683 QTC::TC("qpdf", "QPDF xref skipped space"); 654 QTC::TC("qpdf", "QPDF xref skipped space");
684 - warn(damagedPDF(  
685 - "", 0, "extraneous whitespace seen before xref")); 655 + warn(damagedPDF("", 0, "extraneous whitespace seen before xref"));
686 } 656 }
687 QTC::TC( 657 QTC::TC(
688 "qpdf", 658 "qpdf",
@@ -724,8 +694,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset) @@ -724,8 +694,7 @@ QPDF::read_xref(qpdf_offset_t xref_offset)
724 "", 694 "",
725 0, 695 0,
726 ("reported number of objects (" + std::to_string(size) + 696 ("reported number of objects (" + std::to_string(size) +
727 - ") is not one plus the highest object number (" +  
728 - std::to_string(max_obj) + ")"))); 697 + ") is not one plus the highest object number (" + std::to_string(max_obj) + ")")));
729 } 698 }
730 699
731 // We no longer need the deleted_objects table, so go ahead and 700 // We no longer need the deleted_objects table, so go ahead and
@@ -782,8 +751,7 @@ QPDF::parse_xrefFirst(std::string const&amp; line, int&amp; obj, int&amp; num, int&amp; bytes) @@ -782,8 +751,7 @@ QPDF::parse_xrefFirst(std::string const&amp; line, int&amp; obj, int&amp; num, int&amp; bytes)
782 } 751 }
783 752
784 bool 753 bool
785 -QPDF::parse_xrefEntry(  
786 - std::string const& line, qpdf_offset_t& f1, int& f2, char& type) 754 +QPDF::parse_xrefEntry(std::string const& line, qpdf_offset_t& f1, int& f2, char& type)
787 { 755 {
788 // is_space and is_digit both return false on '\0', so this will 756 // is_space and is_digit both return false on '\0', so this will
789 // not overrun the null-terminated buffer. 757 // not overrun the null-terminated buffer.
@@ -891,8 +859,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset) @@ -891,8 +859,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
891 if (!parse_xrefEntry(xref_entry, f1, f2, type)) { 859 if (!parse_xrefEntry(xref_entry, f1, f2, type)) {
892 QTC::TC("qpdf", "QPDF invalid xref entry"); 860 QTC::TC("qpdf", "QPDF invalid xref entry");
893 throw damagedPDF( 861 throw damagedPDF(
894 - "xref table",  
895 - "invalid xref entry (obj=" + std::to_string(i) + ")"); 862 + "xref table", "invalid xref entry (obj=" + std::to_string(i) + ")");
896 } 863 }
897 if (type == 'f') { 864 if (type == 'f') {
898 // Save deleted items until after we've checked the 865 // Save deleted items until after we've checked the
@@ -911,8 +878,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset) @@ -911,8 +878,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
911 } 878 }
912 879
913 // Set offset to previous xref table if any 880 // Set offset to previous xref table if any
914 - QPDFObjectHandle cur_trailer =  
915 - readObject(m->file, "trailer", QPDFObjGen(), false); 881 + QPDFObjectHandle cur_trailer = readObject(m->file, "trailer", QPDFObjGen(), false);
916 if (!cur_trailer.isDictionary()) { 882 if (!cur_trailer.isDictionary()) {
917 QTC::TC("qpdf", "QPDF missing trailer"); 883 QTC::TC("qpdf", "QPDF missing trailer");
918 throw damagedPDF("", "expected trailer dictionary"); 884 throw damagedPDF("", "expected trailer dictionary");
@@ -927,8 +893,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset) @@ -927,8 +893,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
927 } 893 }
928 if (!m->trailer.getKey("/Size").isInteger()) { 894 if (!m->trailer.getKey("/Size").isInteger()) {
929 QTC::TC("qpdf", "QPDF trailer size not integer"); 895 QTC::TC("qpdf", "QPDF trailer size not integer");
930 - throw damagedPDF(  
931 - "trailer", "/Size key in trailer dictionary is not an integer"); 896 + throw damagedPDF("trailer", "/Size key in trailer dictionary is not an integer");
932 } 897 }
933 } 898 }
934 899
@@ -940,11 +905,9 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset) @@ -940,11 +905,9 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
940 // Read the xref stream but disregard any return value 905 // Read the xref stream but disregard any return value
941 // -- we'll use our trailer's /Prev key instead of the 906 // -- we'll use our trailer's /Prev key instead of the
942 // xref stream's. 907 // xref stream's.
943 - (void)read_xrefStream(  
944 - cur_trailer.getKey("/XRefStm").getIntValue()); 908 + (void)read_xrefStream(cur_trailer.getKey("/XRefStm").getIntValue());
945 } else { 909 } else {
946 - throw damagedPDF(  
947 - "xref stream", xref_offset, "invalid /XRefStm"); 910 + throw damagedPDF("xref stream", xref_offset, "invalid /XRefStm");
948 } 911 }
949 } 912 }
950 } 913 }
@@ -957,8 +920,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset) @@ -957,8 +920,7 @@ QPDF::read_xrefTable(qpdf_offset_t xref_offset)
957 if (cur_trailer.hasKey("/Prev")) { 920 if (cur_trailer.hasKey("/Prev")) {
958 if (!cur_trailer.getKey("/Prev").isInteger()) { 921 if (!cur_trailer.getKey("/Prev").isInteger()) {
959 QTC::TC("qpdf", "QPDF trailer prev not integer"); 922 QTC::TC("qpdf", "QPDF trailer prev not integer");
960 - throw damagedPDF(  
961 - "trailer", "/Prev key in trailer dictionary is not an integer"); 923 + throw damagedPDF("trailer", "/Prev key in trailer dictionary is not an integer");
962 } 924 }
963 QTC::TC("qpdf", "QPDF prev key in trailer dictionary"); 925 QTC::TC("qpdf", "QPDF prev key in trailer dictionary");
964 xref_offset = cur_trailer.getKey("/Prev").getIntValue(); 926 xref_offset = cur_trailer.getKey("/Prev").getIntValue();
@@ -977,13 +939,8 @@ QPDF::read_xrefStream(qpdf_offset_t xref_offset) @@ -977,13 +939,8 @@ QPDF::read_xrefStream(qpdf_offset_t xref_offset)
977 QPDFObjGen x_og; 939 QPDFObjGen x_og;
978 QPDFObjectHandle xref_obj; 940 QPDFObjectHandle xref_obj;
979 try { 941 try {
980 - xref_obj = readObjectAtOffset(  
981 - false,  
982 - xref_offset,  
983 - "xref stream",  
984 - QPDFObjGen(0, 0),  
985 - x_og,  
986 - true); 942 + xref_obj =
  943 + readObjectAtOffset(false, xref_offset, "xref stream", QPDFObjGen(0, 0), x_og, true);
987 } catch (QPDFExc&) { 944 } catch (QPDFExc&) {
988 // ignore -- report error below 945 // ignore -- report error below
989 } 946 }
@@ -1008,12 +965,9 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj) @@ -1008,12 +965,9 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1008 QPDFObjectHandle dict = xref_obj.getDict(); 965 QPDFObjectHandle dict = xref_obj.getDict();
1009 QPDFObjectHandle W_obj = dict.getKey("/W"); 966 QPDFObjectHandle W_obj = dict.getKey("/W");
1010 QPDFObjectHandle Index_obj = dict.getKey("/Index"); 967 QPDFObjectHandle Index_obj = dict.getKey("/Index");
1011 - if (!(W_obj.isArray() && (W_obj.getArrayNItems() >= 3) &&  
1012 - W_obj.getArrayItem(0).isInteger() &&  
1013 - W_obj.getArrayItem(1).isInteger() &&  
1014 - W_obj.getArrayItem(2).isInteger() &&  
1015 - dict.getKey("/Size").isInteger() &&  
1016 - (Index_obj.isArray() || Index_obj.isNull()))) { 968 + if (!(W_obj.isArray() && (W_obj.getArrayNItems() >= 3) && W_obj.getArrayItem(0).isInteger() &&
  969 + W_obj.getArrayItem(1).isInteger() && W_obj.getArrayItem(2).isInteger() &&
  970 + dict.getKey("/Size").isInteger() && (Index_obj.isArray() || Index_obj.isNull()))) {
1017 throw damagedPDF( 971 throw damagedPDF(
1018 "xref stream", 972 "xref stream",
1019 xref_offset, 973 xref_offset,
@@ -1035,12 +989,9 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj) @@ -1035,12 +989,9 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1035 } 989 }
1036 if (entry_size == 0) { 990 if (entry_size == 0) {
1037 throw damagedPDF( 991 throw damagedPDF(
1038 - "xref stream",  
1039 - xref_offset,  
1040 - "Cross-reference stream's /W indicates entry size of 0"); 992 + "xref stream", xref_offset, "Cross-reference stream's /W indicates entry size of 0");
1041 } 993 }
1042 - unsigned long long max_num_entries =  
1043 - static_cast<unsigned long long>(-1) / entry_size; 994 + unsigned long long max_num_entries = static_cast<unsigned long long>(-1) / entry_size;
1044 995
1045 std::vector<long long> indx; 996 std::vector<long long> indx;
1046 if (Index_obj.isArray()) { 997 if (Index_obj.isArray()) {
@@ -1059,8 +1010,8 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj) @@ -1059,8 +1010,8 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1059 throw damagedPDF( 1010 throw damagedPDF(
1060 "xref stream", 1011 "xref stream",
1061 xref_offset, 1012 xref_offset,
1062 - ("Cross-reference stream's /Index's item " +  
1063 - std::to_string(i) + " is not an integer")); 1013 + ("Cross-reference stream's /Index's item " + std::to_string(i) +
  1014 + " is not an integer"));
1064 } 1015 }
1065 } 1016 }
1066 QTC::TC("qpdf", "QPDF xref /Index is array", n_index == 2 ? 0 : 1); 1017 QTC::TC("qpdf", "QPDF xref /Index is array", n_index == 2 ? 0 : 1);
@@ -1078,8 +1029,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj) @@ -1078,8 +1029,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1078 "xref stream", 1029 "xref stream",
1079 xref_offset, 1030 xref_offset,
1080 ("Cross-reference stream claims to contain too many entries: " + 1031 ("Cross-reference stream claims to contain too many entries: " +
1081 - std::to_string(indx.at(i)) + " " +  
1082 - std::to_string(max_num_entries) + " " + 1032 + std::to_string(indx.at(i)) + " " + std::to_string(max_num_entries) + " " +
1083 std::to_string(num_entries))); 1033 std::to_string(num_entries)));
1084 } 1034 }
1085 num_entries += toS(indx.at(i)); 1035 num_entries += toS(indx.at(i));
@@ -1097,8 +1047,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj) @@ -1097,8 +1047,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1097 "xref stream", 1047 "xref stream",
1098 xref_offset, 1048 xref_offset,
1099 ("Cross-reference stream data has the wrong size; expected = " + 1049 ("Cross-reference stream data has the wrong size; expected = " +
1100 - std::to_string(expected_size) +  
1101 - "; actual = " + std::to_string(actual_size))); 1050 + std::to_string(expected_size) + "; actual = " + std::to_string(actual_size)));
1102 if (expected_size > actual_size) { 1051 if (expected_size > actual_size) {
1103 throw x; 1052 throw x;
1104 } else { 1053 } else {
@@ -1137,8 +1086,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj) @@ -1137,8 +1086,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1137 // an uncompressed object record, in which case the generation 1086 // an uncompressed object record, in which case the generation
1138 // number appears as the third field. 1087 // number appears as the third field.
1139 int obj = toI(indx.at(cur_chunk)); 1088 int obj = toI(indx.at(cur_chunk));
1140 - if ((obj < 0) ||  
1141 - ((std::numeric_limits<int>::max() - obj) < chunk_count)) { 1089 + if ((obj < 0) || ((std::numeric_limits<int>::max() - obj) < chunk_count)) {
1142 std::ostringstream msg; 1090 std::ostringstream msg;
1143 msg.imbue(std::locale::classic()); 1091 msg.imbue(std::locale::classic());
1144 msg << "adding " << chunk_count << " to " << obj 1092 msg << "adding " << chunk_count << " to " << obj
@@ -1181,8 +1129,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj) @@ -1181,8 +1129,7 @@ QPDF::processXRefStream(qpdf_offset_t xref_offset, QPDFObjectHandle&amp; xref_obj)
1181 if (dict.hasKey("/Prev")) { 1129 if (dict.hasKey("/Prev")) {
1182 if (!dict.getKey("/Prev").isInteger()) { 1130 if (!dict.getKey("/Prev").isInteger()) {
1183 throw damagedPDF( 1131 throw damagedPDF(
1184 - "xref stream",  
1185 - "/Prev key in xref stream dictionary is not an integer"); 1132 + "xref stream", "/Prev key in xref stream dictionary is not an integer");
1186 } 1133 }
1187 QTC::TC("qpdf", "QPDF prev key in xref stream dictionary"); 1134 QTC::TC("qpdf", "QPDF prev key in xref stream dictionary");
1188 xref_offset = dict.getKey("/Prev").getIntValue(); 1135 xref_offset = dict.getKey("/Prev").getIntValue();
@@ -1241,9 +1188,7 @@ QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite) @@ -1241,9 +1188,7 @@ QPDF::insertXrefEntry(int obj, int f0, qpdf_offset_t f1, int f2, bool overwrite)
1241 break; 1188 break;
1242 1189
1243 default: 1190 default:
1244 - throw damagedPDF(  
1245 - "xref stream",  
1246 - "unknown xref stream entry type " + std::to_string(f0)); 1191 + throw damagedPDF("xref stream", "unknown xref stream entry type " + std::to_string(f0));
1247 break; 1192 break;
1248 } 1193 }
1249 } 1194 }
@@ -1262,9 +1207,8 @@ QPDF::showXRefTable() @@ -1262,9 +1207,8 @@ QPDF::showXRefTable()
1262 break; 1207 break;
1263 1208
1264 case 2: 1209 case 2:
1265 - *m->log->getInfo()  
1266 - << "compressed; stream = " << entry.getObjStreamNumber()  
1267 - << ", index = " << entry.getObjStreamIndex(); 1210 + *m->log->getInfo() << "compressed; stream = " << entry.getObjStreamNumber()
  1211 + << ", index = " << entry.getObjStreamIndex();
1268 break; 1212 break;
1269 1213
1270 default: 1214 default:
@@ -1337,8 +1281,7 @@ QPDF::getAllObjects() @@ -1337,8 +1281,7 @@ QPDF::getAllObjects()
1337 } 1281 }
1338 1282
1339 void 1283 void
1340 -QPDF::setLastObjectDescription(  
1341 - std::string const& description, QPDFObjGen const& og) 1284 +QPDF::setLastObjectDescription(std::string const& description, QPDFObjGen const& og)
1342 { 1285 {
1343 m->last_object_description.clear(); 1286 m->last_object_description.clear();
1344 if (!description.empty()) { 1287 if (!description.empty()) {
@@ -1369,16 +1312,13 @@ QPDF::readObject( @@ -1369,16 +1312,13 @@ QPDF::readObject(
1369 decrypter_ph = std::make_shared<StringDecrypter>(this, og); 1312 decrypter_ph = std::make_shared<StringDecrypter>(this, og);
1370 decrypter = decrypter_ph.get(); 1313 decrypter = decrypter_ph.get();
1371 } 1314 }
1372 - auto object =  
1373 - QPDFParser(  
1374 - input, m->last_object_description, m->tokenizer, decrypter, this)  
1375 - .parse(empty, false); 1315 + auto object = QPDFParser(input, m->last_object_description, m->tokenizer, decrypter, this)
  1316 + .parse(empty, false);
1376 if (empty) { 1317 if (empty) {
1377 // Nothing in the PDF spec appears to allow empty objects, but 1318 // Nothing in the PDF spec appears to allow empty objects, but
1378 // they have been encountered in actual PDF files and Adobe 1319 // they have been encountered in actual PDF files and Adobe
1379 // Reader appears to ignore them. 1320 // Reader appears to ignore them.
1380 - warn(damagedPDF(  
1381 - input, input->getLastOffset(), "empty object treated as null")); 1321 + warn(damagedPDF(input, input->getLastOffset(), "empty object treated as null"));
1382 } else if (object.isDictionary() && (!in_object_stream)) { 1322 } else if (object.isDictionary() && (!in_object_stream)) {
1383 // check for stream 1323 // check for stream
1384 qpdf_offset_t cur_offset = input->tell(); 1324 qpdf_offset_t cur_offset = input->tell();
@@ -1428,9 +1368,7 @@ QPDF::readObject( @@ -1428,9 +1368,7 @@ QPDF::readObject(
1428 } 1368 }
1429 } else if (QUtil::is_space(ch)) { 1369 } else if (QUtil::is_space(ch)) {
1430 warn(damagedPDF( 1370 warn(damagedPDF(
1431 - input,  
1432 - input->tell(),  
1433 - "stream keyword followed by extraneous whitespace")); 1371 + input, input->tell(), "stream keyword followed by extraneous whitespace"));
1434 done = false; 1372 done = false;
1435 } else { 1373 } else {
1436 QTC::TC("qpdf", "QPDF stream without newline"); 1374 QTC::TC("qpdf", "QPDF stream without newline");
@@ -1450,13 +1388,11 @@ QPDF::readObject( @@ -1450,13 +1388,11 @@ QPDF::readObject(
1450 size_t length = 0; 1388 size_t length = 0;
1451 1389
1452 try { 1390 try {
1453 - std::map<std::string, QPDFObjectHandle> dict =  
1454 - object.getDictAsMap(); 1391 + std::map<std::string, QPDFObjectHandle> dict = object.getDictAsMap();
1455 1392
1456 if (dict.count("/Length") == 0) { 1393 if (dict.count("/Length") == 0) {
1457 QTC::TC("qpdf", "QPDF stream without length"); 1394 QTC::TC("qpdf", "QPDF stream without length");
1458 - throw damagedPDF(  
1459 - input, offset, "stream dictionary lacks /Length key"); 1395 + throw damagedPDF(input, offset, "stream dictionary lacks /Length key");
1460 } 1396 }
1461 1397
1462 QPDFObjectHandle length_obj = dict["/Length"]; 1398 QPDFObjectHandle length_obj = dict["/Length"];
@@ -1475,8 +1411,7 @@ QPDF::readObject( @@ -1475,8 +1411,7 @@ QPDF::readObject(
1475 input->seek(toO(length), SEEK_CUR); 1411 input->seek(toO(length), SEEK_CUR);
1476 if (!readToken(input).isWord("endstream")) { 1412 if (!readToken(input).isWord("endstream")) {
1477 QTC::TC("qpdf", "QPDF missing endstream"); 1413 QTC::TC("qpdf", "QPDF missing endstream");
1478 - throw damagedPDF(  
1479 - input, input->getLastOffset(), "expected endstream"); 1414 + throw damagedPDF(input, input->getLastOffset(), "expected endstream");
1480 } 1415 }
1481 } catch (QPDFExc& e) { 1416 } catch (QPDFExc& e) {
1482 if (m->attempt_recovery) { 1417 if (m->attempt_recovery) {
@@ -1486,9 +1421,7 @@ QPDF::readObject( @@ -1486,9 +1421,7 @@ QPDF::readObject(
1486 throw; 1421 throw;
1487 } 1422 }
1488 } 1423 }
1489 - object = newIndirect(  
1490 - og,  
1491 - QPDF_Stream::create(this, og, object, stream_offset, length)); 1424 + object = newIndirect(og, QPDF_Stream::create(this, og, object, stream_offset, length));
1492 } else { 1425 } else {
1493 input->seek(cur_offset, SEEK_SET); 1426 input->seek(cur_offset, SEEK_SET);
1494 } 1427 }
@@ -1514,14 +1447,11 @@ QPDF::findEndstream() @@ -1514,14 +1447,11 @@ QPDF::findEndstream()
1514 1447
1515 size_t 1448 size_t
1516 QPDF::recoverStreamLength( 1449 QPDF::recoverStreamLength(
1517 - std::shared_ptr<InputSource> input,  
1518 - QPDFObjGen const& og,  
1519 - qpdf_offset_t stream_offset) 1450 + std::shared_ptr<InputSource> input, QPDFObjGen const& og, qpdf_offset_t stream_offset)
1520 { 1451 {
1521 // Try to reconstruct stream length by looking for 1452 // Try to reconstruct stream length by looking for
1522 // endstream or endobj 1453 // endstream or endobj
1523 - warn(damagedPDF(  
1524 - input, stream_offset, "attempting to recover stream length")); 1454 + warn(damagedPDF(input, stream_offset, "attempting to recover stream length"));
1525 1455
1526 PatternFinder ef(*this, &QPDF::findEndstream); 1456 PatternFinder ef(*this, &QPDF::findEndstream);
1527 size_t length = 0; 1457 size_t length = 0;
@@ -1544,8 +1474,7 @@ QPDF::recoverStreamLength( @@ -1544,8 +1474,7 @@ QPDF::recoverStreamLength(
1544 if (entry.getType() == 1) { 1474 if (entry.getType() == 1) {
1545 qpdf_offset_t obj_offset = entry.getOffset(); 1475 qpdf_offset_t obj_offset = entry.getOffset();
1546 if ((obj_offset > stream_offset) && 1476 if ((obj_offset > stream_offset) &&
1547 - ((this_obj_offset == 0) ||  
1548 - (this_obj_offset > obj_offset))) { 1477 + ((this_obj_offset == 0) || (this_obj_offset > obj_offset))) {
1549 this_obj_offset = obj_offset; 1478 this_obj_offset = obj_offset;
1550 this_og = iter.first; 1479 this_og = iter.first;
1551 } 1480 }
@@ -1562,14 +1491,10 @@ QPDF::recoverStreamLength( @@ -1562,14 +1491,10 @@ QPDF::recoverStreamLength(
1562 1491
1563 if (length == 0) { 1492 if (length == 0) {
1564 warn(damagedPDF( 1493 warn(damagedPDF(
1565 - input,  
1566 - stream_offset,  
1567 - "unable to recover stream data; treating stream as empty")); 1494 + input, stream_offset, "unable to recover stream data; treating stream as empty"));
1568 } else { 1495 } else {
1569 - warn(damagedPDF(  
1570 - input,  
1571 - stream_offset,  
1572 - "recovered stream length: " + std::to_string(length))); 1496 + warn(
  1497 + damagedPDF(input, stream_offset, "recovered stream length: " + std::to_string(length)));
1573 } 1498 }
1574 1499
1575 QTC::TC("qpdf", "QPDF recovered stream length"); 1500 QTC::TC("qpdf", "QPDF recovered stream length");
@@ -1579,8 +1504,7 @@ QPDF::recoverStreamLength( @@ -1579,8 +1504,7 @@ QPDF::recoverStreamLength(
1579 QPDFTokenizer::Token 1504 QPDFTokenizer::Token
1580 QPDF::readToken(std::shared_ptr<InputSource> input, size_t max_len) 1505 QPDF::readToken(std::shared_ptr<InputSource> input, size_t max_len)
1581 { 1506 {
1582 - return m->tokenizer.readToken(  
1583 - input, m->last_object_description, true, max_len); 1507 + return m->tokenizer.readToken(input, m->last_object_description, true, max_len);
1584 } 1508 }
1585 1509
1586 QPDFObjectHandle 1510 QPDFObjectHandle
@@ -1650,8 +1574,7 @@ QPDF::readObjectAtOffset( @@ -1650,8 +1574,7 @@ QPDF::readObjectAtOffset(
1650 } 1574 }
1651 if (check_og && (exp_og != og)) { 1575 if (check_og && (exp_og != og)) {
1652 QTC::TC("qpdf", "QPDF err wrong objid/generation"); 1576 QTC::TC("qpdf", "QPDF err wrong objid/generation");
1653 - QPDFExc e =  
1654 - damagedPDF(offset, "expected " + exp_og.unparse(' ') + " obj"); 1577 + QPDFExc e = damagedPDF(offset, "expected " + exp_og.unparse(' ') + " obj");
1655 if (try_recovery) { 1578 if (try_recovery) {
1656 // Will be retried below 1579 // Will be retried below
1657 throw e; 1580 throw e;
@@ -1665,11 +1588,10 @@ QPDF::readObjectAtOffset( @@ -1665,11 +1588,10 @@ QPDF::readObjectAtOffset(
1665 if (try_recovery) { 1588 if (try_recovery) {
1666 // Try again after reconstructing xref table 1589 // Try again after reconstructing xref table
1667 reconstruct_xref(e); 1590 reconstruct_xref(e);
1668 - if (m->xref_table.count(exp_og) &&  
1669 - (m->xref_table[exp_og].getType() == 1)) { 1591 + if (m->xref_table.count(exp_og) && (m->xref_table[exp_og].getType() == 1)) {
1670 qpdf_offset_t new_offset = m->xref_table[exp_og].getOffset(); 1592 qpdf_offset_t new_offset = m->xref_table[exp_og].getOffset();
1671 - QPDFObjectHandle result = readObjectAtOffset(  
1672 - false, new_offset, description, exp_og, og, false); 1593 + QPDFObjectHandle result =
  1594 + readObjectAtOffset(false, new_offset, description, exp_og, og, false);
1673 QTC::TC("qpdf", "QPDF recovered in readObjectAtOffset"); 1595 QTC::TC("qpdf", "QPDF recovered in readObjectAtOffset");
1674 return result; 1596 return result;
1675 } else { 1597 } else {
@@ -1777,8 +1699,7 @@ QPDF::resolve(QPDFObjGen og) @@ -1777,8 +1699,7 @@ QPDF::resolve(QPDFObjGen og)
1777 // indirectly in some key that has to be resolved during 1699 // indirectly in some key that has to be resolved during
1778 // object parsing, such as stream length. 1700 // object parsing, such as stream length.
1779 QTC::TC("qpdf", "QPDF recursion loop in resolve"); 1701 QTC::TC("qpdf", "QPDF recursion loop in resolve");
1780 - warn(damagedPDF(  
1781 - "", "loop detected resolving object " + og.unparse(' '))); 1702 + warn(damagedPDF("", "loop detected resolving object " + og.unparse(' ')));
1782 updateCache(og, QPDF_Null::create(), -1, -1); 1703 updateCache(og, QPDF_Null::create(), -1, -1);
1783 return; 1704 return;
1784 } 1705 }
@@ -1793,8 +1714,7 @@ QPDF::resolve(QPDFObjGen og) @@ -1793,8 +1714,7 @@ QPDF::resolve(QPDFObjGen og)
1793 qpdf_offset_t offset = entry.getOffset(); 1714 qpdf_offset_t offset = entry.getOffset();
1794 // Object stored in cache by readObjectAtOffset 1715 // Object stored in cache by readObjectAtOffset
1795 QPDFObjGen a_og; 1716 QPDFObjGen a_og;
1796 - QPDFObjectHandle oh =  
1797 - readObjectAtOffset(true, offset, "", og, a_og, false); 1717 + QPDFObjectHandle oh = readObjectAtOffset(true, offset, "", og, a_og, false);
1798 } 1718 }
1799 break; 1719 break;
1800 1720
@@ -1804,19 +1724,13 @@ QPDF::resolve(QPDFObjGen og) @@ -1804,19 +1724,13 @@ QPDF::resolve(QPDFObjGen og)
1804 1724
1805 default: 1725 default:
1806 throw damagedPDF( 1726 throw damagedPDF(
1807 - "",  
1808 - 0,  
1809 - ("object " + og.unparse('/') +  
1810 - " has unexpected xref entry type")); 1727 + "", 0, ("object " + og.unparse('/') + " has unexpected xref entry type"));
1811 } 1728 }
1812 } catch (QPDFExc& e) { 1729 } catch (QPDFExc& e) {
1813 warn(e); 1730 warn(e);
1814 } catch (std::exception& e) { 1731 } catch (std::exception& e) {
1815 warn(damagedPDF( 1732 warn(damagedPDF(
1816 - "",  
1817 - 0,  
1818 - ("object " + og.unparse('/') +  
1819 - ": error reading object: " + e.what()))); 1733 + "", 0, ("object " + og.unparse('/') + ": error reading object: " + e.what())));
1820 } 1734 }
1821 } 1735 }
1822 1736
@@ -1841,8 +1755,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) @@ -1841,8 +1755,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1841 QPDFObjectHandle obj_stream = getObjectByID(obj_stream_number, 0); 1755 QPDFObjectHandle obj_stream = getObjectByID(obj_stream_number, 0);
1842 if (!obj_stream.isStream()) { 1756 if (!obj_stream.isStream()) {
1843 throw damagedPDF( 1757 throw damagedPDF(
1844 - "supposed object stream " + std::to_string(obj_stream_number) +  
1845 - " is not a stream"); 1758 + "supposed object stream " + std::to_string(obj_stream_number) + " is not a stream");
1846 } 1759 }
1847 1760
1848 // For linearization data in the object, use the data from the 1761 // For linearization data in the object, use the data from the
@@ -1855,14 +1768,12 @@ QPDF::resolveObjectsInStream(int obj_stream_number) @@ -1855,14 +1768,12 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1855 if (!dict.isDictionaryOfType("/ObjStm")) { 1768 if (!dict.isDictionaryOfType("/ObjStm")) {
1856 QTC::TC("qpdf", "QPDF ERR object stream with wrong type"); 1769 QTC::TC("qpdf", "QPDF ERR object stream with wrong type");
1857 warn(damagedPDF( 1770 warn(damagedPDF(
1858 - "supposed object stream " + std::to_string(obj_stream_number) +  
1859 - " has wrong type")); 1771 + "supposed object stream " + std::to_string(obj_stream_number) + " has wrong type"));
1860 } 1772 }
1861 1773
1862 if (!(dict.getKey("/N").isInteger() && dict.getKey("/First").isInteger())) { 1774 if (!(dict.getKey("/N").isInteger() && dict.getKey("/First").isInteger())) {
1863 throw damagedPDF( 1775 throw damagedPDF(
1864 - ("object stream " + std::to_string(obj_stream_number) +  
1865 - " has incorrect keys")); 1776 + ("object stream " + std::to_string(obj_stream_number) + " has incorrect keys"));
1866 } 1777 }
1867 1778
1868 int n = dict.getKey("/N").getIntValueAsInt(); 1779 int n = dict.getKey("/N").getIntValueAsInt();
@@ -1874,8 +1785,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) @@ -1874,8 +1785,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1874 auto input = std::shared_ptr<InputSource>( 1785 auto input = std::shared_ptr<InputSource>(
1875 // line-break 1786 // line-break
1876 new BufferInputSource( 1787 new BufferInputSource(
1877 - (m->file->getName() + " object stream " +  
1878 - std::to_string(obj_stream_number)), 1788 + (m->file->getName() + " object stream " + std::to_string(obj_stream_number)),
1879 bp.get())); 1789 bp.get()));
1880 1790
1881 for (int i = 0; i < n; ++i) { 1791 for (int i = 0; i < n; ++i) {
@@ -1902,8 +1812,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number) @@ -1902,8 +1812,7 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
1902 for (auto const& iter: offsets) { 1812 for (auto const& iter: offsets) {
1903 QPDFObjGen og(iter.first, 0); 1813 QPDFObjGen og(iter.first, 0);
1904 QPDFXRefEntry const& entry = m->xref_table[og]; 1814 QPDFXRefEntry const& entry = m->xref_table[og];
1905 - if ((entry.getType() == 2) &&  
1906 - (entry.getObjStreamNumber() == obj_stream_number)) { 1815 + if ((entry.getType() == 2) && (entry.getObjStreamNumber() == obj_stream_number)) {
1907 int offset = iter.second; 1816 int offset = iter.second;
1908 input->seek(offset, SEEK_SET); 1817 input->seek(offset, SEEK_SET);
1909 QPDFObjectHandle oh = readObject(input, "", og, true); 1818 QPDFObjectHandle oh = readObject(input, "", og, true);
@@ -1956,8 +1865,7 @@ QPDF::nextObjGen() @@ -1956,8 +1865,7 @@ QPDF::nextObjGen()
1956 { 1865 {
1957 int max_objid = toI(getObjectCount()); 1866 int max_objid = toI(getObjectCount());
1958 if (max_objid == std::numeric_limits<int>::max()) { 1867 if (max_objid == std::numeric_limits<int>::max()) {
1959 - throw std::range_error(  
1960 - "max object id is too high to create new objects"); 1868 + throw std::range_error("max object id is too high to create new objects");
1961 } 1869 }
1962 return QPDFObjGen(max_objid + 1, 0); 1870 return QPDFObjGen(max_objid + 1, 0);
1963 } 1871 }
@@ -1974,8 +1882,7 @@ QPDFObjectHandle @@ -1974,8 +1882,7 @@ QPDFObjectHandle
1974 QPDF::makeIndirectObject(QPDFObjectHandle oh) 1882 QPDF::makeIndirectObject(QPDFObjectHandle oh)
1975 { 1883 {
1976 if (!oh.isInitialized()) { 1884 if (!oh.isInitialized()) {
1977 - throw std::logic_error(  
1978 - "attempted to make an uninitialized QPDFObjectHandle indirect"); 1885 + throw std::logic_error("attempted to make an uninitialized QPDFObjectHandle indirect");
1979 } 1886 }
1980 return makeIndirectFromQPDFObject(oh.getObj()); 1887 return makeIndirectFromQPDFObject(oh.getObj());
1981 } 1888 }
@@ -1989,16 +1896,15 @@ QPDF::newReserved() @@ -1989,16 +1896,15 @@ QPDF::newReserved()
1989 QPDFObjectHandle 1896 QPDFObjectHandle
1990 QPDF::newStream() 1897 QPDF::newStream()
1991 { 1898 {
1992 - return makeIndirectFromQPDFObject(QPDF_Stream::create(  
1993 - this, nextObjGen(), QPDFObjectHandle::newDictionary(), 0, 0)); 1899 + return makeIndirectFromQPDFObject(
  1900 + QPDF_Stream::create(this, nextObjGen(), QPDFObjectHandle::newDictionary(), 0, 0));
1994 } 1901 }
1995 1902
1996 QPDFObjectHandle 1903 QPDFObjectHandle
1997 QPDF::newStream(std::shared_ptr<Buffer> data) 1904 QPDF::newStream(std::shared_ptr<Buffer> data)
1998 { 1905 {
1999 auto result = newStream(); 1906 auto result = newStream();
2000 - result.replaceStreamData(  
2001 - data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); 1907 + result.replaceStreamData(data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
2002 return result; 1908 return result;
2003 } 1909 }
2004 1910
@@ -2006,8 +1912,7 @@ QPDFObjectHandle @@ -2006,8 +1912,7 @@ QPDFObjectHandle
2006 QPDF::newStream(std::string const& data) 1912 QPDF::newStream(std::string const& data)
2007 { 1913 {
2008 auto result = newStream(); 1914 auto result = newStream();
2009 - result.replaceStreamData(  
2010 - data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); 1915 + result.replaceStreamData(data, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
2011 return result; 1916 return result;
2012 } 1917 }
2013 1918
@@ -2025,8 +1930,7 @@ QPDF::reserveObjectIfNotExists(QPDFObjGen const&amp; og) @@ -2025,8 +1930,7 @@ QPDF::reserveObjectIfNotExists(QPDFObjGen const&amp; og)
2025 QPDFObjectHandle 1930 QPDFObjectHandle
2026 QPDF::reserveStream(QPDFObjGen const& og) 1931 QPDF::reserveStream(QPDFObjGen const& og)
2027 { 1932 {
2028 - return {  
2029 - QPDF_Stream::create(this, og, QPDFObjectHandle::newDictionary(), 0, 0)}; 1933 + return {QPDF_Stream::create(this, og, QPDFObjectHandle::newDictionary(), 0, 0)};
2030 } 1934 }
2031 1935
2032 QPDFObjectHandle 1936 QPDFObjectHandle
@@ -2069,8 +1973,7 @@ QPDF::replaceObject(QPDFObjGen const&amp; og, QPDFObjectHandle oh) @@ -2069,8 +1973,7 @@ QPDF::replaceObject(QPDFObjGen const&amp; og, QPDFObjectHandle oh)
2069 { 1973 {
2070 if (oh.isIndirect() || !oh.isInitialized()) { 1974 if (oh.isIndirect() || !oh.isInitialized()) {
2071 QTC::TC("qpdf", "QPDF replaceObject called with indirect object"); 1975 QTC::TC("qpdf", "QPDF replaceObject called with indirect object");
2072 - throw std::logic_error(  
2073 - "QPDF::replaceObject called with indirect object handle"); 1976 + throw std::logic_error("QPDF::replaceObject called with indirect object handle");
2074 } 1977 }
2075 updateCache(og, oh.getObj(), -1, -1); 1978 updateCache(og, oh.getObj(), -1, -1);
2076 } 1979 }
@@ -2132,14 +2035,12 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign) @@ -2132,14 +2035,12 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign)
2132 // the intention is to not update the pages tree. 2035 // the intention is to not update the pages tree.
2133 if (!foreign.isIndirect()) { 2036 if (!foreign.isIndirect()) {
2134 QTC::TC("qpdf", "QPDF copyForeign direct"); 2037 QTC::TC("qpdf", "QPDF copyForeign direct");
2135 - throw std::logic_error(  
2136 - "QPDF::copyForeign called with direct object handle"); 2038 + throw std::logic_error("QPDF::copyForeign called with direct object handle");
2137 } 2039 }
2138 QPDF& other = foreign.getQPDF(); 2040 QPDF& other = foreign.getQPDF();
2139 if (&other == this) { 2041 if (&other == this) {
2140 QTC::TC("qpdf", "QPDF copyForeign not foreign"); 2042 QTC::TC("qpdf", "QPDF copyForeign not foreign");
2141 - throw std::logic_error(  
2142 - "QPDF::copyForeign called with object from this QPDF"); 2043 + throw std::logic_error("QPDF::copyForeign called with object from this QPDF");
2143 } 2044 }
2144 2045
2145 ObjCopier& obj_copier = m->object_copiers[other.m->unique_id]; 2046 ObjCopier& obj_copier = m->object_copiers[other.m->unique_id];
@@ -2163,8 +2064,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign) @@ -2163,8 +2064,7 @@ QPDF::copyForeignObject(QPDFObjectHandle foreign)
2163 2064
2164 // Copy any new objects and replace the reservations. 2065 // Copy any new objects and replace the reservations.
2165 for (auto& to_copy: obj_copier.to_copy) { 2066 for (auto& to_copy: obj_copier.to_copy) {
2166 - QPDFObjectHandle copy =  
2167 - replaceForeignIndirectObjects(to_copy, obj_copier, true); 2067 + QPDFObjectHandle copy = replaceForeignIndirectObjects(to_copy, obj_copier, true);
2168 if (!to_copy.isStream()) { 2068 if (!to_copy.isStream()) {
2169 QPDFObjGen og(to_copy.getObjGen()); 2069 QPDFObjGen og(to_copy.getObjGen());
2170 replaceReserved(obj_copier.object_map[og], copy); 2070 replaceReserved(obj_copier.object_map[og], copy);
@@ -2180,8 +2080,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top) @@ -2180,8 +2080,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top)
2180 { 2080 {
2181 auto foreign_tc = foreign.getTypeCode(); 2081 auto foreign_tc = foreign.getTypeCode();
2182 if (foreign_tc == ::ot_reserved) { 2082 if (foreign_tc == ::ot_reserved) {
2183 - throw std::logic_error(  
2184 - "QPDF: attempting to copy a foreign reserved object"); 2083 + throw std::logic_error("QPDF: attempting to copy a foreign reserved object");
2185 } 2084 }
2186 2085
2187 if (foreign.isPagesObject()) { 2086 if (foreign.isPagesObject()) {
@@ -2209,8 +2108,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top) @@ -2209,8 +2108,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top)
2209 QTC::TC("qpdf", "QPDF copy indirect"); 2108 QTC::TC("qpdf", "QPDF copy indirect");
2210 if (obj_copier.object_map.count(foreign_og) == 0) { 2109 if (obj_copier.object_map.count(foreign_og) == 0) {
2211 obj_copier.to_copy.push_back(foreign); 2110 obj_copier.to_copy.push_back(foreign);
2212 - obj_copier.object_map[foreign_og] =  
2213 - foreign.isStream() ? newStream() : newReserved(); 2111 + obj_copier.object_map[foreign_og] = foreign.isStream() ? newStream() : newReserved();
2214 } 2112 }
2215 } 2113 }
2216 2114
@@ -2234,8 +2132,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top) @@ -2234,8 +2132,7 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier&amp; obj_copier, bool top)
2234 } 2132 }
2235 2133
2236 QPDFObjectHandle 2134 QPDFObjectHandle
2237 -QPDF::replaceForeignIndirectObjects(  
2238 - QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top) 2135 +QPDF::replaceForeignIndirectObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier, bool top)
2239 { 2136 {
2240 auto foreign_tc = foreign.getTypeCode(); 2137 auto foreign_tc = foreign.getTypeCode();
2241 QPDFObjectHandle result; 2138 QPDFObjectHandle result;
@@ -2257,8 +2154,7 @@ QPDF::replaceForeignIndirectObjects( @@ -2257,8 +2154,7 @@ QPDF::replaceForeignIndirectObjects(
2257 for (int i = 0; i < n; ++i) { 2154 for (int i = 0; i < n; ++i) {
2258 result.appendItem( 2155 result.appendItem(
2259 // line-break 2156 // line-break
2260 - replaceForeignIndirectObjects(  
2261 - foreign.getArrayItem(i), obj_copier, false)); 2157 + replaceForeignIndirectObjects(foreign.getArrayItem(i), obj_copier, false));
2262 } 2158 }
2263 } else if (foreign_tc == ::ot_dictionary) { 2159 } else if (foreign_tc == ::ot_dictionary) {
2264 QTC::TC("qpdf", "QPDF replace dictionary"); 2160 QTC::TC("qpdf", "QPDF replace dictionary");
@@ -2266,9 +2162,7 @@ QPDF::replaceForeignIndirectObjects( @@ -2266,9 +2162,7 @@ QPDF::replaceForeignIndirectObjects(
2266 std::set<std::string> keys = foreign.getKeys(); 2162 std::set<std::string> keys = foreign.getKeys();
2267 for (auto const& iter: keys) { 2163 for (auto const& iter: keys) {
2268 result.replaceKey( 2164 result.replaceKey(
2269 - iter,  
2270 - replaceForeignIndirectObjects(  
2271 - foreign.getKey(iter), obj_copier, false)); 2165 + iter, replaceForeignIndirectObjects(foreign.getKey(iter), obj_copier, false));
2272 } 2166 }
2273 } else if (foreign_tc == ::ot_stream) { 2167 } else if (foreign_tc == ::ot_stream) {
2274 QTC::TC("qpdf", "QPDF replace stream"); 2168 QTC::TC("qpdf", "QPDF replace stream");
@@ -2279,9 +2173,7 @@ QPDF::replaceForeignIndirectObjects( @@ -2279,9 +2173,7 @@ QPDF::replaceForeignIndirectObjects(
2279 std::set<std::string> keys = old_dict.getKeys(); 2173 std::set<std::string> keys = old_dict.getKeys();
2280 for (auto const& iter: keys) { 2174 for (auto const& iter: keys) {
2281 dict.replaceKey( 2175 dict.replaceKey(
2282 - iter,  
2283 - replaceForeignIndirectObjects(  
2284 - old_dict.getKey(iter), obj_copier, false)); 2176 + iter, replaceForeignIndirectObjects(old_dict.getKey(iter), obj_copier, false));
2285 } 2177 }
2286 copyStreamData(result, foreign); 2178 copyStreamData(result, foreign);
2287 } else { 2179 } else {
@@ -2309,8 +2201,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign) @@ -2309,8 +2201,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2309 if (m->copied_stream_data_provider == nullptr) { 2201 if (m->copied_stream_data_provider == nullptr) {
2310 m->copied_stream_data_provider = new CopiedStreamDataProvider(*this); 2202 m->copied_stream_data_provider = new CopiedStreamDataProvider(*this);
2311 m->copied_streams = 2203 m->copied_streams =
2312 - std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(  
2313 - m->copied_stream_data_provider); 2204 + std::shared_ptr<QPDFObjectHandle::StreamDataProvider>(m->copied_stream_data_provider);
2314 } 2205 }
2315 QPDFObjGen local_og(result.getObjGen()); 2206 QPDFObjGen local_og(result.getObjGen());
2316 // Copy information from the foreign stream so we can pipe its 2207 // Copy information from the foreign stream so we can pipe its
@@ -2325,8 +2216,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign) @@ -2325,8 +2216,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2325 " stream object from foreign stream"); 2216 " stream object from foreign stream");
2326 } 2217 }
2327 std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer(); 2218 std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer();
2328 - if ((foreign_stream_qpdf.m->immediate_copy_from) &&  
2329 - (stream_buffer == nullptr)) { 2219 + if ((foreign_stream_qpdf.m->immediate_copy_from) && (stream_buffer == nullptr)) {
2330 // Pull the stream data into a buffer before attempting 2220 // Pull the stream data into a buffer before attempting
2331 // the copy operation. Do it on the source stream so that 2221 // the copy operation. Do it on the source stream so that
2332 // if the source stream is copied multiple times, we don't 2222 // if the source stream is copied multiple times, we don't
@@ -2347,12 +2237,9 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign) @@ -2347,12 +2237,9 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2347 } else if (stream_provider.get()) { 2237 } else if (stream_provider.get()) {
2348 // In this case, the remote stream's QPDF must stay in scope. 2238 // In this case, the remote stream's QPDF must stay in scope.
2349 QTC::TC("qpdf", "QPDF copy foreign stream with provider"); 2239 QTC::TC("qpdf", "QPDF copy foreign stream with provider");
2350 - m->copied_stream_data_provider->registerForeignStream(  
2351 - local_og, foreign); 2240 + m->copied_stream_data_provider->registerForeignStream(local_og, foreign);
2352 result.replaceStreamData( 2241 result.replaceStreamData(
2353 - m->copied_streams,  
2354 - dict.getKey("/Filter"),  
2355 - dict.getKey("/DecodeParms")); 2242 + m->copied_streams, dict.getKey("/Filter"), dict.getKey("/DecodeParms"));
2356 } else { 2243 } else {
2357 auto foreign_stream_data = std::make_shared<ForeignStreamData>( 2244 auto foreign_stream_data = std::make_shared<ForeignStreamData>(
2358 foreign_stream_qpdf.m->encp, 2245 foreign_stream_qpdf.m->encp,
@@ -2361,20 +2248,16 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign) @@ -2361,20 +2248,16 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
2361 stream->getParsedOffset(), 2248 stream->getParsedOffset(),
2362 stream->getLength(), 2249 stream->getLength(),
2363 dict); 2250 dict);
2364 - m->copied_stream_data_provider->registerForeignStream(  
2365 - local_og, foreign_stream_data); 2251 + m->copied_stream_data_provider->registerForeignStream(local_og, foreign_stream_data);
2366 result.replaceStreamData( 2252 result.replaceStreamData(
2367 - m->copied_streams,  
2368 - dict.getKey("/Filter"),  
2369 - dict.getKey("/DecodeParms")); 2253 + m->copied_streams, dict.getKey("/Filter"), dict.getKey("/DecodeParms"));
2370 } 2254 }
2371 } 2255 }
2372 2256
2373 void 2257 void
2374 QPDF::swapObjects(int objid1, int generation1, int objid2, int generation2) 2258 QPDF::swapObjects(int objid1, int generation1, int objid2, int generation2)
2375 { 2259 {
2376 - swapObjects(  
2377 - QPDFObjGen(objid1, generation1), QPDFObjGen(objid2, generation2)); 2260 + swapObjects(QPDFObjGen(objid1, generation1), QPDFObjGen(objid2, generation2));
2378 } 2261 }
2379 2262
2380 void 2263 void
@@ -2519,8 +2402,7 @@ QPDF::getCompressibleObjGens() @@ -2519,8 +2402,7 @@ QPDF::getCompressibleObjGens()
2519 if (og == encryption_dict_og) { 2402 if (og == encryption_dict_og) {
2520 QTC::TC("qpdf", "QPDF exclude encryption dictionary"); 2403 QTC::TC("qpdf", "QPDF exclude encryption dictionary");
2521 } else if (!(obj.isStream() || 2404 } else if (!(obj.isStream() ||
2522 - (obj.isDictionaryOfType("/Sig") &&  
2523 - obj.hasKey("/ByteRange") && 2405 + (obj.isDictionaryOfType("/Sig") && obj.hasKey("/ByteRange") &&
2524 obj.hasKey("/Contents")))) { 2406 obj.hasKey("/Contents")))) {
2525 result.push_back(og); 2407 result.push_back(og);
2526 } 2408 }
@@ -2571,8 +2453,7 @@ QPDF::pipeStreamData( @@ -2571,8 +2453,7 @@ QPDF::pipeStreamData(
2571 { 2453 {
2572 std::vector<std::shared_ptr<Pipeline>> to_delete; 2454 std::vector<std::shared_ptr<Pipeline>> to_delete;
2573 if (encp->encrypted) { 2455 if (encp->encrypted) {
2574 - decryptStream(  
2575 - encp, file, qpdf_for_warning, pipeline, og, stream_dict, to_delete); 2456 + decryptStream(encp, file, qpdf_for_warning, pipeline, og, stream_dict, to_delete);
2576 } 2457 }
2577 2458
2578 bool success = false; 2459 bool success = false;
@@ -2584,10 +2465,7 @@ QPDF::pipeStreamData( @@ -2584,10 +2465,7 @@ QPDF::pipeStreamData(
2584 size_t len = file->read(buf, to_read); 2465 size_t len = file->read(buf, to_read);
2585 if (len == 0) { 2466 if (len == 0) {
2586 throw damagedPDF( 2467 throw damagedPDF(
2587 - file,  
2588 - "",  
2589 - file->getLastOffset(),  
2590 - "unexpected EOF reading stream data"); 2468 + file, "", file->getLastOffset(), "unexpected EOF reading stream data");
2591 } 2469 }
2592 length -= len; 2470 length -= len;
2593 pipeline->write(buf, len); 2471 pipeline->write(buf, len);
@@ -2607,8 +2485,8 @@ QPDF::pipeStreamData( @@ -2607,8 +2485,8 @@ QPDF::pipeStreamData(
2607 file, 2485 file,
2608 "", 2486 "",
2609 file->getLastOffset(), 2487 file->getLastOffset(),
2610 - ("error decoding stream data for object " +  
2611 - og.unparse(' ') + ": " + e.what()))); 2488 + ("error decoding stream data for object " + og.unparse(' ') + ": " +
  2489 + e.what())));
2612 if (will_retry) { 2490 if (will_retry) {
2613 qpdf_for_warning.warn( 2491 qpdf_for_warning.warn(
2614 // line-break 2492 // line-break
@@ -2694,17 +2572,14 @@ QPDF::damagedPDF( @@ -2694,17 +2572,14 @@ QPDF::damagedPDF(
2694 qpdf_offset_t offset, 2572 qpdf_offset_t offset,
2695 std::string const& message) 2573 std::string const& message)
2696 { 2574 {
2697 - return QPDFExc(  
2698 - qpdf_e_damaged_pdf, input->getName(), object, offset, message); 2575 + return QPDFExc(qpdf_e_damaged_pdf, input->getName(), object, offset, message);
2699 } 2576 }
2700 2577
2701 // Return an exception of type qpdf_e_damaged_pdf. The object is taken from 2578 // Return an exception of type qpdf_e_damaged_pdf. The object is taken from
2702 // m->last_object_description. 2579 // m->last_object_description.
2703 QPDFExc 2580 QPDFExc
2704 QPDF::damagedPDF( 2581 QPDF::damagedPDF(
2705 - std::shared_ptr<InputSource> const& input,  
2706 - qpdf_offset_t offset,  
2707 - std::string const& message) 2582 + std::shared_ptr<InputSource> const& input, qpdf_offset_t offset, std::string const& message)
2708 { 2583 {
2709 return damagedPDF(input, m->last_object_description, offset, message); 2584 return damagedPDF(input, m->last_object_description, offset, message);
2710 } 2585 }
@@ -2712,11 +2587,9 @@ QPDF::damagedPDF( @@ -2712,11 +2587,9 @@ QPDF::damagedPDF(
2712 // Return an exception of type qpdf_e_damaged_pdf. The filename is taken from 2587 // Return an exception of type qpdf_e_damaged_pdf. The filename is taken from
2713 // m->file. 2588 // m->file.
2714 QPDFExc 2589 QPDFExc
2715 -QPDF::damagedPDF(  
2716 - std::string const& object, qpdf_offset_t offset, std::string const& message) 2590 +QPDF::damagedPDF(std::string const& object, qpdf_offset_t offset, std::string const& message)
2717 { 2591 {
2718 - return QPDFExc(  
2719 - qpdf_e_damaged_pdf, m->file->getName(), object, offset, message); 2592 + return QPDFExc(qpdf_e_damaged_pdf, m->file->getName(), object, offset, message);
2720 } 2593 }
2721 2594
2722 // Return an exception of type qpdf_e_damaged_pdf. The filename is taken from 2595 // Return an exception of type qpdf_e_damaged_pdf. The filename is taken from
@@ -2741,8 +2614,7 @@ QPDF::damagedPDF(qpdf_offset_t offset, std::string const&amp; message) @@ -2741,8 +2614,7 @@ QPDF::damagedPDF(qpdf_offset_t offset, std::string const&amp; message)
2741 QPDFExc 2614 QPDFExc
2742 QPDF::damagedPDF(std::string const& message) 2615 QPDF::damagedPDF(std::string const& message)
2743 { 2616 {
2744 - return damagedPDF(  
2745 - m->last_object_description, m->file->getLastOffset(), message); 2617 + return damagedPDF(m->last_object_description, m->file->getLastOffset(), message);
2746 } 2618 }
2747 2619
2748 bool 2620 bool
libqpdf/QPDFAcroFormDocumentHelper.cc
@@ -41,8 +41,7 @@ QPDFAcroFormDocumentHelper::getOrCreateAcroForm() @@ -41,8 +41,7 @@ QPDFAcroFormDocumentHelper::getOrCreateAcroForm()
41 auto acroform = this->qpdf.getRoot().getKey("/AcroForm"); 41 auto acroform = this->qpdf.getRoot().getKey("/AcroForm");
42 if (!acroform.isDictionary()) { 42 if (!acroform.isDictionary()) {
43 acroform = this->qpdf.getRoot().replaceKeyAndGetNew( 43 acroform = this->qpdf.getRoot().replaceKeyAndGetNew(
44 - "/AcroForm",  
45 - this->qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary())); 44 + "/AcroForm", this->qpdf.makeIndirectObject(QPDFObjectHandle::newDictionary()));
46 } 45 }
47 return acroform; 46 return acroform;
48 } 47 }
@@ -53,24 +52,20 @@ QPDFAcroFormDocumentHelper::addFormField(QPDFFormFieldObjectHelper ff) @@ -53,24 +52,20 @@ QPDFAcroFormDocumentHelper::addFormField(QPDFFormFieldObjectHelper ff)
53 auto acroform = getOrCreateAcroForm(); 52 auto acroform = getOrCreateAcroForm();
54 auto fields = acroform.getKey("/Fields"); 53 auto fields = acroform.getKey("/Fields");
55 if (!fields.isArray()) { 54 if (!fields.isArray()) {
56 - fields = acroform.replaceKeyAndGetNew(  
57 - "/Fields", QPDFObjectHandle::newArray()); 55 + fields = acroform.replaceKeyAndGetNew("/Fields", QPDFObjectHandle::newArray());
58 } 56 }
59 fields.appendItem(ff.getObjectHandle()); 57 fields.appendItem(ff.getObjectHandle());
60 QPDFObjGen::set visited; 58 QPDFObjGen::set visited;
61 - traverseField(  
62 - ff.getObjectHandle(), QPDFObjectHandle::newNull(), 0, visited); 59 + traverseField(ff.getObjectHandle(), QPDFObjectHandle::newNull(), 0, visited);
63 } 60 }
64 61
65 void 62 void
66 -QPDFAcroFormDocumentHelper::addAndRenameFormFields(  
67 - std::vector<QPDFObjectHandle> fields) 63 +QPDFAcroFormDocumentHelper::addAndRenameFormFields(std::vector<QPDFObjectHandle> fields)
68 { 64 {
69 analyze(); 65 analyze();
70 std::map<std::string, std::string> renames; 66 std::map<std::string, std::string> renames;
71 QPDFObjGen::set seen; 67 QPDFObjGen::set seen;
72 - for (std::list<QPDFObjectHandle> queue{fields.begin(), fields.end()};  
73 - !queue.empty(); 68 + for (std::list<QPDFObjectHandle> queue{fields.begin(), fields.end()}; !queue.empty();
74 queue.pop_front()) { 69 queue.pop_front()) {
75 auto& obj = queue.front(); 70 auto& obj = queue.front();
76 if (seen.add(obj)) { 71 if (seen.add(obj)) {
@@ -90,8 +85,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields( @@ -90,8 +85,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(
90 // at the end of the fully qualified name, appending to /T 85 // at the end of the fully qualified name, appending to /T
91 // has the effect of appending the same thing to the fully 86 // has the effect of appending the same thing to the fully
92 // qualified name. 87 // qualified name.
93 - std::string old_name =  
94 - QPDFFormFieldObjectHelper(obj).getFullyQualifiedName(); 88 + std::string old_name = QPDFFormFieldObjectHelper(obj).getFullyQualifiedName();
95 if (renames.count(old_name) == 0) { 89 if (renames.count(old_name) == 0) {
96 std::string new_name = old_name; 90 std::string new_name = old_name;
97 int suffix = 0; 91 int suffix = 0;
@@ -120,8 +114,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields( @@ -120,8 +114,7 @@ QPDFAcroFormDocumentHelper::addAndRenameFormFields(
120 } 114 }
121 115
122 void 116 void
123 -QPDFAcroFormDocumentHelper::removeFormFields(  
124 - std::set<QPDFObjGen> const& to_remove) 117 +QPDFAcroFormDocumentHelper::removeFormFields(std::set<QPDFObjGen> const& to_remove)
125 { 118 {
126 auto acroform = this->qpdf.getRoot().getKey("/AcroForm"); 119 auto acroform = this->qpdf.getRoot().getKey("/AcroForm");
127 if (!acroform.isDictionary()) { 120 if (!acroform.isDictionary()) {
@@ -162,8 +155,7 @@ QPDFAcroFormDocumentHelper::removeFormFields( @@ -162,8 +155,7 @@ QPDFAcroFormDocumentHelper::removeFormFields(
162 } 155 }
163 156
164 void 157 void
165 -QPDFAcroFormDocumentHelper::setFormFieldName(  
166 - QPDFFormFieldObjectHelper ff, std::string const& name) 158 +QPDFAcroFormDocumentHelper::setFormFieldName(QPDFFormFieldObjectHelper ff, std::string const& name)
167 { 159 {
168 ff.setFieldAttribute("/T", name); 160 ff.setFieldAttribute("/T", name);
169 QPDFObjGen::set visited; 161 QPDFObjGen::set visited;
@@ -257,8 +249,7 @@ QPDFAcroFormDocumentHelper::analyze() @@ -257,8 +249,7 @@ QPDFAcroFormDocumentHelper::analyze()
257 QPDFObjectHandle fields = acroform.getKey("/Fields"); 249 QPDFObjectHandle fields = acroform.getKey("/Fields");
258 if (!fields.isArray()) { 250 if (!fields.isArray()) {
259 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper fields not array"); 251 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper fields not array");
260 - acroform.warnIfPossible(  
261 - "/Fields key of /AcroForm dictionary is not an array; ignoring"); 252 + acroform.warnIfPossible("/Fields key of /AcroForm dictionary is not an array; ignoring");
262 fields = QPDFObjectHandle::newArray(); 253 fields = QPDFObjectHandle::newArray();
263 } 254 }
264 255
@@ -294,12 +285,10 @@ QPDFAcroFormDocumentHelper::analyze() @@ -294,12 +285,10 @@ QPDFAcroFormDocumentHelper::analyze()
294 // adding a self-contained annotation (merged with the 285 // adding a self-contained annotation (merged with the
295 // field dictionary) to the page's /Annots array and 286 // field dictionary) to the page's /Annots array and
296 // forgetting to also put it in /AcroForm. 287 // forgetting to also put it in /AcroForm.
297 - annot.warnIfPossible(  
298 - "this widget annotation is not"  
299 - " reachable from /AcroForm in the document catalog"); 288 + annot.warnIfPossible("this widget annotation is not"
  289 + " reachable from /AcroForm in the document catalog");
300 m->annotation_to_field[og] = QPDFFormFieldObjectHelper(annot); 290 m->annotation_to_field[og] = QPDFFormFieldObjectHelper(annot);
301 - m->field_to_annotations[og].push_back(  
302 - QPDFAnnotationObjectHelper(annot)); 291 + m->field_to_annotations[og].push_back(QPDFAnnotationObjectHelper(annot));
303 } 292 }
304 } 293 }
305 } 294 }
@@ -307,10 +296,7 @@ QPDFAcroFormDocumentHelper::analyze() @@ -307,10 +296,7 @@ QPDFAcroFormDocumentHelper::analyze()
307 296
308 void 297 void
309 QPDFAcroFormDocumentHelper::traverseField( 298 QPDFAcroFormDocumentHelper::traverseField(
310 - QPDFObjectHandle field,  
311 - QPDFObjectHandle parent,  
312 - int depth,  
313 - QPDFObjGen::set& visited) 299 + QPDFObjectHandle field, QPDFObjectHandle parent, int depth, QPDFObjGen::set& visited)
314 { 300 {
315 if (depth > 100) { 301 if (depth > 100) {
316 // Arbitrarily cut off recursion at a fixed depth to avoid 302 // Arbitrarily cut off recursion at a fixed depth to avoid
@@ -319,16 +305,14 @@ QPDFAcroFormDocumentHelper::traverseField( @@ -319,16 +305,14 @@ QPDFAcroFormDocumentHelper::traverseField(
319 } 305 }
320 if (!field.isIndirect()) { 306 if (!field.isIndirect()) {
321 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper direct field"); 307 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper direct field");
322 - field.warnIfPossible(  
323 - "encountered a direct object as a field or annotation while"  
324 - " traversing /AcroForm; ignoring field or annotation"); 308 + field.warnIfPossible("encountered a direct object as a field or annotation while"
  309 + " traversing /AcroForm; ignoring field or annotation");
325 return; 310 return;
326 } 311 }
327 if (!field.isDictionary()) { 312 if (!field.isDictionary()) {
328 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper non-dictionary field"); 313 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper non-dictionary field");
329 - field.warnIfPossible(  
330 - "encountered a non-dictionary as a field or annotation while"  
331 - " traversing /AcroForm; ignoring field or annotation"); 314 + field.warnIfPossible("encountered a non-dictionary as a field or annotation while"
  315 + " traversing /AcroForm; ignoring field or annotation");
332 return; 316 return;
333 } 317 }
334 QPDFObjGen og(field.getObjGen()); 318 QPDFObjGen og(field.getObjGen());
@@ -359,23 +343,17 @@ QPDFAcroFormDocumentHelper::traverseField( @@ -359,23 +343,17 @@ QPDFAcroFormDocumentHelper::traverseField(
359 if (field.hasKey("/Parent")) { 343 if (field.hasKey("/Parent")) {
360 is_field = true; 344 is_field = true;
361 } 345 }
362 - if (field.hasKey("/Subtype") || field.hasKey("/Rect") ||  
363 - field.hasKey("/AP")) { 346 + if (field.hasKey("/Subtype") || field.hasKey("/Rect") || field.hasKey("/AP")) {
364 is_annotation = true; 347 is_annotation = true;
365 } 348 }
366 } 349 }
367 350
368 - QTC::TC(  
369 - "qpdf", "QPDFAcroFormDocumentHelper field found", (depth == 0) ? 0 : 1);  
370 - QTC::TC(  
371 - "qpdf",  
372 - "QPDFAcroFormDocumentHelper annotation found",  
373 - (is_field ? 0 : 1)); 351 + QTC::TC("qpdf", "QPDFAcroFormDocumentHelper field found", (depth == 0) ? 0 : 1);
  352 + QTC::TC("qpdf", "QPDFAcroFormDocumentHelper annotation found", (is_field ? 0 : 1));
374 353
375 if (is_annotation) { 354 if (is_annotation) {
376 QPDFObjectHandle our_field = (is_field ? field : parent); 355 QPDFObjectHandle our_field = (is_field ? field : parent);
377 - m->field_to_annotations[our_field.getObjGen()].push_back(  
378 - QPDFAnnotationObjectHelper(field)); 356 + m->field_to_annotations[our_field.getObjGen()].push_back(QPDFAnnotationObjectHelper(field));
379 m->annotation_to_field[og] = QPDFFormFieldObjectHelper(our_field); 357 m->annotation_to_field[og] = QPDFFormFieldObjectHelper(our_field);
380 } 358 }
381 359
@@ -400,8 +378,7 @@ QPDFAcroFormDocumentHelper::getNeedAppearances() @@ -400,8 +378,7 @@ QPDFAcroFormDocumentHelper::getNeedAppearances()
400 { 378 {
401 bool result = false; 379 bool result = false;
402 QPDFObjectHandle acroform = this->qpdf.getRoot().getKey("/AcroForm"); 380 QPDFObjectHandle acroform = this->qpdf.getRoot().getKey("/AcroForm");
403 - if (acroform.isDictionary() &&  
404 - acroform.getKey("/NeedAppearances").isBool()) { 381 + if (acroform.isDictionary() && acroform.getKey("/NeedAppearances").isBool()) {
405 result = acroform.getKey("/NeedAppearances").getBoolValue(); 382 result = acroform.getKey("/NeedAppearances").getBoolValue();
406 } 383 }
407 return result; 384 return result;
@@ -418,8 +395,7 @@ QPDFAcroFormDocumentHelper::setNeedAppearances(bool val) @@ -418,8 +395,7 @@ QPDFAcroFormDocumentHelper::setNeedAppearances(bool val)
418 return; 395 return;
419 } 396 }
420 if (val) { 397 if (val) {
421 - acroform.replaceKey(  
422 - "/NeedAppearances", QPDFObjectHandle::newBool(true)); 398 + acroform.replaceKey("/NeedAppearances", QPDFObjectHandle::newBool(true));
423 } else { 399 } else {
424 acroform.removeKey("/NeedAppearances"); 400 acroform.removeKey("/NeedAppearances");
425 } 401 }
@@ -472,8 +448,7 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields( @@ -472,8 +448,7 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields(
472 // we may be put a value on the field that is unused. This is 448 // we may be put a value on the field that is unused. This is
473 // harmless, so it's not worth trying to work around. 449 // harmless, so it's not worth trying to work around.
474 450
475 - auto has_explicit = [](QPDFFormFieldObjectHelper& field,  
476 - std::string const& key) { 451 + auto has_explicit = [](QPDFFormFieldObjectHelper& field, std::string const& key) {
477 if (field.getObjectHandle().hasKey(key)) { 452 if (field.getObjectHandle().hasKey(key)) {
478 return true; 453 return true;
479 } 454 }
@@ -490,16 +465,14 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields( @@ -490,16 +465,14 @@ QPDFAcroFormDocumentHelper::adjustInheritedFields(
490 std::string da = cur_field.getDefaultAppearance(); 465 std::string da = cur_field.getDefaultAppearance();
491 if (da != from_default_da) { 466 if (da != from_default_da) {
492 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override da"); 467 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override da");
493 - obj.replaceKey(  
494 - "/DA", QPDFObjectHandle::newUnicodeString(from_default_da)); 468 + obj.replaceKey("/DA", QPDFObjectHandle::newUnicodeString(from_default_da));
495 } 469 }
496 } 470 }
497 if (override_q && (!has_explicit(cur_field, "/Q"))) { 471 if (override_q && (!has_explicit(cur_field, "/Q"))) {
498 int q = cur_field.getQuadding(); 472 int q = cur_field.getQuadding();
499 if (q != from_default_q) { 473 if (q != from_default_q) {
500 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override q"); 474 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper override q");
501 - obj.replaceKey(  
502 - "/Q", QPDFObjectHandle::newInteger(from_default_q)); 475 + obj.replaceKey("/Q", QPDFObjectHandle::newInteger(from_default_q));
503 } 476 }
504 } 477 }
505 } 478 }
@@ -511,11 +484,8 @@ namespace @@ -511,11 +484,8 @@ namespace
511 { 484 {
512 public: 485 public:
513 ResourceReplacer( 486 ResourceReplacer(
514 - std::map<std::string, std::map<std::string, std::string>> const&  
515 - dr_map,  
516 - std::map<  
517 - std::string,  
518 - std::map<std::string, std::set<size_t>>> const& rnames); 487 + std::map<std::string, std::map<std::string, std::string>> const& dr_map,
  488 + std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames);
519 virtual ~ResourceReplacer() = default; 489 virtual ~ResourceReplacer() = default;
520 virtual void handleToken(QPDFTokenizer::Token const&) override; 490 virtual void handleToken(QPDFTokenizer::Token const&) override;
521 491
@@ -527,8 +497,7 @@ namespace @@ -527,8 +497,7 @@ namespace
527 497
528 ResourceReplacer::ResourceReplacer( 498 ResourceReplacer::ResourceReplacer(
529 std::map<std::string, std::map<std::string, std::string>> const& dr_map, 499 std::map<std::string, std::map<std::string, std::string>> const& dr_map,
530 - std::map<std::string, std::map<std::string, std::set<size_t>>> const&  
531 - rnames) : 500 + std::map<std::string, std::map<std::string, std::set<size_t>>> const& rnames) :
532 offset(0) 501 offset(0)
533 { 502 {
534 // We have: 503 // We have:
@@ -564,8 +533,7 @@ ResourceReplacer::handleToken(QPDFTokenizer::Token const&amp; token) @@ -564,8 +533,7 @@ ResourceReplacer::handleToken(QPDFTokenizer::Token const&amp; token)
564 { 533 {
565 bool wrote = false; 534 bool wrote = false;
566 if (token.getType() == QPDFTokenizer::tt_name) { 535 if (token.getType() == QPDFTokenizer::tt_name) {
567 - std::string name =  
568 - QPDFObjectHandle::newName(token.getValue()).getName(); 536 + std::string name = QPDFObjectHandle::newName(token.getValue()).getName();
569 if (to_replace.count(name) && to_replace[name].count(offset)) { 537 if (to_replace.count(name) && to_replace[name].count(offset)) {
570 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper replaced DA token"); 538 QTC::TC("qpdf", "QPDFAcroFormDocumentHelper replaced DA token");
571 write(to_replace[name][offset]); 539 write(to_replace[name][offset]);
@@ -580,8 +548,7 @@ ResourceReplacer::handleToken(QPDFTokenizer::Token const&amp; token) @@ -580,8 +548,7 @@ ResourceReplacer::handleToken(QPDFTokenizer::Token const&amp; token)
580 548
581 void 549 void
582 QPDFAcroFormDocumentHelper::adjustDefaultAppearances( 550 QPDFAcroFormDocumentHelper::adjustDefaultAppearances(
583 - QPDFObjectHandle obj,  
584 - std::map<std::string, std::map<std::string, std::string>> const& dr_map) 551 + QPDFObjectHandle obj, std::map<std::string, std::map<std::string, std::string>> const& dr_map)
585 { 552 {
586 // This method is called on a field that has been copied from 553 // This method is called on a field that has been copied from
587 // another file but whose /DA still refers to resources in the 554 // another file but whose /DA still refers to resources in the
@@ -624,8 +591,7 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances( @@ -624,8 +591,7 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances(
624 // then filter it. We don't attach the stream to anything, so it 591 // then filter it. We don't attach the stream to anything, so it
625 // will get discarded. 592 // will get discarded.
626 ResourceFinder rf; 593 ResourceFinder rf;
627 - auto da_stream =  
628 - QPDFObjectHandle::newStream(&this->qpdf, DA.getUTF8Value()); 594 + auto da_stream = QPDFObjectHandle::newStream(&this->qpdf, DA.getUTF8Value());
629 try { 595 try {
630 auto nwarnings = this->qpdf.numWarnings(); 596 auto nwarnings = this->qpdf.numWarnings();
631 da_stream.parseAsContents(&rf); 597 da_stream.parseAsContents(&rf);
@@ -646,15 +612,13 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances( @@ -646,15 +612,13 @@ QPDFAcroFormDocumentHelper::adjustDefaultAppearances(
646 Pl_Buffer buf_pl("filtered DA"); 612 Pl_Buffer buf_pl("filtered DA");
647 da_stream.filterAsContents(&rr, &buf_pl); 613 da_stream.filterAsContents(&rr, &buf_pl);
648 auto buf = buf_pl.getBufferSharedPointer(); 614 auto buf = buf_pl.getBufferSharedPointer();
649 - std::string new_da(  
650 - reinterpret_cast<char*>(buf->getBuffer()), buf->getSize()); 615 + std::string new_da(reinterpret_cast<char*>(buf->getBuffer()), buf->getSize());
651 obj.replaceKey("/DA", QPDFObjectHandle::newString(new_da)); 616 obj.replaceKey("/DA", QPDFObjectHandle::newString(new_da));
652 } 617 }
653 618
654 void 619 void
655 QPDFAcroFormDocumentHelper::adjustAppearanceStream( 620 QPDFAcroFormDocumentHelper::adjustAppearanceStream(
656 - QPDFObjectHandle stream,  
657 - std::map<std::string, std::map<std::string, std::string>> dr_map) 621 + QPDFObjectHandle stream, std::map<std::string, std::map<std::string, std::string>> dr_map)
658 { 622 {
659 // We don't have to modify appearance streams or their resource 623 // We don't have to modify appearance streams or their resource
660 // dictionaries for them to display properly, but we need to do so 624 // dictionaries for them to display properly, but we need to do so
@@ -740,8 +704,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream( @@ -740,8 +704,7 @@ QPDFAcroFormDocumentHelper::adjustAppearanceStream(
740 } catch (std::exception& e) { 704 } catch (std::exception& e) {
741 // No way to reproduce in test suite right now since error 705 // No way to reproduce in test suite right now since error
742 // conditions are converted to warnings. 706 // conditions are converted to warnings.
743 - stream.warnIfPossible(  
744 - std::string("Unable to parse appearance stream: ") + e.what()); 707 + stream.warnIfPossible(std::string("Unable to parse appearance stream: ") + e.what());
745 } 708 }
746 } 709 }
747 710
@@ -839,8 +802,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( @@ -839,8 +802,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
839 } 802 }
840 dr.makeResourcesIndirect(this->qpdf); 803 dr.makeResourcesIndirect(this->qpdf);
841 if (!dr.isIndirect()) { 804 if (!dr.isIndirect()) {
842 - dr = acroform.replaceKeyAndGetNew(  
843 - "/DR", this->qpdf.makeIndirectObject(dr)); 805 + dr = acroform.replaceKeyAndGetNew("/DR", this->qpdf.makeIndirectObject(dr));
844 } 806 }
845 // Merge the other document's /DR, creating a conflict 807 // Merge the other document's /DR, creating a conflict
846 // map. mergeResources checks to make sure both objects 808 // map. mergeResources checks to make sure both objects
@@ -969,8 +931,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( @@ -969,8 +931,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
969 obj.replaceKey("/Parent", orig_to_copy[parent_og]); 931 obj.replaceKey("/Parent", orig_to_copy[parent_og]);
970 } else { 932 } else {
971 parent.warnIfPossible( 933 parent.warnIfPossible(
972 - "while traversing field " +  
973 - obj.getObjGen().unparse(',') + 934 + "while traversing field " + obj.getObjGen().unparse(',') +
974 ", found parent (" + parent_og.unparse(',') + 935 ", found parent (" + parent_og.unparse(',') +
975 ") that had not been seen, indicating likely" 936 ") that had not been seen, indicating likely"
976 " invalid field structure"); 937 " invalid field structure");
@@ -989,11 +950,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( @@ -989,11 +950,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
989 950
990 if (override_da || override_q) { 951 if (override_da || override_q) {
991 adjustInheritedFields( 952 adjustInheritedFields(
992 - obj,  
993 - override_da,  
994 - from_default_da,  
995 - override_q,  
996 - from_default_q); 953 + obj, override_da, from_default_da, override_q, from_default_q);
997 } 954 }
998 if (foreign) { 955 if (foreign) {
999 // Lazily initialize our /DR and the conflict map. 956 // Lazily initialize our /DR and the conflict map.
@@ -1013,8 +970,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( @@ -1013,8 +970,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
1013 obj.replaceKey("/DR", dr); 970 obj.replaceKey("/DR", dr);
1014 } 971 }
1015 } 972 }
1016 - if (foreign && obj.getKey("/DA").isString() &&  
1017 - (!dr_map.empty())) { 973 + if (foreign && obj.getKey("/DA").isString() && (!dr_map.empty())) {
1018 adjustDefaultAppearances(obj, dr_map); 974 adjustDefaultAppearances(obj, dr_map);
1019 } 975 }
1020 } 976 }
@@ -1060,15 +1016,13 @@ QPDFAcroFormDocumentHelper::transformAnnotations( @@ -1060,15 +1016,13 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
1060 if (apdict.isDictionary()) { 1016 if (apdict.isDictionary()) {
1061 for (auto& ap: apdict.ditems()) { 1017 for (auto& ap: apdict.ditems()) {
1062 if (ap.second.isStream()) { 1018 if (ap.second.isStream()) {
1063 - streams.push_back(  
1064 - replace_stream(apdict, ap.first, ap.second)); 1019 + streams.push_back(replace_stream(apdict, ap.first, ap.second));
1065 } else if (ap.second.isDictionary()) { 1020 } else if (ap.second.isDictionary()) {
1066 for (auto& ap2: ap.second.ditems()) { 1021 for (auto& ap2: ap.second.ditems()) {
1067 if (ap2.second.isStream()) { 1022 if (ap2.second.isStream()) {
1068 streams.push_back( 1023 streams.push_back(
1069 // line-break 1024 // line-break
1070 - replace_stream(  
1071 - ap.second, ap2.first, ap2.second)); 1025 + replace_stream(ap.second, ap2.first, ap2.second));
1072 } 1026 }
1073 } 1027 }
1074 } 1028 }
@@ -1096,8 +1050,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations( @@ -1096,8 +1050,7 @@ QPDFAcroFormDocumentHelper::transformAnnotations(
1096 adjustAppearanceStream(stream, dr_map); 1050 adjustAppearanceStream(stream, dr_map);
1097 } 1051 }
1098 } 1052 }
1099 - auto rect =  
1100 - cm.transformRectangle(annot.getKey("/Rect").getArrayAsRectangle()); 1053 + auto rect = cm.transformRectangle(annot.getKey("/Rect").getArrayAsRectangle());
1101 annot.replaceKey("/Rect", QPDFObjectHandle::newFromRectangle(rect)); 1054 annot.replaceKey("/Rect", QPDFObjectHandle::newFromRectangle(rect));
1102 } 1055 }
1103 } 1056 }
libqpdf/QPDFAnnotationObjectHelper.cc
@@ -47,8 +47,7 @@ QPDFAnnotationObjectHelper::getFlags() @@ -47,8 +47,7 @@ QPDFAnnotationObjectHelper::getFlags()
47 } 47 }
48 48
49 QPDFObjectHandle 49 QPDFObjectHandle
50 -QPDFAnnotationObjectHelper::getAppearanceStream(  
51 - std::string const& which, std::string const& state) 50 +QPDFAnnotationObjectHelper::getAppearanceStream(std::string const& which, std::string const& state)
52 { 51 {
53 QPDFObjectHandle ap = getAppearanceDictionary(); 52 QPDFObjectHandle ap = getAppearanceDictionary();
54 std::string desired_state = state.empty() ? getAppearanceState() : state; 53 std::string desired_state = state.empty() ? getAppearanceState() : state;
@@ -80,10 +79,7 @@ QPDFAnnotationObjectHelper::getAppearanceStream( @@ -80,10 +79,7 @@ QPDFAnnotationObjectHelper::getAppearanceStream(
80 79
81 std::string 80 std::string
82 QPDFAnnotationObjectHelper::getPageContentForAppearance( 81 QPDFAnnotationObjectHelper::getPageContentForAppearance(
83 - std::string const& name,  
84 - int rotate,  
85 - int required_flags,  
86 - int forbidden_flags) 82 + std::string const& name, int rotate, int required_flags, int forbidden_flags)
87 { 83 {
88 if (!getAppearanceStream("/N").isStream()) { 84 if (!getAppearanceStream("/N").isStream()) {
89 return ""; 85 return "";
@@ -242,9 +238,7 @@ QPDFAnnotationObjectHelper::getPageContentForAppearance( @@ -242,9 +238,7 @@ QPDFAnnotationObjectHelper::getPageContentForAppearance(
242 // Compute a matrix to transform the appearance box to the rectangle 238 // Compute a matrix to transform the appearance box to the rectangle
243 QPDFMatrix AA; 239 QPDFMatrix AA;
244 AA.translate(rect.llx, rect.lly); 240 AA.translate(rect.llx, rect.lly);
245 - AA.scale(  
246 - (rect.urx - rect.llx) / (T.urx - T.llx),  
247 - (rect.ury - rect.lly) / (T.ury - T.lly)); 241 + AA.scale((rect.urx - rect.llx) / (T.urx - T.llx), (rect.ury - rect.lly) / (T.ury - T.lly));
248 AA.translate(-T.llx, -T.lly); 242 AA.translate(-T.llx, -T.lly);
249 if (do_rotate) { 243 if (do_rotate) {
250 AA.rotatex90(rotate); 244 AA.rotatex90(rotate);
libqpdf/QPDFArgParser.cc
@@ -9,8 +9,7 @@ @@ -9,8 +9,7 @@
9 #include <cstring> 9 #include <cstring>
10 #include <iostream> 10 #include <iostream>
11 11
12 -QPDFArgParser::Members::Members(  
13 - int argc, char const* const argv[], char const* progname_env) : 12 +QPDFArgParser::Members::Members(int argc, char const* const argv[], char const* progname_env) :
14 13
15 argc(argc), 14 argc(argc),
16 argv(argv), 15 argv(argv),
@@ -25,19 +24,15 @@ QPDFArgParser::Members::Members( @@ -25,19 +24,15 @@ QPDFArgParser::Members::Members(
25 whoami = QUtil::getWhoami(tmp.get()); 24 whoami = QUtil::getWhoami(tmp.get());
26 } 25 }
27 26
28 -QPDFArgParser::QPDFArgParser(  
29 - int argc, char const* const argv[], char const* progname_env) : 27 +QPDFArgParser::QPDFArgParser(int argc, char const* const argv[], char const* progname_env) :
30 m(new Members(argc, argv, progname_env)) 28 m(new Members(argc, argv, progname_env))
31 { 29 {
32 selectHelpOptionTable(); 30 selectHelpOptionTable();
33 char const* help_choices[] = {"all", nullptr}; 31 char const* help_choices[] = {"all", nullptr};
34 // More help choices are added dynamically. 32 // More help choices are added dynamically.
35 - addChoices(  
36 - "help", bindParam(&QPDFArgParser::argHelp, this), false, help_choices);  
37 - addInvalidChoiceHandler(  
38 - "help", bindParam(&QPDFArgParser::invalidHelpArg, this));  
39 - addBare(  
40 - "completion-bash", bindBare(&QPDFArgParser::argCompletionBash, this)); 33 + addChoices("help", bindParam(&QPDFArgParser::argHelp, this), false, help_choices);
  34 + addInvalidChoiceHandler("help", bindParam(&QPDFArgParser::invalidHelpArg, this));
  35 + addBare("completion-bash", bindBare(&QPDFArgParser::argCompletionBash, this));
41 addBare("completion-zsh", bindBare(&QPDFArgParser::argCompletionZsh, this)); 36 addBare("completion-zsh", bindBare(&QPDFArgParser::argCompletionZsh, this));
42 selectMainOptionTable(); 37 selectMainOptionTable();
43 } 38 }
@@ -62,22 +57,19 @@ QPDFArgParser::selectOptionTable(std::string const&amp; name) @@ -62,22 +57,19 @@ QPDFArgParser::selectOptionTable(std::string const&amp; name)
62 auto t = m->option_tables.find(name); 57 auto t = m->option_tables.find(name);
63 if (t == m->option_tables.end()) { 58 if (t == m->option_tables.end()) {
64 QTC::TC("libtests", "QPDFArgParser select unregistered table"); 59 QTC::TC("libtests", "QPDFArgParser select unregistered table");
65 - throw std::logic_error(  
66 - "QPDFArgParser: selecting unregistered option table " + name); 60 + throw std::logic_error("QPDFArgParser: selecting unregistered option table " + name);
67 } 61 }
68 m->option_table = &(t->second); 62 m->option_table = &(t->second);
69 m->option_table_name = name; 63 m->option_table_name = name;
70 } 64 }
71 65
72 void 66 void
73 -QPDFArgParser::registerOptionTable(  
74 - std::string const& name, bare_arg_handler_t end_handler) 67 +QPDFArgParser::registerOptionTable(std::string const& name, bare_arg_handler_t end_handler)
75 { 68 {
76 if (0 != m->option_tables.count(name)) { 69 if (0 != m->option_tables.count(name)) {
77 QTC::TC("libtests", "QPDFArgParser register registered table"); 70 QTC::TC("libtests", "QPDFArgParser register registered table");
78 throw std::logic_error( 71 throw std::logic_error(
79 - "QPDFArgParser: registering already registered option table " +  
80 - name); 72 + "QPDFArgParser: registering already registered option table " + name);
81 } 73 }
82 m->option_tables[name]; 74 m->option_tables[name];
83 selectOptionTable(name); 75 selectOptionTable(name);
@@ -90,8 +82,8 @@ QPDFArgParser::registerArg(std::string const&amp; arg) @@ -90,8 +82,8 @@ QPDFArgParser::registerArg(std::string const&amp; arg)
90 if (0 != m->option_table->count(arg)) { 82 if (0 != m->option_table->count(arg)) {
91 QTC::TC("libtests", "QPDFArgParser duplicate handler"); 83 QTC::TC("libtests", "QPDFArgParser duplicate handler");
92 throw std::logic_error( 84 throw std::logic_error(
93 - "QPDFArgParser: adding a duplicate handler for option " + arg +  
94 - " in " + m->option_table_name + " option table"); 85 + "QPDFArgParser: adding a duplicate handler for option " + arg + " in " +
  86 + m->option_table_name + " option table");
95 } 87 }
96 return ((*m->option_table)[arg]); 88 return ((*m->option_table)[arg]);
97 } 89 }
@@ -113,9 +105,7 @@ QPDFArgParser::addBare(std::string const&amp; arg, bare_arg_handler_t handler) @@ -113,9 +105,7 @@ QPDFArgParser::addBare(std::string const&amp; arg, bare_arg_handler_t handler)
113 105
114 void 106 void
115 QPDFArgParser::addRequiredParameter( 107 QPDFArgParser::addRequiredParameter(
116 - std::string const& arg,  
117 - param_arg_handler_t handler,  
118 - char const* parameter_name) 108 + std::string const& arg, param_arg_handler_t handler, char const* parameter_name)
119 { 109 {
120 OptionEntry& oe = registerArg(arg); 110 OptionEntry& oe = registerArg(arg);
121 oe.parameter_needed = true; 111 oe.parameter_needed = true;
@@ -124,8 +114,7 @@ QPDFArgParser::addRequiredParameter( @@ -124,8 +114,7 @@ QPDFArgParser::addRequiredParameter(
124 } 114 }
125 115
126 void 116 void
127 -QPDFArgParser::addOptionalParameter(  
128 - std::string const& arg, param_arg_handler_t handler) 117 +QPDFArgParser::addOptionalParameter(std::string const& arg, param_arg_handler_t handler)
129 { 118 {
130 OptionEntry& oe = registerArg(arg); 119 OptionEntry& oe = registerArg(arg);
131 oe.parameter_needed = false; 120 oe.parameter_needed = false;
@@ -134,10 +123,7 @@ QPDFArgParser::addOptionalParameter( @@ -134,10 +123,7 @@ QPDFArgParser::addOptionalParameter(
134 123
135 void 124 void
136 QPDFArgParser::addChoices( 125 QPDFArgParser::addChoices(
137 - std::string const& arg,  
138 - param_arg_handler_t handler,  
139 - bool required,  
140 - char const** choices) 126 + std::string const& arg, param_arg_handler_t handler, bool required, char const** choices)
141 { 127 {
142 OptionEntry& oe = registerArg(arg); 128 OptionEntry& oe = registerArg(arg);
143 oe.parameter_needed = required; 129 oe.parameter_needed = required;
@@ -148,15 +134,13 @@ QPDFArgParser::addChoices( @@ -148,15 +134,13 @@ QPDFArgParser::addChoices(
148 } 134 }
149 135
150 void 136 void
151 -QPDFArgParser::addInvalidChoiceHandler(  
152 - std::string const& arg, param_arg_handler_t handler) 137 +QPDFArgParser::addInvalidChoiceHandler(std::string const& arg, param_arg_handler_t handler)
153 { 138 {
154 auto i = m->option_table->find(arg); 139 auto i = m->option_table->find(arg);
155 if (i == m->option_table->end()) { 140 if (i == m->option_table->end()) {
156 QTC::TC("libtests", "QPDFArgParser invalid choice handler to unknown"); 141 QTC::TC("libtests", "QPDFArgParser invalid choice handler to unknown");
157 - throw std::logic_error(  
158 - "QPDFArgParser: attempt to add invalid choice handler"  
159 - " to unknown argument"); 142 + throw std::logic_error("QPDFArgParser: attempt to add invalid choice handler"
  143 + " to unknown argument");
160 } 144 }
161 auto& oe = i->second; 145 auto& oe = i->second;
162 oe.invalid_choice_handler = handler; 146 oe.invalid_choice_handler = handler;
@@ -195,9 +179,7 @@ QPDFArgParser::completionCommon(bool zsh) @@ -195,9 +179,7 @@ QPDFArgParser::completionCommon(bool zsh)
195 std::string appimage; 179 std::string appimage;
196 if (QUtil::get_env(m->progname_env.c_str(), &executable)) { 180 if (QUtil::get_env(m->progname_env.c_str(), &executable)) {
197 progname = executable; 181 progname = executable;
198 - } else if (  
199 - QUtil::get_env("APPDIR", &appdir) &&  
200 - QUtil::get_env("APPIMAGE", &appimage)) { 182 + } else if (QUtil::get_env("APPDIR", &appdir) && QUtil::get_env("APPIMAGE", &appimage)) {
201 // Detect if we're in an AppImage and adjust 183 // Detect if we're in an AppImage and adjust
202 if ((appdir.length() < strlen(m->argv[0])) && 184 if ((appdir.length() < strlen(m->argv[0])) &&
203 (strncmp(appdir.c_str(), m->argv[0], appdir.length()) == 0)) { 185 (strncmp(appdir.c_str(), m->argv[0], appdir.length()) == 0)) {
@@ -345,8 +327,7 @@ QPDFArgParser::handleBashArguments() @@ -345,8 +327,7 @@ QPDFArgParser::handleBashArguments()
345 } 327 }
346 // Explicitly discard any non-space-terminated word. The "current 328 // Explicitly discard any non-space-terminated word. The "current
347 // word" is handled specially. 329 // word" is handled specially.
348 - m->bash_argv_ph =  
349 - QUtil::make_shared_array<char const*>(1 + m->bash_argv.size()); 330 + m->bash_argv_ph = QUtil::make_shared_array<char const*>(1 + m->bash_argv.size());
350 for (size_t i = 0; i < m->bash_argv.size(); ++i) { 331 for (size_t i = 0; i < m->bash_argv.size(); ++i) {
351 m->bash_argv_ph.get()[i] = m->bash_argv.at(i).get(); 332 m->bash_argv_ph.get()[i] = m->bash_argv.at(i).get();
352 } 333 }
@@ -479,8 +460,7 @@ QPDFArgParser::parseArgs() @@ -479,8 +460,7 @@ QPDFArgParser::parseArgs()
479 end_option = true; 460 end_option = true;
480 if (oep == m->option_table->end()) { 461 if (oep == m->option_table->end()) {
481 // This is registered automatically, so this can't happen. 462 // This is registered automatically, so this can't happen.
482 - throw std::logic_error(  
483 - "QPDFArgParser: -- handler not registered"); 463 + throw std::logic_error("QPDFArgParser: -- handler not registered");
484 } 464 }
485 } else if ((arg[0] == '-') && (strcmp(arg, "-") != 0)) { 465 } else if ((arg[0] == '-') && (strcmp(arg, "-") != 0)) {
486 ++arg; 466 ++arg;
@@ -531,18 +511,15 @@ QPDFArgParser::parseArgs() @@ -531,18 +511,15 @@ QPDFArgParser::parseArgs()
531 QTC::TC("libtests", "QPDFArgParser unrecognized"); 511 QTC::TC("libtests", "QPDFArgParser unrecognized");
532 std::string message = "unrecognized argument " + o_arg; 512 std::string message = "unrecognized argument " + o_arg;
533 if (m->option_table != &m->main_option_table) { 513 if (m->option_table != &m->main_option_table) {
534 - message += " (" + m->option_table_name +  
535 - " options must be terminated with --)"; 514 + message += " (" + m->option_table_name + " options must be terminated with --)";
536 } 515 }
537 usage(message); 516 usage(message);
538 } 517 }
539 518
540 OptionEntry& oe = oep->second; 519 OptionEntry& oe = oep->second;
541 if ((oe.parameter_needed && (!have_parameter)) || 520 if ((oe.parameter_needed && (!have_parameter)) ||
542 - ((!oe.choices.empty() && have_parameter &&  
543 - (0 == oe.choices.count(parameter))))) {  
544 - std::string message =  
545 - "--" + arg_s + " must be given as --" + arg_s + "="; 521 + ((!oe.choices.empty() && have_parameter && (0 == oe.choices.count(parameter))))) {
  522 + std::string message = "--" + arg_s + " must be given as --" + arg_s + "=";
546 if (oe.invalid_choice_handler) { 523 if (oe.invalid_choice_handler) {
547 oe.invalid_choice_handler(parameter); 524 oe.invalid_choice_handler(parameter);
548 // Method should call usage() or exit. Just in case it 525 // Method should call usage() or exit. Just in case it
@@ -609,9 +586,7 @@ QPDFArgParser::doFinalChecks() @@ -609,9 +586,7 @@ QPDFArgParser::doFinalChecks()
609 586
610 void 587 void
611 QPDFArgParser::addChoicesToCompletions( 588 QPDFArgParser::addChoicesToCompletions(
612 - option_table_t& option_table,  
613 - std::string const& option,  
614 - std::string const& extra_prefix) 589 + option_table_t& option_table, std::string const& option, std::string const& extra_prefix)
615 { 590 {
616 if (option_table.count(option) != 0) { 591 if (option_table.count(option) != 0) {
617 OptionEntry& oe = option_table[option]; 592 OptionEntry& oe = option_table[option];
@@ -648,9 +623,7 @@ QPDFArgParser::addOptionsToCompletions(option_table_t&amp; option_table) @@ -648,9 +623,7 @@ QPDFArgParser::addOptionsToCompletions(option_table_t&amp; option_table)
648 623
649 void 624 void
650 QPDFArgParser::insertCompletions( 625 QPDFArgParser::insertCompletions(
651 - option_table_t& option_table,  
652 - std::string const& choice_option,  
653 - std::string const& extra_prefix) 626 + option_table_t& option_table, std::string const& choice_option, std::string const& extra_prefix)
654 { 627 {
655 if (!choice_option.empty()) { 628 if (!choice_option.empty()) {
656 addChoicesToCompletions(option_table, choice_option, extra_prefix); 629 addChoicesToCompletions(option_table, choice_option, extra_prefix);
@@ -666,21 +639,17 @@ QPDFArgParser::handleCompletion() @@ -666,21 +639,17 @@ QPDFArgParser::handleCompletion()
666 if (m->completions.empty()) { 639 if (m->completions.empty()) {
667 // Detect --option=... Bash treats the = as a word separator. 640 // Detect --option=... Bash treats the = as a word separator.
668 std::string choice_option; 641 std::string choice_option;
669 - if (m->bash_cur.empty() && (m->bash_prev.length() > 2) &&  
670 - (m->bash_prev.at(0) == '-') && (m->bash_prev.at(1) == '-') &&  
671 - (m->bash_line.at(m->bash_line.length() - 1) == '=')) { 642 + if (m->bash_cur.empty() && (m->bash_prev.length() > 2) && (m->bash_prev.at(0) == '-') &&
  643 + (m->bash_prev.at(1) == '-') && (m->bash_line.at(m->bash_line.length() - 1) == '=')) {
672 choice_option = m->bash_prev.substr(2, std::string::npos); 644 choice_option = m->bash_prev.substr(2, std::string::npos);
673 - } else if (  
674 - (m->bash_prev == "=") &&  
675 - (m->bash_line.length() > (m->bash_cur.length() + 1))) { 645 + } else if ((m->bash_prev == "=") && (m->bash_line.length() > (m->bash_cur.length() + 1))) {
676 // We're sitting at --option=x. Find previous option. 646 // We're sitting at --option=x. Find previous option.
677 size_t end_mark = m->bash_line.length() - m->bash_cur.length() - 1; 647 size_t end_mark = m->bash_line.length() - m->bash_cur.length() - 1;
678 char before_cur = m->bash_line.at(end_mark); 648 char before_cur = m->bash_line.at(end_mark);
679 if (before_cur == '=') { 649 if (before_cur == '=') {
680 size_t space = m->bash_line.find_last_of(' ', end_mark); 650 size_t space = m->bash_line.find_last_of(' ', end_mark);
681 if (space != std::string::npos) { 651 if (space != std::string::npos) {
682 - std::string candidate =  
683 - m->bash_line.substr(space + 1, end_mark - space - 1); 652 + std::string candidate = m->bash_line.substr(space + 1, end_mark - space - 1);
684 if ((candidate.length() > 2) && (candidate.at(0) == '-') && 653 if ((candidate.length() > 2) && (candidate.at(0) == '-') &&
685 (candidate.at(1) == '-')) { 654 (candidate.at(1) == '-')) {
686 choice_option = candidate.substr(2, std::string::npos); 655 choice_option = candidate.substr(2, std::string::npos);
@@ -695,8 +664,7 @@ QPDFArgParser::handleCompletion() @@ -695,8 +664,7 @@ QPDFArgParser::handleCompletion()
695 insertCompletions(*m->option_table, choice_option, extra_prefix); 664 insertCompletions(*m->option_table, choice_option, extra_prefix);
696 if (m->argc == 1) { 665 if (m->argc == 1) {
697 // Help options are valid only by themselves. 666 // Help options are valid only by themselves.
698 - insertCompletions(  
699 - m->help_option_table, choice_option, extra_prefix); 667 + insertCompletions(m->help_option_table, choice_option, extra_prefix);
700 } 668 }
701 } 669 }
702 std::string prefix = extra_prefix + m->bash_cur; 670 std::string prefix = extra_prefix + m->bash_cur;
@@ -716,24 +684,19 @@ QPDFArgParser::addHelpFooter(std::string const&amp; text) @@ -716,24 +684,19 @@ QPDFArgParser::addHelpFooter(std::string const&amp; text)
716 684
717 void 685 void
718 QPDFArgParser::addHelpTopic( 686 QPDFArgParser::addHelpTopic(
719 - std::string const& topic,  
720 - std::string const& short_text,  
721 - std::string const& long_text) 687 + std::string const& topic, std::string const& short_text, std::string const& long_text)
722 { 688 {
723 if (topic == "all") { 689 if (topic == "all") {
724 QTC::TC("libtests", "QPDFArgParser add reserved help topic"); 690 QTC::TC("libtests", "QPDFArgParser add reserved help topic");
725 - throw std::logic_error(  
726 - "QPDFArgParser: can't register reserved help topic " + topic); 691 + throw std::logic_error("QPDFArgParser: can't register reserved help topic " + topic);
727 } 692 }
728 if (!((topic.length() > 0) && (topic.at(0) != '-'))) { 693 if (!((topic.length() > 0) && (topic.at(0) != '-'))) {
729 QTC::TC("libtests", "QPDFArgParser bad topic for help"); 694 QTC::TC("libtests", "QPDFArgParser bad topic for help");
730 - throw std::logic_error(  
731 - "QPDFArgParser: help topics must not start with -"); 695 + throw std::logic_error("QPDFArgParser: help topics must not start with -");
732 } 696 }
733 if (m->help_topics.count(topic)) { 697 if (m->help_topics.count(topic)) {
734 QTC::TC("libtests", "QPDFArgParser add existing topic"); 698 QTC::TC("libtests", "QPDFArgParser add existing topic");
735 - throw std::logic_error(  
736 - "QPDFArgParser: topic " + topic + " has already been added"); 699 + throw std::logic_error("QPDFArgParser: topic " + topic + " has already been added");
737 } 700 }
738 701
739 m->help_topics[topic] = HelpTopic(short_text, long_text); 702 m->help_topics[topic] = HelpTopic(short_text, long_text);
@@ -747,23 +710,20 @@ QPDFArgParser::addOptionHelp( @@ -747,23 +710,20 @@ QPDFArgParser::addOptionHelp(
747 std::string const& short_text, 710 std::string const& short_text,
748 std::string const& long_text) 711 std::string const& long_text)
749 { 712 {
750 - if (!((option_name.length() > 2) && (option_name.at(0) == '-') &&  
751 - (option_name.at(1) == '-'))) { 713 + if (!((option_name.length() > 2) && (option_name.at(0) == '-') && (option_name.at(1) == '-'))) {
752 QTC::TC("libtests", "QPDFArgParser bad option for help"); 714 QTC::TC("libtests", "QPDFArgParser bad option for help");
753 - throw std::logic_error(  
754 - "QPDFArgParser: options for help must start with --"); 715 + throw std::logic_error("QPDFArgParser: options for help must start with --");
755 } 716 }
756 if (m->option_help.count(option_name)) { 717 if (m->option_help.count(option_name)) {
757 QTC::TC("libtests", "QPDFArgParser duplicate option help"); 718 QTC::TC("libtests", "QPDFArgParser duplicate option help");
758 - throw std::logic_error(  
759 - "QPDFArgParser: option " + option_name + " already has help"); 719 + throw std::logic_error("QPDFArgParser: option " + option_name + " already has help");
760 } 720 }
761 auto ht = m->help_topics.find(topic); 721 auto ht = m->help_topics.find(topic);
762 if (ht == m->help_topics.end()) { 722 if (ht == m->help_topics.end()) {
763 QTC::TC("libtests", "QPDFArgParser add to unknown topic"); 723 QTC::TC("libtests", "QPDFArgParser add to unknown topic");
764 throw std::logic_error( 724 throw std::logic_error(
765 - "QPDFArgParser: unable to add option " + option_name +  
766 - " to unknown help topic " + topic); 725 + "QPDFArgParser: unable to add option " + option_name + " to unknown help topic " +
  726 + topic);
767 } 727 }
768 m->option_help[option_name] = HelpTopic(short_text, long_text); 728 m->option_help[option_name] = HelpTopic(short_text, long_text);
769 ht->second.options.insert(option_name); 729 ht->second.options.insert(option_name);
@@ -773,12 +733,9 @@ QPDFArgParser::addOptionHelp( @@ -773,12 +733,9 @@ QPDFArgParser::addOptionHelp(
773 void 733 void
774 QPDFArgParser::getTopHelp(std::ostringstream& msg) 734 QPDFArgParser::getTopHelp(std::ostringstream& msg)
775 { 735 {
776 - msg << "Run \"" << m->whoami << " --help=topic\" for help on a topic."  
777 - << std::endl  
778 - << "Run \"" << m->whoami << " --help=--option\" for help on an option."  
779 - << std::endl  
780 - << "Run \"" << m->whoami << " --help=all\" to see all available help."  
781 - << std::endl 736 + msg << "Run \"" << m->whoami << " --help=topic\" for help on a topic." << std::endl
  737 + << "Run \"" << m->whoami << " --help=--option\" for help on an option." << std::endl
  738 + << "Run \"" << m->whoami << " --help=all\" to see all available help." << std::endl
782 << std::endl 739 << std::endl
783 << "Topics:" << std::endl; 740 << "Topics:" << std::endl;
784 for (auto const& i: m->help_topics) { 741 for (auto const& i: m->help_topics) {
@@ -794,8 +751,7 @@ QPDFArgParser::getAllHelp(std::ostringstream&amp; msg) @@ -794,8 +751,7 @@ QPDFArgParser::getAllHelp(std::ostringstream&amp; msg)
794 for (auto const& i: topics) { 751 for (auto const& i: topics) {
795 auto const& topic = i.first; 752 auto const& topic = i.first;
796 msg << std::endl 753 msg << std::endl
797 - << "== " << topic << " (" << i.second.short_text  
798 - << ") ==" << std::endl 754 + << "== " << topic << " (" << i.second.short_text << ") ==" << std::endl
799 << std::endl; 755 << std::endl;
800 getTopicHelp(topic, i.second, msg); 756 getTopicHelp(topic, i.second, msg);
801 } 757 }
@@ -806,8 +762,7 @@ QPDFArgParser::getAllHelp(std::ostringstream&amp; msg) @@ -806,8 +762,7 @@ QPDFArgParser::getAllHelp(std::ostringstream&amp; msg)
806 } 762 }
807 763
808 void 764 void
809 -QPDFArgParser::getTopicHelp(  
810 - std::string const& name, HelpTopic const& ht, std::ostringstream& msg) 765 +QPDFArgParser::getTopicHelp(std::string const& name, HelpTopic const& ht, std::ostringstream& msg)
811 { 766 {
812 if (ht.long_text.empty()) { 767 if (ht.long_text.empty()) {
813 msg << ht.short_text << std::endl; 768 msg << ht.short_text << std::endl;
@@ -817,8 +772,7 @@ QPDFArgParser::getTopicHelp( @@ -817,8 +772,7 @@ QPDFArgParser::getTopicHelp(
817 if (!ht.options.empty()) { 772 if (!ht.options.empty()) {
818 msg << std::endl << "Related options:" << std::endl; 773 msg << std::endl << "Related options:" << std::endl;
819 for (auto const& i: ht.options) { 774 for (auto const& i: ht.options) {
820 - msg << " " << i << ": " << m->option_help[i].short_text  
821 - << std::endl; 775 + msg << " " << i << ": " << m->option_help[i].short_text << std::endl;
822 } 776 }
823 } 777 }
824 } 778 }
libqpdf/QPDFCryptoProvider.cc
@@ -19,8 +19,7 @@ QPDFCryptoProvider::getImpl() @@ -19,8 +19,7 @@ QPDFCryptoProvider::getImpl()
19 { 19 {
20 QPDFCryptoProvider& p = getInstance(); 20 QPDFCryptoProvider& p = getInstance();
21 if (p.m->default_provider.empty()) { 21 if (p.m->default_provider.empty()) {
22 - throw std::logic_error(  
23 - "QPDFCryptoProvider::getImpl called with no default provider."); 22 + throw std::logic_error("QPDFCryptoProvider::getImpl called with no default provider.");
24 } 23 }
25 return p.getImpl_internal(p.m->default_provider); 24 return p.getImpl_internal(p.m->default_provider);
26 } 25 }
@@ -76,8 +75,7 @@ QPDFCryptoProvider::getImpl_internal(std::string const&amp; name) const @@ -76,8 +75,7 @@ QPDFCryptoProvider::getImpl_internal(std::string const&amp; name) const
76 auto iter = m->providers.find(name); 75 auto iter = m->providers.find(name);
77 if (iter == m->providers.end()) { 76 if (iter == m->providers.end()) {
78 throw std::logic_error( 77 throw std::logic_error(
79 - "QPDFCryptoProvider requested unknown implementation \"" + name +  
80 - "\""); 78 + "QPDFCryptoProvider requested unknown implementation \"" + name + "\"");
81 } 79 }
82 return m->providers[name](); 80 return m->providers[name]();
83 } 81 }
libqpdf/QPDFCrypto_gnutls.cc
@@ -47,8 +47,7 @@ QPDFCrypto_gnutls::MD5_init() @@ -47,8 +47,7 @@ QPDFCrypto_gnutls::MD5_init()
47 if (code < 0) { 47 if (code < 0) {
48 this->hash_ctx = nullptr; 48 this->hash_ctx = nullptr;
49 throw std::runtime_error( 49 throw std::runtime_error(
50 - std::string("gnutls: MD5 error: ") +  
51 - std::string(gnutls_strerror(code))); 50 + std::string("gnutls: MD5 error: ") + std::string(gnutls_strerror(code)));
52 } 51 }
53 } 52 }
54 53
@@ -78,26 +77,22 @@ QPDFCrypto_gnutls::RC4_init(unsigned char const* key_data, int key_len) @@ -78,26 +77,22 @@ QPDFCrypto_gnutls::RC4_init(unsigned char const* key_data, int key_len)
78 { 77 {
79 RC4_finalize(); 78 RC4_finalize();
80 if (key_len == -1) { 79 if (key_len == -1) {
81 - key_len =  
82 - QIntC::to_int(strlen(reinterpret_cast<char const*>(key_data))); 80 + key_len = QIntC::to_int(strlen(reinterpret_cast<char const*>(key_data)));
83 } 81 }
84 gnutls_datum_t key; 82 gnutls_datum_t key;
85 key.data = const_cast<unsigned char*>(key_data); 83 key.data = const_cast<unsigned char*>(key_data);
86 key.size = QIntC::to_uint(key_len); 84 key.size = QIntC::to_uint(key_len);
87 85
88 - int code = gnutls_cipher_init(  
89 - &this->cipher_ctx, GNUTLS_CIPHER_ARCFOUR_128, &key, nullptr); 86 + int code = gnutls_cipher_init(&this->cipher_ctx, GNUTLS_CIPHER_ARCFOUR_128, &key, nullptr);
90 if (code < 0) { 87 if (code < 0) {
91 this->cipher_ctx = nullptr; 88 this->cipher_ctx = nullptr;
92 throw std::runtime_error( 89 throw std::runtime_error(
93 - std::string("gnutls: RC4 error: ") +  
94 - std::string(gnutls_strerror(code))); 90 + std::string("gnutls: RC4 error: ") + std::string(gnutls_strerror(code)));
95 } 91 }
96 } 92 }
97 93
98 void 94 void
99 -QPDFCrypto_gnutls::RC4_process(  
100 - unsigned char const* in_data, size_t len, unsigned char* out_data) 95 +QPDFCrypto_gnutls::RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data)
101 { 96 {
102 gnutls_cipher_encrypt2(this->cipher_ctx, in_data, len, out_data, len); 97 gnutls_cipher_encrypt2(this->cipher_ctx, in_data, len, out_data, len);
103 } 98 }
@@ -223,29 +218,19 @@ QPDFCrypto_gnutls::rijndael_init( @@ -223,29 +218,19 @@ QPDFCrypto_gnutls::rijndael_init(
223 if (code < 0) { 218 if (code < 0) {
224 this->cipher_ctx = nullptr; 219 this->cipher_ctx = nullptr;
225 throw std::runtime_error( 220 throw std::runtime_error(
226 - std::string("gnutls: AES error: ") +  
227 - std::string(gnutls_strerror(code))); 221 + std::string("gnutls: AES error: ") + std::string(gnutls_strerror(code)));
228 } 222 }
229 } 223 }
230 224
231 void 225 void
232 -QPDFCrypto_gnutls::rijndael_process(  
233 - unsigned char* in_data, unsigned char* out_data) 226 +QPDFCrypto_gnutls::rijndael_process(unsigned char* in_data, unsigned char* out_data)
234 { 227 {
235 if (this->encrypt) { 228 if (this->encrypt) {
236 gnutls_cipher_encrypt2( 229 gnutls_cipher_encrypt2(
237 - this->cipher_ctx,  
238 - in_data,  
239 - rijndael_buf_size,  
240 - out_data,  
241 - rijndael_buf_size); 230 + this->cipher_ctx, in_data, rijndael_buf_size, out_data, rijndael_buf_size);
242 } else { 231 } else {
243 gnutls_cipher_decrypt2( 232 gnutls_cipher_decrypt2(
244 - this->cipher_ctx,  
245 - in_data,  
246 - rijndael_buf_size,  
247 - out_data,  
248 - rijndael_buf_size); 233 + this->cipher_ctx, in_data, rijndael_buf_size, out_data, rijndael_buf_size);
249 } 234 }
250 235
251 // Gnutls doesn't support AES in ECB (non-CBC) mode, but the 236 // Gnutls doesn't support AES in ECB (non-CBC) mode, but the
@@ -253,14 +238,8 @@ QPDFCrypto_gnutls::rijndael_process( @@ -253,14 +238,8 @@ QPDFCrypto_gnutls::rijndael_process(
253 // zeroes each time. We jump through a few hoops here to make this 238 // zeroes each time. We jump through a few hoops here to make this
254 // work. 239 // work.
255 if (!this->cbc_mode) { 240 if (!this->cbc_mode) {
256 - static unsigned char zeroes[16] = {  
257 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};  
258 - rijndael_init(  
259 - this->encrypt,  
260 - this->aes_key_data,  
261 - this->aes_key_len,  
262 - false,  
263 - zeroes); 241 + static unsigned char zeroes[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  242 + rijndael_init(this->encrypt, this->aes_key_data, this->aes_key_len, false, zeroes);
264 } 243 }
265 } 244 }
266 245
libqpdf/QPDFCrypto_native.cc
@@ -68,8 +68,7 @@ QPDFCrypto_native::RC4_init(unsigned char const* key_data, int key_len) @@ -68,8 +68,7 @@ QPDFCrypto_native::RC4_init(unsigned char const* key_data, int key_len)
68 } 68 }
69 69
70 void 70 void
71 -QPDFCrypto_native::RC4_process(  
72 - unsigned char const* in_data, size_t len, unsigned char* out_data) 71 +QPDFCrypto_native::RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data)
73 { 72 {
74 this->rc4->process(in_data, len, out_data); 73 this->rc4->process(in_data, len, out_data);
75 } 74 }
@@ -112,13 +111,12 @@ QPDFCrypto_native::rijndael_init( @@ -112,13 +111,12 @@ QPDFCrypto_native::rijndael_init(
112 unsigned char* cbc_block) 111 unsigned char* cbc_block)
113 112
114 { 113 {
115 - this->aes_pdf = std::make_shared<AES_PDF_native>(  
116 - encrypt, key_data, key_len, cbc_mode, cbc_block); 114 + this->aes_pdf =
  115 + std::make_shared<AES_PDF_native>(encrypt, key_data, key_len, cbc_mode, cbc_block);
117 } 116 }
118 117
119 void 118 void
120 -QPDFCrypto_native::rijndael_process(  
121 - unsigned char* in_data, unsigned char* out_data) 119 +QPDFCrypto_native::rijndael_process(unsigned char* in_data, unsigned char* out_data)
122 { 120 {
123 this->aes_pdf->update(in_data, out_data); 121 this->aes_pdf->update(in_data, out_data);
124 } 122 }
libqpdf/QPDFCrypto_openssl.cc
@@ -76,8 +76,7 @@ RC4Loader::~RC4Loader() @@ -76,8 +76,7 @@ RC4Loader::~RC4Loader()
76 static void 76 static void
77 bad_bits(int bits) 77 bad_bits(int bits)
78 { 78 {
79 - throw std::logic_error(  
80 - std::string("unsupported key length: ") + std::to_string(bits)); 79 + throw std::logic_error(std::string("unsupported key length: ") + std::to_string(bits));
81 } 80 }
82 81
83 static void 82 static void
@@ -208,14 +207,11 @@ QPDFCrypto_openssl::RC4_init(unsigned char const* key_data, int key_len) @@ -208,14 +207,11 @@ QPDFCrypto_openssl::RC4_init(unsigned char const* key_data, int key_len)
208 #endif 207 #endif
209 check_openssl(EVP_CIPHER_CTX_reset(cipher_ctx)); 208 check_openssl(EVP_CIPHER_CTX_reset(cipher_ctx));
210 if (key_len == -1) { 209 if (key_len == -1) {
211 - key_len =  
212 - QIntC::to_int(strlen(reinterpret_cast<const char*>(key_data))); 210 + key_len = QIntC::to_int(strlen(reinterpret_cast<const char*>(key_data)));
213 } 211 }
214 - check_openssl(  
215 - EVP_EncryptInit_ex(cipher_ctx, rc4, nullptr, nullptr, nullptr)); 212 + check_openssl(EVP_EncryptInit_ex(cipher_ctx, rc4, nullptr, nullptr, nullptr));
216 check_openssl(EVP_CIPHER_CTX_set_key_length(cipher_ctx, key_len)); 213 check_openssl(EVP_CIPHER_CTX_set_key_length(cipher_ctx, key_len));
217 - check_openssl(  
218 - EVP_EncryptInit_ex(cipher_ctx, nullptr, nullptr, key_data, nullptr)); 214 + check_openssl(EVP_EncryptInit_ex(cipher_ctx, nullptr, nullptr, key_data, nullptr));
219 } 215 }
220 216
221 void 217 void
@@ -242,23 +238,19 @@ QPDFCrypto_openssl::rijndael_init( @@ -242,23 +238,19 @@ QPDFCrypto_openssl::rijndael_init(
242 check_openssl(EVP_CIPHER_CTX_reset(cipher_ctx)); 238 check_openssl(EVP_CIPHER_CTX_reset(cipher_ctx));
243 check_openssl( 239 check_openssl(
244 // line-break 240 // line-break
245 - EVP_CipherInit_ex(  
246 - cipher_ctx, cipher, nullptr, key_data, cbc_block, encrypt)); 241 + EVP_CipherInit_ex(cipher_ctx, cipher, nullptr, key_data, cbc_block, encrypt));
247 check_openssl(EVP_CIPHER_CTX_set_padding(cipher_ctx, 0)); 242 check_openssl(EVP_CIPHER_CTX_set_padding(cipher_ctx, 0));
248 } 243 }
249 244
250 void 245 void
251 -QPDFCrypto_openssl::RC4_process(  
252 - unsigned char const* in_data, size_t len, unsigned char* out_data) 246 +QPDFCrypto_openssl::RC4_process(unsigned char const* in_data, size_t len, unsigned char* out_data)
253 { 247 {
254 int out_len = static_cast<int>(len); 248 int out_len = static_cast<int>(len);
255 - check_openssl(  
256 - EVP_EncryptUpdate(cipher_ctx, out_data, &out_len, in_data, out_len)); 249 + check_openssl(EVP_EncryptUpdate(cipher_ctx, out_data, &out_len, in_data, out_len));
257 } 250 }
258 251
259 void 252 void
260 -QPDFCrypto_openssl::rijndael_process(  
261 - unsigned char* in_data, unsigned char* out_data) 253 +QPDFCrypto_openssl::rijndael_process(unsigned char* in_data, unsigned char* out_data)
262 { 254 {
263 int len = QPDFCryptoImpl::rijndael_buf_size; 255 int len = QPDFCryptoImpl::rijndael_buf_size;
264 check_openssl(EVP_CipherUpdate(cipher_ctx, out_data, &len, in_data, len)); 256 check_openssl(EVP_CipherUpdate(cipher_ctx, out_data, &len, in_data, len));
libqpdf/QPDFEFStreamObjectHelper.cc
@@ -24,13 +24,12 @@ QPDFEFStreamObjectHelper::getParam(std::string const&amp; pkey) @@ -24,13 +24,12 @@ QPDFEFStreamObjectHelper::getParam(std::string const&amp; pkey)
24 } 24 }
25 25
26 void 26 void
27 -QPDFEFStreamObjectHelper::setParam(  
28 - std::string const& pkey, QPDFObjectHandle const& pval) 27 +QPDFEFStreamObjectHelper::setParam(std::string const& pkey, QPDFObjectHandle const& pval)
29 { 28 {
30 auto params = this->oh.getDict().getKey("/Params"); 29 auto params = this->oh.getDict().getKey("/Params");
31 if (!params.isDictionary()) { 30 if (!params.isDictionary()) {
32 - params = this->oh.getDict().replaceKeyAndGetNew(  
33 - "/Params", QPDFObjectHandle::newDictionary()); 31 + params =
  32 + this->oh.getDict().replaceKeyAndGetNew("/Params", QPDFObjectHandle::newDictionary());
34 } 33 }
35 params.replaceKey(pkey, pval); 34 params.replaceKey(pkey, pval);
36 } 35 }
@@ -89,8 +88,7 @@ QPDFEFStreamObjectHelper::getChecksum() @@ -89,8 +88,7 @@ QPDFEFStreamObjectHelper::getChecksum()
89 } 88 }
90 89
91 QPDFEFStreamObjectHelper 90 QPDFEFStreamObjectHelper
92 -QPDFEFStreamObjectHelper::createEFStream(  
93 - QPDF& qpdf, std::shared_ptr<Buffer> data) 91 +QPDFEFStreamObjectHelper::createEFStream(QPDF& qpdf, std::shared_ptr<Buffer> data)
94 { 92 {
95 return newFromStream(qpdf.newStream(data)); 93 return newFromStream(qpdf.newStream(data));
96 } 94 }
@@ -102,12 +100,10 @@ QPDFEFStreamObjectHelper::createEFStream(QPDF&amp; qpdf, std::string const&amp; data) @@ -102,12 +100,10 @@ QPDFEFStreamObjectHelper::createEFStream(QPDF&amp; qpdf, std::string const&amp; data)
102 } 100 }
103 101
104 QPDFEFStreamObjectHelper 102 QPDFEFStreamObjectHelper
105 -QPDFEFStreamObjectHelper::createEFStream(  
106 - QPDF& qpdf, std::function<void(Pipeline*)> provider) 103 +QPDFEFStreamObjectHelper::createEFStream(QPDF& qpdf, std::function<void(Pipeline*)> provider)
107 { 104 {
108 auto stream = qpdf.newStream(); 105 auto stream = qpdf.newStream();
109 - stream.replaceStreamData(  
110 - provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull()); 106 + stream.replaceStreamData(provider, QPDFObjectHandle::newNull(), QPDFObjectHandle::newNull());
111 return newFromStream(stream); 107 return newFromStream(stream);
112 } 108 }
113 109
@@ -128,8 +124,7 @@ QPDFEFStreamObjectHelper::setModDate(std::string const&amp; date) @@ -128,8 +124,7 @@ QPDFEFStreamObjectHelper::setModDate(std::string const&amp; date)
128 QPDFEFStreamObjectHelper& 124 QPDFEFStreamObjectHelper&
129 QPDFEFStreamObjectHelper::setSubtype(std::string const& subtype) 125 QPDFEFStreamObjectHelper::setSubtype(std::string const& subtype)
130 { 126 {
131 - this->oh.getDict().replaceKey(  
132 - "/Subtype", QPDFObjectHandle::newName("/" + subtype)); 127 + this->oh.getDict().replaceKey("/Subtype", QPDFObjectHandle::newName("/" + subtype));
133 return *this; 128 return *this;
134 } 129 }
135 130
@@ -137,22 +132,18 @@ QPDFEFStreamObjectHelper @@ -137,22 +132,18 @@ QPDFEFStreamObjectHelper
137 QPDFEFStreamObjectHelper::newFromStream(QPDFObjectHandle stream) 132 QPDFEFStreamObjectHelper::newFromStream(QPDFObjectHandle stream)
138 { 133 {
139 QPDFEFStreamObjectHelper result(stream); 134 QPDFEFStreamObjectHelper result(stream);
140 - stream.getDict().replaceKey(  
141 - "/Type", QPDFObjectHandle::newName("/EmbeddedFile")); 135 + stream.getDict().replaceKey("/Type", QPDFObjectHandle::newName("/EmbeddedFile"));
142 Pl_Discard discard; 136 Pl_Discard discard;
143 // The PDF spec specifies use of MD5 here and notes that it is not 137 // The PDF spec specifies use of MD5 here and notes that it is not
144 // to be used for security. MD5 is known to be insecure. 138 // to be used for security. MD5 is known to be insecure.
145 Pl_MD5 md5("EF md5", &discard); 139 Pl_MD5 md5("EF md5", &discard);
146 Pl_Count count("EF size", &md5); 140 Pl_Count count("EF size", &md5);
147 if (!stream.pipeStreamData(&count, nullptr, 0, qpdf_dl_all)) { 141 if (!stream.pipeStreamData(&count, nullptr, 0, qpdf_dl_all)) {
148 - stream.warnIfPossible(  
149 - "unable to get stream data for new embedded file stream"); 142 + stream.warnIfPossible("unable to get stream data for new embedded file stream");
150 } else { 143 } else {
  144 + result.setParam("/Size", QPDFObjectHandle::newInteger(count.getCount()));
151 result.setParam( 145 result.setParam(
152 - "/Size", QPDFObjectHandle::newInteger(count.getCount()));  
153 - result.setParam(  
154 - "/CheckSum",  
155 - QPDFObjectHandle::newString(QUtil::hex_decode(md5.getHexDigest()))); 146 + "/CheckSum", QPDFObjectHandle::newString(QUtil::hex_decode(md5.getHexDigest())));
156 } 147 }
157 return result; 148 return result;
158 } 149 }
libqpdf/QPDFEmbeddedFileDocumentHelper.cc
@@ -40,8 +40,7 @@ QPDFEmbeddedFileDocumentHelper::QPDFEmbeddedFileDocumentHelper(QPDF&amp; qpdf) : @@ -40,8 +40,7 @@ QPDFEmbeddedFileDocumentHelper::QPDFEmbeddedFileDocumentHelper(QPDF&amp; qpdf) :
40 if (names.isDictionary()) { 40 if (names.isDictionary()) {
41 auto embedded_files = names.getKey("/EmbeddedFiles"); 41 auto embedded_files = names.getKey("/EmbeddedFiles");
42 if (embedded_files.isDictionary()) { 42 if (embedded_files.isDictionary()) {
43 - m->embedded_files = std::make_shared<QPDFNameTreeObjectHelper>(  
44 - embedded_files, qpdf); 43 + m->embedded_files = std::make_shared<QPDFNameTreeObjectHelper>(embedded_files, qpdf);
45 } 44 }
46 } 45 }
47 } 46 }
@@ -61,8 +60,7 @@ QPDFEmbeddedFileDocumentHelper::initEmbeddedFiles() @@ -61,8 +60,7 @@ QPDFEmbeddedFileDocumentHelper::initEmbeddedFiles()
61 auto root = qpdf.getRoot(); 60 auto root = qpdf.getRoot();
62 auto names = root.getKey("/Names"); 61 auto names = root.getKey("/Names");
63 if (!names.isDictionary()) { 62 if (!names.isDictionary()) {
64 - names = root.replaceKeyAndGetNew(  
65 - "/Names", QPDFObjectHandle::newDictionary()); 63 + names = root.replaceKeyAndGetNew("/Names", QPDFObjectHandle::newDictionary());
66 } 64 }
67 auto embedded_files = names.getKey("/EmbeddedFiles"); 65 auto embedded_files = names.getKey("/EmbeddedFiles");
68 if (!embedded_files.isDictionary()) { 66 if (!embedded_files.isDictionary()) {
@@ -91,8 +89,7 @@ QPDFEmbeddedFileDocumentHelper::getEmbeddedFiles() @@ -91,8 +89,7 @@ QPDFEmbeddedFileDocumentHelper::getEmbeddedFiles()
91 std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>> result; 89 std::map<std::string, std::shared_ptr<QPDFFileSpecObjectHelper>> result;
92 if (m->embedded_files) { 90 if (m->embedded_files) {
93 for (auto const& i: *(m->embedded_files)) { 91 for (auto const& i: *(m->embedded_files)) {
94 - result[i.first] =  
95 - std::make_shared<QPDFFileSpecObjectHelper>(i.second); 92 + result[i.first] = std::make_shared<QPDFFileSpecObjectHelper>(i.second);
96 } 93 }
97 } 94 }
98 return result; 95 return result;
libqpdf/QPDFFileSpecObjectHelper.cc
@@ -19,8 +19,7 @@ QPDFFileSpecObjectHelper::QPDFFileSpecObjectHelper(QPDFObjectHandle oh) : @@ -19,8 +19,7 @@ QPDFFileSpecObjectHelper::QPDFFileSpecObjectHelper(QPDFObjectHandle oh) :
19 } 19 }
20 } 20 }
21 21
22 -static std::vector<std::string> name_keys = {  
23 - "/UF", "/F", "/Unix", "/DOS", "/Mac"}; 22 +static std::vector<std::string> name_keys = {"/UF", "/F", "/Unix", "/DOS", "/Mac"};
24 23
25 std::string 24 std::string
26 QPDFFileSpecObjectHelper::getDescription() 25 QPDFFileSpecObjectHelper::getDescription()
@@ -90,8 +89,7 @@ QPDFFileSpecObjectHelper::createFileSpec( @@ -90,8 +89,7 @@ QPDFFileSpecObjectHelper::createFileSpec(
90 return createFileSpec( 89 return createFileSpec(
91 qpdf, 90 qpdf,
92 filename, 91 filename,
93 - QPDFEFStreamObjectHelper::createEFStream(  
94 - qpdf, QUtil::file_provider(fullpath))); 92 + QPDFEFStreamObjectHelper::createEFStream(qpdf, QUtil::file_provider(fullpath)));
95 } 93 }
96 94
97 QPDFFileSpecObjectHelper 95 QPDFFileSpecObjectHelper
libqpdf/QPDFFormFieldObjectHelper.cc
@@ -76,9 +76,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValue(std::string const&amp; name) @@ -76,9 +76,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValue(std::string const&amp; name)
76 node = node.getKey("/Parent"); 76 node = node.getKey("/Parent");
77 result = node.getKey(name); 77 result = node.getKey(name);
78 if (!result.isNull()) { 78 if (!result.isNull()) {
79 - QTC::TC(  
80 - "qpdf",  
81 - "QPDFFormFieldObjectHelper non-trivial inheritance"); 79 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper non-trivial inheritance");
82 return result; 80 return result;
83 } 81 }
84 } 82 }
@@ -87,8 +85,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValue(std::string const&amp; name) @@ -87,8 +85,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValue(std::string const&amp; name)
87 } 85 }
88 86
89 std::string 87 std::string
90 -QPDFFormFieldObjectHelper::getInheritableFieldValueAsString(  
91 - std::string const& name) 88 +QPDFFormFieldObjectHelper::getInheritableFieldValueAsString(std::string const& name)
92 { 89 {
93 QPDFObjectHandle fv = getInheritableFieldValue(name); 90 QPDFObjectHandle fv = getInheritableFieldValue(name);
94 std::string result; 91 std::string result;
@@ -99,8 +96,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValueAsString( @@ -99,8 +96,7 @@ QPDFFormFieldObjectHelper::getInheritableFieldValueAsString(
99 } 96 }
100 97
101 std::string 98 std::string
102 -QPDFFormFieldObjectHelper::getInheritableFieldValueAsName(  
103 - std::string const& name) 99 +QPDFFormFieldObjectHelper::getInheritableFieldValueAsName(std::string const& name)
104 { 100 {
105 QPDFObjectHandle fv = getInheritableFieldValue(name); 101 QPDFObjectHandle fv = getInheritableFieldValue(name);
106 std::string result; 102 std::string result;
@@ -125,9 +121,7 @@ QPDFFormFieldObjectHelper::getFullyQualifiedName() @@ -125,9 +121,7 @@ QPDFFormFieldObjectHelper::getFullyQualifiedName()
125 while (!node.isNull() && seen.add(node)) { 121 while (!node.isNull() && seen.add(node)) {
126 if (node.getKey("/T").isString()) { 122 if (node.getKey("/T").isString()) {
127 if (!result.empty()) { 123 if (!result.empty()) {
128 - QTC::TC(  
129 - "qpdf",  
130 - "QPDFFormFieldObjectHelper non-trivial qualified name"); 124 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper non-trivial qualified name");
131 result = "." + result; 125 result = "." + result;
132 } 126 }
133 result = node.getKey("/T").getUTF8Value() + result; 127 result = node.getKey("/T").getUTF8Value() + result;
@@ -210,10 +204,7 @@ QPDFFormFieldObjectHelper::getDefaultAppearance() @@ -210,10 +204,7 @@ QPDFFormFieldObjectHelper::getDefaultAppearance()
210 } 204 }
211 std::string result; 205 std::string result;
212 if (value.isString()) { 206 if (value.isString()) {
213 - QTC::TC(  
214 - "qpdf",  
215 - "QPDFFormFieldObjectHelper DA present",  
216 - looked_in_acroform ? 0 : 1); 207 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper DA present", looked_in_acroform ? 0 : 1);
217 result = value.getUTF8Value(); 208 result = value.getUTF8Value();
218 } 209 }
219 return result; 210 return result;
@@ -230,10 +221,7 @@ QPDFFormFieldObjectHelper::getQuadding() @@ -230,10 +221,7 @@ QPDFFormFieldObjectHelper::getQuadding()
230 } 221 }
231 int result = 0; 222 int result = 0;
232 if (fv.isInteger()) { 223 if (fv.isInteger()) {
233 - QTC::TC(  
234 - "qpdf",  
235 - "QPDFFormFieldObjectHelper Q present",  
236 - looked_in_acroform ? 0 : 1); 224 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper Q present", looked_in_acroform ? 0 : 1);
237 result = QIntC::to_int(fv.getIntValue()); 225 result = QIntC::to_int(fv.getIntValue());
238 } 226 }
239 return result; 227 return result;
@@ -255,25 +243,19 @@ QPDFFormFieldObjectHelper::isText() @@ -255,25 +243,19 @@ QPDFFormFieldObjectHelper::isText()
255 bool 243 bool
256 QPDFFormFieldObjectHelper::isCheckbox() 244 QPDFFormFieldObjectHelper::isCheckbox()
257 { 245 {
258 - return (  
259 - (getFieldType() == "/Btn") &&  
260 - ((getFlags() & (ff_btn_radio | ff_btn_pushbutton)) == 0)); 246 + return ((getFieldType() == "/Btn") && ((getFlags() & (ff_btn_radio | ff_btn_pushbutton)) == 0));
261 } 247 }
262 248
263 bool 249 bool
264 QPDFFormFieldObjectHelper::isRadioButton() 250 QPDFFormFieldObjectHelper::isRadioButton()
265 { 251 {
266 - return (  
267 - (getFieldType() == "/Btn") &&  
268 - ((getFlags() & ff_btn_radio) == ff_btn_radio)); 252 + return ((getFieldType() == "/Btn") && ((getFlags() & ff_btn_radio) == ff_btn_radio));
269 } 253 }
270 254
271 bool 255 bool
272 QPDFFormFieldObjectHelper::isPushbutton() 256 QPDFFormFieldObjectHelper::isPushbutton()
273 { 257 {
274 - return (  
275 - (getFieldType() == "/Btn") &&  
276 - ((getFlags() & ff_btn_pushbutton) == ff_btn_pushbutton)); 258 + return ((getFieldType() == "/Btn") && ((getFlags() & ff_btn_pushbutton) == ff_btn_pushbutton));
277 } 259 }
278 260
279 bool 261 bool
@@ -303,15 +285,13 @@ QPDFFormFieldObjectHelper::getChoices() @@ -303,15 +285,13 @@ QPDFFormFieldObjectHelper::getChoices()
303 } 285 }
304 286
305 void 287 void
306 -QPDFFormFieldObjectHelper::setFieldAttribute(  
307 - std::string const& key, QPDFObjectHandle value) 288 +QPDFFormFieldObjectHelper::setFieldAttribute(std::string const& key, QPDFObjectHandle value)
308 { 289 {
309 this->oh.replaceKey(key, value); 290 this->oh.replaceKey(key, value);
310 } 291 }
311 292
312 void 293 void
313 -QPDFFormFieldObjectHelper::setFieldAttribute(  
314 - std::string const& key, std::string const& utf8_value) 294 +QPDFFormFieldObjectHelper::setFieldAttribute(std::string const& key, std::string const& utf8_value)
315 { 295 {
316 this->oh.replaceKey(key, QPDFObjectHandle::newUnicodeString(utf8_value)); 296 this->oh.replaceKey(key, QPDFObjectHandle::newUnicodeString(utf8_value));
317 } 297 }
@@ -330,41 +310,36 @@ QPDFFormFieldObjectHelper::setV(QPDFObjectHandle value, bool need_appearances) @@ -330,41 +310,36 @@ QPDFFormFieldObjectHelper::setV(QPDFObjectHandle value, bool need_appearances)
330 } 310 }
331 } 311 }
332 if (!okay) { 312 if (!okay) {
333 - this->oh.warnIfPossible(  
334 - "ignoring attempt to set a checkbox field to a"  
335 - " value of other than /Yes or /Off"); 313 + this->oh.warnIfPossible("ignoring attempt to set a checkbox field to a"
  314 + " value of other than /Yes or /Off");
336 } 315 }
337 } else if (isRadioButton()) { 316 } else if (isRadioButton()) {
338 if (value.isName()) { 317 if (value.isName()) {
339 setRadioButtonValue(value); 318 setRadioButtonValue(value);
340 } else { 319 } else {
341 - this->oh.warnIfPossible(  
342 - "ignoring attempt to set a radio button field to"  
343 - " an object that is not a name"); 320 + this->oh.warnIfPossible("ignoring attempt to set a radio button field to"
  321 + " an object that is not a name");
344 } 322 }
345 } else if (isPushbutton()) { 323 } else if (isPushbutton()) {
346 - this->oh.warnIfPossible(  
347 - "ignoring attempt set the value of a pushbutton field"); 324 + this->oh.warnIfPossible("ignoring attempt set the value of a pushbutton field");
348 } 325 }
349 return; 326 return;
350 } 327 }
351 if (value.isString()) { 328 if (value.isString()) {
352 - setFieldAttribute(  
353 - "/V", QPDFObjectHandle::newUnicodeString(value.getUTF8Value())); 329 + setFieldAttribute("/V", QPDFObjectHandle::newUnicodeString(value.getUTF8Value()));
354 } else { 330 } else {
355 setFieldAttribute("/V", value); 331 setFieldAttribute("/V", value);
356 } 332 }
357 if (need_appearances) { 333 if (need_appearances) {
358 - QPDF& qpdf = this->oh.getQPDF(  
359 - "QPDFFormFieldObjectHelper::setV called with need_appearances = "  
360 - "true on an object that is not associated with an owning QPDF"); 334 + QPDF& qpdf =
  335 + this->oh.getQPDF("QPDFFormFieldObjectHelper::setV called with need_appearances = "
  336 + "true on an object that is not associated with an owning QPDF");
361 QPDFAcroFormDocumentHelper(qpdf).setNeedAppearances(true); 337 QPDFAcroFormDocumentHelper(qpdf).setNeedAppearances(true);
362 } 338 }
363 } 339 }
364 340
365 void 341 void
366 -QPDFFormFieldObjectHelper::setV(  
367 - std::string const& utf8_value, bool need_appearances) 342 +QPDFFormFieldObjectHelper::setV(std::string const& utf8_value, bool need_appearances)
368 { 343 {
369 setV(QPDFObjectHandle::newUnicodeString(utf8_value), need_appearances); 344 setV(QPDFObjectHandle::newUnicodeString(utf8_value), need_appearances);
370 } 345 }
@@ -390,8 +365,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name) @@ -390,8 +365,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
390 if (ph.isRadioButton()) { 365 if (ph.isRadioButton()) {
391 // This is most likely one of the individual buttons. Try 366 // This is most likely one of the individual buttons. Try
392 // calling on the parent. 367 // calling on the parent.
393 - QTC::TC(  
394 - "qpdf", "QPDFFormFieldObjectHelper set parent radio button"); 368 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper set parent radio button");
395 ph.setRadioButtonValue(name); 369 ph.setRadioButtonValue(name);
396 return; 370 return;
397 } 371 }
@@ -419,9 +393,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name) @@ -419,9 +393,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
419 QPDFObjectHandle grandkid = grandkids.getArrayItem(j); 393 QPDFObjectHandle grandkid = grandkids.getArrayItem(j);
420 AP = grandkid.getKey("/AP"); 394 AP = grandkid.getKey("/AP");
421 if (!AP.isNull()) { 395 if (!AP.isNull()) {
422 - QTC::TC(  
423 - "qpdf",  
424 - "QPDFFormFieldObjectHelper radio button grandkid"); 396 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper radio button grandkid");
425 annot = grandkid; 397 annot = grandkid;
426 break; 398 break;
427 } 399 }
@@ -432,8 +404,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name) @@ -432,8 +404,7 @@ QPDFFormFieldObjectHelper::setRadioButtonValue(QPDFObjectHandle name)
432 } 404 }
433 if (!annot.isInitialized()) { 405 if (!annot.isInitialized()) {
434 QTC::TC("qpdf", "QPDFObjectHandle broken radio button"); 406 QTC::TC("qpdf", "QPDFObjectHandle broken radio button");
435 - this->oh.warnIfPossible(  
436 - "unable to set the value of this radio button"); 407 + this->oh.warnIfPossible("unable to set the value of this radio button");
437 continue; 408 continue;
438 } 409 }
439 if (AP.isDictionary() && AP.getKey("/N").isDictionary() && 410 if (AP.isDictionary() && AP.getKey("/N").isDictionary() &&
@@ -465,9 +436,7 @@ QPDFFormFieldObjectHelper::setCheckBoxValue(bool value) @@ -465,9 +436,7 @@ QPDFFormFieldObjectHelper::setCheckBoxValue(bool value)
465 QPDFObjectHandle kid = kids.getArrayItem(i); 436 QPDFObjectHandle kid = kids.getArrayItem(i);
466 AP = kid.getKey("/AP"); 437 AP = kid.getKey("/AP");
467 if (!AP.isNull()) { 438 if (!AP.isNull()) {
468 - QTC::TC(  
469 - "qpdf",  
470 - "QPDFFormFieldObjectHelper checkbox kid widget"); 439 + QTC::TC("qpdf", "QPDFFormFieldObjectHelper checkbox kid widget");
471 annot = kid; 440 annot = kid;
472 break; 441 break;
473 } 442 }
@@ -555,8 +524,7 @@ ValueSetter::handleToken(QPDFTokenizer::Token const&amp; token) @@ -555,8 +524,7 @@ ValueSetter::handleToken(QPDFTokenizer::Token const&amp; token)
555 break; 524 break;
556 525
557 case st_bmc: 526 case st_bmc:
558 - if ((ttype == QPDFTokenizer::tt_space) ||  
559 - (ttype == QPDFTokenizer::tt_comment)) { 527 + if ((ttype == QPDFTokenizer::tt_space) || (ttype == QPDFTokenizer::tt_comment)) {
560 writeToken(token); 528 writeToken(token);
561 } else { 529 } else {
562 state = st_emc; 530 state = st_emc;
@@ -642,9 +610,7 @@ ValueSetter::writeAppearance() @@ -642,9 +610,7 @@ ValueSetter::writeAppearance()
642 } 610 }
643 highlight = true; 611 highlight = true;
644 highlight_idx = found_idx - QIntC::to_size(wanted_first); 612 highlight_idx = found_idx - QIntC::to_size(wanted_first);
645 - for (size_t i = QIntC::to_size(wanted_first);  
646 - i <= QIntC::to_size(wanted_last);  
647 - ++i) { 613 + for (size_t i = QIntC::to_size(wanted_first); i <= QIntC::to_size(wanted_last); ++i) {
648 lines.push_back(opt.at(i)); 614 lines.push_back(opt.at(i));
649 } 615 }
650 } else { 616 } else {
@@ -661,14 +627,12 @@ ValueSetter::writeAppearance() @@ -661,14 +627,12 @@ ValueSetter::writeAppearance()
661 627
662 // Write the lines centered vertically, highlighting if needed 628 // Write the lines centered vertically, highlighting if needed
663 size_t nlines = lines.size(); 629 size_t nlines = lines.size();
664 - double dy = bbox.ury -  
665 - ((bbox.ury - bbox.lly - (static_cast<double>(nlines) * tfh)) / 2.0); 630 + double dy = bbox.ury - ((bbox.ury - bbox.lly - (static_cast<double>(nlines) * tfh)) / 2.0);
666 if (highlight) { 631 if (highlight) {
667 write( 632 write(
668 "q\n0.85 0.85 0.85 rg\n" + QUtil::double_to_string(bbox.llx) + " " + 633 "q\n0.85 0.85 0.85 rg\n" + QUtil::double_to_string(bbox.llx) + " " +
669 QUtil::double_to_string( 634 QUtil::double_to_string(
670 - bbox.lly + dy -  
671 - (tfh * (static_cast<double>(highlight_idx + 1)))) + 635 + bbox.lly + dy - (tfh * (static_cast<double>(highlight_idx + 1)))) +
672 " " + QUtil::double_to_string(bbox.urx - bbox.llx) + " " + 636 " " + QUtil::double_to_string(bbox.urx - bbox.llx) + " " +
673 QUtil::double_to_string(tfh) + " re f\nQ\n"); 637 QUtil::double_to_string(tfh) + " re f\nQ\n");
674 } 638 }
@@ -681,10 +645,8 @@ ValueSetter::writeAppearance() @@ -681,10 +645,8 @@ ValueSetter::writeAppearance()
681 // which doesn't seem really worth the effort. 645 // which doesn't seem really worth the effort.
682 if (i == 0) { 646 if (i == 0) {
683 write( 647 write(
684 - QUtil::double_to_string(bbox.llx + static_cast<double>(dx)) +  
685 - " " +  
686 - QUtil::double_to_string(bbox.lly + static_cast<double>(dy)) +  
687 - " Td\n"); 648 + QUtil::double_to_string(bbox.llx + static_cast<double>(dx)) + " " +
  649 + QUtil::double_to_string(bbox.lly + static_cast<double>(dy)) + " Td\n");
688 } else { 650 } else {
689 write("0 " + QUtil::double_to_string(-tfh) + " Td\n"); 651 write("0 " + QUtil::double_to_string(-tfh) + " Td\n");
690 } 652 }
@@ -794,8 +756,7 @@ TfFinder::getFontName() @@ -794,8 +756,7 @@ TfFinder::getFontName()
794 } 756 }
795 757
796 QPDFObjectHandle 758 QPDFObjectHandle
797 -QPDFFormFieldObjectHelper::getFontFromResource(  
798 - QPDFObjectHandle resources, std::string const& name) 759 +QPDFFormFieldObjectHelper::getFontFromResource(QPDFObjectHandle resources, std::string const& name)
799 { 760 {
800 QPDFObjectHandle result; 761 QPDFObjectHandle result;
801 if (resources.isDictionary() && resources.getKey("/Font").isDictionary() && 762 if (resources.isDictionary() && resources.getKey("/Font").isDictionary() &&
@@ -806,40 +767,34 @@ QPDFFormFieldObjectHelper::getFontFromResource( @@ -806,40 +767,34 @@ QPDFFormFieldObjectHelper::getFontFromResource(
806 } 767 }
807 768
808 void 769 void
809 -QPDFFormFieldObjectHelper::generateTextAppearance(  
810 - QPDFAnnotationObjectHelper& aoh) 770 +QPDFFormFieldObjectHelper::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
811 { 771 {
812 QPDFObjectHandle AS = aoh.getAppearanceStream("/N"); 772 QPDFObjectHandle AS = aoh.getAppearanceStream("/N");
813 if (AS.isNull()) { 773 if (AS.isNull()) {
814 QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AS from scratch"); 774 QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AS from scratch");
815 QPDFObjectHandle::Rectangle rect = aoh.getRect(); 775 QPDFObjectHandle::Rectangle rect = aoh.getRect();
816 - QPDFObjectHandle::Rectangle bbox(  
817 - 0, 0, rect.urx - rect.llx, rect.ury - rect.lly);  
818 - QPDFObjectHandle dict = QPDFObjectHandle::parse(  
819 - "<< /Resources << /ProcSet [ /PDF /Text ] >>"  
820 - " /Type /XObject /Subtype /Form >>"); 776 + QPDFObjectHandle::Rectangle bbox(0, 0, rect.urx - rect.llx, rect.ury - rect.lly);
  777 + QPDFObjectHandle dict =
  778 + QPDFObjectHandle::parse("<< /Resources << /ProcSet [ /PDF /Text ] >>"
  779 + " /Type /XObject /Subtype /Form >>");
821 dict.replaceKey("/BBox", QPDFObjectHandle::newFromRectangle(bbox)); 780 dict.replaceKey("/BBox", QPDFObjectHandle::newFromRectangle(bbox));
822 - AS = QPDFObjectHandle::newStream(  
823 - this->oh.getOwningQPDF(), "/Tx BMC\nEMC\n"); 781 + AS = QPDFObjectHandle::newStream(this->oh.getOwningQPDF(), "/Tx BMC\nEMC\n");
824 AS.replaceDict(dict); 782 AS.replaceDict(dict);
825 QPDFObjectHandle AP = aoh.getAppearanceDictionary(); 783 QPDFObjectHandle AP = aoh.getAppearanceDictionary();
826 if (AP.isNull()) { 784 if (AP.isNull()) {
827 QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AP from scratch"); 785 QTC::TC("qpdf", "QPDFFormFieldObjectHelper create AP from scratch");
828 - aoh.getObjectHandle().replaceKey(  
829 - "/AP", QPDFObjectHandle::newDictionary()); 786 + aoh.getObjectHandle().replaceKey("/AP", QPDFObjectHandle::newDictionary());
830 AP = aoh.getAppearanceDictionary(); 787 AP = aoh.getAppearanceDictionary();
831 } 788 }
832 AP.replaceKey("/N", AS); 789 AP.replaceKey("/N", AS);
833 } 790 }
834 if (!AS.isStream()) { 791 if (!AS.isStream()) {
835 - aoh.getObjectHandle().warnIfPossible(  
836 - "unable to get normal appearance stream for update"); 792 + aoh.getObjectHandle().warnIfPossible("unable to get normal appearance stream for update");
837 return; 793 return;
838 } 794 }
839 QPDFObjectHandle bbox_obj = AS.getDict().getKey("/BBox"); 795 QPDFObjectHandle bbox_obj = AS.getDict().getKey("/BBox");
840 if (!bbox_obj.isRectangle()) { 796 if (!bbox_obj.isRectangle()) {
841 - aoh.getObjectHandle().warnIfPossible(  
842 - "unable to get appearance stream bounding box"); 797 + aoh.getObjectHandle().warnIfPossible("unable to get appearance stream bounding box");
843 return; 798 return;
844 } 799 }
845 QPDFObjectHandle::Rectangle bbox = bbox_obj.getArrayAsRectangle(); 800 QPDFObjectHandle::Rectangle bbox = bbox_obj.getArrayAsRectangle();
@@ -872,8 +827,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance( @@ -872,8 +827,7 @@ QPDFFormFieldObjectHelper::generateTextAppearance(
872 if (found_font_in_dr && resources.isDictionary()) { 827 if (found_font_in_dr && resources.isDictionary()) {
873 QTC::TC("qpdf", "QPDFFormFieldObjectHelper get font from /DR"); 828 QTC::TC("qpdf", "QPDFFormFieldObjectHelper get font from /DR");
874 if (resources.isIndirect()) { 829 if (resources.isIndirect()) {
875 - resources = resources.getQPDF().makeIndirectObject(  
876 - resources.shallowCopy()); 830 + resources = resources.getQPDF().makeIndirectObject(resources.shallowCopy());
877 AS.getDict().replaceKey("/Resources", resources); 831 AS.getDict().replaceKey("/Resources", resources);
878 } 832 }
879 // Use mergeResources to force /Font to be local 833 // Use mergeResources to force /Font to be local
@@ -899,6 +853,5 @@ QPDFFormFieldObjectHelper::generateTextAppearance( @@ -899,6 +853,5 @@ QPDFFormFieldObjectHelper::generateTextAppearance(
899 853
900 AS.addTokenFilter( 854 AS.addTokenFilter(
901 // line-break 855 // line-break
902 - std::shared_ptr<QPDFObjectHandle::TokenFilter>(  
903 - new ValueSetter(DA, V, opt, tf, bbox))); 856 + std::shared_ptr<QPDFObjectHandle::TokenFilter>(new ValueSetter(DA, V, opt, tf, bbox)));
904 } 857 }
libqpdf/QPDFJob.cc
@@ -50,8 +50,7 @@ namespace @@ -50,8 +50,7 @@ namespace
50 QPDFObjectHandle& image); 50 QPDFObjectHandle& image);
51 ~ImageOptimizer() override = default; 51 ~ImageOptimizer() override = default;
52 void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override; 52 void provideStreamData(QPDFObjGen const&, Pipeline* pipeline) override;
53 - std::shared_ptr<Pipeline>  
54 - makePipeline(std::string const& description, Pipeline* next); 53 + std::shared_ptr<Pipeline> makePipeline(std::string const& description, Pipeline* next);
55 bool evaluate(std::string const& description); 54 bool evaluate(std::string const& description);
56 55
57 private: 56 private:
@@ -78,8 +77,7 @@ namespace @@ -78,8 +77,7 @@ namespace
78 77
79 struct QPDFPageData 78 struct QPDFPageData
80 { 79 {
81 - QPDFPageData(  
82 - std::string const& filename, QPDF* qpdf, std::string const& range); 80 + QPDFPageData(std::string const& filename, QPDF* qpdf, std::string const& range);
83 QPDFPageData(QPDFPageData const& other, int page); 81 QPDFPageData(QPDFPageData const& other, int page);
84 82
85 std::string filename; 83 std::string filename;
@@ -91,8 +89,7 @@ namespace @@ -91,8 +89,7 @@ namespace
91 class ProgressReporter: public QPDFWriter::ProgressReporter 89 class ProgressReporter: public QPDFWriter::ProgressReporter
92 { 90 {
93 public: 91 public:
94 - ProgressReporter(  
95 - Pipeline& p, std::string const& prefix, char const* filename) : 92 + ProgressReporter(Pipeline& p, std::string const& prefix, char const* filename) :
96 p(p), 93 p(p),
97 prefix(prefix), 94 prefix(prefix),
98 filename(filename) 95 filename(filename)
@@ -133,8 +130,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next) @@ -133,8 +130,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
133 if (!(w_obj.isNumber() && h_obj.isNumber())) { 130 if (!(w_obj.isNumber() && h_obj.isNumber())) {
134 if (!description.empty()) { 131 if (!description.empty()) {
135 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) { 132 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
136 - v << prefix << ": " << description  
137 - << ": not optimizing because image dictionary" 133 + v << prefix << ": " << description << ": not optimizing because image dictionary"
138 << " is missing required keys\n"; 134 << " is missing required keys\n";
139 }); 135 });
140 } 136 }
@@ -166,8 +162,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next) @@ -166,8 +162,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
166 } else { 162 } else {
167 h = static_cast<JDIMENSION>(h_obj.getNumericValue()); 163 h = static_cast<JDIMENSION>(h_obj.getNumericValue());
168 } 164 }
169 - std::string colorspace =  
170 - (colorspace_obj.isName() ? colorspace_obj.getName() : std::string()); 165 + std::string colorspace = (colorspace_obj.isName() ? colorspace_obj.getName() : std::string());
171 int components = 0; 166 int components = 0;
172 J_COLOR_SPACE cs = JCS_UNKNOWN; 167 J_COLOR_SPACE cs = JCS_UNKNOWN;
173 if (colorspace == "/DeviceRGB") { 168 if (colorspace == "/DeviceRGB") {
@@ -183,8 +178,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next) @@ -183,8 +178,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
183 QTC::TC("qpdf", "QPDFJob image optimize colorspace"); 178 QTC::TC("qpdf", "QPDFJob image optimize colorspace");
184 if (!description.empty()) { 179 if (!description.empty()) {
185 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) { 180 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
186 - v << prefix << ": " << description  
187 - << ": not optimizing because qpdf can't optimize" 181 + v << prefix << ": " << description << ": not optimizing because qpdf can't optimize"
188 << " images with this colorspace\n"; 182 << " images with this colorspace\n";
189 }); 183 });
190 } 184 }
@@ -196,8 +190,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next) @@ -196,8 +190,7 @@ ImageOptimizer::makePipeline(std::string const&amp; description, Pipeline* next)
196 QTC::TC("qpdf", "QPDFJob image optimize too small"); 190 QTC::TC("qpdf", "QPDFJob image optimize too small");
197 if (!description.empty()) { 191 if (!description.empty()) {
198 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) { 192 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
199 - v << prefix << ": " << description  
200 - << ": not optimizing because image" 193 + v << prefix << ": " << description << ": not optimizing because image"
201 << " is smaller than requested minimum dimensions\n"; 194 << " is smaller than requested minimum dimensions\n";
202 }); 195 });
203 } 196 }
@@ -214,8 +207,7 @@ ImageOptimizer::evaluate(std::string const&amp; description) @@ -214,8 +207,7 @@ ImageOptimizer::evaluate(std::string const&amp; description)
214 if (!image.pipeStreamData(nullptr, 0, qpdf_dl_specialized, true)) { 207 if (!image.pipeStreamData(nullptr, 0, qpdf_dl_specialized, true)) {
215 QTC::TC("qpdf", "QPDFJob image optimize no pipeline"); 208 QTC::TC("qpdf", "QPDFJob image optimize no pipeline");
216 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) { 209 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
217 - v << prefix << ": " << description  
218 - << ": not optimizing because unable to decode data" 210 + v << prefix << ": " << description << ": not optimizing because unable to decode data"
219 << " or data already uses DCT\n"; 211 << " or data already uses DCT\n";
220 }); 212 });
221 return false; 213 return false;
@@ -241,9 +233,8 @@ ImageOptimizer::evaluate(std::string const&amp; description) @@ -241,9 +233,8 @@ ImageOptimizer::evaluate(std::string const&amp; description)
241 return false; 233 return false;
242 } 234 }
243 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) { 235 o.doIfVerbose([&](Pipeline& v, std::string const& prefix) {
244 - v << prefix << ": " << description  
245 - << ": optimizing image reduces size from " << orig_length << " to "  
246 - << c.getCount() << "\n"; 236 + v << prefix << ": " << description << ": optimizing image reduces size from " << orig_length
  237 + << " to " << c.getCount() << "\n";
247 }); 238 });
248 return true; 239 return true;
249 } 240 }
@@ -263,9 +254,7 @@ ImageOptimizer::provideStreamData(QPDFObjGen const&amp;, Pipeline* pipeline) @@ -263,9 +254,7 @@ ImageOptimizer::provideStreamData(QPDFObjGen const&amp;, Pipeline* pipeline)
263 } 254 }
264 255
265 QPDFJob::PageSpec::PageSpec( 256 QPDFJob::PageSpec::PageSpec(
266 - std::string const& filename,  
267 - char const* password,  
268 - std::string const& range) : 257 + std::string const& filename, char const* password, std::string const& range) :
269 filename(filename), 258 filename(filename),
270 range(range) 259 range(range)
271 { 260 {
@@ -274,18 +263,16 @@ QPDFJob::PageSpec::PageSpec( @@ -274,18 +263,16 @@ QPDFJob::PageSpec::PageSpec(
274 } 263 }
275 } 264 }
276 265
277 -QPDFPageData::QPDFPageData(  
278 - std::string const& filename, QPDF* qpdf, std::string const& range) : 266 +QPDFPageData::QPDFPageData(std::string const& filename, QPDF* qpdf, std::string const& range) :
279 filename(filename), 267 filename(filename),
280 qpdf(qpdf), 268 qpdf(qpdf),
281 orig_pages(qpdf->getAllPages()) 269 orig_pages(qpdf->getAllPages())
282 { 270 {
283 try { 271 try {
284 - this->selected_pages = QUtil::parse_numrange(  
285 - range.c_str(), QIntC::to_int(this->orig_pages.size())); 272 + this->selected_pages =
  273 + QUtil::parse_numrange(range.c_str(), QIntC::to_int(this->orig_pages.size()));
286 } catch (std::runtime_error& e) { 274 } catch (std::runtime_error& e) {
287 - throw std::runtime_error(  
288 - "parsing numeric range for " + filename + ": " + e.what()); 275 + throw std::runtime_error("parsing numeric range for " + filename + ": " + e.what());
289 } 276 }
290 } 277 }
291 278
@@ -300,8 +287,7 @@ QPDFPageData::QPDFPageData(QPDFPageData const&amp; other, int page) : @@ -300,8 +287,7 @@ QPDFPageData::QPDFPageData(QPDFPageData const&amp; other, int page) :
300 void 287 void
301 ProgressReporter::reportProgress(int percentage) 288 ProgressReporter::reportProgress(int percentage)
302 { 289 {
303 - this->p << prefix << ": " << filename << ": write progress: " << percentage  
304 - << "%\n"; 290 + this->p << prefix << ": " << filename << ": write progress: " << percentage << "%\n";
305 } 291 }
306 292
307 QPDFJob::Members::Members() : 293 QPDFJob::Members::Members() :
@@ -358,8 +344,7 @@ QPDFJob::registerProgressReporter(std::function&lt;void(int)&gt; handler) @@ -358,8 +344,7 @@ QPDFJob::registerProgressReporter(std::function&lt;void(int)&gt; handler)
358 } 344 }
359 345
360 void 346 void
361 -QPDFJob::doIfVerbose(  
362 - std::function<void(Pipeline&, std::string const& prefix)> fn) 347 +QPDFJob::doIfVerbose(std::function<void(Pipeline&, std::string const& prefix)> fn)
363 { 348 {
364 if (m->verbose) { 349 if (m->verbose) {
365 fn(*m->log->getInfo(), m->message_prefix); 350 fn(*m->log->getInfo(), m->message_prefix);
@@ -459,8 +444,7 @@ QPDFJob::createQPDF() @@ -459,8 +444,7 @@ QPDFJob::createQPDF()
459 // Allow certain operations to work when an incorrect 444 // Allow certain operations to work when an incorrect
460 // password is supplied. 445 // password is supplied.
461 if (m->check_is_encrypted || m->check_requires_password) { 446 if (m->check_is_encrypted || m->check_requires_password) {
462 - m->encryption_status =  
463 - qpdf_es_encrypted | qpdf_es_password_incorrect; 447 + m->encryption_status = qpdf_es_encrypted | qpdf_es_password_incorrect;
464 return nullptr; 448 return nullptr;
465 } 449 }
466 if (m->show_encryption && pdf_sp) { 450 if (m->show_encryption && pdf_sp) {
@@ -513,12 +497,10 @@ QPDFJob::writeQPDF(QPDF&amp; pdf) @@ -513,12 +497,10 @@ QPDFJob::writeQPDF(QPDF&amp; pdf)
513 } 497 }
514 if (m->warnings && (!m->suppress_warnings)) { 498 if (m->warnings && (!m->suppress_warnings)) {
515 if (createsOutput()) { 499 if (createsOutput()) {
516 - *m->log->getWarn()  
517 - << m->message_prefix << ": operation succeeded with warnings;"  
518 - << " resulting file may have some problems\n"; 500 + *m->log->getWarn() << m->message_prefix << ": operation succeeded with warnings;"
  501 + << " resulting file may have some problems\n";
519 } else { 502 } else {
520 - *m->log->getWarn()  
521 - << m->message_prefix << ": operation succeeded with warnings\n"; 503 + *m->log->getWarn() << m->message_prefix << ": operation succeeded with warnings\n";
522 } 504 }
523 } 505 }
524 if (m->report_mem_usage) { 506 if (m->report_mem_usage) {
@@ -611,13 +593,9 @@ QPDFJob::checkConfiguration() @@ -611,13 +593,9 @@ QPDFJob::checkConfiguration()
611 usage("an input file name is required"); 593 usage("an input file name is required");
612 } else if (m->replace_input && (strlen(m->infilename.get()) == 0)) { 594 } else if (m->replace_input && (strlen(m->infilename.get()) == 0)) {
613 usage("--replace-input may not be used with --empty"); 595 usage("--replace-input may not be used with --empty");
614 - } else if (  
615 - m->require_outfile && (m->outfilename == nullptr) &&  
616 - (!m->replace_input)) { 596 + } else if (m->require_outfile && (m->outfilename == nullptr) && (!m->replace_input)) {
617 usage("an output file name is required; use - for standard output"); 597 usage("an output file name is required; use - for standard output");
618 - } else if (  
619 - (!m->require_outfile) &&  
620 - ((m->outfilename != nullptr) || m->replace_input)) { 598 + } else if ((!m->require_outfile) && ((m->outfilename != nullptr) || m->replace_input)) {
621 usage("no output file may be given for this option"); 599 usage("no output file may be given for this option");
622 } 600 }
623 if (m->check_requires_password && m->check_is_encrypted) { 601 if (m->check_requires_password && m->check_is_encrypted) {
@@ -626,8 +604,7 @@ QPDFJob::checkConfiguration() @@ -626,8 +604,7 @@ QPDFJob::checkConfiguration()
626 } 604 }
627 605
628 if (m->encrypt && (!m->allow_insecure) && 606 if (m->encrypt && (!m->allow_insecure) &&
629 - (m->owner_password.empty() && (!m->user_password.empty()) &&  
630 - (m->keylen == 256))) { 607 + (m->owner_password.empty() && (!m->user_password.empty()) && (m->keylen == 256))) {
631 // Note that empty owner passwords for R < 5 are copied from 608 // Note that empty owner passwords for R < 5 are copied from
632 // the user password, so this lack of security is not an issue 609 // the user password, so this lack of security is not an issue
633 // for those files. Also we are consider only the ability to 610 // for those files. Also we are consider only the ability to
@@ -642,8 +619,7 @@ QPDFJob::checkConfiguration() @@ -642,8 +619,7 @@ QPDFJob::checkConfiguration()
642 } 619 }
643 620
644 bool save_to_stdout = false; 621 bool save_to_stdout = false;
645 - if (m->require_outfile && m->outfilename &&  
646 - (strcmp(m->outfilename.get(), "-") == 0)) { 622 + if (m->require_outfile && m->outfilename && (strcmp(m->outfilename.get(), "-") == 0)) {
647 if (m->split_pages) { 623 if (m->split_pages) {
648 usage("--split-pages may not be used when" 624 usage("--split-pages may not be used when"
649 " writing to standard output"); 625 " writing to standard output");
@@ -656,8 +632,7 @@ QPDFJob::checkConfiguration() @@ -656,8 +632,7 @@ QPDFJob::checkConfiguration()
656 if (save_to_stdout) { 632 if (save_to_stdout) {
657 m->log->saveToStandardOutput(true); 633 m->log->saveToStandardOutput(true);
658 } 634 }
659 - if ((!m->split_pages) &&  
660 - QUtil::same_file(m->infilename.get(), m->outfilename.get())) { 635 + if ((!m->split_pages) && QUtil::same_file(m->infilename.get(), m->outfilename.get())) {
661 QTC::TC("qpdf", "QPDFJob same file error"); 636 QTC::TC("qpdf", "QPDFJob same file error");
662 usage("input file and output file are the same;" 637 usage("input file and output file are the same;"
663 " use --replace-input to intentionally" 638 " use --replace-input to intentionally"
@@ -751,8 +726,7 @@ QPDFJob::showEncryption(QPDF&amp; pdf) @@ -751,8 +726,7 @@ QPDFJob::showEncryption(QPDF&amp; pdf)
751 std::string encryption_key = pdf.getEncryptionKey(); 726 std::string encryption_key = pdf.getEncryptionKey();
752 cout << "User password = " << user_password << "\n"; 727 cout << "User password = " << user_password << "\n";
753 if (m->show_encryption_key) { 728 if (m->show_encryption_key) {
754 - cout << "Encryption key = " << QUtil::hex_encode(encryption_key)  
755 - << "\n"; 729 + cout << "Encryption key = " << QUtil::hex_encode(encryption_key) << "\n";
756 } 730 }
757 if (pdf.ownerPasswordMatched()) { 731 if (pdf.ownerPasswordMatched()) {
758 cout << "Supplied password is owner password\n"; 732 cout << "Supplied password is owner password\n";
@@ -760,28 +734,19 @@ QPDFJob::showEncryption(QPDF&amp; pdf) @@ -760,28 +734,19 @@ QPDFJob::showEncryption(QPDF&amp; pdf)
760 if (pdf.userPasswordMatched()) { 734 if (pdf.userPasswordMatched()) {
761 cout << "Supplied password is user password\n"; 735 cout << "Supplied password is user password\n";
762 } 736 }
763 - cout << "extract for accessibility: "  
764 - << show_bool(pdf.allowAccessibility()) << "\n"  
765 - << "extract for any purpose: " << show_bool(pdf.allowExtractAll())  
766 - << "\n"  
767 - << "print low resolution: " << show_bool(pdf.allowPrintLowRes())  
768 - << "\n"  
769 - << "print high resolution: " << show_bool(pdf.allowPrintHighRes())  
770 - << "\n"  
771 - << "modify document assembly: "  
772 - << show_bool(pdf.allowModifyAssembly()) << "\n" 737 + cout << "extract for accessibility: " << show_bool(pdf.allowAccessibility()) << "\n"
  738 + << "extract for any purpose: " << show_bool(pdf.allowExtractAll()) << "\n"
  739 + << "print low resolution: " << show_bool(pdf.allowPrintLowRes()) << "\n"
  740 + << "print high resolution: " << show_bool(pdf.allowPrintHighRes()) << "\n"
  741 + << "modify document assembly: " << show_bool(pdf.allowModifyAssembly()) << "\n"
773 << "modify forms: " << show_bool(pdf.allowModifyForm()) << "\n" 742 << "modify forms: " << show_bool(pdf.allowModifyForm()) << "\n"
774 - << "modify annotations: " << show_bool(pdf.allowModifyAnnotation())  
775 - << "\n" 743 + << "modify annotations: " << show_bool(pdf.allowModifyAnnotation()) << "\n"
776 << "modify other: " << show_bool(pdf.allowModifyOther()) << "\n" 744 << "modify other: " << show_bool(pdf.allowModifyOther()) << "\n"
777 << "modify anything: " << show_bool(pdf.allowModifyAll()) << "\n"; 745 << "modify anything: " << show_bool(pdf.allowModifyAll()) << "\n";
778 if (V >= 4) { 746 if (V >= 4) {
779 - cout << "stream encryption method: "  
780 - << show_encryption_method(stream_method) << "\n"  
781 - << "string encryption method: "  
782 - << show_encryption_method(string_method) << "\n"  
783 - << "file encryption method: "  
784 - << show_encryption_method(file_method) << "\n"; 747 + cout << "stream encryption method: " << show_encryption_method(stream_method) << "\n"
  748 + << "string encryption method: " << show_encryption_method(string_method) << "\n"
  749 + << "file encryption method: " << show_encryption_method(file_method) << "\n";
785 } 750 }
786 } 751 }
787 } 752 }
@@ -830,8 +795,7 @@ QPDFJob::doCheck(QPDF&amp; pdf) @@ -830,8 +795,7 @@ QPDFJob::doCheck(QPDF&amp; pdf)
830 page.parseContents(&discard_contents); 795 page.parseContents(&discard_contents);
831 } catch (QPDFExc& e) { 796 } catch (QPDFExc& e) {
832 okay = false; 797 okay = false;
833 - *m->log->getError()  
834 - << "ERROR: page " << pageno << ": " << e.what() << "\n"; 798 + *m->log->getError() << "ERROR: page " << pageno << ": " << e.what() << "\n";
835 } 799 }
836 } 800 }
837 } catch (std::exception& e) { 801 } catch (std::exception& e) {
@@ -885,8 +849,7 @@ QPDFJob::doShowObj(QPDF&amp; pdf) @@ -885,8 +849,7 @@ QPDFJob::doShowObj(QPDF&amp; pdf)
885 *m->log->getInfo() << obj.unparseResolved() << "\n"; 849 *m->log->getInfo() << obj.unparseResolved() << "\n";
886 } 850 }
887 if (error) { 851 if (error) {
888 - throw std::runtime_error(  
889 - "unable to get object " + obj.getObjGen().unparse(',')); 852 + throw std::runtime_error("unable to get object " + obj.getObjGen().unparse(','));
890 } 853 }
891 } 854 }
892 855
@@ -899,8 +862,8 @@ QPDFJob::doShowPages(QPDF&amp; pdf) @@ -899,8 +862,8 @@ QPDFJob::doShowPages(QPDF&amp; pdf)
899 QPDFObjectHandle page = ph.getObjectHandle(); 862 QPDFObjectHandle page = ph.getObjectHandle();
900 ++pageno; 863 ++pageno;
901 864
902 - cout << "page " << pageno << ": " << page.getObjectID() << " "  
903 - << page.getGeneration() << " R\n"; 865 + cout << "page " << pageno << ": " << page.getObjectID() << " " << page.getGeneration()
  866 + << " R\n";
904 if (m->show_page_images) { 867 if (m->show_page_images) {
905 std::map<std::string, QPDFObjectHandle> images = ph.getImages(); 868 std::map<std::string, QPDFObjectHandle> images = ph.getImages();
906 if (!images.empty()) { 869 if (!images.empty()) {
@@ -911,8 +874,8 @@ QPDFJob::doShowPages(QPDF&amp; pdf) @@ -911,8 +874,8 @@ QPDFJob::doShowPages(QPDF&amp; pdf)
911 QPDFObjectHandle dict = image.getDict(); 874 QPDFObjectHandle dict = image.getDict();
912 int width = dict.getKey("/Width").getIntValueAsInt(); 875 int width = dict.getKey("/Width").getIntValueAsInt();
913 int height = dict.getKey("/Height").getIntValueAsInt(); 876 int height = dict.getKey("/Height").getIntValueAsInt();
914 - cout << " " << name << ": " << image.unparse() << ", "  
915 - << width << " x " << height << "\n"; 877 + cout << " " << name << ": " << image.unparse() << ", " << width << " x "
  878 + << height << "\n";
916 } 879 }
917 } 880 }
918 } 881 }
@@ -932,10 +895,8 @@ QPDFJob::doListAttachments(QPDF&amp; pdf) @@ -932,10 +895,8 @@ QPDFJob::doListAttachments(QPDF&amp; pdf)
932 for (auto const& i: efdh.getEmbeddedFiles()) { 895 for (auto const& i: efdh.getEmbeddedFiles()) {
933 std::string const& key = i.first; 896 std::string const& key = i.first;
934 auto efoh = i.second; 897 auto efoh = i.second;
935 - *m->log->getInfo()  
936 - << key << " -> "  
937 - << efoh->getEmbeddedFileStream().getObjGen().unparse(',')  
938 - << "\n"; 898 + *m->log->getInfo() << key << " -> "
  899 + << efoh->getEmbeddedFileStream().getObjGen().unparse(',') << "\n";
939 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 900 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
940 auto desc = efoh->getDescription(); 901 auto desc = efoh->getDescription();
941 if (!desc.empty()) { 902 if (!desc.empty()) {
@@ -951,12 +912,10 @@ QPDFJob::doListAttachments(QPDF&amp; pdf) @@ -951,12 +912,10 @@ QPDFJob::doListAttachments(QPDF&amp; pdf)
951 auto efs = QPDFEFStreamObjectHelper(i2.second); 912 auto efs = QPDFEFStreamObjectHelper(i2.second);
952 v << " " << i2.first << " -> " 913 v << " " << i2.first << " -> "
953 << efs.getObjectHandle().getObjGen().unparse(',') << "\n"; 914 << efs.getObjectHandle().getObjGen().unparse(',') << "\n";
954 - v << " creation date: " << efs.getCreationDate()  
955 - << "\n" 915 + v << " creation date: " << efs.getCreationDate() << "\n"
956 << " modification date: " << efs.getModDate() << "\n" 916 << " modification date: " << efs.getModDate() << "\n"
957 << " mime type: " << efs.getSubtype() << "\n" 917 << " mime type: " << efs.getSubtype() << "\n"
958 - << " checksum: "  
959 - << QUtil::hex_encode(efs.getChecksum()) << "\n"; 918 + << " checksum: " << QUtil::hex_encode(efs.getChecksum()) << "\n";
960 } 919 }
961 }); 920 });
962 } 921 }
@@ -971,8 +930,7 @@ QPDFJob::doShowAttachment(QPDF&amp; pdf) @@ -971,8 +930,7 @@ QPDFJob::doShowAttachment(QPDF&amp; pdf)
971 QPDFEmbeddedFileDocumentHelper efdh(pdf); 930 QPDFEmbeddedFileDocumentHelper efdh(pdf);
972 auto fs = efdh.getEmbeddedFile(m->attachment_to_show); 931 auto fs = efdh.getEmbeddedFile(m->attachment_to_show);
973 if (!fs) { 932 if (!fs) {
974 - throw std::runtime_error(  
975 - "attachment " + m->attachment_to_show + " not found"); 933 + throw std::runtime_error("attachment " + m->attachment_to_show + " not found");
976 } 934 }
977 auto efs = fs->getEmbeddedFileStream(); 935 auto efs = fs->getEmbeddedFileStream();
978 // saveToStandardOutput has already been called, but it's harmless 936 // saveToStandardOutput has already been called, but it's harmless
@@ -982,8 +940,7 @@ QPDFJob::doShowAttachment(QPDF&amp; pdf) @@ -982,8 +940,7 @@ QPDFJob::doShowAttachment(QPDF&amp; pdf)
982 } 940 }
983 941
984 void 942 void
985 -QPDFJob::parse_object_id(  
986 - std::string const& objspec, bool& trailer, int& obj, int& gen) 943 +QPDFJob::parse_object_id(std::string const& objspec, bool& trailer, int& obj, int& gen)
987 { 944 {
988 if (objspec == "trailer") { 945 if (objspec == "trailer") {
989 trailer = true; 946 trailer = true;
@@ -992,8 +949,7 @@ QPDFJob::parse_object_id( @@ -992,8 +949,7 @@ QPDFJob::parse_object_id(
992 obj = QUtil::string_to_int(objspec.c_str()); 949 obj = QUtil::string_to_int(objspec.c_str());
993 size_t comma = objspec.find(','); 950 size_t comma = objspec.find(',');
994 if ((comma != std::string::npos) && (comma + 1 < objspec.length())) { 951 if ((comma != std::string::npos) && (comma + 1 < objspec.length())) {
995 - gen = QUtil::string_to_int(  
996 - objspec.substr(1 + comma, std::string::npos).c_str()); 952 + gen = QUtil::string_to_int(objspec.substr(1 + comma, std::string::npos).c_str());
997 } 953 }
998 } 954 }
999 } 955 }
@@ -1013,8 +969,7 @@ QPDFJob::getWantedJSONObjects() @@ -1013,8 +969,7 @@ QPDFJob::getWantedJSONObjects()
1013 } 969 }
1014 970
1015 void 971 void
1016 -QPDFJob::doJSONObject(  
1017 - Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle& obj) 972 +QPDFJob::doJSONObject(Pipeline* p, bool& first, std::string const& key, QPDFObjectHandle& obj)
1018 { 973 {
1019 if (m->json_version == 1) { 974 if (m->json_version == 1) {
1020 JSON::writeDictionaryItem(p, first, key, obj.getJSON(1, true), 2); 975 JSON::writeDictionaryItem(p, first, key, obj.getJSON(1, true), 2);
@@ -1022,8 +977,7 @@ QPDFJob::doJSONObject( @@ -1022,8 +977,7 @@ QPDFJob::doJSONObject(
1022 auto j = JSON::makeDictionary(); 977 auto j = JSON::makeDictionary();
1023 if (obj.isStream()) { 978 if (obj.isStream()) {
1024 j.addDictionaryMember("stream", JSON::makeDictionary()) 979 j.addDictionaryMember("stream", JSON::makeDictionary())
1025 - .addDictionaryMember(  
1026 - "dict", obj.getDict().getJSON(m->json_version, true)); 980 + .addDictionaryMember("dict", obj.getDict().getJSON(m->json_version, true));
1027 } else { 981 } else {
1028 j.addDictionaryMember("value", obj.getJSON(m->json_version, true)); 982 j.addDictionaryMember("value", obj.getJSON(m->json_version, true));
1029 } 983 }
@@ -1085,22 +1039,18 @@ QPDFJob::doJSONObjectinfo(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1085,22 +1039,18 @@ QPDFJob::doJSONObjectinfo(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1085 for (auto& obj: pdf.getAllObjects()) { 1039 for (auto& obj: pdf.getAllObjects()) {
1086 if (all_objects || wanted_og.count(obj.getObjGen())) { 1040 if (all_objects || wanted_og.count(obj.getObjGen())) {
1087 auto j_details = JSON::makeDictionary(); 1041 auto j_details = JSON::makeDictionary();
1088 - auto j_stream =  
1089 - j_details.addDictionaryMember("stream", JSON::makeDictionary()); 1042 + auto j_stream = j_details.addDictionaryMember("stream", JSON::makeDictionary());
1090 bool is_stream = obj.isStream(); 1043 bool is_stream = obj.isStream();
1091 j_stream.addDictionaryMember("is", JSON::makeBool(is_stream)); 1044 j_stream.addDictionaryMember("is", JSON::makeBool(is_stream));
1092 j_stream.addDictionaryMember( 1045 j_stream.addDictionaryMember(
1093 "length", 1046 "length",
1094 - (is_stream ? obj.getDict().getKey("/Length").getJSON(  
1095 - m->json_version, true) 1047 + (is_stream ? obj.getDict().getKey("/Length").getJSON(m->json_version, true)
1096 : JSON::makeNull())); 1048 : JSON::makeNull()));
1097 j_stream.addDictionaryMember( 1049 j_stream.addDictionaryMember(
1098 "filter", 1050 "filter",
1099 - (is_stream ? obj.getDict().getKey("/Filter").getJSON(  
1100 - m->json_version, true) 1051 + (is_stream ? obj.getDict().getKey("/Filter").getJSON(m->json_version, true)
1101 : JSON::makeNull())); 1052 : JSON::makeNull()));
1102 - JSON::writeDictionaryItem(  
1103 - p, first_object, obj.unparse(), j_details, 2); 1053 + JSON::writeDictionaryItem(p, first_object, obj.unparse(), j_details, 2);
1104 } 1054 }
1105 } 1055 }
1106 JSON::writeDictionaryClose(p, first_object, 1); 1056 JSON::writeDictionaryClose(p, first_object, 1);
@@ -1126,21 +1076,15 @@ QPDFJob::doJSONPages(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1126,21 +1076,15 @@ QPDFJob::doJSONPages(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1126 j_image.addDictionaryMember("name", JSON::makeString(iter2.first)); 1076 j_image.addDictionaryMember("name", JSON::makeString(iter2.first));
1127 QPDFObjectHandle image = iter2.second; 1077 QPDFObjectHandle image = iter2.second;
1128 QPDFObjectHandle dict = image.getDict(); 1078 QPDFObjectHandle dict = image.getDict();
  1079 + j_image.addDictionaryMember("object", image.getJSON(m->json_version));
  1080 + j_image.addDictionaryMember("width", dict.getKey("/Width").getJSON(m->json_version));
  1081 + j_image.addDictionaryMember("height", dict.getKey("/Height").getJSON(m->json_version));
1129 j_image.addDictionaryMember( 1082 j_image.addDictionaryMember(
1130 - "object", image.getJSON(m->json_version));  
1131 - j_image.addDictionaryMember(  
1132 - "width", dict.getKey("/Width").getJSON(m->json_version));  
1133 - j_image.addDictionaryMember(  
1134 - "height", dict.getKey("/Height").getJSON(m->json_version));  
1135 - j_image.addDictionaryMember(  
1136 - "colorspace",  
1137 - dict.getKey("/ColorSpace").getJSON(m->json_version)); 1083 + "colorspace", dict.getKey("/ColorSpace").getJSON(m->json_version));
1138 j_image.addDictionaryMember( 1084 j_image.addDictionaryMember(
1139 - "bitspercomponent",  
1140 - dict.getKey("/BitsPerComponent").getJSON(m->json_version)); 1085 + "bitspercomponent", dict.getKey("/BitsPerComponent").getJSON(m->json_version));
1141 QPDFObjectHandle filters = dict.getKey("/Filter").wrapInArray(); 1086 QPDFObjectHandle filters = dict.getKey("/Filter").wrapInArray();
1142 - j_image.addDictionaryMember(  
1143 - "filter", filters.getJSON(m->json_version)); 1087 + j_image.addDictionaryMember("filter", filters.getJSON(m->json_version));
1144 QPDFObjectHandle decode_parms = dict.getKey("/DecodeParms"); 1088 QPDFObjectHandle decode_parms = dict.getKey("/DecodeParms");
1145 QPDFObjectHandle dp_array; 1089 QPDFObjectHandle dp_array;
1146 if (decode_parms.isArray()) { 1090 if (decode_parms.isArray()) {
@@ -1151,33 +1095,25 @@ QPDFJob::doJSONPages(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1151,33 +1095,25 @@ QPDFJob::doJSONPages(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1151 dp_array.appendItem(decode_parms); 1095 dp_array.appendItem(decode_parms);
1152 } 1096 }
1153 } 1097 }
1154 - j_image.addDictionaryMember(  
1155 - "decodeparms", dp_array.getJSON(m->json_version)); 1098 + j_image.addDictionaryMember("decodeparms", dp_array.getJSON(m->json_version));
1156 j_image.addDictionaryMember( 1099 j_image.addDictionaryMember(
1157 "filterable", 1100 "filterable",
1158 - JSON::makeBool(  
1159 - image.pipeStreamData(nullptr, 0, m->decode_level, true))); 1101 + JSON::makeBool(image.pipeStreamData(nullptr, 0, m->decode_level, true)));
1160 } 1102 }
1161 j_page.addDictionaryMember("images", j_images); 1103 j_page.addDictionaryMember("images", j_images);
1162 - JSON j_contents =  
1163 - j_page.addDictionaryMember("contents", JSON::makeArray()); 1104 + JSON j_contents = j_page.addDictionaryMember("contents", JSON::makeArray());
1164 for (auto& iter2: ph.getPageContents()) { 1105 for (auto& iter2: ph.getPageContents()) {
1165 j_contents.addArrayElement(iter2.getJSON(m->json_version)); 1106 j_contents.addArrayElement(iter2.getJSON(m->json_version));
1166 } 1107 }
1167 - j_page.addDictionaryMember(  
1168 - "label", pldh.getLabelForPage(pageno).getJSON(m->json_version));  
1169 - JSON j_outlines =  
1170 - j_page.addDictionaryMember("outlines", JSON::makeArray());  
1171 - std::vector<QPDFOutlineObjectHelper> outlines =  
1172 - odh.getOutlinesForPage(page.getObjGen()); 1108 + j_page.addDictionaryMember("label", pldh.getLabelForPage(pageno).getJSON(m->json_version));
  1109 + JSON j_outlines = j_page.addDictionaryMember("outlines", JSON::makeArray());
  1110 + std::vector<QPDFOutlineObjectHelper> outlines = odh.getOutlinesForPage(page.getObjGen());
1173 for (auto& oiter: outlines) { 1111 for (auto& oiter: outlines) {
1174 JSON j_outline = j_outlines.addArrayElement(JSON::makeDictionary()); 1112 JSON j_outline = j_outlines.addArrayElement(JSON::makeDictionary());
1175 j_outline.addDictionaryMember( 1113 j_outline.addDictionaryMember(
1176 "object", oiter.getObjectHandle().getJSON(m->json_version)); 1114 "object", oiter.getObjectHandle().getJSON(m->json_version));
1177 - j_outline.addDictionaryMember(  
1178 - "title", JSON::makeString(oiter.getTitle()));  
1179 - j_outline.addDictionaryMember(  
1180 - "dest", oiter.getDest().getJSON(m->json_version, true)); 1115 + j_outline.addDictionaryMember("title", JSON::makeString(oiter.getTitle()));
  1116 + j_outline.addDictionaryMember("dest", oiter.getDest().getJSON(m->json_version, true));
1181 } 1117 }
1182 j_page.addDictionaryMember("pageposfrom1", JSON::makeInt(1 + pageno)); 1118 j_page.addDictionaryMember("pageposfrom1", JSON::makeInt(1 + pageno));
1183 JSON::writeArrayItem(p, first_page, j_page, 2); 1119 JSON::writeArrayItem(p, first_page, j_page, 2);
@@ -1190,8 +1126,7 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1190,8 +1126,7 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1190 { 1126 {
1191 JSON j_labels = JSON::makeArray(); 1127 JSON j_labels = JSON::makeArray();
1192 QPDFPageLabelDocumentHelper pldh(pdf); 1128 QPDFPageLabelDocumentHelper pldh(pdf);
1193 - long long npages =  
1194 - QIntC::to_longlong(QPDFPageDocumentHelper(pdf).getAllPages().size()); 1129 + long long npages = QIntC::to_longlong(QPDFPageDocumentHelper(pdf).getAllPages().size());
1195 if (pldh.hasPageLabels()) { 1130 if (pldh.hasPageLabels()) {
1196 std::vector<QPDFObjectHandle> labels; 1131 std::vector<QPDFObjectHandle> labels;
1197 pldh.getLabelsForPageRange(0, npages - 1, 0, labels); 1132 pldh.getLabelsForPageRange(0, npages - 1, 0, labels);
@@ -1203,11 +1138,9 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1203,11 +1138,9 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1203 break; 1138 break;
1204 } 1139 }
1205 JSON j_label = j_labels.addArrayElement(JSON::makeDictionary()); 1140 JSON j_label = j_labels.addArrayElement(JSON::makeDictionary());
1206 - j_label.addDictionaryMember(  
1207 - "index", (*iter).getJSON(m->json_version)); 1141 + j_label.addDictionaryMember("index", (*iter).getJSON(m->json_version));
1208 ++iter; 1142 ++iter;
1209 - j_label.addDictionaryMember(  
1210 - "label", (*iter).getJSON(m->json_version)); 1143 + j_label.addDictionaryMember("label", (*iter).getJSON(m->json_version));
1211 } 1144 }
1212 } 1145 }
1213 JSON::writeDictionaryItem(p, first, "pagelabels", j_labels, 1); 1146 JSON::writeDictionaryItem(p, first, "pagelabels", j_labels, 1);
@@ -1215,17 +1148,13 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1215,17 +1148,13 @@ QPDFJob::doJSONPageLabels(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1215 1148
1216 void 1149 void
1217 QPDFJob::addOutlinesToJson( 1150 QPDFJob::addOutlinesToJson(
1218 - std::vector<QPDFOutlineObjectHelper> outlines,  
1219 - JSON& j,  
1220 - std::map<QPDFObjGen, int>& page_numbers) 1151 + std::vector<QPDFOutlineObjectHelper> outlines, JSON& j, std::map<QPDFObjGen, int>& page_numbers)
1221 { 1152 {
1222 for (auto& ol: outlines) { 1153 for (auto& ol: outlines) {
1223 JSON jo = j.addArrayElement(JSON::makeDictionary()); 1154 JSON jo = j.addArrayElement(JSON::makeDictionary());
1224 - jo.addDictionaryMember(  
1225 - "object", ol.getObjectHandle().getJSON(m->json_version)); 1155 + jo.addDictionaryMember("object", ol.getObjectHandle().getJSON(m->json_version));
1226 jo.addDictionaryMember("title", JSON::makeString(ol.getTitle())); 1156 jo.addDictionaryMember("title", JSON::makeString(ol.getTitle()));
1227 - jo.addDictionaryMember(  
1228 - "dest", ol.getDest().getJSON(m->json_version, true)); 1157 + jo.addDictionaryMember("dest", ol.getDest().getJSON(m->json_version, true));
1229 jo.addDictionaryMember("open", JSON::makeBool(ol.getCount() >= 0)); 1158 jo.addDictionaryMember("open", JSON::makeBool(ol.getCount() >= 0));
1230 QPDFObjectHandle page = ol.getDestPage(); 1159 QPDFObjectHandle page = ol.getDestPage();
1231 JSON j_destpage = JSON::makeNull(); 1160 JSON j_destpage = JSON::makeNull();
@@ -1262,10 +1191,8 @@ QPDFJob::doJSONAcroform(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1262,10 +1191,8 @@ QPDFJob::doJSONAcroform(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1262 { 1191 {
1263 JSON j_acroform = JSON::makeDictionary(); 1192 JSON j_acroform = JSON::makeDictionary();
1264 QPDFAcroFormDocumentHelper afdh(pdf); 1193 QPDFAcroFormDocumentHelper afdh(pdf);
1265 - j_acroform.addDictionaryMember(  
1266 - "hasacroform", JSON::makeBool(afdh.hasAcroForm()));  
1267 - j_acroform.addDictionaryMember(  
1268 - "needappearances", JSON::makeBool(afdh.getNeedAppearances())); 1194 + j_acroform.addDictionaryMember("hasacroform", JSON::makeBool(afdh.hasAcroForm()));
  1195 + j_acroform.addDictionaryMember("needappearances", JSON::makeBool(afdh.getNeedAppearances()));
1269 JSON j_fields = j_acroform.addDictionaryMember("fields", JSON::makeArray()); 1196 JSON j_fields = j_acroform.addDictionaryMember("fields", JSON::makeArray());
1270 int pagepos1 = 0; 1197 int pagepos1 = 0;
1271 for (auto const& page: QPDFPageDocumentHelper(pdf).getAllPages()) { 1198 for (auto const& page: QPDFPageDocumentHelper(pdf).getAllPages()) {
@@ -1273,52 +1200,34 @@ QPDFJob::doJSONAcroform(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1273,52 +1200,34 @@ QPDFJob::doJSONAcroform(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1273 for (auto& aoh: afdh.getWidgetAnnotationsForPage(page)) { 1200 for (auto& aoh: afdh.getWidgetAnnotationsForPage(page)) {
1274 QPDFFormFieldObjectHelper ffh = afdh.getFieldForAnnotation(aoh); 1201 QPDFFormFieldObjectHelper ffh = afdh.getFieldForAnnotation(aoh);
1275 JSON j_field = j_fields.addArrayElement(JSON::makeDictionary()); 1202 JSON j_field = j_fields.addArrayElement(JSON::makeDictionary());
  1203 + j_field.addDictionaryMember("object", ffh.getObjectHandle().getJSON(m->json_version));
1276 j_field.addDictionaryMember( 1204 j_field.addDictionaryMember(
1277 - "object", ffh.getObjectHandle().getJSON(m->json_version));  
1278 - j_field.addDictionaryMember(  
1279 - "parent",  
1280 - ffh.getObjectHandle().getKey("/Parent").getJSON(  
1281 - m->json_version));  
1282 - j_field.addDictionaryMember(  
1283 - "pageposfrom1", JSON::makeInt(pagepos1));  
1284 - j_field.addDictionaryMember(  
1285 - "fieldtype", JSON::makeString(ffh.getFieldType()));  
1286 - j_field.addDictionaryMember(  
1287 - "fieldflags", JSON::makeInt(ffh.getFlags()));  
1288 - j_field.addDictionaryMember(  
1289 - "fullname", JSON::makeString(ffh.getFullyQualifiedName()));  
1290 - j_field.addDictionaryMember(  
1291 - "partialname", JSON::makeString(ffh.getPartialName())); 1205 + "parent", ffh.getObjectHandle().getKey("/Parent").getJSON(m->json_version));
  1206 + j_field.addDictionaryMember("pageposfrom1", JSON::makeInt(pagepos1));
  1207 + j_field.addDictionaryMember("fieldtype", JSON::makeString(ffh.getFieldType()));
  1208 + j_field.addDictionaryMember("fieldflags", JSON::makeInt(ffh.getFlags()));
  1209 + j_field.addDictionaryMember("fullname", JSON::makeString(ffh.getFullyQualifiedName()));
  1210 + j_field.addDictionaryMember("partialname", JSON::makeString(ffh.getPartialName()));
1292 j_field.addDictionaryMember( 1211 j_field.addDictionaryMember(
1293 "alternativename", JSON::makeString(ffh.getAlternativeName())); 1212 "alternativename", JSON::makeString(ffh.getAlternativeName()));
1294 - j_field.addDictionaryMember(  
1295 - "mappingname", JSON::makeString(ffh.getMappingName()));  
1296 - j_field.addDictionaryMember(  
1297 - "value", ffh.getValue().getJSON(m->json_version)); 1213 + j_field.addDictionaryMember("mappingname", JSON::makeString(ffh.getMappingName()));
  1214 + j_field.addDictionaryMember("value", ffh.getValue().getJSON(m->json_version));
1298 j_field.addDictionaryMember( 1215 j_field.addDictionaryMember(
1299 "defaultvalue", ffh.getDefaultValue().getJSON(m->json_version)); 1216 "defaultvalue", ffh.getDefaultValue().getJSON(m->json_version));
1300 - j_field.addDictionaryMember(  
1301 - "quadding", JSON::makeInt(ffh.getQuadding()));  
1302 - j_field.addDictionaryMember(  
1303 - "ischeckbox", JSON::makeBool(ffh.isCheckbox()));  
1304 - j_field.addDictionaryMember(  
1305 - "isradiobutton", JSON::makeBool(ffh.isRadioButton()));  
1306 - j_field.addDictionaryMember(  
1307 - "ischoice", JSON::makeBool(ffh.isChoice())); 1217 + j_field.addDictionaryMember("quadding", JSON::makeInt(ffh.getQuadding()));
  1218 + j_field.addDictionaryMember("ischeckbox", JSON::makeBool(ffh.isCheckbox()));
  1219 + j_field.addDictionaryMember("isradiobutton", JSON::makeBool(ffh.isRadioButton()));
  1220 + j_field.addDictionaryMember("ischoice", JSON::makeBool(ffh.isChoice()));
1308 j_field.addDictionaryMember("istext", JSON::makeBool(ffh.isText())); 1221 j_field.addDictionaryMember("istext", JSON::makeBool(ffh.isText()));
1309 - JSON j_choices =  
1310 - j_field.addDictionaryMember("choices", JSON::makeArray()); 1222 + JSON j_choices = j_field.addDictionaryMember("choices", JSON::makeArray());
1311 for (auto const& choice: ffh.getChoices()) { 1223 for (auto const& choice: ffh.getChoices()) {
1312 j_choices.addArrayElement(JSON::makeString(choice)); 1224 j_choices.addArrayElement(JSON::makeString(choice));
1313 } 1225 }
1314 - JSON j_annot = j_field.addDictionaryMember(  
1315 - "annotation", JSON::makeDictionary());  
1316 - j_annot.addDictionaryMember(  
1317 - "object", aoh.getObjectHandle().getJSON(m->json_version)); 1226 + JSON j_annot = j_field.addDictionaryMember("annotation", JSON::makeDictionary());
  1227 + j_annot.addDictionaryMember("object", aoh.getObjectHandle().getJSON(m->json_version));
1318 j_annot.addDictionaryMember( 1228 j_annot.addDictionaryMember(
1319 "appearancestate", JSON::makeString(aoh.getAppearanceState())); 1229 "appearancestate", JSON::makeString(aoh.getAppearanceState()));
1320 - j_annot.addDictionaryMember(  
1321 - "annotationflags", JSON::makeInt(aoh.getFlags())); 1230 + j_annot.addDictionaryMember("annotationflags", JSON::makeInt(aoh.getFlags()));
1322 } 1231 }
1323 } 1232 }
1324 JSON::writeDictionaryItem(p, first, "acroform", j_acroform, 1); 1233 JSON::writeDictionaryItem(p, first, "acroform", j_acroform, 1);
@@ -1333,50 +1242,34 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1333,50 +1242,34 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1333 QPDF::encryption_method_e stream_method = QPDF::e_none; 1242 QPDF::encryption_method_e stream_method = QPDF::e_none;
1334 QPDF::encryption_method_e string_method = QPDF::e_none; 1243 QPDF::encryption_method_e string_method = QPDF::e_none;
1335 QPDF::encryption_method_e file_method = QPDF::e_none; 1244 QPDF::encryption_method_e file_method = QPDF::e_none;
1336 - bool is_encrypted =  
1337 - pdf.isEncrypted(R, P, V, stream_method, string_method, file_method); 1245 + bool is_encrypted = pdf.isEncrypted(R, P, V, stream_method, string_method, file_method);
1338 JSON j_encrypt = JSON::makeDictionary(); 1246 JSON j_encrypt = JSON::makeDictionary();
1339 j_encrypt.addDictionaryMember("encrypted", JSON::makeBool(is_encrypted)); 1247 j_encrypt.addDictionaryMember("encrypted", JSON::makeBool(is_encrypted));
1340 j_encrypt.addDictionaryMember( 1248 j_encrypt.addDictionaryMember(
1341 - "userpasswordmatched",  
1342 - JSON::makeBool(is_encrypted && pdf.userPasswordMatched())); 1249 + "userpasswordmatched", JSON::makeBool(is_encrypted && pdf.userPasswordMatched()));
1343 j_encrypt.addDictionaryMember( 1250 j_encrypt.addDictionaryMember(
1344 - "ownerpasswordmatched",  
1345 - JSON::makeBool(is_encrypted && pdf.ownerPasswordMatched()));  
1346 - if (is_encrypted && (V < 5) && pdf.ownerPasswordMatched() &&  
1347 - (!pdf.userPasswordMatched())) { 1251 + "ownerpasswordmatched", JSON::makeBool(is_encrypted && pdf.ownerPasswordMatched()));
  1252 + if (is_encrypted && (V < 5) && pdf.ownerPasswordMatched() && (!pdf.userPasswordMatched())) {
1348 std::string user_password = pdf.getTrimmedUserPassword(); 1253 std::string user_password = pdf.getTrimmedUserPassword();
1349 - j_encrypt.addDictionaryMember(  
1350 - "recovereduserpassword", JSON::makeString(user_password)); 1254 + j_encrypt.addDictionaryMember("recovereduserpassword", JSON::makeString(user_password));
1351 } else { 1255 } else {
1352 - j_encrypt.addDictionaryMember(  
1353 - "recovereduserpassword", JSON::makeNull());  
1354 - }  
1355 - JSON j_capabilities =  
1356 - j_encrypt.addDictionaryMember("capabilities", JSON::makeDictionary());  
1357 - j_capabilities.addDictionaryMember(  
1358 - "accessibility", JSON::makeBool(pdf.allowAccessibility()));  
1359 - j_capabilities.addDictionaryMember(  
1360 - "extract", JSON::makeBool(pdf.allowExtractAll()));  
1361 - j_capabilities.addDictionaryMember(  
1362 - "printlow", JSON::makeBool(pdf.allowPrintLowRes()));  
1363 - j_capabilities.addDictionaryMember(  
1364 - "printhigh", JSON::makeBool(pdf.allowPrintHighRes()));  
1365 - j_capabilities.addDictionaryMember(  
1366 - "modifyassembly", JSON::makeBool(pdf.allowModifyAssembly()));  
1367 - j_capabilities.addDictionaryMember(  
1368 - "modifyforms", JSON::makeBool(pdf.allowModifyForm())); 1256 + j_encrypt.addDictionaryMember("recovereduserpassword", JSON::makeNull());
  1257 + }
  1258 + JSON j_capabilities = j_encrypt.addDictionaryMember("capabilities", JSON::makeDictionary());
  1259 + j_capabilities.addDictionaryMember("accessibility", JSON::makeBool(pdf.allowAccessibility()));
  1260 + j_capabilities.addDictionaryMember("extract", JSON::makeBool(pdf.allowExtractAll()));
  1261 + j_capabilities.addDictionaryMember("printlow", JSON::makeBool(pdf.allowPrintLowRes()));
  1262 + j_capabilities.addDictionaryMember("printhigh", JSON::makeBool(pdf.allowPrintHighRes()));
  1263 + j_capabilities.addDictionaryMember("modifyassembly", JSON::makeBool(pdf.allowModifyAssembly()));
  1264 + j_capabilities.addDictionaryMember("modifyforms", JSON::makeBool(pdf.allowModifyForm()));
1369 /* cSpell:ignore moddifyannotations */ 1265 /* cSpell:ignore moddifyannotations */
1370 std::string MODIFY_ANNOTATIONS = 1266 std::string MODIFY_ANNOTATIONS =
1371 (m->json_version == 1 ? "moddifyannotations" : "modifyannotations"); 1267 (m->json_version == 1 ? "moddifyannotations" : "modifyannotations");
1372 j_capabilities.addDictionaryMember( 1268 j_capabilities.addDictionaryMember(
1373 MODIFY_ANNOTATIONS, JSON::makeBool(pdf.allowModifyAnnotation())); 1269 MODIFY_ANNOTATIONS, JSON::makeBool(pdf.allowModifyAnnotation()));
1374 - j_capabilities.addDictionaryMember(  
1375 - "modifyother", JSON::makeBool(pdf.allowModifyOther()));  
1376 - j_capabilities.addDictionaryMember(  
1377 - "modify", JSON::makeBool(pdf.allowModifyAll()));  
1378 - JSON j_parameters =  
1379 - j_encrypt.addDictionaryMember("parameters", JSON::makeDictionary()); 1270 + j_capabilities.addDictionaryMember("modifyother", JSON::makeBool(pdf.allowModifyOther()));
  1271 + j_capabilities.addDictionaryMember("modify", JSON::makeBool(pdf.allowModifyAll()));
  1272 + JSON j_parameters = j_encrypt.addDictionaryMember("parameters", JSON::makeDictionary());
1380 j_parameters.addDictionaryMember("R", JSON::makeInt(R)); 1273 j_parameters.addDictionaryMember("R", JSON::makeInt(R));
1381 j_parameters.addDictionaryMember("V", JSON::makeInt(V)); 1274 j_parameters.addDictionaryMember("V", JSON::makeInt(V));
1382 j_parameters.addDictionaryMember("P", JSON::makeInt(P)); 1275 j_parameters.addDictionaryMember("P", JSON::makeInt(P));
@@ -1408,14 +1301,10 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1408,14 +1301,10 @@ QPDFJob::doJSONEncrypt(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1408 } else { 1301 } else {
1409 s_overall_method = "mixed"; 1302 s_overall_method = "mixed";
1410 } 1303 }
1411 - j_parameters.addDictionaryMember(  
1412 - "method", JSON::makeString(s_overall_method));  
1413 - j_parameters.addDictionaryMember(  
1414 - "streammethod", JSON::makeString(s_stream_method));  
1415 - j_parameters.addDictionaryMember(  
1416 - "stringmethod", JSON::makeString(s_string_method));  
1417 - j_parameters.addDictionaryMember(  
1418 - "filemethod", JSON::makeString(s_file_method)); 1304 + j_parameters.addDictionaryMember("method", JSON::makeString(s_overall_method));
  1305 + j_parameters.addDictionaryMember("streammethod", JSON::makeString(s_stream_method));
  1306 + j_parameters.addDictionaryMember("stringmethod", JSON::makeString(s_string_method));
  1307 + j_parameters.addDictionaryMember("filemethod", JSON::makeString(s_file_method));
1419 JSON::writeDictionaryItem(p, first, "encrypt", j_encrypt, 1); 1308 JSON::writeDictionaryItem(p, first, "encrypt", j_encrypt, 1);
1420 } 1309 }
1421 1310
@@ -1443,39 +1332,28 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool&amp; first, QPDF&amp; pdf) @@ -1443,39 +1332,28 @@ QPDFJob::doJSONAttachments(Pipeline* p, bool&amp; first, QPDF&amp; pdf)
1443 for (auto const& iter: efdh.getEmbeddedFiles()) { 1332 for (auto const& iter: efdh.getEmbeddedFiles()) {
1444 std::string const& key = iter.first; 1333 std::string const& key = iter.first;
1445 auto fsoh = iter.second; 1334 auto fsoh = iter.second;
1446 - auto j_details =  
1447 - j_attachments.addDictionaryMember(key, JSON::makeDictionary()); 1335 + auto j_details = j_attachments.addDictionaryMember(key, JSON::makeDictionary());
1448 j_details.addDictionaryMember( 1336 j_details.addDictionaryMember(
1449 "filespec", JSON::makeString(fsoh->getObjectHandle().unparse())); 1337 "filespec", JSON::makeString(fsoh->getObjectHandle().unparse()));
  1338 + j_details.addDictionaryMember("preferredname", JSON::makeString(fsoh->getFilename()));
1450 j_details.addDictionaryMember( 1339 j_details.addDictionaryMember(
1451 - "preferredname", JSON::makeString(fsoh->getFilename()));  
1452 - j_details.addDictionaryMember(  
1453 - "preferredcontents",  
1454 - JSON::makeString(fsoh->getEmbeddedFileStream().unparse()));  
1455 - j_details.addDictionaryMember(  
1456 - "description", null_or_string(fsoh->getDescription()));  
1457 - auto j_names =  
1458 - j_details.addDictionaryMember("names", JSON::makeDictionary()); 1340 + "preferredcontents", JSON::makeString(fsoh->getEmbeddedFileStream().unparse()));
  1341 + j_details.addDictionaryMember("description", null_or_string(fsoh->getDescription()));
  1342 + auto j_names = j_details.addDictionaryMember("names", JSON::makeDictionary());
1459 for (auto const& i2: fsoh->getFilenames()) { 1343 for (auto const& i2: fsoh->getFilenames()) {
1460 j_names.addDictionaryMember(i2.first, JSON::makeString(i2.second)); 1344 j_names.addDictionaryMember(i2.first, JSON::makeString(i2.second));
1461 } 1345 }
1462 - auto j_streams =  
1463 - j_details.addDictionaryMember("streams", JSON::makeDictionary()); 1346 + auto j_streams = j_details.addDictionaryMember("streams", JSON::makeDictionary());
1464 for (auto i2: fsoh->getEmbeddedFileStreams().ditems()) { 1347 for (auto i2: fsoh->getEmbeddedFileStreams().ditems()) {
1465 auto efs = QPDFEFStreamObjectHelper(i2.second); 1348 auto efs = QPDFEFStreamObjectHelper(i2.second);
1466 - auto j_stream =  
1467 - j_streams.addDictionaryMember(i2.first, JSON::makeDictionary());  
1468 - j_stream.addDictionaryMember(  
1469 - "creationdate",  
1470 - null_or_string(to_iso8601(efs.getCreationDate()))); 1349 + auto j_stream = j_streams.addDictionaryMember(i2.first, JSON::makeDictionary());
1471 j_stream.addDictionaryMember( 1350 j_stream.addDictionaryMember(
1472 - "modificationdate",  
1473 - null_or_string(to_iso8601(efs.getCreationDate()))); 1351 + "creationdate", null_or_string(to_iso8601(efs.getCreationDate())));
1474 j_stream.addDictionaryMember( 1352 j_stream.addDictionaryMember(
1475 - "mimetype", null_or_string(efs.getSubtype())); 1353 + "modificationdate", null_or_string(to_iso8601(efs.getCreationDate())));
  1354 + j_stream.addDictionaryMember("mimetype", null_or_string(efs.getSubtype()));
1476 j_stream.addDictionaryMember( 1355 j_stream.addDictionaryMember(
1477 - "checksum",  
1478 - null_or_string(QUtil::hex_encode(efs.getChecksum()))); 1356 + "checksum", null_or_string(QUtil::hex_encode(efs.getChecksum())));
1479 } 1357 }
1480 } 1358 }
1481 JSON::writeDictionaryItem(p, first, "attachments", j_attachments, 1); 1359 JSON::writeDictionaryItem(p, first, "attachments", j_attachments, 1);
@@ -1503,8 +1381,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys) @@ -1503,8 +1381,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys)
1503 JSON schema = JSON::makeDictionary(); 1381 JSON schema = JSON::makeDictionary();
1504 schema.addDictionaryMember( 1382 schema.addDictionaryMember(
1505 "version", 1383 "version",
1506 - JSON::makeString(  
1507 - "JSON format serial number; increased for non-compatible changes")); 1384 + JSON::makeString("JSON format serial number; increased for non-compatible changes"));
1508 JSON j_params = schema.addDictionaryMember("parameters", JSON::parse(R"({ 1385 JSON j_params = schema.addDictionaryMember("parameters", JSON::parse(R"({
1509 "decodelevel": "decode level used to determine stream filterability" 1386 "decodelevel": "decode level used to determine stream filterability"
1510 })")); 1387 })"));
@@ -1521,8 +1398,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys) @@ -1521,8 +1398,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys)
1521 })")); 1398 })"));
1522 } 1399 }
1523 if (all_keys || keys->count("objectinfo")) { 1400 if (all_keys || keys->count("objectinfo")) {
1524 - JSON objectinfo =  
1525 - schema.addDictionaryMember("objectinfo", JSON::parse(R"({ 1401 + JSON objectinfo = schema.addDictionaryMember("objectinfo", JSON::parse(R"({
1526 "<object-id>": { 1402 "<object-id>": {
1527 "stream": { 1403 "stream": {
1528 "filter": "if stream, its filters, otherwise null", 1404 "filter": "if stream, its filters, otherwise null",
@@ -1667,8 +1543,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys) @@ -1667,8 +1543,7 @@ QPDFJob::json_schema(int json_version, std::set&lt;std::string&gt;* keys)
1667 })")); 1543 })"));
1668 } 1544 }
1669 if (all_keys || keys->count("attachments")) { 1545 if (all_keys || keys->count("attachments")) {
1670 - JSON attachments =  
1671 - schema.addDictionaryMember("attachments", JSON::parse(R"({ 1546 + JSON attachments = schema.addDictionaryMember("attachments", JSON::parse(R"({
1672 "<attachment-key>": { 1547 "<attachment-key>": {
1673 "filespec": "object containing the file spec", 1548 "filespec": "object containing the file spec",
1674 "preferredcontents": "most preferred embedded file stream", 1549 "preferredcontents": "most preferred embedded file stream",
@@ -1728,8 +1603,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p) @@ -1728,8 +1603,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p)
1728 // change is made to the JSON format. Clients of the JSON are to 1603 // change is made to the JSON format. Clients of the JSON are to
1729 // ignore unrecognized keys, so we only update the version of a 1604 // ignore unrecognized keys, so we only update the version of a
1730 // key disappears or if its value changes meaning. 1605 // key disappears or if its value changes meaning.
1731 - JSON::writeDictionaryItem(  
1732 - p, first, "version", JSON::makeInt(m->json_version), 1); 1606 + JSON::writeDictionaryItem(p, first, "version", JSON::makeInt(m->json_version), 1);
1733 JSON j_params = JSON::makeDictionary(); 1607 JSON j_params = JSON::makeDictionary();
1734 std::string decode_level_str; 1608 std::string decode_level_str;
1735 switch (m->decode_level) { 1609 switch (m->decode_level) {
@@ -1746,8 +1620,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p) @@ -1746,8 +1620,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p)
1746 decode_level_str = "all"; 1620 decode_level_str = "all";
1747 break; 1621 break;
1748 } 1622 }
1749 - j_params.addDictionaryMember(  
1750 - "decodelevel", JSON::makeString(decode_level_str)); 1623 + j_params.addDictionaryMember("decodelevel", JSON::makeString(decode_level_str));
1751 JSON::writeDictionaryItem(p, first, "parameters", j_params, 1); 1624 JSON::writeDictionaryItem(p, first, "parameters", j_params, 1);
1752 } 1625 }
1753 bool all_keys = m->json_keys.empty(); 1626 bool all_keys = m->json_keys.empty();
@@ -1784,8 +1657,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p) @@ -1784,8 +1657,7 @@ QPDFJob::doJSON(QPDF&amp; pdf, Pipeline* p)
1784 // repairing the page tree. To see the original file with any page 1657 // repairing the page tree. To see the original file with any page
1785 // tree problems and the page tree not flattened, select 1658 // tree problems and the page tree not flattened, select
1786 // qpdf/objects/objectinfo without other keys. 1659 // qpdf/objects/objectinfo without other keys.
1787 - if (all_keys || m->json_keys.count("objects") ||  
1788 - m->json_keys.count("qpdf")) { 1660 + if (all_keys || m->json_keys.count("objects") || m->json_keys.count("qpdf")) {
1789 doJSONObjects(p, first, pdf); 1661 doJSONObjects(p, first, pdf);
1790 } 1662 }
1791 if (m->json_version == 1) { 1663 if (m->json_version == 1) {
@@ -1823,8 +1695,7 @@ QPDFJob::doInspection(QPDF&amp; pdf) @@ -1823,8 +1695,7 @@ QPDFJob::doInspection(QPDF&amp; pdf)
1823 } 1695 }
1824 if (m->show_npages) { 1696 if (m->show_npages) {
1825 QTC::TC("qpdf", "QPDFJob npages"); 1697 QTC::TC("qpdf", "QPDFJob npages");
1826 - cout << pdf.getRoot().getKey("/Pages").getKey("/Count").getIntValue()  
1827 - << "\n"; 1698 + cout << pdf.getRoot().getKey("/Pages").getKey("/Count").getIntValue() << "\n";
1828 } 1699 }
1829 if (m->show_encryption) { 1700 if (m->show_encryption) {
1830 showEncryption(pdf); 1701 showEncryption(pdf);
@@ -1917,8 +1788,7 @@ QPDFJob::doProcess( @@ -1917,8 +1788,7 @@ QPDFJob::doProcess(
1917 password = ptemp.c_str(); 1788 password = ptemp.c_str();
1918 } 1789 }
1919 } 1790 }
1920 - if ((password == nullptr) || empty || m->password_is_hex_key ||  
1921 - m->suppress_password_recovery) { 1791 + if ((password == nullptr) || empty || m->password_is_hex_key || m->suppress_password_recovery) {
1922 // There is no password, or we're not doing recovery, so just 1792 // There is no password, or we're not doing recovery, so just
1923 // do the normal processing with the supplied password. 1793 // do the normal processing with the supplied password.
1924 doProcessOnce(pdf, fn, password, empty, used_for_input, main_input); 1794 doProcessOnce(pdf, fn, password, empty, used_for_input, main_input);
@@ -1927,8 +1797,7 @@ QPDFJob::doProcess( @@ -1927,8 +1797,7 @@ QPDFJob::doProcess(
1927 1797
1928 // Get a list of otherwise encoded strings. Keep in scope for this 1798 // Get a list of otherwise encoded strings. Keep in scope for this
1929 // method. 1799 // method.
1930 - std::vector<std::string> passwords_str =  
1931 - QUtil::possible_repaired_encodings(password); 1800 + std::vector<std::string> passwords_str = QUtil::possible_repaired_encodings(password);
1932 // Represent to char const*, as required by the QPDF class. 1801 // Represent to char const*, as required by the QPDF class.
1933 std::vector<char const*> passwords; 1802 std::vector<char const*> passwords;
1934 for (auto const& iter: passwords_str) { 1803 for (auto const& iter: passwords_str) {
@@ -1981,15 +1850,8 @@ QPDFJob::processFile( @@ -1981,15 +1850,8 @@ QPDFJob::processFile(
1981 bool main_input) 1850 bool main_input)
1982 { 1851 {
1983 auto f1 = std::mem_fn<void(char const*, char const*)>(&QPDF::processFile); 1852 auto f1 = std::mem_fn<void(char const*, char const*)>(&QPDF::processFile);
1984 - auto fn =  
1985 - std::bind(f1, std::placeholders::_1, filename, std::placeholders::_2);  
1986 - doProcess(  
1987 - pdf,  
1988 - fn,  
1989 - password,  
1990 - strcmp(filename, "") == 0,  
1991 - used_for_input,  
1992 - main_input); 1853 + auto fn = std::bind(f1, std::placeholders::_1, filename, std::placeholders::_2);
  1854 + doProcess(pdf, fn, password, strcmp(filename, "") == 0, used_for_input, main_input);
1993 } 1855 }
1994 1856
1995 void 1857 void
@@ -2019,32 +1881,26 @@ QPDFJob::validateUnderOverlay(QPDF&amp; pdf, UnderOverlay* uo) @@ -2019,32 +1881,26 @@ QPDFJob::validateUnderOverlay(QPDF&amp; pdf, UnderOverlay* uo)
2019 uo->to_pagenos = QUtil::parse_numrange(uo->to_nr.c_str(), main_npages); 1881 uo->to_pagenos = QUtil::parse_numrange(uo->to_nr.c_str(), main_npages);
2020 } catch (std::runtime_error& e) { 1882 } catch (std::runtime_error& e) {
2021 throw std::runtime_error( 1883 throw std::runtime_error(
2022 - "parsing numeric range for " + uo->which +  
2023 - " \"to\" pages: " + e.what()); 1884 + "parsing numeric range for " + uo->which + " \"to\" pages: " + e.what());
2024 } 1885 }
2025 try { 1886 try {
2026 if (uo->from_nr.empty()) { 1887 if (uo->from_nr.empty()) {
2027 QTC::TC("qpdf", "QPDFJob from_nr from repeat_nr"); 1888 QTC::TC("qpdf", "QPDFJob from_nr from repeat_nr");
2028 uo->from_nr = uo->repeat_nr; 1889 uo->from_nr = uo->repeat_nr;
2029 } 1890 }
2030 - uo->from_pagenos =  
2031 - QUtil::parse_numrange(uo->from_nr.c_str(), uo_npages); 1891 + uo->from_pagenos = QUtil::parse_numrange(uo->from_nr.c_str(), uo_npages);
2032 if (!uo->repeat_nr.empty()) { 1892 if (!uo->repeat_nr.empty()) {
2033 - uo->repeat_pagenos =  
2034 - QUtil::parse_numrange(uo->repeat_nr.c_str(), uo_npages); 1893 + uo->repeat_pagenos = QUtil::parse_numrange(uo->repeat_nr.c_str(), uo_npages);
2035 } 1894 }
2036 } catch (std::runtime_error& e) { 1895 } catch (std::runtime_error& e) {
2037 throw std::runtime_error( 1896 throw std::runtime_error(
2038 - "parsing numeric range for " + uo->which + " file " + uo->filename +  
2039 - ": " + e.what()); 1897 + "parsing numeric range for " + uo->which + " file " + uo->filename + ": " + e.what());
2040 } 1898 }
2041 } 1899 }
2042 1900
2043 static QPDFAcroFormDocumentHelper* 1901 static QPDFAcroFormDocumentHelper*
2044 get_afdh_for_qpdf( 1902 get_afdh_for_qpdf(
2045 - std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>&  
2046 - afdh_map,  
2047 - QPDF* q) 1903 + std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>& afdh_map, QPDF* q)
2048 { 1904 {
2049 auto uid = q->getUniqueId(); 1905 auto uid = q->getUniqueId();
2050 if (!afdh_map.count(uid)) { 1906 if (!afdh_map.count(uid)) {
@@ -2068,8 +1924,7 @@ QPDFJob::doUnderOverlayForPage( @@ -2068,8 +1924,7 @@ QPDFJob::doUnderOverlayForPage(
2068 return ""; 1924 return "";
2069 } 1925 }
2070 1926
2071 - std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>  
2072 - afdh; 1927 + std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>> afdh;
2073 auto make_afdh = [&](QPDFPageObjectHelper& ph) { 1928 auto make_afdh = [&](QPDFPageObjectHelper& ph) {
2074 QPDF& q = ph.getObjectHandle().getQPDF(); 1929 QPDF& q = ph.getObjectHandle().getQPDF();
2075 return get_afdh_for_qpdf(afdh, &q); 1930 return get_afdh_for_qpdf(afdh, &q);
@@ -2085,8 +1940,7 @@ QPDFJob::doUnderOverlayForPage( @@ -2085,8 +1940,7 @@ QPDFJob::doUnderOverlayForPage(
2085 }); 1940 });
2086 auto from_page = pages.at(QIntC::to_size(from_pageno - 1)); 1941 auto from_page = pages.at(QIntC::to_size(from_pageno - 1));
2087 if (0 == fo.count(from_pageno)) { 1942 if (0 == fo.count(from_pageno)) {
2088 - fo[from_pageno] =  
2089 - pdf.copyForeignObject(from_page.getFormXObjectForPage()); 1943 + fo[from_pageno] = pdf.copyForeignObject(from_page.getFormXObjectForPage());
2090 } 1944 }
2091 1945
2092 // If the same page is overlaid or underlaid multiple times, 1946 // If the same page is overlaid or underlaid multiple times,
@@ -2096,12 +1950,8 @@ QPDFJob::doUnderOverlayForPage( @@ -2096,12 +1950,8 @@ QPDFJob::doUnderOverlayForPage(
2096 std::string name = resources.getUniqueResourceName("/Fx", min_suffix); 1950 std::string name = resources.getUniqueResourceName("/Fx", min_suffix);
2097 QPDFMatrix cm; 1951 QPDFMatrix cm;
2098 std::string new_content = dest_page.placeFormXObject( 1952 std::string new_content = dest_page.placeFormXObject(
2099 - fo[from_pageno],  
2100 - name,  
2101 - dest_page.getTrimBox().getArrayAsRectangle(),  
2102 - cm);  
2103 - dest_page.copyAnnotations(  
2104 - from_page, cm, dest_afdh, make_afdh(from_page)); 1953 + fo[from_pageno], name, dest_page.getTrimBox().getArrayAsRectangle(), cm);
  1954 + dest_page.copyAnnotations(from_page, cm, dest_afdh, make_afdh(from_page));
2105 if (!new_content.empty()) { 1955 if (!new_content.empty()) {
2106 resources.mergeResources("<< /XObject << >> >>"_qpdf); 1956 resources.mergeResources("<< /XObject << >> >>"_qpdf);
2107 auto xobject = resources.getKey("/XObject"); 1957 auto xobject = resources.getKey("/XObject");
@@ -2116,8 +1966,7 @@ QPDFJob::doUnderOverlayForPage( @@ -2116,8 +1966,7 @@ QPDFJob::doUnderOverlayForPage(
2116 } 1966 }
2117 1967
2118 void 1968 void
2119 -QPDFJob::getUOPagenos(  
2120 - QPDFJob::UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos) 1969 +QPDFJob::getUOPagenos(QPDFJob::UnderOverlay& uo, std::map<int, std::vector<int>>& pagenos)
2121 { 1970 {
2122 size_t idx = 0; 1971 size_t idx = 0;
2123 size_t from_size = uo.from_pagenos.size(); 1972 size_t from_size = uo.from_pagenos.size();
@@ -2126,8 +1975,7 @@ QPDFJob::getUOPagenos( @@ -2126,8 +1975,7 @@ QPDFJob::getUOPagenos(
2126 if (idx < from_size) { 1975 if (idx < from_size) {
2127 pagenos[to_pageno].push_back(uo.from_pagenos.at(idx)); 1976 pagenos[to_pageno].push_back(uo.from_pagenos.at(idx));
2128 } else if (repeat_size) { 1977 } else if (repeat_size) {
2129 - pagenos[to_pageno].push_back(  
2130 - uo.repeat_pagenos.at((idx - from_size) % repeat_size)); 1978 + pagenos[to_pageno].push_back(uo.repeat_pagenos.at((idx - from_size) % repeat_size));
2131 } 1979 }
2132 ++idx; 1980 ++idx;
2133 } 1981 }
@@ -2163,12 +2011,10 @@ QPDFJob::handleUnderOverlay(QPDF&amp; pdf) @@ -2163,12 +2011,10 @@ QPDFJob::handleUnderOverlay(QPDF&amp; pdf)
2163 v << prefix << ": processing underlay/overlay\n"; 2011 v << prefix << ": processing underlay/overlay\n";
2164 }); 2012 });
2165 for (size_t i = 0; i < main_npages; ++i) { 2013 for (size_t i = 0; i < main_npages; ++i) {
2166 - doIfVerbose([&](Pipeline& v, std::string const& prefix) {  
2167 - v << " page " << 1 + i << "\n";  
2168 - }); 2014 + doIfVerbose(
  2015 + [&](Pipeline& v, std::string const& prefix) { v << " page " << 1 + i << "\n"; });
2169 auto pageno = QIntC::to_int(i) + 1; 2016 auto pageno = QIntC::to_int(i) + 1;
2170 - if (!(underlay_pagenos.count(pageno) ||  
2171 - overlay_pagenos.count(pageno))) { 2017 + if (!(underlay_pagenos.count(pageno) || overlay_pagenos.count(pageno))) {
2172 continue; 2018 continue;
2173 } 2019 }
2174 // This code converts the original page, any underlays, and 2020 // This code converts the original page, any underlays, and
@@ -2184,19 +2030,12 @@ QPDFJob::handleUnderOverlay(QPDF&amp; pdf) @@ -2184,19 +2030,12 @@ QPDFJob::handleUnderOverlay(QPDF&amp; pdf)
2184 // the original page, which we are going to replace. Therefore 2030 // the original page, which we are going to replace. Therefore
2185 // we have to explicitly copy it. 2031 // we have to explicitly copy it.
2186 auto content_data = this_page_fo.getRawStreamData(); 2032 auto content_data = this_page_fo.getRawStreamData();
2187 - this_page_fo.replaceStreamData(  
2188 - content_data, QPDFObjectHandle(), QPDFObjectHandle());  
2189 - auto resources = dest_page_oh.replaceKeyAndGetNew(  
2190 - "/Resources", "<< /XObject << >> >>"_qpdf); 2033 + this_page_fo.replaceStreamData(content_data, QPDFObjectHandle(), QPDFObjectHandle());
  2034 + auto resources =
  2035 + dest_page_oh.replaceKeyAndGetNew("/Resources", "<< /XObject << >> >>"_qpdf);
2191 resources.getKey("/XObject").replaceKeyAndGetNew("/Fx0", this_page_fo); 2036 resources.getKey("/XObject").replaceKeyAndGetNew("/Fx0", this_page_fo);
2192 auto content = doUnderOverlayForPage( 2037 auto content = doUnderOverlayForPage(
2193 - pdf,  
2194 - m->underlay,  
2195 - underlay_pagenos,  
2196 - i,  
2197 - underlay_fo,  
2198 - upages,  
2199 - dest_page); 2038 + pdf, m->underlay, underlay_pagenos, i, underlay_fo, upages, dest_page);
2200 content += dest_page.placeFormXObject( 2039 content += dest_page.placeFormXObject(
2201 this_page_fo, 2040 this_page_fo,
2202 "/Fx0", 2041 "/Fx0",
@@ -2231,8 +2070,7 @@ QPDFJob::addAttachments(QPDF&amp; pdf) @@ -2231,8 +2070,7 @@ QPDFJob::addAttachments(QPDF&amp; pdf)
2231 continue; 2070 continue;
2232 } 2071 }
2233 2072
2234 - auto fs = QPDFFileSpecObjectHelper::createFileSpec(  
2235 - pdf, to_add.filename, to_add.path); 2073 + auto fs = QPDFFileSpecObjectHelper::createFileSpec(pdf, to_add.filename, to_add.path);
2236 if (!to_add.description.empty()) { 2074 if (!to_add.description.empty()) {
2237 fs.setDescription(to_add.description); 2075 fs.setDescription(to_add.description);
2238 } 2076 }
@@ -2244,8 +2082,8 @@ QPDFJob::addAttachments(QPDF&amp; pdf) @@ -2244,8 +2082,8 @@ QPDFJob::addAttachments(QPDF&amp; pdf)
2244 2082
2245 efdh.replaceEmbeddedFile(to_add.key, fs); 2083 efdh.replaceEmbeddedFile(to_add.key, fs);
2246 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 2084 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2247 - v << prefix << ": attached " << to_add.path << " as "  
2248 - << to_add.filename << " with key " << to_add.key << "\n"; 2085 + v << prefix << ": attached " << to_add.path << " as " << to_add.filename << " with key "
  2086 + << to_add.key << "\n";
2249 }); 2087 });
2250 } 2088 }
2251 2089
@@ -2273,28 +2111,19 @@ QPDFJob::copyAttachments(QPDF&amp; pdf) @@ -2273,28 +2111,19 @@ QPDFJob::copyAttachments(QPDF&amp; pdf)
2273 std::vector<std::string> duplicates; 2111 std::vector<std::string> duplicates;
2274 for (auto const& to_copy: m->attachments_to_copy) { 2112 for (auto const& to_copy: m->attachments_to_copy) {
2275 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 2113 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2276 - v << prefix << ": copying attachments from " << to_copy.path  
2277 - << "\n"; 2114 + v << prefix << ": copying attachments from " << to_copy.path << "\n";
2278 }); 2115 });
2279 std::unique_ptr<QPDF> other; 2116 std::unique_ptr<QPDF> other;
2280 - processFile(  
2281 - other,  
2282 - to_copy.path.c_str(),  
2283 - to_copy.password.c_str(),  
2284 - false,  
2285 - false); 2117 + processFile(other, to_copy.path.c_str(), to_copy.password.c_str(), false, false);
2286 QPDFEmbeddedFileDocumentHelper other_efdh(*other); 2118 QPDFEmbeddedFileDocumentHelper other_efdh(*other);
2287 auto other_attachments = other_efdh.getEmbeddedFiles(); 2119 auto other_attachments = other_efdh.getEmbeddedFiles();
2288 for (auto const& iter: other_attachments) { 2120 for (auto const& iter: other_attachments) {
2289 std::string new_key = to_copy.prefix + iter.first; 2121 std::string new_key = to_copy.prefix + iter.first;
2290 if (efdh.getEmbeddedFile(new_key)) { 2122 if (efdh.getEmbeddedFile(new_key)) {
2291 - duplicates.push_back(  
2292 - "file: " + to_copy.path + ", key: " + new_key); 2123 + duplicates.push_back("file: " + to_copy.path + ", key: " + new_key);
2293 } else { 2124 } else {
2294 - auto new_fs_oh =  
2295 - pdf.copyForeignObject(iter.second->getObjectHandle());  
2296 - efdh.replaceEmbeddedFile(  
2297 - new_key, QPDFFileSpecObjectHelper(new_fs_oh)); 2125 + auto new_fs_oh = pdf.copyForeignObject(iter.second->getObjectHandle());
  2126 + efdh.replaceEmbeddedFile(new_key, QPDFFileSpecObjectHelper(new_fs_oh));
2298 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 2127 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2299 v << " " << iter.first << " -> " << new_key << "\n"; 2128 v << " " << iter.first << " -> " << new_key << "\n";
2300 }); 2129 });
@@ -2337,8 +2166,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf) @@ -2337,8 +2166,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2337 if (m->remove_restrictions) { 2166 if (m->remove_restrictions) {
2338 pdf.removeSecurityRestrictions(); 2167 pdf.removeSecurityRestrictions();
2339 } 2168 }
2340 - if (m->externalize_inline_images ||  
2341 - (m->optimize_images && (!m->keep_inline_images))) { 2169 + if (m->externalize_inline_images || (m->optimize_images && (!m->keep_inline_images))) {
2342 for (auto& ph: dh.getAllPages()) { 2170 for (auto& ph: dh.getAllPages()) {
2343 ph.externalizeInlineImages(m->ii_min_bytes); 2171 ph.externalizeInlineImages(m->ii_min_bytes);
2344 } 2172 }
@@ -2350,18 +2178,10 @@ QPDFJob::handleTransformations(QPDF&amp; pdf) @@ -2350,18 +2178,10 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2350 ph.forEachImage( 2178 ph.forEachImage(
2351 true, 2179 true,
2352 [this, pageno, &pdf]( 2180 [this, pageno, &pdf](
2353 - QPDFObjectHandle& obj,  
2354 - QPDFObjectHandle& xobj_dict,  
2355 - std::string const& key) { 2181 + QPDFObjectHandle& obj, QPDFObjectHandle& xobj_dict, std::string const& key) {
2356 auto io = std::make_unique<ImageOptimizer>( 2182 auto io = std::make_unique<ImageOptimizer>(
2357 - *this,  
2358 - m->oi_min_width,  
2359 - m->oi_min_height,  
2360 - m->oi_min_area,  
2361 - obj);  
2362 - if (io->evaluate(  
2363 - "image " + key + " on page " +  
2364 - std::to_string(pageno))) { 2183 + *this, m->oi_min_width, m->oi_min_height, m->oi_min_area, obj);
  2184 + if (io->evaluate("image " + key + " on page " + std::to_string(pageno))) {
2365 QPDFObjectHandle new_image = pdf.newStream(); 2185 QPDFObjectHandle new_image = pdf.newStream();
2366 new_image.replaceDict(obj.getDict().shallowCopy()); 2186 new_image.replaceDict(obj.getDict().shallowCopy());
2367 new_image.replaceStreamData( 2187 new_image.replaceStreamData(
@@ -2378,8 +2198,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf) @@ -2378,8 +2198,7 @@ QPDFJob::handleTransformations(QPDF&amp; pdf)
2378 afdh->generateAppearancesIfNeeded(); 2198 afdh->generateAppearancesIfNeeded();
2379 } 2199 }
2380 if (m->flatten_annotations) { 2200 if (m->flatten_annotations) {
2381 - dh.flattenAnnotations(  
2382 - m->flatten_annotations_required, m->flatten_annotations_forbidden); 2201 + dh.flattenAnnotations(m->flatten_annotations_required, m->flatten_annotations_forbidden);
2383 } 2202 }
2384 if (m->coalesce_contents) { 2203 if (m->coalesce_contents) {
2385 for (auto& page: dh.getAllPages()) { 2204 for (auto& page: dh.getAllPages()) {
@@ -2438,8 +2257,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf) @@ -2438,8 +2257,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2438 QPDFObjGen::set nodes_seen; // loop detection 2257 QPDFObjGen::set nodes_seen; // loop detection
2439 2258
2440 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 2259 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2441 - v << prefix << ": " << pdf.getFilename()  
2442 - << ": checking for shared resources\n"; 2260 + v << prefix << ": " << pdf.getFilename() << ": checking for shared resources\n";
2443 }); 2261 });
2444 2262
2445 std::list<QPDFObjectHandle> queue; 2263 std::list<QPDFObjectHandle> queue;
@@ -2458,8 +2276,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf) @@ -2458,8 +2276,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2458 if (dict.hasKey("/Resources")) { 2276 if (dict.hasKey("/Resources")) {
2459 QTC::TC("qpdf", "QPDFJob found resources in non-leaf"); 2277 QTC::TC("qpdf", "QPDFJob found resources in non-leaf");
2460 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 2278 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2461 - v << " found resources in non-leaf page node "  
2462 - << og.unparse(' ') << "\n"; 2279 + v << " found resources in non-leaf page node " << og.unparse(' ') << "\n";
2463 }); 2280 });
2464 return true; 2281 return true;
2465 } 2282 }
@@ -2474,8 +2291,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf) @@ -2474,8 +2291,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2474 if (!resources_seen.add(resources)) { 2291 if (!resources_seen.add(resources)) {
2475 QTC::TC("qpdf", "QPDFJob found shared resources in leaf"); 2292 QTC::TC("qpdf", "QPDFJob found shared resources in leaf");
2476 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 2293 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2477 - v << " found shared resources in leaf node "  
2478 - << og.unparse(' ') << ": " 2294 + v << " found shared resources in leaf node " << og.unparse(' ') << ": "
2479 << resources.getObjGen().unparse(' ') << "\n"; 2295 << resources.getObjGen().unparse(' ') << "\n";
2480 }); 2296 });
2481 return true; 2297 return true;
@@ -2488,8 +2304,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf) @@ -2488,8 +2304,7 @@ QPDFJob::shouldRemoveUnreferencedResources(QPDF&amp; pdf)
2488 if (!resources_seen.add(xobject)) { 2304 if (!resources_seen.add(xobject)) {
2489 QTC::TC("qpdf", "QPDFJob found shared xobject in leaf"); 2305 QTC::TC("qpdf", "QPDFJob found shared xobject in leaf");
2490 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 2306 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2491 - v << " found shared xobject in leaf node "  
2492 - << og.unparse(' ') << ": " 2307 + v << " found shared xobject in leaf node " << og.unparse(' ') << ": "
2493 << xobject.getObjGen().unparse(' ') << "\n"; 2308 << xobject.getObjGen().unparse(' ') << "\n";
2494 }); 2309 });
2495 return true; 2310 return true;
@@ -2531,8 +2346,7 @@ added_page(QPDF&amp; pdf, QPDFPageObjectHelper page) @@ -2531,8 +2346,7 @@ added_page(QPDF&amp; pdf, QPDFPageObjectHelper page)
2531 } 2346 }
2532 2347
2533 void 2348 void
2534 -QPDFJob::handlePageSpecs(  
2535 - QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap) 2349 +QPDFJob::handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap)
2536 { 2350 {
2537 // Parse all page specifications and translate them into lists of 2351 // Parse all page specifications and translate them into lists of
2538 // actual pages. 2352 // actual pages.
@@ -2554,13 +2368,10 @@ QPDFJob::handlePageSpecs( @@ -2554,13 +2368,10 @@ QPDFJob::handlePageSpecs(
2554 filenames.insert(page_spec.filename); 2368 filenames.insert(page_spec.filename);
2555 } 2369 }
2556 m->keep_files_open = (filenames.size() <= m->keep_files_open_threshold); 2370 m->keep_files_open = (filenames.size() <= m->keep_files_open_threshold);
2557 - QTC::TC(  
2558 - "qpdf",  
2559 - "QPDFJob automatically set keep files open",  
2560 - m->keep_files_open ? 0 : 1); 2371 + QTC::TC("qpdf", "QPDFJob automatically set keep files open", m->keep_files_open ? 0 : 1);
2561 doIfVerbose([&](Pipeline& v, std::string const& prefix) { 2372 doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2562 - v << prefix << ": selecting --keep-open-files="  
2563 - << (m->keep_files_open ? "y" : "n") << "\n"; 2373 + v << prefix << ": selecting --keep-open-files=" << (m->keep_files_open ? "y" : "n")
  2374 + << "\n";
2564 }); 2375 });
2565 } 2376 }
2566 2377
@@ -2600,8 +2411,7 @@ QPDFJob::handlePageSpecs( @@ -2600,8 +2411,7 @@ QPDFJob::handlePageSpecs(
2600 cis->stayOpen(true); 2411 cis->stayOpen(true);
2601 } else { 2412 } else {
2602 QTC::TC("qpdf", "QPDFJob keep files open y"); 2413 QTC::TC("qpdf", "QPDFJob keep files open y");
2603 - FileInputSource* fis =  
2604 - new FileInputSource(page_spec.filename.c_str()); 2414 + FileInputSource* fis = new FileInputSource(page_spec.filename.c_str());
2605 is = std::shared_ptr<InputSource>(fis); 2415 is = std::shared_ptr<InputSource>(fis);
2606 } 2416 }
2607 std::unique_ptr<QPDF> qpdf_sp; 2417 std::unique_ptr<QPDF> qpdf_sp;
@@ -2618,10 +2428,7 @@ QPDFJob::handlePageSpecs( @@ -2618,10 +2428,7 @@ QPDFJob::handlePageSpecs(
2618 // associated with this occurrence of the file. 2428 // associated with this occurrence of the file.
2619 parsed_specs.push_back( 2429 parsed_specs.push_back(
2620 // line-break 2430 // line-break
2621 - QPDFPageData(  
2622 - page_spec.filename,  
2623 - page_spec_qpdfs[page_spec.filename],  
2624 - page_spec.range)); 2431 + QPDFPageData(page_spec.filename, page_spec_qpdfs[page_spec.filename], page_spec.range));
2625 } 2432 }
2626 2433
2627 std::map<unsigned long long, bool> remove_unreferenced; 2434 std::map<unsigned long long, bool> remove_unreferenced;
@@ -2636,8 +2443,7 @@ QPDFJob::handlePageSpecs( @@ -2636,8 +2443,7 @@ QPDFJob::handlePageSpecs(
2636 QPDF& other(*(iter.second)); 2443 QPDF& other(*(iter.second));
2637 auto other_uuid = other.getUniqueId(); 2444 auto other_uuid = other.getUniqueId();
2638 if (remove_unreferenced.count(other_uuid) == 0) { 2445 if (remove_unreferenced.count(other_uuid) == 0) {
2639 - remove_unreferenced[other_uuid] =  
2640 - shouldRemoveUnreferencedResources(other); 2446 + remove_unreferenced[other_uuid] = shouldRemoveUnreferencedResources(other);
2641 } 2447 }
2642 if (cis) { 2448 if (cis) {
2643 cis->stayOpen(false); 2449 cis->stayOpen(false);
@@ -2676,9 +2482,7 @@ QPDFJob::handlePageSpecs( @@ -2676,9 +2482,7 @@ QPDFJob::handlePageSpecs(
2676 got_pages = true; 2482 got_pages = true;
2677 new_parsed_specs.push_back( 2483 new_parsed_specs.push_back(
2678 // line-break 2484 // line-break
2679 - QPDFPageData(  
2680 - page_data,  
2681 - page_data.selected_pages.at(cur_page + j))); 2485 + QPDFPageData(page_data, page_data.selected_pages.at(cur_page + j)));
2682 } 2486 }
2683 } 2487 }
2684 } 2488 }
@@ -2694,8 +2498,7 @@ QPDFJob::handlePageSpecs( @@ -2694,8 +2498,7 @@ QPDFJob::handlePageSpecs(
2694 std::vector<QPDFObjectHandle> new_labels; 2498 std::vector<QPDFObjectHandle> new_labels;
2695 bool any_page_labels = false; 2499 bool any_page_labels = false;
2696 int out_pageno = 0; 2500 int out_pageno = 0;
2697 - std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>>  
2698 - afdh_map; 2501 + std::map<unsigned long long, std::shared_ptr<QPDFAcroFormDocumentHelper>> afdh_map;
2699 auto this_afdh = get_afdh_for_qpdf(afdh_map, &pdf); 2502 auto this_afdh = get_afdh_for_qpdf(afdh_map, &pdf);
2700 std::set<QPDFObjGen> referenced_fields; 2503 std::set<QPDFObjGen> referenced_fields;
2701 for (auto& page_data: parsed_specs) { 2504 for (auto& page_data: parsed_specs) {
@@ -2716,10 +2519,8 @@ QPDFJob::handlePageSpecs( @@ -2716,10 +2519,8 @@ QPDFJob::handlePageSpecs(
2716 // Pages are specified from 1 but numbered from 0 in the 2519 // Pages are specified from 1 but numbered from 0 in the
2717 // vector 2520 // vector
2718 int pageno = pageno_iter - 1; 2521 int pageno = pageno_iter - 1;
2719 - pldh.getLabelsForPageRange(  
2720 - pageno, pageno, out_pageno++, new_labels);  
2721 - QPDFPageObjectHelper to_copy =  
2722 - page_data.orig_pages.at(QIntC::to_size(pageno)); 2522 + pldh.getLabelsForPageRange(pageno, pageno, out_pageno++, new_labels);
  2523 + QPDFPageObjectHelper to_copy = page_data.orig_pages.at(QIntC::to_size(pageno));
2723 QPDFObjGen to_copy_og = to_copy.getObjectHandle().getObjGen(); 2524 QPDFObjGen to_copy_og = to_copy.getObjectHandle().getObjGen();
2724 unsigned long long from_uuid = page_data.qpdf->getUniqueId(); 2525 unsigned long long from_uuid = page_data.qpdf->getUniqueId();
2725 if (copied_pages[from_uuid].count(to_copy_og)) { 2526 if (copied_pages[from_uuid].count(to_copy_og)) {
@@ -2754,8 +2555,7 @@ QPDFJob::handlePageSpecs( @@ -2754,8 +2555,7 @@ QPDFJob::handlePageSpecs(
2754 // adjusted. If we copy any page from the original file 2555 // adjusted. If we copy any page from the original file
2755 // more than once, that page would be in conflict with the 2556 // more than once, that page would be in conflict with the
2756 // previous copy of itself. 2557 // previous copy of itself.
2757 - if (other_afdh->hasAcroForm() &&  
2758 - ((!this_file) || (!first_copy_from_orig))) { 2558 + if (other_afdh->hasAcroForm() && ((!this_file) || (!first_copy_from_orig))) {
2759 if (!this_file) { 2559 if (!this_file) {
2760 QTC::TC("qpdf", "QPDFJob copy fields not this file"); 2560 QTC::TC("qpdf", "QPDFJob copy fields not this file");
2761 } else if (!first_copy_from_orig) { 2561 } else if (!first_copy_from_orig) {
@@ -2763,10 +2563,7 @@ QPDFJob::handlePageSpecs( @@ -2763,10 +2563,7 @@ QPDFJob::handlePageSpecs(
2763 } 2563 }
2764 try { 2564 try {
2765 this_afdh->fixCopiedAnnotations( 2565 this_afdh->fixCopiedAnnotations(
2766 - new_page,  
2767 - to_copy.getObjectHandle(),  
2768 - *other_afdh,  
2769 - &referenced_fields); 2566 + new_page, to_copy.getObjectHandle(), *other_afdh, &referenced_fields);
2770 } catch (std::exception& e) { 2567 } catch (std::exception& e) {
2771 pdf.warn( 2568 pdf.warn(
2772 qpdf_e_damaged_pdf, 2569 qpdf_e_damaged_pdf,
@@ -2800,9 +2597,7 @@ QPDFJob::handlePageSpecs( @@ -2800,9 +2597,7 @@ QPDFJob::handlePageSpecs(
2800 referenced_fields.insert(field.getObjectHandle().getObjGen()); 2597 referenced_fields.insert(field.getObjectHandle().getObjGen());
2801 } 2598 }
2802 } else { 2599 } else {
2803 - pdf.replaceObject(  
2804 - page.getObjectHandle().getObjGen(),  
2805 - QPDFObjectHandle::newNull()); 2600 + pdf.replaceObject(page.getObjectHandle().getObjGen(), QPDFObjectHandle::newNull());
2806 } 2601 }
2807 } 2602 }
2808 // Remove unreferenced form fields 2603 // Remove unreferenced form fields
@@ -2843,8 +2638,7 @@ QPDFJob::handleRotations(QPDF&amp; pdf) @@ -2843,8 +2638,7 @@ QPDFJob::handleRotations(QPDF&amp; pdf)
2843 for (int pageno_iter: QUtil::parse_numrange(range.c_str(), npages)) { 2638 for (int pageno_iter: QUtil::parse_numrange(range.c_str(), npages)) {
2844 int pageno = pageno_iter - 1; 2639 int pageno = pageno_iter - 1;
2845 if ((pageno >= 0) && (pageno < npages)) { 2640 if ((pageno >= 0) && (pageno < npages)) {
2846 - pages.at(QIntC::to_size(pageno))  
2847 - .rotatePage(rspec.angle, rspec.relative); 2641 + pages.at(QIntC::to_size(pageno)).rotatePage(rspec.angle, rspec.relative);
2848 } 2642 }
2849 } 2643 }
2850 } 2644 }
@@ -2869,24 +2663,21 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password) @@ -2869,24 +2663,21 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password)
2869 bool has_8bit_chars; 2663 bool has_8bit_chars;
2870 bool is_valid_utf8; 2664 bool is_valid_utf8;
2871 bool is_utf16; 2665 bool is_utf16;
2872 - QUtil::analyze_encoding(  
2873 - password, has_8bit_chars, is_valid_utf8, is_utf16); 2666 + QUtil::analyze_encoding(password, has_8bit_chars, is_valid_utf8, is_utf16);
2874 if (!has_8bit_chars) { 2667 if (!has_8bit_chars) {
2875 return; 2668 return;
2876 } 2669 }
2877 if (m->password_mode == QPDFJob::pm_unicode) { 2670 if (m->password_mode == QPDFJob::pm_unicode) {
2878 if (!is_valid_utf8) { 2671 if (!is_valid_utf8) {
2879 QTC::TC("qpdf", "QPDFJob password not unicode"); 2672 QTC::TC("qpdf", "QPDFJob password not unicode");
2880 - throw std::runtime_error(  
2881 - "supplied password is not valid UTF-8"); 2673 + throw std::runtime_error("supplied password is not valid UTF-8");
2882 } 2674 }
2883 if (R < 5) { 2675 if (R < 5) {
2884 std::string encoded; 2676 std::string encoded;
2885 if (!QUtil::utf8_to_pdf_doc(password, encoded)) { 2677 if (!QUtil::utf8_to_pdf_doc(password, encoded)) {
2886 QTC::TC("qpdf", "QPDFJob password not encodable"); 2678 QTC::TC("qpdf", "QPDFJob password not encodable");
2887 - throw std::runtime_error(  
2888 - "supplied password cannot be encoded for"  
2889 - " 40-bit or 128-bit encryption formats"); 2679 + throw std::runtime_error("supplied password cannot be encoded for"
  2680 + " 40-bit or 128-bit encryption formats");
2890 } 2681 }
2891 password = encoded; 2682 password = encoded;
2892 } 2683 }
@@ -2895,8 +2686,7 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password) @@ -2895,8 +2686,7 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password)
2895 std::string encoded; 2686 std::string encoded;
2896 if (QUtil::utf8_to_pdf_doc(password, encoded)) { 2687 if (QUtil::utf8_to_pdf_doc(password, encoded)) {
2897 QTC::TC("qpdf", "QPDFJob auto-encode password"); 2688 QTC::TC("qpdf", "QPDFJob auto-encode password");
2898 - doIfVerbose([&](Pipeline& v,  
2899 - std::string const& prefix) { 2689 + doIfVerbose([&](Pipeline& v, std::string const& prefix) {
2900 v << prefix << ": automatically converting Unicode" 2690 v << prefix << ": automatically converting Unicode"
2901 << " password to single-byte encoding as" 2691 << " password to single-byte encoding as"
2902 << " required for 40-bit or 128-bit" 2692 << " required for 40-bit or 128-bit"
@@ -2905,25 +2695,23 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password) @@ -2905,25 +2695,23 @@ QPDFJob::maybeFixWritePassword(int R, std::string&amp; password)
2905 password = encoded; 2695 password = encoded;
2906 } else { 2696 } else {
2907 QTC::TC("qpdf", "QPDFJob bytes fallback warning"); 2697 QTC::TC("qpdf", "QPDFJob bytes fallback warning");
2908 - *m->log->getError()  
2909 - << m->message_prefix << ": WARNING: "  
2910 - << "supplied password looks like a Unicode"  
2911 - << " password with characters not allowed in"  
2912 - << " passwords for 40-bit and 128-bit "  
2913 - "encryption;"  
2914 - << " most readers will not be able to open this"  
2915 - << " file with the supplied password."  
2916 - << " (Use --password-mode=bytes to suppress "  
2917 - "this"  
2918 - << " warning and use the password anyway.)\n"; 2698 + *m->log->getError() << m->message_prefix << ": WARNING: "
  2699 + << "supplied password looks like a Unicode"
  2700 + << " password with characters not allowed in"
  2701 + << " passwords for 40-bit and 128-bit "
  2702 + "encryption;"
  2703 + << " most readers will not be able to open this"
  2704 + << " file with the supplied password."
  2705 + << " (Use --password-mode=bytes to suppress "
  2706 + "this"
  2707 + << " warning and use the password anyway.)\n";
2919 } 2708 }
2920 } else if ((R >= 5) && (!is_valid_utf8)) { 2709 } else if ((R >= 5) && (!is_valid_utf8)) {
2921 QTC::TC("qpdf", "QPDFJob invalid utf-8 in auto"); 2710 QTC::TC("qpdf", "QPDFJob invalid utf-8 in auto");
2922 - throw std::runtime_error(  
2923 - "supplied password is not a valid Unicode password,"  
2924 - " which is required for 256-bit encryption; to"  
2925 - " really use this password, rerun with the"  
2926 - " --password-mode=bytes option"); 2711 + throw std::runtime_error("supplied password is not a valid Unicode password,"
  2712 + " which is required for 256-bit encryption; to"
  2713 + " really use this password, rerun with the"
  2714 + " --password-mode=bytes option");
2927 } 2715 }
2928 } 2716 }
2929 } 2717 }
@@ -2953,28 +2741,25 @@ QPDFJob::setEncryptionOptions(QPDF&amp; pdf, QPDFWriter&amp; w) @@ -2953,28 +2741,25 @@ QPDFJob::setEncryptionOptions(QPDF&amp; pdf, QPDFWriter&amp; w)
2953 throw std::logic_error("bad encryption keylen"); 2741 throw std::logic_error("bad encryption keylen");
2954 } 2742 }
2955 if ((R > 3) && (m->r3_accessibility == false)) { 2743 if ((R > 3) && (m->r3_accessibility == false)) {
2956 - *m->log->getError()  
2957 - << m->message_prefix << ": -accessibility=n is ignored for modern"  
2958 - << " encryption formats\n"; 2744 + *m->log->getError() << m->message_prefix << ": -accessibility=n is ignored for modern"
  2745 + << " encryption formats\n";
2959 } 2746 }
2960 maybeFixWritePassword(R, m->user_password); 2747 maybeFixWritePassword(R, m->user_password);
2961 maybeFixWritePassword(R, m->owner_password); 2748 maybeFixWritePassword(R, m->owner_password);
2962 if ((R < 4) || ((R == 4) && (!m->use_aes))) { 2749 if ((R < 4) || ((R == 4) && (!m->use_aes))) {
2963 if (!m->allow_weak_crypto) { 2750 if (!m->allow_weak_crypto) {
2964 QTC::TC("qpdf", "QPDFJob weak crypto error"); 2751 QTC::TC("qpdf", "QPDFJob weak crypto error");
2965 - *m->log->getError()  
2966 - << m->message_prefix  
2967 - << ": refusing to write a file with RC4, a weak "  
2968 - "cryptographic "  
2969 - "algorithm\n"  
2970 - << "Please use 256-bit keys for better security.\n"  
2971 - << "Pass --allow-weak-crypto to enable writing insecure "  
2972 - "files.\n"  
2973 - << "See also "  
2974 - "https://qpdf.readthedocs.io/en/stable/"  
2975 - "weak-crypto.html\n";  
2976 - throw std::runtime_error(  
2977 - "refusing to write a file with weak crypto"); 2752 + *m->log->getError() << m->message_prefix
  2753 + << ": refusing to write a file with RC4, a weak "
  2754 + "cryptographic "
  2755 + "algorithm\n"
  2756 + << "Please use 256-bit keys for better security.\n"
  2757 + << "Pass --allow-weak-crypto to enable writing insecure "
  2758 + "files.\n"
  2759 + << "See also "
  2760 + "https://qpdf.readthedocs.io/en/stable/"
  2761 + "weak-crypto.html\n";
  2762 + throw std::runtime_error("refusing to write a file with weak crypto");
2978 } 2763 }
2979 } 2764 }
2980 switch (R) { 2765 switch (R) {
@@ -3046,10 +2831,7 @@ QPDFJob::setEncryptionOptions(QPDF&amp; pdf, QPDFWriter&amp; w) @@ -3046,10 +2831,7 @@ QPDFJob::setEncryptionOptions(QPDF&amp; pdf, QPDFWriter&amp; w)
3046 } 2831 }
3047 2832
3048 static void 2833 static void
3049 -parse_version(  
3050 - std::string const& full_version_string,  
3051 - std::string& version,  
3052 - int& extension_level) 2834 +parse_version(std::string const& full_version_string, std::string& version, int& extension_level)
3053 { 2835 {
3054 auto vp = QUtil::make_unique_cstr(full_version_string); 2836 auto vp = QUtil::make_unique_cstr(full_version_string);
3055 char* v = vp.get(); 2837 char* v = vp.get();
@@ -3144,18 +2926,13 @@ QPDFJob::setWriterOptions(QPDF&amp; pdf, QPDFWriter&amp; w) @@ -3144,18 +2926,13 @@ QPDFJob::setWriterOptions(QPDF&amp; pdf, QPDFWriter&amp; w)
3144 } 2926 }
3145 if (m->progress) { 2927 if (m->progress) {
3146 if (m->progress_handler) { 2928 if (m->progress_handler) {
3147 - w.registerProgressReporter(  
3148 - std::shared_ptr<QPDFWriter::ProgressReporter>(  
3149 - new QPDFWriter::FunctionProgressReporter(  
3150 - m->progress_handler))); 2929 + w.registerProgressReporter(std::shared_ptr<QPDFWriter::ProgressReporter>(
  2930 + new QPDFWriter::FunctionProgressReporter(m->progress_handler)));
3151 } else { 2931 } else {
3152 - char const* outfilename =  
3153 - m->outfilename ? m->outfilename.get() : "standard output";  
3154 - w.registerProgressReporter(  
3155 - std::shared_ptr<QPDFWriter::ProgressReporter>(  
3156 - // line-break  
3157 - new ProgressReporter(  
3158 - *m->log->getInfo(), m->message_prefix, outfilename))); 2932 + char const* outfilename = m->outfilename ? m->outfilename.get() : "standard output";
  2933 + w.registerProgressReporter(std::shared_ptr<QPDFWriter::ProgressReporter>(
  2934 + // line-break
  2935 + new ProgressReporter(*m->log->getInfo(), m->message_prefix, outfilename)));
3159 } 2936 }
3160 } 2937 }
3161 } 2938 }
@@ -3170,14 +2947,10 @@ QPDFJob::doSplitPages(QPDF&amp; pdf) @@ -3170,14 +2947,10 @@ QPDFJob::doSplitPages(QPDF&amp; pdf)
3170 char* num_spot = strstr(const_cast<char*>(m->outfilename.get()), "%d"); 2947 char* num_spot = strstr(const_cast<char*>(m->outfilename.get()), "%d");
3171 if (num_spot != nullptr) { 2948 if (num_spot != nullptr) {
3172 QTC::TC("qpdf", "QPDFJob split-pages %d"); 2949 QTC::TC("qpdf", "QPDFJob split-pages %d");
3173 - before = std::string(  
3174 - m->outfilename.get(),  
3175 - QIntC::to_size(num_spot - m->outfilename.get())); 2950 + before = std::string(m->outfilename.get(), QIntC::to_size(num_spot - m->outfilename.get()));
3176 after = num_spot + 2; 2951 after = num_spot + 2;
3177 } else if ( 2952 } else if (
3178 - (len >= 4) &&  
3179 - (QUtil::str_compare_nocase(m->outfilename.get() + len - 4, ".pdf") ==  
3180 - 0)) { 2953 + (len >= 4) && (QUtil::str_compare_nocase(m->outfilename.get() + len - 4, ".pdf") == 0)) {
3181 QTC::TC("qpdf", "QPDFJob split-pages .pdf"); 2954 QTC::TC("qpdf", "QPDFJob split-pages .pdf");
3182 before = std::string(m->outfilename.get(), len - 4) + "-"; 2955 before = std::string(m->outfilename.get(), len - 4) + "-";
3183 after = m->outfilename.get() + len - 4; 2956 after = m->outfilename.get() + len - 4;
@@ -3232,24 +3005,18 @@ QPDFJob::doSplitPages(QPDF&amp; pdf) @@ -3232,24 +3005,18 @@ QPDFJob::doSplitPages(QPDF&amp; pdf)
3232 if (pldh.hasPageLabels()) { 3005 if (pldh.hasPageLabels()) {
3233 std::vector<QPDFObjectHandle> labels; 3006 std::vector<QPDFObjectHandle> labels;
3234 pldh.getLabelsForPageRange( 3007 pldh.getLabelsForPageRange(
3235 - QIntC::to_longlong(first - 1),  
3236 - QIntC::to_longlong(last - 1),  
3237 - 0,  
3238 - labels); 3008 + QIntC::to_longlong(first - 1), QIntC::to_longlong(last - 1), 0, labels);
3239 QPDFObjectHandle page_labels = QPDFObjectHandle::newDictionary(); 3009 QPDFObjectHandle page_labels = QPDFObjectHandle::newDictionary();
3240 page_labels.replaceKey("/Nums", QPDFObjectHandle::newArray(labels)); 3010 page_labels.replaceKey("/Nums", QPDFObjectHandle::newArray(labels));
3241 outpdf.getRoot().replaceKey("/PageLabels", page_labels); 3011 outpdf.getRoot().replaceKey("/PageLabels", page_labels);
3242 } 3012 }
3243 - std::string page_range =  
3244 - QUtil::uint_to_string(first, QIntC::to_int(pageno_len)); 3013 + std::string page_range = QUtil::uint_to_string(first, QIntC::to_int(pageno_len));
3245 if (m->split_pages > 1) { 3014 if (m->split_pages > 1) {
3246 - page_range +=  
3247 - "-" + QUtil::uint_to_string(last, QIntC::to_int(pageno_len)); 3015 + page_range += "-" + QUtil::uint_to_string(last, QIntC::to_int(pageno_len));
3248 } 3016 }
3249 std::string outfile = before + page_range + after; 3017 std::string outfile = before + page_range + after;
3250 if (QUtil::same_file(m->infilename.get(), outfile.c_str())) { 3018 if (QUtil::same_file(m->infilename.get(), outfile.c_str())) {
3251 - throw std::runtime_error(  
3252 - "split pages would overwrite input file with " + outfile); 3019 + throw std::runtime_error("split pages would overwrite input file with " + outfile);
3253 } 3020 }
3254 QPDFWriter w(outpdf, outfile.c_str()); 3021 QPDFWriter w(outpdf, outfile.c_str());
3255 setWriterOptions(outpdf, w); 3022 setWriterOptions(outpdf, w);
@@ -3268,8 +3035,7 @@ QPDFJob::writeOutfile(QPDF&amp; pdf) @@ -3268,8 +3035,7 @@ QPDFJob::writeOutfile(QPDF&amp; pdf)
3268 // Append but don't prepend to the path to generate a 3035 // Append but don't prepend to the path to generate a
3269 // temporary name. This saves us from having to split the path 3036 // temporary name. This saves us from having to split the path
3270 // by directory and non-directory. 3037 // by directory and non-directory.
3271 - temp_out = QUtil::make_shared_cstr(  
3272 - std::string(m->infilename.get()) + ".~qpdf-temp#"); 3038 + temp_out = QUtil::make_shared_cstr(std::string(m->infilename.get()) + ".~qpdf-temp#");
3273 // m->outfilename will be restored to 0 before temp_out 3039 // m->outfilename will be restored to 0 before temp_out
3274 // goes out of scope. 3040 // goes out of scope.
3275 m->outfilename = temp_out; 3041 m->outfilename = temp_out;
@@ -3312,17 +3078,14 @@ QPDFJob::writeOutfile(QPDF&amp; pdf) @@ -3312,17 +3078,14 @@ QPDFJob::writeOutfile(QPDF&amp; pdf)
3312 QUtil::rename_file(m->infilename.get(), backup.c_str()); 3078 QUtil::rename_file(m->infilename.get(), backup.c_str());
3313 QUtil::rename_file(temp_out.get(), m->infilename.get()); 3079 QUtil::rename_file(temp_out.get(), m->infilename.get());
3314 if (warnings) { 3080 if (warnings) {
3315 - *m->log->getError()  
3316 - << m->message_prefix  
3317 - << ": there are warnings; original file kept in " << backup  
3318 - << "\n"; 3081 + *m->log->getError() << m->message_prefix
  3082 + << ": there are warnings; original file kept in " << backup << "\n";
3319 } else { 3083 } else {
3320 try { 3084 try {
3321 QUtil::remove_file(backup.c_str()); 3085 QUtil::remove_file(backup.c_str());
3322 } catch (QPDFSystemError& e) { 3086 } catch (QPDFSystemError& e) {
3323 *m->log->getError() 3087 *m->log->getError()
3324 - << m->message_prefix << ": unable to delete original file ("  
3325 - << e.what() << ");" 3088 + << m->message_prefix << ": unable to delete original file (" << e.what() << ");"
3326 << " original file left in " << backup 3089 << " original file left in " << backup
3327 << ", but the input was successfully replaced\n"; 3090 << ", but the input was successfully replaced\n";
3328 } 3091 }
@@ -3342,12 +3105,9 @@ QPDFJob::writeJSON(QPDF&amp; pdf) @@ -3342,12 +3105,9 @@ QPDFJob::writeJSON(QPDF&amp; pdf)
3342 if (m->json_stream_prefix.empty()) { 3105 if (m->json_stream_prefix.empty()) {
3343 m->json_stream_prefix = m->outfilename.get(); 3106 m->json_stream_prefix = m->outfilename.get();
3344 } 3107 }
3345 - fc = std::make_shared<QUtil::FileCloser>(  
3346 - QUtil::safe_fopen(m->outfilename.get(), "w")); 3108 + fc = std::make_shared<QUtil::FileCloser>(QUtil::safe_fopen(m->outfilename.get(), "w"));
3347 fp = std::make_shared<Pl_StdioFile>("json output", fc->f); 3109 fp = std::make_shared<Pl_StdioFile>("json output", fc->f);
3348 - } else if (  
3349 - (m->json_stream_data == qpdf_sj_file) &&  
3350 - m->json_stream_prefix.empty()) { 3110 + } else if ((m->json_stream_data == qpdf_sj_file) && m->json_stream_prefix.empty()) {
3351 QTC::TC("qpdf", "QPDFJob need json-stream-prefix for stdout"); 3111 QTC::TC("qpdf", "QPDFJob need json-stream-prefix for stdout");
3352 usage("please specify --json-stream-prefix since the input file " 3112 usage("please specify --json-stream-prefix since the input file "
3353 "name is unknown"); 3113 "name is unknown");
libqpdf/QPDFJob_argv.cc
@@ -46,8 +46,7 @@ namespace @@ -46,8 +46,7 @@ namespace
46 }; 46 };
47 } // namespace 47 } // namespace
48 48
49 -ArgParser::ArgParser(  
50 - QPDFArgParser& ap, std::shared_ptr<QPDFJob::Config> c_main) : 49 +ArgParser::ArgParser(QPDFArgParser& ap, std::shared_ptr<QPDFJob::Config> c_main) :
51 ap(ap), 50 ap(ap),
52 c_main(c_main), 51 c_main(c_main),
53 pages_password(nullptr), 52 pages_password(nullptr),
@@ -107,8 +106,7 @@ ArgParser::argVersion() @@ -107,8 +106,7 @@ ArgParser::argVersion()
107 auto whoami = this->ap.getProgname(); 106 auto whoami = this->ap.getProgname();
108 *QPDFLogger::defaultLogger()->getInfo() 107 *QPDFLogger::defaultLogger()->getInfo()
109 << whoami << " version " << QPDF::QPDFVersion() << "\n" 108 << whoami << " version " << QPDF::QPDFVersion() << "\n"
110 - << "Run " << whoami  
111 - << " --copyright to see copyright and license information.\n"; 109 + << "Run " << whoami << " --copyright to see copyright and license information.\n";
112 } 110 }
113 111
114 void 112 void
@@ -152,8 +150,7 @@ ArgParser::argJsonHelp(std::string const&amp; parameter) @@ -152,8 +150,7 @@ ArgParser::argJsonHelp(std::string const&amp; parameter)
152 if ((version < 1) || (version > JSON::LATEST)) { 150 if ((version < 1) || (version > JSON::LATEST)) {
153 usage(std::string("unsupported json version ") + parameter); 151 usage(std::string("unsupported json version ") + parameter);
154 } 152 }
155 - *QPDFLogger::defaultLogger()->getInfo()  
156 - << QPDFJob::json_out_schema(version) << "\n"; 153 + *QPDFLogger::defaultLogger()->getInfo() << QPDFJob::json_out_schema(version) << "\n";
157 } 154 }
158 155
159 void 156 void
@@ -263,10 +260,7 @@ ArgParser::argPagesPositional(std::string const&amp; arg) @@ -263,10 +260,7 @@ ArgParser::argPagesPositional(std::string const&amp; arg)
263 if (range_p == nullptr) { 260 if (range_p == nullptr) {
264 if (arg.empty()) { 261 if (arg.empty()) {
265 // The filename or password was the last argument 262 // The filename or password was the last argument
266 - QTC::TC(  
267 - "qpdf",  
268 - "QPDFJob pages range omitted at end",  
269 - this->pages_password ? 0 : 1); 263 + QTC::TC("qpdf", "QPDFJob pages range omitted at end", this->pages_password ? 0 : 1);
270 } else { 264 } else {
271 // We need to accumulate some more arguments 265 // We need to accumulate some more arguments
272 return; 266 return;
libqpdf/QPDFJob_config.cc
@@ -658,8 +658,7 @@ QPDFJob::Config::passwordFile(std::string const&amp; parameter) @@ -658,8 +658,7 @@ QPDFJob::Config::passwordFile(std::string const&amp; parameter)
658 658
659 if (lines.size() > 1) { 659 if (lines.size() > 1) {
660 *QPDFLogger::defaultLogger()->getError() 660 *QPDFLogger::defaultLogger()->getError()
661 - << this->o.m->message_prefix  
662 - << ": WARNING: all but the first line of" 661 + << this->o.m->message_prefix << ": WARNING: all but the first line of"
663 << " the password file are ignored\n"; 662 << " the password file are ignored\n";
664 } 663 }
665 } 664 }
@@ -751,8 +750,7 @@ QPDFJob::Config::removeUnreferencedResources(std::string const&amp; parameter) @@ -751,8 +750,7 @@ QPDFJob::Config::removeUnreferencedResources(std::string const&amp; parameter)
751 QPDFJob::Config* 750 QPDFJob::Config*
752 QPDFJob::Config::showObject(std::string const& parameter) 751 QPDFJob::Config::showObject(std::string const& parameter)
753 { 752 {
754 - QPDFJob::parse_object_id(  
755 - parameter, o.m->show_trailer, o.m->show_obj, o.m->show_gen); 753 + QPDFJob::parse_object_id(parameter, o.m->show_trailer, o.m->show_obj, o.m->show_gen);
756 o.m->require_outfile = false; 754 o.m->require_outfile = false;
757 return this; 755 return this;
758 } 756 }
@@ -761,13 +759,11 @@ QPDFJob::Config* @@ -761,13 +759,11 @@ QPDFJob::Config*
761 QPDFJob::Config::jobJsonFile(std::string const& parameter) 759 QPDFJob::Config::jobJsonFile(std::string const& parameter)
762 { 760 {
763 try { 761 try {
764 - o.initializeFromJson(  
765 - QUtil::read_file_into_string(parameter.c_str()), true); 762 + o.initializeFromJson(QUtil::read_file_into_string(parameter.c_str()), true);
766 } catch (std::exception& e) { 763 } catch (std::exception& e) {
767 throw std::runtime_error( 764 throw std::runtime_error(
768 - "error with job-json file " + std::string(parameter) + ": " +  
769 - e.what() + "\nRun " + this->o.m->message_prefix +  
770 - " --job-json-help for information on the file format."); 765 + "error with job-json file " + std::string(parameter) + ": " + e.what() + "\nRun " +
  766 + this->o.m->message_prefix + " --job-json-help for information on the file format.");
771 } 767 }
772 return this; 768 return this;
773 } 769 }
@@ -900,8 +896,7 @@ QPDFJob::AttConfig::replace() @@ -900,8 +896,7 @@ QPDFJob::AttConfig::replace()
900 QPDFJob::Config* 896 QPDFJob::Config*
901 QPDFJob::AttConfig::endAddAttachment() 897 QPDFJob::AttConfig::endAddAttachment()
902 { 898 {
903 - static std::string now =  
904 - QUtil::qpdf_time_to_pdf_time(QUtil::get_current_qpdf_time()); 899 + static std::string now = QUtil::qpdf_time_to_pdf_time(QUtil::get_current_qpdf_time());
905 if (this->att.path.empty()) { 900 if (this->att.path.empty()) {
906 usage("add attachment: no file specified"); 901 usage("add attachment: no file specified");
907 } 902 }
@@ -953,8 +948,7 @@ QPDFJob::PagesConfig* @@ -953,8 +948,7 @@ QPDFJob::PagesConfig*
953 QPDFJob::PagesConfig::pageSpec( 948 QPDFJob::PagesConfig::pageSpec(
954 std::string const& filename, std::string const& range, char const* password) 949 std::string const& filename, std::string const& range, char const* password)
955 { 950 {
956 - this->config->o.m->page_specs.push_back(  
957 - QPDFJob::PageSpec(filename, password, range)); 951 + this->config->o.m->page_specs.push_back(QPDFJob::PageSpec(filename, password, range));
958 return this; 952 return this;
959 } 953 }
960 954
@@ -1035,9 +1029,7 @@ QPDFJob::UOConfig::password(std::string const&amp; parameter) @@ -1035,9 +1029,7 @@ QPDFJob::UOConfig::password(std::string const&amp; parameter)
1035 1029
1036 std::shared_ptr<QPDFJob::EncConfig> 1030 std::shared_ptr<QPDFJob::EncConfig>
1037 QPDFJob::Config::encrypt( 1031 QPDFJob::Config::encrypt(
1038 - int keylen,  
1039 - std::string const& user_password,  
1040 - std::string const& owner_password) 1032 + int keylen, std::string const& user_password, std::string const& owner_password)
1041 { 1033 {
1042 o.m->keylen = keylen; 1034 o.m->keylen = keylen;
1043 if (keylen == 256) { 1035 if (keylen == 256) {