LibreOffice Module sc (master) 1
addinlis.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <memory>
23#include "adiasync.hxx"
24#include <com/sun/star/sheet/XResultListener.hpp>
25#include <com/sun/star/lang/XServiceInfo.hpp>
27
28namespace com::sun::star::sheet { class XVolatileResult; }
29namespace rtl { template <class reference_type> class Reference; }
30
31class ScDocument;
32
33class ScAddInListener final : public cppu::WeakImplHelper<
34 css::sheet::XResultListener,
35 css::lang::XServiceInfo >,
36 public SvtBroadcaster
37{
38private:
39 css::uno::Reference<css::sheet::XVolatileResult> xVolRes;
40 css::uno::Any aResult;
41 std::unique_ptr<ScAddInDocs> pDocs; // documents where this is used
42
43 static ::std::vector<rtl::Reference<ScAddInListener>> aAllListeners;
44
45 // always allocated via CreateListener
46 ScAddInListener( css::uno::Reference<css::sheet::XVolatileResult> const & xVR,
47 ScDocument* pD );
48
49public:
50 virtual ~ScAddInListener() override;
51
52 // create Listener and put it into global list
54 const css::uno::Reference<css::sheet::XVolatileResult>& xVR,
55 ScDocument* pDoc );
56
57 static ScAddInListener* Get( const css::uno::Reference<css::sheet::XVolatileResult>& xVR );
58
59 static void RemoveDocument( ScDocument* pDocument );
60
61 bool HasDocument( ScDocument* pDoc ) const
62 { return pDocs->find( pDoc ) != pDocs->end(); }
63
64 void AddDocument( ScDocument* pDoc )
65 { pDocs->insert( pDoc ); }
66
67 const css::uno::Any& GetResult() const
68 { return aResult; }
69
70 // XResultListener
71 virtual void SAL_CALL modified( const css::sheet::ResultEvent& aEvent ) override;
72
73 // XEventListener
74 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
75
76 // XServiceInfo
77 virtual OUString SAL_CALL getImplementationName() override;
78
79 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
80
81 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
82};
83
84/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static ScAddInListener * CreateListener(const css::uno::Reference< css::sheet::XVolatileResult > &xVR, ScDocument *pDoc)
const css::uno::Any & GetResult() const
Definition: addinlis.hxx:67
std::unique_ptr< ScAddInDocs > pDocs
Definition: addinlis.hxx:41
virtual ~ScAddInListener() override
Definition: addinlis.cxx:56
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
static void RemoveDocument(ScDocument *pDocument)
Definition: addinlis.cxx:77
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: addinlis.cxx:121
static ScAddInListener * Get(const css::uno::Reference< css::sheet::XVolatileResult > &xVR)
Definition: addinlis.cxx:60
css::uno::Any aResult
Definition: addinlis.hxx:40
ScAddInListener(css::uno::Reference< css::sheet::XVolatileResult > const &xVR, ScDocument *pD)
Definition: addinlis.cxx:49
void AddDocument(ScDocument *pDoc)
Definition: addinlis.hxx:64
virtual void SAL_CALL modified(const css::sheet::ResultEvent &aEvent) override
Definition: addinlis.cxx:102
css::uno::Reference< css::sheet::XVolatileResult > xVolRes
Definition: addinlis.hxx:39
bool HasDocument(ScDocument *pDoc) const
Definition: addinlis.hxx:61
static ::std::vector< rtl::Reference< ScAddInListener > > aAllListeners
Definition: addinlis.hxx:43
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Reference
unsigned char sal_Bool