2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-09-28 04:59:05 +00:00
Commit Graph

1419 Commits

Author SHA1 Message Date
m-holger
d7b8525235 Refactor QPDFObjectHandle::unsafeShallowCopy 2022-11-20 12:07:22 -05:00
m-holger
0289b21c3b Remove redundant QPDFObjectHandle::copyObject2
copyObject2 repeats a second time what
new_obj = QPDFObjectHandle(obj->copy(true))
in shallowCopyInternal2 already did.
2022-11-20 12:07:22 -05:00
m-holger
15e8d3a763 Remove redundant parameter first_level_only from QPDFObjectHandle::shallowCopyInternal2 and copyObject2 2022-11-20 12:07:22 -05:00
m-holger
0827b1096e Remove redundant parameters cross_indirect and stop_atstreams from QPDFObjectHandle::copyObject2 2022-11-20 12:07:22 -05:00
m-holger
63d1dcb414 Split QPDFObjectHandle::shallowCopyInternal and copyObject
Have separate versions for unsafeShallowCopy, shallowCopy and makeDirect.
2022-11-20 12:07:22 -05:00
m-holger
dbc5f07b90 Rename QPDFObject::shallowCopy to copy
Add optional parameter shallow. Change logic errors to runtime errors.
2022-11-20 12:07:22 -05:00
m-holger
34a6f8938f Add methods QPDFTokenizer::Token::isWord 2022-11-20 11:55:02 -05:00
m-holger
dca70f13e7 Add method QPDFTokenizer::Token::isInteger 2022-11-20 11:55:02 -05:00
Jay Berkenbilt
e9980efec8 Correctly handle reuse of xref stream (fixes #809) 2022-11-19 17:03:17 -05:00
m-holger
d79a823d66 Remove QPDF_Stream::getOffset and QPDF_Stream::setObjGen 2022-11-19 14:10:42 -05:00
m-holger
6350cf16e6 Remove QPDF_Stream::offset 2022-11-19 14:10:42 -05:00
m-holger
3a86b893f7 Remove redundant parameters from QPDF_Stream::warn 2022-11-19 14:10:42 -05:00
m-holger
69e67b45bb Remove QPDF_Stream qpdf and og data members 2022-11-19 14:10:42 -05:00
m-holger
bf347dfb73 Remove QPDFObjectHandle::Factory::newStream 2022-11-19 14:10:42 -05:00
m-holger
743a735ee0 Use QPDF::newStream in library 2022-11-19 14:10:42 -05:00
m-holger
9ebabd1953 Add new methods QPDF::newStream 2022-11-19 14:10:42 -05:00
m-holger
0a3c533186 Add private method QPDF::nextObjGen 2022-11-19 14:10:42 -05:00
m-holger
b3d71e1f58 Add private overload of QPDF::makeIndirectObject taking a QPDFObject shared_ptr 2022-11-19 14:10:42 -05:00
m-holger
fc64d0a371 Fix stray formatting error 2022-11-14 07:05:58 -05:00
Jay Berkenbilt
d94e6958ef Fix stray formatting error 2022-10-08 17:05:11 -04:00
Jay Berkenbilt
2bc9121fa1 Fix major performance bug with openssl crypto (fixes #798)
Lazily load MD5 and RC4 once in the life of the program. Only load the
legacy provider if RC4 is actually being used.
2022-10-08 17:04:59 -04:00
Jay Berkenbilt
5c5b4e640e Be more conservative about QPDF_DLL_CLASS with mingw (fixes #799)
* Define it even though previous experiments have shown it to be
  unnecessary since it seems like it may be necessary after all
* Add QPDF_DLL_CLASS to QPDFObjectHelper and QPDFDocumentHelper in
  case there's some future unknown reason why someone may want to have
  them and/or in case it helps with the weird
  QPDFNameTreeObjectHelper problem.
2022-10-06 08:40:08 -04:00
m-holger
d44bba3914 Fix typos in error message 2022-10-03 11:42:27 -04:00
m-holger
c63fb86c01 Inline call to QPDFObjectHandle::parse in QPDF::readObject 2022-10-01 11:17:39 -04:00
m-holger
cb0a6be983 Code tidy: use QPDF::toS and QPDF::toI where possible 2022-10-01 11:17:39 -04:00
m-holger
5ccab4be03 Add private methods QPDF::damagedPDF 2022-10-01 11:17:39 -04:00
Jay Berkenbilt
f4ca04cec1 Fix edge case in character encoding (fixes #778)
Avoid representing as PDF Doc encoding any string whose PDF Doc
encoding representation starts with a UTF-16 or UTF-8 marker.
2022-09-26 08:06:47 -04:00
m-holger
4fb7d1335a Tune QPDF_String::useHexString() 2022-09-24 17:09:56 -04:00
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