summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-09-04 16:51:59 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-09-07 12:32:26 +0200
commitf3d2a591db8b14d5d83ec6f7e7d4273b44f0a354 (patch)
treec7dcc1305506e388af8816d0084604282410b2c9 /sw
parentf5785760e288d84c1f961d05e7bcb3da45b5d2b6 (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. Conflicts: sw/source/core/doc/docnew.cxx Change-Id: Ic1afc82d7b59f1bd32815586f756e7e8408e5c6b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102150 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/doc.hxx2
-rw-r--r--sw/source/core/doc/doc.cxx5
-rw-r--r--sw/source/core/doc/docnew.cxx22
3 files changed, 29 insertions, 0 deletions
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 83f89c88db79..e110052bed2b 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -1647,6 +1647,8 @@ public:
/// Returns true if no dictionary can be found for any content
bool IsDictionaryMissing() { return meDictionaryMissing == MissingDictionary::True; }
+ void SetLanguage(const LanguageType eLang, const sal_uInt16 nId);
+
private:
// Copies master header to left / first one, if necessary - used by ChgPageDesc().
void CopyMasterHeader(const SwPageDesc &rChged, const SwFormatHeader &rHead, SwPageDesc &pDesc, bool bLeft, bool bFirst);
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 59ea8ea19672..d1f4725250d8 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -127,6 +127,7 @@
#include <osl/diagnose.h>
#include <osl/interlck.h>
#include <vbahelper/vbaaccesshelper.hxx>
+#include <editeng/langitem.hxx>
#include <calbck.hxx>
/* @@@MAINTAINABILITY-HORROR@@@
@@ -1839,5 +1840,9 @@ void SwDoc::SetMissingDictionaries( bool bIsMissing )
meDictionaryMissing = MissingDictionary::False;
};
+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 4d36e33b50d4..dd8e87042ef2 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -24,6 +24,7 @@
#include <proofreadingiterator.hxx>
#include <com/sun/star/text/XFlatParagraphIteratorProvider.hpp>
#include <com/sun/star/linguistic2/XProofreadingIterator.hpp>
+#include <com/sun/star/i18n/ScriptType.hpp>
#include <comphelper/processfactory.hxx>
#include <comphelper/random.hxx>
@@ -120,6 +121,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;
@@ -376,6 +380,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();
}