From e8493f9349d18cbcb323930a9bf200c542a72d62 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 28 Jul 2019 09:01:19 +0200 Subject: loplugin:collapseif Change-Id: I69bfafa97c66ef944cc6ae35c7e2f66d0430d6a4 Reviewed-on: https://gerrit.libreoffice.org/76496 Tested-by: Jenkins Reviewed-by: Noel Grandin --- basic/source/sbx/sbxvalue.cxx | 63 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 33 deletions(-) (limited to 'basic/source') diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 1a011b6706d1..37f8cffbf413 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -976,43 +976,40 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) { aL.eType = aR.eType = SbxDECIMAL; bDecimal = true; - if( rOp.Get( aR ) ) + if( rOp.Get( aR ) && Get( aL ) ) { - if( Get( aL ) ) + if( aL.pDecimal && aR.pDecimal ) { - if( aL.pDecimal && aR.pDecimal ) - { - bool bOk = true; - switch( eOp ) - { - case SbxMUL: - bOk = ( *(aL.pDecimal) *= *(aR.pDecimal) ); - break; - case SbxDIV: - if( aR.pDecimal->isZero() ) - SetError( ERRCODE_BASIC_ZERODIV ); - else - bOk = ( *(aL.pDecimal) /= *(aR.pDecimal) ); - break; - case SbxPLUS: - bOk = ( *(aL.pDecimal) += *(aR.pDecimal) ); - break; - case SbxMINUS: - bOk = ( *(aL.pDecimal) -= *(aR.pDecimal) ); - break; - case SbxNEG: - bOk = ( aL.pDecimal->neg() ); - break; - default: - SetError( ERRCODE_BASIC_BAD_ARGUMENT ); - } - if( !bOk ) - SetError( ERRCODE_BASIC_MATH_OVERFLOW ); - } - else + bool bOk = true; + switch( eOp ) { - SetError( ERRCODE_BASIC_CONVERSION ); + case SbxMUL: + bOk = ( *(aL.pDecimal) *= *(aR.pDecimal) ); + break; + case SbxDIV: + if( aR.pDecimal->isZero() ) + SetError( ERRCODE_BASIC_ZERODIV ); + else + bOk = ( *(aL.pDecimal) /= *(aR.pDecimal) ); + break; + case SbxPLUS: + bOk = ( *(aL.pDecimal) += *(aR.pDecimal) ); + break; + case SbxMINUS: + bOk = ( *(aL.pDecimal) -= *(aR.pDecimal) ); + break; + case SbxNEG: + bOk = ( aL.pDecimal->neg() ); + break; + default: + SetError( ERRCODE_BASIC_BAD_ARGUMENT ); } + if( !bOk ) + SetError( ERRCODE_BASIC_MATH_OVERFLOW ); + } + else + { + SetError( ERRCODE_BASIC_CONVERSION ); } } } -- cgit