xref: /AOO41X/main/extensions/test/ole/AxTestComponents/Basic.cpp (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #include "stdafx.h"
28*cdf0e10cSrcweir //#include "AxTestComponents.h"
29*cdf0e10cSrcweir #include "Basic.h"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir 
33*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
34*cdf0e10cSrcweir // CBasic
35*cdf0e10cSrcweir CBasic::CBasic():	m_cPrpByte(0),m_nPrpShort(0),m_lPrpLong(0),m_fPrpFloat(0), m_dPrpDouble(0),m_PrpArray(0),
36*cdf0e10cSrcweir m_safearray(NULL), m_bool(VARIANT_FALSE),
37*cdf0e10cSrcweir m_arByte(0), m_arShort(0), m_arLong(0), m_arString(0), m_arVariant(0), m_arFloat(0),
38*cdf0e10cSrcweir m_arDouble(0), m_arObject(0), m_arByteDim2(0), m_date(0.), m_scode(0)
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir {
41*cdf0e10cSrcweir 	memset(&m_cy, 0, sizeof(CY));
42*cdf0e10cSrcweir 	memset(&m_decimal, 0, sizeof(DECIMAL));
43*cdf0e10cSrcweir }
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir CBasic::~CBasic()
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir 	SafeArrayDestroy(m_safearray);
48*cdf0e10cSrcweir 	SafeArrayDestroy(m_arByte);
49*cdf0e10cSrcweir 	SafeArrayDestroy(m_arShort);
50*cdf0e10cSrcweir 	SafeArrayDestroy(m_arLong);
51*cdf0e10cSrcweir 	SafeArrayDestroy(m_arString);
52*cdf0e10cSrcweir 	SafeArrayDestroy(m_arVariant);
53*cdf0e10cSrcweir 	SafeArrayDestroy(m_arFloat);
54*cdf0e10cSrcweir 	SafeArrayDestroy(m_arDouble);
55*cdf0e10cSrcweir 	SafeArrayDestroy(m_arObject);
56*cdf0e10cSrcweir 	SafeArrayDestroy(m_arByteDim2);
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir }
59*cdf0e10cSrcweir STDMETHODIMP CBasic::inBool(VARIANT_BOOL val)
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir 	m_bool = val;
62*cdf0e10cSrcweir 	return S_OK;
63*cdf0e10cSrcweir }
64*cdf0e10cSrcweir STDMETHODIMP CBasic::inByte(unsigned char val)
65*cdf0e10cSrcweir {
66*cdf0e10cSrcweir 	m_byte = val;
67*cdf0e10cSrcweir 	return S_OK;
68*cdf0e10cSrcweir }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir STDMETHODIMP CBasic::inShort(short val)
71*cdf0e10cSrcweir {
72*cdf0e10cSrcweir 	m_short = val;
73*cdf0e10cSrcweir 	return S_OK;
74*cdf0e10cSrcweir }
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir STDMETHODIMP CBasic::inLong(long val)
77*cdf0e10cSrcweir {
78*cdf0e10cSrcweir 	m_long = val;
79*cdf0e10cSrcweir 	return S_OK;
80*cdf0e10cSrcweir }
81*cdf0e10cSrcweir 
82*cdf0e10cSrcweir STDMETHODIMP CBasic::inString(BSTR val)
83*cdf0e10cSrcweir {
84*cdf0e10cSrcweir 	m_bstr = val;
85*cdf0e10cSrcweir 	return S_OK;
86*cdf0e10cSrcweir }
87*cdf0e10cSrcweir 
88*cdf0e10cSrcweir STDMETHODIMP CBasic::inFloat(float val)
89*cdf0e10cSrcweir {
90*cdf0e10cSrcweir 	m_float = val;
91*cdf0e10cSrcweir 	return S_OK;
92*cdf0e10cSrcweir }
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir STDMETHODIMP CBasic::inDouble(double val)
95*cdf0e10cSrcweir {
96*cdf0e10cSrcweir 	m_double = val;
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir 	CComVariant varDest;
99*cdf0e10cSrcweir 	CComVariant varSource(val);
100*cdf0e10cSrcweir 	HRESULT hr = VariantChangeType(&varDest, &varSource, 0, VT_BSTR);
101*cdf0e10cSrcweir 	return S_OK;
102*cdf0e10cSrcweir }
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir STDMETHODIMP CBasic::inVariant(VARIANT val)
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir 	m_var1 = val;
107*cdf0e10cSrcweir 	return S_OK;
108*cdf0e10cSrcweir }
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir STDMETHODIMP CBasic::inArray(LPSAFEARRAY val)
111*cdf0e10cSrcweir {
112*cdf0e10cSrcweir 	HRESULT hr = S_OK;
113*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_safearray)))
114*cdf0e10cSrcweir 		return hr;
115*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, &m_safearray)))
116*cdf0e10cSrcweir 		return hr;
117*cdf0e10cSrcweir 	return S_OK;
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir 
120*cdf0e10cSrcweir STDMETHODIMP CBasic::inObject(IDispatch *val)
121*cdf0e10cSrcweir {
122*cdf0e10cSrcweir 	m_obj = val;
123*cdf0e10cSrcweir 	return S_OK;
124*cdf0e10cSrcweir }
125*cdf0e10cSrcweir 
126*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutBool(VARIANT_BOOL* val)
127*cdf0e10cSrcweir {
128*cdf0e10cSrcweir 	VARIANT_BOOL aBool = *val;
129*cdf0e10cSrcweir 	*val = m_bool;
130*cdf0e10cSrcweir 	m_bool = aBool;
131*cdf0e10cSrcweir 	return S_OK;
132*cdf0e10cSrcweir }
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutByte(unsigned char* val)
136*cdf0e10cSrcweir {
137*cdf0e10cSrcweir 	unsigned char aByte = *val;
138*cdf0e10cSrcweir 	*val = m_byte;
139*cdf0e10cSrcweir 	m_byte = aByte;
140*cdf0e10cSrcweir 	return S_OK;
141*cdf0e10cSrcweir }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutShort(short *val)
144*cdf0e10cSrcweir {
145*cdf0e10cSrcweir 	short aShort = *val;
146*cdf0e10cSrcweir 	*val = m_short;
147*cdf0e10cSrcweir 	m_short = aShort;
148*cdf0e10cSrcweir 	return S_OK;
149*cdf0e10cSrcweir }
150*cdf0e10cSrcweir 
151*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutLong(long *val)
152*cdf0e10cSrcweir {
153*cdf0e10cSrcweir 	long aLong = *val;
154*cdf0e10cSrcweir 	*val = m_long;
155*cdf0e10cSrcweir 	m_long = aLong;
156*cdf0e10cSrcweir 	return S_OK;
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutString(BSTR *val)
160*cdf0e10cSrcweir {
161*cdf0e10cSrcweir 	CComBSTR aStr = *val;
162*cdf0e10cSrcweir 	HRESULT hr = S_OK;
163*cdf0e10cSrcweir 	if (FAILED( hr = m_bstr.CopyTo(val)))
164*cdf0e10cSrcweir 		return hr;
165*cdf0e10cSrcweir 	m_bstr = aStr;
166*cdf0e10cSrcweir 	return S_OK;
167*cdf0e10cSrcweir }
168*cdf0e10cSrcweir 
169*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutFloat(float *val)
170*cdf0e10cSrcweir {
171*cdf0e10cSrcweir 	float aFloat = *val;
172*cdf0e10cSrcweir 	*val = m_float;
173*cdf0e10cSrcweir 	m_float = aFloat;
174*cdf0e10cSrcweir 	return S_OK;
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutDouble(double *val)
178*cdf0e10cSrcweir {
179*cdf0e10cSrcweir 	double aDouble = *val;
180*cdf0e10cSrcweir 	*val = m_double;
181*cdf0e10cSrcweir 	m_double  = aDouble;
182*cdf0e10cSrcweir 	return S_OK;
183*cdf0e10cSrcweir }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutVariant(VARIANT *val)
186*cdf0e10cSrcweir {
187*cdf0e10cSrcweir 	CComVariant aVar = *val;
188*cdf0e10cSrcweir 	HRESULT hr = S_OK;
189*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val, &m_var1)))
190*cdf0e10cSrcweir 		return hr;
191*cdf0e10cSrcweir 	m_var1 = aVar;
192*cdf0e10cSrcweir 	return S_OK;
193*cdf0e10cSrcweir }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir /* The array contains VARIANT according to IDL.
196*cdf0e10cSrcweir 	If the VARIANTs contain strings then we append "out" to each string.
197*cdf0e10cSrcweir */
198*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutArray(LPSAFEARRAY *val)
199*cdf0e10cSrcweir {
200*cdf0e10cSrcweir 	SAFEARRAY* aAr = NULL;
201*cdf0e10cSrcweir 	HRESULT hr = S_OK;
202*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(*val, &aAr)))
203*cdf0e10cSrcweir 		return hr;
204*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_safearray, val)))
205*cdf0e10cSrcweir 		return hr;
206*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(aAr, & m_safearray)))
207*cdf0e10cSrcweir 		return hr;
208*cdf0e10cSrcweir 	return S_OK;
209*cdf0e10cSrcweir }
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutObject(IDispatch **val)
212*cdf0e10cSrcweir {
213*cdf0e10cSrcweir 	CComPtr<IDispatch> disp = *val;
214*cdf0e10cSrcweir 	if (*val)
215*cdf0e10cSrcweir 		(*val)->Release();
216*cdf0e10cSrcweir 	*val = m_obj;
217*cdf0e10cSrcweir 	if (*val)
218*cdf0e10cSrcweir 		(*val)->AddRef();
219*cdf0e10cSrcweir 	m_obj = disp;
220*cdf0e10cSrcweir 	return S_OK;
221*cdf0e10cSrcweir }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir STDMETHODIMP CBasic::outBool(VARIANT_BOOL* val)
225*cdf0e10cSrcweir {
226*cdf0e10cSrcweir 	*val = m_bool;
227*cdf0e10cSrcweir 	return S_OK;
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir STDMETHODIMP CBasic::outByte(unsigned char *val)
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir 	*val= m_byte;
233*cdf0e10cSrcweir 	return S_OK;
234*cdf0e10cSrcweir }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir STDMETHODIMP CBasic::outShort(short *val)
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir 	*val= m_short;
239*cdf0e10cSrcweir 	return S_OK;
240*cdf0e10cSrcweir }
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir STDMETHODIMP CBasic::outLong(long *val)
243*cdf0e10cSrcweir {
244*cdf0e10cSrcweir 	*val= m_long;
245*cdf0e10cSrcweir 	return S_OK;
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir STDMETHODIMP CBasic::outString(BSTR *val)
249*cdf0e10cSrcweir {
250*cdf0e10cSrcweir 	*val= SysAllocString(m_bstr);
251*cdf0e10cSrcweir 	return S_OK;
252*cdf0e10cSrcweir }
253*cdf0e10cSrcweir 
254*cdf0e10cSrcweir STDMETHODIMP CBasic::outFloat(float *val)
255*cdf0e10cSrcweir {
256*cdf0e10cSrcweir 	*val= m_float;
257*cdf0e10cSrcweir 	return S_OK;
258*cdf0e10cSrcweir }
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir STDMETHODIMP CBasic::outDouble(double *val)
261*cdf0e10cSrcweir {
262*cdf0e10cSrcweir 	*val= m_double;
263*cdf0e10cSrcweir 	return S_OK;
264*cdf0e10cSrcweir }
265*cdf0e10cSrcweir 
266*cdf0e10cSrcweir STDMETHODIMP CBasic::outVariant(VARIANT *val)
267*cdf0e10cSrcweir {
268*cdf0e10cSrcweir 	HRESULT hr = S_OK;
269*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val, &m_var1)))
270*cdf0e10cSrcweir 		return hr;
271*cdf0e10cSrcweir 	return S_OK;
272*cdf0e10cSrcweir }
273*cdf0e10cSrcweir 
274*cdf0e10cSrcweir STDMETHODIMP CBasic::outArray(LPSAFEARRAY *val)
275*cdf0e10cSrcweir {
276*cdf0e10cSrcweir 	HRESULT hr = S_OK;
277*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_safearray, val)))
278*cdf0e10cSrcweir 		return false;
279*cdf0e10cSrcweir 	return S_OK;
280*cdf0e10cSrcweir }
281*cdf0e10cSrcweir 
282*cdf0e10cSrcweir STDMETHODIMP CBasic::outObject(IDispatch* *val)
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir 	*val = m_obj;
285*cdf0e10cSrcweir 	if (m_obj)
286*cdf0e10cSrcweir 		(*val)->AddRef();
287*cdf0e10cSrcweir 
288*cdf0e10cSrcweir 	return S_OK;
289*cdf0e10cSrcweir }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir 
292*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpBool(VARIANT_BOOL* pVal)
293*cdf0e10cSrcweir {
294*cdf0e10cSrcweir 	if (!pVal) return E_POINTER;
295*cdf0e10cSrcweir 	*pVal = m_bool;
296*cdf0e10cSrcweir 	return S_OK;
297*cdf0e10cSrcweir }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpBool(VARIANT_BOOL val)
300*cdf0e10cSrcweir {
301*cdf0e10cSrcweir 	m_bool = val;
302*cdf0e10cSrcweir 	return S_OK;
303*cdf0e10cSrcweir }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpByte(unsigned char *pVal)
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	if( !pVal)
309*cdf0e10cSrcweir 		return E_POINTER;
310*cdf0e10cSrcweir 	*pVal= m_cPrpByte;
311*cdf0e10cSrcweir 	return S_OK;
312*cdf0e10cSrcweir }
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpByte(unsigned char newVal)
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir 	m_cPrpByte= newVal;
317*cdf0e10cSrcweir 	return S_OK;
318*cdf0e10cSrcweir }
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpShort(short *pVal)
321*cdf0e10cSrcweir {
322*cdf0e10cSrcweir 	if( !pVal)
323*cdf0e10cSrcweir 		return E_POINTER;
324*cdf0e10cSrcweir 	*pVal= m_nPrpShort;
325*cdf0e10cSrcweir 	return S_OK;
326*cdf0e10cSrcweir }
327*cdf0e10cSrcweir 
328*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpShort(short newVal)
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir 	m_nPrpShort= newVal;
331*cdf0e10cSrcweir 	return S_OK;
332*cdf0e10cSrcweir }
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpLong(long *pVal)
335*cdf0e10cSrcweir {
336*cdf0e10cSrcweir 	if( !pVal)
337*cdf0e10cSrcweir 		return E_POINTER;
338*cdf0e10cSrcweir 	*pVal= m_lPrpLong;
339*cdf0e10cSrcweir 	return S_OK;
340*cdf0e10cSrcweir }
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpLong(long newVal)
343*cdf0e10cSrcweir {
344*cdf0e10cSrcweir 	m_lPrpLong= newVal;
345*cdf0e10cSrcweir 	return S_OK;
346*cdf0e10cSrcweir }
347*cdf0e10cSrcweir 
348*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpString(BSTR *pVal)
349*cdf0e10cSrcweir {
350*cdf0e10cSrcweir 	if( !pVal)
351*cdf0e10cSrcweir 		return E_POINTER;
352*cdf0e10cSrcweir 	m_bstrPrpString.CopyTo( pVal );
353*cdf0e10cSrcweir 	return S_OK;
354*cdf0e10cSrcweir }
355*cdf0e10cSrcweir 
356*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpString(BSTR newVal)
357*cdf0e10cSrcweir {
358*cdf0e10cSrcweir 	m_bstrPrpString= newVal;
359*cdf0e10cSrcweir 	return S_OK;
360*cdf0e10cSrcweir }
361*cdf0e10cSrcweir 
362*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpFloat(float *pVal)
363*cdf0e10cSrcweir {
364*cdf0e10cSrcweir 	if( !pVal)
365*cdf0e10cSrcweir 		return E_POINTER;
366*cdf0e10cSrcweir 	*pVal= m_fPrpFloat;
367*cdf0e10cSrcweir 	return S_OK;
368*cdf0e10cSrcweir }
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpFloat(float newVal)
371*cdf0e10cSrcweir {
372*cdf0e10cSrcweir 	m_fPrpFloat= newVal;
373*cdf0e10cSrcweir 	return S_OK;
374*cdf0e10cSrcweir }
375*cdf0e10cSrcweir 
376*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpDouble(double *pVal)
377*cdf0e10cSrcweir {
378*cdf0e10cSrcweir 	if( !pVal)
379*cdf0e10cSrcweir 		return E_POINTER;
380*cdf0e10cSrcweir 	*pVal= m_dPrpDouble;
381*cdf0e10cSrcweir 	return S_OK;
382*cdf0e10cSrcweir }
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpDouble(double newVal)
385*cdf0e10cSrcweir {
386*cdf0e10cSrcweir 	m_dPrpDouble= newVal;
387*cdf0e10cSrcweir 	return S_OK;
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpVariant(VARIANT *pVal)
391*cdf0e10cSrcweir {
392*cdf0e10cSrcweir 	if( !pVal)
393*cdf0e10cSrcweir 		return E_POINTER;
394*cdf0e10cSrcweir 	HRESULT hr = S_OK;
395*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy( pVal, &m_PropVariant)))
396*cdf0e10cSrcweir 		return hr;
397*cdf0e10cSrcweir 	return hr;
398*cdf0e10cSrcweir }
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpVariant(VARIANT newVal)
401*cdf0e10cSrcweir {
402*cdf0e10cSrcweir 	m_PropVariant= newVal;
403*cdf0e10cSrcweir 	return S_OK;
404*cdf0e10cSrcweir }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpArray(LPSAFEARRAY *pVal)
407*cdf0e10cSrcweir {
408*cdf0e10cSrcweir 	if( !pVal)
409*cdf0e10cSrcweir 		return E_POINTER;
410*cdf0e10cSrcweir 	HRESULT hr = S_OK;
411*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy( m_PrpArray, pVal)))
412*cdf0e10cSrcweir 		return hr;
413*cdf0e10cSrcweir 	return hr;
414*cdf0e10cSrcweir }
415*cdf0e10cSrcweir 
416*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpArray(LPSAFEARRAY newVal)
417*cdf0e10cSrcweir {
418*cdf0e10cSrcweir 	HRESULT hr = S_OK;
419*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy( m_PrpArray)))
420*cdf0e10cSrcweir 		return hr;
421*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy( newVal, &m_PrpArray)))
422*cdf0e10cSrcweir 		return hr;
423*cdf0e10cSrcweir 	return hr;
424*cdf0e10cSrcweir }
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpObject(IDispatch **pVal)
427*cdf0e10cSrcweir {
428*cdf0e10cSrcweir 	if( !pVal)
429*cdf0e10cSrcweir 		return E_POINTER;
430*cdf0e10cSrcweir 	*pVal= m_PrpObject;
431*cdf0e10cSrcweir 	if( *pVal != NULL)
432*cdf0e10cSrcweir 		(*pVal)->AddRef();
433*cdf0e10cSrcweir 	return S_OK;
434*cdf0e10cSrcweir }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpObject(IDispatch *newVal)
437*cdf0e10cSrcweir {
438*cdf0e10cSrcweir 	m_PrpObject= newVal;
439*cdf0e10cSrcweir 	return S_OK;
440*cdf0e10cSrcweir }
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir STDMETHODIMP CBasic::mixed1(
443*cdf0e10cSrcweir             /* [out][in] */ unsigned char *aChar,
444*cdf0e10cSrcweir 			/* [out][in] */ float *aFloat,
445*cdf0e10cSrcweir             /* [out][in] */ VARIANT *aVar)
446*cdf0e10cSrcweir 
447*cdf0e10cSrcweir {
448*cdf0e10cSrcweir 	HRESULT hr= S_OK;
449*cdf0e10cSrcweir 	inoutByte(aChar);
450*cdf0e10cSrcweir 	inoutFloat(aFloat);
451*cdf0e10cSrcweir 	inoutVariant(aVar);
452*cdf0e10cSrcweir 	return hr;
453*cdf0e10cSrcweir }
454*cdf0e10cSrcweir 
455*cdf0e10cSrcweir 
456*cdf0e10cSrcweir 
457*cdf0e10cSrcweir 
458*cdf0e10cSrcweir // VT_UI1
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir STDMETHODIMP CBasic::inSequenceLong(LPSAFEARRAY val)
461*cdf0e10cSrcweir {
462*cdf0e10cSrcweir 	HRESULT hr = S_OK;
463*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arLong)))
464*cdf0e10cSrcweir 		return hr;
465*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arLong)))
466*cdf0e10cSrcweir 		return hr;
467*cdf0e10cSrcweir 	return hr;
468*cdf0e10cSrcweir }
469*cdf0e10cSrcweir 
470*cdf0e10cSrcweir STDMETHODIMP CBasic::inSequenceByte( LPSAFEARRAY val)
471*cdf0e10cSrcweir {
472*cdf0e10cSrcweir 	HRESULT hr = S_OK;
473*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arByte)))
474*cdf0e10cSrcweir 		return hr;
475*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arByte)))
476*cdf0e10cSrcweir 		return hr;
477*cdf0e10cSrcweir 	return hr;
478*cdf0e10cSrcweir }
479*cdf0e10cSrcweir 
480*cdf0e10cSrcweir STDMETHODIMP CBasic::inSequenceShort(LPSAFEARRAY val)
481*cdf0e10cSrcweir {
482*cdf0e10cSrcweir 	HRESULT hr = S_OK;
483*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arShort)))
484*cdf0e10cSrcweir 		return hr;
485*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arShort)))
486*cdf0e10cSrcweir 		return hr;
487*cdf0e10cSrcweir 	return hr;
488*cdf0e10cSrcweir }
489*cdf0e10cSrcweir 
490*cdf0e10cSrcweir STDMETHODIMP CBasic::inSequenceString(LPSAFEARRAY val)
491*cdf0e10cSrcweir {
492*cdf0e10cSrcweir 	HRESULT hr = S_OK;
493*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arString)))
494*cdf0e10cSrcweir 		return hr;
495*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arString)))
496*cdf0e10cSrcweir 		return hr;
497*cdf0e10cSrcweir 	return hr;
498*cdf0e10cSrcweir }
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir STDMETHODIMP CBasic::inSequenceFloat(LPSAFEARRAY val)
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir 	HRESULT hr = S_OK;
503*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arFloat)))
504*cdf0e10cSrcweir 		return hr;
505*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arFloat)))
506*cdf0e10cSrcweir 		return hr;
507*cdf0e10cSrcweir 	return hr;
508*cdf0e10cSrcweir }
509*cdf0e10cSrcweir 
510*cdf0e10cSrcweir STDMETHODIMP CBasic::inSequenceDouble(LPSAFEARRAY val)
511*cdf0e10cSrcweir {
512*cdf0e10cSrcweir 	HRESULT hr = S_OK;
513*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arDouble)))
514*cdf0e10cSrcweir 		return hr;
515*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arDouble)))
516*cdf0e10cSrcweir 		return hr;
517*cdf0e10cSrcweir 	return hr;
518*cdf0e10cSrcweir }
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir STDMETHODIMP CBasic::inSequenceObject(LPSAFEARRAY val)
521*cdf0e10cSrcweir {
522*cdf0e10cSrcweir 	HRESULT hr = S_OK;
523*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arObject)))
524*cdf0e10cSrcweir 		return hr;
525*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arObject)))
526*cdf0e10cSrcweir 		return hr;
527*cdf0e10cSrcweir 	return hr;
528*cdf0e10cSrcweir }
529*cdf0e10cSrcweir 
530*cdf0e10cSrcweir void CBasic::printArray( LPSAFEARRAY val, BSTR message, VARTYPE type)
531*cdf0e10cSrcweir {
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir 	HRESULT hr= S_OK;
534*cdf0e10cSrcweir 	USES_CONVERSION;
535*cdf0e10cSrcweir 	long lbound=0;
536*cdf0e10cSrcweir 	long ubound= 0;
537*cdf0e10cSrcweir 	hr= SafeArrayGetLBound( val, 1, &lbound);
538*cdf0e10cSrcweir 	hr= SafeArrayGetUBound( val, 1, &ubound);
539*cdf0e10cSrcweir 	long length= ubound - lbound +1;
540*cdf0e10cSrcweir 
541*cdf0e10cSrcweir 	CComVariant varElement;
542*cdf0e10cSrcweir 	char buf[1024];
543*cdf0e10cSrcweir 	sprintf( buf,"%s", W2A(message));
544*cdf0e10cSrcweir 
545*cdf0e10cSrcweir 	for( long i= 0; i < length ; i++)
546*cdf0e10cSrcweir 	{
547*cdf0e10cSrcweir 		char tmp[1024];
548*cdf0e10cSrcweir 		long data=0;
549*cdf0e10cSrcweir 		CComVariant var;
550*cdf0e10cSrcweir 		switch( type)
551*cdf0e10cSrcweir 		{
552*cdf0e10cSrcweir 		case VT_UI1:
553*cdf0e10cSrcweir 		case VT_I2:
554*cdf0e10cSrcweir 		case VT_I4:
555*cdf0e10cSrcweir 		case VT_ERROR:
556*cdf0e10cSrcweir 			hr= SafeArrayGetElement( val, &i, (void*)&data);
557*cdf0e10cSrcweir 			sprintf( tmp, "%d \n", *(long*)&data);
558*cdf0e10cSrcweir 			break;
559*cdf0e10cSrcweir 		case VT_BSTR:
560*cdf0e10cSrcweir 			hr= SafeArrayGetElement( val, &i, (void*)&data);
561*cdf0e10cSrcweir 			sprintf( tmp, "%S \n", (BSTR)data);
562*cdf0e10cSrcweir 			break;
563*cdf0e10cSrcweir 		case VT_VARIANT:
564*cdf0e10cSrcweir 			hr= SafeArrayGetElement( val, &i, &var);
565*cdf0e10cSrcweir 			sprintf( tmp, "%x \n", var.byref);
566*cdf0e10cSrcweir 			break;
567*cdf0e10cSrcweir 		case VT_R4:
568*cdf0e10cSrcweir 			hr= SafeArrayGetElement( val, &i, (void*)&data);
569*cdf0e10cSrcweir 			sprintf( tmp, "%f \n", *(float*) &data);
570*cdf0e10cSrcweir 			break;
571*cdf0e10cSrcweir 		case VT_R8: ;
572*cdf0e10cSrcweir 			hr= SafeArrayGetElement( val, &i, (void*)&data);
573*cdf0e10cSrcweir 			sprintf( tmp, "%f \n", *(double*) &data);
574*cdf0e10cSrcweir 			break;
575*cdf0e10cSrcweir 		case VT_DISPATCH:
576*cdf0e10cSrcweir 			// we assume the objects are instances of this component and have the
577*cdf0e10cSrcweir 			// property prpString set.
578*cdf0e10cSrcweir 			hr= SafeArrayGetElement( val, &i, (void*)&data);
579*cdf0e10cSrcweir 			IDispatch* pdisp= ( IDispatch*) data;
580*cdf0e10cSrcweir 			CComDispatchDriver driver( pdisp);
581*cdf0e10cSrcweir 			CComVariant var;
582*cdf0e10cSrcweir 			if( pdisp)
583*cdf0e10cSrcweir 			{
584*cdf0e10cSrcweir 				driver.GetPropertyByName(L"prpString", &var);
585*cdf0e10cSrcweir 				sprintf( tmp, "%x : %S \n", *(long*)&data, var.bstrVal);
586*cdf0e10cSrcweir 			}
587*cdf0e10cSrcweir 			else
588*cdf0e10cSrcweir 				sprintf( tmp, "%x\n", *(long*)&data);
589*cdf0e10cSrcweir 		}
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir 		strcat( buf, tmp);
592*cdf0e10cSrcweir 	}
593*cdf0e10cSrcweir 	MessageBox( NULL, _T(A2T(buf)), _T("AxTestComponents.Basic"), MB_OK);
594*cdf0e10cSrcweir 
595*cdf0e10cSrcweir }
596*cdf0e10cSrcweir // V_ERROR OLECHAR VARIANT VT_UI1
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir STDMETHODIMP CBasic::outSequenceByte(LPSAFEARRAY* val)
599*cdf0e10cSrcweir {
600*cdf0e10cSrcweir 	HRESULT hr= S_OK;
601*cdf0e10cSrcweir 	hr = SafeArrayCopy(m_arByte, val);
602*cdf0e10cSrcweir 	return hr;
603*cdf0e10cSrcweir }
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir STDMETHODIMP CBasic::outSequenceShort(LPSAFEARRAY* val)
606*cdf0e10cSrcweir {
607*cdf0e10cSrcweir 	HRESULT hr= S_OK;
608*cdf0e10cSrcweir 	hr = SafeArrayCopy(m_arShort, val);
609*cdf0e10cSrcweir 	return hr;
610*cdf0e10cSrcweir }
611*cdf0e10cSrcweir 
612*cdf0e10cSrcweir STDMETHODIMP CBasic::outSequenceLong(LPSAFEARRAY* val)
613*cdf0e10cSrcweir {
614*cdf0e10cSrcweir 	HRESULT hr= S_OK;
615*cdf0e10cSrcweir 	hr = SafeArrayCopy(m_arLong, val);
616*cdf0e10cSrcweir 	return hr;
617*cdf0e10cSrcweir }
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir STDMETHODIMP CBasic::outSequenceString(LPSAFEARRAY* val)
620*cdf0e10cSrcweir {
621*cdf0e10cSrcweir 	HRESULT hr= S_OK;
622*cdf0e10cSrcweir 	hr = SafeArrayCopy(m_arString, val);
623*cdf0e10cSrcweir 	return hr;
624*cdf0e10cSrcweir }
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir STDMETHODIMP CBasic::outSequenceFloat(LPSAFEARRAY* val)
627*cdf0e10cSrcweir {
628*cdf0e10cSrcweir 	HRESULT hr= S_OK;
629*cdf0e10cSrcweir 	hr = SafeArrayCopy(m_arFloat, val);
630*cdf0e10cSrcweir 	return hr;
631*cdf0e10cSrcweir }
632*cdf0e10cSrcweir 
633*cdf0e10cSrcweir STDMETHODIMP CBasic::outSequenceDouble(LPSAFEARRAY* val)
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir 	HRESULT hr= S_OK;
636*cdf0e10cSrcweir 	hr = SafeArrayCopy(m_arDouble, val);
637*cdf0e10cSrcweir 	return hr;
638*cdf0e10cSrcweir }
639*cdf0e10cSrcweir 
640*cdf0e10cSrcweir STDMETHODIMP CBasic::outSequenceObject(LPSAFEARRAY* val)
641*cdf0e10cSrcweir {
642*cdf0e10cSrcweir 	HRESULT hr = S_OK;
643*cdf0e10cSrcweir 	hr = SafeArrayCopy(m_arObject, val);
644*cdf0e10cSrcweir 	return S_OK;
645*cdf0e10cSrcweir }
646*cdf0e10cSrcweir 
647*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutSequenceByte(LPSAFEARRAY* val)
648*cdf0e10cSrcweir {
649*cdf0e10cSrcweir 	HRESULT hr = S_OK;
650*cdf0e10cSrcweir 	SAFEARRAY *arTemp = NULL;
651*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
652*cdf0e10cSrcweir 		return hr;
653*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_arByte, val)))
654*cdf0e10cSrcweir 		return hr;
655*cdf0e10cSrcweir 	m_arByte = arTemp;
656*cdf0e10cSrcweir 	return hr;
657*cdf0e10cSrcweir }
658*cdf0e10cSrcweir 
659*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutSequenceShort(LPSAFEARRAY* val)
660*cdf0e10cSrcweir {
661*cdf0e10cSrcweir 	HRESULT hr = S_OK;
662*cdf0e10cSrcweir 	SAFEARRAY *arTemp = NULL;
663*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
664*cdf0e10cSrcweir 		return hr;
665*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_arShort, val)))
666*cdf0e10cSrcweir 		return hr;
667*cdf0e10cSrcweir 	m_arShort = arTemp;
668*cdf0e10cSrcweir 	return hr;
669*cdf0e10cSrcweir }
670*cdf0e10cSrcweir 
671*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutSequenceLong(LPSAFEARRAY* val)
672*cdf0e10cSrcweir {
673*cdf0e10cSrcweir 	HRESULT hr = S_OK;
674*cdf0e10cSrcweir 	SAFEARRAY *arTemp = NULL;
675*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
676*cdf0e10cSrcweir 		return hr;
677*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_arLong, val)))
678*cdf0e10cSrcweir 		return hr;
679*cdf0e10cSrcweir 	m_arLong = arTemp;
680*cdf0e10cSrcweir 	return hr;
681*cdf0e10cSrcweir }
682*cdf0e10cSrcweir 
683*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutSequenceString(LPSAFEARRAY* val)
684*cdf0e10cSrcweir {
685*cdf0e10cSrcweir 	HRESULT hr = S_OK;
686*cdf0e10cSrcweir 	SAFEARRAY *arTemp = NULL;
687*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
688*cdf0e10cSrcweir 		return hr;
689*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_arString, val)))
690*cdf0e10cSrcweir 		return hr;
691*cdf0e10cSrcweir 	m_arString = arTemp;
692*cdf0e10cSrcweir 	return hr;
693*cdf0e10cSrcweir }
694*cdf0e10cSrcweir 
695*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutSequenceFloat(LPSAFEARRAY* val)
696*cdf0e10cSrcweir {
697*cdf0e10cSrcweir 	HRESULT hr = S_OK;
698*cdf0e10cSrcweir 	SAFEARRAY *arTemp = NULL;
699*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
700*cdf0e10cSrcweir 		return hr;
701*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_arFloat, val)))
702*cdf0e10cSrcweir 		return hr;
703*cdf0e10cSrcweir 	m_arFloat = arTemp;
704*cdf0e10cSrcweir 	return hr;
705*cdf0e10cSrcweir }
706*cdf0e10cSrcweir 
707*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutSequenceDouble(LPSAFEARRAY* val)
708*cdf0e10cSrcweir {
709*cdf0e10cSrcweir 	HRESULT hr = S_OK;
710*cdf0e10cSrcweir 	SAFEARRAY *arTemp = NULL;
711*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
712*cdf0e10cSrcweir 		return hr;
713*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_arDouble, val)))
714*cdf0e10cSrcweir 		return hr;
715*cdf0e10cSrcweir 	m_arDouble = arTemp;
716*cdf0e10cSrcweir 	return hr;
717*cdf0e10cSrcweir }
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutSequenceObject(LPSAFEARRAY* val)
720*cdf0e10cSrcweir {
721*cdf0e10cSrcweir 	HRESULT hr = S_OK;
722*cdf0e10cSrcweir 	SAFEARRAY *arTemp = NULL;
723*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(*val, &arTemp)))
724*cdf0e10cSrcweir 		return hr;
725*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(m_arObject, val)))
726*cdf0e10cSrcweir 		return hr;
727*cdf0e10cSrcweir 	m_arObject = arTemp;
728*cdf0e10cSrcweir 	return hr;
729*cdf0e10cSrcweir }
730*cdf0e10cSrcweir 
731*cdf0e10cSrcweir // 2-dimensional Array
732*cdf0e10cSrcweir STDMETHODIMP CBasic::inMulDimArrayLong(LPSAFEARRAY val)
733*cdf0e10cSrcweir {
734*cdf0e10cSrcweir 	printMulArray( val, VT_I4);
735*cdf0e10cSrcweir 	return S_OK;
736*cdf0e10cSrcweir }
737*cdf0e10cSrcweir // 2-dimensional Array
738*cdf0e10cSrcweir STDMETHODIMP CBasic::inMulDimArrayVariant(LPSAFEARRAY val)
739*cdf0e10cSrcweir {
740*cdf0e10cSrcweir 	printMulArray( val, VT_VARIANT);
741*cdf0e10cSrcweir 	return S_OK;
742*cdf0e10cSrcweir }
743*cdf0e10cSrcweir // 3-dimensional Array
744*cdf0e10cSrcweir STDMETHODIMP CBasic::inMulDimArrayLong2(LPSAFEARRAY val)
745*cdf0e10cSrcweir {
746*cdf0e10cSrcweir 	printMulArray( val, VT_I4);
747*cdf0e10cSrcweir 	return S_OK;
748*cdf0e10cSrcweir }
749*cdf0e10cSrcweir // 3-dimensional Array
750*cdf0e10cSrcweir STDMETHODIMP CBasic::inMulDimArrayVariant2(LPSAFEARRAY val)
751*cdf0e10cSrcweir {
752*cdf0e10cSrcweir 	return S_OK;
753*cdf0e10cSrcweir }
754*cdf0e10cSrcweir 
755*cdf0e10cSrcweir 
756*cdf0e10cSrcweir STDMETHODIMP CBasic::inMulDimArrayByte(LPSAFEARRAY val)
757*cdf0e10cSrcweir {
758*cdf0e10cSrcweir 	HRESULT hr = S_OK;
759*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arByteDim2)))
760*cdf0e10cSrcweir 		return hr;
761*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arByteDim2)))
762*cdf0e10cSrcweir 		return hr;
763*cdf0e10cSrcweir 	return hr;
764*cdf0e10cSrcweir }
765*cdf0e10cSrcweir // 3-dimensionales array
766*cdf0e10cSrcweir STDMETHODIMP CBasic::inMulDimArrayByte2(LPSAFEARRAY val)
767*cdf0e10cSrcweir {
768*cdf0e10cSrcweir 
769*cdf0e10cSrcweir 	// TODO: Add your implementation code here
770*cdf0e10cSrcweir 	//printMulArray( val, VT_UI1);
771*cdf0e10cSrcweir 	return S_OK;
772*cdf0e10cSrcweir }
773*cdf0e10cSrcweir 
774*cdf0e10cSrcweir // supports 2 and 3 dimensionals SAFEARRAY with elements of long or VARIANT
775*cdf0e10cSrcweir void CBasic::printMulArray( SAFEARRAY* val, VARTYPE type)
776*cdf0e10cSrcweir {
777*cdf0e10cSrcweir 	HRESULT hr= S_OK;
778*cdf0e10cSrcweir 	UINT dims= SafeArrayGetDim( val);
779*cdf0e10cSrcweir 	long lbound1;
780*cdf0e10cSrcweir 	long ubound1;
781*cdf0e10cSrcweir 	long lbound2;
782*cdf0e10cSrcweir 	long ubound2;
783*cdf0e10cSrcweir 	long lbound3;
784*cdf0e10cSrcweir 	long ubound3;
785*cdf0e10cSrcweir 	long length1;
786*cdf0e10cSrcweir 	long length2;
787*cdf0e10cSrcweir 	long length3;
788*cdf0e10cSrcweir 
789*cdf0e10cSrcweir 	char buff[4096];
790*cdf0e10cSrcweir 	buff[0]=0;
791*cdf0e10cSrcweir 
792*cdf0e10cSrcweir 	if( dims == 2)
793*cdf0e10cSrcweir 	{
794*cdf0e10cSrcweir 		hr= SafeArrayGetLBound( val, 1, &lbound1);
795*cdf0e10cSrcweir 		hr= SafeArrayGetUBound( val, 1, &ubound1);
796*cdf0e10cSrcweir 		length1= ubound1 - lbound1 +1;
797*cdf0e10cSrcweir 
798*cdf0e10cSrcweir 		hr= SafeArrayGetLBound( val, 2, &lbound2);
799*cdf0e10cSrcweir 		hr= SafeArrayGetUBound( val, 2, &ubound2);
800*cdf0e10cSrcweir 		length2= ubound2 - lbound2 + 1;
801*cdf0e10cSrcweir 		char tmpBuf[1024];
802*cdf0e10cSrcweir 		tmpBuf[0]=0;
803*cdf0e10cSrcweir 		long index[2];
804*cdf0e10cSrcweir 		for( long i= 0; i< length2; i++)
805*cdf0e10cSrcweir 		{
806*cdf0e10cSrcweir 			for( long j= 0; j<length1; j++)
807*cdf0e10cSrcweir 			{
808*cdf0e10cSrcweir 				index[0]= j;
809*cdf0e10cSrcweir 				index[1]= i;
810*cdf0e10cSrcweir 				long longVal;
811*cdf0e10cSrcweir 				CComVariant var;
812*cdf0e10cSrcweir 				switch( type)
813*cdf0e10cSrcweir 				{
814*cdf0e10cSrcweir 				case VT_I4:
815*cdf0e10cSrcweir 					hr= SafeArrayGetElement( val, index, &longVal);
816*cdf0e10cSrcweir 					sprintf( tmpBuf, "(%d,%d): %d\n", index[1], index[0], longVal);
817*cdf0e10cSrcweir 					break;
818*cdf0e10cSrcweir 				case VT_UI1:
819*cdf0e10cSrcweir 					hr= SafeArrayGetElement( val, index, &longVal);
820*cdf0e10cSrcweir 					sprintf( tmpBuf, "(%d,%d): %d\n", index[1], index[0], (unsigned char)longVal);
821*cdf0e10cSrcweir 					break;
822*cdf0e10cSrcweir 				case VT_VARIANT:
823*cdf0e10cSrcweir 					hr= SafeArrayGetElement( val, index, &var );
824*cdf0e10cSrcweir 					sprintf( tmpBuf, "(%d,%d):  %d (vartype %d)\n",  index[1], index[0], var.byref, var.vt);
825*cdf0e10cSrcweir 					break;
826*cdf0e10cSrcweir 				}
827*cdf0e10cSrcweir 				strcat( buff,tmpBuf);
828*cdf0e10cSrcweir 			}
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir 		}
831*cdf0e10cSrcweir 
832*cdf0e10cSrcweir 
833*cdf0e10cSrcweir 	}
834*cdf0e10cSrcweir 	else if( dims == 3 )
835*cdf0e10cSrcweir 	{
836*cdf0e10cSrcweir 		hr= SafeArrayGetLBound( val, 1, &lbound1);
837*cdf0e10cSrcweir 		hr= SafeArrayGetUBound( val, 1, &ubound1);
838*cdf0e10cSrcweir 		length1= ubound1 - lbound1 +1;
839*cdf0e10cSrcweir 
840*cdf0e10cSrcweir 		hr= SafeArrayGetLBound( val, 2, &lbound2);
841*cdf0e10cSrcweir 		hr= SafeArrayGetUBound( val, 2, &ubound2);
842*cdf0e10cSrcweir 		length2= ubound2 - lbound2 + 1;
843*cdf0e10cSrcweir 
844*cdf0e10cSrcweir 		hr= SafeArrayGetLBound( val, 3, &lbound3);
845*cdf0e10cSrcweir 		hr= SafeArrayGetUBound( val, 3, &ubound3);
846*cdf0e10cSrcweir 		length3= ubound3 - lbound3 +1;
847*cdf0e10cSrcweir 		char tmpBuf[1024];
848*cdf0e10cSrcweir 		tmpBuf[0]=0;
849*cdf0e10cSrcweir 		long index[3];
850*cdf0e10cSrcweir 		for( long i= 0; i< length3; i++)
851*cdf0e10cSrcweir 		{
852*cdf0e10cSrcweir 			for( long j= 0; j<length2; j++)
853*cdf0e10cSrcweir 			{
854*cdf0e10cSrcweir 				for( long k= 0; k<length1; k++)
855*cdf0e10cSrcweir 				{
856*cdf0e10cSrcweir 					index[0]= k;
857*cdf0e10cSrcweir 					index[1]= j;
858*cdf0e10cSrcweir 					index[2]= i;
859*cdf0e10cSrcweir 					long longVal;
860*cdf0e10cSrcweir 					CComVariant var;
861*cdf0e10cSrcweir 					switch( type)
862*cdf0e10cSrcweir 					{
863*cdf0e10cSrcweir 					case VT_I4:
864*cdf0e10cSrcweir 						hr= SafeArrayGetElement( val, index, &longVal);
865*cdf0e10cSrcweir 						sprintf( tmpBuf, "(%d,%d,%d): %d\n", index[2], index[1], index[0], longVal);
866*cdf0e10cSrcweir 						break;
867*cdf0e10cSrcweir 					case VT_UI1:
868*cdf0e10cSrcweir 						hr= SafeArrayGetElement( val, index, &longVal);
869*cdf0e10cSrcweir 						sprintf( tmpBuf, "(%d,%d,%d): %d\n", index[2], index[1], index[0], (unsigned char)longVal);
870*cdf0e10cSrcweir 						break;
871*cdf0e10cSrcweir 
872*cdf0e10cSrcweir 					case VT_VARIANT:
873*cdf0e10cSrcweir 						hr= SafeArrayGetElement( val, index, &var );
874*cdf0e10cSrcweir 						sprintf( tmpBuf, "(%d,%d,%d):  %d (vartype %d)\n", index[2],  index[1], index[0], var.byref, var.vt);
875*cdf0e10cSrcweir 						break;
876*cdf0e10cSrcweir 					}
877*cdf0e10cSrcweir 					strcat( buff,tmpBuf);
878*cdf0e10cSrcweir 				}
879*cdf0e10cSrcweir 			}
880*cdf0e10cSrcweir 
881*cdf0e10cSrcweir 		}
882*cdf0e10cSrcweir 
883*cdf0e10cSrcweir 	}
884*cdf0e10cSrcweir 
885*cdf0e10cSrcweir 	MessageBox( NULL, A2T( buff), _T("AxTestControl.Basic"), MB_OK);
886*cdf0e10cSrcweir 
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir }
889*cdf0e10cSrcweir 
890*cdf0e10cSrcweir 
891*cdf0e10cSrcweir 
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir STDMETHODIMP CBasic::outMore(long* val1, long* val2)
894*cdf0e10cSrcweir {
895*cdf0e10cSrcweir 	// TODO: Add your implementation code here
896*cdf0e10cSrcweir 	*val1= 111;
897*cdf0e10cSrcweir 	*val2= 112;
898*cdf0e10cSrcweir 	return S_OK;
899*cdf0e10cSrcweir }
900*cdf0e10cSrcweir // If an optional parameter was not provided then the respective member will
901*cdf0e10cSrcweir // not be set
902*cdf0e10cSrcweir STDMETHODIMP CBasic::optional1(/*[in]*/ long val1, /*[in, optional]*/ VARIANT* val2)
903*cdf0e10cSrcweir {
904*cdf0e10cSrcweir 	m_long = val1;
905*cdf0e10cSrcweir 	if (val2->vt != VT_ERROR)
906*cdf0e10cSrcweir 		m_var1 = *val2;
907*cdf0e10cSrcweir 	return S_OK;
908*cdf0e10cSrcweir }
909*cdf0e10cSrcweir 
910*cdf0e10cSrcweir STDMETHODIMP CBasic::optional2(/*[out]*/ long* val1,/*[out, optional]*/ VARIANT* val2)
911*cdf0e10cSrcweir {
912*cdf0e10cSrcweir 	HRESULT hr = S_OK;
913*cdf0e10cSrcweir 	*val1 = m_long;
914*cdf0e10cSrcweir 
915*cdf0e10cSrcweir 	if (val2->vt != VT_ERROR)
916*cdf0e10cSrcweir 		hr = VariantCopy(val2, & m_var1);
917*cdf0e10cSrcweir 	return hr;
918*cdf0e10cSrcweir }
919*cdf0e10cSrcweir 
920*cdf0e10cSrcweir STDMETHODIMP CBasic::optional3(/*[in, optional]*/ VARIANT* val1,/*[in, optional]*/ VARIANT* val2)
921*cdf0e10cSrcweir {
922*cdf0e10cSrcweir 	//if (val1->vt != VT_ERROR)
923*cdf0e10cSrcweir 		m_var1 = *val1;
924*cdf0e10cSrcweir 
925*cdf0e10cSrcweir 	//if (val2->vt != VT_ERROR)
926*cdf0e10cSrcweir 		m_var2 = *val2;
927*cdf0e10cSrcweir 	return S_OK;
928*cdf0e10cSrcweir }
929*cdf0e10cSrcweir 
930*cdf0e10cSrcweir STDMETHODIMP CBasic::optional4(/*[in, out, optional]*/ VARIANT* val1,
931*cdf0e10cSrcweir 							   /*[in, out, optional]*/ VARIANT* val2)
932*cdf0e10cSrcweir {
933*cdf0e10cSrcweir 	HRESULT hr = S_OK;
934*cdf0e10cSrcweir 	//return the previously set in values
935*cdf0e10cSrcweir 	if (val1->vt != VT_ERROR)
936*cdf0e10cSrcweir 	{
937*cdf0e10cSrcweir 		CComVariant var1(*val1);
938*cdf0e10cSrcweir 		if (FAILED(hr = VariantCopy(val1, & m_var1)))
939*cdf0e10cSrcweir 			return hr;
940*cdf0e10cSrcweir 		m_var1 = var1;
941*cdf0e10cSrcweir 	}
942*cdf0e10cSrcweir 	if (val2->vt != VT_ERROR)
943*cdf0e10cSrcweir 	{
944*cdf0e10cSrcweir 		CComVariant var2(*val2);
945*cdf0e10cSrcweir 		if (FAILED(hr = VariantCopy(val2, & m_var2)))
946*cdf0e10cSrcweir 			return hr;
947*cdf0e10cSrcweir 		m_var2 = var2;
948*cdf0e10cSrcweir 	}
949*cdf0e10cSrcweir 	return hr;
950*cdf0e10cSrcweir }
951*cdf0e10cSrcweir 
952*cdf0e10cSrcweir STDMETHODIMP CBasic::optional5(/*[out, optional]*/ VARIANT* val1,
953*cdf0e10cSrcweir 							   /*[out, optional]*/ VARIANT* val2)
954*cdf0e10cSrcweir {
955*cdf0e10cSrcweir 	HRESULT hr = S_OK;
956*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val1, &m_var1)))
957*cdf0e10cSrcweir 		return hr;
958*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val2, &m_var2)))
959*cdf0e10cSrcweir 		return hr;
960*cdf0e10cSrcweir 	return hr;
961*cdf0e10cSrcweir }
962*cdf0e10cSrcweir 
963*cdf0e10cSrcweir STDMETHODIMP CBasic::defaultvalue1(/*[in, defaultvalue(10)]*/ long val1,
964*cdf0e10cSrcweir 								   /*[in, defaultvalue(3.14)]*/ double* val2,
965*cdf0e10cSrcweir 								//   /*[in, defaultvalue(10)]*/ VARIANT val3,
966*cdf0e10cSrcweir 							       /*[in, defaultvalue(100)]*/ VARIANT* val4)
967*cdf0e10cSrcweir {
968*cdf0e10cSrcweir 	m_long = val1;
969*cdf0e10cSrcweir 	m_double = *val2;
970*cdf0e10cSrcweir //	m_var1 = val3;
971*cdf0e10cSrcweir 	m_var2 = *val4;
972*cdf0e10cSrcweir 	return S_OK;
973*cdf0e10cSrcweir }
974*cdf0e10cSrcweir STDMETHODIMP CBasic::defaultvalue2(/*[in, out, defaultvalue(10)]*/ long* val1,
975*cdf0e10cSrcweir 								   /*[in, out, defaultvalue(3.14)]*/ double* val2,
976*cdf0e10cSrcweir 								//   /*[in, out, defaultvalue(10)]*/ VARIANT* val3,
977*cdf0e10cSrcweir 							       /*[in, out, defaultvalue(100)]*/ VARIANT* val4)
978*cdf0e10cSrcweir {
979*cdf0e10cSrcweir 	HRESULT hr = S_OK;
980*cdf0e10cSrcweir 	long aLong = *val1;
981*cdf0e10cSrcweir 	double aDouble = *val2;
982*cdf0e10cSrcweir //	CComVariant var1(*val3);
983*cdf0e10cSrcweir 	CComVariant var2(*val4);
984*cdf0e10cSrcweir 	*val1 = m_long;
985*cdf0e10cSrcweir 	*val2 = m_double;
986*cdf0e10cSrcweir 	//if (FAILED(hr = VariantCopy(val3, &m_var1)))
987*cdf0e10cSrcweir 	//	return hr;
988*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val4, &m_var2)))
989*cdf0e10cSrcweir 		return hr;
990*cdf0e10cSrcweir 	m_long = aLong;
991*cdf0e10cSrcweir 	m_double = aDouble;
992*cdf0e10cSrcweir //	m_var1 = var1;
993*cdf0e10cSrcweir 	m_var2 = var2;
994*cdf0e10cSrcweir 	return hr;
995*cdf0e10cSrcweir }
996*cdf0e10cSrcweir /* val2 contains the variable argument list. If no such arguments are supplied
997*cdf0e10cSrcweir 	then the safearray is invalid. SafeArrayCopy then returns E_INVALIDARG
998*cdf0e10cSrcweir */
999*cdf0e10cSrcweir STDMETHODIMP CBasic::varargfunc1(/*[in]*/ long val1,/*[in]*/ LPSAFEARRAY val2)
1000*cdf0e10cSrcweir {
1001*cdf0e10cSrcweir 	m_long = val1;
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1004*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_safearray)))
1005*cdf0e10cSrcweir 		return hr;
1006*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val2, & m_safearray)))
1007*cdf0e10cSrcweir 	{
1008*cdf0e10cSrcweir 		if (hr != E_INVALIDARG)
1009*cdf0e10cSrcweir 			return hr;
1010*cdf0e10cSrcweir 	}
1011*cdf0e10cSrcweir 	return S_OK;
1012*cdf0e10cSrcweir }
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir STDMETHODIMP CBasic::varargfunc2(/*[out]*/ long* val1, /*[out]*/ SAFEARRAY ** val2)
1015*cdf0e10cSrcweir {
1016*cdf0e10cSrcweir 	*val1 = m_long;
1017*cdf0e10cSrcweir 	HRESULT hr = SafeArrayCopy(m_safearray, val2);
1018*cdf0e10cSrcweir 	return hr;
1019*cdf0e10cSrcweir }
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir STDMETHODIMP CBasic::inSequenceByteDim2(LPSAFEARRAY val)
1022*cdf0e10cSrcweir {
1023*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1024*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayDestroy(m_arByteDim2)))
1025*cdf0e10cSrcweir 		return hr;
1026*cdf0e10cSrcweir 	if (FAILED(hr = SafeArrayCopy(val, & m_arByteDim2)))
1027*cdf0e10cSrcweir 		return hr;
1028*cdf0e10cSrcweir 	return hr;
1029*cdf0e10cSrcweir }
1030*cdf0e10cSrcweir 
1031*cdf0e10cSrcweir 
1032*cdf0e10cSrcweir STDMETHODIMP CBasic::inCurrency(CY val)
1033*cdf0e10cSrcweir {
1034*cdf0e10cSrcweir 	m_cy = val;
1035*cdf0e10cSrcweir 	return S_OK;
1036*cdf0e10cSrcweir }
1037*cdf0e10cSrcweir 
1038*cdf0e10cSrcweir STDMETHODIMP CBasic::outCurrency(CY* val)
1039*cdf0e10cSrcweir {
1040*cdf0e10cSrcweir 	*val = m_cy;
1041*cdf0e10cSrcweir 	return S_OK;
1042*cdf0e10cSrcweir }
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutCurrency(CY* val)
1045*cdf0e10cSrcweir {
1046*cdf0e10cSrcweir 	CY tmp = *val;
1047*cdf0e10cSrcweir 	*val = m_cy;
1048*cdf0e10cSrcweir 	m_cy = tmp;
1049*cdf0e10cSrcweir 	return S_OK;
1050*cdf0e10cSrcweir }
1051*cdf0e10cSrcweir 
1052*cdf0e10cSrcweir STDMETHODIMP CBasic::inDate(DATE val)
1053*cdf0e10cSrcweir {
1054*cdf0e10cSrcweir 	m_date = val;
1055*cdf0e10cSrcweir 	return S_OK;
1056*cdf0e10cSrcweir }
1057*cdf0e10cSrcweir 
1058*cdf0e10cSrcweir STDMETHODIMP CBasic::outDate(DATE* val)
1059*cdf0e10cSrcweir {
1060*cdf0e10cSrcweir 	*val = m_date;
1061*cdf0e10cSrcweir 	return S_OK;
1062*cdf0e10cSrcweir }
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutDate(DATE* val)
1065*cdf0e10cSrcweir {
1066*cdf0e10cSrcweir 	DATE tmp = *val;
1067*cdf0e10cSrcweir 	*val = m_date;
1068*cdf0e10cSrcweir 	m_date = tmp;
1069*cdf0e10cSrcweir 	return S_OK;
1070*cdf0e10cSrcweir }
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpCurrency(CY* pVal)
1073*cdf0e10cSrcweir {
1074*cdf0e10cSrcweir 	*pVal = m_cy;
1075*cdf0e10cSrcweir 	return S_OK;
1076*cdf0e10cSrcweir }
1077*cdf0e10cSrcweir 
1078*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpCurrency(CY newVal)
1079*cdf0e10cSrcweir {
1080*cdf0e10cSrcweir 	m_cy = newVal;
1081*cdf0e10cSrcweir 	return S_OK;
1082*cdf0e10cSrcweir }
1083*cdf0e10cSrcweir 
1084*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpDate(DATE* pVal)
1085*cdf0e10cSrcweir {
1086*cdf0e10cSrcweir 	*pVal = m_date;
1087*cdf0e10cSrcweir 	return S_OK;
1088*cdf0e10cSrcweir }
1089*cdf0e10cSrcweir 
1090*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpDate(DATE newVal)
1091*cdf0e10cSrcweir {
1092*cdf0e10cSrcweir 	m_date = newVal;
1093*cdf0e10cSrcweir 	return S_OK;
1094*cdf0e10cSrcweir }
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir //VT_I4 DECIMAL_NEG //tagVARIANT DISPATCH_PROPERTYPUT
1097*cdf0e10cSrcweir STDMETHODIMP CBasic::inDecimal(DECIMAL val)
1098*cdf0e10cSrcweir {
1099*cdf0e10cSrcweir 	m_decimal = val;
1100*cdf0e10cSrcweir 	return S_OK;
1101*cdf0e10cSrcweir }
1102*cdf0e10cSrcweir 
1103*cdf0e10cSrcweir STDMETHODIMP CBasic::outDecimal(DECIMAL* val)
1104*cdf0e10cSrcweir {
1105*cdf0e10cSrcweir 	* val = m_decimal;
1106*cdf0e10cSrcweir 	return S_OK;
1107*cdf0e10cSrcweir }
1108*cdf0e10cSrcweir 
1109*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutDecimal(DECIMAL* val)
1110*cdf0e10cSrcweir {
1111*cdf0e10cSrcweir 	DECIMAL tmp;
1112*cdf0e10cSrcweir 	tmp = * val;
1113*cdf0e10cSrcweir 	* val = m_decimal;
1114*cdf0e10cSrcweir 	m_decimal = tmp;
1115*cdf0e10cSrcweir 	return S_OK;
1116*cdf0e10cSrcweir }
1117*cdf0e10cSrcweir 
1118*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpDecimal(DECIMAL* pVal)
1119*cdf0e10cSrcweir {
1120*cdf0e10cSrcweir 	* pVal = m_decimal;
1121*cdf0e10cSrcweir 	return S_OK;
1122*cdf0e10cSrcweir }
1123*cdf0e10cSrcweir 
1124*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpDecimal(DECIMAL newVal)
1125*cdf0e10cSrcweir {
1126*cdf0e10cSrcweir 	m_decimal = newVal;
1127*cdf0e10cSrcweir 	return S_OK;
1128*cdf0e10cSrcweir }
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir STDMETHODIMP CBasic::inSCode(SCODE val)
1131*cdf0e10cSrcweir {
1132*cdf0e10cSrcweir 	m_scode = val;
1133*cdf0e10cSrcweir 	return S_OK;
1134*cdf0e10cSrcweir }
1135*cdf0e10cSrcweir 
1136*cdf0e10cSrcweir STDMETHODIMP CBasic::outScode(SCODE* val)
1137*cdf0e10cSrcweir {
1138*cdf0e10cSrcweir 	* val = m_scode;
1139*cdf0e10cSrcweir 	return S_OK;
1140*cdf0e10cSrcweir }
1141*cdf0e10cSrcweir 
1142*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutSCode(SCODE* val)
1143*cdf0e10cSrcweir {
1144*cdf0e10cSrcweir 	SCODE tmp = *val;
1145*cdf0e10cSrcweir 	* val = m_scode;
1146*cdf0e10cSrcweir 	m_scode = tmp;
1147*cdf0e10cSrcweir 	return S_OK;
1148*cdf0e10cSrcweir }
1149*cdf0e10cSrcweir 
1150*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpSCode(SCODE* pVal)
1151*cdf0e10cSrcweir {
1152*cdf0e10cSrcweir 	* pVal = m_scode;
1153*cdf0e10cSrcweir 	return S_OK;
1154*cdf0e10cSrcweir }
1155*cdf0e10cSrcweir 
1156*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpSCode(SCODE newVal)
1157*cdf0e10cSrcweir {
1158*cdf0e10cSrcweir 	m_scode = newVal;
1159*cdf0e10cSrcweir 	return S_OK;
1160*cdf0e10cSrcweir }
1161*cdf0e10cSrcweir 
1162*cdf0e10cSrcweir STDMETHODIMP CBasic::inrefLong(LONG* val)
1163*cdf0e10cSrcweir {
1164*cdf0e10cSrcweir 	m_long = * val;
1165*cdf0e10cSrcweir 	return S_OK;
1166*cdf0e10cSrcweir }
1167*cdf0e10cSrcweir 
1168*cdf0e10cSrcweir STDMETHODIMP CBasic::inrefVariant(VARIANT* val)
1169*cdf0e10cSrcweir {
1170*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1171*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy( & m_var1, val)))
1172*cdf0e10cSrcweir 		return hr;
1173*cdf0e10cSrcweir 	return S_OK;
1174*cdf0e10cSrcweir }
1175*cdf0e10cSrcweir 
1176*cdf0e10cSrcweir STDMETHODIMP CBasic::inrefDecimal(DECIMAL* val)
1177*cdf0e10cSrcweir {
1178*cdf0e10cSrcweir 	m_decimal = * val;
1179*cdf0e10cSrcweir 	return S_OK;
1180*cdf0e10cSrcweir }
1181*cdf0e10cSrcweir 
1182*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpRefLong(long* pVal)
1183*cdf0e10cSrcweir {
1184*cdf0e10cSrcweir 	*pVal = m_long;
1185*cdf0e10cSrcweir 	return S_OK;
1186*cdf0e10cSrcweir }
1187*cdf0e10cSrcweir 
1188*cdf0e10cSrcweir STDMETHODIMP CBasic::putref_prpRefLong(long* newVal)
1189*cdf0e10cSrcweir {
1190*cdf0e10cSrcweir 	m_long = * newVal;
1191*cdf0e10cSrcweir 	return S_OK;
1192*cdf0e10cSrcweir }
1193*cdf0e10cSrcweir 
1194*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prprefVariant(VARIANT* pVal)
1195*cdf0e10cSrcweir {
1196*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1197*cdf0e10cSrcweir 	hr = VariantCopy(pVal, & m_var1);
1198*cdf0e10cSrcweir 	return hr;
1199*cdf0e10cSrcweir }
1200*cdf0e10cSrcweir 
1201*cdf0e10cSrcweir STDMETHODIMP CBasic::putref_prprefVariant(VARIANT* newVal)
1202*cdf0e10cSrcweir {
1203*cdf0e10cSrcweir 	m_var1 = * newVal;
1204*cdf0e10cSrcweir 	return S_OK;
1205*cdf0e10cSrcweir }
1206*cdf0e10cSrcweir 
1207*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prprefDecimal(DECIMAL* pVal)
1208*cdf0e10cSrcweir {
1209*cdf0e10cSrcweir 	* pVal = m_decimal;
1210*cdf0e10cSrcweir 	return S_OK;
1211*cdf0e10cSrcweir }
1212*cdf0e10cSrcweir 
1213*cdf0e10cSrcweir STDMETHODIMP CBasic::putref_prprefDecimal(DECIMAL* newVal)
1214*cdf0e10cSrcweir {
1215*cdf0e10cSrcweir 	m_decimal = *newVal;
1216*cdf0e10cSrcweir 	return S_OK;
1217*cdf0e10cSrcweir }
1218*cdf0e10cSrcweir 
1219*cdf0e10cSrcweir 
1220*cdf0e10cSrcweir STDMETHODIMP CBasic::optional6(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4)
1221*cdf0e10cSrcweir {
1222*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1223*cdf0e10cSrcweir 	if (FAILED(hr = m_var1.Copy(val1)))
1224*cdf0e10cSrcweir 		return hr;
1225*cdf0e10cSrcweir 	if (FAILED(hr = m_var2.Copy(val2)))
1226*cdf0e10cSrcweir 		return hr;
1227*cdf0e10cSrcweir 	if (FAILED(hr = m_var3.Copy(val3)))
1228*cdf0e10cSrcweir 		return hr;
1229*cdf0e10cSrcweir 	if (FAILED(hr = m_var4.Copy(val4)))
1230*cdf0e10cSrcweir 		return hr;
1231*cdf0e10cSrcweir 	return S_OK;
1232*cdf0e10cSrcweir }
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir STDMETHODIMP CBasic::optional7(VARIANT* val1, VARIANT* val2, VARIANT* val3, VARIANT* val4)
1235*cdf0e10cSrcweir {
1236*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1237*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val1, & m_var1)))
1238*cdf0e10cSrcweir 		return hr;
1239*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val2, & m_var2)))
1240*cdf0e10cSrcweir 		return hr;
1241*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val3, & m_var3)))
1242*cdf0e10cSrcweir 		return hr;
1243*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val4, & m_var4)))
1244*cdf0e10cSrcweir 		return hr;
1245*cdf0e10cSrcweir 
1246*cdf0e10cSrcweir 	return S_OK;
1247*cdf0e10cSrcweir }
1248*cdf0e10cSrcweir 
1249*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpMultiArg1(VARIANT* val1, VARIANT* val2, VARIANT* pVal)
1250*cdf0e10cSrcweir {
1251*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1252*cdf0e10cSrcweir 	CComVariant tmp1(*val1);
1253*cdf0e10cSrcweir 	CComVariant tmp2(*val2);
1254*cdf0e10cSrcweir 
1255*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val1, & m_var1)))
1256*cdf0e10cSrcweir 		return hr;
1257*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val2, & m_var2)))
1258*cdf0e10cSrcweir 		return hr;
1259*cdf0e10cSrcweir 	m_var1 = tmp1;
1260*cdf0e10cSrcweir 	m_var2 = tmp2;
1261*cdf0e10cSrcweir 	if  (FAILED(hr = VariantCopy(pVal, & m_var3)))
1262*cdf0e10cSrcweir 		return hr;
1263*cdf0e10cSrcweir 	return S_OK;
1264*cdf0e10cSrcweir }
1265*cdf0e10cSrcweir 
1266*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpMultiArg1(VARIANT* val1, VARIANT* val2, VARIANT* newVal)
1267*cdf0e10cSrcweir {
1268*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1269*cdf0e10cSrcweir 	CComVariant tmp1( * val1);
1270*cdf0e10cSrcweir 	CComVariant tmp2( * val2);
1271*cdf0e10cSrcweir 
1272*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val1, & m_var1)))
1273*cdf0e10cSrcweir 		return hr;
1274*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(val2, & m_var2)))
1275*cdf0e10cSrcweir 		return hr;
1276*cdf0e10cSrcweir 	m_var1 = tmp1;
1277*cdf0e10cSrcweir 	m_var2 = tmp2;
1278*cdf0e10cSrcweir 
1279*cdf0e10cSrcweir 	m_var3 = *newVal;
1280*cdf0e10cSrcweir 	return S_OK;
1281*cdf0e10cSrcweir }
1282*cdf0e10cSrcweir 
1283*cdf0e10cSrcweir // tagVARIANT DISPATCH_PROPERTYPUT DISPID_PROPERTYPUT VARIANTARG LOCALE_USER_DEFAULT
1284*cdf0e10cSrcweir 
1285*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpMultiArg2(VARIANT val1, VARIANT* pVal)
1286*cdf0e10cSrcweir {
1287*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1288*cdf0e10cSrcweir 	m_var1 =  val1;
1289*cdf0e10cSrcweir 
1290*cdf0e10cSrcweir 	if (FAILED(hr = VariantCopy(pVal, & m_var2)))
1291*cdf0e10cSrcweir 		return hr;
1292*cdf0e10cSrcweir 	return S_OK;
1293*cdf0e10cSrcweir }
1294*cdf0e10cSrcweir 
1295*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpMultiArg2(VARIANT val1, VARIANT newVal)
1296*cdf0e10cSrcweir {
1297*cdf0e10cSrcweir 	m_var1 = val1;
1298*cdf0e10cSrcweir 	m_var2 = newVal;
1299*cdf0e10cSrcweir 	return S_OK;
1300*cdf0e10cSrcweir }
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir // returns the values set by prpMultiArg2
1303*cdf0e10cSrcweir STDMETHODIMP CBasic::prpMultiArg2GetValues(VARIANT* val1, VARIANT* valProperty)
1304*cdf0e10cSrcweir {
1305*cdf0e10cSrcweir 	HRESULT hr = S_OK;
1306*cdf0e10cSrcweir 	if (FAILED(VariantCopy(val1, & m_var1)))
1307*cdf0e10cSrcweir 		return hr;
1308*cdf0e10cSrcweir 	if (FAILED(VariantCopy(valProperty, & m_var2)))
1309*cdf0e10cSrcweir 		return hr;
1310*cdf0e10cSrcweir 	return S_OK;
1311*cdf0e10cSrcweir }
1312*cdf0e10cSrcweir 
1313*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpMultiArg3(LONG* val1, LONG* pVal)
1314*cdf0e10cSrcweir {
1315*cdf0e10cSrcweir 	long aLong = *val1;
1316*cdf0e10cSrcweir 	*val1 = m_long;
1317*cdf0e10cSrcweir 	m_long = aLong;
1318*cdf0e10cSrcweir 
1319*cdf0e10cSrcweir 	* pVal = m_long2;
1320*cdf0e10cSrcweir 	return S_OK;
1321*cdf0e10cSrcweir }
1322*cdf0e10cSrcweir 
1323*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpMultiArg3(LONG* val1, LONG newVal)
1324*cdf0e10cSrcweir {
1325*cdf0e10cSrcweir 	long aLong = *val1;
1326*cdf0e10cSrcweir 	*val1 = m_long;
1327*cdf0e10cSrcweir 	m_long = aLong;
1328*cdf0e10cSrcweir 
1329*cdf0e10cSrcweir 	m_long2 = newVal;
1330*cdf0e10cSrcweir 	return S_OK;
1331*cdf0e10cSrcweir }
1332*cdf0e10cSrcweir 
1333*cdf0e10cSrcweir STDMETHODIMP CBasic::inUnknown(IUnknown* val)
1334*cdf0e10cSrcweir {
1335*cdf0e10cSrcweir 	m_unknown = val;
1336*cdf0e10cSrcweir 
1337*cdf0e10cSrcweir 	return S_OK;
1338*cdf0e10cSrcweir }
1339*cdf0e10cSrcweir 
1340*cdf0e10cSrcweir STDMETHODIMP CBasic::outUnknown(IUnknown** val)
1341*cdf0e10cSrcweir {
1342*cdf0e10cSrcweir 	m_unknown.CopyTo(val);
1343*cdf0e10cSrcweir 	return S_OK;
1344*cdf0e10cSrcweir }
1345*cdf0e10cSrcweir 
1346*cdf0e10cSrcweir STDMETHODIMP CBasic::inoutUnknown(IUnknown** val)
1347*cdf0e10cSrcweir {
1348*cdf0e10cSrcweir 	CComPtr<IUnknown> tmp = *val;
1349*cdf0e10cSrcweir 	m_unknown.CopyTo(val);
1350*cdf0e10cSrcweir 	m_unknown = tmp;
1351*cdf0e10cSrcweir 	return S_OK;
1352*cdf0e10cSrcweir }
1353*cdf0e10cSrcweir 
1354*cdf0e10cSrcweir STDMETHODIMP CBasic::get_prpUnknown(IUnknown** pVal)
1355*cdf0e10cSrcweir {
1356*cdf0e10cSrcweir 	m_prpUnknown.CopyTo(pVal);
1357*cdf0e10cSrcweir 	return S_OK;
1358*cdf0e10cSrcweir }
1359*cdf0e10cSrcweir 
1360*cdf0e10cSrcweir STDMETHODIMP CBasic::put_prpUnknown(IUnknown* newVal)
1361*cdf0e10cSrcweir {
1362*cdf0e10cSrcweir 	m_prpUnknown = newVal;
1363*cdf0e10cSrcweir 	return S_OK;
1364*cdf0e10cSrcweir }
1365