1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _LINGUISTIC_LNGPROPHELP_HXX_ 25 #define _LINGUISTIC_LNGPROPHELP_HXX_ 26 27 #include <tools/solar.h> 28 #include <uno/lbnames.h> 29 #include <cppuhelper/implbase2.hxx> 30 #include <cppuhelper/interfacecontainer.h> 31 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 32 #include <com/sun/star/beans/PropertyValues.hpp> 33 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> 34 #include <linguistic/lngdllapi.h> 35 36 namespace com { namespace sun { namespace star { namespace beans { 37 class XPropertySet; 38 }}}} 39 40 namespace com { namespace sun { namespace star { namespace linguistic2 { 41 struct LinguServiceEvent; 42 }}}} 43 44 45 namespace linguistic 46 { 47 48 /////////////////////////////////////////////////////////////////////////// 49 // PropertyChgHelper 50 // Base class for all XPropertyChangeListener members of the 51 // various lingu services. 52 53 54 // Flags for type of events allowed to be launched 55 #define AE_SPELLCHECKER 1 56 #define AE_HYPHENATOR 2 57 //#define AE_THESAURUS 4 58 59 typedef cppu::WeakImplHelper2 60 < 61 ::com::sun::star::beans::XPropertyChangeListener, 62 ::com::sun::star::linguistic2::XLinguServiceEventBroadcaster 63 > PropertyChgHelperBase; 64 65 class PropertyChgHelper : 66 public PropertyChgHelperBase 67 { 68 ::com::sun::star::uno::Sequence< ::rtl::OUString > aPropNames; 69 ::com::sun::star::uno::Reference< 70 ::com::sun::star::uno::XInterface > xMyEvtObj; 71 ::cppu::OInterfaceContainerHelper aLngSvcEvtListeners; 72 ::com::sun::star::uno::Reference< 73 ::com::sun::star::beans::XPropertySet > xPropSet; 74 75 int nEvtFlags; // flags for event types allowed to be launched 76 77 // default values 78 sal_Bool bIsIgnoreControlCharacters; 79 sal_Bool bIsUseDictionaryList; 80 81 // return values, will be set to default value or current temporary value 82 sal_Bool bResIsIgnoreControlCharacters; 83 sal_Bool bResIsUseDictionaryList; 84 85 86 // disallow use of copy-constructor and assignment-operator 87 PropertyChgHelper( const PropertyChgHelper & ); 88 PropertyChgHelper & operator = ( const PropertyChgHelper & ); 89 90 protected: 91 virtual void SetDefaultValues(); 92 virtual void GetCurrentValues(); 93 94 ::com::sun::star::uno::Sequence< ::rtl::OUString > & GetPropNames()95 GetPropNames() { return aPropNames; } 96 ::com::sun::star::uno::Reference< 97 ::com::sun::star::beans::XPropertySet > & GetPropSet()98 GetPropSet() { return xPropSet; } 99 100 void AddPropNames( const char *pNewNames[], sal_Int32 nCount ); 101 102 virtual sal_Bool propertyChange_Impl( 103 const ::com::sun::star::beans::PropertyChangeEvent& rEvt ); 104 105 public: 106 PropertyChgHelper( 107 const ::com::sun::star::uno::Reference< 108 ::com::sun::star::uno::XInterface > &rxSource, 109 ::com::sun::star::uno::Reference< 110 ::com::sun::star::beans::XPropertySet > &rxPropSet, 111 int nAllowedEvents ); 112 virtual ~PropertyChgHelper(); 113 114 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); 115 116 // XEventListener 117 virtual void SAL_CALL 118 disposing( const ::com::sun::star::lang::EventObject& rSource ) 119 throw(::com::sun::star::uno::RuntimeException); 120 121 // XPropertyChangeListener 122 virtual void SAL_CALL 123 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) 124 throw(::com::sun::star::uno::RuntimeException); 125 126 // XLinguServiceEventBroadcaster 127 virtual sal_Bool SAL_CALL 128 addLinguServiceEventListener( 129 const ::com::sun::star::uno::Reference< 130 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) 131 throw(::com::sun::star::uno::RuntimeException); 132 virtual sal_Bool SAL_CALL 133 removeLinguServiceEventListener( 134 const ::com::sun::star::uno::Reference< 135 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) 136 throw(::com::sun::star::uno::RuntimeException); 137 138 // non-UNO functions 139 void AddAsPropListener(); 140 void RemoveAsPropListener(); 141 void LaunchEvent( 142 const ::com::sun::star::linguistic2::LinguServiceEvent& rEvt ); 143 144 const ::com::sun::star::uno::Sequence< ::rtl::OUString > & GetPropNames() const145 GetPropNames() const { return aPropNames; } 146 const ::com::sun::star::uno::Reference< 147 ::com::sun::star::beans::XPropertySet > & GetPropSet() const148 GetPropSet() const { return xPropSet; } 149 const ::com::sun::star::uno::Reference< 150 ::com::sun::star::uno::XInterface > & GetEvtObj() const151 GetEvtObj() const { return xMyEvtObj; } 152 IsIgnoreControlCharacters() const153 sal_Bool IsIgnoreControlCharacters() const { return bResIsIgnoreControlCharacters; } IsUseDictionaryList() const154 sal_Bool IsUseDictionaryList() const { return bResIsUseDictionaryList; } 155 }; 156 157 158 /////////////////////////////////////////////////////////////////////////// 159 class PropertyHelper_Thes : 160 public PropertyChgHelper 161 { 162 // disallow use of copy-constructor and assignment-operator 163 PropertyHelper_Thes( const PropertyHelper_Thes & ); 164 PropertyHelper_Thes & operator = ( const PropertyHelper_Thes & ); 165 166 public: 167 PropertyHelper_Thes( 168 const ::com::sun::star::uno::Reference< 169 ::com::sun::star::uno::XInterface > &rxSource, 170 ::com::sun::star::uno::Reference< 171 ::com::sun::star::beans::XPropertySet > &rxPropSet ); 172 virtual ~PropertyHelper_Thes(); 173 174 // XPropertyChangeListener 175 virtual void SAL_CALL 176 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) 177 throw(::com::sun::star::uno::RuntimeException); 178 }; 179 180 class LNG_DLLPUBLIC PropertyHelper_Thesaurus 181 { 182 PropertyHelper_Thes* pInst; 183 com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper; 184 185 // disallow use of copy-constructor and assignment-operator 186 PropertyHelper_Thesaurus( const PropertyHelper_Thes & ); 187 PropertyHelper_Thesaurus & operator = ( const PropertyHelper_Thes & ); 188 189 public: 190 PropertyHelper_Thesaurus( 191 const ::com::sun::star::uno::Reference< 192 ::com::sun::star::uno::XInterface > &rxSource, 193 ::com::sun::star::uno::Reference< 194 ::com::sun::star::beans::XPropertySet > &rxPropSet ); 195 ~PropertyHelper_Thesaurus(); 196 void AddAsPropListener(); 197 void RemoveAsPropListener(); 198 void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); 199 }; 200 201 202 /////////////////////////////////////////////////////////////////////////// 203 204 class PropertyHelper_Spell : 205 public PropertyChgHelper 206 { 207 // default values 208 sal_Bool bIsSpellUpperCase; 209 sal_Bool bIsSpellWithDigits; 210 211 sal_Bool bIsSpellCapitalization; 212 213 // return values, will be set to default value or current temporary value 214 sal_Int16 nResMaxNumberOfSuggestions; // special value that is not part of the property set and thus needs to be handled differently 215 sal_Bool bResIsSpellUpperCase; 216 sal_Bool bResIsSpellWithDigits; 217 sal_Bool bResIsSpellCapitalization; 218 219 220 // disallow use of copy-constructor and assignment-operator 221 PropertyHelper_Spell( const PropertyHelper_Spell & ); 222 PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ); 223 224 protected: 225 // PropertyChgHelper 226 virtual void SetDefaultValues(); 227 virtual void GetCurrentValues(); 228 virtual sal_Bool propertyChange_Impl( 229 const ::com::sun::star::beans::PropertyChangeEvent& rEvt ); 230 231 public: 232 PropertyHelper_Spell( 233 const ::com::sun::star::uno::Reference< 234 ::com::sun::star::uno::XInterface > &rxSource, 235 ::com::sun::star::uno::Reference< 236 ::com::sun::star::beans::XPropertySet > &rxPropSet ); 237 virtual ~PropertyHelper_Spell(); 238 239 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); 240 241 // XPropertyChangeListener 242 virtual void SAL_CALL 243 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) 244 throw(::com::sun::star::uno::RuntimeException); 245 246 virtual sal_Int16 GetDefaultNumberOfSuggestions() const; 247 GetMaxNumberOfSuggestions() const248 sal_Int16 GetMaxNumberOfSuggestions() const { return nResMaxNumberOfSuggestions; } IsSpellUpperCase() const249 sal_Bool IsSpellUpperCase() const { return bResIsSpellUpperCase; } IsSpellWithDigits() const250 sal_Bool IsSpellWithDigits() const { return bResIsSpellWithDigits; } IsSpellCapitalization() const251 sal_Bool IsSpellCapitalization() const { return bResIsSpellCapitalization; } 252 }; 253 254 255 class LNG_DLLPUBLIC PropertyHelper_Spelling 256 { 257 PropertyHelper_Spell* pInst; 258 com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper; 259 260 // disallow use of copy-constructor and assignment-operator 261 PropertyHelper_Spelling( const PropertyHelper_Spell & ); 262 PropertyHelper_Spelling & operator = ( const PropertyHelper_Spell & ); 263 264 public: 265 PropertyHelper_Spelling( 266 const ::com::sun::star::uno::Reference< 267 ::com::sun::star::uno::XInterface > &rxSource, 268 ::com::sun::star::uno::Reference< 269 ::com::sun::star::beans::XPropertySet > &rxPropSet ); 270 ~PropertyHelper_Spelling(); 271 272 void AddAsPropListener(); 273 void RemoveAsPropListener(); 274 void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); 275 sal_Int16 GetMaxNumberOfSuggestions() const; 276 sal_Bool IsSpellUpperCase() const; 277 sal_Bool IsSpellWithDigits() const; 278 sal_Bool IsSpellCapitalization() const; 279 sal_Bool addLinguServiceEventListener( 280 const ::com::sun::star::uno::Reference< 281 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) 282 throw(::com::sun::star::uno::RuntimeException); 283 sal_Bool removeLinguServiceEventListener( 284 const ::com::sun::star::uno::Reference< 285 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) 286 throw(::com::sun::star::uno::RuntimeException); 287 }; 288 289 /////////////////////////////////////////////////////////////////////////// 290 291 class PropertyHelper_Hyphen : 292 public PropertyChgHelper 293 { 294 // default values 295 sal_Int16 nHyphMinLeading, 296 nHyphMinTrailing, 297 nHyphMinWordLength; 298 299 // return values, will be set to default value or current temporary value 300 sal_Int16 nResHyphMinLeading, 301 nResHyphMinTrailing, 302 nResHyphMinWordLength; 303 304 // disallow use of copy-constructor and assignment-operator 305 PropertyHelper_Hyphen( const PropertyHelper_Hyphen & ); 306 PropertyHelper_Hyphen & operator = ( const PropertyHelper_Hyphen & ); 307 308 protected: 309 // PropertyChgHelper 310 virtual void SetDefaultValues(); 311 virtual void GetCurrentValues(); 312 virtual sal_Bool propertyChange_Impl( 313 const ::com::sun::star::beans::PropertyChangeEvent& rEvt ); 314 315 public: 316 PropertyHelper_Hyphen( 317 const ::com::sun::star::uno::Reference< 318 ::com::sun::star::uno::XInterface > &rxSource, 319 ::com::sun::star::uno::Reference< 320 ::com::sun::star::beans::XPropertySet > &rxPropSet); 321 virtual ~PropertyHelper_Hyphen(); 322 323 virtual void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); 324 325 // XPropertyChangeListener 326 virtual void SAL_CALL 327 propertyChange( const ::com::sun::star::beans::PropertyChangeEvent& rEvt ) 328 throw(::com::sun::star::uno::RuntimeException); 329 GetMinLeading() const330 sal_Int16 GetMinLeading() const { return nResHyphMinLeading; } GetMinTrailing() const331 sal_Int16 GetMinTrailing() const { return nResHyphMinTrailing; } GetMinWordLength() const332 sal_Int16 GetMinWordLength() const { return nResHyphMinWordLength; } 333 }; 334 335 class LNG_DLLPUBLIC PropertyHelper_Hyphenation 336 { 337 PropertyHelper_Hyphen* pInst; 338 com::sun::star::uno::Reference< com::sun::star::beans::XPropertyChangeListener > xPropHelper; 339 340 // disallow use of copy-constructor and assignment-operator 341 PropertyHelper_Hyphenation( const PropertyHelper_Hyphen & ); 342 PropertyHelper_Hyphenation & operator = ( const PropertyHelper_Hyphen & ); 343 344 public: 345 PropertyHelper_Hyphenation( 346 const ::com::sun::star::uno::Reference< 347 ::com::sun::star::uno::XInterface > &rxSource, 348 ::com::sun::star::uno::Reference< 349 ::com::sun::star::beans::XPropertySet > &rxPropSet); 350 ~PropertyHelper_Hyphenation(); 351 352 void AddAsPropListener(); 353 void RemoveAsPropListener(); 354 void SetTmpPropVals( const com::sun::star::beans::PropertyValues &rPropVals ); 355 sal_Int16 GetMinLeading() const; 356 sal_Int16 GetMinTrailing() const; 357 sal_Int16 GetMinWordLength() const; 358 sal_Bool addLinguServiceEventListener( 359 const ::com::sun::star::uno::Reference< 360 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) 361 throw(::com::sun::star::uno::RuntimeException); 362 sal_Bool removeLinguServiceEventListener( 363 const ::com::sun::star::uno::Reference< 364 ::com::sun::star::linguistic2::XLinguServiceEventListener >& rxListener ) 365 throw(::com::sun::star::uno::RuntimeException); 366 }; 367 368 /////////////////////////////////////////////////////////////////////////// 369 370 } // namespace linguistic 371 372 #endif 373 374