diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index b12c052a..c5cc70b9 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -586,135 +586,142 @@ class QPDFJob ~Members() = default; private: + // These default values are duplicated in help and docs. + static int constexpr DEFAULT_KEEP_FILES_OPEN_THRESHOLD = 200; + static int constexpr DEFAULT_OI_MIN_WIDTH = 128; + static int constexpr DEFAULT_OI_MIN_HEIGHT = 128; + static int constexpr DEFAULT_OI_MIN_AREA = 16384; + static int constexpr DEFAULT_II_MIN_BYTES = 1024; + Members(); Members(Members const&) = delete; std::shared_ptr log; - std::string message_prefix; - bool warnings; - unsigned long encryption_status; - bool verbose; + std::string message_prefix{"qpdf"}; + bool warnings{false}; + unsigned long encryption_status{0}; + bool verbose{false}; std::shared_ptr password; - bool linearize; - bool decrypt; - int split_pages; - bool progress; - std::function progress_handler; - bool suppress_warnings; - bool warnings_exit_zero; - bool copy_encryption; + bool linearize{false}; + bool decrypt{false}; + int split_pages{0}; + bool progress{false}; + std::function progress_handler{nullptr}; + bool suppress_warnings{false}; + bool warnings_exit_zero{false}; + bool copy_encryption{false}; std::string encryption_file; std::shared_ptr encryption_file_password; - bool encrypt; - bool password_is_hex_key; - bool suppress_password_recovery; - password_mode_e password_mode; - bool allow_insecure; - bool allow_weak_crypto; + bool encrypt{false}; + bool password_is_hex_key{false}; + bool suppress_password_recovery{false}; + password_mode_e password_mode{pm_auto}; + bool allow_insecure{false}; + bool allow_weak_crypto{false}; std::string user_password; std::string owner_password; - int keylen; - bool r2_print; - bool r2_modify; - bool r2_extract; - bool r2_annotate; - bool r3_accessibility; - bool r3_extract; - bool r3_assemble; - bool r3_annotate_and_form; - bool r3_form_filling; - bool r3_modify_other; - qpdf_r3_print_e r3_print; - bool force_V4; - bool force_R5; - bool cleartext_metadata; - bool use_aes; - bool stream_data_set; - qpdf_stream_data_e stream_data_mode; - bool compress_streams; - bool compress_streams_set; - bool recompress_flate; - bool recompress_flate_set; - int compression_level; - qpdf_stream_decode_level_e decode_level; - bool decode_level_set; - bool normalize_set; - bool normalize; - bool suppress_recovery; - bool object_stream_set; - qpdf_object_stream_e object_stream_mode; - bool ignore_xref_streams; - bool qdf_mode; - bool preserve_unreferenced_objects; - remove_unref_e remove_unreferenced_page_resources; - bool keep_files_open; - bool keep_files_open_set; - size_t keep_files_open_threshold; - bool newline_before_endstream; + int keylen{0}; + bool r2_print{true}; + bool r2_modify{true}; + bool r2_extract{true}; + bool r2_annotate{true}; + bool r3_accessibility{true}; + bool r3_extract{true}; + bool r3_assemble{true}; + bool r3_annotate_and_form{true}; + bool r3_form_filling{true}; + bool r3_modify_other{true}; + qpdf_r3_print_e r3_print{qpdf_r3p_full}; + bool force_V4{false}; + bool force_R5{false}; + bool cleartext_metadata{false}; + bool use_aes{false}; + bool stream_data_set{false}; + qpdf_stream_data_e stream_data_mode{qpdf_s_compress}; + bool compress_streams{true}; + bool compress_streams_set{false}; + bool recompress_flate{false}; + bool recompress_flate_set{false}; + int compression_level{-1}; + qpdf_stream_decode_level_e decode_level{qpdf_dl_generalized}; + bool decode_level_set{false}; + bool normalize_set{false}; + bool normalize{false}; + bool suppress_recovery{false}; + bool object_stream_set{false}; + qpdf_object_stream_e object_stream_mode{qpdf_o_preserve}; + bool ignore_xref_streams{false}; + bool qdf_mode{false}; + bool preserve_unreferenced_objects{false}; + remove_unref_e remove_unreferenced_page_resources{re_auto}; + bool keep_files_open{true}; + bool keep_files_open_set{false}; + size_t keep_files_open_threshold{DEFAULT_KEEP_FILES_OPEN_THRESHOLD}; + bool newline_before_endstream{false}; std::string linearize_pass1; - bool coalesce_contents; - bool flatten_annotations; - int flatten_annotations_required; - int flatten_annotations_forbidden; - bool generate_appearances; + bool coalesce_contents{false}; + bool flatten_annotations{false}; + int flatten_annotations_required{0}; + int flatten_annotations_forbidden{an_invisible | an_hidden}; + bool generate_appearances{false}; PDFVersion max_input_version; std::string min_version; std::string force_version; - bool show_npages; - bool deterministic_id; - bool static_id; - bool static_aes_iv; - bool suppress_original_object_id; - bool show_encryption; - bool show_encryption_key; - bool check_linearization; - bool show_linearization; - bool show_xref; - bool show_trailer; - int show_obj; - int show_gen; - bool show_raw_stream_data; - bool show_filtered_stream_data; - bool show_pages; - bool show_page_images; - size_t collate; - bool flatten_rotation; - bool list_attachments; + bool show_npages{false}; + bool deterministic_id{false}; + bool static_id{false}; + bool static_aes_iv{false}; + bool suppress_original_object_id{false}; + bool show_encryption{false}; + bool show_encryption_key{false}; + bool check_linearization{false}; + bool show_linearization{false}; + bool show_xref{false}; + bool show_trailer{false}; + int show_obj{0}; + int show_gen{0}; + bool show_raw_stream_data{false}; + bool show_filtered_stream_data{false}; + bool show_pages{false}; + bool show_page_images{false}; + size_t collate{0}; + bool flatten_rotation{false}; + bool list_attachments{false}; std::string attachment_to_show; std::list attachments_to_remove; std::list attachments_to_add; std::list attachments_to_copy; - int json_version; + int json_version{0}; std::set json_keys; std::set json_objects; - qpdf_json_stream_data_e json_stream_data; - bool json_stream_data_set; + qpdf_json_stream_data_e json_stream_data{qpdf_sj_none}; + bool json_stream_data_set{false}; std::string json_stream_prefix; - bool test_json_schema; - bool check; - bool optimize_images; - bool externalize_inline_images; - bool keep_inline_images; - bool remove_page_labels; - size_t oi_min_width; - size_t oi_min_height; - size_t oi_min_area; - size_t ii_min_bytes; - UnderOverlay underlay; - UnderOverlay overlay; - UnderOverlay* under_overlay; + bool test_json_schema{false}; + bool check{false}; + bool optimize_images{false}; + bool externalize_inline_images{false}; + bool keep_inline_images{false}; + bool remove_page_labels{false}; + size_t oi_min_width{DEFAULT_OI_MIN_WIDTH}; + size_t oi_min_height{DEFAULT_OI_MIN_HEIGHT}; + size_t oi_min_area{DEFAULT_OI_MIN_AREA}; + size_t ii_min_bytes{DEFAULT_II_MIN_BYTES}; + UnderOverlay underlay{"underlay"}; + UnderOverlay overlay{"overlay"}; + UnderOverlay* under_overlay{nullptr}; std::vector page_specs; std::map rotations; - bool require_outfile; - bool replace_input; - bool check_is_encrypted; - bool check_requires_password; + bool require_outfile{true}; + bool replace_input{false}; + bool check_is_encrypted{false}; + bool check_requires_password{false}; std::shared_ptr infilename; std::shared_ptr outfilename; - bool json_input; - bool json_output; + bool json_input{false}; + bool json_output{false}; std::string update_from_json; - bool report_mem_usage; + bool report_mem_usage{false}; }; std::shared_ptr m; }; diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index 01e4a22a..c46e1951 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -304,121 +304,8 @@ ProgressReporter::reportProgress(int percentage) << "%\n"; } -// These default values are duplicated in help and docs. -static int constexpr DEFAULT_KEEP_FILES_OPEN_THRESHOLD = 200; -static int constexpr DEFAULT_OI_MIN_WIDTH = 128; -static int constexpr DEFAULT_OI_MIN_HEIGHT = 128; -static int constexpr DEFAULT_OI_MIN_AREA = 16384; -static int constexpr DEFAULT_II_MIN_BYTES = 1024; - QPDFJob::Members::Members() : - log(QPDFLogger::defaultLogger()), - message_prefix("qpdf"), - warnings(false), - encryption_status(0), - verbose(false), - password(nullptr), - linearize(false), - decrypt(false), - split_pages(0), - progress(false), - progress_handler(nullptr), - suppress_warnings(false), - warnings_exit_zero(false), - copy_encryption(false), - encryption_file_password(nullptr), - encrypt(false), - password_is_hex_key(false), - suppress_password_recovery(false), - password_mode(pm_auto), - allow_insecure(false), - allow_weak_crypto(false), - keylen(0), - r2_print(true), - r2_modify(true), - r2_extract(true), - r2_annotate(true), - r3_accessibility(true), - r3_extract(true), - r3_assemble(true), - r3_annotate_and_form(true), - r3_form_filling(true), - r3_modify_other(true), - r3_print(qpdf_r3p_full), - force_V4(false), - force_R5(false), - cleartext_metadata(false), - use_aes(false), - stream_data_set(false), - stream_data_mode(qpdf_s_compress), - compress_streams(true), - compress_streams_set(false), - recompress_flate(false), - recompress_flate_set(false), - compression_level(-1), - decode_level(qpdf_dl_generalized), - decode_level_set(false), - normalize_set(false), - normalize(false), - suppress_recovery(false), - object_stream_set(false), - object_stream_mode(qpdf_o_preserve), - ignore_xref_streams(false), - qdf_mode(false), - preserve_unreferenced_objects(false), - remove_unreferenced_page_resources(re_auto), - keep_files_open(true), - keep_files_open_set(false), - keep_files_open_threshold(DEFAULT_KEEP_FILES_OPEN_THRESHOLD), - newline_before_endstream(false), - coalesce_contents(false), - flatten_annotations(false), - flatten_annotations_required(0), - flatten_annotations_forbidden(an_invisible | an_hidden), - generate_appearances(false), - show_npages(false), - deterministic_id(false), - static_id(false), - static_aes_iv(false), - suppress_original_object_id(false), - show_encryption(false), - show_encryption_key(false), - check_linearization(false), - show_linearization(false), - show_xref(false), - show_trailer(false), - show_obj(0), - show_gen(0), - show_raw_stream_data(false), - show_filtered_stream_data(false), - show_pages(false), - show_page_images(false), - collate(0), - flatten_rotation(false), - list_attachments(false), - json_version(0), - json_stream_data(qpdf_sj_none), - json_stream_data_set(false), - test_json_schema(false), - check(false), - optimize_images(false), - externalize_inline_images(false), - keep_inline_images(false), - remove_page_labels(false), - oi_min_width(DEFAULT_OI_MIN_WIDTH), - oi_min_height(DEFAULT_OI_MIN_HEIGHT), - oi_min_area(DEFAULT_OI_MIN_AREA), - ii_min_bytes(DEFAULT_II_MIN_BYTES), - underlay("underlay"), - overlay("overlay"), - under_overlay(nullptr), - require_outfile(true), - replace_input(false), - check_is_encrypted(false), - check_requires_password(false), - json_input(false), - json_output(false), - report_mem_usage(false) + log(QPDFLogger::defaultLogger()) { }