Commit a758ba09 authored by Alexander.Trofimov's avatar Alexander.Trofimov

speed up asc_getCellInfo

parent dc071c2a
......@@ -2592,7 +2592,7 @@ var editor;
// Cell interface
spreadsheet_api.prototype.asc_getCellInfo = function() {
return this.wb.getWorksheet().getSelectionInfo();
return this.wb.getSelectionInfo();
};
// Получить координаты активной ячейки
......
......@@ -157,6 +157,7 @@
this.Api = Api;
this.collaborativeEditing = collaborativeEditing;
this.lastSendInfoRange = null;
this.oSelectionInfo = null;
this.canUpdateAfterShiftUp = false; // Нужно ли обновлять информацию после отпускания Shift
//----- declaration -----
......@@ -846,7 +847,7 @@
return this.lastSendInfoRange.isEqual(range) && this.lastSendInfoRangeIsSelectOnShape === isSelectOnShape;
};
WorkbookView.prototype._onWSSelectionChanged = function(info) {
WorkbookView.prototype._updateSelectionInfo = function (info) {
var ws = this.cellFormulaEnterWSOpen ? this.cellFormulaEnterWSOpen : this.getWorksheet();
this.lastSendInfoRange = ws.model.selectionRange.getLast().clone(true);
this.lastSendInfoRangeIsSelectOnShape = ws.getSelectionShape();
......@@ -854,18 +855,23 @@
if (null === info) {
info = ws.getSelectionInfo();
}
this.oSelectionInfo = info;
};
WorkbookView.prototype._onWSSelectionChanged = function(info) {
this._updateSelectionInfo(info);
// При редактировании ячейки не нужно пересылать изменения
if (this.input && false === ws.getCellEditMode() && c_oAscSelectionDialogType.None === this.selectionDialogType) {
if (this.input && false === this.getCellEditMode() && c_oAscSelectionDialogType.None === this.selectionDialogType) {
// Сами запретим заходить в строку формул, когда выделен shape
if (this.lastSendInfoRangeIsSelectOnShape) {
this.input.disabled = true;
this.input.value = '';
} else {
this.input.disabled = false;
this.input.value = info.text;
this.input.value = this.oSelectionInfo.text;
}
}
this.handlers.trigger("asc_onSelectionChanged", info);
this.handlers.trigger("asc_onSelectionChanged", this.oSelectionInfo);
this.handlers.trigger("asc_onSelectionEnd");
};
......@@ -1514,7 +1520,7 @@
* @param [bLockDraw]
* @returns {WorkbookView}
*/
WorkbookView.prototype.showWorksheet = function(index, isResized, bLockDraw) {
WorkbookView.prototype.showWorksheet = function (index, isResized, bLockDraw) {
if (index === this.wsActive) {
return this;
}
......@@ -1525,21 +1531,21 @@
var ws = this.getWorksheet();
// Останавливаем ввод данных в редакторе ввода. Если в режиме ввода формул, то продолжаем работать с cellEditor'ом, чтобы можно было
// выбирать ячейки для формулы
if (ws.getCellEditMode()){
if( this.cellEditor && this.cellEditor.formulaIsOperator() ){
this.copyActiveSheet = this.wsActive;
if( !this.cellFormulaEnterWSOpen ){
this.cellFormulaEnterWSOpen = ws;
} else {
ws.setFormulaEditMode(false);
}
}
else{
if (!isResized)
this._onStopCellEditing();
}
if (ws.getCellEditMode()) {
if (this.cellEditor && this.cellEditor.formulaIsOperator()) {
this.copyActiveSheet = this.wsActive;
if (!this.cellFormulaEnterWSOpen) {
this.cellFormulaEnterWSOpen = ws;
} else {
ws.setFormulaEditMode(false);
}
} else {
if (!isResized) {
this._onStopCellEditing();
}
}
}
// Делаем очистку селекта
ws.cleanSelection();
this.stopTarget(ws);
......@@ -1570,28 +1576,26 @@
ws = this.getWorksheet(index);
// Мы делали resize или меняли zoom, но не перерисовывали данный лист (он был не активный)
if ( ws.updateResize && ws.updateZoom ) {
ws.changeZoomResize();
}
else if ( ws.updateResize ) {
ws.resize( true );
}
else if ( ws.updateZoom ) {
ws.changeZoom( true );
}
if (ws.updateResize && ws.updateZoom) {
ws.changeZoomResize();
} else if (ws.updateResize) {
ws.resize(true);
} else if (ws.updateZoom) {
ws.changeZoom(true);
}
if (this.cellEditor && this.cellFormulaEnterWSOpen ) {
if (ws === this.cellFormulaEnterWSOpen){
this.cellFormulaEnterWSOpen.setFormulaEditMode( true );
this.cellEditor._showCanvas();
} else if (this.cellFormulaEnterWSOpen.getCellEditMode() && this.cellEditor.isFormula() ) {
this.cellFormulaEnterWSOpen.setFormulaEditMode( false );
/*скрываем cellEditor, в редактор добавляем %selected sheet name%+"!" */
this.cellEditor._hideCanvas();
ws.cleanSelection();
ws.setFormulaEditMode(true);
}
if (this.cellEditor && this.cellFormulaEnterWSOpen) {
if (ws === this.cellFormulaEnterWSOpen) {
this.cellFormulaEnterWSOpen.setFormulaEditMode(true);
this.cellEditor._showCanvas();
} else if (this.cellFormulaEnterWSOpen.getCellEditMode() && this.cellEditor.isFormula()) {
this.cellFormulaEnterWSOpen.setFormulaEditMode(false);
/*скрываем cellEditor, в редактор добавляем %selected sheet name%+"!" */
this.cellEditor._hideCanvas();
ws.cleanSelection();
ws.setFormulaEditMode(true);
}
}
if (!bLockDraw) {
ws.draw();
......@@ -1773,6 +1777,13 @@
this.wsMustDraw = false;
};
WorkbookView.prototype.getSelectionInfo = function () {
if (!this.oSelectionInfo) {
this._updateSelectionInfo();
}
return this.oSelectionInfo;
};
// Получаем свойство: редактируем мы сейчас или нет
WorkbookView.prototype.getCellEditMode = function() {
return this.isCellEditMode;
......
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