Commit b5d41b16b874e322befbd3fa2dde07714f7090a3
1 parent
1cc532dc
QPDFJob: convert under/overlay and rotate
Showing
11 changed files
with
145 additions
and
121 deletions
generate_auto_job
| @@ -32,30 +32,6 @@ def write_file(filename): | @@ -32,30 +32,6 @@ def write_file(filename): | ||
| 32 | os.rename(tmpfile, filename) | 32 | os.rename(tmpfile, filename) |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | -# QXXXQ | ||
| 36 | -# These are trivial but not in main and so need a different config | ||
| 37 | -# object. Some are in more than one table. | ||
| 38 | -not_yet = set([ | ||
| 39 | - 'accessibility', | ||
| 40 | - 'allow-insecure', | ||
| 41 | - 'annotate', | ||
| 42 | - 'assemble', | ||
| 43 | - 'cleartext-metadata', | ||
| 44 | - 'extract', | ||
| 45 | - 'force-R5', | ||
| 46 | - 'force-V4', | ||
| 47 | - 'form', | ||
| 48 | - 'from', | ||
| 49 | - 'modify', | ||
| 50 | - 'modify-other', | ||
| 51 | - 'print', | ||
| 52 | - 'repeat', | ||
| 53 | - 'rotate', | ||
| 54 | - 'to', | ||
| 55 | - 'use-aes', | ||
| 56 | -]) | ||
| 57 | - | ||
| 58 | - | ||
| 59 | class Main: | 35 | class Main: |
| 60 | SOURCES = [ | 36 | SOURCES = [ |
| 61 | whoami, | 37 | whoami, |
| @@ -447,8 +423,7 @@ class Main: | @@ -447,8 +423,7 @@ class Main: | ||
| 447 | for i, [kind, v] in flags.items(): | 423 | for i, [kind, v] in flags.items(): |
| 448 | self.options_without_help.add(f'--{i}') | 424 | self.options_without_help.add(f'--{i}') |
| 449 | add_jdata(i, table_prefix or table) | 425 | add_jdata(i, table_prefix or table) |
| 450 | - # QXXXQ not_yet | ||
| 451 | - if i in not_yet or config is None or i in o.get('manual', []): | 426 | + if config is None or i in o.get('manual', []): |
| 452 | identifier = self.to_identifier(i, arg_prefix, False) | 427 | identifier = self.to_identifier(i, arg_prefix, False) |
| 453 | self.handle_flag(i, identifier, kind, v) | 428 | self.handle_flag(i, identifier, kind, v) |
| 454 | else: | 429 | else: |
include/qpdf/QPDFJob.hh
| @@ -201,6 +201,22 @@ class QPDFJob | @@ -201,6 +201,22 @@ class QPDFJob | ||
| 201 | Config& config; | 201 | Config& config; |
| 202 | }; | 202 | }; |
| 203 | 203 | ||
| 204 | + class UOConfig | ||
| 205 | + { | ||
| 206 | + friend class QPDFJob; | ||
| 207 | + friend class Config; | ||
| 208 | + public: | ||
| 209 | + QPDF_DLL UOConfig& path(char const* parameter); | ||
| 210 | + | ||
| 211 | +# include <qpdf/auto_job_c_uo.hh> | ||
| 212 | + | ||
| 213 | + private: | ||
| 214 | + UOConfig(Config&); | ||
| 215 | + UOConfig(PagesConfig const&) = delete; | ||
| 216 | + | ||
| 217 | + Config& config; | ||
| 218 | + }; | ||
| 219 | + | ||
| 204 | // Configuration is performed by calling methods XXX QXXXQ document | 220 | // Configuration is performed by calling methods XXX QXXXQ document |
| 205 | class Config | 221 | class Config |
| 206 | { | 222 | { |
| @@ -210,6 +226,8 @@ class QPDFJob | @@ -210,6 +226,8 @@ class QPDFJob | ||
| 210 | std::shared_ptr<CopyAttConfig> copyAttachmentsFrom(); | 226 | std::shared_ptr<CopyAttConfig> copyAttachmentsFrom(); |
| 211 | std::shared_ptr<AttConfig> addAttachment(); | 227 | std::shared_ptr<AttConfig> addAttachment(); |
| 212 | std::shared_ptr<PagesConfig> pages(); | 228 | std::shared_ptr<PagesConfig> pages(); |
| 229 | + std::shared_ptr<UOConfig> overlay(); | ||
| 230 | + std::shared_ptr<UOConfig> underlay(); | ||
| 213 | 231 | ||
| 214 | # include <qpdf/auto_job_c_main.hh> | 232 | # include <qpdf/auto_job_c_main.hh> |
| 215 | 233 | ||
| @@ -422,16 +440,12 @@ class QPDFJob | @@ -422,16 +440,12 @@ class QPDFJob | ||
| 422 | bool check_requires_password; | 440 | bool check_requires_password; |
| 423 | std::shared_ptr<char> infilename; | 441 | std::shared_ptr<char> infilename; |
| 424 | std::shared_ptr<char> outfilename; | 442 | std::shared_ptr<char> outfilename; |
| 425 | - | ||
| 426 | - // Helper functions | ||
| 427 | - void parseRotationParameter(std::string const&); | ||
| 428 | - std::vector<int> parseNumrange(char const* range, int max, | ||
| 429 | - bool throw_error = false); | ||
| 430 | - | ||
| 431 | - | ||
| 432 | // QXXXQ END-PUBLIC | 443 | // QXXXQ END-PUBLIC |
| 433 | 444 | ||
| 434 | private: | 445 | private: |
| 446 | + // Helper functions | ||
| 447 | + void parseRotationParameter(std::string const&); | ||
| 448 | + std::vector<int> parseNumrange(char const* range, int max); | ||
| 435 | 449 | ||
| 436 | // Basic file processing | 450 | // Basic file processing |
| 437 | std::shared_ptr<QPDF> processFile( | 451 | std::shared_ptr<QPDF> processFile( |
include/qpdf/auto_job_c_main.hh
| @@ -65,6 +65,7 @@ QPDF_DLL Config& oiMinWidth(char const* parameter); | @@ -65,6 +65,7 @@ QPDF_DLL Config& oiMinWidth(char const* parameter); | ||
| 65 | QPDF_DLL Config& password(char const* parameter); | 65 | QPDF_DLL Config& password(char const* parameter); |
| 66 | QPDF_DLL Config& passwordFile(char const* parameter); | 66 | QPDF_DLL Config& passwordFile(char const* parameter); |
| 67 | QPDF_DLL Config& removeAttachment(char const* parameter); | 67 | QPDF_DLL Config& removeAttachment(char const* parameter); |
| 68 | +QPDF_DLL Config& rotate(char const* parameter); | ||
| 68 | QPDF_DLL Config& showAttachment(char const* parameter); | 69 | QPDF_DLL Config& showAttachment(char const* parameter); |
| 69 | QPDF_DLL Config& showObject(char const* parameter); | 70 | QPDF_DLL Config& showObject(char const* parameter); |
| 70 | QPDF_DLL Config& compressStreams(char const* parameter); | 71 | QPDF_DLL Config& compressStreams(char const* parameter); |
include/qpdf/auto_job_c_uo.hh
0 โ 100644
| 1 | +// | ||
| 2 | +// This file is automatically generated by generate_auto_job. | ||
| 3 | +// Edits will be automatically overwritten if the build is | ||
| 4 | +// run in maintainer mode. | ||
| 5 | +// | ||
| 6 | +QPDF_DLL Config& end(); | ||
| 7 | +QPDF_DLL UOConfig& to(char const* parameter); | ||
| 8 | +QPDF_DLL UOConfig& from(char const* parameter); | ||
| 9 | +QPDF_DLL UOConfig& repeat(char const* parameter); | ||
| 10 | +QPDF_DLL UOConfig& password(char const* parameter); |
job.sums
| 1 | # Generated by generate_auto_job | 1 | # Generated by generate_auto_job |
| 2 | -generate_auto_job d41f3092545906dcd9a82f88ff41939bf695a36ecaebfe8559c66bd92b7416fb | 2 | +generate_auto_job 7a539a822d332e33e08495a82a3fb86ceed2da2bb92ca492dd7ed888d226ab6a |
| 3 | include/qpdf/auto_job_c_att.hh ecc3f8f711b486b491e811176362a90c022eb225ff12157df3a10ca021be87b1 | 3 | include/qpdf/auto_job_c_att.hh ecc3f8f711b486b491e811176362a90c022eb225ff12157df3a10ca021be87b1 |
| 4 | include/qpdf/auto_job_c_copy_att.hh caffae3d1faf2cd92a07ba77da638cce31da3e074a047918834195c0f3ed508a | 4 | include/qpdf/auto_job_c_copy_att.hh caffae3d1faf2cd92a07ba77da638cce31da3e074a047918834195c0f3ed508a |
| 5 | -include/qpdf/auto_job_c_main.hh 1e060e9dd2029d21b29fed03e3a1e62164050b43684bd7434cc9e9707f73150d | 5 | +include/qpdf/auto_job_c_main.hh 7f7c0a4d8e640a2d24908af348f7b658ca81d3d8aa5346cf4327f6c1d4021119 |
| 6 | include/qpdf/auto_job_c_pages.hh 79ee6e52a36fedfd0e6ca60bd926bc25a3e975ab6fa984a7e798a48791e8ba86 | 6 | include/qpdf/auto_job_c_pages.hh 79ee6e52a36fedfd0e6ca60bd926bc25a3e975ab6fa984a7e798a48791e8ba86 |
| 7 | -job.yml 4cd60df0caa74b68cc39352910a8381c3411248bc3edef69f9d16d75e807f451 | ||
| 8 | -libqpdf/qpdf/auto_job_decl.hh f9f2a605fb8b5fed9b74c4cd07c07c3cdee60e2628d082250810c8074d5acd83 | 7 | +include/qpdf/auto_job_c_uo.hh 80404376f19fe57d67421ad0c5fb1755811758c73870df96f081f032b196deff |
| 8 | +job.yml 1f508cb7108c55885fbe98537676573bbfddf7b476b2023fd10a975d47afc037 | ||
| 9 | +libqpdf/qpdf/auto_job_decl.hh dc9232ed6961d709abacbbf71eb7d19c5e6951894aec6f480afcd3b6ba463206 | ||
| 9 | libqpdf/qpdf/auto_job_help.hh 383eea80e2c185ef5295fc126246457a7ceeffea759fdb90bb2e6727532ea538 | 10 | libqpdf/qpdf/auto_job_help.hh 383eea80e2c185ef5295fc126246457a7ceeffea759fdb90bb2e6727532ea538 |
| 10 | -libqpdf/qpdf/auto_job_init.hh b776c87e61d56842f23cb46fb6d4e44f5740e64854844bcc454fd812f7b4f8d5 | 11 | +libqpdf/qpdf/auto_job_init.hh 25a93a4ded91e1faa2d6a9d2bb85d811b5b49ae54c9fbdccad65b94538365418 |
| 11 | libqpdf/qpdf/auto_job_schema.hh 6e6d72e99dacd02c22d9ac70f4dc78a935f879d2a16c89f07f2bdfa936cc2ae3 | 12 | libqpdf/qpdf/auto_job_schema.hh 6e6d72e99dacd02c22d9ac70f4dc78a935f879d2a16c89f07f2bdfa936cc2ae3 |
| 12 | manual/_ext/qpdf.py 855fe12de5af7a10bb24be6ecc4d5dff4c84ac58cf388a13be6bbb394346a67d | 13 | manual/_ext/qpdf.py 855fe12de5af7a10bb24be6ecc4d5dff4c84ac58cf388a13be6bbb394346a67d |
| 13 | manual/cli.rst 68122ff8179c10df3fe6d577adde4973c346f7866ba9a511bab5a6e6f292a6f1 | 14 | manual/cli.rst 68122ff8179c10df3fe6d577adde4973c346f7866ba9a511bab5a6e6f292a6f1 |
job.yml
| @@ -205,6 +205,7 @@ options: | @@ -205,6 +205,7 @@ options: | ||
| 205 | - force-R5 | 205 | - force-R5 |
| 206 | - allow-insecure | 206 | - allow-insecure |
| 207 | - table: underlay/overlay | 207 | - table: underlay/overlay |
| 208 | + config: c_uo | ||
| 208 | prefix: UO | 209 | prefix: UO |
| 209 | positional: true | 210 | positional: true |
| 210 | required_parameter: | 211 | required_parameter: |
libqpdf/QPDFJob.cc
| @@ -507,7 +507,7 @@ QPDFJob::parseRotationParameter(std::string const& parameter) | @@ -507,7 +507,7 @@ QPDFJob::parseRotationParameter(std::string const& parameter) | ||
| 507 | bool range_valid = false; | 507 | bool range_valid = false; |
| 508 | try | 508 | try |
| 509 | { | 509 | { |
| 510 | - parseNumrange(range.c_str(), 0, true); | 510 | + QUtil::parse_numrange(range.c_str(), 0); |
| 511 | range_valid = true; | 511 | range_valid = true; |
| 512 | } | 512 | } |
| 513 | catch (std::runtime_error const&) | 513 | catch (std::runtime_error const&) |
| @@ -532,7 +532,7 @@ QPDFJob::parseRotationParameter(std::string const& parameter) | @@ -532,7 +532,7 @@ QPDFJob::parseRotationParameter(std::string const& parameter) | ||
| 532 | } | 532 | } |
| 533 | 533 | ||
| 534 | std::vector<int> | 534 | std::vector<int> |
| 535 | -QPDFJob::parseNumrange(char const* range, int max, bool throw_error) | 535 | +QPDFJob::parseNumrange(char const* range, int max) |
| 536 | { | 536 | { |
| 537 | try | 537 | try |
| 538 | { | 538 | { |
| @@ -540,14 +540,7 @@ QPDFJob::parseNumrange(char const* range, int max, bool throw_error) | @@ -540,14 +540,7 @@ QPDFJob::parseNumrange(char const* range, int max, bool throw_error) | ||
| 540 | } | 540 | } |
| 541 | catch (std::runtime_error& e) | 541 | catch (std::runtime_error& e) |
| 542 | { | 542 | { |
| 543 | - if (throw_error) | ||
| 544 | - { | ||
| 545 | - throw(e); | ||
| 546 | - } | ||
| 547 | - else | ||
| 548 | - { | ||
| 549 | - throw ConfigError(e.what()); | ||
| 550 | - } | 543 | + throw ConfigError(e.what()); |
| 551 | } | 544 | } |
| 552 | return std::vector<int>(); | 545 | return std::vector<int>(); |
| 553 | } | 546 | } |
libqpdf/QPDFJob_argv.cc
| @@ -36,7 +36,6 @@ namespace | @@ -36,7 +36,6 @@ namespace | ||
| 36 | void usage(std::string const& message); | 36 | void usage(std::string const& message); |
| 37 | void initOptionTables(); | 37 | void initOptionTables(); |
| 38 | void doFinalChecks(); | 38 | void doFinalChecks(); |
| 39 | - void parseUnderOverlayOptions(QPDFJob::UnderOverlay*); | ||
| 40 | 39 | ||
| 41 | QPDFArgParser ap; | 40 | QPDFArgParser ap; |
| 42 | QPDFJob& o; | 41 | QPDFJob& o; |
| @@ -44,6 +43,7 @@ namespace | @@ -44,6 +43,7 @@ namespace | ||
| 44 | std::shared_ptr<QPDFJob::CopyAttConfig> c_copy_att; | 43 | std::shared_ptr<QPDFJob::CopyAttConfig> c_copy_att; |
| 45 | std::shared_ptr<QPDFJob::AttConfig> c_att; | 44 | std::shared_ptr<QPDFJob::AttConfig> c_att; |
| 46 | std::shared_ptr<QPDFJob::PagesConfig> c_pages; | 45 | std::shared_ptr<QPDFJob::PagesConfig> c_pages; |
| 46 | + std::shared_ptr<QPDFJob::UOConfig> c_uo; | ||
| 47 | std::vector<char*> accumulated_args; // points to member in ap | 47 | std::vector<char*> accumulated_args; // points to member in ap |
| 48 | char* pages_password; | 48 | char* pages_password; |
| 49 | }; | 49 | }; |
| @@ -321,7 +321,7 @@ ArgParser::argPagesPositional(char* arg) | @@ -321,7 +321,7 @@ ArgParser::argPagesPositional(char* arg) | ||
| 321 | { | 321 | { |
| 322 | try | 322 | try |
| 323 | { | 323 | { |
| 324 | - o.parseNumrange(range, 0, true); | 324 | + QUtil::parse_numrange(range, 0); |
| 325 | } | 325 | } |
| 326 | catch (std::runtime_error& e1) | 326 | catch (std::runtime_error& e1) |
| 327 | { | 327 | { |
| @@ -369,19 +369,15 @@ ArgParser::argEndPages() | @@ -369,19 +369,15 @@ ArgParser::argEndPages() | ||
| 369 | void | 369 | void |
| 370 | ArgParser::argUnderlay() | 370 | ArgParser::argUnderlay() |
| 371 | { | 371 | { |
| 372 | - parseUnderOverlayOptions(&o.underlay); | 372 | + this->c_uo = c_main->underlay(); |
| 373 | + this->ap.selectOptionTable(O_UNDERLAY_OVERLAY); | ||
| 373 | } | 374 | } |
| 374 | 375 | ||
| 375 | void | 376 | void |
| 376 | ArgParser::argOverlay() | 377 | ArgParser::argOverlay() |
| 377 | { | 378 | { |
| 378 | - parseUnderOverlayOptions(&o.overlay); | ||
| 379 | -} | ||
| 380 | - | ||
| 381 | -void | ||
| 382 | -ArgParser::argRotate(char* parameter) | ||
| 383 | -{ | ||
| 384 | - o.parseRotationParameter(parameter); | 379 | + this->c_uo = c_main->overlay(); |
| 380 | + this->ap.selectOptionTable(O_UNDERLAY_OVERLAY); | ||
| 385 | } | 381 | } |
| 386 | 382 | ||
| 387 | void | 383 | void |
| @@ -576,57 +572,14 @@ ArgParser::argEnd256BitEncryption() | @@ -576,57 +572,14 @@ ArgParser::argEnd256BitEncryption() | ||
| 576 | void | 572 | void |
| 577 | ArgParser::argUOPositional(char* arg) | 573 | ArgParser::argUOPositional(char* arg) |
| 578 | { | 574 | { |
| 579 | - if (! o.under_overlay->filename.empty()) | ||
| 580 | - { | ||
| 581 | - usage(o.under_overlay->which + " file already specified"); | ||
| 582 | - } | ||
| 583 | - else | ||
| 584 | - { | ||
| 585 | - o.under_overlay->filename = arg; | ||
| 586 | - } | ||
| 587 | -} | ||
| 588 | - | ||
| 589 | -void | ||
| 590 | -ArgParser::argUOTo(char* parameter) | ||
| 591 | -{ | ||
| 592 | - o.parseNumrange(parameter, 0); | ||
| 593 | - o.under_overlay->to_nr = parameter; | ||
| 594 | -} | ||
| 595 | - | ||
| 596 | -void | ||
| 597 | -ArgParser::argUOFrom(char* parameter) | ||
| 598 | -{ | ||
| 599 | - if (strlen(parameter)) | ||
| 600 | - { | ||
| 601 | - o.parseNumrange(parameter, 0); | ||
| 602 | - } | ||
| 603 | - o.under_overlay->from_nr = parameter; | ||
| 604 | -} | ||
| 605 | - | ||
| 606 | -void | ||
| 607 | -ArgParser::argUORepeat(char* parameter) | ||
| 608 | -{ | ||
| 609 | - if (strlen(parameter)) | ||
| 610 | - { | ||
| 611 | - o.parseNumrange(parameter, 0); | ||
| 612 | - } | ||
| 613 | - o.under_overlay->repeat_nr = parameter; | ||
| 614 | -} | ||
| 615 | - | ||
| 616 | -void | ||
| 617 | -ArgParser::argUOPassword(char* parameter) | ||
| 618 | -{ | ||
| 619 | - o.under_overlay->password = QUtil::make_shared_cstr(parameter); | 575 | + c_uo->path(arg); |
| 620 | } | 576 | } |
| 621 | 577 | ||
| 622 | void | 578 | void |
| 623 | ArgParser::argEndUnderlayOverlay() | 579 | ArgParser::argEndUnderlayOverlay() |
| 624 | { | 580 | { |
| 625 | - if (o.under_overlay->filename.empty()) | ||
| 626 | - { | ||
| 627 | - usage(o.under_overlay->which + " file not specified"); | ||
| 628 | - } | ||
| 629 | - o.under_overlay = 0; | 581 | + c_uo->end(); |
| 582 | + c_uo = nullptr; | ||
| 630 | } | 583 | } |
| 631 | 584 | ||
| 632 | void | 585 | void |
| @@ -668,13 +621,6 @@ ArgParser::usage(std::string const& message) | @@ -668,13 +621,6 @@ ArgParser::usage(std::string const& message) | ||
| 668 | } | 621 | } |
| 669 | 622 | ||
| 670 | void | 623 | void |
| 671 | -ArgParser::parseUnderOverlayOptions(QPDFJob::UnderOverlay* uo) | ||
| 672 | -{ | ||
| 673 | - o.under_overlay = uo; | ||
| 674 | - this->ap.selectOptionTable(O_UNDERLAY_OVERLAY); | ||
| 675 | -} | ||
| 676 | - | ||
| 677 | -void | ||
| 678 | ArgParser::parseOptions() | 624 | ArgParser::parseOptions() |
| 679 | { | 625 | { |
| 680 | try | 626 | try |
libqpdf/QPDFJob_config.cc
| @@ -688,6 +688,13 @@ QPDFJob::Config::jobJsonFile(char const* parameter) | @@ -688,6 +688,13 @@ QPDFJob::Config::jobJsonFile(char const* parameter) | ||
| 688 | return *this; | 688 | return *this; |
| 689 | } | 689 | } |
| 690 | 690 | ||
| 691 | +QPDFJob::Config& | ||
| 692 | +QPDFJob::Config::rotate(char const* parameter) | ||
| 693 | +{ | ||
| 694 | + o.parseRotationParameter(parameter); | ||
| 695 | + return *this; | ||
| 696 | +} | ||
| 697 | + | ||
| 691 | std::shared_ptr<QPDFJob::CopyAttConfig> | 698 | std::shared_ptr<QPDFJob::CopyAttConfig> |
| 692 | QPDFJob::Config::copyAttachmentsFrom() | 699 | QPDFJob::Config::copyAttachmentsFrom() |
| 693 | { | 700 | { |
| @@ -875,3 +882,84 @@ QPDFJob::PagesConfig::pageSpec(std::string const& filename, | @@ -875,3 +882,84 @@ QPDFJob::PagesConfig::pageSpec(std::string const& filename, | ||
| 875 | QPDFJob::PageSpec(filename, password, range)); | 882 | QPDFJob::PageSpec(filename, password, range)); |
| 876 | return *this; | 883 | return *this; |
| 877 | } | 884 | } |
| 885 | + | ||
| 886 | +std::shared_ptr<QPDFJob::UOConfig> | ||
| 887 | +QPDFJob::Config::overlay() | ||
| 888 | +{ | ||
| 889 | + o.under_overlay = &o.overlay; | ||
| 890 | + return std::shared_ptr<UOConfig>(new UOConfig(*this)); | ||
| 891 | +} | ||
| 892 | + | ||
| 893 | +std::shared_ptr<QPDFJob::UOConfig> | ||
| 894 | +QPDFJob::Config::underlay() | ||
| 895 | +{ | ||
| 896 | + o.under_overlay = &o.underlay; | ||
| 897 | + return std::shared_ptr<UOConfig>(new UOConfig(*this)); | ||
| 898 | +} | ||
| 899 | + | ||
| 900 | +QPDFJob::UOConfig::UOConfig(Config& c) : | ||
| 901 | + config(c) | ||
| 902 | +{ | ||
| 903 | +} | ||
| 904 | + | ||
| 905 | +QPDFJob::Config& | ||
| 906 | +QPDFJob::UOConfig::end() | ||
| 907 | +{ | ||
| 908 | + if (config.o.under_overlay->filename.empty()) | ||
| 909 | + { | ||
| 910 | + usage(config.o.under_overlay->which + " file not specified"); | ||
| 911 | + } | ||
| 912 | + config.o.under_overlay = 0; | ||
| 913 | + return this->config; | ||
| 914 | +} | ||
| 915 | + | ||
| 916 | +QPDFJob::UOConfig& | ||
| 917 | +QPDFJob::UOConfig::path(char const* parameter) | ||
| 918 | +{ | ||
| 919 | + if (! config.o.under_overlay->filename.empty()) | ||
| 920 | + { | ||
| 921 | + usage(config.o.under_overlay->which + " file already specified"); | ||
| 922 | + } | ||
| 923 | + else | ||
| 924 | + { | ||
| 925 | + config.o.under_overlay->filename = parameter; | ||
| 926 | + } | ||
| 927 | + return *this; | ||
| 928 | +} | ||
| 929 | + | ||
| 930 | +QPDFJob::UOConfig& | ||
| 931 | +QPDFJob::UOConfig::to(char const* parameter) | ||
| 932 | +{ | ||
| 933 | + config.o.parseNumrange(parameter, 0); | ||
| 934 | + config.o.under_overlay->to_nr = parameter; | ||
| 935 | + return *this; | ||
| 936 | +} | ||
| 937 | + | ||
| 938 | +QPDFJob::UOConfig& | ||
| 939 | +QPDFJob::UOConfig::from(char const* parameter) | ||
| 940 | +{ | ||
| 941 | + if (strlen(parameter)) | ||
| 942 | + { | ||
| 943 | + config.o.parseNumrange(parameter, 0); | ||
| 944 | + } | ||
| 945 | + config.o.under_overlay->from_nr = parameter; | ||
| 946 | + return *this; | ||
| 947 | +} | ||
| 948 | + | ||
| 949 | +QPDFJob::UOConfig& | ||
| 950 | +QPDFJob::UOConfig::repeat(char const* parameter) | ||
| 951 | +{ | ||
| 952 | + if (strlen(parameter)) | ||
| 953 | + { | ||
| 954 | + config.o.parseNumrange(parameter, 0); | ||
| 955 | + } | ||
| 956 | + config.o.under_overlay->repeat_nr = parameter; | ||
| 957 | + return *this; | ||
| 958 | +} | ||
| 959 | + | ||
| 960 | +QPDFJob::UOConfig& | ||
| 961 | +QPDFJob::UOConfig::password(char const* parameter) | ||
| 962 | +{ | ||
| 963 | + config.o.under_overlay->password = QUtil::make_shared_cstr(parameter); | ||
| 964 | + return *this; | ||
| 965 | +} |
libqpdf/qpdf/auto_job_decl.hh
| @@ -24,7 +24,6 @@ void argEncrypt(); | @@ -24,7 +24,6 @@ void argEncrypt(); | ||
| 24 | void argOverlay(); | 24 | void argOverlay(); |
| 25 | void argPages(); | 25 | void argPages(); |
| 26 | void argUnderlay(); | 26 | void argUnderlay(); |
| 27 | -void argRotate(char *); | ||
| 28 | void argPagesPositional(char*); | 27 | void argPagesPositional(char*); |
| 29 | void argPagesPassword(char *); | 28 | void argPagesPassword(char *); |
| 30 | void argEndPages(); | 29 | void argEndPages(); |
| @@ -51,10 +50,6 @@ void argEnc256ForceR5(); | @@ -51,10 +50,6 @@ void argEnc256ForceR5(); | ||
| 51 | void argEnc256AllowInsecure(); | 50 | void argEnc256AllowInsecure(); |
| 52 | void argEnd256BitEncryption(); | 51 | void argEnd256BitEncryption(); |
| 53 | void argUOPositional(char*); | 52 | void argUOPositional(char*); |
| 54 | -void argUOTo(char *); | ||
| 55 | -void argUOFrom(char *); | ||
| 56 | -void argUORepeat(char *); | ||
| 57 | -void argUOPassword(char *); | ||
| 58 | void argEndUnderlayOverlay(); | 53 | void argEndUnderlayOverlay(); |
| 59 | void argAttPositional(char*); | 54 | void argAttPositional(char*); |
| 60 | void argEndAttachment(); | 55 | void argEndAttachment(); |
libqpdf/qpdf/auto_job_init.hh
| @@ -97,7 +97,7 @@ this->ap.addRequiredParameter("oi-min-width", [this](char *x){c_main->oiMinWidth | @@ -97,7 +97,7 @@ this->ap.addRequiredParameter("oi-min-width", [this](char *x){c_main->oiMinWidth | ||
| 97 | this->ap.addRequiredParameter("password", [this](char *x){c_main->password(x);}, "password"); | 97 | this->ap.addRequiredParameter("password", [this](char *x){c_main->password(x);}, "password"); |
| 98 | this->ap.addRequiredParameter("password-file", [this](char *x){c_main->passwordFile(x);}, "password"); | 98 | this->ap.addRequiredParameter("password-file", [this](char *x){c_main->passwordFile(x);}, "password"); |
| 99 | this->ap.addRequiredParameter("remove-attachment", [this](char *x){c_main->removeAttachment(x);}, "attachment"); | 99 | this->ap.addRequiredParameter("remove-attachment", [this](char *x){c_main->removeAttachment(x);}, "attachment"); |
| 100 | -this->ap.addRequiredParameter("rotate", p(&ArgParser::argRotate), "[+|-]angle"); | 100 | +this->ap.addRequiredParameter("rotate", [this](char *x){c_main->rotate(x);}, "[+|-]angle"); |
| 101 | this->ap.addRequiredParameter("show-attachment", [this](char *x){c_main->showAttachment(x);}, "attachment"); | 101 | this->ap.addRequiredParameter("show-attachment", [this](char *x){c_main->showAttachment(x);}, "attachment"); |
| 102 | this->ap.addRequiredParameter("show-object", [this](char *x){c_main->showObject(x);}, "trailer"); | 102 | this->ap.addRequiredParameter("show-object", [this](char *x){c_main->showObject(x);}, "trailer"); |
| 103 | this->ap.addChoices("compress-streams", [this](char *x){c_main->compressStreams(x);}, true, yn_choices); | 103 | this->ap.addChoices("compress-streams", [this](char *x){c_main->compressStreams(x);}, true, yn_choices); |
| @@ -137,10 +137,10 @@ this->ap.addBare("force-R5", b(&ArgParser::argEnc256ForceR5)); | @@ -137,10 +137,10 @@ this->ap.addBare("force-R5", b(&ArgParser::argEnc256ForceR5)); | ||
| 137 | this->ap.addBare("allow-insecure", b(&ArgParser::argEnc256AllowInsecure)); | 137 | this->ap.addBare("allow-insecure", b(&ArgParser::argEnc256AllowInsecure)); |
| 138 | this->ap.registerOptionTable("underlay/overlay", b(&ArgParser::argEndUnderlayOverlay)); | 138 | this->ap.registerOptionTable("underlay/overlay", b(&ArgParser::argEndUnderlayOverlay)); |
| 139 | this->ap.addPositional(p(&ArgParser::argUOPositional)); | 139 | this->ap.addPositional(p(&ArgParser::argUOPositional)); |
| 140 | -this->ap.addRequiredParameter("to", p(&ArgParser::argUOTo), "page-range"); | ||
| 141 | -this->ap.addRequiredParameter("from", p(&ArgParser::argUOFrom), "page-range"); | ||
| 142 | -this->ap.addRequiredParameter("repeat", p(&ArgParser::argUORepeat), "page-range"); | ||
| 143 | -this->ap.addRequiredParameter("password", p(&ArgParser::argUOPassword), "password"); | 140 | +this->ap.addRequiredParameter("to", [this](char *x){c_uo->to(x);}, "page-range"); |
| 141 | +this->ap.addRequiredParameter("from", [this](char *x){c_uo->from(x);}, "page-range"); | ||
| 142 | +this->ap.addRequiredParameter("repeat", [this](char *x){c_uo->repeat(x);}, "page-range"); | ||
| 143 | +this->ap.addRequiredParameter("password", [this](char *x){c_uo->password(x);}, "password"); | ||
| 144 | this->ap.registerOptionTable("attachment", b(&ArgParser::argEndAttachment)); | 144 | this->ap.registerOptionTable("attachment", b(&ArgParser::argEndAttachment)); |
| 145 | this->ap.addPositional(p(&ArgParser::argAttPositional)); | 145 | this->ap.addPositional(p(&ArgParser::argAttPositional)); |
| 146 | this->ap.addBare("replace", [this](){c_att->replace();}); | 146 | this->ap.addBare("replace", [this](){c_att->replace();}); |