diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-28 09:56:02 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-28 17:03:53 -0400 |
commit | ea6ee3f9213ced2c86e684b043ad71cac22911e6 (patch) | |
tree | fa33575066d90bb7cfb255854c5e153b3aa8fa9a /sc | |
parent | 663b7062855a21e6c9a24830ffb5ac7ae2669466 (diff) |
GetValueCellValue() to take a double, not ScValueCell.
Change-Id: Idac293e6475caabe73e961cde5578c34d561e06a
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 84 |
2 files changed, 37 insertions, 49 deletions
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 18d635235b3f..bf57765f9be0 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -191,7 +191,7 @@ double GetCellValue( const ScAddress&, const ScBaseCell* ); double GetCellValue( const ScAddress&, ScRefCellValue& rCell ); double GetCellValueOrZero( const ScAddress&, const ScBaseCell* ); double GetCellValueOrZero( const ScAddress&, ScRefCellValue& rCell ); -double GetValueCellValue( const ScAddress&, const ScValueCell* ); +double GetValueCellValue( const ScAddress&, double fOrig ); ScBaseCell* GetCell( const ScAddress& rPos ); void GetCellString( String& rStr, const ScBaseCell* pCell ); void GetCellString( OUString& rStr, ScRefCellValue& rCell ); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index cc4d190ebb82..ef39a4a7d72e 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -178,16 +178,14 @@ sal_uLong ScInterpreter::GetCellNumberFormat( const ScAddress& rPos, ScRefCellVa /// Only ValueCell, formula cells already store the result rounded. -double ScInterpreter::GetValueCellValue( const ScAddress& rPos, const ScValueCell* pCell ) +double ScInterpreter::GetValueCellValue( const ScAddress& rPos, double fOrig ) { - RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::GetValueCellValue" ); - double fVal = pCell->GetValue(); - if ( bCalcAsShown && fVal != 0.0 ) + if ( bCalcAsShown && fOrig != 0.0 ) { sal_uLong nFormat = pDok->GetNumberFormat( rPos ); - fVal = pDok->RoundValueAsShown( fVal, nFormat ); + fOrig = pDok->RoundValueAsShown( fOrig, nFormat ); } - return fVal; + return fOrig; } sal_uInt16 ScInterpreter::GetCellErrCode( const ScRefCellValue& rCell ) @@ -744,22 +742,24 @@ bool ScInterpreter::CreateDoubleArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, while (nCol <= nCol2) { aAdr.SetCol( nCol ); - ScBaseCell* pCell = pDok->GetCell( aAdr ); - if (pCell) + + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (!aCell.isEmpty()) { sal_uInt16 nErr = 0; double nVal = 0.0; bool bOk = true; - switch ( pCell->GetCellType() ) + switch (aCell.meType) { case CELLTYPE_VALUE : - nVal = GetValueCellValue( aAdr, (ScValueCell*)pCell ); + nVal = GetValueCellValue(aAdr, aCell.mfValue); break; case CELLTYPE_FORMULA : - if (((ScFormulaCell*)pCell)->IsValue()) + if (aCell.mpFormula->IsValue()) { - nErr = ((ScFormulaCell*)pCell)->GetErrCode(); - nVal = ((ScFormulaCell*)pCell)->GetValue(); + nErr = aCell.mpFormula->GetErrCode(); + nVal = aCell.mpFormula->GetValue(); } else bOk = false; @@ -931,33 +931,31 @@ bool ScInterpreter::CreateCellArr(SCCOL nCol1, SCROW nRow1, SCTAB nTab1, while (nCol <= nCol2) { aAdr.SetCol( nCol ); - ScBaseCell* pCell = pDok->GetCell( aAdr ); - if (pCell) + ScRefCellValue aCell; + aCell.assign(*pDok, aAdr); + if (!aCell.isEmpty()) { sal_uInt16 nErr = 0; sal_uInt16 nType = 0; // 0 = Zahl; 1 = String double nVal = 0.0; String aStr; bool bOk = true; - switch ( pCell->GetCellType() ) + switch (aCell.meType) { case CELLTYPE_STRING : - aStr = ((ScStringCell*)pCell)->GetString(); - nType = 1; - break; case CELLTYPE_EDIT : - aStr = ((ScEditCell*)pCell)->GetString(); + aStr = aCell.getString(); nType = 1; break; case CELLTYPE_VALUE : - nVal = GetValueCellValue( aAdr, (ScValueCell*)pCell ); + nVal = GetValueCellValue(aAdr, aCell.mfValue); break; case CELLTYPE_FORMULA : - nErr = ((ScFormulaCell*)pCell)->GetErrCode(); - if (((ScFormulaCell*)pCell)->IsValue()) - nVal = ((ScFormulaCell*)pCell)->GetValue(); + nErr = aCell.mpFormula->GetErrCode(); + if (aCell.mpFormula->IsValue()) + nVal = aCell.mpFormula->GetValue(); else - aStr = ((ScFormulaCell*)pCell)->GetString(); + aStr = aCell.mpFormula->GetString(); break; default : bOk = false; @@ -3580,43 +3578,33 @@ bool ScInterpreter::SetSbxVariable( SbxVariable* pVar, const ScAddress& rPos ) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::SetSbxVariable" ); bool bOk = true; - ScBaseCell* pCell = pDok->GetCell( rPos ); - if (pCell) + ScRefCellValue aCell; + aCell.assign(*pDok, rPos); + if (!aCell.isEmpty()) { sal_uInt16 nErr; double nVal; - switch( pCell->GetCellType() ) + switch (aCell.meType) { case CELLTYPE_VALUE : - nVal = GetValueCellValue( rPos, (ScValueCell*)pCell ); + nVal = GetValueCellValue(rPos, aCell.mfValue); pVar->PutDouble( nVal ); - break; + break; case CELLTYPE_STRING : - { - OUString aVal = ((ScStringCell*)pCell)->GetString(); - pVar->PutString( aVal ); - break; - } case CELLTYPE_EDIT : - { - OUString aVal = ((ScEditCell*) pCell)->GetString(); - pVar->PutString( aVal ); - break; - } + pVar->PutString(aCell.getString()); + break; case CELLTYPE_FORMULA : - nErr = ((ScFormulaCell*)pCell)->GetErrCode(); + nErr = aCell.mpFormula->GetErrCode(); if( !nErr ) { - if( ((ScFormulaCell*)pCell)->IsValue() ) + if (aCell.mpFormula->IsValue()) { - nVal = ((ScFormulaCell*)pCell)->GetValue(); - pVar->PutDouble( nVal ); + nVal = aCell.mpFormula->GetValue(); + pVar->PutDouble(aCell.mpFormula->GetValue()); } else - { - OUString aVal = ((ScFormulaCell*)pCell)->GetString(); - pVar->PutString( aVal ); - } + pVar->PutString(aCell.mpFormula->GetString()); } else SetError( nErr ), bOk = false; |