tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / extensions / source / activex / SODispatchInterceptor.h
blob3c060434820b1e5ca59cf2e46db7cf87ec8f0be4
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 #pragma once
24 #ifdef _MSC_VER
25 #pragma once
26 #endif
28 #include "resource.h"
29 #include <ExDispID.h>
30 #include <ExDisp.h>
31 #include <shlguid.h>
33 #include <atlctl.h>
35 #include <so_activex.h>
37 class CSOActiveX;
40 // SODispatchInterceptor
42 class SODispatchInterceptor :
43 public IDispatchImpl<ISODispatchInterceptor, &IID_ISODispatchInterceptor, &LIBID_SO_ACTIVEXLib>,
44 public ISupportErrorInfo,
45 public CComObjectRoot,
46 public CComCoClass<SODispatchInterceptor,&CLSID_SODispatchInterceptor>
48 CComPtr<IDispatch> m_xMaster;
49 CComPtr<IDispatch> m_xSlave;
50 CSOActiveX* m_xParentControl;
51 CRITICAL_SECTION mMutex;
52 public:
53 SODispatchInterceptor() : m_xParentControl( nullptr ) { InitializeCriticalSection(&mMutex); }
54 virtual ~SODispatchInterceptor() { ATLASSERT( !m_xParentControl ); DeleteCriticalSection(&mMutex); }
56 BEGIN_COM_MAP(SODispatchInterceptor)
57 COM_INTERFACE_ENTRY(IDispatch)
58 COM_INTERFACE_ENTRY(ISODispatchInterceptor)
59 COM_INTERFACE_ENTRY(ISupportErrorInfo)
60 #if defined __clang__
61 #pragma clang diagnostic push
62 #pragma clang diagnostic ignored "-Winconsistent-missing-override"
63 #endif
64 END_COM_MAP()
65 #if defined __clang__
66 #pragma clang diagnostic pop
67 #endif
68 DECLARE_NOT_AGGREGATABLE(SODispatchInterceptor)
69 // Remove the comment from the line above if you don't want your object to
70 // support aggregation.
72 DECLARE_REGISTRY_RESOURCEID(IDR_SODISPATCHINTERCEPTOR)
74 void SetParent( CSOActiveX* pParent )
76 ATLASSERT( !m_xParentControl );
77 EnterCriticalSection( &mMutex );
78 m_xParentControl = pParent;
79 LeaveCriticalSection( &mMutex );
82 void ClearParent()
84 EnterCriticalSection( &mMutex );
85 m_xParentControl = nullptr;
86 LeaveCriticalSection( &mMutex );
89 // ISupportsErrorInfo
90 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) override;
92 // ISODispatchInterceptor
94 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getSlaveDispatchProvider(
95 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) override
97 *retVal = m_xSlave;
98 return S_OK;
101 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setSlaveDispatchProvider(
102 /* [in] */ IDispatch __RPC_FAR *xNewDispatchProvider) override
104 m_xSlave = xNewDispatchProvider;
105 return S_OK;
108 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getMasterDispatchProvider(
109 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) override
111 *retVal = m_xMaster;
112 return S_OK;
115 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setMasterDispatchProvider(
116 /* [in] */ IDispatch __RPC_FAR *xNewSupplier) override
118 m_xMaster = xNewSupplier;
119 return S_OK;
122 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatch(
123 /* [in] */ IDispatch __RPC_FAR *aURL,
124 /* [in] */ BSTR aTargetFrameName,
125 /* [in] */ long nSearchFlags,
126 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) override;
128 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatches(
129 /* [in] */ SAFEARRAY __RPC_FAR * aDescripts,
130 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *retVal) override;
132 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispatch(
133 /* [in] */ IDispatch __RPC_FAR *aURL,
134 /* [in] */ SAFEARRAY __RPC_FAR * aArgs) override;
136 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addStatusListener(
137 /* [in] */ IDispatch __RPC_FAR *xControl,
138 /* [in] */ IDispatch __RPC_FAR *aURL) override;
140 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeStatusListener(
141 /* [in] */ IDispatch __RPC_FAR *xControl,
142 /* [in] */ IDispatch __RPC_FAR *aURL) override;
144 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getInterceptedURLs(
145 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal) override;
147 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
148 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal) override
150 *pVal = SafeArrayCreateVector( VT_BSTR, 0, 4 );
152 if( !*pVal )
153 return E_FAIL;
155 LONG ix = 0;
156 CComBSTR aInterface( OLESTR( "com.sun.star.frame.XDispatchProviderInterceptor" ) );
157 SafeArrayPutElement( *pVal, &ix, aInterface );
159 ix = 1;
160 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatchProvider" ) );
161 SafeArrayPutElement( *pVal, &ix, aInterface );
163 ix = 2;
164 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatch" ) );
165 SafeArrayPutElement( *pVal, &ix, aInterface );
167 ix = 3;
168 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XInterceptorInfo" ) );
169 SafeArrayPutElement( *pVal, &ix, aInterface );
171 return S_OK;
175 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */