2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 15:18:56 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 10:46:38 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2005-09-29 11:41:24 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2005-09-29 11:41:24 +00:00
|
|
|
*
|
2008-04-11 10:46:38 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 10:46:38 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 10:46:38 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 10:46:38 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
2008-04-11 10:46:38 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 15:18:56 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 08:59:51 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_basic.hxx"
|
|
|
|
|
2000-09-18 15:18:56 +00:00
|
|
|
#include "propacc.hxx"
|
|
|
|
|
|
|
|
#include <tools/urlobj.hxx>
|
|
|
|
#include <tools/errcode.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/svarray.hxx>
|
2007-06-27 13:18:20 +00:00
|
|
|
#include <basic/sbstar.hxx>
|
2000-09-18 15:18:56 +00:00
|
|
|
#include <sbunoobj.hxx>
|
|
|
|
|
2007-06-05 14:10:29 +00:00
|
|
|
using com::sun::star::uno::Reference;
|
2000-09-18 15:18:56 +00:00
|
|
|
using namespace com::sun::star::uno;
|
|
|
|
using namespace com::sun::star::lang;
|
|
|
|
using namespace com::sun::star::beans;
|
|
|
|
using namespace cppu;
|
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Declaration conversion from Sbx to UNO with known target type
|
2002-04-29 10:26:00 +00:00
|
|
|
Any sbxToUnoValue( SbxVariable* pVar, const Type& rType, Property* pUnoProperty = NULL );
|
2000-09-18 15:18:56 +00:00
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
#ifdef WNT
|
|
|
|
#define CDECL _cdecl
|
|
|
|
#endif
|
2007-09-20 14:54:23 +00:00
|
|
|
#if defined(UNX) || defined(OS2)
|
2000-09-18 15:18:56 +00:00
|
|
|
#define CDECL
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int CDECL SbCompare_PropertyValues_Impl( const void *arg1, const void *arg2 )
|
|
|
|
{
|
|
|
|
return ((PropertyValue*)arg1)->Name.compareTo( ((PropertyValue*)arg2)->Name );
|
|
|
|
}
|
|
|
|
|
2006-06-19 16:39:43 +00:00
|
|
|
extern "C" int CDECL SbCompare_UString_PropertyValue_Impl( const void *arg1, const void *arg2 )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2008-06-24 15:02:14 +00:00
|
|
|
const ::rtl::OUString *pArg1 = (::rtl::OUString*) arg1;
|
2000-09-18 15:18:56 +00:00
|
|
|
const PropertyValue **pArg2 = (const PropertyValue**) arg2;
|
|
|
|
return pArg1->compareTo( (*pArg2)->Name );
|
|
|
|
}
|
|
|
|
|
|
|
|
int CDECL SbCompare_Properties_Impl( const void *arg1, const void *arg2 )
|
|
|
|
{
|
|
|
|
return ((Property*)arg1)->Name.compareTo( ((Property*)arg2)->Name );
|
|
|
|
}
|
|
|
|
|
2006-06-19 16:39:43 +00:00
|
|
|
extern "C" int CDECL SbCompare_UString_Property_Impl( const void *arg1, const void *arg2 )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2008-06-24 15:02:14 +00:00
|
|
|
const ::rtl::OUString *pArg1 = (::rtl::OUString*) arg1;
|
2000-09-18 15:18:56 +00:00
|
|
|
const Property *pArg2 = (Property*) arg2;
|
|
|
|
return pArg1->compareTo( pArg2->Name );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SbPropertyValues::SbPropertyValues()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SbPropertyValues::~SbPropertyValues()
|
|
|
|
{
|
|
|
|
_xInfo = Reference< XPropertySetInfo >();
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
for ( sal_uInt16 n = 0; n < _aPropVals.Count(); ++n )
|
2000-09-18 15:18:56 +00:00
|
|
|
delete _aPropVals.GetObject( n );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Reference< XPropertySetInfo > SbPropertyValues::getPropertySetInfo(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
// create on demand?
|
|
|
|
if ( !_xInfo.is() )
|
|
|
|
{
|
|
|
|
SbPropertySetInfo *pInfo = new SbPropertySetInfo( _aPropVals );
|
|
|
|
((SbPropertyValues*)this)->_xInfo = (XPropertySetInfo*)pInfo;
|
|
|
|
}
|
|
|
|
return _xInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int32 SbPropertyValues::GetIndex_Impl( const ::rtl::OUString &rPropName ) const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
PropertyValue **ppPV;
|
|
|
|
ppPV = (PropertyValue **)
|
|
|
|
bsearch( &rPropName, _aPropVals.GetData(), _aPropVals.Count(),
|
|
|
|
sizeof( PropertyValue* ),
|
|
|
|
SbCompare_UString_PropertyValue_Impl );
|
|
|
|
return ppPV ? ( (ppPV-_aPropVals.GetData()) / sizeof(ppPV) ) : USHRT_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SbPropertyValues::setPropertyValue(
|
2008-06-24 15:02:14 +00:00
|
|
|
const ::rtl::OUString& aPropertyName,
|
2000-09-18 15:18:56 +00:00
|
|
|
const Any& aValue)
|
2001-09-12 10:55:40 +00:00
|
|
|
throw (::com::sun::star::beans::UnknownPropertyException,
|
|
|
|
::com::sun::star::beans::PropertyVetoException,
|
|
|
|
::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::lang::WrappedTargetException,
|
|
|
|
::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int32 nIndex = GetIndex_Impl( aPropertyName );
|
2006-10-12 13:25:24 +00:00
|
|
|
PropertyValue *pPropVal = _aPropVals.GetObject(
|
2011-01-10 14:40:57 +01:00
|
|
|
sal::static_int_cast< sal_uInt16 >(nIndex));
|
2000-09-18 15:18:56 +00:00
|
|
|
pPropVal->Value = aValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Any SbPropertyValues::getPropertyValue(
|
2008-06-24 15:02:14 +00:00
|
|
|
const ::rtl::OUString& aPropertyName)
|
2001-09-12 10:55:40 +00:00
|
|
|
throw(::com::sun::star::beans::UnknownPropertyException,
|
|
|
|
::com::sun::star::lang::WrappedTargetException,
|
|
|
|
::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int32 nIndex = GetIndex_Impl( aPropertyName );
|
2000-09-18 15:18:56 +00:00
|
|
|
if ( nIndex != USHRT_MAX )
|
2006-10-12 13:25:24 +00:00
|
|
|
return _aPropVals.GetObject(
|
2011-01-10 14:40:57 +01:00
|
|
|
sal::static_int_cast< sal_uInt16 >(nIndex))->Value;
|
2000-09-18 15:18:56 +00:00
|
|
|
return Any();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SbPropertyValues::addPropertyChangeListener(
|
2008-06-24 15:02:14 +00:00
|
|
|
const ::rtl::OUString& aPropertyName,
|
2000-09-18 15:18:56 +00:00
|
|
|
const Reference< XPropertyChangeListener >& )
|
2001-09-12 10:55:40 +00:00
|
|
|
throw ()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-19 16:39:43 +00:00
|
|
|
(void)aPropertyName;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SbPropertyValues::removePropertyChangeListener(
|
2008-06-24 15:02:14 +00:00
|
|
|
const ::rtl::OUString& aPropertyName,
|
2000-09-18 15:18:56 +00:00
|
|
|
const Reference< XPropertyChangeListener >& )
|
2001-09-12 10:55:40 +00:00
|
|
|
throw ()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-19 16:39:43 +00:00
|
|
|
(void)aPropertyName;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SbPropertyValues::addVetoableChangeListener(
|
2008-06-24 15:02:14 +00:00
|
|
|
const ::rtl::OUString& aPropertyName,
|
2000-09-18 15:18:56 +00:00
|
|
|
const Reference< XVetoableChangeListener >& )
|
2001-09-12 10:55:40 +00:00
|
|
|
throw()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-19 16:39:43 +00:00
|
|
|
(void)aPropertyName;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SbPropertyValues::removeVetoableChangeListener(
|
2008-06-24 15:02:14 +00:00
|
|
|
const ::rtl::OUString& aPropertyName,
|
2000-09-18 15:18:56 +00:00
|
|
|
const Reference< XVetoableChangeListener >& )
|
2001-09-12 10:55:40 +00:00
|
|
|
throw()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-19 16:39:43 +00:00
|
|
|
(void)aPropertyName;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2001-09-12 10:55:40 +00:00
|
|
|
Sequence< PropertyValue > SbPropertyValues::getPropertyValues(void) throw (::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
Sequence<PropertyValue> aRet( _aPropVals.Count());
|
2011-01-10 14:40:57 +01:00
|
|
|
for ( sal_uInt16 n = 0; n < _aPropVals.Count(); ++n )
|
2000-09-18 15:18:56 +00:00
|
|
|
aRet.getArray()[n] = *_aPropVals.GetObject(n);
|
|
|
|
return aRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SbPropertyValues::setPropertyValues(const Sequence< PropertyValue >& rPropertyValues )
|
2001-09-12 10:55:40 +00:00
|
|
|
throw (::com::sun::star::beans::UnknownPropertyException,
|
|
|
|
::com::sun::star::beans::PropertyVetoException,
|
|
|
|
::com::sun::star::lang::IllegalArgumentException,
|
|
|
|
::com::sun::star::lang::WrappedTargetException,
|
|
|
|
::com::sun::star::uno::RuntimeException)
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
if ( _aPropVals.Count() )
|
|
|
|
throw PropertyExistException();
|
|
|
|
|
|
|
|
const PropertyValue *pPropVals = rPropertyValues.getConstArray();
|
|
|
|
for ( sal_Int16 n = 0; n < rPropertyValues.getLength(); ++n )
|
|
|
|
{
|
|
|
|
PropertyValue *pPropVal = new PropertyValue(pPropVals[n]);
|
|
|
|
_aPropVals.Insert( pPropVal, n );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//PropertySetInfoImpl
|
|
|
|
|
|
|
|
PropertySetInfoImpl::PropertySetInfoImpl()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int32 PropertySetInfoImpl::GetIndex_Impl( const ::rtl::OUString &rPropName ) const
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
Property *pP;
|
|
|
|
pP = (Property*)
|
|
|
|
bsearch( &rPropName, _aProps.getConstArray(), _aProps.getLength(),
|
|
|
|
sizeof( Property ),
|
|
|
|
SbCompare_UString_Property_Impl );
|
2011-01-10 14:40:57 +01:00
|
|
|
return pP ? sal::static_int_cast<sal_Int32>( (pP-_aProps.getConstArray()) / sizeof(pP) ) : -1;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
2001-09-12 10:55:40 +00:00
|
|
|
Sequence< Property > PropertySetInfoImpl::getProperties(void) throw()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return _aProps;
|
|
|
|
}
|
|
|
|
|
2008-06-24 15:02:14 +00:00
|
|
|
Property PropertySetInfoImpl::getPropertyByName(const ::rtl::OUString& Name) throw( RuntimeException )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-10-12 13:25:24 +00:00
|
|
|
sal_Int32 nIndex = GetIndex_Impl( Name );
|
2000-09-18 15:18:56 +00:00
|
|
|
if( USHRT_MAX != nIndex )
|
|
|
|
return _aProps.getConstArray()[ nIndex ];
|
|
|
|
return Property();
|
|
|
|
}
|
|
|
|
|
2008-06-24 15:02:14 +00:00
|
|
|
sal_Bool PropertySetInfoImpl::hasPropertyByName(const ::rtl::OUString& Name) throw( RuntimeException )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-10-12 13:25:24 +00:00
|
|
|
sal_Int32 nIndex = GetIndex_Impl( Name );
|
2000-09-18 15:18:56 +00:00
|
|
|
return USHRT_MAX != nIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
SbPropertySetInfo::SbPropertySetInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SbPropertySetInfo::SbPropertySetInfo( const SbPropertyValueArr_Impl &rPropVals )
|
|
|
|
{
|
|
|
|
aImpl._aProps.realloc( rPropVals.Count() );
|
2011-01-10 14:40:57 +01:00
|
|
|
for ( sal_uInt16 n = 0; n < rPropVals.Count(); ++n )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
Property &rProp = aImpl._aProps.getArray()[n];
|
|
|
|
const PropertyValue &rPropVal = *rPropVals.GetObject(n);
|
|
|
|
rProp.Name = rPropVal.Name;
|
|
|
|
rProp.Handle = rPropVal.Handle;
|
|
|
|
rProp.Type = getCppuVoidType();
|
|
|
|
rProp.Attributes = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SbPropertySetInfo::~SbPropertySetInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Sequence< Property > SbPropertySetInfo::getProperties(void) throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return aImpl.getProperties();
|
|
|
|
}
|
|
|
|
|
2008-06-24 15:02:14 +00:00
|
|
|
Property SbPropertySetInfo::getPropertyByName(const ::rtl::OUString& Name)
|
2000-09-18 15:18:56 +00:00
|
|
|
throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return aImpl.getPropertyByName( Name );
|
|
|
|
}
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Bool SbPropertySetInfo::hasPropertyByName(const ::rtl::OUString& Name)
|
2000-09-18 15:18:56 +00:00
|
|
|
throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return aImpl.hasPropertyByName( Name );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SbPropertyContainer::SbPropertyContainer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
SbPropertyContainer::~SbPropertyContainer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2008-06-24 15:02:14 +00:00
|
|
|
void SbPropertyContainer::addProperty(const ::rtl::OUString& Name,
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Int16 Attributes,
|
2000-09-18 15:18:56 +00:00
|
|
|
const Any& DefaultValue)
|
|
|
|
throw( PropertyExistException, IllegalTypeException,
|
|
|
|
IllegalArgumentException, RuntimeException )
|
|
|
|
{
|
2006-06-19 16:39:43 +00:00
|
|
|
(void)Name;
|
|
|
|
(void)Attributes;
|
|
|
|
(void)DefaultValue;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2008-06-24 15:02:14 +00:00
|
|
|
void SbPropertyContainer::removeProperty(const ::rtl::OUString& Name)
|
2000-09-18 15:18:56 +00:00
|
|
|
throw( UnknownPropertyException, RuntimeException )
|
|
|
|
{
|
2006-06-19 16:39:43 +00:00
|
|
|
(void)Name;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
// XPropertySetInfo
|
2001-09-12 10:55:40 +00:00
|
|
|
Sequence< Property > SbPropertyContainer::getProperties(void) throw ()
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
|
|
|
return aImpl.getProperties();
|
|
|
|
}
|
|
|
|
|
2008-06-24 15:02:14 +00:00
|
|
|
Property SbPropertyContainer::getPropertyByName(const ::rtl::OUString& Name)
|
2000-09-18 15:18:56 +00:00
|
|
|
throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return aImpl.getPropertyByName( Name );
|
|
|
|
}
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
sal_Bool SbPropertyContainer::hasPropertyByName(const ::rtl::OUString& Name)
|
2000-09-18 15:18:56 +00:00
|
|
|
throw( RuntimeException )
|
|
|
|
{
|
|
|
|
return aImpl.hasPropertyByName( Name );
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Sequence< PropertyValue > SbPropertyContainer::getPropertyValues(void)
|
|
|
|
{
|
|
|
|
return Sequence<PropertyValue>();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void SbPropertyContainer::setPropertyValues(const Sequence< PropertyValue >& PropertyValues_)
|
|
|
|
{
|
2006-06-19 16:39:43 +00:00
|
|
|
(void)PropertyValues_;
|
2000-09-18 15:18:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2011-01-10 14:40:57 +01:00
|
|
|
void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, sal_Bool bWrite )
|
2000-09-18 15:18:56 +00:00
|
|
|
{
|
2006-06-19 16:39:43 +00:00
|
|
|
(void)pBasic;
|
|
|
|
(void)bWrite;
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// We need at least one parameter
|
|
|
|
// TODO: In this case < 2 is not correct ;-)
|
2000-09-18 15:18:56 +00:00
|
|
|
if ( rPar.Count() < 2 )
|
|
|
|
{
|
|
|
|
StarBASIC::Error( SbERR_BAD_ARGUMENT );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Get class names of struct
|
2000-09-18 15:18:56 +00:00
|
|
|
String aServiceName( RTL_CONSTASCII_USTRINGPARAM("stardiv.uno.beans.PropertySet") );
|
|
|
|
|
|
|
|
Reference< XInterface > xInterface = (OWeakObject*) new SbPropertyValues();
|
|
|
|
|
|
|
|
SbxVariableRef refVar = rPar.Get(0);
|
|
|
|
if( xInterface.is() )
|
|
|
|
{
|
2009-04-25 00:18:20 +00:00
|
|
|
// Set PropertyValues
|
2000-09-18 15:18:56 +00:00
|
|
|
Any aArgAsAny = sbxToUnoValue( rPar.Get(1),
|
2002-04-29 10:26:00 +00:00
|
|
|
getCppuType( (Sequence<PropertyValue>*)0 ) );
|
2000-09-18 15:18:56 +00:00
|
|
|
Sequence<PropertyValue> *pArg =
|
|
|
|
(Sequence<PropertyValue>*) aArgAsAny.getValue();
|
|
|
|
Reference< XPropertyAccess > xPropAcc = Reference< XPropertyAccess >::query( xInterface );
|
|
|
|
xPropAcc->setPropertyValues( *pArg );
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Build a SbUnoObject and return it
|
2000-09-18 15:18:56 +00:00
|
|
|
Any aAny;
|
|
|
|
aAny <<= xInterface;
|
|
|
|
SbUnoObjectRef xUnoObj = new SbUnoObject( aServiceName, aAny );
|
|
|
|
if( xUnoObj->getUnoAny().getValueType().getTypeClass() != TypeClass_VOID )
|
|
|
|
{
|
2009-04-25 00:18:20 +00:00
|
|
|
// Return object
|
2000-09-18 15:18:56 +00:00
|
|
|
refVar->PutObject( (SbUnoObject*)xUnoObj );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-25 00:18:20 +00:00
|
|
|
// Object could not be created
|
2000-09-18 15:18:56 +00:00
|
|
|
refVar->PutObject( NULL );
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|