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