oox/source/export/shapes.cxx        |   19 ++++++++++++-------
 sd/qa/unit/data/ppt/tdf168736-1.ppt |binary
 sd/qa/unit/data/ppt/tdf168736-2.ppt |binary
 sd/qa/unit/export-tests-ooxml3.cxx  |   20 ++++++++++++++++++++
 4 files changed, 32 insertions(+), 7 deletions(-)

New commits:
commit b19957e1bbd596462a6601847833c5435c57afd0
Author:     Karthik <[email protected]>
AuthorDate: Mon Oct 27 14:09:35 2025 +0530
Commit:     Michael Stahl <[email protected]>
CommitDate: Thu Oct 30 18:19:20 2025 +0100

    tdf#168736: Fix interop: PPT->PPTX images with internal-links
    
    When PPT files with pictures containing links to internal slides are
    saved as PPTX, it results in corrupted XML output.
    
    Change-Id: Ie5ec67d342d64e2412eb6979e6c2cb58d4a8f97a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193017
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx
index 76a5ed28f280..a043a3c09353 100644
--- a/oox/source/export/shapes.cxx
+++ b/oox/source/export/shapes.cxx
@@ -749,7 +749,8 @@ static OUString lcl_GetTarget(const 
css::uno::Reference<css::frame::XModel>& xMo
         if (!xNamed)
             continue;
         OUString sSlideName = "#" + xNamed->getName();
-        if (rURL == sSlideName)
+        OUString sApiName = "#page" + OUString::number(i + 1);
+        if (rURL == sSlideName || rURL == sApiName)
         {
             sTarget = "slide" + OUString::number(i + 1) + ".xml";
             break;
@@ -1486,16 +1487,20 @@ void ShapeExport::WriteGraphicObjectShapePart( const 
Reference< XShape >& xShape
         bool bExtURL = URLTransformer().isExternalURL(sBookmark);
         sBookmark = bExtURL ? sBookmark : lcl_GetTarget(GetFB()->getModel(), 
sBookmark);
 
-        OUString sRelId = mpFB->addRelation(mpFS->getOutputStream(),
-                                            bExtURL ? 
oox::getRelationship(Relationship::HYPERLINK)
-                                                    : 
oox::getRelationship(Relationship::SLIDE),
-                                            sBookmark, bExtURL);
-
+        OUString sRelId;
+        if (!sBookmark.isEmpty())
+        {
+            sRelId = mpFB->addRelation(mpFS->getOutputStream(),
+                                       bExtURL ? 
oox::getRelationship(Relationship::HYPERLINK)
+                                               : 
oox::getRelationship(Relationship::SLIDE),
+                                       sBookmark, bExtURL);
+        }
         if (bExtURL)
             mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), 
sRelId);
         else
             mpFS->singleElementNS(XML_a, XML_hlinkClick, FSNS(XML_r, XML_id), 
sRelId, XML_action,
-                                  "ppaction://hlinksldjump");
+                                  sBookmark.isEmpty() ? "ppaction://noaction"
+                                                      : 
"ppaction://hlinksldjump");
     }
     AddExtLst(pFS, xShapeProps);
     pFS->endElementNS(mnXmlNamespace, XML_cNvPr);
diff --git a/sd/qa/unit/data/ppt/tdf168736-1.ppt 
b/sd/qa/unit/data/ppt/tdf168736-1.ppt
new file mode 100644
index 000000000000..dc4bf7071ecc
Binary files /dev/null and b/sd/qa/unit/data/ppt/tdf168736-1.ppt differ
diff --git a/sd/qa/unit/data/ppt/tdf168736-2.ppt 
b/sd/qa/unit/data/ppt/tdf168736-2.ppt
new file mode 100644
index 000000000000..1d08f151ad0c
Binary files /dev/null and b/sd/qa/unit/data/ppt/tdf168736-2.ppt differ
diff --git a/sd/qa/unit/export-tests-ooxml3.cxx 
b/sd/qa/unit/export-tests-ooxml3.cxx
index a3c2572fbfb7..1c54a7fcbc7f 100644
--- a/sd/qa/unit/export-tests-ooxml3.cxx
+++ b/sd/qa/unit/export-tests-ooxml3.cxx
@@ -1030,6 +1030,26 @@ CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf135843)
     assertXPath(pXmlDoc, sPathStart + 
"/a:tr[3]/a:tc[1]/a:tcPr/a:lnB/a:solidFill");
 }
 
+CPPUNIT_TEST_FIXTURE(SdOOXMLExportTest3, testTdf168736)
+{
+    createSdImpressDoc("ppt/tdf168736-1.ppt");
+    save(u"Impress Office Open XML"_ustr);
+
+    xmlDocUniquePtr pXmlDoc = parseExport(u"ppt/slides/slide1.xml"_ustr);
+
+    // Verify hyperlink to nextslide is properly exported the Relationship has 
Target attribute
+    assertXPath(pXmlDoc, 
"/p:sld/p:cSld/p:spTree/p:sp[3]/p:txBody/a:p/a:r/a:rPr/a:hlinkClick",
+                "action", u"ppaction://hlinkshowjump?jump=nextslide");
+
+    createSdImpressDoc("ppt/tdf168736-2.ppt");
+    save(u"Impress Office Open XML"_ustr);
+
+    xmlDocUniquePtr pXmlDocRels = 
parseExport(u"ppt/slides/_rels/slide2.xml.rels"_ustr);
+
+    // Verify that the Relationship has Target attribute
+    assertXPath(pXmlDocRels, "/rels:Relationships/rels:Relationship[1]", 
"Target", u"slide1.xml");
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to