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 
23 
24 // SOComWindowPeer.h: Definition of the SOComWindowPeer class
25 //
26 //////////////////////////////////////////////////////////////////////
27 
28 #if !defined __SOCOMWINDOWPEER_H_
29 #define __SOCOMWINDOWPEER_H_
30 
31 #if _MSC_VER > 1000
32 #pragma once
33 #endif // _MSC_VER > 1000
34 
35 #include "resource.h"       // main symbols
36 #include <ExDispID.h>
37 #include <ExDisp.h>
38 #include <shlguid.h>
39 #include <atlctl.h>
40 
41 #include "so_activex.h"
42 
43 /////////////////////////////////////////////////////////////////////////////
44 // SOComWindowPeer
45 
46 class SOComWindowPeer :
47 	public IDispatchImpl<ISOComWindowPeer, &IID_ISOComWindowPeer, &LIBID_SO_ACTIVEXLib>,
48 	public ISupportErrorInfo,
49 	public CComObjectRoot,
50 	public CComCoClass<SOComWindowPeer,&CLSID_SOComWindowPeer>
51 {
52 	HWND m_hwnd;
53 public:
SOComWindowPeer()54 	SOComWindowPeer() : m_hwnd( NULL ) {}
55 
56 BEGIN_COM_MAP(SOComWindowPeer)
57 	COM_INTERFACE_ENTRY(IDispatch)
58 	COM_INTERFACE_ENTRY(ISOComWindowPeer)
59 	COM_INTERFACE_ENTRY(ISupportErrorInfo)
60 END_COM_MAP()
61 DECLARE_NOT_AGGREGATABLE(SOComWindowPeer)
62 // Remove the comment from the line above if you don't want your object to
63 // support aggregation.
64 
65 DECLARE_REGISTRY_RESOURCEID(IDR_SOCOMWINDOWPEER)
66 
67 // ISupportsErrorInfo
68 	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
69 
70 // ISOComWindowPeer
getWindowHandle(SAFEARRAY __RPC_FAR * procId,short s,long __RPC_FAR * ret)71         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getWindowHandle(
72             /* [in] */ SAFEARRAY __RPC_FAR * procId,
73             /* [in] */ short s,
74             /* [retval][out] */ long __RPC_FAR *ret)
75 		{
76 			*ret = (long) m_hwnd;
77 			return S_OK;
78 		}
79 
getToolkit(IDispatch __RPC_FAR * __RPC_FAR * retVal)80         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getToolkit(
81             /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
82 		{
83 			*retVal = NULL;
84 			return S_OK;
85 		}
86 
setPointer(IDispatch __RPC_FAR * xPointer)87         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setPointer(
88             /* [in] */ IDispatch __RPC_FAR *xPointer)
89 		{
90 			return S_OK;
91 		}
92 
setBackground(int nColor)93         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setBackground(
94             /* [in] */ int nColor)
95 		{
96 			return S_OK;
97 		}
98 
invalidate(short __MIDL_0015)99         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidate(
100             /* [in] */ short __MIDL_0015)
101 		{
102 			return S_OK;
103 		}
104 
invalidateRect(IDispatch __RPC_FAR * aRect,short nFlags)105         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidateRect(
106             /* [in] */ IDispatch __RPC_FAR *aRect,
107             /* [in] */ short nFlags)
108 		{
109 			return S_OK;
110 		}
111 
dispose(void)112         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispose( void)
113 		{
114 			return S_OK;
115 		}
116 
addEventListener(IDispatch __RPC_FAR * xListener)117         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addEventListener(
118             /* [in] */ IDispatch __RPC_FAR *xListener)
119 		{
120 			return S_OK;
121 		}
122 
removeEventListener(IDispatch __RPC_FAR * xListener)123         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeEventListener(
124             /* [in] */ IDispatch __RPC_FAR *xListener)
125 		{
126 			return S_OK;
127 		}
128 
get_Bridge_implementedInterfaces(SAFEARRAY __RPC_FAR * __RPC_FAR * pVal)129         virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
130             /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
131 		{
132 			*pVal = SafeArrayCreateVector( VT_BSTR, 0, 2 );
133 
134 			if( !*pVal )
135 				return E_FAIL;
136 
137 			long ix = 0;
138             CComBSTR aInterface( OLESTR( "com.sun.star.awt.XSystemDependentWindowPeer" ) );
139 			SafeArrayPutElement( *pVal, &ix, aInterface );
140 
141 			ix = 1;
142             aInterface = CComBSTR( OLESTR( "com.sun.star.awt.XWindowPeer" ) );
143 			SafeArrayPutElement( *pVal, &ix, aInterface );
144 
145 			return S_OK;
146 		}
147 
SetHWNDInternally(HWND hwnd)148 		void SetHWNDInternally( HWND hwnd ) { m_hwnd = hwnd; }
149 };
150 
151 #endif // __SOCOMWINDOWPEER_H_
152