xref: /aoo41x/main/linguistic/source/lngsvcmgr.hxx (revision 63ce064a)
1*63ce064aSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*63ce064aSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*63ce064aSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*63ce064aSAndrew Rist  * distributed with this work for additional information
6*63ce064aSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*63ce064aSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*63ce064aSAndrew Rist  * "License"); you may not use this file except in compliance
9*63ce064aSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*63ce064aSAndrew Rist  *
11*63ce064aSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*63ce064aSAndrew Rist  *
13*63ce064aSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*63ce064aSAndrew Rist  * software distributed under the License is distributed on an
15*63ce064aSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*63ce064aSAndrew Rist  * KIND, either express or implied.  See the License for the
17*63ce064aSAndrew Rist  * specific language governing permissions and limitations
18*63ce064aSAndrew Rist  * under the License.
19*63ce064aSAndrew Rist  *
20*63ce064aSAndrew Rist  *************************************************************/
21*63ce064aSAndrew Rist 
22*63ce064aSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _LINGUISTIC_LNGSVCMGR_HXX_
25cdf0e10cSrcweir #define _LINGUISTIC_LNGSVCMGR_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <uno/lbnames.h>			// CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
28cdf0e10cSrcweir #include <cppuhelper/implbase4.hxx>	// helper for implementations
29cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h>	//OMultiTypeInterfaceContainerHelper
30cdf0e10cSrcweir 
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
33cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
34cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
35cdf0e10cSrcweir #include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
36cdf0e10cSrcweir #include <com/sun/star/linguistic2/XAvailableLocales.hpp>
37cdf0e10cSrcweir #include <unotools/configitem.hxx>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir //#include <vcl/timer.hxx>
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #include "linguistic/misc.hxx"
42cdf0e10cSrcweir #include "defs.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir class SpellCheckerDispatcher;
45cdf0e10cSrcweir class HyphenatorDispatcher;
46cdf0e10cSrcweir class ThesaurusDispatcher;
47cdf0e10cSrcweir class GrammarCheckingIterator;
48cdf0e10cSrcweir class LngSvcMgrListenerHelper;
49cdf0e10cSrcweir struct SvcInfo;
50cdf0e10cSrcweir 
51cdf0e10cSrcweir namespace com { namespace sun { namespace star { namespace linguistic2 {
52cdf0e10cSrcweir 	class XLinguServiceEventBroadcaster;
53cdf0e10cSrcweir 	class XSpellChecker;
54cdf0e10cSrcweir     class XProofreader;
55cdf0e10cSrcweir     class XProofreadingIterator;
56cdf0e10cSrcweir 	class XHyphenator;
57cdf0e10cSrcweir 	class XThesaurus;
58cdf0e10cSrcweir } } } }
59cdf0e10cSrcweir 
60cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
61cdf0e10cSrcweir 
62cdf0e10cSrcweir 
63cdf0e10cSrcweir class LngSvcMgr :
64cdf0e10cSrcweir 	public cppu::WeakImplHelper4
65cdf0e10cSrcweir 	<
66cdf0e10cSrcweir 		com::sun::star::linguistic2::XLinguServiceManager,
67cdf0e10cSrcweir 		com::sun::star::linguistic2::XAvailableLocales,
68cdf0e10cSrcweir 		com::sun::star::lang::XComponent,
69cdf0e10cSrcweir 		com::sun::star::lang::XServiceInfo
70cdf0e10cSrcweir     >,
71cdf0e10cSrcweir     private utl::ConfigItem
72cdf0e10cSrcweir {
73cdf0e10cSrcweir     friend class LngSvcMgrListenerHelper;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	::cppu::OInterfaceContainerHelper					aEvtListeners;
76cdf0e10cSrcweir 
77cdf0e10cSrcweir 	com::sun::star::uno::Reference<
78cdf0e10cSrcweir         ::com::sun::star::linguistic2::XSpellChecker >              xSpellDsp;
79cdf0e10cSrcweir     com::sun::star::uno::Reference<
80cdf0e10cSrcweir         ::com::sun::star::linguistic2::XProofreadingIterator >   	xGrammarDsp;
81cdf0e10cSrcweir 	com::sun::star::uno::Reference<
82cdf0e10cSrcweir         ::com::sun::star::linguistic2::XHyphenator >                xHyphDsp;
83cdf0e10cSrcweir 	com::sun::star::uno::Reference<
84cdf0e10cSrcweir         ::com::sun::star::linguistic2::XThesaurus >                 xThesDsp;
85cdf0e10cSrcweir 
86cdf0e10cSrcweir 	com::sun::star::uno::Reference<
87cdf0e10cSrcweir 		::com::sun::star::lang::XEventListener >		xListenerHelper;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir 	com::sun::star::uno::Sequence<
90cdf0e10cSrcweir 		com::sun::star::lang::Locale >					aAvailSpellLocales;
91cdf0e10cSrcweir     com::sun::star::uno::Sequence<
92cdf0e10cSrcweir         com::sun::star::lang::Locale >                  aAvailGrammarLocales;
93cdf0e10cSrcweir 	com::sun::star::uno::Sequence<
94cdf0e10cSrcweir 		com::sun::star::lang::Locale >					aAvailHyphLocales;
95cdf0e10cSrcweir 	com::sun::star::uno::Sequence<
96cdf0e10cSrcweir 		com::sun::star::lang::Locale >					aAvailThesLocales;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	SpellCheckerDispatcher *							pSpellDsp;
99cdf0e10cSrcweir     GrammarCheckingIterator *                           pGrammarDsp;
100cdf0e10cSrcweir 	HyphenatorDispatcher *								pHyphDsp;
101cdf0e10cSrcweir 	ThesaurusDispatcher *								pThesDsp;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 	LngSvcMgrListenerHelper *							pListenerHelper;
104cdf0e10cSrcweir 
105cdf0e10cSrcweir     typedef std::vector< SvcInfo * >    SvcInfoArray;
106cdf0e10cSrcweir 	SvcInfoArray *										pAvailSpellSvcs;
107cdf0e10cSrcweir     SvcInfoArray *                                      pAvailGrammarSvcs;
108cdf0e10cSrcweir 	SvcInfoArray *										pAvailHyphSvcs;
109cdf0e10cSrcweir 	SvcInfoArray *										pAvailThesSvcs;
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	sal_Bool bDisposing;
112cdf0e10cSrcweir 	sal_Bool bHasAvailSpellLocales;
113cdf0e10cSrcweir     sal_Bool bHasAvailGrammarLocales;
114cdf0e10cSrcweir 	sal_Bool bHasAvailHyphLocales;
115cdf0e10cSrcweir 	sal_Bool bHasAvailThesLocales;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	// disallow copy-constructor and assignment-operator for now
118cdf0e10cSrcweir 	LngSvcMgr(const LngSvcMgr &);
119cdf0e10cSrcweir 	LngSvcMgr & operator = (const LngSvcMgr &);
120cdf0e10cSrcweir 
121cdf0e10cSrcweir 	void	GetAvailableSpellSvcs_Impl();
122cdf0e10cSrcweir     void    GetAvailableGrammarSvcs_Impl();
123cdf0e10cSrcweir 	void	GetAvailableHyphSvcs_Impl();
124cdf0e10cSrcweir 	void	GetAvailableThesSvcs_Impl();
125cdf0e10cSrcweir 	void	GetListenerHelper_Impl();
126cdf0e10cSrcweir 
127cdf0e10cSrcweir     void    GetSpellCheckerDsp_Impl( sal_Bool bSetSvcList = sal_True );
128cdf0e10cSrcweir     void    GetGrammarCheckerDsp_Impl( sal_Bool bSetSvcList = sal_True );
129cdf0e10cSrcweir     void    GetHyphenatorDsp_Impl( sal_Bool bSetSvcList = sal_True );
130cdf0e10cSrcweir     void    GetThesaurusDsp_Impl( sal_Bool bSetSvcList = sal_True );
131cdf0e10cSrcweir 
132cdf0e10cSrcweir 	void	SetCfgServiceLists( SpellCheckerDispatcher &rSpellDsp );
133cdf0e10cSrcweir     void    SetCfgServiceLists( GrammarCheckingIterator &rGrammarDsp );
134cdf0e10cSrcweir 	void	SetCfgServiceLists( HyphenatorDispatcher &rHyphDsp );
135cdf0e10cSrcweir 	void	SetCfgServiceLists( ThesaurusDispatcher &rThesDsp );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 	sal_Bool	SaveCfgSvcs( const String &rServiceName );
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     void    SetAvailableCfgServiceLists( LinguDispatcher &rDispatcher,
140cdf0e10cSrcweir                     const SvcInfoArray &rAvailSvcs );
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     static void clearSvcInfoArray(SvcInfoArray *pInfo);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir     // utl::ConfigItem (to allow for listening of changes of relevant properties)
145cdf0e10cSrcweir     virtual void    Notify( const com::sun::star::uno::Sequence< rtl::OUString > &rPropertyNames );
146cdf0e10cSrcweir     virtual void    Commit();
147cdf0e10cSrcweir 
148cdf0e10cSrcweir public:
149cdf0e10cSrcweir 	LngSvcMgr();
150cdf0e10cSrcweir 	virtual ~LngSvcMgr();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir 	// XLinguServiceManager
153cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XSpellChecker > SAL_CALL getSpellChecker(  ) throw (::com::sun::star::uno::RuntimeException);
154cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XHyphenator > SAL_CALL getHyphenator(  ) throw (::com::sun::star::uno::RuntimeException);
155cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::linguistic2::XThesaurus > SAL_CALL getThesaurus(  ) throw (::com::sun::star::uno::RuntimeException);
156cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL addLinguServiceManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
157cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL removeLinguServiceManagerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
158cdf0e10cSrcweir     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);
159cdf0e10cSrcweir     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);
160cdf0e10cSrcweir     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);
161cdf0e10cSrcweir 
162cdf0e10cSrcweir 	// XAvailableLocales
163cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > SAL_CALL getAvailableLocales( const ::rtl::OUString& aServiceName ) throw (::com::sun::star::uno::RuntimeException);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	// XComponent
166cdf0e10cSrcweir     virtual void SAL_CALL dispose(  ) throw (::com::sun::star::uno::RuntimeException);
167cdf0e10cSrcweir     virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
168cdf0e10cSrcweir     virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
169cdf0e10cSrcweir 
170cdf0e10cSrcweir 	// XServiceInfo
171cdf0e10cSrcweir     virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw (::com::sun::star::uno::RuntimeException);
172cdf0e10cSrcweir     virtual ::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException);
173cdf0e10cSrcweir     virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw (::com::sun::star::uno::RuntimeException);
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     static inline ::rtl::OUString   getImplementationName_Static();
177cdf0e10cSrcweir     static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static() throw();
178cdf0e10cSrcweir 
179cdf0e10cSrcweir 	sal_Bool	AddLngSvcEvtBroadcaster(
180cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference<
181cdf0e10cSrcweir 					::com::sun::star::linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster );
182cdf0e10cSrcweir 	sal_Bool	RemoveLngSvcEvtBroadcaster(
183cdf0e10cSrcweir 				const ::com::sun::star::uno::Reference<
184cdf0e10cSrcweir 					::com::sun::star::linguistic2::XLinguServiceEventBroadcaster > &rxBroadcaster );
185cdf0e10cSrcweir };
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 
getImplementationName_Static()188cdf0e10cSrcweir inline ::rtl::OUString LngSvcMgr::getImplementationName_Static()
189cdf0e10cSrcweir {
190cdf0e10cSrcweir 	return A2OU( "com.sun.star.lingu2.LngSvcMgr" );
191cdf0e10cSrcweir }
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 
194cdf0e10cSrcweir ///////////////////////////////////////////////////////////////////////////
195cdf0e10cSrcweir 
196cdf0e10cSrcweir #endif
197cdf0e10cSrcweir 
198