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