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) throw(com::sun::star::uno::RuntimeException);
52 
53 	virtual sal_Int32 SAL_CALL correctInputSequence(rtl::OUString& Text, sal_Int32 nStartPos,
54 		sal_Unicode inputChar, sal_Int16 inputCheckMode) throw(com::sun::star::uno::RuntimeException);
55 
56 	//XServiceInfo
57 	virtual rtl::OUString SAL_CALL getImplementationName() throw( com::sun::star::uno::RuntimeException );
58 	virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
59 		throw( com::sun::star::uno::RuntimeException );
60 	virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames()
61 		throw( com::sun::star::uno::RuntimeException );
62 
63 protected:
64 	sal_Int16 checkMode;
65 	const sal_Char *serviceName;
66 
67 private :
68 	struct lookupTableItem {
lookupTableItemcom::sun::star::i18n::InputSequenceCheckerImpl::lookupTableItem69 	    lookupTableItem(const sal_Char* rLanguage, const com::sun::star::uno::Reference < com::sun::star::i18n::XExtendedInputSequenceChecker >& rxISC) :
70 			aLanguage(rLanguage), xISC(rxISC) {}
71 	    const sal_Char* aLanguage;
72 	    com::sun::star::uno::Reference < com::sun::star::i18n::XExtendedInputSequenceChecker > xISC;
73 	};
74 	std::vector<lookupTableItem*> lookupTable;
75 	lookupTableItem *cachedItem;
76 
77 	com::sun::star::uno::Reference < com::sun::star::lang::XMultiServiceFactory > xMSF;
78 
79 	com::sun::star::uno::Reference< com::sun::star::i18n::XExtendedInputSequenceChecker >& SAL_CALL getInputSequenceChecker(sal_Char* rLanguage)
80 		throw (com::sun::star::uno::RuntimeException);
81 	sal_Char* SAL_CALL getLanguageByScripType(sal_Unicode cChar, sal_Unicode nChar);
82 };
83 
84 } } } }
85 
86 #endif // _I18N_BREAKITERATOR_HXX_
87