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