Commit 9990f28f authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix bug 33465

add write to history clone sparkline data
parent 17b5b949
......@@ -2637,20 +2637,23 @@ var editor;
this.wb.getWorksheet().freezePane();
};
spreadsheet_api.prototype.asc_setSparklineGroup = function (id, oSparklineGroup) {
var t = this;
var changeSparkline = function(res) {
if (res) {
var changedSparkline = AscCommon.g_oTableId.Get_ById(id);
if (changedSparkline) {
changedSparkline.set(oSparklineGroup);
t.wb._onWSSelectionChanged();
t.wb.getWorksheet().draw();
}
}
};
this._isLockedSparkline(id, changeSparkline);
};
spreadsheet_api.prototype.asc_setSparklineGroup = function (id, oSparklineGroup) {
var t = this;
var changeSparkline = function (res) {
if (res) {
var changedSparkline = AscCommon.g_oTableId.Get_ById(id);
if (changedSparkline) {
History.Create_NewPoint();
History.StartTransaction();
changedSparkline.set(oSparklineGroup);
History.EndTransaction();
t.wb._onWSSelectionChanged();
t.wb.getWorksheet().draw();
}
}
};
this._isLockedSparkline(id, changeSparkline);
};
// Cell interface
spreadsheet_api.prototype.asc_getCellInfo = function() {
......
......@@ -170,6 +170,7 @@ function (window, undefined) {
window['AscCH'].historyitem_Sparkline_ColorHigh = 24;
window['AscCH'].historyitem_Sparkline_ColorLow = 25;
window['AscCH'].historyitem_Sparkline_F = 26;
window['AscCH'].historyitem_Sparkline_Clone_Sparklines = 27;
function CHistory()
{
......
......@@ -4786,6 +4786,16 @@ CellArea.prototype = {
w.WriteString2(data.newPr);
}
break;
case AscCH.historyitem_Sparkline_Clone_Sparklines:
if (data.newPr) {
w.WriteLong(data.newPr.length);
data.newPr.forEach(function (item) {
w.WriteLong(item.sqref.c1);
w.WriteLong(item.sqref.r1);
w.WriteString2(item.f);
});
}
break;
}
};
sparklineGroup.prototype.Load_Changes = function (r) {
......@@ -4886,6 +4896,17 @@ CellArea.prototype = {
case AscCH.historyitem_Sparkline_F:
this.f = r.GetBool() ? r.GetString2() : null;
break;
case AscCH.historyitem_Sparkline_Clone_Sparklines:
var count = r.GetLong(), oSparkline, col, row;
for (var i = 0; i < count; ++i) {
oSparkline = new sparkline();
col = r.GetLong();
row = r.GetLong();
oSparkline.sqref = Asc.Range(col, row, col, row);
oSparkline.setF(r.GetString2());
this.arrSparklines.push(oSparkline);
}
break;
}
this.cleanCache();
};
......@@ -5119,9 +5140,6 @@ CellArea.prototype = {
return color instanceof Asc.asc_CColor ? CorrectAscColor(color) : color ? color.clone(): color;
};
History.Create_NewPoint();
History.StartTransaction();
this.type = checkProperty(this.type, val.type, AscCH.historyitem_Sparkline_Type);
this.lineWeight = checkProperty(this.lineWeight, val.lineWeight, AscCH.historyitem_Sparkline_LineWeight);
this.displayEmptyCellsAs = checkProperty(this.displayEmptyCellsAs, val.displayEmptyCellsAs, AscCH.historyitem_Sparkline_DisplayEmptyCellsAs);
......@@ -5152,8 +5170,6 @@ CellArea.prototype = {
this.f = checkProperty(this.f, val.f, AscCH.historyitem_Sparkline_F);
this.cleanCache();
History.EndTransaction();
};
sparklineGroup.prototype.clone = function (onlyProps) {
var res = new sparklineGroup(!onlyProps);
......@@ -5161,9 +5177,12 @@ CellArea.prototype = {
res.f = this.f;
if (!onlyProps) {
var newSparklines = [];
for (var i = 0; i < this.arrSparklines.length; ++i) {
res.arrSparklines.push(this.arrSparklines[i].clone());
newSparklines.push(this.arrSparklines[i].clone());
}
History.Add(res, {Type: AscCH.historyitem_Sparkline_Clone_Sparklines, oldPr: null, newPr: newSparklines});
}
return res;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment