Commit eeffc69d872e16468f3627054dfdad586fafae29
1 parent
fa967655
QPDFJob_json: implement handlers for pages
Showing
1 changed file
with
34 additions
and
9 deletions
libqpdf/QPDFJob_json.cc
| ... | ... | @@ -426,13 +426,13 @@ Handlers::endInspect() |
| 426 | 426 | void |
| 427 | 427 | Handlers::beginOptionsAddAttachmentArray(JSON) |
| 428 | 428 | { |
| 429 | - // QXXXQ | |
| 429 | + // nothing needed | |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | void |
| 433 | 433 | Handlers::endOptionsAddAttachmentArray() |
| 434 | 434 | { |
| 435 | - // QXXXQ | |
| 435 | + // nothing needed | |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | void |
| ... | ... | @@ -459,13 +459,13 @@ Handlers::setupOptionsAddAttachmentPath(std::string const& key) |
| 459 | 459 | void |
| 460 | 460 | Handlers::beginOptionsCopyAttachmentsFromArray(JSON) |
| 461 | 461 | { |
| 462 | - // QXXXQ | |
| 462 | + // nothing needed | |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | void |
| 466 | 466 | Handlers::endOptionsCopyAttachmentsFromArray() |
| 467 | 467 | { |
| 468 | - // QXXXQ | |
| 468 | + // nothing needed | |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | void |
| ... | ... | @@ -500,25 +500,50 @@ Handlers::setupOptionsCopyAttachmentsFromPassword(std::string const& key) |
| 500 | 500 | void |
| 501 | 501 | Handlers::beginOptionsPagesArray(JSON) |
| 502 | 502 | { |
| 503 | - // QXXXQ | |
| 503 | + this->c_pages = c_main->pages(); | |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | void |
| 507 | 507 | Handlers::endOptionsPagesArray() |
| 508 | 508 | { |
| 509 | - // QXXXQ | |
| 509 | + c_pages->endPages(); | |
| 510 | + c_pages = nullptr; | |
| 510 | 511 | } |
| 511 | 512 | |
| 512 | 513 | void |
| 513 | -Handlers::beginOptionsPages(JSON) | |
| 514 | +Handlers::beginOptionsPages(JSON j) | |
| 514 | 515 | { |
| 515 | - // QXXXQ | |
| 516 | + std::string file; | |
| 517 | + std::string range("1-z"); | |
| 518 | + std::string password; | |
| 519 | + bool file_seen = false; | |
| 520 | + bool password_seen = false; | |
| 521 | + j.forEachDictItem([&](std::string const& key, JSON value){ | |
| 522 | + if (key == "file") | |
| 523 | + { | |
| 524 | + file_seen = value.getString(file); | |
| 525 | + } | |
| 526 | + else if (key == "range") | |
| 527 | + { | |
| 528 | + value.getString(range); | |
| 529 | + } | |
| 530 | + else if (key == "password") | |
| 531 | + { | |
| 532 | + password_seen = value.getString(password); | |
| 533 | + } | |
| 534 | + }); | |
| 535 | + if (! file_seen) | |
| 536 | + { | |
| 537 | + usage("file is required in page specification"); | |
| 538 | + } | |
| 539 | + this->c_pages->pageSpec( | |
| 540 | + file, range, password_seen ? password.c_str() : nullptr); | |
| 516 | 541 | } |
| 517 | 542 | |
| 518 | 543 | void |
| 519 | 544 | Handlers::endOptionsPages() |
| 520 | 545 | { |
| 521 | - // QXXXQ | |
| 546 | + // nothing needed | |
| 522 | 547 | } |
| 523 | 548 | |
| 524 | 549 | void | ... | ... |