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