Commit 68f35960 authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

подправил первоначальный пересчет формлу при открытии документа баг "Bug 21503...

подправил первоначальный пересчет формлу при открытии документа баг "Bug 21503 - Длительное открытие XLSX файла из-за большого количества формул"

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50930 954022d7-b5bf-4e40-9824-e11837661b57
parent 31e9a40f
...@@ -1448,83 +1448,67 @@ Workbook.prototype.init=function(){ ...@@ -1448,83 +1448,67 @@ Workbook.prototype.init=function(){
при открытии документа если есть ячейки помеченные как пересчитываемые или есть ячейки без значения. при открытии документа если есть ячейки помеченные как пересчитываемые или есть ячейки без значения.
*/ */
this.buildDependency(); this.buildDependency();
var nR = this.needRecalc, thas = this, timerID, calculatedCells = {}, nRLength = nR.length, timeStart, timeEnd, timeCurrent, timeCount = 0, first = true, sr, timeoutID1; var nR = this.needRecalc, thas = this, calculatedCells = {}, nRLength = nR.length, timeStart, timeEnd, timeCount = 0, first = true, sr;
function R(){ function R() {
while( nR.length > 0 ){
for ( var id in nR ) {
var sr1, sr2; var sr1, sr2;
timeStart = (new Date()).getTime(); timeStart = (new Date()).getTime();
var dep1, f = false, id; var dep1, f = false;
for(var id1 in nR) { if ( id == "length" ) {
if( id1 == "length" ){
continue; continue;
} }
id = id1;
break;
}
if( id in nR){
dep1 = thas.dependencyFormulas.t_sort_master( nR[id][0], nR[id][1] ); dep1 = thas.dependencyFormulas.t_sort_master( nR[id][0], nR[id][1] );
for(var i = 0; i < dep1.badF.length; i++){ for ( var i = 0; i < dep1.badF.length; i++ ) {
for(var j = 0; j < dep1.depF.length; j++){ for ( var j = 0; j < dep1.depF.length; j++ ) {
if(dep1.badF[i] == dep1.depF[j]) if ( dep1.badF[i] == dep1.depF[j] )
dep1.depF.splice(j,1); dep1.depF.splice( j, 1 );
} }
} }
for(var j = 0; j < dep1.depF.length; j++){ for ( var j = 0; j < dep1.depF.length; j++ ) {
if( dep1.depF[j].nodeId in nR){ if ( dep1.depF[j].nodeId in nR ) {
nR[dep1.depF[j].nodeId] = undefined; nR[dep1.depF[j].nodeId] = undefined;
delete nR[dep1.depF[j].nodeId] delete nR[dep1.depF[j].nodeId]
nR.length--; nR.length--;
} }
} }
for(var j = 0; j < dep1.badF.length; j++){ for ( var j = 0; j < dep1.badF.length; j++ ) {
if( dep1.badF[j].nodeId in nR){ if ( dep1.badF[j].nodeId in nR ) {
nR[dep1.badF[j].nodeId] = undefined; nR[dep1.badF[j].nodeId] = undefined;
delete nR[dep1.badF[j].nodeId] delete nR[dep1.badF[j].nodeId]
nR.length--; nR.length--;
} }
} }
sr1 = thas.recalcDependency(dep1.badF,true,true); sr1 = thas.recalcDependency( dep1.badF, true, true );
for(var k = 0; k < dep1.depF.length; k++){ for ( var k = 0; k < dep1.depF.length; k++ ) {
if(dep1.depF[k].nodeId in calculatedCells){ if ( dep1.depF[k].nodeId in calculatedCells ) {
dep1.depF.splice(k,1); dep1.depF.splice( k, 1 );
k--; k--;
} }
} }
sr2 = thas.recalcDependency(dep1.depF,false); sr2 = thas.recalcDependency( dep1.depF, false );
for(var k = 0; k < dep1.depF.length; k++){ for ( var k = 0; k < dep1.depF.length; k++ ) {
calculatedCells[dep1.depF[k].nodeId] = dep1.depF[k].nodeId calculatedCells[dep1.depF[k].nodeId] = dep1.depF[k].nodeId
} }
sr = searchCleenCacheArea( sr, searchCleenCacheArea(sr1,sr2) ); sr = searchCleenCacheArea( sr, searchCleenCacheArea( sr1, sr2 ) );
}
clearTimeout(timerID);
timeEnd = (new Date()).getTime(); timeEnd = (new Date()).getTime();
timeCount += (timeEnd - timeStart); timeCount += (timeEnd - timeStart);
if(first){
thas.isNeedCacheClean = false;
first = false;
if ( thas.startActionOn ){
thas.handlers.trigger("asc_onStartAction",c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Recalc);
thas.startActionOn = false;
}
else{
thas.startActionOn = true;
}
}
} }
clearTimeout( timeoutID1 );
first = false; first = false;
thas.isNeedCacheClean = true; thas.isNeedCacheClean = true;
var ws = thas.getWorksheet(thas.getActive()); var ws = thas.getWorksheet( thas.getActive() );
thas.handlers.trigger("cleanCellCache", ws.getId(), new Asc.Range( 0, 0, ws.getColsCount()-1, ws.getRowsCount()-1 ), c_oAscCanChangeColWidth.numbers); thas.handlers.trigger( "cleanCellCache", ws.getId(), new Asc.Range( 0, 0, ws.getColsCount() - 1, ws.getRowsCount() - 1 ), c_oAscCanChangeColWidth.numbers );
thas.startActionOn = false; thas.startActionOn = false;
thas.handlers.trigger("asc_onEndAction",c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Recalc); thas.handlers.trigger( "asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Recalc );
} }
if( nR.length > 0 ){ if( nR.length > 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