Commit dd44ea64 authored by konovalovsergey's avatar konovalovsergey

total table formulas error during paste and move copy, shift cell errors, refactoring

parent 8eed7231
This diff is collapsed.
This diff is collapsed.
......@@ -4701,6 +4701,11 @@ TablePart.prototype.clone = function(ws, tableName) {
res.AutoFilter = this.AutoFilter.clone();
if (this.SortState)
res.SortState = this.SortState.clone();
if (this.TableColumns) {
res.TableColumns = [];
for (i = 0; i < this.TableColumns.length; ++i)
res.TableColumns.push(this.TableColumns[i].clone());
}
if (this.TableStyleInfo)
res.TableStyleInfo = this.TableStyleInfo.clone();
......@@ -4709,7 +4714,6 @@ TablePart.prototype.clone = function(ws, tableName) {
for (i = 0; i < this.result.length; ++i)
res.result.push(this.result[i].clone());
}
var oldName = this.DisplayName;
if(tableName)
{
res.DisplayName = tableName;
......@@ -4721,12 +4725,6 @@ TablePart.prototype.clone = function(ws, tableName) {
if(ws !== null)
res.recalc(ws, tableName);
var newName = oldName == res.DisplayName ? null : res.DisplayName;
if (this.TableColumns) {
res.TableColumns = [];
for (i = 0; i < this.TableColumns.length; ++i)
res.TableColumns.push(this.TableColumns[i].clone(newName));
}
return res;
};
TablePart.prototype.renameSheetCopy = function(ws, renameParams) {
......@@ -5368,26 +5366,15 @@ function TableColumn() {
this.TotalsRowFormula.removeDependencies();
}
};
TableColumn.prototype.clone = function(opt_TableName, ws, renameParams) {
TableColumn.prototype.clone = function(opt_ws) {
var res = new TableColumn();
res.Name = this.Name;
res.TotalsRowLabel = this.TotalsRowLabel;
res.TotalsRowFunction = this.TotalsRowFunction;
if (this.TotalsRowFormula) {
if(opt_TableName){
} else {
}
ws = ws ? ws : this.TotalsRowFormula.ws;
if(renameParams)
{
this.renameSheetCopy(ws, renameParams);
}
res._setTotalRowFormula(this.TotalsRowFormula.Formula, ws, false);
opt_ws = opt_ws ? opt_ws : this.TotalsRowFormula.ws;
res._setTotalRowFormula(this.TotalsRowFormula.Formula, opt_ws, false);
}
if (this.dxf)
res.dxf = this.dxf.clone;
......
......@@ -351,12 +351,13 @@
var tablePartsContainsRange = filterInfo.tablePartsContainsRange;
//props from paste
var bWithoutFilter, displayName, tablePart;
var bWithoutFilter, displayName, tablePart, offset;
if(props)
{
bWithoutFilter = props.bWithoutFilter;
displayName = props.displayName;
tablePart = props.tablePart;
offset = props.offset;
}
//*****callBack on add filter
......@@ -397,7 +398,7 @@
}
//add to model
var newTablePart = t._addNewFilter(filterRange, styleName, bWithoutFilter, displayName, tablePart);
var newTablePart = t._addNewFilter(filterRange, styleName, bWithoutFilter, displayName, tablePart, offset);
var newDisplayName = newTablePart && newTablePart.DisplayName ? newTablePart.DisplayName : null;
if(styleName)
......@@ -3458,7 +3459,7 @@
return ar;
},
_addNewFilter: function(ref, style, bWithoutFilter, tablePartDisplayName, tablePart, isCloneTableColumns)
_addNewFilter: function(ref, style, bWithoutFilter, tablePartDisplayName, tablePart, offset)
{
var worksheet = this.worksheet;
var newFilter;
......@@ -3534,14 +3535,9 @@
var tableColumns;
if(tablePart && tablePart.TableColumns)
{
var renameParams = {};
renameParams.tableNameMap = {};
renameParams.tableNameMap[tablePart.DisplayName] = newTableName;
var cloneTableColumns = [];
for(var i = 0; i < tablePart.TableColumns.length; i++)
{
cloneTableColumns.push(tablePart.TableColumns[i].clone(null, worksheet, renameParams));
for(var i = 0; i < tablePart.TableColumns.length; i++) {
cloneTableColumns.push(tablePart.TableColumns[i].clone(worksheet));
}
tableColumns = cloneTableColumns;
}
......@@ -3552,6 +3548,13 @@
newFilter.TableColumns = tableColumns;
worksheet.TableParts[worksheet.TableParts.length] = newFilter;
if (tablePart) {
var renameParams = {};
renameParams.offset = offset;
renameParams.tableNameMap = {};
renameParams.tableNameMap[tablePart.DisplayName] = newTableName;
newFilter.renameSheetCopy(worksheet, renameParams);
}
return worksheet.TableParts[worksheet.TableParts.length - 1];
}
......@@ -4677,6 +4680,7 @@
{
var diffCol = arnTo.c1 - arnFrom.c1;
var diffRow = arnTo.r1 - arnFrom.r1;
var offset = {offsetCol: diffCol, offsetRow: diffRow};
var newRange, ref, bWithoutFilter;
for(var i = 0; i < findFilters.length; i++)
......@@ -4695,7 +4699,7 @@
var cleanRange = new AscCommonExcel.Range(worksheet, newRange.r1, newRange.c1, newRange.r2, newRange.c2);
cleanRange.cleanFormat();
}
this.addAutoFilter(findFilters[i].TableStyleInfo.Name, newRange, null, offLock, {tablePart: findFilters[i]});
this.addAutoFilter(findFilters[i].TableStyleInfo.Name, newRange, null, offLock, {tablePart: findFilters[i], offset: offset});
}
}
}
......
......@@ -9238,7 +9238,7 @@
diffRow = tablePartRange.r1 - refInsertBinary.r1;
diffCol = tablePartRange.c1 - refInsertBinary.c1;
range = t.model.getRange3( diffRow + selectionRange.r1, diffCol + selectionRange.c1, diffRow + selectionRange.r1 + (tablePartRange.r2 - tablePartRange.r1), diffCol + selectionRange.c1 + (tablePartRange.c2 - tablePartRange.c1) );
var offset = {offsetCol: range.bbox.c1 - tablePartRange.c1, offsetRow: range.bbox.r1 - tablePartRange.r1};
//если область вставки содержит форматированную таблицу, которая пересекается с вставляемой форматированной таблицей
var intersectionRangeWithTableParts = t.model.autoFilters._intersectionRangeWithTableParts( range.bbox );
if ( intersectionRangeWithTableParts )
......@@ -9254,7 +9254,7 @@
bWithoutFilter = true;
}
var props = {bWithoutFilter: bWithoutFilter, tablePart: aFilters[aF]};
var props = {bWithoutFilter: bWithoutFilter, tablePart: aFilters[aF], offset: offset};
t.model.autoFilters.addAutoFilter( aFilters[aF].TableStyleInfo.Name, range.bbox, true, true, props );
}
}
......
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