summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-09-04 16:51:59 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-09-04 18:00:29 +0200
commit7d379bd8535b32a8d63a5fa8131cd9e82c7ff94f (patch)
treeca0524cb6048c799bd89e5bc373ef79f0816a2d3 /sw/source
parent74244dc85ee597ec6e9a40351d123257c342fbfb (diff)
sw: default to UI locale when language is missing
This means that when extras/source/shellnew/soffice.odt is opened, it'll always match the user's language. The same was already working in Calc and Impress. Change-Id: Ic1afc82d7b59f1bd32815586f756e7e8408e5c6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102051 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/doc.cxx5
-rw-r--r--sw/source/core/doc/docnew.cxx22
2 files changed, 27 insertions, 0 deletions
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 005927fbee51..a1f9ed152a46 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -93,6 +93,7 @@
#include <osl/diagnose.h>
#include <osl/interlck.h>
#include <vbahelper/vbaaccesshelper.hxx>
+#include <editeng/langitem.hxx>
#include <calbck.hxx>
#include <crsrsh.hxx>
@@ -1826,5 +1827,9 @@ void SwDoc::SetMissingDictionaries( bool bIsMissing )
meDictionaryMissing = MissingDictionary::True;
};
+void SwDoc::SetLanguage(const LanguageType eLang, const sal_uInt16 nId)
+{
+ mpAttrPool->SetPoolDefaultItem(SvxLanguageItem(eLang, nId));
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 70961797a7e6..8d61f215e602 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
#include <com/sun/star/frame/XModel.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/random.hxx>
@@ -100,6 +101,9 @@
#include <fmtmeta.hxx>
#include <svx/xfillit0.hxx>
+#include <unotools/configmgr.hxx>
+#include <i18nlangtag/mslangid.hxx>
+#include <editeng/langitem.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::document;
@@ -357,6 +361,24 @@ SwDoc::SwDoc()
}
mnRsidRoot = mnRsid;
+ if (!utl::ConfigManager::IsFuzzing())
+ {
+ // Make sure that in case the document language is not set, then we don't return
+ // LANGUAGE_DONTKNOW, but the UI locale.
+ const SvtLinguConfig aLinguConfig;
+ SvtLinguOptions aOptions;
+ aLinguConfig.GetOptions(aOptions);
+ LanguageType eLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage,
+ i18n::ScriptType::LATIN);
+ SetLanguage(eLang, RES_CHRATR_LANGUAGE);
+ eLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CJK,
+ i18n::ScriptType::ASIAN);
+ SetLanguage(eLang, RES_CHRATR_CJK_LANGUAGE);
+ eLang = MsLangId::resolveSystemLanguageByScriptType(aOptions.nDefaultLanguage_CTL,
+ i18n::ScriptType::COMPLEX);
+ SetLanguage(eLang, RES_CHRATR_CTL_LANGUAGE);
+ }
+
getIDocumentState().ResetModified();
}