bump product version to 4.1.6.2
[LibreOffice.git] / framework / inc / classes / propertysethelper.hxx
blobf414cf6714c0ff3567a7b006d817291429138e72
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 __FRAMEWORK_CLASSES_PROPERTYSETHELPER_HXX_
21 #define __FRAMEWORK_CLASSES_PROPERTYSETHELPER_HXX_
23 #include <threadhelp/threadhelpbase.hxx>
24 #include <threadhelp/transactionbase.hxx>
25 #include <macros/debug.hxx>
26 #include <general.h>
27 #include <stdtypes.h>
29 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
30 #include <com/sun/star/beans/XPropertySet.hpp>
31 #include <com/sun/star/beans/XPropertySetInfo.hpp>
32 #include <com/sun/star/beans/PropertyExistException.hpp>
33 #include <com/sun/star/beans/UnknownPropertyException.hpp>
35 #include <cppuhelper/weakref.hxx>
36 #include <fwidllapi.h>
39 namespace framework{
41 //_________________________________________________________________________________________________________________
43 /** supports the API XPropertySet and XPropertySetInfo.
45 * It must be used as baseclass. The internal list of supported
46 * properties can be changed everytimes so dynamic property set's
47 * can be implemented.
49 * Further the derived and this base class share the same lock.
50 * So it's possible to be threadsafe if it's needed.
52 class FWI_DLLPUBLIC PropertySetHelper : public css::beans::XPropertySet
53 , public css::beans::XPropertySetInfo
55 //-------------------------------------------------------------------------
56 /* types */
57 protected:
59 typedef BaseHash< css::beans::Property > TPropInfoHash;
61 //-------------------------------------------------------------------------
62 /* member */
63 protected:
65 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR;
67 PropertySetHelper::TPropInfoHash m_lProps;
69 ListenerHash m_lSimpleChangeListener;
70 ListenerHash m_lVetoChangeListener;
72 sal_Bool m_bReleaseLockOnCall;
74 // hold it weak ... otherwise this helper has to be "killed" explicitly .-)
75 css::uno::WeakReference< css::uno::XInterface > m_xBroadcaster;
77 LockHelper& m_rLock;
78 TransactionManager& m_rTransactionManager;
80 //-------------------------------------------------------------------------
81 /* native interface */
82 public:
84 //---------------------------------------------------------------------
85 /** initialize new instance of this helper.
87 * @param xSMGR
88 * points to an uno service manager, which is used internaly to create own
89 * needed uno services.
91 * @param pExternalLock
92 * this helper must be used as a baseclass ...
93 * but then it should synchronize its own calls
94 * with the same lock then it's superclass uses.
96 * @param pExternalTransactionManager
97 * this helper must be used as a baseclass ...
98 * but then it should synchronize its own calls
99 * with the same transaction manager then it's superclass.
101 * @param bReleaseLockOnCall
102 * see member m_bReleaseLockOnCall
104 PropertySetHelper(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ,
105 LockHelper* pExternalLock ,
106 TransactionManager* pExternalTransactionManager ,
107 sal_Bool bReleaseLockOnCall );
109 //---------------------------------------------------------------------
110 /** free all needed memory.
112 virtual ~PropertySetHelper();
114 //---------------------------------------------------------------------
115 /** set a new owner for this helper.
117 * This owner is used as source for all broadcasted events.
118 * Further we hold it weak, because we dont wish to be disposed() .-)
120 void impl_setPropertyChangeBroadcaster(const css::uno::Reference< css::uno::XInterface >& xBroadcaster);
122 //---------------------------------------------------------------------
123 /** add a new property info to the set of supported ones.
125 * @param aProperty
126 * describes the new property.
128 * @throw [com::sun::star::beans::PropertyExistException]
129 * if a property with the same name already exists.
131 * Note: The consistence of the whole set of properties is not checked here.
132 * Means e.g. ... a handle which exists more then once is not detected.
133 * The owner of this class has to be sure, that every new property does
134 * not clash with any existing one.
136 virtual void SAL_CALL impl_addPropertyInfo(const css::beans::Property& aProperty)
137 throw(css::beans::PropertyExistException,
138 css::uno::Exception );
140 //---------------------------------------------------------------------
141 /** remove an existing property info from the set of supported ones.
143 * @param sProperty
144 * the name of the property.
146 * @throw [com::sun::star::beans::UnknownPropertyException]
147 * if no property with the specified name exists.
149 virtual void SAL_CALL impl_removePropertyInfo(const OUString& sProperty)
150 throw(css::beans::UnknownPropertyException,
151 css::uno::Exception );
153 //---------------------------------------------------------------------
154 /** mark the object as "useable for working" or "dead".
156 * This correspond to the lifetime handling implemented by the base class TransactionBase.
157 * There is no chance to reactive a "dead" object by calling impl_enablePropertySet()
158 * again!
160 virtual void SAL_CALL impl_enablePropertySet();
161 virtual void SAL_CALL impl_disablePropertySet();
163 //---------------------------------------------------------------------
166 virtual void SAL_CALL impl_setPropertyValue(const OUString& sProperty,
167 sal_Int32 nHandle ,
168 const css::uno::Any& aValue ) = 0;
170 virtual css::uno::Any SAL_CALL impl_getPropertyValue(const OUString& sProperty,
171 sal_Int32 nHandle ) = 0;
173 //-------------------------------------------------------------------------
174 /* uno interface */
175 public:
177 // XPropertySet
178 virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo()
179 throw(css::uno::RuntimeException);
181 virtual void SAL_CALL setPropertyValue(const OUString& sProperty,
182 const css::uno::Any& aValue )
183 throw(css::beans::UnknownPropertyException,
184 css::beans::PropertyVetoException ,
185 css::lang::IllegalArgumentException ,
186 css::lang::WrappedTargetException ,
187 css::uno::RuntimeException );
189 virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& sProperty)
190 throw(css::beans::UnknownPropertyException,
191 css::lang::WrappedTargetException ,
192 css::uno::RuntimeException );
194 virtual void SAL_CALL addPropertyChangeListener(const OUString& sProperty,
195 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener)
196 throw(css::beans::UnknownPropertyException,
197 css::lang::WrappedTargetException ,
198 css::uno::RuntimeException );
200 virtual void SAL_CALL removePropertyChangeListener(const OUString& sProperty,
201 const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener)
202 throw(css::beans::UnknownPropertyException,
203 css::lang::WrappedTargetException ,
204 css::uno::RuntimeException );
206 virtual void SAL_CALL addVetoableChangeListener(const OUString& sProperty,
207 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener)
208 throw(css::beans::UnknownPropertyException,
209 css::lang::WrappedTargetException ,
210 css::uno::RuntimeException );
212 virtual void SAL_CALL removeVetoableChangeListener(const OUString& sProperty,
213 const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener)
214 throw(css::beans::UnknownPropertyException,
215 css::lang::WrappedTargetException ,
216 css::uno::RuntimeException );
218 // XPropertySetInfo
219 virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties()
220 throw(css::uno::RuntimeException);
222 virtual css::beans::Property SAL_CALL getPropertyByName(const OUString& sName)
223 throw(css::beans::UnknownPropertyException,
224 css::uno::RuntimeException );
226 virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& sName)
227 throw(css::uno::RuntimeException);
229 //-------------------------------------------------------------------------
230 /* internal helper */
231 private:
233 sal_Bool impl_existsVeto(const css::beans::PropertyChangeEvent& aEvent);
235 void impl_notifyChangeListener(const css::beans::PropertyChangeEvent& aEvent);
238 } // namespace framework
240 #endif // #ifndef __FRAMEWORK_CLASSES_PROPERTYSETHELPER_HXX_
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */