bump product version to 4.1.6.2
[LibreOffice.git] / forms / source / component / errorbroadcaster.cxx
blobf9a010ba112fceb66bad04bae9f1c38535aa328a
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>
24 //.........................................................................
25 namespace frm
27 //.........................................................................
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 //=====================================================================
36 //= OErrorBroadcaster
37 //=====================================================================
38 //---------------------------------------------------------------------
39 OErrorBroadcaster::OErrorBroadcaster( ::cppu::OBroadcastHelper& _rBHelper )
40 :m_rBHelper( _rBHelper )
41 ,m_aErrorListeners( _rBHelper.rMutex )
45 //---------------------------------------------------------------------
46 OErrorBroadcaster::~OErrorBroadcaster( )
48 SAL_WARN_IF( !m_rBHelper.bDisposed && !m_rBHelper.bInDispose, "forms.component",
49 "OErrorBroadcaster::~OErrorBroadcaster: not disposed!" );
50 // herein, we don't have a chance to do the dispose ourself ....
52 SAL_WARN_IF( m_aErrorListeners.getLength(), "forms.component",
53 "OErrorBroadcaster::~OErrorBroadcaster: still have listeners!" );
54 // either we're not disposed, or the derived class did not call our dispose from within their dispose
57 //---------------------------------------------------------------------
58 void SAL_CALL OErrorBroadcaster::disposing()
60 EventObject aDisposeEvent( static_cast< XSQLErrorBroadcaster* >( this ) );
61 m_aErrorListeners.disposeAndClear( aDisposeEvent );
64 //------------------------------------------------------------------------------
65 void SAL_CALL OErrorBroadcaster::onError( const SQLException& _rException, const OUString& _rContextDescription )
67 Any aError;
68 if ( !_rContextDescription.isEmpty() )
69 aError = makeAny( prependErrorInfo( _rException, static_cast< XSQLErrorBroadcaster* >( this ), _rContextDescription ) );
70 else
71 aError = makeAny( _rException );
73 onError( SQLErrorEvent( static_cast< XSQLErrorBroadcaster* >( this ), aError ) );
76 //------------------------------------------------------------------------------
77 void SAL_CALL OErrorBroadcaster::onError( const ::com::sun::star::sdb::SQLErrorEvent& _rError )
79 if ( m_aErrorListeners.getLength() )
82 ::cppu::OInterfaceIteratorHelper aIter( m_aErrorListeners );
83 while ( aIter.hasMoreElements() )
84 static_cast< XSQLErrorListener* >( aIter.next() )->errorOccured( _rError );
88 //------------------------------------------------------------------------------
89 void SAL_CALL OErrorBroadcaster::addSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException )
91 m_aErrorListeners.addInterface( _rxListener );
94 //------------------------------------------------------------------------------
95 void SAL_CALL OErrorBroadcaster::removeSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException )
97 m_aErrorListeners.removeInterface( _rxListener );
100 //.........................................................................
101 } // namespace frm
102 //.........................................................................
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */