[PATCH] fdo#48023 fix RTF import of Russian characters without an encoding specified

Miklos Vajna vmiklos at suse.cz
Sat Apr 21 02:25:18 PDT 2012


lcl_GetDefaultTextEncodingForRTF() in editeng did the same.
---
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 023b6c6..f482077 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -549,13 +549,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);
-- 
1.7.7


--LZvS9be/3tNcYl/X--


More information about the LibreOffice mailing list