merge the formfield patch from ooo-build
[ooovba.git] / linguistic / inc / lngprophelp.hxx
blobef5e913af42206c4fd851fef25ee152fb2d63e6c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: prophelp.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _LINGUISTIC_LNGPROPHELP_HXX_
32 #define _LINGUISTIC_LNGPROPHELP_HXX_
34 #include <tools/solar.h>
36 #include <uno/lbnames.h>
37 #include <cppuhelper/implbase2.hxx>
38 #include <cppuhelper/interfacecontainer.h>
39 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
40 #include <com/sun/star/beans/PropertyValues.hpp>
42 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp>
44 namespace com { namespace sun { namespace star { namespace beans {
45 class XPropertySet;
46 }}}}
48 namespace com { namespace sun { namespace star { namespace linguistic2 {
49 struct LinguServiceEvent;
50 }}}}
53 namespace linguistic
56 ///////////////////////////////////////////////////////////////////////////
57 // PropertyChgHelper
58 // Base class for all XPropertyChangeListener members of the
59 // various lingu services.
62 // Flags for type of events allowed to be launched
63 #define AE_SPELLCHECKER 1
64 #define AE_HYPHENATOR 2
65 //#define AE_THESAURUS 4
67 typedef cppu::WeakImplHelper2
69 ::com::sun::star::beans::XPropertyChangeListener,
70 ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster
71 > PropertyChgHelperBase;
73 class PropertyChgHelper :
74 public PropertyChgHelperBase
76 ::com::sun::star::uno::Sequence< ::rtl::OUString > aPropNames;
77 ::com::sun::star::uno::Reference<
78 ::com::sun::star::uno::XInterface > xMyEvtObj;
79 ::cppu::OInterfaceContainerHelper aLngSvcEvtListeners;
80 ::com::sun::star::uno::Reference<
81 ::com::sun::star::beans::XPropertySet > xPropSet;
83 int nEvtFlags; // flags for event types allowed to be launched
85 // default values
86 BOOL bIsIgnoreControlCharacters;
87 BOOL bIsUseDictionaryList;
89 // return values, will be set to default value or current temporary value
90 BOOL bResIsIgnoreControlCharacters;
91 BOOL bResIsUseDictionaryList;
94 // disallow use of copy-constructor and assignment-operator
95 PropertyChgHelper( const PropertyChgHelper & );
96 PropertyChgHelper & operator = ( const PropertyChgHelper & );
98 protected:
99 virtual void SetDefaultValues();
100 virtual void GetCurrentValues();
102 ::com::sun::star::uno::Sequence< ::rtl::OUString > &
103 GetPropNames() { return aPropNames; }
104 ::com::sun::star::uno::Reference<
105 ::com::sun::star::beans::XPropertySet > &
106 GetPropSet() { return xPropSet; }
108 void AddPropNames( const char *pNewNames[], INT32 nCount );
110 virtual BOOL propertyChange_Impl(
111 const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
113 public:
114 PropertyChgHelper(
115 const ::com::sun::star::uno::Reference<
116 ::com::sun::star::uno::XInterface > &rxSource,
117 ::com::sun::star::uno::Reference<
118 ::com::sun::star::beans::XPropertySet > &rxPropSet,
119 int nAllowedEvents );
120 virtual ~PropertyChgHelper();
122 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
124 // XEventListener
125 virtual void SAL_CALL
126 disposing( const ::com::sun::star::lang::EventObject& rSource )
127 throw(::com::sun::star::uno::RuntimeException);
129 // XPropertyChangeListener
130 virtual void SAL_CALL
131 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
132 throw(::com::sun::star::uno::RuntimeException);
134 // XLinguServiceEventBroadcaster
135 virtual sal_Bool SAL_CALL
136 addLinguServiceEventListener(
137 const ::com::sun::star::uno::Reference<
138 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
139 throw(::com::sun::star::uno::RuntimeException);
140 virtual sal_Bool SAL_CALL
141 removeLinguServiceEventListener(
142 const ::com::sun::star::uno::Reference<
143 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener )
144 throw(::com::sun::star::uno::RuntimeException);
146 // non-UNO functions
147 void AddAsPropListener();
148 void RemoveAsPropListener();
149 void LaunchEvent(
150 const ::com::sun::star::linguistic2::LinguServiceEvent& rEvt );
152 const ::com::sun::star::uno::Sequence< ::rtl::OUString > &
153 GetPropNames() const { return aPropNames; }
154 const ::com::sun::star::uno::Reference<
155 ::com::sun::star::beans::XPropertySet > &
156 GetPropSet() const { return xPropSet; }
157 const ::com::sun::star::uno::Reference<
158 ::com::sun::star::uno::XInterface > &
159 GetEvtObj() const { return xMyEvtObj; }
161 BOOL IsIgnoreControlCharacters() const { return bResIsIgnoreControlCharacters; }
162 BOOL IsUseDictionaryList() const { return bResIsUseDictionaryList; }
166 ///////////////////////////////////////////////////////////////////////////
168 class PropertyHelper_Thes :
169 public PropertyChgHelper
171 // disallow use of copy-constructor and assignment-operator
172 PropertyHelper_Thes( const PropertyHelper_Thes & );
173 PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & );
175 public:
176 PropertyHelper_Thes(
177 const ::com::sun::star::uno::Reference<
178 ::com::sun::star::uno::XInterface > &rxSource,
179 ::com::sun::star::uno::Reference<
180 ::com::sun::star::beans::XPropertySet > &rxPropSet );
181 virtual ~PropertyHelper_Thes();
183 // XPropertyChangeListener
184 virtual void SAL_CALL
185 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
186 throw(::com::sun::star::uno::RuntimeException);
189 ///////////////////////////////////////////////////////////////////////////
191 class PropertyHelper_Spell :
192 public PropertyChgHelper
194 // default values
195 BOOL bIsSpellUpperCase;
196 BOOL bIsSpellWithDigits;
197 BOOL bIsSpellCapitalization;
199 // return values, will be set to default value or current temporary value
200 INT16 nResMaxNumberOfSuggestions; // special value that is not part of the property set and thus needs to be handled differently
201 BOOL bResIsSpellUpperCase;
202 BOOL bResIsSpellWithDigits;
203 BOOL bResIsSpellCapitalization;
206 // disallow use of copy-constructor and assignment-operator
207 PropertyHelper_Spell( const PropertyHelper_Spell & );
208 PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & );
210 protected:
211 // PropertyChgHelper
212 virtual void SetDefaultValues();
213 virtual void GetCurrentValues();
214 virtual BOOL propertyChange_Impl(
215 const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
217 public:
218 PropertyHelper_Spell(
219 const ::com::sun::star::uno::Reference<
220 ::com::sun::star::uno::XInterface > &rxSource,
221 ::com::sun::star::uno::Reference<
222 ::com::sun::star::beans::XPropertySet > &rxPropSet );
223 virtual ~PropertyHelper_Spell();
225 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
227 // XPropertyChangeListener
228 virtual void SAL_CALL
229 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
230 throw(::com::sun::star::uno::RuntimeException);
232 virtual INT16 GetDefaultNumberOfSuggestions() const;
234 INT16 GetMaxNumberOfSuggestions() const { return nResMaxNumberOfSuggestions; }
235 BOOL IsSpellUpperCase() const { return bResIsSpellUpperCase; }
236 BOOL IsSpellWithDigits() const { return bResIsSpellWithDigits; }
237 BOOL IsSpellCapitalization() const { return bResIsSpellCapitalization; }
240 ///////////////////////////////////////////////////////////////////////////
242 class PropertyHelper_Hyphen :
243 public PropertyChgHelper
245 // default values
246 INT16 nHyphMinLeading,
247 nHyphMinTrailing,
248 nHyphMinWordLength;
250 // return values, will be set to default value or current temporary value
251 INT16 nResHyphMinLeading,
252 nResHyphMinTrailing,
253 nResHyphMinWordLength;
255 // disallow use of copy-constructor and assignment-operator
256 PropertyHelper_Hyphen( const PropertyHelper_Hyphen & );
257 PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & );
259 protected:
260 // PropertyChgHelper
261 virtual void SetDefaultValues();
262 virtual void GetCurrentValues();
263 virtual BOOL propertyChange_Impl(
264 const ::com::sun::star::beans::PropertyChangeEvent& rEvt );
266 public:
267 PropertyHelper_Hyphen(
268 const ::com::sun::star::uno::Reference<
269 ::com::sun::star::uno::XInterface > &rxSource,
270 ::com::sun::star::uno::Reference<
271 ::com::sun::star::beans::XPropertySet > &rxPropSet);
272 virtual ~PropertyHelper_Hyphen();
274 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals );
276 // XPropertyChangeListener
277 virtual void SAL_CALL
278 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt )
279 throw(::com::sun::star::uno::RuntimeException);
281 INT16 GetMinLeading() const { return nResHyphMinLeading; }
282 INT16 GetMinTrailing() const { return nResHyphMinTrailing; }
283 INT16 GetMinWordLength() const { return nResHyphMinWordLength; }
286 ///////////////////////////////////////////////////////////////////////////
288 } // namespace linguistic
290 #endif