Commit a4c52c6c authored by konovalovsergey's avatar konovalovsergey

renameSheetCopy dependence leak; cStrucTable error parse with wrong column...

renameSheetCopy dependence leak; cStrucTable error parse with wrong column name; getByCells speedup; write formulas history before filter history; minor bugs
parent 4f6138e6
...@@ -1688,23 +1688,27 @@ cStrucTable.prototype.toLocaleString = function () { ...@@ -1688,23 +1688,27 @@ cStrucTable.prototype.toLocaleString = function () {
data = data.substr(0, data.length - 1); data = data.substr(0, data.length - 1);
if (this.hdtcstart) { if (this.hdtcstart) {
if (this.hdtcstartIndex) {
columns_1 = this.wb.getTableNameColumnByIndex(this.tableName, this.hdtcstartIndex.index); columns_1 = this.wb.getTableNameColumnByIndex(this.tableName, this.hdtcstartIndex.index);
if (columns_1) { if (columns_1) {
this.hdtcstart = columns_1.columnName; this.hdtcstart = columns_1.columnName;
} else if (this.hdtcstartIndex.name) { } else if (this.hdtcstartIndex.name) {
this.hdtcstart = this.hdtcstartIndex.name; this.hdtcstart = this.hdtcstartIndex.name;
} }
}
data += FormulaSeparators.functionArgumentSeparatorDef + "[" + this.hdtcstart.replace(/#/g, "'#") + "]" data += FormulaSeparators.functionArgumentSeparatorDef + "[" + this.hdtcstart.replace(/#/g, "'#") + "]"
} }
if (this.hdtcend) { if (this.hdtcend) {
if (this.hdtcendIndex) {
columns_2 = this.wb.getTableNameColumnByIndex(this.tableName, this.hdtcendIndex.index); columns_2 = this.wb.getTableNameColumnByIndex(this.tableName, this.hdtcendIndex.index);
if (columns_2) { if (columns_2) {
this.hdtcend = columns_2.columnName; this.hdtcend = columns_2.columnName;
} else if (this.hdtcendIndex.name) { } else if (this.hdtcendIndex.name) {
this.hdtcend = this.hdtcendIndex.name; this.hdtcend = this.hdtcendIndex.name;
} }
}
data += ":[" + this.hdtcend.replace(/#/g, "'#") + "]" data += ":[" + this.hdtcend.replace(/#/g, "'#") + "]"
} }
...@@ -1738,7 +1742,7 @@ cStrucTable.prototype.toLocaleString = function () { ...@@ -1738,7 +1742,7 @@ cStrucTable.prototype.toLocaleString = function () {
this.colStartIndex = this.wb.getTableIndexColumnByName(this.tableName, this.colStart); this.colStartIndex = this.wb.getTableIndexColumnByName(this.tableName, this.colStart);
this.colEndIndex = this.wb.getTableIndexColumnByName(this.tableName, this.colEnd); this.colEndIndex = this.wb.getTableIndexColumnByName(this.tableName, this.colEnd);
if (!this.colStartIndex && !this.colEndIndex) { if (!this.colStartIndex || !this.colEndIndex) {
return this._createAreaError(paramObj); return this._createAreaError(paramObj);
} }
} else { } else {
...@@ -4994,6 +4998,12 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) { ...@@ -4994,6 +4998,12 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
return this; return this;
}; };
parserFormula.prototype.renameSheetCopy = function(params) { parserFormula.prototype.renameSheetCopy = function(params) {
var isInDependencies = this.isInDependencies;
if (isInDependencies) {
//before change outStack necessary to removeDependencies
this.removeDependencies();
}
for (var i = 0; i < this.outStack.length; i++) { for (var i = 0; i < this.outStack.length; i++) {
var elem = this.outStack[i]; var elem = this.outStack[i];
if (cElementType.cell3D === elem.type) { if (cElementType.cell3D === elem.type) {
...@@ -5029,6 +5039,9 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) { ...@@ -5029,6 +5039,9 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
} }
} }
} }
if (isInDependencies) {
this.buildDependencies();
}
return this; return this;
}; };
parserFormula.prototype.removeSheet = function(sheetId, tableNamesMap) { parserFormula.prototype.removeSheet = function(sheetId, tableNamesMap) {
......
...@@ -268,7 +268,8 @@ ...@@ -268,7 +268,8 @@
} }
function getVertexIndex(bbox) { function getVertexIndex(bbox) {
return bbox.getName(); //without $
return bbox.getAbsName2(false, false, false, false);
} }
function DependencyGraph(wb) { function DependencyGraph(wb) {
...@@ -755,6 +756,9 @@ ...@@ -755,6 +756,9 @@
delTableName: function(tableName) { delTableName: function(tableName) {
this.buildDependency(); this.buildDependency();
var defName = this._delDefName(tableName, null); var defName = this._delDefName(tableName, null);
if (defName) {
defName.removeDependencies();
}
this.addToChangedDefName(defName); this.addToChangedDefName(defName);
var notifyData = {type: AscCommon.c_oNotifyType.ChangeDefName, from: defName.getUndoDefName(), to: null}; var notifyData = {type: AscCommon.c_oNotifyType.ChangeDefName, from: defName.getUndoDefName(), to: null};
this._broadcastDefName(tableName, notifyData); this._broadcastDefName(tableName, notifyData);
...@@ -920,7 +924,7 @@ ...@@ -920,7 +924,7 @@
}, },
getAllFormulas: function(formulas) { getAllFormulas: function(formulas) {
this._foreachDefName(function(defName) { this._foreachDefName(function(defName) {
if (!defName.isTable && defName.parsedRef) { if (defName.parsedRef) {
formulas.push(defName.parsedRef); formulas.push(defName.parsedRef);
} }
}); });
...@@ -1220,7 +1224,14 @@ ...@@ -1220,7 +1224,14 @@
for (var id in curNodeY.storedValue.vals) { for (var id in curNodeY.storedValue.vals) {
var elem = curNodeY.storedValue.vals[id]; var elem = curNodeY.storedValue.vals[id];
if (0 !== (1 & elem.startFlag) && !elem.dataWrap.isOutput) { if (0 !== (1 & elem.startFlag) && !elem.dataWrap.isOutput) {
curNodes[id] = elem; for (var i = elem.dataWrap.bbox.c1; i <= elem.dataWrap.bbox.c2; ++i) {
var curNodesElem = curNodes[i];
if (!curNodesElem) {
curNodesElem = {};
curNodes[i] = curNodesElem;
}
curNodesElem[id] = elem;
}
} }
} }
} }
...@@ -1231,12 +1242,18 @@ ...@@ -1231,12 +1242,18 @@
curCellY = g_FCI.row; curCellY = g_FCI.row;
} }
if (curCellY <= curY) { if (curCellY <= curY) {
for (var id in curNodes) { var curNodesElemX = curNodes[curCellX];
var elem = curNodes[id]; for (var id in curNodesElemX) {
if (elem && elem.dataWrap.bbox.contains(curCellX, curCellY)) { var elem = curNodesElemX[id];
if (!elem.dataWrap.isOutput) {
elem.dataWrap.isOutput = true; elem.dataWrap.isOutput = true;
res.push(elem.dataWrap); res.push(elem.dataWrap);
delete curNodes[id]; for (var i = elem.dataWrap.bbox.c1; i <= elem.dataWrap.bbox.c2; ++i) {
var curNodesElem = curNodes[i];
if (curNodesElem) {
delete curNodesElem[id];
}
}
} }
} }
curCellIndex++; curCellIndex++;
...@@ -1246,7 +1263,12 @@ ...@@ -1246,7 +1263,12 @@
for (var id in curNodeY.storedValue.vals) { for (var id in curNodeY.storedValue.vals) {
var elem = curNodeY.storedValue.vals[id]; var elem = curNodeY.storedValue.vals[id];
if (0 !== (2 & elem.startFlag) && !elem.dataWrap.isOutput) { if (0 !== (2 & elem.startFlag) && !elem.dataWrap.isOutput) {
delete curNodes[id]; for (var i = elem.dataWrap.bbox.c1; i <= elem.dataWrap.bbox.c2; ++i) {
var curNodesElem = curNodes[i];
if (curNodesElem) {
delete curNodesElem[id];
}
}
} }
} }
curNodeYIndex++; curNodeYIndex++;
...@@ -4357,7 +4379,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){ ...@@ -4357,7 +4379,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
} }
return res; return res;
}; };
Woorksheet.prototype.renameDependencyNodes = function(offset, oBBox, rec, noDelete){ Woorksheet.prototype.renameDependencyNodes = function(offset, oBBox){
return this.workbook.dependencyFormulas.shift(this.Id, oBBox, offset); return this.workbook.dependencyFormulas.shift(this.Id, oBBox, offset);
}; };
Woorksheet.prototype.getAllCol = function(){ Woorksheet.prototype.getAllCol = function(){
...@@ -4753,7 +4775,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){ ...@@ -4753,7 +4775,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
cell.removeHyperlink(); cell.removeHyperlink();
} }
}; };
Cell.prototype.setFormula = function(formula) { Cell.prototype.setFormula = function(formula, bHistoryUndo) {
var DataOld = null; var DataOld = null;
var DataNew = null; var DataNew = null;
if (History.Is_On()) if (History.Is_On())
...@@ -4766,8 +4788,10 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){ ...@@ -4766,8 +4788,10 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
if (History.Is_On()) { if (History.Is_On()) {
DataNew = this.getValueData(); DataNew = this.getValueData();
if (false == DataOld.isEqual(DataNew)) if (false == DataOld.isEqual(DataNew)){
History.Add(AscCommonExcel.g_oUndoRedoCell, AscCH.historyitem_Cell_ChangeValue, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, DataOld, DataNew)); var typeHistory = bHistoryUndo ? AscCH.historyitem_Cell_ChangeValueUndo : AscCH.historyitem_Cell_ChangeValue;
History.Add(AscCommonExcel.g_oUndoRedoCell, typeHistory, this.ws.getId(), new Asc.Range(this.nCol, this.nRow, this.nCol, this.nRow), new UndoRedoData_CellSimpleData(this.nRow, this.nCol, DataOld, DataNew), bHistoryUndo);}
} }
}; };
Cell.prototype.removeDependencies = function() { Cell.prototype.removeDependencies = function() {
...@@ -5182,7 +5206,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){ ...@@ -5182,7 +5206,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
} else if (AscCommon.c_oNotifyParentType.ChangeFormula === type) { } else if (AscCommon.c_oNotifyParentType.ChangeFormula === type) {
var DataOld = this.getValueData(); var DataOld = this.getValueData();
if (eventData.isRebuild) { if (eventData.isRebuild) {
this.setFormula(eventData.assemble); this.setFormula(eventData.assemble, true);
} else { } else {
this.formulaParsed.Formula = eventData.assemble; this.formulaParsed.Formula = eventData.assemble;
this.formulaParsed.buildDependencies(); this.formulaParsed.buildDependencies();
......
...@@ -1182,7 +1182,7 @@ ...@@ -1182,7 +1182,7 @@
History.StartTransaction(); History.StartTransaction();
var changeFilter = function(filter, isTablePart) var changeFilter = function(filter, isTablePart, index)
{ {
var bRes = false; var bRes = false;
var oldFilter = filter.clone(null); var oldFilter = filter.clone(null);
...@@ -1192,9 +1192,11 @@ ...@@ -1192,9 +1192,11 @@
//смотрим находится ли фильтр(первая его строчка) внутри выделенного фрагмента //смотрим находится ли фильтр(первая его строчка) внутри выделенного фрагмента
if ((activeCells.containsFirstLineRange(bbox) && !isTablePart) || (isTablePart && activeCells.containsRange(bbox))) { if ((activeCells.containsFirstLineRange(bbox) && !isTablePart) || (isTablePart && activeCells.containsRange(bbox))) {
if(isTablePart) if(isTablePart) {
oRange.setTableStyle(null); oRange.setTableStyle(null);
else //write formulas history before filter history
worksheet.deleteTablePart(index);
} else
worksheet.AutoFilter = null; worksheet.AutoFilter = null;
//открываем скрытые строки //открываем скрытые строки
...@@ -1221,9 +1223,7 @@ ...@@ -1221,9 +1223,7 @@
for (var i = worksheet.TableParts.length - 1; i >= 0; i--) for (var i = worksheet.TableParts.length - 1; i >= 0; i--)
{ {
var tablePart = worksheet.TableParts[i]; var tablePart = worksheet.TableParts[i];
if (changeFilter(tablePart, true)) { changeFilter(tablePart, true, i);
worksheet.deleteTablePart(i);
}
} }
} }
...@@ -2938,6 +2938,8 @@ ...@@ -2938,6 +2938,8 @@
if(worksheet.TableParts) if(worksheet.TableParts)
{ {
worksheet.workbook.dependencyFormulas.buildDependency(); worksheet.workbook.dependencyFormulas.buildDependency();
//without lockRecal each setValue call calculation
worksheet.workbook.dependencyFormulas.lockRecal();
for(var i = 0; i < worksheet.TableParts.length; i++) for(var i = 0; i < worksheet.TableParts.length; i++)
{ {
var filter = worksheet.TableParts[i]; var filter = worksheet.TableParts[i];
...@@ -2950,6 +2952,7 @@ ...@@ -2950,6 +2952,7 @@
var intersection = range.intersection(tableRange); var intersection = range.intersection(tableRange);
if(null !== intersection && 0 !== filter.HeaderRowCount) if(null !== intersection && 0 !== filter.HeaderRowCount)
{ {
var toHistory = [];
//проходимся по всем заголовкам //проходимся по всем заголовкам
for(var j = tableRange.c1; j <= tableRange.c2; j++) for(var j = tableRange.c1; j <= tableRange.c2; j++)
{ {
...@@ -2992,17 +2995,21 @@ ...@@ -2992,17 +2995,21 @@
if(null !== newVal) if(null !== newVal)
{ {
this._addHistoryObj({nCol: cell.bbox.c1, nRow: cell.bbox.r1, val: oldVal}, AscCH.historyitem_AutoFilter_ChangeColumnName, {activeCells: range, nCol: cell.bbox.c1, nRow: cell.bbox.r1, val: newVal}); toHistory.push([{nCol: cell.bbox.c1, nRow: cell.bbox.r1, val: oldVal}, AscCH.historyitem_AutoFilter_ChangeColumnName, {activeCells: range, nCol: cell.bbox.c1, nRow: cell.bbox.r1, val: newVal}]);
} }
} }
//write formulas history before filter history
worksheet.handlers.trigger("changeColumnTablePart", filter.DisplayName); worksheet.handlers.trigger("changeColumnTablePart", filter.DisplayName);
for (var i = 0; i < toHistory.length; ++i) {
this._addHistoryObj.apply(this, toHistory[i]);
}
} }
else else
{ {
this._changeTotalsRowData(filter, range, props); this._changeTotalsRowData(filter, range, props);
} }
} }
worksheet.workbook.dependencyFormulas.unlockRecal();
} }
}, },
......
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