Commit c4e56fa5f40188ddf4f75d316e57143c10ed51fa

Authored by Jay Berkenbilt
1 parent 2a2ec1c0

QPDFJob: make createsOutput callable before run()

include/qpdf/QPDFJob.hh
@@ -85,6 +85,10 @@ class QPDFJob @@ -85,6 +85,10 @@ class QPDFJob
85 QPDF_DLL 85 QPDF_DLL
86 void setOutputStreams(std::ostream* out_stream, std::ostream* err_stream); 86 void setOutputStreams(std::ostream* out_stream, std::ostream* err_stream);
87 87
  88 + // Returns true if output is created by the specified job.
  89 + QPDF_DLL
  90 + bool createsOutput() const;
  91 +
88 // QXXXQ set options -- implemented in QPDFJob_options.cc 92 // QXXXQ set options -- implemented in QPDFJob_options.cc
89 93
90 // QXXXQ these will not be in the final interface 94 // QXXXQ these will not be in the final interface
@@ -108,9 +112,6 @@ class QPDFJob @@ -108,9 +112,6 @@ class QPDFJob
108 QPDF_DLL 112 QPDF_DLL
109 bool hasWarnings(); 113 bool hasWarnings();
110 114
111 - QPDF_DLL  
112 - bool createsOutput(); // QXXXQ need better name  
113 -  
114 // Return value is bitwise OR of values from qpdf_encryption_status_e 115 // Return value is bitwise OR of values from qpdf_encryption_status_e
115 QPDF_DLL 116 QPDF_DLL
116 unsigned long getEncryptionStatus(); 117 unsigned long getEncryptionStatus();
@@ -398,7 +399,6 @@ class QPDFJob @@ -398,7 +399,6 @@ class QPDFJob
398 399
399 std::string message_prefix; 400 std::string message_prefix;
400 bool warnings; 401 bool warnings;
401 - bool creates_output;  
402 std::ostream* cout; 402 std::ostream* cout;
403 std::ostream* cerr; 403 std::ostream* cerr;
404 unsigned long encryption_status; 404 unsigned long encryption_status;
libqpdf/QPDFJob.cc
@@ -322,7 +322,6 @@ ProgressReporter::reportProgress(int percentage) @@ -322,7 +322,6 @@ ProgressReporter::reportProgress(int percentage)
322 QPDFJob::Members::Members() : 322 QPDFJob::Members::Members() :
323 message_prefix("qpdf"), 323 message_prefix("qpdf"),
324 warnings(false), 324 warnings(false),
325 - creates_output(false),  
326 cout(&std::cout), 325 cout(&std::cout),
327 cerr(&std::cerr), 326 cerr(&std::cerr),
328 encryption_status(0) 327 encryption_status(0)
@@ -500,8 +499,7 @@ QPDFJob::run() @@ -500,8 +499,7 @@ QPDFJob::run()
500 handleUnderOverlay(pdf); 499 handleUnderOverlay(pdf);
501 handleTransformations(pdf); 500 handleTransformations(pdf);
502 501
503 - this->m->creates_output = ((o.outfilename != nullptr) || o.replace_input);  
504 - if (! this->m->creates_output) 502 + if (! createsOutput())
505 { 503 {
506 doInspection(pdf); 504 doInspection(pdf);
507 } 505 }
@@ -526,9 +524,10 @@ QPDFJob::hasWarnings() @@ -526,9 +524,10 @@ QPDFJob::hasWarnings()
526 } 524 }
527 525
528 bool 526 bool
529 -QPDFJob::createsOutput() 527 +QPDFJob::createsOutput() const
530 { 528 {
531 - return this->m->creates_output; 529 + QPDFJob const& o = *this; // QXXXQ
  530 + return ((o.outfilename != nullptr) || o.replace_input);
532 } 531 }
533 532
534 bool 533 bool