/src/libreoffice/include/linguistic/lngprophelp.hxx
Line | Count | Source |
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 INCLUDED_LINGUISTIC_LNGPROPHELP_HXX |
21 | | #define INCLUDED_LINGUISTIC_LNGPROPHELP_HXX |
22 | | |
23 | | #include <cppuhelper/implbase.hxx> |
24 | | #include <comphelper/interfacecontainer3.hxx> |
25 | | #include <com/sun/star/beans/XPropertyChangeListener.hpp> |
26 | | #include <com/sun/star/beans/PropertyValues.hpp> |
27 | | #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> |
28 | | #include <linguistic/lngdllapi.h> |
29 | | #include <rtl/ref.hxx> |
30 | | #include <config_options.h> |
31 | | |
32 | | namespace com::sun::star::beans { class XPropertySet; } |
33 | | namespace com::sun::star::linguistic2 { struct LinguServiceEvent; } |
34 | | namespace com::sun::star::linguistic2 { class XLinguProperties; } |
35 | | |
36 | | |
37 | | namespace linguistic |
38 | | { |
39 | | |
40 | | // PropertyChgHelper |
41 | | // Base class for all XPropertyChangeListener members of the |
42 | | // various lingu services. |
43 | | |
44 | | |
45 | | // Flags for type of events allowed to be launched |
46 | 0 | #define AE_SPELLCHECKER 1 |
47 | 0 | #define AE_HYPHENATOR 2 |
48 | | |
49 | | typedef cppu::WeakImplHelper |
50 | | < |
51 | | css::beans::XPropertyChangeListener, |
52 | | css::linguistic2::XLinguServiceEventBroadcaster |
53 | | > PropertyChgHelperBase; |
54 | | |
55 | | class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyChgHelper : |
56 | | public PropertyChgHelperBase |
57 | | { |
58 | | std::vector< OUString > aPropNames; |
59 | | css::uno::Reference< css::uno::XInterface > xMyEvtObj; |
60 | | ::comphelper::OInterfaceContainerHelper3<css::linguistic2::XLinguServiceEventListener> aLngSvcEvtListeners; |
61 | | css::uno::Reference< css::beans::XPropertySet > xPropSet; |
62 | | |
63 | | int nEvtFlags; // flags for event types allowed to be launched |
64 | | |
65 | | // default values |
66 | | bool bIsIgnoreControlCharacters; |
67 | | bool bIsUseDictionaryList; |
68 | | |
69 | | // return values, will be set to default value or current temporary value |
70 | | bool bResIsIgnoreControlCharacters; |
71 | | bool bResIsUseDictionaryList; |
72 | | |
73 | | PropertyChgHelper( const PropertyChgHelper & ) = delete; |
74 | | PropertyChgHelper & operator = ( const PropertyChgHelper & ) = delete; |
75 | | |
76 | | protected: |
77 | | virtual void SetDefaultValues(); |
78 | | virtual void GetCurrentValues(); |
79 | | |
80 | 0 | std::vector< OUString > & GetPropNames() { return aPropNames; } |
81 | | css::uno::Reference< |
82 | | css::beans::XPropertySet > & |
83 | 0 | GetPropSet() { return xPropSet; } |
84 | | |
85 | | virtual bool propertyChange_Impl( const css::beans::PropertyChangeEvent& rEvt ); |
86 | | |
87 | | public: |
88 | | PropertyChgHelper( |
89 | | const css::uno::Reference< css::uno::XInterface > &rxSource, |
90 | | css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet, |
91 | | int nAllowedEvents ); |
92 | | virtual ~PropertyChgHelper() override; |
93 | | |
94 | | virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); |
95 | | |
96 | | // XEventListener |
97 | | virtual void SAL_CALL |
98 | | disposing( const css::lang::EventObject& rSource ) override final; |
99 | | |
100 | | // XPropertyChangeListener |
101 | | virtual void SAL_CALL |
102 | | propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override; |
103 | | |
104 | | // XLinguServiceEventBroadcaster |
105 | | virtual sal_Bool SAL_CALL |
106 | | addLinguServiceEventListener( |
107 | | const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ) override final; |
108 | | virtual sal_Bool SAL_CALL |
109 | | removeLinguServiceEventListener( |
110 | | const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ) override final; |
111 | | |
112 | | // non-UNO functions |
113 | | void AddAsPropListener(); |
114 | | void RemoveAsPropListener(); |
115 | | void LaunchEvent( const css::linguistic2::LinguServiceEvent& rEvt ); |
116 | | |
117 | | const std::vector< OUString > & |
118 | 0 | GetPropNames() const { return aPropNames; } |
119 | | const css::uno::Reference< css::beans::XPropertySet > & |
120 | 0 | GetPropSet() const { return xPropSet; } |
121 | | const css::uno::Reference< css::uno::XInterface > & |
122 | 0 | GetEvtObj() const { return xMyEvtObj; } |
123 | | }; |
124 | | |
125 | | |
126 | | class PropertyHelper_Thes final : |
127 | | public PropertyChgHelper |
128 | | { |
129 | | PropertyHelper_Thes( const PropertyHelper_Thes & ) = delete; |
130 | | PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & ) = delete; |
131 | | |
132 | | public: |
133 | | PropertyHelper_Thes( |
134 | | const css::uno::Reference< css::uno::XInterface > &rxSource, |
135 | | css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); |
136 | | virtual ~PropertyHelper_Thes() override; |
137 | | |
138 | | // XPropertyChangeListener |
139 | | virtual void SAL_CALL |
140 | | propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override; |
141 | | }; |
142 | | |
143 | | class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Thesaurus |
144 | | { |
145 | | rtl::Reference< PropertyHelper_Thes > mxPropHelper; |
146 | | |
147 | | // disallow use of copy-constructor and assignment-operator |
148 | | PropertyHelper_Thesaurus( const PropertyHelper_Thes & ) = delete; |
149 | | PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & ) = delete; |
150 | | |
151 | | public: |
152 | | PropertyHelper_Thesaurus( |
153 | | const css::uno::Reference< css::uno::XInterface > &rxSource, |
154 | | css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); |
155 | | ~PropertyHelper_Thesaurus(); |
156 | | void AddAsPropListener(); |
157 | | void RemoveAsPropListener(); |
158 | | void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); |
159 | | }; |
160 | | |
161 | | |
162 | | class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Spell final : |
163 | | public PropertyChgHelper |
164 | | { |
165 | | // default values |
166 | | bool bIsSpellUpperCase; |
167 | | bool bIsSpellWithDigits; |
168 | | bool bIsSpellClosedCompound; |
169 | | bool bIsSpellHyphenatedCompound; |
170 | | |
171 | | // return values, will be set to default value or current temporary value |
172 | | bool bResIsSpellUpperCase; |
173 | | bool bResIsSpellWithDigits; |
174 | | bool bResIsSpellClosedCompound; |
175 | | bool bResIsSpellHyphenatedCompound; |
176 | | |
177 | | PropertyHelper_Spell( const PropertyHelper_Spell & ) = delete; |
178 | | PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ) = delete; |
179 | | |
180 | | // PropertyChgHelper |
181 | | virtual void SetDefaultValues() override; |
182 | | virtual void GetCurrentValues() override; |
183 | | virtual bool propertyChange_Impl( |
184 | | const css::beans::PropertyChangeEvent& rEvt ) override; |
185 | | |
186 | | public: |
187 | | PropertyHelper_Spell( |
188 | | const css::uno::Reference< css::uno::XInterface > &rxSource, |
189 | | css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); |
190 | | virtual ~PropertyHelper_Spell() override; |
191 | | |
192 | | virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override; |
193 | | |
194 | | // XPropertyChangeListener |
195 | | virtual void SAL_CALL |
196 | | propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override; |
197 | | |
198 | 0 | bool IsSpellUpperCase() const { return bResIsSpellUpperCase; } |
199 | 0 | bool IsSpellWithDigits() const { return bResIsSpellWithDigits; } |
200 | 0 | bool IsSpellClosedCompound() const { return bResIsSpellClosedCompound; } |
201 | 0 | bool IsSpellHyphenatedCompound() const { return bResIsSpellHyphenatedCompound; } |
202 | | }; |
203 | | |
204 | | |
205 | | class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Spelling |
206 | | { |
207 | | rtl::Reference< PropertyHelper_Spell > mxPropHelper; |
208 | | |
209 | | // disallow use of copy-constructor and assignment-operator |
210 | | PropertyHelper_Spelling( const PropertyHelper_Spell & ) = delete; |
211 | | PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & ) = delete; |
212 | | |
213 | | public: |
214 | | PropertyHelper_Spelling( |
215 | | const css::uno::Reference< css::uno::XInterface > &rxSource, |
216 | | css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet ); |
217 | | ~PropertyHelper_Spelling(); |
218 | | |
219 | | void AddAsPropListener(); |
220 | | void RemoveAsPropListener(); |
221 | | void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); |
222 | | bool IsSpellUpperCase() const; |
223 | | bool IsSpellWithDigits() const; |
224 | | bool IsSpellClosedCompound() const; |
225 | | bool IsSpellHyphenatedCompound() const; |
226 | | /// @throws css::uno::RuntimeException |
227 | | bool addLinguServiceEventListener( |
228 | | const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ); |
229 | | /// @throws css::uno::RuntimeException |
230 | | bool removeLinguServiceEventListener( |
231 | | const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ); |
232 | | }; |
233 | | |
234 | | |
235 | | class PropertyHelper_Hyphen final : |
236 | | public PropertyChgHelper |
237 | | { |
238 | | // default values |
239 | | sal_Int16 nHyphMinLeading, |
240 | | nHyphMinTrailing, |
241 | | nHyphCompoundMinLeading, |
242 | | nHyphCompoundMinTrailing, |
243 | | nHyphMinWordLength, |
244 | | nHyphTextHyphenZone; |
245 | | bool bNoHyphenateCaps; |
246 | | |
247 | | // return values, will be set to default value or current temporary value |
248 | | sal_Int16 nResHyphMinLeading, |
249 | | nResHyphMinTrailing, |
250 | | nResHyphCompoundMinLeading, |
251 | | nResHyphCompoundMinTrailing, |
252 | | nResHyphMinWordLength, |
253 | | nResHyphTextHyphenZone; |
254 | | bool bResNoHyphenateCaps; |
255 | | |
256 | | PropertyHelper_Hyphen( const PropertyHelper_Hyphen & ) = delete; |
257 | | PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & ) = delete; |
258 | | |
259 | | // PropertyChgHelper |
260 | | virtual void SetDefaultValues() override; |
261 | | virtual void GetCurrentValues() override; |
262 | | virtual bool propertyChange_Impl( |
263 | | const css::beans::PropertyChangeEvent& rEvt ) override; |
264 | | |
265 | | public: |
266 | | PropertyHelper_Hyphen( |
267 | | const css::uno::Reference< css::uno::XInterface > &rxSource, |
268 | | css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet); |
269 | | virtual ~PropertyHelper_Hyphen() override; |
270 | | |
271 | | virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override; |
272 | | |
273 | | // XPropertyChangeListener |
274 | | virtual void SAL_CALL |
275 | | propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override; |
276 | | |
277 | 0 | sal_Int16 GetMinLeading() const { return nResHyphMinLeading; } |
278 | 0 | sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; } |
279 | 0 | sal_Int16 GetCompoundMinLeading() const { return nResHyphCompoundMinLeading; } |
280 | 0 | sal_Int16 GetCompoundMinTrailing() const { return nResHyphCompoundMinTrailing; } |
281 | 0 | sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; } |
282 | 0 | bool IsNoHyphenateCaps() const { return bResNoHyphenateCaps; } |
283 | | }; |
284 | | |
285 | | class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Hyphenation |
286 | | { |
287 | | rtl::Reference< PropertyHelper_Hyphen > mxPropHelper; |
288 | | |
289 | | // disallow use of copy-constructor and assignment-operator |
290 | | PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & ) = delete; |
291 | | PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & ) = delete; |
292 | | |
293 | | public: |
294 | | PropertyHelper_Hyphenation( |
295 | | const css::uno::Reference< css::uno::XInterface > &rxSource, |
296 | | css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet); |
297 | | ~PropertyHelper_Hyphenation(); |
298 | | |
299 | | void AddAsPropListener(); |
300 | | void RemoveAsPropListener(); |
301 | | void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ); |
302 | | sal_Int16 GetMinLeading() const; |
303 | | sal_Int16 GetMinTrailing() const; |
304 | | sal_Int16 GetCompoundMinLeading() const; |
305 | | sal_Int16 GetCompoundMinTrailing() const; |
306 | | sal_Int16 GetMinWordLength() const; |
307 | | bool IsNoHyphenateCaps() const; |
308 | | /// @throws css::uno::RuntimeException |
309 | | bool addLinguServiceEventListener( |
310 | | const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ); |
311 | | /// @throws css::uno::RuntimeException |
312 | | bool removeLinguServiceEventListener( |
313 | | const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ); |
314 | | }; |
315 | | |
316 | | } // namespace linguistic |
317 | | |
318 | | #endif |
319 | | |
320 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |