Kaydet (Commit) 9a283e44 authored tarafından Eike Rathke's avatar Eike Rathke

Resolves: tdf#105558 accept numeric BASIC return types as numeric

... not only SbxINTEGER, SbxLONG, SbxSINGLE and SbxDOUBLE.

Change-Id: I75d892f5ae60ef1b18bd86e64777dea746e35a1f
üst cb3c2eab
...@@ -3122,6 +3122,34 @@ static bool lcl_setVBARange( ScRange& aRange, ScDocument* pDok, SbxVariable* pPa ...@@ -3122,6 +3122,34 @@ static bool lcl_setVBARange( ScRange& aRange, ScDocument* pDok, SbxVariable* pPa
return bOk; 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 #endif
void ScInterpreter::ScMacro() void ScInterpreter::ScMacro()
...@@ -3341,6 +3369,7 @@ void ScInterpreter::ScMacro() ...@@ -3341,6 +3369,7 @@ void ScInterpreter::ScMacro()
pMacroMgr->AddDependentCell(pModule->GetName(), pMyFormulaCell); pMacroMgr->AddDependentCell(pModule->GetName(), pMyFormulaCell);
} }
double fVal;
SbxDataType eResType = refRes->GetType(); SbxDataType eResType = refRes->GetType();
if( SbxBase::GetError() ) if( SbxBase::GetError() )
{ {
...@@ -3350,9 +3379,21 @@ void ScInterpreter::ScMacro() ...@@ -3350,9 +3379,21 @@ void ScInterpreter::ScMacro()
{ {
PushNoValue(); 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 ) else if ( eResType & SbxARRAY )
{ {
...@@ -3387,7 +3428,6 @@ void ScInterpreter::ScMacro() ...@@ -3387,7 +3428,6 @@ void ScInterpreter::ScMacro()
if ( pMat ) if ( pMat )
{ {
SbxVariable* pV; SbxVariable* pV;
SbxDataType eType;
for ( SCSIZE j=0; j < nR; j++ ) for ( SCSIZE j=0; j < nR; j++ )
{ {
sal_Int32 nIdx[ 2 ]; sal_Int32 nIdx[ 2 ];
...@@ -3398,10 +3438,9 @@ void ScInterpreter::ScMacro() ...@@ -3398,10 +3438,9 @@ void ScInterpreter::ScMacro()
{ {
nIdx[ nColIdx ] = nCs + static_cast<sal_Int32>(i); nIdx[ nColIdx ] = nCs + static_cast<sal_Int32>(i);
pV = pDimArray->Get32( nIdx ); pV = pDimArray->Get32( nIdx );
eType = pV->GetType(); if ( lcl_isNumericResult( fVal, pV) )
if ( eType >= SbxINTEGER && eType <= SbxDOUBLE )
{ {
pMat->PutDouble( pV->GetDouble(), i, j ); pMat->PutDouble( fVal, i, j );
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment