mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-23 03:18:59 +00:00
Modify newIndirect to set QPDFObjectHandle::obj
This commit is contained in:
parent
16841bec32
commit
2a2eebcaea
@ -1180,6 +1180,8 @@ class QPDF
|
|||||||
void stopOnError(std::string const& message);
|
void stopOnError(std::string const& message);
|
||||||
QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og);
|
QPDFObjectHandle reserveObjectIfNotExists(QPDFObjGen const& og);
|
||||||
QPDFObjectHandle reserveStream(QPDFObjGen const& og);
|
QPDFObjectHandle reserveStream(QPDFObjGen const& og);
|
||||||
|
QPDFObjectHandle
|
||||||
|
newIndirect(QPDFObjGen const&, std::shared_ptr<QPDFObject> const&);
|
||||||
|
|
||||||
// Calls finish() on the pipeline when done but does not delete it
|
// Calls finish() on the pipeline when done but does not delete it
|
||||||
bool pipeStreamData(
|
bool pipeStreamData(
|
||||||
|
@ -1443,9 +1443,12 @@ class QPDFObjectHandle
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static QPDFObjectHandle
|
static QPDFObjectHandle
|
||||||
newIndirect(QPDF* qpdf, QPDFObjGen const& og)
|
newIndirect(
|
||||||
|
QPDF* qpdf,
|
||||||
|
QPDFObjGen const& og,
|
||||||
|
std::shared_ptr<QPDFObject> const& obj)
|
||||||
{
|
{
|
||||||
return QPDFObjectHandle::newIndirect(qpdf, og);
|
return QPDFObjectHandle(qpdf, og, obj);
|
||||||
}
|
}
|
||||||
static QPDFObjectHandle
|
static QPDFObjectHandle
|
||||||
newStream(
|
newStream(
|
||||||
@ -1557,7 +1560,16 @@ class QPDFObjectHandle
|
|||||||
bool isImage(bool exclude_imagemask = true);
|
bool isImage(bool exclude_imagemask = true);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPDFObjectHandle(QPDF*, QPDFObjGen const& og);
|
QPDFObjectHandle(
|
||||||
|
QPDF* qpdf,
|
||||||
|
QPDFObjGen const& og,
|
||||||
|
std::shared_ptr<QPDFObject> const& obj) :
|
||||||
|
initialized(true),
|
||||||
|
qpdf(qpdf),
|
||||||
|
og(og),
|
||||||
|
obj(obj)
|
||||||
|
{
|
||||||
|
}
|
||||||
QPDFObjectHandle(std::shared_ptr<QPDFObject> const&);
|
QPDFObjectHandle(std::shared_ptr<QPDFObject> const&);
|
||||||
|
|
||||||
// Private object factory methods
|
// Private object factory methods
|
||||||
|
@ -1463,8 +1463,7 @@ QPDF::getAllObjects()
|
|||||||
fixDanglingReferences(true);
|
fixDanglingReferences(true);
|
||||||
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;
|
result.push_back(newIndirect(iter.first, iter.second.object));
|
||||||
result.push_back(getObjectByObjGen(og));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2128,6 +2127,15 @@ QPDF::resolveObjectsInStream(int obj_stream_number)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPDFObjectHandle
|
||||||
|
QPDF::newIndirect(QPDFObjGen const& og, std::shared_ptr<QPDFObject> const& obj)
|
||||||
|
{
|
||||||
|
if (!obj->hasDescription()) {
|
||||||
|
obj->setDescription(this, "object " + og.unparse(' '));
|
||||||
|
}
|
||||||
|
return QPDFObjectHandle::Factory::newIndirect(this, og, obj);
|
||||||
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDF::makeIndirectObject(QPDFObjectHandle oh)
|
QPDF::makeIndirectObject(QPDFObjectHandle oh)
|
||||||
{
|
{
|
||||||
@ -2137,9 +2145,9 @@ QPDF::makeIndirectObject(QPDFObjectHandle oh)
|
|||||||
"max object id is too high to create new objects");
|
"max object id is too high to create new objects");
|
||||||
}
|
}
|
||||||
QPDFObjGen next(max_objid + 1, 0);
|
QPDFObjGen next(max_objid + 1, 0);
|
||||||
this->m->obj_cache[next] =
|
m->obj_cache[next] =
|
||||||
ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);
|
ObjCache(QPDFObjectHandle::ObjAccessor::getObject(oh), -1, -1);
|
||||||
return QPDFObjectHandle::Factory::newIndirect(this, next);
|
return newIndirect(next, m->obj_cache[next].object);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
@ -2148,8 +2156,10 @@ QPDF::reserveObjectIfNotExists(QPDFObjGen const& og)
|
|||||||
if ((!m->obj_cache.count(og)) && (!m->xref_table.count(og))) {
|
if ((!m->obj_cache.count(og)) && (!m->xref_table.count(og))) {
|
||||||
resolve(og);
|
resolve(og);
|
||||||
m->obj_cache[og].object = QPDF_Reserved::create();
|
m->obj_cache[og].object = QPDF_Reserved::create();
|
||||||
|
return newIndirect(og, m->obj_cache[og].object);
|
||||||
|
} else {
|
||||||
|
return getObject(og);
|
||||||
}
|
}
|
||||||
return getObject(og);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
@ -2162,7 +2172,8 @@ QPDF::reserveStream(QPDFObjGen const& og)
|
|||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDF::getObject(QPDFObjGen const& og)
|
QPDF::getObject(QPDFObjGen const& og)
|
||||||
{
|
{
|
||||||
return QPDFObjectHandle::Factory::newIndirect(this, og);
|
auto obj = (og.getObj() != 0) ? resolve(og) : QPDF_Null::create();
|
||||||
|
return newIndirect(og, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <qpdf/QPDF_Reserved.hh>
|
#include <qpdf/QPDF_Reserved.hh>
|
||||||
#include <qpdf/QPDF_Stream.hh>
|
#include <qpdf/QPDF_Stream.hh>
|
||||||
#include <qpdf/QPDF_String.hh>
|
#include <qpdf/QPDF_String.hh>
|
||||||
|
#include <qpdf/QPDF_Unresolved.hh>
|
||||||
#include <qpdf/SparseOHArray.hh>
|
#include <qpdf/SparseOHArray.hh>
|
||||||
|
|
||||||
#include <qpdf/QIntC.hh>
|
#include <qpdf/QIntC.hh>
|
||||||
@ -240,13 +241,6 @@ QPDFObjectHandle::QPDFObjectHandle() :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, QPDFObjGen const& og) :
|
|
||||||
initialized(true),
|
|
||||||
qpdf(qpdf),
|
|
||||||
og(og)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) :
|
QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) :
|
||||||
initialized(true),
|
initialized(true),
|
||||||
qpdf(nullptr),
|
qpdf(nullptr),
|
||||||
@ -1953,7 +1947,7 @@ QPDFObjectHandle::newIndirect(QPDF* qpdf, QPDFObjGen const& og)
|
|||||||
return newNull();
|
return newNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
return QPDFObjectHandle(qpdf, og);
|
return QPDFObjectHandle(qpdf, og, QPDF_Unresolved::create());
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
@ -2553,10 +2547,11 @@ QPDFObjectHandle::dereference()
|
|||||||
if (!this->initialized) {
|
if (!this->initialized) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this->obj() == nullptr ||
|
if ((this->obj->getTypeCode() == QPDFObject::ot_unresolved) ||
|
||||||
(getObjectID() &&
|
(getObjectID() &&
|
||||||
QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj))) {
|
QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj))) {
|
||||||
obj = QPDF::Resolver::resolve(this->qpdf, getObjGen());
|
this->obj = QPDF::Resolver::resolve(this->qpdf, getObjGen());
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user