diff options
author | m-holger <m-holger@kubitscheck.org> | 2023-03-05 13:27:15 +0100 |
---|---|---|
committer | m-holger <m-holger@kubitscheck.org> | 2023-03-09 18:21:55 +0100 |
commit | 43d9ee56ea958428ce3a8e395a029035d81f914f (patch) | |
tree | 30947e3e5eb966efe9f1d84ab7ed4bf01e9cd655 /include | |
parent | 4359de903866b2753273ddfefc12f00d06c83668 (diff) | |
download | qpdf-43d9ee56ea958428ce3a8e395a029035d81f914f.tar.zst |
Split QPDFJob::run into createQPDF and writeQPDF
Also, change QPDFJob to use unique_ptr<QPDF> instead of shared pointers.
Diffstat (limited to 'include')
-rw-r--r-- | include/qpdf/QPDFJob.hh | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/include/qpdf/QPDFJob.hh b/include/qpdf/QPDFJob.hh index 9bf81fcc..2a82d61c 100644 --- a/include/qpdf/QPDFJob.hh +++ b/include/qpdf/QPDFJob.hh @@ -397,6 +397,21 @@ class QPDFJob QPDF_DLL void run(); + // The following two methods allow a job to be run in two stages - creation + // of a QPDF object and writing of the QPDF object. This allows the QPDF + // object to be modified prior to writing it out. See + // examples/qpdfjob-remove-annotations for an illustration of its use. + + // Run the first stage of the job. Return a nullptr if the configuration is + // not valid. + QPDF_DLL + std::unique_ptr<QPDF> createQPDF(); + + // Run the second stage of the job. Do nothing if a nullptr is passed as + // parameter. + QPDF_DLL + void writeQPDF(QPDF& qpdf); + // CHECK STATUS -- these methods provide information known after // run() is called. @@ -474,7 +489,7 @@ class QPDFJob std::string to_nr; std::string from_nr; std::string repeat_nr; - std::shared_ptr<QPDF> pdf; + std::unique_ptr<QPDF> pdf; std::vector<int> to_pagenos; std::vector<int> from_pagenos; std::vector<int> repeat_pagenos; @@ -490,25 +505,25 @@ class QPDFJob // Basic file processing void processFile( - std::shared_ptr<QPDF>&, + std::unique_ptr<QPDF>&, char const* filename, char const* password, bool used_for_input, bool main_input); void processInputSource( - std::shared_ptr<QPDF>&, + std::unique_ptr<QPDF>&, std::shared_ptr<InputSource> is, char const* password, bool used_for_input); void doProcess( - std::shared_ptr<QPDF>&, + std::unique_ptr<QPDF>&, std::function<void(QPDF*, char const*)> fn, char const* password, bool empty, bool used_for_input, bool main_input); void doProcessOnce( - std::shared_ptr<QPDF>&, + std::unique_ptr<QPDF>&, std::function<void(QPDF*, char const*)> fn, char const* password, bool empty, @@ -518,7 +533,7 @@ class QPDFJob // Transformations void setQPDFOptions(QPDF& pdf); void - handlePageSpecs(QPDF& pdf, std::vector<std::shared_ptr<QPDF>>& page_heap); + handlePageSpecs(QPDF& pdf, std::vector<std::unique_ptr<QPDF>>& page_heap); bool shouldRemoveUnreferencedResources(QPDF& pdf); void handleRotations(QPDF& pdf); void |