aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-01-23 00:43:05 +0100
committerJay Berkenbilt <ejb@ql.org>2022-01-30 19:11:03 +0100
commite48bfce93069d4bb720649bef3e9328f1e783e1e (patch)
treeb0af3264f726bf3c6547415b7fdccf58eaafdf74 /libqpdf
parente4905983d2751b4b0f7ae535cdffee2be7fbf36f (diff)
downloadqpdf-e48bfce93069d4bb720649bef3e9328f1e783e1e.tar.zst
QPDFJob: convert PageSpec to used shared pointer
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFJob.cc20
1 files changed, 16 insertions, 4 deletions
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))
{