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