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 "jscriptclasses.hxx"
32 //========================================================================
34 //========================================================================
35 JScriptValue::JScriptValue(): m_bOutParam(0), m_bInOutParam(0)
39 JScriptValue::~JScriptValue()
44 // JScriptValue, IDispatch --------------------------------------------
45 STDMETHODIMP
JScriptValue::GetTypeInfoCount(UINT
* /*pctinfo*/)
50 // JScriptValue, IDispatch --------------------------------------------
51 STDMETHODIMP
JScriptValue::GetTypeInfo( UINT
/*iTInfo*/,
53 ITypeInfo
** /*ppTInfo*/)
58 // JScriptValue, IDispatch --------------------------------------------
59 STDMETHODIMP
JScriptValue::GetIDsOfNames( REFIID
/*riid*/,
70 CComBSTR
name(*rgszNames
);
73 if( name
== CComBSTR( L
"set") )
75 else if( name
== CComBSTR( L
"get") )
77 else if( name
== CComBSTR( L
"initoutparam") )
79 else if( name
== CComBSTR( L
"initinoutparam") )
82 ret
= DISP_E_UNKNOWNNAME
;
87 // JScriptValue, IDispatch --------------------------------------------
88 STDMETHODIMP
JScriptValue::Invoke( DISPID dispIdMember
,
92 DISPPARAMS
*pDispParams
,
94 EXCEPINFO
* /*pExcepInfo*/,
97 if( pDispParams
->cNamedArgs
)
98 return DISP_E_NONAMEDARGS
;
102 switch( dispIdMember
)
104 case 0: // DISPID_VALUE
105 if( wFlags
& DISPATCH_PROPERTYGET
&& pVarResult
)
107 if( FAILED( VariantCopy( pVarResult
, &m_varValue
)))
114 if( wFlags
& DISPATCH_METHOD
)
115 ret
= Set( pDispParams
->rgvarg
[1], pDispParams
->rgvarg
[0]);
117 ret
= DISP_E_EXCEPTION
;
120 if( wFlags
& DISPATCH_METHOD
)
121 ret
= Get( pVarResult
);
123 ret
= DISP_E_EXCEPTION
;
126 if( wFlags
& DISPATCH_METHOD
)
129 ret
= DISP_E_EXCEPTION
;
132 if( wFlags
& DISPATCH_METHOD
)
133 ret
= InitInOutParam( pDispParams
->rgvarg
[1], pDispParams
->rgvarg
[0]);
135 ret
= DISP_E_EXCEPTION
;
138 ret
= DISP_E_MEMBERNOTFOUND
;
145 // JScriptValue, IScriptOutParam-----------------------
146 STDMETHODIMP
JScriptValue::Set( VARIANT type
, VARIANT value
)
151 hr
= VariantCopyInd( &m_varValue
, &value
);
154 if( SUCCEEDED( hr
= VariantChangeType( &var
, &type
, 0, VT_BSTR
)))
155 m_bstrType
= var
.bstrVal
;
159 // JScriptValue, IScriptOutParam-----------------------
160 STDMETHODIMP
JScriptValue::Get( VARIANT
*val
)
165 HRESULT hr
= VariantCopy( val
, &m_varValue
);
170 STDMETHODIMP
JScriptValue::InitOutParam()
175 m_bInOutParam
= false;
180 STDMETHODIMP
JScriptValue::InitInOutParam( VARIANT type
, VARIANT value
)
186 return Set( type
, value
);
189 STDMETHODIMP
JScriptValue::IsOutParam( VARIANT_BOOL
* flag
)
194 *flag
= m_bOutParam
? VARIANT_TRUE
: VARIANT_FALSE
;
199 STDMETHODIMP
JScriptValue::IsInOutParam( VARIANT_BOOL
* flag
)
204 *flag
= m_bInOutParam
? VARIANT_TRUE
: VARIANT_FALSE
;
209 STDMETHODIMP
JScriptValue::GetValue( BSTR
* type
, VARIANT
*value
)
215 if( SUCCEEDED( hr
= m_bstrType
.CopyTo( type
)))
216 hr
= VariantCopy( value
, &m_varValue
);
221 //##########################################################################################
223 //##########################################################################################
225 JScriptOutParam::JScriptOutParam()
229 JScriptOutParam::~JScriptOutParam()
234 // JScriptOutParam, IDispatch --------------------------------------------
235 STDMETHODIMP
JScriptOutParam::GetTypeInfoCount(UINT
* /*pctinfo*/)
240 // JScriptOutParam, IDispatch --------------------------------------------
241 STDMETHODIMP
JScriptOutParam::GetTypeInfo( UINT
/*iTInfo*/,
243 ITypeInfo
** /*ppTInfo*/)
248 // JScriptOutParam, IDispatch --------------------------------------------
249 STDMETHODIMP
JScriptOutParam::GetIDsOfNames( REFIID
/*riid*/,
260 CComBSTR
name(*rgszNames
);
263 if( name
== CComBSTR( L
"0") )
266 ret
= DISP_E_UNKNOWNNAME
;
271 // JScriptOutParam, IDispatch --------------------------------------------
272 STDMETHODIMP
JScriptOutParam::Invoke( DISPID dispIdMember
,
276 DISPPARAMS
*pDispParams
,
278 EXCEPINFO
* /*pExcepInfo*/,
282 switch( dispIdMember
)
284 case 0: // DISPID_VALUE
285 if( wFlags
& DISPATCH_PROPERTYGET
&& pVarResult
)
287 if( FAILED( VariantCopy( pVarResult
, &m_varValue
)))
290 else if( wFlags
& DISPATCH_PROPERTYPUT
|| wFlags
& DISPATCH_PROPERTYPUTREF
)
293 if( FAILED( VariantCopyInd( &m_varValue
, &pDispParams
->rgvarg
[0])))
300 if( wFlags
& DISPATCH_PROPERTYGET
&& pVarResult
)
302 if( FAILED( VariantCopy( pVarResult
, &m_varValue
)))
305 else if( wFlags
& DISPATCH_PROPERTYPUT
|| wFlags
& DISPATCH_PROPERTYPUTREF
)
308 if( FAILED( VariantCopyInd( &m_varValue
, &pDispParams
->rgvarg
[0])))
316 ret
= DISP_E_MEMBERNOTFOUND
;