update credits
[LibreOffice.git] / forms / source / inc / listenercontainers.hxx
blob1e9809b390ab3013f423cba1c88ffd732d2ff997
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
21 #define FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
23 #include <com/sun/star/form/XResetListener.hpp>
24 #include <comphelper/listenernotification.hxx>
25 #include <cppuhelper/weak.hxx>
27 //........................................................................
28 namespace frm
30 //........................................................................
32 //=====================================================================
33 //= EventListeners
34 //=====================================================================
35 template < class LISTENER >
36 class EventListeners : public ::comphelper::OListenerContainerBase< LISTENER, ::com::sun::star::lang::EventObject >
38 public:
39 typedef LISTENER ListenerClass;
40 typedef ::com::sun::star::lang::EventObject EventClass;
41 typedef ::comphelper::OListenerContainerBase< ListenerClass, EventClass >
42 EventListeners_Base;
44 private:
45 ::cppu::OWeakObject& m_rInstigator;
47 protected:
48 ::cppu::OWeakObject& getInstigator() { return m_rInstigator; }
50 protected:
51 inline EventListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
52 :EventListeners_Base( _rMutex )
53 ,m_rInstigator( _rInstigator )
57 // still waiting to be overwritten
58 virtual bool implTypedNotify(
59 const ::com::sun::star::uno::Reference< ListenerClass >& _rxListener,
60 const EventClass& _rEvent
61 ) SAL_THROW( ( ::com::sun::star::uno::Exception ) ) = 0;
63 public:
64 inline bool notify()
66 ::com::sun::star::lang::EventObject aEvent( m_rInstigator );
67 return EventListeners_Base::notify( aEvent );
70 inline void disposing()
72 ::com::sun::star::lang::EventObject aEvent( m_rInstigator );
73 EventListeners_Base::disposing( aEvent );
75 protected:
76 using EventListeners_Base::notify;
77 using EventListeners_Base::disposing;
80 //=====================================================================
81 //= ResetListeners
82 //=====================================================================
83 typedef EventListeners < ::com::sun::star::form::XResetListener
84 > ResetListeners_Base;
85 class ResetListeners : public ResetListeners_Base
87 private:
88 enum NotificationType
90 eApproval,
91 eFinal
93 NotificationType m_eCurrentNotificationType;
95 public:
96 inline ResetListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
97 :ResetListeners_Base( _rInstigator, _rMutex )
98 ,m_eCurrentNotificationType( eApproval )
102 /** see whether all our listeners approve the reset
104 sal_Bool approveReset()
106 m_eCurrentNotificationType = eApproval;
107 return notify();
110 /** tell all our listeners that the reset happened
112 void resetted()
114 m_eCurrentNotificationType = eFinal;
115 notify();
118 protected:
119 virtual bool implTypedNotify(
120 const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& _rxListener,
121 const ::com::sun::star::lang::EventObject& _rEvent
122 ) SAL_THROW( ( ::com::sun::star::uno::Exception ) );
125 //........................................................................
126 } // namespace frm
127 //........................................................................
129 #endif // FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */