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