1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
30 #include "unotypewrapper.hxx"
31 #include "rtl/ustring.hxx"
34 bool createUnoTypeWrapper(BSTR sTypeName
, VARIANT
* pVar
)
37 OSL_ASSERT(sTypeName
&& pVar
);
38 CComObject
< UnoTypeWrapper
>* pObj
;
40 if( SUCCEEDED( CComObject
<UnoTypeWrapper
>::CreateInstance( &pObj
)))
43 pVar
->vt
= VT_DISPATCH
;
45 pVar
->pdispVal
= CComQIPtr
<IDispatch
, &__uuidof(IDispatch
)>(pObj
->GetUnknown());
47 pVar
->pdispVal
= CComQIPtr
<IDispatch
>(pObj
->GetUnknown());
49 //now set the value, e.i. the name of the type
51 CComQIPtr
<IUnoTypeWrapper
, &__uuidof(IUnoTypeWrapper
)> spType(pVar
->pdispVal
);
53 CComQIPtr
<IUnoTypeWrapper
> spType(pVar
->pdispVal
);
56 if (SUCCEEDED(spType
->put_Name(sTypeName
)))
65 bool createUnoTypeWrapper(const rtl::OUString
& sTypeName
, VARIANT
* pVar
)
67 CComBSTR
bstr(reinterpret_cast<LPCOLESTR
>(sTypeName
.getStr()));
68 return createUnoTypeWrapper(bstr
, pVar
);
71 UnoTypeWrapper::UnoTypeWrapper()
75 UnoTypeWrapper::~UnoTypeWrapper()
80 // UnoTypeWrapper, IDispatch --------------------------------------------
81 STDMETHODIMP
UnoTypeWrapper::GetTypeInfoCount(UINT
* /*pctinfo*/)
86 // UnoTypeWrapper, IDispatch --------------------------------------------
87 STDMETHODIMP
UnoTypeWrapper::GetTypeInfo( UINT
/*iTInfo*/,
89 ITypeInfo
** /*ppTInfo*/)
94 // UnoTypeWrapper, IDispatch --------------------------------------------
95 STDMETHODIMP
UnoTypeWrapper::GetIDsOfNames( REFIID
/*riid*/,
105 CComBSTR
name(*rgszNames
);
108 if( name
== CComBSTR( L
"name") )
109 *rgDispId
= DISPID_VALUE
;
111 ret
= DISP_E_UNKNOWNNAME
;
116 // UnoTypeWrapper, IDispatch --------------------------------------------
117 STDMETHODIMP
UnoTypeWrapper::Invoke( DISPID dispIdMember
,
121 DISPPARAMS
*pDispParams
,
123 EXCEPINFO
* /*pExcepInfo*/,
126 if (pDispParams
== NULL
)
127 return DISP_E_EXCEPTION
;
129 if( pDispParams
->cNamedArgs
)
130 return DISP_E_NONAMEDARGS
;
134 switch( dispIdMember
)
136 case DISPID_VALUE
: // DISPID_VALUE
137 if (wFlags
& DISPATCH_PROPERTYGET
)
139 if (pVarResult
== NULL
)
144 get_Name( & pVarResult
->bstrVal
);
145 pVarResult
->vt
= VT_BSTR
;
149 ret
= DISP_E_MEMBERNOTFOUND
;
156 // IUnoTypeWrapper-----------------------
157 STDMETHODIMP
UnoTypeWrapper::put_Name(BSTR val
)
166 // (UnoTypeWrapper-----------------------
167 STDMETHODIMP
UnoTypeWrapper::get_Name(BSTR
*pVal
)
173 *pVal
= m_sName
.Copy();