mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
Add QPDF::getObject to replace getObjectByObjGen and getObjectByID
For consistency with similar methods, e.g. replaceObject.
This commit is contained in:
parent
a9c0b02668
commit
1553868c4a
@ -385,6 +385,10 @@ class QPDF
|
|||||||
// Retrieve an object by object ID and generation. Returns an
|
// Retrieve an object by object ID and generation. Returns an
|
||||||
// indirect reference to it.
|
// indirect reference to it.
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
|
QPDFObjectHandle getObject(QPDFObjGen const&);
|
||||||
|
QPDF_DLL
|
||||||
|
QPDFObjectHandle getObject(int objid, int generation);
|
||||||
|
QPDF_DLL
|
||||||
QPDFObjectHandle getObjectByObjGen(QPDFObjGen const&);
|
QPDFObjectHandle getObjectByObjGen(QPDFObjGen const&);
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
QPDFObjectHandle getObjectByID(int objid, int generation);
|
QPDFObjectHandle getObjectByID(int objid, int generation);
|
||||||
|
@ -2148,7 +2148,7 @@ QPDF::reserveObjectIfNotExists(QPDFObjGen const& og)
|
|||||||
resolve(og);
|
resolve(og);
|
||||||
replaceObject(og, QPDFObjectHandle::Factory::makeReserved());
|
replaceObject(og, QPDFObjectHandle::Factory::makeReserved());
|
||||||
}
|
}
|
||||||
return getObjectByObjGen(og);
|
return getObject(og);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
@ -2159,15 +2159,27 @@ QPDF::reserveStream(QPDFObjGen const& og)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDF::getObjectByObjGen(QPDFObjGen const& og)
|
QPDF::getObject(QPDFObjGen const& og)
|
||||||
{
|
{
|
||||||
return QPDFObjectHandle::Factory::newIndirect(this, og);
|
return QPDFObjectHandle::Factory::newIndirect(this, og);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPDFObjectHandle
|
||||||
|
QPDF::getObject(int objid, int generation)
|
||||||
|
{
|
||||||
|
return getObject(QPDFObjGen(objid, generation));
|
||||||
|
}
|
||||||
|
|
||||||
|
QPDFObjectHandle
|
||||||
|
QPDF::getObjectByObjGen(QPDFObjGen const& og)
|
||||||
|
{
|
||||||
|
return getObject(og);
|
||||||
|
}
|
||||||
|
|
||||||
QPDFObjectHandle
|
QPDFObjectHandle
|
||||||
QPDF::getObjectByID(int objid, int generation)
|
QPDF::getObjectByID(int objid, int generation)
|
||||||
{
|
{
|
||||||
return getObjectByObjGen(QPDFObjGen(objid, generation));
|
return getObject(QPDFObjGen(objid, generation));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -183,7 +183,7 @@ QPDFAcroFormDocumentHelper::getFormFields()
|
|||||||
analyze();
|
analyze();
|
||||||
std::vector<QPDFFormFieldObjectHelper> result;
|
std::vector<QPDFFormFieldObjectHelper> result;
|
||||||
for (auto const& iter: this->m->field_to_annotations) {
|
for (auto const& iter: this->m->field_to_annotations) {
|
||||||
result.push_back(this->qpdf.getObjectByObjGen(iter.first));
|
result.push_back(this->qpdf.getObject(iter.first));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1897,7 +1897,7 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object)
|
|||||||
// pass 1.
|
// pass 1.
|
||||||
indicateProgress(true, false);
|
indicateProgress(true, false);
|
||||||
}
|
}
|
||||||
QPDFObjectHandle obj_to_write = this->m->pdf.getObjectByObjGen(obj);
|
QPDFObjectHandle obj_to_write = this->m->pdf.getObject(obj);
|
||||||
if (obj_to_write.isStream()) {
|
if (obj_to_write.isStream()) {
|
||||||
// This condition occurred in a fuzz input. Ideally we
|
// This condition occurred in a fuzz input. Ideally we
|
||||||
// should block it at at parse time, but it's not
|
// should block it at at parse time, but it's not
|
||||||
|
@ -394,7 +394,7 @@ QPDF::JSONReactor::replaceObject(
|
|||||||
auto og = to_replace.getObjGen();
|
auto og = to_replace.getObjGen();
|
||||||
this->reserved.erase(og);
|
this->reserved.erase(og);
|
||||||
this->pdf.replaceObject(og, replacement);
|
this->pdf.replaceObject(og, replacement);
|
||||||
auto oh = pdf.getObjectByObjGen(og);
|
auto oh = pdf.getObject(og);
|
||||||
setObjectDescription(oh, value);
|
setObjectDescription(oh, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -706,7 +706,7 @@ QPDF::getUncompressedObject(
|
|||||||
return obj;
|
return obj;
|
||||||
} else {
|
} else {
|
||||||
int repl = (*(object_stream_data.find(obj.getObjectID()))).second;
|
int repl = (*(object_stream_data.find(obj.getObjectID()))).second;
|
||||||
return getObjectByObjGen(QPDFObjGen(repl, 0));
|
return getObject(repl, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1381,9 +1381,9 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
|
|||||||
stopOnError("found other than one root while"
|
stopOnError("found other than one root while"
|
||||||
" calculating linearization data");
|
" calculating linearization data");
|
||||||
}
|
}
|
||||||
this->m->part4.push_back(getObjectByObjGen(*(lc_root.begin())));
|
this->m->part4.push_back(getObject(*(lc_root.begin())));
|
||||||
for (auto const& og: lc_open_document) {
|
for (auto const& og: lc_open_document) {
|
||||||
this->m->part4.push_back(getObjectByObjGen(og));
|
this->m->part4.push_back(getObject(og));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Part 6: first page objects. Note: implementation note 124
|
// Part 6: first page objects. Note: implementation note 124
|
||||||
@ -1412,11 +1412,11 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
|
|||||||
// hint tables.
|
// hint tables.
|
||||||
|
|
||||||
for (auto const& og: lc_first_page_private) {
|
for (auto const& og: lc_first_page_private) {
|
||||||
this->m->part6.push_back(getObjectByObjGen(og));
|
this->m->part6.push_back(getObject(og));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto const& og: lc_first_page_shared) {
|
for (auto const& og: lc_first_page_shared) {
|
||||||
this->m->part6.push_back(getObjectByObjGen(og));
|
this->m->part6.push_back(getObject(og));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place the outline dictionary if it goes in the first page section.
|
// Place the outline dictionary if it goes in the first page section.
|
||||||
@ -1462,7 +1462,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
|
|||||||
for (auto const& og: this->m->obj_user_to_objects[ou]) {
|
for (auto const& og: this->m->obj_user_to_objects[ou]) {
|
||||||
if (lc_other_page_private.count(og)) {
|
if (lc_other_page_private.count(og)) {
|
||||||
lc_other_page_private.erase(og);
|
lc_other_page_private.erase(og);
|
||||||
this->m->part7.push_back(getObjectByObjGen(og));
|
this->m->part7.push_back(getObject(og));
|
||||||
++this->m->c_page_offset_data.entries.at(i).nobjects;
|
++this->m->c_page_offset_data.entries.at(i).nobjects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1479,7 +1479,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
|
|||||||
|
|
||||||
// Order is unimportant.
|
// Order is unimportant.
|
||||||
for (auto const& og: lc_other_page_shared) {
|
for (auto const& og: lc_other_page_shared) {
|
||||||
this->m->part8.push_back(getObjectByObjGen(og));
|
this->m->part8.push_back(getObject(og));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Part 9: other objects
|
// Part 9: other objects
|
||||||
@ -1501,7 +1501,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
|
|||||||
for (auto const& og: pages_ogs) {
|
for (auto const& og: pages_ogs) {
|
||||||
if (lc_other.count(og)) {
|
if (lc_other.count(og)) {
|
||||||
lc_other.erase(og);
|
lc_other.erase(og);
|
||||||
this->m->part9.push_back(getObjectByObjGen(og));
|
this->m->part9.push_back(getObject(og));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1531,7 +1531,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
|
|||||||
for (auto const& og: ogs) {
|
for (auto const& og: ogs) {
|
||||||
if (lc_thumbnail_private.count(og)) {
|
if (lc_thumbnail_private.count(og)) {
|
||||||
lc_thumbnail_private.erase(og);
|
lc_thumbnail_private.erase(og);
|
||||||
this->m->part9.push_back(getObjectByObjGen(og));
|
this->m->part9.push_back(getObject(og));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1544,7 +1544,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
|
|||||||
|
|
||||||
// Place shared thumbnail objects
|
// Place shared thumbnail objects
|
||||||
for (auto const& og: lc_thumbnail_shared) {
|
for (auto const& og: lc_thumbnail_shared) {
|
||||||
this->m->part9.push_back(getObjectByObjGen(og));
|
this->m->part9.push_back(getObject(og));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Place outlines unless in first page
|
// Place outlines unless in first page
|
||||||
@ -1554,7 +1554,7 @@ QPDF::calculateLinearizationData(std::map<int, int> const& object_stream_data)
|
|||||||
|
|
||||||
// Place all remaining objects
|
// Place all remaining objects
|
||||||
for (auto const& og: lc_other) {
|
for (auto const& og: lc_other) {
|
||||||
this->m->part9.push_back(getObjectByObjGen(og));
|
this->m->part9.push_back(getObject(og));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we got everything exactly once.
|
// Make sure we got everything exactly once.
|
||||||
@ -1656,7 +1656,7 @@ QPDF::pushOutlinesToPart(
|
|||||||
lc_outlines.erase(outlines_og);
|
lc_outlines.erase(outlines_og);
|
||||||
part.push_back(outlines);
|
part.push_back(outlines);
|
||||||
for (auto const& og: lc_outlines) {
|
for (auto const& og: lc_outlines) {
|
||||||
part.push_back(getObjectByObjGen(og));
|
part.push_back(getObject(og));
|
||||||
++this->m->c_outline_data.nobjects;
|
++this->m->c_outline_data.nobjects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user