Use OLE helper macros in wxWebView to reduce the amount of duplicated code.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70096 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
#include "wx/webview.h"
|
#include "wx/webview.h"
|
||||||
#include "wx/msw/ole/automtn.h"
|
#include "wx/msw/ole/automtn.h"
|
||||||
#include "wx/msw/ole/activex.h"
|
#include "wx/msw/ole/activex.h"
|
||||||
|
#include "wx/msw/ole/oleutils.h"
|
||||||
#include "wx/msw/wrapwin.h"
|
#include "wx/msw/wrapwin.h"
|
||||||
#include "wx/msw/missing.h"
|
#include "wx/msw/missing.h"
|
||||||
#include "wx/sharedptr.h"
|
#include "wx/sharedptr.h"
|
||||||
@@ -295,7 +296,6 @@ private:
|
|||||||
class VirtualProtocol : public wxIInternetProtocol
|
class VirtualProtocol : public wxIInternetProtocol
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
ULONG m_refCount;
|
|
||||||
wxIInternetProtocolSink* m_protocolSink;
|
wxIInternetProtocolSink* m_protocolSink;
|
||||||
wxString m_html;
|
wxString m_html;
|
||||||
VOID * fileP;
|
VOID * fileP;
|
||||||
@@ -305,12 +305,10 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
|
VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler);
|
||||||
~VirtualProtocol();
|
~VirtualProtocol() {};
|
||||||
|
|
||||||
//IUnknown
|
//IUnknown
|
||||||
ULONG STDMETHODCALLTYPE AddRef();
|
DECLARE_IUNKNOWN_METHODS;
|
||||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
|
|
||||||
ULONG STDMETHODCALLTYPE Release();
|
|
||||||
|
|
||||||
//IInternetProtocolRoot
|
//IInternetProtocolRoot
|
||||||
HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
|
HRESULT STDMETHODCALLTYPE Abort(HRESULT WXUNUSED(hrReason),
|
||||||
@@ -341,18 +339,17 @@ public:
|
|||||||
class ClassFactory : public IClassFactory
|
class ClassFactory : public IClassFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_refCount(0), m_handler(handler) {}
|
ClassFactory(wxSharedPtr<wxWebViewHandler> handler) : m_handler(handler) {}
|
||||||
//IUnknown
|
|
||||||
ULONG STDMETHODCALLTYPE AddRef();
|
|
||||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject);
|
|
||||||
ULONG STDMETHODCALLTYPE Release();
|
|
||||||
|
|
||||||
//IClassFactory
|
//IClassFactory
|
||||||
HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
|
HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter,
|
||||||
REFIID riid, void** ppvObject);
|
REFIID riid, void** ppvObject);
|
||||||
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
|
HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
|
||||||
|
|
||||||
|
//IUnknown
|
||||||
|
DECLARE_IUNKNOWN_METHODS;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ULONG m_refCount;
|
|
||||||
wxSharedPtr<wxWebViewHandler> m_handler;
|
wxSharedPtr<wxWebViewHandler> m_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1051,50 +1051,17 @@ void wxWebViewIE::onActiveXEvent(wxActiveXEvent& evt)
|
|||||||
|
|
||||||
VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler)
|
VirtualProtocol::VirtualProtocol(wxSharedPtr<wxWebViewHandler> handler)
|
||||||
{
|
{
|
||||||
m_refCount = 0;
|
|
||||||
m_file = NULL;
|
m_file = NULL;
|
||||||
m_handler = handler;
|
m_handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualProtocol::~VirtualProtocol()
|
BEGIN_IID_TABLE(VirtualProtocol)
|
||||||
{
|
ADD_IID(Unknown)
|
||||||
}
|
ADD_RAW_IID(wxIID_IInternetProtocolRoot)
|
||||||
|
ADD_RAW_IID(wxIID_IInternetProtocol)
|
||||||
|
END_IID_TABLE;
|
||||||
|
|
||||||
ULONG VirtualProtocol::AddRef()
|
IMPLEMENT_IUNKNOWN_METHODS(VirtualProtocol)
|
||||||
{
|
|
||||||
m_refCount++;
|
|
||||||
return m_refCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT VirtualProtocol::QueryInterface(REFIID riid, void **ppvObject)
|
|
||||||
{
|
|
||||||
if(riid == IID_IUnknown || riid == wxIID_IInternetProtocolRoot ||
|
|
||||||
riid == wxIID_IInternetProtocol)
|
|
||||||
{
|
|
||||||
*ppvObject = (wxIInternetProtocol*)this;
|
|
||||||
AddRef();
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*ppvObject = NULL;
|
|
||||||
return E_POINTER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG VirtualProtocol::Release()
|
|
||||||
{
|
|
||||||
m_refCount--;
|
|
||||||
if (m_refCount > 0)
|
|
||||||
{
|
|
||||||
return m_refCount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT VirtualProtocol::Start(LPCWSTR szUrl, wxIInternetProtocolSink *pOIProtSink,
|
HRESULT VirtualProtocol::Start(LPCWSTR szUrl, wxIInternetProtocolSink *pOIProtSink,
|
||||||
wxIInternetBindInfo *pOIBindInfo, DWORD grfPI,
|
wxIInternetBindInfo *pOIBindInfo, DWORD grfPI,
|
||||||
@@ -1162,6 +1129,13 @@ HRESULT VirtualProtocol::Read(void *pv, ULONG cb, ULONG *pcbRead)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BEGIN_IID_TABLE(ClassFactory)
|
||||||
|
ADD_IID(Unknown)
|
||||||
|
ADD_IID(ClassFactory)
|
||||||
|
END_IID_TABLE;
|
||||||
|
|
||||||
|
IMPLEMENT_IUNKNOWN_METHODS(ClassFactory)
|
||||||
|
|
||||||
HRESULT ClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid,
|
HRESULT ClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid,
|
||||||
void ** ppvObject)
|
void ** ppvObject)
|
||||||
{
|
{
|
||||||
@@ -1181,41 +1155,4 @@ STDMETHODIMP ClassFactory::LockServer(BOOL fLock)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG ClassFactory::AddRef(void)
|
|
||||||
{
|
|
||||||
m_refCount++;
|
|
||||||
return m_refCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT ClassFactory::QueryInterface(REFIID riid, void **ppvObject)
|
|
||||||
{
|
|
||||||
if ((riid == IID_IUnknown) || (riid == IID_IClassFactory))
|
|
||||||
{
|
|
||||||
*ppvObject = this;
|
|
||||||
AddRef();
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*ppvObject = NULL;
|
|
||||||
return E_POINTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG ClassFactory::Release(void)
|
|
||||||
{
|
|
||||||
m_refCount--;
|
|
||||||
if (m_refCount > 0)
|
|
||||||
{
|
|
||||||
return m_refCount;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
delete this;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE
|
#endif // wxUSE_WEBVIEW && wxUSE_WEBVIEW_IE
|
||||||
|
Reference in New Issue
Block a user