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 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
30*cdf0e10cSrcweir #include "ado/Aolevariant.hxx"
31*cdf0e10cSrcweir #include "connectivity/dbconversion.hxx"
32*cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLException.hpp>
33*cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
36*cdf0e10cSrcweir #include "diagnose_ex.h"
37*cdf0e10cSrcweir #include "resource/sharedresources.hxx"
38*cdf0e10cSrcweir #include "resource/ado_res.hrc"
39*cdf0e10cSrcweir #include "com/sun/star/bridge/oleautomation/Date.hpp"
40*cdf0e10cSrcweir #include "com/sun/star/bridge/oleautomation/Currency.hpp"
41*cdf0e10cSrcweir #include "com/sun/star/bridge/oleautomation/SCode.hpp"
42*cdf0e10cSrcweir #include "com/sun/star/bridge/oleautomation/Decimal.hpp"
43*cdf0e10cSrcweir 
44*cdf0e10cSrcweir using namespace com::sun::star::beans;
45*cdf0e10cSrcweir using namespace com::sun::star::uno;
46*cdf0e10cSrcweir using namespace com::sun::star::bridge::oleautomation;
47*cdf0e10cSrcweir using namespace connectivity::ado;
48*cdf0e10cSrcweir using ::rtl::OUString;
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir OLEString::OLEString()
51*cdf0e10cSrcweir 	:m_sStr(NULL)
52*cdf0e10cSrcweir {
53*cdf0e10cSrcweir }
54*cdf0e10cSrcweir OLEString::OLEString(const BSTR& _sBStr)
55*cdf0e10cSrcweir 	:m_sStr(_sBStr)
56*cdf0e10cSrcweir {
57*cdf0e10cSrcweir }
58*cdf0e10cSrcweir OLEString::OLEString(const ::rtl::OUString& _sBStr)
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir 	m_sStr = ::SysAllocString(reinterpret_cast<LPCOLESTR>(_sBStr.getStr()));
61*cdf0e10cSrcweir }
62*cdf0e10cSrcweir OLEString::~OLEString()
63*cdf0e10cSrcweir {
64*cdf0e10cSrcweir 	if(m_sStr)
65*cdf0e10cSrcweir 		::SysFreeString(m_sStr);
66*cdf0e10cSrcweir }
67*cdf0e10cSrcweir OLEString& OLEString::operator=(const ::rtl::OUString& _rSrc)
68*cdf0e10cSrcweir {
69*cdf0e10cSrcweir 	if(m_sStr)
70*cdf0e10cSrcweir 		::SysFreeString(m_sStr);
71*cdf0e10cSrcweir 	m_sStr = ::SysAllocString(reinterpret_cast<LPCOLESTR>(_rSrc.getStr()));
72*cdf0e10cSrcweir 	return *this;
73*cdf0e10cSrcweir }
74*cdf0e10cSrcweir OLEString& OLEString::operator=(const OLEString& _rSrc)
75*cdf0e10cSrcweir {
76*cdf0e10cSrcweir 	if(this != &_rSrc)
77*cdf0e10cSrcweir 	{
78*cdf0e10cSrcweir 		if(m_sStr)
79*cdf0e10cSrcweir 			::SysFreeString(m_sStr);
80*cdf0e10cSrcweir 		m_sStr = ::SysAllocString(_rSrc.m_sStr);
81*cdf0e10cSrcweir 	}
82*cdf0e10cSrcweir 	return *this;
83*cdf0e10cSrcweir }
84*cdf0e10cSrcweir OLEString& OLEString::operator=(const BSTR& _rSrc)
85*cdf0e10cSrcweir {
86*cdf0e10cSrcweir 	if(m_sStr)
87*cdf0e10cSrcweir 		::SysFreeString(m_sStr);
88*cdf0e10cSrcweir 	m_sStr = _rSrc;
89*cdf0e10cSrcweir 	return *this;
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir OLEString::operator ::rtl::OUString() const
92*cdf0e10cSrcweir {
93*cdf0e10cSrcweir 	return (m_sStr != NULL) ? ::rtl::OUString(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(m_sStr)),::SysStringLen(m_sStr)) : ::rtl::OUString();
94*cdf0e10cSrcweir }
95*cdf0e10cSrcweir OLEString::operator BSTR() const
96*cdf0e10cSrcweir {
97*cdf0e10cSrcweir 	return m_sStr;
98*cdf0e10cSrcweir }
99*cdf0e10cSrcweir BSTR* OLEString::operator &()
100*cdf0e10cSrcweir {
101*cdf0e10cSrcweir 	return &m_sStr;
102*cdf0e10cSrcweir }
103*cdf0e10cSrcweir sal_Int32 OLEString::length() const
104*cdf0e10cSrcweir {
105*cdf0e10cSrcweir 	return (m_sStr != NULL) ? ::SysStringLen(m_sStr) : 0;
106*cdf0e10cSrcweir }
107*cdf0e10cSrcweir 
108*cdf0e10cSrcweir OLEVariant::OLEVariant()
109*cdf0e10cSrcweir {
110*cdf0e10cSrcweir 	VariantInit(this);
111*cdf0e10cSrcweir }
112*cdf0e10cSrcweir OLEVariant::OLEVariant(const VARIANT& varSrc)
113*cdf0e10cSrcweir {
114*cdf0e10cSrcweir 	::VariantInit(this);
115*cdf0e10cSrcweir 	HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(&varSrc));
116*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
117*cdf0e10cSrcweir     OSL_UNUSED(eRet);
118*cdf0e10cSrcweir }
119*cdf0e10cSrcweir OLEVariant::OLEVariant(const OLEVariant& varSrc)
120*cdf0e10cSrcweir {
121*cdf0e10cSrcweir 	::VariantInit(this);
122*cdf0e10cSrcweir 	HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(static_cast<const VARIANT*>(&varSrc)));
123*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
124*cdf0e10cSrcweir     OSL_UNUSED(eRet);
125*cdf0e10cSrcweir }
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir OLEVariant::OLEVariant(sal_Bool x)				{	VariantInit(this);	vt = VT_BOOL;	boolVal		= (x ? VARIANT_TRUE : VARIANT_FALSE);}
128*cdf0e10cSrcweir OLEVariant::OLEVariant(sal_Int8 n)				{	VariantInit(this);	vt = VT_I1;		bVal		= n;}
129*cdf0e10cSrcweir OLEVariant::OLEVariant(sal_Int16 n)				{	VariantInit(this);	vt = VT_I2;		intVal		= n;}
130*cdf0e10cSrcweir OLEVariant::OLEVariant(sal_Int32 n)				{	VariantInit(this);	vt = VT_I4;		lVal		= n;}
131*cdf0e10cSrcweir OLEVariant::OLEVariant(sal_Int64 x)				{	VariantInit(this);	vt = VT_I4;		lVal		= (LONG)x;}
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir OLEVariant::OLEVariant(const rtl::OUString& us)
134*cdf0e10cSrcweir {
135*cdf0e10cSrcweir 	::VariantInit(this);
136*cdf0e10cSrcweir 	vt		= VT_BSTR;
137*cdf0e10cSrcweir 	bstrVal	= SysAllocString(reinterpret_cast<LPCOLESTR>(us.getStr()));
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir OLEVariant::~OLEVariant()
140*cdf0e10cSrcweir {
141*cdf0e10cSrcweir 	HRESULT eRet = ::VariantClear(this);
142*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
143*cdf0e10cSrcweir     OSL_UNUSED(eRet);
144*cdf0e10cSrcweir } // clears all the memory that was allocated before
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir OLEVariant::OLEVariant(const ::com::sun::star::util::Date& x )
147*cdf0e10cSrcweir {
148*cdf0e10cSrcweir 	VariantInit(this);
149*cdf0e10cSrcweir 	vt		= VT_DATE;
150*cdf0e10cSrcweir 	dblVal	= ::dbtools::DBTypeConversion::toDouble(x,::com::sun::star::util::Date(30,12,1899));
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir OLEVariant::OLEVariant(const ::com::sun::star::util::Time& x )
153*cdf0e10cSrcweir {
154*cdf0e10cSrcweir 	VariantInit(this);
155*cdf0e10cSrcweir 	vt		= VT_DATE;
156*cdf0e10cSrcweir 	dblVal	= ::dbtools::DBTypeConversion::toDouble(x);
157*cdf0e10cSrcweir }
158*cdf0e10cSrcweir OLEVariant::OLEVariant(const ::com::sun::star::util::DateTime& x )
159*cdf0e10cSrcweir {
160*cdf0e10cSrcweir 	VariantInit(this);
161*cdf0e10cSrcweir 	vt		= VT_DATE;
162*cdf0e10cSrcweir 	dblVal	= ::dbtools::DBTypeConversion::toDouble(x,::com::sun::star::util::Date(30,12,1899));
163*cdf0e10cSrcweir }
164*cdf0e10cSrcweir OLEVariant::OLEVariant(const float &x)
165*cdf0e10cSrcweir {
166*cdf0e10cSrcweir 	VariantInit(this);
167*cdf0e10cSrcweir 	vt		= VT_R4;
168*cdf0e10cSrcweir 	fltVal	= x;
169*cdf0e10cSrcweir }
170*cdf0e10cSrcweir OLEVariant::OLEVariant(const double &x)
171*cdf0e10cSrcweir {
172*cdf0e10cSrcweir 	VariantInit(this);
173*cdf0e10cSrcweir 	vt		= VT_R8;
174*cdf0e10cSrcweir 	dblVal	= x;
175*cdf0e10cSrcweir }
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir OLEVariant::OLEVariant(IDispatch* pDispInterface)
179*cdf0e10cSrcweir {
180*cdf0e10cSrcweir 	VariantInit(this);
181*cdf0e10cSrcweir 	setIDispatch( pDispInterface );
182*cdf0e10cSrcweir }
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir OLEVariant::OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x)
185*cdf0e10cSrcweir {
186*cdf0e10cSrcweir 	VariantInit(this);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	vt		= VT_ARRAY|VT_UI1;
189*cdf0e10cSrcweir 
190*cdf0e10cSrcweir     SAFEARRAYBOUND rgsabound[1];
191*cdf0e10cSrcweir     rgsabound[0].lLbound = 0;
192*cdf0e10cSrcweir 	rgsabound[0].cElements = x.getLength();
193*cdf0e10cSrcweir     //	parray	= SafeArrayCreate(VT_UI1,1,rgsabound);
194*cdf0e10cSrcweir 	parray	= SafeArrayCreateVector(VT_UI1, 0, x.getLength());
195*cdf0e10cSrcweir 	const sal_Int8* pBegin = x.getConstArray();
196*cdf0e10cSrcweir 	const sal_Int8* pEnd = pBegin + x.getLength();
197*cdf0e10cSrcweir 
198*cdf0e10cSrcweir 	for(sal_Int32 i=0;pBegin != pEnd;++i,++pBegin)
199*cdf0e10cSrcweir 	{
200*cdf0e10cSrcweir 		sal_Int32 nData = *pBegin;
201*cdf0e10cSrcweir 		HRESULT rs = SafeArrayPutElement(parray,&i,&nData);
202*cdf0e10cSrcweir 		OSL_ENSURE(S_OK == rs,"Error while copy byte data");
203*cdf0e10cSrcweir         OSL_UNUSED(rs);
204*cdf0e10cSrcweir 	}
205*cdf0e10cSrcweir }
206*cdf0e10cSrcweir //
207*cdf0e10cSrcweir OLEVariant& OLEVariant::operator=(const OLEVariant& varSrc)
208*cdf0e10cSrcweir {
209*cdf0e10cSrcweir 	HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(static_cast<const VARIANT*>(&varSrc)));
210*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
211*cdf0e10cSrcweir     OSL_UNUSED(eRet);
212*cdf0e10cSrcweir 	return *this;
213*cdf0e10cSrcweir }
214*cdf0e10cSrcweir // Assign a const VARIANT& (::VariantCopy handles everything)
215*cdf0e10cSrcweir //
216*cdf0e10cSrcweir OLEVariant& OLEVariant::operator=(const tagVARIANT& varSrc)
217*cdf0e10cSrcweir {
218*cdf0e10cSrcweir 	HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(&varSrc));
219*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
220*cdf0e10cSrcweir     OSL_UNUSED(eRet);
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir 	return *this;
223*cdf0e10cSrcweir }
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir // Assign a const VARIANT* (::VariantCopy handles everything)
226*cdf0e10cSrcweir //
227*cdf0e10cSrcweir OLEVariant& OLEVariant::operator=(const VARIANT* pSrc)
228*cdf0e10cSrcweir {
229*cdf0e10cSrcweir 	HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(pSrc));
230*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
231*cdf0e10cSrcweir     OSL_UNUSED(eRet);
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir 	return *this;
234*cdf0e10cSrcweir }
235*cdf0e10cSrcweir 
236*cdf0e10cSrcweir void OLEVariant::setByte(sal_uInt8 n)
237*cdf0e10cSrcweir {
238*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
239*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
240*cdf0e10cSrcweir     OSL_UNUSED(eRet);
241*cdf0e10cSrcweir 	vt = VT_UI1;
242*cdf0e10cSrcweir 	bVal = n;
243*cdf0e10cSrcweir }
244*cdf0e10cSrcweir void OLEVariant::setInt16(sal_Int16 n)
245*cdf0e10cSrcweir {
246*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
247*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
248*cdf0e10cSrcweir     OSL_UNUSED(eRet);
249*cdf0e10cSrcweir 	vt		= VT_I2;
250*cdf0e10cSrcweir 	iVal	= n;
251*cdf0e10cSrcweir }
252*cdf0e10cSrcweir void OLEVariant::setInt32(sal_Int32 n)
253*cdf0e10cSrcweir {
254*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
255*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
256*cdf0e10cSrcweir     OSL_UNUSED(eRet);
257*cdf0e10cSrcweir 	vt		= VT_I4;
258*cdf0e10cSrcweir 	lVal	= n;
259*cdf0e10cSrcweir }
260*cdf0e10cSrcweir void OLEVariant::setFloat(float f)
261*cdf0e10cSrcweir {	HRESULT eRet = VariantClear(this);
262*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
263*cdf0e10cSrcweir     OSL_UNUSED(eRet);
264*cdf0e10cSrcweir 	vt		= VT_R4;
265*cdf0e10cSrcweir 	fltVal	= f;
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir void OLEVariant::setDouble(double d)
268*cdf0e10cSrcweir {
269*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
270*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
271*cdf0e10cSrcweir     OSL_UNUSED(eRet);
272*cdf0e10cSrcweir 	vt		= VT_R8;
273*cdf0e10cSrcweir 	dblVal	= d;
274*cdf0e10cSrcweir }
275*cdf0e10cSrcweir void OLEVariant::setDate(DATE d)
276*cdf0e10cSrcweir {	HRESULT eRet = VariantClear(this);
277*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
278*cdf0e10cSrcweir     OSL_UNUSED(eRet);
279*cdf0e10cSrcweir 	vt		= VT_DATE;
280*cdf0e10cSrcweir 	date	= d;
281*cdf0e10cSrcweir }
282*cdf0e10cSrcweir void OLEVariant::setChar(unsigned char a)
283*cdf0e10cSrcweir {
284*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
285*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
286*cdf0e10cSrcweir     OSL_UNUSED(eRet);
287*cdf0e10cSrcweir 	vt = VT_UI1;
288*cdf0e10cSrcweir 	bVal		= a;
289*cdf0e10cSrcweir }
290*cdf0e10cSrcweir void OLEVariant::setCurrency(double aCur)
291*cdf0e10cSrcweir {
292*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
293*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
294*cdf0e10cSrcweir     OSL_UNUSED(eRet);
295*cdf0e10cSrcweir 	vt = VT_CY;
296*cdf0e10cSrcweir 	set(aCur*10000);
297*cdf0e10cSrcweir }
298*cdf0e10cSrcweir void OLEVariant::setBool(sal_Bool b)
299*cdf0e10cSrcweir {
300*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
301*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
302*cdf0e10cSrcweir     OSL_UNUSED(eRet);
303*cdf0e10cSrcweir 	vt = VT_BOOL;
304*cdf0e10cSrcweir 	boolVal		= b ? VARIANT_TRUE : VARIANT_FALSE;
305*cdf0e10cSrcweir }
306*cdf0e10cSrcweir void OLEVariant::setString(const rtl::OUString& us)
307*cdf0e10cSrcweir {
308*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
309*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
310*cdf0e10cSrcweir     OSL_UNUSED(eRet);
311*cdf0e10cSrcweir 	vt = VT_BSTR;
312*cdf0e10cSrcweir 	bstrVal		= ::SysAllocString(reinterpret_cast<LPCOLESTR>(us.getStr()));
313*cdf0e10cSrcweir }
314*cdf0e10cSrcweir void OLEVariant::setNoArg()
315*cdf0e10cSrcweir {
316*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
317*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
318*cdf0e10cSrcweir     OSL_UNUSED(eRet);
319*cdf0e10cSrcweir 	vt = VT_ERROR;
320*cdf0e10cSrcweir 	scode		= DISP_E_PARAMNOTFOUND;
321*cdf0e10cSrcweir }
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir void OLEVariant::setNull()
324*cdf0e10cSrcweir {
325*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
326*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
327*cdf0e10cSrcweir     OSL_UNUSED(eRet);
328*cdf0e10cSrcweir 	vt = VT_NULL;
329*cdf0e10cSrcweir }
330*cdf0e10cSrcweir void OLEVariant::setEmpty()
331*cdf0e10cSrcweir {
332*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
333*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
334*cdf0e10cSrcweir     OSL_UNUSED(eRet);
335*cdf0e10cSrcweir 	vt = VT_EMPTY;
336*cdf0e10cSrcweir }
337*cdf0e10cSrcweir 
338*cdf0e10cSrcweir void OLEVariant::setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr)
339*cdf0e10cSrcweir {
340*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
341*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
342*cdf0e10cSrcweir     OSL_UNUSED(eRet);
343*cdf0e10cSrcweir 	vt = VT_ARRAY|VT_UI1; parray = pSafeAr;
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir void OLEVariant::setArray(SAFEARRAY* pSafeArray, VARTYPE vtType)
347*cdf0e10cSrcweir {
348*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
349*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
350*cdf0e10cSrcweir     OSL_UNUSED(eRet);
351*cdf0e10cSrcweir 	vt = (VARTYPE)(VT_ARRAY|vtType);
352*cdf0e10cSrcweir 	parray = pSafeArray;
353*cdf0e10cSrcweir }
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir void OLEVariant::setIDispatch(IDispatch* pDispInterface)
356*cdf0e10cSrcweir {
357*cdf0e10cSrcweir 	HRESULT eRet = VariantClear(this);
358*cdf0e10cSrcweir 	OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
359*cdf0e10cSrcweir     OSL_UNUSED(eRet);
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir 	vt = VT_DISPATCH;
362*cdf0e10cSrcweir 	pdispVal = pDispInterface;
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir 	if ( pDispInterface )
365*cdf0e10cSrcweir 		pDispInterface->AddRef();
366*cdf0e10cSrcweir }
367*cdf0e10cSrcweir 
368*cdf0e10cSrcweir 
369*cdf0e10cSrcweir sal_Bool OLEVariant::isNull() const  {	return (vt == VT_NULL);		}
370*cdf0e10cSrcweir sal_Bool OLEVariant::isEmpty() const {	return (vt == VT_EMPTY);	}
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir VARTYPE OLEVariant::getType() const { return vt; }
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir OLEVariant::operator ::com::sun::star::util::Date() const
375*cdf0e10cSrcweir {
376*cdf0e10cSrcweir 	return isNull() ? ::com::sun::star::util::Date(30,12,1899) : ::dbtools::DBTypeConversion::toDate(getDate(),::com::sun::star::util::Date(30,12,1899));
377*cdf0e10cSrcweir }
378*cdf0e10cSrcweir OLEVariant::operator ::com::sun::star::util::Time()	const
379*cdf0e10cSrcweir {
380*cdf0e10cSrcweir 	return isNull() ? ::com::sun::star::util::Time() : ::dbtools::DBTypeConversion::toTime(getDate());
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir OLEVariant::operator ::com::sun::star::util::DateTime()const
383*cdf0e10cSrcweir {
384*cdf0e10cSrcweir 	return isNull() ? ::com::sun::star::util::DateTime() : ::dbtools::DBTypeConversion::toDateTime(getDate(),::com::sun::star::util::Date(30,12,1899));
385*cdf0e10cSrcweir }
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir VARIANT_BOOL OLEVariant::VariantBool(sal_Bool bEinBoolean)
388*cdf0e10cSrcweir {
389*cdf0e10cSrcweir 	return (bEinBoolean ? VARIANT_TRUE : VARIANT_FALSE);
390*cdf0e10cSrcweir }
391*cdf0e10cSrcweir 
392*cdf0e10cSrcweir void OLEVariant::CHS()
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir 	cyVal.Lo  ^= (sal_uInt32)-1;
395*cdf0e10cSrcweir 	cyVal.Hi ^= -1;
396*cdf0e10cSrcweir 	cyVal.Lo++;
397*cdf0e10cSrcweir 	if( !cyVal.Lo )
398*cdf0e10cSrcweir 		cyVal.Hi++;
399*cdf0e10cSrcweir }
400*cdf0e10cSrcweir 
401*cdf0e10cSrcweir void OLEVariant::set(double n)
402*cdf0e10cSrcweir {
403*cdf0e10cSrcweir 	if( n >= 0 )
404*cdf0e10cSrcweir 	{
405*cdf0e10cSrcweir 		cyVal.Hi = (sal_Int32)(n / (double)4294967296.0);
406*cdf0e10cSrcweir 		cyVal.Lo  = (sal_uInt32)(n - ((double)cyVal.Hi * (double)4294967296.0));
407*cdf0e10cSrcweir 	}
408*cdf0e10cSrcweir 	else {
409*cdf0e10cSrcweir 		cyVal.Hi = (sal_Int32)(-n / (double)4294967296.0);
410*cdf0e10cSrcweir 		cyVal.Lo  = (sal_uInt32)(-n - ((double)cyVal.Hi * (double)4294967296.0));
411*cdf0e10cSrcweir 		CHS();
412*cdf0e10cSrcweir 	}
413*cdf0e10cSrcweir }
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir OLEVariant::operator rtl::OUString() const
416*cdf0e10cSrcweir {
417*cdf0e10cSrcweir 	if (V_VT(this) == VT_BSTR)
418*cdf0e10cSrcweir 		return reinterpret_cast<const sal_Unicode*>(LPCOLESTR(V_BSTR(this)));
419*cdf0e10cSrcweir 
420*cdf0e10cSrcweir 	if(isNull())
421*cdf0e10cSrcweir 		return ::rtl::OUString();
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir 	OLEVariant varDest;
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir 	varDest.ChangeType(VT_BSTR, this);
426*cdf0e10cSrcweir 
427*cdf0e10cSrcweir 	return reinterpret_cast<const sal_Unicode*>(LPCOLESTR(V_BSTR(&varDest)));
428*cdf0e10cSrcweir }
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir // -----------------------------------------------------------------------------
431*cdf0e10cSrcweir void OLEVariant::ChangeType(VARTYPE vartype, const OLEVariant* pSrc)
432*cdf0e10cSrcweir {
433*cdf0e10cSrcweir 	//
434*cdf0e10cSrcweir 	// If pDest is NULL, convert type in place
435*cdf0e10cSrcweir 	//
436*cdf0e10cSrcweir 	if (pSrc == NULL)
437*cdf0e10cSrcweir 		pSrc = this;
438*cdf0e10cSrcweir 
439*cdf0e10cSrcweir 	if	(	( this != pSrc )
440*cdf0e10cSrcweir 		||	( vartype != V_VT( this ) )
441*cdf0e10cSrcweir 		)
442*cdf0e10cSrcweir 	{
443*cdf0e10cSrcweir 		if ( FAILED( ::VariantChangeType(	static_cast< VARIANT* >( this ),
444*cdf0e10cSrcweir 											const_cast< VARIANT* >( static_cast< const VARIANT* >( pSrc ) ),
445*cdf0e10cSrcweir 											0,
446*cdf0e10cSrcweir 											vartype ) ) )
447*cdf0e10cSrcweir 		{
448*cdf0e10cSrcweir             ::connectivity::SharedResources aResources;
449*cdf0e10cSrcweir             const ::rtl::OUString sError( aResources.getResourceString(STR_TYPE_NOT_CONVERT));
450*cdf0e10cSrcweir 			throw ::com::sun::star::sdbc::SQLException(
451*cdf0e10cSrcweir 				sError,
452*cdf0e10cSrcweir 				NULL,
453*cdf0e10cSrcweir 				::rtl::OUString::createFromAscii( "S1000" ),
454*cdf0e10cSrcweir 				1000,
455*cdf0e10cSrcweir 				::com::sun::star::uno::Any()
456*cdf0e10cSrcweir 			);
457*cdf0e10cSrcweir 		}
458*cdf0e10cSrcweir 	}
459*cdf0e10cSrcweir }
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir // -----------------------------------------------------------------------------
462*cdf0e10cSrcweir OLEVariant::operator ::com::sun::star::uno::Sequence< sal_Int8 >() const
463*cdf0e10cSrcweir {
464*cdf0e10cSrcweir 	::com::sun::star::uno::Sequence< sal_Int8 > aRet;
465*cdf0e10cSrcweir 	if(V_VT(this) == VT_BSTR)
466*cdf0e10cSrcweir 	{
467*cdf0e10cSrcweir 		OLEString sStr(V_BSTR(this));
468*cdf0e10cSrcweir 		aRet = ::com::sun::star::uno::Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>((const wchar_t*)sStr),sizeof(sal_Unicode)*sStr.length());
469*cdf0e10cSrcweir 	}
470*cdf0e10cSrcweir 	else if(!isNull())
471*cdf0e10cSrcweir 	{
472*cdf0e10cSrcweir 		SAFEARRAY* pArray = getUI1SAFEARRAYPtr();
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir 		if(pArray)
475*cdf0e10cSrcweir 		{
476*cdf0e10cSrcweir 			HRESULT hresult1,hresult2;
477*cdf0e10cSrcweir 			long lBound,uBound;
478*cdf0e10cSrcweir 			// Verify that the SafeArray is the proper shape.
479*cdf0e10cSrcweir 			hresult1 = ::SafeArrayGetLBound(pArray, 1, &lBound);
480*cdf0e10cSrcweir 			hresult2 = ::SafeArrayGetUBound(pArray, 1, &uBound);
481*cdf0e10cSrcweir 			if ( SUCCEEDED(hresult1) && SUCCEEDED(hresult2) )
482*cdf0e10cSrcweir 			{
483*cdf0e10cSrcweir 				long nCount = uBound-lBound+1;
484*cdf0e10cSrcweir 				aRet.realloc(nCount);
485*cdf0e10cSrcweir 				sal_Int8* pData = aRet.getArray();
486*cdf0e10cSrcweir 				for(long i=0; SUCCEEDED(hresult1) && lBound <= uBound ;++i,++lBound)
487*cdf0e10cSrcweir 				{
488*cdf0e10cSrcweir 					sal_Int32 nData = 0;
489*cdf0e10cSrcweir 					hresult1 = ::SafeArrayGetElement(pArray,&lBound,&nData);
490*cdf0e10cSrcweir 					if ( SUCCEEDED(hresult1) )
491*cdf0e10cSrcweir 					{
492*cdf0e10cSrcweir 						*pData = static_cast<sal_Int8>(nData);
493*cdf0e10cSrcweir 						++pData;
494*cdf0e10cSrcweir 					}
495*cdf0e10cSrcweir 				}
496*cdf0e10cSrcweir 			}
497*cdf0e10cSrcweir 		}
498*cdf0e10cSrcweir 	}
499*cdf0e10cSrcweir 
500*cdf0e10cSrcweir 	return aRet;
501*cdf0e10cSrcweir }
502*cdf0e10cSrcweir // -----------------------------------------------------------------------------
503*cdf0e10cSrcweir ::rtl::OUString OLEVariant::getString() const
504*cdf0e10cSrcweir {
505*cdf0e10cSrcweir 	if(isNull())
506*cdf0e10cSrcweir 		return ::rtl::OUString();
507*cdf0e10cSrcweir 	else
508*cdf0e10cSrcweir 		return *this;
509*cdf0e10cSrcweir }
510*cdf0e10cSrcweir // -----------------------------------------------------------------------------
511*cdf0e10cSrcweir sal_Bool OLEVariant::getBool() const
512*cdf0e10cSrcweir {
513*cdf0e10cSrcweir 	if (V_VT(this) == VT_BOOL)
514*cdf0e10cSrcweir 		return V_BOOL(this) == VARIANT_TRUE ? sal_True : sal_False;
515*cdf0e10cSrcweir 	if(isNull())
516*cdf0e10cSrcweir 		return sal_False;
517*cdf0e10cSrcweir 
518*cdf0e10cSrcweir 	OLEVariant varDest;
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir 	varDest.ChangeType(VT_BOOL, this);
521*cdf0e10cSrcweir 
522*cdf0e10cSrcweir 	return V_BOOL(&varDest) == VARIANT_TRUE ? sal_True : sal_False;
523*cdf0e10cSrcweir }
524*cdf0e10cSrcweir // -----------------------------------------------------------------------------
525*cdf0e10cSrcweir IUnknown* OLEVariant::getIUnknown() const
526*cdf0e10cSrcweir {
527*cdf0e10cSrcweir 	if (V_VT(this) == VT_UNKNOWN)
528*cdf0e10cSrcweir 	{
529*cdf0e10cSrcweir 		return V_UNKNOWN(this);
530*cdf0e10cSrcweir 	}
531*cdf0e10cSrcweir 	if(isNull())
532*cdf0e10cSrcweir 		return NULL;
533*cdf0e10cSrcweir 
534*cdf0e10cSrcweir 	OLEVariant varDest;
535*cdf0e10cSrcweir 
536*cdf0e10cSrcweir 	varDest.ChangeType(VT_UNKNOWN, this);
537*cdf0e10cSrcweir 
538*cdf0e10cSrcweir 	V_UNKNOWN(&varDest)->AddRef();
539*cdf0e10cSrcweir 	return V_UNKNOWN(&varDest);
540*cdf0e10cSrcweir }
541*cdf0e10cSrcweir // -----------------------------------------------------------------------------
542*cdf0e10cSrcweir IDispatch* OLEVariant::getIDispatch() const
543*cdf0e10cSrcweir {
544*cdf0e10cSrcweir 	if (V_VT(this) == VT_DISPATCH)
545*cdf0e10cSrcweir 	{
546*cdf0e10cSrcweir 		return V_DISPATCH(this);
547*cdf0e10cSrcweir 	}
548*cdf0e10cSrcweir 
549*cdf0e10cSrcweir 	if(isNull())
550*cdf0e10cSrcweir 		return NULL;
551*cdf0e10cSrcweir 
552*cdf0e10cSrcweir 	OLEVariant varDest;
553*cdf0e10cSrcweir 
554*cdf0e10cSrcweir 	varDest.ChangeType(VT_DISPATCH, this);
555*cdf0e10cSrcweir 
556*cdf0e10cSrcweir 	V_DISPATCH(&varDest)->AddRef();
557*cdf0e10cSrcweir 	return V_DISPATCH(&varDest);
558*cdf0e10cSrcweir }
559*cdf0e10cSrcweir // -----------------------------------------------------------------------------
560*cdf0e10cSrcweir sal_uInt8 OLEVariant::getByte() const
561*cdf0e10cSrcweir {
562*cdf0e10cSrcweir 	if (V_VT(this) == VT_UI1)
563*cdf0e10cSrcweir 		return V_UI1(this);
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir 	if(isNull())
566*cdf0e10cSrcweir 		return sal_Int8(0);
567*cdf0e10cSrcweir 	OLEVariant varDest;
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir 	varDest.ChangeType(VT_UI1, this);
570*cdf0e10cSrcweir 
571*cdf0e10cSrcweir 	return V_UI1(&varDest);
572*cdf0e10cSrcweir }
573*cdf0e10cSrcweir // -----------------------------------------------------------------------------
574*cdf0e10cSrcweir sal_Int16 OLEVariant::getInt16() const
575*cdf0e10cSrcweir {
576*cdf0e10cSrcweir 	if (V_VT(this) == VT_I2)
577*cdf0e10cSrcweir 		return V_I2(this);
578*cdf0e10cSrcweir 
579*cdf0e10cSrcweir 	if(isNull())
580*cdf0e10cSrcweir 		return sal_Int16(0);
581*cdf0e10cSrcweir 	OLEVariant varDest;
582*cdf0e10cSrcweir 
583*cdf0e10cSrcweir 	varDest.ChangeType(VT_I2, this);
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir 	return V_I2(&varDest);
586*cdf0e10cSrcweir }
587*cdf0e10cSrcweir // -----------------------------------------------------------------------------
588*cdf0e10cSrcweir sal_Int8 OLEVariant::getInt8() const
589*cdf0e10cSrcweir {
590*cdf0e10cSrcweir 	if (V_VT(this) == VT_I1)
591*cdf0e10cSrcweir 		return V_I1(this);
592*cdf0e10cSrcweir 
593*cdf0e10cSrcweir 	if(isNull())
594*cdf0e10cSrcweir 		return sal_Int8(0);
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir 	OLEVariant varDest;
597*cdf0e10cSrcweir 
598*cdf0e10cSrcweir 	varDest.ChangeType(VT_I1, this);
599*cdf0e10cSrcweir 
600*cdf0e10cSrcweir 	return V_I1(&varDest);
601*cdf0e10cSrcweir }
602*cdf0e10cSrcweir // -----------------------------------------------------------------------------
603*cdf0e10cSrcweir sal_Int32 OLEVariant::getInt32() const
604*cdf0e10cSrcweir {
605*cdf0e10cSrcweir 	if (V_VT(this) == VT_I4)
606*cdf0e10cSrcweir 		return V_I4(this);
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir 	if(isNull())
609*cdf0e10cSrcweir 		return sal_Int32(0);
610*cdf0e10cSrcweir 
611*cdf0e10cSrcweir 	OLEVariant varDest;
612*cdf0e10cSrcweir 
613*cdf0e10cSrcweir 	varDest.ChangeType(VT_I4, this);
614*cdf0e10cSrcweir 
615*cdf0e10cSrcweir 	return V_I4(&varDest);
616*cdf0e10cSrcweir }
617*cdf0e10cSrcweir // -----------------------------------------------------------------------------
618*cdf0e10cSrcweir sal_uInt32 OLEVariant::getUInt32() const
619*cdf0e10cSrcweir {
620*cdf0e10cSrcweir 	if (V_VT(this) == VT_UI4)
621*cdf0e10cSrcweir 		return V_UI4(this);
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir 	if(isNull())
624*cdf0e10cSrcweir 		return sal_uInt32(0);
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 	OLEVariant varDest;
627*cdf0e10cSrcweir 
628*cdf0e10cSrcweir 	varDest.ChangeType(VT_UI4, this);
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir 	return V_UI4(&varDest);
631*cdf0e10cSrcweir }
632*cdf0e10cSrcweir // -----------------------------------------------------------------------------
633*cdf0e10cSrcweir float OLEVariant::getFloat() const
634*cdf0e10cSrcweir {
635*cdf0e10cSrcweir 	if (V_VT(this) == VT_R4)
636*cdf0e10cSrcweir 		return V_R4(this);
637*cdf0e10cSrcweir 
638*cdf0e10cSrcweir 	if(isNull())
639*cdf0e10cSrcweir 		return float(0);
640*cdf0e10cSrcweir 	OLEVariant varDest;
641*cdf0e10cSrcweir 
642*cdf0e10cSrcweir 	varDest.ChangeType(VT_R4, this);
643*cdf0e10cSrcweir 
644*cdf0e10cSrcweir 	return V_R4(&varDest);
645*cdf0e10cSrcweir }
646*cdf0e10cSrcweir // -----------------------------------------------------------------------------
647*cdf0e10cSrcweir double OLEVariant::getDouble() const
648*cdf0e10cSrcweir {
649*cdf0e10cSrcweir 	if (V_VT(this) == VT_R8)
650*cdf0e10cSrcweir 		return V_R8(this);
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir 	if(isNull())
653*cdf0e10cSrcweir 		return double(0);
654*cdf0e10cSrcweir 	OLEVariant varDest;
655*cdf0e10cSrcweir 
656*cdf0e10cSrcweir 	varDest.ChangeType(VT_R8, this);
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir 	return V_R8(&varDest);
659*cdf0e10cSrcweir }
660*cdf0e10cSrcweir // -----------------------------------------------------------------------------
661*cdf0e10cSrcweir double OLEVariant::getDate() const
662*cdf0e10cSrcweir {
663*cdf0e10cSrcweir 	if (V_VT(this) == VT_DATE)
664*cdf0e10cSrcweir 		return V_DATE(this);
665*cdf0e10cSrcweir 
666*cdf0e10cSrcweir 	if(isNull())
667*cdf0e10cSrcweir 		return double(0);
668*cdf0e10cSrcweir 	OLEVariant varDest;
669*cdf0e10cSrcweir 
670*cdf0e10cSrcweir 	varDest.ChangeType(VT_DATE, this);
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir 	return V_DATE(&varDest);
673*cdf0e10cSrcweir }
674*cdf0e10cSrcweir // -----------------------------------------------------------------------------
675*cdf0e10cSrcweir CY OLEVariant::getCurrency() const
676*cdf0e10cSrcweir {
677*cdf0e10cSrcweir 	if (V_VT(this) == VT_CY)
678*cdf0e10cSrcweir 		return V_CY(this);
679*cdf0e10cSrcweir 
680*cdf0e10cSrcweir 	if(isNull())
681*cdf0e10cSrcweir 	{
682*cdf0e10cSrcweir 		CY aVar;
683*cdf0e10cSrcweir 		aVar.int64 = sal_Int64(0);
684*cdf0e10cSrcweir 		return aVar;
685*cdf0e10cSrcweir 	}
686*cdf0e10cSrcweir 	OLEVariant varDest;
687*cdf0e10cSrcweir 
688*cdf0e10cSrcweir 	varDest.ChangeType(VT_CY, this);
689*cdf0e10cSrcweir 
690*cdf0e10cSrcweir 	return V_CY(&varDest);
691*cdf0e10cSrcweir }
692*cdf0e10cSrcweir // -----------------------------------------------------------------------------
693*cdf0e10cSrcweir SAFEARRAY* OLEVariant::getUI1SAFEARRAYPtr() const
694*cdf0e10cSrcweir {
695*cdf0e10cSrcweir 	if (V_VT(this) == (VT_ARRAY|VT_UI1))
696*cdf0e10cSrcweir 		return V_ARRAY(this);
697*cdf0e10cSrcweir 
698*cdf0e10cSrcweir 	if(isNull())
699*cdf0e10cSrcweir 		return (0);
700*cdf0e10cSrcweir 	OLEVariant varDest;
701*cdf0e10cSrcweir 
702*cdf0e10cSrcweir 	varDest.ChangeType((VT_ARRAY|VT_UI1), this);
703*cdf0e10cSrcweir 
704*cdf0e10cSrcweir 	return V_ARRAY(&varDest);
705*cdf0e10cSrcweir }
706*cdf0e10cSrcweir // -----------------------------------------------------------------------------
707*cdf0e10cSrcweir ::com::sun::star::uno::Any OLEVariant::makeAny() const
708*cdf0e10cSrcweir {
709*cdf0e10cSrcweir     ::com::sun::star::uno::Any aValue;
710*cdf0e10cSrcweir     switch (V_VT(this))
711*cdf0e10cSrcweir     {
712*cdf0e10cSrcweir 	    case VT_EMPTY:
713*cdf0e10cSrcweir 	    case VT_NULL:
714*cdf0e10cSrcweir 		    aValue.setValue(NULL, Type());
715*cdf0e10cSrcweir 		    break;
716*cdf0e10cSrcweir 	    case VT_I2:
717*cdf0e10cSrcweir 		    aValue.setValue( & iVal, getCppuType( (sal_Int16*)0));
718*cdf0e10cSrcweir 		    break;
719*cdf0e10cSrcweir 	    case VT_I4:
720*cdf0e10cSrcweir 		    aValue.setValue( & lVal, getCppuType( (sal_Int32*)0));
721*cdf0e10cSrcweir 		    break;
722*cdf0e10cSrcweir 	    case VT_R4:
723*cdf0e10cSrcweir 		    aValue.setValue( & fltVal, getCppuType( (float*)0));
724*cdf0e10cSrcweir 		    break;
725*cdf0e10cSrcweir 	    case VT_R8:
726*cdf0e10cSrcweir 		    aValue.setValue(& dblVal, getCppuType( (double*)0));
727*cdf0e10cSrcweir 		    break;
728*cdf0e10cSrcweir 	    case VT_CY:
729*cdf0e10cSrcweir          {
730*cdf0e10cSrcweir              Currency cy(cyVal.int64);
731*cdf0e10cSrcweir              aValue <<= cy;
732*cdf0e10cSrcweir 		    break;
733*cdf0e10cSrcweir          }
734*cdf0e10cSrcweir 	    case VT_DATE:
735*cdf0e10cSrcweir          {
736*cdf0e10cSrcweir              aValue <<= (::com::sun::star::util::Date)*this;
737*cdf0e10cSrcweir 		    break;
738*cdf0e10cSrcweir          }
739*cdf0e10cSrcweir 	    case VT_BSTR:
740*cdf0e10cSrcweir 	    {
741*cdf0e10cSrcweir 		    OUString b(reinterpret_cast<const sal_Unicode*>(bstrVal));
742*cdf0e10cSrcweir 		    aValue.setValue( &b, getCppuType( &b));
743*cdf0e10cSrcweir 		    break;
744*cdf0e10cSrcweir 	    }
745*cdf0e10cSrcweir 	    case VT_BOOL:
746*cdf0e10cSrcweir 	    {
747*cdf0e10cSrcweir 		    sal_Bool b= boolVal == VARIANT_TRUE;
748*cdf0e10cSrcweir 		    aValue.setValue( &b, getCppuType( &b));
749*cdf0e10cSrcweir 		    break;
750*cdf0e10cSrcweir 	    }
751*cdf0e10cSrcweir 	    case VT_I1:
752*cdf0e10cSrcweir 		    aValue.setValue( & cVal, getCppuType((sal_Int8*)0));
753*cdf0e10cSrcweir 		    break;
754*cdf0e10cSrcweir 	    case VT_UI1: // there is no unsigned char in UNO
755*cdf0e10cSrcweir 		    aValue.setValue( & bVal, getCppuType( (sal_Int8*)0));
756*cdf0e10cSrcweir 		    break;
757*cdf0e10cSrcweir 	    case VT_UI2:
758*cdf0e10cSrcweir 		    aValue.setValue( & uiVal, getCppuType( (sal_uInt16*)0));
759*cdf0e10cSrcweir 		    break;
760*cdf0e10cSrcweir 	    case VT_UI4:
761*cdf0e10cSrcweir 		    aValue.setValue( & ulVal, getCppuType( (sal_uInt32*)0));
762*cdf0e10cSrcweir 		    break;
763*cdf0e10cSrcweir 	    case VT_INT:
764*cdf0e10cSrcweir 		    aValue.setValue( & intVal, getCppuType( (sal_Int32*)0));
765*cdf0e10cSrcweir 		    break;
766*cdf0e10cSrcweir 	    case VT_UINT:
767*cdf0e10cSrcweir 		    aValue.setValue( & uintVal, getCppuType( (sal_uInt32*)0));
768*cdf0e10cSrcweir 		    break;
769*cdf0e10cSrcweir 	    case VT_VOID:
770*cdf0e10cSrcweir 		    aValue.setValue( NULL, Type());
771*cdf0e10cSrcweir 		    break;
772*cdf0e10cSrcweir          case VT_DECIMAL:
773*cdf0e10cSrcweir          {
774*cdf0e10cSrcweir              Decimal dec;
775*cdf0e10cSrcweir              dec.Scale = decVal.scale;
776*cdf0e10cSrcweir              dec.Sign = decVal.sign;
777*cdf0e10cSrcweir              dec.LowValue = decVal.Lo32;
778*cdf0e10cSrcweir              dec.MiddleValue = decVal.Mid32;
779*cdf0e10cSrcweir              dec.HighValue = decVal.Hi32;
780*cdf0e10cSrcweir              aValue <<= dec;
781*cdf0e10cSrcweir              break;
782*cdf0e10cSrcweir          }
783*cdf0e10cSrcweir 
784*cdf0e10cSrcweir 	    default:
785*cdf0e10cSrcweir 		    break;
786*cdf0e10cSrcweir     }
787*cdf0e10cSrcweir     return aValue;
788*cdf0e10cSrcweir }
789*cdf0e10cSrcweir // -----------------------------------------------------------------------------
790*cdf0e10cSrcweir // -----------------------------------------------------------------------------
791*cdf0e10cSrcweir // -----------------------------------------------------------------------------
792