xref: /AOO41X/main/framework/source/fwi/classes/propertysethelper.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32*cdf0e10cSrcweir //	my own includes
33*cdf0e10cSrcweir 
34*cdf0e10cSrcweir #include <classes/propertysethelper.hxx>
35*cdf0e10cSrcweir #include <threadhelp/transactionguard.hxx>
36*cdf0e10cSrcweir #include <threadhelp/readguard.hxx>
37*cdf0e10cSrcweir #include <threadhelp/writeguard.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
40*cdf0e10cSrcweir //	interface includes
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
43*cdf0e10cSrcweir //	other includes
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
46*cdf0e10cSrcweir //	namespace
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir namespace framework{
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
51*cdf0e10cSrcweir //  non exported definitions
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir //-----------------------------------------------------------------------------
54*cdf0e10cSrcweir PropertySetHelper::PropertySetHelper(const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR                       ,
55*cdf0e10cSrcweir                                            LockHelper*                                             pExternalLock               ,
56*cdf0e10cSrcweir                                            TransactionManager*                                     pExternalTransactionManager ,
57*cdf0e10cSrcweir                                            sal_Bool                                                bReleaseLockOnCall          )
58*cdf0e10cSrcweir     : m_xSMGR                (xSMGR                                )
59*cdf0e10cSrcweir     , m_lSimpleChangeListener(pExternalLock->getShareableOslMutex())
60*cdf0e10cSrcweir     , m_lVetoChangeListener  (pExternalLock->getShareableOslMutex())
61*cdf0e10cSrcweir     , m_bReleaseLockOnCall   (bReleaseLockOnCall                   )
62*cdf0e10cSrcweir     , m_rLock                (*pExternalLock                       )
63*cdf0e10cSrcweir     , m_rTransactionManager  (*pExternalTransactionManager         )
64*cdf0e10cSrcweir {
65*cdf0e10cSrcweir }
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir //-----------------------------------------------------------------------------
68*cdf0e10cSrcweir PropertySetHelper::~PropertySetHelper()
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir }
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir //-----------------------------------------------------------------------------
73*cdf0e10cSrcweir void PropertySetHelper::impl_setPropertyChangeBroadcaster(const css::uno::Reference< css::uno::XInterface >& xBroadcaster)
74*cdf0e10cSrcweir {
75*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_SOFTEXCEPTIONS);
76*cdf0e10cSrcweir 
77*cdf0e10cSrcweir     // SAFE ->
78*cdf0e10cSrcweir     WriteGuard aWriteLock(m_rLock);
79*cdf0e10cSrcweir     m_xBroadcaster = xBroadcaster;
80*cdf0e10cSrcweir     aWriteLock.unlock();
81*cdf0e10cSrcweir     // <- SAFE
82*cdf0e10cSrcweir }
83*cdf0e10cSrcweir 
84*cdf0e10cSrcweir //-----------------------------------------------------------------------------
85*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::impl_addPropertyInfo(const css::beans::Property& aProperty)
86*cdf0e10cSrcweir     throw(css::beans::PropertyExistException,
87*cdf0e10cSrcweir           css::uno::Exception               )
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_SOFTEXCEPTIONS);
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir     // SAFE ->
92*cdf0e10cSrcweir     WriteGuard aWriteLock(m_rLock);
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt = m_lProps.find(aProperty.Name);
95*cdf0e10cSrcweir     if (pIt != m_lProps.end())
96*cdf0e10cSrcweir         throw css::beans::PropertyExistException();
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir     m_lProps[aProperty.Name] = aProperty;
99*cdf0e10cSrcweir     // <- SAFE
100*cdf0e10cSrcweir }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir //-----------------------------------------------------------------------------
103*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::impl_removePropertyInfo(const ::rtl::OUString& sProperty)
104*cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
105*cdf0e10cSrcweir           css::uno::Exception                 )
106*cdf0e10cSrcweir {
107*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_SOFTEXCEPTIONS);
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir     // SAFE ->
110*cdf0e10cSrcweir     WriteGuard aWriteLock(m_rLock);
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::iterator pIt = m_lProps.find(sProperty);
113*cdf0e10cSrcweir     if (pIt == m_lProps.end())
114*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException();
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir     m_lProps.erase(pIt);
117*cdf0e10cSrcweir     // <- SAFE
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir //-----------------------------------------------------------------------------
121*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::impl_enablePropertySet()
122*cdf0e10cSrcweir {
123*cdf0e10cSrcweir }
124*cdf0e10cSrcweir 
125*cdf0e10cSrcweir //-----------------------------------------------------------------------------
126*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::impl_disablePropertySet()
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_SOFTEXCEPTIONS);
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir     // SAFE ->
131*cdf0e10cSrcweir     WriteGuard aWriteLock(m_rLock);
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir     css::uno::Reference< css::uno::XInterface > xThis(static_cast< css::beans::XPropertySet* >(this), css::uno::UNO_QUERY);
134*cdf0e10cSrcweir     css::lang::EventObject aEvent(xThis);
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir     m_lSimpleChangeListener.disposeAndClear(aEvent);
137*cdf0e10cSrcweir     m_lVetoChangeListener.disposeAndClear(aEvent);
138*cdf0e10cSrcweir     m_lProps.free();
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     aWriteLock.unlock();
141*cdf0e10cSrcweir     // <- SAFE
142*cdf0e10cSrcweir }
143*cdf0e10cSrcweir 
144*cdf0e10cSrcweir //-----------------------------------------------------------------------------
145*cdf0e10cSrcweir sal_Bool PropertySetHelper::impl_existsVeto(const css::beans::PropertyChangeEvent& aEvent)
146*cdf0e10cSrcweir {
147*cdf0e10cSrcweir     /*  Dont use the lock here!
148*cdf0e10cSrcweir         The used helper is threadsafe and it lives for the whole lifetime of
149*cdf0e10cSrcweir         our own object.
150*cdf0e10cSrcweir     */
151*cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper* pVetoListener = m_lVetoChangeListener.getContainer(aEvent.PropertyName);
152*cdf0e10cSrcweir 	if (! pVetoListener)
153*cdf0e10cSrcweir         return sal_False;
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir 	::cppu::OInterfaceIteratorHelper pListener(*pVetoListener);
156*cdf0e10cSrcweir 	while (pListener.hasMoreElements())
157*cdf0e10cSrcweir 	{
158*cdf0e10cSrcweir         try
159*cdf0e10cSrcweir         {
160*cdf0e10cSrcweir             css::uno::Reference< css::beans::XVetoableChangeListener > xListener(
161*cdf0e10cSrcweir                 ((css::beans::XVetoableChangeListener*)pListener.next()),
162*cdf0e10cSrcweir                 css::uno::UNO_QUERY_THROW);
163*cdf0e10cSrcweir             xListener->vetoableChange(aEvent);
164*cdf0e10cSrcweir         }
165*cdf0e10cSrcweir         catch(const css::uno::RuntimeException&)
166*cdf0e10cSrcweir             { pListener.remove(); }
167*cdf0e10cSrcweir         catch(const css::beans::PropertyVetoException&)
168*cdf0e10cSrcweir             { return sal_True; }
169*cdf0e10cSrcweir 	}
170*cdf0e10cSrcweir 
171*cdf0e10cSrcweir     return sal_False;
172*cdf0e10cSrcweir }
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir //-----------------------------------------------------------------------------
175*cdf0e10cSrcweir void PropertySetHelper::impl_notifyChangeListener(const css::beans::PropertyChangeEvent& aEvent)
176*cdf0e10cSrcweir {
177*cdf0e10cSrcweir     /*  Dont use the lock here!
178*cdf0e10cSrcweir         The used helper is threadsafe and it lives for the whole lifetime of
179*cdf0e10cSrcweir         our own object.
180*cdf0e10cSrcweir     */
181*cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper* pSimpleListener = m_lSimpleChangeListener.getContainer(aEvent.PropertyName);
182*cdf0e10cSrcweir 	if (! pSimpleListener)
183*cdf0e10cSrcweir         return;
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 	::cppu::OInterfaceIteratorHelper pListener(*pSimpleListener);
186*cdf0e10cSrcweir 	while (pListener.hasMoreElements())
187*cdf0e10cSrcweir 	{
188*cdf0e10cSrcweir         try
189*cdf0e10cSrcweir         {
190*cdf0e10cSrcweir             css::uno::Reference< css::beans::XPropertyChangeListener > xListener(
191*cdf0e10cSrcweir                 ((css::beans::XVetoableChangeListener*)pListener.next()),
192*cdf0e10cSrcweir                 css::uno::UNO_QUERY_THROW);
193*cdf0e10cSrcweir             xListener->propertyChange(aEvent);
194*cdf0e10cSrcweir         }
195*cdf0e10cSrcweir         catch(const css::uno::RuntimeException&)
196*cdf0e10cSrcweir             { pListener.remove(); }
197*cdf0e10cSrcweir 	}
198*cdf0e10cSrcweir }
199*cdf0e10cSrcweir 
200*cdf0e10cSrcweir //-----------------------------------------------------------------------------
201*cdf0e10cSrcweir css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL PropertySetHelper::getPropertySetInfo()
202*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
203*cdf0e10cSrcweir {
204*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_HARDEXCEPTIONS);
205*cdf0e10cSrcweir 
206*cdf0e10cSrcweir     css::uno::Reference< css::beans::XPropertySetInfo > xInfo(static_cast< css::beans::XPropertySetInfo* >(this), css::uno::UNO_QUERY_THROW);
207*cdf0e10cSrcweir     return xInfo;
208*cdf0e10cSrcweir }
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir //-----------------------------------------------------------------------------
211*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::setPropertyValue(const ::rtl::OUString& sProperty,
212*cdf0e10cSrcweir                                                   const css::uno::Any&   aValue   )
213*cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
214*cdf0e10cSrcweir           css::beans::PropertyVetoException   ,
215*cdf0e10cSrcweir           css::lang::IllegalArgumentException ,
216*cdf0e10cSrcweir           css::lang::WrappedTargetException   ,
217*cdf0e10cSrcweir           css::uno::RuntimeException          )
218*cdf0e10cSrcweir {
219*cdf0e10cSrcweir     // TODO look for e.g. readonly props and reject setProp() call!
220*cdf0e10cSrcweir 
221*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_HARDEXCEPTIONS);
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir     // SAFE ->
224*cdf0e10cSrcweir     WriteGuard aWriteLock(m_rLock);
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty);
227*cdf0e10cSrcweir     if (pIt == m_lProps.end())
228*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException();
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir     css::beans::Property aPropInfo = pIt->second;
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir     sal_Bool bLocked = sal_True;
233*cdf0e10cSrcweir     if (m_bReleaseLockOnCall)
234*cdf0e10cSrcweir     {
235*cdf0e10cSrcweir         aWriteLock.unlock();
236*cdf0e10cSrcweir         bLocked = sal_False;
237*cdf0e10cSrcweir         // <- SAFE
238*cdf0e10cSrcweir     }
239*cdf0e10cSrcweir 
240*cdf0e10cSrcweir     css::uno::Any aCurrentValue = impl_getPropertyValue(aPropInfo.Name, aPropInfo.Handle);
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir     if (! bLocked)
243*cdf0e10cSrcweir     {
244*cdf0e10cSrcweir         // SAFE ->
245*cdf0e10cSrcweir         aWriteLock.lock();
246*cdf0e10cSrcweir         bLocked = sal_True;
247*cdf0e10cSrcweir     }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir     sal_Bool bWillBeChanged = (aCurrentValue != aValue);
250*cdf0e10cSrcweir     if (! bWillBeChanged)
251*cdf0e10cSrcweir         return;
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir     css::beans::PropertyChangeEvent aEvent;
254*cdf0e10cSrcweir     aEvent.PropertyName   = aPropInfo.Name;
255*cdf0e10cSrcweir     aEvent.Further        = sal_False;
256*cdf0e10cSrcweir     aEvent.PropertyHandle = aPropInfo.Handle;
257*cdf0e10cSrcweir     aEvent.OldValue       = aCurrentValue;
258*cdf0e10cSrcweir     aEvent.NewValue       = aValue;
259*cdf0e10cSrcweir     aEvent.Source         = css::uno::Reference< css::uno::XInterface >(m_xBroadcaster.get(), css::uno::UNO_QUERY);
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir     if (m_bReleaseLockOnCall)
262*cdf0e10cSrcweir     {
263*cdf0e10cSrcweir         aWriteLock.unlock();
264*cdf0e10cSrcweir         bLocked = sal_False;
265*cdf0e10cSrcweir         // <- SAFE
266*cdf0e10cSrcweir     }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir     if (impl_existsVeto(aEvent))
269*cdf0e10cSrcweir         throw css::beans::PropertyVetoException();
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir     impl_setPropertyValue(aPropInfo.Name, aPropInfo.Handle, aValue);
272*cdf0e10cSrcweir 
273*cdf0e10cSrcweir     impl_notifyChangeListener(aEvent);
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir //-----------------------------------------------------------------------------
277*cdf0e10cSrcweir css::uno::Any SAL_CALL PropertySetHelper::getPropertyValue(const ::rtl::OUString& sProperty)
278*cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
279*cdf0e10cSrcweir           css::lang::WrappedTargetException   ,
280*cdf0e10cSrcweir           css::uno::RuntimeException          )
281*cdf0e10cSrcweir {
282*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_HARDEXCEPTIONS);
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir     // SAFE ->
285*cdf0e10cSrcweir     ReadGuard aReadLock(m_rLock);
286*cdf0e10cSrcweir 
287*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty);
288*cdf0e10cSrcweir     if (pIt == m_lProps.end())
289*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException();
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir     css::beans::Property aPropInfo = pIt->second;
292*cdf0e10cSrcweir 
293*cdf0e10cSrcweir     sal_Bool bLocked = sal_True;
294*cdf0e10cSrcweir     if (m_bReleaseLockOnCall)
295*cdf0e10cSrcweir     {
296*cdf0e10cSrcweir         aReadLock.unlock();
297*cdf0e10cSrcweir         bLocked = sal_False;
298*cdf0e10cSrcweir         // <- SAFE
299*cdf0e10cSrcweir     }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     return impl_getPropertyValue(aPropInfo.Name, aPropInfo.Handle);
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir //-----------------------------------------------------------------------------
305*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::addPropertyChangeListener(const ::rtl::OUString&                                            sProperty,
306*cdf0e10cSrcweir                                                            const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener)
307*cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
308*cdf0e10cSrcweir           css::lang::WrappedTargetException   ,
309*cdf0e10cSrcweir           css::uno::RuntimeException          )
310*cdf0e10cSrcweir {
311*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_HARDEXCEPTIONS);
312*cdf0e10cSrcweir 
313*cdf0e10cSrcweir     // SAFE ->
314*cdf0e10cSrcweir     ReadGuard aReadLock(m_rLock);
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty);
317*cdf0e10cSrcweir     if (pIt == m_lProps.end())
318*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException();
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir     aReadLock.unlock();
321*cdf0e10cSrcweir     // <- SAFE
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir     m_lSimpleChangeListener.addInterface(sProperty, xListener);
324*cdf0e10cSrcweir }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir //-----------------------------------------------------------------------------
327*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::removePropertyChangeListener(const ::rtl::OUString&                                            sProperty,
328*cdf0e10cSrcweir                                                               const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener)
329*cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
330*cdf0e10cSrcweir           css::lang::WrappedTargetException   ,
331*cdf0e10cSrcweir           css::uno::RuntimeException          )
332*cdf0e10cSrcweir {
333*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_SOFTEXCEPTIONS);
334*cdf0e10cSrcweir 
335*cdf0e10cSrcweir     // SAFE ->
336*cdf0e10cSrcweir     ReadGuard aReadLock(m_rLock);
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty);
339*cdf0e10cSrcweir     if (pIt == m_lProps.end())
340*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException();
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir     aReadLock.unlock();
343*cdf0e10cSrcweir     // <- SAFE
344*cdf0e10cSrcweir 
345*cdf0e10cSrcweir     m_lSimpleChangeListener.removeInterface(sProperty, xListener);
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir //-----------------------------------------------------------------------------
349*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::addVetoableChangeListener(const ::rtl::OUString&                                            sProperty,
350*cdf0e10cSrcweir                                                            const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener)
351*cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
352*cdf0e10cSrcweir           css::lang::WrappedTargetException   ,
353*cdf0e10cSrcweir           css::uno::RuntimeException          )
354*cdf0e10cSrcweir {
355*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_HARDEXCEPTIONS);
356*cdf0e10cSrcweir 
357*cdf0e10cSrcweir     // SAFE ->
358*cdf0e10cSrcweir     ReadGuard aReadLock(m_rLock);
359*cdf0e10cSrcweir 
360*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty);
361*cdf0e10cSrcweir     if (pIt == m_lProps.end())
362*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException();
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir     aReadLock.unlock();
365*cdf0e10cSrcweir     // <- SAFE
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir     m_lVetoChangeListener.addInterface(sProperty, xListener);
368*cdf0e10cSrcweir }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir //-----------------------------------------------------------------------------
371*cdf0e10cSrcweir void SAL_CALL PropertySetHelper::removeVetoableChangeListener(const ::rtl::OUString&                                            sProperty,
372*cdf0e10cSrcweir                                                               const css::uno::Reference< css::beans::XVetoableChangeListener >& xListener)
373*cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
374*cdf0e10cSrcweir           css::lang::WrappedTargetException   ,
375*cdf0e10cSrcweir           css::uno::RuntimeException          )
376*cdf0e10cSrcweir {
377*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_SOFTEXCEPTIONS);
378*cdf0e10cSrcweir 
379*cdf0e10cSrcweir     // SAFE ->
380*cdf0e10cSrcweir     ReadGuard aReadLock(m_rLock);
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt = m_lProps.find(sProperty);
383*cdf0e10cSrcweir     if (pIt == m_lProps.end())
384*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException();
385*cdf0e10cSrcweir 
386*cdf0e10cSrcweir     aReadLock.unlock();
387*cdf0e10cSrcweir     // <- SAFE
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir     m_lVetoChangeListener.removeInterface(sProperty, xListener);
390*cdf0e10cSrcweir }
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir //-----------------------------------------------------------------------------
393*cdf0e10cSrcweir css::uno::Sequence< css::beans::Property > SAL_CALL PropertySetHelper::getProperties()
394*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
395*cdf0e10cSrcweir {
396*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_HARDEXCEPTIONS);
397*cdf0e10cSrcweir 
398*cdf0e10cSrcweir     // SAFE ->
399*cdf0e10cSrcweir     ReadGuard aReadLock(m_rLock);
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir     sal_Int32                                        c     = (sal_Int32)m_lProps.size();
402*cdf0e10cSrcweir     css::uno::Sequence< css::beans::Property >       lProps(c);
403*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt   ;
404*cdf0e10cSrcweir 
405*cdf0e10cSrcweir     for (  pIt  = m_lProps.begin();
406*cdf0e10cSrcweir            pIt != m_lProps.end()  ;
407*cdf0e10cSrcweir          ++pIt                    )
408*cdf0e10cSrcweir     {
409*cdf0e10cSrcweir         lProps[--c] = pIt->second;
410*cdf0e10cSrcweir     }
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir     return lProps;
413*cdf0e10cSrcweir     // <- SAFE
414*cdf0e10cSrcweir }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir //-----------------------------------------------------------------------------
417*cdf0e10cSrcweir css::beans::Property SAL_CALL PropertySetHelper::getPropertyByName(const ::rtl::OUString& sName)
418*cdf0e10cSrcweir     throw(css::beans::UnknownPropertyException,
419*cdf0e10cSrcweir           css::uno::RuntimeException          )
420*cdf0e10cSrcweir {
421*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_HARDEXCEPTIONS);
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir     // SAFE ->
424*cdf0e10cSrcweir     ReadGuard aReadLock(m_rLock);
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::const_iterator pIt = m_lProps.find(sName);
427*cdf0e10cSrcweir     if (pIt == m_lProps.end())
428*cdf0e10cSrcweir         throw css::beans::UnknownPropertyException();
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir     return pIt->second;
431*cdf0e10cSrcweir     // <- SAFE
432*cdf0e10cSrcweir }
433*cdf0e10cSrcweir 
434*cdf0e10cSrcweir //-----------------------------------------------------------------------------
435*cdf0e10cSrcweir sal_Bool SAL_CALL PropertySetHelper::hasPropertyByName(const ::rtl::OUString& sName)
436*cdf0e10cSrcweir     throw(css::uno::RuntimeException)
437*cdf0e10cSrcweir {
438*cdf0e10cSrcweir     TransactionGuard aTransaction(m_rTransactionManager, E_HARDEXCEPTIONS);
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir     // SAFE ->
441*cdf0e10cSrcweir     ReadGuard aReadLock(m_rLock);
442*cdf0e10cSrcweir 
443*cdf0e10cSrcweir     PropertySetHelper::TPropInfoHash::iterator pIt    = m_lProps.find(sName);
444*cdf0e10cSrcweir     sal_Bool                                   bExist = (pIt != m_lProps.end());
445*cdf0e10cSrcweir 
446*cdf0e10cSrcweir     return bExist;
447*cdf0e10cSrcweir     // <- SAFE
448*cdf0e10cSrcweir }
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir } // namespace framework
451