Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _LINGUISTIC_LNGPROPHELP_HXX_
30 : : #define _LINGUISTIC_LNGPROPHELP_HXX_
31 : :
32 : : #include <tools/solar.h>
33 : : #include <uno/lbnames.h>
34 : : #include <cppuhelper/implbase2.hxx>
35 : : #include <cppuhelper/interfacecontainer.h>
36 : : #include <com/sun/star/beans/XPropertyChangeListener.hpp>
37 : : #include <com/sun/star/beans/PropertyValues.hpp>
38 : : #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
39 : : #include <linguistic/lngdllapi.h>
40 : :
41 : : namespace com { namespace sun { namespace star { namespace beans {
42 : : class XPropertySet;
43 : : }}}}
44 : :
45 : : namespace com { namespace sun { namespace star { namespace linguistic2 {
46 : : struct LinguServiceEvent;
47 : : }}}}
48 : :
49 : :
50 : : namespace linguistic
51 : : {
52 : :
53 : : // PropertyChgHelper
54 : : // Base class for all XPropertyChangeListener members of the
55 : : // various lingu services.
56 : :
57 : :
58 : : // Flags for type of events allowed to be launched
59 : : #define AE_SPELLCHECKER 1
60 : : #define AE_HYPHENATOR 2
61 : :
62 : : typedef cppu::WeakImplHelper2
63 : : <
64 : : ::com::sun::star::beans::XPropertyChangeListener,
65 : : ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster
66 : : > PropertyChgHelperBase;
67 : :
68 : : class PropertyChgHelper :
69 : : public PropertyChgHelperBase
70 : : {
71 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > aPropNames;
72 : : ::com::sun::star::uno::Reference<
73 : : ::com::sun::star::uno::XInterface > xMyEvtObj;
74 : : ::cppu::OInterfaceContainerHelper aLngSvcEvtListeners;
75 : : ::com::sun::star::uno::Reference<
76 : : ::com::sun::star::beans::XPropertySet > xPropSet;
77 : :
78 : : int nEvtFlags; // flags for event types allowed to be launched
79 : :
80 : : // default values
81 : : sal_Bool bIsIgnoreControlCharacters;
82 : : sal_Bool bIsUseDictionaryList;
83 : :
84 : : // return values, will be set to default value or current temporary value
85 : : sal_Bool bResIsIgnoreControlCharacters;
86 : : sal_Bool bResIsUseDictionaryList;
87 : :
88 : :
89 : : // disallow use of copy-constructor and assignment-operator
90 : : PropertyChgHelper( const PropertyChgHelper & );
91 : : PropertyChgHelper & operator = ( const PropertyChgHelper & );
92 : :
93 : : protected:
94 : : virtual void SetDefaultValues();
95 : : virtual void GetCurrentValues();
96 : :
97 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > &
98 : 343 : GetPropNames() { return aPropNames; }
99 : : ::com::sun::star::uno::Reference<
100 : : ::com::sun::star::beans::XPropertySet > &
101 : 343 : GetPropSet() { return xPropSet; }
102 : :
103 : : void AddPropNames( const char *pNewNames[], sal_Int32 nCount );
104 : :
105 : : virtual sal_Bool propertyChange_Impl(
106 : : const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
107 : :
108 : : public:
109 : : PropertyChgHelper(
110 : : const ::com::sun::star::uno::Reference<
111 : : ::com::sun::star::uno::XInterface > &rxSource,
112 : : ::com::sun::star::uno::Reference<
113 : : ::com::sun::star::beans::XPropertySet > &rxPropSet,
114 : : int nAllowedEvents );
115 : : virtual ~PropertyChgHelper();
116 : :
117 : : virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
118 : :
119 : : // XEventListener
120 : : virtual void SAL_CALL
121 : : disposing( const ::com::sun::star::lang::EventObject& rSource )
122 : : throw(::com::sun::star::uno::RuntimeException);
123 : :
124 : : // XPropertyChangeListener
125 : : virtual void SAL_CALL
126 : : propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
127 : : throw(::com::sun::star::uno::RuntimeException);
128 : :
129 : : // XLinguServiceEventBroadcaster
130 : : virtual sal_Bool SAL_CALL
131 : : addLinguServiceEventListener(
132 : : const ::com::sun::star::uno::Reference<
133 : : ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
134 : : throw(::com::sun::star::uno::RuntimeException);
135 : : virtual sal_Bool SAL_CALL
136 : : removeLinguServiceEventListener(
137 : : const ::com::sun::star::uno::Reference<
138 : : ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
139 : : throw(::com::sun::star::uno::RuntimeException);
140 : :
141 : : // non-UNO functions
142 : : void LNG_DLLPUBLIC AddAsPropListener();
143 : : void LNG_DLLPUBLIC RemoveAsPropListener();
144 : : void LaunchEvent(
145 : : const ::com::sun::star::linguistic2::LinguServiceEvent& rEvt );
146 : :
147 : : const ::com::sun::star::uno::Sequence< ::rtl::OUString > &
148 : : GetPropNames() const { return aPropNames; }
149 : : const ::com::sun::star::uno::Reference<
150 : : ::com::sun::star::beans::XPropertySet > &
151 : : GetPropSet() const { return xPropSet; }
152 : : const ::com::sun::star::uno::Reference<
153 : : ::com::sun::star::uno::XInterface > &
154 : 0 : GetEvtObj() const { return xMyEvtObj; }
155 : :
156 : : sal_Bool IsIgnoreControlCharacters() const { return bResIsIgnoreControlCharacters; }
157 : : sal_Bool IsUseDictionaryList() const { return bResIsUseDictionaryList; }
158 : : };
159 : :
160 : :
161 : : class PropertyHelper_Thes :
162 : : public PropertyChgHelper
163 : : {
164 : : // disallow use of copy-constructor and assignment-operator
165 : : PropertyHelper_Thes( const PropertyHelper_Thes & );
166 : : PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & );
167 : :
168 : : public:
169 : : PropertyHelper_Thes(
170 : : const ::com::sun::star::uno::Reference<
171 : : ::com::sun::star::uno::XInterface > &rxSource,
172 : : ::com::sun::star::uno::Reference<
173 : : ::com::sun::star::beans::XPropertySet > &rxPropSet );
174 : : virtual ~PropertyHelper_Thes();
175 : :
176 : : // XPropertyChangeListener
177 : : virtual void SAL_CALL
178 : : propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
179 : : throw(::com::sun::star::uno::RuntimeException);
180 : : };
181 : :
182 : : class LNG_DLLPUBLIC PropertyHelper_Thesaurus
183 : : {
184 : : PropertyHelper_Thes* pInst;
185 : : com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper;
186 : :
187 : : // disallow use of copy-constructor and assignment-operator
188 : : PropertyHelper_Thesaurus( const PropertyHelper_Thes & );
189 : : PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & );
190 : :
191 : : public:
192 : : PropertyHelper_Thesaurus(
193 : : const ::com::sun::star::uno::Reference<
194 : : ::com::sun::star::uno::XInterface > &rxSource,
195 : : ::com::sun::star::uno::Reference<
196 : : ::com::sun::star::beans::XPropertySet > &rxPropSet );
197 : : ~PropertyHelper_Thesaurus();
198 : : void AddAsPropListener();
199 : : void RemoveAsPropListener();
200 : : void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
201 : : };
202 : :
203 : :
204 : : class LNG_DLLPUBLIC PropertyHelper_Spell :
205 : : public PropertyChgHelper
206 : : {
207 : : // default values
208 : : sal_Bool bIsSpellUpperCase;
209 : : sal_Bool bIsSpellWithDigits;
210 : : sal_Bool bIsSpellCapitalization;
211 : :
212 : : // return values, will be set to default value or current temporary value
213 : : sal_Int16 nResMaxNumberOfSuggestions; // special value that is not part of the property set and thus needs to be handled differently
214 : : sal_Bool bResIsSpellUpperCase;
215 : : sal_Bool bResIsSpellWithDigits;
216 : : sal_Bool bResIsSpellCapitalization;
217 : :
218 : :
219 : : // disallow use of copy-constructor and assignment-operator
220 : : PropertyHelper_Spell( const PropertyHelper_Spell & );
221 : : PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & );
222 : :
223 : : protected:
224 : : // PropertyChgHelper
225 : : virtual void SetDefaultValues();
226 : : virtual void GetCurrentValues();
227 : : virtual sal_Bool propertyChange_Impl(
228 : : const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
229 : :
230 : : public:
231 : : PropertyHelper_Spell(
232 : : const ::com::sun::star::uno::Reference<
233 : : ::com::sun::star::uno::XInterface > &rxSource,
234 : : ::com::sun::star::uno::Reference<
235 : : ::com::sun::star::beans::XPropertySet > &rxPropSet );
236 : : virtual ~PropertyHelper_Spell();
237 : :
238 : : virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
239 : :
240 : : // XPropertyChangeListener
241 : : virtual void SAL_CALL
242 : : propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
243 : : throw(::com::sun::star::uno::RuntimeException);
244 : :
245 : : virtual sal_Int16 GetDefaultNumberOfSuggestions() const;
246 : :
247 : : sal_Int16 GetMaxNumberOfSuggestions() const { return nResMaxNumberOfSuggestions; }
248 : 12613 : sal_Bool IsSpellUpperCase() const { return bResIsSpellUpperCase; }
249 : 12449 : sal_Bool IsSpellWithDigits() const { return bResIsSpellWithDigits; }
250 : 4096 : sal_Bool IsSpellCapitalization() const { return bResIsSpellCapitalization; }
251 : : };
252 : :
253 : :
254 : : class LNG_DLLPUBLIC PropertyHelper_Spelling
255 : : {
256 : : PropertyHelper_Spell* pInst;
257 : : com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper;
258 : :
259 : : // disallow use of copy-constructor and assignment-operator
260 : : PropertyHelper_Spelling( const PropertyHelper_Spell & );
261 : : PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & );
262 : :
263 : : public:
264 : : PropertyHelper_Spelling(
265 : : const ::com::sun::star::uno::Reference<
266 : : ::com::sun::star::uno::XInterface > &rxSource,
267 : : ::com::sun::star::uno::Reference<
268 : : ::com::sun::star::beans::XPropertySet > &rxPropSet );
269 : : ~PropertyHelper_Spelling();
270 : :
271 : : void AddAsPropListener();
272 : : void RemoveAsPropListener();
273 : : void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
274 : : sal_Bool IsSpellUpperCase() const;
275 : : sal_Bool IsSpellWithDigits() const;
276 : : sal_Bool IsSpellCapitalization() const;
277 : : sal_Bool addLinguServiceEventListener(
278 : : const ::com::sun::star::uno::Reference<
279 : : ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
280 : : throw(::com::sun::star::uno::RuntimeException);
281 : : sal_Bool removeLinguServiceEventListener(
282 : : const ::com::sun::star::uno::Reference<
283 : : ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
284 : : throw(::com::sun::star::uno::RuntimeException);
285 : : };
286 : :
287 : :
288 : : class PropertyHelper_Hyphen :
289 : : public PropertyChgHelper
290 : : {
291 : : // default values
292 : : sal_Int16 nHyphMinLeading,
293 : : nHyphMinTrailing,
294 : : nHyphMinWordLength;
295 : :
296 : : // return values, will be set to default value or current temporary value
297 : : sal_Int16 nResHyphMinLeading,
298 : : nResHyphMinTrailing,
299 : : nResHyphMinWordLength;
300 : :
301 : : // disallow use of copy-constructor and assignment-operator
302 : : PropertyHelper_Hyphen( const PropertyHelper_Hyphen & );
303 : : PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & );
304 : :
305 : : protected:
306 : : // PropertyChgHelper
307 : : virtual void SetDefaultValues();
308 : : virtual void GetCurrentValues();
309 : : virtual sal_Bool propertyChange_Impl(
310 : : const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
311 : :
312 : : public:
313 : : PropertyHelper_Hyphen(
314 : : const ::com::sun::star::uno::Reference<
315 : : ::com::sun::star::uno::XInterface > &rxSource,
316 : : ::com::sun::star::uno::Reference<
317 : : ::com::sun::star::beans::XPropertySet > &rxPropSet);
318 : : virtual ~PropertyHelper_Hyphen();
319 : :
320 : : virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
321 : :
322 : : // XPropertyChangeListener
323 : : virtual void SAL_CALL
324 : : propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
325 : : throw(::com::sun::star::uno::RuntimeException);
326 : :
327 : 33603 : sal_Int16 GetMinLeading() const { return nResHyphMinLeading; }
328 : 33603 : sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; }
329 : 33603 : sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; }
330 : : };
331 : :
332 : : class LNG_DLLPUBLIC PropertyHelper_Hyphenation
333 : : {
334 : : PropertyHelper_Hyphen* pInst;
335 : : com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper;
336 : :
337 : : // disallow use of copy-constructor and assignment-operator
338 : : PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & );
339 : : PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & );
340 : :
341 : : public:
342 : : PropertyHelper_Hyphenation(
343 : : const ::com::sun::star::uno::Reference<
344 : : ::com::sun::star::uno::XInterface > &rxSource,
345 : : ::com::sun::star::uno::Reference<
346 : : ::com::sun::star::beans::XPropertySet > &rxPropSet);
347 : : ~PropertyHelper_Hyphenation();
348 : :
349 : : void AddAsPropListener();
350 : : void RemoveAsPropListener();
351 : : void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
352 : : sal_Int16 GetMinLeading() const;
353 : : sal_Int16 GetMinTrailing() const;
354 : : sal_Int16 GetMinWordLength() const;
355 : : sal_Bool addLinguServiceEventListener(
356 : : const ::com::sun::star::uno::Reference<
357 : : ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
358 : : throw(::com::sun::star::uno::RuntimeException);
359 : : sal_Bool removeLinguServiceEventListener(
360 : : const ::com::sun::star::uno::Reference<
361 : : ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
362 : : throw(::com::sun::star::uno::RuntimeException);
363 : : };
364 : :
365 : : } // namespace linguistic
366 : :
367 : : #endif
368 : :
369 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|