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/implbase2.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>
35 //= OAutoConnectionDisposer
37 typedef ::cppu::WeakImplHelper2
< ::com::sun::star::beans::XPropertyChangeListener
,
38 ::com::sun::star::sdbc::XRowSetListener
39 > OAutoConnectionDisposer_Base
;
41 class OOO_DLLPUBLIC_DBTOOLS OAutoConnectionDisposer
: public OAutoConnectionDisposer_Base
43 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>
44 m_xOriginalConnection
;
45 ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
> m_xRowSet
; // needed to add as listener
46 bool m_bRSListening
: 1; // true when we're listening on rowset
47 bool m_bPropertyListening
: 1; // true when we're listening for property changes
50 /** constructs an object
51 <p>The connection given will be set on the rowset (as ActiveConnection), and the object adds itself as property
52 change listener for the connection. Once somebody sets a new ActiveConnection, the old one (the one given
53 here) will be disposed.</p>
55 OAutoConnectionDisposer(
56 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XRowSet
>& _rxRowSet
,
57 const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XConnection
>& _rxConnection
61 // XPropertyChangeListener
62 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& _rEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
65 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& _rSource
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
68 virtual void SAL_CALL
cursorMoved( const ::com::sun::star::lang::EventObject
& event
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
69 virtual void SAL_CALL
rowChanged( const ::com::sun::star::lang::EventObject
& event
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
70 virtual void SAL_CALL
rowSetChanged( const ::com::sun::star::lang::EventObject
& event
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
73 void clearConnection();
75 void startRowSetListening();
76 void stopRowSetListening();
77 bool isRowSetListening() const { return m_bRSListening
; }
79 void startPropertyListening( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxProps
);
80 void stopPropertyListening( const ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
>& _rxEventSource
);
81 bool isPropertyListening() const { return m_bPropertyListening
; }
85 } // namespace dbtools
88 #endif // INCLUDED_CONNECTIVITY_CONNCLEANUP_HXX
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */