diff options
author | Jay Berkenbilt <ejb@ql.org> | 2020-12-25 15:50:55 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2020-12-28 18:58:19 +0100 |
commit | 1a62cce94012e05e25e81dd7016766d9d039281d (patch) | |
tree | 6cd0383118701eb18bd09241d22421b38409e2f7 /include/qpdf | |
parent | 09027344b9a6265a597da7c3c92e0fdd3ccb71fb (diff) | |
download | qpdf-1a62cce94012e05e25e81dd7016766d9d039281d.tar.zst |
Restructure optimize to allow skipping parameters of filtered streams
Diffstat (limited to 'include/qpdf')
-rw-r--r-- | include/qpdf/QPDF.hh | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/include/qpdf/QPDF.hh b/include/qpdf/QPDF.hh index b0e9b717..a6f49b4b 100644 --- a/include/qpdf/QPDF.hh +++ b/include/qpdf/QPDF.hh @@ -564,16 +564,28 @@ class QPDF // QPDF_optimization.cc // The object_stream_data map maps from a "compressed" object to - // the object stream that contains it. This enables optimize to + // the object stream that contains it. This enables optimize to // populate the object <-> user maps with only uncompressed - // objects. If allow_changes is false, an exception will be - // thrown if any changes are made during the optimization process. - // This is available so that the test suite can make sure that a - // linearized file is already optimized. When called in this way, - // optimize() still populates the object <-> user maps + // objects. If allow_changes is false, an exception will be thrown + // if any changes are made during the optimization process. This + // is available so that the test suite can make sure that a + // linearized file is already optimized. When called in this way, + // optimize() still populates the object <-> user maps. The + // optional skip_stream_parameters parameter, if present, is + // called for each stream object. The function should return 2 if + // optimization should discard /Length, /Filter, and /DecodeParms; + // 1 if it should discard /Length, and 0 if it should preserve all + // keys. This is used by QPDFWriter to avoid creation of dangling + // objects for stream dictionary keys it will be regenerating. QPDF_DLL void optimize(std::map<int, int> const& object_stream_data, bool allow_changes = true); + // ABI: make function optional and merge overloaded versions + QPDF_DLL + void optimize( + std::map<int, int> const& object_stream_data, + bool allow_changes, + std::function<int(QPDFObjectHandle&)> skip_stream_parameters); // Traverse page tree return all /Page objects. It also detects // and resolves cases in which the same /Page object is @@ -1356,10 +1368,14 @@ class QPDF std::vector<QPDFObjectHandle>& all_pages, bool allow_changes, bool warn_skipped_keys, std::set<QPDFObjGen>& visited); - void updateObjectMaps(ObjUser const& ou, QPDFObjectHandle oh); - void updateObjectMapsInternal(ObjUser const& ou, QPDFObjectHandle oh, - std::set<QPDFObjGen>& visited, bool top, - int depth); + void updateObjectMaps( + ObjUser const& ou, QPDFObjectHandle oh, + std::function<int(QPDFObjectHandle&)> skip_stream_parameters); + void updateObjectMapsInternal( + ObjUser const& ou, QPDFObjectHandle oh, + std::function<int(QPDFObjectHandle&)> skip_stream_parameters, + std::set<QPDFObjGen>& visited, bool top, + int depth); void filterCompressedObjects(std::map<int, int> const& object_stream_data); // Type conversion helper methods |