]> git.saurik.com Git - wxWidgets.git/blob - src/msw/ole/oleutils.cpp
Added clipboard cut and paste
[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 #if wxUSE_OLE
35
36 #ifndef __CYGWIN10__
37
38 #include <windows.h>
39
40 // OLE
41 #include "wx/msw/ole/uuid.h"
42 #include "wx/msw/ole/oleutils.h"
43
44 #if defined(__VISUALC__) && (__VISUALC__ > 1000)
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 #if wxUSE_DRAG_AND_DROP
64
65 // ----------------------------------------------------------------------------
66 // Debug support
67 // ----------------------------------------------------------------------------
68
69 #if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ > 1000)
70 static wxString GetIidName(REFIID riid)
71 {
72 // an association between symbolic name and numeric value of an IID
73 struct KNOWN_IID {
74 const IID *pIid;
75 const wxChar *szName;
76 };
77
78 // construct the table containing all known interfaces
79 #define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) }
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),
86 #if !defined( __VISUALC__) || (__VISUALC__!=1010)
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),
94 #endif
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
166 for ( size_t ui = 0; ui < WXSIZEOF(aKnownIids); ui++ ) {
167 if ( riid == *aKnownIids[ui].pIid ) {
168 return aKnownIids[ui].szName;
169 }
170 }
171
172 // unknown IID, just transform to string
173 Uuid uuid(riid);
174 return wxString((const wxChar *)uuid);
175 }
176
177 void wxLogQueryInterface(const wxChar *szInterface, REFIID riid)
178 {
179 wxLogTrace(wxT("%s::QueryInterface (iid = %s)"),
180 szInterface, GetIidName(riid).c_str());
181 }
182
183 void wxLogAddRef(const wxChar *szInterface, ULONG cRef)
184 {
185 wxLogTrace(wxT("After %s::AddRef: m_cRef = %d"), szInterface, cRef + 1);
186 }
187
188 void wxLogRelease(const wxChar *szInterface, ULONG cRef)
189 {
190 wxLogTrace(wxT("After %s::Release: m_cRef = %d"), szInterface, cRef - 1);
191 }
192
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
211 #endif //WXDEBUG
212
213 #endif
214 // wxUSE_DRAG_AND_DROP
215
216 #endif
217 // __CYGWIN10__
218
219 #endif
220 // wxUSE_OLE
221