1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_chart2.hxx"
31 #include "ModifyListenerCallBack.hxx"
32 #include "MutexContainer.hxx"
33 #include <cppuhelper/compbase1.hxx>
35 using namespace ::com::sun::star
;
36 using ::com::sun::star::uno::Reference
;
40 typedef ::cppu::WeakComponentImplHelper1
<
41 ::com::sun::star::util::XModifyListener
>
42 ModifyListenerCallBack_Base
;
44 class ModifyListenerCallBack_impl
45 : public ::chart::MutexContainer
46 , public ModifyListenerCallBack_Base
49 explicit ModifyListenerCallBack_impl( const Link
& rCallBack
);
50 virtual ~ModifyListenerCallBack_impl();
52 void startListening( const Reference
< util::XModifyBroadcaster
>& xBroadcaster
);
56 virtual void SAL_CALL
modified( const lang::EventObject
& aEvent
) throw (uno::RuntimeException
);
59 virtual void SAL_CALL
disposing( const lang::EventObject
& Source
) throw (uno::RuntimeException
);
61 using ::cppu::WeakComponentImplHelperBase::disposing
;
64 Link m_aLink
;//will be callef on modify
65 Reference
< util::XModifyBroadcaster
> m_xBroadcaster
;//broadcaster to listen at
69 ModifyListenerCallBack_impl::ModifyListenerCallBack_impl( const Link
& rCallBack
)
70 : ModifyListenerCallBack_Base( m_aMutex
)
71 , m_aLink( rCallBack
)
76 ModifyListenerCallBack_impl::~ModifyListenerCallBack_impl()
81 void SAL_CALL
ModifyListenerCallBack_impl::modified( const lang::EventObject
& /*aEvent*/ ) throw (uno::RuntimeException
)
87 void SAL_CALL
ModifyListenerCallBack_impl::disposing( const lang::EventObject
& /*Source*/ ) throw (uno::RuntimeException
)
89 m_xBroadcaster
.clear();
92 void ModifyListenerCallBack_impl::startListening( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyBroadcaster
>& xBroadcaster
)
94 if( m_xBroadcaster
== xBroadcaster
)
98 m_xBroadcaster
= xBroadcaster
;
99 if( m_xBroadcaster
.is() )
100 m_xBroadcaster
->addModifyListener( this );
102 void ModifyListenerCallBack_impl::stopListening()
104 if( m_xBroadcaster
.is() )
106 m_xBroadcaster
->removeModifyListener( this );
107 m_xBroadcaster
.clear();
111 //-------------------------------------------
113 ModifyListenerCallBack::ModifyListenerCallBack( const Link
& rCallBack
)
114 : pModifyListener_impl( new ModifyListenerCallBack_impl(rCallBack
) )
115 , m_xModifyListener( pModifyListener_impl
)
119 ModifyListenerCallBack::~ModifyListenerCallBack()
124 void ModifyListenerCallBack::startListening( const ::com::sun::star::uno::Reference
< ::com::sun::star::util::XModifyBroadcaster
>& xBroadcaster
)
126 pModifyListener_impl
->startListening( xBroadcaster
);
128 void ModifyListenerCallBack::stopListening()
130 pModifyListener_impl
->stopListening();