LibreOffice Module chart2 (master) 1
WeakListenerAdapter.hxx
Go to the documentation of this file.
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#pragma once
20
21#include <com/sun/star/lang/XEventListener.hpp>
22#include <com/sun/star/view/XSelectionChangeListener.hpp>
25
26namespace chart
27{
28
41template< class Listener >
42 class WeakListenerAdapter : public
43 ::cppu::WeakImplHelper< Listener >
44{
45public:
46 explicit WeakListenerAdapter( const css::uno::Reference< Listener > & xListener ) :
47 m_xListener( xListener )
48 {}
49
50protected:
51 // ____ XEventListener (base of all listeners) ____
52 virtual void SAL_CALL disposing(
53 const css::lang::EventObject& Source ) override
54 {
55 css::uno::Reference< css::lang::XEventListener > xEventListener(
56 css::uno::Reference< Listener >( m_xListener), css::uno::UNO_QUERY );
57 if( xEventListener.is())
58 xEventListener->disposing( Source );
59 }
60
61 css::uno::Reference< Listener > getListener() const
62 {
63 return m_xListener;
64 }
65
66private:
67 css::uno::WeakReference< Listener > m_xListener;
68};
69
71 public WeakListenerAdapter< css::view::XSelectionChangeListener >
72{
73public:
75 const css::uno::Reference< css::view::XSelectionChangeListener > & xListener );
76 virtual ~WeakSelectionChangeListenerAdapter() override;
77
78protected:
79 // ____ XSelectionChangeListener ____
80 virtual void SAL_CALL selectionChanged(
81 const css::lang::EventObject& aEvent ) override;
82};
83
84} // namespace chart
85
86/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
Adapter that enables adding listeners as weak UNO references.
css::uno::WeakReference< Listener > m_xListener
css::uno::Reference< Listener > getListener() const
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
WeakListenerAdapter(const css::uno::Reference< Listener > &xListener)
virtual void SAL_CALL selectionChanged(const css::lang::EventObject &aEvent) override
WeakSelectionChangeListenerAdapter(const css::uno::Reference< css::view::XSelectionChangeListener > &xListener)