[Libreoffice-commits] core.git: sw/qa sw/source
Tünde Tóth (via logerrit)
logerrit at kemper.freedesktop.org
Wed Sep 4 10:35:13 UTC 2019
sw/qa/extras/ooxmlexport/data/tdf127116.odt |binary
sw/qa/extras/ooxmlexport/ooxmlexport10.cxx | 5 ++++-
sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 11 +++++++++++
sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 2 +-
sw/source/filter/ww8/docxattributeoutput.cxx | 5 +++++
5 files changed, 21 insertions(+), 2 deletions(-)
New commits:
commit 79939168b47ae9c8089c93f88ed322dff67203fe
Author: Tünde Tóth <tundeth at gmail.com>
AuthorDate: Thu Aug 29 11:54:22 2019 +0200
Commit: László Németh <nemeth at numbertext.org>
CommitDate: Wed Sep 4 12:34:36 2019 +0200
tdf#127116 DOCX export: fix hyperlink to bookmark target with spaces
Conversion of spaces to underline characters was only in bookmark names,
but not in the URLs using these bookmark names.
Change-Id: Idb0d9945c79139d8a935ffcf6a3b29a9298c2270
Reviewed-on: https://gerrit.libreoffice.org/78267
Reviewed-by: László Németh <nemeth at numbertext.org>
Tested-by: László Németh <nemeth at numbertext.org>
diff --git a/sw/qa/extras/ooxmlexport/data/tdf127116.odt b/sw/qa/extras/ooxmlexport/data/tdf127116.odt
new file mode 100644
index 000000000000..2825b34c078f
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf127116.odt differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
index a57b1ad39f96..babff3bbec07 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport10.cxx
@@ -128,8 +128,11 @@ DECLARE_OOXMLEXPORT_TEST(testSmartart, "smartart.docx")
DECLARE_OOXMLEXPORT_TEST(testFdo69548, "fdo69548.docx")
{
+ if (!mbExported)
+ return;
+
// The problem was that the last space in target URL was removed
- CPPUNIT_ASSERT_EQUAL(OUString("#this is a bookmark"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
+ CPPUNIT_ASSERT_EQUAL(OUString("#this_is_a_bookmark"), getProperty<OUString>(getRun(getParagraph(1), 1), "HyperLinkURL"));
}
DECLARE_OOXMLEXPORT_TEST(testWpsOnly, "wps-only.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
index 295177486228..ed6bcc309c93 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx
@@ -640,6 +640,17 @@ DECLARE_OOXMLEXPORT_TEST(tdf118169, "tdf118169.docx")
CPPUNIT_ASSERT_EQUAL(OUString(u"őőőőőőőőőőőűűűű"), getProperty<OUString>(xPropertySet, "Label"));
}
+DECLARE_OOXMLEXPORT_TEST(testTdf127116, "tdf127116.odt")
+{
+ xmlDocPtr pXmlDoc = parseExport("word/document.xml");
+ if (!pXmlDoc)
+ return;
+
+ OUString bookmarkName = getXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:bookmarkStart", "name");
+ OUString anchor = getXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:hyperlink", "anchor");
+ CPPUNIT_ASSERT_EQUAL(anchor, bookmarkName);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
index d716ad535f84..e269a3bfba6e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx
@@ -651,7 +651,7 @@ DECLARE_OOXMLEXPORT_TEST(testToxmarkHyperlink, "toxmarkhyperlink.fodt")
DECLARE_OOXMLEXPORT_TEST(testOO34469, "ooo34469-1.odt")
{
if (xmlDocPtr pXmlDoc = parseExport())
- assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:hyperlink[1]", "anchor", "2.9.2.Creating New files|outline");
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:hyperlink[1]", "anchor", "2.9.2.Creating_New_files|outline");
}
DECLARE_OOXMLEXPORT_TEST(testOO39845, "ooo39845-7.odt")
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 0a0a8a94badb..debba8ae9ae1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2914,6 +2914,11 @@ bool DocxAttributeOutput::StartURL( const OUString& rUrl, const OUString& rTarge
}
}
}
+ if (sMark.indexOf(' ') != -1 && !sMark.endsWith("|table") && !sMark.endsWith("|frame") && !sMark.endsWith("|graphic") && !sMark.endsWith("|ole") && !sMark.endsWith("|region"))
+ {
+ // Spaces are prohibited in bookmark name.
+ sMark = sMark.replace(' ', '_');
+ }
m_pHyperlinkAttrList->add( FSNS( XML_w, XML_anchor ),
OUStringToOString( sMark, RTL_TEXTENCODING_UTF8 ).getStr( ) );
}
More information about the Libreoffice-commits
mailing list