Commit Graph

154 Commits

Author SHA1 Message Date
Jay Berkenbilt 68e721981a Add new QPDF::warn that takes most of QPDFExc's arguments 2022-04-23 18:25:43 -04:00
Jay Berkenbilt ce5c3bcad8 QPDFJob: pass capture output streams through to underlying QPDF 2022-04-18 11:24:17 -04:00
Jay Berkenbilt cdd0b4fb7d Use = default and = delete where possible in classes 2022-04-16 11:39:14 -04:00
Jay Berkenbilt a68703b07e Replace PointerHolder with std::shared_ptr in library sources only
(patrepl and cleanpatch are my own utilities)

patrepl s/PointerHolder/std::shared_ptr/g {include,libqpdf}/qpdf/*.hh
patrepl s/PointerHolder/std::shared_ptr/g libqpdf/*.cc
patrepl s/make_pointer_holder/std::make_shared/g libqpdf/*.cc
patrepl s/make_array_pointer_holder/QUtil::make_shared_array/g libqpdf/*.cc
patrepl s,qpdf/std::shared_ptr,qpdf/PointerHolder, **/*.cc **/*.hh
git restore include/qpdf/PointerHolder.hh
cleanpatch
./format-code
2022-04-09 17:33:29 -04:00
Jay Berkenbilt 77e889495f Update some code manually to get better formatting results
Add comments to force line breaks, parenthesize function arguments
that are contatenated strings, etc. -- these kinds of changes improve
clang-format's results and also cause emacs cc-mode to match
clang-format. After this type of change, most of the time, when
clang-format and emacs disagree, clang-format is better.
2022-04-05 14:56:19 -04:00
Jay Berkenbilt 12f1eb15ca Programmatically apply new formatting to code
Run this:

for i in  **/*.cc **/*.c **/*.h **/*.hh; do
  clang-format < $i >| $i.new && mv $i.new $i
done
2022-04-04 08:10:40 -04:00
Jay Berkenbilt ae17402c52 Move default values to constexpr
This was mainly to get comments about defaults out of constructor
initializer lists where their fragile when a code formatter is being
used.
2022-02-26 08:16:12 -05:00
m-holger 4ff837f099 Fix tests for Form XObjects
Remove test for type == /XObject in QPDFObjectHandle::isFormXObject
as type value is optional (as per spec 8.10.2).

Replace code to test for /Form in QPDFJob::shouldRemoveUnreferencedResources
with a call to isFormXObject.
2022-02-10 19:47:37 -05:00
Jay Berkenbilt d501e1c0d4 Only update output version from files used as input
If we're opening a PDF file to copy its encryption information or
attachments, its version doesn't need to influence the output version.
2022-02-08 13:49:22 -05:00
Jay Berkenbilt f91b21c7d4 Preserve input PDF version on pages/split-pages (fixes #610) 2022-02-08 12:34:14 -05:00
Jay Berkenbilt c62e8e2b28 Update for clean compile with POINTERHOLDER_TRANSITION=2 2022-02-07 17:38:22 -05:00
Jay Berkenbilt 7fb22740e1 Add operator ""_qpdf for creating QPDFObjectHandle literals 2022-02-05 11:29:25 -05:00
Jay Berkenbilt 5f3f78822b Improve use of std::unique_ptr
* Use unique_ptr in place of shared_ptr in some cases
* unique_ptr for arrays does not require a custom deleter
* use std::make_unique (c++14) where possible
2022-02-05 11:24:56 -05:00
m-holger 1925ffd467 Fix --check-linearization of non-linearized files (fixes #615) 2022-02-04 06:52:38 -05:00
Jay Berkenbilt 03e67a28fe Move QTC::TC for qpdf to QPDFJob
All the coverage cases that used to be in qpdf.cc are now in
QPDFJob*.cc. It doesn't really matter, but better to follow the
convention of starting with the class that includes the coverage call.
2022-02-01 09:04:55 -05:00
Jay Berkenbilt b42f3e1d15 Move more code from qpdf.cc into QPDFJob 2022-02-01 09:04:55 -05:00
Jay Berkenbilt cc5485dac1 QPDFJob: documentation 2022-02-01 09:04:55 -05:00
Jay Berkenbilt e3506253f1 Add optional version to --json 2022-01-31 15:57:45 -05:00
Jay Berkenbilt f99e0af49c QPDFJob: rename function that returns job schema 2022-01-31 15:57:45 -05:00
Jay Berkenbilt 0364024781 Use QPDFUsage exception for cli, json, and QPDFJob errors 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 9013b7ca91 QPDFJob: move placeholder json to a separate source file 2022-01-30 13:11:03 -05:00
Jay Berkenbilt edef2cd330 QPDFJob: make remaining members private 2022-01-30 13:11:03 -05:00
Jay Berkenbilt f2409f4fca Minor cleanup 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 01969c78a8 QPDFJob: move private members into Members 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 1258054543 QPDFJob: eliminate most access to QPDFJob members from ArgParser
All that's left now is input and output handling.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt b5d41b16b8 QPDFJob: convert under/overlay and rotate 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 1cc532dc91 QPDFJob: move some helpers from ArgParser to QPDFJob 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 9373881cca Add QPDFJob::ConfigError exception 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 21c897aad0 QPDFJob: convert a flag in other than the main table 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 79187e585a QPDFJob: begin configuration API with verbose 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 558f043d91 QPDFJob: TRUE -> true 2022-01-30 13:11:03 -05:00
Jay Berkenbilt fcdbc8a102 Move doFinalChecks to QPDFJob::checkConfiguration 2022-01-30 13:11:03 -05:00
Jay Berkenbilt c4e56fa5f4 QPDFJob: make createsOutput callable before run() 2022-01-30 13:11:03 -05:00
Jay Berkenbilt d526d4c17f QPDFJob: convert Under/Overlay to use shared pointers 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 88891a75a2 QPDFJob: convert Under/Overlay ranges to strings 2022-01-30 13:11:03 -05:00
Jay Berkenbilt e48bfce930 QPDFJob: convert PageSpec to used shared pointer 2022-01-30 13:11:03 -05:00
Jay Berkenbilt e4905983d2 QPDFJob: convert outfilename to shared pointer 2022-01-30 13:11:03 -05:00
Jay Berkenbilt e5edfc786f QPDFJob: convert infilename to shared pointer 2022-01-30 13:11:03 -05:00
Jay Berkenbilt ee7824cf28 QPDFJob: convert encryption_file args to shared pointers 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 021db6f226 QPDFJob: convert password to shared pointer 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 1a8c2eb93b QPDFJob: use std::shared_ptr over PointerHolder where possible
Also fix QPDFArgParser
2022-01-30 13:11:03 -05:00
Jay Berkenbilt cf8405d91e Fix json schema for objects to include dictionary key 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 2e58541493 Use JSON::parse to initialize schema for json mode 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 5303130cf9 Fix comment on duplicated top-level json keys 2022-01-30 13:11:03 -05:00
Jay Berkenbilt a301cc5373 Minor code cleanup 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 3ab25d595b Fix doc typos caught by m-holger -- thanks 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 8dcf6da259 QPDFJob: remove non-check from doFinalChecks 2022-01-30 13:11:03 -05:00
Jay Berkenbilt bd89aac360 QPDFJob increment: move arg parsing into QPDFJob
Move ArgParser from qpdf.cc into QPDFJob.cc. It still works with
millions of public member variables, but now qpdf.cc is minimal and
just calls stable library functions.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt 12396702af QPDFJob: reorder functions, no other changes 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 2394dd8519 QPDFJob increment: static functions to member functions
Convert remaining static functions that take QPDFJob& as a parameter
to member functions. Utility functions that don't take QPDFJob& remain
static functions and can probably just stay that way since the keep
extra complexity out of QPDFJob.hh.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt e2975b9ed0 QPDFJob: de-templatize do_process and do_process_once 2022-01-30 13:11:03 -05:00
Jay Berkenbilt 2f631997f2 QPDFJob increment: remove std::cout, std::cerr, whoami
Remove remaining temporary duplication of hard-coded values and direct
access to std::cout, std::cerr, and whoami in favor of parameters in
QPDFJob. This moves a few more static methods into QPDFJob member
functions.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt 1ddf5b4b4b QPDFJob increment: get rid of exit, handle verbose
Remove all calls to exit() from QPDFJob. Handle code that runs in
verbose mode to enable it to make use of output streams and message
prefix (whoami) from QPDFJob. This removes temporarily duplicated exit
code logic and most access to whoami/std::cout outside of QPDFJob
proper.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt 0910e767ad QPDFJob increment: basic QPDFJob structure
Move most of the methods called from qpdf.cc after argument parsing
into QPDFJob. In this increment, enough QPDFJob API has been added to
handle the branch of QPDFJob::run() that creates output with an
appropriate division between qpdf.cc and QPDFJob.

There are temporary bits of code to enable everything to compile and
pass the test suite, including some duplication and hard-coded values.
2022-01-30 13:11:03 -05:00