Navigation Menu

Skip to content

Commit

Permalink
Spreadsheet: Fixed issue #3361.
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindkv authored and yorikvanhavre committed Jul 31, 2018
1 parent 13da3dd commit d2f9ab6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Mod/Spreadsheet/App/Cell.cpp
Expand Up @@ -461,8 +461,8 @@ void Cell::setSpans(int rows, int columns)
if (rows != rowSpan || columns != colSpan) {
PropertySheet::AtomicPropertyChange signaller(*owner);

rowSpan = rows;
colSpan = columns;
rowSpan = (rows == -1 ? 1 : rows);
colSpan = (columns == -1 ? 1 : columns);
setUsed(SPANS_SET, (rowSpan != 1 || colSpan != 1) );
setUsed(SPANS_UPDATED);
}
Expand Down
23 changes: 21 additions & 2 deletions src/Mod/Spreadsheet/App/PropertySheet.cpp
Expand Up @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit d2f9ab6

Please sign in to comment.