Update ooo320-m1
[ooovba.git] / extensions / source / ole / windata.hxx
blob01c7bc4b819dcee773d5a7618c00e2a627fae1be
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: windata.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef AUTOMATION_BRIDGE_WINDATA_HXX
31 #define AUTOMATION_BRIDGE_WINDATA_HXX
33 #pragma warning (push,1)
34 #pragma warning (disable:4668)
35 #pragma warning (disable:4548)
36 #include "oleidl.h"
38 #include <atlbase.h>
39 #pragma warning (pop)
40 #include "osl/diagnose.h"
42 namespace ole_adapter
44 //Wrapper for VARDESC
45 class VarDesc
47 VARDESC* operator = (const VarDesc*);
48 VarDesc(const VarDesc&);
49 // Construction
50 public:
51 CComPtr< ITypeInfo > m_pTypeInfo;
52 VARDESC* m_pVarDesc;
54 VarDesc(ITypeInfo* pTypeInfo) :
55 m_pVarDesc(NULL),
56 m_pTypeInfo(pTypeInfo)
58 OSL_ASSERT(pTypeInfo);
60 ~VarDesc()
62 if (m_pVarDesc != NULL)
64 m_pTypeInfo->ReleaseVarDesc(m_pVarDesc);
68 VARDESC* operator->()
70 return m_pVarDesc;
73 VARDESC** operator&()
75 return &m_pVarDesc;
78 operator VARDESC* ()
80 return m_pVarDesc;
84 //Wrapper for FUNCDESC structure
85 class FuncDesc
87 FUNCDESC* operator = (const FuncDesc &);
88 FuncDesc(const FuncDesc&);
89 CComPtr<ITypeInfo> m_pTypeInfo;
90 FUNCDESC * m_pFuncDesc;
92 public:
94 FuncDesc(ITypeInfo * pTypeInfo) :
95 m_pFuncDesc(NULL),
96 m_pTypeInfo(pTypeInfo)
98 OSL_ASSERT(pTypeInfo);
100 ~FuncDesc()
102 ReleaseFUNCDESC();
105 FUNCDESC* operator -> ()
107 return m_pFuncDesc;
110 FUNCDESC** operator & ()
112 return & m_pFuncDesc;
115 operator FUNCDESC* ()
117 return m_pFuncDesc;
120 FUNCDESC* operator = (FUNCDESC* pDesc)
122 ReleaseFUNCDESC();
123 m_pFuncDesc = pDesc;
124 return m_pFuncDesc;
126 FUNCDESC* Detach()
128 FUNCDESC* pDesc = m_pFuncDesc;
129 m_pFuncDesc = NULL;
130 return pDesc;
133 void ReleaseFUNCDESC()
135 if (m_pFuncDesc != NULL)
137 m_pTypeInfo->ReleaseFuncDesc(m_pFuncDesc);
139 m_pFuncDesc = NULL;
142 //Wrapper for EXCEPINFO structure
143 class ExcepInfo : public EXCEPINFO
145 EXCEPINFO* operator = (const ExcepInfo& );
146 ExcepInfo(const ExcepInfo &);
147 public:
148 ExcepInfo()
150 memset(this, 0, sizeof(ExcepInfo));
152 ~ExcepInfo()
154 if (bstrSource != NULL)
155 ::SysFreeString(bstrSource);
156 if (bstrDescription != NULL)
157 ::SysFreeString(bstrDescription);
158 if (bstrHelpFile != NULL)
159 ::SysFreeString(bstrHelpFile);
163 //Wrapper for TYPEATTR
164 class TypeAttr
166 TYPEATTR* operator = (const TypeAttr &);
167 TypeAttr(const TypeAttr &);
168 public:
169 CComPtr< ITypeInfo > m_pTypeInfo;
170 TYPEATTR* m_pTypeAttr;
172 TypeAttr(ITypeInfo* pTypeInfo) :
173 m_pTypeAttr( NULL ),
174 m_pTypeInfo( pTypeInfo )
176 OSL_ASSERT(pTypeInfo);
178 ~TypeAttr() throw()
180 if (m_pTypeAttr != NULL)
182 m_pTypeInfo->ReleaseTypeAttr(m_pTypeAttr);
186 TYPEATTR** operator&() throw()
188 return &m_pTypeAttr;
191 TYPEATTR* operator->() throw()
193 return m_pTypeAttr;
201 #endif