Commit de5df82f authored by GoshaZotov's avatar GoshaZotov

recalculate formulas after set hidden row into tables

parent 8361d4e2
......@@ -3970,6 +3970,8 @@
{
this.getRange3(start,0,stop, 0)._foreachRow(fProcessRow);
}
//todo возможно стоит вызывать эту функцию только в случае открытия строк
this.autoFilters.recalFormulasAfterTableRowHidden(start, stop);
};
Worksheet.prototype.getRowHidden=function(index){
var res;
......@@ -4024,6 +4026,7 @@
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){
//start, stop 0 based
......
......@@ -370,6 +370,9 @@
this.worksheet = currentSheet;
this.changeFilters = null;
this.needRecalcFormulas = false;
this.doNotRecalcFormulas = false;
this.m_oColor = new AscCommon.CColor(120, 120, 120);
return this;
}
......@@ -592,12 +595,14 @@
var rangeOldFilter = null;
//**get filter**
var filterObj = this._getPressedFilter(ar, autoFiltersObject.cellId)
var filterObj = this._getPressedFilter(ar, autoFiltersObject.cellId);
var currentFilter = filterObj.filter;
if(filterObj.filter === null)
return;
this._waitRecalFormulasAfterTableRowHidden(true);
//if apply a/f from context menu
if(autoFiltersObject && null === autoFiltersObject.automaticRowCount && currentFilter.isAutoFilter() && currentFilter.isApplyAutoFilter() === false)
{
......@@ -759,6 +764,7 @@
{
this._resetTablePartStyle();
}
this._waitRecalFormulasAfterTableRowHidden(false);
return {minChangeRow: minChangeRow, rangeOldFilter: rangeOldFilter, nOpenRowsCount: nOpenRowsCount, nAllRowsCount: nAllRowsCount};
},
......@@ -770,6 +776,8 @@
var bRedoChanges = worksheet.workbook.bRedoChanges;
var minChangeRow;
this._waitRecalFormulasAfterTableRowHidden(true);
//**get filter**
var filter = this._getFilterByDisplayName(displayName);
var autoFilter = filter && false === filter.isAutoFilter() ? filter.AutoFilter : filter;
......@@ -811,6 +819,7 @@
History.EndTransaction();
this._waitRecalFormulasAfterTableRowHidden(false);
return {minChangeRow: minChangeRow, updateRange: filter.Ref, filter: filter};
},
......@@ -1285,6 +1294,8 @@
return bRes;
};
this._waitRecalFormulasAfterTableRowHidden(true);
if(worksheet.AutoFilter && !bNotDeleteAutoFilter)
{
changeFilter(worksheet.AutoFilter);
......@@ -1298,6 +1309,7 @@
}
}
this._waitRecalFormulasAfterTableRowHidden(false);
t._setStyleTablePartsAfterOpenRows(activeCells);
History.EndTransaction();
......@@ -1358,6 +1370,40 @@
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) {
for(var i = 0; i < redrawTablesArr.length; i++) {
this._cleanStyleTable(redrawTablesArr[i].oldfilterRef);
......@@ -2085,6 +2131,8 @@
var bUndoChanges = worksheet.workbook.bUndoChanges;
var bRedoChanges = worksheet.workbook.bRedoChanges;
this._waitRecalFormulasAfterTableRowHidden(true);
if(arnTo == null && arnFrom == null && data)
{
arnTo = data.moveFrom ? data.moveFrom : null;
......@@ -2185,6 +2233,7 @@
}
}
this._waitRecalFormulasAfterTableRowHidden(false);
return isUpdate ? range : null;
},
......@@ -4015,6 +4064,11 @@
values[count] = tempResult;
};
if(isOpenHiddenRows)
{
this._waitRecalFormulasAfterTableRowHidden(true);
}
var maxFilterRow = ref.r2;
var automaticRowCount = null;
......@@ -4113,6 +4167,10 @@
individualCount++;
}
if(isOpenHiddenRows)
{
this._waitRecalFormulasAfterTableRowHidden(false);
}
return {values: this._sortArrayMinMax(values), automaticRowCount: automaticRowCount};
},
......@@ -4215,6 +4273,7 @@
if(colId === null)
return;
this._waitRecalFormulasAfterTableRowHidden(true);
for(var i = ref.r1 + 1; i <= ref.r2; i++)
{
if(worksheet.getRowHidden(i) === false)
......@@ -4225,6 +4284,7 @@
worksheet.setRowHidden(false, i, i);
}
}
this._waitRecalFormulasAfterTableRowHidden(false);
},
_openAllHiddenRowsByFilter: function(filter)
......@@ -4387,7 +4447,6 @@
if(null != options.TotalsRowCount)
totalsRowCount = options.TotalsRowCount;
worksheet.workbook.dependencyFormulas.lockRecal();
if(style && worksheet.workbook.TableStyles && worksheet.workbook.TableStyles.AllStyles)
{
//заполняем названия столбцов
......@@ -4436,14 +4495,12 @@
styleForCurTable = worksheet.workbook.TableStyles.AllStyles[style.Name];
if (!styleForCurTable) {
worksheet.workbook.dependencyFormulas.unlockRecal();
return;
}
//заполняем стили
styleForCurTable.initStyle(worksheet.sheetMergedStyles, bbox, style, headerRowCount, totalsRowCount);
}
worksheet.workbook.dependencyFormulas.unlockRecal();
},
_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