1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include "ModifyListenerCallBack.hxx"
22 #include "MutexContainer.hxx"
23 #include <cppuhelper/compbase1.hxx>
25 using namespace ::com::sun::star
;
26 using ::com::sun::star::uno::Reference
;
30 typedef ::cppu::WeakComponentImplHelper1
<
31 ::com::sun::star::util::XModifyListener
>
32 ModifyListenerCallBack_Base
;
34 class ModifyListenerCallBack_impl
35 : public ::chart::MutexContainer
36 , public ModifyListenerCallBack_Base
39 explicit ModifyListenerCallBack_impl( const Link
& rCallBack
);
40 virtual ~ModifyListenerCallBack_impl();
42 void startListening( const Reference
< util::XModifyBroadcaster
>& xBroadcaster
);
46 virtual void SAL_CALL
modified( const lang::EventObject
& aEvent
) throw (uno::RuntimeException
);
49 virtual void SAL_CALL
disposing( const lang::EventObject
& Source
) throw (uno::RuntimeException
);
51 using ::cppu::WeakComponentImplHelperBase::disposing
;
54 Link m_aLink
;//will be callef on modify
55 Reference
< util::XModifyBroadcaster
> m_xBroadcaster
;//broadcaster to listen at
59 ModifyListenerCallBack_impl::ModifyListenerCallBack_impl( const Link
& rCallBack
)
60 : ModifyListenerCallBack_Base( m_aMutex
)
61 , m_aLink( rCallBack
)
66 ModifyListenerCallBack_impl::~ModifyListenerCallBack_impl()
71 void SAL_CALL
ModifyListenerCallBack_impl::modified( const lang::EventObject
& /*aEvent*/ ) throw (uno::RuntimeException
)
77 void SAL_CALL
ModifyListenerCallBack_impl::disposing( const lang::EventObject
& /*Source*/ ) throw (uno::RuntimeException
)
79 m_xBroadcaster
.clear();
82 void ModifyListenerCallBack_impl::startListening( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyBroadcaster
>& xBroadcaster
)
84 if( m_xBroadcaster
== xBroadcaster
)
88 m_xBroadcaster
= xBroadcaster
;
89 if( m_xBroadcaster
.is() )
90 m_xBroadcaster
->addModifyListener( this );
92 void ModifyListenerCallBack_impl::stopListening()
94 if( m_xBroadcaster
.is() )
96 m_xBroadcaster
->removeModifyListener( this );
97 m_xBroadcaster
.clear();
101 //-------------------------------------------
103 ModifyListenerCallBack::ModifyListenerCallBack( const Link
& rCallBack
)
104 : pModifyListener_impl( new ModifyListenerCallBack_impl(rCallBack
) )
105 , m_xModifyListener( pModifyListener_impl
)
109 ModifyListenerCallBack::~ModifyListenerCallBack()
114 void ModifyListenerCallBack::startListening( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyBroadcaster
>& xBroadcaster
)
116 pModifyListener_impl
->startListening( xBroadcaster
);
118 void ModifyListenerCallBack::stopListening()
120 pModifyListener_impl
->stopListening();
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */