From 6f7defd274fd2f3b48356cc5f221dfca4fbd1290 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 25 Apr 2012 17:51:45 +0200 Subject: fdo#48037 fix RTF import of localized fields --- 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(+) create mode 100644 sw/qa/extras/rtftok/data/fdo48037.rtf 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 #include #include +#include #include #include #include +#include #include #include @@ -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 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 xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference xFields(xFieldsAccess->createEnumeration()); + uno::Reference 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. -- cgit v1.2.3