xref: /aoo4110/main/sc/source/core/inc/addinlis.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_ADDINLIS_HXX
25 #define SC_ADDINLIS_HXX
26 
27 #include "adiasync.hxx"			// for ScAddInDocs PtrArr
28 #include <tools/list.hxx>
29 #include <com/sun/star/sheet/XResultListener.hpp>
30 #include <com/sun/star/sheet/XVolatileResult.hpp>
31 #include <com/sun/star/lang/XServiceInfo.hpp>
32 #include <cppuhelper/implbase2.hxx>
33 
34 
35 
36 class ScDocument;
37 
38 
39 class ScAddInListener : public cppu::WeakImplHelper2<
40 							com::sun::star::sheet::XResultListener,
41 							com::sun::star::lang::XServiceInfo >,
42 						public SvtBroadcaster
43 {
44 private:
45 	com::sun::star::uno::Reference<com::sun::star::sheet::XVolatileResult> xVolRes;
46 	com::sun::star::uno::Any	aResult;
47 	ScAddInDocs*				pDocs;			// documents where this is used
48 
49 	static List					aAllListeners;
50 
51 							// always allocated via CreateListener
52 							ScAddInListener(
53 								com::sun::star::uno::Reference<
54 									com::sun::star::sheet::XVolatileResult> xVR,
55 								ScDocument* pD );
56 
57 public:
58 	virtual					~ScAddInListener();
59 
60 							// create Listener and put it into global list
61 	static ScAddInListener*	CreateListener(
62 								com::sun::star::uno::Reference<
63 									com::sun::star::sheet::XVolatileResult> xVR,
64 								ScDocument* pDoc );
65 
66 	static ScAddInListener*	Get( com::sun::star::uno::Reference<
67 									com::sun::star::sheet::XVolatileResult> xVR );
68 	static void				RemoveDocument( ScDocument* pDocument );
69 
HasDocument(ScDocument * pDoc) const70 	sal_Bool					HasDocument( ScDocument* pDoc ) const	{ return pDocs->Seek_Entry( pDoc ); }
AddDocument(ScDocument * pDoc)71 	void					AddDocument( ScDocument* pDoc )			{ pDocs->Insert( pDoc ); }
GetResult() const72 	const com::sun::star::uno::Any& GetResult() const				{ return aResult; }
73 
74 
75 							// XResultListener
76 	virtual void SAL_CALL	modified( const ::com::sun::star::sheet::ResultEvent& aEvent )
77 								throw(::com::sun::star::uno::RuntimeException);
78 
79 							// XEventListener
80 	virtual void SAL_CALL	disposing( const ::com::sun::star::lang::EventObject& Source )
81 								throw(::com::sun::star::uno::RuntimeException);
82 
83 							// XServiceInfo
84 	virtual ::rtl::OUString SAL_CALL getImplementationName(  )
85 								throw(::com::sun::star::uno::RuntimeException);
86 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
87 								throw(::com::sun::star::uno::RuntimeException);
88 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
89 								throw(::com::sun::star::uno::RuntimeException);
90 };
91 
92 
93 #endif
94 
95