Commit 591b909d authored by konovalovsergey's avatar konovalovsergey

removeDependencies in cArea3D, removeSheet formula error

parent 38ff9fb9
......@@ -1112,6 +1112,8 @@ function cArea3D( val, wsFrom, wsTo, wb ) {/*Area3D means "Sheat1!A1:E5" for exa
}
this.wsFrom = this._wb.getWorksheetByName( wsFrom ).getId();
this.wsTo = this._wb.getWorksheetByName( wsTo ).getId();
//dependenceRange allow change sheets and then independently removeDependencies
this.dependenceRange = null;
}
cArea3D.prototype = Object.create( cBaseType.prototype );
......@@ -4642,7 +4644,7 @@ parserFormula.prototype.parse = function(local, digitDelim) {
/* Referens to DefinedNames */ else if (parserHelp.isName.call(this, this.Formula, this.pCurrPos, this.wb,
this.ws)[0]) {
found_operand = new cName(this.operand_str, this.wb, this.ws);
found_operand = new cName(this.operand_str, this.wb, this.ws);
var defName = found_operand.getDefName();
if (defName && defName.isTable) {
//need assemble becase source formula wrong
......@@ -5267,6 +5269,7 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
this.wb.dependencyFormulas.startListeningRange(ref.getWsId(), bbox, this);
} else if (cElementType.cellsRange3D === ref.type && ref.isValid()) {
wsR = ref.range(ref.wsRange());
ref.dependenceRange = wsR;
for (var j = 0; j < wsR.length; j++) {
var range = wsR[j];
if (range) {
......@@ -5327,8 +5330,8 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
bbox.setOffsetLast({offsetRow: 1, offsetCol: 0});
}
this.wb.dependencyFormulas.endListeningRange(ref.getWsId(), bbox, this);
} else if (cElementType.cellsRange3D === ref.type && ref.isValid()) {
wsR = ref.range(ref.wsRange());
} else if (cElementType.cellsRange3D === ref.type && ref.isValid() && ref.dependenceRange) {
wsR = ref.dependenceRange;
for (var j = 0; j < wsR.length; j++) {
var range = wsR[j];
if (range) {
......
......@@ -465,32 +465,24 @@
}
},
removeSheet: function(sheetId, tableNames) {
var t = this;
//cells
var sheet = this.wb.getWorksheetById(sheetId);
var range = sheet.getRange3(0, 0, gc_nMaxRow0, gc_nMaxCol0);
range._setPropertyNoEmpty(null, null, function(cell){
if (cell.formulaParsed) {
cell.formulaParsed.removeDependencies();
var formulas = [];
this.wb.getWorksheetById(sheetId).getAllFormulas(formulas);
for (var i = 0; i < formulas.length; ++i) {
formulas[i].removeDependencies();
}
});
//defnames
var sheetContainerFrom = this.defNames.sheet[sheetId];
if (sheetContainerFrom) {
for (var name in sheetContainerFrom) {
var defNameOld = sheetContainerFrom[name];
if (!defNameOld.isTable) {
this._removeDefName(sheetId, name, AscCH.historyitem_Workbook_DefinedNamesChangeUndo);
this._foreachDefNameSheet(sheetId, function(defName){
if (!defName.isTable) {
t._removeDefName(sheetId, defName.name, AscCH.historyitem_Workbook_DefinedNamesChangeUndo);
}
}
}
});
//tables
var tableNamesMap = {};
for (var i = 0; i < tableNames.length; ++i) {
var tableName = tableNames[i];
var defName = this._delDefName(tableName, null);
if (defName) {
defName.removeDependencies();
}
this._removeDefName(null, tableName, null);
tableNamesMap[tableName] = 1;
}
//dependence
......@@ -955,9 +947,11 @@
_removeDefName: function(sheetId, name, historyType) {
var defName = this._delDefName(name, sheetId);
if (defName) {
History.Create_NewPoint();
History.Add(AscCommonExcel.g_oUndoRedoWorkbook, historyType, null, null,
new UndoRedoData_FromTo(defName.getUndoDefName(), null));
if (null != historyType) {
History.Create_NewPoint();
History.Add(AscCommonExcel.g_oUndoRedoWorkbook, historyType, null, null,
new UndoRedoData_FromTo(defName.getUndoDefName(), null));
}
defName.removeDependencies();
this.addToChangedDefName(defName);
......
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