22#include <com/sun/star/i18n/CollatorOptions.hpp>
23#include <com/sun/star/i18n/LocaleData2.hpp>
45 const OUString& str2, sal_Int32 off2, sal_Int32 len2)
48 return cachedItem->xC->compareSubstring(str1, off1, len1, str2, off2, len2);
52 for (
int i = 0;
i < len1 &&
i < len2;
i++)
53 if (unistr1[
i] != unistr2[
i])
54 return unistr1[
i] < unistr2[
i] ? -1 : 1;
55 return len1 == len2 ? 0 : (len1 < len2 ? -1 : 1);
62 return cachedItem->xC->compareString(in_str1, in_str2);
72 auto pImpl = std::find_if(imp.begin(), imp.end(),
73 [](
const Implementation& rImp) { return rImp.isDefault; });
74 if (pImpl != imp.end())
99 sal_Int32 options = std::accumulate(collatorOptions.begin(), collatorOptions.end(),
100 sal_Int32(0), [](sal_Int32 nSum, sal_Int32 nOpt) {
return nSum | nOpt; });
110 auto pBegin = list.getArray();
113 for (
const auto& rImpl : imp) {
116 if (rImpl.isDefault && pId != pBegin)
117 std::swap(*pBegin, *pId);
129 std::transform(option_str.begin(), option_str.end(), option_int.getArray(), [](
const OUString& rOpt) {
130 return rOpt ==
"IGNORE_CASE" ? CollatorOptions::CollatorOptions_IGNORE_CASE :
131 rOpt ==
"IGNORE_KANA" ? CollatorOptions::CollatorOptions_IGNORE_KANA :
132 rOpt ==
"IGNORE_WIDTH" ? CollatorOptions::CollatorOptions_IGNORE_WIDTH : 0; });
149 m_xContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.i18n.Collator_" + serviceName,
m_xContext );
153 xC.set( xI, UNO_QUERY );
155 lookupTable.emplace_back(rLocale, rSortAlgorithm, serviceName, xC);
168 if (
cachedItem->equals(rLocale, rSortAlgorithm)) {
173 bool bLoaded =
false;
174 if (!rSortAlgorithm.isEmpty())
183 for (
auto const& fallback : aFallbacks)
185 bLoaded =
createCollator( rLocale, fallback +
"_" + rSortAlgorithm, rSortAlgorithm);
192 bLoaded =
createCollator( rLocale, rSortAlgorithm, rSortAlgorithm);
210 return "com.sun.star.i18n.Collator";
221 return {
"com.sun.star.i18n.Collator" };
226extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
228 css::uno::XComponentContext *context,
229 css::uno::Sequence<css::uno::Any>
const &)
Reference< XComponentContext > m_xContext
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual ~CollatorImpl() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
css::uno::Reference< css::i18n::XLocaleData5 > mxLocaleData
virtual sal_Int32 SAL_CALL loadDefaultCollator(const css::lang::Locale &rLocale, sal_Int32 collatorOptions) override
virtual sal_Int32 SAL_CALL compareSubstring(const OUString &s1, sal_Int32 off1, sal_Int32 len1, const OUString &s2, sal_Int32 off2, sal_Int32 len2) override
virtual sal_Int32 SAL_CALL loadCollatorAlgorithm(const OUString &impl, const css::lang::Locale &rLocale, sal_Int32 collatorOptions) override
std::optional< lookupTableItem > cachedItem
virtual OUString SAL_CALL getImplementationName() override
css::lang::Locale nLocale
std::vector< lookupTableItem > lookupTable
css::uno::Reference< css::uno::XComponentContext > m_xContext
virtual css::uno::Sequence< sal_Int32 > SAL_CALL listCollatorOptions(const OUString &collatorAlgorithmName) override
virtual void SAL_CALL loadCollatorAlgorithmWithEndUserOption(const OUString &impl, const css::lang::Locale &rLocale, const css::uno::Sequence< sal_Int32 > &collatorOptions) override
void loadCachedCollator(const css::lang::Locale &rLocale, const OUString &rSortAlgorithm)
virtual css::uno::Sequence< OUString > SAL_CALL listCollatorAlgorithms(const css::lang::Locale &rLocale) override
bool createCollator(const css::lang::Locale &rLocale, const OUString &serviceName, const OUString &rSortAlgorithm)
CollatorImpl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual sal_Int32 SAL_CALL compareString(const OUString &s1, const OUString &s2) override
static ::std::vector< OUString > getFallbackLocaleServiceNames(const css::lang::Locale &rLocale)
Generates fallback strings suitable as parts of service names, excluding the one obtained via getFirs...
static OUString getFirstLocaleServiceName(const css::lang::Locale &rLocale)
Generates a <Language>_<Country> or <Variant> (if Language=="qlt") string suitable as part of service...
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_i18n_Collator_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
Constant values shared between i18npool and, for example, the number formatter.