sw/qa/extras/ooxmlexport/data/tdf127362.odt  |binary
 sw/qa/extras/ooxmlexport/ooxmlexport13.cxx   |   15 +++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.cxx |    6 ++++++
 3 files changed, 21 insertions(+)

New commits:
commit 745f4cc374297a73ff5243cdd42a839e469619e7
Author:     Tünde Tóth <tund...@gmail.com>
AuthorDate: Mon Sep 9 13:50:30 2019 +0200
Commit:     László Németh <nem...@numbertext.org>
CommitDate: Tue Sep 10 08:16:32 2019 +0200

    tdf#127362 DOCX export: fix image hyperlink with space to bookmark target
    
    Images as hyperlinks to internal bookmark targets didn't work after
    export, because spaces were replaced only in bookmarks with underline
    characters, now in hyperlinks, too.
    
    Change-Id: I281b2cde276607aa93de92745cfa1ba887ba9976
    Reviewed-on: https://gerrit.libreoffice.org/78782
    Reviewed-by: László Németh <nem...@numbertext.org>
    Tested-by: László Németh <nem...@numbertext.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf127362.odt 
b/sw/qa/extras/ooxmlexport/data/tdf127362.odt
new file mode 100644
index 000000000000..488f1528fd15
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf127362.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index b8c9f7a9f15c..dd059cdb6af9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -729,6 +729,21 @@ DECLARE_OOXMLEXPORT_TEST(testTdf127339, "tdf127339.docx")
     assertXPathNoAttribute(pXmlRels, 
"/rels:Relationships/rels:Relationship[@Target='#bookmark']", "TargetMode");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testTdf127362, "tdf127362.odt")
+{
+    xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+    if (!pXmlDoc)
+        return;
+
+    xmlDocPtr pXmlRels = parseExport("word/_rels/document.xml.rels");
+    if (!pXmlRels)
+        return;
+
+    OUString bookmarkName = "#" + getXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:bookmarkStart", "name");
+    OUString anchor = getXPath(pXmlRels, 
"/rels:Relationships/rels:Relationship[@Id='rId3']", "Target");
+    CPPUNIT_ASSERT_EQUAL(anchor, bookmarkName);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx 
b/sw/source/filter/ww8/docxattributeoutput.cxx
index 46c44a0b8a87..77f12ac20a7c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -4851,6 +4851,12 @@ void DocxAttributeOutput::FlyFrameGraphic( const 
SwGrfNode* pGrfNode, const Size
         xPropSet->getPropertyValue("HyperLinkURL") >>= sURL;
         if(!sURL.isEmpty())
         {
+            if (sURL.startsWith("#") && sURL.indexOf(' ') != -1 && 
!sURL.endsWith("|outline") && !sURL.endsWith("|table") &&
+                !sURL.endsWith("|frame") && !sURL.endsWith("|graphic") && 
!sURL.endsWith("|ole") && !sURL.endsWith("|region"))
+            {
+                // Spaces are prohibited in bookmark name.
+                sURL = sURL.replace(' ', '_');
+            }
             sRelId = GetExport().GetFilter().addRelation( 
m_pSerializer->getOutputStream(),
                         oox::getRelationship(Relationship::HYPERLINK),
                         sURL, !sURL.startsWith("#") );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to