diff options
Diffstat (limited to 'basic/source/runtime')
-rw-r--r-- | basic/source/runtime/methods.cxx | 16 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 16 |
2 files changed, 21 insertions, 11 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx index 9a21e488d4aa..0a5a2b1736dd 100644 --- a/basic/source/runtime/methods.cxx +++ b/basic/source/runtime/methods.cxx @@ -61,6 +61,7 @@ #else #include <osl/file.hxx> #endif +#include "errobject.hxx" #ifdef _USE_UNO #include <comphelper/processfactory.hxx> @@ -256,6 +257,7 @@ RTLFUNC(Error) { String aErrorMsg; SbError nErr = 0L; + INT32 nCode = 0; if( rPar.Count() == 1 ) { nErr = StarBASIC::GetErrBasic(); @@ -263,14 +265,24 @@ RTLFUNC(Error) } else { - INT32 nCode = rPar.Get( 1 )->GetLong(); + nCode = rPar.Get( 1 )->GetLong(); if( nCode > 65535L ) StarBASIC::Error( SbERR_CONVERSION ); else nErr = StarBASIC::GetSfxFromVBError( (USHORT)nCode ); } pBasic->MakeErrorText( nErr, aErrorMsg ); - rPar.Get( 0 )->PutString( pBasic->GetErrorText() ); + String tmpErrMsg( pBasic->GetErrorText() ); + // If this rtlfunc 'Error' passed a errcode the same as the active Err Objects's + // current err then return the description for the error message if it is set + // ( complicated isn't it ? ) + if ( SbiRuntime::isVBAEnabled() && rPar.Count() > 1 ); + { + com::sun::star::uno::Reference< ooo::vba::XErrObject > xErrObj( SbxErrObject::getUnoErrObject() ); + if ( xErrObj.is() && xErrObj->getNumber() == nCode && xErrObj->getDescription().getLength() ) + tmpErrMsg = xErrObj->getDescription(); + } + rPar.Get( 0 )->PutString( tmpErrMsg ); } } diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 75ff47c73486..59129d0db9b9 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -807,7 +807,11 @@ void SbiRuntime::Error( SbError n ) // we really need a new vba compatible error list if ( !aMsg.Len() ) { - StarBASIC::MakeErrorText( n, aMsg ); + // is the error number vb or ( sb ) + SbError nTmp = StarBASIC::GetSfxFromVBError( n ); + if ( !nTmp ) + nTmp = n; + StarBASIC::MakeErrorText( nTmp, aMsg ); aMsg = StarBASIC::GetErrorText(); if ( !aMsg.Len() ) // no message for err no. // need localized resource here @@ -815,14 +819,8 @@ void SbiRuntime::Error( SbError n ) } // no num? most likely then it *is* really a vba err SbxErrObject::getUnoErrObject()->setNumber( ( StarBASIC::GetVBErrorCode( n ) == 0 ) ? n : StarBASIC::GetVBErrorCode( n ) ); - SbxErrObject::getUnoErrObject()->setDescription( aMsg ); - - // prepend an error number to the message. - String aTmp = '\''; - aTmp += String::CreateFromInt32( SbxErrObject::getUnoErrObject()->getNumber() ); - aTmp += String( RTL_CONSTASCII_USTRINGPARAM("\'\n") ); - aTmp += aMsg; - + //SbxErrObject::getUnoErrObject()->setDescription( aMsg ); + String aTmp = aMsg; pInst->aErrorMsg = aTmp; nError = SbERR_BASIC_COMPAT; } |