From d0b7cc8ac6773e3ddab1c34da910072fac441d07 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sun, 24 Apr 2022 12:47:24 -0400 Subject: QPDFJob json: make removeAttachment take an array (fixes #693) --- libqpdf/QPDFJob_json.cc | 11 +++++++++++ libqpdf/qpdf/auto_job_json_decl.hh | 2 ++ libqpdf/qpdf/auto_job_json_init.hh | 2 ++ libqpdf/qpdf/auto_job_schema.hh | 4 +++- 4 files changed, 18 insertions(+), 1 deletion(-) (limited to 'libqpdf') diff --git a/libqpdf/QPDFJob_json.cc b/libqpdf/QPDFJob_json.cc index c0247e0b..e529439a 100644 --- a/libqpdf/QPDFJob_json.cc +++ b/libqpdf/QPDFJob_json.cc @@ -412,6 +412,17 @@ Handlers::setupAddAttachmentFile() addParameter([this](char const* p) { c_att->file(p); }); } +void +Handlers::beginRemoveAttachmentArray(JSON) +{ + // nothing needed +} + +void +Handlers::endRemoveAttachmentArray() +{ + // nothing needed +} void Handlers::beginCopyAttachmentsFromArray(JSON) { diff --git a/libqpdf/qpdf/auto_job_json_decl.hh b/libqpdf/qpdf/auto_job_json_decl.hh index 7f996928..f02dc657 100644 --- a/libqpdf/qpdf/auto_job_json_decl.hh +++ b/libqpdf/qpdf/auto_job_json_decl.hh @@ -29,6 +29,8 @@ void endAddAttachmentArray(); void beginAddAttachment(JSON); void endAddAttachment(); void setupAddAttachmentFile(); +void beginRemoveAttachmentArray(JSON); +void endRemoveAttachmentArray(); void beginCopyAttachmentsFromArray(JSON); void endCopyAttachmentsFromArray(); void beginCopyAttachmentsFrom(JSON); diff --git a/libqpdf/qpdf/auto_job_json_init.hh b/libqpdf/qpdf/auto_job_json_init.hh index 2f807469..3c83ec2d 100644 --- a/libqpdf/qpdf/auto_job_json_init.hh +++ b/libqpdf/qpdf/auto_job_json_init.hh @@ -327,7 +327,9 @@ popHandler(); // key: replace popHandler(); // array: .addAttachment[] popHandler(); // key: addAttachment pushKey("removeAttachment"); +beginArray(bindJSON(&Handlers::beginRemoveAttachmentArray), bindBare(&Handlers::endRemoveAttachmentArray)); // .removeAttachment[] addParameter([this](std::string const& p) { c_main->removeAttachment(p); }); +popHandler(); // array: .removeAttachment[] popHandler(); // key: removeAttachment pushKey("copyAttachmentsFrom"); beginArray(bindJSON(&Handlers::beginCopyAttachmentsFromArray), bindBare(&Handlers::endCopyAttachmentsFromArray)); // .copyAttachmentsFrom[] diff --git a/libqpdf/qpdf/auto_job_schema.hh b/libqpdf/qpdf/auto_job_schema.hh index ca9fc1e1..557af9ee 100644 --- a/libqpdf/qpdf/auto_job_schema.hh +++ b/libqpdf/qpdf/auto_job_schema.hh @@ -111,7 +111,9 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({ "replace": "replace attachment with same key" } ], - "removeAttachment": "remove an embedded file", + "removeAttachment": [ + "remove an embedded file" + ], "copyAttachmentsFrom": [ { "file": "file to copy attachments from", -- cgit v1.2.3-70-g09d2