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 #ifndef CHART_OPROPERTYSET_HXX 24 #define CHART_OPROPERTYSET_HXX 25 26 // helper classes 27 #include <cppuhelper/propshlp.hxx> 28 #include <cppuhelper/interfacecontainer.hxx> 29 #include <cppuhelper/weak.hxx> 30 31 // interfaces and types 32 // #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_ 33 // #include <com/sun/star/lang/XServiceInfo.hpp> 34 // #endif 35 #include <com/sun/star/lang/XTypeProvider.hpp> 36 #include <com/sun/star/beans/XPropertyState.hpp> 37 #include <com/sun/star/beans/XMultiPropertyStates.hpp> 38 #include <com/sun/star/beans/Property.hpp> 39 #include <com/sun/star/style/XStyleSupplier.hpp> 40 // #ifndef _COM_SUN_STAR_BEANS_XFASTPROPERTYSTATE_HPP_ 41 // #include <com/sun/star/beans/XFastPropertyState.hpp> 42 // #endif 43 #include <osl/mutex.hxx> 44 #include "charttoolsdllapi.hxx" 45 46 #include <memory> 47 48 namespace property 49 { 50 51 namespace impl 52 { class ImplOPropertySet; } 53 54 55 class OOO_DLLPUBLIC_CHARTTOOLS OPropertySet : 56 public ::cppu::OBroadcastHelper, 57 // includes beans::XPropertySet, XMultiPropertySet and XFastPropertySet 58 public ::cppu::OPropertySetHelper, 59 // includes uno::XWeak (and XInterface, esp. ref-counting) 60 // public virtual ::cppu::OWeakObject, 61 62 // public virtual ::com::sun::star::lang::XServiceInfo, 63 public ::com::sun::star::lang::XTypeProvider, 64 public ::com::sun::star::beans::XPropertyState, 65 public ::com::sun::star::beans::XMultiPropertyStates, 66 public ::com::sun::star::style::XStyleSupplier 67 // public ::com::sun::star::beans::XFastPropertyState 68 { 69 public: 70 OPropertySet( ::osl::Mutex & rMutex ); 71 virtual ~OPropertySet(); 72 73 protected: 74 explicit OPropertySet( const OPropertySet & rOther, ::osl::Mutex & rMutex ); 75 76 void SetNewValuesExplicitlyEvenIfTheyEqualDefault(); 77 78 /** implement this method to provide default values for all properties 79 supporting defaults. If a property does not have a default value, you 80 may throw an UnknownPropertyException. 81 */ 82 virtual ::com::sun::star::uno::Any GetDefaultValue( sal_Int32 nHandle ) const = 0; 83 84 /** The InfoHelper table contains all property names and types of 85 this object. 86 87 @return the object that provides information for the 88 PropertySetInfo 89 90 @see ::cppu::OPropertySetHelper 91 */ 92 virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0; 93 94 95 /** Try to convert the value <code>rValue</code> to the type required by the 96 property associated with <code>nHandle</code>. 97 98 Overload this method to take influence in modification of properties. 99 100 If the conversion changed , </sal_True> is returned and the converted value 101 is in <code>rConvertedValue</code>. The former value is contained in 102 <code>rOldValue</code>. 103 104 After this call returns successfully, the vetoable listeners are 105 notified. 106 107 @throws IllegalArgumentException, if the conversion was not successful, 108 or if there is no corresponding property to the given handle. 109 110 @param rConvertedValue the converted value. Only set if return is true. 111 @param rOldValue the old value. Only set if return is true. 112 @param nHandle the handle of the property. 113 114 @return true, if the conversion was successful and converted value 115 differs from the old value. 116 117 @see ::cppu::OPropertySetHelper 118 */ 119 virtual sal_Bool SAL_CALL convertFastPropertyValue 120 ( ::com::sun::star::uno::Any & rConvertedValue, 121 ::com::sun::star::uno::Any & rOldValue, 122 sal_Int32 nHandle, 123 const ::com::sun::star::uno::Any& rValue ); 124 125 /** The same as setFastPropertyValue; nHandle is always valid. 126 The changes must not be broadcasted in this method. 127 128 @attention 129 Although you are permitted to throw any UNO exception, only the following 130 are valid for usage: 131 -- ::com::sun::star::beans::UnknownPropertyException 132 -- ::com::sun::star::beans::PropertyVetoException 133 -- ::com::sun::star::lang::IllegalArgumentException 134 -- ::com::sun::star::lang::WrappedTargetException 135 -- ::com::sun::star::uno::RuntimeException 136 137 @param nHandle handle 138 @param rValue value 139 140 @see ::cppu::OPropertySetHelper 141 */ 142 virtual void SAL_CALL setFastPropertyValue_NoBroadcast 143 ( sal_Int32 nHandle, 144 const ::com::sun::star::uno::Any& rValue ); 145 146 /** 147 The same as getFastPropertyValue, but return the value through rValue and 148 nHandle is always valid. 149 150 @see ::cppu::OPropertySetHelper 151 */ 152 virtual void SAL_CALL getFastPropertyValue 153 ( ::com::sun::star::uno::Any& rValue, 154 sal_Int32 nHandle ) const; 155 156 /// make original interface function visible again 157 using ::com::sun::star::beans::XFastPropertySet::getFastPropertyValue; 158 159 /** implement this method in derived classes to get called when properties 160 change. 161 */ 162 virtual void firePropertyChangeEvent(); 163 164 /// call this when a derived component is disposed 165 virtual void disposePropertySet(); 166 167 // ======================================== 168 // Interfaces 169 // ======================================== 170 171 // ____ XInterface ____ 172 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ); 173 // virtual void SAL_CALL acquire() throw (); 174 // virtual void SAL_CALL release() throw (); 175 176 177 // ____ XServiceInfo ____ 178 // virtual ::rtl::OUString SAL_CALL 179 // getImplementationName() 180 // throw (::com::sun::star::uno::RuntimeException); 181 // virtual sal_Bool SAL_CALL 182 // supportsService( const ::rtl::OUString& ServiceName ) 183 // throw (::com::sun::star::uno::RuntimeException); 184 // virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL 185 // getSupportedServiceNames() 186 // throw (::com::sun::star::uno::RuntimeException); 187 188 // ____ XTypeProvider ____ 189 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL 190 getTypes(); 191 virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL 192 getImplementationId(); 193 194 // ____ XPropertyState ____ 195 virtual ::com::sun::star::beans::PropertyState SAL_CALL 196 getPropertyState( const ::rtl::OUString& PropertyName ); 197 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL 198 getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ); 199 virtual void SAL_CALL 200 setPropertyToDefault( const ::rtl::OUString& PropertyName ); 201 virtual ::com::sun::star::uno::Any SAL_CALL 202 getPropertyDefault( const ::rtl::OUString& aPropertyName ); 203 204 // ____ XMultiPropertyStates ____ 205 // Note: getPropertyStates() is already implemented in XPropertyState with the 206 // same signature 207 virtual void SAL_CALL 208 setAllPropertiesToDefault(); 209 virtual void SAL_CALL 210 setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ); 211 virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL 212 getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ); 213 214 // ____ XStyleSupplier ____ 215 virtual ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle > SAL_CALL getStyle(); 216 virtual void SAL_CALL setStyle( const ::com::sun::star::uno::Reference< ::com::sun::star::style::XStyle >& xStyle ); 217 218 // ____ XFastPropertyState ____ 219 // virtual ::com::sun::star::beans::PropertyState SAL_CALL getFastPropertyState( sal_Int32 nHandle ) 220 // throw (::com::sun::star::beans::UnknownPropertyException, 221 // ::com::sun::star::uno::RuntimeException); 222 // virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getFastPropertyStates( const ::com::sun::star::uno::Sequence< sal_Int32 >& aHandles ) 223 // throw (::com::sun::star::beans::UnknownPropertyException, 224 // ::com::sun::star::uno::RuntimeException); 225 // virtual void SAL_CALL setFastPropertyToDefault( sal_Int32 nHandle ) 226 // throw (::com::sun::star::beans::UnknownPropertyException, 227 // ::com::sun::star::uno::RuntimeException); 228 // virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyDefault( sal_Int32 nHandle ) 229 // throw (::com::sun::star::beans::UnknownPropertyException, 230 // ::com::sun::star::lang::WrappedTargetException, 231 // ::com::sun::star::uno::RuntimeException); 232 233 // ____ XMultiPropertySet ____ 234 virtual void SAL_CALL setPropertyValues( 235 const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, 236 const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ); 237 238 // ____ XFastPropertySet ____ 239 virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ); 240 241 // Note: it is assumed that the base class implements setPropertyValue by 242 // using setFastPropertyValue 243 244 private: 245 /// reference to mutex of class deriving from here 246 ::osl::Mutex & m_rMutex; 247 248 /// pImpl idiom implementation 249 ::std::auto_ptr< impl::ImplOPropertySet > m_pImplProperties; 250 bool m_bSetNewValuesExplicitlyEvenIfTheyEqualDefault; 251 }; 252 253 } // namespace property 254 255 // CHART_OPROPERTYSET_HXX 256 #endif 257