merge the formfield patch from ooo-build
[ooovba.git] / extensions / source / activex / main / SODispatchInterceptor.h
blob956b252cb2a695897f3eda7eb035af871a6df899
1 // SODispatchInterceptor.h: Definition of the SODispatchInterceptor class
2 //
3 //////////////////////////////////////////////////////////////////////
5 #if !defined __SODISPATCHINTERCEPTOR_H_
6 #define __SODISPATCHINTERCEPTOR_H_
8 #if _MSC_VER > 1000
9 #pragma once
10 #endif // _MSC_VER > 1000
12 #include "resource.h" // main symbols
13 #include <ExDispID.h>
14 #include <ExDisp.h>
15 #include <shlguid.h>
17 #if defined(_MSC_VER) && (_MSC_VER >= 1300)
18 #undef _DEBUG
19 #endif
20 #include <atlctl.h>
22 #include "so_activex.h"
24 class CSOActiveX;
26 /////////////////////////////////////////////////////////////////////////////
27 // SODispatchInterceptor
29 class SODispatchInterceptor :
30 public IDispatchImpl<ISODispatchInterceptor, &IID_ISODispatchInterceptor, &LIBID_SO_ACTIVEXLib>,
31 public ISupportErrorInfo,
32 public CComObjectRoot,
33 public CComCoClass<SODispatchInterceptor,&CLSID_SODispatchInterceptor>
35 CComPtr<IDispatch> m_xMaster;
36 CComPtr<IDispatch> m_xSlave;
37 CSOActiveX* m_xParentControl;
38 CRITICAL_SECTION mMutex;
39 public:
40 SODispatchInterceptor() : m_xParentControl( NULL ) { InitializeCriticalSection(&mMutex); }
41 virtual ~SODispatchInterceptor() { ATLASSERT( !m_xParentControl ); DeleteCriticalSection(&mMutex); }
43 BEGIN_COM_MAP(SODispatchInterceptor)
44 COM_INTERFACE_ENTRY(IDispatch)
45 COM_INTERFACE_ENTRY(ISODispatchInterceptor)
46 COM_INTERFACE_ENTRY(ISupportErrorInfo)
47 END_COM_MAP()
48 DECLARE_NOT_AGGREGATABLE(SODispatchInterceptor)
49 // Remove the comment from the line above if you don't want your object to
50 // support aggregation.
52 DECLARE_REGISTRY_RESOURCEID(IDR_SODISPATCHINTERCEPTOR)
54 void SetParent( CSOActiveX* pParent )
56 ATLASSERT( !m_xParentControl );
57 EnterCriticalSection( &mMutex );
58 m_xParentControl = pParent;
59 LeaveCriticalSection( &mMutex );
62 void ClearParent()
64 EnterCriticalSection( &mMutex );
65 m_xParentControl = NULL;
66 LeaveCriticalSection( &mMutex );
69 // ISupportsErrorInfo
70 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
72 // ISODispatchInterceptor
74 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getSlaveDispatchProvider(
75 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
77 *retVal = m_xSlave;
78 return S_OK;
81 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setSlaveDispatchProvider(
82 /* [in] */ IDispatch __RPC_FAR *xNewDispatchProvider)
84 m_xSlave = xNewDispatchProvider;
85 return S_OK;
88 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getMasterDispatchProvider(
89 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
91 *retVal = m_xMaster;
92 return S_OK;
95 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setMasterDispatchProvider(
96 /* [in] */ IDispatch __RPC_FAR *xNewSupplier)
98 m_xMaster = xNewSupplier;
99 return S_OK;
102 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatch(
103 /* [in] */ IDispatch __RPC_FAR *aURL,
104 /* [in] */ BSTR aTargetFrameName,
105 /* [in] */ long nSearchFlags,
106 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal);
108 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatches(
109 /* [in] */ SAFEARRAY __RPC_FAR * aDescripts,
110 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *retVal);
112 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispatch(
113 /* [in] */ IDispatch __RPC_FAR *aURL,
114 /* [in] */ SAFEARRAY __RPC_FAR * aArgs);
116 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addStatusListener(
117 /* [in] */ IDispatch __RPC_FAR *xControl,
118 /* [in] */ IDispatch __RPC_FAR *aURL);
120 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeStatusListener(
121 /* [in] */ IDispatch __RPC_FAR *xControl,
122 /* [in] */ IDispatch __RPC_FAR *aURL);
124 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getInterceptedURLs(
125 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal);
127 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
128 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
130 *pVal = SafeArrayCreateVector( VT_BSTR, 0, 4 );
132 if( !*pVal )
133 return E_FAIL;
135 long ix = 0;
136 CComBSTR aInterface( OLESTR( "com.sun.star.frame.XDispatchProviderInterceptor" ) );
137 SafeArrayPutElement( *pVal, &ix, aInterface );
139 ix = 1;
140 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatchProvider" ) );
141 SafeArrayPutElement( *pVal, &ix, aInterface );
143 ix = 2;
144 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatch" ) );
145 SafeArrayPutElement( *pVal, &ix, aInterface );
147 ix = 3;
148 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XInterceptorInfo" ) );
149 SafeArrayPutElement( *pVal, &ix, aInterface );
151 return S_OK;
155 #endif // __SODISPATCHINTERCEPTOR_H_