1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
23 #include "adiasync.hxx"
24 #include <com/sun/star/sheet/XResultListener.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <cppuhelper/implbase.hxx>
28 namespace com::sun::star::sheet
{ class XVolatileResult
; }
29 namespace rtl
{ template <class reference_type
> class Reference
; }
33 class ScAddInListener final
: public cppu::WeakImplHelper
<
34 css::sheet::XResultListener
,
35 css::lang::XServiceInfo
>,
39 css::uno::Reference
<css::sheet::XVolatileResult
> xVolRes
;
40 css::uno::Any aResult
;
41 std::unique_ptr
<ScAddInDocs
> pDocs
; // documents where this is used
43 static ::std::vector
<rtl::Reference
<ScAddInListener
>> aAllListeners
;
45 // always allocated via CreateListener
46 ScAddInListener( css::uno::Reference
<css::sheet::XVolatileResult
> xVR
,
50 virtual ~ScAddInListener() override
;
52 // create Listener and put it into global list
53 static ScAddInListener
* CreateListener(
54 const css::uno::Reference
<css::sheet::XVolatileResult
>& xVR
,
57 static ScAddInListener
* Get( const css::uno::Reference
<css::sheet::XVolatileResult
>& xVR
);
59 static void RemoveDocument( ScDocument
* pDocument
);
61 bool HasDocument( ScDocument
* pDoc
) const
62 { return pDocs
->find( pDoc
) != pDocs
->end(); }
64 void AddDocument( ScDocument
* pDoc
)
65 { pDocs
->insert( pDoc
); }
67 const css::uno::Any
& GetResult() const
71 virtual void SAL_CALL
modified( const css::sheet::ResultEvent
& aEvent
) override
;
74 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
77 virtual OUString SAL_CALL
getImplementationName() override
;
79 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
81 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames() override
;
84 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */