xref: /AOO41X/main/i18npool/inc/characterclassificationImpl.hxx (revision f7bd9df41d712080226d57e4f6f528539c130a0c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _I18N_CHARACTERCLASSIFICATIONIMPL_HXX_
24 #define _I18N_CHARACTERCLASSIFICATIONIMPL_HXX_
25 
26 #include <com/sun/star/i18n/XCharacterClassification.hpp>
27 #include <cppuhelper/implbase2.hxx> // helper for implementations
28 #include <vector>
29 #include <com/sun/star/i18n/KCharacterType.hpp>
30 #include <com/sun/star/lang/XServiceInfo.hpp>
31 
32 namespace com { namespace sun { namespace star { namespace i18n {
33 
34 class CharacterClassificationImpl : public cppu::WeakImplHelper2
35 <
36     XCharacterClassification,
37     com::sun::star::lang::XServiceInfo
38 >
39 {
40 public:
41 
42     CharacterClassificationImpl( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
43     virtual ~CharacterClassificationImpl();
44 
45     virtual rtl::OUString SAL_CALL toUpper( const rtl::OUString& Text,
46         sal_Int32 nPos, sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale )
47         throw(com::sun::star::uno::RuntimeException);
48     virtual rtl::OUString SAL_CALL toLower( const rtl::OUString& Text,
49         sal_Int32 nPos, sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale )
50         throw(com::sun::star::uno::RuntimeException);
51     virtual rtl::OUString SAL_CALL toTitle( const rtl::OUString& Text, sal_Int32 nPos,
52         sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale )
53         throw(com::sun::star::uno::RuntimeException);
54     virtual sal_Int16 SAL_CALL getType( const rtl::OUString& Text, sal_Int32 nPos )
55         throw(com::sun::star::uno::RuntimeException);
56     virtual sal_Int16 SAL_CALL getCharacterDirection( const rtl::OUString& Text, sal_Int32 nPos )
57         throw(com::sun::star::uno::RuntimeException);
58     virtual sal_Int16 SAL_CALL getScript( const rtl::OUString& Text, sal_Int32 nPos )
59         throw(com::sun::star::uno::RuntimeException);
60     virtual sal_Int32 SAL_CALL getCharacterType( const rtl::OUString& text, sal_Int32 nPos,
61         const com::sun::star::lang::Locale& rLocale )
62         throw(com::sun::star::uno::RuntimeException);
63     virtual sal_Int32 SAL_CALL getStringType( const rtl::OUString& text, sal_Int32 nPos,
64         sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale )
65         throw(com::sun::star::uno::RuntimeException);
66     virtual ParseResult SAL_CALL parseAnyToken( const rtl::OUString& Text, sal_Int32 nPos,
67         const com::sun::star::lang::Locale& rLocale, sal_Int32 nStartCharFlags,
68         const rtl::OUString& userDefinedCharactersStart, sal_Int32 nContCharFlags,
69         const rtl::OUString& userDefinedCharactersCont )
70         throw(com::sun::star::uno::RuntimeException);
71     virtual ParseResult SAL_CALL parsePredefinedToken( sal_Int32 nTokenType,
72         const rtl::OUString& Text, sal_Int32 nPos, const com::sun::star::lang::Locale& rLocale,
73         sal_Int32 nStartCharFlags, const rtl::OUString& userDefinedCharactersStart,
74         sal_Int32 nContCharFlags, const rtl::OUString& userDefinedCharactersCont )
75         throw(com::sun::star::uno::RuntimeException);
76 
77     //XServiceInfo
78     virtual rtl::OUString SAL_CALL getImplementationName(void)
79                 throw( com::sun::star::uno::RuntimeException );
80     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
81         throw( com::sun::star::uno::RuntimeException );
82     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
83         throw( com::sun::star::uno::RuntimeException );
84 
85 private:
86     struct lookupTableItem {
lookupTableItemcom::sun::star::i18n::CharacterClassificationImpl::lookupTableItem87         lookupTableItem(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& rName,
88         com::sun::star::uno::Reference < XCharacterClassification >& rxCI) :
89         aLocale(rLocale), aName(rName), xCI(rxCI) {};
90         com::sun::star::lang::Locale aLocale;
91         rtl::OUString aName;
92         com::sun::star::uno::Reference < XCharacterClassification > xCI;
equalscom::sun::star::i18n::CharacterClassificationImpl::lookupTableItem93         sal_Bool SAL_CALL equals(const com::sun::star::lang::Locale& rLocale) {
94         return aLocale.Language == rLocale.Language &&
95             aLocale.Country == rLocale.Country &&
96             aLocale.Variant == rLocale.Variant;
97         };
98     };
99     std::vector<lookupTableItem*> lookupTable;
100     lookupTableItem *cachedItem;
101 
102     com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
103     com::sun::star::uno::Reference < XCharacterClassification > xUCI;
104 
105     com::sun::star::uno::Reference < XCharacterClassification > SAL_CALL
106     getLocaleSpecificCharacterClassification(const com::sun::star::lang::Locale& rLocale) throw(com::sun::star::uno::RuntimeException);
107     sal_Bool SAL_CALL
108     createLocaleSpecificCharacterClassification(const rtl::OUString& serviceName, const com::sun::star::lang::Locale& rLocale);
109 
110 };
111 
112 } } } }
113 
114 #endif
115