Hi Stephan,

On Wednesday, 2010-04-14 22:07:46 +0200, Stephan Bergmann wrote:

> qadevOOo/tests/java/ifc/accessibility/_XAccesibleContext.java checks
> that a com.sun.star.accessibility.XAccessibleContext.getLocale UNO
> method returns a com.sun.star.lang.Locale that has a non-empty Country
> member.  The implementation of that method
> (toolkit/source/awt/vclxaccessiblecomponent.cxx) simply returns
> Application::GetSettings().GetLocale().  That
> (vcl/source/app/settings.cxx) in turn calls SvtSysLocale::GetLocale,
> which (unotools/source/misc/syslocale.cxx) in turn calls
> SvtSysLocaleOptions::GetRealLocale, which
> (unotools/source/config/syslocaleoptions.cxx) relies on
> SvtSysLocaleOptions_Impl::MakeRealLocale.  This internally uses
> 
>   m_eRealLanguage = MsLangId::getSystemLanguage();
>   MsLangId::convertLanguageToLocale(m_eRealLanguage, m_aRealLanguage);

> First, MsLangId::getSystemLanguage
> (i18npool/inc/i18npool/mslangid.hxx) calls
> getPlatformSystemLanguageImpl (i18npool/source/isolang/inunx.cxx).
> That, for MACOSX, uses osl_getProcessLocale to obtain a locale (with
> rLang="en" and rCountry="DE" in my case, as it internally favors
> CFPreferencesCopyAppValue("AppleLocale") over inspecting the LANG/LC_*
> environment variables),

That originates back from MacOS!X. Should it inspect LANG/LC_* first
also for MacOSX and fall back to osl_getProcessLocale() only if not set?

> but then calls MsLangId::convertIsoNamesToLanguage(rLang, rCountry),
> which has nothing more specific than LANGUAGE_ENGLISH to represent
> that odd language/country combination.

That LANGUAGE_ENGLISH (and a few other) with primary language only is
broken anyway, see comments in i18npool/source/isolang/isolang.cxx

I didn't find time yet to clean that stuff up, needs to investigate
everywhere's usage.

> Thus, second, MsLangId::convertLanguageToLocale has lost the country
> information ("DE"), so will produce a Locale instance that only has
> language information ("en").  Up all the levels again, this will make
> the unoapi check in _XAccessibleContext.java fail.

That's bad.


> Now, where is the error?
> 
> - SvtSysLocaleOptions_Impl::MakeRealLocale
> (unotools/source/config/syslocaleoptions.cxx) obtaining a LanguageType
> enum value to create a Locale from it looks wrong, as the LanguageType
> enum obviously cannot encode all the relevant information.

We need to obtain a valid LanguageType ID as that usually is the only
thing the core knows about and is used in attribution, items and so on.
Don't be mislead by the name LanguageType, in fact those are IDs
encoding both, language and country. We should fall back to a fully
resolvable and back and forth convertible locale though for the two,
system locale and system UI locale. That basically means to obtain the
final values through the MsLangId::convertLocaleToLanguageWithFallback()
method.

When and where to do this though must be carefully considered. Probably
both, the i18npool getPlatformSystemLanguageImpl() and
SvtSysLocaleOptions_Impl::MakeRealLocale() have to do it, the latter for
the case where language is not empty.

Care to write me an issue for this?


> - However, is _XAccessibleContext.java correct in requiring
> a non-empty Country member?

No idea. What does it use the locale for, and why isn't it satisfied
with a language only? Note also that there are some locales that will
never have a country assigned, for example Esperanto and Interlingua.

> The documentation of the
> com.sun.star.lang.Locale UNO struct specifies for the Country member:
> "If this field contains an empty string, the meaning depends on the
> context."  I lack the context here to judge whether
> com.sun.star.accessibility.XAccessibleContext.getLocale may
> legitimately return a Locale that "depends on the context" in this
> way...

I can't judge either.

  Eike

-- 
 OOo/SO Calc core developer. Number formatter stricken i18n transpositionizer.
 SunSign   0x87F8D412 : 2F58 5236 DB02 F335 8304  7D6C 65C9 F9B5 87F8 D412
 OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
 Please don't send personal mail to the [email protected] account, which I use for
 mailing lists only and don't read from outside Sun. Use [email protected] Thanks.

Attachment: pgpL8OsJGe8wT.pgp
Description: PGP signature

Reply via email to