Commit 2c6a6f3c authored by Alexander Trofimov's avatar Alexander Trofimov Committed by GitHub

Merge pull request #22 from ONLYOFFICE/release/3.8.1

fix bug 31609
parents 44f714e2 74e22264
...@@ -7175,44 +7175,49 @@ ...@@ -7175,44 +7175,49 @@
WorksheetView.prototype.getSelectionMathInfo = function () { WorksheetView.prototype.getSelectionMathInfo = function () {
var ar = this.activeRange; var ar = this.activeRange;
var range = this.model.getRange3( ar.r1, ar.c1, ar.r2, ar.c2 ); var range = this.model.getRange3(ar.r1, ar.c1, ar.r2, ar.c2);
var tmp; var tmp;
var oSelectionMathInfo = new asc_CSelectionMathInfo(); var oSelectionMathInfo = new asc_CSelectionMathInfo();
var sum = 0; var sum = 0;
range._setPropertyNoEmpty( null, null, function ( c ) { var t = this;
if ( false === c.isEmptyTextString() ) { range._setPropertyNoEmpty(null, null, function (cell, r) {
if (!cell.isEmptyTextString() && t.height_1px <= t.rows[r].height) {
++oSelectionMathInfo.count; ++oSelectionMathInfo.count;
if ( CellValueType.Number === c.getType() ) { if (CellValueType.Number === cell.getType()) {
tmp = parseFloat( c.getValueWithoutFormat() ); tmp = parseFloat(cell.getValueWithoutFormat());
if ( isNaN( tmp ) ) { if (isNaN(tmp)) {
return; return;
} }
if ( 0 === oSelectionMathInfo.countNumbers ) { if (0 === oSelectionMathInfo.countNumbers) {
oSelectionMathInfo.min = oSelectionMathInfo.max = tmp; oSelectionMathInfo.min = oSelectionMathInfo.max = tmp;
} } else {
else { oSelectionMathInfo.min = Math.min(oSelectionMathInfo.min, tmp);
oSelectionMathInfo.min = Math.min( oSelectionMathInfo.min, tmp ); oSelectionMathInfo.max = Math.max(oSelectionMathInfo.max, tmp);
oSelectionMathInfo.max = Math.max( oSelectionMathInfo.max, tmp );
} }
++oSelectionMathInfo.countNumbers; ++oSelectionMathInfo.countNumbers;
sum += tmp; sum += tmp;
} }
} }
} ); });
// Показываем только данные для 2-х или более ячеек (http://bugzserver/show_bug.cgi?id=24115) // Показываем только данные для 2-х или более ячеек (http://bugzserver/show_bug.cgi?id=24115)
if ( 1 < oSelectionMathInfo.countNumbers ) { if (1 < oSelectionMathInfo.countNumbers) {
// Мы должны отдавать в формате активной ячейки // Мы должны отдавать в формате активной ячейки
var numFormat = range.getNumFormat(); var numFormat = range.getNumFormat();
if ( Asc.c_oAscNumFormatType.Time === numFormat.getType() ) { if (Asc.c_oAscNumFormatType.Time === numFormat.getType()) {
// Для времени нужно отдавать в формате [h]:mm:ss (http://bugzserver/show_bug.cgi?id=26271) // Для времени нужно отдавать в формате [h]:mm:ss (http://bugzserver/show_bug.cgi?id=26271)
numFormat = AscCommon.oNumFormatCache.get( '[h]:mm:ss' ); numFormat = AscCommon.oNumFormatCache.get('[h]:mm:ss');
} }
oSelectionMathInfo.sum = numFormat.formatToMathInfo( sum, CellValueType.Number, this.settings.mathMaxDigCount ); oSelectionMathInfo.sum =
oSelectionMathInfo.average = numFormat.formatToMathInfo( sum / oSelectionMathInfo.countNumbers, CellValueType.Number, this.settings.mathMaxDigCount ); numFormat.formatToMathInfo(sum, CellValueType.Number, this.settings.mathMaxDigCount);
oSelectionMathInfo.average =
numFormat.formatToMathInfo(sum / oSelectionMathInfo.countNumbers, CellValueType.Number,
this.settings.mathMaxDigCount);
oSelectionMathInfo.min = numFormat.formatToMathInfo( oSelectionMathInfo.min, CellValueType.Number, this.settings.mathMaxDigCount ); oSelectionMathInfo.min =
oSelectionMathInfo.max = numFormat.formatToMathInfo( oSelectionMathInfo.max, CellValueType.Number, this.settings.mathMaxDigCount ); numFormat.formatToMathInfo(oSelectionMathInfo.min, CellValueType.Number, this.settings.mathMaxDigCount);
oSelectionMathInfo.max =
numFormat.formatToMathInfo(oSelectionMathInfo.max, CellValueType.Number, this.settings.mathMaxDigCount);
} }
return oSelectionMathInfo; return oSelectionMathInfo;
}; };
......
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