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