[Libreoffice-commits] core.git: 2 commits - reportdesign/source sw/qa sw/source

Michael Stahl mstahl at redhat.com
Wed Jun 15 16:16:22 UTC 2016


 reportdesign/source/core/api/ReportDefinition.cxx |    5 +++
 sw/qa/extras/rtfexport/data/hyperlink_empty.rtf   |    8 ++++++
 sw/qa/extras/rtfexport/rtfexport.cxx              |   11 ++++++++
 sw/source/filter/ww8/rtfattributeoutput.cxx       |   28 +++++++++++-----------
 4 files changed, 38 insertions(+), 14 deletions(-)

New commits:
commit b4855bd63c05096df1a2da339133f243bb30d902
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

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 a0da235..4e87ecb 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;
 }
commit cd7671ef5e3102e91c68588d1ccc39d2521af561
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Jun 15 14:55:06 2016 +0200

    tdf#100325 reportdesign: try to set URL as DocumentBaseURL
    
    ... if it is missing, similar to what SfxObjectShell::DoLoad() does.
    
    Change-Id: I5b0ae1f892355a5e9786d590c821656b58d29cf2

diff --git a/reportdesign/source/core/api/ReportDefinition.cxx b/reportdesign/source/core/api/ReportDefinition.cxx
index f4ccbb0..fb30a37 100644
--- a/reportdesign/source/core/api/ReportDefinition.cxx
+++ b/reportdesign/source/core/api/ReportDefinition.cxx
@@ -1694,6 +1694,11 @@ void SAL_CALL OReportDefinition::load( const uno::Sequence< beans::PropertyValue
         throw uno::RuntimeException();
     }
 
+    if (!aArguments.has("DocumentBaseURL") && !sURL.isEmpty())
+    {
+        aArguments.put("DocumentBaseURL", sURL);
+    }
+
     impl_loadFromStorage_nolck_throw( xDocumentStorage, aArguments.getPropertyValues() );
     // TODO: do we need to take ownership of the storage? In opposite to loadFromStorage, we created the storage
     // ourself here, and perhaps this means we're also responsible for it ...?


More information about the Libreoffice-commits mailing list