Commit 154c88dc authored by GoshaZotov's avatar GoshaZotov

fix Bug #32335

parent c3cdd104
......@@ -4581,8 +4581,11 @@ TablePart.prototype.changeRef = function(col, row, bIsFirst) {
ref.setOffsetLast({offsetCol: col ? col : 0, offsetRow: row ? row : 0});
this.Ref = ref;
//event
this.handlers.trigger("changeRefTablePart", this.DisplayName, this.Ref);
var endRow = this.TotalsRowCount && this.TotalsRowCount >= 1 ? this.Ref.r2 - 1 : this.Ref.r2;
var refNamedRanges = Asc.Range(this.Ref.c1, this.Ref.r1, this.Ref.c2, endRow);
this.handlers.trigger("changeRefTablePart", this.DisplayName, refNamedRanges);
if(this.AutoFilter)
this.AutoFilter.changeRef(col, row, bIsFirst);
......@@ -4767,7 +4770,10 @@ TablePart.prototype.getTableRangeForFormula = function(objectParam)
if(endCol === null)
endCol = startCol;
res = new Asc.Range(this.Ref.c1 + startCol, this.Ref.r1+1, this.Ref.c1 + endCol, this.Ref.r2);
var startRow = this.HeaderRowCount === null ? this.Ref.r1 + 1 : this.Ref.r1;
var endRow = this.TotalsRowCount > 0 ? this.Ref.r2 - 1 : this.Ref.r2;
res = new Asc.Range(this.Ref.c1 + startCol, startRow, this.Ref.c1 + endCol, endRow);
break;
}
}
......@@ -4855,6 +4861,7 @@ TablePart.prototype.generateTotalsRowLabel = function()
}
this.TableColumns[0].generateTotalsRowLabel();
this.TableColumns[this.TableColumns.length - 1].generateTotalsRowFunction();
};
TablePart.prototype.changeDisplayName = function(newName)
......@@ -5079,6 +5086,71 @@ TableColumn.prototype.generateTotalsRowLabel = function(){
this.TotalsRowLabel = "Summary";
}
};
TableColumn.prototype.generateTotalsRowFunction = function(){
//TODO добавить в перевод
if(this.TotalsRowFunction === null)
{
this.TotalsRowFunction = Asc.ETotalsRowFunction.totalrowfunctionSum;
}
};
TableColumn.prototype.getTotalRowFormula = function(tablePart){
var res = null;
if(null !== this.TotalsRowFunction)
{
switch(this.TotalsRowFunction)
{
case Asc.ETotalsRowFunction.totalrowfunctionAverage:
{
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionCount:
{
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionCountNums:
{
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionCustom:
{
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionMax:
{
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionMin:
{
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionNone:
{
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionStdDev:
{
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionSum:
{
res = "=SUBTOTAL(109;" + tablePart.DisplayName + "[" + this.Name + "]";
break;
}
case Asc.ETotalsRowFunction.totalrowfunctionVar:
{
break;
}
}
}
else if(null !== this.TotalsRowFormula)
{
res = this.TotalsRowFormula;
}
return res;
};
/** @constructor */
function TableStyleInfo() {
......
......@@ -2186,9 +2186,9 @@
{
var clearRange = new AscCommonExcel.Range(worksheet, tablePart.Ref.r2, tablePart.Ref.c1, tablePart.Ref.r2, tablePart.Ref.c2);
this._clearRange(clearRange, true);
tablePart.changeRef(null, -1);
tablePart.TotalsRowCount = tablePart.TotalsRowCount === null ? 1 : null;
tablePart.changeRef(null, -1);
}
else
{
......@@ -2196,19 +2196,19 @@
var rangeUpTable = new Asc.Range(tablePart.Ref.c1, tablePart.Ref.r2 + 1, tablePart.Ref.c2, tablePart.Ref.r2 + 1);
if(this._isEmptyCurrentRange(rangeUpTable) && this.searchRangeInTableParts(rangeUpTable) === -1)
{
tablePart.changeRef(null, 1);
isSetValue = true;
tablePart.TotalsRowCount = tablePart.TotalsRowCount === null ? 1 : null;
tablePart.changeRef(null, 1);
}
else
{
worksheet.getRange3(tablePart.Ref.r2 + 1, tablePart.Ref.c1, tablePart.Ref.r2 + 1, tablePart.Ref.c2).addCellsShiftBottom();
tablePart.changeRef(null, 1);
isSetValue = true;
tablePart.TotalsRowCount = tablePart.TotalsRowCount === null ? 1 : null;
tablePart.changeRef(null, 1);
}
if(val === true)
......@@ -2225,9 +2225,9 @@
{
var clearRange = new AscCommonExcel.Range(worksheet, tablePart.Ref.r1, tablePart.Ref.c1, tablePart.Ref.r1, tablePart.Ref.c2);
this._clearRange(clearRange, true);
tablePart.changeRef(null, 1, true);
tablePart.HeaderRowCount = tablePart.HeaderRowCount === null ? 0 : null;
tablePart.changeRef(null, 1, true);
}
else
{
......@@ -2235,21 +2235,20 @@
var rangeUpTable = new Asc.Range(tablePart.Ref.c1, tablePart.Ref.r1 - 1, tablePart.Ref.c2, tablePart.Ref.r1 - 1);
if(this._isEmptyCurrentRange(rangeUpTable) && this.searchRangeInTableParts(rangeUpTable) === -1)
{
tablePart.changeRef(null, -1, true);
isSetValue = true;
tablePart.HeaderRowCount = tablePart.HeaderRowCount === null ? 0 : null;
tablePart.changeRef(null, -1, true);
}
else
{
worksheet.getRange3(tablePart.Ref.r2 + 1, tablePart.Ref.c1, tablePart.Ref.r2 + 1, tablePart.Ref.c2).addCellsShiftBottom();
worksheet._moveRange(tablePart.Ref, new Asc.Range(tablePart.Ref.c1, tablePart.Ref.r1 + 1, tablePart.Ref.c2, tablePart.Ref.r2 + 1));
tablePart.changeRef(null, -1, true);
isSetValue = true;
tablePart.HeaderRowCount = tablePart.HeaderRowCount === null ? 0 : null;
tablePart.changeRef(null, -1, true);
}
}
......@@ -3944,12 +3943,21 @@
range.setType(CellValueType.String);
}
if(tableColumn !== null && tableColumn.TotalsRowLabel !== null && totalsRowCount > 0)
if(tableColumn !== null && totalsRowCount > 0)
{
range = worksheet.getCell3(bbox.r2, ncol);
range.setValue(tableColumn.TotalsRowLabel);
range.setType(CellValueType.String);
//TODO + далее необходимо добавлять формулу
if(null !== tableColumn.TotalsRowLabel)
{
range.setValue(tableColumn.TotalsRowLabel);
range.setType(CellValueType.String);
}
var formula = tableColumn.getTotalRowFormula(options);
if(null !== formula)
{
range.setValue(formula);
}
}
}
}
......
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