xref: /aoo41x/main/sc/inc/callform.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_CALLFORM_HXX
29 #define SC_CALLFORM_HXX
30 
31 #include "collect.hxx"
32 
33 //------------------------------------------------------------------------
34 #define MAXFUNCPARAM	16
35 #define MAXARRSIZE		0xfffe
36 
37 //------------------------------------------------------------------------
38 #ifndef WNT
39 #define CALLTYPE
40 #else
41 #define CALLTYPE			__cdecl
42 #endif
43 
44 extern "C" {
45 typedef void (CALLTYPE* AdvData)( double& nHandle, void* pData );
46 }
47 
48 //------------------------------------------------------------------------
49 enum ParamType
50 {
51 	PTR_DOUBLE,
52 	PTR_STRING,
53 	PTR_DOUBLE_ARR,
54 	PTR_STRING_ARR,
55 	PTR_CELL_ARR,
56 	NONE
57 };
58 
59 //------------------------------------------------------------------------
60 class ModuleData;
61 class FuncData : public ScDataObject
62 {
63 friend class FuncCollection;
64 	const ModuleData* pModuleData;
65 	String		aInternalName;
66 	String		aFuncName;
67 	sal_uInt16      nNumber;
68 	sal_uInt16		nParamCount;
69 	ParamType	eAsyncType;
70 	ParamType	eParamType[MAXFUNCPARAM];
71 private:
72 	FuncData(const String& rIName);
73 public:
74 	FuncData(const ModuleData*pModule,
75 			 const String&    rIName,
76 			 const String&    rFName,
77 				   sal_uInt16     nNo,
78 				   sal_uInt16     nCount,
79 			 const ParamType* peType,
80 				   ParamType  eType);
81 	FuncData(const FuncData& rData);
82 	virtual	ScDataObject*	Clone() const { return new FuncData(*this); }
83 
84 	const	String&		GetModuleName() const;
85 	const	String&		GetInternalName() const { return aInternalName; }
86 	const	String&		GetFuncName() const { return aFuncName; }
87 			sal_uInt16		GetParamCount() const { return nParamCount; }
88 			ParamType	GetParamType(sal_uInt16 nIndex) const { return eParamType[nIndex]; }
89 			ParamType	GetReturnType() const { return eParamType[0]; }
90 			ParamType	GetAsyncType() const { return eAsyncType; }
91 			sal_Bool        Call(void** ppParam);
92 			sal_Bool 		Unadvice(double nHandle);
93 
94 						// Name und Beschreibung des Parameters nParam.
95 						// nParam==0 => Desc := Funktions-Beschreibung,
96 						// Name := n/a
97 			sal_Bool		GetParamDesc( String& aName, String& aDesc, sal_uInt16 nParam );
98 };
99 
100 
101 //------------------------------------------------------------------------
102 class FuncCollection : public ScSortedCollection
103 {
104 public:
105 	FuncCollection(sal_uInt16 nLim = 4, sal_uInt16 nDel = 4, sal_Bool bDup = sal_False) : ScSortedCollection ( nLim, nDel, bDup ) {}
106 	FuncCollection(const FuncCollection& rFuncCollection) : ScSortedCollection ( rFuncCollection ) {}
107 
108 	virtual	ScDataObject*	Clone() const { return new FuncCollection(*this); }
109 			FuncData*	operator[]( const sal_uInt16 nIndex) const {return (FuncData*)At(nIndex);}
110 	virtual	short		Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
111 			sal_Bool 		SearchFunc( const String& rName, sal_uInt16& rIndex ) const;
112 };
113 
114 
115 sal_Bool InitExternalFunc(const rtl::OUString& rModuleName);
116 void ExitExternalFunc();
117 
118 #endif
119