]> git.saurik.com Git - wxWidgets.git/blob - src/msw/ole/oleutils.cpp
wxTempFile bug corrected: the temp file is now created in the same dir
[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 #define IN_WX_MAIN_CPP
26 #include "wx/wxprec.h"
27
28 #if defined(__BORLANDC__)
29 #pragma hdrstop
30 #endif
31
32 #include <wx/setup.h>
33
34 #if USE_DRAG_AND_DROP
35
36 #include <wx/log.h>
37
38 #include <windows.h>
39
40 // OLE
41 #include <wx/msw/ole/uuid.h>
42 #include <wx/msw/ole/oleutils.h>
43
44 #ifndef __BORLANDC__
45 #include <docobj.h>
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
63 // ----------------------------------------------------------------------------
64 // Debug support
65 // ----------------------------------------------------------------------------
66
67 #ifdef __DEBUG__
68
69 const char *GetIidName(REFIID riid)
70 {
71 // an association between symbolic name and numeric value of an IID
72 struct KNOWN_IID {
73 const IID *pIid;
74 const char *szName;
75 };
76
77 // construct the table containing all known interfaces
78 #define ADD_KNOWN_IID(name) { &IID_I##name, #name }
79
80 static const KNOWN_IID aKnownIids[] = {
81 ADD_KNOWN_IID(AdviseSink),
82 ADD_KNOWN_IID(AdviseSink2),
83 ADD_KNOWN_IID(BindCtx),
84 ADD_KNOWN_IID(ClassFactory),
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),
92 ADD_KNOWN_IID(DataAdviseHolder),
93 ADD_KNOWN_IID(DataObject),
94 ADD_KNOWN_IID(Debug),
95 ADD_KNOWN_IID(DebugStream),
96 ADD_KNOWN_IID(DfReserved1),
97 ADD_KNOWN_IID(DfReserved2),
98 ADD_KNOWN_IID(DfReserved3),
99 ADD_KNOWN_IID(Dispatch),
100 ADD_KNOWN_IID(DropSource),
101 ADD_KNOWN_IID(DropTarget),
102 ADD_KNOWN_IID(EnumCallback),
103 ADD_KNOWN_IID(EnumFORMATETC),
104 ADD_KNOWN_IID(EnumGeneric),
105 ADD_KNOWN_IID(EnumHolder),
106 ADD_KNOWN_IID(EnumMoniker),
107 ADD_KNOWN_IID(EnumOLEVERB),
108 ADD_KNOWN_IID(EnumSTATDATA),
109 ADD_KNOWN_IID(EnumSTATSTG),
110 ADD_KNOWN_IID(EnumString),
111 ADD_KNOWN_IID(EnumUnknown),
112 ADD_KNOWN_IID(EnumVARIANT),
113 ADD_KNOWN_IID(ExternalConnection),
114 ADD_KNOWN_IID(InternalMoniker),
115 ADD_KNOWN_IID(LockBytes),
116 ADD_KNOWN_IID(Malloc),
117 ADD_KNOWN_IID(Marshal),
118 ADD_KNOWN_IID(MessageFilter),
119 ADD_KNOWN_IID(Moniker),
120 ADD_KNOWN_IID(OleAdviseHolder),
121 ADD_KNOWN_IID(OleCache),
122 ADD_KNOWN_IID(OleCache2),
123 ADD_KNOWN_IID(OleCacheControl),
124 ADD_KNOWN_IID(OleClientSite),
125 ADD_KNOWN_IID(OleContainer),
126 ADD_KNOWN_IID(OleInPlaceActiveObject),
127 ADD_KNOWN_IID(OleInPlaceFrame),
128 ADD_KNOWN_IID(OleInPlaceObject),
129 ADD_KNOWN_IID(OleInPlaceSite),
130 ADD_KNOWN_IID(OleInPlaceUIWindow),
131 ADD_KNOWN_IID(OleItemContainer),
132 ADD_KNOWN_IID(OleLink),
133 ADD_KNOWN_IID(OleManager),
134 ADD_KNOWN_IID(OleObject),
135 ADD_KNOWN_IID(OlePresObj),
136 ADD_KNOWN_IID(OleWindow),
137 ADD_KNOWN_IID(PSFactory),
138 ADD_KNOWN_IID(ParseDisplayName),
139 ADD_KNOWN_IID(Persist),
140 ADD_KNOWN_IID(PersistFile),
141 ADD_KNOWN_IID(PersistStorage),
142 ADD_KNOWN_IID(PersistStream),
143 ADD_KNOWN_IID(ProxyManager),
144 ADD_KNOWN_IID(RootStorage),
145 ADD_KNOWN_IID(RpcChannel),
146 ADD_KNOWN_IID(RpcProxy),
147 ADD_KNOWN_IID(RpcStub),
148 ADD_KNOWN_IID(RunnableObject),
149 ADD_KNOWN_IID(RunningObjectTable),
150 ADD_KNOWN_IID(StdMarshalInfo),
151 ADD_KNOWN_IID(Storage),
152 ADD_KNOWN_IID(Stream),
153 ADD_KNOWN_IID(StubManager),
154 ADD_KNOWN_IID(Unknown),
155 ADD_KNOWN_IID(ViewObject),
156 ADD_KNOWN_IID(ViewObject2),
157 };
158
159 // don't clobber preprocessor name space
160 #undef ADD_KNOWN_IID
161
162 // try to find the interface in the table
163 for ( uint ui = 0; ui < WXSIZEOF(aKnownIids); ui++ ) {
164 if ( riid == *aKnownIids[ui].pIid ) {
165 return aKnownIids[ui].szName;
166 }
167 }
168
169 // unknown IID, just transform to string
170 static Uuid s_uuid;
171 s_uuid.Set(riid);
172 return s_uuid;
173 }
174
175 void wxLogQueryInterface(const char *szInterface, REFIID riid)
176 {
177 wxLogTrace("%s::QueryInterface (iid = %s)", szInterface, GetIidName(riid));
178 }
179
180 void wxLogAddRef(const char *szInterface, ULONG cRef)
181 {
182 wxLogTrace("After %s::AddRef: m_cRef = %d", szInterface, cRef + 1);
183 }
184
185 void wxLogRelease(const char *szInterface, ULONG cRef)
186 {
187 wxLogTrace("After %s::Release: m_cRef = %d", szInterface, cRef - 1);
188 }
189
190 #endif //DEBUG
191
192 #endif
193 // USE_DRAG_AND_DROP