Get the style color and number just once
[LibreOffice.git] / chart2 / source / tools / ModifyListenerCallBack.cxx
blob758b25386f9644e7fe0b7cdac86412f0a5c78d94
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #include <ModifyListenerCallBack.hxx>
21 #include <comphelper/compbase.hxx>
23 using namespace ::com::sun::star;
24 using ::com::sun::star::uno::Reference;
26 namespace chart {
28 typedef comphelper::WeakComponentImplHelper< css::util::XModifyListener >
29 ModifyListenerCallBack_Base;
31 class ModifyListenerCallBack_impl
32 : public ModifyListenerCallBack_Base
34 public:
35 explicit ModifyListenerCallBack_impl( const Link<void*,void>& rCallBack );
37 void startListening( const Reference< util::XModifyBroadcaster >& xBroadcaster );
38 void stopListening();
40 //XModifyListener
41 virtual void SAL_CALL modified( const lang::EventObject& aEvent ) override;
43 //XEventListener
44 virtual void SAL_CALL disposing( const lang::EventObject& Source ) override;
46 using ::comphelper::WeakComponentImplHelperBase::disposing;
48 private:
49 Link<void*,void> m_aLink;//will be called on modify
50 Reference< util::XModifyBroadcaster > m_xBroadcaster;//broadcaster to listen at
53 ModifyListenerCallBack_impl::ModifyListenerCallBack_impl( const Link<void*,void>& rCallBack )
54 : m_aLink( rCallBack )
58 //XModifyListener
59 void SAL_CALL ModifyListenerCallBack_impl::modified( const lang::EventObject& /*aEvent*/ )
61 m_aLink.Call(nullptr);
64 //XEventListener
65 void SAL_CALL ModifyListenerCallBack_impl::disposing( const lang::EventObject& /*Source*/ )
67 m_xBroadcaster.clear();
70 void ModifyListenerCallBack_impl::startListening( const css::uno::Reference< css::util::XModifyBroadcaster >& xBroadcaster )
72 if( m_xBroadcaster == xBroadcaster )
73 return;
75 stopListening();
76 m_xBroadcaster = xBroadcaster;
77 if( m_xBroadcaster.is() )
78 m_xBroadcaster->addModifyListener( this );
80 void ModifyListenerCallBack_impl::stopListening()
82 if( m_xBroadcaster.is() )
84 m_xBroadcaster->removeModifyListener( this );
85 m_xBroadcaster.clear();
89 ModifyListenerCallBack::ModifyListenerCallBack( const Link<void*,void>& rCallBack )
90 : pModifyListener_impl( new ModifyListenerCallBack_impl(rCallBack) )
91 , m_xModifyListener( pModifyListener_impl )
95 ModifyListenerCallBack::~ModifyListenerCallBack()
97 stopListening();
100 void ModifyListenerCallBack::startListening( const css::uno::Reference< css::util::XModifyBroadcaster >& xBroadcaster )
102 pModifyListener_impl->startListening( xBroadcaster );
104 void ModifyListenerCallBack::stopListening()
106 pModifyListener_impl->stopListening();
109 } // namespace chart
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */