Commit efd5aced350f36d267a247288462b68cd6a8c492

Authored by m-holger
1 parent bc6e62b9

Refactor `QPDFJob` configuration: consolidate options into `w_cfg`, update metho…

…d calls, and streamline related logic for improved encapsulation and maintainability.
libqpdf/QPDFJob.cc
@@ -804,7 +804,7 @@ QPDFJob::doShowObj(QPDF& pdf) @@ -804,7 +804,7 @@ QPDFJob::doShowObj(QPDF& pdf)
804 m->log->saveToStandardOutput(true); 804 m->log->saveToStandardOutput(true);
805 obj.pipeStreamData( 805 obj.pipeStreamData(
806 m->log->getSave().get(), 806 m->log->getSave().get(),
807 - (filter && m->normalize) ? qpdf_ef_normalize : 0, 807 + filter && m->w_cfg.normalize_content() ? qpdf_ef_normalize : 0,
808 filter ? qpdf_dl_all : qpdf_dl_none); 808 filter ? qpdf_dl_all : qpdf_dl_none);
809 } 809 }
810 } else { 810 } else {
@@ -974,7 +974,7 @@ QPDFJob::doJSONObjects(Pipeline* p, bool& first, QPDF& pdf) @@ -974,7 +974,7 @@ QPDFJob::doJSONObjects(Pipeline* p, bool& first, QPDF& pdf)
974 p, 974 p,
975 false, 975 false,
976 first, 976 first,
977 - m->decode_level, 977 + m->w_cfg.decode_level(),
978 m->json_stream_data, 978 m->json_stream_data,
979 m->json_stream_prefix, 979 m->json_stream_prefix,
980 json_objects); 980 json_objects);
@@ -1052,7 +1052,7 @@ QPDFJob::doJSONPages(Pipeline* p, bool& first, QPDF& pdf) @@ -1052,7 +1052,7 @@ QPDFJob::doJSONPages(Pipeline* p, bool& first, QPDF& pdf)
1052 j_image.addDictionaryMember("decodeparms", dp_array.getJSON(m->json_version)); 1052 j_image.addDictionaryMember("decodeparms", dp_array.getJSON(m->json_version));
1053 j_image.addDictionaryMember( 1053 j_image.addDictionaryMember(
1054 "filterable", 1054 "filterable",
1055 - JSON::makeBool(image.pipeStreamData(nullptr, 0, m->decode_level, true))); 1055 + JSON::makeBool(image.pipeStreamData(nullptr, 0, m->w_cfg.decode_level(), true)));
1056 } 1056 }
1057 j_page.addDictionaryMember("images", j_images); 1057 j_page.addDictionaryMember("images", j_images);
1058 JSON j_contents = j_page.addDictionaryMember("contents", JSON::makeArray()); 1058 JSON j_contents = j_page.addDictionaryMember("contents", JSON::makeArray());
@@ -1569,7 +1569,7 @@ QPDFJob::doJSON(QPDF& pdf, Pipeline* p) @@ -1569,7 +1569,7 @@ QPDFJob::doJSON(QPDF& pdf, Pipeline* p)
1569 JSON::writeDictionaryItem(p, first, "version", JSON::makeInt(m->json_version), 1); 1569 JSON::writeDictionaryItem(p, first, "version", JSON::makeInt(m->json_version), 1);
1570 JSON j_params = JSON::makeDictionary(); 1570 JSON j_params = JSON::makeDictionary();
1571 std::string decode_level_str; 1571 std::string decode_level_str;
1572 - switch (m->decode_level) { 1572 + switch (m->w_cfg.decode_level()) {
1573 case qpdf_dl_none: 1573 case qpdf_dl_none:
1574 decode_level_str = "none"; 1574 decode_level_str = "none";
1575 break; 1575 break;
@@ -2884,45 +2884,12 @@ QPDFJob::setWriterOptions(Writer& w) @@ -2884,45 +2884,12 @@ QPDFJob::setWriterOptions(Writer& w)
2884 if (m->compression_level >= 0) { 2884 if (m->compression_level >= 0) {
2885 Pl_Flate::setCompressionLevel(m->compression_level); 2885 Pl_Flate::setCompressionLevel(m->compression_level);
2886 } 2886 }
2887 - if (m->qdf_mode) {  
2888 - w.setQDFMode(true);  
2889 - }  
2890 - if (m->preserve_unreferenced_objects) {  
2891 - w.setPreserveUnreferencedObjects(true);  
2892 - }  
2893 - if (m->newline_before_endstream) {  
2894 - w.setNewlineBeforeEndstream(true);  
2895 - }  
2896 - if (m->normalize_set) {  
2897 - w.setContentNormalization(m->normalize);  
2898 - }  
2899 - if (m->stream_data_set) {  
2900 - w.setStreamDataMode(m->stream_data_mode);  
2901 - }  
2902 - if (m->compress_streams_set) {  
2903 - w.setCompressStreams(m->compress_streams);  
2904 - }  
2905 - if (m->recompress_flate_set) {  
2906 - w.setRecompressFlate(m->recompress_flate);  
2907 - }  
2908 - if (m->decode_level_set) {  
2909 - w.setDecodeLevel(m->decode_level);  
2910 - }  
2911 if (m->decrypt) { 2887 if (m->decrypt) {
2912 w.setPreserveEncryption(false); 2888 w.setPreserveEncryption(false);
2913 } 2889 }
2914 - if (m->deterministic_id) {  
2915 - w.setDeterministicID(true);  
2916 - }  
2917 - if (m->static_id) {  
2918 - w.setStaticID(true);  
2919 - }  
2920 if (m->static_aes_iv) { 2890 if (m->static_aes_iv) {
2921 w.setStaticAesIV(true); 2891 w.setStaticAesIV(true);
2922 } 2892 }
2923 - if (m->suppress_original_object_id) {  
2924 - w.setSuppressOriginalObjectIDs(true);  
2925 - }  
2926 if (m->copy_encryption) { 2893 if (m->copy_encryption) {
2927 std::unique_ptr<QPDF> encryption_pdf; 2894 std::unique_ptr<QPDF> encryption_pdf;
2928 processFile( 2895 processFile(
@@ -2936,15 +2903,6 @@ QPDFJob::setWriterOptions(Writer&amp; w) @@ -2936,15 +2903,6 @@ QPDFJob::setWriterOptions(Writer&amp; w)
2936 if (m->encrypt) { 2903 if (m->encrypt) {
2937 setEncryptionOptions(w); 2904 setEncryptionOptions(w);
2938 } 2905 }
2939 - if (m->linearize) {  
2940 - w.setLinearization(true);  
2941 - }  
2942 - if (!m->linearize_pass1.empty()) {  
2943 - w.setLinearizationPass1Filename(m->linearize_pass1);  
2944 - }  
2945 - if (m->object_stream_set) {  
2946 - w.setObjectStreamMode(m->object_stream_mode);  
2947 - }  
2948 w.setMinimumPDFVersion(m->max_input_version); 2906 w.setMinimumPDFVersion(m->max_input_version);
2949 if (!m->min_version.empty()) { 2907 if (!m->min_version.empty()) {
2950 std::string version; 2908 std::string version;
libqpdf/QPDFJob_config.cc
@@ -124,8 +124,7 @@ QPDFJob::Config::collate(std::string const&amp; parameter) @@ -124,8 +124,7 @@ QPDFJob::Config::collate(std::string const&amp; parameter)
124 QPDFJob::Config* 124 QPDFJob::Config*
125 QPDFJob::Config::compressStreams(std::string const& parameter) 125 QPDFJob::Config::compressStreams(std::string const& parameter)
126 { 126 {
127 - o.m->compress_streams_set = true;  
128 - o.m->compress_streams = (parameter == "y"); 127 + o.m->w_cfg.compress_streams(parameter == "y");
129 return this; 128 return this;
130 } 129 }
131 130
@@ -146,7 +145,7 @@ QPDFJob::Config::jpegQuality(std::string const&amp; parameter) @@ -146,7 +145,7 @@ QPDFJob::Config::jpegQuality(std::string const&amp; parameter)
146 QPDFJob::Config* 145 QPDFJob::Config*
147 QPDFJob::Config::copyEncryption(std::string const& parameter) 146 QPDFJob::Config::copyEncryption(std::string const& parameter)
148 { 147 {
149 - if (o.m->deterministic_id) { 148 + if (o.m->w_cfg.deterministic_id()) {
150 usage("the deterministic-id option is incompatible with encrypted output files"); 149 usage("the deterministic-id option is incompatible with encrypted output files");
151 } 150 }
152 o.m->inputs.encryption_file = parameter; 151 o.m->inputs.encryption_file = parameter;
@@ -171,7 +170,7 @@ QPDFJob::Config::deterministicId() @@ -171,7 +170,7 @@ QPDFJob::Config::deterministicId()
171 if (o.m->encrypt || o.m->copy_encryption) { 170 if (o.m->encrypt || o.m->copy_encryption) {
172 usage("the deterministic-id option is incompatible with encrypted output files"); 171 usage("the deterministic-id option is incompatible with encrypted output files");
173 } 172 }
174 - o.m->deterministic_id = true; 173 + o.m->w_cfg.deterministic_id(true);
175 return this; 174 return this;
176 } 175 }
177 176
@@ -327,9 +326,7 @@ QPDFJob::Config::jsonOutput(std::string const&amp; parameter) @@ -327,9 +326,7 @@ QPDFJob::Config::jsonOutput(std::string const&amp; parameter)
327 // No need to set json_stream_data_set -- that indicates explicit use of --json-stream-data. 326 // No need to set json_stream_data_set -- that indicates explicit use of --json-stream-data.
328 o.m->json_stream_data = qpdf_sj_inline; 327 o.m->json_stream_data = qpdf_sj_inline;
329 } 328 }
330 - if (!o.m->decode_level_set) {  
331 - o.m->decode_level = qpdf_dl_none;  
332 - } 329 + o.m->w_cfg.default_decode_level(qpdf_dl_none);
333 o.m->json_keys.insert("qpdf"); 330 o.m->json_keys.insert("qpdf");
334 return this; 331 return this;
335 } 332 }
@@ -373,14 +370,14 @@ QPDFJob::Config::keepInlineImages() @@ -373,14 +370,14 @@ QPDFJob::Config::keepInlineImages()
373 QPDFJob::Config* 370 QPDFJob::Config*
374 QPDFJob::Config::linearize() 371 QPDFJob::Config::linearize()
375 { 372 {
376 - o.m->linearize = true; 373 + o.m->w_cfg.linearize(true);
377 return this; 374 return this;
378 } 375 }
379 376
380 QPDFJob::Config* 377 QPDFJob::Config*
381 QPDFJob::Config::linearizePass1(std::string const& parameter) 378 QPDFJob::Config::linearizePass1(std::string const& parameter)
382 { 379 {
383 - o.m->linearize_pass1 = parameter; 380 + o.m->w_cfg.linearize_pass1(parameter);
384 return this; 381 return this;
385 } 382 }
386 383
@@ -402,14 +399,14 @@ QPDFJob::Config::minVersion(std::string const&amp; parameter) @@ -402,14 +399,14 @@ QPDFJob::Config::minVersion(std::string const&amp; parameter)
402 QPDFJob::Config* 399 QPDFJob::Config*
403 QPDFJob::Config::newlineBeforeEndstream() 400 QPDFJob::Config::newlineBeforeEndstream()
404 { 401 {
405 - o.m->newline_before_endstream = true; 402 + o.m->w_cfg.newline_before_endstream(true);
406 return this; 403 return this;
407 } 404 }
408 405
409 QPDFJob::Config* 406 QPDFJob::Config*
410 QPDFJob::Config::noOriginalObjectIds() 407 QPDFJob::Config::noOriginalObjectIds()
411 { 408 {
412 - o.m->suppress_original_object_id = true; 409 + o.m->w_cfg.no_original_object_ids(true);
413 return this; 410 return this;
414 } 411 }
415 412
@@ -423,8 +420,7 @@ QPDFJob::Config::noWarn() @@ -423,8 +420,7 @@ QPDFJob::Config::noWarn()
423 QPDFJob::Config* 420 QPDFJob::Config*
424 QPDFJob::Config::normalizeContent(std::string const& parameter) 421 QPDFJob::Config::normalizeContent(std::string const& parameter)
425 { 422 {
426 - o.m->normalize_set = true;  
427 - o.m->normalize = (parameter == "y"); 423 + o.m->w_cfg.normalize_content(parameter == "y");
428 return this; 424 return this;
429 } 425 }
430 426
@@ -473,7 +469,7 @@ QPDFJob::Config::passwordIsHexKey() @@ -473,7 +469,7 @@ QPDFJob::Config::passwordIsHexKey()
473 QPDFJob::Config* 469 QPDFJob::Config*
474 QPDFJob::Config::preserveUnreferenced() 470 QPDFJob::Config::preserveUnreferenced()
475 { 471 {
476 - o.m->preserve_unreferenced_objects = true; 472 + o.m->w_cfg.preserve_unreferenced(true);
477 return this; 473 return this;
478 } 474 }
479 475
@@ -494,7 +490,7 @@ QPDFJob::Config::progress() @@ -494,7 +490,7 @@ QPDFJob::Config::progress()
494 QPDFJob::Config* 490 QPDFJob::Config*
495 QPDFJob::Config::qdf() 491 QPDFJob::Config::qdf()
496 { 492 {
497 - o.m->qdf_mode = true; 493 + o.m->w_cfg.qdf(true);
498 return this; 494 return this;
499 } 495 }
500 496
@@ -508,8 +504,7 @@ QPDFJob::Config::rawStreamData() @@ -508,8 +504,7 @@ QPDFJob::Config::rawStreamData()
508 QPDFJob::Config* 504 QPDFJob::Config*
509 QPDFJob::Config::recompressFlate() 505 QPDFJob::Config::recompressFlate()
510 { 506 {
511 - o.m->recompress_flate_set = true;  
512 - o.m->recompress_flate = true; 507 + o.m->w_cfg.recompress_flate(true);
513 return this; 508 return this;
514 } 509 }
515 510
@@ -649,7 +644,7 @@ QPDFJob::Config::staticAesIv() @@ -649,7 +644,7 @@ QPDFJob::Config::staticAesIv()
649 QPDFJob::Config* 644 QPDFJob::Config*
650 QPDFJob::Config::staticId() 645 QPDFJob::Config::staticId()
651 { 646 {
652 - o.m->static_id = true; 647 + o.m->w_cfg.static_id(true);
653 return this; 648 return this;
654 } 649 }
655 650
@@ -731,13 +726,12 @@ QPDFJob::Config::passwordMode(std::string const&amp; parameter) @@ -731,13 +726,12 @@ QPDFJob::Config::passwordMode(std::string const&amp; parameter)
731 QPDFJob::Config* 726 QPDFJob::Config*
732 QPDFJob::Config::streamData(std::string const& parameter) 727 QPDFJob::Config::streamData(std::string const& parameter)
733 { 728 {
734 - o.m->stream_data_set = true;  
735 if (parameter == "compress") { 729 if (parameter == "compress") {
736 - o.m->stream_data_mode = qpdf_s_compress; 730 + o.m->w_cfg.stream_data(qpdf_s_compress);
737 } else if (parameter == "preserve") { 731 } else if (parameter == "preserve") {
738 - o.m->stream_data_mode = qpdf_s_preserve; 732 + o.m->w_cfg.stream_data(qpdf_s_preserve);
739 } else if (parameter == "uncompress") { 733 } else if (parameter == "uncompress") {
740 - o.m->stream_data_mode = qpdf_s_uncompress; 734 + o.m->w_cfg.stream_data(qpdf_s_uncompress);
741 } else { 735 } else {
742 usage("invalid stream-data option"); 736 usage("invalid stream-data option");
743 } 737 }
@@ -747,15 +741,14 @@ QPDFJob::Config::streamData(std::string const&amp; parameter) @@ -747,15 +741,14 @@ QPDFJob::Config::streamData(std::string const&amp; parameter)
747 QPDFJob::Config* 741 QPDFJob::Config*
748 QPDFJob::Config::decodeLevel(std::string const& parameter) 742 QPDFJob::Config::decodeLevel(std::string const& parameter)
749 { 743 {
750 - o.m->decode_level_set = true;  
751 if (parameter == "none") { 744 if (parameter == "none") {
752 - o.m->decode_level = qpdf_dl_none; 745 + o.m->w_cfg.decode_level(qpdf_dl_none);
753 } else if (parameter == "generalized") { 746 } else if (parameter == "generalized") {
754 - o.m->decode_level = qpdf_dl_generalized; 747 + o.m->w_cfg.decode_level(qpdf_dl_generalized);
755 } else if (parameter == "specialized") { 748 } else if (parameter == "specialized") {
756 - o.m->decode_level = qpdf_dl_specialized; 749 + o.m->w_cfg.decode_level(qpdf_dl_specialized);
757 } else if (parameter == "all") { 750 } else if (parameter == "all") {
758 - o.m->decode_level = qpdf_dl_all; 751 + o.m->w_cfg.decode_level(qpdf_dl_all);
759 } else { 752 } else {
760 usage("invalid option"); 753 usage("invalid option");
761 } 754 }
@@ -765,13 +758,12 @@ QPDFJob::Config::decodeLevel(std::string const&amp; parameter) @@ -765,13 +758,12 @@ QPDFJob::Config::decodeLevel(std::string const&amp; parameter)
765 QPDFJob::Config* 758 QPDFJob::Config*
766 QPDFJob::Config::objectStreams(std::string const& parameter) 759 QPDFJob::Config::objectStreams(std::string const& parameter)
767 { 760 {
768 - o.m->object_stream_set = true;  
769 if (parameter == "disable") { 761 if (parameter == "disable") {
770 - o.m->object_stream_mode = qpdf_o_disable; 762 + o.m->w_cfg.object_streams(qpdf_o_disable);
771 } else if (parameter == "preserve") { 763 } else if (parameter == "preserve") {
772 - o.m->object_stream_mode = qpdf_o_preserve; 764 + o.m->w_cfg.object_streams(qpdf_o_preserve);
773 } else if (parameter == "generate") { 765 } else if (parameter == "generate") {
774 - o.m->object_stream_mode = qpdf_o_generate; 766 + o.m->w_cfg.object_streams(qpdf_o_generate);
775 } else { 767 } else {
776 usage("invalid object stream mode"); 768 usage("invalid object stream mode");
777 } 769 }
@@ -1111,7 +1103,7 @@ std::shared_ptr&lt;QPDFJob::EncConfig&gt; @@ -1111,7 +1103,7 @@ std::shared_ptr&lt;QPDFJob::EncConfig&gt;
1111 QPDFJob::Config::encrypt( 1103 QPDFJob::Config::encrypt(
1112 int keylen, std::string const& user_password, std::string const& owner_password) 1104 int keylen, std::string const& user_password, std::string const& owner_password)
1113 { 1105 {
1114 - if (o.m->deterministic_id) { 1106 + if (o.m->w_cfg.deterministic_id()) {
1115 usage("the deterministic-id option is incompatible with encrypted output files"); 1107 usage("the deterministic-id option is incompatible with encrypted output files");
1116 } 1108 }
1117 o.m->keylen = keylen; 1109 o.m->keylen = keylen;
libqpdf/QPDFWriter.cc
@@ -577,17 +577,17 @@ Config::stream_data(qpdf_stream_data_e mode) @@ -577,17 +577,17 @@ Config::stream_data(qpdf_stream_data_e mode)
577 { 577 {
578 switch (mode) { 578 switch (mode) {
579 case qpdf_s_uncompress: 579 case qpdf_s_uncompress:
580 - stream_decode_level(std::max(qpdf_dl_generalized, stream_decode_level_)); 580 + decode_level(std::max(qpdf_dl_generalized, decode_level_));
581 compress_streams(false); 581 compress_streams(false);
582 return *this; 582 return *this;
583 583
584 case qpdf_s_preserve: 584 case qpdf_s_preserve:
585 - stream_decode_level(qpdf_dl_none); 585 + decode_level(qpdf_dl_none);
586 compress_streams(false); 586 compress_streams(false);
587 return *this; 587 return *this;
588 588
589 case qpdf_s_compress: 589 case qpdf_s_compress:
590 - stream_decode_level(std::max(qpdf_dl_generalized, stream_decode_level_)); 590 + decode_level(std::max(qpdf_dl_generalized, decode_level_));
591 compress_streams(true); 591 compress_streams(true);
592 } 592 }
593 return *this; 593 return *this;
@@ -614,18 +614,18 @@ Config::compress_streams(bool val) @@ -614,18 +614,18 @@ Config::compress_streams(bool val)
614 void 614 void
615 QPDFWriter::setDecodeLevel(qpdf_stream_decode_level_e val) 615 QPDFWriter::setDecodeLevel(qpdf_stream_decode_level_e val)
616 { 616 {
617 - m->cfg.stream_decode_level(val); 617 + m->cfg.decode_level(val);
618 } 618 }
619 619
620 Config& 620 Config&
621 -Config::stream_decode_level(qpdf_stream_decode_level_e val) 621 +Config::decode_level(qpdf_stream_decode_level_e val)
622 { 622 {
623 if (pclm_) { 623 if (pclm_) {
624 usage("stream_decode_level cannot be set when pclm is set"); 624 usage("stream_decode_level cannot be set when pclm is set");
625 return *this; 625 return *this;
626 } 626 }
627 - stream_decode_level_set_ = true;  
628 - stream_decode_level_ = val; 627 + decode_level_set_ = true;
  628 + decode_level_ = val;
629 return *this; 629 return *this;
630 } 630 }
631 631
@@ -664,8 +664,8 @@ Config::qdf(bool val) @@ -664,8 +664,8 @@ Config::qdf(bool val)
664 if (!compress_streams_set_) { 664 if (!compress_streams_set_) {
665 compress_streams(false); 665 compress_streams(false);
666 } 666 }
667 - if (!stream_decode_level_set_) {  
668 - stream_decode_level(qpdf_dl_generalized); 667 + if (!decode_level_set_) {
  668 + decode_level(qpdf_dl_generalized);
669 } 669 }
670 preserve_encryption_ = false; 670 preserve_encryption_ = false;
671 // Generate indirect stream lengths for qdf mode since fix-qdf uses them for storing 671 // Generate indirect stream lengths for qdf mode since fix-qdf uses them for storing
@@ -785,7 +785,7 @@ QPDFWriter::setStaticAesIV(bool val) @@ -785,7 +785,7 @@ QPDFWriter::setStaticAesIV(bool val)
785 void 785 void
786 QPDFWriter::setSuppressOriginalObjectIDs(bool val) 786 QPDFWriter::setSuppressOriginalObjectIDs(bool val)
787 { 787 {
788 - m->cfg.suppress_original_object_ids(val); 788 + m->cfg.no_original_object_ids(val);
789 } 789 }
790 790
791 void 791 void
@@ -814,7 +814,7 @@ Config::linearize(bool val) @@ -814,7 +814,7 @@ Config::linearize(bool val)
814 void 814 void
815 QPDFWriter::setLinearizationPass1Filename(std::string const& filename) 815 QPDFWriter::setLinearizationPass1Filename(std::string const& filename)
816 { 816 {
817 - m->cfg.lin_pass1_filename(filename); 817 + m->cfg.linearize_pass1(filename);
818 } 818 }
819 819
820 void 820 void
@@ -826,7 +826,7 @@ QPDFWriter::setPCLm(bool val) @@ -826,7 +826,7 @@ QPDFWriter::setPCLm(bool val)
826 Config& 826 Config&
827 Config::pclm(bool val) 827 Config::pclm(bool val)
828 { 828 {
829 - if (stream_decode_level_set_ || compress_streams_set_ || linearize_) { 829 + if (decode_level_set_ || compress_streams_set_ || linearize_) {
830 usage( 830 usage(
831 "pclm cannot be set when stream_decode_level, compress_streams, linearize or qdf are " 831 "pclm cannot be set when stream_decode_level, compress_streams, linearize or qdf are "
832 "set"); 832 "set");
@@ -834,7 +834,7 @@ Config::pclm(bool val) @@ -834,7 +834,7 @@ Config::pclm(bool val)
834 } 834 }
835 pclm_ = val; 835 pclm_ = val;
836 if (val) { 836 if (val) {
837 - stream_decode_level_ = qpdf_dl_none; 837 + decode_level_ = qpdf_dl_none;
838 compress_streams_ = false; 838 compress_streams_ = false;
839 linearize_ = false; 839 linearize_ = false;
840 } 840 }
@@ -1549,7 +1549,7 @@ impl::Writer::will_filter_stream(QPDFObjectHandle stream, std::string* stream_da @@ -1549,7 +1549,7 @@ impl::Writer::will_filter_stream(QPDFObjectHandle stream, std::string* stream_da
1549 { 1549 {
1550 const bool is_root_metadata = stream.isRootMetadata(); 1550 const bool is_root_metadata = stream.isRootMetadata();
1551 bool filter = false; 1551 bool filter = false;
1552 - auto decode_level = cfg.stream_decode_level(); 1552 + auto decode_level = cfg.decode_level();
1553 int encode_flags = 0; 1553 int encode_flags = 0;
1554 Dictionary stream_dict = stream.getDict(); 1554 Dictionary stream_dict = stream.getDict();
1555 1555
@@ -1912,7 +1912,7 @@ impl::Writer::writeObjectStream(QPDFObjectHandle object) @@ -1912,7 +1912,7 @@ impl::Writer::writeObjectStream(QPDFObjectHandle object)
1912 } 1912 }
1913 if (cfg.qdf()) { 1913 if (cfg.qdf()) {
1914 write("%% Object stream: object ").write(new_o).write(", index ").write(count); 1914 write("%% Object stream: object ").write(new_o).write(", index ").write(count);
1915 - if (!cfg.suppress_original_object_ids()) { 1915 + if (!cfg.no_original_object_ids()) {
1916 write("; original object ID: ").write(og.getObj()); 1916 write("; original object ID: ").write(og.getObj());
1917 // For compatibility, only write the generation if non-zero. While object 1917 // For compatibility, only write the generation if non-zero. While object
1918 // streams only allow objects with generation 0, if we are generating object 1918 // streams only allow objects with generation 0, if we are generating object
@@ -2017,7 +2017,7 @@ impl::Writer::writeObject(QPDFObjectHandle object, int object_stream_index) @@ -2017,7 +2017,7 @@ impl::Writer::writeObject(QPDFObjectHandle object, int object_stream_index)
2017 } 2017 }
2018 } 2018 }
2019 if (object_stream_index == -1) { 2019 if (object_stream_index == -1) {
2020 - if (cfg.qdf() && !cfg.suppress_original_object_ids()) { 2020 + if (cfg.qdf() && !cfg.no_original_object_ids()) {
2021 write("%% Original object ID: ").write(object.getObjGen().unparse(' ')).write("\n"); 2021 write("%% Original object ID: ").write(object.getObjGen().unparse(' ')).write("\n");
2022 } 2022 }
2023 openObject(new_id); 2023 openObject(new_id);
@@ -2880,8 +2880,8 @@ impl::Writer::writeLinearized() @@ -2880,8 +2880,8 @@ impl::Writer::writeLinearized()
2880 auto pp_md5 = pipeline_stack.popper(); 2880 auto pp_md5 = pipeline_stack.popper();
2881 for (int pass: {1, 2}) { 2881 for (int pass: {1, 2}) {
2882 if (pass == 1) { 2882 if (pass == 1) {
2883 - if (!cfg.lin_pass1_filename().empty()) {  
2884 - lin_pass1_file = QUtil::safe_fopen(cfg.lin_pass1_filename().data(), "wb"); 2883 + if (!cfg.linearize_pass1().empty()) {
  2884 + lin_pass1_file = QUtil::safe_fopen(cfg.linearize_pass1().data(), "wb");
2885 pipeline_stack.activate( 2885 pipeline_stack.activate(
2886 pp_pass1, 2886 pp_pass1,
2887 std::make_unique<Pl_StdioFile>("linearization pass1", lin_pass1_file)); 2887 std::make_unique<Pl_StdioFile>("linearization pass1", lin_pass1_file));
libqpdf/qpdf/QPDFJob_private.hh
@@ -177,7 +177,6 @@ class QPDFJob::Members @@ -177,7 +177,6 @@ class QPDFJob::Members
177 unsigned long encryption_status{0}; 177 unsigned long encryption_status{0};
178 bool verbose{false}; 178 bool verbose{false};
179 std::string password; 179 std::string password;
180 - bool linearize{false};  
181 bool decrypt{false}; 180 bool decrypt{false};
182 bool remove_restrictions{false}; 181 bool remove_restrictions{false};
183 int split_pages{0}; 182 int split_pages{0};
@@ -208,25 +207,9 @@ class QPDFJob::Members @@ -208,25 +207,9 @@ class QPDFJob::Members
208 bool force_R5{false}; 207 bool force_R5{false};
209 bool cleartext_metadata{false}; 208 bool cleartext_metadata{false};
210 bool use_aes{false}; 209 bool use_aes{false};
211 - bool stream_data_set{false};  
212 - qpdf_stream_data_e stream_data_mode{qpdf_s_compress};  
213 - bool compress_streams{true};  
214 - bool compress_streams_set{false};  
215 - bool recompress_flate{false};  
216 - bool recompress_flate_set{false};  
217 int compression_level{-1}; 210 int compression_level{-1};
218 int jpeg_quality{-1}; 211 int jpeg_quality{-1};
219 - qpdf_stream_decode_level_e decode_level{qpdf_dl_generalized};  
220 - bool decode_level_set{false};  
221 - bool normalize_set{false};  
222 - bool normalize{false};  
223 - bool object_stream_set{false};  
224 - qpdf_object_stream_e object_stream_mode{qpdf_o_preserve};  
225 - bool qdf_mode{false};  
226 - bool preserve_unreferenced_objects{false};  
227 remove_unref_e remove_unreferenced_page_resources{re_auto}; 212 remove_unref_e remove_unreferenced_page_resources{re_auto};
228 - bool newline_before_endstream{false};  
229 - std::string linearize_pass1;  
230 bool coalesce_contents{false}; 213 bool coalesce_contents{false};
231 bool flatten_annotations{false}; 214 bool flatten_annotations{false};
232 int flatten_annotations_required{0}; 215 int flatten_annotations_required{0};
@@ -236,10 +219,7 @@ class QPDFJob::Members @@ -236,10 +219,7 @@ class QPDFJob::Members
236 std::string min_version; 219 std::string min_version;
237 std::string force_version; 220 std::string force_version;
238 bool show_npages{false}; 221 bool show_npages{false};
239 - bool deterministic_id{false};  
240 - bool static_id{false};  
241 bool static_aes_iv{false}; 222 bool static_aes_iv{false};
242 - bool suppress_original_object_id{false};  
243 bool show_encryption{false}; 223 bool show_encryption{false};
244 bool show_encryption_key{false}; 224 bool show_encryption_key{false};
245 bool check_linearization{false}; 225 bool check_linearization{false};
libqpdf/qpdf/QPDFWriter_private.hh
@@ -45,15 +45,15 @@ namespace qpdf @@ -45,15 +45,15 @@ namespace qpdf
45 Config& linearize(bool val); 45 Config& linearize(bool val);
46 46
47 std::string const& 47 std::string const&
48 - lin_pass1_filename() const 48 + linearize_pass1() const
49 { 49 {
50 - return lin_pass1_filename_; 50 + return linearize_pass1_;
51 } 51 }
52 52
53 Config& 53 Config&
54 - lin_pass1_filename(std::string const& val) 54 + linearize_pass1(std::string const& val)
55 { 55 {
56 - lin_pass1_filename_ = val; 56 + linearize_pass1_ = val;
57 return *this; 57 return *this;
58 } 58 }
59 59
@@ -83,13 +83,22 @@ namespace qpdf @@ -83,13 +83,22 @@ namespace qpdf
83 return *this; 83 return *this;
84 } 84 }
85 85
  86 + Config&
  87 + default_decode_level(qpdf_stream_decode_level_e val)
  88 + {
  89 + if (!decode_level_set_) {
  90 + decode_level_ = val;
  91 + }
  92 + return *this;
  93 + }
  94 +
86 qpdf_stream_decode_level_e 95 qpdf_stream_decode_level_e
87 - stream_decode_level() const 96 + decode_level() const
88 { 97 {
89 - return stream_decode_level_; 98 + return decode_level_;
90 } 99 }
91 100
92 - Config& stream_decode_level(qpdf_stream_decode_level_e val); 101 + Config& decode_level(qpdf_stream_decode_level_e val);
93 102
94 qpdf_object_stream_e 103 qpdf_object_stream_e
95 object_streams() const 104 object_streams() const
@@ -202,15 +211,15 @@ namespace qpdf @@ -202,15 +211,15 @@ namespace qpdf
202 } 211 }
203 212
204 bool 213 bool
205 - suppress_original_object_ids() const 214 + no_original_object_ids() const
206 { 215 {
207 - return suppress_original_object_ids_; 216 + return no_original_object_ids_;
208 } 217 }
209 218
210 Config& 219 Config&
211 - suppress_original_object_ids(bool val) 220 + no_original_object_ids(bool val)
212 { 221 {
213 - suppress_original_object_ids_ = val; 222 + no_original_object_ids_ = val;
214 return *this; 223 return *this;
215 } 224 }
216 225
@@ -282,10 +291,10 @@ namespace qpdf @@ -282,10 +291,10 @@ namespace qpdf
282 std::string forced_pdf_version_; 291 std::string forced_pdf_version_;
283 std::string extra_header_text_; 292 std::string extra_header_text_;
284 // For linearization only 293 // For linearization only
285 - std::string lin_pass1_filename_; 294 + std::string linearize_pass1_;
286 295
287 qpdf_object_stream_e object_streams_{qpdf_o_preserve}; 296 qpdf_object_stream_e object_streams_{qpdf_o_preserve};
288 - qpdf_stream_decode_level_e stream_decode_level_{qpdf_dl_generalized}; 297 + qpdf_stream_decode_level_e decode_level_{qpdf_dl_generalized};
289 298
290 int forced_extension_level_{0}; 299 int forced_extension_level_{0};
291 300
@@ -293,14 +302,14 @@ namespace qpdf @@ -293,14 +302,14 @@ namespace qpdf
293 bool normalize_content_{false}; 302 bool normalize_content_{false};
294 bool compress_streams_{true}; 303 bool compress_streams_{true};
295 bool compress_streams_set_{false}; 304 bool compress_streams_set_{false};
296 - bool stream_decode_level_set_{false}; 305 + bool decode_level_set_{false};
297 bool recompress_flate_{false}; 306 bool recompress_flate_{false};
298 bool qdf_{false}; 307 bool qdf_{false};
299 bool preserve_unreferenced_{false}; 308 bool preserve_unreferenced_{false};
300 bool newline_before_endstream_{false}; 309 bool newline_before_endstream_{false};
301 bool deterministic_id_{false}; 310 bool deterministic_id_{false};
302 bool static_id_{false}; 311 bool static_id_{false};
303 - bool suppress_original_object_ids_{false}; 312 + bool no_original_object_ids_{false};
304 bool direct_stream_lengths_{true}; 313 bool direct_stream_lengths_{true};
305 bool preserve_encryption_{true}; 314 bool preserve_encryption_{true};
306 bool linearize_{false}; 315 bool linearize_{false};