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