LCOV - code coverage report
Current view: top level - extensions/source/bibliography - loadlisteneradapter.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 10 0.0 %
Date: 2012-08-25 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 6 0.0 %

           Branch data     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 EXTENSIONS_BIB_LOADLISTENERADAPTER_HXX
      21                 :            : #define EXTENSIONS_BIB_LOADLISTENERADAPTER_HXX
      22                 :            : 
      23                 :            : #include <osl/mutex.hxx>
      24                 :            : #include <com/sun/star/lang/XComponent.hpp>
      25                 :            : #include <cppuhelper/implbase1.hxx>
      26                 :            : #include <com/sun/star/form/XLoadable.hpp>
      27                 :            : 
      28                 :            : //.........................................................................
      29                 :            : namespace bib
      30                 :            : {
      31                 :            : //.........................................................................
      32                 :            : 
      33                 :            :     class OComponentAdapterBase;
      34                 :            : 
      35                 :            :     //=====================================================================
      36                 :            :     //= OComponentListener
      37                 :            :     //=====================================================================
      38                 :            :     class OComponentListener
      39                 :            :     {
      40                 :            :         friend class OComponentAdapterBase;
      41                 :            : 
      42                 :            :     private:
      43                 :            :         OComponentAdapterBase*  m_pAdapter;
      44                 :            :         ::osl::Mutex&           m_rMutex;
      45                 :            :     protected:
      46                 :          0 :         OComponentListener( ::osl::Mutex& _rMutex )
      47                 :            :             :m_pAdapter( NULL )
      48                 :          0 :             ,m_rMutex( _rMutex )
      49                 :            :         {
      50                 :          0 :         }
      51                 :            : 
      52                 :            :         virtual ~OComponentListener();
      53                 :            : 
      54                 :            :         // XEventListener equivalents
      55                 :            :         virtual void _disposing( const ::com::sun::star::lang::EventObject& _rSource ) throw( ::com::sun::star::uno::RuntimeException );
      56                 :            : 
      57                 :            :     protected:
      58                 :            :         void setAdapter( OComponentAdapterBase* _pAdapter );
      59                 :            :     };
      60                 :            : 
      61                 :            :     //=====================================================================
      62                 :            :     //= OComponentAdapterBase
      63                 :            :     //=====================================================================
      64                 :            :     class OComponentAdapterBase
      65                 :            :     {
      66                 :            :         friend class OComponentListener;
      67                 :            : 
      68                 :            :     private:
      69                 :            :         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
      70                 :            :                                             m_xComponent;
      71                 :            :         OComponentListener*                 m_pListener;
      72                 :            :         sal_Int32                           m_nLockCount;
      73                 :            :         sal_Bool                            m_bListening    : 1;
      74                 :            :         sal_Bool                            m_bAutoRelease  : 1;
      75                 :            : 
      76                 :            :         // impl method for dispose - virtual, 'cause you at least need to remove the listener from the broadcaster
      77                 :            :         virtual void disposing() = 0;
      78                 :            : 
      79                 :            :     protected:
      80                 :            :         // attribute access for derivees
      81                 :            :         const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >&
      82                 :          0 :                                 getComponent() const    { return m_xComponent; }
      83                 :          0 :         OComponentListener*     getListener()           { return m_pListener; }
      84                 :            : 
      85                 :            :         // to be called by derivees which started listening at the component
      86                 :            :         virtual void    startComponentListening() = 0;
      87                 :            : 
      88                 :            :         virtual ~OComponentAdapterBase();
      89                 :            : 
      90                 :            :     public:
      91                 :            :         OComponentAdapterBase(
      92                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxComp,
      93                 :            :             sal_Bool _bAutoRelease = sal_True
      94                 :            :         );
      95                 :            : 
      96                 :            :         // late construction
      97                 :            :         // can be called from within you ctor, to have you're object fully initialized at the moment of
      98                 :            :         // the call (which would not be the case when calling this ctor)
      99                 :            :         void Init( OComponentListener* _pListener );
     100                 :            : 
     101                 :            :     // base for ref-counting, implemented by OComponentAdapter
     102                 :            :         virtual void SAL_CALL acquire(  ) throw () = 0;
     103                 :            :         virtual void SAL_CALL release(  ) throw () = 0;
     104                 :            : 
     105                 :            :     // helper
     106                 :            :         /// get the lock count
     107                 :          0 :         sal_Int32   locked() const { return m_nLockCount; }
     108                 :            : 
     109                 :            :         /// dispose the object - stop listening and such
     110                 :            :         void dispose();
     111                 :            : 
     112                 :            :     protected:
     113                 :            :     // XEventListener
     114                 :            :         virtual void SAL_CALL disposing( const  ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException);
     115                 :            :     };
     116                 :            : 
     117                 :            :     //=====================================================================
     118                 :            :     //= OLoadListener
     119                 :            :     //=====================================================================
     120         [ #  # ]:          0 :     class OLoadListener : public OComponentListener
     121                 :            :     {
     122                 :            :         friend class OLoadListenerAdapter;
     123                 :            : 
     124                 :            :     protected:
     125                 :          0 :         OLoadListener( ::osl::Mutex& _rMutex ) : OComponentListener( _rMutex ) { }
     126                 :            : 
     127                 :            :     // XLoadListener equivalents
     128                 :            :         virtual void _loaded( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
     129                 :            :         virtual void _unloading( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
     130                 :            :         virtual void _unloaded( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
     131                 :            :         virtual void _reloading( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
     132                 :            :         virtual void _reloaded( const ::com::sun::star::lang::EventObject& aEvent ) = 0;
     133                 :            :     };
     134                 :            : 
     135                 :            :     //=====================================================================
     136                 :            :     //= OLoadListenerAdapter
     137                 :            :     //=====================================================================
     138                 :            :     typedef ::cppu::WeakImplHelper1< ::com::sun::star::form::XLoadListener >    OLoadListenerAdapter_Base;
     139 [ #  # ][ #  # ]:          0 :     class OLoadListenerAdapter
     140                 :            :         :public OLoadListenerAdapter_Base
     141                 :            :         ,public OComponentAdapterBase
     142                 :            :     {
     143                 :            :     protected:
     144                 :          0 :         OLoadListener*      getLoadListener( )  { return static_cast< OLoadListener* >( getListener() ); }
     145                 :            : 
     146                 :            :     protected:
     147                 :            :         virtual void    disposing();
     148                 :            :         virtual void    startComponentListening();
     149                 :            : 
     150                 :            :     public:
     151                 :            :         OLoadListenerAdapter(
     152                 :            :             const ::com::sun::star::uno::Reference< ::com::sun::star::form::XLoadable >& _rxLoadable,
     153                 :            :             sal_Bool _bAutoRelease = sal_True
     154                 :            :         );
     155                 :            : 
     156                 :            : 
     157                 :            :         virtual void SAL_CALL acquire(  ) throw ();
     158                 :            :         virtual void SAL_CALL release(  ) throw ();
     159                 :            : 
     160                 :            :     protected:
     161                 :            :     // XEventListener
     162                 :            :         virtual void SAL_CALL disposing( const  ::com::sun::star::lang::EventObject& _rSource ) throw( ::com::sun::star::uno::RuntimeException);
     163                 :            : 
     164                 :            :     // XLoadListener
     165                 :            :         virtual void SAL_CALL loaded( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     166                 :            :         virtual void SAL_CALL unloading( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     167                 :            :         virtual void SAL_CALL unloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     168                 :            :         virtual void SAL_CALL reloading( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     169                 :            :         virtual void SAL_CALL reloaded( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     170                 :            :     };
     171                 :            : 
     172                 :            : //.........................................................................
     173                 :            : }   // namespace bib
     174                 :            : //.........................................................................
     175                 :            : 
     176                 :            : #endif // EXTENSIONS_BIB_LOADLISTENERADAPTER_HXX
     177                 :            : 
     178                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10