252 if (typeName ==
"short" || typeName ==
"char")
254 else if (typeName ==
"float")
264 if (out && arg.vt == (VT_VARIANT|VT_BYREF) && arg.pvarVal) {
269 VARIANT *pVariant =
new VARIANT;
271 arg.vt = VT_VARIANT|VT_BYREF;
272 arg.pvarVal = pVariant;
276 switch ((
int)qvar.
type()) {
278 if (out && arg.vt == (VT_BSTR|VT_BYREF)) {
280 SysFreeString(*arg.pbstrVal);
282 arg.vt = VT_BSTR|VT_BYREF;
287 arg.pbstrVal =
new BSTR(arg.bstrVal);
294 if (out && arg.vt == (VT_I4|VT_BYREF)) {
295 *arg.plVal = qvar.
toInt();
298 arg.lVal = qvar.
toInt();
300 if (typeName ==
"short") {
302 arg.piVal =
new short(arg.lVal);
303 }
else if (typeName ==
"char") {
305 arg.pcVal=
new char(arg.lVal);
307 arg.plVal =
new long(arg.lVal);
315 if (out && (arg.vt == (VT_UINT|VT_BYREF) || arg.vt == (VT_I4|VT_BYREF))) {
316 *arg.puintVal = qvar.
toUInt();
319 arg.uintVal = qvar.
toUInt();
321 arg.puintVal =
new uint(arg.uintVal);
328 if (out && arg.vt == (VT_CY|VT_BYREF)) {
330 #if !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400 331 }
else if (out && arg.vt == (VT_I8|VT_BYREF)) {
337 arg.pllVal =
new LONGLONG(arg.llVal);
346 arg.pcyVal =
new CY(arg.cyVal);
354 if (out && arg.vt == (VT_CY|VT_BYREF)) {
356 #if !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400 357 }
else if (out && arg.vt == (VT_UI8|VT_BYREF)) {
363 arg.pullVal =
new ULONGLONG(arg.ullVal);
372 arg.pcyVal =
new CY(arg.cyVal);
382 if (out && arg.vt == (VT_BOOL|VT_BYREF)) {
383 *arg.pboolVal = qvar.
toBool() ? VARIANT_TRUE : VARIANT_FALSE;
386 arg.boolVal = qvar.
toBool() ? VARIANT_TRUE : VARIANT_FALSE;
388 arg.pboolVal =
new short(arg.boolVal);
394 if (out && arg.vt == (VT_R8|VT_BYREF)) {
400 if (typeName ==
"float") {
402 arg.pfltVal =
new float(arg.dblVal);
404 arg.pdblVal =
new double(arg.dblVal);
411 if (out && arg.vt == (VT_COLOR|VT_BYREF)) {
418 arg.plVal =
new long(arg.lVal);
427 if (out && arg.vt == (VT_DATE|VT_BYREF)) {
433 arg.pdate =
new DATE(arg.date);
439 if (out && arg.vt == (VT_DISPATCH|VT_BYREF)) {
442 *arg.ppdispVal =
QFontToIFont(qvariant_cast<QFont>(qvar));
444 arg.vt = VT_DISPATCH;
445 arg.pdispVal =
QFontToIFont(qvariant_cast<QFont>(qvar));
447 arg.ppdispVal =
new IDispatch*(arg.pdispVal);
454 if (out && arg.vt == (VT_DISPATCH|VT_BYREF)) {
459 arg.vt = VT_DISPATCH;
462 arg.ppdispVal =
new IDispatch*(arg.pdispVal);
472 if (out && (arg.vt & VT_BYREF)) {
473 switch(arg.vt & ~VT_BYREF) {
487 *arg.pintVal = shape;
490 *arg.puintVal = shape;
497 arg.plVal =
new long(arg.lVal);
508 const int count = list.
count();
509 VARTYPE vt = VT_VARIANT;
521 pElement = &variant.lVal;
525 pElement = &variant.dblVal;
529 pElement = &variant.date;
533 pElement = &variant.boolVal;
536 #if !defined(Q_OS_WINCE) && defined(_MSC_VER) && _MSC_VER >= 1400 538 pElement = &variant.llVal;
541 pElement = &variant.cyVal;
547 SAFEARRAY *array = 0;
553 int maxColumns = col.
count();
556 SAFEARRAYBOUND rgsabound[2] = { {0} };
557 rgsabound[0].cElements = count;
558 rgsabound[1].cElements = maxColumns;
559 array = SafeArrayCreate(VT_VARIANT, 2, rgsabound);
561 for (LONG i = 0; i < count; ++i) {
564 int columnCount =
qMin(maxColumns, columns.
count());
565 for (LONG j = 0; j < columnCount; ++j) {
567 VariantInit(&variant);
570 SafeArrayPutElement(array, rgIndices, pElement);
578 array = SafeArrayCreateVector(vt, 0, count);
583 VariantInit(&variant);
585 SafeArrayPutElement(array, &
index, pElement);
589 if (out && arg.vt == (VT_ARRAY|vt|VT_BYREF)) {
591 SafeArrayDestroy(*arg.pparray);
592 *arg.pparray = array;
594 arg.vt = VT_ARRAY|vt;
597 arg.pparray =
new SAFEARRAY*(arg.parray);
607 const int count = list.
count();
608 SAFEARRAY *array = SafeArrayCreateVector(VT_BSTR, 0, count);
612 SafeArrayPutElement(array, &
index, bstr);
616 if (out && arg.vt == (VT_ARRAY|VT_BSTR|VT_BYREF)) {
618 SafeArrayDestroy(*arg.pparray);
619 *arg.pparray = array;
621 arg.vt = VT_ARRAY|VT_BSTR;
624 arg.pparray =
new SAFEARRAY*(arg.parray);
635 SAFEARRAY *array = SafeArrayCreateVector(VT_UI1, 0, count);
639 SafeArrayAccessData(array, (
void **)&dest);
640 memcpy(dest, data, count);
641 SafeArrayUnaccessData(array);
644 if (out && arg.vt == (VT_ARRAY|VT_UI1|VT_BYREF)) {
646 SafeArrayDestroy(*arg.pparray);
647 *arg.pparray = array;
649 arg.vt = VT_ARRAY|VT_UI1;
652 arg.pparray =
new SAFEARRAY*(arg.parray);
664 typedef HRESULT(WINAPI* PGetRecordInfoFromTypeInfo)(ITypeInfo *, IRecordInfo **);
665 static PGetRecordInfoFromTypeInfo pGetRecordInfoFromTypeInfo = 0;
666 static bool resolved =
false;
669 pGetRecordInfoFromTypeInfo = (PGetRecordInfoFromTypeInfo)oleaut32.resolve(
"GetRecordInfoFromTypeInfo");
672 if (!pGetRecordInfoFromTypeInfo)
675 ITypeInfo *typeInfo = 0;
676 IRecordInfo *recordInfo = 0;
683 pGetRecordInfoFromTypeInfo(typeInfo, &recordInfo);
689 switch (qvar.
type()) {
693 recordInfo->RecordCreateCopy(&qrect, &record);
699 recordInfo->RecordCreateCopy(&qsize, &record);
705 recordInfo->RecordCreateCopy(&qpoint, &record);
711 arg.pRecInfo = recordInfo,
712 arg.pvRecord = record;
714 qWarning(
"QVariantToVARIANT: out-parameter not supported for records");
728 arg.vt = VT_DISPATCH;
729 arg.pdispVal = *(IDispatch**)qvar.
data();
731 arg.pdispVal->AddRef();
733 qWarning(
"QVariantToVARIANT: out-parameter not supported for IDispatch");
737 arg.vt = VT_DISPATCH;
738 arg.ppdispVal = *(IDispatch***)qvar.
data();
743 arg.punkVal = *(IUnknown**)qvar.
data();
745 arg.punkVal->AddRef();
747 qWarning(
"QVariantToVARIANT: out-parameter not supported for IUnknown");
752 arg.vt = VT_DISPATCH;
761 qWarning(
"QVariantToVARIANT: out-parameter not supported for subtype");
768 arg.vt = VT_DISPATCH;
769 object->queryInterface(IID_IDispatch, (
void**)&arg.pdispVal);
771 qWarning(
"QVariantToVARIANT: out-parameter not supported for subtype");
781 if (out && arg.vt == (VT_ERROR|VT_BYREF)) {
782 *arg.plVal = DISP_E_PARAMNOTFOUND;
785 arg.lVal = DISP_E_PARAMNOTFOUND;
787 arg.plVal =
new long(arg.lVal);
797 Q_ASSERT(!out || (arg.vt & VT_BYREF));
The QVariant class acts like a union for the most common Qt data types.
void clearVARIANT(VARIANT *var)
void truncate(int pos)
Truncates the byte array at index position pos.
The QCursor class provides a mouse cursor with an arbitrary shape.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
QAxFactory * qAxFactory()
The QByteArray class provides an array of bytes.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
QDateTime toDateTime() const
Returns the variant as a QDateTime if the variant has type() DateTime , Date , or String ; otherwise ...
QList< QVariant > toList() const
Returns the variant as a QVariantList if the variant has type() List or StringList ; otherwise return...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool toBool() const
Returns the variant as a bool if the variant has type() Bool.
int count(const T &t) const
Returns the number of occurrences of value in the list.
ITypeLib * qAxTypeLibrary
The QString class provides a Unicode character string.
int qstrcmp(const char *str1, const char *str2)
A safe strcmp() function.
The QAxObject class provides a QObject that wraps a COM object.
bool startsWith(const QByteArray &a) const
Returns true if this byte array starts with byte array ba; otherwise returns false.
static DATE QDateTimeToDATE(const QDateTime &dt)
QByteArray toByteArray() const
Returns the variant as a QByteArray if the variant has type() ByteArray or String (converted using QS...
int toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
qlonglong toLongLong(bool *ok=0) const
Returns the variant as a long long int if the variant has type() LongLong , Bool , ByteArray , Char , Double , Int , String , UInt , or ULongLong ; otherwise returns 0.
bool canConvert(Type t) const
Returns true if the variant's type can be cast to the requested type, t.
static IPictureDisp * QPixmapToIPicture(const QPixmap &pixmap)
const T & at(int i) const
Returns the item at index position i in the list.
The QStringList class provides a list of strings.
bool QVariantToVARIANT(const QVariant &var, VARIANT &arg, const QByteArray &typeName, bool out)
qulonglong toULongLong(bool *ok=0) const
Returns the variant as as an unsigned long long int if the variant has type() ULongLong ...
Q_CORE_EXPORT void qWarning(const char *,...)
static const char * data(const QByteArray &arr)
Type
This enum type defines the types of variable that a QVariant can contain.
static uint QColorToOLEColor(const QColor &col)
virtual bool createObjectWrapper(QObject *object, IDispatch **wrapper)
Reimplement this function to provide the COM object for object in wrapper.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
const char * typeName() const
Returns the name of the type stored in the variant.
QSize toSize() const
Returns the variant as a QSize if the variant has type() Size ; otherwise returns an invalid QSize...
bool convert(Type t)
Casts the variant to the requested type, t.
int length() const
Same as size().
const char * constData() const
Returns a pointer to the data stored in the byte array.
int count(char c) const
Returns the number of occurrences of character ch in the byte array.
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Type type() const
Returns the storage type of the value stored in the variant.
const void * constData() const
The QPoint class defines a point in the plane using integer precision.
static BSTR QStringToBSTR(const QString &str)
uint toUInt(bool *ok=0) const
Returns the variant as an unsigned int if the variant has type() UInt , Bool , ByteArray ...
The QRect class defines a rectangle in the plane using integer precision.
double toDouble(bool *ok=0) const
Returns the variant as a double if the variant has type() Double , QMetaType::Float ...
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
static IFontDisp * QFontToIFont(const QFont &font)
static Type nameToType(const char *name)
Converts the string representation of the storage type given in name, to its enum representation...
QPoint toPoint() const
Returns the variant as a QPoint if the variant has type() Point or PointF ; otherwise returns a null ...
bool endsWith(const QByteArray &a) const
Returns true if this byte array ends with byte array ba; otherwise returns false. ...
T qvariant_cast(const QVariant &value)
Returns the given value converted to the template type T.