diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-03-09 13:36:27 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-03-11 10:45:28 +0100 |
commit | 4158c7380a3be30899dd4164c2299c52ac732c5d (patch) | |
tree | 1ebcd4abe843179b4a7105ccd5b843278a0b4a2a /vcl/source | |
parent | 08a9d2d250e041c3a6e7f7570cd2d6964dd96182 (diff) |
PDF export of PDF images: don't preserve annotations in general
Regression from 33c9bc0225a92f26770f9ef20b252af47853e7b9 (PDF export of
PDF images: preserve hyperlinks, 2022-01-07), the problem was that we
want to preserve hyperlinks, but annotations are added by the PDF export
explicitly, so it isn't a good idea to "preserve" them as well.
Fix the problem by going back to the old behavior, except when the
annotation sub-type is /Link.
This keeps hyperlinks working but doesn't lead to duplicated comments
when re-exporting an image + adding comments explicitly.
Change-Id: I910990da59bdc1150cc346f1a5471cb6da55dd2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131243
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
(cherry picked from commit 63dba12b779dd4d007c8cb8cf4b967bd78077cac)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131205
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 141c4f823fc1..0a971622d5bc 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -8438,7 +8438,7 @@ void PDFWriterImpl::writeReferenceXObject(const ReferenceXObjectEmit& rEmit) return; } - // Merge page annotations (links, etc) from pPage to our page. + // Merge link annotations from pPage to our page. std::vector<filter::PDFObjectElement*> aAnnots; if (auto pArray = dynamic_cast<filter::PDFArrayElement*>(pPage->Lookup("Annots"))) { @@ -8456,7 +8456,19 @@ void PDFWriterImpl::writeReferenceXObject(const ReferenceXObjectEmit& rEmit) continue; } - // Annotation refers to an object, remember it. + auto pType = dynamic_cast<filter::PDFNameElement*>(pObject->Lookup("Type")); + if (!pType || pType->GetValue() != "Annot") + { + continue; + } + + auto pSubtype = dynamic_cast<filter::PDFNameElement*>(pObject->Lookup("Subtype")); + if (!pSubtype || pSubtype->GetValue() != "Link") + { + continue; + } + + // Reference to a link annotation object, remember it. aAnnots.push_back(pObject); } } |