Kaydet (Commit) e824c2db authored tarafından Rüdiger Timm's avatar Rüdiger Timm

INTEGRATION: CWS npower1 (1.36.22); FILE MERGED

2006/04/13 09:10:34 npower 1.36.22.2: #i64315# changed ArrayWrapper detetection code to better match oleautomation
2006/04/12 11:25:07 npower 1.36.22.1: #i64317#, #i64315# changes to add new option 'VBASupport' & uno->basic multi-dim array support
üst 9cadbdfc
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: sbunoobj.cxx,v $ * $RCSfile: sbunoobj.cxx,v $
* *
* $Revision: 1.37 $ * $Revision: 1.38 $
* *
* last change: $Author: rt $ $Date: 2006-05-05 08:37:24 $ * last change: $Author: rt $ $Date: 2006-05-05 10:11:09 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <com/sun/star/script/ArrayWrapper.hpp>
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/uno/DeploymentException.hpp> #include <com/sun/star/uno/DeploymentException.hpp>
...@@ -467,6 +468,86 @@ SbxDataType unoToSbxType( const Reference< XIdlClass >& xIdlClass ) ...@@ -467,6 +468,86 @@ SbxDataType unoToSbxType( const Reference< XIdlClass >& xIdlClass )
} }
return eRetType; return eRetType;
} }
void unoToSbxValue( SbxVariable* pVar, const Any& aValue );
static void implSequenceToMultiDimArray( SbxDimArray*& pArray, Sequence< sal_Int32 >& indices, Sequence< sal_Int32 >& sizes, const Any& aValue, sal_Int32& dimension, sal_Bool bIsZeroIndex )
{
Type aType = aValue.getValueType();
TypeClass eTypeClass = aType.getTypeClass();
sal_Int32 indicesIndex = indices.getLength() -1;
sal_Int32 dimCopy = dimension;
if ( eTypeClass == TypeClass_SEQUENCE )
{
Reference< XIdlClass > xIdlTargetClass = TypeToIdlClass( aType );
Reference< XIdlArray > xIdlArray = xIdlTargetClass->getArray();
sal_Int32 nLen = xIdlArray->getLen( aValue );
for ( sal_Int32 index = 0; index < nLen; ++index )
{
Any aElementAny = xIdlArray->get( aValue, (UINT32)index );
// This detects the dimension were currently processing
if ( dimCopy == dimension )
{
++dimCopy;
if ( sizes.getLength() < dimCopy )
{
sizes.realloc( sizes.getLength() + 1 );
sizes[ sizes.getLength() - 1 ] = nLen;
indices.realloc( indices.getLength() + 1 );
indicesIndex = indices.getLength() - 1;
}
}
if ( bIsZeroIndex )
indices[ dimCopy - 1 ] = index;
else
indices[ dimCopy - 1] = index + 1;
implSequenceToMultiDimArray( pArray, indices, sizes, aElementAny, dimCopy, bIsZeroIndex );
}
}
else
{
if ( indices.getLength() < 1 )
{
// Should never ever get here ( indices.getLength()
// should equal number of dimensions in the array )
// And that should at least be 1 !
// #QUESTION is there a better error?
StarBASIC::Error( SbERR_INVALID_OBJECT );
return;
}
if ( !pArray )
{
SbxDataType eSbxElementType = unoToSbxType( aValue.getValueTypeClass() );
pArray = new SbxDimArray( eSbxElementType );
sal_Int32 nIndexLen = indices.getLength();
// Dimension the array
for ( sal_Int32 index = 0; index < nIndexLen; ++index )
{
if ( bIsZeroIndex )
pArray->unoAddDim32( 0, sizes[ index ] - 1);
else
pArray->unoAddDim32( 1, sizes[ index ] );
}
}
if ( pArray )
{
SbxDataType eSbxElementType = unoToSbxType( aValue.getValueTypeClass() );
SbxVariableRef xVar = new SbxVariable( eSbxElementType );
unoToSbxValue( (SbxVariable*)xVar, aValue );
sal_Int32* pIndices = indices.getArray();
pArray->Put32( (SbxVariable*)xVar, pIndices );
}
}
}
void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
{ {
...@@ -499,12 +580,33 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) ...@@ -499,12 +580,33 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
} }
} }
break; break;
// Interfaces und Structs muessen in ein SbUnoObject gewrappt werden // Interfaces und Structs muessen in ein SbUnoObject gewrappt werden
case TypeClass_INTERFACE: case TypeClass_INTERFACE:
case TypeClass_STRUCT: case TypeClass_STRUCT:
{ {
if( eTypeClass == TypeClass_STRUCT ) if( eTypeClass == TypeClass_STRUCT )
{
ArrayWrapper aWrap;
if ( (aValue >>= aWrap) )
{
SbxDimArray* pArray = NULL;
Sequence< sal_Int32 > indices;
Sequence< sal_Int32 > sizes;
sal_Int32 dimension = 0;
implSequenceToMultiDimArray( pArray, indices, sizes, aWrap.Array, dimension, aWrap.IsZeroIndex );
if ( pArray )
{
SbxDimArrayRef xArray = pArray;
USHORT nFlags = pVar->GetFlags();
pVar->ResetFlag( SBX_FIXED );
pVar->PutObject( (SbxDimArray*)xArray );
pVar->SetFlags( nFlags );
}
else
pVar->PutEmpty();
break;
}
else
{ {
SbiInstance* pInst = pINST; SbiInstance* pInst = pINST;
if( pInst && pInst->IsCompatibility() ) if( pInst && pInst->IsCompatibility() )
...@@ -539,7 +641,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue ) ...@@ -539,7 +641,7 @@ void unoToSbxValue( SbxVariable* pVar, const Any& aValue )
} }
} }
} }
}
// SbUnoObject instanzieren // SbUnoObject instanzieren
String aName; String aName;
SbUnoObject* pSbUnoObject = new SbUnoObject( aName, aValue ); SbUnoObject* pSbUnoObject = new SbUnoObject( aName, aValue );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment