merge the formfield patch from ooo-build
[ooovba.git] / forms / source / inc / listenercontainers.hxx
blob5899253ccd89fcaba29f719ab54cead0ea53db25
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: listenercontainers.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
32 #define FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
34 /** === begin UNO includes === **/
35 #include <com/sun/star/form/XResetListener.hpp>
36 /** === end UNO includes === **/
37 #include <comphelper/listenernotification.hxx>
38 #include <cppuhelper/weak.hxx>
40 //........................................................................
41 namespace frm
43 //........................................................................
45 //=====================================================================
46 //= EventListeners
47 //=====================================================================
48 template < class LISTENER >
49 class EventListeners : public ::comphelper::OListenerContainerBase< LISTENER, ::com::sun::star::lang::EventObject >
51 public:
52 typedef LISTENER ListenerClass;
53 typedef ::com::sun::star::lang::EventObject EventClass;
54 typedef ::comphelper::OListenerContainerBase< ListenerClass, EventClass >
55 EventListeners_Base;
57 private:
58 ::cppu::OWeakObject& m_rInstigator;
60 protected:
61 ::cppu::OWeakObject& getInstigator() { return m_rInstigator; }
63 protected:
64 inline EventListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
65 :EventListeners_Base( _rMutex )
66 ,m_rInstigator( _rInstigator )
70 // still waiting to be overwritten
71 virtual bool implTypedNotify(
72 const ::com::sun::star::uno::Reference< ListenerClass >& _rxListener,
73 const EventClass& _rEvent
74 ) SAL_THROW( ( ::com::sun::star::uno::Exception ) ) = 0;
76 public:
77 inline bool notify()
79 ::com::sun::star::lang::EventObject aEvent( m_rInstigator );
80 return EventListeners_Base::notify( aEvent );
83 inline void disposing()
85 ::com::sun::star::lang::EventObject aEvent( m_rInstigator );
86 EventListeners_Base::disposing( aEvent );
88 protected:
89 using EventListeners_Base::notify;
90 using EventListeners_Base::disposing;
93 //=====================================================================
94 //= ResetListeners
95 //=====================================================================
96 typedef EventListeners < ::com::sun::star::form::XResetListener
97 > ResetListeners_Base;
98 class ResetListeners : public ResetListeners_Base
100 private:
101 enum NotificationType
103 eApproval,
104 eFinal
106 NotificationType m_eCurrentNotificationType;
108 public:
109 inline ResetListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
110 :ResetListeners_Base( _rInstigator, _rMutex )
111 ,m_eCurrentNotificationType( eApproval )
115 /** see whether all our listeners approve the reset
117 sal_Bool approveReset()
119 m_eCurrentNotificationType = eApproval;
120 return notify();
123 /** tell all our listeners that the reset happened
125 void resetted()
127 m_eCurrentNotificationType = eFinal;
128 notify();
131 protected:
132 virtual bool implTypedNotify(
133 const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& _rxListener,
134 const ::com::sun::star::lang::EventObject& _rEvent
135 ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
138 //........................................................................
139 } // namespace frm
140 //........................................................................
142 #endif // FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX