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