From e48bfce93069d4bb720649bef3e9328f1e783e1e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 22 Jan 2022 18:43:05 -0500 Subject: QPDFJob: convert PageSpec to used shared pointer --- libqpdf/QPDFJob.cc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index 129436d6..233fc5d7 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -64,7 +64,7 @@ namespace struct QPDFPageData { QPDFPageData(std::string const& filename, - QPDF* qpdf, char const* range); + QPDF* qpdf, std::string const& range); QPDFPageData(QPDFPageData const& other, int page); std::string filename; @@ -272,9 +272,21 @@ ImageOptimizer::provideStreamData(int, int, Pipeline* pipeline) false, false); } +QPDFJob::PageSpec::PageSpec(std::string const& filename, + char const* password, + std::string const& range) : + filename(filename), + range(range) +{ + if (password) + { + this->password = QUtil::make_shared_cstr(password); + } +} + QPDFPageData::QPDFPageData(std::string const& filename, QPDF* qpdf, - char const* range) : + std::string const& range) : filename(filename), qpdf(qpdf), orig_pages(qpdf->getAllPages()) @@ -282,7 +294,7 @@ QPDFPageData::QPDFPageData(std::string const& filename, try { this->selected_pages = - QUtil::parse_numrange(range, + QUtil::parse_numrange(range.c_str(), QIntC::to_int(this->orig_pages.size())); } catch (std::runtime_error& e) @@ -2599,7 +2611,7 @@ QPDFJob::handlePageSpecs( // the API, you can just create two different QPDF objects // to the same underlying file with the same path to // achieve the same affect. - char const* password = page_spec.password; + char const* password = page_spec.password.get(); if ((! o.encryption_file.empty()) && (password == 0) && (page_spec.filename == o.encryption_file)) { -- cgit v1.2.3-70-g09d2