mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 10:58:58 +00:00
Tune QPDF::readObjectInStream
This commit is contained in:
parent
aabd3f6f9b
commit
5754ab8b39
@ -1010,7 +1010,7 @@ class QPDF
|
||||
QPDFObjectHandle readObject(std::string const& description, QPDFObjGen og);
|
||||
void readStream(QPDFObjectHandle& object, QPDFObjGen og, qpdf_offset_t offset);
|
||||
void validateStreamLineEnd(QPDFObjectHandle& object, QPDFObjGen og, qpdf_offset_t offset);
|
||||
QPDFObjectHandle readObjectInStream(std::shared_ptr<InputSource>, QPDFObjGen og);
|
||||
QPDFObjectHandle readObjectInStream(std::shared_ptr<InputSource>& input, int obj);
|
||||
size_t recoverStreamLength(
|
||||
std::shared_ptr<InputSource> input, QPDFObjGen const& og, qpdf_offset_t stream_offset);
|
||||
QPDFTokenizer::Token readToken(std::shared_ptr<InputSource>, size_t max_len = 0);
|
||||
|
@ -1413,10 +1413,11 @@ QPDF::validateStreamLineEnd(QPDFObjectHandle& object, QPDFObjGen og, qpdf_offset
|
||||
}
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDF::readObjectInStream(std::shared_ptr<InputSource> input, QPDFObjGen og)
|
||||
QPDF::readObjectInStream(std::shared_ptr<InputSource>& input, int obj)
|
||||
{
|
||||
setLastObjectDescription("", og);
|
||||
qpdf_offset_t offset = input->tell();
|
||||
m->last_object_description.erase(7); // last_object_description starts with "object "
|
||||
m->last_object_description += std::to_string(obj);
|
||||
m->last_object_description += " 0";
|
||||
|
||||
bool empty = false;
|
||||
auto object = QPDFParser(input, m->last_object_description, m->tokenizer, nullptr, this)
|
||||
@ -1426,9 +1427,6 @@ QPDF::readObjectInStream(std::shared_ptr<InputSource> input, QPDFObjGen og)
|
||||
// actual PDF files and Adobe Reader appears to ignore them.
|
||||
warn(damagedPDF(input, input->getLastOffset(), "empty object treated as null"));
|
||||
}
|
||||
|
||||
// Override last_offset so that it points to the beginning of the object we just read
|
||||
input->setLastOffset(offset);
|
||||
return object;
|
||||
}
|
||||
|
||||
@ -1787,13 +1785,15 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
|
||||
// found here in the cache. Remember that some objects stored here might have been overridden
|
||||
// by new objects appended to the file, so it is necessary to recheck the xref table and only
|
||||
// cache what would actually be resolved here.
|
||||
m->last_object_description.clear();
|
||||
m->last_object_description += "object ";
|
||||
for (auto const& iter: offsets) {
|
||||
QPDFObjGen og(iter.first, 0);
|
||||
QPDFXRefEntry const& entry = m->xref_table[og];
|
||||
if ((entry.getType() == 2) && (entry.getObjStreamNumber() == obj_stream_number)) {
|
||||
int offset = iter.second;
|
||||
input->seek(offset, SEEK_SET);
|
||||
QPDFObjectHandle oh = readObjectInStream(input, og);
|
||||
QPDFObjectHandle oh = readObjectInStream(input, iter.first);
|
||||
updateCache(og, oh.getObj(), end_before_space, end_after_space);
|
||||
} else {
|
||||
QTC::TC("qpdf", "QPDF not caching overridden objstm object");
|
||||
|
Loading…
Reference in New Issue
Block a user