masterfix DEV300: #i10000# build fix
[LibreOffice.git] / forms / source / inc / listenercontainers.hxx
blobd4f088d4e1804079b49b56c4760350a686f09fc0
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
29 #define FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
31 /** === begin UNO includes === **/
32 #include <com/sun/star/form/XResetListener.hpp>
33 /** === end UNO includes === **/
34 #include <comphelper/listenernotification.hxx>
35 #include <cppuhelper/weak.hxx>
37 //........................................................................
38 namespace frm
40 //........................................................................
42 //=====================================================================
43 //= EventListeners
44 //=====================================================================
45 template < class LISTENER >
46 class EventListeners : public ::comphelper::OListenerContainerBase< LISTENER, ::com::sun::star::lang::EventObject >
48 public:
49 typedef LISTENER ListenerClass;
50 typedef ::com::sun::star::lang::EventObject EventClass;
51 typedef ::comphelper::OListenerContainerBase< ListenerClass, EventClass >
52 EventListeners_Base;
54 private:
55 ::cppu::OWeakObject& m_rInstigator;
57 protected:
58 ::cppu::OWeakObject& getInstigator() { return m_rInstigator; }
60 protected:
61 inline EventListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
62 :EventListeners_Base( _rMutex )
63 ,m_rInstigator( _rInstigator )
67 // still waiting to be overwritten
68 virtual bool implTypedNotify(
69 const ::com::sun::star::uno::Reference< ListenerClass >& _rxListener,
70 const EventClass& _rEvent
71 ) SAL_THROW( ( ::com::sun::star::uno::Exception ) ) = 0;
73 public:
74 inline bool notify()
76 ::com::sun::star::lang::EventObject aEvent( m_rInstigator );
77 return EventListeners_Base::notify( aEvent );
80 inline void disposing()
82 ::com::sun::star::lang::EventObject aEvent( m_rInstigator );
83 EventListeners_Base::disposing( aEvent );
85 protected:
86 using EventListeners_Base::notify;
87 using EventListeners_Base::disposing;
90 //=====================================================================
91 //= ResetListeners
92 //=====================================================================
93 typedef EventListeners < ::com::sun::star::form::XResetListener
94 > ResetListeners_Base;
95 class ResetListeners : public ResetListeners_Base
97 private:
98 enum NotificationType
100 eApproval,
101 eFinal
103 NotificationType m_eCurrentNotificationType;
105 public:
106 inline ResetListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
107 :ResetListeners_Base( _rInstigator, _rMutex )
108 ,m_eCurrentNotificationType( eApproval )
112 /** see whether all our listeners approve the reset
114 sal_Bool approveReset()
116 m_eCurrentNotificationType = eApproval;
117 return notify();
120 /** tell all our listeners that the reset happened
122 void resetted()
124 m_eCurrentNotificationType = eFinal;
125 notify();
128 protected:
129 virtual bool implTypedNotify(
130 const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& _rxListener,
131 const ::com::sun::star::lang::EventObject& _rEvent
132 ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
135 //........................................................................
136 } // namespace frm
137 //........................................................................
139 #endif // FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX