Commit 2aa4d399 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

add History.UndoRedoPrepare, History.UndoRedoEnd....

add History.UndoRedoPrepare, History.UndoRedoEnd. trigger("updateSheetViewSettings"), trigger("asc_onUpdateTabColor" перенесены в History.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56547 954022d7-b5bf-4e40-9824-e11837661b57
parent f3ba8db6
...@@ -352,6 +352,7 @@ function CHistory(workbook) ...@@ -352,6 +352,7 @@ function CHistory(workbook)
this.TurnOffHistory = 0; this.TurnOffHistory = 0;
this.Transaction = 0; this.Transaction = 0;
this.RecIndex = -1; this.RecIndex = -1;
this.lastDrawingObjects = null;
} }
CHistory.prototype = CHistory.prototype =
{ {
...@@ -387,7 +388,6 @@ CHistory.prototype = ...@@ -387,7 +388,6 @@ CHistory.prototype =
// Проверяем можно ли сделать Undo // Проверяем можно ли сделать Undo
if ( true != this.Can_Undo() ) if ( true != this.Can_Undo() )
return null; return null;
var bIsOn = false;
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");
...@@ -395,24 +395,9 @@ CHistory.prototype = ...@@ -395,24 +395,9 @@ CHistory.prototype =
this._checkCurPoint(); this._checkCurPoint();
var Point = this.Points[this.Index--]; var Point = this.Points[this.Index--];
var oRedoObjectParam = new Asc.RedoObjectParam();
this.UndoRedoPrepare(oRedoObjectParam, true);
if(this.Is_On())
{
bIsOn = true;
this.TurnOff();
}
/* отключаем отрисовку на случай необходимости пересчета ячеек, заносим ячейку, при необходимости в список перерисовываемых */
lockDraw(this.workbook);
this.workbook.handlers.trigger("lockDraw");
this.workbook.bUndoChanges = true;
var isReInit = false;
var isRedrawAll = true;
var bChangeWorksheetUpdate = false;
var oChangeWorksheetUpdate = {};
var bUpdateWorksheetByModel = false;
var bOnSheetsChanged = false;
var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive()); var oCurWorksheet = this.workbook.getWorksheet(this.workbook.getActive());
if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId()) if(null != Point.nLastSheetId && Point.nLastSheetId != oCurWorksheet.getId())
this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId); this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId);
...@@ -424,66 +409,11 @@ CHistory.prototype = ...@@ -424,66 +409,11 @@ CHistory.prototype =
Item.Class.Undo( Item.Type, Item.Data, Item.SheetId ); Item.Class.Undo( Item.Type, Item.Data, Item.SheetId );
else else
Item.Class.Undo(Item.Data); Item.Class.Undo(Item.Data);
if (g_oUndoRedoWorksheet === Item.Class && (historyitem_Worksheet_RowProp == Item.Type || historyitem_Worksheet_ColProp == Item.Type)) this._addRedoObjectParam(oRedoObjectParam, Item);
{
bChangeWorksheetUpdate = true;
oChangeWorksheetUpdate[Item.SheetId] = Item.SheetId;
}
else if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type)
isReInit = true;
else if (g_oUndoRedoWorkbook === Item.Class && (historyitem_Workbook_SheetAdd === Item.Type || historyitem_Workbook_SheetRemove === Item.Type || historyitem_Workbook_SheetMove === Item.Type || historyitem_Workbook_SheetPositions === Item.Type)) {
bUpdateWorksheetByModel = true;
bOnSheetsChanged = true;
}
else if (g_oUndoRedoWorksheet === Item.Class && (historyitem_Worksheet_Rename === Item.Type || historyitem_Worksheet_Hide === Item.Type))
bOnSheetsChanged = true;
}
var wsViews = Asc["editor"].wb.wsViews;
for(var i = 0; i < wsViews.length; ++i)
{
if(wsViews[i])
{
wsViews[i].objectRender.controller.recalculate(undefined, Point);
}
}
gUndoInsDelCellsFlag = true;
for(var i in Point.UpdateRigions)
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
if(null != Point.SelectRange)
this.workbook.handlers.trigger("setSelection", Point.SelectRange.clone(), /*validRange*/false);
if ( Point.SelectionState != null )
this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
if(bChangeWorksheetUpdate)
{
for(var i in oChangeWorksheetUpdate)
this.workbook.handlers.trigger("changeWorksheetUpdate", oChangeWorksheetUpdate[i]);
} }
if (bUpdateWorksheetByModel) this.UndoRedoEnd(Point, oRedoObjectParam, true);
this.workbook.handlers.trigger("updateWorksheetByModel");
if (bOnSheetsChanged)
this.workbook.handlers.trigger("asc_onSheetsChanged");
this._sendCanUndoRedo();
this.workbook.bUndoChanges = false;
if (isReInit)
this.workbook.handlers.trigger("reInit");
if (isRedrawAll)
this.workbook.handlers.trigger("drawWS");
else
this.workbook.handlers.trigger("showDrawingObjects", true);
if(isRealObject(this.lastDrawingObjects))
{
this.lastDrawingObjects.sendGraphicObjectProps();
this.lastDrawingObjects = null;
}
/* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */
buildRecalc(this.workbook);
unLockDraw(this.workbook);
if(bIsOn)
this.TurnOn();
}, },
RedoPrepare : function (oRedoObjectParam) { UndoRedoPrepare : function (oRedoObjectParam, bUndo) {
if (this.Is_On()) { if (this.Is_On()) {
oRedoObjectParam.bIsOn = true; oRedoObjectParam.bIsOn = true;
this.TurnOff(); this.TurnOff();
...@@ -492,6 +422,9 @@ CHistory.prototype = ...@@ -492,6 +422,9 @@ CHistory.prototype =
lockDraw(this.workbook); lockDraw(this.workbook);
this.workbook.handlers.trigger("lockDraw"); this.workbook.handlers.trigger("lockDraw");
if (bUndo)
this.workbook.bUndoChanges = true;
else
this.workbook.bRedoChanges = true; this.workbook.bRedoChanges = true;
}, },
RedoAdd : function(oRedoObjectParam, Class, Type, sheetid, range, Data, LocalChange) RedoAdd : function(oRedoObjectParam, Class, Type, sheetid, range, Data, LocalChange)
...@@ -520,19 +453,7 @@ CHistory.prototype = ...@@ -520,19 +453,7 @@ CHistory.prototype =
Class.Load_Changes(Data.oBinaryReader, null, new CDocumentColor(255, 255, 255)); Class.Load_Changes(Data.oBinaryReader, null, new CDocumentColor(255, 255, 255));
} }
} }
if (g_oUndoRedoWorksheet === Class && historyitem_Worksheet_SetViewSettings === Type) this._addRedoObjectParam(oRedoObjectParam, this.CurPoint.Items[this.CurPoint.Items.length - 1]);
oRedoObjectParam.bIsReInit = true;
else if (g_oUndoRedoWorksheet === Class && (historyitem_Worksheet_RowProp == Type || historyitem_Worksheet_ColProp == Type))
{
oRedoObjectParam.bChangeWorksheetUpdate = true;
oRedoObjectParam.oChangeWorksheetUpdate[sheetid] = sheetid;
}
else if (g_oUndoRedoWorkbook === Class && (historyitem_Workbook_SheetAdd === Type || historyitem_Workbook_SheetRemove === Type || historyitem_Workbook_SheetMove === Type || historyitem_Workbook_SheetPositions === Type)) {
oRedoObjectParam.bUpdateWorksheetByModel = true;
oRedoObjectParam.bOnSheetsChanged = true;
}
else if (g_oUndoRedoWorksheet === Class && (historyitem_Worksheet_Rename === Type || historyitem_Worksheet_Hide === Type))
oRedoObjectParam.bOnSheetsChanged = true;
}, },
RedoExecute : function(Point, oRedoObjectParam) RedoExecute : function(Point, oRedoObjectParam)
{ {
...@@ -552,19 +473,7 @@ CHistory.prototype = ...@@ -552,19 +473,7 @@ CHistory.prototype =
Item.Class.Load_Changes(Item.Data.oBinaryReader, null, new CDocumentColor(255, 255, 255)); Item.Class.Load_Changes(Item.Data.oBinaryReader, null, new CDocumentColor(255, 255, 255));
} }
} }
if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type) this._addRedoObjectParam(oRedoObjectParam, Item);
oRedoObjectParam.bIsReInit = true;
else if (g_oUndoRedoWorksheet === Item.Class && (historyitem_Worksheet_RowProp == Item.Type || historyitem_Worksheet_ColProp == Item.Type))
{
oRedoObjectParam.bChangeWorksheetUpdate = true;
oRedoObjectParam.oChangeWorksheetUpdate[Item.SheetId] = Item.SheetId;
}
else if (g_oUndoRedoWorkbook === Item.Class && (historyitem_Workbook_SheetAdd === Item.Type || historyitem_Workbook_SheetRemove === Item.Type || historyitem_Workbook_SheetMove === Item.Type || historyitem_Workbook_SheetPositions === Item.Type)) {
oRedoObjectParam.bUpdateWorksheetByModel = true;
oRedoObjectParam.bOnSheetsChanged = true;
}
else if (g_oUndoRedoWorksheet === Item.Class && (historyitem_Worksheet_Rename === Item.Type || historyitem_Worksheet_Hide === Item.Type))
oRedoObjectParam.bOnSheetsChanged = true;
} }
CollaborativeEditing.Apply_LinkData(); CollaborativeEditing.Apply_LinkData();
var wsViews = Asc["editor"].wb.wsViews; var wsViews = Asc["editor"].wb.wsViews;
...@@ -591,57 +500,79 @@ CHistory.prototype = ...@@ -591,57 +500,79 @@ CHistory.prototype =
this.lastDrawingObjects = null; this.lastDrawingObjects = null;
} }
}, },
RedoEnd : function(Point, oRedoObjectParam) UndoRedoEnd: function (Point, oRedoObjectParam, bUndo) {
{ if (!bUndo && null == Point) {
if(null == Point)
{
this._checkCurPoint(); this._checkCurPoint();
Point = this.Points[this.Index]; Point = this.Points[this.Index];
CollaborativeEditing.Apply_LinkData(); CollaborativeEditing.Apply_LinkData();
var wsViews = Asc["editor"].wb.wsViews; var wsViews = Asc["editor"].wb.wsViews;
for(var i = 0; i < wsViews.length; ++i) for (var i = 0; i < wsViews.length; ++i) {
{ if (wsViews[i]) {
if(wsViews[i])
{
wsViews[i].objectRender.controller.recalculate(true, null); wsViews[i].objectRender.controller.recalculate(true, null);
} }
} }
} }
if(null == Point) if (null != Point) {
return; if (bUndo) {
var wsViews = Asc["editor"].wb.wsViews;
for (var i = 0; i < wsViews.length; ++i) {
if (wsViews[i]) {
wsViews[i].objectRender.controller.recalculate(undefined, Point);
}
}
gUndoInsDelCellsFlag = true;
}
for (var i in Point.UpdateRigions)
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
if (bUndo) {
this.workbook.handlers.trigger("setSelection", Point.SelectRange.clone(), /*validRange*/false);
if (Point.SelectionState != null)
this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
}
else {
var oSelectRange = null; var oSelectRange = null;
if(null != Point.SelectRangeRedo) if (null != Point.SelectRangeRedo)
oSelectRange = Point.SelectRangeRedo; oSelectRange = Point.SelectRangeRedo;
else if(null != Point.SelectRange) else if (null != Point.SelectRange)
oSelectRange = Point.SelectRange; oSelectRange = Point.SelectRange;
for(var i in Point.UpdateRigions) if (null != oSelectRange)
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
if(null != oSelectRange)
this.workbook.handlers.trigger("setSelection", oSelectRange.clone()); this.workbook.handlers.trigger("setSelection", oSelectRange.clone());
if(oRedoObjectParam.bChangeWorksheetUpdate)
{
for(var i in oRedoObjectParam.oChangeWorksheetUpdate)
this.workbook.handlers.trigger("changeWorksheetUpdate", oRedoObjectParam.oChangeWorksheetUpdate[i]);
} }
for (var i in oRedoObjectParam.oChangeWorksheetUpdate)
this.workbook.handlers.trigger("changeWorksheetUpdate", oRedoObjectParam.oChangeWorksheetUpdate[i]);
if (oRedoObjectParam.bUpdateWorksheetByModel) if (oRedoObjectParam.bUpdateWorksheetByModel)
this.workbook.handlers.trigger("updateWorksheetByModel"); this.workbook.handlers.trigger("updateWorksheetByModel");
if (oRedoObjectParam.bOnSheetsChanged) if (oRedoObjectParam.bOnSheetsChanged)
this.workbook.handlers.trigger("asc_onSheetsChanged"); this.workbook.handlers.trigger("asc_onSheetsChanged");
//if (Point.SelectionState != null) for (var i in oRedoObjectParam.oOnUpdateTabColor) {
// this.workbook.handlers.trigger("setSelectionState", Point.SelectionState); var curSheet = this.workbook.getWorksheetById(i);
if (curSheet)
this.workbook.handlers.trigger("asc_onUpdateTabColor", curSheet.getIndex());
}
if (oRedoObjectParam.oOnUpdateSheetViewSettings[this.workbook.getWorksheet(this.workbook.getActive()).getId()])
this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings");
this._sendCanUndoRedo(); this._sendCanUndoRedo();
if (bUndo)
this.workbook.bUndoChanges = false;
else
this.workbook.bRedoChanges = false; this.workbook.bRedoChanges = false;
if (oRedoObjectParam.bIsReInit) if (oRedoObjectParam.bIsReInit)
this.workbook.handlers.trigger("reInit"); this.workbook.handlers.trigger("reInit");
this.workbook.handlers.trigger("drawWS"); this.workbook.handlers.trigger("drawWS");
if (bUndo) {
if (isRealObject(this.lastDrawingObjects)) {
this.lastDrawingObjects.sendGraphicObjectProps();
this.lastDrawingObjects = null;
}
}
}
/* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */ /* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */
buildRecalc(this.workbook); buildRecalc(this.workbook);
unLockDraw(this.workbook); unLockDraw(this.workbook);
if(oRedoObjectParam.bIsOn) if (oRedoObjectParam.bIsOn)
this.TurnOn(); this.TurnOn();
}, },
Redo : function() Redo : function()
...@@ -651,7 +582,7 @@ CHistory.prototype = ...@@ -651,7 +582,7 @@ CHistory.prototype =
return null; return null;
var oRedoObjectParam = new Asc.RedoObjectParam(); var oRedoObjectParam = new Asc.RedoObjectParam();
this.RedoPrepare(oRedoObjectParam); this.UndoRedoPrepare(oRedoObjectParam, false);
this.CurPoint = null; this.CurPoint = null;
var Point = this.Points[++this.Index]; var Point = this.Points[++this.Index];
...@@ -661,9 +592,26 @@ CHistory.prototype = ...@@ -661,9 +592,26 @@ CHistory.prototype =
this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId); this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId);
this.RedoExecute(Point, oRedoObjectParam); this.RedoExecute(Point, oRedoObjectParam);
this.RedoEnd(Point, oRedoObjectParam); this.UndoRedoEnd(Point, oRedoObjectParam, false);
},
_addRedoObjectParam: function (oRedoObjectParam, Point) {
if (g_oUndoRedoWorksheet === Point.Class && historyitem_Worksheet_SetViewSettings === Point.Type) {
oRedoObjectParam.bIsReInit = true;
oRedoObjectParam.oOnUpdateSheetViewSettings[Point.SheetId] = Point.SheetId;
}
else if (g_oUndoRedoWorksheet === Point.Class && (historyitem_Worksheet_RowProp == Point.Type || historyitem_Worksheet_ColProp == Point.Type))
oRedoObjectParam.oChangeWorksheetUpdate[Point.SheetId] = Point.SheetId;
else if (g_oUndoRedoWorkbook === Point.Class && (historyitem_Workbook_SheetAdd === Point.Type || historyitem_Workbook_SheetRemove === Point.Type || historyitem_Workbook_SheetMove === Point.Type || historyitem_Workbook_SheetPositions === Point.Type)) {
oRedoObjectParam.bUpdateWorksheetByModel = true;
oRedoObjectParam.bOnSheetsChanged = true;
}
else if (g_oUndoRedoWorksheet === Point.Class && (historyitem_Worksheet_Rename === Point.Type || historyitem_Worksheet_Hide === Point.Type))
oRedoObjectParam.bOnSheetsChanged = true;
else if (g_oUndoRedoWorksheet === Point.Class && historyitem_Worksheet_SetTabColor === Point.Type)
oRedoObjectParam.oOnUpdateTabColor[Point.SheetId] = Point.SheetId;
else if (g_oUndoRedoWorksheet === Point.Class && historyitem_Worksheet_ChangeFrozenCell === Point.Type)
oRedoObjectParam.oOnUpdateSheetViewSettings[Point.SheetId] = Point.SheetId;
}, },
Get_RecalcData : function(Point2) Get_RecalcData : function(Point2)
{ {
//if ( this.Index >= 0 ) //if ( this.Index >= 0 )
......
...@@ -1647,7 +1647,7 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){ ...@@ -1647,7 +1647,7 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
History.SetSelectionRedo(null); History.SetSelectionRedo(null);
var oHistoryPositions = null;//нужен самый последний historyitem_Workbook_SheetPositions var oHistoryPositions = null;//нужен самый последний historyitem_Workbook_SheetPositions
var oRedoObjectParam = new Asc.RedoObjectParam(); var oRedoObjectParam = new Asc.RedoObjectParam();
History.RedoPrepare(oRedoObjectParam); History.UndoRedoPrepare(oRedoObjectParam, false);
for(var i = 0, length = aChanges.length; i < length; ++i) for(var i = 0, length = aChanges.length; i < length; ++i)
{ {
var sChange = aChanges[i]; var sChange = aChanges[i];
...@@ -1673,7 +1673,7 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){ ...@@ -1673,7 +1673,7 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
if(null != oHistoryPositions) if(null != oHistoryPositions)
History.RedoAdd(oRedoObjectParam, oHistoryPositions.oClass, oHistoryPositions.nActionType, oHistoryPositions.nSheetId, oHistoryPositions.oRange, oHistoryPositions.oData); History.RedoAdd(oRedoObjectParam, oHistoryPositions.oClass, oHistoryPositions.nActionType, oHistoryPositions.nSheetId, oHistoryPositions.oRange, oHistoryPositions.oData);
History.RedoEnd(null, oRedoObjectParam); History.UndoRedoEnd(null, oRedoObjectParam, false);
oThis.bCollaborativeChanges = false; oThis.bCollaborativeChanges = false;
History.Clear(); History.Clear();
if(null != fCallback) if(null != fCallback)
...@@ -2117,7 +2117,7 @@ Woorksheet.prototype.setTabColor=function(color){ ...@@ -2117,7 +2117,7 @@ Woorksheet.prototype.setTabColor=function(color){
new UndoRedoData_FromTo(this.sheetPr.TabColor ? this.sheetPr.TabColor.clone() : null, color ? color.clone() : null)); new UndoRedoData_FromTo(this.sheetPr.TabColor ? this.sheetPr.TabColor.clone() : null, color ? color.clone() : null));
this.sheetPr.TabColor = color; this.sheetPr.TabColor = color;
if (!this.workbook.bUndoChanges && !this.workbook.bRedoChanges)
this.workbook.handlers.trigger("asc_onUpdateTabColor", this.getIndex()); this.workbook.handlers.trigger("asc_onUpdateTabColor", this.getIndex());
}; };
Woorksheet.prototype.renameWsToCollaborate=function(name){ Woorksheet.prototype.renameWsToCollaborate=function(name){
...@@ -2218,6 +2218,7 @@ Woorksheet.prototype.setSheetViewSettings = function (options) { ...@@ -2218,6 +2218,7 @@ Woorksheet.prototype.setSheetViewSettings = function (options) {
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_SetViewSettings, this.getId(), null, new UndoRedoData_FromTo(current, options.clone())); History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_SetViewSettings, this.getId(), null, new UndoRedoData_FromTo(current, options.clone()));
this.sheetViews[0].setSettings(options); this.sheetViews[0].setSettings(options);
if (!this.workbook.bUndoChanges && !this.workbook.bRedoChanges)
this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings"); this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings");
}; };
Woorksheet.prototype.getRowsCount=function(){ Woorksheet.prototype.getRowsCount=function(){
......
...@@ -1159,10 +1159,11 @@ ...@@ -1159,10 +1159,11 @@
this.bIsOn = false; this.bIsOn = false;
this.bIsReInit = false; this.bIsReInit = false;
this.bChangeWorksheetUpdate = false;
this.oChangeWorksheetUpdate = {}; this.oChangeWorksheetUpdate = {};
this.bUpdateWorksheetByModel = false; this.bUpdateWorksheetByModel = false;
this.bOnSheetsChanged = false; this.bOnSheetsChanged = false;
this.oOnUpdateTabColor = {};
this.oOnUpdateSheetViewSettings = {};
} }
/** @constructor */ /** @constructor */
......
...@@ -3297,7 +3297,7 @@ ...@@ -3297,7 +3297,7 @@
this.draw(); this.draw();
// Эвент на обновление // Эвент на обновление
if (isUpdate) if (isUpdate && !this.model.workbook.bUndoChanges && !this.model.workbook.bRedoChanges)
this.handlers.trigger("updateSheetViewSettings"); this.handlers.trigger("updateSheetViewSettings");
}; };
......
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