[Libreoffice-commits] .: sw/qa writerfilter/source

Miklos Vajna vmiklos at kemper.freedesktop.org
Sat Apr 21 05:37:25 PDT 2012


 sw/qa/extras/rtftok/data/fdo48876.rtf          |    5 +++++
 sw/qa/extras/rtftok/rtftok.cxx                 |   17 +++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   10 ++++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)

New commits:
commit 99b875aee04a808fb28715fb0e143a2b00332832
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Sat Apr 21 12:53:22 2012 +0200

    fdo#48876 fix RTF import of \sl without \slmult

diff --git a/sw/qa/extras/rtftok/data/fdo48876.rtf b/sw/qa/extras/rtftok/data/fdo48876.rtf
new file mode 100644
index 0000000..49a6eb0
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/fdo48876.rtf
@@ -0,0 +1,5 @@
+{\rtf
+\sl54
+C
+\par
+}
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index 6870f02..0bb45e4 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -29,6 +29,8 @@
 #include <com/sun/star/drawing/XDrawPageSupplier.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/style/CaseMap.hpp>
+#include <com/sun/star/style/LineSpacing.hpp>
+#include <com/sun/star/style/LineSpacingMode.hpp>
 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
 #include <com/sun/star/table/BorderLine2.hpp>
 #include <com/sun/star/table/BorderLineStyle.hpp>
@@ -83,6 +85,7 @@ public:
     void testFdo39053();
     void testFdo48356();
     void testFdo48023();
+    void testFdo48876();
 
     CPPUNIT_TEST_SUITE(RtfModelTest);
 #if !defined(MACOSX) && !defined(WNT)
@@ -108,6 +111,7 @@ public:
     CPPUNIT_TEST(testFdo39053);
     CPPUNIT_TEST(testFdo48356);
     CPPUNIT_TEST(testFdo48023);
+    CPPUNIT_TEST(testFdo48876);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -599,6 +603,19 @@ void RtfModelTest::testFdo48023()
     CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
 }
 
+void RtfModelTest::testFdo48876()
+{
+    load("fdo48876.rtf");
+    uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+    uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+    CPPUNIT_ASSERT(xParaEnum->hasMoreElements());
+    uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
+    style::LineSpacing aSpacing;
+    xPropertySet->getPropertyValue("ParaLineSpacing") >>= aSpacing;
+    CPPUNIT_ASSERT_EQUAL(style::LineSpacingMode::MINIMUM, aSpacing.Mode);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index e50cc1f..750e473 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2379,9 +2379,15 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
             }
             break;
         case RTF_SL:
-            if (nParam > 0)
             {
-                // NS_sprm::LN_PDyaLine could be used, but that won't work with slmult
+                // This is similar to RTF_ABSH, negative value means 'exact', positive means 'at least'.
+                RTFValue::Pointer_t pValue(new RTFValue(NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_atLeast));
+                if (nParam < 0)
+                {
+                    pValue.reset(new RTFValue(NS_ooxml::LN_Value_wordprocessingml_ST_LineSpacingRule_exact));
+                    pIntValue.reset(new RTFValue(-nParam));
+                }
+                m_aStates.top().aParagraphAttributes->push_back(make_pair(NS_ooxml::LN_CT_Spacing_lineRule, pValue));
                 m_aStates.top().aParagraphAttributes->push_back(make_pair(NS_ooxml::LN_CT_Spacing_line, pIntValue));
             }
             break;


More information about the Libreoffice-commits mailing list