Kaydet (Commit) 94040c20 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

ResolveStaticReference() to also dynamically recalc formula cells.

Change-Id: If42e5105be0e6db7c63d7c4e7c43de23716d6cbf
üst f67fa232
......@@ -1859,13 +1859,10 @@ formula::FormulaTokenRef ScColumn::ResolveStaticReference( SCROW nRow )
case sc::element_type_formula:
{
ScFormulaCell* p = sc::formula_block::at(*it->data, aPos.second);
if (p->GetDirty())
// Dirty formula cell is not considered static (for now).
// Return null token. Later we will switch to dynamically
// interpreting all dirty formula cells.
return formula::FormulaTokenRef();
if (p->IsValue())
return formula::FormulaTokenRef(new formula::FormulaDoubleToken(p->GetValue()));
return formula::FormulaTokenRef(new formula::FormulaDoubleToken(p->GetResultDouble()));
return formula::FormulaTokenRef(new formula::FormulaStringToken(p->GetString()));
}
case sc::element_type_empty:
default:
......@@ -1881,28 +1878,34 @@ class ToMatrixHandler
ScMatrix& mrMat;
SCCOL mnMatCol;
SCROW mnTopRow;
bool mbSuccess;
public:
ToMatrixHandler(ScMatrix& rMat, SCCOL nMatCol, SCROW nTopRow) :
mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow), mbSuccess(true) {}
mrMat(rMat), mnMatCol(nMatCol), mnTopRow(nTopRow) {}
void operator() (size_t nRow, double fVal)
{
mrMat.PutDouble(fVal, mnMatCol, nRow - mnTopRow);
}
void operator() (size_t nRow, ScFormulaCell* p)
void operator() (size_t nRow, const ScFormulaCell* p)
{
if (p->GetDirty())
{
mbSuccess = false;
return;
}
// Formula cell may need to re-calculate.
ScFormulaCell& rCell = const_cast<ScFormulaCell&>(*p);
if (rCell.IsValue())
mrMat.PutDouble(rCell.GetValue(), mnMatCol, nRow - mnTopRow);
else
mrMat.PutString(rCell.GetString(), mnMatCol, nRow - mnTopRow);
}
mrMat.PutDouble(p->GetResultDouble(), mnMatCol, nRow - mnTopRow);
void operator() (size_t nRow, const OUString& rStr)
{
mrMat.PutString(rStr, mnMatCol, nRow - mnTopRow);
}
bool isSuccess() const { return mbSuccess; }
void operator() (size_t nRow, const EditTextObject* pStr)
{
mrMat.PutString(ScEditUtil::GetString(*pStr), mnMatCol, nRow - mnTopRow);
}
};
}
......@@ -1913,8 +1916,8 @@ bool ScColumn::ResolveStaticReference( ScMatrix& rMat, SCCOL nMatCol, SCROW nRow
return false;
ToMatrixHandler aFunc(rMat, nMatCol, nRow1);
sc::ProcessFormulaNumeric(maCells.begin(), maCells, nRow1, nRow2, aFunc);
return aFunc.isSuccess();
sc::ParseAllNonEmpty(maCells.begin(), maCells, nRow1, nRow2, aFunc);
return true;
}
namespace {
......
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