Spreadsheet: Expressions using a spreadsheet cell address are now correctly renamed when rows/columns are removed/inserted.
This commit is contained in:
parent
29695a8ae7
commit
e2650860cc
|
@ -504,7 +504,7 @@ void PropertySheet::clear(CellAddress address)
|
||||||
rebuildDocDepList();
|
rebuildDocDepList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos)
|
void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos, std::map<App::ObjectIdentifier, App::ObjectIdentifier> & renames)
|
||||||
{
|
{
|
||||||
std::map<CellAddress, Cell*>::const_iterator i = data.find(currPos);
|
std::map<CellAddress, Cell*>::const_iterator i = data.find(currPos);
|
||||||
std::map<CellAddress, Cell*>::const_iterator j = data.find(newPos);
|
std::map<CellAddress, Cell*>::const_iterator j = data.find(newPos);
|
||||||
|
@ -528,6 +528,8 @@ void PropertySheet::moveCell(CellAddress currPos, CellAddress newPos)
|
||||||
addDependencies(newPos);
|
addDependencies(newPos);
|
||||||
setDirty(newPos);
|
setDirty(newPos);
|
||||||
|
|
||||||
|
renames[ObjectIdentifier(owner, currPos.toString())] = ObjectIdentifier(owner, newPos.toString());
|
||||||
|
|
||||||
rebuildDocDepList();
|
rebuildDocDepList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -609,6 +611,7 @@ private:
|
||||||
void PropertySheet::insertRows(int row, int count)
|
void PropertySheet::insertRows(int row, int count)
|
||||||
{
|
{
|
||||||
std::vector<CellAddress> keys;
|
std::vector<CellAddress> keys;
|
||||||
|
std::map<App::ObjectIdentifier, App::ObjectIdentifier> renames;
|
||||||
|
|
||||||
/* Copy all keys from cells map */
|
/* Copy all keys from cells map */
|
||||||
boost::copy( data | boost::adaptors::map_keys, std::back_inserter(keys));
|
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)
|
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)
|
void PropertySheet::removeRows(int row, int count)
|
||||||
{
|
{
|
||||||
std::vector<CellAddress> keys;
|
std::vector<CellAddress> keys;
|
||||||
|
std::map<App::ObjectIdentifier, App::ObjectIdentifier> renames;
|
||||||
|
|
||||||
/* Copy all keys from cells map */
|
/* Copy all keys from cells map */
|
||||||
boost::copy(data | boost::adaptors::map_keys, std::back_inserter(keys));
|
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)
|
if (i->row() >= row && i->row() < row + count)
|
||||||
clear(*i);
|
clear(*i);
|
||||||
else if (i->row() >= row + count)
|
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)
|
void PropertySheet::insertColumns(int col, int count)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<CellAddress> keys;
|
std::vector<CellAddress> keys;
|
||||||
|
std::map<App::ObjectIdentifier, App::ObjectIdentifier> renames;
|
||||||
|
|
||||||
/* Copy all keys from cells map */
|
/* Copy all keys from cells map */
|
||||||
boost::copy(data | boost::adaptors::map_keys, std::back_inserter(keys));
|
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)
|
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)
|
void PropertySheet::removeColumns(int col, int count)
|
||||||
{
|
{
|
||||||
std::vector<CellAddress> keys;
|
std::vector<CellAddress> keys;
|
||||||
|
std::map<App::ObjectIdentifier, App::ObjectIdentifier> renames;
|
||||||
|
|
||||||
/* Copy all keys from cells map */
|
/* Copy all keys from cells map */
|
||||||
boost::copy(data | boost::adaptors::map_keys, std::back_inserter(keys));
|
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)
|
if (i->col() >= col && i->col() < col + count)
|
||||||
clear(*i);
|
clear(*i);
|
||||||
else if (i->col() >= col + count)
|
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
|
unsigned int PropertySheet::getMemSize() const
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
|
|
||||||
bool isDirty() const { return dirty.size() > 0; }
|
bool isDirty() const { return dirty.size() > 0; }
|
||||||
|
|
||||||
void moveCell(CellAddress currPos, CellAddress newPos);
|
void moveCell(CellAddress currPos, CellAddress newPos, std::map<App::ObjectIdentifier, App::ObjectIdentifier> &renames);
|
||||||
|
|
||||||
void insertRows(int row, int count);
|
void insertRows(int row, int count);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user