LCOV - code coverage report
Current view: top level - forms/source/inc - listenercontainers.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 22 54.5 %
Date: 2015-06-13 12:38:46 Functions: 5 10 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
      21             : #define INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
      22             : 
      23             : #include <com/sun/star/form/XResetListener.hpp>
      24             : #include <comphelper/listenernotification.hxx>
      25             : #include <cppuhelper/weak.hxx>
      26             : 
      27             : 
      28             : namespace frm
      29             : {
      30             : 
      31             :     template < class LISTENER >
      32         190 :     class EventListeners : public ::comphelper::OListenerContainerBase< LISTENER, ::com::sun::star::lang::EventObject >
      33             :     {
      34             :     public:
      35             :         typedef LISTENER                            ListenerClass;
      36             :         typedef ::com::sun::star::lang::EventObject EventClass;
      37             :         typedef ::comphelper::OListenerContainerBase< ListenerClass, EventClass >
      38             :                                                     EventListeners_Base;
      39             : 
      40             :     private:
      41             :         ::cppu::OWeakObject&    m_rInstigator;
      42             : 
      43             :     protected:
      44             :         ::cppu::OWeakObject&    getInstigator() { return m_rInstigator; }
      45             : 
      46             :     protected:
      47         192 :         inline EventListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
      48             :             :EventListeners_Base( _rMutex )
      49         192 :             ,m_rInstigator( _rInstigator )
      50             :         {
      51         192 :         }
      52             : 
      53             :         // still waiting to be overwritten
      54             :         virtual bool    implTypedNotify(
      55             :                             const ::com::sun::star::uno::Reference< ListenerClass >& _rxListener,
      56             :                             const EventClass& _rEvent
      57             :                         ) = 0;
      58             : 
      59             :     public:
      60           0 :         inline bool notify()
      61             :         {
      62           0 :             ::com::sun::star::lang::EventObject aEvent( m_rInstigator );
      63           0 :             return EventListeners_Base::notify( aEvent );
      64             :         }
      65             : 
      66         183 :         inline void disposing()
      67             :         {
      68         183 :             ::com::sun::star::lang::EventObject aEvent( m_rInstigator );
      69         183 :             EventListeners_Base::disposing( aEvent );
      70         183 :         }
      71             :     protected:
      72             :         using EventListeners_Base::notify;
      73             :         using EventListeners_Base::disposing;
      74             :     };
      75             : 
      76             :     typedef EventListeners  <   ::com::sun::star::form::XResetListener
      77             :                             >   ResetListeners_Base;
      78         190 :     class ResetListeners : public ResetListeners_Base
      79             :     {
      80             :     private:
      81             :         enum NotificationType
      82             :         {
      83             :             eApproval,
      84             :             eFinal
      85             :         };
      86             :         NotificationType        m_eCurrentNotificationType;
      87             : 
      88             :     public:
      89         192 :         inline ResetListeners( ::cppu::OWeakObject& _rInstigator, ::osl::Mutex& _rMutex )
      90             :             :ResetListeners_Base( _rInstigator, _rMutex )
      91         192 :             ,m_eCurrentNotificationType( eApproval )
      92             :         {
      93         192 :         }
      94             : 
      95             :         /** see whether all our listeners approve the reset
      96             :         */
      97           0 :         bool approveReset()
      98             :         {
      99           0 :             m_eCurrentNotificationType = eApproval;
     100           0 :             return notify();
     101             :         }
     102             : 
     103             :         /** tell all our listeners that the reset happened
     104             :         */
     105           0 :         void resetted()
     106             :         {
     107           0 :             m_eCurrentNotificationType = eFinal;
     108           0 :             notify();
     109           0 :         }
     110             : 
     111             :     protected:
     112             :         virtual bool    implTypedNotify(
     113             :                             const ::com::sun::star::uno::Reference< ::com::sun::star::form::XResetListener >& _rxListener,
     114             :                             const ::com::sun::star::lang::EventObject& _rEvent
     115             :                         ) SAL_OVERRIDE;
     116             :     };
     117             : 
     118             : 
     119             : } // namespace frm
     120             : 
     121             : 
     122             : #endif // INCLUDED_FORMS_SOURCE_INC_LISTENERCONTAINERS_HXX
     123             : 
     124             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11