Commit 6b17ad98 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

при изменении значения в ячейке при вычислении формулы, надо сбрасывать кеш...

при изменении значения в ячейке при вычислении формулы, надо сбрасывать кеш элементов содержащих эту ячейку.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53923 954022d7-b5bf-4e40-9824-e11837661b57
parent 8d32c791
...@@ -709,17 +709,19 @@ function cTRANSPOSE() { ...@@ -709,17 +709,19 @@ function cTRANSPOSE() {
cTRANSPOSE.prototype = Object.create( cBaseFunction.prototype ) cTRANSPOSE.prototype = Object.create( cBaseFunction.prototype )
function VHLOOKUPCache(bHor){ function VHLOOKUPCache(bHor){
this.cache = {}; this.cacheId = {};
this.cacheRanges = {};
this.bHor = bHor; this.bHor = bHor;
} }
VHLOOKUPCache.prototype.get = function(range, valueForSearching, isValueString, arg3Value){ VHLOOKUPCache.prototype.get = function(range, valueForSearching, isValueString, arg3Value){
var res = null; var res = null;
var _this = this; var _this = this;
var sRangeName = range.getWorksheet().getId() + cCharDelimiter + range.getName(); var wsId = range.getWorksheet().getId();
var cacheElem = this.cache[sRangeName]; var sRangeName = wsId + cCharDelimiter + range.getName();
var cacheElem = this.cacheId[sRangeName];
if(null == cacheElem) if(null == cacheElem)
{ {
cacheElem = {foreachArray: [], results: {}}; cacheElem = {id: sRangeName, foreachArray: [], results: {}};
range._foreachNoEmpty( /*func for cell in col*/ function(cell, r, c, r1, c1){ range._foreachNoEmpty( /*func for cell in col*/ function(cell, r, c, r1, c1){
var cv = cell.getValueWithoutFormat(); var cv = cell.getValueWithoutFormat();
if(_this.bHor) if(_this.bHor)
...@@ -727,7 +729,14 @@ VHLOOKUPCache.prototype.get = function(range, valueForSearching, isValueString, ...@@ -727,7 +729,14 @@ VHLOOKUPCache.prototype.get = function(range, valueForSearching, isValueString,
else else
cacheElem.foreachArray.push({cv: cv, cvType: checkTypeCell( cv ), index: r, indexStart: r1}); cacheElem.foreachArray.push({cv: cv, cvType: checkTypeCell( cv ), index: r, indexStart: r1});
}); });
this.cache[sRangeName] = cacheElem; this.cacheId[sRangeName] = cacheElem;
var cacheRange = this.cacheRanges[wsId];
if(null == cacheRange)
{
cacheRange = new RangeDataManager(null);
this.cacheRanges[wsId] = cacheRange;
}
cacheRange.add(range.getBBox0(), cacheElem);
} }
var sInputKey = valueForSearching + cCharDelimiter + isValueString + cCharDelimiter + arg3Value; var sInputKey = valueForSearching + cCharDelimiter + isValueString + cCharDelimiter + arg3Value;
res = cacheElem.results[sInputKey]; res = cacheElem.results[sInputKey];
...@@ -786,8 +795,22 @@ VHLOOKUPCache.prototype._calculate = function(cacheArray, valueForSearching, isV ...@@ -786,8 +795,22 @@ VHLOOKUPCache.prototype._calculate = function(cacheArray, valueForSearching, isV
} }
return res; return res;
}; };
VHLOOKUPCache.prototype.remove = function(cell){
var wsId = cell.ws.getId();
var cacheRange = this.cacheRanges[wsId];
if(null != cacheRange)
{
var oGetRes = cacheRange.get(new Asc.Range(cell.oId.getCol0(), cell.oId.getRow0(), cell.oId.getCol0(), cell.oId.getRow0()));
for(var i = 0, length = oGetRes.all.length; i < length; ++i)
{
var elem = oGetRes.all[i];
elem.data.results = {};
}
}
};
VHLOOKUPCache.prototype.clean = function(){ VHLOOKUPCache.prototype.clean = function(){
this.cache = {}; this.cacheId = {};
this.cacheRanges = {};
}; };
var g_oVLOOKUPCache = new VHLOOKUPCache(false); var g_oVLOOKUPCache = new VHLOOKUPCache(false);
......
...@@ -3424,6 +3424,8 @@ Woorksheet.prototype._RecalculatedFunctions=function(cell,bad){ ...@@ -3424,6 +3424,8 @@ Woorksheet.prototype._RecalculatedFunctions=function(cell,bad){
__cell.oValue.type = CellValueType.String; __cell.oValue.type = CellValueType.String;
__cell.oValue.text = res.getValue().toString(); __cell.oValue.text = res.getValue().toString();
} }
g_oVLOOKUPCache.remove(__cell);
g_oHLOOKUPCache.remove(__cell);
__cell.setFormulaCA(res.ca); __cell.setFormulaCA(res.ca);
if( res.numFormat !== undefined && res.numFormat >= 0){ if( res.numFormat !== undefined && res.numFormat >= 0){
......
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