summaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <jberkenbilt@users.noreply.github.com>2023-06-17 16:57:56 +0200
committerGitHub <noreply@github.com>2023-06-17 16:57:56 +0200
commit21612165c6c1b49b88786c0232215f2e894254ea (patch)
tree8622e39048766c13bd466e07bd42c6fb4e345103 /libqpdf
parentd3c444a7fb7ef62d44633cba4ab433348bc27943 (diff)
parentd8e078fbb775fb585b3c908b89139561d98c786c (diff)
downloadqpdf-21612165c6c1b49b88786c0232215f2e894254ea.tar.zst
Merge pull request #981 from m-holger/writer
Remove redundant loop in QPDFWriter::prepareFileForWrite
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFWriter.cc34
1 files changed, 15 insertions, 19 deletions
diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc
index 50594a09..17a77e39 100644
--- a/libqpdf/QPDFWriter.cc
+++ b/libqpdf/QPDFWriter.cc
@@ -2034,29 +2034,25 @@ 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()) {
- QTC::TC("qpdf", "QPDFWriter make Extensions direct");
- extensions_indirect = true;
- oh = root.replaceKeyAndGetNew(key, oh.shallowCopy());
- }
- if (oh.hasKey("/ADBE")) {
- QPDFObjectHandle adbe = oh.getKey("/ADBE");
- if (adbe.isIndirect()) {
- QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
- adbe.makeDirect();
- oh.replaceKey("/ADBE", adbe);
- }
+ 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");
+ oh = root.replaceKeyAndGetNew("/Extensions", oh.shallowCopy());
+ }
+ if (oh.hasKey("/ADBE")) {
+ auto adbe = oh.getKey("/ADBE");
+ if (adbe.isIndirect()) {
+ QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
+ adbe.makeDirect();
+ oh.replaceKey("/ADBE", adbe);
}
}
}