LibreOffice Module chart2 (master) 1
ModifyListenerCallBack.cxx
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
22
23using namespace ::com::sun::star;
24using ::com::sun::star::uno::Reference;
25
26namespace chart {
27
30
33{
34public:
35 explicit ModifyListenerCallBack_impl( const Link<void*,void>& rCallBack );
36
37 void startListening( const Reference< util::XModifyBroadcaster >& xBroadcaster );
38 void stopListening();
39
40 //XModifyListener
41 virtual void SAL_CALL modified( const lang::EventObject& aEvent ) override;
42
43 //XEventListener
44 virtual void SAL_CALL disposing( const lang::EventObject& Source ) override;
45
46 using ::comphelper::WeakComponentImplHelperBase::disposing;
47
48private:
49 Link<void*,void> m_aLink;//will be called on modify
51};
52
54 : m_aLink( rCallBack )
55{
56}
57
58//XModifyListener
59void SAL_CALL ModifyListenerCallBack_impl::modified( const lang::EventObject& /*aEvent*/ )
60{
61 m_aLink.Call(nullptr);
62}
63
64//XEventListener
65void SAL_CALL ModifyListenerCallBack_impl::disposing( const lang::EventObject& /*Source*/ )
66{
67 m_xBroadcaster.clear();
68}
69
70void ModifyListenerCallBack_impl::startListening( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyBroadcaster >& xBroadcaster )
71{
72 if( m_xBroadcaster == xBroadcaster )
73 return;
74
76 m_xBroadcaster = xBroadcaster;
77 if( m_xBroadcaster.is() )
78 m_xBroadcaster->addModifyListener( this );
79}
81{
82 if( m_xBroadcaster.is() )
83 {
84 m_xBroadcaster->removeModifyListener( this );
85 m_xBroadcaster.clear();
86 }
87}
88
90 : pModifyListener_impl( new ModifyListenerCallBack_impl(rCallBack) )
91 , m_xModifyListener( pModifyListener_impl )
92{
93}
94
96{
98}
99
100void ModifyListenerCallBack::startListening( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XModifyBroadcaster >& xBroadcaster )
101{
102 pModifyListener_impl->startListening( xBroadcaster );
103}
105{
107}
108
109} // namespace chart
110
111/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
ModifyListenerCallBack_impl(const Link< void *, void > &rCallBack)
virtual void SAL_CALL modified(const lang::EventObject &aEvent) override
void startListening(const Reference< util::XModifyBroadcaster > &xBroadcaster)
Reference< util::XModifyBroadcaster > m_xBroadcaster
virtual void SAL_CALL disposing(const lang::EventObject &Source) override
ModifyListenerCallBack(const Link< void *, void > &rCallBack)
ModifyListenerCallBack_impl * pModifyListener_impl
void startListening(const ::com::sun::star::uno::Reference<::com::sun::star::util::XModifyBroadcaster > &xBroadcaster)
comphelper::WeakComponentImplHelper< css::util::XModifyListener > ModifyListenerCallBack_Base