summaryrefslogtreecommitdiff
path: root/sc/source/core/data/column3.cxx
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-07-03 22:48:31 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-07-08 22:00:53 -0400
commit0da05b6cfa4c2ba4f988201f799cecb5af73c841 (patch)
tree902c39bee0be59cdb434da0fead75532f2938328 /sc/source/core/data/column3.cxx
parent771d7e6dd513cb8e924964bcacd0435e93bb303a (diff)
Adjust formula grouping on range deletion.
Change-Id: Id3c2cd0a3cffa299c8424f9c9e4989ce8bd60719
Diffstat (limited to 'sc/source/core/data/column3.cxx')
-rw-r--r--sc/source/core/data/column3.cxx32
1 files changed, 24 insertions, 8 deletions
diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx
index d3b4f2c246f7..3b71a19e5615 100644
--- a/sc/source/core/data/column3.cxx
+++ b/sc/source/core/data/column3.cxx
@@ -739,17 +739,33 @@ class EmptyCells
ScColumn& mrColumn;
sc::ColumnBlockPosition& mrPos;
sc::CellStoreType::iterator miPos;
- sc::CellStoreType& mrCells;
- sc::CellTextAttrStoreType& mrAttrs;
+
+ void splitFormulaGrouping(sc::CellStoreType& rCells, const sc::CellStoreType::position_type& rPos)
+ {
+ if (rPos.first->type == sc::element_type_formula)
+ {
+ ScFormulaCell& rCell = *sc::formula_block::at(*rPos.first->data, rPos.second);
+ mrColumn.UnshareFormulaCell(rPos, rCell);
+ }
+ }
+
public:
- EmptyCells(sc::ColumnBlockPosition& rPos, ScColumn& rColumn, sc::CellStoreType& rCells, sc::CellTextAttrStoreType& rAttrs) :
- mrColumn(rColumn), mrPos(rPos), mrCells(rCells), mrAttrs(rAttrs) {}
+ EmptyCells(sc::ColumnBlockPosition& rPos, ScColumn& rColumn) :
+ mrColumn(rColumn), mrPos(rPos) {}
void operator() (const sc::SingleColumnSpanSet::Span& rSpan)
{
- mrPos.miCellPos = mrCells.set_empty(mrPos.miCellPos, rSpan.mnRow1, rSpan.mnRow2);
- mrPos.miCellTextAttrPos = mrAttrs.set_empty(mrPos.miCellTextAttrPos, rSpan.mnRow1, rSpan.mnRow2);
- mrColumn.RegroupFormulaCells(rSpan.mnRow1, rSpan.mnRow2);
+ sc::CellStoreType& rCells = mrColumn.GetCellStore();
+
+ // First, split formula grouping at the top and bottom boundaries
+ // before emptying the cells.
+ sc::CellStoreType::position_type aPos = rCells.position(mrPos.miCellPos, rSpan.mnRow1);
+ splitFormulaGrouping(rCells, aPos);
+ aPos = rCells.position(aPos.first, rSpan.mnRow2);
+ splitFormulaGrouping(rCells, aPos);
+
+ mrPos.miCellPos = rCells.set_empty(mrPos.miCellPos, rSpan.mnRow1, rSpan.mnRow2);
+ mrPos.miCellTextAttrPos = mrColumn.GetCellAttrStore().set_empty(mrPos.miCellTextAttrPos, rSpan.mnRow1, rSpan.mnRow2);
}
};
@@ -783,7 +799,7 @@ void ScColumn::DeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag)
aBlockPos.miCellTextAttrPos = maCellTextAttrs.begin();
// Delete the cells for real.
- std::for_each(aSpans.begin(), aSpans.end(), EmptyCells(aBlockPos, *this, maCells, maCellTextAttrs));
+ std::for_each(aSpans.begin(), aSpans.end(), EmptyCells(aBlockPos, *this));
CellStorageModified();
}