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>
25 #include <comphelper/lok.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
,
63 public comphelper::LibreOfficeKit::ThreadJoinable
65 friend class LngSvcMgrListenerHelper
;
67 ::comphelper::OInterfaceContainerHelper3
<css::lang::XEventListener
> aEvtListeners
;
70 css::util::XModifyBroadcaster
> xMB
;
76 css::lang::Locale
> aAvailSpellLocales
;
78 css::lang::Locale
> aAvailGrammarLocales
;
80 css::lang::Locale
> aAvailHyphLocales
;
82 css::lang::Locale
> aAvailThesLocales
;
84 rtl::Reference
<SpellCheckerDispatcher
> mxSpellDsp
;
85 rtl::Reference
<GrammarCheckingIterator
> mxGrammarDsp
;
86 rtl::Reference
<HyphenatorDispatcher
> mxHyphDsp
;
87 rtl::Reference
<ThesaurusDispatcher
> mxThesDsp
;
89 rtl::Reference
<LngSvcMgrListenerHelper
> mxListenerHelper
;
91 typedef std::vector
< SvcInfo
> SvcInfoArray
;
92 std::optional
<SvcInfoArray
> pAvailSpellSvcs
;
93 std::optional
<SvcInfoArray
> pAvailGrammarSvcs
;
94 std::optional
<SvcInfoArray
> pAvailHyphSvcs
;
95 std::optional
<SvcInfoArray
> pAvailThesSvcs
;
99 LngSvcMgr(const LngSvcMgr
&) = delete;
100 LngSvcMgr
& operator = (const LngSvcMgr
&) = delete;
102 void GetAvailableSpellSvcs_Impl();
103 void GetAvailableGrammarSvcs_Impl();
104 void GetAvailableHyphSvcs_Impl();
105 void GetAvailableThesSvcs_Impl();
106 void GetListenerHelper_Impl();
108 void GetSpellCheckerDsp_Impl( bool bSetSvcList
= true );
109 void GetGrammarCheckerDsp_Impl( bool bSetSvcList
= true );
110 void GetHyphenatorDsp_Impl( bool bSetSvcList
= true );
111 void GetThesaurusDsp_Impl( bool bSetSvcList
= true );
113 void SetCfgServiceLists( SpellCheckerDispatcher
&rSpellDsp
);
114 void SetCfgServiceLists( GrammarCheckingIterator
&rGrammarDsp
);
115 void SetCfgServiceLists( HyphenatorDispatcher
&rHyphDsp
);
116 void SetCfgServiceLists( ThesaurusDispatcher
&rThesDsp
);
118 bool SaveCfgSvcs( std::u16string_view rServiceName
);
120 // utl::ConfigItem (to allow for listening of changes of relevant properties)
121 virtual void Notify( const css::uno::Sequence
< OUString
> &rPropertyNames
) override
;
122 virtual void ImplCommit() override
;
125 void stopListening();
126 DECL_LINK( updateAndBroadcast
, Timer
*, void );
130 virtual ~LngSvcMgr() override
;
132 // XLinguServiceManager
133 virtual css::uno::Reference
< css::linguistic2::XSpellChecker
> SAL_CALL
getSpellChecker( ) override
;
134 virtual css::uno::Reference
< css::linguistic2::XHyphenator
> SAL_CALL
getHyphenator( ) override
;
135 virtual css::uno::Reference
< css::linguistic2::XThesaurus
> SAL_CALL
getThesaurus( ) override
;
136 virtual sal_Bool SAL_CALL
addLinguServiceManagerListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
137 virtual sal_Bool SAL_CALL
removeLinguServiceManagerListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
138 virtual css::uno::Sequence
< OUString
> SAL_CALL
getAvailableServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
) override
;
139 virtual void SAL_CALL
setConfiguredServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
, const css::uno::Sequence
< OUString
>& aServiceImplNames
) override
;
140 virtual css::uno::Sequence
< OUString
> SAL_CALL
getConfiguredServices( const OUString
& aServiceName
, const css::lang::Locale
& aLocale
) override
;
143 virtual css::uno::Sequence
< css::lang::Locale
> SAL_CALL
getAvailableLocales( const OUString
& aServiceName
) override
;
146 virtual void SAL_CALL
dispose( ) override
;
147 virtual void SAL_CALL
addEventListener( const css::uno::Reference
< css::lang::XEventListener
>& xListener
) override
;
148 virtual void SAL_CALL
removeEventListener( const css::uno::Reference
< css::lang::XEventListener
>& aListener
) override
;
151 virtual OUString SAL_CALL
getImplementationName( ) override
;
152 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
153 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
156 virtual void SAL_CALL
disposing( const css::lang::EventObject
& rSource
) override
;
159 virtual void SAL_CALL
modified( const css::lang::EventObject
& rEvent
) override
;
161 // comphelper::LibreOfficeKit::ThreadJoinable
162 virtual bool joinThreads() override
;
164 bool AddLngSvcEvtBroadcaster(
165 const css::uno::Reference
< css::linguistic2::XLinguServiceEventBroadcaster
> &rxBroadcaster
);
168 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */