Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
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/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
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 .
18 : : */
19 : : #ifndef _I18N_COLLATORIMPL_HXX_
20 : : #define _I18N_COLLATORIMPL_HXX_
21 : :
22 : : #include <comphelper/processfactory.hxx>
23 : : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
24 : : #include <com/sun/star/uno/Reference.h>
25 : : #include <com/sun/star/i18n/XLocaleData.hpp>
26 : : #include <com/sun/star/i18n/XCollator.hpp>
27 : : #include <com/sun/star/lang/Locale.hpp>
28 : : #include <cppuhelper/weak.hxx>
29 : : #include <cppuhelper/implbase2.hxx>
30 : : #include <com/sun/star/lang/XServiceInfo.hpp>
31 : : #include <sal/alloca.h>
32 : : #include <vector>
33 : :
34 : : namespace com { namespace sun { namespace star { namespace i18n {
35 : : // ----------------------------------------------------
36 : : // class CollatorImpl
37 : : // ----------------------------------------------------
38 : : class CollatorImpl : public cppu::WeakImplHelper2
39 : : <
40 : : XCollator,
41 : : com::sun::star::lang::XServiceInfo
42 : : >
43 : : {
44 : : public:
45 : :
46 : : // Constructors
47 : : CollatorImpl( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
48 : : // Destructor
49 : : ~CollatorImpl();
50 : :
51 : : virtual sal_Int32 SAL_CALL compareSubstring(const rtl::OUString& s1, sal_Int32 off1, sal_Int32 len1,
52 : : const rtl::OUString& s2, sal_Int32 off2, sal_Int32 len2) throw(com::sun::star::uno::RuntimeException);
53 : :
54 : : virtual sal_Int32 SAL_CALL compareString( const rtl::OUString& s1,
55 : : const rtl::OUString& s2) throw(com::sun::star::uno::RuntimeException);
56 : :
57 : : virtual sal_Int32 SAL_CALL loadDefaultCollator( const lang::Locale& rLocale, sal_Int32 collatorOptions)
58 : : throw(com::sun::star::uno::RuntimeException);
59 : :
60 : : virtual sal_Int32 SAL_CALL loadCollatorAlgorithm( const rtl::OUString& impl, const lang::Locale& rLocale,
61 : : sal_Int32 collatorOptions) throw(com::sun::star::uno::RuntimeException);
62 : :
63 : : virtual void SAL_CALL loadCollatorAlgorithmWithEndUserOption( const rtl::OUString& impl, const lang::Locale& rLocale,
64 : : const com::sun::star::uno::Sequence< sal_Int32 >& collatorOptions) throw(com::sun::star::uno::RuntimeException);
65 : :
66 : : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL listCollatorAlgorithms( const lang::Locale& rLocale )
67 : : throw(com::sun::star::uno::RuntimeException);
68 : :
69 : : virtual com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL listCollatorOptions( const rtl::OUString& collatorAlgorithmName )
70 : : throw(com::sun::star::uno::RuntimeException);
71 : :
72 : : //XServiceInfo
73 : : virtual rtl::OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException );
74 : : virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( com::sun::star::uno::RuntimeException );
75 : : virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( com::sun::star::uno::RuntimeException );
76 : :
77 : : protected:
78 : : lang::Locale nLocale;
79 : : private :
80 : 552 : struct lookupTableItem {
81 : : lang::Locale aLocale;
82 : : rtl::OUString algorithm;
83 : : rtl::OUString service;
84 : : com::sun::star::uno::Reference < XCollator > xC;
85 : 573 : lookupTableItem(const lang::Locale& rLocale, const rtl::OUString& _algorithm, const rtl::OUString& _service,
86 : 573 : com::sun::star::uno::Reference < XCollator >& _xC) : aLocale(rLocale), algorithm(_algorithm), service(_service), xC(_xC) {}
87 : 0 : sal_Bool SAL_CALL equals(const lang::Locale& rLocale, const rtl::OUString& _algorithm) {
88 : 0 : return aLocale.Language == rLocale.Language &&
89 : 0 : aLocale.Country == rLocale.Country &&
90 : 0 : aLocale.Variant == rLocale.Variant &&
91 [ # # ][ # # : 0 : algorithm == _algorithm;
# # # # ]
92 : : }
93 : : };
94 : : std::vector<lookupTableItem*> lookupTable;
95 : : lookupTableItem *cachedItem;
96 : :
97 : : // Service Factory
98 : : com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
99 : : // lang::Locale Data
100 : : com::sun::star::uno::Reference < XLocaleData > localedata;
101 : :
102 : : sal_Bool SAL_CALL createCollator(const lang::Locale& rLocale, const rtl::OUString& serviceName,
103 : : const rtl::OUString& rSortAlgorithm) throw(com::sun::star::uno::RuntimeException);
104 : : void SAL_CALL loadCachedCollator(const lang::Locale& rLocale, const rtl::OUString& rSortAlgorithm)
105 : : throw(com::sun::star::uno::RuntimeException);
106 : : };
107 : :
108 : : } } } }
109 : :
110 : : #endif
111 : :
112 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|