fdo#48023 fix RTF import of Russian characters without an encoding specified
lcl_GetDefaultTextEncodingForRTF() in editeng did the same.
This commit is contained in:
parent
2abba84aa7
commit
f8bda240a0
8
sw/qa/extras/rtftok/data/fdo48023.rtf
Normal file
8
sw/qa/extras/rtftok/data/fdo48023.rtf
Normal file
@ -0,0 +1,8 @@
|
||||
{\rtf
|
||||
{\fonttbl
|
||||
{\f1 Arial;}
|
||||
}
|
||||
\pard
|
||||
\f1 Ïðîãðàììèñò
|
||||
\par
|
||||
}
|
@ -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();
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user