1*c45d927aSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*c45d927aSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*c45d927aSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*c45d927aSAndrew Rist * distributed with this work for additional information 6*c45d927aSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*c45d927aSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*c45d927aSAndrew Rist * "License"); you may not use this file except in compliance 9*c45d927aSAndrew Rist * with the License. You may obtain a copy of the License at 10*c45d927aSAndrew Rist * 11*c45d927aSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*c45d927aSAndrew Rist * 13*c45d927aSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*c45d927aSAndrew Rist * software distributed under the License is distributed on an 15*c45d927aSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*c45d927aSAndrew Rist * KIND, either express or implied. See the License for the 17*c45d927aSAndrew Rist * specific language governing permissions and limitations 18*c45d927aSAndrew Rist * under the License. 19*c45d927aSAndrew Rist * 20*c45d927aSAndrew Rist *************************************************************/ 21*c45d927aSAndrew Rist 22*c45d927aSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef SD_TOOLS_PROPERTY_SET_HXX 25cdf0e10cSrcweir #define SD_TOOLS_PROPERTY_SET_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <cppuhelper/basemutex.hxx> 28cdf0e10cSrcweir #include <cppuhelper/compbase1.hxx> 29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 30cdf0e10cSrcweir #include <boost/scoped_ptr.hpp> 31cdf0e10cSrcweir #include <map> 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace css = ::com::sun::star; 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace sd { namespace tools { 36cdf0e10cSrcweir 37cdf0e10cSrcweir namespace { 38cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper1 < 39cdf0e10cSrcweir css::beans::XPropertySet 40cdf0e10cSrcweir > PropertySetInterfaceBase; 41cdf0e10cSrcweir } 42cdf0e10cSrcweir 43cdf0e10cSrcweir 44cdf0e10cSrcweir /** A very simple implementation of the XPropertySet interface. It does not 45cdf0e10cSrcweir support constrained properties and thus does not support vetoable 46cdf0e10cSrcweir listeners. It does not support the optional property set info. 47cdf0e10cSrcweir 48cdf0e10cSrcweir In order to use it you have to derive from this class and implement the 49cdf0e10cSrcweir GetPropertyValue() and SetPropertyValue() methods. 50cdf0e10cSrcweir */ 51cdf0e10cSrcweir class PropertySet 52cdf0e10cSrcweir : protected ::cppu::BaseMutex, 53cdf0e10cSrcweir public PropertySetInterfaceBase 54cdf0e10cSrcweir { 55cdf0e10cSrcweir public: 56cdf0e10cSrcweir explicit PropertySet (void); 57cdf0e10cSrcweir virtual ~PropertySet (void); 58cdf0e10cSrcweir 59cdf0e10cSrcweir virtual void SAL_CALL disposing (void); 60cdf0e10cSrcweir 61cdf0e10cSrcweir // XPropertySet 62cdf0e10cSrcweir 63cdf0e10cSrcweir virtual css::uno::Reference<css::beans::XPropertySetInfo> 64cdf0e10cSrcweir SAL_CALL getPropertySetInfo (void) 65cdf0e10cSrcweir throw(css::uno::RuntimeException); 66cdf0e10cSrcweir 67cdf0e10cSrcweir virtual void SAL_CALL setPropertyValue ( 68cdf0e10cSrcweir const rtl::OUString& rsPropertyName, 69cdf0e10cSrcweir const css::uno::Any& rsPropertyValue) 70cdf0e10cSrcweir throw(css::beans::UnknownPropertyException, 71cdf0e10cSrcweir css::beans::PropertyVetoException, 72cdf0e10cSrcweir css::lang::IllegalArgumentException, 73cdf0e10cSrcweir css::lang::WrappedTargetException, 74cdf0e10cSrcweir css::uno::RuntimeException); 75cdf0e10cSrcweir 76cdf0e10cSrcweir virtual css::uno::Any SAL_CALL getPropertyValue (const rtl::OUString& rsPropertyName) 77cdf0e10cSrcweir throw(css::beans::UnknownPropertyException, 78cdf0e10cSrcweir css::lang::WrappedTargetException, 79cdf0e10cSrcweir css::uno::RuntimeException); 80cdf0e10cSrcweir 81cdf0e10cSrcweir virtual void SAL_CALL addPropertyChangeListener ( 82cdf0e10cSrcweir const rtl::OUString& rsPropertyName, 83cdf0e10cSrcweir const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) 84cdf0e10cSrcweir throw(css::beans::UnknownPropertyException, 85cdf0e10cSrcweir css::lang::WrappedTargetException, 86cdf0e10cSrcweir css::uno::RuntimeException); 87cdf0e10cSrcweir 88cdf0e10cSrcweir virtual void SAL_CALL removePropertyChangeListener ( 89cdf0e10cSrcweir const rtl::OUString& rsPropertyName, 90cdf0e10cSrcweir const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener) 91cdf0e10cSrcweir throw(css::beans::UnknownPropertyException, 92cdf0e10cSrcweir css::lang::WrappedTargetException, 93cdf0e10cSrcweir css::uno::RuntimeException); 94cdf0e10cSrcweir 95cdf0e10cSrcweir virtual void SAL_CALL addVetoableChangeListener ( 96cdf0e10cSrcweir const rtl::OUString& rsPropertyName, 97cdf0e10cSrcweir const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) 98cdf0e10cSrcweir throw(css::beans::UnknownPropertyException, 99cdf0e10cSrcweir css::lang::WrappedTargetException, 100cdf0e10cSrcweir css::uno::RuntimeException); 101cdf0e10cSrcweir 102cdf0e10cSrcweir virtual void SAL_CALL removeVetoableChangeListener ( 103cdf0e10cSrcweir const rtl::OUString& rsPropertyName, 104cdf0e10cSrcweir const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener) 105cdf0e10cSrcweir throw(css::beans::UnknownPropertyException, 106cdf0e10cSrcweir css::lang::WrappedTargetException, 107cdf0e10cSrcweir css::uno::RuntimeException); 108cdf0e10cSrcweir 109cdf0e10cSrcweir protected: 110cdf0e10cSrcweir /** Return the requested property value. 111cdf0e10cSrcweir @throw com::sun::star::beans::UnknownPropertyException when the 112cdf0e10cSrcweir property is not supported. 113cdf0e10cSrcweir */ 114cdf0e10cSrcweir virtual css::uno::Any GetPropertyValue (const ::rtl::OUString& rsPropertyName) = 0; 115cdf0e10cSrcweir /** Set the given property value. 116cdf0e10cSrcweir @return the old value. 117cdf0e10cSrcweir @throw com::sun::star::beans::UnknownPropertyException when the 118cdf0e10cSrcweir property is not supported. 119cdf0e10cSrcweir */ 120cdf0e10cSrcweir virtual css::uno::Any SetPropertyValue ( 121cdf0e10cSrcweir const ::rtl::OUString& rsPropertyName, 122cdf0e10cSrcweir const css::uno::Any& rValue) = 0; 123cdf0e10cSrcweir 124cdf0e10cSrcweir private: 125cdf0e10cSrcweir typedef ::std::multimap<rtl::OUString, 126cdf0e10cSrcweir css::uno::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer; 127cdf0e10cSrcweir ::boost::scoped_ptr<ChangeListenerContainer> mpChangeListeners; 128cdf0e10cSrcweir 129cdf0e10cSrcweir /** Call all listeners that are registered for the given property name. 130cdf0e10cSrcweir Call this method with an empty property name to call listeners that 131cdf0e10cSrcweir are registered for all properties. 132cdf0e10cSrcweir */ 133cdf0e10cSrcweir void CallListeners ( 134cdf0e10cSrcweir const rtl::OUString& rsPropertyName, 135cdf0e10cSrcweir const css::beans::PropertyChangeEvent& rEvent); 136cdf0e10cSrcweir 137cdf0e10cSrcweir /** This method throws a DisposedException when the object has already been 138cdf0e10cSrcweir disposed. 139cdf0e10cSrcweir */ 140cdf0e10cSrcweir void ThrowIfDisposed (void) 141cdf0e10cSrcweir throw (css::lang::DisposedException); 142cdf0e10cSrcweir }; 143cdf0e10cSrcweir 144cdf0e10cSrcweir } } // end of namespace ::sd::tools 145cdf0e10cSrcweir 146cdf0e10cSrcweir #endif 147