]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/ole/oleutils.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ole/oleutils.cpp
3 // Purpose: implementation of OLE helper functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "oleutils.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
27 #if defined(__BORLANDC__)
41 #include "wx/msw/ole/uuid.h"
42 #include "wx/msw/ole/oleutils.h"
44 #if defined(__VISUALC__) && (__VISUALC__ > 1000)
48 // ============================================================================
50 // ============================================================================
52 // return TRUE if the iid is in the array
53 bool IsIidFromList(REFIID riid
, const IID
*aIids
[], size_t nCount
)
55 for ( size_t i
= 0; i
< nCount
; i
++ ) {
56 if ( riid
== *aIids
[i
] )
63 #if wxUSE_DRAG_AND_DROP
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 #if defined(__WXDEBUG__) && ( ( defined(__VISUALC__) && (__VISUALC__ > 1000) ) || defined(__MWERKS__) )
70 static wxString
GetIidName(REFIID riid
)
72 // an association between symbolic name and numeric value of an IID
78 // construct the table containing all known interfaces
79 #define ADD_KNOWN_IID(name) { &IID_I##name, _T(#name) }
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) ) && !defined(__MWERKS__)
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
),
95 ADD_KNOWN_IID(DataAdviseHolder
),
96 ADD_KNOWN_IID(DataObject
),
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
),
162 // don't clobber preprocessor name space
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
;
172 // unknown IID, just transform to string
174 return wxString((const wxChar
*)uuid
);
177 void wxLogQueryInterface(const wxChar
*szInterface
, REFIID riid
)
179 wxLogTrace(wxTRACE_OleCalls
, wxT("%s::QueryInterface (iid = %s)"),
180 szInterface
, GetIidName(riid
).c_str());
183 void wxLogAddRef(const wxChar
*szInterface
, ULONG cRef
)
185 wxLogTrace(wxTRACE_OleCalls
, wxT("After %s::AddRef: m_cRef = %d"), szInterface
, cRef
+ 1);
188 void wxLogRelease(const wxChar
*szInterface
, ULONG cRef
)
190 wxLogTrace(wxTRACE_OleCalls
, wxT("After %s::Release: m_cRef = %d"), szInterface
, cRef
- 1);
193 #elif defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ <= 1000)
196 void wxLogQueryInterface(const char *szInterface
, REFIID riid
)
198 wxLogTrace("%s::QueryInterface", szInterface
);
201 void wxLogAddRef(const char *szInterface
, ULONG cRef
)
203 wxLogTrace("After %s::AddRef: m_cRef = %d", szInterface
, cRef
+ 1);
206 void wxLogRelease(const char *szInterface
, ULONG cRef
)
208 wxLogTrace("After %s::Release: m_cRef = %d", szInterface
, cRef
- 1);
214 // wxUSE_DRAG_AND_DROP