sc/source/ui/view/output2.cxx | 2 sw/source/core/text/EnhancedPDFExportHelper.cxx | 21 ++---- vcl/qa/cppunit/pdfexport/data/LinkPages.fodt | 4 - vcl/qa/cppunit/pdfexport/data/LinkWithFly.fodt | 4 - vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt | 4 - vcl/qa/cppunit/pdfexport/pdfexport.cxx | 34 +++++----- vcl/qa/cppunit/pdfexport/pdfexport2.cxx | 14 +--- vcl/source/gdi/pdfwriter_impl.cxx | 7 +- 8 files changed, 44 insertions(+), 46 deletions(-)
New commits: commit 3b4f0b2b0d54f605602587fb3ffc1b901d4a3c4e Author: Michael Stahl <[email protected]> AuthorDate: Thu Mar 6 18:53:35 2025 +0100 Commit: Adolfo Jayme Barrientos <[email protected]> CommitDate: Mon Mar 10 01:43:29 2025 +0100 tdf#161583 vcl,sc,sw: PDF/UA export: fix Contents of Link annotations In ISO 14289-2:2024 the requirement was changed from "shall" to "should": Link annotations should include a Contents entry to enrich information available to assistive technology. There is also now a Well-Tagged PDF (WTPDF) Version 1.0.0, which says: 8.9.2.4.2 Link Link annotations should include a Contents entry to enrich information available to assistive technology. NOTE 1 Link annotations are often accessed out of context; the Contents entry provides optional additional information. The Contents entry is also particularly valuable in the context of link targets that are not intended to be human-readable. EXAMPLE — A link over the text “click here” is improved by a Contents entry to advise the user regarding the link’s target. So adapt PDFWriterImpl::emitLinkAnnotations() to produce "Contents" only if there is some alt text. The sw a11y check will already warn if the alt text/"name" is missing on a hyperlink in a SwTextNode, and a previous commit added a warning if it is missing on a hyperlink in a SwFlyFrameFormat. Contents should in any case not contain the textual representation of the hyperlinks, that was a misunderstanding, but describe the target of the link. This requires adapting numerous unit tests. (regression from commit fa3f04bdd4f73a1b3be70dfb709c44638ef7e3d9) Change-Id: I88a7ae83d17d781115c93152d267ddb57208c200 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182600 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins (cherry picked from commit 9cef7e5ba50b483cd84682528c7ef503965b6104) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182626 Reviewed-by: Adolfo Jayme Barrientos <[email protected]> diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx index 7bbfb988b45f..9748fa922a61 100644 --- a/sc/source/ui/view/output2.cxx +++ b/sc/source/ui/view/output2.cxx @@ -888,7 +888,7 @@ static void lcl_DoHyperlinkResult( const OutputDevice* pDev, const tools::Rectan if ( !aURL.isEmpty() && pPDFData ) { vcl::PDFExtOutDevBookmarkEntry aBookmark; - aBookmark.nLinkId = pPDFData->CreateLink(rRect, aCellText); + aBookmark.nLinkId = pPDFData->CreateLink(rRect, u""_ustr); aBookmark.aBookmark = aURL; std::vector< vcl::PDFExtOutDevBookmarkEntry >& rBookmarks = pPDFData->GetBookmarks(); rBookmarks.push_back( aBookmark ); diff --git a/sw/source/core/text/EnhancedPDFExportHelper.cxx b/sw/source/core/text/EnhancedPDFExportHelper.cxx index c95a84fb9e92..829d0d92d04c 100644 --- a/sw/source/core/text/EnhancedPDFExportHelper.cxx +++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx @@ -2307,8 +2307,6 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe SwRects const aTmp(GetCursorRectsContainingText(mrSh)); OSL_ENSURE( !aTmp.empty(), "Enhanced pdf export - rectangles are missing" ); OUString altText(p->rINetAttr.GetINetFormat().GetName()); - if (altText.isEmpty()) - altText = mrSh.GetSelText(); const SwPageFrame* pSelectionPage = static_cast<const SwPageFrame*>( mrSh.GetLayout()->Lower() ); @@ -2432,7 +2430,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe { Point aNullPt; const SwRect aLinkRect = pFrameFormat->FindLayoutRect( false, &aNullPt ); - OUString const formatName(pFrameFormat->GetName()); + OUString const linkName(pItem->GetName()); // Link PageNums std::vector<sal_Int32> aLinkPageNums = CalcOutputPageNums( aLinkRect ); @@ -2441,7 +2439,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe { tools::Rectangle aRect(SwRectToPDFRect(pCurrPage, aLinkRect.SVRect())); const sal_Int32 nLinkId = - pPDFExtOutDevData->CreateLink(aRect, formatName, aLinkPageNum); + pPDFExtOutDevData->CreateLink(aRect, linkName, aLinkPageNum); // Store link info for tagged pdf output: const IdMapEntry aLinkEntry(aLinkRect, nLinkId); @@ -2462,7 +2460,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe { const SwTextNode* pTNd = pAnchorNode->GetTextNode(); if ( pTNd ) - MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, aLinkRect, nDestId, aURL, bInternal, formatName); + MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, aLinkRect, nDestId, aURL, bInternal, linkName); } } } @@ -2561,7 +2559,6 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe // #i44368# Links in Header/Footer const bool bHeaderFooter = pDoc->IsInHeaderFooter( *pTNd ); - OUString const content(pField->ExpandField(true, mrSh.GetLayout())); // Create links for all selected rectangles: const size_t nNumOfRects = aTmp.size(); @@ -2578,7 +2575,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe // Link Export aRect = SwRectToPDFRect(pCurrPage, rLinkRect.SVRect()); const sal_Int32 nLinkId = - pPDFExtOutDevData->CreateLink(aRect, content, aLinkPageNum); + pPDFExtOutDevData->CreateLink(aRect, rRefName, aLinkPageNum); // Store link info for tagged pdf output: const IdMapEntry aLinkEntry( rLinkRect, nLinkId ); @@ -2590,7 +2587,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe // #i44368# Links in Header/Footer if ( bHeaderFooter ) { - MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, rLinkRect, nDestId, "", true, content); + MakeHeaderFooterLinks(*pPDFExtOutDevData, *pTNd, rLinkRect, nDestId, "", true, rRefName); } } } @@ -2675,7 +2672,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe OUString const numStrRef(pTextFootnote->GetFootnote().GetViewNumStr(*pDoc, mrSh.GetLayout(), false)); // Export back link - const sal_Int32 nBackLinkId = pPDFExtOutDevData->CreateLink(aFootnoteSymbolRect, numStrSymbol, nDestPageNum); + const sal_Int32 nBackLinkId = pPDFExtOutDevData->CreateLink(aFootnoteSymbolRect, numStrRef, nDestPageNum); // Destination Export const sal_Int32 nDestId = pPDFExtOutDevData->CreateDest(aRect, nDestPageNum); mrSh.GotoFootnoteAnchor(); @@ -2684,7 +2681,7 @@ void SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe pCurrPage = static_cast<const SwPageFrame*>( mrSh.GetLayout()->Lower() ); // Link Export aRect = SwRectToPDFRect(pCurrPage, aLinkRect.SVRect()); - const sal_Int32 nLinkId = pPDFExtOutDevData->CreateLink(aRect, numStrRef, aLinkPageNum); + const sal_Int32 nLinkId = pPDFExtOutDevData->CreateLink(aRect, numStrSymbol, aLinkPageNum); // Back link destination Export const sal_Int32 nBackDestId = pPDFExtOutDevData->CreateDest(aRect, aLinkPageNum); // Store link info for tagged pdf output: @@ -2955,7 +2952,7 @@ void SwEnhancedPDFExportHelper::ExportAuthorityEntryLinks() continue; } - OUString const content(rAuthorityField.ExpandField(true, mrSh.GetLayout())); + OUString const content(rAuthorityField.GetAuthority(mrSh.GetLayout())); // Select the field. mrSh.SwCursorShell::SetMark(); @@ -3006,7 +3003,7 @@ void SwEnhancedPDFExportHelper::ExportAuthorityEntryLinks() continue; } - OUString const content(rAuthorityField.ExpandField(true, mrSh.GetLayout())); + OUString const content(rAuthorityField.GetAuthority(mrSh.GetLayout())); // Select the field. mrSh.SwCursorShell::SetMark(); diff --git a/vcl/qa/cppunit/pdfexport/data/LinkPages.fodt b/vcl/qa/cppunit/pdfexport/data/LinkPages.fodt index 50fff8bea4fc..50958d3b193c 100644 --- a/vcl/qa/cppunit/pdfexport/data/LinkPages.fodt +++ b/vcl/qa/cppunit/pdfexport/data/LinkPages.fodt @@ -131,8 +131,8 @@ <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> </text:sequence-decls> - <text:h text:style-name="P3" text:outline-level="1"><text:a xlink:type="simple" xlink:href="http://example.com/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link"><text:bookmark-start text:name="__RefHeading___Toc17_3815242785"/><text:span text:style-name="T6">foo foo </text:span><text:soft-page-break/><text:span text:style-name="T6">foo foo</text:span></text:a><text:bookmark-end text:name="__RefHeading___Toc17_3815242785"/></text:h> + <text:h text:style-name="P3" text:outline-level="1"><text:a xlink:type="simple" xlink:href="http://example.com/" office:name="quadfoo" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link"><text:bookmark-start text:name="__RefHeading___Toc17_3815242785"/><text:span text:style-name="T6">foo foo </text:span><text:soft-page-break/><text:span text:style-name="T6">foo foo</text:span></text:a><text:bookmark-end text:name="__RefHeading___Toc17_3815242785"/></text:h> <text:p text:style-name="Text_20_body"><text:soft-page-break/><text:span text:style-name="T4"><text:bookmark-ref text:reference-format="text" text:ref-name="__RefHeading___Toc17_3815242785">foo foo foo foo</text:bookmark-ref></text:span><text:soft-page-break/></text:p> </office:text> </office:body> -</office:document> \ No newline at end of file +</office:document> diff --git a/vcl/qa/cppunit/pdfexport/data/LinkWithFly.fodt b/vcl/qa/cppunit/pdfexport/data/LinkWithFly.fodt index 5c14cee1f28c..881ef60da399 100644 --- a/vcl/qa/cppunit/pdfexport/data/LinkWithFly.fodt +++ b/vcl/qa/cppunit/pdfexport/data/LinkWithFly.fodt @@ -117,7 +117,7 @@ <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> </text:sequence-decls> - <text:p text:style-name="Standard"><text:a xlink:type="simple" xlink:href="https://www.mozilla.org/en-US/firefox/119.0/releasenotes/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://www.mozilla.org/en-US<draw:frame draw:style-name="fr1" draw:name="Image1" text:anchor-type="char" svg:x="5.318cm" svg:y="0.056cm" svg:width="6.364cm" svg:height="6.364cm" draw:z-index="0"><draw:image draw:mime-type="image/png"> + <text:p text:style-name="Standard"><text:a xlink:type="simple" xlink:href="https://www.mozilla.org/en-US/firefox/119.0/releasenotes/" office:name="Firefox119" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://www.mozilla.org/en-US<draw:frame draw:style-name="fr1" draw:name="Image1" text:anchor-type="char" svg:x="5.318cm" svg:y="0.056cm" svg:width="6.364cm" svg:height="6.364cm" draw:z-index="0"><draw:image draw:mime-type="image/png"> <office:binary-data>iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAABGdBTUEAANbY1E9YMgAAABl0 RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFpSURBVHjaYvz//z8DtQBAADER o+jjZGuibAQIICZiDOK/cgzFwEnrV/4HYXS1AAHERIxBR58yMiAb2DtzM1b1AAHERIxBIIBu @@ -131,7 +131,7 @@ </draw:image> <svg:title>house</svg:title> </draw:frame>/firefox/119.0/releasenotes/</text:a></text:p> - <text:p text:style-name="P1"><text:a xlink:type="simple" xlink:href="https://www.mozilla.org/en-US/firefox/118.0/releasenotes/" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://www.mozilla.org/en-US/firefox/118.0/releasenotes/</text:a></text:p> + <text:p text:style-name="P1"><text:a xlink:type="simple" xlink:href="https://www.mozilla.org/en-US/firefox/118.0/releasenotes/" office:name="Firefox118" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://www.mozilla.org/en-US/firefox/118.0/releasenotes/</text:a></text:p> </office:text> </office:body> </office:document> diff --git a/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt b/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt index eda699e27f02..6498ed2e0b47 100644 --- a/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt +++ b/vcl/qa/cppunit/pdfexport/data/PDF_export_with_formcontrol.fodt @@ -162,9 +162,9 @@ </text:sequence-decls> <text:p text:style-name="P15">This <text:span text:style-name="T1">t</text:span>ext document contains some links and a text control.</text:p> <text:p text:style-name="P13"><text:span text:style-name="T1">When exporting the document to PDF in LO 7.5.</text:span><text:span text:style-name="T6">3.2</text:span><text:span text:style-name="T1"> or newer the links won't have the right target any more. First link to "Kläranlage" will open last link to "#pano=24", </text:span><text:span text:style-name="T5">second link won't open anything and third link will open "Mechanische Vorreinigung"</text:span></text:p> - <text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="https://klexikon.zum.de/wiki/Kläranlage" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://klexikon.zum.de/wiki/Kläranlage</text:a></text:p> + <text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="https://klexikon.zum.de/wiki/Kläranlage" office:name="wiki-seite" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://klexikon.zum.de/wiki/Kläranlage</text:a></text:p> <text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="https://de.wikipedia.org/wiki/Kläranlage#Mechanische_Vorreinigung" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://de.wikipedia.org/wiki/Kläranlage#Mechanische_Vorreinigung</text:a></text:p> - <text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="https://vr-easy.com/tour/usr/220113-virtuellerschulausflug/#pano=24" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://vr-easy.com/tour/usr/220113-virtuellerschulausflug/#pano=24</text:a></text:p> + <text:p text:style-name="Text_20_body"><text:a xlink:type="simple" xlink:href="https://vr-easy.com/tour/usr/220113-virtuellerschulausflug/#pano=24" office:name="tour" text:style-name="Internet_20_link" text:visited-style-name="Visited_20_Internet_20_Link">https://vr-easy.com/tour/usr/220113-virtuellerschulausflug/#pano=24</text:a></text:p> <text:p text:style-name="Text_20_body">Here a form control for getting possibility to input content.</text:p> <text:p text:style-name="Text_20_body"><draw:control text:anchor-type="as-char" svg:y="-0.3146in" draw:z-index="0" draw:name="Form1" draw:style-name="gr1" draw:text-style-name="P28" svg:width="6.3776in" svg:height="1.7717in" draw:control="control1"/></text:p> <text:p text:style-name="Text_20_body">When deleting the form control links will work as expected.</text:p> diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx index 40b2023e11b7..925dd153bb33 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -2253,7 +2253,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"Error: Reference source not found"_ustr, + u"__RefHeading___Toc1501_2152971747"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -2320,7 +2320,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"Error: Reference source not found"_ustr, + u"__RefHeading___Toc1501_2152971747"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -2386,7 +2386,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"Error: Reference source not found"_ustr, + u"__RefHeading___Toc1501_2152971747"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -2452,7 +2452,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"Error: Reference source not found"_ustr, + u"__RefHeading___Toc1501_2152971747"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -2518,7 +2518,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"Error: Reference source not found"_ustr, + u"__RefHeading___Toc1501_2152971747"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -2647,7 +2647,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"https://www.mozilla.org/en-US/firefox/119.0/releasenotes/"_ustr, + u"Firefox119"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -2714,7 +2714,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"https://www.mozilla.org/en-US/firefox/119.0/releasenotes/"_ustr, + u"Firefox119"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -2803,7 +2803,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"https://www.mozilla.org/en-US/firefox/118.0/releasenotes/"_ustr, + u"Firefox118"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -2870,7 +2870,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf157816Link) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"https://www.mozilla.org/en-US/firefox/118.0/releasenotes/"_ustr, + u"Firefox118"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -3030,7 +3030,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"foo foo foo foo"_ustr, + u"quadfoo"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -3096,7 +3096,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"foo foo foo foo"_ustr, + u"quadfoo"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -3162,7 +3162,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"foo foo foo foo"_ustr, + u"quadfoo"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -3228,7 +3228,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"foo foo foo foo"_ustr, + u"quadfoo"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -3306,7 +3306,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"foo foo foo foo"_ustr, + u"__RefHeading___Toc17_3815242785"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -3372,7 +3372,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"foo foo foo foo"_ustr, + u"__RefHeading___Toc17_3815242785"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -3438,7 +3438,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"foo foo foo foo"_ustr, + u"__RefHeading___Toc17_3815242785"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); @@ -3504,7 +3504,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testTdf142806) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"foo foo foo foo"_ustr, + u"__RefHeading___Toc17_3815242785"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); auto pStructParent = dynamic_cast<vcl::filter::PDFNumberElement*>( pAnnot->Lookup("StructParent"_ostr)); diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx index e7a997b401e2..85a0472ceb11 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx @@ -2947,7 +2947,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157397) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"https://klexikon.zum.de/wiki/Kläranlage"_ustr, + u"wiki-seite"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); CPPUNIT_ASSERT_EQUAL("Link"_ostr, pASubtype->GetValue()); auto pAA @@ -3020,9 +3020,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157397) CPPUNIT_ASSERT_EQUAL("Link"_ostr, pASubtype->GetValue()); auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); - CPPUNIT_ASSERT_EQUAL( - u"https://de.wikipedia.org/wiki/Kläranlage#Mechanische_Vorreinigung"_ustr, - ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); + CPPUNIT_ASSERT(!pAContents); CPPUNIT_ASSERT_EQUAL("Link"_ostr, pASubtype->GetValue()); auto pAA = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pAnnot->Lookup("A"_ostr)); @@ -3096,8 +3094,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf157397) auto pAContents = dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)); CPPUNIT_ASSERT_EQUAL( - u"https://vr-easy.com/tour/usr/220113-virtuellerschulausflug/#pano=24"_ustr, - ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); + u"tour"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pAContents)); CPPUNIT_ASSERT_EQUAL("Link"_ostr, pASubtype->GetValue()); auto pAA = dynamic_cast<vcl::filter::PDFDictionaryElement*>(pAnnot->Lookup("A"_ostr)); @@ -3715,7 +3712,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testFlyFrameHyperlinkAnnot) auto pContents = dynamic_cast<vcl::filter::PDFHexStringElement*>(pAnnot->Lookup("Contents"_ostr)); - CPPUNIT_ASSERT_EQUAL(u"Image2"_ustr, + CPPUNIT_ASSERT_EQUAL(u"Ship to Bugzilla"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE(*pContents)); auto pStructParent @@ -4295,6 +4292,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testURIs) xCursor->gotoEnd(/*bExpand=*/true); uno::Reference<beans::XPropertySet> xCursorProps(xCursor, uno::UNO_QUERY); xCursorProps->setPropertyValue(u"HyperLinkURL"_ustr, uno::Any(URIs[i].in)); + xCursorProps->setPropertyValue(u"HyperLinkName"_ustr, uno::Any(u"Testname"_ustr)); // Save as PDF. uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY); @@ -4338,7 +4336,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testURIs) // Check it matches CPPUNIT_ASSERT_EQUAL(URIs[i].out, pURIElem->GetValue()); // tdf#148934 check a11y - CPPUNIT_ASSERT_EQUAL(u"Test pdf"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE( + CPPUNIT_ASSERT_EQUAL(u"Testname"_ustr, ::vcl::filter::PDFDocument::DecodeHexStringUTF16BE( *dynamic_cast<vcl::filter::PDFHexStringElement*>( pAnnot->Lookup("Contents"_ostr)))); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index cb914231d049..208d5631f364 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -3734,8 +3734,11 @@ bool PDFWriterImpl::emitLinkAnnotations() appendFixedInt( rLink.m_aRect.Bottom(), aLine ); aLine.append( "]" ); // ISO 14289-1:2014, Clause: 7.18.5 - aLine.append("/Contents"); - appendUnicodeTextStringEncrypt(rLink.m_AltText, rLink.m_nObject, aLine); + if (!rLink.m_AltText.isEmpty()) + { + aLine.append("/Contents"); + appendUnicodeTextStringEncrypt(rLink.m_AltText, rLink.m_nObject, aLine); + } if( rLink.m_nDest >= 0 ) { aLine.append( "/Dest" );
