update dev300-m58
[ooovba.git] / sd / source / ui / inc / tools / PropertySet.hxx
blobe35e0b1d18d559c4987eadaab3e83d6d07dcd8e4
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: PropertySet.hxx,v $
11 * $Revision: 1.3 $
13 * This file is part of OpenOffice.org.
15 * OpenOffice.org is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License version 3
17 * only, as published by the Free Software Foundation.
19 * OpenOffice.org is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License version 3 for more details
23 * (a copy is included in the LICENSE file that accompanied this code).
25 * You should have received a copy of the GNU Lesser General Public License
26 * version 3 along with OpenOffice.org. If not, see
27 * <http://www.openoffice.org/license.html>
28 * for a copy of the LGPLv3 License.
30 ************************************************************************/
32 #ifndef SD_TOOLS_PROPERTY_SET_HXX
33 #define SD_TOOLS_PROPERTY_SET_HXX
35 #include <cppuhelper/basemutex.hxx>
36 #include <cppuhelper/compbase1.hxx>
37 #include <com/sun/star/beans/XPropertySet.hpp>
38 #include <boost/scoped_ptr.hpp>
39 #include <map>
41 namespace css = ::com::sun::star;
43 namespace sd { namespace tools {
45 namespace {
46 typedef ::cppu::WeakComponentImplHelper1 <
47 css::beans::XPropertySet
48 > PropertySetInterfaceBase;
52 /** A very simple implementation of the XPropertySet interface. It does not
53 support constrained properties and thus does not support vetoable
54 listeners. It does not support the optional property set info.
56 In order to use it you have to derive from this class and implement the
57 GetPropertyValue() and SetPropertyValue() methods.
59 class PropertySet
60 : protected ::cppu::BaseMutex,
61 public PropertySetInterfaceBase
63 public:
64 explicit PropertySet (void);
65 virtual ~PropertySet (void);
67 virtual void SAL_CALL disposing (void);
70 /** Create an UnknownPropertyException, but do not yet throw it. This
71 method fills in the fields of the exception.
73 css::beans::UnknownPropertyException CreateUnknownPropertyException (
74 const rtl::OUString& rsPropertyName);
76 // XPropertySet
78 virtual css::uno::Reference<css::beans::XPropertySetInfo>
79 SAL_CALL getPropertySetInfo (void)
80 throw(css::uno::RuntimeException);
82 virtual void SAL_CALL setPropertyValue (
83 const rtl::OUString& rsPropertyName,
84 const css::uno::Any& rsPropertyValue)
85 throw(css::beans::UnknownPropertyException,
86 css::beans::PropertyVetoException,
87 css::lang::IllegalArgumentException,
88 css::lang::WrappedTargetException,
89 css::uno::RuntimeException);
91 virtual css::uno::Any SAL_CALL getPropertyValue (const rtl::OUString& rsPropertyName)
92 throw(css::beans::UnknownPropertyException,
93 css::lang::WrappedTargetException,
94 css::uno::RuntimeException);
96 virtual void SAL_CALL addPropertyChangeListener (
97 const rtl::OUString& rsPropertyName,
98 const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
99 throw(css::beans::UnknownPropertyException,
100 css::lang::WrappedTargetException,
101 css::uno::RuntimeException);
103 virtual void SAL_CALL removePropertyChangeListener (
104 const rtl::OUString& rsPropertyName,
105 const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
106 throw(css::beans::UnknownPropertyException,
107 css::lang::WrappedTargetException,
108 css::uno::RuntimeException);
110 virtual void SAL_CALL addVetoableChangeListener (
111 const rtl::OUString& rsPropertyName,
112 const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
113 throw(css::beans::UnknownPropertyException,
114 css::lang::WrappedTargetException,
115 css::uno::RuntimeException);
117 virtual void SAL_CALL removeVetoableChangeListener (
118 const rtl::OUString& rsPropertyName,
119 const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
120 throw(css::beans::UnknownPropertyException,
121 css::lang::WrappedTargetException,
122 css::uno::RuntimeException);
124 protected:
125 /** Return the requested property value.
126 @throw com::sun::star::beans::UnknownPropertyException when the
127 property is not supported.
129 virtual css::uno::Any GetPropertyValue (const ::rtl::OUString& rsPropertyName) = 0;
130 /** Set the given property value.
131 @return the old value.
132 @throw com::sun::star::beans::UnknownPropertyException when the
133 property is not supported.
135 virtual css::uno::Any SetPropertyValue (
136 const ::rtl::OUString& rsPropertyName,
137 const css::uno::Any& rValue) = 0;
139 private:
140 typedef ::std::multimap<rtl::OUString,
141 css::uno::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer;
142 ::boost::scoped_ptr<ChangeListenerContainer> mpChangeListeners;
144 /** Call all listeners that are registered for the given property name.
145 Call this method with an empty property name to call listeners that
146 are registered for all properties.
148 void CallListeners (
149 const rtl::OUString& rsPropertyName,
150 const css::beans::PropertyChangeEvent& rEvent);
152 /** This method throws a DisposedException when the object has already been
153 disposed.
155 void ThrowIfDisposed (void)
156 throw (css::lang::DisposedException);
159 } } // end of namespace ::sd::tools
161 #endif