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