Commit 546e7cb8 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил математическую информацию о выделении (пока правда только по окончании выделения)

Эвент - asc_onSelectionMathChanged
Возвращается - asc_CSelectionMathInfo
Методы: asc_getCount, asc_getSum, asc_getAverage
Выводим информацию только если asc_getCount > 1
asc_getSum и asc_getAverage могут вернуть null (это если мы выделили только текстовую информацию)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52718 954022d7-b5bf-4e40-9824-e11837661b57
parent 580721c5
......@@ -1093,6 +1093,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
* asc_onCellTextChanged (text, cursorPosition, isFormula, formulaPos, formulaName)
* asc_onSelectionChanged (asc_CCellInfo); - эвент на смену информации о выделении
* asc_onSelectionNameChanged (sName); - эвент на смену имени выделения (Id-ячейки, число выделенных столбцов/строк, имя диаграммы и др.)
* asc_onSelectionMathChanged (asc_CSelectionMathInfo); - эвент на смену математической информации о выделении
* asc_onZoomChanged (zoom)
* asc_onSheetsChanged () - эвент на обновление списка листов
* asc_onActiveSheetChanged (indexActiveSheet) - эвент на обновление активного листа
......
......@@ -1025,6 +1025,21 @@
return this;
}
// Математическая информация о выделении
/** @constructor */
function asc_CSelectionMathInfo() {
this.count = 0;
this.sum = null;
this.average = null;
}
asc_CSelectionMathInfo.prototype = {
constructor: asc_CSelectionMathInfo,
asc_getCount: function () { return this.count; },
asc_getSum: function () { return this.sum; },
asc_getAverage: function () { return this.average; }
};
/*
* Export
* -----------------------------------------------------------------------------
......@@ -1150,5 +1165,11 @@
window["Asc"]["asc_CSheetPr"] = window["Asc"].asc_CSheetPr = asc_CSheetPr;
window["Asc"]["asc_CSelectionMathInfo"] = window["Asc"].asc_CSelectionMathInfo = asc_CSelectionMathInfo;
prot = asc_CSelectionMathInfo.prototype;
prot["asc_getCount"] = prot.asc_getCount;
prot["asc_getSum"] = prot.asc_getSum;
prot["asc_getAverage"] = prot.asc_getAverage;
}
)(jQuery, window);
......@@ -410,6 +410,7 @@
"reinitializeScrollX" : function () {self.controller.reinitializeScroll(/*horizontal*/2);},
"selectionChanged" : function () {self._onWSSelectionChanged.apply(self, arguments);},
"selectionNameChanged" : function () {self._onSelectionNameChanged.apply(self, arguments);},
"selectionMathInfoChanged" : function () {self._onSelectionMathInfoChanged.apply(self, arguments);},
"onErrorEvent" : function (errorId, level) {self.handlers.trigger("asc_onError", errorId, level);},
"slowOperation" : function (isStart) {self.handlers.trigger((isStart ? "asc_onStartAction" : "asc_onEndAction"), c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.SlowOperation);},
"setAutoFiltersDialog" : function (arrVal) {self.handlers.trigger("asc_onSetAFDialog", arrVal);},
......@@ -424,6 +425,10 @@
this.handlers.trigger("asc_onSelectionNameChanged", name);
},
_onSelectionMathInfoChanged: function (info) {
this.handlers.trigger("asc_onSelectionMathChanged", info);
},
// Проверяет, сменили ли мы диапазон (для того, чтобы не отправлять одинаковую информацию о диапазоне)
_isEqualRange: function (range, isSelectOnShape) {
if (null === this.lastSendInfoRange)
......@@ -535,6 +540,7 @@
var isSelectOnShape = ws.getSelectionShape();
if (!this._isEqualRange(ar, isSelectOnShape)) {
this._onWSSelectionChanged(ws.getSelectionInfo());
this._onSelectionMathInfoChanged(ws.getSelectionMathInfo());
}
var ct = ws.getCursorTypeFromXY(x, y, this.controller.settings.isViewerMode);
......@@ -1058,6 +1064,7 @@
ws.draw();
this._onSelectionNameChanged(ws.getSelectionName(/*bRangeText*/false));
this._onWSSelectionChanged(ws.getSelectionInfo());
this._onSelectionMathInfoChanged(ws.getSelectionMathInfo());
this.controller.reinitializeScroll();
// Zoom теперь на каждом листе одинаковый, не отправляем смену
return this;
......
......@@ -46,6 +46,7 @@
var asc_CPagePrint = asc.CPagePrint;
var asc_CCollaborativeRange = asc.asc_CCollaborativeRange;
var asc_CCellCommentator = asc.asc_CCellCommentator;
var asc_CSelectionMathInfo = asc.asc_CSelectionMathInfo;
/*
* Constants
......@@ -5543,6 +5544,29 @@
return false;
},
getSelectionMathInfo: function () {
var ar = this.activeRange;
var range = this.model.getRange3(ar.r1, ar.c1, ar.r2, ar.c2);
var tmp;
var oSelectionMathInfo = new asc_CSelectionMathInfo();
var sum = 0, countNumbers = 0;
range._setPropertyNoEmpty(null, null, function (c) {
++oSelectionMathInfo.count;
if (CellValueType.Number === c.getType() && false === c.isEmptyTextString()) {
tmp = parseFloat(c.getValueWithoutFormat());
if (isNaN(tmp))
return;
++countNumbers;
sum += tmp;
}
});
if (0 !== countNumbers) {
oSelectionMathInfo.sum = sum;
oSelectionMathInfo.average = sum / countNumbers;
}
return oSelectionMathInfo;
},
getSelectionName: function (bRangeText) {
if (this.isSelectOnShape)
return " "; // Пока отправим пустое имя(с пробелом, пустое не воспринимаем в меню..) ToDo
......@@ -5785,6 +5809,7 @@
_updateSelectionNameAndInfo: function () {
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
},
getSelectionShape: function () {
......@@ -5795,6 +5820,7 @@
// отправляем евент для получения свойств картинки, шейпа или группы
this._trigger("selectionNameChanged", this.getSelectionName());
this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
},
getActiveRangeObj: function(){
return this.activeRange.clone(true);
......@@ -5836,6 +5862,7 @@
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
return this._calcActiveCellOffset();
},
......@@ -5859,6 +5886,7 @@
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
oRes = this._calcActiveCellOffset();
}
......@@ -5893,8 +5921,10 @@
if (!this.isCellEditMode && (sc !== ar.startCol || sr !== ar.startRow || isChangeSelectionShape)) {
if (!this.isSelectionDialogMode) {
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
if (!isSelectMode)
if (!isSelectMode) {
this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
}
} else {
// Смена диапазона
this._trigger("selectionRangeChanged", this.getSelectionRangeValue());
......@@ -6013,8 +6043,10 @@
if (!this.isCellEditMode && !arnOld.isEqual(ar.clone(true))) {
if (!this.isSelectionDialogMode) {
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/true));
if (!isSelectMode)
if (!isSelectMode) {
this._trigger("selectionChanged", this.getSelectionInfo(false));
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
}
} else {
// Смена диапазона
this._trigger("selectionRangeChanged", this.getSelectionRangeValue());
......@@ -9625,6 +9657,7 @@
t._trigger("reinitializeScroll");
t._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
t._trigger("selectionChanged", t.getSelectionInfo());
t._trigger("selectionMathInfoChanged", t.getSelectionMathInfo());
}
t.objectRender.rebuildChartGraphicObjects();
......
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