nss: upgrade to release 3.73
[LibreOffice.git] / include / linguistic / lngprophelp.hxx
blob52af61c4e61cf21271d4f9b44fbd4f8384ce655b
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 INCLUDED_LINGUISTIC_LNGPROPHELP_HXX
21 #define INCLUDED_LINGUISTIC_LNGPROPHELP_HXX
23 #include <cppuhelper/implbase.hxx>
24 #include <comphelper/interfacecontainer2.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>
32 namespace com::sun::star::beans { class XPropertySet; }
33 namespace com::sun::star::linguistic2 { struct LinguServiceEvent; }
34 namespace com::sun::star::linguistic2 { class XLinguProperties; }
37 namespace linguistic
40 // PropertyChgHelper
41 // Base class for all XPropertyChangeListener members of the
42 // various lingu services.
45 // Flags for type of events allowed to be launched
46 #define AE_SPELLCHECKER 1
47 #define AE_HYPHENATOR 2
49 typedef cppu::WeakImplHelper
51 css::beans::XPropertyChangeListener,
52 css::linguistic2::XLinguServiceEventBroadcaster
53 > PropertyChgHelperBase;
55 class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyChgHelper :
56 public PropertyChgHelperBase
58 css::uno::Sequence< OUString > aPropNames;
59 css::uno::Reference< css::uno::XInterface > xMyEvtObj;
60 ::comphelper::OInterfaceContainerHelper2 aLngSvcEvtListeners;
61 css::uno::Reference< css::beans::XPropertySet > xPropSet;
63 int nEvtFlags; // flags for event types allowed to be launched
65 // default values
66 bool bIsIgnoreControlCharacters;
67 bool bIsUseDictionaryList;
69 // return values, will be set to default value or current temporary value
70 bool bResIsIgnoreControlCharacters;
71 bool bResIsUseDictionaryList;
73 PropertyChgHelper( const PropertyChgHelper & ) = delete;
74 PropertyChgHelper & operator = ( const PropertyChgHelper & ) = delete;
76 protected:
77 virtual void SetDefaultValues();
78 virtual void GetCurrentValues();
80 css::uno::Sequence< OUString > &
81 GetPropNames() { return aPropNames; }
82 css::uno::Reference<
83 css::beans::XPropertySet > &
84 GetPropSet() { return xPropSet; }
86 void AddPropNames( const char *pNewNames[], sal_Int32 nCount );
88 virtual bool propertyChange_Impl( const css::beans::PropertyChangeEvent& rEvt );
90 public:
91 PropertyChgHelper(
92 const css::uno::Reference< css::uno::XInterface > &rxSource,
93 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet,
94 int nAllowedEvents );
95 virtual ~PropertyChgHelper() override;
97 virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals );
99 // XEventListener
100 virtual void SAL_CALL
101 disposing( const css::lang::EventObject& rSource ) override;
103 // XPropertyChangeListener
104 virtual void SAL_CALL
105 propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override;
107 // XLinguServiceEventBroadcaster
108 virtual sal_Bool SAL_CALL
109 addLinguServiceEventListener(
110 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ) override;
111 virtual sal_Bool SAL_CALL
112 removeLinguServiceEventListener(
113 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener ) override;
115 // non-UNO functions
116 void AddAsPropListener();
117 void RemoveAsPropListener();
118 void LaunchEvent( const css::linguistic2::LinguServiceEvent& rEvt );
120 const css::uno::Sequence< OUString > &
121 GetPropNames() const { return aPropNames; }
122 const css::uno::Reference< css::beans::XPropertySet > &
123 GetPropSet() const { return xPropSet; }
124 const css::uno::Reference< css::uno::XInterface > &
125 GetEvtObj() const { return xMyEvtObj; }
129 class PropertyHelper_Thes final :
130 public PropertyChgHelper
132 PropertyHelper_Thes( const PropertyHelper_Thes & ) = delete;
133 PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & ) = delete;
135 public:
136 PropertyHelper_Thes(
137 const css::uno::Reference< css::uno::XInterface > &rxSource,
138 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet );
139 virtual ~PropertyHelper_Thes() override;
141 // XPropertyChangeListener
142 virtual void SAL_CALL
143 propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override;
146 class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Thesaurus
148 rtl::Reference< PropertyHelper_Thes > mxPropHelper;
150 // disallow use of copy-constructor and assignment-operator
151 PropertyHelper_Thesaurus( const PropertyHelper_Thes & ) = delete;
152 PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & ) = delete;
154 public:
155 PropertyHelper_Thesaurus(
156 const css::uno::Reference< css::uno::XInterface > &rxSource,
157 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet );
158 ~PropertyHelper_Thesaurus();
159 void AddAsPropListener();
160 void RemoveAsPropListener();
161 void SetTmpPropVals( const css::beans::PropertyValues &rPropVals );
165 class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Spell final :
166 public PropertyChgHelper
168 // default values
169 bool bIsSpellUpperCase;
170 bool bIsSpellWithDigits;
171 bool bIsSpellCapitalization;
173 // return values, will be set to default value or current temporary value
174 bool bResIsSpellUpperCase;
175 bool bResIsSpellWithDigits;
176 bool bResIsSpellCapitalization;
178 PropertyHelper_Spell( const PropertyHelper_Spell & ) = delete;
179 PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ) = delete;
181 // PropertyChgHelper
182 virtual void SetDefaultValues() override;
183 virtual void GetCurrentValues() override;
184 virtual bool propertyChange_Impl(
185 const css::beans::PropertyChangeEvent& rEvt ) override;
187 public:
188 PropertyHelper_Spell(
189 const css::uno::Reference< css::uno::XInterface > &rxSource,
190 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet );
191 virtual ~PropertyHelper_Spell() override;
193 virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override;
195 // XPropertyChangeListener
196 virtual void SAL_CALL
197 propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override;
199 bool IsSpellUpperCase() const { return bResIsSpellUpperCase; }
200 bool IsSpellWithDigits() const { return bResIsSpellWithDigits; }
201 bool IsSpellCapitalization() const { return bResIsSpellCapitalization; }
205 class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Spelling
207 rtl::Reference< PropertyHelper_Spell > mxPropHelper;
209 // disallow use of copy-constructor and assignment-operator
210 PropertyHelper_Spelling( const PropertyHelper_Spell & ) = delete;
211 PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & ) = delete;
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();
219 void AddAsPropListener();
220 void RemoveAsPropListener();
221 void SetTmpPropVals( const css::beans::PropertyValues &rPropVals );
222 bool IsSpellUpperCase() const;
223 bool IsSpellWithDigits() const;
224 bool IsSpellCapitalization() const;
225 /// @throws css::uno::RuntimeException
226 bool addLinguServiceEventListener(
227 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener );
228 /// @throws css::uno::RuntimeException
229 bool removeLinguServiceEventListener(
230 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener );
234 class PropertyHelper_Hyphen final :
235 public PropertyChgHelper
237 // default values
238 sal_Int16 nHyphMinLeading,
239 nHyphMinTrailing,
240 nHyphMinWordLength;
241 bool bNoHyphenateCaps;
243 // return values, will be set to default value or current temporary value
244 sal_Int16 nResHyphMinLeading,
245 nResHyphMinTrailing,
246 nResHyphMinWordLength;
247 bool bResNoHyphenateCaps;
249 PropertyHelper_Hyphen( const PropertyHelper_Hyphen & ) = delete;
250 PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & ) = delete;
252 // PropertyChgHelper
253 virtual void SetDefaultValues() override;
254 virtual void GetCurrentValues() override;
255 virtual bool propertyChange_Impl(
256 const css::beans::PropertyChangeEvent& rEvt ) override;
258 public:
259 PropertyHelper_Hyphen(
260 const css::uno::Reference< css::uno::XInterface > &rxSource,
261 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet);
262 virtual ~PropertyHelper_Hyphen() override;
264 virtual void SetTmpPropVals( const css::beans::PropertyValues &rPropVals ) override;
266 // XPropertyChangeListener
267 virtual void SAL_CALL
268 propertyChange( const css::beans::PropertyChangeEvent& rEvt ) override;
270 sal_Int16 GetMinLeading() const { return nResHyphMinLeading; }
271 sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; }
272 sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; }
273 bool IsNoHyphenateCaps() const { return bResNoHyphenateCaps; }
276 class UNLESS_MERGELIBS(LNG_DLLPUBLIC) PropertyHelper_Hyphenation
278 rtl::Reference< PropertyHelper_Hyphen > mxPropHelper;
280 // disallow use of copy-constructor and assignment-operator
281 PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & ) = delete;
282 PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & ) = delete;
284 public:
285 PropertyHelper_Hyphenation(
286 const css::uno::Reference< css::uno::XInterface > &rxSource,
287 css::uno::Reference< css::linguistic2::XLinguProperties > const &rxPropSet);
288 ~PropertyHelper_Hyphenation();
290 void AddAsPropListener();
291 void RemoveAsPropListener();
292 void SetTmpPropVals( const css::beans::PropertyValues &rPropVals );
293 sal_Int16 GetMinLeading() const;
294 sal_Int16 GetMinTrailing() const;
295 sal_Int16 GetMinWordLength() const;
296 bool IsNoHyphenateCaps() const;
297 /// @throws css::uno::RuntimeException
298 bool addLinguServiceEventListener(
299 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener );
300 /// @throws css::uno::RuntimeException
301 bool removeLinguServiceEventListener(
302 const css::uno::Reference< css::linguistic2::XLinguServiceEventListener >& rxListener );
305 } // namespace linguistic
307 #endif
309 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */