merge the formfield patch from ooo-build
[ooovba.git] / forms / source / component / errorbroadcaster.cxx
blobf77eca0df9fd892bfa1dce77244e99555e7be9c3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: errorbroadcaster.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_forms.hxx"
33 #include "errorbroadcaster.hxx"
34 #include <connectivity/dbtools.hxx>
35 #include <com/sun/star/sdb/SQLContext.hpp>
37 //.........................................................................
38 namespace frm
40 //.........................................................................
42 using namespace ::com::sun::star::uno;
43 using namespace ::com::sun::star::lang;
44 using namespace ::com::sun::star::sdbc;
45 using namespace ::com::sun::star::sdb;
46 using namespace ::dbtools;
48 //=====================================================================
49 //= OErrorBroadcaster
50 //=====================================================================
51 //---------------------------------------------------------------------
52 OErrorBroadcaster::OErrorBroadcaster( ::cppu::OBroadcastHelper& _rBHelper )
53 :m_rBHelper( _rBHelper )
54 ,m_aErrorListeners( _rBHelper.rMutex )
58 //---------------------------------------------------------------------
59 OErrorBroadcaster::~OErrorBroadcaster( )
61 OSL_ENSURE( m_rBHelper.bDisposed || m_rBHelper.bInDispose,
62 "OErrorBroadcaster::~OErrorBroadcaster: not disposed!" );
63 // herein, we don't have a chance to do the dispose ourself ....
65 OSL_ENSURE( 0 == m_aErrorListeners.getLength(),
66 "OErrorBroadcaster::~OErrorBroadcaster: still have listeners!" );
67 // either we're not disposed, or the derived class did not call our dispose from within their dispose
70 //---------------------------------------------------------------------
71 void SAL_CALL OErrorBroadcaster::disposing()
73 EventObject aDisposeEvent( static_cast< XSQLErrorBroadcaster* >( this ) );
74 m_aErrorListeners.disposeAndClear( aDisposeEvent );
77 //------------------------------------------------------------------------------
78 void SAL_CALL OErrorBroadcaster::onError( const SQLException& _rException, const ::rtl::OUString& _rContextDescription )
80 Any aError;
81 if ( _rContextDescription.getLength() )
82 aError = makeAny( prependErrorInfo( _rException, static_cast< XSQLErrorBroadcaster* >( this ), _rContextDescription ) );
83 else
84 aError = makeAny( _rException );
86 onError( SQLErrorEvent( static_cast< XSQLErrorBroadcaster* >( this ), aError ) );
89 //------------------------------------------------------------------------------
90 void SAL_CALL OErrorBroadcaster::onError( const ::com::sun::star::sdb::SQLErrorEvent& _rError )
92 if ( m_aErrorListeners.getLength() )
95 ::cppu::OInterfaceIteratorHelper aIter( m_aErrorListeners );
96 while ( aIter.hasMoreElements() )
97 static_cast< XSQLErrorListener* >( aIter.next() )->errorOccured( _rError );
101 //------------------------------------------------------------------------------
102 void SAL_CALL OErrorBroadcaster::addSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException )
104 m_aErrorListeners.addInterface( _rxListener );
107 //------------------------------------------------------------------------------
108 void SAL_CALL OErrorBroadcaster::removeSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener ) throw( RuntimeException )
110 m_aErrorListeners.removeInterface( _rxListener );
113 //.........................................................................
114 } // namespace frm
115 //.........................................................................