LibreOffice Module forms (master) 1
errorbroadcaster.cxx
Go to the documentation of this file.
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"
22#include <sal/log.hxx>
23
24
25namespace 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
36 :m_rBHelper( _rBHelper )
37 ,m_aErrorListeners( _rBHelper.rMutex )
38 {
39 }
40
41
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 }
52
53
55 {
56 EventObject aDisposeEvent( static_cast< XSQLErrorBroadcaster* >( this ) );
57 m_aErrorListeners.disposeAndClear( aDisposeEvent );
58 }
59
60
61 void OErrorBroadcaster::onError( const SQLException& _rException, const OUString& _rContextDescription )
62 {
63 Any aError;
64 if ( !_rContextDescription.isEmpty() )
65 aError <<= prependErrorInfo( _rException, static_cast< XSQLErrorBroadcaster* >( this ), _rContextDescription );
66 else
67 aError <<= _rException;
68
69 onError( SQLErrorEvent( static_cast< XSQLErrorBroadcaster* >( this ), aError ) );
70 }
71
72
73 void OErrorBroadcaster::onError( const css::sdb::SQLErrorEvent& _rError )
74 {
75 m_aErrorListeners.notifyEach( &XSQLErrorListener::errorOccured, _rError );
76 }
77
78
79 void SAL_CALL OErrorBroadcaster::addSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener )
80 {
81 m_aErrorListeners.addInterface( _rxListener );
82 }
83
84
85 void SAL_CALL OErrorBroadcaster::removeSQLErrorListener( const Reference< XSQLErrorListener >& _rxListener )
86 {
88 }
89
90
91} // namespace frm
92
93
94/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 addInterface(const css::uno::Reference< ListenerT > &rxIFace)
void disposeAndClear(const css::lang::EventObject &rEvt)
sal_Int32 removeInterface(const css::uno::Reference< ListenerT > &rxIFace)
void notifyEach(void(SAL_CALL ListenerT::*NotificationMethod)(const EventT &), const EventT &Event)
::comphelper::OInterfaceContainerHelper3< css::sdb::XSQLErrorListener > m_aErrorListeners
virtual void SAL_CALL removeSQLErrorListener(const css::uno::Reference< css::sdb::XSQLErrorListener > &_rListener) override
::cppu::OBroadcastHelper & m_rBHelper
virtual void SAL_CALL addSQLErrorListener(const css::uno::Reference< css::sdb::XSQLErrorListener > &_rListener) override
void onError(const css::sdbc::SQLException &_rException, const OUString &_rContextDescription)
OErrorBroadcaster(::cppu::OBroadcastHelper &_rBHelper)
#define SAL_WARN_IF(condition, area, stream)
ListBox is a bit confusing / different from other form components, so here are a few notes:
Definition: BaseListBox.hxx:25