Commit f416b6ad authored by konovalovsergey's avatar konovalovsergey

for delete table column

parent 689ad408
......@@ -1859,6 +1859,59 @@ cStrucTable.prototype._buildLocalTableString = function (reservedColumn,local) {
this.tableName = to.name;
}
};
cStrucTable.prototype.removeTableColumn = function(deleted) {
if (this.oneColumn) {
if (deleted[this.oneColumn]) {
return true;
} else {
this.oneColumnIndex = this.wb.getTableIndexColumnByName(this.tableName, this.oneColumn);
if (!this.oneColumnIndex) {
return true;
}
}
}
if (this.columnRange) {
if (deleted[this.colStart]) {
return true;
} else {
this.colStartIndex = this.wb.getTableIndexColumnByName(this.tableName, this.colStart);
if (!this.colStartIndex) {
return true;
}
}
if (deleted[this.colEnd]) {
return true;
} else {
this.colEndIndex = this.wb.getTableIndexColumnByName(this.tableName, this.colEnd);
if (!this.colEndIndex) {
return true;
}
}
}
if (this.hdt) {
if(this.hdtcstart){
if (deleted[this.hdtcstart]) {
return true;
} else {
this.hdtcstartIndex = this.wb.getTableIndexColumnByName(this.tableName, this.hdtcstart);
if (!this.hdtcstartIndex) {
return true;
}
}
}
if(this.hdtcend){
if (deleted[this.hdtcend]) {
return true;
} else {
this.hdtcendIndex = this.wb.getTableIndexColumnByName(this.tableName, this.hdtcend);
if (!this.hdtcendIndex) {
return true;
}
}
}
}
return false;
};
/** @constructor */
function cName3D(val, wb, ws) {
......@@ -3841,12 +3894,16 @@ function parserFormula( formula, parent, _ws ) {
} else if (AscCommon.c_oNotifyType.ChangeDefName === data.type) {
if (!data.to) {
this.removeTableName(data.from);
eventData.isRebuild = true;
} else if (data.from.name != data.to.name) {
this.changeDefName(data.from, data.to);
} else if (data.from.isTable) {
needAssemble = false;
eventData.isRebuild = true;
}
} else if (AscCommon.c_oNotifyType.DelColumnTable === data.type) {
this.removeTableColumn(data.tableName, data.deleted);
eventData.isRebuild = true;
} else if (AscCommon.c_oNotifyType.Rebuild === data.type) {
eventData.isRebuild = true;
} else if (AscCommon.c_oNotifyType.ChangeSheet === data.type) {
......@@ -4817,7 +4874,7 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
}
};
parserFormula.prototype.removeTableName = function(defName) {
var i, elem, sheetId;
var i, elem;
for (i = 0; i < this.outStack.length; i++) {
elem = this.outStack[i];
if (elem.type == cElementType.table && elem.tableName == defName.name) {
......@@ -4825,6 +4882,17 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
}
}
};
parserFormula.prototype.removeTableColumn = function(tableName, deleted) {
var i, elem;
for (i = 0; i < this.outStack.length; i++) {
elem = this.outStack[i];
if (elem.type == cElementType.table && elem.tableName == tableName) {
if (elem.removeTableColumn(deleted)) {
this.outStack[i] = new cError(cErrorType.bad_reference);
}
}
}
};
parserFormula.prototype.shiftCells = function(notifyType, sheetId, bbox, offset) {
var elem;
for (var i = 0; i < this.outStack.length; i++) {
......
......@@ -930,7 +930,7 @@ CHistory.prototype.GetSerializeArray = function()
//функция, которая перемещает последнее действие на первую позицию(в текущей точке)
CHistory.prototype.ChangeActionsEndToStart = function()
{
var curPoint = this.Points[this.Index];
var curPoint = this.Points[this.Index];
if(curPoint && curPoint.Items.length > 0)
{
var endAction = curPoint.Items.pop();
......
......@@ -753,11 +753,17 @@
}
},
delTableName: function(tableName) {
this.buildDependency();
var defName = this._delDefName(tableName, null);
this.addToChangedDefName(defName);
var notifyData = {type: AscCommon.c_oNotifyType.ChangeDefName, from: defName.getUndoDefName(), to: null};
this._broadcastDefName(tableName, notifyData);
},
delColumnTable: function(tableName, deleted) {
this.buildDependency();
var notifyData = {type: AscCommon.c_oNotifyType.DelColumnTable, tableName: tableName, deleted: deleted};
this._broadcastDefName(tableName, notifyData);
},
rebuildTable: function(tableName) {
var defName = this.getDefNameByName(tableName, null);
if (defName) {
......@@ -1395,6 +1401,9 @@
},
"changeColumnTablePart": function ( tableName ) {
self.dependencyFormulas.rebuildTable( tableName );
},
"deleteColumnTablePart": function(tableName, deleted) {
self.dependencyFormulas.delColumnTable(tableName, deleted);
}
} );
for(var i = 0, length = tableCustomFunc.length; i < length; ++i) {
......
......@@ -5852,10 +5852,16 @@ TablePart.prototype.deleteTableColumns = function(activeRange)
diff = activeRange.c2 - activeRange.c1 + 1;
startCol = activeRange.c1 - this.Ref.c1;
}
if(diff !== null){
if (diff !== null) {
var deleted = this.TableColumns.splice(startCol, diff);
this.removeDependencies(deleted);
var deletedMap = {};
for (var i = 0; i < deleted.length; ++i) {
deletedMap[deleted[i].Name] = 1;
}
this.handlers.trigger("deleteColumnTablePart", this.DisplayName, deletedMap);
}
};
......@@ -6073,12 +6079,8 @@ TablePart.prototype.getRangeWithoutHeaderFooter = function()
TablePart.prototype.checkTotalRowFormula = function(ws)
{
if(this.TotalsRowCount)
{
for(var i = 0; i < this.TableColumns.length; i++)
{
this.TableColumns[i].checkTotalRowFormula(ws, this);
}
for (var i = 0; i < this.TableColumns.length; i++) {
this.TableColumns[i].checkTotalRowFormula(ws, this);
}
};
......
......@@ -816,7 +816,8 @@
Rebuild: 4,
Changed: 5,
ChangeDefName: 6,
ChangeSheet: 7
ChangeSheet: 7,
DelColumnTable: 8
};
var c_oNotifyParentType = {
......
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