mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-03 07:12:28 +00:00
Merge pull request #981 from m-holger/writer
Remove redundant loop in QPDFWriter::prepareFileForWrite
This commit is contained in:
commit
21612165c6
@ -2034,29 +2034,25 @@ QPDFWriter::getTrimmedTrailer()
|
|||||||
return trailer;
|
return trailer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make document extension level information direct as required by the spec.
|
||||||
void
|
void
|
||||||
QPDFWriter::prepareFileForWrite()
|
QPDFWriter::prepareFileForWrite()
|
||||||
{
|
{
|
||||||
// Make document extension level information direct as required by the spec.
|
|
||||||
|
|
||||||
m->pdf.fixDanglingReferences();
|
m->pdf.fixDanglingReferences();
|
||||||
QPDFObjectHandle root = m->pdf.getRoot();
|
auto root = m->pdf.getRoot();
|
||||||
for (auto const& key: root.getKeys()) {
|
auto oh = root.getKey("/Extensions");
|
||||||
QPDFObjectHandle oh = root.getKey(key);
|
if (oh.isDictionary()) {
|
||||||
if ((key == "/Extensions") && (oh.isDictionary())) {
|
const bool extensions_indirect = oh.isIndirect();
|
||||||
bool extensions_indirect = false;
|
if (extensions_indirect) {
|
||||||
if (oh.isIndirect()) {
|
QTC::TC("qpdf", "QPDFWriter make Extensions direct");
|
||||||
QTC::TC("qpdf", "QPDFWriter make Extensions direct");
|
oh = root.replaceKeyAndGetNew("/Extensions", oh.shallowCopy());
|
||||||
extensions_indirect = true;
|
}
|
||||||
oh = root.replaceKeyAndGetNew(key, oh.shallowCopy());
|
if (oh.hasKey("/ADBE")) {
|
||||||
}
|
auto adbe = oh.getKey("/ADBE");
|
||||||
if (oh.hasKey("/ADBE")) {
|
if (adbe.isIndirect()) {
|
||||||
QPDFObjectHandle adbe = oh.getKey("/ADBE");
|
QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
|
||||||
if (adbe.isIndirect()) {
|
adbe.makeDirect();
|
||||||
QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
|
oh.replaceKey("/ADBE", adbe);
|
||||||
adbe.makeDirect();
|
|
||||||
oh.replaceKey("/ADBE", adbe);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user