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
28extern "C" {
29void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData );
30}
31
32class ScDocument;
33using ScAddInDocs = std::set<ScDocument*>;
34
35class ScAddInAsync final : public SvtBroadcaster
36{
37private:
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
49public:
50 // cTor only if ScAddInAsync::Get fails.
51 // nIndex: Index from FunctionCollection
53 virtual ~ScAddInAsync() override;
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};
73using ScAddInAsyncs = std::set<std::unique_ptr<ScAddInAsync>, CompareScAddInAsync>;
74
75extern ScAddInAsyncs theAddInAsyncTbl; // in adiasync.cxx
76
77/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScAddInAsyncs theAddInAsyncTbl
Definition: adiasync.cxx:32
std::set< ScDocument * > ScAddInDocs
Definition: adiasync.hxx:33
std::set< std::unique_ptr< ScAddInAsync >, CompareScAddInAsync > ScAddInAsyncs
Definition: adiasync.hxx:73
void CALLTYPE ScAddInAsyncCallBack(double &nHandle, void *pData)
Definition: adiasync.cxx:35
ParamType
Definition: callform.hxx:41
#define CALLTYPE
Definition: callform.hxx:31
double GetValue() const
Definition: adiasync.hxx:59
bool operator<(const ScAddInAsync &r) const
Definition: adiasync.hxx:66
static ScAddInAsync * Get(sal_uLong nHandle)
Definition: adiasync.cxx:62
virtual ~ScAddInAsync() override
Definition: adiasync.cxx:53
ParamType GetType() const
Definition: adiasync.hxx:58
static void CallBack(sal_uLong nHandle, void *pData)
Definition: adiasync.cxx:74
sal_uLong nHandle
Definition: adiasync.hxx:45
std::unique_ptr< ScAddInDocs > pDocs
Definition: adiasync.hxx:43
ParamType meType
Definition: adiasync.hxx:46
bool IsValid() const
Definition: adiasync.hxx:57
static void RemoveDocument(ScDocument *pDocument)
Definition: adiasync.cxx:118
LegacyFuncData * mpFuncData
Definition: adiasync.hxx:44
ScAddInAsync(sal_uLong nHandle, LegacyFuncData *pFuncData, ScDocument *pDoc)
Definition: adiasync.cxx:41
OUString * pStr
Definition: adiasync.hxx:41
void AddDocument(ScDocument *pDoc)
Definition: adiasync.hxx:63
double nVal
Definition: adiasync.hxx:40
const OUString & GetString() const
Definition: adiasync.hxx:60
bool HasDocument(ScDocument *pDoc) const
Definition: adiasync.hxx:61
sal_uIntPtr sal_uLong
bool operator()(std::unique_ptr< ScAddInAsync > const &lhs, std::unique_ptr< ScAddInAsync > const &rhs) const
Definition: adiasync.hxx:71