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 // Basic.h : Declaration of the CBasic
28 
29 #ifndef __BASIC_H_
30 #define __BASIC_H_
31 
32 #include "resource.h"       // main symbols
33 //#include "AxTestComponents.h"
34 #import  "AxTestComponents.tlb" no_namespace no_implementation raw_interfaces_only named_guids
35 //#include "AxTestComponents.h"
36 /////////////////////////////////////////////////////////////////////////////
37 // CBasic
38 class ATL_NO_VTABLE CBasic :
39 	public CComObjectRootEx<CComSingleThreadModel>,
40 	public CComCoClass<CBasic, &CLSID_Basic>,
41 	public IDispatchImpl<IBasic, &IID_IBasic, &LIBID_AXTESTCOMPONENTSLib>
42 	{
43 public:
44 	CBasic();
45 	~CBasic();
46 
47 	DECLARE_REGISTRY_RESOURCEID(IDR_BASIC)
48 
49 	DECLARE_PROTECT_FINAL_CONSTRUCT()
50 
51 	BEGIN_COM_MAP(CBasic)
52 		COM_INTERFACE_ENTRY(IBasic)
53 		COM_INTERFACE_ENTRY(IDispatch)
54 	END_COM_MAP()
55 
56 	// IBasic
57 public:
58 	STDMETHOD(outMore)(/*[out]*/long* val1, /*[out]*/long* val2);
59 	STDMETHOD(inMulDimArrayByte2)(LPSAFEARRAY val);
60 	STDMETHOD(inMulDimArrayByte)(LPSAFEARRAY val);
61 	STDMETHOD(inMulDimArrayVariant2)(LPSAFEARRAY val);
62 	STDMETHOD(inMulDimArrayLong2)(LPSAFEARRAY val);
63 	STDMETHOD(inMulDimArrayVariant)(LPSAFEARRAY val);
64 	STDMETHOD(inMulDimArrayLong)( LPSAFEARRAY val);
65 	STDMETHOD(inoutSequenceObject)(LPSAFEARRAY* val);
66 	STDMETHOD(inoutSequenceDouble)(LPSAFEARRAY * val);
67 	STDMETHOD(inoutSequenceFloat)(LPSAFEARRAY * val);
68 	STDMETHOD(inoutSequenceString)(LPSAFEARRAY* val);
69 	STDMETHOD(inoutSequenceLong)(LPSAFEARRAY * val);
70 	STDMETHOD(inoutSequenceShort)(LPSAFEARRAY * val);
71 	STDMETHOD(inoutSequenceByte)(LPSAFEARRAY * val);
72 	STDMETHOD(outSequenceObject)(/*[out]*/ LPSAFEARRAY* val);
73 	STDMETHOD(outSequenceDouble)(/*[out]*/ LPSAFEARRAY* val);
74 	STDMETHOD(outSequenceFloat)(/*[out]*/ LPSAFEARRAY* val);
75 	STDMETHOD(outSequenceString)(/*[out]*/ LPSAFEARRAY* val);
76 	STDMETHOD(outSequenceLong)(/*[out]*/ LPSAFEARRAY* val);
77 	STDMETHOD(outSequenceShort)(/*[out]*/ LPSAFEARRAY* val);
78 	STDMETHOD(outSequenceByte)(/*[out]*/ LPSAFEARRAY* val);
79 	STDMETHOD(inSequenceObject)(LPSAFEARRAY ar);
80 	STDMETHOD(inSequenceDouble)(LPSAFEARRAY ar);
81 	STDMETHOD(inSequenceFloat)(LPSAFEARRAY ar);
82 	STDMETHOD(inSequenceString)(LPSAFEARRAY ar);
83 	STDMETHOD(inSequenceShort)(LPSAFEARRAY ar);
84 	STDMETHOD(inSequenceByte)(LPSAFEARRAY ar);
85 	STDMETHOD(inSequenceLong)(LPSAFEARRAY  ar);
86 	STDMETHOD(mixed1)(
87 		/* [out][in] */ unsigned char *aChar,
88 		/* [out][in] */ float *aFloat,
89 		/* [out][in] */ VARIANT *aVar);
90 		STDMETHOD(get_prpObject)(/*[out, retval]*/ IDispatch* *pVal);
91 	STDMETHOD(put_prpObject)(/*[in]*/ IDispatch* newVal);
92 	STDMETHOD(get_prpArray)(/*[out, retval]*/ LPSAFEARRAY *pVal);
93 	STDMETHOD(put_prpArray)(/*[in]*/ LPSAFEARRAY newVal);
94 	STDMETHOD(get_prpVariant)(/*[out, retval]*/ VARIANT *pVal);
95 	STDMETHOD(put_prpVariant)(/*[in]*/ VARIANT newVal);
96 	STDMETHOD(get_prpDouble)(/*[out, retval]*/ double *pVal);
97 	STDMETHOD(put_prpDouble)(/*[in]*/ double newVal);
98 	STDMETHOD(get_prpFloat)(/*[out, retval]*/ float *pVal);
99 	STDMETHOD(put_prpFloat)(/*[in]*/ float newVal);
100 	STDMETHOD(get_prpString)(/*[out, retval]*/ BSTR *pVal);
101 	STDMETHOD(put_prpString)(/*[in]*/ BSTR newVal);
102 	STDMETHOD(get_prpLong)(/*[out, retval]*/ long *pVal);
103 	STDMETHOD(put_prpLong)(/*[in]*/ long newVal);
104 	STDMETHOD(get_prpShort)(/*[out, retval]*/ short *pVal);
105 	STDMETHOD(put_prpShort)(/*[in]*/ short newVal);
106 	STDMETHOD(get_prpByte)(/*[out, retval]*/ unsigned char *pVal);
107 	STDMETHOD(put_prpByte)(/*[in]*/ unsigned char newVal);
108 	STDMETHOD(get_prpBool)(/*[out, retval]*/ VARIANT_BOOL *pVal);
109 	STDMETHOD(put_prpBool)(/*[in]*/ VARIANT_BOOL newVal);
110 
111 	STDMETHOD(outObject)(/*[out]*/ IDispatch* *val);
112 	STDMETHOD(outArray)(/*[out]*/ LPSAFEARRAY * val);
113 	STDMETHOD(outVariant)(/*[out]*/ VARIANT* val);
114 	STDMETHOD(outDouble)(/*[out]*/ double* val);
115 	STDMETHOD(outFloat)(/*[out]*/ float* val);
116 	STDMETHOD(outString)(/*[out]*/ BSTR* val);
117 	STDMETHOD(outLong)(/*[out]*/ long* val);
118 	STDMETHOD(outShort)(/*[out]*/ short* val);
119 	STDMETHOD(outByte)(/*[out]*/ unsigned char* val);
120 	STDMETHOD(outBool)(/*[out]*/ VARIANT_BOOL* val);
121 
122 	STDMETHOD(inoutObject)(/*[in,out]*/ IDispatch* *val);
123 	STDMETHOD(inoutArray)(/*[in,out]*/ LPSAFEARRAY * val);
124 	STDMETHOD(inoutVariant)(/*[in,out]*/ VARIANT * val);
125 	STDMETHOD(inoutDouble)(/*[in,out]*/ double * val);
126 	STDMETHOD(inoutFloat)(/*[in,out]*/ float * val);
127 	STDMETHOD(inoutString)(/*[in, out]*/ BSTR* val);
128 	STDMETHOD(inoutLong)(/*[in,out]*/ long * val);
129 	STDMETHOD(inoutShort)(/*[in,out]*/ short* val);
130 	STDMETHOD(inoutByte)(/*[in,out]*/ unsigned char* val);
131 	STDMETHOD(inoutBool)(/*[in,out]*/ VARIANT_BOOL* val);
132 
133 
134 	STDMETHOD(inObject)(/*[in]*/ IDispatch* val);
135 	STDMETHOD(inArray)(/*[in]*/ LPSAFEARRAY val);
136 	STDMETHOD(inVariant)(/*[in]*/ VARIANT val);
137 	STDMETHOD(inDouble)(/*[in]*/ double val);
138 	STDMETHOD(inFloat)(/*[in]*/ float val);
139 	STDMETHOD(inString)(/*[in]*/ BSTR val);
140 	STDMETHOD(inLong)(/*[in]*/ long val);
141 	STDMETHOD(inShort)(/*[in]*/ short val);
142 	STDMETHOD(inByte)(/*[in]*/ unsigned char val);
143 	STDMETHOD(inBool)(/*[in]*/ VARIANT_BOOL val);
144 
145 
146 	STDMETHOD(optional1)(/*[in]*/ long val1, /*[in, optional]*/ VARIANT* val2);
147 	STDMETHOD(optional2)(/*[out]*/ long* val1,/*[out, optional]*/ VARIANT* val2);
148 	STDMETHOD(optional3)(/*[in, optional]*/ VARIANT* val1,/*[in, optional]*/ VARIANT* val2);
149 	STDMETHOD(optional4)(/*[in, out, optional]*/ VARIANT* val1,/*[in, out, optional]*/ VARIANT* val2);
150 	STDMETHOD(optional5)(/*[out, optional]*/ VARIANT* val1,/*[out, optional]*/ VARIANT* val2);
151 
152 
153 	STDMETHOD(defaultvalue1)(/*[in, defaultvalue(10)]*/ long val1,
154 		/*[in, defaultvalue(3.14)]*/ double* val2,
155 		// /*[in, defaultvalue(10)]*/ VARIANT val3,
156 		/*[in, defaultvalue(100)]*/ VARIANT* val4);
157 
158 		STDMETHOD(defaultvalue2)(/*[in, out, defaultvalue(10)]*/ long* val1,
159 		/*[in, out, defaultvalue(3.14)]*/ double* val2,
160 		// /*[in, out, defaultvalue(10)]*/ VARIANT* val3,
161 		/*[in, out, defaultvalue(100)]*/ VARIANT* val4);
162 
163 		STDMETHOD(varargfunc1)(/*[in]*/ long val1,/*[in]*/ LPSAFEARRAY val2);
164 
165 	STDMETHOD(varargfunc2)(/*[out]*/ long* val1, /*[out]*/ SAFEARRAY ** val2);
166 
167 
168 	// members for property implementations
169 	unsigned char m_cPrpByte;
170 	short m_nPrpShort;
171 	long m_lPrpLong;
172 	float m_fPrpFloat;
173 	double m_dPrpDouble;
174 	CComPtr<IDispatch> m_PrpObject;
175 	CComPtr<IUnknown> m_prpUnknown;
176 
177 	CComBSTR m_bstrPrpString;
178 	CComVariant m_PropVariant;
179 	LPSAFEARRAY m_PrpArray;
180 protected:
181 	VARIANT_BOOL m_bool;
182 	unsigned char  m_byte;
183 	short m_short;
184 	long m_long;
185 	long m_long2;
186 	float m_float;
187 	double m_double;
188 	CComVariant m_var1;
189 	CComVariant m_var2;
190 	CComVariant m_var3;
191 	CComVariant m_var4;
192 	CComBSTR m_bstr;
193 	CY m_cy;
194 	DATE m_date;
195 	DECIMAL m_decimal;
196 	SCODE m_scode;
197 	SAFEARRAY * m_safearray;
198 	CComPtr<IDispatch> m_obj;
199 	CComPtr<IUnknown> m_unknown;
200 
201 	SAFEARRAY * m_arByte;
202 	SAFEARRAY * m_arShort;
203 	SAFEARRAY * m_arLong;
204 	SAFEARRAY * m_arString;
205 	SAFEARRAY * m_arVariant;
206 	SAFEARRAY * m_arFloat;
207 	SAFEARRAY * m_arDouble;
208 	SAFEARRAY * m_arObject;
209 	SAFEARRAY * m_arByteDim2;
210 
211 	static void printArray(LPSAFEARRAY val, BSTR message, VARTYPE type);
212 	static void printMulArray(LPSAFEARRAY val, VARTYPE type);
213 
214 
215 public:
216 	STDMETHOD(inSequenceByteDim2)(LPSAFEARRAY val);
217 	STDMETHOD(inCurrency)(CY val);
218 	STDMETHOD(outCurrency)(CY* val);
219 	STDMETHOD(inoutCurrency)(CY* val);
220 	STDMETHOD(inDate)(DATE val);
221 	STDMETHOD(outDate)(DATE* val);
222 	STDMETHOD(inoutDate)(DATE* val);
223 	STDMETHOD(get_prpCurrency)(CY* pVal);
224 	STDMETHOD(put_prpCurrency)(CY newVal);
225 	STDMETHOD(get_prpDate)(DATE* pVal);
226 	STDMETHOD(put_prpDate)(DATE newVal);
227 	STDMETHOD(inDecimal)(DECIMAL val);
228 	STDMETHOD(outDecimal)(DECIMAL* val);
229 	STDMETHOD(inoutDecimal)(DECIMAL* val);
230 	STDMETHOD(get_prpDecimal)(DECIMAL* pVal);
231 	STDMETHOD(put_prpDecimal)(DECIMAL newVal);
232 	STDMETHOD(inSCode)(SCODE val);
233 	STDMETHOD(outScode)(SCODE* val);
234 	STDMETHOD(inoutSCode)(SCODE* val);
235 	STDMETHOD(get_prpSCode)(SCODE* pVal);
236 	STDMETHOD(put_prpSCode)(SCODE newVal);
237 	STDMETHOD(inrefLong)(LONG* val);
238 	STDMETHOD(inrefVariant)(VARIANT* val);
239 	STDMETHOD(inrefDecimal)(DECIMAL* val);
240 	STDMETHOD(get_prpRefLong)(long* pVal);
241 	STDMETHOD(putref_prpRefLong)(long* newVal);
242 	STDMETHOD(get_prprefVariant)(VARIANT* pVal);
243 	STDMETHOD(putref_prprefVariant)(VARIANT* newVal);
244 	STDMETHOD(get_prprefDecimal)(DECIMAL* pVal);
245 	STDMETHOD(putref_prprefDecimal)(DECIMAL* newVal);
246 	STDMETHOD(optional6)(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4);
247 	STDMETHOD(optional7)(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4);
248 
249 	STDMETHOD(get_prpMultiArg1)(VARIANT* val1, VARIANT* val2, VARIANT* pVal);
250 	//STDMETHOD(get_prpMultiArg1)(VARIANT* val1, VARIANT* pVal);
251 	STDMETHOD(put_prpMultiArg1)(VARIANT* val1, VARIANT* val2, VARIANT* newVal);
252 	//STDMETHOD(put_prpMultiArg1)(VARIANT* val1, VARIANT* newVal);
253 	STDMETHOD(get_prpMultiArg2)(VARIANT val1, VARIANT* pVal);
254 	STDMETHOD(put_prpMultiArg2)(VARIANT val1, VARIANT newVal);
255 	STDMETHOD(prpMultiArg2GetValues)(VARIANT* val1, VARIANT* valProperty);
256 	STDMETHOD(get_prpMultiArg3)(LONG* val1, LONG* pVal);
257 	STDMETHOD(put_prpMultiArg3)(LONG* val1, LONG newVal);
258 
259 	// IFoo Methods
260 public:
261 	STDMETHOD(inUnknown)(IUnknown* val);
262 	STDMETHOD(outUnknown)(IUnknown** val);
263 	STDMETHOD(inoutUnknown)(IUnknown** val);
264 	STDMETHOD(get_prpUnknown)(IUnknown** pVal);
265 	STDMETHOD(put_prpUnknown)(IUnknown* newVal);
266 };
267 
268 #endif //__BASIC_H_
269 
270