Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef SC_ADDINLIS_HXX
21 : #define SC_ADDINLIS_HXX
22 :
23 : #include "adiasync.hxx"
24 : #include <com/sun/star/sheet/XResultListener.hpp>
25 : #include <com/sun/star/sheet/XVolatileResult.hpp>
26 : #include <com/sun/star/lang/XServiceInfo.hpp>
27 : #include <cppuhelper/implbase2.hxx>
28 :
29 : class ScDocument;
30 :
31 : class ScAddInListener : public cppu::WeakImplHelper2<
32 : com::sun::star::sheet::XResultListener,
33 : com::sun::star::lang::XServiceInfo >,
34 : public SvtBroadcaster
35 : {
36 : private:
37 : com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVolRes;
38 : com::sun::star::uno::Any aResult;
39 : ScAddInDocs* pDocs; // documents where this is used
40 :
41 : static ::std::list<ScAddInListener*> aAllListeners;
42 :
43 : // always allocated via CreateListener
44 : ScAddInListener( com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVR,
45 : ScDocument* pD );
46 :
47 : public:
48 : virtual ~ScAddInListener();
49 :
50 : // create Listener and put it into global list
51 : static ScAddInListener* CreateListener(
52 : com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVR,
53 : ScDocument* pDoc );
54 :
55 : static ScAddInListener*Get( com::sun::star::uno::Reference<
56 : com::sun::star::sheet::XVolatileResult> xVR );
57 :
58 : static void RemoveDocument( ScDocument* pDocument );
59 :
60 0 : bool HasDocument( ScDocument* pDoc ) const
61 0 : { return pDocs->find( pDoc ) != pDocs->end(); }
62 :
63 0 : void AddDocument( ScDocument* pDoc )
64 0 : { pDocs->insert( pDoc ); }
65 :
66 0 : const com::sun::star::uno::Any& GetResult() const
67 0 : { return aResult; }
68 :
69 : // XResultListener
70 : virtual void SAL_CALL modified( const ::com::sun::star::sheet::ResultEvent& aEvent )
71 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
72 :
73 : // XEventListener
74 : virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
75 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
76 :
77 : // XServiceInfo
78 : virtual OUString SAL_CALL getImplementationName()
79 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
80 :
81 : virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName )
82 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
83 :
84 : virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
85 : throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
86 : };
87 :
88 : #endif // SC_ADDINLIS_HXX
89 :
90 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|