1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _LINGU2_PROPHELP_HXX_ 29 #define _LINGU2_PROPHELP_HXX_ 30 31 #include <tools/solar.h> 32 33 #include <uno/lbnames.h> // CPPU_CURRENT_LANGUAGE_BINDING_NAME macro, which specify the environment type 34 #include <cppuhelper/implbase2.hxx> // helper for implementations 35 #include <cppuhelper/interfacecontainer.h> 36 #include <com/sun/star/beans/XPropertyChangeListener.hpp> 37 #include <com/sun/star/beans/PropertyValues.hpp> 38 39 #include <com/sun/star/linguistic2/XLinguServiceEventBroadcaster.hpp> 40 41 namespace com { namespace sun { namespace star { namespace beans { 42 class XPropertySet; 43 }}}}; 44 45 namespace com { namespace sun { namespace star { namespace linguistic2 { 46 struct LinguServiceEvent; 47 }}}}; 48 49 50 using namespace ::rtl; 51 using namespace ::com::sun::star::uno; 52 using namespace ::com::sun::star::beans; 53 using namespace ::com::sun::star::lang; 54 using namespace ::com::sun::star::linguistic2; 55 56 /////////////////////////////////////////////////////////////////////////// 57 // PropertyChgHelper 58 // virtual base class for all XPropertyChangeListener members of the 59 // various lingu services. 60 // Only propertyChange needs to be implemented. 61 62 class PropertyChgHelper : 63 public cppu::WeakImplHelper2 64 < 65 XPropertyChangeListener, 66 XLinguServiceEventBroadcaster 67 > 68 { 69 Sequence< OUString > aPropNames; 70 Reference< XInterface > xMyEvtObj; 71 ::cppu::OInterfaceContainerHelper aLngSvcEvtListeners; 72 Reference< XPropertySet > xPropSet; 73 74 // disallow use of copy-constructor and assignment-operator 75 PropertyChgHelper( const PropertyChgHelper & ); 76 PropertyChgHelper & operator = ( const PropertyChgHelper & ); 77 78 public: 79 PropertyChgHelper( 80 const Reference< XInterface > &rxSource, 81 Reference< XPropertySet > &rxPropSet, 82 const char *pPropNames[], USHORT nPropCount ); 83 virtual ~PropertyChgHelper(); 84 85 // XEventListener 86 virtual void SAL_CALL 87 disposing( const EventObject& rSource ) 88 throw(RuntimeException); 89 90 // XPropertyChangeListener 91 virtual void SAL_CALL 92 propertyChange( const PropertyChangeEvent& rEvt ) 93 throw(RuntimeException) = 0; 94 95 // XLinguServiceEventBroadcaster 96 virtual sal_Bool SAL_CALL 97 addLinguServiceEventListener( 98 const Reference< XLinguServiceEventListener >& rxListener ) 99 throw(RuntimeException); 100 virtual sal_Bool SAL_CALL 101 removeLinguServiceEventListener( 102 const Reference< XLinguServiceEventListener >& rxListener ) 103 throw(RuntimeException); 104 105 // non UNO functions 106 void AddAsPropListener(); 107 void RemoveAsPropListener(); 108 void LaunchEvent( const LinguServiceEvent& rEvt ); 109 110 const Sequence< OUString > & 111 GetPropNames() const { return aPropNames; } 112 const Reference< XPropertySet > & 113 GetPropSet() const { return xPropSet; } 114 const Reference< XInterface > & 115 GetEvtObj() const { return xMyEvtObj; } 116 }; 117 118 119 /////////////////////////////////////////////////////////////////////////// 120 121 122 class PropertyHelper_Spell : 123 public PropertyChgHelper 124 { 125 // default values 126 BOOL bIsGermanPreReform; 127 BOOL bIsIgnoreControlCharacters; 128 BOOL bIsUseDictionaryList; 129 BOOL bIsSpellUpperCase; 130 BOOL bIsSpellWithDigits; 131 BOOL bIsSpellCapitalization; 132 133 // return values, will be set to default value or current temporary value 134 BOOL bResIsGermanPreReform; 135 BOOL bResIsIgnoreControlCharacters; 136 BOOL bResIsUseDictionaryList; 137 BOOL bResIsSpellUpperCase; 138 BOOL bResIsSpellWithDigits; 139 BOOL bResIsSpellCapitalization; 140 141 142 // disallow use of copy-constructor and assignment-operator 143 PropertyHelper_Spell( const PropertyHelper_Spell & ); 144 PropertyHelper_Spell & operator = ( const PropertyHelper_Spell & ); 145 146 void SetDefault(); 147 148 public: 149 PropertyHelper_Spell( 150 const Reference< XInterface > &rxSource, 151 Reference< XPropertySet > &rxPropSet ); 152 virtual ~PropertyHelper_Spell(); 153 154 // XPropertyChangeListener 155 virtual void SAL_CALL 156 propertyChange( const PropertyChangeEvent& rEvt ) 157 throw(RuntimeException); 158 159 void SetTmpPropVals( const PropertyValues &rPropVals ); 160 161 BOOL IsGermanPreReform() const { return bResIsGermanPreReform; } 162 BOOL IsIgnoreControlCharacters() const { return bResIsIgnoreControlCharacters; } 163 BOOL IsUseDictionaryList() const { return bResIsUseDictionaryList; } 164 BOOL IsSpellUpperCase() const { return bResIsSpellUpperCase; } 165 BOOL IsSpellWithDigits() const { return bResIsSpellWithDigits; } 166 BOOL IsSpellCapitalization() const { return bResIsSpellCapitalization; } 167 }; 168 169 /////////////////////////////////////////////////////////////////////////// 170 171 #endif 172 173