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 .
22 #include <cppuhelper/implbase.hxx>
23 #include <comphelper/interfacecontainer3.hxx>
26 #include <com/sun/star/uno/Reference.h>
27 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <com/sun/star/linguistic2/XLinguServiceManager2.hpp>
29 #include <com/sun/star/util/XModifyBroadcaster.hpp>
30 #include <com/sun/star/util/XModifyListener.hpp>
31 #include <unotools/configitem.hxx>
32 #include <rtl/ref.hxx>
33 #include <vcl/timer.hxx>
34 #include <vcl/idle.hxx>
38 class SpellCheckerDispatcher
;
39 class HyphenatorDispatcher
;
40 class ThesaurusDispatcher
;
41 class GrammarCheckingIterator
;
42 class LngSvcMgrListenerHelper
;
45 namespace com::sun::star::linguistic2
{
46 class XLinguServiceEventBroadcaster
;
48 class XProofreadingIterator
;
55 public cppu::WeakImplHelper
57 css::linguistic2::XLinguServiceManager2
,
58 css::lang::XServiceInfo
,
59 css::util::XModifyListener
61 private utl::ConfigItem
63 friend class LngSvcMgrListenerHelper
;
65 ::comphelper::OInterfaceContainerHelper3
<css::lang::XEventListener
> aEvtListeners
;
68 css::util::XModifyBroadcaster
> xMB
;
74 css::lang::Locale
> aAvailSpellLocales
;
76 css::lang::Locale
> aAvailGrammarLocales
;
78 css::lang::Locale
> aAvailHyphLocales
;
80 css::lang::Locale
> aAvailThesLocales
;
82 rtl::Reference
<SpellCheckerDispatcher
> mxSpellDsp
;
83 rtl::Reference
<GrammarCheckingIterator
> mxGrammarDsp
;
84 rtl::Reference
<HyphenatorDispatcher
> mxHyphDsp
;
85 rtl::Reference
<ThesaurusDispatcher
> mxThesDsp
;
87 rtl::Reference
<LngSvcMgrListenerHelper
> mxListenerHelper
;
89 typedef std::vector
< SvcInfo
> SvcInfoArray
;
90 std::optional
<SvcInfoArray
> pAvailSpellSvcs
;
91 std::optional
<SvcInfoArray
> pAvailGrammarSvcs
;
92 std::optional
<SvcInfoArray
> pAvailHyphSvcs
;
93 std::optional
<SvcInfoArray
> pAvailThesSvcs
;
97 LngSvcMgr(const LngSvcMgr
&) = delete;
98 LngSvcMgr
& operator = (const LngSvcMgr
&) = delete;
100 void GetAvailableSpellSvcs_Impl();
101 void GetAvailableGrammarSvcs_Impl();
102 void GetAvailableHyphSvcs_Impl();
103 void GetAvailableThesSvcs_Impl();
104 void GetListenerHelper_Impl();
106 void GetSpellCheckerDsp_Impl( bool bSetSvcList
= true );
107 void GetGrammarCheckerDsp_Impl( bool bSetSvcList
= true );
108 void GetHyphenatorDsp_Impl( bool bSetSvcList
= true );
109 void GetThesaurusDsp_Impl( bool bSetSvcList
= true );
111 void SetCfgServiceLists( SpellCheckerDispatcher
&rSpellDsp
);
112 void SetCfgServiceLists( GrammarCheckingIterator
&rGrammarDsp
);
113 void SetCfgServiceLists( HyphenatorDispatcher
&rHyphDsp
);
114 void SetCfgServiceLists( ThesaurusDispatcher
&rThesDsp
);
116 bool SaveCfgSvcs( std::u16string_view rServiceName
);
118 // utl::ConfigItem (to allow for listening of changes of relevant properties)
119 virtual void Notify( const css::uno::Sequence
< OUString
> &rPropertyNames
) override
;
120 virtual void ImplCommit() override
;
123 void stopListening();
124 DECL_LINK( updateAndBroadcast
, Timer
*, void );
128 virtual ~LngSvcMgr() override
;
130 // XLinguServiceManager
131 virtual css::uno::Reference
< css::linguistic2::XSpellChecker
> SAL_CALL
getSpellChecker( ) override
;
132 virtual css::uno::Reference
< css::linguistic2::XHyphenator
> SAL_CALL
getHyphenator( ) override
;
133 virtual css::uno::Reference
< css::linguistic2::XThesaurus
> SAL_CALL
getThesaurus( ) override
;
134 virtual sal_Bool SAL_CALL
addLinguServiceManagerListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
135 virtual sal_Bool SAL_CALL
removeLinguServiceManagerListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
136 virtual css::uno::Sequence
< OUString
> SAL_CALL
getAvailableServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
) override
;
137 virtual void SAL_CALL
setConfiguredServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
, const css::uno::Sequence
< OUString
>& aServiceImplNames
) override
;
138 virtual css::uno::Sequence
< OUString
> SAL_CALL
getConfiguredServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
) override
;
141 virtual css::uno::Sequence
< css::lang::Locale
> SAL_CALL
getAvailableLocales( const OUString
& aServiceName
) override
;
144 virtual void SAL_CALL
dispose( ) override
;
145 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
146 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
149 virtual OUString SAL_CALL
getImplementationName( ) override
;
150 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
151 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
154 virtual void SAL_CALL
disposing( const css::lang::EventObject
& rSource
) override
;
157 virtual void SAL_CALL
modified( const css::lang::EventObject
& rEvent
) override
;
159 bool AddLngSvcEvtBroadcaster(
160 const css::uno::Reference
< css::linguistic2::XLinguServiceEventBroadcaster
> &rxBroadcaster
);
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */