Commit c2876087 authored by konovalovsergey's avatar konovalovsergey

table names after delete sheet

parent 3092544d
......@@ -3772,17 +3772,17 @@ function parserFormula( formula, parent, _ws ) {
eventData.isRebuild = true;
} else if (AscCommon.c_oNotifyType.ChangeSheet === data.type) {
needAssemble = false;
if (this.is3D) {
var changeData = data.data;
if (this.is3D || changeData.remove) {
if (changeData.insert) {
eventData.isRebuild = this.insertSheet(changeData.insert);
} else if (changeData.replace || changeData.remove) {
eventData.isRebuild = true;
var moveSheetRes = 0;
if (changeData.replace) {
moveSheetRes = this.moveSheet(changeData.replace);
if (changeData.remove) {
moveSheetRes = this.removeSheet(changeData.remove, changeData.tableNamesMap);
} else {
moveSheetRes = this.removeSheet(changeData.remove);
moveSheetRes = this.moveSheet(changeData.replace);
}
if (2 === moveSheetRes) {
needAssemble = true;
......@@ -4887,7 +4887,7 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
}
return this;
};
parserFormula.prototype.removeSheet = function(sheetId) {
parserFormula.prototype.removeSheet = function(sheetId, tableNamesMap) {
var nRes = 0;
var ws = this.wb.getWorksheetById(sheetId);
if (ws) {
......@@ -4935,6 +4935,11 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
this.outStack[i] = new cError(cErrorType.bad_reference);
nRes = 2;
}
} else if (cElementType.table === elem.type) {
if (tableNamesMap[elem.tableName]) {
this.outStack[i] = new cError(cErrorType.bad_reference);
nRes = 2;
}
}
}
}
......
......@@ -425,7 +425,7 @@ function getRangeType(oBBox){
this._shiftMoveDelete(AscCommon.c_oNotifyType.Move, sheetId, bboxFrom, offset);
this.addToChangedRange(sheetId, bboxFrom);
},
changeSheet: function(sheetId, data) {
changeSheet: function(sheetId, data, tableNamesMap) {
this.buildDependency();
var listeners = {};
var sheetContainer = this.sheetListeners[sheetId];
......@@ -446,6 +446,17 @@ function getRangeType(oBBox){
listeners[listenerId] = sheetContainer.defName3d[listenerId];
}
}
if(tableNamesMap){
for (var tableName in tableNamesMap) {
var nameIndex = getDefNameIndex(tableName);
var container = this.defNameListeners[nameIndex];
if (container) {
for (var listenerId in container.listeners) {
listeners[listenerId] = container.listeners[listenerId];
}
}
}
}
var notifyData = {type: AscCommon.c_oNotifyType.ChangeSheet, data: data};
for (var listenerId in listeners) {
listeners[listenerId].notify(notifyData);
......@@ -471,11 +482,17 @@ function getRangeType(oBBox){
}
}
//tables
var tableNamesMap = {};
for (var i = 0; i < tableNames.length; ++i) {
this._delDefName(tableNames[i], null);
var tableName = tableNames[i];
var defName = this._delDefName(tableName, null);
if (defName) {
defName.removeDependencies();
}
tableNamesMap[tableName] = 1;
}
//dependence
this.changeSheet(sheetId, {remove: sheetId});
this.changeSheet(sheetId, {remove: sheetId, tableNamesMap: tableNamesMap}, tableNamesMap);
},
//lock
lockRecal: function() {
......
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