/src/qpdf/libqpdf/qpdf/QPDFWriter_private.hh
Line | Count | Source |
1 | | #ifndef QPDFWRITER_PRIVATE_HH |
2 | | #define QPDFWRITER_PRIVATE_HH |
3 | | |
4 | | #include <qpdf/QPDFWriter.hh> |
5 | | |
6 | | #include <qpdf/ObjTable.hh> |
7 | | |
8 | | // This file is intended for inclusion by QPDFWriter, QPDF, QPDF_optimization and QPDF_linearization |
9 | | // only. |
10 | | |
11 | | struct QPDFWriter::Object |
12 | | { |
13 | | int renumber{0}; |
14 | | int gen{0}; |
15 | | int object_stream{0}; |
16 | | }; |
17 | | |
18 | | struct QPDFWriter::NewObject |
19 | | { |
20 | | QPDFXRefEntry xref; |
21 | | qpdf_offset_t length{0}; |
22 | | }; |
23 | | |
24 | | class QPDFWriter::ObjTable: public ::ObjTable<QPDFWriter::Object> |
25 | | { |
26 | | friend class QPDFWriter; |
27 | | |
28 | | public: |
29 | | bool |
30 | | getStreamsEmpty() const noexcept |
31 | 17.9k | { |
32 | 17.9k | return streams_empty; |
33 | 17.9k | } |
34 | | |
35 | | private: |
36 | | // For performance, set by QPDFWriter rather than tracked by ObjTable. |
37 | | bool streams_empty{false}; |
38 | | }; |
39 | | |
40 | | class QPDFWriter::NewObjTable: public ::ObjTable<QPDFWriter::NewObject> |
41 | | { |
42 | | friend class QPDFWriter; |
43 | | }; |
44 | | |
45 | | class QPDFWriter::Members |
46 | | { |
47 | | friend class QPDFWriter; |
48 | | |
49 | | public: |
50 | | QPDF_DLL |
51 | | ~Members(); |
52 | | |
53 | | private: |
54 | | Members(QPDF& pdf); |
55 | | Members(Members const&) = delete; |
56 | | |
57 | | QPDF& pdf; |
58 | | QPDFObjGen root_og{-1, 0}; |
59 | | char const* filename{"unspecified"}; |
60 | | FILE* file{nullptr}; |
61 | | bool close_file{false}; |
62 | | Pl_Buffer* buffer_pipeline{nullptr}; |
63 | | Buffer* output_buffer{nullptr}; |
64 | | bool normalize_content_set{false}; |
65 | | bool normalize_content{false}; |
66 | | bool compress_streams{true}; |
67 | | bool compress_streams_set{false}; |
68 | | qpdf_stream_decode_level_e stream_decode_level{qpdf_dl_none}; |
69 | | bool stream_decode_level_set{false}; |
70 | | bool recompress_flate{false}; |
71 | | bool qdf_mode{false}; |
72 | | bool preserve_unreferenced_objects{false}; |
73 | | bool newline_before_endstream{false}; |
74 | | bool static_id{false}; |
75 | | bool suppress_original_object_ids{false}; |
76 | | bool direct_stream_lengths{true}; |
77 | | bool encrypted{false}; |
78 | | bool preserve_encryption{true}; |
79 | | bool linearized{false}; |
80 | | bool pclm{false}; |
81 | | qpdf_object_stream_e object_stream_mode{qpdf_o_preserve}; |
82 | | std::string encryption_key; |
83 | | bool encrypt_metadata{true}; |
84 | | bool encrypt_use_aes{false}; |
85 | | std::map<std::string, std::string> encryption_dictionary; |
86 | | int encryption_V{0}; |
87 | | int encryption_R{0}; |
88 | | |
89 | | std::string id1; // for /ID key of |
90 | | std::string id2; // trailer dictionary |
91 | | std::string final_pdf_version; |
92 | | int final_extension_level{0}; |
93 | | std::string min_pdf_version; |
94 | | int min_extension_level{0}; |
95 | | std::string forced_pdf_version; |
96 | | int forced_extension_level{0}; |
97 | | std::string extra_header_text; |
98 | | int encryption_dict_objid{0}; |
99 | | std::string cur_data_key; |
100 | | std::list<std::shared_ptr<Pipeline>> to_delete; |
101 | | Pl_Count* pipeline{nullptr}; |
102 | | std::vector<QPDFObjectHandle> object_queue; |
103 | | size_t object_queue_front{0}; |
104 | | QPDFWriter::ObjTable obj; |
105 | | QPDFWriter::NewObjTable new_obj; |
106 | | int next_objid{1}; |
107 | | int cur_stream_length_id{0}; |
108 | | size_t cur_stream_length{0}; |
109 | | bool added_newline{false}; |
110 | | size_t max_ostream_index{0}; |
111 | | std::set<QPDFObjGen> normalized_streams; |
112 | | std::map<QPDFObjGen, int> page_object_to_seq; |
113 | | std::map<QPDFObjGen, int> contents_to_page_seq; |
114 | | std::map<int, std::vector<QPDFObjGen>> object_stream_to_objects; |
115 | | std::list<Pipeline*> pipeline_stack; |
116 | | unsigned long long next_stack_id{0}; |
117 | | bool deterministic_id{false}; |
118 | | Pl_MD5* md5_pipeline{nullptr}; |
119 | | std::string deterministic_id_data; |
120 | | bool did_write_setup{false}; |
121 | | |
122 | | // For linearization only |
123 | | std::string lin_pass1_filename; |
124 | | |
125 | | // For progress reporting |
126 | | std::shared_ptr<QPDFWriter::ProgressReporter> progress_reporter; |
127 | | int events_expected{0}; |
128 | | int events_seen{0}; |
129 | | int next_progress_report{0}; |
130 | | }; |
131 | | |
132 | | #endif // QPDFWRITER_PRIVATE_HH |