Commit 44d7103d authored by GoshaZotov's avatar GoshaZotov Committed by Alexander.Trofimov

fix Bug #32335

parent 329b80a4
......@@ -4557,8 +4557,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);
......@@ -4743,7 +4746,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;
}
}
......@@ -4831,6 +4837,7 @@ TablePart.prototype.generateTotalsRowLabel = function()
}
this.TableColumns[0].generateTotalsRowLabel();
this.TableColumns[this.TableColumns.length - 1].generateTotalsRowFunction();
};
TablePart.prototype.changeDisplayName = function(newName)
......@@ -5055,6 +5062,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() {
......
......@@ -2162,9 +2162,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
{
......@@ -2172,19 +2172,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)
......@@ -2201,9 +2201,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
{
......@@ -2211,21 +2211,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);
}
}
......@@ -3920,12 +3919,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