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

add rebuild sparklines cache after change cell value

parent 57720f70
...@@ -6653,7 +6653,7 @@ ...@@ -6653,7 +6653,7 @@
this.ReadSparkline = function (type, length, oSparkline) { this.ReadSparkline = function (type, length, oSparkline) {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
if (c_oSer_Sparkline.SparklineRef === type) { 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) { } else if (c_oSer_Sparkline.SparklineSqRef === type) {
oSparkline.setSqref(this.stream.GetString2LE(length)); oSparkline.setSqref(this.stream.GetString2LE(length));
} else } else
......
...@@ -3175,6 +3175,11 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){ ...@@ -3175,6 +3175,11 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){
} }
return res; return res;
}; };
Workbook.prototype.updateSparklineCache = function(sheet, ranges) {
for (var i = 0; i < this.aWorksheets.length; ++i) {
this.aWorksheets[i].updateSparklineCache(sheet, ranges);
}
};
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
/** /**
* @constructor * @constructor
...@@ -5392,6 +5397,14 @@ Woorksheet.prototype.createTablePart = function(){ ...@@ -5392,6 +5397,14 @@ Woorksheet.prototype.createTablePart = function(){
return new AscCommonExcel.TablePart(this.handlers); 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 * @constructor
......
...@@ -4481,9 +4481,6 @@ function sparklineGroup() { ...@@ -4481,9 +4481,6 @@ function sparklineGroup() {
this.arrSparklines = []; this.arrSparklines = [];
this.arrCachedSparklines = []; this.arrCachedSparklines = [];
} }
sparklineGroup.prototype.clearCached = function() {
this.arrCachedSparklines.length = 0;
};
sparklineGroup.prototype.addView = function(oSparklineView, index) { sparklineGroup.prototype.addView = function(oSparklineView, index) {
this.arrCachedSparklines[index] = oSparklineView; this.arrCachedSparklines[index] = oSparklineView;
}; };
...@@ -4496,10 +4493,15 @@ sparklineGroup.prototype.draw = function(oDrawingContext) { ...@@ -4496,10 +4493,15 @@ sparklineGroup.prototype.draw = function(oDrawingContext) {
this.arrCachedSparklines[i].draw(graphics); 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) { for (var i = 0; i < this.arrSparklines.length; ++i) {
if (range.intersectionSimple(this.arrSparklines[i].f)) { if (sheet === this.arrSparklines[i].fSheet) {
this.arrCachedSparklines[i] = null; 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) { ...@@ -4507,10 +4509,20 @@ sparklineGroup.prototype.updateCache = function(range) {
function sparkline() { function sparkline() {
this.sqref = null; this.sqref = null;
this.f = null; this.f = null;
this.fRange = null;
this.fSheet = null;
} }
sparkline.prototype.setSqref = function(sqref) { sparkline.prototype.setSqref = function(sqref) {
this.sqref = AscCommonExcel.g_oRangeCache.getAscRange(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) { sparkline.prototype.checkInRange = function(range) {
return this.sqref ? range.isIntersect(this.sqref) : false; return this.sqref ? range.isIntersect(this.sqref) : false;
}; };
......
...@@ -11746,6 +11746,8 @@ ...@@ -11746,6 +11746,8 @@
this._updateSelectionNameAndInfo(); this._updateSelectionNameAndInfo();
} }
this.model.onUpdateRanges(arrChanged);
this.objectRender.rebuildChartGraphicObjects( new AscFormat.CChangeTableData( null, null, null, null, arrChanged ) ); this.objectRender.rebuildChartGraphicObjects( new AscFormat.CChangeTableData( null, null, null, null, arrChanged ) );
this.cellCommentator.updateCommentPosition(); this.cellCommentator.updateCommentPosition();
this.handlers.trigger( "onDocumentPlaceChanged" ); this.handlers.trigger( "onDocumentPlaceChanged" );
......
...@@ -2372,13 +2372,6 @@ function DrawingObjects() { ...@@ -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) _this.checkSparklineGroupMinMaxVal = function(oSparklineGroup)
{ {
var maxVal = null, minVal = null, i, j; 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