LibreOffice Module extensions (master) 1
SODispatchInterceptor.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20// SODispatchInterceptor.h: Definition of the SODispatchInterceptor class
21
22#pragma once
23
24#ifdef _MSC_VER
25#pragma once
26#endif
27
28#include "resource.h"
29#include <ExDispID.h>
30#include <ExDisp.h>
31#include <shlguid.h>
32
33#include <atlctl.h>
34
35#include <so_activex.h>
36
37class CSOActiveX;
38
39
40// SODispatchInterceptor
41
43 public IDispatchImpl<ISODispatchInterceptor, &IID_ISODispatchInterceptor, &LIBID_SO_ACTIVEXLib>,
44 public ISupportErrorInfo,
45 public CComObjectRoot,
46 public CComCoClass<SODispatchInterceptor,&CLSID_SODispatchInterceptor>
47{
48 CComPtr<IDispatch> m_xMaster;
49 CComPtr<IDispatch> m_xSlave;
51 CRITICAL_SECTION mMutex;
52public:
53 SODispatchInterceptor() : m_xParentControl( nullptr ) { InitializeCriticalSection(&mMutex); }
54 virtual ~SODispatchInterceptor() { ATLASSERT( !m_xParentControl ); DeleteCriticalSection(&mMutex); }
55
56BEGIN_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
64END_COM_MAP()
65#if defined __clang__
66#pragma clang diagnostic pop
67#endif
68DECLARE_NOT_AGGREGATABLE(SODispatchInterceptor)
69// Remove the comment from the line above if you don't want your object to
70// support aggregation.
71
72DECLARE_REGISTRY_RESOURCEID(IDR_SODISPATCHINTERCEPTOR)
73
74 void SetParent( CSOActiveX* pParent )
75 {
76 ATLASSERT( !m_xParentControl );
77 EnterCriticalSection( &mMutex );
78 m_xParentControl = pParent;
79 LeaveCriticalSection( &mMutex );
80 }
81
83 {
84 EnterCriticalSection( &mMutex );
85 m_xParentControl = nullptr;
86 LeaveCriticalSection( &mMutex );
87 }
88
89// ISupportsErrorInfo
90 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid) override;
91
92// ISODispatchInterceptor
93
94 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getSlaveDispatchProvider(
95 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) override
96 {
97 *retVal = m_xSlave;
98 return S_OK;
99 }
100
101 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setSlaveDispatchProvider(
102 /* [in] */ IDispatch __RPC_FAR *xNewDispatchProvider) override
103 {
104 m_xSlave = xNewDispatchProvider;
105 return S_OK;
106 }
107
108 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getMasterDispatchProvider(
109 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) override
110 {
111 *retVal = m_xMaster;
112 return S_OK;
113 }
114
115 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setMasterDispatchProvider(
116 /* [in] */ IDispatch __RPC_FAR *xNewSupplier) override
117 {
118 m_xMaster = xNewSupplier;
119 return S_OK;
120 }
121
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;
127
128 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE queryDispatches(
129 /* [in] */ SAFEARRAY __RPC_FAR * aDescripts,
130 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *retVal) override;
131
132 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispatch(
133 /* [in] */ IDispatch __RPC_FAR *aURL,
134 /* [in] */ SAFEARRAY __RPC_FAR * aArgs) override;
135
136 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addStatusListener(
137 /* [in] */ IDispatch __RPC_FAR *xControl,
138 /* [in] */ IDispatch __RPC_FAR *aURL) override;
139
140 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeStatusListener(
141 /* [in] */ IDispatch __RPC_FAR *xControl,
142 /* [in] */ IDispatch __RPC_FAR *aURL) override;
143
144 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getInterceptedURLs(
145 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal) override;
146
147 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
148 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal) override
149 {
150 *pVal = SafeArrayCreateVector( VT_BSTR, 0, 4 );
151
152 if( !*pVal )
153 return E_FAIL;
154
155 LONG ix = 0;
156 CComBSTR aInterface( OLESTR( "com.sun.star.frame.XDispatchProviderInterceptor" ) );
157 SafeArrayPutElement( *pVal, &ix, aInterface );
158
159 ix = 1;
160 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatchProvider" ) );
161 SafeArrayPutElement( *pVal, &ix, aInterface );
162
163 ix = 2;
164 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XDispatch" ) );
165 SafeArrayPutElement( *pVal, &ix, aInterface );
166
167 ix = 3;
168 aInterface = CComBSTR( OLESTR( "com.sun.star.frame.XInterceptorInfo" ) );
169 SafeArrayPutElement( *pVal, &ix, aInterface );
170
171 return S_OK;
172 }
173};
174
175/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual HRESULT STDMETHODCALLTYPE dispatch(IDispatch __RPC_FAR *aURL, SAFEARRAY __RPC_FAR *aArgs) override
virtual HRESULT STDMETHODCALLTYPE removeStatusListener(IDispatch __RPC_FAR *xControl, IDispatch __RPC_FAR *aURL) override
CComPtr< IDispatch > m_xMaster
virtual HRESULT STDMETHODCALLTYPE setMasterDispatchProvider(IDispatch __RPC_FAR *xNewSupplier) override
virtual HRESULT STDMETHODCALLTYPE getMasterDispatchProvider(IDispatch __RPC_FAR *__RPC_FAR *retVal) override
virtual HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(SAFEARRAY __RPC_FAR *__RPC_FAR *pVal) override
virtual HRESULT STDMETHODCALLTYPE addStatusListener(IDispatch __RPC_FAR *xControl, IDispatch __RPC_FAR *aURL) override
STDMETHOD() InterfaceSupportsErrorInfo(REFIID riid) override
virtual HRESULT STDMETHODCALLTYPE getInterceptedURLs(SAFEARRAY __RPC_FAR *__RPC_FAR *pVal) override
CComPtr< IDispatch > m_xSlave
void SetParent(CSOActiveX *pParent)
virtual HRESULT STDMETHODCALLTYPE getSlaveDispatchProvider(IDispatch __RPC_FAR *__RPC_FAR *retVal) override
virtual HRESULT STDMETHODCALLTYPE queryDispatch(IDispatch __RPC_FAR *aURL, BSTR aTargetFrameName, long nSearchFlags, IDispatch __RPC_FAR *__RPC_FAR *retVal) override
virtual HRESULT STDMETHODCALLTYPE setSlaveDispatchProvider(IDispatch __RPC_FAR *xNewDispatchProvider) override
virtual HRESULT STDMETHODCALLTYPE queryDispatches(SAFEARRAY __RPC_FAR *aDescripts, SAFEARRAY __RPC_FAR *__RPC_FAR *retVal) override
#define VT_BSTR
LONG
#define IDR_SODISPATCHINTERCEPTOR
Definition: resource.h:30