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 291 Writer(QPDF& qpdf, QPDFWriter& w) :
292 292 Common(qpdf.doc()),
293 293 lin(qpdf.doc().linearization()),
294   - w(w),
295 294 root_og(
296 295 qpdf.getRoot().getObjGen().isIndirect() ? qpdf.getRoot().getObjGen()
297 296 : QPDFObjGen(-1, 0)),
... ... @@ -301,7 +300,7 @@ namespace qpdf::impl
301 300  
302 301 void write();
303 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 304 void copyEncryptionParameters(QPDF&);
306 305 void doWriteSetup();
307 306 void prepareFileForWrite();
... ... @@ -425,7 +424,6 @@ namespace qpdf::impl
425 424  
426 425 qpdf::Writer::Config cfg;
427 426  
428   - QPDFWriter& w;
429 427 QPDFObjGen root_og{-1, 0};
430 428 char const* filename{"unspecified"};
431 429 FILE* file{nullptr};
... ... @@ -1120,15 +1118,15 @@ impl::Writer::setEncryptionMinimumVersion()
1120 1118 {
1121 1119 auto const R = encryption->getR();
1122 1120 if (R >= 6) {
1123   - w.setMinimumPDFVersion("1.7", 8);
  1121 + setMinimumPDFVersion("1.7", 8);
1124 1122 } else if (R == 5) {
1125   - w.setMinimumPDFVersion("1.7", 3);
  1123 + setMinimumPDFVersion("1.7", 3);
1126 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 1126 } else if (R == 3) {
1129   - w.setMinimumPDFVersion("1.4");
  1127 + setMinimumPDFVersion("1.4");
1130 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 2338 if (object_stream_to_objects.empty()) {
2341 2339 obj.streams_empty = true;
2342 2340 } else {
2343   - w.setMinimumPDFVersion("1.5");
  2341 + setMinimumPDFVersion("1.5");
2344 2342 }
2345 2343 }
2346 2344  
... ...