mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-23 03:18:59 +00:00
QPDFObjGen : tidy QPDFObjectHandle private methods
Change method signature to use QPDFObjGen.
This commit is contained in:
parent
b123f79dfd
commit
3404ca8ac8
@ -1429,21 +1429,20 @@ class QPDFObjectHandle
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static QPDFObjectHandle
|
static QPDFObjectHandle
|
||||||
newIndirect(QPDF* qpdf, int objid, int generation)
|
newIndirect(QPDF* qpdf, QPDFObjGen const& og)
|
||||||
{
|
{
|
||||||
return QPDFObjectHandle::newIndirect(qpdf, objid, generation);
|
return QPDFObjectHandle::newIndirect(qpdf, og);
|
||||||
}
|
}
|
||||||
static QPDFObjectHandle
|
static QPDFObjectHandle
|
||||||
newStream(
|
newStream(
|
||||||
QPDF* qpdf,
|
QPDF* qpdf,
|
||||||
int objid,
|
QPDFObjGen const& og,
|
||||||
int generation,
|
|
||||||
QPDFObjectHandle stream_dict,
|
QPDFObjectHandle stream_dict,
|
||||||
qpdf_offset_t offset,
|
qpdf_offset_t offset,
|
||||||
size_t length)
|
size_t length)
|
||||||
{
|
{
|
||||||
return QPDFObjectHandle::newStream(
|
return QPDFObjectHandle::newStream(
|
||||||
qpdf, objid, generation, stream_dict, offset, length);
|
qpdf, og, stream_dict, offset, length);
|
||||||
}
|
}
|
||||||
// Reserve an object with a specific ID
|
// Reserve an object with a specific ID
|
||||||
static QPDFObjectHandle
|
static QPDFObjectHandle
|
||||||
@ -1563,11 +1562,10 @@ class QPDFObjectHandle
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Private object factory methods
|
// Private object factory methods
|
||||||
static QPDFObjectHandle newIndirect(QPDF*, int objid, int generation);
|
static QPDFObjectHandle newIndirect(QPDF*, QPDFObjGen const& og);
|
||||||
static QPDFObjectHandle newStream(
|
static QPDFObjectHandle newStream(
|
||||||
QPDF* qpdf,
|
QPDF* qpdf,
|
||||||
int objid,
|
QPDFObjGen const& og,
|
||||||
int generation,
|
|
||||||
QPDFObjectHandle stream_dict,
|
QPDFObjectHandle stream_dict,
|
||||||
qpdf_offset_t offset,
|
qpdf_offset_t offset,
|
||||||
size_t length);
|
size_t length);
|
||||||
|
@ -1404,9 +1404,8 @@ QPDF::fixDanglingReferences(bool force)
|
|||||||
// For each non-scalar item to process, put it in the queue.
|
// For each non-scalar item to process, put it in the queue.
|
||||||
std::list<QPDFObjectHandle> queue;
|
std::list<QPDFObjectHandle> queue;
|
||||||
queue.push_back(this->m->trailer);
|
queue.push_back(this->m->trailer);
|
||||||
for (auto const& iter: to_process) {
|
for (auto const& og: to_process) {
|
||||||
QPDFObjectHandle obj = QPDFObjectHandle::Factory::newIndirect(
|
QPDFObjectHandle obj = QPDFObjectHandle::Factory::newIndirect(this, og);
|
||||||
this, iter.getObj(), iter.getGen());
|
|
||||||
if (obj.isDictionary() || obj.isArray()) {
|
if (obj.isDictionary() || obj.isArray()) {
|
||||||
queue.push_back(obj);
|
queue.push_back(obj);
|
||||||
} else if (obj.isStream()) {
|
} else if (obj.isStream()) {
|
||||||
@ -1472,10 +1471,7 @@ QPDF::getAllObjects()
|
|||||||
std::vector<QPDFObjectHandle> result;
|
std::vector<QPDFObjectHandle> result;
|
||||||
for (auto const& iter: this->m->obj_cache) {
|
for (auto const& iter: this->m->obj_cache) {
|
||||||
QPDFObjGen const& og = iter.first;
|
QPDFObjGen const& og = iter.first;
|
||||||
result.push_back(
|
result.push_back(QPDFObjectHandle::Factory::newIndirect(this, og));
|
||||||
// line-break
|
|
||||||
QPDFObjectHandle::Factory::newIndirect(
|
|
||||||
this, og.getObj(), og.getGen()));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1662,7 +1658,11 @@ QPDF::readObject(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
object = QPDFObjectHandle::Factory::newStream(
|
object = QPDFObjectHandle::Factory::newStream(
|
||||||
this, objid, generation, object, stream_offset, length);
|
this,
|
||||||
|
QPDFObjGen(objid, generation),
|
||||||
|
object,
|
||||||
|
stream_offset,
|
||||||
|
length);
|
||||||
} else {
|
} else {
|
||||||
input->seek(cur_offset, SEEK_SET);
|
input->seek(cur_offset, SEEK_SET);
|
||||||
}
|
}
|
||||||
@ -2159,8 +2159,7 @@ QPDF::makeIndirectObject(QPDFObjectHandle oh)
|
|||||||
QPDFObjGen next(max_objid + 1, 0);
|
QPDFObjGen next(max_objid + 1, 0);
|
||||||
this->m->obj_cache[next] =
|
this->m->obj_cache[next] =
|
||||||
ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);
|
ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);
|
||||||
return QPDFObjectHandle::Factory::newIndirect(
|
return QPDFObjectHandle::Factory::newIndirect(this, next);
|
||||||
this, next.getObj(), next.getGen());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
@ -2178,19 +2177,19 @@ QPDFObjectHandle
|
|||||||
QPDF::reserveStream(int objid, int gen)
|
QPDF::reserveStream(int objid, int gen)
|
||||||
{
|
{
|
||||||
return QPDFObjectHandle::Factory::newStream(
|
return QPDFObjectHandle::Factory::newStream(
|
||||||
this, objid, gen, QPDFObjectHandle::newDictionary(), 0, 0);
|
this, QPDFObjGen(objid, gen), QPDFObjectHandle::newDictionary(), 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDF::getObjectByObjGen(QPDFObjGen const& og)
|
QPDF::getObjectByObjGen(QPDFObjGen const& og)
|
||||||
{
|
{
|
||||||
return getObjectByID(og.getObj(), og.getGen());
|
return QPDFObjectHandle::Factory::newIndirect(this, og);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDF::getObjectByID(int objid, int generation)
|
QPDF::getObjectByID(int objid, int generation)
|
||||||
{
|
{
|
||||||
return QPDFObjectHandle::Factory::newIndirect(this, objid, generation);
|
return getObjectByObjGen(QPDFObjGen(objid, generation));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2180,8 +2180,9 @@ QPDFObjectHandle::parseInternal(
|
|||||||
// Try to resolve indirect objects
|
// Try to resolve indirect objects
|
||||||
object = newIndirect(
|
object = newIndirect(
|
||||||
context,
|
context,
|
||||||
olist.at(olist.size() - 2).getIntValueAsInt(),
|
QPDFObjGen(
|
||||||
olist.at(olist.size() - 1).getIntValueAsInt());
|
olist.at(olist.size() - 2).getIntValueAsInt(),
|
||||||
|
olist.at(olist.size() - 1).getIntValueAsInt()));
|
||||||
olist.remove_last();
|
olist.remove_last();
|
||||||
olist.remove_last();
|
olist.remove_last();
|
||||||
} else if ((value == "endobj") && (state == st_top)) {
|
} else if ((value == "endobj") && (state == st_top)) {
|
||||||
@ -2469,9 +2470,9 @@ QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDFObjectHandle::newIndirect(QPDF* qpdf, int objid, int generation)
|
QPDFObjectHandle::newIndirect(QPDF* qpdf, QPDFObjGen const& og)
|
||||||
{
|
{
|
||||||
if (objid == 0) {
|
if (!og.isIndirect()) {
|
||||||
// Special case: QPDF uses objid 0 as a sentinel for direct
|
// Special case: QPDF uses objid 0 as a sentinel for direct
|
||||||
// objects, and the PDF specification doesn't allow for object
|
// objects, and the PDF specification doesn't allow for object
|
||||||
// 0. Treat indirect references to object 0 as null so that we
|
// 0. Treat indirect references to object 0 as null so that we
|
||||||
@ -2480,7 +2481,7 @@ QPDFObjectHandle::newIndirect(QPDF* qpdf, int objid, int generation)
|
|||||||
return newNull();
|
return newNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPDFObjectHandle(qpdf, QPDFObjGen(objid, generation));
|
return QPDFObjectHandle(qpdf, og);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
@ -2628,14 +2629,13 @@ QPDFObjectHandle::newDictionary(
|
|||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDFObjectHandle::newStream(
|
QPDFObjectHandle::newStream(
|
||||||
QPDF* qpdf,
|
QPDF* qpdf,
|
||||||
int objid,
|
QPDFObjGen const& og,
|
||||||
int generation,
|
|
||||||
QPDFObjectHandle stream_dict,
|
QPDFObjectHandle stream_dict,
|
||||||
qpdf_offset_t offset,
|
qpdf_offset_t offset,
|
||||||
size_t length)
|
size_t length)
|
||||||
{
|
{
|
||||||
QPDFObjectHandle result = QPDFObjectHandle(QPDF_Stream::create(
|
QPDFObjectHandle result = QPDFObjectHandle(QPDF_Stream::create(
|
||||||
qpdf, objid, generation, stream_dict, offset, length));
|
qpdf, og.getObj(), og.getGen(), stream_dict, offset, length));
|
||||||
if (offset) {
|
if (offset) {
|
||||||
result.setParsedOffset(offset);
|
result.setParsedOffset(offset);
|
||||||
}
|
}
|
||||||
@ -2683,8 +2683,7 @@ QPDFObjectHandle::newReserved(QPDF* qpdf)
|
|||||||
// Reserve a spot for this object by assigning it an object
|
// Reserve a spot for this object by assigning it an object
|
||||||
// number, but then return an unresolved handle to the object.
|
// number, but then return an unresolved handle to the object.
|
||||||
QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved());
|
QPDFObjectHandle reserved = qpdf->makeIndirectObject(makeReserved());
|
||||||
QPDFObjectHandle result =
|
QPDFObjectHandle result = newIndirect(qpdf, reserved.getObjGen());
|
||||||
newIndirect(qpdf, reserved.getObjectID(), reserved.getGeneration());
|
|
||||||
result.reserved = true;
|
result.reserved = true;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ QPDF::isLinearized()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle candidate =
|
QPDFObjectHandle candidate =
|
||||||
QPDFObjectHandle::Factory::newIndirect(this, lindict_obj, 0);
|
QPDFObjectHandle::Factory::newIndirect(this, QPDFObjGen(lindict_obj));
|
||||||
if (!candidate.isDictionary()) {
|
if (!candidate.isDictionary()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user