1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  *  The Contents of this file are made available subject to the terms of
4*cdf0e10cSrcweir  *  the BSD license.
5*cdf0e10cSrcweir  *
6*cdf0e10cSrcweir  *  Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir  *  All rights reserved.
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  *  Redistribution and use in source and binary forms, with or without
10*cdf0e10cSrcweir  *  modification, are permitted provided that the following conditions
11*cdf0e10cSrcweir  *  are met:
12*cdf0e10cSrcweir  *  1. Redistributions of source code must retain the above copyright
13*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer.
14*cdf0e10cSrcweir  *  2. Redistributions in binary form must reproduce the above copyright
15*cdf0e10cSrcweir  *     notice, this list of conditions and the following disclaimer in the
16*cdf0e10cSrcweir  *     documentation and/or other materials provided with the distribution.
17*cdf0e10cSrcweir  *  3. Neither the name of Sun Microsystems, Inc. nor the names of its
18*cdf0e10cSrcweir  *     contributors may be used to endorse or promote products derived
19*cdf0e10cSrcweir  *     from this software without specific prior written permission.
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22*cdf0e10cSrcweir  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23*cdf0e10cSrcweir  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24*cdf0e10cSrcweir  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25*cdf0e10cSrcweir  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26*cdf0e10cSrcweir  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27*cdf0e10cSrcweir  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28*cdf0e10cSrcweir  *  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29*cdf0e10cSrcweir  *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
30*cdf0e10cSrcweir  *  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
31*cdf0e10cSrcweir  *  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*cdf0e10cSrcweir  *
33*cdf0e10cSrcweir  *************************************************************************/
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir // SOComWindowPeer.h: Definition of the SOComWindowPeer class
36*cdf0e10cSrcweir //
37*cdf0e10cSrcweir //////////////////////////////////////////////////////////////////////
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #if !defined __SOCOMWINDOWPEER_H_
40*cdf0e10cSrcweir #define __SOCOMWINDOWPEER_H_
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #if _MSC_VER > 1000
43*cdf0e10cSrcweir #pragma once
44*cdf0e10cSrcweir #endif // _MSC_VER > 1000
45*cdf0e10cSrcweir 
46*cdf0e10cSrcweir #include "resource.h"       // main symbols
47*cdf0e10cSrcweir #include <ExDispID.h>
48*cdf0e10cSrcweir #include <ExDisp.h>
49*cdf0e10cSrcweir #include <shlguid.h>
50*cdf0e10cSrcweir #include <atlctl.h>
51*cdf0e10cSrcweir 
52*cdf0e10cSrcweir #include "so_activex.h"
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
55*cdf0e10cSrcweir // SOComWindowPeer
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir class SOComWindowPeer :
58*cdf0e10cSrcweir 	public IDispatchImpl<ISOComWindowPeer, &IID_ISOComWindowPeer, &LIBID_SO_ACTIVEXLib>,
59*cdf0e10cSrcweir 	public ISupportErrorInfo,
60*cdf0e10cSrcweir 	public CComObjectRoot,
61*cdf0e10cSrcweir 	public CComCoClass<SOComWindowPeer,&CLSID_SOComWindowPeer>
62*cdf0e10cSrcweir {
63*cdf0e10cSrcweir 	HWND m_hwnd;
64*cdf0e10cSrcweir public:
65*cdf0e10cSrcweir 	SOComWindowPeer() : m_hwnd( NULL ) {}
66*cdf0e10cSrcweir 
67*cdf0e10cSrcweir BEGIN_COM_MAP(SOComWindowPeer)
68*cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IDispatch)
69*cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(ISOComWindowPeer)
70*cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(ISupportErrorInfo)
71*cdf0e10cSrcweir END_COM_MAP()
72*cdf0e10cSrcweir DECLARE_NOT_AGGREGATABLE(SOComWindowPeer)
73*cdf0e10cSrcweir // Remove the comment from the line above if you don't want your object to
74*cdf0e10cSrcweir // support aggregation.
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir DECLARE_REGISTRY_RESOURCEID(IDR_SOCOMWINDOWPEER)
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir // ISupportsErrorInfo
79*cdf0e10cSrcweir 	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
80*cdf0e10cSrcweir 
81*cdf0e10cSrcweir // ISOComWindowPeer
82*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getWindowHandle(
83*cdf0e10cSrcweir             /* [in] */ SAFEARRAY __RPC_FAR * procId,
84*cdf0e10cSrcweir             /* [in] */ short s,
85*cdf0e10cSrcweir             /* [retval][out] */ long __RPC_FAR *ret)
86*cdf0e10cSrcweir 		{
87*cdf0e10cSrcweir 			*ret = (long) m_hwnd;
88*cdf0e10cSrcweir 			return S_OK;
89*cdf0e10cSrcweir 		}
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE getToolkit(
92*cdf0e10cSrcweir             /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *retVal)
93*cdf0e10cSrcweir 		{
94*cdf0e10cSrcweir 			*retVal = NULL;
95*cdf0e10cSrcweir 			return S_OK;
96*cdf0e10cSrcweir 		}
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setPointer(
99*cdf0e10cSrcweir             /* [in] */ IDispatch __RPC_FAR *xPointer)
100*cdf0e10cSrcweir 		{
101*cdf0e10cSrcweir 			return S_OK;
102*cdf0e10cSrcweir 		}
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE setBackground(
105*cdf0e10cSrcweir             /* [in] */ int nColor)
106*cdf0e10cSrcweir 		{
107*cdf0e10cSrcweir 			return S_OK;
108*cdf0e10cSrcweir 		}
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidate(
111*cdf0e10cSrcweir             /* [in] */ short __MIDL_0015)
112*cdf0e10cSrcweir 		{
113*cdf0e10cSrcweir 			return S_OK;
114*cdf0e10cSrcweir 		}
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE invalidateRect(
117*cdf0e10cSrcweir             /* [in] */ IDispatch __RPC_FAR *aRect,
118*cdf0e10cSrcweir             /* [in] */ short nFlags)
119*cdf0e10cSrcweir 		{
120*cdf0e10cSrcweir 			return S_OK;
121*cdf0e10cSrcweir 		}
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE dispose( void)
124*cdf0e10cSrcweir 		{
125*cdf0e10cSrcweir 			return S_OK;
126*cdf0e10cSrcweir 		}
127*cdf0e10cSrcweir 
128*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE addEventListener(
129*cdf0e10cSrcweir             /* [in] */ IDispatch __RPC_FAR *xListener)
130*cdf0e10cSrcweir 		{
131*cdf0e10cSrcweir 			return S_OK;
132*cdf0e10cSrcweir 		}
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE removeEventListener(
135*cdf0e10cSrcweir             /* [in] */ IDispatch __RPC_FAR *xListener)
136*cdf0e10cSrcweir 		{
137*cdf0e10cSrcweir 			return S_OK;
138*cdf0e10cSrcweir 		}
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir         virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
141*cdf0e10cSrcweir             /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
142*cdf0e10cSrcweir 		{
143*cdf0e10cSrcweir 			*pVal = SafeArrayCreateVector( VT_BSTR, 0, 2 );
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir 			if( !*pVal )
146*cdf0e10cSrcweir 				return E_FAIL;
147*cdf0e10cSrcweir 
148*cdf0e10cSrcweir 			long ix = 0;
149*cdf0e10cSrcweir             CComBSTR aInterface( OLESTR( "com.sun.star.awt.XSystemDependentWindowPeer" ) );
150*cdf0e10cSrcweir 			SafeArrayPutElement( *pVal, &ix, aInterface );
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 			ix = 1;
153*cdf0e10cSrcweir             aInterface = CComBSTR( OLESTR( "com.sun.star.awt.XWindowPeer" ) );
154*cdf0e10cSrcweir 			SafeArrayPutElement( *pVal, &ix, aInterface );
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 			return S_OK;
157*cdf0e10cSrcweir 		}
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 		void SetHWNDInternally( HWND hwnd ) { m_hwnd = hwnd; }
160*cdf0e10cSrcweir };
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir #endif // __SOCOMWINDOWPEER_H_
163