mirror of
https://github.com/qpdf/qpdf.git
synced 2025-02-07 06:08:26 +00:00
Remove QPDFObjectHandle::newIndirect
Modify QPDFParser::parse to call QPDF::getObject instead.
This commit is contained in:
parent
c5d0428da2
commit
356b582cec
@ -1592,7 +1592,6 @@ class QPDFObjectHandle
|
||||
QPDFObjectHandle(std::shared_ptr<QPDFObject> const&);
|
||||
|
||||
// Private object factory methods
|
||||
static QPDFObjectHandle newIndirect(QPDF*, QPDFObjGen const& og);
|
||||
static QPDFObjectHandle newStream(
|
||||
QPDF* qpdf,
|
||||
QPDFObjGen const& og,
|
||||
|
@ -64,7 +64,9 @@ class QPDFValue
|
||||
void
|
||||
setParsedOffset(qpdf_offset_t offset)
|
||||
{
|
||||
parsed_offset = offset;
|
||||
if (parsed_offset < 0) {
|
||||
parsed_offset = offset;
|
||||
}
|
||||
}
|
||||
qpdf_offset_t
|
||||
getParsedOffset()
|
||||
|
@ -2002,20 +2002,6 @@ QPDFObjectHandle::getParsedOffset()
|
||||
}
|
||||
}
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDFObjectHandle::newIndirect(QPDF* qpdf, QPDFObjGen const& og)
|
||||
{
|
||||
if (!og.isIndirect()) {
|
||||
// Special case: QPDF uses objid 0 as a sentinel for direct
|
||||
// objects, and the PDF specification doesn't allow for object
|
||||
// 0. Treat indirect references to object 0 as null so that we
|
||||
// never create an indirect object with objid 0.
|
||||
QTC::TC("qpdf", "QPDFObjectHandle indirect with 0 objid");
|
||||
return newNull();
|
||||
}
|
||||
return QPDFObjectHandle(qpdf, og, QPDF_Unresolved::create());
|
||||
}
|
||||
|
||||
QPDFObjectHandle
|
||||
QPDFObjectHandle::newBool(bool value)
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <qpdf/QPDFParser.hh>
|
||||
|
||||
#include <qpdf/QPDF.hh>
|
||||
#include <qpdf/QPDFObjGen.hh>
|
||||
#include <qpdf/QPDFObjectHandle.hh>
|
||||
#include <qpdf/QPDF_Array.hh>
|
||||
#include <qpdf/QTC.hh>
|
||||
#include <qpdf/QUtil.hh>
|
||||
|
||||
@ -55,6 +55,7 @@ QPDFParser::parse(bool& empty, bool content_stream)
|
||||
|
||||
while (!done) {
|
||||
bool bad = false;
|
||||
bool indirect_ref = false;
|
||||
is_null = false;
|
||||
auto& frame = stack.back();
|
||||
auto& olist = frame.olist;
|
||||
@ -185,12 +186,16 @@ QPDFParser::parse(bool& empty, bool content_stream)
|
||||
"QPDFObjectHandle::parse called without context"
|
||||
" on an object with indirect references");
|
||||
}
|
||||
// Try to resolve indirect objects
|
||||
object = QPDFObjectHandle::newIndirect(
|
||||
context,
|
||||
QPDFObjGen(
|
||||
olist.at(size - 2).getIntValueAsInt(),
|
||||
olist.back().getIntValueAsInt()));
|
||||
auto ref_og = QPDFObjGen(
|
||||
olist.at(size - 2).getIntValueAsInt(),
|
||||
olist.back().getIntValueAsInt());
|
||||
if (ref_og.isIndirect()) {
|
||||
object = context->getObject(ref_og);
|
||||
indirect_ref = true;
|
||||
} else {
|
||||
QTC::TC("qpdf", "QPDFParser indirect with 0 objid");
|
||||
is_null = true;
|
||||
}
|
||||
olist.pop_back();
|
||||
olist.pop_back();
|
||||
} else if ((value == "endobj") && (state == st_top)) {
|
||||
@ -274,8 +279,8 @@ QPDFParser::parse(bool& empty, bool content_stream)
|
||||
|
||||
case st_dictionary:
|
||||
case st_array:
|
||||
if (!object.isDirectNull()) {
|
||||
// No need to set description for direct nulls- they will
|
||||
if (!indirect_ref && !object.isDirectNull()) {
|
||||
// No need to set description for direct nulls - they will
|
||||
// become implicit.
|
||||
setDescriptionFromInput(object, input->getLastOffset());
|
||||
object.setParsedOffset(input->getLastOffset());
|
||||
|
@ -254,7 +254,7 @@ QPDFWriter standard deterministic ID 1
|
||||
QPDFWriter linearized deterministic ID 1
|
||||
QPDFWriter deterministic with no data 0
|
||||
qpdf-c called qpdf_set_deterministic_ID 0
|
||||
QPDFObjectHandle indirect with 0 objid 0
|
||||
QPDFParser indirect with 0 objid 0
|
||||
QPDF object id 0 0
|
||||
QPDF recursion loop in resolve 0
|
||||
QPDFParser treat word as string 0
|
||||
|
Loading…
x
Reference in New Issue
Block a user