sw/qa/extras/rtfexport/data/hyperlink_empty.rtf | 8 ++++++ sw/qa/extras/rtfexport/rtfexport.cxx | 11 +++++++++ sw/source/filter/ww8/rtfattributeoutput.cxx | 28 ++++++++++++------------ 3 files changed, 33 insertions(+), 14 deletions(-)
New commits: commit f687c57465292e940f9e0d69aa2e4ee3376bd569 Author: Michael Stahl <[email protected]> Date: Wed Jun 15 18:07:12 2016 +0200 tdf#100105 sw: RTF export: fix empty hyperlinks For empty hyperlinks the EndURL() is called immediately after StartURL() Due to the way the various buffers are written, the group closing braces are written before the groups are opened, which is rather invalid. Using the m_aRun buffer instead of m_aStyles appears to fix the problem. (regression from b8907bf3d3b37c686a414ffbbd2d732348aab5b9) (cherry picked from commit b4855bd63c05096df1a2da339133f243bb30d902) Reviewed-on: https://gerrit.libreoffice.org/26336 Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Stahl <[email protected]> (cherry picked from commit 744bd590fd2c39638e8df41a569cb2cc376e7450) Change-Id: I6910e1afa0ee262ae0496cf1d3aa83ae3e537ad0 Reviewed-on: https://gerrit.libreoffice.org/26699 Tested-by: Jenkins <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> diff --git a/sw/qa/extras/rtfexport/data/hyperlink_empty.rtf b/sw/qa/extras/rtfexport/data/hyperlink_empty.rtf new file mode 100644 index 0000000..bdd263d --- /dev/null +++ b/sw/qa/extras/rtfexport/data/hyperlink_empty.rtf @@ -0,0 +1,8 @@ +{\rtf1 +{\field +{\*\fldinst HYPERLINK "http://example.net"} +{\fldrslt } +} +foobar +\par +} diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx index 11b92e8..d22ebc1 100644 --- a/sw/qa/extras/rtfexport/rtfexport.cxx +++ b/sw/qa/extras/rtfexport/rtfexport.cxx @@ -523,6 +523,17 @@ DECLARE_RTFEXPORT_TEST(testHyperlink, "hyperlink.rtf") CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 3, "!"), "HyperLinkURL")); } +DECLARE_RTFEXPORT_TEST(testHyperlinkTdf100105, "hyperlink_empty.rtf") +{ + // export of empty link was invalid, group was closed before it was opened + uno::Reference<text::XTextDocument> xTextDoc(mxComponent, uno::UNO_QUERY); + uno::Reference<text::XTextCursor> xCursor(xTextDoc->getText()->createTextCursor()); + xCursor->gotoStart(false); + CPPUNIT_ASSERT_EQUAL(OUString("http://example.net"), getProperty<OUString>(xCursor, "HyperLinkURL")); + // getRun doesn't provide a 0-length hyperlink + CPPUNIT_ASSERT_EQUAL(OUString(""), getProperty<OUString>(getRun(getParagraph(1), 1, "foobar"), "HyperLinkURL")); +} + DECLARE_RTFEXPORT_TEST(test78758, "fdo78758.rtf") { CPPUNIT_ASSERT_EQUAL(OUString("#__RefHeading___Toc264438068"), diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 9e1c583..4e088f1 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -555,27 +555,27 @@ bool RtfAttributeOutput::StartURL(const OUString& rUrl, const OUString& rTarget) // Ignore hyperlink without an URL. if (!rUrl.isEmpty()) { - m_aStyles.append('{'); - m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FIELD); - m_aStyles.append('{'); - m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE); - m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FLDINST); - m_aStyles.append(" HYPERLINK "); + m_aRun->append('{'); + m_aRun->append(OOO_STRING_SVTOOLS_RTF_FIELD); + m_aRun->append('{'); + m_aRun->append(OOO_STRING_SVTOOLS_RTF_IGNORE); + m_aRun->append(OOO_STRING_SVTOOLS_RTF_FLDINST); + m_aRun->append(" HYPERLINK "); OUString sURL(rUrl); - m_aStyles.append("\""); - m_aStyles.append(msfilter::rtfutil::OutString(sURL, m_rExport.eCurrentEncoding)); - m_aStyles.append("\" "); + m_aRun->append("\""); + m_aRun->append(msfilter::rtfutil::OutString(sURL, m_rExport.eCurrentEncoding)); + m_aRun->append("\" "); if (!rTarget.isEmpty()) { - m_aStyles.append("\\\\t \""); - m_aStyles.append(msfilter::rtfutil::OutString(rTarget, m_rExport.eCurrentEncoding)); - m_aStyles.append("\" "); + m_aRun->append("\\\\t \""); + m_aRun->append(msfilter::rtfutil::OutString(rTarget, m_rExport.eCurrentEncoding)); + m_aRun->append("\" "); } - m_aStyles.append("}"); - m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {"); + m_aRun->append("}"); + m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " {"); } return true; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
