]> git.saurik.com Git - wxWidgets.git/blame - src/msw/ole/oleutils.cpp
More small fixes
[wxWidgets.git] / src / msw / ole / oleutils.cpp
CommitLineData
bbf1f0e5
KB
1///////////////////////////////////////////////////////////////////////////////
2// Name: ole/oleutils.cpp
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>
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// Declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#ifdef __GNUG__
21#pragma implementation "oleutils.h"
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
bbf1f0e5
KB
25#include "wx/wxprec.h"
26
27#if defined(__BORLANDC__)
28#pragma hdrstop
29#endif
30
3096bd2f
VZ
31#include "wx/setup.h"
32#include "wx/log.h"
bbf1f0e5 33
ae090fdb
JS
34#ifndef __CYGWIN10__
35
bbf1f0e5
KB
36#include <windows.h>
37
38// OLE
3096bd2f
VZ
39#include "wx/msw/ole/uuid.h"
40#include "wx/msw/ole/oleutils.h"
bbf1f0e5 41
3f4a0c5b
VZ
42#if defined(__VISUALC__) && (__VISUALC__ > 1000)
43 #include <docobj.h>
bbf1f0e5
KB
44#endif
45
46// ============================================================================
47// Implementation
48// ============================================================================
49
50// return TRUE if the iid is in the array
51bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount)
52{
53 for ( size_t i = 0; i < nCount; i++ ) {
54 if ( riid == *aIids[i] )
55 return TRUE;
56 }
57
58 return FALSE;
59}
60
47d67540 61#if wxUSE_DRAG_AND_DROP
c740f496 62
bbf1f0e5
KB
63// ----------------------------------------------------------------------------
64// Debug support
65// ----------------------------------------------------------------------------
66
3f4a0c5b 67#if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ > 1000)
f6bcfd97 68static wxString GetIidName(REFIID riid)
bbf1f0e5
KB
69{
70 // an association between symbolic name and numeric value of an IID
71 struct KNOWN_IID {
72 const IID *pIid;
f6bcfd97 73 const wxChar *szName;
bbf1f0e5
KB
74 };
75
76 // construct the table containing all known interfaces
f6bcfd97 77 #define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) }
bbf1f0e5
KB
78
79 static const KNOWN_IID aKnownIids[] = {
80 ADD_KNOWN_IID(AdviseSink),
81 ADD_KNOWN_IID(AdviseSink2),
82 ADD_KNOWN_IID(BindCtx),
83 ADD_KNOWN_IID(ClassFactory),
27a9bd48 84#if !defined( __VISUALC__) || (__VISUALC__!=1010)
bbf1f0e5
KB
85 ADD_KNOWN_IID(ContinueCallback),
86 ADD_KNOWN_IID(EnumOleDocumentViews),
87 ADD_KNOWN_IID(OleCommandTarget),
88 ADD_KNOWN_IID(OleDocument),
89 ADD_KNOWN_IID(OleDocumentSite),
90 ADD_KNOWN_IID(OleDocumentView),
91 ADD_KNOWN_IID(Print),
27a9bd48 92#endif
bbf1f0e5
KB
93 ADD_KNOWN_IID(DataAdviseHolder),
94 ADD_KNOWN_IID(DataObject),
95 ADD_KNOWN_IID(Debug),
96 ADD_KNOWN_IID(DebugStream),
97 ADD_KNOWN_IID(DfReserved1),
98 ADD_KNOWN_IID(DfReserved2),
99 ADD_KNOWN_IID(DfReserved3),
100 ADD_KNOWN_IID(Dispatch),
101 ADD_KNOWN_IID(DropSource),
102 ADD_KNOWN_IID(DropTarget),
103 ADD_KNOWN_IID(EnumCallback),
104 ADD_KNOWN_IID(EnumFORMATETC),
105 ADD_KNOWN_IID(EnumGeneric),
106 ADD_KNOWN_IID(EnumHolder),
107 ADD_KNOWN_IID(EnumMoniker),
108 ADD_KNOWN_IID(EnumOLEVERB),
109 ADD_KNOWN_IID(EnumSTATDATA),
110 ADD_KNOWN_IID(EnumSTATSTG),
111 ADD_KNOWN_IID(EnumString),
112 ADD_KNOWN_IID(EnumUnknown),
113 ADD_KNOWN_IID(EnumVARIANT),
114 ADD_KNOWN_IID(ExternalConnection),
115 ADD_KNOWN_IID(InternalMoniker),
116 ADD_KNOWN_IID(LockBytes),
117 ADD_KNOWN_IID(Malloc),
118 ADD_KNOWN_IID(Marshal),
119 ADD_KNOWN_IID(MessageFilter),
120 ADD_KNOWN_IID(Moniker),
121 ADD_KNOWN_IID(OleAdviseHolder),
122 ADD_KNOWN_IID(OleCache),
123 ADD_KNOWN_IID(OleCache2),
124 ADD_KNOWN_IID(OleCacheControl),
125 ADD_KNOWN_IID(OleClientSite),
126 ADD_KNOWN_IID(OleContainer),
127 ADD_KNOWN_IID(OleInPlaceActiveObject),
128 ADD_KNOWN_IID(OleInPlaceFrame),
129 ADD_KNOWN_IID(OleInPlaceObject),
130 ADD_KNOWN_IID(OleInPlaceSite),
131 ADD_KNOWN_IID(OleInPlaceUIWindow),
132 ADD_KNOWN_IID(OleItemContainer),
133 ADD_KNOWN_IID(OleLink),
134 ADD_KNOWN_IID(OleManager),
135 ADD_KNOWN_IID(OleObject),
136 ADD_KNOWN_IID(OlePresObj),
137 ADD_KNOWN_IID(OleWindow),
138 ADD_KNOWN_IID(PSFactory),
139 ADD_KNOWN_IID(ParseDisplayName),
140 ADD_KNOWN_IID(Persist),
141 ADD_KNOWN_IID(PersistFile),
142 ADD_KNOWN_IID(PersistStorage),
143 ADD_KNOWN_IID(PersistStream),
144 ADD_KNOWN_IID(ProxyManager),
145 ADD_KNOWN_IID(RootStorage),
146 ADD_KNOWN_IID(RpcChannel),
147 ADD_KNOWN_IID(RpcProxy),
148 ADD_KNOWN_IID(RpcStub),
149 ADD_KNOWN_IID(RunnableObject),
150 ADD_KNOWN_IID(RunningObjectTable),
151 ADD_KNOWN_IID(StdMarshalInfo),
152 ADD_KNOWN_IID(Storage),
153 ADD_KNOWN_IID(Stream),
154 ADD_KNOWN_IID(StubManager),
155 ADD_KNOWN_IID(Unknown),
156 ADD_KNOWN_IID(ViewObject),
157 ADD_KNOWN_IID(ViewObject2),
158 };
159
160 // don't clobber preprocessor name space
161 #undef ADD_KNOWN_IID
162
163 // try to find the interface in the table
c86f1403 164 for ( size_t ui = 0; ui < WXSIZEOF(aKnownIids); ui++ ) {
bbf1f0e5
KB
165 if ( riid == *aKnownIids[ui].pIid ) {
166 return aKnownIids[ui].szName;
167 }
168 }
169
170 // unknown IID, just transform to string
f6bcfd97
BP
171 Uuid uuid(riid);
172 return wxString((const wxChar *)uuid);
bbf1f0e5
KB
173}
174
f6bcfd97 175void wxLogQueryInterface(const wxChar *szInterface, REFIID riid)
bbf1f0e5 176{
f6bcfd97
BP
177 wxLogTrace(wxT("%s::QueryInterface (iid = %s)"),
178 szInterface, GetIidName(riid).c_str());
bbf1f0e5
KB
179}
180
f6bcfd97 181void wxLogAddRef(const wxChar *szInterface, ULONG cRef)
bbf1f0e5 182{
f6bcfd97 183 wxLogTrace(wxT("After %s::AddRef: m_cRef = %d"), szInterface, cRef + 1);
bbf1f0e5
KB
184}
185
f6bcfd97 186void wxLogRelease(const wxChar *szInterface, ULONG cRef)
bbf1f0e5 187{
f6bcfd97 188 wxLogTrace(wxT("After %s::Release: m_cRef = %d"), szInterface, cRef - 1);
bbf1f0e5
KB
189}
190
aeab10d0
JS
191#elif defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ <= 1000)
192
193// For VC++ 4
194void wxLogQueryInterface(const char *szInterface, REFIID riid)
195{
196 wxLogTrace("%s::QueryInterface", szInterface);
197}
198
199void wxLogAddRef(const char *szInterface, ULONG cRef)
200{
201 wxLogTrace("After %s::AddRef: m_cRef = %d", szInterface, cRef + 1);
202}
203
204void wxLogRelease(const char *szInterface, ULONG cRef)
205{
206 wxLogTrace("After %s::Release: m_cRef = %d", szInterface, cRef - 1);
207}
208
b2aef89b 209#endif //WXDEBUG
bbf1f0e5
KB
210
211#endif
47d67540 212 // wxUSE_DRAG_AND_DROP
ae090fdb
JS
213
214#endif
215 // __CYGWIN10__
216