diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2017-01-24 22:52:10 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-01-25 06:46:53 +0000 |
commit | f26bbdb386f9e66b1a154d0589b1a446ea2dd8d5 (patch) | |
tree | c36c033bee75e52c3f317ae748fb5b5610008915 /writerfilter | |
parent | 999183f7fddd69903e028a35caa6ff85e255f13e (diff) |
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 <ci@libreoffice.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'writerfilter')
-rw-r--r-- | writerfilter/source/rtftok/rtfdispatchvalue.cxx | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/writerfilter/source/rtftok/rtfdispatchvalue.cxx b/writerfilter/source/rtftok/rtfdispatchvalue.cxx index cfef7c665bb2..a63eee1c0f9a 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; |