diff options
author | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-10-26 09:26:36 +0200 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2012-11-03 20:24:27 -0500 |
commit | c5b7d8f9d9b9a3c74334af620879e99ee1858679 (patch) | |
tree | 331ec4e923ac6454e07d183ce0eaaf47f1986a85 /basic | |
parent | basic: convert StepPAD to OUString (diff) | |
download | core-c5b7d8f9d9b9a3c74334af620879e99ee1858679.tar.gz core-c5b7d8f9d9b9a3c74334af620879e99ee1858679.zip |
basic migration to OUString
Change-Id: I1f9403174b3779801d91ba20d846191ed9a09eed
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/sb.cxx | 2 | ||||
-rw-r--r-- | basic/source/inc/runtime.hxx | 4 | ||||
-rw-r--r-- | basic/source/runtime/step1.cxx | 25 | ||||
-rw-r--r-- | basic/source/runtime/step2.cxx | 220 |
4 files changed, 180 insertions, 71 deletions
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 3a31b5a105e9..bb375ee8d055 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -602,7 +602,7 @@ SbxObject* SbTypeFactory::CreateObject( const rtl::OUString& rClassName ) return pRet; } -SbxObject* createUserTypeImpl( const String& rClassName ) +SbxObject* createUserTypeImpl( const OUString& rClassName ) { SbxObject* pRetObj = GetSbData()->pTypeFac->CreateObject( rClassName ); return pRetObj; diff --git a/basic/source/inc/runtime.hxx b/basic/source/inc/runtime.hxx index 86e2828db131..005f262b81b8 100644 --- a/basic/source/inc/runtime.hxx +++ b/basic/source/inc/runtime.hxx @@ -377,7 +377,7 @@ class SbiRuntime void StepPARAM( sal_uInt32, sal_uInt32), StepCREATE( sal_uInt32, sal_uInt32 ); void StepCALL( sal_uInt32, sal_uInt32 ), StepCALLC( sal_uInt32, sal_uInt32 ); void StepCASEIS( sal_uInt32, sal_uInt32 ), StepSTMNT( sal_uInt32, sal_uInt32 ); - SbxVariable* StepSTATIC_Impl( String& aName, SbxDataType& t ); + SbxVariable* StepSTATIC_Impl( OUString& aName, SbxDataType& t ); void StepOPEN( sal_uInt32, sal_uInt32 ), StepSTATIC( sal_uInt32, sal_uInt32 ); void StepTCREATE(sal_uInt32,sal_uInt32), StepDCREATE(sal_uInt32,sal_uInt32); void StepGLOBAL_P( sal_uInt32, sal_uInt32 ),StepFIND_G( sal_uInt32, sal_uInt32 ); @@ -413,7 +413,7 @@ public: SbiForStack* FindForStackItemForCollection( class BasicCollection* pCollection ); - SbxBase* FindElementExtern( const String& rName ); + SbxBase* FindElementExtern( const OUString& rName ); static bool isVBAEnabled(); }; diff --git a/basic/source/runtime/step1.cxx b/basic/source/runtime/step1.cxx index 483d912107be..feee72c0db8c 100644 --- a/basic/source/runtime/step1.cxx +++ b/basic/source/runtime/step1.cxx @@ -30,7 +30,7 @@ #include "sbunoobj.hxx" #include "errobject.hxx" -bool checkUnoObjectType( SbUnoObject* refVal, const ::rtl::OUString& aClass ); +bool checkUnoObjectType( SbUnoObject* refVal, const OUString& aClass ); // loading a numeric constant (+ID) @@ -78,7 +78,7 @@ void SbiRuntime::StepARGN( sal_uInt32 nOp1 ) StarBASIC::FatalError( SbERR_INTERNAL_ERROR ); else { - String aAlias( pImg->GetString( static_cast<short>( nOp1 ) ) ); + OUString aAlias( pImg->GetString( static_cast<short>( nOp1 ) ) ); SbxVariableRef pVal = PopVar(); if( bVBAEnabled && ( pVal->ISA(SbxMethod) || pVal->ISA(SbUnoProperty) || pVal->ISA(SbProcedureProperty) ) ) { @@ -361,7 +361,7 @@ void SbiRuntime::StepERRHDL( sal_uInt32 nOp1 ) StepJUMP( nOp1 ); pError = pCode; pCode = p; - pInst->aErrorMsg = String(); + pInst->aErrorMsg = OUString(); pInst->nErr = 0; pInst->nErl = 0; nError = 0; @@ -391,7 +391,7 @@ void SbiRuntime::StepRESUME( sal_uInt32 nOp1 ) if( nOp1 > 1 ) StepJUMP( nOp1 ); - pInst->aErrorMsg = String(); + pInst->aErrorMsg = OUString(); pInst->nErr = 0; pInst->nErl = 0; nError = 0; @@ -420,14 +420,14 @@ void SbiRuntime::StepCLOSE( sal_uInt32 nOp1 ) void SbiRuntime::StepPRCHAR( sal_uInt32 nOp1 ) { - rtl::OString s(static_cast<sal_Char>(nOp1)); + OString s(static_cast<sal_Char>(nOp1)); pIosys->Write( s ); Error( pIosys->GetError() ); } // check whether TOS is a certain object class (+StringID) -bool SbiRuntime::implIsClass( SbxObject* pObj, const ::rtl::OUString& aClass ) +bool SbiRuntime::implIsClass( SbxObject* pObj, const OUString& aClass ) { bool bRet = true; @@ -438,13 +438,12 @@ bool SbiRuntime::implIsClass( SbxObject* pObj, const ::rtl::OUString& aClass ) bRet = aClass.equalsIgnoreAsciiCaseAsciiL( RTL_CONSTASCII_STRINGPARAM("object") ); if( !bRet ) { - String aObjClass = pObj->GetClassName(); + OUString aObjClass = pObj->GetClassName(); SbModule* pClassMod = GetSbData()->pClassFac->FindClass( aObjClass ); SbClassData* pClassData; if( pClassMod && (pClassData=pClassMod->pClassData) != NULL ) { - SbxVariable* pClassVar = - pClassData->mxIfaces->Find( aClass, SbxCLASS_DONTCARE ); + SbxVariable* pClassVar = pClassData->mxIfaces->Find( aClass, SbxCLASS_DONTCARE ); bRet = (pClassVar != NULL); } } @@ -453,7 +452,7 @@ bool SbiRuntime::implIsClass( SbxObject* pObj, const ::rtl::OUString& aClass ) } bool SbiRuntime::checkClass_Impl( const SbxVariableRef& refVal, - const ::rtl::OUString& aClass, bool bRaiseErrors, bool bDefault ) + const OUString& aClass, bool bRaiseErrors, bool bDefault ) { bool bOk = bDefault; @@ -519,11 +518,13 @@ void SbiRuntime::StepSETCLASS_impl( sal_uInt32 nOp1, bool bHandleDflt ) { SbxVariableRef refVal = PopVar(); SbxVariableRef refVar = PopVar(); - String aClass( pImg->GetString( static_cast<short>( nOp1 ) ) ); + OUString aClass( pImg->GetString( static_cast<short>( nOp1 ) ) ); bool bOk = checkClass_Impl( refVal, aClass, true ); if( bOk ) + { StepSET_Impl( refVal, refVar, bHandleDflt ); // don't do handle dflt prop for a "proper" set + } } void SbiRuntime::StepVBASETCLASS( sal_uInt32 nOp1 ) @@ -539,7 +540,7 @@ void SbiRuntime::StepSETCLASS( sal_uInt32 nOp1 ) void SbiRuntime::StepTESTCLASS( sal_uInt32 nOp1 ) { SbxVariableRef xObjVal = PopVar(); - String aClass( pImg->GetString( static_cast<short>( nOp1 ) ) ); + OUString aClass( pImg->GetString( static_cast<short>( nOp1 ) ) ); bool bDefault = !bVBAEnabled; bool bOk = checkClass_Impl( xObjVal, aClass, false, bDefault ); diff --git a/basic/source/runtime/step2.cxx b/basic/source/runtime/step2.cxx index 5c70c6e2e3d0..df132dd91f6a 100644 --- a/basic/source/runtime/step2.cxx +++ b/basic/source/runtime/step2.cxx @@ -41,21 +41,23 @@ using namespace com::sun::star::script; using com::sun::star::uno::Reference; -SbxVariable* getVBAConstant( const String& rName ); +SbxVariable* getVBAConstant( const OUString& rName ); // the bits in the String-ID: // 0x8000 - Argv is reserved -SbxVariable* SbiRuntime::FindElement - ( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError nNotFound, bool bLocal, bool bStatic ) +SbxVariable* SbiRuntime::FindElement( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, + SbError nNotFound, bool bLocal, bool bStatic ) { bool bIsVBAInterOp = SbiRuntime::isVBAEnabled(); if( bIsVBAInterOp ) { StarBASIC* pMSOMacroRuntimeLib = GetSbData()->pMSOMacroRuntimLib; if( pMSOMacroRuntimeLib != NULL ) + { pMSOMacroRuntimeLib->ResetFlag( SBX_EXTSEARCH ); + } } SbxVariable* pElem = NULL; @@ -68,32 +70,36 @@ SbxVariable* SbiRuntime::FindElement { bool bFatalError = false; SbxDataType t = (SbxDataType) nOp2; - String aName( pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ) ); + OUString aName( pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ) ); // Hacky capture of Evaluate [] syntax // this should be tackled I feel at the pcode level - if ( bIsVBAInterOp && aName.Search('[') == 0 ) + if ( bIsVBAInterOp && aName.indexOf((sal_Unicode)'[') == 0 ) { // emulate pcode here StepARGC(); // psuedo StepLOADSC - String sArg = aName.Copy( 1, aName.Len() - 2 ); + OUString sArg = aName.copy( 1, aName.getLength() - 2 ); SbxVariable* p = new SbxVariable; p->PutString( sArg ); PushVar( p ); StepARGV(); nOp1 = nOp1 | 0x8000; // indicate params are present - aName = rtl::OUString("Evaluate"); + aName = OUString("Evaluate"); } if( bLocal ) { if ( bStatic ) { if ( pMeth ) + { pElem = pMeth->GetStatics()->Find( aName, SbxCLASS_DONTCARE ); + } } if ( !pElem ) + { pElem = refLocals->Find( aName, SbxCLASS_DONTCARE ); + } } if( !pElem ) { @@ -108,8 +114,9 @@ SbxVariable* SbiRuntime::FindElement { SbiInstance* pInst_ = GetSbData()->pInst; if( pInst_ && pInst_->IsCompatibility() && pObj != pElem->GetParent() ) + { pElem = NULL; // Found but in wrong module! - + } // Interfaces: Use SBX_EXTFOUND } } @@ -127,9 +134,13 @@ SbxVariable* SbiRuntime::FindElement // Try Find in VBA symbols space pElem = rBasic.VBAFind( aName, SbxCLASS_DONTCARE ); if ( pElem ) + { bSetName = false; // don't overwrite uno name + } else + { pElem = VBAConstantHelper::instance().getVBAConstant( aName ); + } } if( !pElem ) @@ -159,7 +170,9 @@ SbxVariable* SbiRuntime::FindElement // #72382 save locally, all variables that have been declared // implicit would become global automatically otherwise! if ( bSetName ) + { pElem->SetName( aName ); + } refLocals->Put( pElem, refLocals->Count() ); } } @@ -169,7 +182,9 @@ SbxVariable* SbiRuntime::FindElement // not there and not in the object? // don't establish if that thing has parameters! if( nOp1 & 0x8000 ) + { bFatalError = true; + } // else, if there are parameters, use different error code if( !bLocal || pImg->GetFlag( SBIMG_EXPLICIT ) ) @@ -179,13 +194,17 @@ SbxVariable* SbiRuntime::FindElement if( !( nOp1 & 0x8000 ) && nNotFound == SbERR_PROC_UNDEFINED ) + { nNotFound = SbERR_VAR_UNDEFINED; + } } if( bFatalError ) { // #39108 use dummy variable instead of fatal error if( !xDummyVar.Is() ) + { xDummyVar = new SbxVariable( SbxVARIANT ); + } pElem = xDummyVar; ClearArgvStack(); @@ -195,12 +214,16 @@ SbxVariable* SbiRuntime::FindElement else { if ( bStatic ) + { pElem = StepSTATIC_Impl( aName, t ); + } if ( !pElem ) { pElem = new SbxVariable( t ); if( t != SbxVARIANT ) + { pElem->SetFlag( SBX_FIXED ); + } pElem->SetName( aName ); refLocals->Put( pElem, refLocals->Count() ); } @@ -221,7 +244,9 @@ SbxVariable* SbiRuntime::FindElement { if( t != SbxVARIANT && t != t2 && t >= SbxINTEGER && t <= SbxSTRING ) + { pElem->SetType( t ), bSet = true; + } } // assign pElem to a Ref, to delete a temp-var if applicable SbxVariableRef refTemp = pElem; @@ -244,7 +269,9 @@ SbxVariable* SbiRuntime::FindElement pNew->SetFlag( SBX_READWRITE ); if( bSet ) + { pElem->SetType( t2 ); + } pElem = pNew; } // consider index-access for UnoObjects @@ -265,23 +292,25 @@ SbxVariable* SbiRuntime::FindElement } // for current scope (e. g. query from BASIC-IDE) -SbxBase* SbiRuntime::FindElementExtern( const String& rName ) +SbxBase* SbiRuntime::FindElementExtern( const OUString& rName ) { // don't expect pMeth to be != 0, as there are none set // in the RunInit yet SbxVariable* pElem = NULL; - if( !pMod || !rName.Len() ) + if( !pMod || !rName.getLength() ) + { return NULL; - + } if( refLocals ) + { pElem = refLocals->Find( rName, SbxCLASS_DONTCARE ); - + } if ( !pElem && pMeth ) { // for statics, set the method's name in front - String aMethName = pMeth->GetName(); - aMethName += ':'; + OUString aMethName = pMeth->GetName(); + aMethName += ":"; aMethName += rName; pElem = pMod->Find(aMethName, SbxCLASS_DONTCARE); } @@ -303,7 +332,7 @@ SbxBase* SbiRuntime::FindElementExtern( const String& rName ) { // Parameter is missing pElem = new SbxVariable( SbxSTRING ); - pElem->PutString( String( RTL_CONSTASCII_USTRINGPARAM("<missing parameter>" ) ) ); + pElem->PutString( OUString("<missing parameter>")); } else { @@ -334,7 +363,9 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 ) if( nOp1 & 0x8000 ) { if( !refArgv ) + { StarBASIC::FatalError( SbERR_INTERNAL_ERROR ); + } bool bHasNamed = false; sal_uInt16 i; sal_uInt16 nArgCount = refArgv->Count(); @@ -369,13 +400,15 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 ) sal_uInt16 nCurPar = 1; AutomationNamedArgsSbxArray* pArg = new AutomationNamedArgsSbxArray( nArgCount ); - ::rtl::OUString* pNames = pArg->getNames().getArray(); + OUString* pNames = pArg->getNames().getArray(); for( i = 1 ; i < nArgCount ; i++ ) { SbxVariable* pVar = refArgv->Get( i ); - const String& rName = refArgv->GetAlias( i ); - if( rName.Len() ) + const OUString& rName = refArgv->GetAlias( i ); + if( rName.getLength() ) + { pNames[i] = rName; + } pArg->Put( pVar, nCurPar++ ); } refArgv = pArg; @@ -396,22 +429,30 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 ) Reference< XInterface > x = *(Reference< XInterface >*)aAny.getValue(); Reference< XDefaultMethod > xDfltMethod( x, UNO_QUERY ); - rtl::OUString sDefaultMethod; + OUString sDefaultMethod; if ( xDfltMethod.is() ) + { sDefaultMethod = xDfltMethod->getDefaultMethodName(); + } if ( !sDefaultMethod.isEmpty() ) { SbxVariable* meth = pUnoObj->Find( sDefaultMethod, SbxCLASS_METHOD ); if( meth != NULL ) + { pInfo = meth->GetInfo(); + } if( pInfo ) + { bError_ = false; + } } } } } if( bError_ ) + { Error( SbERR_NO_NAMED_ARGS ); + } } else { @@ -420,8 +461,8 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 ) for( i = 1 ; i < nArgCount ; i++ ) { SbxVariable* pVar = refArgv->Get( i ); - const String& rName = refArgv->GetAlias( i ); - if( rName.Len() ) + const OUString& rName = refArgv->GetAlias( i ); + if( rName.getLength() ) { // nCurPar is set to the found parameter sal_uInt16 j = 1; @@ -451,7 +492,9 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 ) PopArgv(); } else + { p->SetParameters( NULL ); + } } // getting an array element @@ -482,13 +525,17 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) pElem = new SbxVariable; } else + { pElem = pArray->Get( pPar->Get( 1 )->GetInteger() ); + } } } // #42940, set parameter 0 to NULL so that var doesn't contain itself if( pPar ) + { pPar->Put( NULL, 0 ); + } } // consider index-access for UnoObjects else if( pElem->GetType() == SbxOBJECT && !pElem->ISA(SbxMethod) && ( !bVBAEnabled || ( bVBAEnabled && !pElem->ISA(SbxProperty) ) ) ) @@ -544,7 +591,7 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) aAny <<= xRet; // #67173 don't specify a name so that the real class name is entered - String aName; + OUString aName; SbxObjectRef xWrapper = (SbxObject*)new SbUnoObject( aName, aAny ); pElem->PutObject( xWrapper ); } @@ -556,15 +603,18 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) } else { - rtl::OUString sDefaultMethod; + OUString sDefaultMethod; Reference< XDefaultMethod > xDfltMethod( x, UNO_QUERY ); if ( xDfltMethod.is() ) + { sDefaultMethod = xDfltMethod->getDefaultMethodName(); + } else if( xIndexAccess.is() ) - sDefaultMethod = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "getByIndex" ) ); - + { + sDefaultMethod = OUString( RTL_CONSTASCII_USTRINGPARAM( "getByIndex" ) ); + } if ( !sDefaultMethod.isEmpty() ) { SbxVariable* meth = pUnoObj->Find( sDefaultMethod, SbxCLASS_METHOD ); @@ -594,7 +644,9 @@ SbxVariable* SbiRuntime::CheckArray( SbxVariable* pElem ) { SbxArray* pParam = pElem->GetParameters(); if( pParam != NULL && !pElem->IsSet( SBX_VAR_TO_DIM ) ) + { Error( SbERR_NO_OBJECT ); + } } } } @@ -613,7 +665,9 @@ void SbiRuntime::StepFIND_Impl( SbxObject* pObj, sal_uInt32 nOp1, sal_uInt32 nOp2, SbError nNotFound, bool bLocal, bool bStatic ) { if( !refLocals ) + { refLocals = new SbxArray; + } PushVar( FindElement( pObj, nOp1, nOp2, nNotFound, bLocal, bStatic ) ); } // loading a local/global variable (+StringID+type) @@ -629,12 +683,15 @@ void SbiRuntime::StepFIND_CM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pMod); if( pClassModuleObject ) + { pMod->SetFlag( SBX_GBLSEARCH ); - + } StepFIND_Impl( pMod, nOp1, nOp2, SbERR_PROC_UNDEFINED, true ); if( pClassModuleObject ) + { pMod->ResetFlag( SBX_GBLSEARCH ); + } } void SbiRuntime::StepFIND_STATIC( sal_uInt32 nOp1, sal_uInt32 nOp2 ) @@ -661,8 +718,9 @@ void SbiRuntime::StepELEM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // ActiveComponent.Selection(0).Text // #74254 now per list if( pObj ) + { SaveRef( (SbxVariable*)pObj ); - + } PushVar( FindElement( pObj, nOp1, nOp2, SbERR_NO_METHOD, false ) ); } @@ -690,13 +748,18 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) (t == SbxOBJECT || t == SbxSTRING) ) { if( t == SbxOBJECT ) + { p->PutObject( NULL ); + } else - p->PutString( String() ); + { + p->PutString( OUString() ); + } } else + { p->PutErr( 448 ); // like in VB: Error-Code 448 (SbERR_NAMED_NOT_FOUND) - + } refParams->Put( p, iLoop ); iLoop--; } @@ -720,7 +783,7 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) pParam->nUserData & 0xffff ); if( nDefaultId > 0 ) { - String aDefaultStr = pImg->GetString( nDefaultId ); + OUString aDefaultStr = pImg->GetString( nDefaultId ); p = new SbxVariable(); p->PutString( aDefaultStr ); refParams->Put( p, i ); @@ -730,7 +793,9 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) } } if( !bOpt ) + { Error( SbERR_NOT_OPTIONAL ); + } } else if( t != SbxVARIANT && (SbxDataType)(p->GetType() & 0x0FFF ) != t ) { @@ -739,7 +804,9 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) *q = *p; p = q; if ( i ) + { refParams->Put( p, i ); + } } SetupArgs( p, nOp1 ); PushVar( CheckArray( p ) ); @@ -750,7 +817,9 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 nOp2 ) void SbiRuntime::StepCASEIS( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { if( !refCaseStk || !refCaseStk->Count() ) + { StarBASIC::FatalError( SbERR_INTERNAL_ERROR ); + } else { SbxVariableRef xComp = PopVar(); @@ -765,28 +834,36 @@ void SbiRuntime::StepCASEIS( sal_uInt32 nOp1, sal_uInt32 nOp2 ) void SbiRuntime::StepCALL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { - String aName = pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ); + OUString aName = pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ); SbxArray* pArgs = NULL; if( nOp1 & 0x8000 ) + { pArgs = refArgv; + } DllCall( aName, aLibName, pArgs, (SbxDataType) nOp2, false ); - aLibName = String(); + aLibName = OUString(); if( nOp1 & 0x8000 ) + { PopArgv(); + } } // call of a DLL-procedure after CDecl (+StringID+type) void SbiRuntime::StepCALLC( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { - String aName = pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ); + OUString aName = pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ); SbxArray* pArgs = NULL; if( nOp1 & 0x8000 ) + { pArgs = refArgv; + } DllCall( aName, aLibName, pArgs, (SbxDataType) nOp2, true ); - aLibName = String(); + aLibName = OUString(); if( nOp1 & 0x8000 ) + { PopArgv(); + } } @@ -797,14 +874,16 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // If the Expr-Stack at the beginning of a statement constains a variable, // some fool has called X as a function, although it's a variable! bool bFatalExpr = false; - String sUnknownMethodName; + OUString sUnknownMethodName; if( nExprLvl > 1 ) + { bFatalExpr = true; + } else if( nExprLvl ) { SbxVariable* p = refExprStk->Get( 0 ); - if( p->GetRefCount() > 1 - && refLocals.Is() && refLocals->Find( p->GetName(), p->GetClass() ) ) + if( p->GetRefCount() > 1 && + refLocals.Is() && refLocals->Find( p->GetName(), p->GetClass() ) ) { sUnknownMethodName = p->GetName(); bFatalExpr = true; @@ -850,12 +929,16 @@ void SbiRuntime::StepSTMNT( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // (there's a difference here in case of a jump out of a loop) sal_uInt16 nExspectedForLevel = static_cast<sal_uInt16>( nOp2 / 0x100 ); if( pGosubStk ) + { nExspectedForLevel = nExspectedForLevel + pGosubStk->nStartForLvl; + } // if the actual for-level is too small it'd jump out // of a loop -> corrected while( nForLvl > nExspectedForLevel ) + { PopFor(); + } } // 16.10.96: #31460 new concept for StepInto/Over/Out @@ -892,9 +975,9 @@ void SbiRuntime::StepOPEN( sal_uInt32 nOp1, sal_uInt32 nOp2 ) SbxVariableRef pLen = PopVar(); short nBlkLen = pLen->GetInteger(); short nChan = pChan->GetInteger(); - rtl::OString aName(rtl::OUStringToOString(pName->GetString(), osl_getThreadTextEncoding())); + OString aName(rtl::OUStringToOString(pName->GetString(), osl_getThreadTextEncoding())); pIosys->Open( nChan, aName, static_cast<short>( nOp1 ), - static_cast<short>( nOp2 ), nBlkLen ); + static_cast<short>( nOp2 ), nBlkLen ); Error( pIosys->GetError() ); } @@ -902,15 +985,17 @@ void SbiRuntime::StepOPEN( sal_uInt32 nOp1, sal_uInt32 nOp2 ) void SbiRuntime::StepCREATE( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { - String aClass( pImg->GetString( static_cast<short>( nOp2 ) ) ); + OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) ); SbxObject *pObj = SbxBase::CreateObject( aClass ); if( !pObj ) + { Error( SbERR_INVALID_OBJECT ); + } else { - String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); + OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); pObj->SetName( aName ); - // the object must be able to call the BASIC + // the object must be able to call the BASIC pObj->SetParent( &rBasic ); SbxVariable* pNew = new SbxVariable; pNew->PutObject( pObj ); @@ -981,13 +1066,17 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) pArray->GetDim32( i+1, nLower, nUpper ); nSize = nUpper - nLower + 1; if( i == 0 ) + { nTotalSize = nSize; + } else + { nTotalSize *= nSize; + } } // create objects and insert them into the array - String aClass( pImg->GetString( static_cast<short>( nOp2 ) ) ); + OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) ); for( i = 0 ; i < nTotalSize ; i++ ) { SbxObject *pClassObj = SbxBase::CreateObject( aClass ); @@ -998,7 +1087,7 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) } else { - String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); + OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); pClassObj->SetName( aName ); // the object must be able to call the basic pClassObj->SetParent( &rBasic ); @@ -1062,16 +1151,18 @@ void SbiRuntime::StepDCREATE_IMPL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) // create object from user-type (+StringID+StringID) -SbxObject* createUserTypeImpl( const String& rClassName ); // sb.cxx +SbxObject* createUserTypeImpl( const OUString& rClassName ); // sb.cxx void SbiRuntime::StepTCREATE( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { - String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); - String aClass( pImg->GetString( static_cast<short>( nOp2 ) ) ); + OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); + OUString aClass( pImg->GetString( static_cast<short>( nOp2 ) ) ); SbxObject* pCopyObj = createUserTypeImpl( aClass ); if( pCopyObj ) + { pCopyObj->SetName( aName ); + } SbxVariable* pNew = new SbxVariable; pNew->PutObject( pCopyObj ); pNew->SetDeclareClassName( aClass ); @@ -1082,12 +1173,14 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3 { bool bWithEvents = ((t & 0xff) == SbxOBJECT && (nOp2 & SBX_TYPE_WITH_EVENTS_FLAG) != 0); if( bWithEvents ) + { pVar->SetFlag( SBX_WITH_EVENTS ); - + } bool bDimAsNew = ((nOp2 & SBX_TYPE_DIM_AS_NEW_FLAG) != 0); if( bDimAsNew ) + { pVar->SetFlag( SBX_DIM_AS_NEW ); - + } bool bFixedString = ((t & 0xff) == SbxSTRING && (nOp2 & SBX_FIXED_LEN_STRING_FLAG) != 0); if( bFixedString ) { @@ -1107,8 +1200,10 @@ void SbiRuntime::implHandleSbxFlags( SbxVariable* pVar, SbxDataType t, sal_uInt3 void SbiRuntime::StepLOCAL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { if( !refLocals.Is() ) + { refLocals = new SbxArray; - String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); + } + OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); if( refLocals->Find( aName, SbxCLASS_DONTCARE ) == NULL ) { SbxDataType t = (SbxDataType)(nOp2 & 0xffff); @@ -1123,18 +1218,24 @@ void SbiRuntime::StepLOCAL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) void SbiRuntime::StepPUBLIC_Impl( sal_uInt32 nOp1, sal_uInt32 nOp2, bool bUsedForClassModule ) { - String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); + OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); SbxDataType t = (SbxDataType)(SbxDataType)(nOp2 & 0xffff);; sal_Bool bFlag = pMod->IsSet( SBX_NO_MODIFY ); pMod->SetFlag( SBX_NO_MODIFY ); SbxVariableRef p = pMod->Find( aName, SbxCLASS_PROPERTY ); if( p.Is() ) + { pMod->Remove (p); + } SbProperty* pProp = pMod->GetProperty( aName, t ); if( !bUsedForClassModule ) + { pProp->SetFlag( SBX_PRIVATE ); + } if( !bFlag ) + { pMod->ResetFlag( SBX_NO_MODIFY ); + } if( pProp ) { pProp->SetFlag( SBX_DONTSTORE ); @@ -1166,9 +1267,10 @@ void SbiRuntime::StepPUBLIC_P( sal_uInt32 nOp1, sal_uInt32 nOp2 ) void SbiRuntime::StepGLOBAL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { if( pImg->GetFlag( SBIMG_CLASSMODULE ) ) + { StepPUBLIC_Impl( nOp1, nOp2, true ); - - String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); + } + OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); SbxDataType t = (SbxDataType)(nOp2 & 0xffff); // Store module scope variables at module scope @@ -1185,10 +1287,14 @@ void SbiRuntime::StepGLOBAL( sal_uInt32 nOp1, sal_uInt32 nOp2 ) rBasic.SetFlag( SBX_NO_MODIFY ); SbxVariableRef p = pStorage->Find( aName, SbxCLASS_PROPERTY ); if( p.Is() ) + { pStorage->Remove (p); + } p = pStorage->Make( aName, SbxCLASS_PROPERTY, t ); if( !bFlag ) + { pStorage->ResetFlag( SBX_NO_MODIFY ); + } if( p ) { p->SetFlag( SBX_DONTSTORE ); @@ -1224,7 +1330,7 @@ void SbiRuntime::StepFIND_G( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { // Return dummy variable SbxDataType t = (SbxDataType) nOp2; - String aName( pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ) ); + OUString aName( pImg->GetString( static_cast<short>( nOp1 & 0x7FFF ) ) ); SbxVariable* pDummyVar = new SbxVariable( t ); pDummyVar->SetName( aName ); @@ -1233,7 +1339,7 @@ void SbiRuntime::StepFIND_G( sal_uInt32 nOp1, sal_uInt32 nOp2 ) } -SbxVariable* SbiRuntime::StepSTATIC_Impl( String& aName, SbxDataType& t ) +SbxVariable* SbiRuntime::StepSTATIC_Impl( OUString& aName, SbxDataType& t ) { SbxVariable* p = NULL; if ( pMeth ) @@ -1243,7 +1349,9 @@ SbxVariable* SbiRuntime::StepSTATIC_Impl( String& aName, SbxDataType& t ) { p = new SbxVariable( t ); if( t != SbxVARIANT ) + { p->SetFlag( SBX_FIXED ); + } p->SetName( aName ); pStatics->Put( p, pStatics->Count() ); } @@ -1253,7 +1361,7 @@ SbxVariable* SbiRuntime::StepSTATIC_Impl( String& aName, SbxDataType& t ) // establishing a static variable (+StringID+type) void SbiRuntime::StepSTATIC( sal_uInt32 nOp1, sal_uInt32 nOp2 ) { - String aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); + OUString aName( pImg->GetString( static_cast<short>( nOp1 ) ) ); SbxDataType t = (SbxDataType) nOp2; StepSTATIC_Impl( aName, t ); } |