Commit b3633a23 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Поправил историю для перерисовок после undo/redo. Поправил getSelectionState...

Поправил историю для перерисовок после undo/redo. Поправил getSelectionState для объектов (не пишем туда весь worksheet, вместо этого пишем только id).
Поправил добавление в историю (не пишем лишнюю информацию).

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57568 954022d7-b5bf-4e40-9824-e11837661b57
parent abddaa82
......@@ -4402,7 +4402,7 @@ DrawingObjectsController.prototype =
var worksheetView = this.drawingObjects.getWorksheet();
if(worksheetView)
{
selection_state.worksheet = worksheetView.model;
selection_state.worksheetId = worksheetView.model.getId();
}
}
return [selection_state];
......
......@@ -222,7 +222,7 @@ CHistory.prototype =
if ( true != this.Can_Undo() )
return null;
if ( this.Index === this.Points.length - 1 )
if (this.Index === this.Points.length - 1)
this.LastState = this.workbook.handlers.trigger("getSelectionState");
this._checkCurPoint();
......@@ -231,9 +231,6 @@ CHistory.prototype =
var oRedoObjectParam = new Asc.RedoObjectParam();
this.UndoRedoPrepare(oRedoObjectParam, true);
var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive());
if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId())
this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId);
// Откатываем все действия в обратном порядке (относительно их выполенения)
for ( var Index = Point.Items.length - 1; Index >= 0; Index-- )
{
......@@ -253,8 +250,7 @@ CHistory.prototype =
}
/* отключаем отрисовку на случай необходимости пересчета ячеек, заносим ячейку, при необходимости в список перерисовываемых */
lockDraw(this.workbook);
this.workbook.handlers.trigger("lockDraw");
if (bUndo)
this.workbook.bUndoChanges = true;
else
......@@ -336,13 +332,14 @@ CHistory.prototype =
}
},
UndoRedoEnd: function (Point, oRedoObjectParam, bUndo) {
var wsViews, i, oState;
if (!bUndo && null == Point) {
this._checkCurPoint();
Point = this.Points[this.Index];
CollaborativeEditing.Apply_LinkData();
this.Get_RecalcData(Point);
var wsViews = Asc["editor"].wb.wsViews;
for (var i = 0; i < wsViews.length; ++i) {
wsViews = Asc["editor"].wb.wsViews;
for (i = 0; i < wsViews.length; ++i) {
if (wsViews[i]) {
wsViews[i].objectRender.controller.recalculate2(true);
}
......@@ -357,8 +354,8 @@ CHistory.prototype =
if (null != Point) {
if (bUndo) {
this.Get_RecalcData(Point);
var wsViews = Asc["editor"].wb.wsViews;
for (var i = 0; i < wsViews.length; ++i) {
wsViews = Asc["editor"].wb.wsViews;
for (i = 0; i < wsViews.length; ++i) {
if (wsViews[i]) {
wsViews[i].objectRender.controller.recalculate2(undefined);
}
......@@ -369,29 +366,28 @@ CHistory.prototype =
//синхронизация index и id worksheet
if (oRedoObjectParam.bUpdateWorksheetByModel)
this.workbook.handlers.trigger("updateWorksheetByModel");
for (var i in Point.UpdateRigions)
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
oState = bUndo ? Point.SelectionState : ((this.Index === this.Points.length - 1) ?
this.LastState : this.Points[this.Index + 1].SelectionState);
// ToDo какое-то не очень решение брать 0-й элемент и у него получать индекс!
var nSheetId = (null !== oState) ? oState[0].worksheetId : Point.nLastSheetId;
if (null !== nSheetId)
this.workbook.handlers.trigger('showWorksheet', nSheetId);
for (i in Point.UpdateRigions)
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i], false, true);
if (bUndo) {
if(Point.SelectionState && Point.SelectionState[0] && Point.SelectionState[0].focus) {
if (Point.SelectionState != null) {
this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
}
}
else {
if (Point.SelectionState) {
this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
} else {
this.workbook.handlers.trigger("setSelection", Point.SelectRange.clone(), /*validRange*/false);
}
}
else {
var State = null;
if ( this.Index === this.Points.length - 1 )
State = this.LastState;
else
State = this.Points[this.Index + 1].SelectionState;
if ( State && State[0] && State[0].focus) {
this.workbook.handlers.trigger("setSelectionState", State);
}
else {
} else {
if (null !== oState && oState[0] && oState[0].focus) {
this.workbook.handlers.trigger("setSelectionState", oState);
} else {
var oSelectRange = null;
if (null != Point.SelectRangeRedo)
oSelectRange = Point.SelectRangeRedo;
......@@ -400,13 +396,13 @@ CHistory.prototype =
if (null != oSelectRange)
this.workbook.handlers.trigger("setSelection", oSelectRange.clone());
}
}
for (var i in oRedoObjectParam.oChangeWorksheetUpdate)
this.workbook.handlers.trigger("changeWorksheetUpdate", oRedoObjectParam.oChangeWorksheetUpdate[i]);
for (i in oRedoObjectParam.oChangeWorksheetUpdate)
this.workbook.handlers.trigger("changeWorksheetUpdate",
oRedoObjectParam.oChangeWorksheetUpdate[i],{lockDraw: true});
if (oRedoObjectParam.bOnSheetsChanged)
this.workbook.handlers.trigger("asc_onSheetsChanged");
for (var i in oRedoObjectParam.oOnUpdateTabColor) {
for (i in oRedoObjectParam.oOnUpdateTabColor) {
var curSheet = this.workbook.getWorksheetById(i);
if (curSheet)
this.workbook.handlers.trigger("asc_onUpdateTabColor", curSheet.getIndex());
......@@ -448,9 +444,6 @@ CHistory.prototype =
this.CurPoint = null;
var Point = this.Points[++this.Index];
var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive());
if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId())
this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId);
this.RedoExecute(Point, oRedoObjectParam);
this.UndoRedoEnd(Point, oRedoObjectParam, false);
......@@ -594,15 +587,23 @@ CHistory.prototype =
var Items = [];
var UpdateRigions = {};
var Time = new Date().getTime();
var oSelectRange = this.workbook.handlers.trigger("getSelection");
var oSelectRange = null, nLastSheetId = null,
oSelectionState = this.workbook.handlers.trigger("getSelectionState");
if (null === oSelectionState) {
var wsActive = this.workbook.getWorksheet(this.workbook.getActive());
if (wsActive)
nLastSheetId = wsActive.getId();
oSelectRange = this.workbook.handlers.trigger("getSelection");
}
this.CurPoint = {
Items : Items, // Массив изменений, начиная с текущего момента
UpdateRigions : UpdateRigions,
nLastSheetId : null,
nLastSheetId : nLastSheetId,
SelectRange : oSelectRange,
SelectRangeRedo : oSelectRange,
Time : Time, // Текущее время
SelectionState : this.workbook.handlers.trigger("getSelectionState")
SelectionState : oSelectionState
};
},
......@@ -621,7 +622,8 @@ CHistory.prototype =
var Item;
if ( this.RecIndex >= this.Index )
this.RecIndex = this.Index - 1;
// ToDo Убрать это!!!
if(Class && !Class.Save_Changes)
{
Item =
......@@ -661,7 +663,8 @@ CHistory.prototype =
updateRange = range.clone();
oCurPoint.UpdateRigions[sheetid] = updateRange;
}
oCurPoint.nLastSheetId = sheetid;
if (null != sheetid)
oCurPoint.nLastSheetId = sheetid;
if(1 == oCurPoint.Items.length)
this._sendCanUndoRedo();
},
......
......@@ -104,8 +104,6 @@
this.lastFindResults = {}; // Результаты поиска (для поиска по всей книге, чтобы перейти на другой лист)
this.fReplaceCallback = null; // Callback для замены текста
this._lockDraw = false;
// Фонт, который выставлен в DrawingContext, он должен быть один на все DrawingContext-ы
this.m_oFont = new asc_FP(this.model.getDefaultFont(), this.model.getDefaultSize());
......@@ -309,10 +307,12 @@
self.getWorksheetById(wsId).changeWorksheet("delCell", {val: val, range: range});
});
this.model.handlers.add("showWorksheet", function (wsId) {
self.showWorksheetById(wsId);
var ws = self.getWorksheetById(wsId);
if ( ws )
self.handlers.trigger("asc_onActiveSheetChanged", ws.model.getIndex());
var wsModel = self.model.getWorksheetById(wsId), index;
if (wsModel) {
index = wsModel.getIndex();
self.showWorksheet(index, false, true);
self.handlers.trigger("asc_onActiveSheetChanged", index);
}
});
this.model.handlers.add("setSelection", function () {
self._onSetSelection.apply(self, arguments);
......@@ -335,9 +335,6 @@
this.model.handlers.add("showDrawingObjects", function () {
self.onShowDrawingObjects.apply(self, arguments);
});
this.model.handlers.add("lockDraw", function () {
self.lockDraw.apply(self, arguments);
});
this.model.handlers.add("setCanUndo", function (bCanUndo) {
self.handlers.trigger("asc_onCanUndoChanged", bCanUndo);
});
......@@ -589,17 +586,15 @@
WorkbookView.prototype._onGetSelectionState = function () {
var ws = this.getWorksheet();
return ws.objectRender.controller.getSelectionState();
var res = ws.objectRender.controller.getSelectionState();
// ToDo лучше на getSelectionState возвращать null
return (res && res[0] && res[0].focus) ? res : null;
};
WorkbookView.prototype._onSetSelectionState = function (state) {
if(state[0] && state[0].worksheet)
{
var ws = this.getWorksheet(state[0].worksheet.index);
if(ws)
{
this.showWorksheet(state[0].worksheet.index);
if (null !== state) {
var ws = this.getWorksheetById(state[0].worksheetId);
if (ws) {
ws.objectRender.controller.setSelectionState(state);
ws.setSelectionShape(true);
var d = ws._calcActiveCellOffset(ws.objectRender.getSelectedDrawingsRange());
......@@ -612,7 +607,6 @@
ws.objectRender.controller.updateSelectionState();
}
// Селектим после выставления состояния
}
};
......@@ -1169,19 +1163,14 @@
return ws;
};
WorkbookView.prototype.showWorksheetById = function (id) {
var wsModel = this.model.getWorksheetById(id);
if ( wsModel )
this.showWorksheet(wsModel.getIndex());
};
/**
*
* @param index
* @param [isResized]
* @param [bLockDraw]
* @returns {WorkbookView}
*/
WorkbookView.prototype.showWorksheet = function (index, isResized) {
WorkbookView.prototype.showWorksheet = function (index, isResized, bLockDraw) {
if (index === this.wsActive) {return this;}
var isSendInfo = (-1 === this.wsActive) || !isResized;
......@@ -1223,8 +1212,10 @@
ws.resize(true);
else if (ws.updateZoom)
ws.changeZoom(true);
ws.draw();
if (!bLockDraw)
ws.draw();
if (c_oAscSelectionDialogType.Chart === this.selectionDialogType) {
// Когда идет выбор диапазона, то на позываемом листе должны выставить нужный режим
ws.setSelectionDialogMode(this.selectionDialogType, selectionRange);
......@@ -1956,18 +1947,13 @@
ws._updateVisibleRowsCount();
};
WorkbookView.prototype.drawWS = function (){
this._lockDraw = false;
this.getWorksheet().draw(this._lockDraw);
this.getWorksheet().draw();
};
WorkbookView.prototype.onShowDrawingObjects = function (clearCanvas) {
var ws = this.getWorksheet();
ws.objectRender.showDrawingObjects(clearCanvas);
};
WorkbookView.prototype.lockDraw = function (){
this._lockDraw = true;
};
WorkbookView.prototype.insertHyperlink = function (options) {
var ws = this.getWorksheet();
if ( ws.objectRender.selectedGraphicObjectsExists() ) {
......
......@@ -6514,15 +6514,14 @@
return cell_info;
};
WorksheetView.prototype._getSelectionInfoObject = function (bExt) {
WorksheetView.prototype._getSelectionInfoObject = function () {
var objectInfo = new asc_CCellInfo();
var defaults = this.settings.cells;
var selectionType = c_oAscSelectionType.RangeShape;
objectInfo.flags = new asc_CCellFlag();
var graphicObjects = this.objectRender.getSelectedGraphicObjects();
if (graphicObjects.length)
selectionType = objectInfo.flags.selectionType = this.objectRender.getGraphicSelectionType(graphicObjects[0].Id);
objectInfo.flags.selectionType = this.objectRender.getGraphicSelectionType(graphicObjects[0].Id);
var textPr = this.objectRender.controller.getParagraphTextPr();
var theme = this.objectRender.controller.getTheme();
......@@ -9718,7 +9717,7 @@
bIsUpdateY = true;
}
if (bIsUpdateX && bIsUpdateY)
this.handlers.trigger("reinitializeScroll");
t.handlers.trigger("reinitializeScroll");
else if (bIsUpdateX)
t.handlers.trigger("reinitializeScrollX");
else if (bIsUpdateY)
......
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