diff options
author | Sascha Ballach <sab@openoffice.org> | 2002-05-24 14:02:04 +0000 |
---|---|---|
committer | Sascha Ballach <sab@openoffice.org> | 2002-05-24 14:02:04 +0000 |
commit | 882d15f01fd7341c1850973d60c9b7bacc7f5e8c (patch) | |
tree | eaf65414b61631fab4a7c7ba714519bddb58fd18 | |
parent | 24da580f8bd0a348fee64c07f9015b09918f8388 (diff) |
#95584#; create a Broadcaster to broadcast draw events
-rw-r--r-- | sc/source/ui/Accessibility/DrawModelBroadcaster.cxx | 130 | ||||
-rw-r--r-- | sc/source/ui/inc/DrawModelBroadcaster.hxx | 102 |
2 files changed, 232 insertions, 0 deletions
diff --git a/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx b/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx new file mode 100644 index 000000000000..8ab090b8e5ec --- /dev/null +++ b/sc/source/ui/Accessibility/DrawModelBroadcaster.cxx @@ -0,0 +1,130 @@ +/************************************************************************* + * + * $RCSfile: DrawModelBroadcaster.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sab $ $Date: 2002-05-24 15:02:04 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SC_DRAWMODELBROADCASTER_HXX +#include "DrawModelBroadcaster.hxx" +#endif + +#ifndef _SVDMODEL_HXX +#include <svx/svdmodel.hxx> +#endif +#ifndef SVX_UNOMOD_HXX +#include <svx/unomod.hxx> +#endif +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +using namespace ::com::sun::star; + +ScDrawModelBroadcaster::ScDrawModelBroadcaster( SdrModel *pDrawModel ) : + maEventListeners( maListenerMutex ), + mpDrawModel( pDrawModel ) +{ + StartListening( *mpDrawModel ); +} + +ScDrawModelBroadcaster::~ScDrawModelBroadcaster() +{ + EndListening( *mpDrawModel ); +} + +void SAL_CALL ScDrawModelBroadcaster::addEventListener( const uno::Reference< document::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + maEventListeners.addInterface( xListener ); +} + +void SAL_CALL ScDrawModelBroadcaster::removeEventListener( const uno::Reference< document::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + maEventListeners.removeInterface( xListener ); +} + +void ScDrawModelBroadcaster::Notify( SfxBroadcaster& rBC, + const SfxHint& rHint ) +{ + const SdrHint *pSdrHint = PTR_CAST( SdrHint, &rHint ); + if( !pSdrHint ) + return; + + document::EventObject aEvent; + if( !SvxUnoDrawMSFactory::createEvent( mpDrawModel, pSdrHint, aEvent ) ) + return; + + ::cppu::OInterfaceIteratorHelper aIter( maEventListeners ); + while( aIter.hasMoreElements() ) + { + uno::Reference < document::XEventListener > xListener( aIter.next(), uno::UNO_QUERY ); + try + { + xListener->notifyEvent( aEvent ); + } + catch( uno::RuntimeException& r ) + { +#ifdef DEBUG + ByteString aError( "Runtime exception caught while notifying shape.:\n" ); + aError += ByteString( String( r.Message), RTL_TEXTENCODING_ASCII_US ); + DBG_ERROR( aError.GetBuffer() ); +#endif + } + } +} diff --git a/sc/source/ui/inc/DrawModelBroadcaster.hxx b/sc/source/ui/inc/DrawModelBroadcaster.hxx new file mode 100644 index 000000000000..d54078254227 --- /dev/null +++ b/sc/source/ui/inc/DrawModelBroadcaster.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * $RCSfile: DrawModelBroadcaster.hxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: sab $ $Date: 2002-05-24 15:01:16 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +#ifndef _SC_DRAWMODELBROADCASTER_HXX +#define _SC_DRAWMODELBROADCASTER_HXX + + +#ifndef _SFXLSTNER_HXX +#include <svtools/lstner.hxx> +#endif +#ifndef _CPPUHELPER_INTERFACECONTAINER_H_ +#include <cppuhelper/interfacecontainer.h> +#endif +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#include <cppuhelper/implbase1.hxx> +#endif + +#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTBROADCASTER_HPP_ +#include <com/sun/star/document/XEventBroadcaster.hpp> +#endif + +class SdrModel; + +class ScDrawModelBroadcaster : public SfxListener, + public ::cppu::WeakImplHelper1< com::sun::star::document::XEventBroadcaster > +{ + mutable ::osl::Mutex maListenerMutex; + ::cppu::OInterfaceContainerHelper maEventListeners; + SdrModel *mpDrawModel; + +public: + + ScDrawModelBroadcaster( SdrModel *pDrawModel ); + virtual ~ScDrawModelBroadcaster(); + + virtual void SAL_CALL addEventListener( const com::sun::star::uno::Reference< com::sun::star::document::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< com::sun::star::document::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); +}; + +#endif
\ No newline at end of file |