1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: unotypewrapper.cxx,v $
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 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_extensions.hxx"
33 #include "unotypewrapper.hxx"
34 #include "rtl/ustring.hxx"
37 bool createUnoTypeWrapper(BSTR sTypeName
, VARIANT
* pVar
)
40 OSL_ASSERT(sTypeName
&& pVar
);
41 CComObject
< UnoTypeWrapper
>* pObj
;
43 if( SUCCEEDED( CComObject
<UnoTypeWrapper
>::CreateInstance( &pObj
)))
46 pVar
->vt
= VT_DISPATCH
;
48 pVar
->pdispVal
= CComQIPtr
<IDispatch
, &__uuidof(IDispatch
)>(pObj
->GetUnknown());
50 pVar
->pdispVal
= CComQIPtr
<IDispatch
>(pObj
->GetUnknown());
52 //now set the value, e.i. the name of the type
54 CComQIPtr
<IUnoTypeWrapper
, &__uuidof(IUnoTypeWrapper
)> spType(pVar
->pdispVal
);
56 CComQIPtr
<IUnoTypeWrapper
> spType(pVar
->pdispVal
);
59 if (SUCCEEDED(spType
->put_Name(sTypeName
)))
68 bool createUnoTypeWrapper(const rtl::OUString
& sTypeName
, VARIANT
* pVar
)
70 CComBSTR
bstr(reinterpret_cast<LPCOLESTR
>(sTypeName
.getStr()));
71 return createUnoTypeWrapper(bstr
, pVar
);
74 UnoTypeWrapper::UnoTypeWrapper()
78 UnoTypeWrapper::~UnoTypeWrapper()
83 // UnoTypeWrapper, IDispatch --------------------------------------------
84 STDMETHODIMP
UnoTypeWrapper::GetTypeInfoCount(UINT
* /*pctinfo*/)
89 // UnoTypeWrapper, IDispatch --------------------------------------------
90 STDMETHODIMP
UnoTypeWrapper::GetTypeInfo( UINT
/*iTInfo*/,
92 ITypeInfo
** /*ppTInfo*/)
97 // UnoTypeWrapper, IDispatch --------------------------------------------
98 STDMETHODIMP
UnoTypeWrapper::GetIDsOfNames( REFIID
/*riid*/,
108 CComBSTR
name(*rgszNames
);
111 if( name
== CComBSTR( L
"name") )
112 *rgDispId
= DISPID_VALUE
;
114 ret
= DISP_E_UNKNOWNNAME
;
119 // UnoTypeWrapper, IDispatch --------------------------------------------
120 STDMETHODIMP
UnoTypeWrapper::Invoke( DISPID dispIdMember
,
124 DISPPARAMS
*pDispParams
,
126 EXCEPINFO
* /*pExcepInfo*/,
129 if (pDispParams
== NULL
)
130 return DISP_E_EXCEPTION
;
132 if( pDispParams
->cNamedArgs
)
133 return DISP_E_NONAMEDARGS
;
137 switch( dispIdMember
)
139 case DISPID_VALUE
: // DISPID_VALUE
140 if (wFlags
& DISPATCH_PROPERTYGET
)
142 if (pVarResult
== NULL
)
147 get_Name( & pVarResult
->bstrVal
);
148 pVarResult
->vt
= VT_BSTR
;
152 ret
= DISP_E_MEMBERNOTFOUND
;
159 // IUnoTypeWrapper-----------------------
160 STDMETHODIMP
UnoTypeWrapper::put_Name(BSTR val
)
169 // (UnoTypeWrapper-----------------------
170 STDMETHODIMP
UnoTypeWrapper::get_Name(BSTR
*pVal
)
176 *pVal
= m_sName
.Copy();