summaryrefslogtreecommitdiff
path: root/configmgr
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2009-11-23 17:12:51 +0100
committersb <sb@openoffice.org>2009-11-23 17:12:51 +0100
commit8f48a583e09dee3b0e1eb202c161ad978efb70b3 (patch)
tree93772013cc2547645de876c0e28d01a4b2c33451 /configmgr
parentec35afc6182e6d5acc8f55045e5c85e636d6bf90 (diff)
sb111: #i101955# fixed locale matching
Diffstat (limited to 'configmgr')
-rw-r--r--configmgr/source/childaccess.cxx36
-rw-r--r--configmgr/source/configurationprovider.cxx2
2 files changed, 24 insertions, 14 deletions
diff --git a/configmgr/source/childaccess.cxx b/configmgr/source/childaccess.cxx
index 11bb5b016789..77c4f77bc4ba 100644
--- a/configmgr/source/childaccess.cxx
+++ b/configmgr/source/childaccess.cxx
@@ -282,25 +282,35 @@ css::uno::Any ChildAccess::asValue() {
{
rtl::OUString locale(getRootAccess()->getLocale());
if (!Components::allLocales(locale)) {
- rtl::Reference< ChildAccess > child(getChild(locale));
+ // Find best match using an adaption of RFC 4647 lookup matching
+ // rules, removing "-" or "_" delimited segments from the end;
+ // defaults are the empty string locale, the "en-US" locale, the
+ // first child (if any), or a nil value (even though it may be
+ // illegal for the given property), in that order:
+ rtl::Reference< ChildAccess > child;
+ for (;;) {
+ child = getChild(locale);
+ if (child.is() || locale.getLength() == 0) {
+ break;
+ }
+ sal_Int32 i = locale.getLength() - 1;
+ while (i > 0 && locale[i] != '-' && locale[i] != '_') {
+ --i;
+ }
+ locale = locale.copy(0, i);
+ }
if (!child.is()) {
- //TODO: find best match
- child = getChild(rtl::OUString());
+ child = getChild(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en-US")));
if (!child.is()) {
- child = getChild(
- rtl::OUString(
- RTL_CONSTASCII_USTRINGPARAM("en-US")));
- if (!child.is()) {
- std::vector< rtl::Reference< ChildAccess > > all(
- getAllChildren());
- if (all.empty()) {
- return css::uno::Any();
- }
+ std::vector< rtl::Reference< ChildAccess > > all(
+ getAllChildren());
+ if (!all.empty()) {
child = all.front();
}
}
}
- return child->asValue();
+ return child.is() ? child->asValue() : css::uno::Any();
}
}
break;
diff --git a/configmgr/source/configurationprovider.cxx b/configmgr/source/configurationprovider.cxx
index 72d42154c66e..ea72fd86a6d4 100644
--- a/configmgr/source/configurationprovider.cxx
+++ b/configmgr/source/configurationprovider.cxx
@@ -252,7 +252,7 @@ Service::createInstanceWithArguments(
//TODO: should the Access use the dynamically changing locale_ instead?
locale = locale_;
if (locale.getLength() == 0) {
- locale = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en"));//TODO
+ locale = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("en-US"));
}
}
bool update;