Commit c2876087 authored by konovalovsergey's avatar konovalovsergey

table names after delete sheet

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