Skip to content

Commit

Permalink
Spreadsheet: Fixed issue #2352, removal of rows and columns.
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindkv authored and wwmayer committed Dec 9, 2015
1 parent 4b5ae54 commit 71605e6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Mod/Spreadsheet/App/PropertySheet.cpp
Expand Up @@ -567,8 +567,9 @@ class RewriteExpressionVisitor : public ExpressionVisitor {
if (varExpr) {
static const boost::regex e("(\\${0,1})([A-Za-z]+)(\\${0,1})([0-9]+)");
boost::cmatch cm;
std::string s = varExpr->name();

if (boost::regex_match(varExpr->name().c_str(), cm, e)) {
if (boost::regex_match(s.c_str(), cm, e)) {
const boost::sub_match<const char *> colstr = cm[2];
const boost::sub_match<const char *> rowstr = cm[4];
int thisRow, thisCol;
Expand All @@ -590,11 +591,11 @@ class RewriteExpressionVisitor : public ExpressionVisitor {
CellAddress to(r.to());

if (from.row() >= mRow || from.col() >= mCol) {
from = CellAddress(from.row() + mRowCount, from.col() + mColCount);
from = CellAddress(std::max(0, from.row() + mRowCount), std::max(0, from.col() + mColCount));
mChanged = true;
}
if (to.row() >= mRow || to.col() >= mCol) {
to = CellAddress(to.row() + mRowCount, to.col() + mColCount);
to = CellAddress(std::max(0, to.row() + mRowCount), std::max(0, to.col() + mColCount));
mChanged = true;
}
rangeExpr->setRange(Range(from, to));
Expand Down Expand Up @@ -667,7 +668,7 @@ void PropertySheet::removeRows(int row, int count)
/* Sort them */
std::sort(keys.begin(), keys.end(), boost::bind(&PropertySheet::rowSortFunc, this, _1, _2));

RewriteExpressionVisitor visitor(CellAddress(row + count, CellAddress::MAX_COLUMNS), -count, 0);
RewriteExpressionVisitor visitor(CellAddress(row + count - 1, CellAddress::MAX_COLUMNS), -count, 0);

Signaller signaller(*this);
for (std::vector<CellAddress>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
Expand Down Expand Up @@ -753,7 +754,7 @@ void PropertySheet::removeColumns(int col, int count)
/* Sort them */
std::sort(keys.begin(), keys.end(), boost::bind(&PropertySheet::colSortFunc, this, _1, _2));

RewriteExpressionVisitor visitor(CellAddress(CellAddress::MAX_ROWS, col + count), 0, -count);
RewriteExpressionVisitor visitor(CellAddress(CellAddress::MAX_ROWS, col + count - 1), 0, -count);

Signaller signaller(*this);
for (std::vector<CellAddress>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
Expand Down

0 comments on commit 71605e6

Please sign in to comment.