LCOV - code coverage report
Current view: top level - forms/source/component - errorbroadcaster.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 15 28 53.6 %
Date: 2012-08-25 Functions: 5 8 62.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 7 46 15.2 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "errorbroadcaster.hxx"
      30                 :            : #include <connectivity/dbtools.hxx>
      31                 :            : #include <com/sun/star/sdb/SQLContext.hpp>
      32                 :            : 
      33                 :            : //.........................................................................
      34                 :            : namespace frm
      35                 :            : {
      36                 :            : //.........................................................................
      37                 :            : 
      38                 :            :     using namespace ::com::sun::star::uno;
      39                 :            :     using namespace ::com::sun::star::lang;
      40                 :            :     using namespace ::com::sun::star::sdbc;
      41                 :            :     using namespace ::com::sun::star::sdb;
      42                 :            :     using namespace ::dbtools;
      43                 :            : 
      44                 :            :     //=====================================================================
      45                 :            :     //= OErrorBroadcaster
      46                 :            :     //=====================================================================
      47                 :            :     //---------------------------------------------------------------------
      48                 :         95 :     OErrorBroadcaster::OErrorBroadcaster( ::cppu::OBroadcastHelper& _rBHelper )
      49                 :            :         :m_rBHelper( _rBHelper )
      50         [ +  - ]:         95 :         ,m_aErrorListeners( _rBHelper.rMutex )
      51                 :            :     {
      52                 :         95 :     }
      53                 :            : 
      54                 :            :     //---------------------------------------------------------------------
      55         [ +  - ]:         91 :     OErrorBroadcaster::~OErrorBroadcaster( )
      56                 :            :     {
      57                 :            :         OSL_ENSURE( m_rBHelper.bDisposed || m_rBHelper.bInDispose,
      58                 :            :             "OErrorBroadcaster::~OErrorBroadcaster: not disposed!" );
      59                 :            :         // herein, we don't have a chance to do the dispose ourself ....
      60                 :            : 
      61                 :            :         OSL_ENSURE( 0 == m_aErrorListeners.getLength(),
      62                 :            :             "OErrorBroadcaster::~OErrorBroadcaster: still have listeners!" );
      63                 :            :         // either we're not disposed, or the derived class did not call our dispose from within their dispose
      64         [ -  + ]:         91 :     }
      65                 :            : 
      66                 :            :     //---------------------------------------------------------------------
      67                 :         91 :     void SAL_CALL OErrorBroadcaster::disposing()
      68                 :            :     {
      69 [ +  - ][ +  - ]:         91 :         EventObject aDisposeEvent( static_cast< XSQLErrorBroadcaster* >( this ) );
      70 [ +  - ][ +  - ]:         91 :         m_aErrorListeners.disposeAndClear( aDisposeEvent );
      71                 :         91 :     }
      72                 :            : 
      73                 :            :     //------------------------------------------------------------------------------
      74                 :          0 :     void SAL_CALL OErrorBroadcaster::onError( const SQLException& _rException, const ::rtl::OUString& _rContextDescription )
      75                 :            :     {
      76                 :          0 :         Any aError;
      77         [ #  # ]:          0 :         if ( !_rContextDescription.isEmpty() )
      78 [ #  # ][ #  # ]:          0 :             aError = makeAny( prependErrorInfo( _rException, static_cast< XSQLErrorBroadcaster* >( this ), _rContextDescription ) );
         [ #  # ][ #  # ]
      79                 :            :         else
      80         [ #  # ]:          0 :             aError = makeAny( _rException );
      81                 :            : 
      82 [ #  # ][ #  # ]:          0 :         onError( SQLErrorEvent( static_cast< XSQLErrorBroadcaster* >( this ), aError ) );
         [ #  # ][ #  # ]
      83                 :          0 :     }
      84                 :            : 
      85                 :            :     //------------------------------------------------------------------------------
      86                 :          0 :     void SAL_CALL OErrorBroadcaster::onError( const ::com::sun::star::sdb::SQLErrorEvent& _rError )
      87                 :            :     {
      88         [ #  # ]:          0 :         if ( m_aErrorListeners.getLength() )
      89                 :            :         {
      90                 :            : 
      91         [ #  # ]:          0 :             ::cppu::OInterfaceIteratorHelper aIter( m_aErrorListeners );
      92         [ #  # ]:          0 :             while ( aIter.hasMoreElements() )
      93 [ #  # ][ #  # ]:          0 :                 static_cast< XSQLErrorListener* >( aIter.next() )->errorOccured( _rError );
                 [ #  # ]
      94                 :            :         }
      95                 :          0 :     }
      96                 :            : 
      97                 :            :     //------------------------------------------------------------------------------
      98                 :         78 :     void SAL_CALL OErrorBroadcaster::addSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException )
      99                 :            :     {
     100                 :         78 :         m_aErrorListeners.addInterface( _rxListener );
     101                 :         78 :     }
     102                 :            : 
     103                 :            :     //------------------------------------------------------------------------------
     104                 :         42 :     void SAL_CALL OErrorBroadcaster::removeSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException )
     105                 :            :     {
     106                 :         42 :         m_aErrorListeners.removeInterface( _rxListener );
     107                 :         42 :     }
     108                 :            : 
     109                 :            : //.........................................................................
     110                 :            : }   // namespace frm
     111                 :            : //.........................................................................
     112                 :            : 
     113                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10