xref: /AOO41X/main/extensions/source/ole/unotypewrapper.hxx (revision 46dbaceef8c12a09e4905feda473ecab36e10d03)
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 #ifndef UNO_TYPE_WRAPPER_HXX
24 #define UNO_TYPE_WRAPPER_HXX
25 
26 #pragma warning (push,1)
27 #pragma warning (disable:4548)
28 
29 #include <tools/presys.h>
30 //#include "stdafx.h"
31 #define STRICT
32 #define _WIN32_WINNT 0x0400
33 #define _WIN32_DCOM
34 #if OSL_DEBUG_LEVEL > 0
35 //#define _ATL_DEBUG_INTERFACES
36 #endif
37 #include <atlbase.h>
38 extern CComModule _Module;
39 #include <atlcom.h>
40 #include <tools/postsys.h>
41 
42 #pragma warning (pop)
43 #pragma warning (disable:4505)
44     // disable "unreferenced local function has been removed" globally
45 
46 #include "comifaces.hxx"
47 
48 /* creates an UnoTypWrapper and sets the Name property to the value
49    specified by sTypeName.
50    Returns true if the object could be created and initialized.
51  */
52 bool createUnoTypeWrapper(BSTR sTypeName, VARIANT * pVariant);
53 bool createUnoTypeWrapper(const rtl::OUString& sTypeName, VARIANT * pVar);
54 
55 class UnoTypeWrapper:
56       public CComObjectRootEx<CComMultiThreadModel>,
57       public IUnoTypeWrapper,
58       public IDispatch
59 {
60 public:
61     UnoTypeWrapper();
62     virtual ~UnoTypeWrapper();
63 
64     BEGIN_COM_MAP(UnoTypeWrapper)
65         COM_INTERFACE_ENTRY(IDispatch)
66         COM_INTERFACE_ENTRY(IUnoTypeWrapper)
67     END_COM_MAP()
68 
69     // IDispatch -------------------------------------------
70     STDMETHOD( GetTypeInfoCount)(UINT *pctinfo);
71 
72     STDMETHOD( GetTypeInfo)( UINT iTInfo,
73                              LCID lcid,
74                              ITypeInfo **ppTInfo);
75 
76     STDMETHOD( GetIDsOfNames)( REFIID riid,
77                                LPOLESTR *rgszNames,
78                                UINT cNames,
79                                LCID lcid,
80                                DISPID *rgDispId);
81 
82     STDMETHOD( Invoke)( DISPID dispIdMember,
83                         REFIID riid,
84                         LCID lcid,
85                         WORD wFlags,
86                         DISPPARAMS *pDispParams,
87                         VARIANT *pVarResult,
88                         EXCEPINFO *pExcepInfo,
89                         UINT *puArgErr);
90     // IUnoTypeWrapper --------------------------------------
91     STDMETHOD(put_Name)(BSTR val);
92     STDMETHOD(get_Name)(BSTR* pVal);
93 
94     CComBSTR m_sName;
95 };
96 
97 #endif
98