vcl/inc/pdf/COSWriter.hxx | 8 ++++++++ vcl/source/gdi/pdfwriter_impl.cxx | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-)
New commits: commit d95e3d472f057b2224737dd1c72fd2eee03847a6 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Dec 17 22:39:59 2024 +0900 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Wed Dec 18 08:39:37 2024 +0100 pdf: /Win entry is deprecated in PDF 2.0 for launch actions /Win is deprecated, as well as /Mac and /Unix (which we don't write), so instead write /F directly, not under /Win entry. Change-Id: Ic6b71f6e7aba8d5e4a22e678f82fa5a70d9b7c5b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178674 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/vcl/inc/pdf/COSWriter.hxx b/vcl/inc/pdf/COSWriter.hxx index 2cc3790f76e0..b80f0f84f424 100644 --- a/vcl/inc/pdf/COSWriter.hxx +++ b/vcl/inc/pdf/COSWriter.hxx @@ -120,6 +120,14 @@ public: void writeLiteralEncrypt(std::u16string_view value, sal_Int32 nObject, rtl_TextEncoding nEncoding = RTL_TEXTENCODING_ASCII_US); + void writeKeyAndLiteralEncrypt(std::string_view key, std::u16string_view value, + sal_Int32 nObject, + rtl_TextEncoding nEncoding = RTL_TEXTENCODING_ASCII_US) + { + mrBuffer.append(key); + writeLiteralEncrypt(value, nObject, nEncoding); + } + void writeLiteralEncrypt(std::string_view value, sal_Int32 nObject); void writeKeyAndLiteralEncrypt(std::string_view key, std::string_view value, sal_Int32 nObject) diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 0ca42b79c69c..4c39710abab3 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -3644,10 +3644,21 @@ we check in the following sequence: aLine.append( "/A<</Type/Action/S"); if( bIsUNCPath ) // handle Win UNC paths { - aLine.append( "/Launch/Win<</F" ); - // INetURLObject is not good with UNC paths, use original path - aWriter.writeLiteralEncrypt(url, rLink.m_nObject, osl_getThreadTextEncoding()); - aLine.append( ">>" ); + aLine.append("/Launch"); + // Entry /Win is deprecated in PDF 2.0 + if (m_aContext.Version >= PDFWriter::PDFVersion::PDF_2_0) + { + // So write /F directly. AFAICS it's up to PDF viewer to resolve this correctly + aWriter.writeKeyAndLiteralEncrypt("/F", url, rLink.m_nObject, osl_getThreadTextEncoding()); + } + else + { + aLine.append("/Win"); + aWriter.startDict(); + // INetURLObject is not good with UNC paths, use original path + aWriter.writeKeyAndLiteralEncrypt("/F", url, rLink.m_nObject, osl_getThreadTextEncoding()); + aWriter.endDict(); + } } else {