summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-04-25 17:51:45 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-04-26 11:20:27 +0200
commit6f7defd274fd2f3b48356cc5f221dfca4fbd1290 (patch)
tree364b087cefbc3b7e9017e35d99d1ff0832a29f25
parenta3a9fe4c93af76f0287bf940763409ea346cf186 (diff)
fdo#48037 fix RTF import of localized fields
-rw-r--r--sw/qa/extras/rtftok/data/fdo48037.rtf13
-rw-r--r--sw/qa/extras/rtftok/rtftok.cxx24
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx3
3 files changed, 40 insertions, 0 deletions
diff --git a/sw/qa/extras/rtftok/data/fdo48037.rtf b/sw/qa/extras/rtftok/data/fdo48037.rtf
new file mode 100644
index 000000000000..af7217e49428
--- /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 e4168891c491..af327611784e 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 4ec43a0b052e..0e1a53faef3e 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.