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/implbase2.hxx>
24 #include <cppuhelper/interfacecontainer.h>
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::WeakImplHelper2
54 ::com::sun::star::beans::XPropertyChangeListener
,
55 ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster
56 > PropertyChgHelperBase
;
58 class PropertyChgHelper
:
59 public PropertyChgHelperBase
61 ::com::sun::star::uno::Sequence
< OUString
> aPropNames
;
62 ::com::sun::star::uno::Reference
<
63 ::com::sun::star::uno::XInterface
> xMyEvtObj
;
64 ::cppu::OInterfaceContainerHelper aLngSvcEvtListeners
;
65 ::com::sun::star::uno::Reference
<
66 ::com::sun::star::beans::XPropertySet
> xPropSet
;
68 int nEvtFlags
; // flags for event types allowed to be launched
71 bool bIsIgnoreControlCharacters
;
72 bool bIsUseDictionaryList
;
74 // return values, will be set to default value or current temporary value
75 bool bResIsIgnoreControlCharacters
;
76 bool bResIsUseDictionaryList
;
78 PropertyChgHelper( const PropertyChgHelper
& ) SAL_DELETED_FUNCTION
;
79 PropertyChgHelper
& operator = ( const PropertyChgHelper
& ) SAL_DELETED_FUNCTION
;
82 virtual void SetDefaultValues();
83 virtual void GetCurrentValues();
85 ::com::sun::star::uno::Sequence
< OUString
> &
86 GetPropNames() { return aPropNames
; }
87 ::com::sun::star::uno::Reference
<
88 ::com::sun::star::beans::XPropertySet
> &
89 GetPropSet() { return xPropSet
; }
91 void AddPropNames( const char *pNewNames
[], sal_Int32 nCount
);
93 virtual bool propertyChange_Impl(
94 const ::com::sun::star::beans::PropertyChangeEvent
& rEvt
);
98 const ::com::sun::star::uno::Reference
<
99 ::com::sun::star::uno::XInterface
> &rxSource
,
100 ::com::sun::star::uno::Reference
<
101 ::com::sun::star::linguistic2::XLinguProperties
> &rxPropSet
,
102 int nAllowedEvents
);
103 virtual ~PropertyChgHelper();
105 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues
&rPropVals
);
108 virtual void SAL_CALL
109 disposing( const ::com::sun::star::lang::EventObject
& rSource
)
110 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
112 // XPropertyChangeListener
113 virtual void SAL_CALL
114 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& rEvt
)
115 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
117 // XLinguServiceEventBroadcaster
118 virtual sal_Bool SAL_CALL
119 addLinguServiceEventListener(
120 const ::com::sun::star::uno::Reference
<
121 ::com::sun::star::linguistic2::XLinguServiceEventListener
>& rxListener
)
122 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
123 virtual sal_Bool SAL_CALL
124 removeLinguServiceEventListener(
125 const ::com::sun::star::uno::Reference
<
126 ::com::sun::star::linguistic2::XLinguServiceEventListener
>& rxListener
)
127 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
130 void LNG_DLLPUBLIC
AddAsPropListener();
131 void LNG_DLLPUBLIC
RemoveAsPropListener();
133 const ::com::sun::star::linguistic2::LinguServiceEvent
& rEvt
);
135 const ::com::sun::star::uno::Sequence
< OUString
> &
136 GetPropNames() const { return aPropNames
; }
137 const ::com::sun::star::uno::Reference
<
138 ::com::sun::star::beans::XPropertySet
> &
139 GetPropSet() const { return xPropSet
; }
140 const ::com::sun::star::uno::Reference
<
141 ::com::sun::star::uno::XInterface
> &
142 GetEvtObj() const { return xMyEvtObj
; }
144 bool IsIgnoreControlCharacters() const { return bResIsIgnoreControlCharacters
; }
145 bool IsUseDictionaryList() const { return bResIsUseDictionaryList
; }
149 class PropertyHelper_Thes
:
150 public PropertyChgHelper
152 PropertyHelper_Thes( const PropertyHelper_Thes
& ) SAL_DELETED_FUNCTION
;
153 PropertyHelper_Thes
& operator = ( const PropertyHelper_Thes
& ) SAL_DELETED_FUNCTION
;
157 const ::com::sun::star::uno::Reference
<
158 ::com::sun::star::uno::XInterface
> &rxSource
,
159 ::com::sun::star::uno::Reference
<
160 ::com::sun::star::linguistic2::XLinguProperties
> &rxPropSet
);
161 virtual ~PropertyHelper_Thes();
163 // XPropertyChangeListener
164 virtual void SAL_CALL
165 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& rEvt
)
166 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
169 class LNG_DLLPUBLIC PropertyHelper_Thesaurus
171 PropertyHelper_Thes
* pInst
;
172 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertyChangeListener
> xPropHelper
;
174 // disallow use of copy-constructor and assignment-operator
175 PropertyHelper_Thesaurus( const PropertyHelper_Thes
& );
176 PropertyHelper_Thesaurus
& operator = ( const PropertyHelper_Thes
& );
179 PropertyHelper_Thesaurus(
180 const ::com::sun::star::uno::Reference
<
181 ::com::sun::star::uno::XInterface
> &rxSource
,
182 ::com::sun::star::uno::Reference
<
183 ::com::sun::star::linguistic2::XLinguProperties
> &rxPropSet
);
184 ~PropertyHelper_Thesaurus();
185 void AddAsPropListener();
186 void RemoveAsPropListener();
187 void SetTmpPropVals( const com::sun::star::beans::PropertyValues
&rPropVals
);
191 class LNG_DLLPUBLIC PropertyHelper_Spell
:
192 public PropertyChgHelper
195 bool bIsSpellUpperCase
;
196 bool bIsSpellWithDigits
;
197 bool bIsSpellCapitalization
;
199 // return values, will be set to default value or current temporary value
200 sal_Int16 nResMaxNumberOfSuggestions
; // special value that is not part of the property set and thus needs to be handled differently
201 bool bResIsSpellUpperCase
;
202 bool bResIsSpellWithDigits
;
203 bool bResIsSpellCapitalization
;
205 PropertyHelper_Spell( const PropertyHelper_Spell
& ) SAL_DELETED_FUNCTION
;
206 PropertyHelper_Spell
& operator = ( const PropertyHelper_Spell
& ) SAL_DELETED_FUNCTION
;
210 virtual void SetDefaultValues() SAL_OVERRIDE
;
211 virtual void GetCurrentValues() SAL_OVERRIDE
;
212 virtual bool propertyChange_Impl(
213 const ::com::sun::star::beans::PropertyChangeEvent
& rEvt
) SAL_OVERRIDE
;
216 PropertyHelper_Spell(
217 const ::com::sun::star::uno::Reference
<
218 ::com::sun::star::uno::XInterface
> &rxSource
,
219 ::com::sun::star::uno::Reference
<
220 ::com::sun::star::linguistic2::XLinguProperties
> &rxPropSet
);
221 virtual ~PropertyHelper_Spell();
223 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues
&rPropVals
) SAL_OVERRIDE
;
225 // XPropertyChangeListener
226 virtual void SAL_CALL
227 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& rEvt
)
228 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
230 static sal_Int16
GetDefaultNumberOfSuggestions() { return 16; }
232 sal_Int16
GetMaxNumberOfSuggestions() const { return nResMaxNumberOfSuggestions
; }
233 bool IsSpellUpperCase() const { return bResIsSpellUpperCase
; }
234 bool IsSpellWithDigits() const { return bResIsSpellWithDigits
; }
235 bool IsSpellCapitalization() const { return bResIsSpellCapitalization
; }
239 class LNG_DLLPUBLIC PropertyHelper_Spelling
241 PropertyHelper_Spell
* pInst
;
242 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertyChangeListener
> xPropHelper
;
244 // disallow use of copy-constructor and assignment-operator
245 PropertyHelper_Spelling( const PropertyHelper_Spell
& );
246 PropertyHelper_Spelling
& operator = ( const PropertyHelper_Spell
& );
249 PropertyHelper_Spelling(
250 const ::com::sun::star::uno::Reference
<
251 ::com::sun::star::uno::XInterface
> &rxSource
,
252 ::com::sun::star::uno::Reference
<
253 ::com::sun::star::linguistic2::XLinguProperties
> &rxPropSet
);
254 ~PropertyHelper_Spelling();
256 void AddAsPropListener();
257 void RemoveAsPropListener();
258 void SetTmpPropVals( const com::sun::star::beans::PropertyValues
&rPropVals
);
259 bool IsSpellUpperCase() const;
260 bool IsSpellWithDigits() const;
261 bool IsSpellCapitalization() const;
262 bool addLinguServiceEventListener(
263 const ::com::sun::star::uno::Reference
<
264 ::com::sun::star::linguistic2::XLinguServiceEventListener
>& rxListener
)
265 throw(::com::sun::star::uno::RuntimeException
);
266 bool removeLinguServiceEventListener(
267 const ::com::sun::star::uno::Reference
<
268 ::com::sun::star::linguistic2::XLinguServiceEventListener
>& rxListener
)
269 throw(::com::sun::star::uno::RuntimeException
);
273 class PropertyHelper_Hyphen
:
274 public PropertyChgHelper
277 sal_Int16 nHyphMinLeading
,
281 // return values, will be set to default value or current temporary value
282 sal_Int16 nResHyphMinLeading
,
284 nResHyphMinWordLength
;
286 PropertyHelper_Hyphen( const PropertyHelper_Hyphen
& ) SAL_DELETED_FUNCTION
;
287 PropertyHelper_Hyphen
& operator = ( const PropertyHelper_Hyphen
& ) SAL_DELETED_FUNCTION
;
291 virtual void SetDefaultValues() SAL_OVERRIDE
;
292 virtual void GetCurrentValues() SAL_OVERRIDE
;
293 virtual bool propertyChange_Impl(
294 const ::com::sun::star::beans::PropertyChangeEvent
& rEvt
) SAL_OVERRIDE
;
297 PropertyHelper_Hyphen(
298 const ::com::sun::star::uno::Reference
<
299 ::com::sun::star::uno::XInterface
> &rxSource
,
300 ::com::sun::star::uno::Reference
<
301 ::com::sun::star::linguistic2::XLinguProperties
> &rxPropSet
);
302 virtual ~PropertyHelper_Hyphen();
304 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues
&rPropVals
) SAL_OVERRIDE
;
306 // XPropertyChangeListener
307 virtual void SAL_CALL
308 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& rEvt
)
309 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
311 sal_Int16
GetMinLeading() const { return nResHyphMinLeading
; }
312 sal_Int16
GetMinTrailing() const { return nResHyphMinTrailing
; }
313 sal_Int16
GetMinWordLength() const { return nResHyphMinWordLength
; }
316 class LNG_DLLPUBLIC PropertyHelper_Hyphenation
318 PropertyHelper_Hyphen
* pInst
;
319 com::sun::star::uno::Reference
< com::sun::star::beans::XPropertyChangeListener
> xPropHelper
;
321 // disallow use of copy-constructor and assignment-operator
322 PropertyHelper_Hyphenation( const PropertyHelper_Hyphen
& );
323 PropertyHelper_Hyphenation
& operator = ( const PropertyHelper_Hyphen
& );
326 PropertyHelper_Hyphenation(
327 const ::com::sun::star::uno::Reference
<
328 ::com::sun::star::uno::XInterface
> &rxSource
,
329 ::com::sun::star::uno::Reference
<
330 ::com::sun::star::linguistic2::XLinguProperties
> &rxPropSet
);
331 ~PropertyHelper_Hyphenation();
333 void AddAsPropListener();
334 void RemoveAsPropListener();
335 void SetTmpPropVals( const com::sun::star::beans::PropertyValues
&rPropVals
);
336 sal_Int16
GetMinLeading() const;
337 sal_Int16
GetMinTrailing() const;
338 sal_Int16
GetMinWordLength() const;
339 bool addLinguServiceEventListener(
340 const ::com::sun::star::uno::Reference
<
341 ::com::sun::star::linguistic2::XLinguServiceEventListener
>& rxListener
)
342 throw(::com::sun::star::uno::RuntimeException
);
343 bool removeLinguServiceEventListener(
344 const ::com::sun::star::uno::Reference
<
345 ::com::sun::star::linguistic2::XLinguServiceEventListener
>& rxListener
)
346 throw(::com::sun::star::uno::RuntimeException
);
349 } // namespace linguistic
353 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */