Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/connectivity/conncleanup.hxx
Line
Count
Source
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
#pragma once
21
22
#include <cppuhelper/implbase.hxx>
23
#include <com/sun/star/beans/XPropertyChangeListener.hpp>
24
#include <com/sun/star/sdbc/XRowSetListener.hpp>
25
#include <connectivity/dbtoolsdllapi.hxx>
26
27
28
namespace com::sun::star::beans { class XPropertySet; }
29
namespace com::sun::star::sdbc { class XRowSet; }
30
namespace com::sun::star::sdbc { class XConnection; }
31
32
namespace dbtools
33
{
34
35
36
    //= OAutoConnectionDisposer
37
38
    typedef ::cppu::WeakImplHelper <   css::beans::XPropertyChangeListener,
39
                                       css::sdbc::XRowSetListener
40
                                   >   OAutoConnectionDisposer_Base;
41
42
    class OOO_DLLPUBLIC_DBTOOLS OAutoConnectionDisposer final : public OAutoConnectionDisposer_Base
43
    {
44
        css::uno::Reference< css::sdbc::XConnection >
45
                    m_xOriginalConnection;
46
        css::uno::Reference< css::sdbc::XRowSet > m_xRowSet; // needed to add as listener
47
        bool    m_bRSListening          : 1; // true when we're listening on rowset
48
        bool    m_bPropertyListening    : 1; // true when we're listening for property changes
49
50
    public:
51
        /** constructs an object
52
            <p>The connection given will be set on the rowset (as ActiveConnection), and the object adds itself as property
53
            change listener for the connection. Once somebody sets a new ActiveConnection, the old one (the one given
54
            here) will be disposed.</p>
55
        */
56
        OAutoConnectionDisposer(
57
            const css::uno::Reference< css::sdbc::XRowSet >& _rxRowSet,
58
            const css::uno::Reference< css::sdbc::XConnection >& _rxConnection
59
            );
60
61
    private:
62
        // XPropertyChangeListener
63
        virtual void SAL_CALL propertyChange( const css::beans::PropertyChangeEvent& _rEvent ) override;
64
65
        // XEventListener
66
        virtual void SAL_CALL disposing( const css::lang::EventObject& _rSource ) override;
67
68
        // XRowSetListener
69
        virtual void SAL_CALL cursorMoved( const css::lang::EventObject& event ) override;
70
        virtual void SAL_CALL rowChanged( const css::lang::EventObject& event ) override;
71
        virtual void SAL_CALL rowSetChanged( const css::lang::EventObject& event ) override;
72
73
        void clearConnection();
74
75
        void        startRowSetListening();
76
        void        stopRowSetListening();
77
0
        bool        isRowSetListening() const { return m_bRSListening; }
78
79
        void        startPropertyListening( const css::uno::Reference< css::beans::XPropertySet >& _rxProps );
80
        void        stopPropertyListening( const css::uno::Reference< css::beans::XPropertySet >& _rxEventSource );
81
    };
82
83
84
}   // namespace dbtools
85
86
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */