Commit 8b09f332 authored by konovalovsergey's avatar konovalovsergey

extend table formula listening with header/total; change changeRefTablePart...

extend table formula listening with header/total; change changeRefTablePart interface; prevent multiple broadcast defname
parent 3bdbb9bd
...@@ -1840,6 +1840,11 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) { ...@@ -1840,6 +1840,11 @@ cStrucTable.prototype._createArea = function ( val, opt_bbox ) {
cStrucTable.prototype._buildLocalTableString = function (reservedColumn,local) { cStrucTable.prototype._buildLocalTableString = function (reservedColumn,local) {
return parserHelp.getColumnNameByType(reservedColumn, local); return parserHelp.getColumnNameByType(reservedColumn, local);
}; };
cStrucTable.prototype.changeDefName = function (from, to) {
if (this.tableName == from.name) {
this.tableName = to.name;
}
};
/** @constructor */ /** @constructor */
function cName3D(val, wb, ws) { function cName3D(val, wb, ws) {
...@@ -4733,16 +4738,11 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) { ...@@ -4733,16 +4738,11 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
return elem; return elem;
}; };
parserFormula.prototype.changeDefName = function(from, to) { parserFormula.prototype.changeDefName = function(from, to) {
var i, elem, sheetId; var i, elem;
for (i = 0; i < this.outStack.length; i++) { for (i = 0; i < this.outStack.length; i++) {
elem = this.outStack[i]; elem = this.outStack[i];
if (elem.type == cElementType.name || elem.type == cElementType.name3D) { if (elem.type == cElementType.name || elem.type == cElementType.name3D || elem.type == cElementType.table) {
elem.changeDefName(from, to); elem.changeDefName(from, to);
} else if (elem.type == cElementType.table) {
sheetId = elem.ws ? elem.ws.getId() : null;
if (elem.tableName == from.name && (null == from.sheetId || sheetId == from.sheetId )) {
elem.tableName = to.name;
}
} }
} }
}; };
......
...@@ -201,7 +201,7 @@ function getRangeType(oBBox){ ...@@ -201,7 +201,7 @@ function getRangeType(oBBox){
this.ref = ref; this.ref = ref;
//all ref should be 3d, so worksheet can be anyone //all ref should be 3d, so worksheet can be anyone
this.parsedRef = new parserFormula(ref, this, AscCommonExcel.g_DefNameWorksheet); this.parsedRef = new parserFormula(ref, this, AscCommonExcel.g_DefNameWorksheet);
this.parsedRef.setIsTable(true); this.parsedRef.setIsTable(this.isTable);
if (opt_forceBuild) { if (opt_forceBuild) {
this.parsedRef.parse(); this.parsedRef.parse();
this.parsedRef.buildDependencies(); this.parsedRef.buildDependencies();
...@@ -588,12 +588,14 @@ function getRangeType(oBBox){ ...@@ -588,12 +588,14 @@ function getRangeType(oBBox){
addDefNameOpen: function(name, ref, sheetIndex, hidden, isTable) { addDefNameOpen: function(name, ref, sheetIndex, hidden, isTable) {
var sheetId = this.wb.getSheetIdByIndex(sheetIndex); var sheetId = this.wb.getSheetIdByIndex(sheetIndex);
var defName = new DefName(this.wb, name, ref, sheetId, hidden, isTable); var defName = new DefName(this.wb, name, ref, sheetId, hidden, isTable);
return this._addDefName(defName); this._addDefName(defName);
return defName;
}, },
addDefName: function(name, ref, sheetId, hidden, isTable) { addDefName: function(name, ref, sheetId, hidden, isTable) {
var defName = new DefName(this.wb, name, ref, sheetId, hidden, isTable); var defName = new DefName(this.wb, name, ref, sheetId, hidden, isTable);
defName.setRef(defName.ref, true); defName.setRef(defName.ref, true);
return this._addDefName(defName); this._addDefName(defName);
return defName;
}, },
removeDefName: function(sheetId, name) { removeDefName: function(sheetId, name) {
this._removeDefName(sheetId, name, AscCH.historyitem_Workbook_DefinedNamesChange); this._removeDefName(sheetId, name, AscCH.historyitem_Workbook_DefinedNamesChange);
...@@ -869,13 +871,19 @@ function getRangeType(oBBox){ ...@@ -869,13 +871,19 @@ function getRangeType(oBBox){
console.timeEnd('broadscastVolatile'); console.timeEnd('broadscastVolatile');
console.time('broadcastCells'); console.time('broadcastCells');
var calcTrack = []; var calcTrack = [];
var noCalcTrack = [];
while (this.changedCell || this.changedDefName) { while (this.changedCell || this.changedDefName) {
this._broadcastDefNames(notifyData); this._broadcastDefNames(notifyData, noCalcTrack);
this._broadcastCells(notifyData, calcTrack); this._broadcastCells(notifyData, calcTrack);
} }
this._broadcastCellsEnd(); this._broadcastCellsEnd();
console.timeEnd('broadcastCells'); console.timeEnd('broadcastCells');
console.time('calculate'); console.time('calculate');
for (var i = 0; i < noCalcTrack.length; ++i) {
var formula = noCalcTrack[i];
//defName recalc when calc formula containing it. no need calc it
formula.setIsDirty(false);
}
for (var i = 0; i < calcTrack.length; ++i) { for (var i = 0; i < calcTrack.length; ++i) {
var formula = calcTrack[i]; var formula = calcTrack[i];
if (formula.getIsDirty()) { if (formula.getIsDirty()) {
...@@ -1038,15 +1046,15 @@ function getRangeType(oBBox){ ...@@ -1038,15 +1046,15 @@ function getRangeType(oBBox){
} }
} }
}, },
_broadcastDefNames: function(notifyData) { _broadcastDefNames: function(notifyData, noCalcTrack) {
if (this.changedDefName) { if (this.changedDefName) {
var changedDefName = this.changedDefName; var changedDefName = this.changedDefName;
this.changedDefName = null; this.changedDefName = null;
for (var nodeId in changedDefName) { for (var nodeId in changedDefName) {
var defName = this.getDefNameByNodeId(nodeId); var defName = this.getDefNameByNodeId(nodeId);
if (defName && defName.parsedRef) { if (defName && defName.parsedRef) {
//defName recalc when calc formula containing it. no need calc it defName.parsedRef.setIsDirty(true);
defName.parsedRef.setIsDirty(false); noCalcTrack.push(defName.parsedRef);
} }
getFromDefNameId(nodeId); getFromDefNameId(nodeId);
this._broadcastDefName(g_FDNI.name, notifyData); this._broadcastDefName(g_FDNI.name, notifyData);
...@@ -2254,6 +2262,9 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){ ...@@ -2254,6 +2262,9 @@ Workbook.prototype.getTableNameColumnByIndex = function(tableName, columnIndex){
return Asc.floor((count * this.maxDigitWidth + this.paddingPlusBorder) / this.maxDigitWidth * 256) / 256; return Asc.floor((count * this.maxDigitWidth + this.paddingPlusBorder) / this.maxDigitWidth * 256) / 256;
}; };
Workbook.prototype.getUndoDefName = function(ascName) { Workbook.prototype.getUndoDefName = function(ascName) {
if (!ascName) {
return ascName;
}
var sheetId = this.getSheetIdByIndex(ascName.LocalSheetId); var sheetId = this.getSheetIdByIndex(ascName.LocalSheetId);
return new UndoRedoData_DefinedNames(ascName.Name, ascName.Ref, sheetId, ascName.isTable); return new UndoRedoData_DefinedNames(ascName.Name, ascName.Ref, sheetId, ascName.isTable);
}; };
......
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