1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: lngsvcmgr.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _LINGUISTIC_LNGSVCMGR_HXX_
32 #define _LINGUISTIC_LNGSVCMGR_HXX_
34 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type
35 #include <cppuhelper/implbase4.hxx> // helper for implementations
36 #include <cppuhelper/interfacecontainer.h> //OMultiTypeInterfaceContainerHelper
39 #include <com/sun/star/uno/Reference.h>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
41 #include <com/sun/star/lang/XComponent.hpp>
42 #include <com/sun/star/linguistic2/XLinguServiceManager.hpp>
43 #include <com/sun/star/linguistic2/XAvailableLocales.hpp>
44 #include <unotools/configitem.hxx>
46 #include <vcl/timer.hxx>
51 class SpellCheckerDispatcher
;
52 class HyphenatorDispatcher
;
53 class ThesaurusDispatcher
;
54 class GrammarCheckingIterator
;
55 class LngSvcMgrListenerHelper
;
58 namespace com
{ namespace sun
{ namespace star
{ namespace linguistic2
{
59 class XLinguServiceEventBroadcaster
;
62 class XProofreadingIterator
;
67 ///////////////////////////////////////////////////////////////////////////
71 public cppu::WeakImplHelper4
73 com::sun::star::linguistic2::XLinguServiceManager
,
74 com::sun::star::linguistic2::XAvailableLocales
,
75 com::sun::star::lang::XComponent
,
76 com::sun::star::lang::XServiceInfo
78 private utl::ConfigItem
80 friend class LngSvcMgrListenerHelper
;
82 ::cppu::OInterfaceContainerHelper aEvtListeners
;
84 com::sun::star::uno::Reference
<
85 ::com::sun::star::linguistic2::XSpellChecker
> xSpellDsp
;
86 com::sun::star::uno::Reference
<
87 ::com::sun::star::linguistic2::XProofreadingIterator
> xGrammarDsp
;
88 com::sun::star::uno::Reference
<
89 ::com::sun::star::linguistic2::XHyphenator
> xHyphDsp
;
90 com::sun::star::uno::Reference
<
91 ::com::sun::star::linguistic2::XThesaurus
> xThesDsp
;
93 com::sun::star::uno::Reference
<
94 ::com::sun::star::lang::XEventListener
> xListenerHelper
;
96 com::sun::star::uno::Sequence
<
97 com::sun::star::lang::Locale
> aAvailSpellLocales
;
98 com::sun::star::uno::Sequence
<
99 com::sun::star::lang::Locale
> aAvailGrammarLocales
;
100 com::sun::star::uno::Sequence
<
101 com::sun::star::lang::Locale
> aAvailHyphLocales
;
102 com::sun::star::uno::Sequence
<
103 com::sun::star::lang::Locale
> aAvailThesLocales
;
105 SpellCheckerDispatcher
* pSpellDsp
;
106 GrammarCheckingIterator
* pGrammarDsp
;
107 HyphenatorDispatcher
* pHyphDsp
;
108 ThesaurusDispatcher
* pThesDsp
;
110 LngSvcMgrListenerHelper
* pListenerHelper
;
112 typedef std::vector
< SvcInfo
* > SvcInfoArray
;
113 SvcInfoArray
* pAvailSpellSvcs
;
114 SvcInfoArray
* pAvailGrammarSvcs
;
115 SvcInfoArray
* pAvailHyphSvcs
;
116 SvcInfoArray
* pAvailThesSvcs
;
119 BOOL bHasAvailSpellLocales
;
120 BOOL bHasAvailGrammarLocales
;
121 BOOL bHasAvailHyphLocales
;
122 BOOL bHasAvailThesLocales
;
124 // disallow copy-constructor and assignment-operator for now
125 LngSvcMgr(const LngSvcMgr
&);
126 LngSvcMgr
& operator = (const LngSvcMgr
&);
128 void GetAvailableSpellSvcs_Impl();
129 void GetAvailableGrammarSvcs_Impl();
130 void GetAvailableHyphSvcs_Impl();
131 void GetAvailableThesSvcs_Impl();
132 void GetListenerHelper_Impl();
134 void GetSpellCheckerDsp_Impl( sal_Bool bSetSvcList
= sal_True
);
135 void GetGrammarCheckerDsp_Impl( sal_Bool bSetSvcList
= sal_True
);
136 void GetHyphenatorDsp_Impl( sal_Bool bSetSvcList
= sal_True
);
137 void GetThesaurusDsp_Impl( sal_Bool bSetSvcList
= sal_True
);
139 void SetCfgServiceLists( SpellCheckerDispatcher
&rSpellDsp
);
140 void SetCfgServiceLists( GrammarCheckingIterator
&rGrammarDsp
);
141 void SetCfgServiceLists( HyphenatorDispatcher
&rHyphDsp
);
142 void SetCfgServiceLists( ThesaurusDispatcher
&rThesDsp
);
144 BOOL
SaveCfgSvcs( const String
&rServiceName
);
146 void SetAvailableCfgServiceLists( LinguDispatcher
&rDispatcher
,
147 const SvcInfoArray
&rAvailSvcs
);
149 // utl::ConfigItem (to allow for listening of changes of relevant properties)
150 virtual void Notify( const com::sun::star::uno::Sequence
< rtl::OUString
> &rPropertyNames
);
151 virtual void Commit();
155 virtual ~LngSvcMgr();
157 // XLinguServiceManager
158 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XSpellChecker
> SAL_CALL
getSpellChecker( ) throw (::com::sun::star::uno::RuntimeException
);
159 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XHyphenator
> SAL_CALL
getHyphenator( ) throw (::com::sun::star::uno::RuntimeException
);
160 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XThesaurus
> SAL_CALL
getThesaurus( ) throw (::com::sun::star::uno::RuntimeException
);
161 virtual ::sal_Bool SAL_CALL
addLinguServiceManagerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
162 virtual ::sal_Bool SAL_CALL
removeLinguServiceManagerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
163 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
);
164 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
);
165 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
);
168 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::lang::Locale
> SAL_CALL
getAvailableLocales( const ::rtl::OUString
& aServiceName
) throw (::com::sun::star::uno::RuntimeException
);
171 virtual void SAL_CALL
dispose( ) throw (::com::sun::star::uno::RuntimeException
);
172 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
173 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
176 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
);
177 virtual ::sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
);
178 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
);
181 static inline ::rtl::OUString
getImplementationName_Static();
182 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_Static() throw();
184 BOOL
AddLngSvcEvtBroadcaster(
185 const ::com::sun::star::uno::Reference
<
186 ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster
> &rxBroadcaster
);
187 BOOL
RemoveLngSvcEvtBroadcaster(
188 const ::com::sun::star::uno::Reference
<
189 ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster
> &rxBroadcaster
);
193 inline ::rtl::OUString
LngSvcMgr::getImplementationName_Static()
195 return A2OU( "com.sun.star.lingu2.LngSvcMgr" );
199 ///////////////////////////////////////////////////////////////////////////