diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 352ce8108..8d052bf8e 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -504,7 +504,7 @@ void PropertySheet::clear(CellAddress address) rebuildDocDepList(); } -void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos) +void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos, std::map & renames) { std::map::const_iterator i = data.find(currPos); std::map::const_iterator j = data.find(newPos); @@ -528,6 +528,8 @@ void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos) addDependencies(newPos); setDirty(newPos); + renames[ObjectIdentifier(owner, currPos.toString())] = ObjectIdentifier(owner, newPos.toString()); + rebuildDocDepList(); } } @@ -609,6 +611,7 @@ private: void PropertySheet::insertRows(int row, int count) { std::vector keys; + std::map renames; /* Copy all keys from cells map */ boost::copy( data | boost::adaptors::map_keys, std::back_inserter(keys)); @@ -635,8 +638,10 @@ void PropertySheet::insertRows(int row, int count) } if (i->row() >= row) - moveCell(*i, CellAddress(i->row() + count, i->col())); + moveCell(*i, CellAddress(i->row() + count, i->col()), renames); } + + owner->getDocument()->renameObjectIdentifiers(renames); } /** @@ -654,6 +659,7 @@ bool PropertySheet::rowSortFunc(const CellAddress & a, const CellAddress & b) { void PropertySheet::removeRows(int row, int count) { std::vector keys; + std::map renames; /* Copy all keys from cells map */ boost::copy(data | boost::adaptors::map_keys, std::back_inserter(keys)); @@ -682,14 +688,16 @@ void PropertySheet::removeRows(int row, int count) if (i->row() >= row && i->row() < row + count) clear(*i); else if (i->row() >= row + count) - moveCell(*i, CellAddress(i->row() - count, i->col())); + moveCell(*i, CellAddress(i->row() - count, i->col()), renames); } + + owner->getDocument()->renameObjectIdentifiers(renames); } void PropertySheet::insertColumns(int col, int count) { - std::vector keys; + std::map renames; /* Copy all keys from cells map */ boost::copy(data | boost::adaptors::map_keys, std::back_inserter(keys)); @@ -716,8 +724,10 @@ void PropertySheet::insertColumns(int col, int count) } if (i->col() >= col) - moveCell(*i, CellAddress(i->row(), i->col() + count)); + moveCell(*i, CellAddress(i->row(), i->col() + count), renames); } + + owner->getDocument()->renameObjectIdentifiers(renames); } /** @@ -735,6 +745,7 @@ bool PropertySheet::colSortFunc(const CellAddress & a, const CellAddress & b) { void PropertySheet::removeColumns(int col, int count) { std::vector keys; + std::map renames; /* Copy all keys from cells map */ boost::copy(data | boost::adaptors::map_keys, std::back_inserter(keys)); @@ -763,8 +774,10 @@ void PropertySheet::removeColumns(int col, int count) if (i->col() >= col && i->col() < col + count) clear(*i); else if (i->col() >= col + count) - moveCell(*i, CellAddress(i->row(), i->col() - count)); + moveCell(*i, CellAddress(i->row(), i->col() - count), renames); } + + owner->getDocument()->renameObjectIdentifiers(renames); } unsigned int PropertySheet::getMemSize() const diff --git a/src/Mod/Spreadsheet/App/PropertySheet.h b/src/Mod/Spreadsheet/App/PropertySheet.h index 1462bfac5..0e2e78f90 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.h +++ b/src/Mod/Spreadsheet/App/PropertySheet.h @@ -95,7 +95,7 @@ public: bool isDirty() const { return dirty.size() > 0; } - void moveCell(CellAddress currPos, CellAddress newPos); + void moveCell(CellAddress currPos, CellAddress newPos, std::map &renames); void insertRows(int row, int count);