Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / forms / source / inc / listenercontainers.hxx
blobe46443dbc0d1b30e62c0face55d5176128e8c652
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 INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
21 #define INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
23 #include <com/sun/star/form/XResetListener.hpp>
24 #include <comphelper/listenernotification.hxx>
25 #include <cppuhelper/weak.hxx>
28 namespace frm
31 template < class LISTENER >
32 class EventListeners : public ::comphelper::OListenerContainerBase< LISTENER, css::lang::EventObject >
34 public:
35 typedef ::comphelper::OListenerContainerBase< LISTENER, css::lang::EventObject >
36 EventListeners_Base;
38 private:
39 ::cppu::OWeakObject& m_rInstigator;
41 protected:
42 inline EventListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
43 :EventListeners_Base( _rMutex )
44 ,m_rInstigator( _rInstigator )
48 public:
49 inline bool notify()
51 css::lang::EventObject aEvent( m_rInstigator );
52 return EventListeners_Base::notify( aEvent );
55 inline void disposing()
57 css::lang::EventObject aEvent( m_rInstigator );
58 EventListeners_Base::disposing( aEvent );
60 protected:
61 using EventListeners_Base::notify;
62 using EventListeners_Base::disposing;
65 typedef EventListeners < css::form::XResetListener
66 > ResetListeners_Base;
67 class ResetListeners : public ResetListeners_Base
69 private:
70 enum NotificationType
72 eApproval,
73 eFinal
75 NotificationType m_eCurrentNotificationType;
77 public:
78 inline ResetListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
79 :ResetListeners_Base( _rInstigator, _rMutex )
80 ,m_eCurrentNotificationType( eApproval )
84 /** see whether all our listeners approve the reset
86 bool approveReset()
88 m_eCurrentNotificationType = eApproval;
89 return notify();
92 /** tell all our listeners that the reset happened
94 void resetted()
96 m_eCurrentNotificationType = eFinal;
97 notify();
100 protected:
101 virtual bool implTypedNotify(
102 const css::uno::Reference< css::form::XResetListener >& _rxListener,
103 const css::lang::EventObject& _rEvent
104 ) override;
108 } // namespace frm
111 #endif // INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
113 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */