1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #ifndef _LINGUISTIC_LNGSVCMGR_HXX_ 29*cdf0e10cSrcweir #define _LINGUISTIC_LNGSVCMGR_HXX_ 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 32*cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx> // helper for implementations 33*cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h> //OMultiTypeInterfaceContainerHelper 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir 36*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h> 37*cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 38*cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLinguServiceManager.hpp> 40*cdf0e10cSrcweir #include <com/sun/star/linguistic2/XAvailableLocales.hpp> 41*cdf0e10cSrcweir #include <unotools/configitem.hxx> 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir //#include <vcl/timer.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include "linguistic/misc.hxx" 46*cdf0e10cSrcweir #include "defs.hxx" 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir class SpellCheckerDispatcher; 49*cdf0e10cSrcweir class HyphenatorDispatcher; 50*cdf0e10cSrcweir class ThesaurusDispatcher; 51*cdf0e10cSrcweir class GrammarCheckingIterator; 52*cdf0e10cSrcweir class LngSvcMgrListenerHelper; 53*cdf0e10cSrcweir struct SvcInfo; 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace linguistic2 { 56*cdf0e10cSrcweir class XLinguServiceEventBroadcaster; 57*cdf0e10cSrcweir class XSpellChecker; 58*cdf0e10cSrcweir class XProofreader; 59*cdf0e10cSrcweir class XProofreadingIterator; 60*cdf0e10cSrcweir class XHyphenator; 61*cdf0e10cSrcweir class XThesaurus; 62*cdf0e10cSrcweir } } } } 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir class LngSvcMgr : 68*cdf0e10cSrcweir public cppu::WeakImplHelper4 69*cdf0e10cSrcweir < 70*cdf0e10cSrcweir com::sun::star::linguistic2::XLinguServiceManager, 71*cdf0e10cSrcweir com::sun::star::linguistic2::XAvailableLocales, 72*cdf0e10cSrcweir com::sun::star::lang::XComponent, 73*cdf0e10cSrcweir com::sun::star::lang::XServiceInfo 74*cdf0e10cSrcweir >, 75*cdf0e10cSrcweir private utl::ConfigItem 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir friend class LngSvcMgrListenerHelper; 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir ::cppu::OInterfaceContainerHelper aEvtListeners; 80*cdf0e10cSrcweir 81*cdf0e10cSrcweir com::sun::star::uno::Reference< 82*cdf0e10cSrcweir ::com::sun::star::linguistic2::XSpellChecker > xSpellDsp; 83*cdf0e10cSrcweir com::sun::star::uno::Reference< 84*cdf0e10cSrcweir ::com::sun::star::linguistic2::XProofreadingIterator > xGrammarDsp; 85*cdf0e10cSrcweir com::sun::star::uno::Reference< 86*cdf0e10cSrcweir ::com::sun::star::linguistic2::XHyphenator > xHyphDsp; 87*cdf0e10cSrcweir com::sun::star::uno::Reference< 88*cdf0e10cSrcweir ::com::sun::star::linguistic2::XThesaurus > xThesDsp; 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir com::sun::star::uno::Reference< 91*cdf0e10cSrcweir ::com::sun::star::lang::XEventListener > xListenerHelper; 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir com::sun::star::uno::Sequence< 94*cdf0e10cSrcweir com::sun::star::lang::Locale > aAvailSpellLocales; 95*cdf0e10cSrcweir com::sun::star::uno::Sequence< 96*cdf0e10cSrcweir com::sun::star::lang::Locale > aAvailGrammarLocales; 97*cdf0e10cSrcweir com::sun::star::uno::Sequence< 98*cdf0e10cSrcweir com::sun::star::lang::Locale > aAvailHyphLocales; 99*cdf0e10cSrcweir com::sun::star::uno::Sequence< 100*cdf0e10cSrcweir com::sun::star::lang::Locale > aAvailThesLocales; 101*cdf0e10cSrcweir 102*cdf0e10cSrcweir SpellCheckerDispatcher * pSpellDsp; 103*cdf0e10cSrcweir GrammarCheckingIterator * pGrammarDsp; 104*cdf0e10cSrcweir HyphenatorDispatcher * pHyphDsp; 105*cdf0e10cSrcweir ThesaurusDispatcher * pThesDsp; 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir LngSvcMgrListenerHelper * pListenerHelper; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir typedef std::vector< SvcInfo * > SvcInfoArray; 110*cdf0e10cSrcweir SvcInfoArray * pAvailSpellSvcs; 111*cdf0e10cSrcweir SvcInfoArray * pAvailGrammarSvcs; 112*cdf0e10cSrcweir SvcInfoArray * pAvailHyphSvcs; 113*cdf0e10cSrcweir SvcInfoArray * pAvailThesSvcs; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir sal_Bool bDisposing; 116*cdf0e10cSrcweir sal_Bool bHasAvailSpellLocales; 117*cdf0e10cSrcweir sal_Bool bHasAvailGrammarLocales; 118*cdf0e10cSrcweir sal_Bool bHasAvailHyphLocales; 119*cdf0e10cSrcweir sal_Bool bHasAvailThesLocales; 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir // disallow copy-constructor and assignment-operator for now 122*cdf0e10cSrcweir LngSvcMgr(const LngSvcMgr &); 123*cdf0e10cSrcweir LngSvcMgr & operator = (const LngSvcMgr &); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir void GetAvailableSpellSvcs_Impl(); 126*cdf0e10cSrcweir void GetAvailableGrammarSvcs_Impl(); 127*cdf0e10cSrcweir void GetAvailableHyphSvcs_Impl(); 128*cdf0e10cSrcweir void GetAvailableThesSvcs_Impl(); 129*cdf0e10cSrcweir void GetListenerHelper_Impl(); 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir void GetSpellCheckerDsp_Impl( sal_Bool bSetSvcList = sal_True ); 132*cdf0e10cSrcweir void GetGrammarCheckerDsp_Impl( sal_Bool bSetSvcList = sal_True ); 133*cdf0e10cSrcweir void GetHyphenatorDsp_Impl( sal_Bool bSetSvcList = sal_True ); 134*cdf0e10cSrcweir void GetThesaurusDsp_Impl( sal_Bool bSetSvcList = sal_True ); 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir void SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp ); 137*cdf0e10cSrcweir void SetCfgServiceLists( GrammarCheckingIterator &rGrammarDsp ); 138*cdf0e10cSrcweir void SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp ); 139*cdf0e10cSrcweir void SetCfgServiceLists( ThesaurusDispatcher &rThesDsp ); 140*cdf0e10cSrcweir 141*cdf0e10cSrcweir sal_Bool SaveCfgSvcs( const String &rServiceName ); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir void SetAvailableCfgServiceLists( LinguDispatcher &rDispatcher, 144*cdf0e10cSrcweir const SvcInfoArray &rAvailSvcs ); 145*cdf0e10cSrcweir 146*cdf0e10cSrcweir static void clearSvcInfoArray(SvcInfoArray *pInfo); 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir // utl::ConfigItem (to allow for listening of changes of relevant properties) 149*cdf0e10cSrcweir virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames ); 150*cdf0e10cSrcweir virtual void Commit(); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir public: 153*cdf0e10cSrcweir LngSvcMgr(); 154*cdf0e10cSrcweir virtual ~LngSvcMgr(); 155*cdf0e10cSrcweir 156*cdf0e10cSrcweir // XLinguServiceManager 157*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellChecker > SAL_CALL getSpellChecker( ) throw (::com::sun::star::uno::RuntimeException); 158*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenator > SAL_CALL getHyphenator( ) throw (::com::sun::star::uno::RuntimeException); 159*cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XThesaurus > SAL_CALL getThesaurus( ) throw (::com::sun::star::uno::RuntimeException); 160*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL addLinguServiceManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 161*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL removeLinguServiceManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 162*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getAvailableServices( const ::rtl::OUString& aServiceName, const ::com::sun::star::lang::Locale& aLocale ) throw (::com::sun::star::uno::RuntimeException); 163*cdf0e10cSrcweir virtual void SAL_CALL setConfiguredServices( const ::rtl::OUString& aServiceName, const ::com::sun::star::lang::Locale& aLocale, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aServiceImplNames ) throw (::com::sun::star::uno::RuntimeException); 164*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getConfiguredServices( const ::rtl::OUString& aServiceName, const ::com::sun::star::lang::Locale& aLocale ) throw (::com::sun::star::uno::RuntimeException); 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir // XAvailableLocales 167*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getAvailableLocales( const ::rtl::OUString& aServiceName ) throw (::com::sun::star::uno::RuntimeException); 168*cdf0e10cSrcweir 169*cdf0e10cSrcweir // XComponent 170*cdf0e10cSrcweir virtual void SAL_CALL dispose( ) throw (::com::sun::star::uno::RuntimeException); 171*cdf0e10cSrcweir virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); 172*cdf0e10cSrcweir virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException); 173*cdf0e10cSrcweir 174*cdf0e10cSrcweir // XServiceInfo 175*cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException); 176*cdf0e10cSrcweir virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 177*cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException); 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir 180*cdf0e10cSrcweir static inline ::rtl::OUString getImplementationName_Static(); 181*cdf0e10cSrcweir static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw(); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir sal_Bool AddLngSvcEvtBroadcaster( 184*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 185*cdf0e10cSrcweir ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster ); 186*cdf0e10cSrcweir sal_Bool RemoveLngSvcEvtBroadcaster( 187*cdf0e10cSrcweir const ::com::sun::star::uno::Reference< 188*cdf0e10cSrcweir ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster ); 189*cdf0e10cSrcweir }; 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir 192*cdf0e10cSrcweir inline ::rtl::OUString LngSvcMgr::getImplementationName_Static() 193*cdf0e10cSrcweir { 194*cdf0e10cSrcweir return A2OU( "com.sun.star.lingu2.LngSvcMgr" ); 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////// 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir #endif 201*cdf0e10cSrcweir 202