xref: /AOO41X/main/sc/source/core/inc/adiasync.hxx (revision 38d50f7b14e1cf975d8c6468d9633894cd59b523)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef SC_ADIASYNC_HXX
25 #define SC_ADIASYNC_HXX
26 
27 #include <svl/broadcast.hxx>
28 #include <svl/svarray.hxx>
29 
30 #include "callform.hxx"
31 
32 extern "C" {
33 void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData );
34 }
35 
36 
37 class ScAddInAsync;
38 typedef ScAddInAsync* ScAddInAsyncPtr;
39 SV_DECL_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr, 4, 4 )
40 extern ScAddInAsyncs theAddInAsyncTbl;  // in adiasync.cxx
41 
42 class ScDocument;
43 typedef ScDocument* ScAddInDocPtr;
44 SV_DECL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr, 1, 1 )
45 
46 class String;
47 
48 class ScAddInAsync : public SvtBroadcaster
49 {
50 private:
51     union
52     {
53         double      nVal;               // aktueller Wert
54         String*     pStr;
55     };
56     ScAddInDocs*    pDocs;              // Liste der benutzenden Dokumente
57     FuncData*       pFuncData;          // Zeiger auf die Daten in der Collection
58     sal_uLong           nHandle;            // wird von double auf sal_uLong gecasted
59     ParamType       eType;              // PTR_DOUBLE oder PTR_STRING Ergebnis
60     sal_Bool            bValid;             // ob Wert gueltig
61 
62 public:
63                     // cTor nur wenn ScAddInAsync::Get fehlschlaegt!
64                     // nIndex: Index aus der FunctionCollection
65                     ScAddInAsync( sal_uLong nHandle, sal_uInt16 nIndex,
66                                     ScDocument* pDoc );
67                     // default-cTor nur fuer das eine globale aSeekObj !!!
68                     ScAddInAsync();
69     virtual         ~ScAddInAsync();
70     static ScAddInAsync*    Get( sal_uLong nHandle );
71     static void     CallBack( sal_uLong nHandle, void* pData );
72     static void     RemoveDocument( ScDocument* pDocument );
IsValid() const73     sal_Bool            IsValid() const         { return bValid; }
GetType() const74     ParamType       GetType() const         { return eType; }
GetValue() const75     double          GetValue() const        { return nVal; }
GetString() const76     const String&   GetString() const       { return *pStr; }
HasDocument(ScDocument * pDoc) const77     sal_Bool            HasDocument( ScDocument* pDoc ) const
78                         { return pDocs->Seek_Entry( pDoc ); }
AddDocument(ScDocument * pDoc)79     void            AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); }
80 
81     // Vergleichsoperatoren fuer PtrArrSort
operator <(const ScAddInAsync & r)82     sal_Bool operator < ( const ScAddInAsync& r ) { return nHandle <  r.nHandle; }
operator ==(const ScAddInAsync & r)83     sal_Bool operator ==( const ScAddInAsync& r ) { return nHandle == r.nHandle; }
84 };
85 
86 
87 
88 #endif
89