1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 // SOComWindowPeer.h: Definition of the SOComWindowPeer class 23 // 24 ////////////////////////////////////////////////////////////////////// 25 26 #if !defined __SOCOMWINDOWPEER_H_ 27 #define __SOCOMWINDOWPEER_H_ 28 29 #if _MSC_VER > 1000 30 #pragma once 31 #endif // _MSC_VER > 1000 32 33 #include "resource.h" // main symbols 34 #include <ExDispID.h> 35 #include <ExDisp.h> 36 #include <shlguid.h> 37 38 #if defined(_MSC_VER) && (_MSC_VER >= 1300) 39 #undef _DEBUG 40 #endif 41 #include <atlctl.h> 42 43 #include "so_activex.h" 44 45 ///////////////////////////////////////////////////////////////////////////// 46 // SOComWindowPeer 47 48 class SOComWindowPeer : 49 public IDispatchImpl<ISOComWindowPeer, &IID_ISOComWindowPeer, &LIBID_SO_ACTIVEXLib>, 50 public ISupportErrorInfo, 51 public CComObjectRoot, 52 public CComCoClass<SOComWindowPeer,&CLSID_SOComWindowPeer> 53 { 54 HWND m_hwnd; 55 public: SOComWindowPeer()56 SOComWindowPeer() : m_hwnd( NULL ) {} ~SOComWindowPeer()57 virtual ~SOComWindowPeer() { } 58 59 BEGIN_COM_MAP(SOComWindowPeer) 60 COM_INTERFACE_ENTRY(IDispatch) 61 COM_INTERFACE_ENTRY(ISOComWindowPeer) 62 COM_INTERFACE_ENTRY(ISupportErrorInfo) 63 END_COM_MAP() 64 DECLARE_NOT_AGGREGATABLE(SOComWindowPeer) 65 // Remove the comment from the line above if you don't want your object to 66 // support aggregation. 67 68 DECLARE_REGISTRY_RESOURCEID(IDR_SOCOMWINDOWPEER) 69 70 // ISupportsErrorInfo 71 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid); 72 73 // ISOComWindowPeer getWindowHandle(SAFEARRAY __RPC_FAR *,short,long __RPC_FAR * ret)74 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getWindowHandle( 75 /* [in] */ SAFEARRAY __RPC_FAR * /*procId*/, 76 /* [in] */ short /*s*/, 77 /* [retval][out] */ long __RPC_FAR *ret) 78 { 79 *ret = HandleToLong( m_hwnd ); 80 return S_OK; 81 } 82 getToolkit(IDispatch __RPC_FAR * __RPC_FAR * retVal)83 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getToolkit( 84 /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal) 85 { 86 *retVal = NULL; 87 return S_OK; 88 } 89 setPointer(IDispatch __RPC_FAR *)90 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setPointer( 91 /* [in] */ IDispatch __RPC_FAR* /*xPointer*/) 92 { 93 return S_OK; 94 } 95 setBackground(int)96 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setBackground( 97 /* [in] */ int /*nColor*/) 98 { 99 return S_OK; 100 } 101 invalidate(short)102 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidate( 103 /* [in] */ short /*__MIDL_0015*/) 104 { 105 return S_OK; 106 } 107 invalidateRect(IDispatch __RPC_FAR *,short)108 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidateRect( 109 /* [in] */ IDispatch __RPC_FAR* /*aRect*/, 110 /* [in] */ short /*nFlags*/) 111 { 112 return S_OK; 113 } 114 dispose(void)115 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispose( void) 116 { 117 return S_OK; 118 } 119 addEventListener(IDispatch __RPC_FAR *)120 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addEventListener( 121 /* [in] */ IDispatch __RPC_FAR* /*xListener*/) 122 { 123 return S_OK; 124 } 125 removeEventListener(IDispatch __RPC_FAR *)126 virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeEventListener( 127 /* [in] */ IDispatch __RPC_FAR* /*xListener*/) 128 { 129 return S_OK; 130 } 131 get_Bridge_implementedInterfaces(SAFEARRAY __RPC_FAR * __RPC_FAR * pVal)132 virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces( 133 /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal) 134 { 135 *pVal = SafeArrayCreateVector( VT_BSTR, 0, 2 ); 136 137 if( !*pVal ) 138 return E_FAIL; 139 140 long ix = 0; 141 CComBSTR aInterface( OLESTR( "com.sun.star.awt.XSystemDependentWindowPeer" ) ); 142 SafeArrayPutElement( *pVal, &ix, aInterface ); 143 144 ix = 1; 145 aInterface = CComBSTR( OLESTR( "com.sun.star.awt.XWindowPeer" ) ); 146 SafeArrayPutElement( *pVal, &ix, aInterface ); 147 148 return S_OK; 149 } 150 SetHWNDInternally(HWND hwnd)151 void SetHWNDInternally( HWND hwnd ) { m_hwnd = hwnd; } 152 }; 153 154 #endif // __SOCOMWINDOWPEER_H_ 155