From 07d790ca473cd6e71f0343419b819fa6b485dc01 Mon Sep 17 00:00:00 2001 From: Michael Stahl Date: Wed, 12 Jul 2023 15:26:25 +0200 Subject: tdf#154982 vcl: PDF Export: split BeginStructureElement ... into 3 parts: EnsureStructureElement/InitStructureElement/BeginStructureElement So EnsureStructureElement and BeginStructureElement/EndStructureElement can be called multiple times for the same object, passing in a unique key and PDFExtOutDevData will only create the element once. InitStructureElement will be used exactly once for each object when its actual content is exported. In PDFExtOutDevData rely on the indexes being the same here and in PDFWriterImpl, because then only PDFExtOutDevData needs to maintain the map from key to index. Change-Id: Idea6e34627fe559038cf13cf01dafe84b759e3c8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154357 Tested-by: Jenkins Reviewed-by: Michael Stahl --- filter/source/pdf/pdfexport.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'filter') diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index f9c5fb44af6b..8199132b66b4 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -1263,7 +1263,9 @@ void PDFExport::ImplWriteWatermark( vcl::PDFWriter& rWriter, const Size& rPageSi rWriter.Push(); // tdf#152235 tag around the reference to the XObject on the page - rWriter.BeginStructureElement(vcl::PDFWriter::NonStructElement, ::std::u16string_view()); + sal_Int32 const id = rWriter.EnsureStructureElement(); + rWriter.InitStructureElement(id, vcl::PDFWriter::NonStructElement, ::std::u16string_view()); + rWriter.BeginStructureElement(id); rWriter.SetStructureAttribute(vcl::PDFWriter::Type, vcl::PDFWriter::Pagination); rWriter.SetStructureAttribute(vcl::PDFWriter::Subtype, vcl::PDFWriter::Watermark); // HACK: this should produce *nothing* itself but is necessary to output @@ -1359,7 +1361,9 @@ void PDFExport::ImplWriteTiledWatermark( vcl::PDFWriter& rWriter, const Size& rP rWriter.Push(); // tdf#152235 tag around the reference to the XObject on the page - rWriter.BeginStructureElement(vcl::PDFWriter::NonStructElement, ::std::u16string_view()); + sal_Int32 const id = rWriter.EnsureStructureElement(); + rWriter.InitStructureElement(id, vcl::PDFWriter::NonStructElement, ::std::u16string_view()); + rWriter.BeginStructureElement(id); rWriter.SetStructureAttribute(vcl::PDFWriter::Type, vcl::PDFWriter::Pagination); rWriter.SetStructureAttribute(vcl::PDFWriter::Subtype, vcl::PDFWriter::Watermark); // HACK: this should produce *nothing* itself but is necessary to output -- cgit