[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.2' - sw/inc sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Mon Sep 7 10:32:59 UTC 2020
sw/inc/doc.hxx | 2 ++
sw/source/core/doc/doc.cxx | 5 +++++
sw/source/core/doc/docnew.cxx | 22 ++++++++++++++++++++++
3 files changed, 29 insertions(+)
New commits:
commit f3d2a591db8b14d5d83ec6f7e7d4273b44f0a354
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Fri Sep 4 16:51:59 2020 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Sep 7 12:32:26 2020 +0200
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 at gmail.com>
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
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();
}
More information about the Libreoffice-commits
mailing list