1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_LINGUISTIC_SOURCE_LNGSVCMGR_HXX
21 #define INCLUDED_LINGUISTIC_SOURCE_LNGSVCMGR_HXX
23 #include <cppuhelper/implbase3.hxx>
24 #include <cppuhelper/interfacecontainer.h>
27 #include <com/sun/star/uno/Reference.h>
28 #include <com/sun/star/lang/XServiceInfo.hpp>
29 #include <com/sun/star/linguistic2/XLinguServiceManager2.hpp>
30 #include <com/sun/star/util/XModifyBroadcaster.hpp>
31 #include <com/sun/star/util/XModifyListener.hpp>
32 #include <unotools/configitem.hxx>
33 #include <vcl/timer.hxx>
34 #include <vcl/idle.hxx>
35 #include <boost/ptr_container/ptr_vector.hpp>
37 #include "linguistic/misc.hxx"
40 class SpellCheckerDispatcher
;
41 class HyphenatorDispatcher
;
42 class ThesaurusDispatcher
;
43 class GrammarCheckingIterator
;
44 class LngSvcMgrListenerHelper
;
47 namespace com
{ namespace sun
{ namespace star
{ namespace linguistic2
{
48 class XLinguServiceEventBroadcaster
;
50 class XProofreadingIterator
;
58 public cppu::WeakImplHelper3
60 com::sun::star::linguistic2::XLinguServiceManager2
,
61 com::sun::star::lang::XServiceInfo
,
62 com::sun::star::util::XModifyListener
64 private utl::ConfigItem
66 friend class LngSvcMgrListenerHelper
;
68 ::cppu::OInterfaceContainerHelper aEvtListeners
;
70 com::sun::star::uno::Reference
<
71 ::com::sun::star::linguistic2::XSpellChecker
> xSpellDsp
;
72 com::sun::star::uno::Reference
<
73 ::com::sun::star::linguistic2::XProofreadingIterator
> xGrammarDsp
;
74 com::sun::star::uno::Reference
<
75 ::com::sun::star::linguistic2::XHyphenator
> xHyphDsp
;
76 com::sun::star::uno::Reference
<
77 ::com::sun::star::linguistic2::XThesaurus
> xThesDsp
;
79 com::sun::star::uno::Reference
<
80 ::com::sun::star::lang::XEventListener
> xListenerHelper
;
82 com::sun::star::uno::Reference
<
83 ::com::sun::star::util::XModifyBroadcaster
> xMB
;
88 com::sun::star::uno::Sequence
<
89 com::sun::star::lang::Locale
> aAvailSpellLocales
;
90 com::sun::star::uno::Sequence
<
91 com::sun::star::lang::Locale
> aAvailGrammarLocales
;
92 com::sun::star::uno::Sequence
<
93 com::sun::star::lang::Locale
> aAvailHyphLocales
;
94 com::sun::star::uno::Sequence
<
95 com::sun::star::lang::Locale
> aAvailThesLocales
;
97 SpellCheckerDispatcher
* pSpellDsp
;
98 GrammarCheckingIterator
* pGrammarDsp
;
99 HyphenatorDispatcher
* pHyphDsp
;
100 ThesaurusDispatcher
* pThesDsp
;
102 LngSvcMgrListenerHelper
* pListenerHelper
;
104 typedef boost::ptr_vector
< SvcInfo
> SvcInfoArray
;
105 SvcInfoArray
* pAvailSpellSvcs
;
106 SvcInfoArray
* pAvailGrammarSvcs
;
107 SvcInfoArray
* pAvailHyphSvcs
;
108 SvcInfoArray
* pAvailThesSvcs
;
112 LngSvcMgr(const LngSvcMgr
&) SAL_DELETED_FUNCTION
;
113 LngSvcMgr
& operator = (const LngSvcMgr
&) SAL_DELETED_FUNCTION
;
115 void GetAvailableSpellSvcs_Impl();
116 void GetAvailableGrammarSvcs_Impl();
117 void GetAvailableHyphSvcs_Impl();
118 void GetAvailableThesSvcs_Impl();
119 void GetListenerHelper_Impl();
121 void GetSpellCheckerDsp_Impl( bool bSetSvcList
= true );
122 void GetGrammarCheckerDsp_Impl( bool bSetSvcList
= true );
123 void GetHyphenatorDsp_Impl( bool bSetSvcList
= true );
124 void GetThesaurusDsp_Impl( bool bSetSvcList
= true );
126 void SetCfgServiceLists( SpellCheckerDispatcher
&rSpellDsp
);
127 void SetCfgServiceLists( GrammarCheckingIterator
&rGrammarDsp
);
128 void SetCfgServiceLists( HyphenatorDispatcher
&rHyphDsp
);
129 void SetCfgServiceLists( ThesaurusDispatcher
&rThesDsp
);
131 bool SaveCfgSvcs( const OUString
&rServiceName
);
133 static void clearSvcInfoArray(SvcInfoArray
*&rpInfo
);
135 // utl::ConfigItem (to allow for listening of changes of relevant properties)
136 virtual void Notify( const com::sun::star::uno::Sequence
< OUString
> &rPropertyNames
) SAL_OVERRIDE
;
137 virtual void ImplCommit() SAL_OVERRIDE
;
140 void stopListening();
141 DECL_LINK_TYPED( updateAndBroadcast
, Idle
*, void );
145 virtual ~LngSvcMgr();
147 // XLinguServiceManager
148 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XSpellChecker
> SAL_CALL
getSpellChecker( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
149 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XHyphenator
> SAL_CALL
getHyphenator( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
150 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::linguistic2::XThesaurus
> SAL_CALL
getThesaurus( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
151 virtual sal_Bool SAL_CALL
addLinguServiceManagerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
152 virtual sal_Bool SAL_CALL
removeLinguServiceManagerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
153 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getAvailableServices( const OUString
& aServiceName
, const ::com::sun::star::lang::Locale
& aLocale
)
154 throw (::com::sun::star::uno::RuntimeException
,
155 std::exception
) SAL_OVERRIDE
;
156 virtual void SAL_CALL
setConfiguredServices( const OUString
& aServiceName
, const ::com::sun::star::lang::Locale
& aLocale
, const ::com::sun::star::uno::Sequence
< OUString
>& aServiceImplNames
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
157 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getConfiguredServices( const OUString
& aServiceName
, const ::com::sun::star::lang::Locale
& aLocale
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
160 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::lang::Locale
> SAL_CALL
getAvailableLocales( const OUString
& aServiceName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
163 virtual void SAL_CALL
dispose( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
164 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
165 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
168 virtual OUString SAL_CALL
getImplementationName( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
169 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
170 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
173 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& rSource
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
176 virtual void SAL_CALL
modified( const ::com::sun::star::lang::EventObject
& rEvent
) throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
178 static inline OUString
getImplementationName_Static();
179 static ::com::sun::star::uno::Sequence
< OUString
> getSupportedServiceNames_Static() throw();
181 bool AddLngSvcEvtBroadcaster(
182 const ::com::sun::star::uno::Reference
<
183 ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster
> &rxBroadcaster
);
187 inline OUString
LngSvcMgr::getImplementationName_Static()
189 return OUString( "com.sun.star.lingu2.LngSvcMgr" );
196 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */