Spreadsheet: Fixed issue #3361.
This commit is contained in:
committed by
Yorik van Havre
parent
13da3dd830
commit
d2f9ab6a11
@@ -552,7 +552,14 @@ void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos, std::map<A
|
||||
|
||||
if (i != data.end()) {
|
||||
Cell * cell = i->second;
|
||||
int rows, columns;
|
||||
|
||||
// Get merged cell data
|
||||
cell->getSpans(rows, columns);
|
||||
|
||||
// Remove merged cell data
|
||||
splitCell(currPos);
|
||||
|
||||
// Remove from old
|
||||
removeDependencies(currPos);
|
||||
data.erase(currPos);
|
||||
@@ -561,6 +568,15 @@ void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos, std::map<A
|
||||
// Insert into new spot
|
||||
cell->moveAbsolute(newPos);
|
||||
data[newPos] = cell;
|
||||
|
||||
if (rows > 1 || columns > 1) {
|
||||
CellAddress toPos(newPos.row() + rows - 1, newPos.col() + columns - 1);
|
||||
|
||||
mergeCells(newPos, toPos);
|
||||
}
|
||||
else
|
||||
cell->setSpans(-1, -1);
|
||||
|
||||
addDependencies(newPos);
|
||||
setDirty(newPos);
|
||||
|
||||
@@ -875,7 +891,7 @@ void PropertySheet::splitCell(CellAddress address)
|
||||
mergedCells.erase(CellAddress(r, c));
|
||||
}
|
||||
|
||||
setSpans(anchor, 1, 1);
|
||||
setSpans(anchor, -1, -1);
|
||||
}
|
||||
|
||||
void PropertySheet::getSpans(CellAddress address, int & rows, int & cols) const
|
||||
@@ -885,7 +901,10 @@ void PropertySheet::getSpans(CellAddress address, int & rows, int & cols) const
|
||||
if (i != mergedCells.end()) {
|
||||
CellAddress anchor = i->second;
|
||||
|
||||
cellAt(anchor)->getSpans(rows, cols);
|
||||
if (anchor == address)
|
||||
cellAt(anchor)->getSpans(rows, cols);
|
||||
else
|
||||
rows = cols = 1;
|
||||
}
|
||||
else {
|
||||
rows = cols = 1;
|
||||
|
||||
Reference in New Issue
Block a user