Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / extensions / source / activex / SODispatchInterceptor.h
blobdbb2b6a4f031e67bdc7816bcfe032b4d8da9ba71
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 // SODispatchInterceptor.h: Definition of the SODispatchInterceptor class
22 #ifndef INCLUDED_EXTENSIONS_SOURCE_ACTIVEX_SODISPATCHINTERCEPTOR_H
23 #define INCLUDED_EXTENSIONS_SOURCE_ACTIVEX_SODISPATCHINTERCEPTOR_H
25 #ifdef _MSC_VER
26 #pragma once
27 #endif
29 #include "resource.h"
30 #include <ExDispID.h>
31 #include <ExDisp.h>
32 #include <shlguid.h>
34 #include <atlctl.h>
36 #include <so_activex.h>
38 class CSOActiveX;
41 // SODispatchInterceptor
43 class SODispatchInterceptor :
44 public IDispatchImpl<ISODispatchInterceptor, &IID_ISODispatchInterceptor, &LIBID_SO_ACTIVEXLib>,
45 public ISupportErrorInfo,
46 public CComObjectRoot,
47 public CComCoClass<SODispatchInterceptor,&CLSID_SODispatchInterceptor>
49 CComPtr<IDispatch> m_xMaster;
50 CComPtr<IDispatch> m_xSlave;
51 CSOActiveX* m_xParentControl;
52 CRITICAL_SECTION mMutex;
53 public:
54 SODispatchInterceptor() : m_xParentControl( nullptr ) { InitializeCriticalSection(&mMutex); }
55 virtual ~SODispatchInterceptor() { ATLASSERT( !m_xParentControl ); DeleteCriticalSection(&mMutex); }
57 BEGIN_COM_MAP(SODispatchInterceptor)
58 COM_INTERFACE_ENTRY(IDispatch)
59 COM_INTERFACE_ENTRY(ISODispatchInterceptor)
60 COM_INTERFACE_ENTRY(ISupportErrorInfo)
61 #if defined __clang__
62 #pragma clang diagnostic push
63 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
64 #endif
65 END_COM_MAP()
66 #if defined __clang__
67 #pragma clang diagnostic pop
68 #endif
69 DECLARE_NOT_AGGREGATABLE(SODispatchInterceptor)
70 // Remove the comment from the line above if you don't want your object to
71 // support aggregation.
73 DECLARE_REGISTRY_RESOURCEID(IDR_SODISPATCHINTERCEPTOR)
75 void SetParent( CSOActiveX* pParent )
77 ATLASSERT( !m_xParentControl );
78 EnterCriticalSection( &mMutex );
79 m_xParentControl = pParent;
80 LeaveCriticalSection( &mMutex );
83 void ClearParent()
85 EnterCriticalSection( &mMutex );
86 m_xParentControl = nullptr;
87 LeaveCriticalSection( &mMutex );
90 // ISupportsErrorInfo
91 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) override;
93 // ISODispatchInterceptor
95 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getSlaveDispatchProvider(
96 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) override
98 *retVal = m_xSlave;
99 return S_OK;
102 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setSlaveDispatchProvider(
103 /* [in] */ IDispatch __RPC_FAR *xNewDispatchProvider) override
105 m_xSlave = xNewDispatchProvider;
106 return S_OK;
109 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getMasterDispatchProvider(
110 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) override
112 *retVal = m_xMaster;
113 return S_OK;
116 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setMasterDispatchProvider(
117 /* [in] */ IDispatch __RPC_FAR *xNewSupplier) override
119 m_xMaster = xNewSupplier;
120 return S_OK;
123 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatch(
124 /* [in] */ IDispatch __RPC_FAR *aURL,
125 /* [in] */ BSTR aTargetFrameName,
126 /* [in] */ long nSearchFlags,
127 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) override;
129 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatches(
130 /* [in] */ SAFEARRAY __RPC_FAR * aDescripts,
131 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *retVal) override;
133 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispatch(
134 /* [in] */ IDispatch __RPC_FAR *aURL,
135 /* [in] */ SAFEARRAY __RPC_FAR * aArgs) override;
137 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addStatusListener(
138 /* [in] */ IDispatch __RPC_FAR *xControl,
139 /* [in] */ IDispatch __RPC_FAR *aURL) override;
141 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeStatusListener(
142 /* [in] */ IDispatch __RPC_FAR *xControl,
143 /* [in] */ IDispatch __RPC_FAR *aURL) override;
145 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getInterceptedURLs(
146 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal) override;
148 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
149 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal) override
151 *pVal = SafeArrayCreateVector( VT_BSTR, 0, 4 );
153 if( !*pVal )
154 return E_FAIL;
156 long ix = 0;
157 CComBSTR aInterface( OLESTR( "com.sun.star.frame.XDispatchProviderInterceptor" ) );
158 SafeArrayPutElement( *pVal, &ix, aInterface );
160 ix = 1;
161 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatchProvider" ) );
162 SafeArrayPutElement( *pVal, &ix, aInterface );
164 ix = 2;
165 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatch" ) );
166 SafeArrayPutElement( *pVal, &ix, aInterface );
168 ix = 3;
169 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XInterceptorInfo" ) );
170 SafeArrayPutElement( *pVal, &ix, aInterface );
172 return S_OK;
176 #endif // INCLUDED_EXTENSIONS_SOURCE_ACTIVEX_SODISPATCHINTERCEPTOR_H
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */