sc/source/ui/view/output2.cxx                                  |    2 
 sw/qa/extras/layout/layout3.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 +-
 9 files changed, 45 insertions(+), 47 deletions(-)

New commits:
commit 9cef7e5ba50b483cd84682528c7ef503965b6104
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Mar 6 18:53:35 2025 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Mar 6 20:51:25 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 <michael.st...@allotropia.de>
    Tested-by: Jenkins

diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index 4a3bdc5535ba..4dda4290bc09 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 f686899b6d25..517b32171d4a 100644
--- a/sw/source/core/text/EnhancedPDFExportHelper.cxx
+++ b/sw/source/core/text/EnhancedPDFExportHelper.cxx
@@ -2446,8 +2446,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() );
@@ -2571,7 +2569,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 );
 
@@ -2580,7 +2578,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);
@@ -2601,7 +2599,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);
                             }
                         }
                     }
@@ -2700,7 +2698,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();
@@ -2717,7 +2714,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 );
@@ -2729,7 +2726,7 @@ void 
SwEnhancedPDFExportHelper::EnhancedPDFExport(LanguageType const eLanguageDe
                             // #i44368# Links in Header/Footer
                             if ( bHeaderFooter )
                             {
-                                MakeHeaderFooterLinks(*pPDFExtOutDevData, 
*pTNd, rLinkRect, nDestId, u""_ustr, true, content);
+                                MakeHeaderFooterLinks(*pPDFExtOutDevData, 
*pTNd, rLinkRect, nDestId, u""_ustr, true, rRefName);
                             }
                         }
                     }
@@ -2814,7 +2811,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();
@@ -2823,7 +2820,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:
@@ -3165,7 +3162,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();
@@ -3216,7 +3213,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 b40f60724fd5..975b3ae743f4 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -2303,7 +2303,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));
@@ -2370,7 +2370,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));
@@ -2436,7 +2436,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));
@@ -2502,7 +2502,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));
@@ -2568,7 +2568,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));
@@ -2693,7 +2693,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));
@@ -2760,7 +2760,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));
@@ -2849,7 +2849,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));
@@ -2916,7 +2916,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));
@@ -3072,7 +3072,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));
@@ -3138,7 +3138,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));
@@ -3204,7 +3204,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));
@@ -3270,7 +3270,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));
@@ -3348,7 +3348,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));
@@ -3414,7 +3414,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));
@@ -3480,7 +3480,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));
@@ -3546,7 +3546,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 7b8af48bf467..514280ac930f 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -3029,7 +3029,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
@@ -3102,9 +3102,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));
@@ -3178,8 +3176,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));
@@ -3773,7 +3770,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
@@ -4342,6 +4339,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.
         aMediaDescriptor[u"FilterName"_ustr] <<= u"writer_pdf_Export"_ustr;
@@ -4384,7 +4382,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 ec19541fa08e..77b682ac7a35 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -3615,8 +3615,11 @@ bool PDFWriterImpl::emitLinkAnnotations()
         appendFixedInt( rLink.m_aRect.Bottom(), aLine );
         aLine.append( "]" );
         // ISO 14289-1:2014, Clause: 7.18.5
-        aLine.append("/Contents");
-        aWriter.writeUnicodeEncrypt(rLink.m_AltText, rLink.m_nObject);
+        if (!rLink.m_AltText.isEmpty())
+        {
+            aLine.append("/Contents");
+            aWriter.writeUnicodeEncrypt(rLink.m_AltText, rLink.m_nObject);
+        }
         if( rLink.m_nDest >= 0 )
         {
             aLine.append( "/Dest" );
commit 7ada3b1012f84a192b339dd9e3a015fa8979051f
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Thu Mar 6 19:40:36 2025 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Mar 6 20:51:16 2025 +0100

    sw: fix testTdf165354_column
    
    XPath 
'/root/page[1]/body/txt/section/column[2]/body/txt/SwParaPortion/SwLineLayout[1]'
 not found
    
    (regression from commit e79e12484f5a7ec20e48233a2b5b60d7bd8b54ab)
    
    Change-Id: I52a520dfef2a06efacd65556bb1780f05871c7a8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182599
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sw/qa/extras/layout/layout3.cxx b/sw/qa/extras/layout/layout3.cxx
index a2eab99d454c..5e4844ea7b55 100644
--- a/sw/qa/extras/layout/layout3.cxx
+++ b/sw/qa/extras/layout/layout3.cxx
@@ -753,7 +753,7 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter3, testTdf165354_column)
     // loext:hyphenation-keep-type="column" hyphenation-keep-line="true"
     // 2nd frame: shifted hyphenated word (no hyphenation at the end of the 
first column)
     assertXPath(pXmlDoc,
-                
"/root/page[1]/body/txt/section/column[2]/body/txt/SwParaPortion/SwLineLayout[1]",
+                
"/root/page[1]/body/section/column[2]/body/txt/SwParaPortion/SwLineLayout[1]",
                 "portion", u"iner");
 }
 

Reply via email to