2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-05-30 08:50:51 +00:00

QPDFJob: make createsOutput callable before run()

This commit is contained in:
Jay Berkenbilt 2022-01-23 13:04:08 -05:00
parent 2a2ec1c066
commit c4e56fa5f4
2 changed files with 8 additions and 9 deletions

View File

@ -85,6 +85,10 @@ class QPDFJob
QPDF_DLL QPDF_DLL
void setOutputStreams(std::ostream* out_stream, std::ostream* err_stream); void setOutputStreams(std::ostream* out_stream, std::ostream* err_stream);
// Returns true if output is created by the specified job.
QPDF_DLL
bool createsOutput() const;
// QXXXQ set options -- implemented in QPDFJob_options.cc // QXXXQ set options -- implemented in QPDFJob_options.cc
// QXXXQ these will not be in the final interface // QXXXQ these will not be in the final interface
@ -108,9 +112,6 @@ class QPDFJob
QPDF_DLL QPDF_DLL
bool hasWarnings(); bool hasWarnings();
QPDF_DLL
bool createsOutput(); // QXXXQ need better name
// Return value is bitwise OR of values from qpdf_encryption_status_e // Return value is bitwise OR of values from qpdf_encryption_status_e
QPDF_DLL QPDF_DLL
unsigned long getEncryptionStatus(); unsigned long getEncryptionStatus();
@ -398,7 +399,6 @@ class QPDFJob
std::string message_prefix; std::string message_prefix;
bool warnings; bool warnings;
bool creates_output;
std::ostream* cout; std::ostream* cout;
std::ostream* cerr; std::ostream* cerr;
unsigned long encryption_status; unsigned long encryption_status;

View File

@ -322,7 +322,6 @@ ProgressReporter::reportProgress(int percentage)
QPDFJob::Members::Members() : QPDFJob::Members::Members() :
message_prefix("qpdf"), message_prefix("qpdf"),
warnings(false), warnings(false),
creates_output(false),
cout(&std::cout), cout(&std::cout),
cerr(&std::cerr), cerr(&std::cerr),
encryption_status(0) encryption_status(0)
@ -500,8 +499,7 @@ QPDFJob::run()
handleUnderOverlay(pdf); handleUnderOverlay(pdf);
handleTransformations(pdf); handleTransformations(pdf);
this->m->creates_output = ((o.outfilename != nullptr) || o.replace_input); if (! createsOutput())
if (! this->m->creates_output)
{ {
doInspection(pdf); doInspection(pdf);
} }
@ -526,9 +524,10 @@ QPDFJob::hasWarnings()
} }
bool bool
QPDFJob::createsOutput() QPDFJob::createsOutput() const
{ {
return this->m->creates_output; QPDFJob const& o = *this; // QXXXQ
return ((o.outfilename != nullptr) || o.replace_input);
} }
bool bool