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