aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf/QPDFJob_argv.cc
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-01-25 22:37:17 +0100
committerJay Berkenbilt <ejb@ql.org>2022-01-30 19:11:03 +0100
commit0a354af02cf51aeb1602596988c8f826b47b3a81 (patch)
tree3d101f330f411080149082db2dba5291d9b7003f /libqpdf/QPDFJob_argv.cc
parenta87dcba13f4501adc448d82c58fa1dfa7274046d (diff)
downloadqpdf-0a354af02cf51aeb1602596988c8f826b47b3a81.tar.zst
QPDFJob: convert AddAttachment handlers
Diffstat (limited to 'libqpdf/QPDFJob_argv.cc')
-rw-r--r--libqpdf/QPDFJob_argv.cc91
1 files changed, 6 insertions, 85 deletions
diff --git a/libqpdf/QPDFJob_argv.cc b/libqpdf/QPDFJob_argv.cc
index af7ce13f..a32818ba 100644
--- a/libqpdf/QPDFJob_argv.cc
+++ b/libqpdf/QPDFJob_argv.cc
@@ -45,6 +45,7 @@ namespace
QPDFJob& o;
std::shared_ptr<QPDFJob::Config> c_main;
std::shared_ptr<QPDFJob::CopyAttConfig> c_copy_att;
+ std::shared_ptr<QPDFJob::AttConfig> c_att;
std::vector<char*> accumulated_args; // points to member in ap
char* pages_password;
};
@@ -441,7 +442,7 @@ ArgParser::argRotate(char* parameter)
void
ArgParser::argAddAttachment()
{
- o.attachments_to_add.push_back(QPDFJob::AddAttachment());
+ this->c_att = c_main->addAttachment();
this->ap.selectOptionTable(O_ATTACHMENT);
}
@@ -792,100 +793,20 @@ ArgParser::argEndUnderlayOverlay()
void
ArgParser::argAttPositional(char* arg)
{
- o.attachments_to_add.back().path = arg;
-}
-
-void
-ArgParser::argAttKey(char* parameter)
-{
- o.attachments_to_add.back().key = parameter;
-}
-
-void
-ArgParser::argAttFilename(char* parameter)
-{
- o.attachments_to_add.back().filename = parameter;
-}
-
-void
-ArgParser::argAttCreationdate(char* parameter)
-{
- if (! QUtil::pdf_time_to_qpdf_time(parameter))
- {
- usage(std::string(parameter) + " is not a valid PDF timestamp");
- }
- o.attachments_to_add.back().creationdate = parameter;
-}
-
-void
-ArgParser::argAttModdate(char* parameter)
-{
- if (! QUtil::pdf_time_to_qpdf_time(parameter))
- {
- usage(std::string(parameter) + " is not a valid PDF timestamp");
- }
- o.attachments_to_add.back().moddate = parameter;
-}
-
-void
-ArgParser::argAttMimetype(char* parameter)
-{
- if (strchr(parameter, '/') == nullptr)
- {
- usage("mime type should be specified as type/subtype");
- }
- o.attachments_to_add.back().mimetype = parameter;
-}
-
-void
-ArgParser::argAttDescription(char* parameter)
-{
- o.attachments_to_add.back().description = parameter;
-}
-
-void
-ArgParser::argAttReplace()
-{
- o.attachments_to_add.back().replace = true;
+ c_att->path(arg);
}
void
ArgParser::argEndAttachment()
{
- static std::string now = QUtil::qpdf_time_to_pdf_time(
- QUtil::get_current_qpdf_time());
- auto& cur = o.attachments_to_add.back();
- if (cur.path.empty())
- {
- usage("add attachment: no path specified");
- }
- std::string last_element = QUtil::path_basename(cur.path);
- if (last_element.empty())
- {
- usage("path for --add-attachment may not be empty");
- }
- if (cur.filename.empty())
- {
- cur.filename = last_element;
- }
- if (cur.key.empty())
- {
- cur.key = last_element;
- }
- if (cur.creationdate.empty())
- {
- cur.creationdate = now;
- }
- if (cur.moddate.empty())
- {
- cur.moddate = now;
- }
+ c_att->end();
+ c_att = nullptr;
}
void
ArgParser::argCopyAttPositional(char* arg)
{
- c_copy_att->filename(arg);
+ c_copy_att->path(arg);
}
void