22#include <osl/diagnose.h>
24#include <com/sun/star/sdbc/SQLException.hpp>
25#include <com/sun/star/util/Time.hpp>
26#include <com/sun/star/util/Date.hpp>
27#include <com/sun/star/util/DateTime.hpp>
30#include <com/sun/star/bridge/oleautomation/Date.hpp>
31#include <com/sun/star/bridge/oleautomation/Currency.hpp>
32#include <com/sun/star/bridge/oleautomation/SCode.hpp>
33#include <com/sun/star/bridge/oleautomation/Decimal.hpp>
40OLEVariant::OLEVariant()
47 HRESULT eRet = ::VariantCopy(
this, &varSrc);
48 OSL_ENSURE(eRet == S_OK,
"Error while copying an ado variant!");
53 HRESULT eRet = ::VariantCopy(
this,
static_cast<const VARIANT*
>(&varSrc));
54 OSL_ENSURE(eRet == S_OK,
"Error while copying an ado variant!");
67 bstrVal = SysAllocStringLen(o3tl::toW(us.data()), us.length());
71 HRESULT eRet = ::VariantClear(
this);
72 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
119 parray = SafeArrayCreateVector(
VT_UI1, 0,
x.getLength());
120 const sal_Int8* pBegin =
x.getConstArray();
121 const sal_Int8* pEnd = pBegin +
x.getLength();
123 for(sal_Int32
i=0;pBegin != pEnd;++
i,++pBegin)
125 sal_Int32 nData = *pBegin;
126 HRESULT rs = SafeArrayPutElement(parray,&
i,&nData);
127 OSL_ENSURE(S_OK == rs,
"Error while copy byte data");
133 HRESULT eRet = ::VariantCopy(
this,
static_cast<const VARIANT*
>(&varSrc));
134 OSL_ENSURE(eRet == S_OK,
"Error while copying an ado variant!");
141 HRESULT eRet = ::VariantCopy(
this, &varSrc);
142 OSL_ENSURE(eRet == S_OK,
"Error while copying an ado variant!");
151 HRESULT eRet = ::VariantCopy(
this, pSrc);
152 OSL_ENSURE(eRet == S_OK,
"Error while copying an ado variant!");
159 HRESULT eRet = VariantClear(
this);
160 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
166 HRESULT eRet = VariantClear(
this);
167 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
173 HRESULT eRet = VariantClear(
this);
174 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
179{ HRESULT eRet = VariantClear(
this);
180 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
186 HRESULT eRet = VariantClear(
this);
187 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
192{ HRESULT eRet = VariantClear(
this);
193 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
199 HRESULT eRet = VariantClear(
this);
200 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
206 HRESULT eRet = VariantClear(
this);
207 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
213 HRESULT eRet = VariantClear(
this);
214 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
216 boolVal = b ? VARIANT_TRUE : VARIANT_FALSE;
220 HRESULT eRet = VariantClear(
this);
221 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
223 bstrVal = SysAllocStringLen(o3tl::toW(us.data()), us.length());
227 HRESULT eRet = VariantClear(
this);
228 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
230 scode = DISP_E_PARAMNOTFOUND;
235 HRESULT eRet = VariantClear(
this);
236 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
241 HRESULT eRet = VariantClear(
this);
242 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
248 HRESULT eRet = VariantClear(
this);
249 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
255 HRESULT eRet = VariantClear(
this);
256 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
257 vt =
static_cast<VARTYPE
>(
VT_ARRAY|vtType);
263 HRESULT eRet = VariantClear(
this);
264 OSL_ENSURE(eRet == S_OK,
"Error while clearing an ado variant!");
267 pdispVal = pDispInterface;
269 if ( pDispInterface )
270 pDispInterface->AddRef();
294 return (bEinBoolean ? VARIANT_TRUE : VARIANT_FALSE);
299 cyVal.Lo ^= sal_uInt32(-1);
310 cyVal.Hi =
static_cast<sal_Int32
>(
n / 4294967296.0);
311 cyVal.Lo =
static_cast<sal_uInt32
>(
n - (
static_cast<double>(cyVal.Hi) * 4294967296.0));
314 cyVal.Hi =
static_cast<sal_Int32
>(-
n / 4294967296.0);
315 cyVal.Lo =
static_cast<sal_uInt32
>(-
n - (
static_cast<double>(cyVal.Hi) * 4294967296.0));
323 return OUString(o3tl::toU(V_BSTR(
this)));
332 return OUString(o3tl::toU(V_BSTR(&varDest)));
344 if ( (
this != pSrc )
345 || ( vartype != V_VT(
this ) )
348 if ( FAILED( ::VariantChangeType(
static_cast< VARIANT*
>(
this ),
349 static_cast< const VARIANT*
>( pSrc ),
355 throw css::sdbc::SQLException(
369 css::uno::Sequence< sal_Int8 > aRet;
372 aRet = css::uno::Sequence<sal_Int8>(
reinterpret_cast<sal_Int8*
>(V_BSTR(
this)),
373 ::SysStringByteLen(V_BSTR(
this)));
381 HRESULT hresult1,hresult2;
384 hresult1 = ::SafeArrayGetLBound(pArray, 1, &lBound);
385 hresult2 = ::SafeArrayGetUBound(pArray, 1, &uBound);
386 if ( SUCCEEDED(hresult1) && SUCCEEDED(hresult2) )
391 for(; SUCCEEDED(hresult1) && lBound <= uBound ;++lBound)
394 hresult1 = ::SafeArrayGetElement(pArray,&lBound,&nData);
395 if ( SUCCEEDED(hresult1) )
411 return V_BOOL(
this) == VARIANT_TRUE;
419 return V_BOOL(&varDest) == VARIANT_TRUE;
424 if (V_VT(
this) == VT_UNKNOWN)
426 return V_UNKNOWN(
this);
435 V_UNKNOWN(&varDest)->AddRef();
436 return V_UNKNOWN(&varDest);
441 if (V_VT(
this) == VT_DISPATCH)
443 return V_DISPATCH(
this);
453 V_DISPATCH(&varDest)->AddRef();
454 return V_DISPATCH(&varDest);
468 return V_UI1(&varDest);
473 if (V_VT(
this) ==
VT_I2)
482 return V_I2(&varDest);
487 if (V_VT(
this) ==
VT_I1)
497 return V_I1(&varDest);
502 if (V_VT(
this) ==
VT_I4)
512 return V_I4(&varDest);
521 return sal_uInt32(0);
527 return V_UI4(&varDest);
532 if (V_VT(
this) ==
VT_R4)
541 return V_R4(&varDest);
546 if (V_VT(
this) ==
VT_R8)
555 return V_R8(&varDest);
569 return V_DATE(&varDest);
574 if (V_VT(
this) ==
VT_CY)
580 aVar.int64 = sal_Int64(0);
587 return V_CY(&varDest);
593 return V_ARRAY(
this);
601 return V_ARRAY(&varDest);
606 css::uno::Any aValue;
611 aValue.setValue(
nullptr,
Type());
638 OUString b(o3tl::toU(bstrVal));
644 aValue <<= (boolVal == VARIANT_TRUE);
666 aValue.setValue(
nullptr,
Type());
671 dec.Scale = decVal.scale;
672 dec.Sign = decVal.sign;
673 dec.LowValue = decVal.Lo32;
674 dec.MiddleValue = decVal.Mid32;
675 dec.HighValue = decVal.Hi32;
static double toDouble(std::string_view rString)
helper class for accessing resources shared by different libraries in the connectivity module
OUString getResourceString(TranslateId pResId) const
loads a string from the shared resource file
void setInt16(sal_Int16 n)
css::uno::Any makeAny() const
css::util::Date getDate() const
OUString getString() const
css::util::DateTime getDateTime() const
void setChar(unsigned char a)
void setCurrency(double aCur)
OLEVariant & operator=(const OLEVariant &varSrc)
void setByte(sal_uInt8 n)
void setString(std::u16string_view us)
css::util::Time getTime() const
SAFEARRAY * getUI1SAFEARRAYPtr() const
sal_uInt32 getUInt32() const
css::uno::Sequence< sal_Int8 > getByteSequence() const
void setArray(SAFEARRAY *pSafeArray, VARTYPE vtType)
static VARIANT_BOOL VariantBool(bool bEinBoolean)
void setUI1SAFEARRAYPtr(SAFEARRAY *pSafeAr)
double getDateAsDouble() const
void ChangeType(VARTYPE vartype, const OLEVariant *pSrc)
IDispatch * getIDispatch() const
void setInt32(sal_Int32 n)
sal_Int32 getInt32() const
IUnknown * getIUnknown() const
sal_Int16 getInt16() const
void setIDispatch(IDispatch *pDispInterface)
sal_uInt8 getByte() const
std::unique_ptr< sal_Int32[]> pData