1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_I18NPOOL_INC_COLLATORIMPL_HXX
20 #define INCLUDED_I18NPOOL_INC_COLLATORIMPL_HXX
22 #include <comphelper/processfactory.hxx>
23 #include <com/sun/star/uno/Reference.h>
24 #include <com/sun/star/i18n/XLocaleData5.hpp>
25 #include <com/sun/star/i18n/XCollator.hpp>
26 #include <com/sun/star/lang/Locale.hpp>
27 #include <cppuhelper/weak.hxx>
28 #include <cppuhelper/implbase.hxx>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
35 // ----------------------------------------------------
37 // ----------------------------------------------------
38 class CollatorImpl
: public cppu::WeakImplHelper
41 css::lang::XServiceInfo
47 CollatorImpl( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
);
49 virtual ~CollatorImpl() override
;
51 virtual sal_Int32 SAL_CALL
compareSubstring(const OUString
& s1
, sal_Int32 off1
, sal_Int32 len1
,
52 const OUString
& s2
, sal_Int32 off2
, sal_Int32 len2
) override
;
54 virtual sal_Int32 SAL_CALL
compareString( const OUString
& s1
,
55 const OUString
& s2
) override
;
57 virtual sal_Int32 SAL_CALL
loadDefaultCollator( const css::lang::Locale
& rLocale
, sal_Int32 collatorOptions
) override
;
59 virtual sal_Int32 SAL_CALL
loadCollatorAlgorithm( const OUString
& impl
, const css::lang::Locale
& rLocale
,
60 sal_Int32 collatorOptions
) override
;
62 virtual void SAL_CALL
loadCollatorAlgorithmWithEndUserOption( const OUString
& impl
, const css::lang::Locale
& rLocale
,
63 const css::uno::Sequence
< sal_Int32
>& collatorOptions
) override
;
65 virtual css::uno::Sequence
< OUString
> SAL_CALL
listCollatorAlgorithms( const css::lang::Locale
& rLocale
) override
;
67 virtual css::uno::Sequence
< sal_Int32
> SAL_CALL
listCollatorOptions( const OUString
& collatorAlgorithmName
) override
;
70 virtual OUString SAL_CALL
getImplementationName() override
;
71 virtual sal_Bool SAL_CALL
supportsService(const OUString
& ServiceName
) override
;
72 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
75 css::lang::Locale nLocale
;
77 struct lookupTableItem
{
78 css::lang::Locale aLocale
;
81 css::uno::Reference
< XCollator
> xC
;
82 lookupTableItem(const css::lang::Locale
& rLocale
, const OUString
& _algorithm
, const OUString
& _service
,
83 css::uno::Reference
< XCollator
> const & _xC
) : aLocale(rLocale
), algorithm(_algorithm
), service(_service
), xC(_xC
) {}
84 bool SAL_CALL
equals(const css::lang::Locale
& rLocale
, const OUString
& _algorithm
) {
85 return aLocale
.Language
== rLocale
.Language
&&
86 aLocale
.Country
== rLocale
.Country
&&
87 aLocale
.Variant
== rLocale
.Variant
&&
88 algorithm
== _algorithm
;
91 std::vector
<lookupTableItem
*> lookupTable
;
92 lookupTableItem
* cachedItem
;
95 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
97 css::uno::Reference
< css::i18n::XLocaleData5
> mxLocaleData
;
99 /// @throws css::uno::RuntimeException
100 bool SAL_CALL
createCollator(const css::lang::Locale
& rLocale
, const OUString
& serviceName
,
101 const OUString
& rSortAlgorithm
);
102 /// @throws css::uno::RuntimeException
103 void SAL_CALL
loadCachedCollator(const css::lang::Locale
& rLocale
, const OUString
& rSortAlgorithm
);
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */