Commit de5df82f authored by GoshaZotov's avatar GoshaZotov

recalculate formulas after set hidden row into tables

parent 8361d4e2
...@@ -3970,6 +3970,8 @@ ...@@ -3970,6 +3970,8 @@
{ {
this.getRange3(start,0,stop, 0)._foreachRow(fProcessRow); this.getRange3(start,0,stop, 0)._foreachRow(fProcessRow);
} }
//todo возможно стоит вызывать эту функцию только в случае открытия строк
this.autoFilters.recalFormulasAfterTableRowHidden(start, stop);
}; };
Worksheet.prototype.getRowHidden=function(index){ Worksheet.prototype.getRowHidden=function(index){
var res; var res;
...@@ -4024,6 +4026,7 @@ ...@@ -4024,6 +4026,7 @@
History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_RowHide, oThis.getId(),updateRange, new UndoRedoData_FromToRowCol(bHidden, startIndex, endIndex)); History.Add(AscCommonExcel.g_oUndoRedoWorksheet, AscCH.historyitem_Worksheet_RowHide, oThis.getId(),updateRange, new UndoRedoData_FromToRowCol(bHidden, startIndex, endIndex));
} }
} }
this.autoFilters.recalFormulasAfterTableRowHidden(start, stop);
}; };
Worksheet.prototype.setRowBestFit=function(bBestFit, height, start, stop){ Worksheet.prototype.setRowBestFit=function(bBestFit, height, start, stop){
//start, stop 0 based //start, stop 0 based
......
...@@ -370,6 +370,9 @@ ...@@ -370,6 +370,9 @@
this.worksheet = currentSheet; this.worksheet = currentSheet;
this.changeFilters = null; this.changeFilters = null;
this.needRecalcFormulas = false;
this.doNotRecalcFormulas = false;
this.m_oColor = new AscCommon.CColor(120, 120, 120); this.m_oColor = new AscCommon.CColor(120, 120, 120);
return this; return this;
} }
...@@ -592,12 +595,14 @@ ...@@ -592,12 +595,14 @@
var rangeOldFilter = null; var rangeOldFilter = null;
//**get filter** //**get filter**
var filterObj = this._getPressedFilter(ar, autoFiltersObject.cellId) var filterObj = this._getPressedFilter(ar, autoFiltersObject.cellId);
var currentFilter = filterObj.filter; var currentFilter = filterObj.filter;
if(filterObj.filter === null) if(filterObj.filter === null)
return; return;
this._waitRecalFormulasAfterTableRowHidden(true);
//if apply a/f from context menu //if apply a/f from context menu
if(autoFiltersObject && null === autoFiltersObject.automaticRowCount && currentFilter.isAutoFilter() && currentFilter.isApplyAutoFilter() === false) if(autoFiltersObject && null === autoFiltersObject.automaticRowCount && currentFilter.isAutoFilter() && currentFilter.isApplyAutoFilter() === false)
{ {
...@@ -759,7 +764,8 @@ ...@@ -759,7 +764,8 @@
{ {
this._resetTablePartStyle(); this._resetTablePartStyle();
} }
this._waitRecalFormulasAfterTableRowHidden(false);
return {minChangeRow: minChangeRow, rangeOldFilter: rangeOldFilter, nOpenRowsCount: nOpenRowsCount, nAllRowsCount: nAllRowsCount}; return {minChangeRow: minChangeRow, rangeOldFilter: rangeOldFilter, nOpenRowsCount: nOpenRowsCount, nAllRowsCount: nAllRowsCount};
}, },
...@@ -769,7 +775,9 @@ ...@@ -769,7 +775,9 @@
var bUndoChanges = worksheet.workbook.bUndoChanges; var bUndoChanges = worksheet.workbook.bUndoChanges;
var bRedoChanges = worksheet.workbook.bRedoChanges; var bRedoChanges = worksheet.workbook.bRedoChanges;
var minChangeRow; var minChangeRow;
this._waitRecalFormulasAfterTableRowHidden(true);
//**get filter** //**get filter**
var filter = this._getFilterByDisplayName(displayName); var filter = this._getFilterByDisplayName(displayName);
var autoFilter = filter && false === filter.isAutoFilter() ? filter.AutoFilter : filter; var autoFilter = filter && false === filter.isAutoFilter() ? filter.AutoFilter : filter;
...@@ -810,7 +818,8 @@ ...@@ -810,7 +818,8 @@
} }
History.EndTransaction(); History.EndTransaction();
this._waitRecalFormulasAfterTableRowHidden(false);
return {minChangeRow: minChangeRow, updateRange: filter.Ref, filter: filter}; return {minChangeRow: minChangeRow, updateRange: filter.Ref, filter: filter};
}, },
...@@ -1284,7 +1293,9 @@ ...@@ -1284,7 +1293,9 @@
} }
return bRes; return bRes;
}; };
this._waitRecalFormulasAfterTableRowHidden(true);
if(worksheet.AutoFilter && !bNotDeleteAutoFilter) if(worksheet.AutoFilter && !bNotDeleteAutoFilter)
{ {
changeFilter(worksheet.AutoFilter); changeFilter(worksheet.AutoFilter);
...@@ -1297,7 +1308,8 @@ ...@@ -1297,7 +1308,8 @@
changeFilter(tablePart, true, i); changeFilter(tablePart, true, i);
} }
} }
this._waitRecalFormulasAfterTableRowHidden(false);
t._setStyleTablePartsAfterOpenRows(activeCells); t._setStyleTablePartsAfterOpenRows(activeCells);
History.EndTransaction(); History.EndTransaction();
...@@ -1358,6 +1370,40 @@ ...@@ -1358,6 +1370,40 @@
return false; return false;
}, },
recalFormulasAfterTableRowHidden: function (start, stop) {
var worksheet = this.worksheet;
var tableParts = worksheet.TableParts;
var tablePart;
for (var i = 0; i < tableParts.length; i++) {
tablePart = tableParts[i];
if (tablePart && tablePart.isTotalsRow() && start >= tablePart.Ref.r1 && stop <= tablePart.Ref.r2) {
if(this.doNotRecalcFormulas){
this.needRecalcFormulas = true;
}else{
this._recalcFormulas();
}
break;
}
}
},
_waitRecalFormulasAfterTableRowHidden: function(bWait){
if(bWait){
this.doNotRecalcFormulas = true;
} else {
if(this.needRecalcFormulas){
this._recalcFormulas();
}
this.needRecalcFormulas = false;
this.doNotRecalcFormulas = false;
}
},
_recalcFormulas: function(){
this.worksheet.workbook.dependencyFormulas.calcTree();
},
_cleanStylesTables: function(redrawTablesArr) { _cleanStylesTables: function(redrawTablesArr) {
for(var i = 0; i < redrawTablesArr.length; i++) { for(var i = 0; i < redrawTablesArr.length; i++) {
this._cleanStyleTable(redrawTablesArr[i].oldfilterRef); this._cleanStyleTable(redrawTablesArr[i].oldfilterRef);
...@@ -2084,6 +2130,8 @@ ...@@ -2084,6 +2130,8 @@
var bUndoChanges = worksheet.workbook.bUndoChanges; var bUndoChanges = worksheet.workbook.bUndoChanges;
var bRedoChanges = worksheet.workbook.bRedoChanges; var bRedoChanges = worksheet.workbook.bRedoChanges;
this._waitRecalFormulasAfterTableRowHidden(true);
if(arnTo == null && arnFrom == null && data) if(arnTo == null && arnFrom == null && data)
{ {
...@@ -2184,7 +2232,8 @@ ...@@ -2184,7 +2232,8 @@
worksheet.getRange3(tablePart.Ref.r1, tablePart.Ref.c1, tablePart.Ref.r2, tablePart.Ref.c2).unmerge(); worksheet.getRange3(tablePart.Ref.r1, tablePart.Ref.c1, tablePart.Ref.r2, tablePart.Ref.c2).unmerge();
} }
} }
this._waitRecalFormulasAfterTableRowHidden(false);
return isUpdate ? range : null; return isUpdate ? range : null;
}, },
...@@ -4014,7 +4063,12 @@ ...@@ -4014,7 +4063,12 @@
else*/ else*/
values[count] = tempResult; values[count] = tempResult;
}; };
if(isOpenHiddenRows)
{
this._waitRecalFormulasAfterTableRowHidden(true);
}
var maxFilterRow = ref.r2; var maxFilterRow = ref.r2;
var automaticRowCount = null; var automaticRowCount = null;
...@@ -4113,6 +4167,10 @@ ...@@ -4113,6 +4167,10 @@
individualCount++; individualCount++;
} }
if(isOpenHiddenRows)
{
this._waitRecalFormulasAfterTableRowHidden(false);
}
return {values: this._sortArrayMinMax(values), automaticRowCount: automaticRowCount}; return {values: this._sortArrayMinMax(values), automaticRowCount: automaticRowCount};
}, },
...@@ -4214,7 +4272,8 @@ ...@@ -4214,7 +4272,8 @@
if(colId === null) if(colId === null)
return; return;
this._waitRecalFormulasAfterTableRowHidden(true);
for(var i = ref.r1 + 1; i <= ref.r2; i++) for(var i = ref.r1 + 1; i <= ref.r2; i++)
{ {
if(worksheet.getRowHidden(i) === false) if(worksheet.getRowHidden(i) === false)
...@@ -4225,6 +4284,7 @@ ...@@ -4225,6 +4284,7 @@
worksheet.setRowHidden(false, i, i); worksheet.setRowHidden(false, i, i);
} }
} }
this._waitRecalFormulasAfterTableRowHidden(false);
}, },
_openAllHiddenRowsByFilter: function(filter) _openAllHiddenRowsByFilter: function(filter)
...@@ -4386,8 +4446,7 @@ ...@@ -4386,8 +4446,7 @@
headerRowCount = options.HeaderRowCount; headerRowCount = options.HeaderRowCount;
if(null != options.TotalsRowCount) if(null != options.TotalsRowCount)
totalsRowCount = options.TotalsRowCount; totalsRowCount = options.TotalsRowCount;
worksheet.workbook.dependencyFormulas.lockRecal();
if(style && worksheet.workbook.TableStyles && worksheet.workbook.TableStyles.AllStyles) if(style && worksheet.workbook.TableStyles && worksheet.workbook.TableStyles.AllStyles)
{ {
//заполняем названия столбцов //заполняем названия столбцов
...@@ -4436,14 +4495,12 @@ ...@@ -4436,14 +4495,12 @@
styleForCurTable = worksheet.workbook.TableStyles.AllStyles[style.Name]; styleForCurTable = worksheet.workbook.TableStyles.AllStyles[style.Name];
if (!styleForCurTable) { if (!styleForCurTable) {
worksheet.workbook.dependencyFormulas.unlockRecal();
return; return;
} }
//заполняем стили //заполняем стили
styleForCurTable.initStyle(worksheet.sheetMergedStyles, bbox, style, headerRowCount, totalsRowCount); styleForCurTable.initStyle(worksheet.sheetMergedStyles, bbox, style, headerRowCount, totalsRowCount);
} }
worksheet.workbook.dependencyFormulas.unlockRecal();
}, },
_getFormatTableColumnRange: function(table, columnName) _getFormatTableColumnRange: function(table, columnName)
......
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