mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 02:49:00 +00:00
Add new method Objects::replace
This commit is contained in:
parent
6c9903062f
commit
83fc18af09
@ -597,9 +597,15 @@ QPDF::getObjectByID(int id, int gen)
|
||||
}
|
||||
|
||||
void
|
||||
QPDF::replaceObject(int objid, int generation, QPDFObjectHandle oh)
|
||||
QPDF::replaceObject(int id, int gen, QPDFObjectHandle replacement)
|
||||
{
|
||||
replaceObject(QPDFObjGen(objid, generation), oh);
|
||||
m->objects.replace(QPDFObjGen(id, gen), replacement);
|
||||
}
|
||||
|
||||
void
|
||||
QPDF::replaceObject(QPDFObjGen const& og, QPDFObjectHandle replacement)
|
||||
{
|
||||
m->objects.replace(og, replacement);
|
||||
}
|
||||
|
||||
void
|
||||
@ -610,7 +616,7 @@ QPDF::replaceReserved(QPDFObjectHandle reserved, QPDFObjectHandle replacement)
|
||||
if (!(tc == ::ot_reserved || tc == ::ot_null)) {
|
||||
throw std::logic_error("replaceReserved called with non-reserved object");
|
||||
}
|
||||
replaceObject(reserved.getObjGen(), replacement);
|
||||
m->objects.replace(reserved.getObjGen(), replacement);
|
||||
}
|
||||
|
||||
QPDFObjectHandle
|
||||
|
@ -1758,13 +1758,13 @@ Objects::get_for_json(int id, int gen)
|
||||
}
|
||||
|
||||
void
|
||||
QPDF::replaceObject(QPDFObjGen const& og, QPDFObjectHandle oh)
|
||||
Objects::replace(QPDFObjGen og, QPDFObjectHandle oh)
|
||||
{
|
||||
if (!oh || (oh.isIndirect() && !(oh.isStream() && oh.getObjGen() == og))) {
|
||||
QTC::TC("qpdf", "QPDF replaceObject called with indirect object");
|
||||
throw std::logic_error("QPDF::replaceObject called with indirect object handle");
|
||||
}
|
||||
objects().update_table(og, oh.getObj());
|
||||
update_table(og, oh.getObj());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -441,6 +441,10 @@ class QPDF::Objects
|
||||
return get(QPDFObjGen(id, gen));
|
||||
}
|
||||
|
||||
void erase(QPDFObjGen og);
|
||||
|
||||
void replace(QPDFObjGen og, QPDFObjectHandle oh);
|
||||
|
||||
std::map<QPDFObjGen, Entry> obj_cache;
|
||||
|
||||
QPDFObjectHandle readObjectInStream(std::shared_ptr<InputSource>& input, int obj);
|
||||
@ -469,7 +473,6 @@ class QPDF::Objects
|
||||
size_t table_size();
|
||||
|
||||
private:
|
||||
void erase(QPDFObjGen og);
|
||||
bool cached(QPDFObjGen og);
|
||||
bool unresolved(QPDFObjGen og);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user