Coverage Report

Created: 2026-09-28 10:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/UnoControls/source/base/multiplexer.cxx
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
#include <multiplexer.hxx>
21
22
#include <osl/diagnose.h>
23
#include <cppuhelper/queryinterface.hxx>
24
25
using namespace ::cppu;
26
using namespace ::osl;
27
using namespace ::com::sun::star::uno;
28
using namespace ::com::sun::star::awt;
29
using namespace ::com::sun::star::lang;
30
31
namespace unocontrols {
32
33
template <class Interface, typename Event>
34
void OMRCListenerMultiplexerHelper::Multiplex(void (SAL_CALL Interface::*method)(const Event&),
35
                                              const Event& event)
36
0
{
37
0
    std::unique_lock aGuard(m_aMutex);
38
0
    Event aLocalEvent = event;
39
    /* Remark: The control is the event source not the peer.*/
40
    /*         We must change the source of the event.      */
41
0
    aLocalEvent.Source = m_xControl;
42
    /* Is the control not destroyed? */
43
0
    if (!aLocalEvent.Source)
44
0
        return;
45
0
    Listeners<Interface>::list.notifyEach(aGuard, method, aLocalEvent);
46
0
}
Unexecuted instantiation: void unocontrols::OMRCListenerMultiplexerHelper::Multiplex<com::sun::star::awt::XFocusListener, com::sun::star::awt::FocusEvent>(void (com::sun::star::awt::XFocusListener::*)(com::sun::star::awt::FocusEvent const&), com::sun::star::awt::FocusEvent const&)
Unexecuted instantiation: void unocontrols::OMRCListenerMultiplexerHelper::Multiplex<com::sun::star::awt::XWindowListener, com::sun::star::awt::WindowEvent>(void (com::sun::star::awt::XWindowListener::*)(com::sun::star::awt::WindowEvent const&), com::sun::star::awt::WindowEvent const&)
Unexecuted instantiation: void unocontrols::OMRCListenerMultiplexerHelper::Multiplex<com::sun::star::awt::XWindowListener, com::sun::star::lang::EventObject>(void (com::sun::star::awt::XWindowListener::*)(com::sun::star::lang::EventObject const&), com::sun::star::lang::EventObject const&)
Unexecuted instantiation: void unocontrols::OMRCListenerMultiplexerHelper::Multiplex<com::sun::star::awt::XKeyListener, com::sun::star::awt::KeyEvent>(void (com::sun::star::awt::XKeyListener::*)(com::sun::star::awt::KeyEvent const&), com::sun::star::awt::KeyEvent const&)
Unexecuted instantiation: void unocontrols::OMRCListenerMultiplexerHelper::Multiplex<com::sun::star::awt::XMouseListener, com::sun::star::awt::MouseEvent>(void (com::sun::star::awt::XMouseListener::*)(com::sun::star::awt::MouseEvent const&), com::sun::star::awt::MouseEvent const&)
Unexecuted instantiation: void unocontrols::OMRCListenerMultiplexerHelper::Multiplex<com::sun::star::awt::XMouseMotionListener, com::sun::star::awt::MouseEvent>(void (com::sun::star::awt::XMouseMotionListener::*)(com::sun::star::awt::MouseEvent const&), com::sun::star::awt::MouseEvent const&)
Unexecuted instantiation: void unocontrols::OMRCListenerMultiplexerHelper::Multiplex<com::sun::star::awt::XPaintListener, com::sun::star::awt::PaintEvent>(void (com::sun::star::awt::XPaintListener::*)(com::sun::star::awt::PaintEvent const&), com::sun::star::awt::PaintEvent const&)
47
48
//  construct/destruct
49
50
OMRCListenerMultiplexerHelper::OMRCListenerMultiplexerHelper(   const   Reference< XWindow >&   xControl    ,
51
                                                                const   Reference< XWindow >&   xPeer       )
52
0
    : m_xPeer           ( xPeer     )
53
0
    , m_xControl        ( xControl  )
54
0
{
55
0
}
Unexecuted instantiation: unocontrols::OMRCListenerMultiplexerHelper::OMRCListenerMultiplexerHelper(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&, com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)
Unexecuted instantiation: unocontrols::OMRCListenerMultiplexerHelper::OMRCListenerMultiplexerHelper(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&, com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)
56
57
OMRCListenerMultiplexerHelper::~OMRCListenerMultiplexerHelper()
58
0
{
59
0
}
60
61
//  container method
62
63
void OMRCListenerMultiplexerHelper::setPeer( const Reference< XWindow >& xPeer )
64
0
{
65
0
    std::unique_lock aGuard(m_aMutex);
66
0
    if( m_xPeer == xPeer )
67
0
        return;
68
69
0
    if( m_xPeer.is() )
70
0
    {
71
0
        for_each_container(
72
0
            [this, &aGuard]<class Ifc>(const comphelper::OInterfaceContainerHelper4<Ifc>& c)
73
0
            {
74
0
                if (c.getLength(aGuard) > 0)
75
0
                    notifyPeer(m_xPeer, Remove<Ifc>);
76
0
            });
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_0::operator()<com::sun::star::awt::XFocusListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XFocusListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_0::operator()<com::sun::star::awt::XWindowListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XWindowListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_0::operator()<com::sun::star::awt::XKeyListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XKeyListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_0::operator()<com::sun::star::awt::XMouseListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XMouseListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_0::operator()<com::sun::star::awt::XMouseMotionListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XMouseMotionListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_0::operator()<com::sun::star::awt::XPaintListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XPaintListener> const&) const
77
0
    }
78
0
    m_xPeer = xPeer;
79
0
    if( m_xPeer.is() )
80
0
    {
81
0
        for_each_container(
82
0
            [this, &aGuard]<class Ifc>(const comphelper::OInterfaceContainerHelper4<Ifc>& c)
83
0
            {
84
0
                if (c.getLength(aGuard) > 0)
85
0
                    notifyPeer(m_xPeer, Add<Ifc>);
86
0
            });
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_1::operator()<com::sun::star::awt::XFocusListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XFocusListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_1::operator()<com::sun::star::awt::XWindowListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XWindowListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_1::operator()<com::sun::star::awt::XKeyListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XKeyListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_1::operator()<com::sun::star::awt::XMouseListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XMouseListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_1::operator()<com::sun::star::awt::XMouseMotionListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XMouseMotionListener> const&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::setPeer(com::sun::star::uno::Reference<com::sun::star::awt::XWindow> const&)::$_1::operator()<com::sun::star::awt::XPaintListener>(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XPaintListener> const&) const
87
0
    }
88
0
}
89
90
//  container method
91
92
void OMRCListenerMultiplexerHelper::disposeAndClear()
93
0
{
94
0
    std::unique_lock aGuard(m_aMutex);
95
0
    EventObject aEvent;
96
0
    aEvent.Source = m_xControl;
97
0
    for_each_container([&aGuard, &aEvent](auto& c) { c.disposeAndClear(aGuard, aEvent); });
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::disposeAndClear()::$_0::operator()<comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XFocusListener> >(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XFocusListener>&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::disposeAndClear()::$_0::operator()<comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XWindowListener> >(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XWindowListener>&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::disposeAndClear()::$_0::operator()<comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XKeyListener> >(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XKeyListener>&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::disposeAndClear()::$_0::operator()<comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XMouseListener> >(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XMouseListener>&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::disposeAndClear()::$_0::operator()<comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XMouseMotionListener> >(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XMouseMotionListener>&) const
Unexecuted instantiation: multiplexer.cxx:auto unocontrols::OMRCListenerMultiplexerHelper::disposeAndClear()::$_0::operator()<comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XPaintListener> >(comphelper::OInterfaceContainerHelper4<com::sun::star::awt::XPaintListener>&) const
98
0
}
99
100
//  XEventListener
101
102
void SAL_CALL OMRCListenerMultiplexerHelper::disposing( const EventObject& /*aSource*/ )
103
0
{
104
0
    std::unique_lock aGuard(m_aMutex);
105
    // peer is disposed, clear the reference
106
0
    m_xPeer.clear();
107
0
}
108
109
//  XFcousListener
110
111
void OMRCListenerMultiplexerHelper::focusGained(const FocusEvent& aEvent )
112
0
{
113
0
    Multiplex(&XFocusListener::focusGained, aEvent);
114
0
}
115
116
//  XFcousListener
117
118
void OMRCListenerMultiplexerHelper::focusLost(const FocusEvent& aEvent )
119
0
{
120
0
    Multiplex(&XFocusListener::focusLost, aEvent);
121
0
}
122
123
//  XWindowListener
124
125
void OMRCListenerMultiplexerHelper::windowResized(const WindowEvent& aEvent )
126
0
{
127
0
    Multiplex(&XWindowListener::windowResized, aEvent);
128
0
}
129
130
//  XWindowListener
131
132
void OMRCListenerMultiplexerHelper::windowMoved(const WindowEvent& aEvent )
133
0
{
134
0
    Multiplex(&XWindowListener::windowMoved, aEvent);
135
0
}
136
137
//  XWindowListener
138
139
void OMRCListenerMultiplexerHelper::windowShown(const EventObject& aEvent )
140
0
{
141
0
    Multiplex(&XWindowListener::windowShown, aEvent);
142
0
}
143
144
//  XWindowListener
145
146
void OMRCListenerMultiplexerHelper::windowHidden(const EventObject& aEvent )
147
0
{
148
0
    Multiplex(&XWindowListener::windowHidden, aEvent);
149
0
}
150
151
//  XKeyListener
152
153
void OMRCListenerMultiplexerHelper::keyPressed(const KeyEvent& aEvent)
154
0
{
155
0
    Multiplex(&XKeyListener::keyPressed, aEvent);
156
0
}
157
158
//  XKeyListener
159
160
void OMRCListenerMultiplexerHelper::keyReleased(const KeyEvent& aEvent)
161
0
{
162
0
    Multiplex(&XKeyListener::keyReleased, aEvent);
163
0
}
164
165
//  XMouseListener
166
167
void OMRCListenerMultiplexerHelper::mousePressed(const MouseEvent& aEvent)
168
0
{
169
0
    Multiplex(&XMouseListener::mousePressed, aEvent);
170
0
}
171
172
//  XMouseListener
173
174
void OMRCListenerMultiplexerHelper::mouseReleased(const MouseEvent& aEvent)
175
0
{
176
0
    Multiplex(&XMouseListener::mouseReleased, aEvent);
177
0
}
178
179
//  XMouseListener
180
181
void OMRCListenerMultiplexerHelper::mouseEntered(const MouseEvent& aEvent)
182
0
{
183
0
    Multiplex(&XMouseListener::mouseEntered, aEvent);
184
0
}
185
186
//  XMouseListener
187
188
void OMRCListenerMultiplexerHelper::mouseExited(const MouseEvent& aEvent)
189
0
{
190
0
    Multiplex(&XMouseListener::mouseExited, aEvent);
191
0
}
192
193
//  XMouseMotionListener
194
195
void OMRCListenerMultiplexerHelper::mouseDragged(const MouseEvent& aEvent)
196
0
{
197
0
    Multiplex(&XMouseMotionListener::mouseDragged, aEvent);
198
0
}
199
200
//  XMouseMotionListener
201
202
void OMRCListenerMultiplexerHelper::mouseMoved(const MouseEvent& aEvent)
203
0
{
204
0
    Multiplex(&XMouseMotionListener::mouseMoved, aEvent);
205
0
}
206
207
//  XPaintListener
208
209
void OMRCListenerMultiplexerHelper::windowPaint(const PaintEvent& aEvent)
210
0
{
211
0
    Multiplex(&XPaintListener::windowPaint, aEvent);
212
0
}
213
214
} // namespace unocontrols
215
216
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */