LibreOffice Module linguistic (master) 1
lngprophelp.hxx
Go to the documentation of this file.
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
25#include <com/sun/star/beans/XPropertyChangeListener.hpp>
26#include <com/sun/star/beans/PropertyValues.hpp>
27#include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
29#include <rtl/ref.hxx>
30#include <config_options.h>
31
32namespace com::sun::star::beans { class XPropertySet; }
33namespace com::sun::star::linguistic2 { struct LinguServiceEvent; }
34namespace com::sun::star::linguistic2 { class XLinguProperties; }
35
36
37namespace 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#define AE_SPELLCHECKER 1
47#define AE_HYPHENATOR 2
48
49typedef cppu::WeakImplHelper
50<
51 css::beans::XPropertyChangeListener,
52 css::linguistic2::XLinguServiceEventBroadcaster
54
55class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyChgHelper :
57{
58 std::vector< OUString > aPropNames;
59 css::uno::Reference< css::uno::XInterface > xMyEvtObj;
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
76protected:
77 virtual void SetDefaultValues();
78 virtual void GetCurrentValues();
79
80 std::vector< OUString > & GetPropNames() { return aPropNames; }
81 css::uno::Reference<
82 css::beans::XPropertySet > &
83 GetPropSet() { return xPropSet; }
84
85 virtual bool propertyChange_Impl( const css::beans::PropertyChangeEvent& rEvt );
86
87public:
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;
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;
108 virtual sal_Bool SAL_CALL
109 removeLinguServiceEventListener(
110 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ) override;
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 GetPropNames() const { return aPropNames; }
119 const css::uno::Reference< css::beans::XPropertySet > &
120 GetPropSet() const { return xPropSet; }
121 const css::uno::Reference< css::uno::XInterface > &
122 GetEvtObj() const { return xMyEvtObj; }
123};
124
125
127 public PropertyChgHelper
128{
130 PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & ) = delete;
131
132public:
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
143class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Thesaurus
144{
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
151public:
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
162class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Spell final :
163 public PropertyChgHelper
164{
165 // default values
166 bool bIsSpellUpperCase;
167 bool bIsSpellWithDigits;
168 bool bIsSpellCapitalization;
169 bool bIsSpellClosedCompound;
170 bool bIsSpellHyphenatedCompound;
171
172 // return values, will be set to default value or current temporary value
173 bool bResIsSpellUpperCase;
174 bool bResIsSpellWithDigits;
175 bool bResIsSpellCapitalization;
176 bool bResIsSpellClosedCompound;
177 bool bResIsSpellHyphenatedCompound;
178
179 PropertyHelper_Spell( const PropertyHelper_Spell & ) = delete;
180 PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ) = delete;
181
182 // PropertyChgHelper
183 virtual void SetDefaultValues() override;
184 virtual void GetCurrentValues() override;
185 virtual bool propertyChange_Impl(
186 const css::beans::PropertyChangeEvent& rEvt ) override;
187
188public:
189 PropertyHelper_Spell(
190 const css::uno::Reference< css::uno::XInterface > &rxSource,
191 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet );
192 virtual ~PropertyHelper_Spell() override;
193
194 virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override;
195
196 // XPropertyChangeListener
197 virtual void SAL_CALL
198 propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override;
199
200 bool IsSpellUpperCase() const { return bResIsSpellUpperCase; }
201 bool IsSpellWithDigits() const { return bResIsSpellWithDigits; }
202 bool IsSpellCapitalization() const { return bResIsSpellCapitalization; }
203 bool IsSpellClosedCompound() const { return bResIsSpellClosedCompound; }
204 bool IsSpellHyphenatedCompound() const { return bResIsSpellHyphenatedCompound; }
205};
206
207
208class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Spelling
209{
211
212 // disallow use of copy-constructor and assignment-operator
213 PropertyHelper_Spelling( const PropertyHelper_Spell & ) = delete;
214 PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & ) = delete;
215
216public:
217 PropertyHelper_Spelling(
218 const css::uno::Reference< css::uno::XInterface > &rxSource,
219 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet );
220 ~PropertyHelper_Spelling();
221
222 void AddAsPropListener();
223 void RemoveAsPropListener();
224 void SetTmpPropVals( const css::beans::PropertyValues &rPropVals );
225 bool IsSpellUpperCase() const;
226 bool IsSpellWithDigits() const;
227 bool IsSpellCapitalization() const;
228 bool IsSpellClosedCompound() const;
229 bool IsSpellHyphenatedCompound() const;
231 bool addLinguServiceEventListener(
232 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener );
234 bool removeLinguServiceEventListener(
235 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener );
236};
237
238
240 public PropertyChgHelper
241{
242 // default values
247
248 // return values, will be set to default value or current temporary value
253
255 PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & ) = delete;
256
257 // PropertyChgHelper
258 virtual void SetDefaultValues() override;
259 virtual void GetCurrentValues() override;
260 virtual bool propertyChange_Impl(
261 const css::beans::PropertyChangeEvent& rEvt ) override;
262
263public:
265 const css::uno::Reference< css::uno::XInterface > &rxSource,
266 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet);
267 virtual ~PropertyHelper_Hyphen() override;
268
269 virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override;
270
271 // XPropertyChangeListener
272 virtual void SAL_CALL
273 propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override;
274
275 sal_Int16 GetMinLeading() const { return nResHyphMinLeading; }
276 sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; }
277 sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; }
278 bool IsNoHyphenateCaps() const { return bResNoHyphenateCaps; }
279};
280
281class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Hyphenation
282{
284
285 // disallow use of copy-constructor and assignment-operator
286 PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & ) = delete;
287 PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & ) = delete;
288
289public:
290 PropertyHelper_Hyphenation(
291 const css::uno::Reference< css::uno::XInterface > &rxSource,
292 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet);
293 ~PropertyHelper_Hyphenation();
294
295 void AddAsPropListener();
296 void RemoveAsPropListener();
297 void SetTmpPropVals( const css::beans::PropertyValues &rPropVals );
298 sal_Int16 GetMinLeading() const;
299 sal_Int16 GetMinTrailing() const;
300 sal_Int16 GetMinWordLength() const;
301 bool IsNoHyphenateCaps() const;
303 bool addLinguServiceEventListener(
304 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener );
306 bool removeLinguServiceEventListener(
307 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener );
308};
309
310} // namespace linguistic
311
312#endif
313
314/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PropertyHelper_Hyphen(const css::uno::Reference< css::uno::XInterface > &rxSource, css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet)
PropertyHelper_Hyphen(const PropertyHelper_Hyphen &)=delete
PropertyHelper_Thes(const PropertyHelper_Thes &)=delete
PropertyHelper_Thes(const css::uno::Reference< css::uno::XInterface > &rxSource, css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet)
class SAL_NO_VTABLE XPropertySet
cppu::WeakImplHelper< css::beans::XPropertyChangeListener, css::linguistic2::XLinguServiceEventBroadcaster > PropertyChgHelperBase
Definition: lngprophelp.hxx:53
const PropertyStruct aPropNames[]
unsigned char sal_Bool