LCOV - code coverage report
Current view: top level - libreoffice/forms/source/richtext - featuredispatcher.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 53 0.0 %
Date: 2012-12-27 Functions: 0 12 0.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             : #include "featuredispatcher.hxx"
      21             : 
      22             : //........................................................................
      23             : namespace frm
      24             : {
      25             : //........................................................................
      26             : 
      27             :     using namespace ::com::sun::star::uno;
      28             :     using namespace ::com::sun::star::frame;
      29             :     using namespace ::com::sun::star::lang;
      30             :     using namespace ::com::sun::star::util;
      31             : 
      32             :     //====================================================================
      33             :     //= ORichTextFeatureDispatcher
      34             :     //====================================================================
      35             :     //--------------------------------------------------------------------
      36           0 :     ORichTextFeatureDispatcher::ORichTextFeatureDispatcher( EditView& _rView, const URL&  _rURL )
      37             :         :m_aFeatureURL( _rURL )
      38             :         ,m_aStatusListeners( m_aMutex )
      39             :         ,m_pEditView( &_rView )
      40           0 :         ,m_bDisposed( false )
      41             :     {
      42           0 :     }
      43             : 
      44             :     //--------------------------------------------------------------------
      45           0 :     ORichTextFeatureDispatcher::~ORichTextFeatureDispatcher( )
      46             :     {
      47           0 :         if ( !m_bDisposed )
      48             :         {
      49           0 :             acquire();
      50           0 :             dispose();
      51             :         }
      52           0 :     }
      53             : 
      54             :     //--------------------------------------------------------------------
      55           0 :     void ORichTextFeatureDispatcher::dispose()
      56             :     {
      57           0 :         EventObject aEvent( *this );
      58           0 :         m_aStatusListeners.disposeAndClear( aEvent );
      59             : 
      60           0 :         ::osl::ClearableMutexGuard aGuard( m_aMutex );
      61           0 :         m_bDisposed = true;
      62           0 :         disposing( aGuard );
      63           0 :     }
      64             : 
      65             :     //--------------------------------------------------------------------
      66           0 :     void ORichTextFeatureDispatcher::disposing( ::osl::ClearableMutexGuard& /*_rClearBeforeNotify*/ )
      67             :     {
      68           0 :         m_pEditView = NULL;
      69           0 :     }
      70             : 
      71             :     //--------------------------------------------------------------------
      72           0 :     void SAL_CALL ORichTextFeatureDispatcher::addStatusListener( const Reference< XStatusListener >& _rxControl, const URL& _rURL ) throw (RuntimeException)
      73             :     {
      74             :         OSL_ENSURE( !m_bDisposed, "ORichTextFeatureDispatcher::addStatusListener: already disposed!" );
      75           0 :         if ( m_bDisposed )
      76           0 :             throw DisposedException();
      77             : 
      78             :         OSL_ENSURE( _rURL.Complete == getFeatureURL().Complete, "ORichTextFeatureDispatcher::addStatusListener: invalid URL!" );
      79           0 :         if ( _rURL.Complete == getFeatureURL().Complete )
      80           0 :             if ( _rxControl.is() )
      81             :             {
      82           0 :                 m_aStatusListeners.addInterface( _rxControl );
      83           0 :                 newStatusListener( _rxControl );
      84             :             }
      85           0 :     }
      86             : 
      87             :     //--------------------------------------------------------------------
      88           0 :     void SAL_CALL ORichTextFeatureDispatcher::removeStatusListener( const Reference< XStatusListener >& _rxControl, const URL& /*_rURL*/ ) throw (RuntimeException)
      89             :     {
      90           0 :         m_aStatusListeners.removeInterface( _rxControl );
      91           0 :     }
      92             : 
      93             :     //--------------------------------------------------------------------
      94           0 :     void ORichTextFeatureDispatcher::invalidate()
      95             :     {
      96           0 :         invalidateFeatureState_Broadcast();
      97           0 :     }
      98             : 
      99             :     //--------------------------------------------------------------------
     100           0 :     FeatureStateEvent ORichTextFeatureDispatcher::buildStatusEvent() const
     101             :     {
     102           0 :         FeatureStateEvent aEvent;
     103           0 :         aEvent.IsEnabled = sal_False;
     104           0 :         aEvent.Source = *const_cast< ORichTextFeatureDispatcher* >( this );
     105           0 :         aEvent.FeatureURL = getFeatureURL();
     106           0 :         aEvent.Requery = sal_False;
     107           0 :         return aEvent;
     108             :     }
     109             : 
     110             :     //--------------------------------------------------------------------
     111           0 :     void ORichTextFeatureDispatcher::invalidateFeatureState_Broadcast()
     112             :     {
     113           0 :         FeatureStateEvent aEvent( buildStatusEvent() );
     114           0 :         ::cppu::OInterfaceIteratorHelper aIter( getStatusListeners() );
     115           0 :         while ( aIter.hasMoreElements() )
     116           0 :             doNotify( static_cast< XStatusListener* >( aIter.next() ), aEvent );
     117           0 :     }
     118             : 
     119             :     //--------------------------------------------------------------------
     120           0 :     void ORichTextFeatureDispatcher::newStatusListener( const Reference< XStatusListener >& _rxListener )
     121             :     {
     122           0 :         doNotify( _rxListener, buildStatusEvent() );
     123           0 :     }
     124             : 
     125             :     //--------------------------------------------------------------------
     126           0 :     void ORichTextFeatureDispatcher::doNotify( const Reference< XStatusListener >& _rxListener, const FeatureStateEvent& _rEvent ) const SAL_THROW(())
     127             :     {
     128             :         OSL_PRECOND( _rxListener.is(), "ORichTextFeatureDispatcher::doNotify: invalid listener!" );
     129           0 :         if ( _rxListener.is() )
     130             :         {
     131             :             try
     132             :             {
     133           0 :                 _rxListener->statusChanged( _rEvent );
     134             :             }
     135           0 :             catch( const Exception& )
     136             :             {
     137             :                 OSL_FAIL( "ORichTextFeatureDispatcher::doNotify: caught an exception!" );
     138             :             }
     139             :         }
     140           0 :     }
     141             : 
     142             : //........................................................................
     143             : }   // namespace frm
     144             : //........................................................................
     145             : 
     146             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10