You need to sign in before continuing.

Commit 6408d5cde7dc0756d05f9a7bafe28fcaaa06f056

Authored by m-holger
1 parent ce21a651

Refactor `Writer` in `QPDFWriter`: remove unused `w` member, add default value f…

…or `extension_level` in `setMinimumPDFVersion`, and update calls for improved encapsulation.
Showing 1 changed file with 7 additions and 9 deletions
libqpdf/QPDFWriter.cc
@@ -291,7 +291,6 @@ namespace qpdf::impl @@ -291,7 +291,6 @@ namespace qpdf::impl
291 Writer(QPDF& qpdf, QPDFWriter& w) : 291 Writer(QPDF& qpdf, QPDFWriter& w) :
292 Common(qpdf.doc()), 292 Common(qpdf.doc()),
293 lin(qpdf.doc().linearization()), 293 lin(qpdf.doc().linearization()),
294 - w(w),  
295 root_og( 294 root_og(
296 qpdf.getRoot().getObjGen().isIndirect() ? qpdf.getRoot().getObjGen() 295 qpdf.getRoot().getObjGen().isIndirect() ? qpdf.getRoot().getObjGen()
297 : QPDFObjGen(-1, 0)), 296 : QPDFObjGen(-1, 0)),
@@ -301,7 +300,7 @@ namespace qpdf::impl @@ -301,7 +300,7 @@ namespace qpdf::impl
301 300
302 void write(); 301 void write();
303 std::map<QPDFObjGen, QPDFXRefEntry> getWrittenXRefTable(); 302 std::map<QPDFObjGen, QPDFXRefEntry> getWrittenXRefTable();
304 - void setMinimumPDFVersion(std::string const& version, int extension_level); 303 + void setMinimumPDFVersion(std::string const& version, int extension_level = 0);
305 void copyEncryptionParameters(QPDF&); 304 void copyEncryptionParameters(QPDF&);
306 void doWriteSetup(); 305 void doWriteSetup();
307 void prepareFileForWrite(); 306 void prepareFileForWrite();
@@ -425,7 +424,6 @@ namespace qpdf::impl @@ -425,7 +424,6 @@ namespace qpdf::impl
425 424
426 qpdf::Writer::Config cfg; 425 qpdf::Writer::Config cfg;
427 426
428 - QPDFWriter& w;  
429 QPDFObjGen root_og{-1, 0}; 427 QPDFObjGen root_og{-1, 0};
430 char const* filename{"unspecified"}; 428 char const* filename{"unspecified"};
431 FILE* file{nullptr}; 429 FILE* file{nullptr};
@@ -1120,15 +1118,15 @@ impl::Writer::setEncryptionMinimumVersion() @@ -1120,15 +1118,15 @@ impl::Writer::setEncryptionMinimumVersion()
1120 { 1118 {
1121 auto const R = encryption->getR(); 1119 auto const R = encryption->getR();
1122 if (R >= 6) { 1120 if (R >= 6) {
1123 - w.setMinimumPDFVersion("1.7", 8); 1121 + setMinimumPDFVersion("1.7", 8);
1124 } else if (R == 5) { 1122 } else if (R == 5) {
1125 - w.setMinimumPDFVersion("1.7", 3); 1123 + setMinimumPDFVersion("1.7", 3);
1126 } else if (R == 4) { 1124 } else if (R == 4) {
1127 - w.setMinimumPDFVersion(cfg.encrypt_use_aes_ ? "1.6" : "1.5"); 1125 + setMinimumPDFVersion(cfg.encrypt_use_aes_ ? "1.6" : "1.5");
1128 } else if (R == 3) { 1126 } else if (R == 3) {
1129 - w.setMinimumPDFVersion("1.4"); 1127 + setMinimumPDFVersion("1.4");
1130 } else { 1128 } else {
1131 - w.setMinimumPDFVersion("1.3"); 1129 + setMinimumPDFVersion("1.3");
1132 } 1130 }
1133 } 1131 }
1134 1132
@@ -2340,7 +2338,7 @@ impl::Writer::doWriteSetup() @@ -2340,7 +2338,7 @@ impl::Writer::doWriteSetup()
2340 if (object_stream_to_objects.empty()) { 2338 if (object_stream_to_objects.empty()) {
2341 obj.streams_empty = true; 2339 obj.streams_empty = true;
2342 } else { 2340 } else {
2343 - w.setMinimumPDFVersion("1.5"); 2341 + setMinimumPDFVersion("1.5");
2344 } 2342 }
2345 } 2343 }
2346 2344