diff options
author | Tünde Tóth <tundeth@gmail.com> | 2019-09-09 13:50:30 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2019-09-10 08:16:32 +0200 |
commit | 745f4cc374297a73ff5243cdd42a839e469619e7 (patch) | |
tree | 647a0321c0209f5635c50435ff64eecba83040fa | |
parent | eedf523c123a82bf3cbc5f389783e22d75b2e2c5 (diff) |
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 <nemeth@numbertext.org>
Tested-by: László Németh <nemeth@numbertext.org>
-rw-r--r-- | sw/qa/extras/ooxmlexport/data/tdf127362.odt | bin | 0 -> 9702 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 15 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 6 |
3 files changed, 21 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf127362.odt b/sw/qa/extras/ooxmlexport/data/tdf127362.odt Binary files differnew file mode 100644 index 000000000000..488f1528fd15 --- /dev/null +++ b/sw/qa/extras/ooxmlexport/data/tdf127362.odt 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("#") ); |