2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-06 04:10:52 +00:00
Commit Graph

402 Commits

Author SHA1 Message Date
m-holger
4490d4c35e Avoid unnecessary copying of stream dictionary in QPDF::readObject 2023-06-05 21:22:40 +01:00
m-holger
3c5700c255 Code tidy - reflow comments and strings 2023-06-02 16:00:40 +01:00
m-holger
698a70e6a8 Code tidy - reflow comments and strings 2023-05-27 10:54:19 +01:00
Jay Berkenbilt
60965d5f4d Rerun clang-format 2023-05-21 13:35:09 -04:00
m-holger
49e6365f63 Replace 'this->m' with 'm'
Manual edits for cases not handled by search and replace
2023-05-21 14:52:24 +01:00
m-holger
85d784952f Globally replace 'this->m->' with 'm->'
Using search and replace.
2023-05-21 14:42:34 +01:00
m-holger
05a49cecf1 Add new method QPDF::newReserved 2023-05-20 19:56:01 +01:00
Jay Berkenbilt
a85635b839
Merge pull request #929 from m-holger/ogguard
Add new convenience class QPDFObjGen::Guard
2023-05-20 14:09:49 -04:00
m-holger
e6577a1323 Replace 'virtual' specifier with 'override' 2023-05-20 15:41:56 +01:00
m-holger
ba5a3567a2 Remove redundant 'virtual' specifiers 2023-05-20 15:41:52 +01:00
m-holger
774d0d558e Use auto when declaring iterators 2023-05-20 15:41:48 +01:00
m-holger
41ec7eda54 Use auto when initialializing with new 2023-05-20 15:41:40 +01:00
m-holger
e28f4efb00 Replace deprecated C++ includes 2023-05-20 15:41:25 +01:00
m-holger
5473c0956c Use QPDFObjGen::set in QPDF::replaceForeignIndirectObjects 2023-05-19 18:52:48 +01:00
m-holger
aeb66311c2 Use QPDFObjGen::set in QPDF::getCompressibleObjGens 2023-05-19 18:49:41 +01:00
m-holger
08d7b56746 Prevent destruction of shared null objects
#863 uses a single null object for nulls that were previously implicit. In
certain circumstances this shared null object gets destroyed (i.e changed
to a QPDF_Destroyed object) when a QPDF object is destroyed.

Modify the QPDF destructor so that null objects get disconnected from the
dying QPDF object but not destroyed to prevent this from happening.
2023-04-11 18:01:14 +01:00
Jay Berkenbilt
40e4d1f97c
Merge pull request #930 from m-holger/throw
Code tidy re-throwing of exceptions
2023-04-01 09:42:52 -04:00
m-holger
d8acccd5c8 Warn if catalog type entry is invalid (fixes #810) 2023-03-19 20:07:53 +00:00
m-holger
9c7aa2cbbd Code tidy re-throwing of exceptions
Avoid copying exceptions.
2023-03-19 17:27:39 +00:00
Jay Berkenbilt
088fabd9b9 Move most QPDF initializations to header 2023-02-18 19:38:37 -05:00
Jay Berkenbilt
1308c45090 Implement --remove-restrictions (fixes #833) 2023-01-28 13:42:19 -05:00
m-holger
e8cdc46286 Tidy QPDFXRefEntry creation 2023-01-21 18:18:15 -05:00
m-holger
d7b470761b Remove QPDFObjectHandle::Factory and ObjAccessor 2022-12-31 19:16:38 -05:00
m-holger
218f069a69 Add new method QPDFObject::setDefaultDescription 2022-12-31 10:23:59 -05:00
m-holger
cfcb279e49 Alternative fix logic for fixDanglingReferences 2022-12-06 15:21:34 -05:00
Jay Berkenbilt
ff42ea4e6c Fix logic for fixDanglingReferences 2022-11-26 18:13:46 -05:00
m-holger
3f632458ae Refactor QPDF::fixDanglingReferences 2022-11-26 16:26:42 -05:00
Jay Berkenbilt
562ff1b608 Rename function for pikepdf (for 11.2.0)
A new private overload of QPDF::makeIndirectObject breaks pikepdf's
build, so renaming function.
2022-11-20 16:04:58 -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
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
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
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
0ad4e190ff Make QPDFLogger() private and provide create method 2022-09-09 07:03:29 -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
0132261ee0 Revert getOwningQPDF, and add getQPDF that returns a reference 2022-09-07 17:26:39 -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
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
a59e7ac7ec Disable copying/assigning to QPDF objects, add QPDF::create() 2022-09-02 08:53:27 -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
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
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
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
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
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
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
bd300be08d Replace calls to QPDFObjectHandle::Factory::newIndirect where possible 2022-08-31 22:45:45 +01: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
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
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
073808aa50 Code tidy : replace 0 with nullptr or true 2022-07-26 13:40:13 +01: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
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
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
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
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
641e92c6a7 QPDF, QPDFJob: use QPDFLogger instead of custom output streams 2022-06-18 09:02:55 -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
47c093c48b Replace std::regex with validators for better performance 2022-05-21 08:43:21 -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
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
e5f3910c3e Add new FileInputSource constructors 2022-05-04 12:07:11 -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
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
ab9d557cb0 Use fluent replaceKey 2022-04-29 20:39:54 -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
75fe4f60c3 Use anonymous namespaces for file-private classes 2022-04-16 13:35:27 -04:00
Jay Berkenbilt
cdd0b4fb7d Use = default and = delete where possible in classes 2022-04-16 11:39:14 -04:00