update credits
[LibreOffice.git] / include / linguistic / lngprophelp.hxx
blob4befc9280cfec6be2e2f1816b66e20fbe34405e7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 _LINGUISTIC_LNGPROPHELP_HXX_
21 #define _LINGUISTIC_LNGPROPHELP_HXX_
23 #include <tools/solar.h>
24 #include <uno/lbnames.h>
25 #include <cppuhelper/implbase2.hxx>
26 #include <cppuhelper/interfacecontainer.h>
27 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
28 #include <com/sun/star/beans/PropertyValues.hpp>
29 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
30 #include <linguistic/lngdllapi.h>
32 namespace com { namespace sun { namespace star { namespace beans {
33 class XPropertySet;
34 }}}}
36 namespace com { namespace sun { namespace star { namespace linguistic2 {
37 struct LinguServiceEvent;
38 }}}}
41 namespace linguistic
44 // PropertyChgHelper
45 // Base class for all XPropertyChangeListener members of the
46 // various lingu services.
49 // Flags for type of events allowed to be launched
50 #define AE_SPELLCHECKER 1
51 #define AE_HYPHENATOR 2
53 typedef cppu::WeakImplHelper2
55 ::com::sun::star::beans::XPropertyChangeListener,
56 ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster
57 > PropertyChgHelperBase;
59 class PropertyChgHelper :
60 public PropertyChgHelperBase
62 ::com::sun::star::uno::Sequence< OUString > aPropNames;
63 ::com::sun::star::uno::Reference<
64 ::com::sun::star::uno::XInterface > xMyEvtObj;
65 ::cppu::OInterfaceContainerHelper aLngSvcEvtListeners;
66 ::com::sun::star::uno::Reference<
67 ::com::sun::star::beans::XPropertySet > xPropSet;
69 int nEvtFlags; // flags for event types allowed to be launched
71 // default values
72 sal_Bool bIsIgnoreControlCharacters;
73 sal_Bool bIsUseDictionaryList;
75 // return values, will be set to default value or current temporary value
76 sal_Bool bResIsIgnoreControlCharacters;
77 sal_Bool bResIsUseDictionaryList;
80 // disallow use of copy-constructor and assignment-operator
81 PropertyChgHelper( const PropertyChgHelper & );
82 PropertyChgHelper & operator = ( const PropertyChgHelper & );
84 protected:
85 virtual void SetDefaultValues();
86 virtual void GetCurrentValues();
88 ::com::sun::star::uno::Sequence< OUString > &
89 GetPropNames() { return aPropNames; }
90 ::com::sun::star::uno::Reference<
91 ::com::sun::star::beans::XPropertySet > &
92 GetPropSet() { return xPropSet; }
94 void AddPropNames( const char *pNewNames[], sal_Int32 nCount );
96 virtual sal_Bool propertyChange_Impl(
97 const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
99 public:
100 PropertyChgHelper(
101 const ::com::sun::star::uno::Reference<
102 ::com::sun::star::uno::XInterface > &rxSource,
103 ::com::sun::star::uno::Reference<
104 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet,
105 int nAllowedEvents );
106 virtual ~PropertyChgHelper();
108 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
110 // XEventListener
111 virtual void SAL_CALL
112 disposing( const ::com::sun::star::lang::EventObject& rSource )
113 throw(::com::sun::star::uno::RuntimeException);
115 // XPropertyChangeListener
116 virtual void SAL_CALL
117 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
118 throw(::com::sun::star::uno::RuntimeException);
120 // XLinguServiceEventBroadcaster
121 virtual sal_Bool SAL_CALL
122 addLinguServiceEventListener(
123 const ::com::sun::star::uno::Reference<
124 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
125 throw(::com::sun::star::uno::RuntimeException);
126 virtual sal_Bool SAL_CALL
127 removeLinguServiceEventListener(
128 const ::com::sun::star::uno::Reference<
129 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
130 throw(::com::sun::star::uno::RuntimeException);
132 // non-UNO functions
133 void LNG_DLLPUBLIC AddAsPropListener();
134 void LNG_DLLPUBLIC RemoveAsPropListener();
135 void LaunchEvent(
136 const ::com::sun::star::linguistic2::LinguServiceEvent& rEvt );
138 const ::com::sun::star::uno::Sequence< OUString > &
139 GetPropNames() const { return aPropNames; }
140 const ::com::sun::star::uno::Reference<
141 ::com::sun::star::beans::XPropertySet > &
142 GetPropSet() const { return xPropSet; }
143 const ::com::sun::star::uno::Reference<
144 ::com::sun::star::uno::XInterface > &
145 GetEvtObj() const { return xMyEvtObj; }
147 sal_Bool IsIgnoreControlCharacters() const { return bResIsIgnoreControlCharacters; }
148 sal_Bool IsUseDictionaryList() const { return bResIsUseDictionaryList; }
152 class PropertyHelper_Thes :
153 public PropertyChgHelper
155 // disallow use of copy-constructor and assignment-operator
156 PropertyHelper_Thes( const PropertyHelper_Thes & );
157 PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & );
159 public:
160 PropertyHelper_Thes(
161 const ::com::sun::star::uno::Reference<
162 ::com::sun::star::uno::XInterface > &rxSource,
163 ::com::sun::star::uno::Reference<
164 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
165 virtual ~PropertyHelper_Thes();
167 // XPropertyChangeListener
168 virtual void SAL_CALL
169 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
170 throw(::com::sun::star::uno::RuntimeException);
173 class LNG_DLLPUBLIC PropertyHelper_Thesaurus
175 PropertyHelper_Thes* pInst;
176 com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper;
178 // disallow use of copy-constructor and assignment-operator
179 PropertyHelper_Thesaurus( const PropertyHelper_Thes & );
180 PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & );
182 public:
183 PropertyHelper_Thesaurus(
184 const ::com::sun::star::uno::Reference<
185 ::com::sun::star::uno::XInterface > &rxSource,
186 ::com::sun::star::uno::Reference<
187 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
188 ~PropertyHelper_Thesaurus();
189 void AddAsPropListener();
190 void RemoveAsPropListener();
191 void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
195 class LNG_DLLPUBLIC PropertyHelper_Spell :
196 public PropertyChgHelper
198 // default values
199 sal_Bool bIsSpellUpperCase;
200 sal_Bool bIsSpellWithDigits;
201 sal_Bool bIsSpellCapitalization;
203 // return values, will be set to default value or current temporary value
204 sal_Int16 nResMaxNumberOfSuggestions; // special value that is not part of the property set and thus needs to be handled differently
205 sal_Bool bResIsSpellUpperCase;
206 sal_Bool bResIsSpellWithDigits;
207 sal_Bool bResIsSpellCapitalization;
210 // disallow use of copy-constructor and assignment-operator
211 PropertyHelper_Spell( const PropertyHelper_Spell & );
212 PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & );
214 protected:
215 // PropertyChgHelper
216 virtual void SetDefaultValues();
217 virtual void GetCurrentValues();
218 virtual sal_Bool propertyChange_Impl(
219 const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
221 public:
222 PropertyHelper_Spell(
223 const ::com::sun::star::uno::Reference<
224 ::com::sun::star::uno::XInterface > &rxSource,
225 ::com::sun::star::uno::Reference<
226 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
227 virtual ~PropertyHelper_Spell();
229 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
231 // XPropertyChangeListener
232 virtual void SAL_CALL
233 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
234 throw(::com::sun::star::uno::RuntimeException);
236 virtual sal_Int16 GetDefaultNumberOfSuggestions() const;
238 sal_Int16 GetMaxNumberOfSuggestions() const { return nResMaxNumberOfSuggestions; }
239 sal_Bool IsSpellUpperCase() const { return bResIsSpellUpperCase; }
240 sal_Bool IsSpellWithDigits() const { return bResIsSpellWithDigits; }
241 sal_Bool IsSpellCapitalization() const { return bResIsSpellCapitalization; }
245 class LNG_DLLPUBLIC PropertyHelper_Spelling
247 PropertyHelper_Spell* pInst;
248 com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper;
250 // disallow use of copy-constructor and assignment-operator
251 PropertyHelper_Spelling( const PropertyHelper_Spell & );
252 PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & );
254 public:
255 PropertyHelper_Spelling(
256 const ::com::sun::star::uno::Reference<
257 ::com::sun::star::uno::XInterface > &rxSource,
258 ::com::sun::star::uno::Reference<
259 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet );
260 ~PropertyHelper_Spelling();
262 void AddAsPropListener();
263 void RemoveAsPropListener();
264 void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
265 sal_Bool IsSpellUpperCase() const;
266 sal_Bool IsSpellWithDigits() const;
267 sal_Bool IsSpellCapitalization() const;
268 sal_Bool addLinguServiceEventListener(
269 const ::com::sun::star::uno::Reference<
270 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
271 throw(::com::sun::star::uno::RuntimeException);
272 sal_Bool removeLinguServiceEventListener(
273 const ::com::sun::star::uno::Reference<
274 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
275 throw(::com::sun::star::uno::RuntimeException);
279 class PropertyHelper_Hyphen :
280 public PropertyChgHelper
282 // default values
283 sal_Int16 nHyphMinLeading,
284 nHyphMinTrailing,
285 nHyphMinWordLength;
287 // return values, will be set to default value or current temporary value
288 sal_Int16 nResHyphMinLeading,
289 nResHyphMinTrailing,
290 nResHyphMinWordLength;
292 // disallow use of copy-constructor and assignment-operator
293 PropertyHelper_Hyphen( const PropertyHelper_Hyphen & );
294 PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & );
296 protected:
297 // PropertyChgHelper
298 virtual void SetDefaultValues();
299 virtual void GetCurrentValues();
300 virtual sal_Bool propertyChange_Impl(
301 const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
303 public:
304 PropertyHelper_Hyphen(
305 const ::com::sun::star::uno::Reference<
306 ::com::sun::star::uno::XInterface > &rxSource,
307 ::com::sun::star::uno::Reference<
308 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet);
309 virtual ~PropertyHelper_Hyphen();
311 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
313 // XPropertyChangeListener
314 virtual void SAL_CALL
315 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
316 throw(::com::sun::star::uno::RuntimeException);
318 sal_Int16 GetMinLeading() const { return nResHyphMinLeading; }
319 sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; }
320 sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; }
323 class LNG_DLLPUBLIC PropertyHelper_Hyphenation
325 PropertyHelper_Hyphen* pInst;
326 com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper;
328 // disallow use of copy-constructor and assignment-operator
329 PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & );
330 PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & );
332 public:
333 PropertyHelper_Hyphenation(
334 const ::com::sun::star::uno::Reference<
335 ::com::sun::star::uno::XInterface > &rxSource,
336 ::com::sun::star::uno::Reference<
337 ::com::sun::star::linguistic2::XLinguProperties > &rxPropSet);
338 ~PropertyHelper_Hyphenation();
340 void AddAsPropListener();
341 void RemoveAsPropListener();
342 void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
343 sal_Int16 GetMinLeading() const;
344 sal_Int16 GetMinTrailing() const;
345 sal_Int16 GetMinWordLength() const;
346 sal_Bool addLinguServiceEventListener(
347 const ::com::sun::star::uno::Reference<
348 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
349 throw(::com::sun::star::uno::RuntimeException);
350 sal_Bool removeLinguServiceEventListener(
351 const ::com::sun::star::uno::Reference<
352 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
353 throw(::com::sun::star::uno::RuntimeException);
356 } // namespace linguistic
358 #endif
360 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */