Spreadsheet: Fixed undo/redo (issue #2483).
This commit is contained in:
@@ -88,6 +88,7 @@ Cell::Cell(const CellAddress &_address, PropertySheet *_owner)
|
||||
, foregroundColor(0, 0, 0, 1)
|
||||
, backgroundColor(1, 1, 1, 0)
|
||||
, displayUnit()
|
||||
, alias()
|
||||
, computedUnit()
|
||||
, rowSpan(1)
|
||||
, colSpan(1)
|
||||
@@ -96,14 +97,9 @@ Cell::Cell(const CellAddress &_address, PropertySheet *_owner)
|
||||
assert(address.isValid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a CellContent object.
|
||||
*
|
||||
*/
|
||||
|
||||
Cell::Cell(const Cell &other)
|
||||
Cell::Cell(PropertySheet *_owner, const Cell &other)
|
||||
: address(other.address)
|
||||
, owner(other.owner)
|
||||
, owner(_owner)
|
||||
, used(other.used)
|
||||
, expression(other.expression ? other.expression->copy() : 0)
|
||||
, alignment(other.alignment)
|
||||
@@ -111,32 +107,40 @@ Cell::Cell(const Cell &other)
|
||||
, foregroundColor(other.foregroundColor)
|
||||
, backgroundColor(other.backgroundColor)
|
||||
, displayUnit(other.displayUnit)
|
||||
, alias(other.alias)
|
||||
, computedUnit(other.computedUnit)
|
||||
, rowSpan(other.rowSpan)
|
||||
, colSpan(other.colSpan)
|
||||
{
|
||||
setUsed(MARK_SET, false);
|
||||
}
|
||||
|
||||
Cell &Cell::operator =(const Cell &rhs)
|
||||
{
|
||||
PropertySheet::AtomicPropertyChange signaller(*owner);
|
||||
|
||||
used = 0;
|
||||
address = rhs.address;
|
||||
owner = rhs.owner;
|
||||
|
||||
setExpression(rhs.expression ? rhs.expression->copy() : 0);
|
||||
setStyle(rhs.style);
|
||||
setAlignment(rhs.alignment);
|
||||
setForeground(rhs.foregroundColor);
|
||||
setStyle(rhs.style);
|
||||
setBackground(rhs.backgroundColor);
|
||||
setForeground(rhs.foregroundColor);
|
||||
setDisplayUnit(rhs.displayUnit.stringRep);
|
||||
setComputedUnit(rhs.computedUnit);
|
||||
setAlias(rhs.alias);
|
||||
setSpans(rhs.rowSpan, rhs.colSpan);
|
||||
|
||||
setUsed(MARK_SET, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a CellContent object.
|
||||
*
|
||||
*/
|
||||
|
||||
Cell::~Cell()
|
||||
{
|
||||
if (expression)
|
||||
|
||||
@@ -47,12 +47,13 @@ class PropertySheet;
|
||||
class DisplayUnit;
|
||||
|
||||
class SpreadsheetExport Cell {
|
||||
|
||||
private:
|
||||
Cell(const Cell & other);
|
||||
public:
|
||||
|
||||
Cell(const App::CellAddress & _address, PropertySheet * _owner);
|
||||
|
||||
Cell(const Cell & other);
|
||||
Cell(PropertySheet * _owner, const Cell & other);
|
||||
|
||||
Cell& operator=( const Cell& rhs );
|
||||
|
||||
|
||||
@@ -212,13 +212,20 @@ PropertySheet::PropertySheet(const PropertySheet &other)
|
||||
, mergedCells(other.mergedCells)
|
||||
, owner(other.owner)
|
||||
, propertyNameToCellMap(other.propertyNameToCellMap)
|
||||
, cellToPropertyNameMap(other.cellToPropertyNameMap)
|
||||
, documentObjectToCellMap(other.documentObjectToCellMap)
|
||||
, cellToDocumentObjectMap(other.cellToDocumentObjectMap)
|
||||
, docDeps(other.docDeps)
|
||||
, documentObjectName(other.documentObjectName)
|
||||
, documentName(other.documentName)
|
||||
, aliasProp(other.aliasProp)
|
||||
, revAliasProp(other.revAliasProp)
|
||||
{
|
||||
std::map<CellAddress, Cell* >::const_iterator i = other.data.begin();
|
||||
|
||||
/* Copy cells */
|
||||
while (i != other.data.end()) {
|
||||
data[i->first] = new Cell(*i->second);
|
||||
data[i->first] = new Cell(this, *i->second);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -256,7 +263,7 @@ void PropertySheet::Paste(const Property &from)
|
||||
recomputeDependencies(ifrom->first);
|
||||
}
|
||||
else {
|
||||
data[ifrom->first] = new Cell(*(ifrom->second)); // Doesn't exist, copy using Cell's copy constructor
|
||||
data[ifrom->first] = new Cell(this, *(ifrom->second)); // Doesn't exist, copy using Cell's copy constructor
|
||||
}
|
||||
|
||||
/* Set dirty */
|
||||
|
||||
@@ -130,14 +130,14 @@ bool SheetView::onMsg(const char *pMsg, const char **ppReturn)
|
||||
getGuiDocument()->undo(1);
|
||||
App::Document* doc = getAppDocument();
|
||||
if (doc)
|
||||
doc->recomputeFeature(sheet);
|
||||
doc->recompute();
|
||||
return true;
|
||||
}
|
||||
else if(strcmp("Redo",pMsg) == 0 ) {
|
||||
getGuiDocument()->redo(1);
|
||||
App::Document* doc = getAppDocument();
|
||||
if (doc)
|
||||
doc->recomputeFeature(sheet);
|
||||
doc->recompute();
|
||||
return true;
|
||||
}
|
||||
else if (strcmp("Save",pMsg) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user