LCOV - code coverage report
Current view: top level - forms/source/component - errorbroadcaster.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 15 28 53.6 %
Date: 2015-06-13 12:38:46 Functions: 5 8 62.5 %
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 "errorbroadcaster.hxx"
      21             : #include <connectivity/dbtools.hxx>
      22             : #include <com/sun/star/sdb/SQLContext.hpp>
      23             : 
      24             : 
      25             : namespace frm
      26             : {
      27             : 
      28             : 
      29             :     using namespace ::com::sun::star::uno;
      30             :     using namespace ::com::sun::star::lang;
      31             :     using namespace ::com::sun::star::sdbc;
      32             :     using namespace ::com::sun::star::sdb;
      33             :     using namespace ::dbtools;
      34             : 
      35          81 :     OErrorBroadcaster::OErrorBroadcaster( ::cppu::OBroadcastHelper& _rBHelper )
      36             :         :m_rBHelper( _rBHelper )
      37          81 :         ,m_aErrorListeners( _rBHelper.rMutex )
      38             :     {
      39          81 :     }
      40             : 
      41             : 
      42          75 :     OErrorBroadcaster::~OErrorBroadcaster( )
      43             :     {
      44             :         SAL_WARN_IF( !m_rBHelper.bDisposed && !m_rBHelper.bInDispose, "forms.component",
      45             :             "OErrorBroadcaster::~OErrorBroadcaster: not disposed!" );
      46             :         // herein, we don't have a chance to do the dispose ourself ....
      47             : 
      48             :         SAL_WARN_IF( m_aErrorListeners.getLength(), "forms.component",
      49             :             "OErrorBroadcaster::~OErrorBroadcaster: still have listeners!" );
      50             :         // either we're not disposed, or the derived class did not call our dispose from within their dispose
      51          75 :     }
      52             : 
      53             : 
      54          75 :     void SAL_CALL OErrorBroadcaster::disposing()
      55             :     {
      56          75 :         EventObject aDisposeEvent( static_cast< XSQLErrorBroadcaster* >( this ) );
      57          75 :         m_aErrorListeners.disposeAndClear( aDisposeEvent );
      58          75 :     }
      59             : 
      60             : 
      61           0 :     void SAL_CALL OErrorBroadcaster::onError( const SQLException& _rException, const OUString& _rContextDescription )
      62             :     {
      63           0 :         Any aError;
      64           0 :         if ( !_rContextDescription.isEmpty() )
      65           0 :             aError = makeAny( prependErrorInfo( _rException, static_cast< XSQLErrorBroadcaster* >( this ), _rContextDescription ) );
      66             :         else
      67           0 :             aError = makeAny( _rException );
      68             : 
      69           0 :         onError( SQLErrorEvent( static_cast< XSQLErrorBroadcaster* >( this ), aError ) );
      70           0 :     }
      71             : 
      72             : 
      73           0 :     void SAL_CALL OErrorBroadcaster::onError( const ::com::sun::star::sdb::SQLErrorEvent& _rError )
      74             :     {
      75           0 :         if ( m_aErrorListeners.getLength() )
      76             :         {
      77             : 
      78           0 :             ::cppu::OInterfaceIteratorHelper aIter( m_aErrorListeners );
      79           0 :             while ( aIter.hasMoreElements() )
      80           0 :                 static_cast< XSQLErrorListener* >( aIter.next() )->errorOccured( _rError );
      81             :         }
      82           0 :     }
      83             : 
      84             : 
      85          62 :     void SAL_CALL OErrorBroadcaster::addSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException, std::exception )
      86             :     {
      87          62 :         m_aErrorListeners.addInterface( _rxListener );
      88          62 :     }
      89             : 
      90             : 
      91          42 :     void SAL_CALL OErrorBroadcaster::removeSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException, std::exception )
      92             :     {
      93          42 :         m_aErrorListeners.removeInterface( _rxListener );
      94          42 :     }
      95             : 
      96             : 
      97             : }   // namespace frm
      98             : 
      99             : 
     100             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11