const gchar* GetLocaleCB(AtkObject* aAtkObj) { AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj); if (!accWrap) return nullptr; nsAutoString locale; accWrap->Language(locale); return AccessibleWrap::ReturnString(locale); }
const gchar * getDocumentLocaleCB(AtkDocument *aDocument) { AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument)); if (!accWrap) return nullptr; nsAutoString locale; accWrap->Language(locale); return locale.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(locale); }
const gchar * getDocumentLocaleCB(AtkDocument *aDocument) { nsAutoString locale; AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument)); if (accWrap) { accWrap->Language(locale); } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aDocument))) { proxy->Language(locale); } return locale.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(locale); }
STDMETHODIMP ia2Accessible::get_locale(IA2Locale* aLocale) { if (!aLocale) return E_INVALIDARG; // Language codes consist of a primary code and a possibly empty series of // subcodes: language-code = primary-code ( "-" subcode )* // Two-letter primary codes are reserved for [ISO639] language abbreviations. // Any two-letter subcode is understood to be a [ISO3166] country code. AccessibleWrap* acc = static_cast<AccessibleWrap*>(this); if (acc->IsDefunct()) return CO_E_OBJNOTCONNECTED; nsAutoString lang; acc->Language(lang); // If primary code consists from two letters then expose it as language. int32_t offset = lang.FindChar('-', 0); if (offset == -1) { if (lang.Length() == 2) { aLocale->language = ::SysAllocString(lang.get()); return S_OK; } } else if (offset == 2) { aLocale->language = ::SysAllocStringLen(lang.get(), 2); // If the first subcode consists from two letters then expose it as // country. offset = lang.FindChar('-', 3); if (offset == -1) { if (lang.Length() == 5) { aLocale->country = ::SysAllocString(lang.get() + 3); return S_OK; } } else if (offset == 5) { aLocale->country = ::SysAllocStringLen(lang.get() + 3, 2); } } // Expose as a string if primary code or subcode cannot point to language or // country abbreviations or if there are more than one subcode. aLocale->variant = ::SysAllocString(lang.get()); return S_OK; }