update dev300-m58
[ooovba.git] / i18npool / inc / collatorImpl.hxx
bloba04048c985b34f306dd48471501dd2715bc8b97d
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: collatorImpl.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _I18N_COLLATORIMPL_HXX_
31 #define _I18N_COLLATORIMPL_HXX_
33 #include <comphelper/processfactory.hxx>
34 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
35 #include <com/sun/star/uno/Reference.h>
36 #include <com/sun/star/i18n/XLocaleData.hpp>
37 #include <com/sun/star/i18n/XCollator.hpp>
38 #include <com/sun/star/lang/Locale.hpp>
39 #include <cppuhelper/weak.hxx>
40 #include <cppuhelper/implbase2.hxx>
41 #include <com/sun/star/lang/XServiceInfo.hpp>
42 #include <sal/alloca.h>
43 #include <vector>
45 namespace com { namespace sun { namespace star { namespace i18n {
46 // ----------------------------------------------------
47 // class CollatorImpl
48 // ----------------------------------------------------
49 class CollatorImpl : public cppu::WeakImplHelper2
51 XCollator,
52 com::sun::star::lang::XServiceInfo
55 public:
57 // Constructors
58 CollatorImpl( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
59 // Destructor
60 ~CollatorImpl();
62 virtual sal_Int32 SAL_CALL compareSubstring(const rtl::OUString& s1, sal_Int32 off1, sal_Int32 len1,
63 const rtl::OUString& s2, sal_Int32 off2, sal_Int32 len2) throw(com::sun::star::uno::RuntimeException);
65 virtual sal_Int32 SAL_CALL compareString( const rtl::OUString& s1,
66 const rtl::OUString& s2) throw(com::sun::star::uno::RuntimeException);
68 virtual sal_Int32 SAL_CALL loadDefaultCollator( const lang::Locale& rLocale, sal_Int32 collatorOptions)
69 throw(com::sun::star::uno::RuntimeException);
71 virtual sal_Int32 SAL_CALL loadCollatorAlgorithm( const rtl::OUString& impl, const lang::Locale& rLocale,
72 sal_Int32 collatorOptions) throw(com::sun::star::uno::RuntimeException);
74 virtual void SAL_CALL loadCollatorAlgorithmWithEndUserOption( const rtl::OUString& impl, const lang::Locale& rLocale,
75 const com::sun::star::uno::Sequence< sal_Int32 >& collatorOptions) throw(com::sun::star::uno::RuntimeException);
77 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL listCollatorAlgorithms( const lang::Locale& rLocale )
78 throw(com::sun::star::uno::RuntimeException);
80 virtual com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL listCollatorOptions( const rtl::OUString& collatorAlgorithmName )
81 throw(com::sun::star::uno::RuntimeException);
83 //XServiceInfo
84 virtual rtl::OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException );
85 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName) throw( com::sun::star::uno::RuntimeException );
86 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() throw( com::sun::star::uno::RuntimeException );
88 protected:
89 lang::Locale nLocale;
90 private :
91 struct lookupTableItem {
92 lang::Locale aLocale;
93 rtl::OUString algorithm;
94 rtl::OUString service;
95 com::sun::star::uno::Reference < XCollator > xC;
96 lookupTableItem(const lang::Locale& rLocale, const rtl::OUString& _algorithm, const rtl::OUString& _service,
97 com::sun::star::uno::Reference < XCollator >& _xC) : aLocale(rLocale), algorithm(_algorithm), service(_service), xC(_xC) {}
98 sal_Bool SAL_CALL equals(const lang::Locale& rLocale, const rtl::OUString& _algorithm) {
99 return aLocale.Language == rLocale.Language &&
100 aLocale.Country == rLocale.Country &&
101 aLocale.Variant == rLocale.Variant &&
102 algorithm == _algorithm;
105 std::vector<lookupTableItem*> lookupTable;
106 lookupTableItem *cachedItem;
108 // Service Factory
109 com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
110 // lang::Locale Data
111 com::sun::star::uno::Reference < XLocaleData > localedata;
113 sal_Bool SAL_CALL createCollator(const lang::Locale& rLocale, const rtl::OUString& serviceName,
114 const rtl::OUString& rSortAlgorithm) throw(com::sun::star::uno::RuntimeException);
115 void SAL_CALL loadCachedCollator(const lang::Locale& rLocale, const rtl::OUString& rSortAlgorithm)
116 throw(com::sun::star::uno::RuntimeException);
119 } } } }
121 #endif