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

Generated by: LCOV version 1.11