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/implbase.hxx>
24 #include <comphelper/interfacecontainer3.hxx>
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 <rtl/ref.hxx>
34 #include <vcl/timer.hxx>
35 #include <vcl/idle.hxx>
39 class SpellCheckerDispatcher
;
40 class HyphenatorDispatcher
;
41 class ThesaurusDispatcher
;
42 class GrammarCheckingIterator
;
43 class LngSvcMgrListenerHelper
;
46 namespace com::sun::star::linguistic2
{
47 class XLinguServiceEventBroadcaster
;
49 class XProofreadingIterator
;
56 public cppu::WeakImplHelper
58 css::linguistic2::XLinguServiceManager2
,
59 css::lang::XServiceInfo
,
60 css::util::XModifyListener
62 private utl::ConfigItem
64 friend class LngSvcMgrListenerHelper
;
66 ::comphelper::OInterfaceContainerHelper3
<css::lang::XEventListener
> aEvtListeners
;
69 css::util::XModifyBroadcaster
> xMB
;
75 css::lang::Locale
> aAvailSpellLocales
;
77 css::lang::Locale
> aAvailGrammarLocales
;
79 css::lang::Locale
> aAvailHyphLocales
;
81 css::lang::Locale
> aAvailThesLocales
;
83 rtl::Reference
<SpellCheckerDispatcher
> mxSpellDsp
;
84 rtl::Reference
<GrammarCheckingIterator
> mxGrammarDsp
;
85 rtl::Reference
<HyphenatorDispatcher
> mxHyphDsp
;
86 rtl::Reference
<ThesaurusDispatcher
> mxThesDsp
;
88 rtl::Reference
<LngSvcMgrListenerHelper
> mxListenerHelper
;
90 typedef std::vector
< SvcInfo
> SvcInfoArray
;
91 std::optional
<SvcInfoArray
> pAvailSpellSvcs
;
92 std::optional
<SvcInfoArray
> pAvailGrammarSvcs
;
93 std::optional
<SvcInfoArray
> pAvailHyphSvcs
;
94 std::optional
<SvcInfoArray
> pAvailThesSvcs
;
98 LngSvcMgr(const LngSvcMgr
&) = delete;
99 LngSvcMgr
& operator = (const LngSvcMgr
&) = delete;
101 void GetAvailableSpellSvcs_Impl();
102 void GetAvailableGrammarSvcs_Impl();
103 void GetAvailableHyphSvcs_Impl();
104 void GetAvailableThesSvcs_Impl();
105 void GetListenerHelper_Impl();
107 void GetSpellCheckerDsp_Impl( bool bSetSvcList
= true );
108 void GetGrammarCheckerDsp_Impl( bool bSetSvcList
= true );
109 void GetHyphenatorDsp_Impl( bool bSetSvcList
= true );
110 void GetThesaurusDsp_Impl( bool bSetSvcList
= true );
112 void SetCfgServiceLists( SpellCheckerDispatcher
&rSpellDsp
);
113 void SetCfgServiceLists( GrammarCheckingIterator
&rGrammarDsp
);
114 void SetCfgServiceLists( HyphenatorDispatcher
&rHyphDsp
);
115 void SetCfgServiceLists( ThesaurusDispatcher
&rThesDsp
);
117 bool SaveCfgSvcs( std::u16string_view rServiceName
);
119 // utl::ConfigItem (to allow for listening of changes of relevant properties)
120 virtual void Notify( const css::uno::Sequence
< OUString
> &rPropertyNames
) override
;
121 virtual void ImplCommit() override
;
124 void stopListening();
125 DECL_LINK( updateAndBroadcast
, Timer
*, void );
129 virtual ~LngSvcMgr() override
;
131 // XLinguServiceManager
132 virtual css::uno::Reference
< css::linguistic2::XSpellChecker
> SAL_CALL
getSpellChecker( ) override
;
133 virtual css::uno::Reference
< css::linguistic2::XHyphenator
> SAL_CALL
getHyphenator( ) override
;
134 virtual css::uno::Reference
< css::linguistic2::XThesaurus
> SAL_CALL
getThesaurus( ) override
;
135 virtual sal_Bool SAL_CALL
addLinguServiceManagerListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
136 virtual sal_Bool SAL_CALL
removeLinguServiceManagerListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
137 virtual css::uno::Sequence
< OUString
> SAL_CALL
getAvailableServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
) override
;
138 virtual void SAL_CALL
setConfiguredServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
, const css::uno::Sequence
< OUString
>& aServiceImplNames
) override
;
139 virtual css::uno::Sequence
< OUString
> SAL_CALL
getConfiguredServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
) override
;
142 virtual css::uno::Sequence
< css::lang::Locale
> SAL_CALL
getAvailableLocales( const OUString
& aServiceName
) override
;
145 virtual void SAL_CALL
dispose( ) override
;
146 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
147 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
150 virtual OUString SAL_CALL
getImplementationName( ) override
;
151 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
152 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
155 virtual void SAL_CALL
disposing( const css::lang::EventObject
& rSource
) override
;
158 virtual void SAL_CALL
modified( const css::lang::EventObject
& rEvent
) override
;
160 bool AddLngSvcEvtBroadcaster(
161 const css::uno::Reference
< css::linguistic2::XLinguServiceEventBroadcaster
> &rxBroadcaster
);
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */