xref: /AOO41X/main/extensions/source/activex/main/SOActiveX.h (revision 5c66ce185204f6c2b1e899d1fa6643bb4f8419e2)
1*5c66ce18SAndrew Rist /**************************************************************
2*5c66ce18SAndrew Rist  *
3*5c66ce18SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*5c66ce18SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*5c66ce18SAndrew Rist  * distributed with this work for additional information
6*5c66ce18SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*5c66ce18SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*5c66ce18SAndrew Rist  * "License"); you may not use this file except in compliance
9*5c66ce18SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*5c66ce18SAndrew Rist  *
11*5c66ce18SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*5c66ce18SAndrew Rist  *
13*5c66ce18SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*5c66ce18SAndrew Rist  * software distributed under the License is distributed on an
15*5c66ce18SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*5c66ce18SAndrew Rist  * KIND, either express or implied.  See the License for the
17*5c66ce18SAndrew Rist  * specific language governing permissions and limitations
18*5c66ce18SAndrew Rist  * under the License.
19*5c66ce18SAndrew Rist  *
20*5c66ce18SAndrew Rist  *************************************************************/
21*5c66ce18SAndrew Rist 
22cdf0e10cSrcweir // SOActiveX.h : Declaration of the CSOActiveX
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef __SOACTIVEX_H_
25cdf0e10cSrcweir #define __SOACTIVEX_H_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "resource.h"       // main symbols
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #pragma warning (disable:4505)
30cdf0e10cSrcweir     // permanently suppress "unreferenced local function has been removed" warning
31cdf0e10cSrcweir 
32cdf0e10cSrcweir #pragma warning (push,1)
33cdf0e10cSrcweir #pragma warning (disable:4265)
34cdf0e10cSrcweir 
35cdf0e10cSrcweir #include <ExDispID.h>
36cdf0e10cSrcweir #include <ExDisp.h>
37cdf0e10cSrcweir #include <shlguid.h>
38cdf0e10cSrcweir 
39cdf0e10cSrcweir #if defined(_MSC_VER) && (_MSC_VER >= 1300)
40cdf0e10cSrcweir #undef _DEBUG
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #include <atlctl.h>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #include "so_activex.h"
45cdf0e10cSrcweir 
46cdf0e10cSrcweir #pragma warning (pop)
47cdf0e10cSrcweir 
48cdf0e10cSrcweir class SODispatchInterceptor;
49cdf0e10cSrcweir 
50cdf0e10cSrcweir enum SOVersion {
51cdf0e10cSrcweir 	SO_NOT_DETECTED = 0,
52cdf0e10cSrcweir 	SO_52,
53cdf0e10cSrcweir 	SO_60,
54cdf0e10cSrcweir 	SO_61,
55cdf0e10cSrcweir 	SO_UNKNOWN,
56cdf0e10cSrcweir 	OO_10,
57cdf0e10cSrcweir 	OO_11,
58cdf0e10cSrcweir 	OO_UNKNOWN
59cdf0e10cSrcweir };
60cdf0e10cSrcweir 
61cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////////////
62cdf0e10cSrcweir // CSOActiveX
63cdf0e10cSrcweir class ATL_NO_VTABLE CSOActiveX :
64cdf0e10cSrcweir 	public CComObjectRootEx<CComSingleThreadModel>,
65cdf0e10cSrcweir 	public IDispatchImpl<ISOActiveX, &IID_ISOActiveX, &LIBID_SO_ACTIVEXLib>,
66cdf0e10cSrcweir 	public CComControl<CSOActiveX>,
67cdf0e10cSrcweir 	public IPersistStreamInitImpl<CSOActiveX>,
68cdf0e10cSrcweir 	public IOleControlImpl<CSOActiveX>,
69cdf0e10cSrcweir 	public IOleObjectImpl<CSOActiveX>,
70cdf0e10cSrcweir 	public IOleInPlaceActiveObjectImpl<CSOActiveX>,
71cdf0e10cSrcweir 	public IViewObjectExImpl<CSOActiveX>,
72cdf0e10cSrcweir 	public IOleInPlaceObjectWindowlessImpl<CSOActiveX>,
73cdf0e10cSrcweir //	public IConnectionPointContainerImpl<CSOActiveX>,
74cdf0e10cSrcweir 	public CComCoClass<CSOActiveX, &CLSID_SOActiveX>,
75cdf0e10cSrcweir //	public CProxy_ItryPluginEvents< CSOActiveX >,
76cdf0e10cSrcweir 	public IPersistPropertyBagImpl< CSOActiveX >,
77cdf0e10cSrcweir 	public IProvideClassInfo2Impl<	&CLSID_SOActiveX,
78cdf0e10cSrcweir 									&DIID__ISOActiveXEvents,
79cdf0e10cSrcweir 									&LIBID_SO_ACTIVEXLib >,
80cdf0e10cSrcweir     public IObjectSafetyImpl< CSOActiveX,
81cdf0e10cSrcweir                               INTERFACESAFE_FOR_UNTRUSTED_DATA >
82cdf0e10cSrcweir {
83cdf0e10cSrcweir protected:
84cdf0e10cSrcweir 	CComPtr<IWebBrowser2>	mWebBrowser2;
85cdf0e10cSrcweir 	DWORD					mCookie;
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 	CComPtr<IDispatch> 		mpDispFactory;
88cdf0e10cSrcweir 	CComPtr<IDispatch> 		mpDispFrame;
89cdf0e10cSrcweir 	CComPtr<IDispatch> 		mpInstanceLocker;
90cdf0e10cSrcweir 	CComPtr<IDispatch> 		mpDispWin;
91cdf0e10cSrcweir     OLECHAR*          		mCurFileUrl;
92cdf0e10cSrcweir 	BOOL					mbLoad;
93cdf0e10cSrcweir 	BOOL					mbViewOnly;
94cdf0e10cSrcweir     WNDCLASS                mPWinClass;
95cdf0e10cSrcweir 	HWND					mParentWin;
96cdf0e10cSrcweir 	HWND					mOffWin;
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 	SODispatchInterceptor*  mpDispatchInterceptor;
99cdf0e10cSrcweir 	SOVersion				mnVersion;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 	BOOL					mbReadyForActivation;
102cdf0e10cSrcweir 	CComPtr<IDispatch> 		mpDispTempFile;
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 	BOOL					mbDrawLocked;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir public:
107cdf0e10cSrcweir 	CSOActiveX();
108cdf0e10cSrcweir 	~CSOActiveX();
109cdf0e10cSrcweir 
110cdf0e10cSrcweir DECLARE_REGISTRY_RESOURCEID(IDR_SOACTIVEX)
111cdf0e10cSrcweir 
112cdf0e10cSrcweir DECLARE_PROTECT_FINAL_CONSTRUCT()
113cdf0e10cSrcweir 
114cdf0e10cSrcweir BEGIN_COM_MAP(CSOActiveX)
115cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(ISOActiveX)
116cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IDispatch)
117cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IViewObjectEx)
118cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IViewObject2)
119cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IViewObject)
120cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
121cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IOleInPlaceObject)
122cdf0e10cSrcweir 	COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
123cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
124cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IOleControl)
125cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IOleObject)
126cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IPersistStreamInit)
127cdf0e10cSrcweir 	COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
128cdf0e10cSrcweir //	COM_INTERFACE_ENTRY(IConnectionPointContainer)
129cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IProvideClassInfo)
130cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IProvideClassInfo2)
131cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IPersistPropertyBag)
132cdf0e10cSrcweir 	COM_INTERFACE_ENTRY(IObjectSafety)
133cdf0e10cSrcweir END_COM_MAP()
134cdf0e10cSrcweir 
135cdf0e10cSrcweir BEGIN_PROP_MAP(CSOActiveX)
136cdf0e10cSrcweir 	PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
137cdf0e10cSrcweir 	PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
138cdf0e10cSrcweir 	// Example entries
139cdf0e10cSrcweir 	// PROP_ENTRY("Property Description", dispid, clsid)
140cdf0e10cSrcweir 	// PROP_PAGE(CLSID_StockColorPage)
141cdf0e10cSrcweir END_PROP_MAP()
142cdf0e10cSrcweir 
143cdf0e10cSrcweir BEGIN_CONNECTION_POINT_MAP(CSOActiveX)
144cdf0e10cSrcweir END_CONNECTION_POINT_MAP()
145cdf0e10cSrcweir 
146cdf0e10cSrcweir BEGIN_MSG_MAP(CSOActiveX)
147cdf0e10cSrcweir 	CHAIN_MSG_MAP(CComControl<CSOActiveX>)
148cdf0e10cSrcweir 	DEFAULT_REFLECTION_HANDLER()
149cdf0e10cSrcweir END_MSG_MAP()
150cdf0e10cSrcweir // Handler prototypes:
151cdf0e10cSrcweir //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
152cdf0e10cSrcweir //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
153cdf0e10cSrcweir //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
157cdf0e10cSrcweir // IViewObjectEx
158cdf0e10cSrcweir 	DECLARE_VIEW_STATUS(VIEWSTATUS_SOLIDBKGND | VIEWSTATUS_OPAQUE)
159cdf0e10cSrcweir 
160cdf0e10cSrcweir // ISOActiveX
161cdf0e10cSrcweir public:
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 	STDMETHOD(SetClientSite)( IOleClientSite* aClientSite );
164cdf0e10cSrcweir 	STDMETHOD(Invoke)(  DISPID dispidMember,
165cdf0e10cSrcweir 						REFIID riid,
166cdf0e10cSrcweir 						LCID lcid,
167cdf0e10cSrcweir                         WORD wFlags,
168cdf0e10cSrcweir 						DISPPARAMS* pDispParams,
169cdf0e10cSrcweir                         VARIANT* pvarResult,
170cdf0e10cSrcweir 						EXCEPINFO* pExcepInfo,
171cdf0e10cSrcweir                         UINT* puArgErr);
172cdf0e10cSrcweir 	STDMETHOD(Load) ( LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog );
173cdf0e10cSrcweir 	STDMETHOD(Load) ( LPSTREAM pStm );
174cdf0e10cSrcweir     STDMETHOD(InitNew) ();
175cdf0e10cSrcweir 	HRESULT OnDrawAdvanced(ATL_DRAWINFO& di);
176cdf0e10cSrcweir 	HRESULT OnDraw(ATL_DRAWINFO& di);
177cdf0e10cSrcweir 
178cdf0e10cSrcweir 	HRESULT SetLayoutManagerProps();
179cdf0e10cSrcweir 	HRESULT CreateFrameOldWay( HWND hwnd, int width, int height );
180cdf0e10cSrcweir 	HRESULT GetUnoStruct( OLECHAR* sStructName, CComPtr<IDispatch>& pdispResult );
181cdf0e10cSrcweir 	HRESULT LoadURLToFrame();
182cdf0e10cSrcweir 	HRESULT CallDispatchMethod( OLECHAR* sUrl, CComVariant* sArgNames, CComVariant* sArgVal, unsigned int count );
183cdf0e10cSrcweir 	HRESULT CallLoadComponentFromURL1PBool( OLECHAR* sUrl, OLECHAR* sArgName, BOOL sArgVal );
184cdf0e10cSrcweir 	HRESULT GetUrlStruct( OLECHAR* sUrl, CComPtr<IDispatch>& pdispUrl );
185cdf0e10cSrcweir 	HRESULT	Cleanup();
186cdf0e10cSrcweir     HRESULT TerminateOffice();
187cdf0e10cSrcweir 	HRESULT GetURL( const OLECHAR* url,
188cdf0e10cSrcweir                                 const OLECHAR* target );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir 	void CallbackCreateXInputStream( CBindStatusCallback<CSOActiveX>* pbsc, BYTE* pBytes, DWORD dwSize );
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 
193cdf0e10cSrcweir 	SOVersion GetVersionConnected();
194cdf0e10cSrcweir };
195cdf0e10cSrcweir 
196cdf0e10cSrcweir #endif //__SOACTIVEX_H_
197cdf0e10cSrcweir 
198