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