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

Miklos Vajna vmiklos at kemper.freedesktop.org
Thu Apr 26 02:19:55 PDT 2012


 sw/qa/extras/rtftok/data/fdo48037.rtf          |   13 +++++++++++++
 sw/qa/extras/rtftok/rtftok.cxx                 |   24 ++++++++++++++++++++++++
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    3 +++
 3 files changed, 40 insertions(+)

New commits:
commit 6f7defd274fd2f3b48356cc5f221dfca4fbd1290
Author: Miklos Vajna <vmiklos at suse.cz>
Date:   Wed Apr 25 17:51:45 2012 +0200

    fdo#48037 fix RTF import of localized fields

diff --git a/sw/qa/extras/rtftok/data/fdo48037.rtf b/sw/qa/extras/rtftok/data/fdo48037.rtf
new file mode 100644
index 0000000..af7217e
--- /dev/null
+++ b/sw/qa/extras/rtftok/data/fdo48037.rtf
@@ -0,0 +1,13 @@
+{\rtf1\ansi\ansicpg1252\uc1 \deff0
+\pard\plain \lang1036
+{\f31 VINCENNES, LE }
+{\field
+{\*\fldinst 
+DATE \\@ "d MMMM yyyy" \\* MERGEFORMAT
+}
+{\fldrslt 
+xxx
+}
+}
+\par
+}
diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx
index e416889..af32761 100644
--- a/sw/qa/extras/rtftok/rtftok.cxx
+++ b/sw/qa/extras/rtftok/rtftok.cxx
@@ -41,9 +41,11 @@
 #include <com/sun/star/text/XPageCursor.hpp>
 #include <com/sun/star/text/XTextDocument.hpp>
 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
 #include <com/sun/star/text/XTextViewCursorSupplier.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
 
 #include <rtl/oustringostreaminserter.hxx>
 #include <test/bootstrapfixture.hxx>
@@ -88,6 +90,7 @@ public:
     void testFdo48876();
     void testFdo48193();
     void testFdo44211();
+    void testFdo48037();
 
     CPPUNIT_TEST_SUITE(RtfModelTest);
 #if !defined(MACOSX) && !defined(WNT)
@@ -115,6 +118,7 @@ public:
     CPPUNIT_TEST(testFdo48023);
     CPPUNIT_TEST(testFdo48876);
     CPPUNIT_TEST(testFdo44211);
+    CPPUNIT_TEST(testFdo48037);
 #endif
     CPPUNIT_TEST_SUITE_END();
 
@@ -647,6 +651,26 @@ void RtfModelTest::testFdo44211()
     CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString());
 }
 
+void RtfModelTest::testFdo48037()
+{
+    load("fdo48037.rtf");
+
+    uno::Reference<util::XNumberFormatsSupplier> xNumberSupplier(mxComponent, uno::UNO_QUERY_THROW);
+    lang::Locale aUSLocale, aFRLocale;
+    aUSLocale.Language = "en";
+    aFRLocale.Language = "fr";
+    sal_Int32 nExpected = xNumberSupplier->getNumberFormats()->addNewConverted("d MMMM yyyy", aUSLocale, aFRLocale);
+
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration());
+    uno::Reference<beans::XPropertySet> xPropertySet(xFields->nextElement(), uno::UNO_QUERY);
+    sal_Int32 nActual = 0;
+    xPropertySet->getPropertyValue("NumberFormat") >>= nActual;
+
+    CPPUNIT_ASSERT_EQUAL(nExpected, nActual);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 4ec43a0..0e1a53f 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2164,6 +2164,9 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     if (nSprm > 0)
     {
         m_aStates.top().aCharacterSprms->push_back(make_pair(nSprm, pIntValue));
+        // Language is a character property, but we should store it at a paragraph level as well for fields.
+        if (nKeyword == RTF_LANG && m_bNeedPap)
+            m_aStates.top().aParagraphSprms->push_back(make_pair(nSprm, pIntValue));
         return 0;
     }
     // Trivial paragraph sprms.


More information about the Libreoffice-commits mailing list