]> git.saurik.com Git - wxWidgets.git/blame - src/msw/ole/oleutils.cpp
Fix wxGrid editors background painting.
[wxWidgets.git] / src / msw / ole / oleutils.cpp
CommitLineData
bbf1f0e5 1///////////////////////////////////////////////////////////////////////////////
521bf4ff 2// Name: src/msw/ole/oleutils.cpp
bbf1f0e5
KB
3// Purpose: implementation of OLE helper functions
4// Author: Vadim Zeitlin
3f4a0c5b 5// Modified by:
bbf1f0e5
KB
6// Created: 19.02.98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 9// Licence: wxWindows licence
bbf1f0e5
KB
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// Declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
bbf1f0e5 20// For compilers that support precompilation, includes "wx.h".
bbf1f0e5
KB
21#include "wx/wxprec.h"
22
23#if defined(__BORLANDC__)
e4db172a 24 #pragma hdrstop
bbf1f0e5
KB
25#endif
26
21709999
JS
27#if wxUSE_OLE
28
e4db172a
WS
29#ifndef WX_PRECOMP
30 #include "wx/log.h"
31#endif
32
ae090fdb
JS
33#ifndef __CYGWIN10__
34
4676948b
JS
35#include "wx/msw/private.h"
36
37#ifdef __WXWINCE__
38 #include <winreg.h>
39 #include <ole2.h>
40
41 #define GUID_DEFINED
42 #define UUID_DEFINED
43#endif
bbf1f0e5
KB
44
45// OLE
4676948b 46#ifndef __WXWINCE__
3096bd2f 47#include "wx/msw/ole/uuid.h"
4676948b
JS
48#endif
49
3096bd2f 50#include "wx/msw/ole/oleutils.h"
226fa6db 51#include "wx/msw/ole/safearray.h"
bbf1f0e5 52
3f4a0c5b
VZ
53#if defined(__VISUALC__) && (__VISUALC__ > 1000)
54 #include <docobj.h>
bbf1f0e5
KB
55#endif
56
57// ============================================================================
58// Implementation
59// ============================================================================
60
0a0e6a5b 61// return true if the iid is in the array
d0400222 62WXDLLEXPORT bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount)
bbf1f0e5
KB
63{
64 for ( size_t i = 0; i < nCount; i++ ) {
65 if ( riid == *aIids[i] )
0a0e6a5b 66 return true;
bbf1f0e5
KB
67 }
68
0a0e6a5b 69 return false;
bbf1f0e5
KB
70}
71
e2898549 72WXDLLEXPORT BSTR wxConvertStringToOle(const wxString& str)
94113cc5 73{
c45ead7b 74 return wxBasicString(str).Get();
94113cc5
JS
75}
76
e2898549 77WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr)
94113cc5 78{
795b0f14
VZ
79 // NULL BSTR is equivalent to an empty string (this is the convention used
80 // by VB and hence we must follow it)
81 if ( !bStr )
82 return wxString();
83
59af032a
VZ
84 const int len = SysStringLen(bStr);
85
94113cc5 86#if wxUSE_UNICODE
59af032a 87 wxString str(bStr, len);
94113cc5 88#else
bba85010 89 wxString str;
9968f7b4 90 if (len)
bba85010 91 {
9968f7b4
VZ
92 wxStringBufferLength buf(str, len); // asserts if len == 0
93 buf.SetLength(WideCharToMultiByte(CP_ACP, 0 /* no flags */,
94 bStr, len /* not necessarily NUL-terminated */,
95 buf, len,
96 NULL, NULL /* no default char */));
bba85010 97 }
94113cc5 98#endif
59af032a 99
94113cc5
JS
100 return str;
101}
102
103// ----------------------------------------------------------------------------
104// wxBasicString
105// ----------------------------------------------------------------------------
106
a518e508 107wxBasicString::wxBasicString(const wxString& str)
94113cc5 108{
a518e508 109 m_bstrBuf = SysAllocString(str.wc_str(*wxConvCurrent));
94113cc5
JS
110}
111
a518e508 112wxBasicString::wxBasicString(const wxBasicString& src)
94113cc5 113{
a518e508 114 m_bstrBuf = src.Get();
94113cc5
JS
115}
116
a518e508 117wxBasicString& wxBasicString::operator=(const wxBasicString& src)
94113cc5 118{
a518e508
VZ
119 SysReAllocString(&m_bstrBuf, src);
120 return *this;
94113cc5
JS
121}
122
94113cc5
JS
123wxBasicString::~wxBasicString()
124{
a518e508 125 SysFreeString(m_bstrBuf);
94113cc5
JS
126}
127
a2fd865b
VS
128
129// ----------------------------------------------------------------------------
130// Convert variants
131// ----------------------------------------------------------------------------
132
133#if wxUSE_VARIANT
134
6c32fb8f
VZ
135// ----------------------------------------------------------------------------
136// wxVariantDataCurrency
137// ----------------------------------------------------------------------------
138
139
140#if wxUSE_ANY
141
142bool wxVariantDataCurrency::GetAsAny(wxAny* any) const
143{
144 *any = m_value;
145 return true;
146}
147
148wxVariantData* wxVariantDataCurrency::VariantDataFactory(const wxAny& any)
149{
150 return new wxVariantDataCurrency(wxANY_AS(any, CURRENCY));
151}
152
153REGISTER_WXANY_CONVERSION(CURRENCY, wxVariantDataCurrency)
154
155#endif // wxUSE_ANY
156
157bool wxVariantDataCurrency::Eq(wxVariantData& data) const
158{
159 wxASSERT_MSG( (data.GetType() == wxS("currency")),
160 "wxVariantDataCurrency::Eq: argument mismatch" );
161
162 wxVariantDataCurrency& otherData = (wxVariantDataCurrency&) data;
163
164 return otherData.m_value.int64 == m_value.int64;
165}
166
167#if wxUSE_STD_IOSTREAM
168bool wxVariantDataCurrency::Write(wxSTD ostream& str) const
169{
170 wxString s;
171 Write(s);
172 str << s;
173 return true;
174}
175#endif
176
177bool wxVariantDataCurrency::Write(wxString& str) const
178{
179 BSTR bStr = NULL;
180 if ( SUCCEEDED(VarBstrFromCy(m_value, LOCALE_USER_DEFAULT, 0, &bStr)) )
181 {
182 str = wxConvertStringFromOle(bStr);
183 SysFreeString(bStr);
184 return true;
185 }
186 return false;
187}
188
189// ----------------------------------------------------------------------------
190// wxVariantDataErrorCode
191// ----------------------------------------------------------------------------
192
193#if wxUSE_ANY
194
195bool wxVariantDataErrorCode::GetAsAny(wxAny* any) const
196{
197 *any = m_value;
198 return true;
199}
200
201wxVariantData* wxVariantDataErrorCode::VariantDataFactory(const wxAny& any)
202{
203 return new wxVariantDataErrorCode(wxANY_AS(any, SCODE));
204}
205
206REGISTER_WXANY_CONVERSION(SCODE, wxVariantDataErrorCode)
207
208#endif // wxUSE_ANY
209
210bool wxVariantDataErrorCode::Eq(wxVariantData& data) const
211{
212 wxASSERT_MSG( (data.GetType() == wxS("errorcode")),
213 "wxVariantDataErrorCode::Eq: argument mismatch" );
214
215 wxVariantDataErrorCode& otherData = (wxVariantDataErrorCode&) data;
216
217 return otherData.m_value == m_value;
218}
219
220#if wxUSE_STD_IOSTREAM
221bool wxVariantDataErrorCode::Write(wxSTD ostream& str) const
222{
223 wxString s;
224 Write(s);
225 str << s;
226 return true;
227}
228#endif
229
230bool wxVariantDataErrorCode::Write(wxString& str) const
231{
232 str << m_value;
233 return true;
234}
235
236
226fa6db
VZ
237// ----------------------------------------------------------------------------
238// wxVariantDataSafeArray
239// ----------------------------------------------------------------------------
240
241#if wxUSE_ANY
242
243bool wxVariantDataSafeArray::GetAsAny(wxAny* any) const
244{
245 *any = m_value;
246 return true;
247}
248
249wxVariantData* wxVariantDataSafeArray::VariantDataFactory(const wxAny& any)
250{
251 return new wxVariantDataSafeArray(wxANY_AS(any, SAFEARRAY*));
252}
253
254REGISTER_WXANY_CONVERSION(SAFEARRAY*, wxVariantDataSafeArray)
255
256#endif // wxUSE_ANY
257
258bool wxVariantDataSafeArray::Eq(wxVariantData& data) const
259{
260 wxASSERT_MSG( (data.GetType() == wxS("safearray")),
261 "wxVariantDataSafeArray::Eq: argument mismatch" );
262
263 wxVariantDataSafeArray& otherData = (wxVariantDataSafeArray&) data;
264
265 return otherData.m_value == m_value;
266}
267
268#if wxUSE_STD_IOSTREAM
269bool wxVariantDataSafeArray::Write(wxSTD ostream& str) const
270{
271 wxString s;
272 Write(s);
273 str << s;
274 return true;
275}
276#endif
277
278bool wxVariantDataSafeArray::Write(wxString& str) const
279{
280 str.Printf(wxS("SAFEARRAY: %p"), (void*)m_value);
281 return true;
282}
6c32fb8f 283
a2fd865b
VS
284WXDLLEXPORT bool wxConvertVariantToOle(const wxVariant& variant, VARIANTARG& oleVariant)
285{
1fbfbfb0 286 VariantInit(&oleVariant);
a2fd865b
VS
287 if (variant.IsNull())
288 {
289 oleVariant.vt = VT_NULL;
290 return true;
291 }
292
293 wxString type(variant.GetType());
294
6c32fb8f
VZ
295 if (type == wxT("errorcode"))
296 {
297 wxVariantDataErrorCode* const
5bdcb1f3
VZ
298 ec = wxStaticCastVariantData(variant.GetData(),
299 wxVariantDataErrorCode);
6c32fb8f
VZ
300 oleVariant.vt = VT_ERROR;
301 oleVariant.scode = ec->GetValue();
302 }
303 else if (type == wxT("currency"))
304 {
305 wxVariantDataCurrency* const
5bdcb1f3
VZ
306 c = wxStaticCastVariantData(variant.GetData(),
307 wxVariantDataCurrency);
6c32fb8f
VZ
308 oleVariant.vt = VT_CY;
309 oleVariant.cyVal = c->GetValue();
310 }
226fa6db
VZ
311 else if (type == wxT("safearray"))
312 {
313 wxVariantDataSafeArray* const
314 vsa = wxStaticCastVariantData(variant.GetData(),
315 wxVariantDataSafeArray);
316 SAFEARRAY* psa = vsa->GetValue();
317 VARTYPE vt;
318
319 wxCHECK(psa, false);
320 HRESULT hr = SafeArrayGetVartype(psa, &vt);
321 if ( FAILED(hr) )
322 {
323 wxLogApiError(wxS("SafeArrayGetVartype()"), hr);
324 SafeArrayDestroy(psa);
325 return false;
326 }
327 oleVariant.vt = vt | VT_ARRAY;
328 oleVariant.parray = psa;
329 }
6c32fb8f 330 else if (type == wxT("long"))
a2fd865b
VS
331 {
332 oleVariant.vt = VT_I4;
333 oleVariant.lVal = variant.GetLong() ;
334 }
30ee0b97
VZ
335 // Original VC6 came with SDK too old to contain VARIANT::llVal declaration
336 // and there doesn't seem to be any way to test for it as Microsoft simply
337 // added it to the later version of oaidl.h without changing anything else.
338 // So assume it's not present for VC6, even though it might be if an
339 // updated SDK is used. In this case the user would need to disable this
340 // check himself.
341#if wxUSE_LONGLONG && !defined(__VISUALC6__)
4b666be6
VZ
342 else if (type == wxT("longlong"))
343 {
344 oleVariant.vt = VT_I8;
345 oleVariant.llVal = variant.GetLongLong().GetValue();
346 }
347#endif
a2fd865b
VS
348 else if (type == wxT("char"))
349 {
350 oleVariant.vt=VT_I1; // Signed Char
351 oleVariant.cVal=variant.GetChar();
352 }
a2fd865b
VS
353 else if (type == wxT("double"))
354 {
355 oleVariant.vt = VT_R8;
356 oleVariant.dblVal = variant.GetDouble();
357 }
358 else if (type == wxT("bool"))
359 {
360 oleVariant.vt = VT_BOOL;
85ecb1d5 361 oleVariant.boolVal = variant.GetBool() ? VARIANT_TRUE : VARIANT_FALSE;
a2fd865b
VS
362 }
363 else if (type == wxT("string"))
364 {
365 wxString str( variant.GetString() );
366 oleVariant.vt = VT_BSTR;
367 oleVariant.bstrVal = wxConvertStringToOle(str);
368 }
369#if wxUSE_DATETIME
370 else if (type == wxT("datetime"))
371 {
372 wxDateTime date( variant.GetDateTime() );
373 oleVariant.vt = VT_DATE;
374
375 SYSTEMTIME st;
376 date.GetAsMSWSysTime(&st);
377
378 SystemTimeToVariantTime(&st, &oleVariant.date);
379 }
380#endif
381 else if (type == wxT("void*"))
382 {
383 oleVariant.vt = VT_DISPATCH;
384 oleVariant.pdispVal = (IDispatch*) variant.GetVoidPtr();
385 }
f0d38b65 386 else if (type == wxT("list"))
a2fd865b 387 {
226fa6db
VZ
388 wxSafeArray<VT_VARIANT> safeArray;
389 if (!safeArray.CreateFromListVariant(variant))
a2fd865b
VS
390 return false;
391
f0d38b65 392 oleVariant.vt = VT_VARIANT | VT_ARRAY;
226fa6db 393 oleVariant.parray = safeArray.Detach();
f0d38b65
VZ
394 }
395 else if (type == wxT("arrstring"))
396 {
226fa6db 397 wxSafeArray<VT_BSTR> safeArray;
f0d38b65 398
226fa6db 399 if (!safeArray.CreateFromArrayString(variant.GetArrayString()))
82c372a7 400 return false;
f0d38b65 401
f0d38b65 402 oleVariant.vt = VT_BSTR | VT_ARRAY;
226fa6db 403 oleVariant.parray = safeArray.Detach();
a2fd865b
VS
404 }
405 else
406 {
407 oleVariant.vt = VT_NULL;
408 return false;
409 }
410 return true;
411}
412
413#ifndef VT_TYPEMASK
414#define VT_TYPEMASK 0xfff
415#endif
416
417WXDLLEXPORT bool
418wxConvertOleToVariant(const VARIANTARG& oleVariant, wxVariant& variant)
419{
420 bool ok = true;
421 if ( oleVariant.vt & VT_ARRAY )
422 {
226fa6db
VZ
423 // TODO: We currently return arrays as wxVariant of the list type
424 // containing the flattened form of array but we should allow
425 // getting it as wxVariantDataSafeArray instead. Doing this is
426 // simple, we'd just need to do something like this:
427 //
428 // if ( oleVariant.parray && SafeArrayGetDim(oleVariant.parray) > 1 )
429 // {
430 // variant.SetData(new wxVariantDataSafeArray(oleVariant.parray));
431 // }
432 //
433 // but currently we don't do it for compatibility reasons.
a2fd865b
VS
434 switch (oleVariant.vt & VT_TYPEMASK)
435 {
226fa6db
VZ
436 case VT_I2:
437 ok = wxSafeArray<VT_I2>::ConvertToVariant(oleVariant.parray, variant);
438 break;
439 case VT_I4:
440 ok = wxSafeArray<VT_I4>::ConvertToVariant(oleVariant.parray, variant);
441 break;
442 case VT_R4:
443 ok = wxSafeArray<VT_R4>::ConvertToVariant(oleVariant.parray, variant);
444 break;
445 case VT_R8:
446 ok = wxSafeArray<VT_R8>::ConvertToVariant(oleVariant.parray, variant);
447 break;
a2fd865b 448 case VT_VARIANT:
226fa6db 449 ok = wxSafeArray<VT_VARIANT>::ConvertToVariant(oleVariant.parray, variant);
a2fd865b 450 break;
a2fd865b
VS
451 case VT_BSTR:
452 {
453 wxArrayString strings;
226fa6db
VZ
454 if ( wxSafeArray<VT_BSTR>::ConvertToArrayString(oleVariant.parray, strings) )
455 variant = strings;
456 else
457 ok = false;
a2fd865b
VS
458 }
459 break;
a2fd865b 460 default:
a2fd865b
VS
461 ok = false;
462 break;
463 }
226fa6db
VZ
464 if ( !ok )
465 {
466 wxLogDebug(wxT("unhandled VT_ARRAY type %x in wxConvertOleToVariant"),
467 oleVariant.vt & VT_TYPEMASK);
468 variant = wxVariant();
469 }
a2fd865b
VS
470 }
471 else if ( oleVariant.vt & VT_BYREF )
472 {
473 switch ( oleVariant.vt & VT_TYPEMASK )
474 {
475 case VT_VARIANT:
476 {
477 VARIANTARG& oleReference = *((LPVARIANT)oleVariant.byref);
478 if (!wxConvertOleToVariant(oleReference,variant))
479 return false;
480 break;
481 }
482
483 default:
484 wxLogError(wxT("wxAutomationObject::ConvertOleToVariant: [as yet] unhandled reference %X"),
485 oleVariant.vt);
486 return false;
487 }
488 }
489 else // simply type (not array or reference)
490 {
491 switch ( oleVariant.vt & VT_TYPEMASK )
492 {
6c32fb8f
VZ
493 case VT_ERROR:
494 variant.SetData(new wxVariantDataErrorCode(oleVariant.scode));
495 break;
496
497 case VT_CY:
498 variant.SetData(new wxVariantDataCurrency(oleVariant.cyVal));
499 break;
500
a2fd865b
VS
501 case VT_BSTR:
502 {
503 wxString str(wxConvertStringFromOle(oleVariant.bstrVal));
504 variant = str;
505 }
506 break;
507
508 case VT_DATE:
509#if wxUSE_DATETIME
510 {
511 SYSTEMTIME st;
512 VariantTimeToSystemTime(oleVariant.date, &st);
513
514 wxDateTime date;
515 date.SetFromMSWSysTime(st);
516 variant = date;
517 }
518#endif // wxUSE_DATETIME
519 break;
520
30ee0b97
VZ
521 // See the comment before the __VISUALC6__ test above.
522#if wxUSE_LONGLONG && !defined(__VISUALC6__)
4b666be6
VZ
523 case VT_I8:
524 variant = wxLongLong(oleVariant.llVal);
525 break;
526#endif // wxUSE_LONGLONG
527
a2fd865b
VS
528 case VT_I4:
529 variant = (long) oleVariant.lVal;
530 break;
531
532 case VT_I2:
533 variant = (long) oleVariant.iVal;
534 break;
535
536 case VT_BOOL:
537 variant = oleVariant.boolVal != 0;
538 break;
539
51909b8b
VZ
540 case VT_R4:
541 variant = oleVariant.fltVal;
542 break;
543
a2fd865b
VS
544 case VT_R8:
545 variant = oleVariant.dblVal;
546 break;
547
548 case VT_DISPATCH:
549 variant = (void*) oleVariant.pdispVal;
550 break;
551
552 case VT_NULL:
553 variant.MakeNull();
554 break;
555
556 case VT_EMPTY:
557 break; // Ignore Empty Variant, used only during destruction of objects
558
559 default:
560 wxLogError(wxT("wxAutomationObject::ConvertOleToVariant: Unknown variant value type %X -> %X"),
561 oleVariant.vt,oleVariant.vt&VT_TYPEMASK);
562 return false;
563 }
564 }
565
566 return ok;
567}
568
569#endif // wxUSE_VARIANT
570
c740f496 571
bbf1f0e5
KB
572// ----------------------------------------------------------------------------
573// Debug support
574// ----------------------------------------------------------------------------
575
a2fd865b
VS
576#if wxUSE_DATAOBJ
577
2415cf67 578#if wxDEBUG_LEVEL && (( defined(__VISUALC__) && (__VISUALC__ > 1000) ))
f6bcfd97 579static wxString GetIidName(REFIID riid)
bbf1f0e5
KB
580{
581 // an association between symbolic name and numeric value of an IID
582 struct KNOWN_IID {
583 const IID *pIid;
f6bcfd97 584 const wxChar *szName;
bbf1f0e5
KB
585 };
586
587 // construct the table containing all known interfaces
9a83f860 588 #define ADD_KNOWN_IID(name) { &IID_I##name, wxT(#name) }
bbf1f0e5
KB
589
590 static const KNOWN_IID aKnownIids[] = {
591 ADD_KNOWN_IID(AdviseSink),
592 ADD_KNOWN_IID(AdviseSink2),
593 ADD_KNOWN_IID(BindCtx),
594 ADD_KNOWN_IID(ClassFactory),
2415cf67 595#if ( !defined( __VISUALC__) || (__VISUALC__!=1010) )
bbf1f0e5
KB
596 ADD_KNOWN_IID(ContinueCallback),
597 ADD_KNOWN_IID(EnumOleDocumentViews),
598 ADD_KNOWN_IID(OleCommandTarget),
599 ADD_KNOWN_IID(OleDocument),
600 ADD_KNOWN_IID(OleDocumentSite),
601 ADD_KNOWN_IID(OleDocumentView),
602 ADD_KNOWN_IID(Print),
27a9bd48 603#endif
bbf1f0e5
KB
604 ADD_KNOWN_IID(DataAdviseHolder),
605 ADD_KNOWN_IID(DataObject),
606 ADD_KNOWN_IID(Debug),
607 ADD_KNOWN_IID(DebugStream),
608 ADD_KNOWN_IID(DfReserved1),
609 ADD_KNOWN_IID(DfReserved2),
610 ADD_KNOWN_IID(DfReserved3),
611 ADD_KNOWN_IID(Dispatch),
612 ADD_KNOWN_IID(DropSource),
613 ADD_KNOWN_IID(DropTarget),
614 ADD_KNOWN_IID(EnumCallback),
615 ADD_KNOWN_IID(EnumFORMATETC),
616 ADD_KNOWN_IID(EnumGeneric),
617 ADD_KNOWN_IID(EnumHolder),
618 ADD_KNOWN_IID(EnumMoniker),
619 ADD_KNOWN_IID(EnumOLEVERB),
620 ADD_KNOWN_IID(EnumSTATDATA),
621 ADD_KNOWN_IID(EnumSTATSTG),
622 ADD_KNOWN_IID(EnumString),
623 ADD_KNOWN_IID(EnumUnknown),
624 ADD_KNOWN_IID(EnumVARIANT),
625 ADD_KNOWN_IID(ExternalConnection),
626 ADD_KNOWN_IID(InternalMoniker),
627 ADD_KNOWN_IID(LockBytes),
628 ADD_KNOWN_IID(Malloc),
629 ADD_KNOWN_IID(Marshal),
630 ADD_KNOWN_IID(MessageFilter),
631 ADD_KNOWN_IID(Moniker),
632 ADD_KNOWN_IID(OleAdviseHolder),
633 ADD_KNOWN_IID(OleCache),
634 ADD_KNOWN_IID(OleCache2),
635 ADD_KNOWN_IID(OleCacheControl),
636 ADD_KNOWN_IID(OleClientSite),
637 ADD_KNOWN_IID(OleContainer),
638 ADD_KNOWN_IID(OleInPlaceActiveObject),
639 ADD_KNOWN_IID(OleInPlaceFrame),
640 ADD_KNOWN_IID(OleInPlaceObject),
641 ADD_KNOWN_IID(OleInPlaceSite),
642 ADD_KNOWN_IID(OleInPlaceUIWindow),
643 ADD_KNOWN_IID(OleItemContainer),
644 ADD_KNOWN_IID(OleLink),
645 ADD_KNOWN_IID(OleManager),
646 ADD_KNOWN_IID(OleObject),
647 ADD_KNOWN_IID(OlePresObj),
648 ADD_KNOWN_IID(OleWindow),
649 ADD_KNOWN_IID(PSFactory),
650 ADD_KNOWN_IID(ParseDisplayName),
651 ADD_KNOWN_IID(Persist),
652 ADD_KNOWN_IID(PersistFile),
653 ADD_KNOWN_IID(PersistStorage),
654 ADD_KNOWN_IID(PersistStream),
655 ADD_KNOWN_IID(ProxyManager),
656 ADD_KNOWN_IID(RootStorage),
657 ADD_KNOWN_IID(RpcChannel),
658 ADD_KNOWN_IID(RpcProxy),
659 ADD_KNOWN_IID(RpcStub),
660 ADD_KNOWN_IID(RunnableObject),
661 ADD_KNOWN_IID(RunningObjectTable),
662 ADD_KNOWN_IID(StdMarshalInfo),
663 ADD_KNOWN_IID(Storage),
664 ADD_KNOWN_IID(Stream),
665 ADD_KNOWN_IID(StubManager),
666 ADD_KNOWN_IID(Unknown),
667 ADD_KNOWN_IID(ViewObject),
668 ADD_KNOWN_IID(ViewObject2),
669 };
670
671 // don't clobber preprocessor name space
672 #undef ADD_KNOWN_IID
673
674 // try to find the interface in the table
c86f1403 675 for ( size_t ui = 0; ui < WXSIZEOF(aKnownIids); ui++ ) {
bbf1f0e5
KB
676 if ( riid == *aKnownIids[ui].pIid ) {
677 return aKnownIids[ui].szName;
678 }
679 }
680
4676948b 681#ifndef __WXWINCE__
bbf1f0e5 682 // unknown IID, just transform to string
f6bcfd97
BP
683 Uuid uuid(riid);
684 return wxString((const wxChar *)uuid);
4676948b
JS
685#else
686 return wxEmptyString;
687#endif
bbf1f0e5
KB
688}
689
d0400222 690WXDLLEXPORT void wxLogQueryInterface(const wxChar *szInterface, REFIID riid)
bbf1f0e5 691{
ba14d986 692 wxLogTrace(wxTRACE_OleCalls, wxT("%s::QueryInterface (iid = %s)"),
f6bcfd97 693 szInterface, GetIidName(riid).c_str());
bbf1f0e5
KB
694}
695
d0400222 696WXDLLEXPORT void wxLogAddRef(const wxChar *szInterface, ULONG cRef)
bbf1f0e5 697{
ba14d986 698 wxLogTrace(wxTRACE_OleCalls, wxT("After %s::AddRef: m_cRef = %d"), szInterface, cRef + 1);
bbf1f0e5
KB
699}
700
d0400222 701WXDLLEXPORT void wxLogRelease(const wxChar *szInterface, ULONG cRef)
bbf1f0e5 702{
ba14d986 703 wxLogTrace(wxTRACE_OleCalls, wxT("After %s::Release: m_cRef = %d"), szInterface, cRef - 1);
bbf1f0e5
KB
704}
705
4b6a582b 706#endif // wxDEBUG_LEVEL
aeab10d0 707
a2fd865b 708#endif // wxUSE_DATAOBJ
aeab10d0 709
4b6a582b 710#endif // __CYGWIN10__
aeab10d0 711
4b6a582b 712#endif // wxUSE_OLE