[Libreoffice-commits] core.git: stoc/source

Eike Rathke erack at redhat.com
Wed Oct 26 22:00:46 UTC 2016


 stoc/source/javavm/javavm.cxx |   73 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 64 insertions(+), 9 deletions(-)

New commits:
commit effb27326746945763bda70e2c375c86a40a05fc
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Oct 25 16:48:11 2016 +0200

    Java 7 DISPLAY and FORMAT locale and script field
    
    Change-Id: Ie62105c60a327f6e5cbcf1a801b341e988471d73
    Reviewed-on: https://gerrit.libreoffice.org/30308
    Reviewed-by: Eike Rathke <erack at redhat.com>
    Tested-by: Eike Rathke <erack at redhat.com>

diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx
index b27df6f..b780b7a 100644
--- a/stoc/source/javavm/javavm.cxx
+++ b/stoc/source/javavm/javavm.cxx
@@ -366,27 +366,82 @@ void getDefaultLocaleFromConfig(
     xConfRegistry_simple->open("org.openoffice.Setup", true, false);
     css::uno::Reference<css::registry::XRegistryKey> xRegistryRootKey = xConfRegistry_simple->getRootKey();
 
-    // read locale
-    css::uno::Reference<css::registry::XRegistryKey> locale = xRegistryRootKey->openKey("L10N/ooLocale");
-    if(locale.is() && !locale->getStringValue().isEmpty()) {
-        LanguageTag aLanguageTag( locale->getStringValue());
+    // Since 1.7 Java knows DISPLAY and FORMAT locales, which match our UI and
+    // system locale. See
+    // http://hg.openjdk.java.net/jdk8u/jdk8u-dev/jdk/file/569b1b644416/src/share/classes/java/util/Locale.java
+    // https://docs.oracle.com/javase/tutorial/i18n/locale/scope.html
+    // https://docs.oracle.com/javase/7/docs/api/java/util/Locale.html
+
+    // Read UI language/locale.
+    css::uno::Reference<css::registry::XRegistryKey> xUILocale = xRegistryRootKey->openKey("L10N/ooLocale");
+    if(xUILocale.is() && !xUILocale->getStringValue().isEmpty()) {
+        LanguageTag aLanguageTag( xUILocale->getStringValue());
         OUString language;
         OUString script;
         OUString country;
-        // Java knows nothing but plain old ISO language and country codes.
+        // Java knows nothing but plain old ISO codes, unless Locale.Builder or
+        // Locale.forLanguageTag() are used, or non-standardized variant field
+        // content which we ignore.
         aLanguageTag.getIsoLanguageScriptCountry( language, script, country);
 
         if(!language.isEmpty()) {
-            OUString prop = "user.language="
-                          + language;
+            OUString prop = "user.language=" + language;
+            pjvm->pushProp(prop);
+        }
 
+        // As of Java 7 also script is supported.
+        if(!script.isEmpty()) {
+            OUString prop = "user.script=" + script;
             pjvm->pushProp(prop);
         }
 
         if(!country.isEmpty()) {
-            OUString prop = "user.country="
-                          + country;
+            OUString prop = "user.country=" + country;
+            pjvm->pushProp(prop);
+        }
+
+        // Java 7 DISPLAY category is our UI language/locale.
+        if(!language.isEmpty()) {
+            OUString prop = "user.language.display=" + language;
+            pjvm->pushProp(prop);
+        }
 
+        if(!script.isEmpty()) {
+            OUString prop = "user.script.display=" + script;
+            pjvm->pushProp(prop);
+        }
+
+        if(!country.isEmpty()) {
+            OUString prop = "user.country.display=" + country;
+            pjvm->pushProp(prop);
+        }
+    }
+
+    // Read system locale.
+    css::uno::Reference<css::registry::XRegistryKey> xLocale = xRegistryRootKey->openKey("L10N/ooSetupSystemLocale");
+    if(xLocale.is() && !xLocale->getStringValue().isEmpty()) {
+        LanguageTag aLanguageTag( xLocale->getStringValue());
+        OUString language;
+        OUString script;
+        OUString country;
+        // Java knows nothing but plain old ISO codes, unless Locale.Builder or
+        // Locale.forLanguageTag() are used, or non-standardized variant field
+        // content which we ignore.
+        aLanguageTag.getIsoLanguageScriptCountry( language, script, country);
+
+        // Java 7 FORMAT category is our system locale.
+        if(!language.isEmpty()) {
+            OUString prop = "user.language.format=" + language;
+            pjvm->pushProp(prop);
+        }
+
+        if(!script.isEmpty()) {
+            OUString prop = "user.script.format=" + script;
+            pjvm->pushProp(prop);
+        }
+
+        if(!country.isEmpty()) {
+            OUString prop = "user.country.format=" + country;
             pjvm->pushProp(prop);
         }
     }


More information about the Libreoffice-commits mailing list