summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-06-26 19:16:45 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-06-27 15:50:06 -0400
commitab030f75deafad4aab33ac47bfb36dd252e3515e (patch)
tree050255329a7b0df9edff6c5109e2848cb7923bda /sc
parenta8153482ad4f918f3501aed34c3131e970592575 (diff)
Handle formula cells in SwapCell().
Change-Id: I9ddc69793e70bd399b93ce472a38060b1a946ff9
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/column.cxx41
1 files changed, 29 insertions, 12 deletions
diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx
index e29a8a681b63..1e08708103fb 100644
--- a/sc/source/core/data/column.cxx
+++ b/sc/source/core/data/column.cxx
@@ -1129,26 +1129,43 @@ void updateRefInFormulaCell( ScFormulaCell& rCell, SCCOL nCol, SCTAB nTab, SCCOL
void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol)
{
- ScFormulaCell* pCell1 = maCells.get<ScFormulaCell*>(nRow);
- ScFormulaCell* pCell2 = rCol.maCells.get<ScFormulaCell*>(nRow);
- if (pCell1)
- updateRefInFormulaCell(*pCell1, rCol.nCol, nTab, rCol.nCol - nCol);
+ sc::CellStoreType::position_type aPos1 = maCells.position(nRow);
+ sc::CellStoreType::position_type aPos2 = rCol.maCells.position(nRow);
- if (pCell2)
- updateRefInFormulaCell(*pCell2, nCol, nTab, nCol - rCol.nCol);
+ if (aPos1.first->type == sc::element_type_formula)
+ {
+ ScFormulaCell& rCell = *sc::formula_block::at(*aPos1.first->data, aPos1.second);
+ updateRefInFormulaCell(rCell, rCol.nCol, nTab, rCol.nCol - nCol);
+ UnshareFormulaCell(aPos1, rCell);
+ }
+
+ if (aPos2.first->type == sc::element_type_formula)
+ {
+ ScFormulaCell& rCell = *sc::formula_block::at(*aPos2.first->data, aPos2.second);
+ updateRefInFormulaCell(rCell, nCol, nTab, nCol - rCol.nCol);
+ UnshareFormulaCell(aPos2, rCell);
+ }
maCells.swap(nRow, nRow, rCol.maCells, nRow);
maCellTextAttrs.swap(nRow, nRow, rCol.maCellTextAttrs, nRow);
- CellStorageModified();
- rCol.CellStorageModified();
+ aPos1 = maCells.position(nRow);
+ aPos2 = rCol.maCells.position(nRow);
- if (pCell1 || pCell2)
+ if (aPos1.first->type == sc::element_type_formula)
{
- // At least one of the two cells is a formula cell. Regroup them.
- RegroupFormulaCells(nRow);
- rCol.RegroupFormulaCells(nRow);
+ ScFormulaCell& rCell = *sc::formula_block::at(*aPos1.first->data, aPos1.second);
+ JoinNewFormulaCell(aPos1, rCell);
}
+
+ if (aPos2.first->type == sc::element_type_formula)
+ {
+ ScFormulaCell& rCell = *sc::formula_block::at(*aPos2.first->data, aPos2.second);
+ rCol.JoinNewFormulaCell(aPos2, rCell);
+ }
+
+ CellStorageModified();
+ rCol.CellStorageModified();
}