xref: /trunk/main/i18npool/inc/characterclassificationImpl.hxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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     virtual rtl::OUString SAL_CALL toLower( const rtl::OUString& Text,
48         sal_Int32 nPos, sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale );
49     virtual rtl::OUString SAL_CALL toTitle( const rtl::OUString& Text, sal_Int32 nPos,
50         sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale );
51     virtual sal_Int16 SAL_CALL getType( const rtl::OUString& Text, sal_Int32 nPos );
52     virtual sal_Int16 SAL_CALL getCharacterDirection( const rtl::OUString& Text, sal_Int32 nPos );
53     virtual sal_Int16 SAL_CALL getScript( const rtl::OUString& Text, sal_Int32 nPos );
54     virtual sal_Int32 SAL_CALL getCharacterType( const rtl::OUString& text, sal_Int32 nPos,
55         const com::sun::star::lang::Locale& rLocale );
56     virtual sal_Int32 SAL_CALL getStringType( const rtl::OUString& text, sal_Int32 nPos,
57         sal_Int32 nCount, const com::sun::star::lang::Locale& rLocale );
58     virtual ParseResult SAL_CALL parseAnyToken( const rtl::OUString& Text, sal_Int32 nPos,
59         const com::sun::star::lang::Locale& rLocale, sal_Int32 nStartCharFlags,
60         const rtl::OUString& userDefinedCharactersStart, sal_Int32 nContCharFlags,
61         const rtl::OUString& userDefinedCharactersCont );
62     virtual ParseResult SAL_CALL parsePredefinedToken( sal_Int32 nTokenType,
63         const rtl::OUString& Text, sal_Int32 nPos, const com::sun::star::lang::Locale& rLocale,
64         sal_Int32 nStartCharFlags, const rtl::OUString& userDefinedCharactersStart,
65         sal_Int32 nContCharFlags, const rtl::OUString& userDefinedCharactersCont );
66 
67     //XServiceInfo
68     virtual rtl::OUString SAL_CALL getImplementationName(void);
69     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName);
70     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void);
71 
72 private:
73     struct lookupTableItem {
lookupTableItemcom::sun::star::i18n::CharacterClassificationImpl::lookupTableItem74         lookupTableItem(const com::sun::star::lang::Locale& rLocale, const rtl::OUString& rName,
75         com::sun::star::uno::Reference < XCharacterClassification >& rxCI) :
76         aLocale(rLocale), aName(rName), xCI(rxCI) {};
77         com::sun::star::lang::Locale aLocale;
78         rtl::OUString aName;
79         com::sun::star::uno::Reference < XCharacterClassification > xCI;
equalscom::sun::star::i18n::CharacterClassificationImpl::lookupTableItem80         sal_Bool SAL_CALL equals(const com::sun::star::lang::Locale& rLocale) {
81         return aLocale.Language == rLocale.Language &&
82             aLocale.Country == rLocale.Country &&
83             aLocale.Variant == rLocale.Variant;
84         };
85     };
86     std::vector<lookupTableItem*> lookupTable;
87     lookupTableItem *cachedItem;
88 
89     com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
90     com::sun::star::uno::Reference < XCharacterClassification > xUCI;
91 
92     com::sun::star::uno::Reference < XCharacterClassification > SAL_CALL
93     getLocaleSpecificCharacterClassification(const com::sun::star::lang::Locale& rLocale);
94     sal_Bool SAL_CALL
95     createLocaleSpecificCharacterClassification(const rtl::OUString& serviceName, const com::sun::star::lang::Locale& rLocale);
96 
97 };
98 
99 } } } }
100 
101 #endif
102