sw/qa/extras/rtftok/data/fdo48023.rtf | 8 ++++++++ sw/qa/extras/rtftok/rtftok.cxx | 25 +++++++++++++++++++++++++ writerfilter/source/rtftok/rtfdocumentimpl.cxx | 17 +++++++++++++++-- 3 files changed, 48 insertions(+), 2 deletions(-)
New commits: commit e0190ffa766dbe26a9d4e9dd29e00baaf0ccd5b9 Author: Miklos Vajna <vmik...@suse.cz> Date: Sat Apr 21 11:28:41 2012 +0200 rtftok: dump collected strings after encoding diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 2b30481..e50cc1f 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -818,9 +818,9 @@ int RTFDocumentImpl::resolveChars(char ch) m_aStates.top().aLevelNumbers.push_back(sal_Int32(ch)); return 0; } - SAL_INFO("writerfilter", OSL_THIS_FUNC << ": collected '" << aStr.getStr() << "'"); OUString aOUStr(OStringToOUString(aStr, m_aStates.top().nCurrentEncoding)); + SAL_INFO("writerfilter", OSL_THIS_FUNC << ": collected '" << aOUStr << "'"); if (m_aStates.top().nDestinationState == DESTINATION_COLORTABLE) { commit f8bda240a09b4ece1c3401874b3cc8f325dbcedb Author: Miklos Vajna <vmik...@suse.cz> Date: Sat Apr 21 11:25:18 2012 +0200 fdo#48023 fix RTF import of Russian characters without an encoding specified lcl_GetDefaultTextEncodingForRTF() in editeng did the same. diff --git a/sw/qa/extras/rtftok/data/fdo48023.rtf b/sw/qa/extras/rtftok/data/fdo48023.rtf new file mode 100644 index 0000000..6d6a0d9 --- /dev/null +++ b/sw/qa/extras/rtftok/data/fdo48023.rtf @@ -0,0 +1,8 @@ +{\rtf +{\fonttbl +{\f1 Arial;} +} +\pard +\f1 Ïðîãðàììèñò +\par +} diff --git a/sw/qa/extras/rtftok/rtftok.cxx b/sw/qa/extras/rtftok/rtftok.cxx index fa1321f..6870f02 100644 --- a/sw/qa/extras/rtftok/rtftok.cxx +++ b/sw/qa/extras/rtftok/rtftok.cxx @@ -82,6 +82,7 @@ public: void testFdo44176(); void testFdo39053(); void testFdo48356(); + void testFdo48023(); CPPUNIT_TEST_SUITE(RtfModelTest); #if !defined(MACOSX) && !defined(WNT) @@ -106,6 +107,7 @@ public: CPPUNIT_TEST(testFdo44176); CPPUNIT_TEST(testFdo39053); CPPUNIT_TEST(testFdo48356); + CPPUNIT_TEST(testFdo48023); #endif CPPUNIT_TEST_SUITE_END(); @@ -574,6 +576,29 @@ void RtfModelTest::testFdo48356() CPPUNIT_ASSERT_EQUAL(1, i); } +void RtfModelTest::testFdo48023() +{ + lang::Locale aLocale; + aLocale.Language = "ru"; + AllSettings aSettings(Application::GetSettings()); + AllSettings aSavedSettings(aSettings); + aSettings.SetLocale(aLocale); + Application::SetSettings(aSettings); + load("fdo48023.rtf"); + Application::SetSettings(aSavedSettings); + + 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(); + uno::Reference<container::XEnumerationAccess> xRangeEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRangeEnum = xRangeEnumAccess->createEnumeration(); + uno::Reference<text::XTextRange> xTextRange(xRangeEnum->nextElement(), uno::UNO_QUERY); + + // Implicit encoding detection based on locale was missing + OUString aExpected("ÐÑогÑаммиÑÑ", 22, RTL_TEXTENCODING_UTF8); + CPPUNIT_ASSERT_EQUAL(aExpected, xTextRange->getString()); +} + CPPUNIT_TEST_SUITE_REGISTRATION(RtfModelTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx index 2527cef..2b30481 100644 --- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx +++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx @@ -513,13 +513,26 @@ sal_uInt32 RTFDocumentImpl::getColorTable(sal_uInt32 nIndex) return 0; } +rtl_TextEncoding lcl_getDefaultTextEncoding() +{ + + const OUString& rLanguage = Application::GetSettings().GetLocale().Language; + + if (rLanguage == "ru" || rLanguage == "uk") + return RTL_TEXTENCODING_MS_1251; + if (rLanguage == "tr") + return RTL_TEXTENCODING_MS_1254; + else + return RTL_TEXTENCODING_MS_1252; +} + rtl_TextEncoding RTFDocumentImpl::getEncoding(sal_uInt32 nFontIndex) { if (!m_pSuperstream) { if (nFontIndex < m_aFontEncodings.size()) return m_aFontEncodings[nFontIndex]; - return 0; + return lcl_getDefaultTextEncoding(); } else return m_pSuperstream->getEncoding(nFontIndex);
_______________________________________________ Libreoffice-commits mailing list Libreoffice-commits@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits