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,24 +2034,21 @@ QPDFWriter::getTrimmedTrailer()
|
||||
return trailer;
|
||||
}
|
||||
|
||||
// Make document extension level information direct as required by the spec.
|
||||
void
|
||||
QPDFWriter::prepareFileForWrite()
|
||||
{
|
||||
// Make document extension level information direct as required by the spec.
|
||||
|
||||
m->pdf.fixDanglingReferences();
|
||||
QPDFObjectHandle root = m->pdf.getRoot();
|
||||
for (auto const& key: root.getKeys()) {
|
||||
QPDFObjectHandle oh = root.getKey(key);
|
||||
if ((key == "/Extensions") && (oh.isDictionary())) {
|
||||
bool extensions_indirect = false;
|
||||
if (oh.isIndirect()) {
|
||||
auto root = m->pdf.getRoot();
|
||||
auto oh = root.getKey("/Extensions");
|
||||
if (oh.isDictionary()) {
|
||||
const bool extensions_indirect = oh.isIndirect();
|
||||
if (extensions_indirect) {
|
||||
QTC::TC("qpdf", "QPDFWriter make Extensions direct");
|
||||
extensions_indirect = true;
|
||||
oh = root.replaceKeyAndGetNew(key, oh.shallowCopy());
|
||||
oh = root.replaceKeyAndGetNew("/Extensions", oh.shallowCopy());
|
||||
}
|
||||
if (oh.hasKey("/ADBE")) {
|
||||
QPDFObjectHandle adbe = oh.getKey("/ADBE");
|
||||
auto adbe = oh.getKey("/ADBE");
|
||||
if (adbe.isIndirect()) {
|
||||
QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
|
||||
adbe.makeDirect();
|
||||
@ -2060,7 +2057,6 @@ QPDFWriter::prepareFileForWrite()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
QPDFWriter::doWriteSetup()
|
||||
|
Loading…
Reference in New Issue
Block a user