[Libreoffice-commits] core.git: Branch 'feature/formula-core-rework' - sc/source
Kohei Yoshida
kohei.yoshida at gmail.com
Thu Mar 28 06:53:40 PDT 2013
sc/source/core/inc/interpre.hxx | 2
sc/source/core/tool/interpr4.cxx | 84 ++++++++++++++++-----------------------
2 files changed, 37 insertions(+), 49 deletions(-)
New commits:
commit 99a90345027b31a95feedccff0f180ef4a40bed8
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date: Thu Mar 28 09:56:02 2013 -0400
GetValueCellValue() to take a double, not ScValueCell.
Change-Id: Idac293e6475caabe73e961cde5578c34d561e06a
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 5eb74f3..6359e82 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 cc4d190..ef39a4a 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;
More information about the Libreoffice-commits
mailing list