m-holger
44a7aff56f
Refactor Pl_Buffer
...
Base implementation of the buffer on std::basic_string<unsigned char>.
2022-09-23 15:09:13 -04:00
m-holger
ae800361fe
Tune QUtil::hex_encode
2022-09-23 06:20:12 -04:00
m-holger
033a66e9a5
Tune unparsing of hex strings in QPDF_String::unparse
2022-09-23 06:20:12 -04:00
m-holger
2e6869483b
Replace calls to QUtil::int_to_string with std::to_string
2022-09-21 15:57:14 -04:00
Jay Berkenbilt
5796475a5e
Cosmetic: use default constructor for QPDFObjGen
2022-09-14 07:35:32 -04:00
Jay Berkenbilt
2394acf7a6
Remove explicit direct object check from getObject
...
An indirect object reference to 0, 0 is invalid. If it appears in the
file or is parsed from a string, the parser catches it. This check
would only be useful for someone explicitly calling getObject with 0,
0, and that would trigger an error during resolve().
2022-09-13 11:21:29 -04:00
Jay Berkenbilt
a0b1a18172
Remove redundant function calls
2022-09-13 11:20:28 -04:00
Jay Berkenbilt
31b2cfbb79
Fix up a few comments
2022-09-13 11:18:49 -04:00
Jay Berkenbilt
4963ce6a53
Remove obsolete LL_FMT check from build ( fixes #768 )
...
This was broken for cross-compilation and has probably been
unnecessary for several years now.
Also fix extraneous whitespace in related some tests.
2022-09-12 11:48:38 -04:00
Jay Berkenbilt
8a3cdfd2af
Change QPDFObjectHandle == to isSameObjectAs
...
Replace operator== and operator!=, which were testing for the same
underlying object, with isSameObjectAs. This change was motivated by
the fact that pikepdf internally had its own operator== method for
QPDFObjectHandle that did structural comparison. I backed out qpdf's
operator== as a courtesy to pikepdf (in my own testing) but also
because I think people might naturally assume that operator== does a
structural comparison, and isSameObjectAs is clearer in its intent.
2022-09-09 18:09:40 -04:00
Jay Berkenbilt
3dbab589e3
Add C API functions for using custom loggers
...
Expose functions to the C API to create new loggers and to setLogger
and getLogger for QPDF and QPDFJob.
2022-09-09 10:49:25 -04:00
Jay Berkenbilt
0ad4e190ff
Make QPDFLogger() private and provide create method
2022-09-09 07:03:29 -04:00
Jay Berkenbilt
f1a2d3160a
Add JSON v2 support to C API
2022-09-09 06:19:09 -04:00
Jay Berkenbilt
66f1fd2ad9
Switch user-supplied functions in C API to return int
2022-09-08 17:36:51 -04:00
Jay Berkenbilt
b0f054e600
Add ability to initialize Pl_Function with a C-style function
2022-09-08 17:35:27 -04:00
Jay Berkenbilt
18a583e8d9
Rename QPDFValueProxy back to QPDFObject
...
QPDFValueProxy wasn't a good name for it. We decided the evil of
having the header file be named QPDFObject_private.hh was less than
the evil of having the class be named something other than what it
should have been named.
2022-09-08 11:29:23 -04:00
Jay Berkenbilt
25ccc7eae4
Rename QPDFValueProxy.hh and QPDFValueProxy.cc
...
Preparing to change the class name back to QPDFObject
2022-09-08 11:19:49 -04:00
Jay Berkenbilt
c7a4967d10
Change reset to disconnect and clarify comments
...
I decided that it's actually fine to copy a direct object to another
QPDF. Even if we eventually prevent a QPDFObject from having multiple
parents, this could happen if an object is moved.
2022-09-08 11:06:15 -04:00
Jay Berkenbilt
dba61da1bf
Create a special "destroyed" type rather than using null
...
When a QPDF is destroyed, changing indirect objects to direct nulls
makes them effectively disappear silently when they sneak into other
places. Instead, we should treat this as an error. Adding a destroyed
object type makes this possible.
2022-09-08 10:36:39 -04:00
Jay Berkenbilt
264e25f391
Clear owning QPDF information for all objects, not just indirect
2022-09-08 10:19:38 -04:00
Jay Berkenbilt
9dcd25a06e
Remove superfluous call to resetObjGen
2022-09-08 10:19:38 -04:00
Jay Berkenbilt
4422588d7d
Remove unneeded owning_qpdf from QPDFValue
...
The qpdf member was already sufficient. Removing this actually fixed a
few pre-existing issues around detecting foreign ownership and
allowing certain conditions to be warnings rather than exceptions.
2022-09-08 10:19:38 -04:00
Jay Berkenbilt
0132261ee0
Revert getOwningQPDF, and add getQPDF that returns a reference
2022-09-07 17:26:39 -04:00
Jay Berkenbilt
76cd7ea67a
Clarify and improve QPDFPageObjectHelper::get*Box methods
...
Add copy_if_fallback and explain how it differs from copy_if_shared.
2022-09-06 19:00:40 -04:00
Jay Berkenbilt
c1def4ead4
Implement QPDFObjectHandle equality
2022-09-06 18:34:23 -04:00
Jay Berkenbilt
94c79bb8f6
Support --show-encryption without a valid password ( fixes #598 )
2022-09-06 12:45:12 -04:00
Jay Berkenbilt
6c61be00e8
Rename QPDFObject -> QPDFValueProxy
...
This is in preparation for restoring a QPDFObject.hh to ease the
transition on qpdf_object_type_e.
This commit was created by
* Renaming QPDFObject.cc and QPDFObject.hh
* Replacing QPDFObject\b with QPDFValueProxy (where \b is word
boundary)
* Running format-code
* Manually resorting files in libqpdf/CMakeLists.txt
* Manually refilling the comment in QPDF.hh near class Resolver
2022-09-05 18:52:59 -04:00
James R. Barlow
12967bdf8a
Take advantage of unique_ptr and move construction for Buffer
...
Since Buffer has always implemented its copy constructor with a deep
copy, its Members object will never have multiple owners. Change to unique_ptr.
Also implement move constructors for Buffer, since there may be cases
where a deep copy is not needed.
2022-09-05 13:29:56 -07:00
m-holger
9c86ba40d8
Fix commit 805c1ad
: Reset QPDFValue::qpdf and QPDFValue::og when ...
...
On destruction of the QPDF object replace all indirect object references
with direct nulls.
Remove all existing code to release resolved references.
Fixes performance issue due to interaction of resetting QPDFValue::qpdf and
og members and prior code.
2022-09-04 10:41:18 +01:00
Jay Berkenbilt
31396f61c9
Disallow --empty with --replace-input ( fixes #728 )
2022-09-02 09:37:17 -04:00
Jay Berkenbilt
a59e7ac7ec
Disable copying/assigning to QPDF objects, add QPDF::create()
2022-09-02 08:53:27 -04:00
Jay Berkenbilt
2a1ae0b44c
Remove remaining virtual functions from QPDFObject
...
This doesn't need an explicit destructor anymore.
2022-09-01 18:19:48 -04:00
Jay Berkenbilt
6d62662e2d
Make QPDFObject::releaseResolved public
...
Now that QPDFObject.hh is out of the public API, we don't really need
QPDFObjAccessor. Also, the function didn't have to be virtual anymore.
2022-09-01 18:19:47 -04:00
Jay Berkenbilt
c510c01568
Remove copyright banner from newly private header files
...
We don't put specific copyright banners on files that aren't installed.
2022-09-01 18:19:47 -04:00
Jay Berkenbilt
1d57772b76
Remove QPDFObject and QPDFValue from public include directory
2022-09-01 18:19:47 -04:00
Jay Berkenbilt
f772c43de8
Stop including QPDFObject.hh from other than private files
...
This required moving some newly inlined functions back to the cc file,
but that seems to have had no measurable performance impact.
2022-09-01 18:19:47 -04:00
Jay Berkenbilt
b663926538
Remove QPDFObject::object_type_e as alias for qpdf_object_type_e
2022-09-01 18:11:22 -04:00
Jay Berkenbilt
ceeb25f3c8
Rename --report-mem-usage to --report-memory-usage
...
Avd xcsv brvtns.
2022-09-01 17:15:41 -04:00
Jay Berkenbilt
481b1aeb50
Add comments after merge of last pull request
2022-09-01 17:15:41 -04:00
Jay Berkenbilt
3d029fb17e
Merge pull request #730 from m-holger/allpages
...
Tidy QPDF::getAllPagesInternal and QPDF::pushInheritedAttributesToPageInternal
2022-09-01 15:28:32 -04:00
m-holger
805c1ad479
Reset QPDFValue::qpdf and QPDFValue::og when the owning QPDF object gets destroyed
2022-09-01 17:20:16 +01:00
m-holger
2b7e9ba2f5
Remove methods and parameters obsoleted by the last two commits
2022-09-01 17:20:02 +01:00
m-holger
1bb40238e0
Add method QPDFObject::getObjGen and remove QPDFObjectHandle::og
2022-09-01 17:19:40 +01:00
m-holger
5033e3b215
Add method QPDFObject::getQPDF and remove QPDFObjectHandle::qpdf
2022-09-01 17:19:31 +01:00
m-holger
4a8515912c
Add method QPDFObject::resolve
2022-09-01 17:19:06 +01:00
m-holger
56e9bcabe9
Add methods QPDFObject::setObjGen and QPDFObject::resetObjGen
...
Also, modify QPDFObject::swapWith to update the ObjGens of the swapped
objects.
Modify QPDF::newIndirect and QPDF::updateCache to keep object ObjGens
up to date.
2022-09-01 17:09:48 +01:00
m-holger
89061d5b33
Change QPDF_Unresolved::create method to take QPDF* and QPDFObjGen parameters
2022-09-01 17:09:07 +01:00
m-holger
ae6e484e23
Change return type of QPDF::resolve to void
2022-09-01 17:08:45 +01:00
m-holger
356b582cec
Remove QPDFObjectHandle::newIndirect
...
Modify QPDFParser::parse to call QPDF::getObject instead.
2022-09-01 16:59:01 +01:00
m-holger
c5d0428da2
Modify QPDF::getObject to not to resolve the object
2022-09-01 14:47:24 +01:00
m-holger
556c34f0f2
Add private method QPDF::ObjCache::update
...
Add a new obj_cache entry or update an existing entry in place.
2022-09-01 14:30:26 +01:00
m-holger
c0cd72a3ee
Add private methods QPDF::isCached and QPDF::isUnresolved
2022-09-01 14:29:53 +01:00
m-holger
23d50a2f14
Remove QPDFObjectHandle::initialized
2022-09-01 14:29:38 +01:00
m-holger
c7005e8a6d
Remove virtual methods QPDFValue::getTypeCode and getTypeName
2022-09-01 14:29:02 +01:00
m-holger
27fae2b55e
Remove QPDF::ObjectChanged
...
Also change QPDF::replaceObject and QPDF::swapObjects such that the
QPDFObject assigned to an og in the obj_cache is never replaced; only
QPDFObject::value is updated.
2022-09-01 14:27:46 +01:00
m-holger
431bd666c0
Split QPDFObject into QPDFObject and QPDFValue
2022-09-01 14:19:34 +01:00
m-holger
43983109f2
Change QPDFObjectHandle::shallowCopyInternal to copy scalars
2022-09-01 00:11:05 +01:00
m-holger
114bffa089
Add private methods QPDFObjectHandle::asArray etc
...
Centralise casting of QPDFObjects and reduce repeated dereferencing.
2022-09-01 00:10:04 +01:00
m-holger
2a2eebcaea
Modify newIndirect to set QPDFObjectHandle::obj
2022-08-31 22:47:11 +01:00
m-holger
16841bec32
Remove QPDFObjectHandle::makeReserved
2022-08-31 22:46:55 +01:00
m-holger
07b66eb0b6
Remove QPDFObjectHandle::reserved
2022-08-31 22:46:25 +01:00
m-holger
7248cab71b
Add class QPDF_Unresolved
...
Allow QPDFObjectHandle::obj to be set prior resolving object.
ot_unresolved has been appended to the list object types in order to
preserve the output of existing test cases.
2022-08-31 22:46:09 +01:00
m-holger
bd300be08d
Replace calls to QPDFObjectHandle::Factory::newIndirect where possible
2022-08-31 22:45:45 +01:00
Jay Berkenbilt
a078202c1b
Merge pull request #752 from jberkenbilt/report-mem-usage
...
Report mem usage
2022-08-31 15:50:17 -04:00
Jay Berkenbilt
7b3134ef94
Add ChangeLog for previous contribution
...
Also remove no-longer-needed #include
2022-08-31 15:06:37 -04:00
Jay Berkenbilt
433f1dae19
Add --report-mem-usage option for debugging/testing
2022-08-31 14:47:27 -04:00
Jay Berkenbilt
0a54247652
Add QUtil::get_max_memory_usage for testing
2022-08-31 14:47:27 -04:00
m-holger
9532dca3a5
Inline QPDFObjectHandle::setParsedOffset
...
Part of #729
2022-08-30 14:55:45 +01:00
m-holger
70d985f942
Optimise QPDFParser::parse for #311 problem
...
Avoid creating new null objects that later will be discarded and made
implicit.
Part of #729
2022-08-30 13:32:54 +01:00
m-holger
97a7ad1d80
Avoid setting descriptions / offsets for direct nulls in QPDFParser::parse
...
Part of #729
2022-08-30 13:07:48 +01:00
m-holger
7402c02c80
Combine stacks in QPDFParser::parse
...
Part of #729
2022-08-30 12:53:19 +01:00
m-holger
74162a2d48
Tune QPDFParser::parse
...
Replace SparseOHArray with std::vector<QPDFObjectHandle>.
Part of #729
2022-08-30 11:32:43 +01:00
m-holger
6fc982b71a
Move QPDFObjectHandle::setObjectDescriptionFromInput to QPDFParser
...
Part of #729
2022-08-30 06:42:46 +01:00
m-holger
8ad1ea34fe
Add private methods QPDFParser::warn
...
Part of #729
2022-08-30 06:04:34 +01:00
m-holger
6670c685ab
Move QPDFObjectHandle::parseInternal to new class QPDFParser
...
Part of #729
2022-08-30 05:56:23 +01:00
Jay Berkenbilt
0adfd74f8b
Merge pull request #747 from m-holger/new_stream
...
Add optional parameter allow_nullptr to QPDFObjectHandle::getOwningQPDF
2022-08-29 16:33:19 -04:00
Jay Berkenbilt
2b01a79e87
Fix header ordering in QTC (format code)
2022-08-29 11:55:02 -04:00
m-holger
c53d54b13d
Add optional parameter allow_nullptr to QPDFObjectHandle::getOwningQPDF
...
Also, inline method and add optional parameter error_msg.
2022-08-28 22:15:59 +01:00
m-holger
b0c1ae05a3
Fix commit b45420a
2022-08-27 12:43:49 +01:00
m-holger
fc4feb6f1a
Remove BufferInputSource::Members
2022-08-27 12:19:51 +01:00
m-holger
d6a447b654
Remove ClosedFileInputSource::Members
2022-08-27 12:13:39 +01:00
m-holger
69a5fb7047
Add methods InputSource::fastRead, fastUnRead and fastTell
...
Provide buffered input for QPDFTokenizer.
2022-08-26 23:55:56 +01:00
m-holger
13ef50cd27
Avoid virtual method call in FileInputSource::read
2022-08-25 15:08:03 +01:00
m-holger
a318b203be
Refactor FileInputSource::seek and FileInputSource::unreadCh
...
Avoid building error message each call "just in case".
2022-08-25 15:04:41 +01:00
m-holger
dc5c8b82eb
Remove FileInputSource::Members
2022-08-25 12:42:14 +01:00
m-holger
7108cd7b98
Remove redundant tests in QPDFTokenizer::readToken
2022-08-25 11:32:08 +01:00
m-holger
10fda01b07
In QPDFTokenizer::readToken move call to getToken out of loop
2022-08-25 11:31:45 +01:00
m-holger
e4073ee868
Remove unnecessary string copy in QPDFTokenizer::getToken
2022-08-25 11:31:09 +01:00
m-holger
b45420a980
Remove QPDFTokenizer::unread_char
2022-08-25 11:30:49 +01:00
m-holger
706106dabb
Refactor QPDFTokenizer::betweenTokens()
2022-08-25 11:30:35 +01:00
m-holger
6371b90ae3
Refactor QPDFTokenizer::presentEOF
2022-08-25 11:30:24 +01:00
m-holger
42ed58e446
Integrate booleans and null into state machine in QPDFTokenizer
2022-08-25 11:30:13 +01:00
m-holger
fe33b7ca18
Integrate numbers into state machine in QPDFTokenizer
2022-08-25 11:26:46 +01:00
m-holger
931fbb6156
Integrate names into state machine in QPDFTokenizer
2022-08-25 11:26:38 +01:00
m-holger
a3f3238f37
Split QPDFTokenizer::handleCharacter into individual methods
2022-08-25 11:26:05 +01:00
m-holger
6111a6a424
Refactor QPDFTokenizer::inCharCode
2022-08-25 10:55:45 +01:00
m-holger
e7889ec5dc
Refactor st_top case in QPDFTokenizer::handleCharacter
2022-08-25 10:51:51 +01:00
m-holger
e4fe0d5cf5
Refactor QPDFTokenizer::inHexstring
2022-08-25 10:50:06 +01:00
m-holger
a5d2e88775
Code tidy: replace if with case statement in QPDFTokenizer::inString
2022-08-25 10:43:29 +01:00
m-holger
7c32f6cc2e
Add state st_string_escape in QPDFTokenizer
2022-08-25 10:41:36 +01:00
m-holger
7c5778f999
Add state st_string_after_cr in QPDFTokenizer
2022-08-21 11:13:48 +01:00
m-holger
f29d0a6312
Add state st_char_code in QPDFTokenizer
2022-08-21 11:01:48 +01:00
m-holger
d26b537a7c
Add private method QPDFTokenizer::inString
2022-08-21 02:54:34 +01:00
m-holger
2697ba49bc
Add private method QPDFTokenizer::inHexstring
2022-08-21 02:46:31 +01:00
m-holger
f9530a5815
Code tidy: replace if with case statement in QPDFTokenizer::handleCharacter
2022-08-21 02:38:49 +01:00
m-holger
86ade3f9cd
Add private method QPDFTokenizer::handleCharacter
2022-08-21 02:26:27 +01:00
m-holger
91fb61eda5
Code tidy: replace if with case statement in QPDFTokenizer::presentCharacter
2022-08-21 00:54:41 +01:00
m-holger
cf945eeabf
Avoid shrinking QPDFTokenizer::val and QPDFTokenizer::raw_val
2022-08-20 19:43:00 +01:00
m-holger
45a6100cbb
Inline QUtil functions used by QPDFTokenizer
2022-08-18 15:23:35 +01:00
m-holger
c08bb0ec02
Remove QPDFTokenizer::Members
2022-08-18 13:13:19 +01:00
Jay Berkenbilt
cef6425bca
Disable QTC inside the library by default ( fixes #714 )
...
This results in measurable performance improvements to packaged binary
libqpdf distributions. QTC remains available for library users and is
still selectively enabled in CI.
2022-08-07 16:20:49 -04:00
Jay Berkenbilt
da71dc6f37
QTC: cache get_env results for improved performance
...
It turns out that QUtil::get_env is particularly expensive on Windows
if there is a large environment. This may be true on other platforms
as well.
2022-08-07 14:23:05 -04:00
Jay Berkenbilt
32e30a3af2
Resolve QPDF{Name,Number} tree helper linker issues ( fixes #745 )
...
This is a guess...I'm not sure exactly why there are linker issues or
how to reproduce them.
2022-08-07 09:21:01 -04:00
Jay Berkenbilt
b90adb1c6c
Merge pull request #746 from m-holger/smart
...
Code tidy: remove redundant calls to smart_ptrs get() method
2022-08-07 08:41:50 -04:00
m-holger
7c6901bce5
Code tidy: remove redundant calls to smart_ptrs get() method
2022-08-07 10:33:25 +01:00
Jay Berkenbilt
3ec43f055a
Fix parsing comment
2022-08-06 14:24:08 -04:00
Jay Berkenbilt
a3037ca440
Merge pull request #739 from m-holger/getobject
...
Add QPDF::getObject to replace getObjectByObjGen and getObjectByID
2022-08-06 14:23:56 -04:00
m-holger
1553868c4a
Add QPDF::getObject to replace getObjectByObjGen and getObjectByID
...
For consistency with similar methods, e.g. replaceObject.
2022-08-01 19:22:37 +01:00
m-holger
407b0766b8
Inline QPDFObjectHandle::getObjGen etc
...
Also, make QPDFObjectHandle::isIndirect const.
2022-08-01 15:08:48 +01:00
m-holger
903a86643a
Fix code formatting of QPDF::pushInheritedAttributesToPageInternal
2022-08-01 13:54:51 +01:00
m-holger
0356bcecc5
Tidy QPDF::pushInheritedAttributesToPageInternal
...
Remove unnecessary parameters.
Remove code that is unnecessary as result of a prior call to QPDF::getAllPages.
Avoid clearing and rebuilding of m->all_pages.
2022-08-01 13:29:14 +01:00
m-holger
ff69773b35
Fix warnings in QPDF::getAllPagesInternal
2022-08-01 13:29:14 +01:00
m-holger
9dea7d3080
Tune QPDF::getAllPagesInternal
...
Avoid calling getAllPagesInternal for each /Page object.
2022-08-01 13:29:14 +01:00
m-holger
4ccca20db0
Remove redundant parameter from QPDF::getAllPagesInternal
2022-08-01 13:29:14 +01:00
Jay Berkenbilt
5d63730b93
Clean up documentation
2022-07-31 16:26:02 -04:00
Jay Berkenbilt
12d065c751
Provide a simpler QPDF::writeJSON
2022-07-31 16:23:17 -04:00
Jay Berkenbilt
13cf35ce2f
Use calledgetallpages and pushedinheritedpageresources
2022-07-31 16:23:17 -04:00
Jay Berkenbilt
5f4224f31a
Simplify --json-output
...
Now --json-output just changes defaults. Allow output file with --json.
2022-07-31 16:23:17 -04:00
Jay Berkenbilt
80acfc3826
Fix --json-help to take a version parameter
2022-07-31 16:23:17 -04:00
Jay Berkenbilt
69820847af
Change the output of --json to use "qpdf" instead of "objects"
2022-07-31 15:17:01 -04:00
Jay Berkenbilt
d01c4f8819
Change --json-output format
...
from "qpdf-v2" to "qpdf": [..., ...]
2022-07-31 10:32:55 -04:00
Jay Berkenbilt
bb96499b61
Update docs and prepare QPDF::writeJSON for changes
...
Add additional parameters that will be needed to call QPDF::writeJSON
in partial mode.
2022-07-31 10:32:55 -04:00
Jay Berkenbilt
0e3d4cdc97
Fix/clarify meaning of depth parameter to json write methods
2022-07-31 10:32:55 -04:00
Jay Berkenbilt
4feb10fdaf
Merge pull request #734 from m-holger/nullptr
...
Code tidy : replace 0 with nullptr or true
2022-07-31 08:33:45 -04:00
m-holger
073808aa50
Code tidy : replace 0 with nullptr or true
2022-07-26 13:40:13 +01:00
Jay Berkenbilt
4674c04cb8
JSON schema: support multi-element array validation
2022-07-24 16:44:51 -04:00
Jay Berkenbilt
f8d1ab9462
JSON schema -- accept single item in place of array
...
When the schema wants a variable-length array, allow a single item as
well as allowing an array.
2022-07-24 16:17:03 -04:00
Jay Berkenbilt
b3e6d445cb
Tweak "AndGet" mutator functions again
...
Remove any ambiguity around whether old or new value is being
returned.
2022-07-24 15:42:23 -04:00
m-holger
8b4afa428e
Revert making second parameter of QPDFObjGen::QPDFObjGen optional
...
Also, change test for QPDFObjGen::isIndirect to obj != 0.
Delete comment from commit afd35f9
.
2022-07-24 16:55:10 +01:00
m-holger
afd35f9a30
Overload StreamDataProvider::provideStreamData
...
Use 'QPDFObjGen const&' instead of 'int, int' in signature.
2022-07-24 16:02:35 +01:00
m-holger
5d0469f1bc
QPDFObjGen : tidy QPDFJob
...
Use QPDFObjGen::unparse where appropriate.
2022-07-24 16:02:35 +01:00
m-holger
4b73d057fb
QPDFObjGen : tidy QPDF_Stream
...
Change method signatures to use QPDFObjGen.
Replace QPDF_Stream::objid and generation with QPDF_Stream::og.
2022-07-24 16:02:35 +01:00
m-holger
f7978db1f6
QPDFObjGen : tidy QPDF private methods
...
Change method signatures to use QPDFObjGen.
Use QPDFObjGen methods where possible.
Remove redundant QPDF::objGenToIndirect.
2022-07-24 16:02:35 +01:00
m-holger
3404ca8ac8
QPDFObjGen : tidy QPDFObjectHandle private methods
...
Change method signature to use QPDFObjGen.
2022-07-24 15:59:49 +01:00
m-holger
b123f79dfd
Replace QPDFObjectHandle::objid and generation with QPDFObjectHandle::og
2022-07-24 15:59:49 +01:00
m-holger
c0168cf88c
QPPFObjGen : tidy QPDF::readObjectAtOffset
...
Change method signature to use QPDFObjGen.
2022-07-24 15:59:49 +01:00
m-holger
eeb6162f76
Add optional parameter separator to QPDFObjGen::unparse
...
Also, revert inlining of unparse and operator << from commit 4c6640c
in
order to avoid exposing QUtil.
2022-07-24 15:41:48 +01:00
Jay Berkenbilt
6f1041afb8
Clarify intent in readObjectAtOffset
...
Rather than using object id -1 to mean "don't care", use object ID 0,
and clarify the difference between that use and indication of a direct
object.
2022-07-24 09:40:11 -04:00
m-holger
4c6640cb45
Inline QPDFObjGen methods
...
ABI breaking change
2022-07-16 14:32:48 -04:00
Jay Berkenbilt
a603c1e395
Run format-code
2022-06-27 12:50:35 -04:00
m-holger
f0a8178091
Refactor QPDFObject creation and cloning
...
Move responsibility for creating shared pointers to objects and cloning from QPDFObjectHandle to QPDFObject.
2022-06-27 12:47:02 -04:00
m-holger
5aa8225f49
Refactor QPDFObjectTypeAccessor and QPDFObjectHandle::dereference
2022-06-27 10:39:04 -04:00
Jay Berkenbilt
0c7c7e4ba4
Track whether certain page modifying methods have been called
...
We need to know whether pushInheritedAttributesToPage or getAllPages
have been called when generating JSON output. When reading the JSON
back in, we have to call the same methods so that object numbers will
line up properly.
2022-06-25 13:55:45 -04:00
Jay Berkenbilt
25aff0bd52
TODO: abandon (again) and update notes about QPDFPagesTree
2022-06-25 13:26:53 -04:00
Jay Berkenbilt
8a32515a62
Add warnings for some additional page tree repair
2022-06-25 13:25:35 -04:00
Jay Berkenbilt
6c4537885e
Reformat code
2022-06-25 11:11:24 -04:00
m-holger
7836e19747
Code tidy: remove redundant calls to QPDFObjectHandle::isInitialized
2022-06-25 11:10:06 -04:00
m-holger
3b3bcab349
Remove QPDF_Stream::setStreamDescription
2022-06-25 08:26:46 -04:00
m-holger
9eda1fdc41
Remove redundant QPDF_Array::setDescription and QPDF_Dictionary::setDescription
2022-06-25 08:25:58 -04:00
m-holger
e9c1637353
Add private method QPDFObjectHandle::getObjGenAsStr
...
Also, use methods to access objid and generation.
2022-06-25 08:25:32 -04:00
m-holger
97f737a562
Code tidy: QPDFJob::doJSONPageLabels
...
Remove redundant variables pages and next.
2022-06-25 08:24:50 -04:00
Jay Berkenbilt
1eb2f208ec
Use Pl_Function in qpdflogger C API implementation
2022-06-19 09:12:59 -04:00
Jay Berkenbilt
eae75dbe44
Add Pl_Function -- a generic function pipeline
2022-06-19 09:12:29 -04:00
Jay Berkenbilt
bb0ea2f8e7
Add qpdfjob_register_progress_reporter
2022-06-19 08:46:58 -04:00
Jay Berkenbilt
87412eb05b
Add QPDFJob::registerProgressReporter
2022-06-19 08:46:58 -04:00
Jay Berkenbilt
3a7ee7e938
Move C-based ProgressReporter helper into QPDFWriter
2022-06-19 08:46:58 -04:00
Jay Berkenbilt
8130d50e3b
Add C API to QPDFLogger
2022-06-19 08:46:58 -04:00
Jay Berkenbilt
daef4e8fb8
Add more flexible funtions to qpdfjob C API
2022-06-19 08:46:58 -04:00
Jay Berkenbilt
e0720eaa78
Use the default logger for other writes to stdout/stderr
...
When there is no context for writing output or error messages, use the
default logger.
2022-06-18 10:38:50 -04:00
Jay Berkenbilt
83be2191b4
Use "save" logger when saving data to standard output
...
This includes the output PDF, streams from --show-object and
attachments from --save-attachment. This also enables --verbose and
--progress to work with saving to stdout.
2022-06-18 09:54:40 -04:00
Jay Berkenbilt
641e92c6a7
QPDF, QPDFJob: use QPDFLogger instead of custom output streams
2022-06-18 09:02:55 -04:00
Jay Berkenbilt
f1f711963b
Add and test QPDFLogger class
2022-06-18 09:02:55 -04:00
Jay Berkenbilt
f588d74140
Add integer types to Pipeline::operator<<
2022-06-18 09:02:55 -04:00
m-holger
057bd659bc
Code tidy: remove redundant variable in QPDF::writeJSON
2022-06-05 18:46:21 -04:00
Jay Berkenbilt
0bd908b550
Update documentation for qpdf JSON v2
2022-05-30 20:03:08 -04:00
Jay Berkenbilt
b7bbf12e85
In json mode, reveal recovered user password when otherwise unavailable
2022-05-30 20:03:08 -04:00
Jay Berkenbilt
f049a77c59
Add additional information when listing attachments
2022-05-30 20:03:08 -04:00
Jay Berkenbilt
04fc7c4bea
Add conversions to ISO-8601 date format
2022-05-30 20:03:08 -04:00
Jay Berkenbilt
27a42c16c7
Change default decode level to "none" with --json-output
2022-05-21 17:51:34 -04:00
Jay Berkenbilt
752f43d4e4
Allow empty b: binary JSON strings
2022-05-21 17:36:32 -04:00
Jay Berkenbilt
05460d405c
Format code
2022-05-21 16:11:42 -04:00
m-holger
6c69a747b9
Code clean up: use range-style for loops wherever possible
...
Remove variables obsoleted by commit 4f24617
.
2022-05-21 16:06:29 -04:00
Jay Berkenbilt
c56a9ca7f6
JSON: Fix large file support
2022-05-21 09:43:45 -04:00
Jay Berkenbilt
47c093c48b
Replace std::regex with validators for better performance
2022-05-21 08:43:21 -04:00
Jay Berkenbilt
9b2eb01e25
Exercise object description in tests
2022-05-20 14:23:32 -04:00
Jay Berkenbilt
6c2fb5b8f0
Add test for bad data and bad datafile
2022-05-20 13:33:30 -04:00
Jay Berkenbilt
d065098089
Test --update-from-json
2022-05-20 11:10:12 -04:00
Jay Berkenbilt
ef955b04b5
Bug fix: don't clobber stream length with replaceDict
2022-05-20 11:09:45 -04:00
Jay Berkenbilt
3eb77a7004
JSON: detect duplicate dictionary keys while parsing
2022-05-20 10:13:15 -04:00
Jay Berkenbilt
6d4e3ba8a4
Test (and fix) handling of dangling references
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
5a2aa59479
Bug fix: isReserved() true for indirect reference to reserved object
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
35b1e1c493
Explicitly test ignoring unknown keys in JSON input
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
dc8df962d8
Make version default to latest for --json-output (like --json)
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
6c7326b290
JSON fix: correctly parse UTF-16 surrogate pairs
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
6f43bf8de3
Major rework -- see long comments
...
* Replace --create-from-json=file with --json-input, which causes the
regular input to be treated as json.
* Eliminate --to-json
* In --json=2, bring back "objects" and eliminate "objectinfo". Stream
data is never present.
* In --json-output=2, write "qpdf-v2" with "objects" and include
stream data.
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
23fc6756f1
Add QUtil::FileCloser to the public API
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
0fe8d44762
Support stream data -- not tested
...
There are no automated tests yet, but committing work so far in
preparation for some refactoring.
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
63c7eefe9d
replaceStreamData: accept uninitialized filter/decode_parms
...
These mean to leave the original values alone. This is needed for
reconstructing streams from JSON given that the stream data and stream
dictionary may appear in any order in the JSON.
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
56f1b411fe
Back out fluent QPDFObjectHandle methods. Keep the andGet methods.
...
I decided these were confusing and inconsistent with how JSON works.
They muddle the API rather than improving it.
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
7e7a9c4379
Parse objects; stream data is not yet handled
2022-05-20 09:16:25 -04:00
Jay Berkenbilt
9064542b5f
Add private methods for reserving specific objects
2022-05-20 07:54:09 -04:00
Jay Berkenbilt
7fa5d1773b
Implement top-level qpdf json parsing
2022-05-16 13:41:40 -04:00
Jay Berkenbilt
8d42eb2632
Add scaffolding for QPDF JSON reactor
2022-05-16 13:41:40 -04:00
Jay Berkenbilt
4fe2e06b47
Add --create-from-json and --update-from-json arguments
...
Also add stubs for top-level QPDF methods (createFromJSON,
updateFromJSON)
2022-05-16 13:41:40 -04:00
Jay Berkenbilt
9a0e9a1a9e
Remove offset from missing /Root error
...
The last offset is irrelevant to not being able to find /Root.
2022-05-16 13:39:26 -04:00
Jay Berkenbilt
051ae7c282
Improve handling of replacing stream data with empty strings
...
When an empty string was passed to replaceStreamData, the code was
passing a null pointer to memcpy. Since a 0 size was also passed, this
was harmless, but it triggers sanitizer errors. The code properly
handles a null pointer as the buffer in other places.
2022-05-16 13:39:26 -04:00
Jay Berkenbilt
60ec94a7c3
Add QUtil::is_long_long
2022-05-16 13:39:26 -04:00
Jay Berkenbilt
4c7cfd5cbc
JSON reactor: improve handling of nested containers
...
Call the parent container's item method before calling the child
item's start method so we can easily know the current nesting level
when nested items are added.
2022-05-14 17:35:06 -04:00
Jay Berkenbilt
2a2f7f1bba
Add maxobjectid to JSON
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
e9390aeaaa
Add --to-json option
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
c76536dd9a
Implement JSON v2 output
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
15272662f6
Fix typo in json output key name
...
moddify -> modify. Also carefully spell checked all remaining keys by
splitting them into words and running a spell checker, not just
relying on visual proofreading. That was the only one.
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
1bc8abfdd3
Implement JSON v2 for Stream
...
Not fully exercised in this commit
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
3246923cf2
Implement JSON v2 for String
...
Also refine the herustic for deciding whether to use hexadecimal
notation for a string.
2022-05-08 13:45:20 -04:00
Jay Berkenbilt
16f4f94cd9
Prepare code for JSON v2
...
Update getJSON() methods and calls to them
2022-05-07 11:12:01 -04:00
Jay Berkenbilt
a9fbbd5dca
Objectinfo json: write incrementally and in numeric order
...
This script was used on test data:
----------
#!/usr/bin/env python3
import json
import sys
import re
def json_dumps(data):
return json.dumps(data, ensure_ascii=False,
indent=2, separators=(',', ': '))
for filename in sys.argv[1:]:
with open(filename, 'r') as f:
data = json.loads(f.read())
if 'objectinfo' not in data:
continue
trailer = None
to_sort = []
for k, v in data['objectinfo'].items():
if k == 'trailer':
trailer = v
else:
m = re.match(r'^(\d+) \d+ R', k)
if m:
to_sort.append([int(m.group(1)), k, v])
newobjectinfo = {x[1]: x[2] for x in sorted(to_sort)}
if trailer is not None:
newobjectinfo['trailer'] = trailer
data['objectinfo'] = newobjectinfo
print(json_dumps(data))
----------
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
948de60990
Objects json: write incrementally and in numeric order
...
The following script was used to adjust test data:
----------
#!/usr/bin/env python3
import json
import sys
import re
def json_dumps(data):
return json.dumps(data, ensure_ascii=False,
indent=2, separators=(',', ': '))
for filename in sys.argv[1:]:
with open(filename, 'r') as f:
data = json.loads(f.read())
if 'objects' not in data:
continue
trailer = None
to_sort = []
for k, v in data['objects'].items():
if k == 'trailer':
trailer = v
else:
m = re.match(r'^(\d+) \d+ R', k)
if m:
to_sort.append([int(m.group(1)), k, v])
newobjects = {x[1]: x[2] for x in sorted(to_sort)}
if trailer is not None:
newobjects['trailer'] = trailer
data['objects'] = newobjects
print(json_dumps(data))
----------
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
f50274ef46
Pages json: write each page incrementally
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
dc9b7287cd
Top-level json: write incrementally
...
This commit just changes the order in which fields are written to the
json without changing their content. All the json files in the test
suite were modified with this script to ensure that we didn't get any
changes other than ordering.
----------
#!/usr/bin/env python3
import json
import sys
def json_dumps(data):
return json.dumps(data, ensure_ascii=False,
indent=2, separators=(',', ': '))
for filename in sys.argv[1:]:
with open(filename, 'r') as f:
data = json.loads(f.read())
newdata = {}
for i in ('version', 'parameters', 'pages', 'pagelabels',
'acroform', 'attachments', 'encrypt', 'outlines',
'objects', 'objectinfo'):
if i in data:
newdata[i] = data[i]
print(json_dumps(newdata))
----------
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
7f65a5c21f
Test json against schema only on demand
...
Testing json against schema requires an in-memory copy, so do it only
when requested by the test suite.
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
a3c9980395
Add next to Pl_String and fix comments
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
b361c5ce19
Add --test-json-schema command-line option
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
7604ac5cb2
QPDFJob: have doJSON write to a pipeline
2022-05-07 08:26:31 -04:00
Jay Berkenbilt
0500d4347a
JSON: add blob type that generates base64-encoded binary data
2022-05-06 19:14:52 -04:00
Jay Berkenbilt
05fda4afa2
Change JSON parser to parse from an InputSource
2022-05-04 12:07:11 -04:00
Jay Berkenbilt
e5f3910c3e
Add new FileInputSource constructors
2022-05-04 12:07:11 -04:00
Jay Berkenbilt
e259635986
JSON: add write methods and implement unparse() in terms of those
2022-05-04 12:07:11 -04:00
Jay Berkenbilt
8b25de24c9
Make "objects" and "pages" consistent in JSON output
2022-05-04 08:32:44 -04:00
Jay Berkenbilt
6b576797cd
Don't call pushInheritedAttributesToPage in json mode
...
We used to have to do that, but for quite some time, the code that
gets images has no longer required it.
2022-05-04 07:11:13 -04:00
Jay Berkenbilt
f4206a0938
Add new Pl_String Pipeline
2022-05-03 18:54:51 -04:00
Jay Berkenbilt
16139d97c8
Add new Pl_OStream Pipeline
2022-05-03 18:54:51 -04:00
Jay Berkenbilt
21d6e3231f
Make use of the new Pipeline methods in some places
2022-05-03 18:31:23 -04:00
Jay Berkenbilt
f1c6bb97db
Add new Pipeline convenience methods
2022-05-03 18:31:22 -04:00
Jay Berkenbilt
59f3e09edf
Make Pipeline::write take an unsigned char const* (API change)
2022-05-03 18:31:22 -04:00
Jay Berkenbilt
62bf296a9c
Make assert handling less error-prone
...
Prevent my future self or other contributors from using assert in
tests and then having that assert not do anything because of the
NDEBUG macro.
2022-05-03 18:31:22 -04:00
Jay Berkenbilt
92b692466f
Remove remaining incorrect assert calls from implementation
2022-05-03 18:31:22 -04:00
Jay Berkenbilt
3d9bac43da
Add internal Pl_Base64
...
Bidirectional base64; will be used by JSON v2.
2022-05-03 18:31:22 -04:00
Jay Berkenbilt
6724a362c3
Move generate_auto_job to the top-level CMakeLists.txt
2022-05-03 08:39:50 -04:00
Jay Berkenbilt
8d2a0eda5a
Add reactors to the JSON parser
2022-05-01 19:55:52 -04:00
Jay Berkenbilt
72e5c73419
Limit parser depth for json parser
2022-05-01 12:56:22 -04:00
Jay Berkenbilt
e34dbbfa18
Spell check
2022-05-01 12:56:22 -04:00
Jay Berkenbilt
8ccd3a8a89
Mark weak encryption with API changes ( fixes #576 )
2022-04-30 17:24:15 -04:00
Jay Berkenbilt
2213ed0c3d
Remove deprecated (pre-8.4.0) encryption APIs
2022-04-30 17:23:58 -04:00
Jay Berkenbilt
cff26040d8
Using insecure crytpo from the CLI is now an error by default
2022-04-30 17:23:58 -04:00
Jay Berkenbilt
ce19471f18
Add comments around non-security-related uses of MD5
2022-04-30 14:15:07 -04:00
Jay Berkenbilt
c365a26e9d
Revert "Remove QPDFObjectHandle::replaceOrRemoveKey"
...
This reverts commit dc059560e7
.
I changed my mind. There's no harm in leaving it deprecated for a
release cycle.
2022-04-30 14:15:07 -04:00
Jay Berkenbilt
dc059560e7
Remove QPDFObjectHandle::replaceOrRemoveKey
...
See ChangeLog for rationale for not deprecating it as originally
planned.
2022-04-30 13:39:45 -04:00
Jay Berkenbilt
4f24617e1e
Code clean up: use range-style for loops wherever possible
...
Where not possible, use "auto" to get the iterator type.
Editorial note: I have avoid this change for a long time because of
not wanting to make gratuitous changes to version history, which can
obscure when certain changes were made, but with having recently
touched every single file to apply automatic code formatting and with
making several broad changes to the API, I decided it was time to take
the plunge and get rid of the older (pre-C++11) verbose iterator
syntax. The new code is just easier to read and understand, and in
many cases, it will be more effecient as fewer temporary copies are
being made.
m-holger, if you're reading, you can see that I've finally come
around. :-)
2022-04-30 13:27:18 -04:00
Jay Berkenbilt
7f023701dd
Formatting: remove space in range-style for loops
...
Change .clang-format and commit automated changes from a fresh run of
format-code
2022-04-30 13:26:43 -04:00
Jay Berkenbilt
2878c186bf
Use fluent appendItem
2022-04-30 10:54:16 -04:00
Jay Berkenbilt
ab9d557cb0
Use fluent replaceKey
2022-04-29 20:39:54 -04:00
Jay Berkenbilt
d8fdf632a9
Use replaceKeyAndGet in a few places in existing code
2022-04-29 20:28:02 -04:00
Jay Berkenbilt
e80fad86e9
Add new QPDFObjectHandle methods for more fluent programming
2022-04-29 20:09:10 -04:00
Jay Berkenbilt
d0b7cc8ac6
QPDFJob json: make removeAttachment take an array ( fixes #693 )
2022-04-24 13:06:19 -04:00
Jay Berkenbilt
63c5a56f38
Fix build logic around generate_auto_job
...
It was being run at configuration time, not build time.
2022-04-24 13:06:16 -04:00
Jay Berkenbilt
08ba21cf49
Fix some bugs around null values in dictionaries
...
Make it so that a key with a null value is always treated as not being
present. This was inconsistent before.
2022-04-24 10:08:32 -04:00
Jay Berkenbilt
4be2f36049
Deprecate replaceOrRemoveKey -- it's the same as replaceKey
2022-04-24 09:31:32 -04:00
Jay Berkenbilt
4925f0d18c
Have dictionary/streams mutators take const& where possible
2022-04-24 09:05:50 -04:00
Jay Berkenbilt
68e721981a
Add new QPDF::warn that takes most of QPDFExc's arguments
2022-04-23 18:25:43 -04:00
Jay Berkenbilt
22b35c4928
Expose QUtil::get_next_utf8_codepoint
2022-04-23 18:25:43 -04:00
Jay Berkenbilt
5bbb0d4c30
Replace switch statements with static map initializers
...
Character transcoding from Unicode to single-byte characters used
hard-coded switch statements because the code predated our adoption of
C++11. Now we have thread-safe, static initialization of map literals,
so use that instead.
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
75fe4f60c3
Use anonymous namespaces for file-private classes
2022-04-16 13:35:27 -04:00
Jay Berkenbilt
80ed3076a0
Remove deprecated name/number tree constructors
...
Remove the name/number tree object helper constructors that don't take
a QPDF&.
2022-04-16 13:13:15 -04:00
Jay Berkenbilt
496ca2e4dc
Remove QPDFAcroFormDocumentHelper::copyFieldsFromForeignPage
2022-04-16 13:12:07 -04:00
Jay Berkenbilt
6df6260751
Change default --json from 1 to latest
2022-04-16 12:57:33 -04:00
Jay Berkenbilt
cdd0b4fb7d
Use = default and = delete where possible in classes
2022-04-16 11:39:14 -04:00
Jay Berkenbilt
2a7d2b63c2
Make ABI-breaking changes that don't modify API at all
...
* Merge overloaded functions by adding default values
* Remove non-const methods that are identical to const methods
2022-04-16 10:41:46 -04:00
Jay Berkenbilt
ce86307a1a
Fix typo in error message
2022-04-10 16:54:23 -04:00
Jay Berkenbilt
90cfe80bac
Clean up/fix DLL.h
...
* Change DLL_EXPORT to libqpdf_EXPORTS (internal to the build). The
new name is cmake's default, is more conventional, and is less
likely to clash with other symbols.
* Add QPDF_DLL_PRIVATE for non-Windows
* Make logic around when to define QPDF_DLL et al more explicit
* Add detailed comments
2022-04-10 16:52:36 -04:00
Jay Berkenbilt
07edf96440
Remove methods of private classes from ABI
...
Prior to the cmake conversion, several private classes had methods
that were exported into the shared library so they could be tested
with libtests. With cmake, we build libtests using an object library,
so this is no longer necessary. The methods that are disappearing from
the ABI were never exposed through public headers, so no code should
be using them. Removal had to wait until the window for ABI-breaking
changes was open.
2022-04-09 17:33:29 -04:00
Jay Berkenbilt
128e41648f
Remove PointerHolder.hh from other than public header files
...
Increase to POINTERHOLDER_TRANSITION=4
2022-04-09 17:33:29 -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
08fb583449
Remove accidentally committed file
2022-04-09 14:37:00 -04:00
Jay Berkenbilt
59834db472
Add documentation for code formatting and contribution guidelines
2022-04-09 12:25:08 -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
97fc98901c
Protect gnutls headers from clang-format rearranging them
2022-04-04 08:05:39 -04:00
Jay Berkenbilt
33caed4f17
Exclude formatting on embedded native crypto
2022-04-03 17:58:36 -04:00
Jay Berkenbilt
f8e97e0ed5
Put spaces around version constraint in pkg-config ( fixes #677 )
...
Also add a pkg-config runtime test that would have caught the error.
2022-03-23 10:52:40 -04:00
Jay Berkenbilt
6dcb26d21e
Fix test for whether atomic library is needed
...
Some platforms need it for atomic<long long> but not for atomic<int>.
2022-03-19 18:19:44 -04:00
Jay Berkenbilt
820a3f04fd
Remove "lt-" workarounds
...
The executables that libtool built invoked the underlying binary with
an "lt-" prefix. The code contained numerous workarounds for testing,
which can now be removed.
2022-03-18 19:53:18 -04:00
Jay Berkenbilt
acdf5b2e7a
Update process for ABI testing
2022-03-18 19:53:18 -04:00
Jay Berkenbilt
70d0d0889b
Remove old build files
2022-03-18 19:53:18 -04:00
Jay Berkenbilt
b8aff90997
Add cmake configuration files
2022-03-18 19:53:18 -04:00
Jay Berkenbilt
3331e8921c
Switch variables to cmake in qpdf-config.h
2022-03-18 19:53:18 -04:00
Jay Berkenbilt
f030789104
Rename bits_include.cc to qpdf/bits_functions.hh
...
It's better to just make it a .hh file to reduce confusion.
2022-03-07 18:01:27 -05:00
Jay Berkenbilt
6dd8465948
TODO: solidify plans for code formatting
2022-02-26 12:08:58 -05:00
Jay Berkenbilt
6aa58d51be
Rename bits.icc to bits_include.cc
2022-02-26 12:08:58 -05:00
Jay Berkenbilt
99393e6ab7
Shorten coverage case name
...
This is so it will fit on one line after a qtest upgrade allows us to
split lines.
2022-02-26 10:18:23 -05:00
Jay Berkenbilt
03bc6535bd
generate_auto_job: protect generated files from formatting
2022-02-26 09:17:51 -05: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
Jay Berkenbilt
36794a60cf
Allow \/ in a json string
2022-02-25 11:42:50 -05:00
Jay Berkenbilt
56b4d5a610
Use val.at instead of val[]
2022-02-22 08:40:49 -05:00
Jay Berkenbilt
f7ac591590
Recognize explicit UTF-8 strings ( fixes #654 )
2022-02-22 08:10:05 -05:00
Jay Berkenbilt
3b4b9efd21
Fix autogeneration of job.sums
2022-02-22 08:10:05 -05:00
Jay Berkenbilt
31b45b0fd4
Fix logic error with Tf when generating appearances ( fixes #655 )
2022-02-18 13:46:35 -05:00
Jay Berkenbilt
3e2109ab37
Remove special case for 0xad for 10.6.2.
2022-02-16 06:52:05 -05:00
Jay Berkenbilt
e810fe678a
Fix asymmetry between newUnicodeString and getUTF8Value
2022-02-15 19:22:35 -05:00
Jay Berkenbilt
a478cbb6dc
Silently/transparently recognize UTF-16LE as UTF-16 ( fixes #649 )
...
The PDF spec only allows UTF-16BE, but most readers seem to accept
UTF-16LE as well, so now qpdf does too.
2022-02-15 16:13:12 -05:00
Jay Berkenbilt
fbd3e56da7
Ignore -- at the top level arg parser ( fixes #652 )
...
This was unintended behavior that was added back for backward
compatibility. It is intentionally undocumented.
2022-02-15 16:13:12 -05:00
Jay Berkenbilt
1065bbb016
Handle odd PDFDoc codepoints in UTF-8 during transcoding ( fixes #650 )
...
There are codepoints in PDFDoc that are not valid UTF-8 but map to
valid UTF-8. We were handling those correctly with bidirectional
mapping.
However, if those same code points appeared in UTF-8, where they have
no meaning, they were left as fixed points when converting to PDFDoc,
where they do have meaning. This change recognizes them as errors.
2022-02-15 08:32:38 -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
235c89e037
Fix one more PDF doc encoding error for 10.6 release ( fixes #637 )
2022-02-09 05:47:58 -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
cfd5147d92
Add QPDF::getVersionAsPDFVersion
2022-02-08 12:34:14 -05:00
Jay Berkenbilt
8082af09be
Add PDFVersion class
2022-02-08 12:34:14 -05:00
Jay Berkenbilt
cb769c62e5
WHITESPACE ONLY -- expand tabs in source code
...
This comment expands all tabs using an 8-character tab-width. You
should ignore this commit when using git blame or use git blame -w.
In the early days, I used to use tabs where possible for indentation,
since emacs did this automatically. In recent years, I have switched
to only using spaces, which means qpdf source code has been a mixture
of spaces and tabs. I have avoided cleaning this up because of not
wanting gratuitous whitespaces change to cloud the output of git
blame, but I changed my mind after discussing with users who view qpdf
source code in editors/IDEs that have other tab widths by default and
in light of the fact that I am planning to start applying automatic
code formatting soon.
2022-02-08 11:51:15 -05:00
Jay Berkenbilt
c62e8e2b28
Update for clean compile with POINTERHOLDER_TRANSITION=2
2022-02-07 17:38:22 -05:00
Jay Berkenbilt
3f22bea084
Use make_array_pointer_holder
...
This will be able to be replaced with QUtil::make_shared_array
2022-02-07 17:38:22 -05:00
Jay Berkenbilt
40f1946df8
Replace PointerHolder arrays with shared_ptr arrays where possible
...
Replace PointerHolder arrays wherever it can be done without breaking ABI.
2022-02-07 17:38:22 -05:00
Jay Berkenbilt
df2f5c6a36
Add QUtil::make_shared_array to help with PointerHolder transition
2022-02-07 14:08:46 -05:00
Jay Berkenbilt
cfaae47dc6
Add getBufferSharedPointer() to Pl_Buffer and QPDFWriter
2022-02-07 12:53:28 -05:00
m-holger
5901fcad4c
C-API expose QPDFObjectHandle::getKeyIfDict
2022-02-06 11:21:15 -05:00
m-holger
8371060340
Add method QPDFObjectHandle::getKeyIfDict
2022-02-06 11:21:15 -05:00
m-holger
2ed5f49a79
C-API expose QPDFObjectHandle::getValueAs... accessors
2022-02-05 19:40:30 -05:00
Jay Berkenbilt
af3f74de8c
Stop using std::iterator ( fixes #618 )
...
Create the typedefs directly in iterators rather than deriving from
the deprecated std::iterator class.
2022-02-05 11:29:25 -05:00
Jay Berkenbilt
7fb22740e1
Add operator ""_qpdf for creating QPDFObjectHandle literals
2022-02-05 11:29:25 -05:00
Jay Berkenbilt
b48a0ff0e8
Add qpdf_empty_pdf to C API
2022-02-05 11:29:25 -05:00
Jay Berkenbilt
8cf7f2bfb5
API contract: qpdf_get_qpdf_version() returns a static
2022-02-05 11:24:56 -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
e58b1174c7
Add new QPDFObjectHandle::getValueAs... accessors
2022-02-05 11:24:35 -05:00
Jay Berkenbilt
cfaa2de804
Update copyright for 2022
2022-02-04 16:36:22 -05:00
Jay Berkenbilt
2229e37e88
Add a blank line after the first header included in each source
2022-02-04 16:31:31 -05:00
Jay Berkenbilt
8eab616d62
Add qpdf version macros to qpdf/DLL.h
2022-02-04 13:41:01 -05:00
Jay Berkenbilt
abc300f05c
Replace containers of PointerHolder with containers of std::shared_ptr
...
None of these are in the public API.
2022-02-04 13:12:37 -05:00
Jay Berkenbilt
f0c2e0ef1e
JSON: use std::shared_ptr internally
2022-02-04 13:12:37 -05:00
Jay Berkenbilt
9044a24097
PointerHolder: deprecate getPointer() and getRefcount()
...
Use get() and use_count() instead. Add #define
NO_POINTERHOLDER_DEPRECATION to remove deprecation markers for these
only.
This commit also removes all deprecated PointerHolder API calls from
qpdf's code except in PointerHolder's test suite, which must continue
to test the deprecated APIs.
2022-02-04 13:12:37 -05:00
m-holger
95e7d36b7a
C-API add two binary UTF8 funtions
...
add qpdf_oh_new_binary_unicode_string and qpdf_oh_get_binary_utf8_value
2022-02-04 13:10:51 -05:00
m-holger
1925ffd467
Fix --check-linearization of non-linearized files ( fixes #615 )
2022-02-04 06:52:38 -05:00
m-holger
4d507251fe
Change QPDFExc type to unsupported for /Standard filter
2022-02-02 14:07:32 -06:00
Jay Berkenbilt
42bff9f458
QPDFJob: let initializeFromArgv just take argv, not argc
...
Let argv be a null-terminated array. There is already code that
assumes this, and it makes it easier to construct the arguments.
2022-02-01 13:50:58 -05:00
Jay Berkenbilt
b02d37bc0a
Make QPDFArgParser accept const argv
...
This makes it much more convention to use the initializeFromArgv
functions since you can use string literals.
2022-02-01 13:50:58 -05:00
Jay Berkenbilt
bc4e2320e7
Add qpdfjob-c.h -- simple C API around parts of QPDFJob
2022-02-01 09:04:55 -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
5a7bb3474e
generate_auto_job: generate overloaded config decls for optional
...
For optional parameter/choices, generate an overloaded config method
that takes no arguments. This makes it possible to convert from a bare
argument to one that takes an optional parameter without breaking
binary compatibility.
2022-02-01 09:04:55 -05:00
Jay Berkenbilt
5953116634
Clean up documentation and help around json options
2022-01-31 18:40:11 -05:00
Jay Berkenbilt
606420ab54
Tweak short text for job schema help
2022-01-31 18:26:03 -05:00
Jay Berkenbilt
21b9290785
QPDFJob json: make bare arguments expect the empty string
...
Changing from bool requiring true to string requiring the empty string
is more consistent with the CLI and makes it possible to add an
optional parameter or choices later without breaking compatibility.
2022-01-31 18:16:09 -05:00
Jay Berkenbilt
ea96330bb6
QPDFJob json: flatten json structure
...
Flatten everything to make it easier to map command-line flags to
json. The old structure was an illusion anyway because there was no
mechanism to enforce that things were in the right place. This also
helps with future flexibility.
2022-01-31 18:16:09 -05:00
Jay Berkenbilt
47f33cec25
QPDFJob: add test cases
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
e3506253f1
Add optional version to --json
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
b4fb9b4ec3
Remove outdated comments
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
caa00556cf
Change filename or path to file in json and QPDFJob
...
Use "file" consistently for specifying a file path. We use "filename"
when adding attachments for a completely different purpose.
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
1a3ed1ee85
job json: move deterministic-id into output options
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
81b6314cb5
QPDFJob: fix logic errors in handling arrays
...
The code was assuming everything was happening inside dictionaries.
Instead, make the dictionary key handler creatino explicit only when
iterating through dictionary keys.
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
1355d95d08
QPDFJob: partial mode for initializeFromJson
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
cd30f626fe
QPDFJob: remove from json a few things that only make sense from CLI
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
eeffc69d87
QPDFJob_json: implement handlers for pages
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
fa9676557e
QDPFJob: incorporate change to JSONHandler for array start function
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
3b60224bae
JSONHandler: pass JSON object to array start function
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
b74e7989c3
QPDFJob_json: implement handlers except pages
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
e01bbccb40
QPDFJob: incorporate change to JSONHandler for dict start function
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
ce3406e93f
JSONHandler: pass JSON object to dict start function
...
If some keys depend on others, we have to check up front since there
is no control of what order key handlers will be called. Anyway, keys
are unordered in json, so we don't want to depend on ordering.
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
11a86e444d
QPDFJob: autogenerate json init and declarations
...
Now still have to go through and implement the handlers.
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
842a9d928e
QPDFJob_json: add code to register handlers
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
967a2b9f28
Fix typo in error message
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
a7b0aec2cf
Fix false compiler warning in debug mode
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
28278e27ea
Keep JSONHandler and QPDFArgParser private
...
Since the functionality of argument parsing has moved into QPDFJob,
these classes no longer need to be public. Their methods still have to
be in the library's binary interface so they can be tested in libtests.
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
0f05cae66a
QPDFJob: generate json decl and init file skeletons
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
8a9100f674
QPDFJob: add checkConfiguration to Config
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
0c8e9e5912
QPDFJob: prepare for automatically generated json handlers
2022-01-31 15:57:45 -05:00
Jay Berkenbilt
7eeaf58bb7
More doc tweaks
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
7097f29019
More editorial changes from m-holger + spell check
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
0e909bab8e
Improve top-level help information
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
0364024781
Use QPDFUsage exception for cli, json, and QPDFJob errors
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
f3d68aa5a0
Incorporate editorial changes from m-holger
2022-01-30 13:11:03 -05:00
m-holger
7dd5f31230
Fix typos in manual
...
Fix typos in cli.rst
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
c62ab2ee9f
QPDFJob: use pointers instead of references for Config
...
Why? The main methods that create them return smart pointers so that
users can initialize them when needed, which you can't do with
references. Returning pointers instead of references makes for a more
uniform interface.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
03f3369f35
QPDFJob: use manually named end functions for Config classes
...
Use named functions rather than just end() for clarity.
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
cf6c56a463
QPDFJob: use config API in place-holder json
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
2c7b583b3a
QPDFJob: move input/output handling into config
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
901e3e4fbf
QPDFArgParser: remove unused copyFromOtherTable
...
This was used, but it no longer is, so let's not keep the extra
complexity around.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
700dfa40d3
QPDFJob: convert encryption handlers
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
95d127641c
QPDFJob: move more top-level trivial handlers into config
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
41c5af8f26
QPDFJob: convert pages
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
0a354af02c
QPDFJob: convert AddAttachment handlers
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
bf255ccc89
QPDFJob: convert password in two tables
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
f60526aff9
QPDFJob: start changing generation for trivial config handlers
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
b4b0df0df9
QPDFJob: convert trivial functions to config API
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
160e869d1e
Mark trivial arg functions
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
564dc03607
QPDFJob: start real API
...
Create QPDFJob_options.cc to hold API implementation functions.
Reorganize a little in preparation for moving public member variables
private and creating the real QPDFJob API that will be used by callers
as well as the argv/json initialization methods.
2022-01-30 13:11:03 -05:00
Jay Berkenbilt
1d099ab743
QPDFJob: placeholder for initializeFromJson
2022-01-30 13:11:03 -05:00