1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <svl/broadcast.hxx>
24 #include <tools/solar.h>
26 #include <callform.hxx>
29 void CALLTYPE
ScAddInAsyncCallBack( double& nHandle
, void* pData
);
33 using ScAddInDocs
= std::set
<ScDocument
*>;
35 class ScAddInAsync final
: public SvtBroadcaster
40 double nVal
; // current value
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?
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
); }
65 // Comparators for PtrArrSort
66 bool operator< ( const ScAddInAsync
& r
) const { return nHandle
< r
.nHandle
; }
69 struct CompareScAddInAsync
71 bool operator()( std::unique_ptr
<ScAddInAsync
> const& lhs
, std::unique_ptr
<ScAddInAsync
> const& rhs
) const { return (*lhs
)<(*rhs
); }
73 using ScAddInAsyncs
= std::set
<std::unique_ptr
<ScAddInAsync
>, CompareScAddInAsync
>;
75 extern ScAddInAsyncs theAddInAsyncTbl
; // in adiasync.cxx
77 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */