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 // SOActionsApproval.h: Definition of the SOActionsApproval class
23 //
24 //////////////////////////////////////////////////////////////////////
25 
26 #if !defined __SODOCUMENTEVENTLISTENER_H_
27 #define __SODOCUMENTEVENTLISTENER_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 
42 #include <atlctl.h>
43 
44 #include "so_activex.h"
45 
46 /////////////////////////////////////////////////////////////////////////////
47 // SOActionsApproval
48 
49 class SOActionsApproval :
50 	public IDispatchImpl<ISOActionsApproval, &IID_ISOActionsApproval, &LIBID_SO_ACTIVEXLib>,
51 	public ISupportErrorInfo,
52 	public CComObjectRoot,
53 	public CComCoClass<SOActionsApproval,&CLSID_SOActionsApproval>
54 {
55 public:
SOActionsApproval()56 	SOActionsApproval() {}
~SOActionsApproval()57 	virtual ~SOActionsApproval() {}
58 
59 BEGIN_COM_MAP(SOActionsApproval)
60 	COM_INTERFACE_ENTRY(IDispatch)
61 	COM_INTERFACE_ENTRY(ISOActionsApproval)
62 	COM_INTERFACE_ENTRY(ISupportErrorInfo)
63 END_COM_MAP()
64 DECLARE_NOT_AGGREGATABLE(SOActionsApproval)
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_SODOCUMENTEVENTLISTENER)
69 
70 // ISupportsErrorInfo
71 	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
72 
73 // ISOActionsApproval
approveAction(long nActionID,boolean * pbApproval)74         virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE approveAction(
75             /* [in] */ long nActionID,
76             /* [retval][out] */ boolean *pbApproval)
77 		{
78 			// only PreventClose is approved
79 			USES_CONVERSION;
80 			*pbApproval = ( nActionID == 1 );
81 
82 			return S_OK;
83 		}
84 
get_Bridge_implementedInterfaces(SAFEARRAY __RPC_FAR * __RPC_FAR * pVal)85         virtual /* [helpstring][id][propget] */ HRESULT STDMETHODCALLTYPE get_Bridge_implementedInterfaces(
86             /* [retval][out] */ SAFEARRAY __RPC_FAR * __RPC_FAR *pVal)
87 		{
88 			*pVal = SafeArrayCreateVector( VT_BSTR, 0, 1 );
89 
90 			if( !*pVal )
91 				return E_FAIL;
92 
93 			long ix = 0;
94             CComBSTR aInterface( OLESTR( "com.sun.star.embed.XActionsApproval" ) );
95 			SafeArrayPutElement( *pVal, &ix, aInterface );
96 
97 			return S_OK;
98 		}
99 };
100 
101 #endif // __SODOCUMENTEVENTLISTENER_H_
102 
103