xref: /trunk/main/extensions/source/ole/windata.hxx (revision 46dbacee)
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 AUTOMATION_BRIDGE_WINDATA_HXX
24 #define AUTOMATION_BRIDGE_WINDATA_HXX
25 
26 #pragma warning (push,1)
27 #pragma warning (disable:4668)
28 #pragma warning (disable:4548)
29 #include "oleidl.h"
30 
31 #include <atlbase.h>
32 #pragma warning (pop)
33 #include "osl/diagnose.h"
34 
35 namespace ole_adapter
36 {
37 //Wrapper for VARDESC
38 class VarDesc
39 {
40 	VARDESC* operator = (const VarDesc*);
41 	VarDesc(const VarDesc&);
42 // Construction
43 public:
44 	CComPtr< ITypeInfo > m_pTypeInfo;
45 	VARDESC* m_pVarDesc;
46 
VarDesc(ITypeInfo * pTypeInfo)47 	VarDesc(ITypeInfo* pTypeInfo) :
48 	  m_pVarDesc(NULL),
49 	  m_pTypeInfo(pTypeInfo)
50    {
51 	   OSL_ASSERT(pTypeInfo);
52    }
~VarDesc()53    ~VarDesc()
54    {
55 	  if (m_pVarDesc != NULL)
56 	  {
57 		 m_pTypeInfo->ReleaseVarDesc(m_pVarDesc);
58 	  }
59    }
60 
operator ->()61    VARDESC* operator->()
62    {
63 	  return m_pVarDesc;
64    }
65 
operator &()66    VARDESC** operator&()
67    {
68 	  return &m_pVarDesc;
69    }
70 
operator VARDESC*()71     operator VARDESC* ()
72     {
73         return m_pVarDesc;
74     }
75 };
76 
77 //Wrapper for FUNCDESC structure
78 class FuncDesc
79 {
80 	FUNCDESC* operator = (const FuncDesc &);
81 	FuncDesc(const FuncDesc&);
82 	CComPtr<ITypeInfo> m_pTypeInfo;
83     FUNCDESC * m_pFuncDesc;
84 
85 public:
86 
FuncDesc(ITypeInfo * pTypeInfo)87 	FuncDesc(ITypeInfo * pTypeInfo) :
88 		m_pFuncDesc(NULL),
89 		m_pTypeInfo(pTypeInfo)
90 		{
91 			OSL_ASSERT(pTypeInfo);
92 		}
~FuncDesc()93 	~FuncDesc()
94 	{
95 		ReleaseFUNCDESC();
96 	}
97 
operator ->()98 	FUNCDESC* operator -> ()
99 	{
100 		return m_pFuncDesc;
101 	}
102 
operator &()103 	FUNCDESC** operator & ()
104 	{
105 		return & m_pFuncDesc;
106 	}
107 
operator FUNCDESC*()108     operator FUNCDESC* ()
109     {
110         return m_pFuncDesc;
111     }
112 
operator =(FUNCDESC * pDesc)113 	FUNCDESC* operator = (FUNCDESC* pDesc)
114 	{
115 		ReleaseFUNCDESC();
116 		m_pFuncDesc = pDesc;
117 		return m_pFuncDesc;
118 	}
Detach()119 	FUNCDESC* Detach()
120 	{
121 		FUNCDESC* pDesc = m_pFuncDesc;
122 		m_pFuncDesc = NULL;
123 		return pDesc;
124 	}
125 
ReleaseFUNCDESC()126 	void ReleaseFUNCDESC()
127 	{
128 		if (m_pFuncDesc != NULL)
129 		{
130 			m_pTypeInfo->ReleaseFuncDesc(m_pFuncDesc);
131 		}
132 		m_pFuncDesc = NULL;
133 	}
134 };
135 //Wrapper for EXCEPINFO structure
136 class ExcepInfo : public EXCEPINFO
137 {
138 	EXCEPINFO* operator = (const ExcepInfo& );
139 	ExcepInfo(const ExcepInfo &);
140 public:
ExcepInfo()141    ExcepInfo()
142    {
143 	  memset(this, 0, sizeof(ExcepInfo));
144    }
~ExcepInfo()145    ~ExcepInfo()
146    {
147    	  if (bstrSource != NULL)
148 		 ::SysFreeString(bstrSource);
149 	  if (bstrDescription != NULL)
150 		::SysFreeString(bstrDescription);
151 	  if (bstrHelpFile != NULL)
152 		::SysFreeString(bstrHelpFile);
153    }
154 };
155 
156 //Wrapper for TYPEATTR
157 class TypeAttr
158 {
159 	TYPEATTR* operator = (const TypeAttr &);
160 	TypeAttr(const TypeAttr &);
161 public:
162 	CComPtr< ITypeInfo > m_pTypeInfo;
163 	TYPEATTR* m_pTypeAttr;
164 
TypeAttr(ITypeInfo * pTypeInfo)165 	TypeAttr(ITypeInfo* pTypeInfo) :
166 	  m_pTypeAttr( NULL ),
167 	  m_pTypeInfo( pTypeInfo )
168    {
169 	   OSL_ASSERT(pTypeInfo);
170    }
~TypeAttr()171    ~TypeAttr() throw()
172    {
173 		if (m_pTypeAttr != NULL)
174 		{
175 			m_pTypeInfo->ReleaseTypeAttr(m_pTypeAttr);
176 		}
177    }
178 
operator &()179    TYPEATTR** operator&() throw()
180    {
181 	  return &m_pTypeAttr;
182    }
183 
operator ->()184    TYPEATTR* operator->() throw()
185    {
186 	  return m_pTypeAttr;
187    }
188 };
189 
190 
191 
192 }
193 
194 #endif
195