diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-09 22:19:15 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-05-09 22:20:26 -0400 |
commit | 83a88b942134314e86ac612d0ef70a8e4919e4af (patch) | |
tree | 376be6cb020bfdc117d7a211854927948d7c2bf7 | |
parent | b44f8185398ff6835a71fe237089746fca7f999d (diff) |
fdo#77056: Treat empty cells as if they have a value of 0.0.
Change-Id: Ibe64cf7177a5298c1878e0014c049dc9c82b1344
-rw-r--r-- | sc/source/core/data/column3.cxx | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 8bb8223b3035..5db4625e72d5 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -1158,6 +1158,23 @@ class MixDataHandler bool mbSkipEmpty; + void doFunction( size_t nDestRow, double fVal1, double fVal2 ) + { + bool bOk = lcl_DoFunction(fVal1, fVal2, mnFunction); + + if (bOk) + miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, fVal1); + else + { + ScAddress aPos(mrDestColumn.GetCol(), nDestRow, mrDestColumn.GetTab()); + + ScFormulaCell* pFC = new ScFormulaCell(&mrDestColumn.GetDoc(), aPos); + pFC->SetErrCode(errNoValue); + + miNewCellsPos = maNewCells.set(miNewCellsPos, nDestRow-mnRowOffset, pFC); + } + } + public: MixDataHandler( sc::ColumnBlockPosition& rBlockPos, @@ -1180,22 +1197,15 @@ public: mrBlockPos.miCellPos = aPos.first; switch (aPos.first->type) { + case sc::element_type_empty: case sc::element_type_numeric: { - // Both src and dest are of numeric type. - bool bOk = lcl_DoFunction(f, sc::numeric_block::at(*aPos.first->data, aPos.second), mnFunction); - - if (bOk) - miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, f); - else - { - ScFormulaCell* pFC = - new ScFormulaCell( - &mrDestColumn.GetDoc(), ScAddress(mrDestColumn.GetCol(), nRow, mrDestColumn.GetTab())); + double fSrcVal = 0.0; + if (aPos.first->type == sc::element_type_numeric) + fSrcVal = sc::numeric_block::at(*aPos.first->data, aPos.second); - pFC->SetErrCode(errNoValue); - miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, pFC); - } + // Both src and dest are of numeric type. + doFunction(nRow, f, fSrcVal); } break; case sc::element_type_formula: @@ -1229,7 +1239,6 @@ public: break; case sc::element_type_string: case sc::element_type_edittext: - case sc::element_type_empty: { // Destination cell is not a number. Just take the source cell. miNewCellsPos = maNewCells.set(miNewCellsPos, nRow-mnRowOffset, f); @@ -1346,9 +1355,9 @@ public: { case sc::element_type_numeric: { - double fVal = sc::numeric_block::at(*aPos.first->data, aPos.second); - miNewCellsPos = maNewCells.set( - miNewCellsPos, nDestRow-mnRowOffset, fVal); + double fVal1 = 0.0; + double fVal2 = sc::numeric_block::at(*aPos.first->data, aPos.second); + doFunction(nDestRow, fVal1, fVal2); } break; case sc::element_type_string: |