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,22 +1688,26 @@ cStrucTable.prototype.toLocaleString = function () {
data = data.substr(0, data.length - 1);
if (this.hdtcstart) {
columns_1 = this.wb.getTableNameColumnByIndex(this.tableName, this.hdtcstartIndex.index);
if (columns_1) {
this.hdtcstart = columns_1.columnName;
} else if (this.hdtcstartIndex.name) {
this.hdtcstart = this.hdtcstartIndex.name;
if (this.hdtcstartIndex) {
columns_1 = this.wb.getTableNameColumnByIndex(this.tableName, this.hdtcstartIndex.index);
if (columns_1) {
this.hdtcstart = columns_1.columnName;
} else if (this.hdtcstartIndex.name) {
this.hdtcstart = this.hdtcstartIndex.name;
}
}
data += FormulaSeparators.functionArgumentSeparatorDef + "[" + this.hdtcstart.replace(/#/g, "'#") + "]"
}
if (this.hdtcend) {
columns_2 = this.wb.getTableNameColumnByIndex(this.tableName, this.hdtcendIndex.index);
if (columns_2) {
this.hdtcend = columns_2.columnName;
} else if (this.hdtcendIndex.name) {
this.hdtcend = this.hdtcendIndex.name;
if (this.hdtcendIndex) {
columns_2 = this.wb.getTableNameColumnByIndex(this.tableName, this.hdtcendIndex.index);
if (columns_2) {
this.hdtcend = columns_2.columnName;
} else if (this.hdtcendIndex.name) {
this.hdtcend = this.hdtcendIndex.name;
}
}
data += ":[" + this.hdtcend.replace(/#/g, "'#") + "]"
......@@ -1738,7 +1742,7 @@ cStrucTable.prototype.toLocaleString = function () {
this.colStartIndex = this.wb.getTableIndexColumnByName(this.tableName, this.colStart);
this.colEndIndex = this.wb.getTableIndexColumnByName(this.tableName, this.colEnd);
if (!this.colStartIndex && !this.colEndIndex) {
if (!this.colStartIndex || !this.colEndIndex) {
return this._createAreaError(paramObj);
}
} else {
......@@ -4994,6 +4998,12 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
return this;
};
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++) {
var elem = this.outStack[i];
if (cElementType.cell3D === elem.type) {
......@@ -5029,6 +5039,9 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
}
}
}
if (isInDependencies) {
this.buildDependencies();
}
return this;
};
parserFormula.prototype.removeSheet = function(sheetId, tableNamesMap) {
......
......@@ -268,7 +268,8 @@
}
function getVertexIndex(bbox) {
return bbox.getName();
//without $
return bbox.getAbsName2(false, false, false, false);
}
function DependencyGraph(wb) {
......@@ -755,6 +756,9 @@
delTableName: function(tableName) {
this.buildDependency();
var defName = this._delDefName(tableName, null);
if (defName) {
defName.removeDependencies();
}
this.addToChangedDefName(defName);
var notifyData = {type: AscCommon.c_oNotifyType.ChangeDefName, from: defName.getUndoDefName(), to: null};
this._broadcastDefName(tableName, notifyData);
......@@ -920,7 +924,7 @@
},
getAllFormulas: function(formulas) {
this._foreachDefName(function(defName) {
if (!defName.isTable && defName.parsedRef) {
if (defName.parsedRef) {
formulas.push(defName.parsedRef);
}
});
......@@ -1220,7 +1224,14 @@
for (var id in curNodeY.storedValue.vals) {
var elem = curNodeY.storedValue.vals[id];
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 @@
curCellY = g_FCI.row;
}
if (curCellY <= curY) {
for (var id in curNodes) {
var elem = curNodes[id];
if (elem && elem.dataWrap.bbox.contains(curCellX, curCellY)) {
var curNodesElemX = curNodes[curCellX];
for (var id in curNodesElemX) {
var elem = curNodesElemX[id];
if (!elem.dataWrap.isOutput) {
elem.dataWrap.isOutput = true;
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++;
......@@ -1246,7 +1263,12 @@
for (var id in curNodeY.storedValue.vals) {
var elem = curNodeY.storedValue.vals[id];
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++;
......@@ -4357,7 +4379,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
}
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);
};
Woorksheet.prototype.getAllCol = function(){
......@@ -4753,7 +4775,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
cell.removeHyperlink();
}
};
Cell.prototype.setFormula = function(formula) {
Cell.prototype.setFormula = function(formula, bHistoryUndo) {
var DataOld = null;
var DataNew = null;
if (History.Is_On())
......@@ -4766,8 +4788,10 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
if (History.Is_On()) {
DataNew = this.getValueData();
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));
if (false == DataOld.isEqual(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() {
......@@ -5182,7 +5206,7 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
} else if (AscCommon.c_oNotifyParentType.ChangeFormula === type) {
var DataOld = this.getValueData();
if (eventData.isRebuild) {
this.setFormula(eventData.assemble);
this.setFormula(eventData.assemble, true);
} else {
this.formulaParsed.Formula = eventData.assemble;
this.formulaParsed.buildDependencies();
......
......@@ -1182,7 +1182,7 @@
History.StartTransaction();
var changeFilter = function(filter, isTablePart)
var changeFilter = function(filter, isTablePart, index)
{
var bRes = false;
var oldFilter = filter.clone(null);
......@@ -1192,9 +1192,11 @@
//смотрим находится ли фильтр(первая его строчка) внутри выделенного фрагмента
if ((activeCells.containsFirstLineRange(bbox) && !isTablePart) || (isTablePart && activeCells.containsRange(bbox))) {
if(isTablePart)
if(isTablePart) {
oRange.setTableStyle(null);
else
//write formulas history before filter history
worksheet.deleteTablePart(index);
} else
worksheet.AutoFilter = null;
//открываем скрытые строки
......@@ -1221,9 +1223,7 @@
for (var i = worksheet.TableParts.length - 1; i >= 0; i--)
{
var tablePart = worksheet.TableParts[i];
if (changeFilter(tablePart, true)) {
worksheet.deleteTablePart(i);
}
changeFilter(tablePart, true, i);
}
}
......@@ -2938,6 +2938,8 @@
if(worksheet.TableParts)
{
worksheet.workbook.dependencyFormulas.buildDependency();
//without lockRecal each setValue call calculation
worksheet.workbook.dependencyFormulas.lockRecal();
for(var i = 0; i < worksheet.TableParts.length; i++)
{
var filter = worksheet.TableParts[i];
......@@ -2950,6 +2952,7 @@
var intersection = range.intersection(tableRange);
if(null !== intersection && 0 !== filter.HeaderRowCount)
{
var toHistory = [];
//проходимся по всем заголовкам
for(var j = tableRange.c1; j <= tableRange.c2; j++)
{
......@@ -2989,20 +2992,24 @@
filter.TableColumns[j - tableRange.c1].Name = generateName;
newVal = generateName;
}
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);
for (var i = 0; i < toHistory.length; ++i) {
this._addHistoryObj.apply(this, toHistory[i]);
}
}
else
{
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