LibreOffice Module sc (master)  1
adiasync.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 <svl/broadcast.hxx>
23 #include <set>
24 #include <tools/solar.h>
25 
26 #include <callform.hxx>
27 
28 extern "C" {
29 void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData );
30 }
31 
32 class ScDocument;
33 using ScAddInDocs = std::set<ScDocument*>;
34 
35 class ScAddInAsync final : public SvtBroadcaster
36 {
37 private:
38  union
39  {
40  double nVal; // current value
41  OUString* pStr;
42  };
43  std::unique_ptr<ScAddInDocs> pDocs; // List of using documents
44  LegacyFuncData* mpFuncData; // Pointer to data in collection
45  sal_uLong nHandle; // is casted from double to sal_uLong
46  ParamType meType; // result of type PTR_DOUBLE or PTR_STRING
47  bool bValid; // is value valid?
48 
49 public:
50  // cTor only if ScAddInAsync::Get fails.
51  // nIndex: Index from FunctionCollection
52  ScAddInAsync(sal_uLong nHandle, LegacyFuncData* pFuncData, ScDocument* pDoc);
53  virtual ~ScAddInAsync() override;
54  static ScAddInAsync* Get( sal_uLong nHandle );
55  static void CallBack( sal_uLong nHandle, void* pData );
56  static void RemoveDocument( ScDocument* pDocument );
57  bool IsValid() const { return bValid; }
58  ParamType GetType() const { return meType; }
59  double GetValue() const { return nVal; }
60  const OUString& GetString() const { return *pStr; }
61  bool HasDocument( ScDocument* pDoc ) const
62  { return pDocs->find( pDoc ) != pDocs->end(); }
63  void AddDocument( ScDocument* pDoc ) { pDocs->insert( pDoc ); }
64 
65  // Comparators for PtrArrSort
66  bool operator< ( const ScAddInAsync& r ) const { return nHandle < r.nHandle; }
67 };
68 
70 {
71  bool operator()( std::unique_ptr<ScAddInAsync> const& lhs, std::unique_ptr<ScAddInAsync> const& rhs ) const { return (*lhs)<(*rhs); }
72 };
73 using ScAddInAsyncs = std::set<std::unique_ptr<ScAddInAsync>, CompareScAddInAsync>;
74 
75 extern ScAddInAsyncs theAddInAsyncTbl; // in adiasync.cxx
76 
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString * pStr
Definition: adiasync.hxx:41
double nVal
Definition: adiasync.hxx:40
std::set< ScDocument * > ScAddInDocs
Definition: adiasync.hxx:33
static void CallBack(sal_uLong nHandle, void *pData)
Definition: adiasync.cxx:74
sal_uIntPtr sal_uLong
virtual ~ScAddInAsync() override
Definition: adiasync.cxx:53
std::unique_ptr< ScAddInDocs > pDocs
Definition: adiasync.hxx:43
bool IsValid() const
Definition: adiasync.hxx:57
ScAddInAsync(sal_uLong nHandle, LegacyFuncData *pFuncData, ScDocument *pDoc)
Definition: adiasync.cxx:41
ParamType meType
Definition: adiasync.hxx:46
ScAddInAsyncs theAddInAsyncTbl
Definition: adiasync.cxx:32
bool operator<(const ScAddInAsync &r) const
Definition: adiasync.hxx:66
bool HasDocument(ScDocument *pDoc) const
Definition: adiasync.hxx:61
void CALLTYPE ScAddInAsyncCallBack(double &nHandle, void *pData)
Definition: adiasync.cxx:35
ParamType
Definition: callform.hxx:40
void AddDocument(ScDocument *pDoc)
Definition: adiasync.hxx:63
const OUString & GetString() const
Definition: adiasync.hxx:60
std::set< std::unique_ptr< ScAddInAsync >, CompareScAddInAsync > ScAddInAsyncs
Definition: adiasync.hxx:73
LegacyFuncData * mpFuncData
Definition: adiasync.hxx:44
static ScAddInAsync * Get(sal_uLong nHandle)
Definition: adiasync.cxx:62
#define CALLTYPE
Definition: callform.hxx:31
static void RemoveDocument(ScDocument *pDocument)
Definition: adiasync.cxx:118
sal_uLong nHandle
Definition: adiasync.hxx:45
bool operator()(std::unique_ptr< ScAddInAsync > const &lhs, std::unique_ptr< ScAddInAsync > const &rhs) const
Definition: adiasync.hxx:71
ParamType GetType() const
Definition: adiasync.hxx:58
double GetValue() const
Definition: adiasync.hxx:59