bump product version to 4.1.6.2
[LibreOffice.git] / sd / source / ui / inc / tools / PropertySet.hxx
blob7955a60c162765d99b421fa0035ed4868be12f29
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef SD_TOOLS_PROPERTY_SET_HXX
21 #define SD_TOOLS_PROPERTY_SET_HXX
23 #include <cppuhelper/basemutex.hxx>
24 #include <cppuhelper/compbase1.hxx>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <boost/scoped_ptr.hpp>
27 #include <map>
29 namespace sd { namespace tools {
31 namespace {
32 typedef ::cppu::WeakComponentImplHelper1 <
33 css::beans::XPropertySet
34 > PropertySetInterfaceBase;
38 /** A very simple implementation of the XPropertySet interface. It does not
39 support constrained properties and thus does not support vetoable
40 listeners. It does not support the optional property set info.
42 In order to use it you have to derive from this class and implement the
43 GetPropertyValue() and SetPropertyValue() methods.
45 class PropertySet
46 : protected ::cppu::BaseMutex,
47 public PropertySetInterfaceBase
49 public:
50 explicit PropertySet (void);
51 virtual ~PropertySet (void);
53 virtual void SAL_CALL disposing (void);
55 // XPropertySet
57 virtual css::uno::Reference<css::beans::XPropertySetInfo>
58 SAL_CALL getPropertySetInfo (void)
59 throw(css::uno::RuntimeException);
61 virtual void SAL_CALL setPropertyValue (
62 const OUString& rsPropertyName,
63 const css::uno::Any& rsPropertyValue)
64 throw(css::beans::UnknownPropertyException,
65 css::beans::PropertyVetoException,
66 css::lang::IllegalArgumentException,
67 css::lang::WrappedTargetException,
68 css::uno::RuntimeException);
70 virtual css::uno::Any SAL_CALL getPropertyValue (const OUString& rsPropertyName)
71 throw(css::beans::UnknownPropertyException,
72 css::lang::WrappedTargetException,
73 css::uno::RuntimeException);
75 virtual void SAL_CALL addPropertyChangeListener (
76 const OUString& rsPropertyName,
77 const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
78 throw(css::beans::UnknownPropertyException,
79 css::lang::WrappedTargetException,
80 css::uno::RuntimeException);
82 virtual void SAL_CALL removePropertyChangeListener (
83 const OUString& rsPropertyName,
84 const css::uno::Reference<css::beans::XPropertyChangeListener>& rxListener)
85 throw(css::beans::UnknownPropertyException,
86 css::lang::WrappedTargetException,
87 css::uno::RuntimeException);
89 virtual void SAL_CALL addVetoableChangeListener (
90 const OUString& rsPropertyName,
91 const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
92 throw(css::beans::UnknownPropertyException,
93 css::lang::WrappedTargetException,
94 css::uno::RuntimeException);
96 virtual void SAL_CALL removeVetoableChangeListener (
97 const OUString& rsPropertyName,
98 const css::uno::Reference<css::beans::XVetoableChangeListener>& rxListener)
99 throw(css::beans::UnknownPropertyException,
100 css::lang::WrappedTargetException,
101 css::uno::RuntimeException);
103 protected:
104 /** Return the requested property value.
105 @throw com::sun::star::beans::UnknownPropertyException when the
106 property is not supported.
108 virtual css::uno::Any GetPropertyValue (const OUString& rsPropertyName) = 0;
109 /** Set the given property value.
110 @return the old value.
111 @throw com::sun::star::beans::UnknownPropertyException when the
112 property is not supported.
114 virtual css::uno::Any SetPropertyValue (
115 const OUString& rsPropertyName,
116 const css::uno::Any& rValue) = 0;
118 private:
119 typedef ::std::multimap<OUString,
120 css::uno::Reference<css::beans::XPropertyChangeListener> > ChangeListenerContainer;
121 ::boost::scoped_ptr<ChangeListenerContainer> mpChangeListeners;
123 /** Call all listeners that are registered for the given property name.
124 Call this method with an empty property name to call listeners that
125 are registered for all properties.
127 void CallListeners (
128 const OUString& rsPropertyName,
129 const css::beans::PropertyChangeEvent& rEvent);
131 /** This method throws a DisposedException when the object has already been
132 disposed.
134 void ThrowIfDisposed (void)
135 throw (css::lang::DisposedException);
138 } } // end of namespace ::sd::tools
140 #endif
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */