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