xref: /trunk/main/sc/source/core/inc/adiasync.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef SC_ADIASYNC_HXX
29 #define SC_ADIASYNC_HXX
30 
31 #include <svl/broadcast.hxx>
32 #include <svl/svarray.hxx>
33 
34 #include "callform.hxx"
35 
36 extern "C" {
37 void CALLTYPE ScAddInAsyncCallBack( double& nHandle, void* pData );
38 }
39 
40 
41 class ScAddInAsync;
42 typedef ScAddInAsync* ScAddInAsyncPtr;
43 SV_DECL_PTRARR_SORT( ScAddInAsyncs, ScAddInAsyncPtr, 4, 4 )
44 extern ScAddInAsyncs theAddInAsyncTbl;	// in adiasync.cxx
45 
46 class ScDocument;
47 typedef ScDocument* ScAddInDocPtr;
48 SV_DECL_PTRARR_SORT( ScAddInDocs, ScAddInDocPtr, 1, 1 )
49 
50 class String;
51 
52 class ScAddInAsync : public SvtBroadcaster
53 {
54 private:
55 	union
56 	{
57 		double		nVal;				// aktueller Wert
58 		String*		pStr;
59 	};
60 	ScAddInDocs*	pDocs;				// Liste der benutzenden Dokumente
61 	FuncData* 		pFuncData;			// Zeiger auf die Daten in der Collection
62 	sal_uLong			nHandle;			// wird von double auf sal_uLong gecasted
63 	ParamType		eType;				// PTR_DOUBLE oder PTR_STRING Ergebnis
64 	sal_Bool			bValid;				// ob Wert gueltig
65 
66 public:
67 					// cTor nur wenn ScAddInAsync::Get fehlschlaegt!
68 					// nIndex: Index aus der FunctionCollection
69 					ScAddInAsync( sal_uLong nHandle, sal_uInt16 nIndex,
70 									ScDocument* pDoc );
71 					// default-cTor nur fuer das eine globale aSeekObj !!!
72 					ScAddInAsync();
73 	virtual			~ScAddInAsync();
74 	static ScAddInAsync*	Get( sal_uLong nHandle );
75 	static void		CallBack( sal_uLong nHandle, void* pData );
76 	static void		RemoveDocument( ScDocument* pDocument );
77 	sal_Bool			IsValid() const			{ return bValid; }
78 	ParamType		GetType() const			{ return eType; }
79 	double			GetValue() const		{ return nVal; }
80 	const String&	GetString() const		{ return *pStr; }
81 	sal_Bool			HasDocument( ScDocument* pDoc ) const
82 						{ return pDocs->Seek_Entry( pDoc ); }
83 	void			AddDocument( ScDocument* pDoc ) { pDocs->Insert( pDoc ); }
84 
85 	// Vergleichsoperatoren fuer PtrArrSort
86 	sal_Bool operator < ( const ScAddInAsync& r ) { return nHandle <  r.nHandle; }
87 	sal_Bool operator ==( const ScAddInAsync& r ) { return nHandle == r.nHandle; }
88 };
89 
90 
91 
92 #endif
93