1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 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. 14 * 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). 20 * 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. 25 * 26 ************************************************************************/ 27 28 #ifndef SC_ADDINLIS_HXX 29 #define SC_ADDINLIS_HXX 30 31 #include "adiasync.hxx" // for ScAddInDocs PtrArr 32 #include <tools/list.hxx> 33 #include <com/sun/star/sheet/XResultListener.hpp> 34 #include <com/sun/star/sheet/XVolatileResult.hpp> 35 #include <com/sun/star/lang/XServiceInfo.hpp> 36 #include <cppuhelper/implbase2.hxx> 37 38 39 40 class ScDocument; 41 42 43 class ScAddInListener : public cppu::WeakImplHelper2< 44 com::sun::star::sheet::XResultListener, 45 com::sun::star::lang::XServiceInfo >, 46 public SvtBroadcaster 47 { 48 private: 49 com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVolRes; 50 com::sun::star::uno::Any aResult; 51 ScAddInDocs* pDocs; // documents where this is used 52 53 static List aAllListeners; 54 55 // always allocated via CreateListener 56 ScAddInListener( 57 com::sun::star::uno::Reference< 58 com::sun::star::sheet::XVolatileResult> xVR, 59 ScDocument* pD ); 60 61 public: 62 virtual ~ScAddInListener(); 63 64 // create Listener and put it into global list 65 static ScAddInListener* CreateListener( 66 com::sun::star::uno::Reference< 67 com::sun::star::sheet::XVolatileResult> xVR, 68 ScDocument* pDoc ); 69 70 static ScAddInListener* Get( com::sun::star::uno::Reference< 71 com::sun::star::sheet::XVolatileResult> xVR ); 72 static void RemoveDocument( ScDocument* pDocument ); 73 74 sal_Bool HasDocument( ScDocument* pDoc ) const { return pDocs->Seek_Entry( pDoc ); } 75 void AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); } 76 const com::sun::star::uno::Any& GetResult() const { return aResult; } 77 78 79 // XResultListener 80 virtual void SAL_CALL modified( const ::com::sun::star::sheet::ResultEvent& aEvent ) 81 throw(::com::sun::star::uno::RuntimeException); 82 83 // XEventListener 84 virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) 85 throw(::com::sun::star::uno::RuntimeException); 86 87 // XServiceInfo 88 virtual ::rtl::OUString SAL_CALL getImplementationName( ) 89 throw(::com::sun::star::uno::RuntimeException); 90 virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) 91 throw(::com::sun::star::uno::RuntimeException); 92 virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) 93 throw(::com::sun::star::uno::RuntimeException); 94 }; 95 96 97 #endif 98 99