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/XPropertyChangeListener.hpp>
25 #include <com/sun/star/sdbc/XRowSetListener.hpp>
26 #include <connectivity/dbtoolsdllapi.hxx>
29 namespace com::sun::star::beans
{ class XPropertySet
; }
30 namespace com::sun::star::sdbc
{ class XRowSet
; }
31 namespace com::sun::star::sdbc
{ class XConnection
; }
37 //= OAutoConnectionDisposer
39 typedef ::cppu::WeakImplHelper
< css::beans::XPropertyChangeListener
,
40 css::sdbc::XRowSetListener
41 > OAutoConnectionDisposer_Base
;
43 class OOO_DLLPUBLIC_DBTOOLS OAutoConnectionDisposer final
: public OAutoConnectionDisposer_Base
45 css::uno::Reference
< css::sdbc::XConnection
>
46 m_xOriginalConnection
;
47 css::uno::Reference
< css::sdbc::XRowSet
> m_xRowSet
; // needed to add as listener
48 bool m_bRSListening
: 1; // true when we're listening on rowset
49 bool m_bPropertyListening
: 1; // true when we're listening for property changes
52 /** constructs an object
53 <p>The connection given will be set on the rowset (as ActiveConnection), and the object adds itself as property
54 change listener for the connection. Once somebody sets a new ActiveConnection, the old one (the one given
55 here) will be disposed.</p>
57 OAutoConnectionDisposer(
58 const css::uno::Reference
< css::sdbc::XRowSet
>& _rxRowSet
,
59 const css::uno::Reference
< css::sdbc::XConnection
>& _rxConnection
63 // XPropertyChangeListener
64 virtual void SAL_CALL
propertyChange( const css::beans::PropertyChangeEvent
& _rEvent
) override
;
67 virtual void SAL_CALL
disposing( const css::lang::EventObject
& _rSource
) override
;
70 virtual void SAL_CALL
cursorMoved( const css::lang::EventObject
& event
) override
;
71 virtual void SAL_CALL
rowChanged( const css::lang::EventObject
& event
) override
;
72 virtual void SAL_CALL
rowSetChanged( const css::lang::EventObject
& event
) override
;
74 void clearConnection();
76 void startRowSetListening();
77 void stopRowSetListening();
78 bool isRowSetListening() const { return m_bRSListening
; }
80 void startPropertyListening( const css::uno::Reference
< css::beans::XPropertySet
>& _rxProps
);
81 void stopPropertyListening( const css::uno::Reference
< css::beans::XPropertySet
>& _rxEventSource
);
85 } // namespace dbtools
88 #endif // INCLUDED_CONNECTIVITY_CONNCLEANUP_HXX
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */