1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_FRAMEWORK_INC_CLASSES_PROPERTYSETHELPER_HXX
21 #define INCLUDED_FRAMEWORK_INC_CLASSES_PROPERTYSETHELPER_HXX
23 #include <threadhelp/transactionbase.hxx>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/beans/XPropertySetInfo.hpp>
29 #include <com/sun/star/beans/PropertyExistException.hpp>
30 #include <com/sun/star/beans/UnknownPropertyException.hpp>
32 #include <cppuhelper/weakref.hxx>
33 #include <fwidllapi.h>
37 /** supports the API XPropertySet and XPropertySetInfo.
39 * It must be used as baseclass. The internal list of supported
40 * properties can be changed every time so dynamic property set's
43 * Further the derived and this base class share the same lock.
44 * So it's possible to be threadsafe if it's needed.
46 class FWI_DLLPUBLIC PropertySetHelper
: public css::beans::XPropertySet
47 , public css::beans::XPropertySetInfo
53 typedef BaseHash
< css::beans::Property
> TPropInfoHash
;
58 PropertySetHelper::TPropInfoHash m_lProps
;
60 ListenerHash m_lSimpleChangeListener
;
61 ListenerHash m_lVetoChangeListener
;
63 bool m_bReleaseLockOnCall
;
65 // hold it weak ... otherwise this helper has to be "killed" explicitly .-)
66 css::uno::WeakReference
< css::uno::XInterface
> m_xBroadcaster
;
68 TransactionManager
& m_rTransactionManager
;
70 /* native interface */
73 /** initialize new instance of this helper.
75 * @param pExternalTransactionManager
76 * this helper must be used as a baseclass ...
77 * but then it should synchronize its own calls
78 * with the same transaction manager then it's superclass.
80 * @param bReleaseLockOnCall
81 * see member m_bReleaseLockOnCall
83 PropertySetHelper( osl::Mutex
& mutex
,
84 TransactionManager
* pExternalTransactionManager
,
85 bool bReleaseLockOnCall
);
87 /** free all needed memory.
89 virtual ~PropertySetHelper();
91 /** set a new owner for this helper.
93 * This owner is used as source for all broadcasted events.
94 * Further we hold it weak, because we dont wish to be disposed() .-)
96 void impl_setPropertyChangeBroadcaster(const css::uno::Reference
< css::uno::XInterface
>& xBroadcaster
);
98 /** add a new property info to the set of supported ones.
101 * describes the new property.
103 * @throw [com::sun::star::beans::PropertyExistException]
104 * if a property with the same name already exists.
106 * Note: The consistence of the whole set of properties is not checked here.
107 * Means e.g. ... a handle which exists more than once is not detected.
108 * The owner of this class has to be sure, that every new property does
109 * not clash with any existing one.
111 void SAL_CALL
impl_addPropertyInfo(const css::beans::Property
& aProperty
)
112 throw(css::beans::PropertyExistException
,
113 css::uno::Exception
);
115 /** mark the object as "useable for working" or "dead".
117 * This correspond to the lifetime handling implemented by the base class TransactionBase.
118 * There is no chance to reactive a "dead" object by calling impl_enablePropertySet()
121 void SAL_CALL
impl_disablePropertySet();
125 virtual void SAL_CALL
impl_setPropertyValue(const OUString
& sProperty
,
127 const css::uno::Any
& aValue
) = 0;
129 virtual css::uno::Any SAL_CALL
impl_getPropertyValue(const OUString
& sProperty
,
130 sal_Int32 nHandle
) = 0;
136 virtual css::uno::Reference
< css::beans::XPropertySetInfo
> SAL_CALL
getPropertySetInfo()
137 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
139 virtual void SAL_CALL
setPropertyValue(const OUString
& sProperty
,
140 const css::uno::Any
& aValue
)
141 throw(css::beans::UnknownPropertyException
,
142 css::beans::PropertyVetoException
,
143 css::lang::IllegalArgumentException
,
144 css::lang::WrappedTargetException
,
145 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
147 virtual css::uno::Any SAL_CALL
getPropertyValue(const OUString
& sProperty
)
148 throw(css::beans::UnknownPropertyException
,
149 css::lang::WrappedTargetException
,
150 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
152 virtual void SAL_CALL
addPropertyChangeListener(const OUString
& sProperty
,
153 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
)
154 throw(css::beans::UnknownPropertyException
,
155 css::lang::WrappedTargetException
,
156 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
158 virtual void SAL_CALL
removePropertyChangeListener(const OUString
& sProperty
,
159 const css::uno::Reference
< css::beans::XPropertyChangeListener
>& xListener
)
160 throw(css::beans::UnknownPropertyException
,
161 css::lang::WrappedTargetException
,
162 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
164 virtual void SAL_CALL
addVetoableChangeListener(const OUString
& sProperty
,
165 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& xListener
)
166 throw(css::beans::UnknownPropertyException
,
167 css::lang::WrappedTargetException
,
168 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
170 virtual void SAL_CALL
removeVetoableChangeListener(const OUString
& sProperty
,
171 const css::uno::Reference
< css::beans::XVetoableChangeListener
>& xListener
)
172 throw(css::beans::UnknownPropertyException
,
173 css::lang::WrappedTargetException
,
174 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
177 virtual css::uno::Sequence
< css::beans::Property
> SAL_CALL
getProperties()
178 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
180 virtual css::beans::Property SAL_CALL
getPropertyByName(const OUString
& sName
)
181 throw(css::beans::UnknownPropertyException
,
182 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
184 virtual sal_Bool SAL_CALL
hasPropertyByName(const OUString
& sName
)
185 throw(css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
187 /* internal helper */
190 bool impl_existsVeto(const css::beans::PropertyChangeEvent
& aEvent
);
192 void impl_notifyChangeListener(const css::beans::PropertyChangeEvent
& aEvent
);
195 } // namespace framework
197 #endif // INCLUDED_FRAMEWORK_INC_CLASSES_PROPERTYSETHELPER_HXX
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */