bump product version to 5.0.4.1
[LibreOffice.git] / forms / source / component / errorbroadcaster.cxx
blob2d1bfe4707d7e4a0bca4d65e3d253a9703d7adf2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "errorbroadcaster.hxx"
21 #include <connectivity/dbtools.hxx>
22 #include <com/sun/star/sdb/SQLContext.hpp>
25 namespace frm
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;
35 OErrorBroadcaster::OErrorBroadcaster( ::cppu::OBroadcastHelper& _rBHelper )
36 :m_rBHelper( _rBHelper )
37 ,m_aErrorListeners( _rBHelper.rMutex )
42 OErrorBroadcaster::~OErrorBroadcaster( )
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 ....
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
54 void SAL_CALL OErrorBroadcaster::disposing()
56 EventObject aDisposeEvent( static_cast< XSQLErrorBroadcaster* >( this ) );
57 m_aErrorListeners.disposeAndClear( aDisposeEvent );
61 void SAL_CALL OErrorBroadcaster::onError( const SQLException& _rException, const OUString& _rContextDescription )
63 Any aError;
64 if ( !_rContextDescription.isEmpty() )
65 aError = makeAny( prependErrorInfo( _rException, static_cast< XSQLErrorBroadcaster* >( this ), _rContextDescription ) );
66 else
67 aError = makeAny( _rException );
69 onError( SQLErrorEvent( static_cast< XSQLErrorBroadcaster* >( this ), aError ) );
73 void SAL_CALL OErrorBroadcaster::onError( const ::com::sun::star::sdb::SQLErrorEvent& _rError )
75 if ( m_aErrorListeners.getLength() )
78 ::cppu::OInterfaceIteratorHelper aIter( m_aErrorListeners );
79 while ( aIter.hasMoreElements() )
80 static_cast< XSQLErrorListener* >( aIter.next() )->errorOccured( _rError );
85 void SAL_CALL OErrorBroadcaster::addSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException, std::exception )
87 m_aErrorListeners.addInterface( _rxListener );
91 void SAL_CALL OErrorBroadcaster::removeSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException, std::exception )
93 m_aErrorListeners.removeInterface( _rxListener );
97 } // namespace frm
100 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */