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 _MACSPELLIMP_H_ 25 #define _MACSPELLIMP_H_ 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 31 #ifdef MACOSX 32 #include <premac.h> 33 #include <Carbon/Carbon.h> 34 #import <Cocoa/Cocoa.h> 35 #include <postmac.h> 36 #endif 37 #include <com/sun/star/lang/XComponent.hpp> 38 #include <com/sun/star/lang/XInitialization.hpp> 39 #include <com/sun/star/lang/XServiceDisplayName.hpp> 40 #include <com/sun/star/beans/XPropertySet.hpp> 41 #include <com/sun/star/beans/PropertyValues.hpp> 42 #include <com/sun/star/lang/XServiceInfo.hpp> 43 #include <com/sun/star/linguistic2/XSpellChecker.hpp> 44 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> 45 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> 46 #include <tools/table.hxx> 47 48 #include <linguistic/misc.hxx> 49 #include <linguistic/lngprophelp.hxx> 50 51 #include <lingutil.hxx> 52 53 using namespace ::rtl; 54 using namespace ::com::sun::star::uno; 55 using namespace ::com::sun::star::beans; 56 using namespace ::com::sun::star::lang; 57 using namespace ::com::sun::star::linguistic2; 58 59 60 /////////////////////////////////////////////////////////////////////////// 61 62 63 class MacSpellChecker : 64 public cppu::WeakImplHelper6 65 < 66 XSpellChecker, 67 XLinguServiceEventBroadcaster, 68 XInitialization, 69 XComponent, 70 XServiceInfo, 71 XServiceDisplayName 72 > 73 { 74 Sequence< Locale > aSuppLocales; 75 // Hunspell ** aDicts; 76 rtl_TextEncoding * aDEncs; 77 Locale * aDLocs; 78 OUString * aDNames; 79 sal_Int32 numdict; 80 NSSpellChecker * macSpell; 81 int macTag; //unique tag for this doc 82 83 ::cppu::OInterfaceContainerHelper aEvtListeners; 84 Reference< XPropertyChangeListener > xPropHelper; 85 linguistic::PropertyHelper_Spell * pPropHelper; 86 sal_Bool bDisposing; 87 88 // disallow copy-constructor and assignment-operator for now 89 MacSpellChecker(const MacSpellChecker &); 90 MacSpellChecker & operator = (const MacSpellChecker &); 91 92 linguistic::PropertyHelper_Spell & GetPropHelper_Impl(); 93 linguistic::PropertyHelper_Spell & GetPropHelper() 94 { 95 return pPropHelper ? *pPropHelper : GetPropHelper_Impl(); 96 } 97 98 sal_Int16 GetSpellFailure( const OUString &rWord, const Locale &rLocale ); 99 Reference< XSpellAlternatives > GetProposals( const OUString &rWord, const Locale &rLocale ); 100 101 public: 102 MacSpellChecker(); 103 virtual ~MacSpellChecker(); 104 105 // XSupportedLocales (for XSpellChecker) 106 virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException); 107 virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException); 108 109 // XSpellChecker 110 virtual sal_Bool SAL_CALL isValid( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); 111 virtual Reference< XSpellAlternatives > SAL_CALL spell( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); 112 113 // XLinguServiceEventBroadcaster 114 virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); 115 virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); 116 117 // XServiceDisplayName 118 virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException); 119 120 // XInitialization 121 virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException); 122 123 // XComponent 124 virtual void SAL_CALL dispose() throw(RuntimeException); 125 virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); 126 virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); 127 128 // XServiceInfo 129 virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); 130 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException); 131 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 132 133 134 static inline OUString getImplementationName_Static() throw(); 135 static Sequence< OUString > getSupportedServiceNames_Static() throw(); 136 }; 137 138 inline OUString MacSpellChecker::getImplementationName_Static() throw() 139 { 140 return A2OU( "org.openoffice.lingu.MacOSXSpellChecker" ); 141 } 142 143 144 145 /////////////////////////////////////////////////////////////////////////// 146 147 #endif 148 149