1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: listenercontainers.hxx,v $
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 //........................................................................
43 //........................................................................
45 //=====================================================================
47 //=====================================================================
48 template < class LISTENER
>
49 class EventListeners
: public ::comphelper::OListenerContainerBase
< LISTENER
, ::com::sun::star::lang::EventObject
>
52 typedef LISTENER ListenerClass
;
53 typedef ::com::sun::star::lang::EventObject EventClass
;
54 typedef ::comphelper::OListenerContainerBase
< ListenerClass
, EventClass
>
58 ::cppu::OWeakObject
& m_rInstigator
;
61 ::cppu::OWeakObject
& getInstigator() { return m_rInstigator
; }
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;
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
);
89 using EventListeners_Base::notify
;
90 using EventListeners_Base::disposing
;
93 //=====================================================================
95 //=====================================================================
96 typedef EventListeners
< ::com::sun::star::form::XResetListener
97 > ResetListeners_Base
;
98 class ResetListeners
: public ResetListeners_Base
101 enum NotificationType
106 NotificationType m_eCurrentNotificationType
;
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
;
123 /** tell all our listeners that the reset happened
127 m_eCurrentNotificationType
= eFinal
;
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 //........................................................................
140 //........................................................................
142 #endif // FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX