writerfilter/source/rtftok/rtfdispatchvalue.cxx |   32 +++++++++++++++++++-----
 1 file changed, 26 insertions(+), 6 deletions(-)

New commits:
commit f26bbdb386f9e66b1a154d0589b1a446ea2dd8d5
Author: Mike Kaganski <mike.kagan...@collabora.com>
Date:   Tue Jan 24 22:52:10 2017 +0300

    tdf#105511: use LO language settings to set default RTF language
    
    ... when file containd ansicpg0/cpg0
    This allows user to change this setting and get proper document
    language. Similar technique is used currently for DXF and WMF.
    
    Change-Id: I884a973d98384c92d45a1d2e19720ffe3e6aa20d
    Reviewed-on: https://gerrit.libreoffice.org/33505
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx 
b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
index cfef7c6..a63eee1 100644
--- a/writerfilter/source/rtftok/rtfdispatchvalue.cxx
+++ b/writerfilter/source/rtftok/rtfdispatchvalue.cxx
@@ -24,8 +24,25 @@
 #include <rtfreferenceproperties.hxx>
 #include <rtfskipdestination.hxx>
 
+#include "officecfg/Setup.hxx"
+#include "officecfg/Office/Linguistic.hxx"
+#include "unotools/wincodepage.hxx"
+
 using namespace com::sun::star;
 
+namespace
+{
+
+OUString getLODefaultLanguage()
+{
+    OUString 
result(::officecfg::Office::Linguistic::General::DefaultLocale::get());
+    if (result.isEmpty())
+        result = ::officecfg::Setup::L10N::ooSetupSystemLocale::get();
+    return result;
+}
+
+}
+
 namespace writerfilter
 {
 
@@ -374,15 +391,18 @@ RTFError RTFDocumentImpl::dispatchValue(RTFKeyword 
nKeyword, int nParam)
     }
     break;
     case RTF_ANSICPG:
+    case RTF_CPG:
     {
-        m_aDefaultState.nCurrentEncoding = 
rtl_getTextEncodingFromWindowsCodePage(nParam);
-        m_aStates.top().nCurrentEncoding = 
rtl_getTextEncodingFromWindowsCodePage(nParam);
+        rtl_TextEncoding nEncoding = (nParam == 0) ?
+            
utl_getWinTextEncodingFromLangStr(getLODefaultLanguage().toUtf8().getStr()) :
+            rtl_getTextEncodingFromWindowsCodePage(nParam);
+        if (nKeyword == RTF_ANSICPG)
+            m_aDefaultState.nCurrentEncoding = nEncoding;
+        else
+            m_nCurrentEncoding = nEncoding;
+        m_aStates.top().nCurrentEncoding = nEncoding;
     }
     break;
-    case RTF_CPG:
-        m_nCurrentEncoding = rtl_getTextEncodingFromWindowsCodePage(nParam);
-        m_aStates.top().nCurrentEncoding = m_nCurrentEncoding;
-        break;
     case RTF_CF:
     {
         RTFSprms aAttributes;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to