summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2005-01-28 15:09:47 +0000
committerRüdiger Timm <rt@openoffice.org>2005-01-28 15:09:47 +0000
commit41d127861bc4b01ad4ab62f5c0c36a9ed3929d30 (patch)
tree062c354acf8ce78f0bf844b303bf043a54d5b621 /basic
parentb1e398f5215844576f91eec6b9ad9d14e660ad72 (diff)
INTEGRATION: CWS ab13fixes (1.7.82); FILE MERGED
2005/01/20 16:47:11 ab 1.7.82.2: #118116# SbiRuntime::StepTestFor(): Fixed for each handling 2005/01/17 16:54:44 ab 1.7.82.1: #118116# SbiRuntime::StepTESTFOR() adapted to for each loops
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/step1.cxx103
1 files changed, 96 insertions, 7 deletions
diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx
index eabf778a8ad1..287b0e0a1636 100644
--- a/basic/source/runtime/step1.cxx
+++ b/basic/source/runtime/step1.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: step1.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
*
- * last change: $Author: obo $ $Date: 2004-03-17 13:37:26 $
+ * last change: $Author: rt $ $Date: 2005-01-28 16:09:47 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -67,6 +67,7 @@
#include "sbintern.hxx"
#include "iosys.hxx"
#include "image.hxx"
+#include "sbunoobj.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBRUNTIME, SBRUNTIME_CODE )
@@ -258,18 +259,106 @@ void SbiRuntime::StepRETURN( USHORT nOp1 )
// FOR-Variable testen (+Endlabel)
+void unoToSbxValue( SbxVariable* pVar, const Any& aValue );
+
void SbiRuntime::StepTESTFOR( USHORT nOp1 )
{
if( !pForStk )
+ {
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
- else
+ return;
+ }
+
+ ForType eForType = pForStk->eForType;
+ bool bEndLoop = false;
+ switch( pForStk->eForType )
{
- SbxOperator eOp = ( pForStk->refInc->GetDouble() < 0 ) ? SbxLT : SbxGT;
- if( pForStk->refVar->Compare( eOp, *pForStk->refEnd ) )
+ case FOR_TO:
{
- PopFor();
- StepJUMP( nOp1 );
+ SbxOperator eOp = ( pForStk->refInc->GetDouble() < 0 ) ? SbxLT : SbxGT;
+ if( pForStk->refVar->Compare( eOp, *pForStk->refEnd ) )
+ bEndLoop = true;
+ break;
+ }
+ case FOR_EACH_ARRAY:
+ {
+ SbiForStack* p = pForStk;
+ if( p->pArrayCurIndices == NULL )
+ {
+ bEndLoop = true;
+ }
+ else
+ {
+ SbxDimArray* pArray = (SbxDimArray*)(SbxVariable*)p->refEnd;
+ short nDims = pArray->GetDims();
+
+ // Empty array?
+ if( nDims == 1 && p->pArrayLowerBounds[0] > p->pArrayUpperBounds[0] )
+ {
+ bEndLoop = true;
+ break;
+ }
+ SbxVariable* pVal = pArray->Get32( p->pArrayCurIndices );
+ *(p->refVar) = *pVal;
+
+ bool bFoundNext = false;
+ for( short i = 0 ; i < nDims ; i++ )
+ {
+ if( p->pArrayCurIndices[i] < p->pArrayUpperBounds[i] )
+ {
+ bFoundNext = true;
+ p->pArrayCurIndices[i]++;
+ for( short j = i - 1 ; j >= 0 ; j-- )
+ p->pArrayCurIndices[j] = p->pArrayLowerBounds[j];
+ break;
+ }
+ }
+ if( !bFoundNext )
+ {
+ delete[] p->pArrayCurIndices;
+ p->pArrayCurIndices = NULL;
+ }
+ }
+ break;
}
+ case FOR_EACH_COLLECTION:
+ {
+ BasicCollection* pCollection = (BasicCollection*)(SbxVariable*)pForStk->refEnd;
+ SbxArrayRef xItemArray = pCollection->xItemArray;
+ INT32 nCount = xItemArray->Count32();
+ if( pForStk->nCurCollectionIndex < nCount )
+ {
+ SbxVariable* pRes = xItemArray->Get32( pForStk->nCurCollectionIndex );
+ pForStk->nCurCollectionIndex++;
+ (*pForStk->refVar) = *pRes;
+ }
+ else
+ {
+ bEndLoop = true;
+ }
+ break;
+ }
+ case FOR_EACH_XENUMERATION:
+ {
+ SbiForStack* p = pForStk;
+ if( p->xEnumeration->hasMoreElements() )
+ {
+ Any aElem = p->xEnumeration->nextElement();
+ SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
+ unoToSbxValue( (SbxVariable*)xVar, aElem );
+ (*pForStk->refVar) = *xVar;
+ }
+ else
+ {
+ bEndLoop = true;
+ }
+ break;
+ }
+ }
+ if( bEndLoop )
+ {
+ PopFor();
+ StepJUMP( nOp1 );
}
}