Commit 1e57bb98 authored by Alexander.Trofimov's avatar Alexander.Trofimov

add rebuild sparklines cache after change cell value

parent 42bb3891
......@@ -6629,7 +6629,7 @@
this.ReadSparkline = function (type, length, oSparkline) {
var res = c_oSerConstants.ReadOk;
if (c_oSer_Sparkline.SparklineRef === type) {
oSparkline.f = this.stream.GetString2LE(length);
oSparkline.setF(this.stream.GetString2LE(length));
} else if (c_oSer_Sparkline.SparklineSqRef === type) {
oSparkline.setSqref(this.stream.GetString2LE(length));
} else
......
......@@ -3151,6 +3151,11 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){
}
return res;
};
Workbook.prototype.updateSparklineCache = function(sheet, ranges) {
for (var i = 0; i < this.aWorksheets.length; ++i) {
this.aWorksheets[i].updateSparklineCache(sheet, ranges);
}
};
//-------------------------------------------------------------------------------------------------
/**
* @constructor
......@@ -5368,6 +5373,14 @@ Woorksheet.prototype.createTablePart = function(){
return new AscCommonExcel.TablePart(this.handlers);
};
Woorksheet.prototype.onUpdateRanges = function(ranges) {
this.workbook.updateSparklineCache(this.sName, ranges);
};
Woorksheet.prototype.updateSparklineCache = function(sheet, ranges) {
for (var i = 0; i < this.sparklineGroups.arrSparklineGroup.length; ++i) {
this.sparklineGroups.arrSparklineGroup[i].updateCache(sheet, ranges);
}
};
//-------------------------------------------------------------------------------------------------
/**
* @constructor
......
......@@ -4457,9 +4457,6 @@ function sparklineGroup() {
this.arrSparklines = [];
this.arrCachedSparklines = [];
}
sparklineGroup.prototype.clearCached = function() {
this.arrCachedSparklines.length = 0;
};
sparklineGroup.prototype.addView = function(oSparklineView, index) {
this.arrCachedSparklines[index] = oSparklineView;
};
......@@ -4472,10 +4469,15 @@ sparklineGroup.prototype.draw = function(oDrawingContext) {
this.arrCachedSparklines[i].draw(graphics);
}
};
sparklineGroup.prototype.updateCache = function(range) {
sparklineGroup.prototype.updateCache = function(sheet, ranges) {
for (var i = 0; i < this.arrSparklines.length; ++i) {
if (range.intersectionSimple(this.arrSparklines[i].f)) {
this.arrCachedSparklines[i] = null;
if (sheet === this.arrSparklines[i].fSheet) {
for (var j = 0; j < ranges.length; ++j) {
if (ranges[j].intersectionSimple(this.arrSparklines[i].fRange)) {
this.arrCachedSparklines[i] = null;
break;
}
}
}
}
};
......@@ -4483,10 +4485,20 @@ sparklineGroup.prototype.updateCache = function(range) {
function sparkline() {
this.sqref = null;
this.f = null;
this.fRange = null;
this.fSheet = null;
}
sparkline.prototype.setSqref = function(sqref) {
this.sqref = AscCommonExcel.g_oRangeCache.getAscRange(sqref);
};
sparkline.prototype.setF = function(f) {
this.f = f;
var res = parserHelp.parse3DRef(this.f);
if (res) {
this.fSheet = res.sheet;
this.fRange = AscCommonExcel.g_oRangeCache.getAscRange(res.range);
}
};
sparkline.prototype.checkInRange = function(range) {
return this.sqref ? range.isIntersect(this.sqref) : false;
};
......
......@@ -11726,6 +11726,8 @@
this._updateSelectionNameAndInfo();
}
this.model.onUpdateRanges(arrChanged);
this.objectRender.rebuildChartGraphicObjects( new AscFormat.CChangeTableData( null, null, null, null, arrChanged ) );
this.cellCommentator.updateCommentPosition();
this.handlers.trigger( "onDocumentPlaceChanged" );
......
......@@ -2348,13 +2348,6 @@ function DrawingObjects() {
}
};
_this.clearSparklineGroups = function(oSparklineGroups, range) {
for(var i = 0; i < oSparklineGroups.arrSparklineGroup.length; ++i) {
var oSparklineGroup = oSparklineGroups.arrSparklineGroup[i];
oSparklineGroup.updateCache(range);
}
};
_this.checkSparklineGroupMinMaxVal = function(oSparklineGroup)
{
var maxVal = null, minVal = null, i, j;
......
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