xref: /trunk/main/i18npool/inc/inputsequencechecker.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_INPUTCHECKER_HXX_
24 #define _I18N_INPUTCHECKER_HXX_
25 
26 #include <comphelper/processfactory.hxx>
27 #include <cppuhelper/implbase2.hxx> // helper for implementations
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
30 #include <com/sun/star/i18n/XExtendedInputSequenceChecker.hpp>
31 
32 #include <vector>
33 
34 namespace com { namespace sun { namespace star { namespace i18n {
35 
36 //  ----------------------------------------------------
37 //  class InputSequenceCheckerImpl
38 //  ----------------------------------------------------
39 class InputSequenceCheckerImpl : public cppu::WeakImplHelper2
40 <
41     com::sun::star::i18n::XExtendedInputSequenceChecker,
42     com::sun::star::lang::XServiceInfo
43 >
44 {
45 public:
46     InputSequenceCheckerImpl( const com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory >& rxMSF );
47     InputSequenceCheckerImpl();
48     ~InputSequenceCheckerImpl();
49 
50     virtual sal_Bool SAL_CALL checkInputSequence(const rtl::OUString& Text, sal_Int32 nStartPos,
51         sal_Unicode inputChar, sal_Int16 inputCheckMode);
52 
53     virtual sal_Int32 SAL_CALL correctInputSequence(rtl::OUString& Text, sal_Int32 nStartPos,
54         sal_Unicode inputChar, sal_Int16 inputCheckMode);
55 
56     //XServiceInfo
57     virtual rtl::OUString SAL_CALL getImplementationName();
58     virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName);
59     virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames();
60 
61 protected:
62     sal_Int16 checkMode;
63     const sal_Char *serviceName;
64 
65 private :
66     struct lookupTableItem {
lookupTableItemcom::sun::star::i18n::InputSequenceCheckerImpl::lookupTableItem67         lookupTableItem(const sal_Char* rLanguage, const com::sun::star::uno::Reference < com::sun::star::i18n::XExtendedInputSequenceChecker >& rxISC) :
68             aLanguage(rLanguage), xISC(rxISC) {}
69         const sal_Char* aLanguage;
70         com::sun::star::uno::Reference < com::sun::star::i18n::XExtendedInputSequenceChecker > xISC;
71     };
72     std::vector<lookupTableItem*> lookupTable;
73     lookupTableItem *cachedItem;
74 
75     com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
76 
77     com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedInputSequenceChecker >& SAL_CALL getInputSequenceChecker(sal_Char* rLanguage);
78     sal_Char* SAL_CALL getLanguageByScripType(sal_Unicode cChar, sal_Unicode nChar);
79 };
80 
81 } } } }
82 
83 #endif // _I18N_BREAKITERATOR_HXX_
84