diff options
author | Eike Rathke <erack@redhat.com> | 2017-01-27 14:55:20 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2017-01-27 14:58:38 +0100 |
commit | 9a283e44ca7de2f2fa276544b4d49cff495bd53d (patch) | |
tree | 0ceb1a152754bfe2473d0353e5ccfc330a249e9d | |
parent | cb3c2eaba64e633f3ea0afb1c32d20faaf4201ae (diff) |
Resolves: tdf#105558 accept numeric BASIC return types as numeric
... not only SbxINTEGER, SbxLONG, SbxSINGLE and SbxDOUBLE.
Change-Id: I75d892f5ae60ef1b18bd86e64777dea746e35a1f
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 51 |
1 files changed, 45 insertions, 6 deletions
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index f32099e8fecd..05e89da3e4d9 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -3122,6 +3122,34 @@ static bool lcl_setVBARange( ScRange& aRange, ScDocument* pDok, SbxVariable* pPa return bOk; } +static bool lcl_isNumericResult( double& fVal, const SbxVariable* pVar ) +{ + switch (pVar->GetType()) + { + case SbxINTEGER: + case SbxLONG: + case SbxSINGLE: + case SbxDOUBLE: + case SbxCURRENCY: + case SbxDATE: + case SbxUSHORT: + case SbxULONG: + case SbxINT: + case SbxUINT: + case SbxSALINT64: + case SbxSALUINT64: + case SbxDECIMAL: + fVal = pVar->GetDouble(); + return true; + case SbxBOOL: + fVal = (pVar->GetBool() ? 1.0 : 0.0); + return true; + default: + ; // nothing + } + return false; +} + #endif void ScInterpreter::ScMacro() @@ -3341,6 +3369,7 @@ void ScInterpreter::ScMacro() pMacroMgr->AddDependentCell(pModule->GetName(), pMyFormulaCell); } + double fVal; SbxDataType eResType = refRes->GetType(); if( SbxBase::GetError() ) { @@ -3350,9 +3379,21 @@ void ScInterpreter::ScMacro() { PushNoValue(); } - else if( eResType >= SbxINTEGER && eResType <= SbxDOUBLE ) + else if (lcl_isNumericResult( fVal, refRes.get())) { - PushDouble( refRes->GetDouble() ); + switch (eResType) + { + case SbxDATE: + nFuncFmtType = css::util::NumberFormat::DATE; + break; + case SbxBOOL: + nFuncFmtType = css::util::NumberFormat::LOGICAL; + break; + // Do not add SbxCURRENCY, we don't know which currency. + default: + ; // nothing + } + PushDouble( fVal ); } else if ( eResType & SbxARRAY ) { @@ -3387,7 +3428,6 @@ void ScInterpreter::ScMacro() if ( pMat ) { SbxVariable* pV; - SbxDataType eType; for ( SCSIZE j=0; j < nR; j++ ) { sal_Int32 nIdx[ 2 ]; @@ -3398,10 +3438,9 @@ void ScInterpreter::ScMacro() { nIdx[ nColIdx ] = nCs + static_cast<sal_Int32>(i); pV = pDimArray->Get32( nIdx ); - eType = pV->GetType(); - if ( eType >= SbxINTEGER && eType <= SbxDOUBLE ) + if ( lcl_isNumericResult( fVal, pV) ) { - pMat->PutDouble( pV->GetDouble(), i, j ); + pMat->PutDouble( fVal, i, j ); } else { |