Line data Source code
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 :
26 : #include "callform.hxx"
27 :
28 : extern "C" {
29 : void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData );
30 : }
31 :
32 : class ScDocument;
33 0 : class ScAddInDocs : public std::set<ScDocument*> {};
34 :
35 : class ScAddInAsync : public SvtBroadcaster
36 : {
37 : private:
38 : union
39 : {
40 : double nVal; // current value
41 : OUString* pStr;
42 : };
43 : ScAddInDocs* pDocs; // List of using documents
44 : FuncData* 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, FuncData* pFuncData, ScDocument* pDoc);
53 : // default-cTor only for that single, global aSeekObj!
54 : ScAddInAsync();
55 : virtual ~ScAddInAsync();
56 : static ScAddInAsync* Get( sal_uLong nHandle );
57 : static void CallBack( sal_uLong nHandle, void* pData );
58 : static void RemoveDocument( ScDocument* pDocument );
59 0 : bool IsValid() const { return bValid; }
60 0 : ParamType GetType() const { return meType; }
61 0 : double GetValue() const { return nVal; }
62 0 : const OUString& GetString() const { return *pStr; }
63 0 : bool HasDocument( ScDocument* pDoc ) const
64 0 : { return pDocs->find( pDoc ) != pDocs->end(); }
65 0 : void AddDocument( ScDocument* pDoc ) { pDocs->insert( pDoc ); }
66 :
67 : // Comparators for PtrArrSort
68 0 : bool operator< ( const ScAddInAsync& r ) const { return nHandle < r.nHandle; }
69 : bool operator==( const ScAddInAsync& r ) const { return nHandle == r.nHandle; }
70 : };
71 :
72 : struct CompareScAddInAsync
73 : {
74 0 : bool operator()( ScAddInAsync* const& lhs, ScAddInAsync* const& rhs ) const { return (*lhs)<(*rhs); }
75 : };
76 104 : class ScAddInAsyncs : public std::set<ScAddInAsync*, CompareScAddInAsync> {};
77 :
78 : extern ScAddInAsyncs theAddInAsyncTbl; // in adiasync.cxx
79 :
80 : #endif
81 :
82 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|