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 _LINGU2_PROPHELP_HXX_ 25 #define _LINGU2_PROPHELP_HXX_ 26 27 #include <tools/solar.h> 28 29 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 30 #include <cppuhelper/implbase2.hxx> // helper for implementations 31 #include <cppuhelper/interfacecontainer.h> 32 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 33 #include <com/sun/star/beans/PropertyValues.hpp> 34 35 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> 36 37 namespace com { namespace sun { namespace star { namespace beans { 38 class XPropertySet; 39 }}}}; 40 41 namespace com { namespace sun { namespace star { namespace linguistic2 { 42 struct LinguServiceEvent; 43 }}}}; 44 45 46 using namespace ::rtl; 47 using namespace ::com::sun::star::uno; 48 using namespace ::com::sun::star::beans; 49 using namespace ::com::sun::star::lang; 50 using namespace ::com::sun::star::linguistic2; 51 52 /////////////////////////////////////////////////////////////////////////// 53 // PropertyChgHelper 54 // virtual base class for all XPropertyChangeListener members of the 55 // various lingu services. 56 // Only propertyChange needs to be implemented. 57 58 class PropertyChgHelper : 59 public cppu::WeakImplHelper2 60 < 61 XPropertyChangeListener, 62 XLinguServiceEventBroadcaster 63 > 64 { 65 Sequence< OUString > aPropNames; 66 Reference< XInterface > xMyEvtObj; 67 ::cppu::OInterfaceContainerHelper aLngSvcEvtListeners; 68 Reference< XPropertySet > xPropSet; 69 70 // disallow use of copy-constructor and assignment-operator 71 PropertyChgHelper( const PropertyChgHelper & ); 72 PropertyChgHelper & operator = ( const PropertyChgHelper & ); 73 74 public: 75 PropertyChgHelper( 76 const Reference< XInterface > &rxSource, 77 Reference< XPropertySet > &rxPropSet, 78 const char *pPropNames[], USHORT nPropCount ); 79 virtual ~PropertyChgHelper(); 80 81 // XEventListener 82 virtual void SAL_CALL 83 disposing( const EventObject& rSource ) 84 throw(RuntimeException); 85 86 // XPropertyChangeListener 87 virtual void SAL_CALL 88 propertyChange( const PropertyChangeEvent& rEvt ) 89 throw(RuntimeException) = 0; 90 91 // XLinguServiceEventBroadcaster 92 virtual sal_Bool SAL_CALL 93 addLinguServiceEventListener( 94 const Reference< XLinguServiceEventListener >& rxListener ) 95 throw(RuntimeException); 96 virtual sal_Bool SAL_CALL 97 removeLinguServiceEventListener( 98 const Reference< XLinguServiceEventListener >& rxListener ) 99 throw(RuntimeException); 100 101 // non UNO functions 102 void AddAsPropListener(); 103 void RemoveAsPropListener(); 104 void LaunchEvent( const LinguServiceEvent& rEvt ); 105 106 const Sequence< OUString > & GetPropNames() const107 GetPropNames() const { return aPropNames; } 108 const Reference< XPropertySet > & GetPropSet() const109 GetPropSet() const { return xPropSet; } 110 const Reference< XInterface > & GetEvtObj() const111 GetEvtObj() const { return xMyEvtObj; } 112 }; 113 114 115 /////////////////////////////////////////////////////////////////////////// 116 117 118 class PropertyHelper_Spell : 119 public PropertyChgHelper 120 { 121 // default values 122 BOOL bIsGermanPreReform; 123 BOOL bIsIgnoreControlCharacters; 124 BOOL bIsUseDictionaryList; 125 BOOL bIsSpellUpperCase; 126 BOOL bIsSpellWithDigits; 127 BOOL bIsSpellCapitalization; 128 129 // return values, will be set to default value or current temporary value 130 BOOL bResIsGermanPreReform; 131 BOOL bResIsIgnoreControlCharacters; 132 BOOL bResIsUseDictionaryList; 133 BOOL bResIsSpellUpperCase; 134 BOOL bResIsSpellWithDigits; 135 BOOL bResIsSpellCapitalization; 136 137 138 // disallow use of copy-constructor and assignment-operator 139 PropertyHelper_Spell( const PropertyHelper_Spell & ); 140 PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ); 141 142 void SetDefault(); 143 144 public: 145 PropertyHelper_Spell( 146 const Reference< XInterface > &rxSource, 147 Reference< XPropertySet > &rxPropSet ); 148 virtual ~PropertyHelper_Spell(); 149 150 // XPropertyChangeListener 151 virtual void SAL_CALL 152 propertyChange( const PropertyChangeEvent& rEvt ) 153 throw(RuntimeException); 154 155 void SetTmpPropVals( const PropertyValues &rPropVals ); 156 IsGermanPreReform() const157 BOOL IsGermanPreReform() const { return bResIsGermanPreReform; } IsIgnoreControlCharacters() const158 BOOL IsIgnoreControlCharacters() const { return bResIsIgnoreControlCharacters; } IsUseDictionaryList() const159 BOOL IsUseDictionaryList() const { return bResIsUseDictionaryList; } IsSpellUpperCase() const160 BOOL IsSpellUpperCase() const { return bResIsSpellUpperCase; } IsSpellWithDigits() const161 BOOL IsSpellWithDigits() const { return bResIsSpellWithDigits; } IsSpellCapitalization() const162 BOOL IsSpellCapitalization() const { return bResIsSpellCapitalization; } 163 }; 164 165 /////////////////////////////////////////////////////////////////////////// 166 167 #endif 168 169