Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / extensions / source / ole / windata.hxx
blobed673c465dc89237473ec908ae54134039f62670
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_EXTENSIONS_SOURCE_OLE_WINDATA_HXX
20 #define INCLUDED_EXTENSIONS_SOURCE_OLE_WINDATA_HXX
22 #include <oleidl.h>
24 #if defined __clang__
25 #pragma clang diagnostic push
26 #pragma clang diagnostic ignored "-Wall"
27 #pragma clang diagnostic ignored "-Wextra"
28 #pragma clang diagnostic ignored "-Wignored-attributes"
29 #pragma clang diagnostic ignored "-Wint-to-pointer-cast"
30 #pragma clang diagnostic ignored "-Winvalid-noreturn"
31 #pragma clang diagnostic ignored "-Wmicrosoft"
32 #pragma clang diagnostic ignored "-Wnon-pod-varargs"
33 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
34 #endif
36 #include <atlbase.h>
38 #if defined __clang__
39 #pragma clang diagnostic pop
40 #endif
42 #include <osl/diagnose.h>
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 explicit VarDesc(ITypeInfo* pTypeInfo) :
55 m_pTypeInfo(pTypeInfo),
56 m_pVarDesc(nullptr)
58 OSL_ASSERT(pTypeInfo);
60 ~VarDesc()
62 if (m_pVarDesc != nullptr)
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 explicit FuncDesc(ITypeInfo * pTypeInfo) :
95 m_pTypeInfo(pTypeInfo),
96 m_pFuncDesc(nullptr)
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 = nullptr;
130 return pDesc;
133 void ReleaseFUNCDESC()
135 if (m_pFuncDesc != nullptr)
137 m_pTypeInfo->ReleaseFuncDesc(m_pFuncDesc);
139 m_pFuncDesc = nullptr;
142 //Wrapper for EXCEPINFO structure
143 class ExcepInfo : public EXCEPINFO
145 EXCEPINFO* operator = (const ExcepInfo& );
146 ExcepInfo(const ExcepInfo &);
147 public:
148 ExcepInfo()
149 : EXCEPINFO{}
152 ~ExcepInfo()
154 if (bstrSource != nullptr)
155 ::SysFreeString(bstrSource);
156 if (bstrDescription != nullptr)
157 ::SysFreeString(bstrDescription);
158 if (bstrHelpFile != nullptr)
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 explicit TypeAttr(ITypeInfo* pTypeInfo) :
173 m_pTypeInfo( pTypeInfo ),
174 m_pTypeAttr( nullptr )
176 OSL_ASSERT(pTypeInfo);
178 ~TypeAttr() throw()
180 if (m_pTypeAttr != nullptr)
182 m_pTypeInfo->ReleaseTypeAttr(m_pTypeAttr);
186 TYPEATTR** operator&() throw()
188 return &m_pTypeAttr;
191 TYPEATTR* operator->() throw()
193 return m_pTypeAttr;
197 #endif
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */