mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Move calculations from QPDF::getObjectCount to Objects::next_id
This commit is contained in:
parent
113ea4e7ae
commit
336d783325
@ -645,7 +645,7 @@ class QPDF
|
|||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
void fixDanglingReferences(bool force = false);
|
void fixDanglingReferences(bool force = false);
|
||||||
|
|
||||||
// Return the approximate number of indirect objects. It is/ approximate because not all objects
|
// Return the approximate number of indirect objects. It is approximate because not all objects
|
||||||
// in the file are preserved in all cases, and gaps in object numbering are not preserved.
|
// in the file are preserved in all cases, and gaps in object numbering are not preserved.
|
||||||
QPDF_DLL
|
QPDF_DLL
|
||||||
size_t getObjectCount();
|
size_t getObjectCount();
|
||||||
|
@ -492,12 +492,7 @@ QPDF::getObjectCount()
|
|||||||
// This method returns the next available indirect object number. makeIndirectObject uses it for
|
// This method returns the next available indirect object number. makeIndirectObject uses it for
|
||||||
// this purpose. After fixDanglingReferences is called, all objects in the xref table will also
|
// this purpose. After fixDanglingReferences is called, all objects in the xref table will also
|
||||||
// be in obj_cache.
|
// be in obj_cache.
|
||||||
fixDanglingReferences();
|
return toS(m->objects.next_id().getObj() - 1);
|
||||||
QPDFObjGen og;
|
|
||||||
if (!m->objects.obj_cache.empty()) {
|
|
||||||
og = (*(m->objects.obj_cache.rbegin())).first;
|
|
||||||
}
|
|
||||||
return toS(og.getObj());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<QPDFObjectHandle>
|
std::vector<QPDFObjectHandle>
|
||||||
|
@ -1712,7 +1712,12 @@ Objects::unresolved(QPDFObjGen og)
|
|||||||
QPDFObjGen
|
QPDFObjGen
|
||||||
Objects::next_id()
|
Objects::next_id()
|
||||||
{
|
{
|
||||||
int max_objid = toI(qpdf.getObjectCount());
|
qpdf.fixDanglingReferences();
|
||||||
|
QPDFObjGen og;
|
||||||
|
if (!obj_cache.empty()) {
|
||||||
|
og = (*(m->objects.obj_cache.rbegin())).first;
|
||||||
|
}
|
||||||
|
int max_objid = og.getObj();
|
||||||
if (max_objid == std::numeric_limits<int>::max()) {
|
if (max_objid == std::numeric_limits<int>::max()) {
|
||||||
throw std::range_error("max object id is too high to create new objects");
|
throw std::range_error("max object id is too high to create new objects");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user