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_LNGPROPHELP_HXX
21 #define INCLUDED_LINGUISTIC_LNGPROPHELP_HXX
23 #include <cppuhelper/implbase.hxx>
24 #include <comphelper/interfacecontainer2.hxx>
25 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
26 #include <com/sun/star/beans/PropertyValues.hpp>
27 #include <com/sun/star/linguistic2/XLinguProperties.hpp>
28 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
29 #include <linguistic/lngdllapi.h>
31 namespace com
{ namespace sun
{ namespace star
{ namespace beans
{
35 namespace com
{ namespace sun
{ namespace star
{ namespace linguistic2
{
36 struct LinguServiceEvent
;
44 // Base class for all XPropertyChangeListener members of the
45 // various lingu services.
48 // Flags for type of events allowed to be launched
49 #define AE_SPELLCHECKER 1
50 #define AE_HYPHENATOR 2
52 typedef cppu::WeakImplHelper
54 css::beans::XPropertyChangeListener
,
55 css::linguistic2::XLinguServiceEventBroadcaster
56 > PropertyChgHelperBase
;
58 class PropertyChgHelper
:
59 public PropertyChgHelperBase
61 css::uno::Sequence
< OUString
> aPropNames
;
62 css::uno::Reference
< css::uno::XInterface
> xMyEvtObj
;
63 ::comphelper::OInterfaceContainerHelper2 aLngSvcEvtListeners
;
64 css::uno::Reference
< css::beans::XPropertySet
> xPropSet
;
66 int nEvtFlags
; // flags for event types allowed to be launched
69 bool bIsIgnoreControlCharacters
;
70 bool bIsUseDictionaryList
;
72 // return values, will be set to default value or current temporary value
73 bool bResIsIgnoreControlCharacters
;
74 bool bResIsUseDictionaryList
;
76 PropertyChgHelper( const PropertyChgHelper
& ) = delete;
77 PropertyChgHelper
& operator = ( const PropertyChgHelper
& ) = delete;
80 virtual void SetDefaultValues();
81 virtual void GetCurrentValues();
83 css::uno::Sequence
< OUString
> &
84 GetPropNames() { return aPropNames
; }
86 css::beans::XPropertySet
> &
87 GetPropSet() { return xPropSet
; }
89 void AddPropNames( const char *pNewNames
[], sal_Int32 nCount
);
91 virtual bool propertyChange_Impl( const css::beans::PropertyChangeEvent
& rEvt
);
95 const css::uno::Reference
< css::uno::XInterface
> &rxSource
,
96 css::uno::Reference
< css::linguistic2::XLinguProperties
> &rxPropSet
,
98 virtual ~PropertyChgHelper() override
;
100 virtual void SetTmpPropVals( const css::beans::PropertyValues
&rPropVals
);
103 virtual void SAL_CALL
104 disposing( const css::lang::EventObject
& rSource
) override
;
106 // XPropertyChangeListener
107 virtual void SAL_CALL
108 propertyChange( const css::beans::PropertyChangeEvent
& rEvt
) override
;
110 // XLinguServiceEventBroadcaster
111 virtual sal_Bool SAL_CALL
112 addLinguServiceEventListener(
113 const css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
>& rxListener
) override
;
114 virtual sal_Bool SAL_CALL
115 removeLinguServiceEventListener(
116 const css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
>& rxListener
) override
;
119 void LNG_DLLPUBLIC
AddAsPropListener();
120 void LNG_DLLPUBLIC
RemoveAsPropListener();
121 void LaunchEvent( const css::linguistic2::LinguServiceEvent
& rEvt
);
123 const css::uno::Sequence
< OUString
> &
124 GetPropNames() const { return aPropNames
; }
125 const css::uno::Reference
< css::beans::XPropertySet
> &
126 GetPropSet() const { return xPropSet
; }
127 const css::uno::Reference
< css::uno::XInterface
> &
128 GetEvtObj() const { return xMyEvtObj
; }
132 class PropertyHelper_Thes
:
133 public PropertyChgHelper
135 PropertyHelper_Thes( const PropertyHelper_Thes
& ) = delete;
136 PropertyHelper_Thes
& operator = ( const PropertyHelper_Thes
& ) = delete;
140 const css::uno::Reference
< css::uno::XInterface
> &rxSource
,
141 css::uno::Reference
< css::linguistic2::XLinguProperties
> &rxPropSet
);
142 virtual ~PropertyHelper_Thes() override
;
144 // XPropertyChangeListener
145 virtual void SAL_CALL
146 propertyChange( const css::beans::PropertyChangeEvent
& rEvt
) override
;
149 class LNG_DLLPUBLIC PropertyHelper_Thesaurus
151 PropertyHelper_Thes
* pInst
;
152 css::uno::Reference
< css::beans::XPropertyChangeListener
> xPropHelper
;
154 // disallow use of copy-constructor and assignment-operator
155 PropertyHelper_Thesaurus( const PropertyHelper_Thes
& ) = delete;
156 PropertyHelper_Thesaurus
& operator = ( const PropertyHelper_Thes
& ) = delete;
159 PropertyHelper_Thesaurus(
160 const css::uno::Reference
< css::uno::XInterface
> &rxSource
,
161 css::uno::Reference
< css::linguistic2::XLinguProperties
> &rxPropSet
);
162 ~PropertyHelper_Thesaurus();
163 void AddAsPropListener();
164 void RemoveAsPropListener();
165 void SetTmpPropVals( const css::beans::PropertyValues
&rPropVals
);
169 class LNG_DLLPUBLIC PropertyHelper_Spell
:
170 public PropertyChgHelper
173 bool bIsSpellUpperCase
;
174 bool bIsSpellWithDigits
;
175 bool bIsSpellCapitalization
;
177 // return values, will be set to default value or current temporary value
178 sal_Int16 nResMaxNumberOfSuggestions
; // special value that is not part of the property set and thus needs to be handled differently
179 bool bResIsSpellUpperCase
;
180 bool bResIsSpellWithDigits
;
181 bool bResIsSpellCapitalization
;
183 PropertyHelper_Spell( const PropertyHelper_Spell
& ) = delete;
184 PropertyHelper_Spell
& operator = ( const PropertyHelper_Spell
& ) = delete;
188 virtual void SetDefaultValues() override
;
189 virtual void GetCurrentValues() override
;
190 virtual bool propertyChange_Impl(
191 const css::beans::PropertyChangeEvent
& rEvt
) override
;
194 PropertyHelper_Spell(
195 const css::uno::Reference
< css::uno::XInterface
> &rxSource
,
196 css::uno::Reference
< css::linguistic2::XLinguProperties
> &rxPropSet
);
197 virtual ~PropertyHelper_Spell() override
;
199 virtual void SetTmpPropVals( const css::beans::PropertyValues
&rPropVals
) override
;
201 // XPropertyChangeListener
202 virtual void SAL_CALL
203 propertyChange( const css::beans::PropertyChangeEvent
& rEvt
) override
;
205 static sal_Int16
GetDefaultNumberOfSuggestions() { return 16; }
207 bool IsSpellUpperCase() const { return bResIsSpellUpperCase
; }
208 bool IsSpellWithDigits() const { return bResIsSpellWithDigits
; }
209 bool IsSpellCapitalization() const { return bResIsSpellCapitalization
; }
213 class LNG_DLLPUBLIC PropertyHelper_Spelling
215 PropertyHelper_Spell
* pInst
;
216 css::uno::Reference
< css::beans::XPropertyChangeListener
> xPropHelper
;
218 // disallow use of copy-constructor and assignment-operator
219 PropertyHelper_Spelling( const PropertyHelper_Spell
& ) = delete;
220 PropertyHelper_Spelling
& operator = ( const PropertyHelper_Spell
& ) = delete;
223 PropertyHelper_Spelling(
224 const css::uno::Reference
< css::uno::XInterface
> &rxSource
,
225 css::uno::Reference
< css::linguistic2::XLinguProperties
> &rxPropSet
);
226 ~PropertyHelper_Spelling();
228 void AddAsPropListener();
229 void RemoveAsPropListener();
230 void SetTmpPropVals( const css::beans::PropertyValues
&rPropVals
);
231 bool IsSpellUpperCase() const;
232 bool IsSpellWithDigits() const;
233 bool IsSpellCapitalization() const;
234 /// @throws css::uno::RuntimeException
235 bool addLinguServiceEventListener(
236 const css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
>& rxListener
);
237 /// @throws css::uno::RuntimeException
238 bool removeLinguServiceEventListener(
239 const css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
>& rxListener
);
243 class PropertyHelper_Hyphen
:
244 public PropertyChgHelper
247 sal_Int16 nHyphMinLeading
,
251 // return values, will be set to default value or current temporary value
252 sal_Int16 nResHyphMinLeading
,
254 nResHyphMinWordLength
;
256 PropertyHelper_Hyphen( const PropertyHelper_Hyphen
& ) = delete;
257 PropertyHelper_Hyphen
& operator = ( const PropertyHelper_Hyphen
& ) = delete;
261 virtual void SetDefaultValues() override
;
262 virtual void GetCurrentValues() override
;
263 virtual bool propertyChange_Impl(
264 const css::beans::PropertyChangeEvent
& rEvt
) override
;
267 PropertyHelper_Hyphen(
268 const css::uno::Reference
< css::uno::XInterface
> &rxSource
,
269 css::uno::Reference
< css::linguistic2::XLinguProperties
> &rxPropSet
);
270 virtual ~PropertyHelper_Hyphen() override
;
272 virtual void SetTmpPropVals( const css::beans::PropertyValues
&rPropVals
) override
;
274 // XPropertyChangeListener
275 virtual void SAL_CALL
276 propertyChange( const css::beans::PropertyChangeEvent
& rEvt
) override
;
278 sal_Int16
GetMinLeading() const { return nResHyphMinLeading
; }
279 sal_Int16
GetMinTrailing() const { return nResHyphMinTrailing
; }
280 sal_Int16
GetMinWordLength() const { return nResHyphMinWordLength
; }
283 class LNG_DLLPUBLIC PropertyHelper_Hyphenation
285 PropertyHelper_Hyphen
* pInst
;
286 css::uno::Reference
< css::beans::XPropertyChangeListener
> xPropHelper
;
288 // disallow use of copy-constructor and assignment-operator
289 PropertyHelper_Hyphenation( const PropertyHelper_Hyphen
& ) = delete;
290 PropertyHelper_Hyphenation
& operator = ( const PropertyHelper_Hyphen
& ) = delete;
293 PropertyHelper_Hyphenation(
294 const css::uno::Reference
< css::uno::XInterface
> &rxSource
,
295 css::uno::Reference
< css::linguistic2::XLinguProperties
> &rxPropSet
);
296 ~PropertyHelper_Hyphenation();
298 void AddAsPropListener();
299 void RemoveAsPropListener();
300 void SetTmpPropVals( const css::beans::PropertyValues
&rPropVals
);
301 sal_Int16
GetMinLeading() const;
302 sal_Int16
GetMinTrailing() const;
303 sal_Int16
GetMinWordLength() const;
304 /// @throws css::uno::RuntimeException
305 bool addLinguServiceEventListener(
306 const css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
>& rxListener
);
307 /// @throws css::uno::RuntimeException
308 bool removeLinguServiceEventListener(
309 const css::uno::Reference
< css::linguistic2::XLinguServiceEventListener
>& rxListener
);
312 } // namespace linguistic
316 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */