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