2010-10-12 08:53:47 -05:00
|
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 10:18:56 -05:00
|
|
|
|
/*************************************************************************
|
|
|
|
|
*
|
2008-04-11 06:06:04 -05:00
|
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 10:18:56 -05:00
|
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 10:18:56 -05:00
|
|
|
|
*
|
2008-04-11 06:06:04 -05:00
|
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 10:18:56 -05:00
|
|
|
|
*
|
2008-04-11 06:06:04 -05:00
|
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 10:18:56 -05:00
|
|
|
|
*
|
2008-04-11 06:06:04 -05: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 10:18:56 -05:00
|
|
|
|
*
|
2008-04-11 06:06:04 -05: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 10:18:56 -05:00
|
|
|
|
*
|
2008-04-11 06:06:04 -05: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 10:18:56 -05:00
|
|
|
|
*
|
|
|
|
|
************************************************************************/
|
|
|
|
|
|
2006-09-17 04:06:49 -05:00
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
|
#include "precompiled_basic.hxx"
|
|
|
|
|
|
2000-09-18 10:18:56 -05:00
|
|
|
|
#include <stdlib.h>
|
2003-03-18 09:28:40 -06:00
|
|
|
|
#include <rtl/math.hxx>
|
2010-04-16 07:10:50 -05:00
|
|
|
|
#include <basic/sbuno.hxx>
|
2000-09-18 10:18:56 -05:00
|
|
|
|
#include "runtime.hxx"
|
|
|
|
|
#include "sbintern.hxx"
|
|
|
|
|
#include "iosys.hxx"
|
|
|
|
|
#include "image.hxx"
|
2005-01-28 09:09:47 -06:00
|
|
|
|
#include "sbunoobj.hxx"
|
2010-03-29 03:39:35 -05:00
|
|
|
|
#include "errobject.hxx"
|
2000-09-18 10:18:56 -05:00
|
|
|
|
|
2007-08-30 04:01:53 -05:00
|
|
|
|
bool checkUnoObjectType( SbUnoObject* refVal,
|
|
|
|
|
const String& aClass );
|
|
|
|
|
|
2000-09-18 10:18:56 -05:00
|
|
|
|
// Laden einer numerischen Konstanten (+ID)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxVariable* p = new SbxVariable( SbxDOUBLE );
|
|
|
|
|
|
|
|
|
|
// #57844 Lokalisierte Funktion benutzen
|
2006-11-03 08:11:10 -06:00
|
|
|
|
String aStr = pImg->GetString( static_cast<short>( nOp1 ) );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
// Auch , zulassen !!!
|
2011-01-10 07:40:57 -06:00
|
|
|
|
sal_uInt16 iComma = aStr.Search( ',' );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
if( iComma != STRING_NOTFOUND )
|
|
|
|
|
{
|
|
|
|
|
String aStr1 = aStr.Copy( 0, iComma );
|
|
|
|
|
String aStr2 = aStr.Copy( iComma + 1 );
|
|
|
|
|
aStr = aStr1;
|
|
|
|
|
aStr += '.';
|
|
|
|
|
aStr += aStr2;
|
|
|
|
|
}
|
2003-03-18 09:28:40 -06:00
|
|
|
|
double n = ::rtl::math::stringToDouble( aStr, '.', ',', NULL, NULL );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
|
|
|
|
|
p->PutDouble( n );
|
|
|
|
|
PushVar( p );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Laden einer Stringkonstanten (+ID)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepLOADSC( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxVariable* p = new SbxVariable;
|
2006-11-03 08:11:10 -06:00
|
|
|
|
p->PutString( pImg->GetString( static_cast<short>( nOp1 ) ) );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
PushVar( p );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Immediate Load (+Wert)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepLOADI( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxVariable* p = new SbxVariable;
|
2011-01-10 07:40:57 -06:00
|
|
|
|
p->PutInteger( static_cast<sal_Int16>( nOp1 ) );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
PushVar( p );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Speichern eines named Arguments in Argv (+Arg-Nr ab 1!)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepARGN( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
if( !refArgv )
|
|
|
|
|
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
|
|
|
|
|
else
|
|
|
|
|
{
|
2006-11-03 08:11:10 -06:00
|
|
|
|
String aAlias( pImg->GetString( static_cast<short>( nOp1 ) ) );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
SbxVariableRef pVal = PopVar();
|
2010-10-06 04:16:27 -05:00
|
|
|
|
if( bVBAEnabled && ( pVal->ISA(SbxMethod) || pVal->ISA(SbUnoProperty) || pVal->ISA(SbProcedureProperty) ) )
|
|
|
|
|
{
|
|
|
|
|
// named variables ( that are Any especially properties ) can be empty at this point and need a broadcast
|
|
|
|
|
if ( pVal->GetType() == SbxEMPTY )
|
|
|
|
|
pVal->Broadcast( SBX_HINT_DATAWANTED );
|
|
|
|
|
// Methoden und Properties evaluieren!
|
|
|
|
|
SbxVariable* pRes = new SbxVariable( *pVal );
|
|
|
|
|
pVal = pRes;
|
|
|
|
|
}
|
2000-09-18 10:18:56 -05:00
|
|
|
|
refArgv->Put( pVal, nArgc );
|
|
|
|
|
refArgv->PutAlias( aAlias, nArgc++ );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Konvertierung des Typs eines Arguments in Argv fuer DECLARE-Fkt. (+Typ)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepARGTYP( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
if( !refArgv )
|
|
|
|
|
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-01-10 07:40:57 -06:00
|
|
|
|
sal_Bool bByVal = (nOp1 & 0x8000) != 0; // Ist BYVAL verlangt?
|
2000-09-18 10:18:56 -05:00
|
|
|
|
SbxDataType t = (SbxDataType) (nOp1 & 0x7FFF);
|
|
|
|
|
SbxVariable* pVar = refArgv->Get( refArgv->Count() - 1 ); // letztes Arg
|
|
|
|
|
|
2011-03-11 19:42:58 -06:00
|
|
|
|
// BYVAL pr<70>fen
|
|
|
|
|
if( pVar->GetRefCount() > 2 ) // 2 ist normal f<>r BYVAL
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
// Parameter ist eine Referenz
|
|
|
|
|
if( bByVal )
|
|
|
|
|
{
|
|
|
|
|
// Call by Value ist verlangt -> Kopie anlegen
|
|
|
|
|
pVar = new SbxVariable( *pVar );
|
|
|
|
|
pVar->SetFlag( SBX_READWRITE );
|
|
|
|
|
refExprStk->Put( pVar, refArgv->Count() - 1 );
|
|
|
|
|
}
|
|
|
|
|
else
|
2011-03-11 19:42:58 -06:00
|
|
|
|
pVar->SetFlag( SBX_REFERENCE ); // Ref-Flag f<>r DllMgr
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Parameter ist KEINE Referenz
|
|
|
|
|
if( bByVal )
|
|
|
|
|
pVar->ResetFlag( SBX_REFERENCE ); // Keine Referenz -> OK
|
|
|
|
|
else
|
|
|
|
|
Error( SbERR_BAD_PARAMETERS ); // Referenz verlangt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( pVar->GetType() != t )
|
|
|
|
|
{
|
|
|
|
|
// Variant, damit richtige Konvertierung
|
|
|
|
|
// Ausserdem Fehler, wenn SbxBYREF
|
|
|
|
|
pVar->Convert( SbxVARIANT );
|
|
|
|
|
pVar->Convert( t );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// String auf feste Laenge bringen (+Laenge)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepPAD( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxVariable* p = GetTOS();
|
|
|
|
|
String& s = (String&)(const String&) *p;
|
|
|
|
|
if( s.Len() > nOp1 )
|
2006-11-03 08:11:10 -06:00
|
|
|
|
s.Erase( static_cast<xub_StrLen>( nOp1 ) );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
else
|
2006-11-03 08:11:10 -06:00
|
|
|
|
s.Expand( static_cast<xub_StrLen>( nOp1 ), ' ' );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sprung (+Target)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepJUMP( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
2009-07-10 07:03:42 -05:00
|
|
|
|
#ifdef DBG_UTIL
|
2006-11-01 09:16:55 -06:00
|
|
|
|
// #QUESTION shouln't this be
|
2011-01-10 07:40:57 -06:00
|
|
|
|
// if( (sal_uInt8*)( nOp1+pImagGetCode() ) >= pImg->GetCodeSize() )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
if( nOp1 >= pImg->GetCodeSize() )
|
|
|
|
|
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
|
|
|
|
|
#endif
|
2011-01-10 07:40:57 -06:00
|
|
|
|
pCode = (const sal_uInt8*) pImg->GetCode() + nOp1;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TOS auswerten, bedingter Sprung (+Target)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepJUMPT( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxVariableRef p = PopVar();
|
|
|
|
|
if( p->GetBool() )
|
|
|
|
|
StepJUMP( nOp1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TOS auswerten, bedingter Sprung (+Target)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepJUMPF( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxVariableRef p = PopVar();
|
2010-10-06 04:16:27 -05:00
|
|
|
|
// In a test e.g. If Null then
|
|
|
|
|
// will evaluate Null will act as if False
|
|
|
|
|
if( ( bVBAEnabled && p->IsNull() ) || !p->GetBool() )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
StepJUMP( nOp1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TOS auswerten, Sprung in JUMP-Tabelle (+MaxVal)
|
|
|
|
|
// Sieht so aus:
|
|
|
|
|
// ONJUMP 2
|
|
|
|
|
// JUMP target1
|
|
|
|
|
// JUMP target2
|
|
|
|
|
// ...
|
|
|
|
|
//Falls im Operanden 0x8000 gesetzt ist, Returnadresse pushen (ON..GOSUB)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepONJUMP( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxVariableRef p = PopVar();
|
2011-01-10 07:40:57 -06:00
|
|
|
|
sal_Int16 n = p->GetInteger();
|
2000-09-18 10:18:56 -05:00
|
|
|
|
if( nOp1 & 0x8000 )
|
|
|
|
|
{
|
|
|
|
|
nOp1 &= 0x7FFF;
|
2006-11-01 09:16:55 -06:00
|
|
|
|
//PushGosub( pCode + 3 * nOp1 );
|
|
|
|
|
PushGosub( pCode + 5 * nOp1 );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
2011-01-10 07:40:57 -06:00
|
|
|
|
if( n < 1 || static_cast<sal_uInt32>(n) > nOp1 )
|
|
|
|
|
n = static_cast<sal_Int16>( nOp1 + 1 );
|
|
|
|
|
//nOp1 = (sal_uInt32) ( (const char*) pCode - pImg->GetCode() ) + 3 * --n;
|
|
|
|
|
nOp1 = (sal_uInt32) ( (const char*) pCode - pImg->GetCode() ) + 5 * --n;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
StepJUMP( nOp1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UP-Aufruf (+Target)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepGOSUB( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
PushGosub( pCode );
|
|
|
|
|
if( nOp1 >= pImg->GetCodeSize() )
|
|
|
|
|
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
|
2011-01-10 07:40:57 -06:00
|
|
|
|
pCode = (const sal_uInt8*) pImg->GetCode() + nOp1;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// UP-Return (+0 oder Target)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepRETURN( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
PopGosub();
|
|
|
|
|
if( nOp1 )
|
|
|
|
|
StepJUMP( nOp1 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// FOR-Variable testen (+Endlabel)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
if( !pForStk )
|
2005-01-28 09:09:47 -06:00
|
|
|
|
{
|
2000-09-18 10:18:56 -05:00
|
|
|
|
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
|
2005-01-28 09:09:47 -06:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool bEndLoop = false;
|
|
|
|
|
switch( pForStk->eForType )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
2005-01-28 09:09:47 -06:00
|
|
|
|
case FOR_TO:
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
2005-01-28 09:09:47 -06:00
|
|
|
|
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;
|
2011-01-10 07:40:57 -06:00
|
|
|
|
sal_Int32 nCount = xItemArray->Count32();
|
2005-01-28 09:09:47 -06:00
|
|
|
|
if( pForStk->nCurCollectionIndex < nCount )
|
|
|
|
|
{
|
|
|
|
|
SbxVariable* pRes = xItemArray->Get32( pForStk->nCurCollectionIndex );
|
|
|
|
|
pForStk->nCurCollectionIndex++;
|
|
|
|
|
(*pForStk->refVar) = *pRes;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bEndLoop = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
2005-01-28 09:09:47 -06:00
|
|
|
|
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 );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tos+1 <= Tos+2 <= Tos, 2xremove (+Target)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepCASETO( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
if( !refCaseStk || !refCaseStk->Count() )
|
|
|
|
|
StarBASIC::FatalError( SbERR_INTERNAL_ERROR );
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SbxVariableRef xTo = PopVar();
|
|
|
|
|
SbxVariableRef xFrom = PopVar();
|
|
|
|
|
SbxVariableRef xCase = refCaseStk->Get( refCaseStk->Count() - 1 );
|
|
|
|
|
if( *xCase >= *xFrom && *xCase <= *xTo )
|
|
|
|
|
StepJUMP( nOp1 );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fehler-Handler
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepERRHDL( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
2011-01-10 07:40:57 -06:00
|
|
|
|
const sal_uInt8* p = pCode;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
StepJUMP( nOp1 );
|
|
|
|
|
pError = pCode;
|
|
|
|
|
pCode = p;
|
|
|
|
|
pInst->aErrorMsg = String();
|
2006-10-12 08:31:12 -05:00
|
|
|
|
pInst->nErr = 0;
|
|
|
|
|
pInst->nErl = 0;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
nError = 0;
|
2010-03-29 03:39:35 -05:00
|
|
|
|
SbxErrObject::getUnoErrObject()->Clear();
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Resume nach Fehlern (+0=statement, 1=next or Label)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepRESUME( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
// AB #32714 Resume ohne Error? -> Fehler
|
|
|
|
|
if( !bInError )
|
|
|
|
|
{
|
|
|
|
|
Error( SbERR_BAD_RESUME );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if( nOp1 )
|
|
|
|
|
{
|
|
|
|
|
// Code-Zeiger auf naechstes Statement setzen
|
2011-01-10 07:40:57 -06:00
|
|
|
|
sal_uInt16 n1, n2;
|
|
|
|
|
pCode = pMod->FindNextStmnt( pErrCode, n1, n2, sal_True, pImg );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
pCode = pErrStmnt;
|
2010-03-29 03:39:35 -05:00
|
|
|
|
if ( pError ) // current in error handler ( and got a Resume Next statment )
|
|
|
|
|
SbxErrObject::getUnoErrObject()->Clear();
|
2000-09-18 10:18:56 -05:00
|
|
|
|
|
|
|
|
|
if( nOp1 > 1 )
|
|
|
|
|
StepJUMP( nOp1 );
|
|
|
|
|
pInst->aErrorMsg = String();
|
2006-10-12 08:31:12 -05:00
|
|
|
|
pInst->nErr = 0;
|
|
|
|
|
pInst->nErl = 0;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
nError = 0;
|
2011-01-10 07:40:57 -06:00
|
|
|
|
bInError = sal_False;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
|
|
|
|
|
// Error-Stack loeschen
|
|
|
|
|
SbErrorStack*& rErrStack = GetSbData()->pErrStack;
|
|
|
|
|
delete rErrStack;
|
|
|
|
|
rErrStack = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Kanal schliessen (+Kanal, 0=Alle)
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepCLOSE( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
2006-10-12 08:31:12 -05:00
|
|
|
|
SbError err;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
if( !nOp1 )
|
|
|
|
|
pIosys->Shutdown();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
err = pIosys->GetError();
|
|
|
|
|
if( !err )
|
|
|
|
|
{
|
|
|
|
|
pIosys->Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
err = pIosys->GetError();
|
|
|
|
|
Error( err );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Zeichen ausgeben (+char)
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepPRCHAR( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
ByteString s( (char) nOp1 );
|
|
|
|
|
pIosys->Write( s );
|
|
|
|
|
Error( pIosys->GetError() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check, ob TOS eine bestimmte Objektklasse ist (+StringID)
|
|
|
|
|
|
2005-03-29 04:52:50 -06:00
|
|
|
|
bool SbiRuntime::implIsClass( SbxObject* pObj, const String& aClass )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
2005-03-29 04:52:50 -06:00
|
|
|
|
bool bRet = true;
|
2004-03-17 06:37:26 -06:00
|
|
|
|
|
2005-03-29 04:52:50 -06:00
|
|
|
|
if( aClass.Len() != 0 )
|
|
|
|
|
{
|
|
|
|
|
bRet = pObj->IsClass( aClass );
|
|
|
|
|
if( !bRet )
|
|
|
|
|
bRet = aClass.EqualsIgnoreCaseAscii( String( RTL_CONSTASCII_USTRINGPARAM("object") ) );
|
|
|
|
|
if( !bRet )
|
|
|
|
|
{
|
|
|
|
|
String aObjClass = pObj->GetClassName();
|
|
|
|
|
SbModule* pClassMod = pCLASSFAC->FindClass( aObjClass );
|
|
|
|
|
SbClassData* pClassData;
|
|
|
|
|
if( pClassMod && (pClassData=pClassMod->pClassData) != NULL )
|
|
|
|
|
{
|
|
|
|
|
SbxVariable* pClassVar =
|
|
|
|
|
pClassData->mxIfaces->Find( aClass, SbxCLASS_DONTCARE );
|
|
|
|
|
bRet = (pClassVar != NULL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return bRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal,
|
2010-06-15 13:02:53 -05:00
|
|
|
|
const String& aClass, bool bRaiseErrors, bool bDefault )
|
2005-03-29 04:52:50 -06:00
|
|
|
|
{
|
2010-06-15 13:02:53 -05:00
|
|
|
|
bool bOk = bDefault;
|
2005-03-29 04:52:50 -06:00
|
|
|
|
|
|
|
|
|
SbxDataType t = refVal->GetType();
|
|
|
|
|
if( t == SbxOBJECT )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxObject* pObj;
|
2005-03-29 04:52:50 -06:00
|
|
|
|
SbxVariable* pVal = (SbxVariable*)refVal;
|
|
|
|
|
if( pVal->IsA( TYPE(SbxObject) ) )
|
|
|
|
|
pObj = (SbxObject*) pVal;
|
2000-09-18 10:18:56 -05:00
|
|
|
|
else
|
|
|
|
|
{
|
2005-03-29 04:52:50 -06:00
|
|
|
|
pObj = (SbxObject*) refVal->GetObject();
|
2000-09-18 10:18:56 -05:00
|
|
|
|
if( pObj && !pObj->IsA( TYPE(SbxObject) ) )
|
|
|
|
|
pObj = NULL;
|
|
|
|
|
}
|
2005-03-29 04:52:50 -06:00
|
|
|
|
if( pObj )
|
2004-03-17 06:37:26 -06:00
|
|
|
|
{
|
2005-03-29 04:52:50 -06:00
|
|
|
|
if( !implIsClass( pObj, aClass ) )
|
|
|
|
|
{
|
2007-08-30 04:01:53 -05:00
|
|
|
|
if ( bVBAEnabled && pObj->IsA( TYPE(SbUnoObject) ) )
|
|
|
|
|
{
|
|
|
|
|
SbUnoObject* pUnoObj = PTR_CAST(SbUnoObject,pObj);
|
|
|
|
|
bOk = checkUnoObjectType( pUnoObj, aClass );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
bOk = false;
|
|
|
|
|
if ( !bOk )
|
|
|
|
|
{
|
|
|
|
|
if( bRaiseErrors )
|
|
|
|
|
Error( SbERR_INVALID_USAGE_OBJECT );
|
|
|
|
|
}
|
2005-03-29 04:52:50 -06:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-06-15 13:02:53 -05:00
|
|
|
|
bOk = true;
|
|
|
|
|
|
2005-03-29 04:52:50 -06:00
|
|
|
|
SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pObj);
|
|
|
|
|
if( pClassModuleObject != NULL )
|
|
|
|
|
pClassModuleObject->triggerInitializeEvent();
|
|
|
|
|
}
|
2004-03-17 06:37:26 -06:00
|
|
|
|
}
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
2005-03-29 04:52:50 -06:00
|
|
|
|
else
|
|
|
|
|
{
|
2007-08-30 04:01:53 -05:00
|
|
|
|
if ( !bVBAEnabled )
|
|
|
|
|
{
|
|
|
|
|
if( bRaiseErrors )
|
|
|
|
|
Error( SbERR_NEEDS_OBJECT );
|
|
|
|
|
bOk = false;
|
|
|
|
|
}
|
2005-03-29 04:52:50 -06:00
|
|
|
|
}
|
|
|
|
|
return bOk;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt )
|
2005-03-29 04:52:50 -06:00
|
|
|
|
{
|
|
|
|
|
SbxVariableRef refVal = PopVar();
|
|
|
|
|
SbxVariableRef refVar = PopVar();
|
2006-11-03 08:11:10 -06:00
|
|
|
|
String aClass( pImg->GetString( static_cast<short>( nOp1 ) ) );
|
2005-03-29 04:52:50 -06:00
|
|
|
|
|
|
|
|
|
bool bOk = checkClass_Impl( refVal, aClass, true );
|
|
|
|
|
if( bOk )
|
2007-08-30 04:01:53 -05:00
|
|
|
|
StepSET_Impl( refVal, refVar, bHandleDflt ); // don't do handle dflt prop for a "proper" set
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepVBASETCLASS( sal_uInt32 nOp1 )
|
2007-08-30 04:01:53 -05:00
|
|
|
|
{
|
|
|
|
|
StepSETCLASS_impl( nOp1, false );
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepSETCLASS( sal_uInt32 nOp1 )
|
2007-08-30 04:01:53 -05:00
|
|
|
|
{
|
|
|
|
|
StepSETCLASS_impl( nOp1, true );
|
2005-03-29 04:52:50 -06:00
|
|
|
|
}
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepTESTCLASS( sal_uInt32 nOp1 )
|
2005-03-29 04:52:50 -06:00
|
|
|
|
{
|
|
|
|
|
SbxVariableRef xObjVal = PopVar();
|
2006-11-03 08:11:10 -06:00
|
|
|
|
String aClass( pImg->GetString( static_cast<short>( nOp1 ) ) );
|
2010-06-15 13:02:53 -05:00
|
|
|
|
bool bDefault = !bVBAEnabled;
|
|
|
|
|
bool bOk = checkClass_Impl( xObjVal, aClass, false, bDefault );
|
2005-03-29 04:52:50 -06:00
|
|
|
|
|
|
|
|
|
SbxVariable* pRet = new SbxVariable;
|
|
|
|
|
pRet->PutBool( bOk );
|
|
|
|
|
PushVar( pRet );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Library fuer anschliessenden Declare-Call definieren
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepLIB( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
2006-11-03 08:11:10 -06:00
|
|
|
|
aLibName = pImg->GetString( static_cast<short>( nOp1 ) );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TOS wird um BASE erhoeht, BASE davor gepusht (+BASE)
|
|
|
|
|
// Dieser Opcode wird vor DIM/REDIM-Anweisungen gepusht,
|
|
|
|
|
// wenn nur ein Index angegeben wurde.
|
|
|
|
|
|
2011-01-10 07:40:57 -06:00
|
|
|
|
void SbiRuntime::StepBASED( sal_uInt32 nOp1 )
|
2000-09-18 10:18:56 -05:00
|
|
|
|
{
|
|
|
|
|
SbxVariable* p1 = new SbxVariable;
|
|
|
|
|
SbxVariableRef x2 = PopVar();
|
2004-03-17 06:37:26 -06:00
|
|
|
|
|
|
|
|
|
// #109275 Check compatiblity mode
|
|
|
|
|
bool bCompatible = ((nOp1 & 0x8000) != 0);
|
2011-01-10 07:40:57 -06:00
|
|
|
|
sal_uInt16 uBase = static_cast<sal_uInt16>(nOp1 & 1); // Can only be 0 or 1
|
2004-03-17 06:37:26 -06:00
|
|
|
|
p1->PutInteger( uBase );
|
|
|
|
|
if( !bCompatible )
|
|
|
|
|
x2->Compute( SbxPLUS, *p1 );
|
2000-09-18 10:18:56 -05:00
|
|
|
|
PushVar( x2 ); // erst die Expr
|
|
|
|
|
PushVar( p1 ); // dann die Base
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-10-12 08:53:47 -05:00
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|