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