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 24 #ifndef _LINGU2_SPELLIMP_HXX_ 25 #define _LINGU2_SPELLIMP_HXX_ 26 27 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 28 #include <cppuhelper/implbase1.hxx> // helper for implementations 29 #include <cppuhelper/implbase6.hxx> // helper for implementations 30 #include <com/sun/star/lang/XComponent.hpp> 31 #include <com/sun/star/lang/XInitialization.hpp> 32 #include <com/sun/star/lang/XServiceDisplayName.hpp> 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 #include <com/sun/star/beans/PropertyValues.hpp> 35 #include <com/sun/star/lang/XServiceInfo.hpp> 36 #include <com/sun/star/linguistic2/XSpellChecker.hpp> 37 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> 38 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> 39 #include <tools/table.hxx> 40 41 #include "linguistic/misc.hxx" 42 #include "sprophelp.hxx" 43 44 using namespace ::rtl; 45 using namespace ::com::sun::star::uno; 46 using namespace ::com::sun::star::beans; 47 using namespace ::com::sun::star::lang; 48 using namespace ::com::sun::star::linguistic2; 49 50 51 #define A2OU(x) ::rtl::OUString::createFromAscii( x ) 52 53 /////////////////////////////////////////////////////////////////////////// 54 55 56 class SpellChecker : 57 public cppu::WeakImplHelper6 58 < 59 XSpellChecker, 60 XLinguServiceEventBroadcaster, 61 XInitialization, 62 XComponent, 63 XServiceInfo, 64 XServiceDisplayName 65 > 66 { 67 Sequence< Locale > aSuppLocales; 68 ::cppu::OInterfaceContainerHelper aEvtListeners; 69 Reference< XPropertyChangeListener > xPropHelper; 70 PropertyHelper_Spell * pPropHelper; 71 BOOL bDisposing; 72 73 // disallow copy-constructor and assignment-operator for now 74 SpellChecker(const SpellChecker &); 75 SpellChecker & operator = (const SpellChecker &); 76 77 PropertyHelper_Spell & GetPropHelper_Impl(); 78 PropertyHelper_Spell & GetPropHelper() 79 { 80 return pPropHelper ? *pPropHelper : GetPropHelper_Impl(); 81 } 82 83 INT16 GetSpellFailure( const OUString &rWord, const Locale &rLocale ); 84 Reference< XSpellAlternatives > 85 GetProposals( const OUString &rWord, const Locale &rLocale ); 86 87 public: 88 SpellChecker(); 89 virtual ~SpellChecker(); 90 91 // XSupportedLocales (for XSpellChecker) 92 virtual Sequence< Locale > SAL_CALL 93 getLocales() 94 throw(RuntimeException); 95 virtual sal_Bool SAL_CALL 96 hasLocale( const Locale& rLocale ) 97 throw(RuntimeException); 98 99 // XSpellChecker 100 virtual sal_Bool SAL_CALL 101 isValid( const OUString& rWord, const Locale& rLocale, 102 const PropertyValues& rProperties ) 103 throw(IllegalArgumentException, 104 RuntimeException); 105 virtual Reference< XSpellAlternatives > SAL_CALL 106 spell( const OUString& rWord, const Locale& rLocale, 107 const PropertyValues& rProperties ) 108 throw(IllegalArgumentException, 109 RuntimeException); 110 111 // XLinguServiceEventBroadcaster 112 virtual sal_Bool SAL_CALL 113 addLinguServiceEventListener( 114 const Reference< XLinguServiceEventListener >& rxLstnr ) 115 throw(RuntimeException); 116 virtual sal_Bool SAL_CALL 117 removeLinguServiceEventListener( 118 const Reference< XLinguServiceEventListener >& rxLstnr ) 119 throw(RuntimeException); 120 121 // XServiceDisplayName 122 virtual OUString SAL_CALL 123 getServiceDisplayName( const Locale& rLocale ) 124 throw(RuntimeException); 125 126 // XInitialization 127 virtual void SAL_CALL 128 initialize( const Sequence< Any >& rArguments ) 129 throw(Exception, RuntimeException); 130 131 // XComponent 132 virtual void SAL_CALL 133 dispose() 134 throw(RuntimeException); 135 virtual void SAL_CALL 136 addEventListener( const Reference< XEventListener >& rxListener ) 137 throw(RuntimeException); 138 virtual void SAL_CALL 139 removeEventListener( const Reference< XEventListener >& rxListener ) 140 throw(RuntimeException); 141 142 //////////////////////////////////////////////////////////// 143 // Service specific part 144 // 145 146 // XServiceInfo 147 virtual OUString SAL_CALL 148 getImplementationName() 149 throw(RuntimeException); 150 virtual sal_Bool SAL_CALL 151 supportsService( const OUString& rServiceName ) 152 throw(RuntimeException); 153 virtual Sequence< OUString > SAL_CALL 154 getSupportedServiceNames() 155 throw(RuntimeException); 156 157 158 static inline OUString 159 getImplementationName_Static() throw(); 160 static Sequence< OUString > 161 getSupportedServiceNames_Static() throw(); 162 }; 163 164 inline OUString SpellChecker::getImplementationName_Static() throw() 165 { 166 return A2OU( "com.sun.star.lingu.examples.SpellChecker" ); 167 } 168 169 170 /////////////////////////////////////////////////////////////////////////// 171 172 #endif 173 174