include/svl/languageoptions.hxx       |    5 ++-
 svl/source/config/ctloptions.cxx      |   49 ++++++++++++++++++++++++++++++++++
 svl/source/config/languageoptions.cxx |    5 +++
 3 files changed, 57 insertions(+), 2 deletions(-)

New commits:
commit 734499c11bcb0ed6a4a3eb2f8543dbcbcf29a11b
Author:     Jonathan Clark <[email protected]>
AuthorDate: Fri Oct 3 12:58:44 2025 -0600
Commit:     Jonathan Clark <[email protected]>
CommitDate: Tue Oct 7 02:32:01 2025 +0200

    tdf#168540 Restore automatically enabling RTL/CTL based on locale
    
    This change makes LibreOffice automatically enable RTL/CTL features
    based on locale. On Windows, in addition to locale, RTL/CTL features are
    enabled if RTL/CTL is installed as an input language.
    
    The code to do this was originally deleted roughly a decade ago, as part
    of an effort to make RTL/CTL support enabled by default. That default
    doesn't seem to be effective anymore, and without the removed code, this
    left LO in a state where all RTL/CTL users had to manually enable
    RTL/CTL support in order to see the features they expect.
    
    This reverts commit 23b92427e3c77fa8d04679ddcaf2dbd3e3580c5d.
    
    Change-Id: I15a9bf9ebdb759b49743d464a2ce6f9305e4c8d6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191835
    Tested-by: Jenkins
    Reviewed-by: Jonathan Clark <[email protected]>

diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx
index e780ed4751e5..9fd050dd7dd2 100644
--- a/include/svl/languageoptions.hxx
+++ b/include/svl/languageoptions.hxx
@@ -77,8 +77,9 @@ namespace SvtLanguageOptions
  */
 namespace SvtSystemLanguageOptions
 {
-    bool            isCJKKeyboardLayoutInstalled();
-};
+bool isCJKKeyboardLayoutInstalled();
+bool isCTLKeyboardLayoutInstalled();
+}
 
 #endif // INCLUDED_SVL_LANGUAGEOPTIONS_HXX
 
diff --git a/svl/source/config/ctloptions.cxx b/svl/source/config/ctloptions.cxx
index 21418e80072c..5f0de9d9e00c 100644
--- a/svl/source/config/ctloptions.cxx
+++ b/svl/source/config/ctloptions.cxx
@@ -20,12 +20,18 @@
 
 #include <svl/ctloptions.hxx>
 
+#include <svl/languageoptions.hxx>
 #include <unotools/configitem.hxx>
 #include <unotools/configmgr.hxx>
+#include <unotools/syslocale.hxx>
 #include <com/sun/star/uno/Any.h>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <i18nlangtag/lang.h>
+#include <i18nlangtag/languagetag.hxx>
+#include <i18nlangtag/mslangid.hxx>
 #include <osl/mutex.hxx>
 #include "itemholder2.hxx"
+#include <officecfg/System.hxx>
 #include <officecfg/Office/Common.hxx>
 
 using namespace ::com::sun::star;
@@ -289,6 +295,49 @@ void SvtCTLOptions_Impl::Load()
         }
     }
 
+    if (!m_bCTLFontEnabled)
+    {
+        SvtScriptType nScriptType = 
SvtLanguageOptions::GetScriptTypeOfLanguage(LANGUAGE_SYSTEM);
+        //system locale is CTL
+        bool bAutoEnableCTL = bool(nScriptType & SvtScriptType::COMPLEX);
+
+        if (!bAutoEnableCTL)
+        {
+            //windows secondary system locale is CTL
+            OUString sWin16SystemLocale = 
officecfg::System::L10N::SystemLocale::get();
+            LanguageType eSystemLanguage = LANGUAGE_NONE;
+            if (!sWin16SystemLocale.isEmpty())
+            {
+                eSystemLanguage
+                    = 
LanguageTag::convertToLanguageTypeWithFallback(sWin16SystemLocale);
+            }
+
+            if (eSystemLanguage != LANGUAGE_SYSTEM)
+            {
+                SvtScriptType nWinScript
+                    = 
SvtLanguageOptions::GetScriptTypeOfLanguage(eSystemLanguage);
+                bAutoEnableCTL = bool(nWinScript & SvtScriptType::COMPLEX);
+            }
+
+            //CTL keyboard is installed
+            if (!bAutoEnableCTL)
+            {
+                bAutoEnableCTL = 
SvtSystemLanguageOptions::isCTLKeyboardLayoutInstalled();
+            }
+        }
+
+        if (bAutoEnableCTL)
+        {
+            m_bCTLFontEnabled = true;
+            LanguageType nLanguage = 
SvtSysLocale().GetLanguageTag().getLanguageType();
+            //enable sequence checking for the appropriate languages
+            m_bCTLSequenceChecking = m_bCTLRestricted = m_bCTLTypeAndReplace
+                = (MsLangId::needsSequenceChecking(nLanguage)
+                   || MsLangId::needsSequenceChecking(LANGUAGE_SYSTEM));
+            Commit();
+        }
+    }
+
     m_bIsLoaded = true;
 }
 void SvtCTLOptions_Impl::SetCTLFontEnabled( bool _bEnabled )
diff --git a/svl/source/config/languageoptions.cxx 
b/svl/source/config/languageoptions.cxx
index 6391175c8550..df494ccb42f9 100644
--- a/svl/source/config/languageoptions.cxx
+++ b/svl/source/config/languageoptions.cxx
@@ -132,6 +132,11 @@ namespace SvtSystemLanguageOptions
     {
         return isKeyboardLayoutTypeInstalled(css::i18n::ScriptType::ASIAN);
     }
+
+    bool isCTLKeyboardLayoutInstalled()
+    {
+        return isKeyboardLayoutTypeInstalled(css::i18n::ScriptType::COMPLEX);
+    }
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Reply via email to