Commit 24b24bd7 authored by Alexander.Trofimov's avatar Alexander.Trofimov

add rebuild sparklines cache after change cell value

parent 57720f70
......@@ -6653,7 +6653,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
......
......@@ -3175,6 +3175,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
......@@ -5392,6 +5397,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
......
......@@ -4481,9 +4481,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;
};
......@@ -4496,10 +4493,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;
}
}
}
}
};
......@@ -4507,10 +4509,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;
};
......
......@@ -11746,6 +11746,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" );
......
......@@ -2372,13 +2372,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