[Libreoffice-commits] core.git: Branch 'libreoffice-5-2' - sw/qa sw/source

Michael Stahl mstahl at redhat.com
Wed Jun 15 21:39:35 UTC 2016


 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 744bd590fd2c39638e8df41a569cb2cc376e7450
Author: Michael Stahl <mstahl at redhat.com>
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)
    
    Change-Id: I6910e1afa0ee262ae0496cf1d3aa83ae3e537ad0
    (cherry picked from commit b4855bd63c05096df1a2da339133f243bb30d902)
    Reviewed-on: https://gerrit.libreoffice.org/26336
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

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 37a7018..f7a272d 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 b6eebc9..2c8894d 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;
 }


More information about the Libreoffice-commits mailing list