1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _LINGU2_SPELLIMP_HXX_ 29 #define _LINGU2_SPELLIMP_HXX_ 30 31 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 32 #include <cppuhelper/implbase1.hxx> // helper for implementations 33 #include <cppuhelper/implbase6.hxx> // helper for implementations 34 #include <com/sun/star/lang/XComponent.hpp> 35 #include <com/sun/star/lang/XInitialization.hpp> 36 #include <com/sun/star/lang/XServiceDisplayName.hpp> 37 #include <com/sun/star/beans/XPropertySet.hpp> 38 #include <com/sun/star/beans/PropertyValues.hpp> 39 #include <com/sun/star/lang/XServiceInfo.hpp> 40 #include <com/sun/star/linguistic2/XSpellChecker.hpp> 41 #include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp> 42 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> 43 #include <tools/table.hxx> 44 45 #include <linguistic/misc.hxx> 46 #include <linguistic/lngprophelp.hxx> 47 48 #include <lingutil.hxx> 49 50 using namespace ::rtl; 51 using namespace ::com::sun::star::uno; 52 using namespace ::com::sun::star::beans; 53 using namespace ::com::sun::star::lang; 54 using namespace ::com::sun::star::linguistic2; 55 56 57 /////////////////////////////////////////////////////////////////////////// 58 59 60 class SpellChecker : 61 public cppu::WeakImplHelper6 62 < 63 XSpellChecker, 64 XLinguServiceEventBroadcaster, 65 XInitialization, 66 XComponent, 67 XServiceInfo, 68 XServiceDisplayName 69 > 70 { 71 Sequence< Locale > aSuppLocales; 72 Hunspell ** aDicts; 73 rtl_TextEncoding * aDEncs; 74 Locale * aDLocs; 75 OUString * aDNames; 76 sal_Int32 numdict; 77 78 ::cppu::OInterfaceContainerHelper aEvtListeners; 79 Reference< XPropertyChangeListener > xPropHelper; 80 linguistic::PropertyHelper_Spell * pPropHelper; 81 sal_Bool bDisposing; 82 83 // disallow copy-constructor and assignment-operator for now 84 SpellChecker(const SpellChecker &); 85 SpellChecker & operator = (const SpellChecker &); 86 87 linguistic::PropertyHelper_Spell & GetPropHelper_Impl(); 88 linguistic::PropertyHelper_Spell & GetPropHelper() 89 { 90 return pPropHelper ? *pPropHelper : GetPropHelper_Impl(); 91 } 92 93 sal_Int16 GetSpellFailure( const OUString &rWord, const Locale &rLocale ); 94 Reference< XSpellAlternatives > GetProposals( const OUString &rWord, const Locale &rLocale ); 95 96 public: 97 SpellChecker(); 98 virtual ~SpellChecker(); 99 100 // XSupportedLocales (for XSpellChecker) 101 virtual Sequence< Locale > SAL_CALL getLocales() throw(RuntimeException); 102 virtual sal_Bool SAL_CALL hasLocale( const Locale& rLocale ) throw(RuntimeException); 103 104 // XSpellChecker 105 virtual sal_Bool SAL_CALL isValid( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); 106 virtual Reference< XSpellAlternatives > SAL_CALL spell( const OUString& rWord, const Locale& rLocale, const PropertyValues& rProperties ) throw(IllegalArgumentException, RuntimeException); 107 108 // XLinguServiceEventBroadcaster 109 virtual sal_Bool SAL_CALL addLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); 110 virtual sal_Bool SAL_CALL removeLinguServiceEventListener( const Reference< XLinguServiceEventListener >& rxLstnr ) throw(RuntimeException); 111 112 // XServiceDisplayName 113 virtual OUString SAL_CALL getServiceDisplayName( const Locale& rLocale ) throw(RuntimeException); 114 115 // XInitialization 116 virtual void SAL_CALL initialize( const Sequence< Any >& rArguments ) throw(Exception, RuntimeException); 117 118 // XComponent 119 virtual void SAL_CALL dispose() throw(RuntimeException); 120 virtual void SAL_CALL addEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); 121 virtual void SAL_CALL removeEventListener( const Reference< XEventListener >& rxListener ) throw(RuntimeException); 122 123 // XServiceInfo 124 virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); 125 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName ) throw(RuntimeException); 126 virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException); 127 128 129 static inline OUString getImplementationName_Static() throw(); 130 static Sequence< OUString > getSupportedServiceNames_Static() throw(); 131 }; 132 133 inline OUString SpellChecker::getImplementationName_Static() throw() 134 { 135 return A2OU( "org.openoffice.lingu.MySpellSpellChecker" ); 136 } 137 138 139 /////////////////////////////////////////////////////////////////////////// 140 141 #endif 142 143