1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_CONNECTIVITY_CONNCLEANUP_HXX
21 #define INCLUDED_CONNECTIVITY_CONNCLEANUP_HXX
23 #include <cppuhelper/implbase.hxx>
24 #include <com/sun/star/beans/XPropertySet.hpp>
25 #include <com/sun/star/sdbc/XRowSet.hpp>
26 #include <com/sun/star/sdbc/XConnection.hpp>
27 #include <connectivity/dbtoolsdllapi.hxx>
34 //= OAutoConnectionDisposer
36 typedef ::cppu::WeakImplHelper
< css::beans::XPropertyChangeListener
,
37 css::sdbc::XRowSetListener
38 > OAutoConnectionDisposer_Base
;
40 class OOO_DLLPUBLIC_DBTOOLS OAutoConnectionDisposer
: public OAutoConnectionDisposer_Base
42 css::uno::Reference
< css::sdbc::XConnection
>
43 m_xOriginalConnection
;
44 css::uno::Reference
< css::sdbc::XRowSet
> m_xRowSet
; // needed to add as listener
45 bool m_bRSListening
: 1; // true when we're listening on rowset
46 bool m_bPropertyListening
: 1; // true when we're listening for property changes
49 /** constructs an object
50 <p>The connection given will be set on the rowset (as ActiveConnection), and the object adds itself as property
51 change listener for the connection. Once somebody sets a new ActiveConnection, the old one (the one given
52 here) will be disposed.</p>
54 OAutoConnectionDisposer(
55 const css::uno::Reference
< css::sdbc::XRowSet
>& _rxRowSet
,
56 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
60 // XPropertyChangeListener
61 virtual void SAL_CALL
propertyChange( const css::beans::PropertyChangeEvent
& _rEvent
) throw (css::uno::RuntimeException
, std::exception
) override
;
64 virtual void SAL_CALL
disposing( const css::lang::EventObject
& _rSource
) throw (css::uno::RuntimeException
, std::exception
) override
;
67 virtual void SAL_CALL
cursorMoved( const css::lang::EventObject
& event
) throw (css::uno::RuntimeException
, std::exception
) override
;
68 virtual void SAL_CALL
rowChanged( const css::lang::EventObject
& event
) throw (css::uno::RuntimeException
, std::exception
) override
;
69 virtual void SAL_CALL
rowSetChanged( const css::lang::EventObject
& event
) throw (css::uno::RuntimeException
, std::exception
) override
;
72 void clearConnection();
74 void startRowSetListening();
75 void stopRowSetListening();
76 bool isRowSetListening() const { return m_bRSListening
; }
78 void startPropertyListening( const css::uno::Reference
< css::beans::XPropertySet
>& _rxProps
);
79 void stopPropertyListening( const css::uno::Reference
< css::beans::XPropertySet
>& _rxEventSource
);
83 } // namespace dbtools
86 #endif // INCLUDED_CONNECTIVITY_CONNCLEANUP_HXX
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */