summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-25 09:30:57 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-26 01:41:17 -0400
commit0e9e3be6f51436c1e5bf1481a434a85e334c09ea (patch)
tree6e04594b107ba5730d5d24506d508da0fe8e435a
parent459729627600fb057265479261ade74a55cd48d5 (diff)
More on ScCellIterator usage migration.
Change-Id: I4ee6b1b3ae110ebfb59a84d6e9fd509ce38ca28c
-rw-r--r--sc/inc/dociter.hxx2
-rw-r--r--sc/source/core/data/dociter.cxx26
-rw-r--r--sc/source/core/tool/interpr5.cxx15
-rw-r--r--sc/source/ui/view/viewfun4.cxx41
4 files changed, 56 insertions, 28 deletions
diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx
index c490a9dbc0b1..6f17e2db0fce 100644
--- a/sc/inc/dociter.hxx
+++ b/sc/inc/dociter.hxx
@@ -247,6 +247,8 @@ public:
OUString getString();
const EditTextObject* getEditText() const;
ScFormulaCell* getFormulaCell();
+ double getValue() const;
+
bool hasString() const;
bool hasNumeric() const;
bool isEmpty() const;
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx
index 8e503b84486d..fb39c8ade1a7 100644
--- a/sc/source/core/data/dociter.cxx
+++ b/sc/source/core/data/dociter.cxx
@@ -1166,6 +1166,20 @@ ScFormulaCell* ScCellIterator::getFormulaCell()
return mpCurFormula;
}
+double ScCellIterator::getValue() const
+{
+ switch (meCurType)
+ {
+ case CELLTYPE_VALUE:
+ return mfCurValue;
+ case CELLTYPE_FORMULA:
+ return mpCurFormula->GetValue();
+ default:
+ ;
+ }
+ return 0.0;
+}
+
bool ScCellIterator::hasString() const
{
switch (meCurType)
@@ -1199,7 +1213,17 @@ bool ScCellIterator::hasNumeric() const
bool ScCellIterator::isEmpty() const
{
- return meCurType == CELLTYPE_NOTE || meCurType == CELLTYPE_NONE;
+ switch (meCurType)
+ {
+ case CELLTYPE_NOTE:
+ case CELLTYPE_NONE:
+ return true;
+ case CELLTYPE_FORMULA:
+ return mpCurFormula->IsEmpty();
+ default:
+ ;
+ }
+ return false;
}
namespace {
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 7a716ed0f71a..74bccc74fffe 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -424,20 +424,24 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken
// Neighboring cell values of identical type are stored and passed as
// an array to the matrix object, for performance reasons.
- for (ScBaseCell* pCell = aCellIter.GetFirst(); pCell; pCell = aCellIter.GetNext(), nPrevRow = nThisRow)
+ for (bool bHas = aCellIter.first(); bHas; bHas = aCellIter.next(), nPrevRow = nThisRow)
{
nThisRow = aCellIter.GetPos().Row();
- if (HasCellEmptyData(pCell))
+ if (aCellIter.isEmpty())
{
aBucket.flush(*pMat, static_cast<SCSIZE>(nCol-nCol1));
continue;
}
- if (HasCellValueData(pCell))
+ if (aCellIter.hasNumeric())
{
ScAddress aAdr(nCol, nThisRow, nTab1);
- double fVal = GetCellValue( aAdr, pCell);
+
+ // TODO: Come back to this and fix it.
+ ScBaseCell* pBC = pDok->GetCell(aAdr);
+ double fVal = GetCellValue(aAdr, pBC);
+
if ( nGlobalError )
{
fVal = CreateDoubleError( nGlobalError);
@@ -459,8 +463,7 @@ ScMatrixRef ScInterpreter::CreateMatrixFromDoubleRef( const FormulaToken* pToken
continue;
}
- String aStr;
- GetCellString( aStr, pCell);
+ String aStr = aCellIter.getString();
if ( nGlobalError )
{
double fVal = CreateDoubleError( nGlobalError);
diff --git a/sc/source/ui/view/viewfun4.cxx b/sc/source/ui/view/viewfun4.cxx
index 944c508de22c..d05795e7feee 100644
--- a/sc/source/ui/view/viewfun4.cxx
+++ b/sc/source/ui/view/viewfun4.cxx
@@ -240,30 +240,29 @@ void ScViewFunc::DoRefConversion( sal_Bool bRecord )
aRange.aStart.SetTab(i);
aRange.aEnd.SetTab(i);
ScCellIterator aIter( pDoc, aRange );
- ScBaseCell* pCell = aIter.GetFirst();
- while ( pCell )
+ for (bool bHas = aIter.first(); bHas; bHas = aIter.next())
{
- if (pCell->GetCellType() == CELLTYPE_FORMULA)
+ if (aIter.getType() != CELLTYPE_FORMULA)
+ continue;
+
+ ScFormulaCell* pCell = aIter.getFormulaCell();
+ OUString aOld;
+ pCell->GetFormula(aOld);
+ sal_Int32 nLen = aOld.getLength();
+ ScRefFinder aFinder( aOld, aIter.GetPos(), pDoc, pDoc->GetAddressConvention() );
+ aFinder.ToggleRel( 0, nLen );
+ if (aFinder.GetFound())
{
- rtl::OUString aOld;
- ((ScFormulaCell*)pCell)->GetFormula(aOld);
- xub_StrLen nLen = aOld.getLength();
- ScRefFinder aFinder( aOld, aIter.GetPos(), pDoc, pDoc->GetAddressConvention() );
- aFinder.ToggleRel( 0, nLen );
- if (aFinder.GetFound())
- {
- ScAddress aPos = ((ScFormulaCell*)pCell)->aPos;
- String aNew = aFinder.GetText();
- ScCompiler aComp( pDoc, aPos);
- aComp.SetGrammar(pDoc->GetGrammar());
- ScTokenArray* pArr = aComp.CompileString( aNew );
- ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aPos,
- pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE );
- pDoc->SetFormulaCell(aPos, pNewCell);
- bOk = true;
- }
+ ScAddress aPos = pCell->aPos;
+ String aNew = aFinder.GetText();
+ ScCompiler aComp( pDoc, aPos);
+ aComp.SetGrammar(pDoc->GetGrammar());
+ ScTokenArray* pArr = aComp.CompileString( aNew );
+ ScFormulaCell* pNewCell = new ScFormulaCell( pDoc, aPos,
+ pArr,formula::FormulaGrammar::GRAM_DEFAULT, MM_NONE );
+ pDoc->SetFormulaCell(aPos, pNewCell);
+ bOk = true;
}
- pCell = aIter.GetNext();
}
}
}