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"; ...@@ -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_onCellTextChanged (text, cursorPosition, isFormula, formulaPos, formulaName)
* asc_onSelectionChanged (asc_CCellInfo); - эвент на смену информации о выделении * asc_onSelectionChanged (asc_CCellInfo); - эвент на смену информации о выделении
* asc_onSelectionNameChanged (sName); - эвент на смену имени выделения (Id-ячейки, число выделенных столбцов/строк, имя диаграммы и др.) * asc_onSelectionNameChanged (sName); - эвент на смену имени выделения (Id-ячейки, число выделенных столбцов/строк, имя диаграммы и др.)
* asc_onSelectionMathChanged (asc_CSelectionMathInfo); - эвент на смену математической информации о выделении
* asc_onZoomChanged (zoom) * asc_onZoomChanged (zoom)
* asc_onSheetsChanged () - эвент на обновление списка листов * asc_onSheetsChanged () - эвент на обновление списка листов
* asc_onActiveSheetChanged (indexActiveSheet) - эвент на обновление активного листа * asc_onActiveSheetChanged (indexActiveSheet) - эвент на обновление активного листа
......
...@@ -1025,6 +1025,21 @@ ...@@ -1025,6 +1025,21 @@
return this; 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 * Export
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
...@@ -1150,5 +1165,11 @@ ...@@ -1150,5 +1165,11 @@
window["Asc"]["asc_CSheetPr"] = window["Asc"].asc_CSheetPr = asc_CSheetPr; 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); )(jQuery, window);
...@@ -404,18 +404,19 @@ ...@@ -404,18 +404,19 @@
_createWorksheetView: function (wsModel) { _createWorksheetView: function (wsModel) {
var self = this, var self = this,
opt = $.extend(true, {}, this.settings.worksheetDefaults, { opt = $.extend(true, {}, this.settings.worksheetDefaults, {
"getViewerMode" : function () { return self.controller.getViewerMode ? self.controller.getViewerMode() : true; }, "getViewerMode" : function () { return self.controller.getViewerMode ? self.controller.getViewerMode() : true; },
"reinitializeScroll" : function () {self.controller.reinitializeScroll(/*All*/);}, "reinitializeScroll" : function () {self.controller.reinitializeScroll(/*All*/);},
"reinitializeScrollY" : function () {self.controller.reinitializeScroll(/*vertical*/1);}, "reinitializeScrollY" : function () {self.controller.reinitializeScroll(/*vertical*/1);},
"reinitializeScrollX" : function () {self.controller.reinitializeScroll(/*horizontal*/2);}, "reinitializeScrollX" : function () {self.controller.reinitializeScroll(/*horizontal*/2);},
"selectionChanged" : function () {self._onWSSelectionChanged.apply(self, arguments);}, "selectionChanged" : function () {self._onWSSelectionChanged.apply(self, arguments);},
"selectionNameChanged" : function () {self._onSelectionNameChanged.apply(self, arguments);}, "selectionNameChanged" : function () {self._onSelectionNameChanged.apply(self, arguments);},
"onErrorEvent" : function (errorId, level) {self.handlers.trigger("asc_onError", errorId, level);}, "selectionMathInfoChanged" : function () {self._onSelectionMathInfoChanged.apply(self, arguments);},
"slowOperation" : function (isStart) {self.handlers.trigger((isStart ? "asc_onStartAction" : "asc_onEndAction"), c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.SlowOperation);}, "onErrorEvent" : function (errorId, level) {self.handlers.trigger("asc_onError", errorId, level);},
"setAutoFiltersDialog" : function (arrVal) {self.handlers.trigger("asc_onSetAFDialog", arrVal);}, "slowOperation" : function (isStart) {self.handlers.trigger((isStart ? "asc_onStartAction" : "asc_onEndAction"), c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.SlowOperation);},
"selectionRangeChanged" : function (val) {self.handlers.trigger("asc_onSelectionRangeChanged", val);}, "setAutoFiltersDialog" : function (arrVal) {self.handlers.trigger("asc_onSetAFDialog", arrVal);},
"getDCForCharts" : function () { return self.drawingCtxCharts; }, "selectionRangeChanged" : function (val) {self.handlers.trigger("asc_onSelectionRangeChanged", val);},
"onRenameCellTextEnd" : function (countFind, countReplace) {self.handlers.trigger("asc_onRenameCellTextEnd", countFind, countReplace);} "getDCForCharts" : function () { return self.drawingCtxCharts; },
"onRenameCellTextEnd" : function (countFind, countReplace) {self.handlers.trigger("asc_onRenameCellTextEnd", countFind, countReplace);}
}); });
return new asc_WSV(wsModel, this.buffers, this.stringRender, this.maxDigitWidth, this.collaborativeEditing, opt); return new asc_WSV(wsModel, this.buffers, this.stringRender, this.maxDigitWidth, this.collaborativeEditing, opt);
}, },
...@@ -424,6 +425,10 @@ ...@@ -424,6 +425,10 @@
this.handlers.trigger("asc_onSelectionNameChanged", name); this.handlers.trigger("asc_onSelectionNameChanged", name);
}, },
_onSelectionMathInfoChanged: function (info) {
this.handlers.trigger("asc_onSelectionMathChanged", info);
},
// Проверяет, сменили ли мы диапазон (для того, чтобы не отправлять одинаковую информацию о диапазоне) // Проверяет, сменили ли мы диапазон (для того, чтобы не отправлять одинаковую информацию о диапазоне)
_isEqualRange: function (range, isSelectOnShape) { _isEqualRange: function (range, isSelectOnShape) {
if (null === this.lastSendInfoRange) if (null === this.lastSendInfoRange)
...@@ -535,6 +540,7 @@ ...@@ -535,6 +540,7 @@
var isSelectOnShape = ws.getSelectionShape(); var isSelectOnShape = ws.getSelectionShape();
if (!this._isEqualRange(ar, isSelectOnShape)) { if (!this._isEqualRange(ar, isSelectOnShape)) {
this._onWSSelectionChanged(ws.getSelectionInfo()); this._onWSSelectionChanged(ws.getSelectionInfo());
this._onSelectionMathInfoChanged(ws.getSelectionMathInfo());
} }
var ct = ws.getCursorTypeFromXY(x, y, this.controller.settings.isViewerMode); var ct = ws.getCursorTypeFromXY(x, y, this.controller.settings.isViewerMode);
...@@ -1058,6 +1064,7 @@ ...@@ -1058,6 +1064,7 @@
ws.draw(); ws.draw();
this._onSelectionNameChanged(ws.getSelectionName(/*bRangeText*/false)); this._onSelectionNameChanged(ws.getSelectionName(/*bRangeText*/false));
this._onWSSelectionChanged(ws.getSelectionInfo()); this._onWSSelectionChanged(ws.getSelectionInfo());
this._onSelectionMathInfoChanged(ws.getSelectionMathInfo());
this.controller.reinitializeScroll(); this.controller.reinitializeScroll();
// Zoom теперь на каждом листе одинаковый, не отправляем смену // Zoom теперь на каждом листе одинаковый, не отправляем смену
return this; return this;
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
var asc_CPagePrint = asc.CPagePrint; var asc_CPagePrint = asc.CPagePrint;
var asc_CCollaborativeRange = asc.asc_CCollaborativeRange; var asc_CCollaborativeRange = asc.asc_CCollaborativeRange;
var asc_CCellCommentator = asc.asc_CCellCommentator; var asc_CCellCommentator = asc.asc_CCellCommentator;
var asc_CSelectionMathInfo = asc.asc_CSelectionMathInfo;
/* /*
* Constants * Constants
...@@ -5543,6 +5544,29 @@ ...@@ -5543,6 +5544,29 @@
return false; 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) { getSelectionName: function (bRangeText) {
if (this.isSelectOnShape) if (this.isSelectOnShape)
return " "; // Пока отправим пустое имя(с пробелом, пустое не воспринимаем в меню..) ToDo return " "; // Пока отправим пустое имя(с пробелом, пустое не воспринимаем в меню..) ToDo
...@@ -5785,6 +5809,7 @@ ...@@ -5785,6 +5809,7 @@
_updateSelectionNameAndInfo: function () { _updateSelectionNameAndInfo: function () {
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false)); this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
this._trigger("selectionChanged", this.getSelectionInfo()); this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
}, },
getSelectionShape: function () { getSelectionShape: function () {
...@@ -5795,6 +5820,7 @@ ...@@ -5795,6 +5820,7 @@
// отправляем евент для получения свойств картинки, шейпа или группы // отправляем евент для получения свойств картинки, шейпа или группы
this._trigger("selectionNameChanged", this.getSelectionName()); this._trigger("selectionNameChanged", this.getSelectionName());
this._trigger("selectionChanged", this.getSelectionInfo()); this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
}, },
getActiveRangeObj: function(){ getActiveRangeObj: function(){
return this.activeRange.clone(true); return this.activeRange.clone(true);
...@@ -5836,6 +5862,7 @@ ...@@ -5836,6 +5862,7 @@
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false)); this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
this._trigger("selectionChanged", this.getSelectionInfo()); this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
return this._calcActiveCellOffset(); return this._calcActiveCellOffset();
}, },
...@@ -5859,6 +5886,7 @@ ...@@ -5859,6 +5886,7 @@
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false)); this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
this._trigger("selectionChanged", this.getSelectionInfo()); this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
oRes = this._calcActiveCellOffset(); oRes = this._calcActiveCellOffset();
} }
...@@ -5893,8 +5921,10 @@ ...@@ -5893,8 +5921,10 @@
if (!this.isCellEditMode && (sc !== ar.startCol || sr !== ar.startRow || isChangeSelectionShape)) { if (!this.isCellEditMode && (sc !== ar.startCol || sr !== ar.startRow || isChangeSelectionShape)) {
if (!this.isSelectionDialogMode) { if (!this.isSelectionDialogMode) {
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false)); this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
if (!isSelectMode) if (!isSelectMode) {
this._trigger("selectionChanged", this.getSelectionInfo()); this._trigger("selectionChanged", this.getSelectionInfo());
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
}
} else { } else {
// Смена диапазона // Смена диапазона
this._trigger("selectionRangeChanged", this.getSelectionRangeValue()); this._trigger("selectionRangeChanged", this.getSelectionRangeValue());
...@@ -6013,8 +6043,10 @@ ...@@ -6013,8 +6043,10 @@
if (!this.isCellEditMode && !arnOld.isEqual(ar.clone(true))) { if (!this.isCellEditMode && !arnOld.isEqual(ar.clone(true))) {
if (!this.isSelectionDialogMode) { if (!this.isSelectionDialogMode) {
this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/true)); this._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/true));
if (!isSelectMode) if (!isSelectMode) {
this._trigger("selectionChanged", this.getSelectionInfo(false)); this._trigger("selectionChanged", this.getSelectionInfo(false));
this._trigger("selectionMathInfoChanged", this.getSelectionMathInfo());
}
} else { } else {
// Смена диапазона // Смена диапазона
this._trigger("selectionRangeChanged", this.getSelectionRangeValue()); this._trigger("selectionRangeChanged", this.getSelectionRangeValue());
...@@ -9625,6 +9657,7 @@ ...@@ -9625,6 +9657,7 @@
t._trigger("reinitializeScroll"); t._trigger("reinitializeScroll");
t._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false)); t._trigger("selectionNameChanged", this.getSelectionName(/*bRangeText*/false));
t._trigger("selectionChanged", t.getSelectionInfo()); t._trigger("selectionChanged", t.getSelectionInfo());
t._trigger("selectionMathInfoChanged", t.getSelectionMathInfo());
} }
t.objectRender.rebuildChartGraphicObjects(); 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