// ============================================================================
// return true if the iid is in the array
-bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount)
+WXDLLEXPORT bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount)
{
for ( size_t i = 0; i < nCount; i++ ) {
if ( riid == *aIids[i] )
#if wxUSE_VARIANT
-/*
- * wxClearVariant
- *
- * Zeros a variant structure without regard to current contents
- */
-void wxClearVariant(VARIANTARG *pvarg)
-{
- pvarg->vt = VT_EMPTY;
- pvarg->wReserved1 = 0;
- pvarg->wReserved2 = 0;
- pvarg->wReserved3 = 0;
- pvarg->lVal = 0;
-}
-
-/*
- * wxReleaseVariant
- *
- * Clears a particular variant structure and releases any external objects
- * or memory contained in the variant. Supports the data types listed above.
- */
-void wxReleaseVariant(VARIANTARG *pvarg)
-{
- VARTYPE vt;
- VARIANTARG _huge *pvargArray;
- LONG lLBound, lUBound, l;
-
- vt = (VARTYPE)(pvarg->vt & 0xfff); // mask off flags
-
- // check if an array. If so, free its contents, then the array itself.
- if (V_ISARRAY(pvarg))
- {
- // variant arrays are all this routine currently knows about. Since a
- // variant can contain anything (even other arrays), call ourselves
- // recursively.
- if (vt == VT_VARIANT)
- {
- SafeArrayGetLBound(pvarg->parray, 1, &lLBound);
- SafeArrayGetUBound(pvarg->parray, 1, &lUBound);
-
- if (lUBound > lLBound)
- {
- lUBound -= lLBound;
-
- SafeArrayAccessData(pvarg->parray, (void**)&pvargArray);
-
- for (l = 0; l < lUBound; l++)
- {
- wxReleaseVariant(pvargArray);
- pvargArray++;
- }
-
- SafeArrayUnaccessData(pvarg->parray);
- }
- }
- else
- {
- wxLogWarning(wxT("wxReleaseVariant: Array contains non-variant type"));
- }
-
- // Free the array itself.
- SafeArrayDestroy(pvarg->parray);
- }
- else
- {
- switch (vt)
- {
- case VT_DISPATCH:
- if (pvarg->pdispVal)
- pvarg->pdispVal->Release();
- break;
-
- case VT_BSTR:
- SysFreeString(pvarg->bstrVal);
- break;
-
- case VT_I2:
- case VT_I4:
- case VT_BOOL:
- case VT_R8:
- case VT_ERROR: // to avoid erroring on an error return from Excel
- case VT_EMPTY:
- case VT_DATE:
- // no work for these types
- break;
-
- default:
- wxLogWarning(wxT("wxReleaseVariant: Unknown type"));
- break;
- }
- }
-
- wxClearVariant(pvarg);
-}
-
WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
{
- wxClearVariant(&oleVariant);
+ VariantInit(&oleVariant);
if (variant.IsNull())
{
oleVariant.vt = VT_NULL;
oleVariant.vt = VT_I4;
oleVariant.lVal = variant.GetLong() ;
}
- // cVal not always present
-#ifndef __GNUWIN32__
+ // Original VC6 came with SDK too old to contain VARIANT::llVal declaration
+ // and there doesn't seem to be any way to test for it as Microsoft simply
+ // added it to the later version of oaidl.h without changing anything else.
+ // So assume it's not present for VC6, even though it might be if an
+ // updated SDK is used. In this case the user would need to disable this
+ // check himself.
+#if wxUSE_LONGLONG && !defined(__VISUALC6__)
+ else if (type == wxT("longlong"))
+ {
+ oleVariant.vt = VT_I8;
+ oleVariant.llVal = variant.GetLongLong().GetValue();
+ }
+#endif
else if (type == wxT("char"))
{
oleVariant.vt=VT_I1; // Signed Char
oleVariant.cVal=variant.GetChar();
}
-#endif
else if (type == wxT("double"))
{
oleVariant.vt = VT_R8;
else if (type == wxT("bool"))
{
oleVariant.vt = VT_BOOL;
- // 'bool' required for VC++ 4 apparently
-#if (defined(__VISUALC__) && (__VISUALC__ <= 1000))
- oleVariant.bool = variant.GetBool();
-#else
- oleVariant.boolVal = variant.GetBool();
-#endif
+ oleVariant.boolVal = variant.GetBool() ? VARIANT_TRUE : VARIANT_FALSE;
}
else if (type == wxT("string"))
{
#endif // wxUSE_DATETIME
break;
+ // See the comment before the __VISUALC6__ test above.
+#if wxUSE_LONGLONG && !defined(__VISUALC6__)
+ case VT_I8:
+ variant = wxLongLong(oleVariant.llVal);
+ break;
+#endif // wxUSE_LONGLONG
+
case VT_I4:
variant = (long) oleVariant.lVal;
break;
variant = oleVariant.boolVal != 0;
break;
+ case VT_R4:
+ variant = oleVariant.fltVal;
+ break;
+
case VT_R8:
variant = oleVariant.dblVal;
break;
#if wxUSE_DATAOBJ
-#if wxDEBUG_LEVEL && ( ( defined(__VISUALC__) && (__VISUALC__ > 1000) ) || defined(__MWERKS__) )
+#if wxDEBUG_LEVEL && (( defined(__VISUALC__) && (__VISUALC__ > 1000) ))
static wxString GetIidName(REFIID riid)
{
// an association between symbolic name and numeric value of an IID
ADD_KNOWN_IID(AdviseSink2),
ADD_KNOWN_IID(BindCtx),
ADD_KNOWN_IID(ClassFactory),
-#if ( !defined( __VISUALC__) || (__VISUALC__!=1010) ) && !defined(__MWERKS__)
+#if ( !defined( __VISUALC__) || (__VISUALC__!=1010) )
ADD_KNOWN_IID(ContinueCallback),
ADD_KNOWN_IID(EnumOleDocumentViews),
ADD_KNOWN_IID(OleCommandTarget),
#endif
}
-void wxLogQueryInterface(const wxChar *szInterface, REFIID riid)
+WXDLLEXPORT void wxLogQueryInterface(const wxChar *szInterface, REFIID riid)
{
wxLogTrace(wxTRACE_OleCalls, wxT("%s::QueryInterface (iid = %s)"),
szInterface, GetIidName(riid).c_str());
}
-void wxLogAddRef(const wxChar *szInterface, ULONG cRef)
+WXDLLEXPORT void wxLogAddRef(const wxChar *szInterface, ULONG cRef)
{
wxLogTrace(wxTRACE_OleCalls, wxT("After %s::AddRef: m_cRef = %d"), szInterface, cRef + 1);
}
-void wxLogRelease(const wxChar *szInterface, ULONG cRef)
+WXDLLEXPORT void wxLogRelease(const wxChar *szInterface, ULONG cRef)
{
wxLogTrace(wxTRACE_OleCalls, wxT("After %s::Release: m_cRef = %d"), szInterface, cRef - 1);
}