summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-06-15 18:07:12 +0200
committerMichael Stahl <mstahl@redhat.com>2016-06-15 21:39:01 +0000
commit744bd590fd2c39638e8df41a569cb2cc376e7450 (patch)
treeb7a7918a177655d1c06b3e531fc60678518fc650 /sw
parent24114cadf10aa9d843d6735d90fcddee3747724d (diff)
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) Change-Id: I6910e1afa0ee262ae0496cf1d3aa83ae3e537ad0 (cherry picked from commit b4855bd63c05096df1a2da339133f243bb30d902) Reviewed-on: https://gerrit.libreoffice.org/26336 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/rtfexport/data/hyperlink_empty.rtf8
-rw-r--r--sw/qa/extras/rtfexport/rtfexport.cxx11
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx28
3 files changed, 33 insertions, 14 deletions
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 000000000000..bdd263df06da
--- /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 37a70184dcdd..f7a272d035fd 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 b6eebc9f6d17..2c8894d0cd95 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -553,26 +553,26 @@ 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 ");
- m_aStyles.append("\"");
- m_aStyles.append(msfilter::rtfutil::OutString(rUrl, m_rExport.m_eCurrentEncoding));
- m_aStyles.append("\" ");
+ m_aRun->append("\"");
+ m_aRun->append(msfilter::rtfutil::OutString(rUrl, m_rExport.m_eCurrentEncoding));
+ m_aRun->append("\" ");
if (!rTarget.isEmpty())
{
- m_aStyles.append("\\\\t \"");
- m_aStyles.append(msfilter::rtfutil::OutString(rTarget, m_rExport.m_eCurrentEncoding));
- m_aStyles.append("\" ");
+ m_aRun->append("\\\\t \"");
+ m_aRun->append(msfilter::rtfutil::OutString(rTarget, m_rExport.m_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;
}