Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


Kohei Yoshida wrote:
This unit test expects that the UI is in English. Two English strings
are hard coded into this test: Sum and Total.

So, I looked into this this morning in hopes of finding a way to set UI
locale to en-US explicitly.

http://cgit.freedesktop.org/libreoffice/calc/commit/?h=libreoffice-3-4&id=5051d6a1f1e239fb38c60a227046111ec438a518

But at the moment this causes run-time exception.  I haven't
investigated deeper into this to find out why.

Hi,

so, finally got to the bottom of this - patches attached. I feel
*slightly* worried about pushing
0001-Fix-non-changeability-of-UI-locale.patch to -3-4 - the second
hunk has some potential to cause loops, so review appreciated.

Generally, and going forward - I'd be a bit happier if unit tests
would not assume en-US locale at all, since at least in theory, it's
possible to do a build w/o en-US at all...

Cheers,

-- Thorsten
From ba779c09c294998dd873068d221b75294135b0e2 Mon Sep 17 00:00:00 2001
From: Thorsten Behrens <tbehrens@novell.com>
Date: Fri, 6 May 2011 18:43:35 +0200
Subject: [PATCH] Force calc unit test to use en-US locale and strings

---
 sc/qa/unit/ucalc.cxx |   37 ++++++++++++++-----------------------
 1 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 0ab6d32..edeb303 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -49,6 +49,8 @@
 #include <cppuhelper/bootstrap.hxx>
 #include <comphelper/processfactory.hxx>
 #include <comphelper/oslfile2streamwrap.hxx>
+#include <i18npool/mslangid.hxx>
+#include <unotools/syslocaleoptions.hxx>
 
 #include <vcl/svapp.hxx>
 #include "scdll.hxx"
@@ -304,28 +306,6 @@ Test::Test()
     //of retaining references to the root ServiceFactory as its passed around
     comphelper::setProcessServiceFactory(xSM);
 
-#if 0
-    // TODO: attempt to explicitly set UI locale to en-US, to get the unit
-    // test to work under non-English build environment.  But this causes
-    // runtime exception....
-    uno::Reference<lang::XMultiServiceFactory> theConfigProvider =
-        uno::Reference<lang::XMultiServiceFactory> (
-            xSM->createInstance(
-                
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider"))), 
uno::UNO_QUERY_THROW);
-
-    uno::Sequence<uno::Any> theArgs(1);
-    OUString aLocalePath(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Linguistic/General"));
-    theArgs[0] <<= aLocalePath;
-    uno::Reference<beans::XPropertySet> xProp(
-        theConfigProvider->createInstanceWithArguments(
-            
OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationUpdateAccess")), 
theArgs), uno::UNO_QUERY_THROW);
-
-    OUString aLang(RTL_CONSTASCII_USTRINGPARAM("en-US"));
-    uno::Any aAny;
-    aAny <<= aLang;
-    xProp->setPropertyValue(OUString(RTL_CONSTASCII_USTRINGPARAM("UILocale")), aAny);
-#endif
-
     // initialise UCB-Broker
     uno::Sequence<uno::Any> aUcbInitSequence(2);
     aUcbInitSequence[0] <<= rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
@@ -339,8 +319,19 @@ Test::Test()
         rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.FileContentProvider"))), 
uno::UNO_QUERY);
     xUcb->registerContentProvider(xFileProvider, 
rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file")), sal_True);
 
-    InitVCL(xSM);
+    // force locale (and resource files loaded) to en-US
+    const LanguageType eLang=LANGUAGE_ENGLISH_US;
 
+    rtl::OUString aLang, aCountry;
+    MsLangId::convertLanguageToIsoNames(eLang, aLang, aCountry);
+    lang::Locale aLocale(aLang, aCountry, rtl::OUString());
+    ResMgr::SetDefaultLocale( aLocale );
+
+    SvtSysLocaleOptions aLocalOptions;
+    aLocalOptions.SetUILocaleConfigString(
+        MsLangId::convertLanguageToIsoString( eLang ) );
+
+    InitVCL(xSM);
     ScDLL::Init();
 
     oslProcessError err = osl_getProcessWorkingDir(&m_aPWDURL.pData);
-- 
1.7.1

From aac391874ad955afcf5c58ebd29680c035cbdeea Mon Sep 17 00:00:00 2001
From: Thorsten Behrens <tbehrens@novell.com>
Date: Fri, 6 May 2011 18:19:22 +0200
Subject: [PATCH] Fix non-changeability of UI locale

Enabled commented-out code, that actually permits changing the ui
locale without having to go through configuration.

This permits forcing en-us locale from the unit tests (which don't
have a working config)
---
 unotools/source/config/syslocaleoptions.cxx |   24 ++++++++++--------------
 1 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/unotools/source/config/syslocaleoptions.cxx 
b/unotools/source/config/syslocaleoptions.cxx
index 005b325..0697942 100644
--- a/unotools/source/config/syslocaleoptions.cxx
+++ b/unotools/source/config/syslocaleoptions.cxx
@@ -273,19 +273,16 @@ void SvtSysLocaleOptions_Impl::MakeRealLocale()
 
 void SvtSysLocaleOptions_Impl::MakeRealUILocale()
 {
-    if ( !m_aRealUILocale.Language.getLength() )
+    // as we can't switch UILocale at runtime, we only store changes in the configuration
+    m_aRealUILocale = lcl_str_to_locale( m_aUILocaleString );
+    if ( m_aRealUILocale.Language.getLength() )
     {
-        // as we can't switch UILocale at runtime, we only store changes in the configuration
-        m_aRealUILocale = lcl_str_to_locale( m_aUILocaleString );
-        if ( m_aRealUILocale.Language.getLength() )
-        {
-            m_eRealUILanguage = MsLangId::convertLocaleToLanguage( m_aRealUILocale );
-        }
-        else
-        {
-            m_eRealUILanguage = MsLangId::getSystemUILanguage();
-            MsLangId::convertLanguageToLocale( m_eRealUILanguage, m_aRealUILocale );
-        }
+        m_eRealUILanguage = MsLangId::convertLocaleToLanguage( m_aRealUILocale );
+    }
+    else
+    {
+        m_eRealUILanguage = MsLangId::getSystemUILanguage();
+        MsLangId::convertLanguageToLocale( m_eRealUILanguage, m_aRealUILocale );
     }
 }
 
@@ -399,13 +396,12 @@ void SvtSysLocaleOptions_Impl::SetUILocaleString( const OUString& rStr )
     if (!m_bROUILocale && rStr != m_aUILocaleString )
     {
         m_aUILocaleString = rStr;
-/*
+
         // as we can't switch UILocale at runtime, we only store changes in the configuration
         MakeRealUILocale();
         MsLangId::setConfiguredSystemLanguage( m_eRealUILanguage );
         SetModified();
         NotifyListeners( SYSLOCALEOPTIONS_HINT_UILOCALE );
-*/
     }
 }
 
-- 
1.7.1

Attachment: pgp69EdZlj6i0.pgp
Description: PGP signature


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.