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
......@@ -351,7 +351,8 @@ function CHistory(workbook)
this.IsModify = false;
this.TurnOffHistory = 0;
this.Transaction = 0;
this.RecIndex = -1;
this.RecIndex = -1;
this.lastDrawingObjects = null;
}
CHistory.prototype =
{
......@@ -387,32 +388,16 @@ CHistory.prototype =
// Проверяем можно ли сделать Undo
if ( true != this.Can_Undo() )
return null;
var bIsOn = false;
if ( this.Index === this.Points.length - 1 )
this.LastState = this.workbook.handlers.trigger("getSelectionState");
this._checkCurPoint();
var Point = this.Points[this.Index--];
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 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);
......@@ -423,67 +408,12 @@ CHistory.prototype =
if(!Item.Class.Read_FromBinary2)
Item.Class.Undo( Item.Type, Item.Data, Item.SheetId );
else
Item.Class.Undo(Item.Data);
if (g_oUndoRedoWorksheet === Item.Class && (historyitem_Worksheet_RowProp == Item.Type || historyitem_Worksheet_ColProp == Item.Type))
{
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.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;
Item.Class.Undo(Item.Data);
this._addRedoObjectParam(oRedoObjectParam, Item);
}
/* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */
buildRecalc(this.workbook);
unLockDraw(this.workbook);
if(bIsOn)
this.TurnOn();
this.UndoRedoEnd(Point, oRedoObjectParam, true);
},
RedoPrepare : function (oRedoObjectParam) {
UndoRedoPrepare : function (oRedoObjectParam, bUndo) {
if (this.Is_On()) {
oRedoObjectParam.bIsOn = true;
this.TurnOff();
......@@ -492,7 +422,10 @@ CHistory.prototype =
lockDraw(this.workbook);
this.workbook.handlers.trigger("lockDraw");
this.workbook.bRedoChanges = true;
if (bUndo)
this.workbook.bUndoChanges = true;
else
this.workbook.bRedoChanges = true;
},
RedoAdd : function(oRedoObjectParam, Class, Type, sheetid, range, Data, LocalChange)
{
......@@ -520,19 +453,7 @@ CHistory.prototype =
Class.Load_Changes(Data.oBinaryReader, null, new CDocumentColor(255, 255, 255));
}
}
if (g_oUndoRedoWorksheet === Class && historyitem_Worksheet_SetViewSettings === Type)
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;
this._addRedoObjectParam(oRedoObjectParam, this.CurPoint.Items[this.CurPoint.Items.length - 1]);
},
RedoExecute : function(Point, oRedoObjectParam)
{
......@@ -551,20 +472,8 @@ CHistory.prototype =
Item.Data.oBinaryReader.Seek(Item.Data.nPos);
Item.Class.Load_Changes(Item.Data.oBinaryReader, null, new CDocumentColor(255, 255, 255));
}
}
if (g_oUndoRedoWorksheet === Item.Class && historyitem_Worksheet_SetViewSettings === Item.Type)
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;
this._addRedoObjectParam(oRedoObjectParam, Item);
}
CollaborativeEditing.Apply_LinkData();
var wsViews = Asc["editor"].wb.wsViews;
......@@ -591,58 +500,80 @@ CHistory.prototype =
this.lastDrawingObjects = null;
}
},
RedoEnd : function(Point, oRedoObjectParam)
{
if(null == Point)
{
this._checkCurPoint();
Point = this.Points[this.Index];
CollaborativeEditing.Apply_LinkData();
var wsViews = Asc["editor"].wb.wsViews;
for(var i = 0; i < wsViews.length; ++i)
{
if(wsViews[i])
{
wsViews[i].objectRender.controller.recalculate(true, null);
}
}
}
if(null == Point)
return;
var oSelectRange = null;
if(null != Point.SelectRangeRedo)
oSelectRange = Point.SelectRangeRedo;
else if(null != Point.SelectRange)
oSelectRange = Point.SelectRange;
for(var i in Point.UpdateRigions)
this.workbook.handlers.trigger("cleanCellCache", i, Point.UpdateRigions[i]);
if(null != oSelectRange)
this.workbook.handlers.trigger("setSelection", oSelectRange.clone());
if(oRedoObjectParam.bChangeWorksheetUpdate)
{
for(var i in oRedoObjectParam.oChangeWorksheetUpdate)
this.workbook.handlers.trigger("changeWorksheetUpdate", oRedoObjectParam.oChangeWorksheetUpdate[i]);
}
if (oRedoObjectParam.bUpdateWorksheetByModel)
this.workbook.handlers.trigger("updateWorksheetByModel");
if (oRedoObjectParam.bOnSheetsChanged)
this.workbook.handlers.trigger("asc_onSheetsChanged");
//if (Point.SelectionState != null)
// this.workbook.handlers.trigger("setSelectionState", Point.SelectionState);
this._sendCanUndoRedo();
this.workbook.bRedoChanges = false;
if (oRedoObjectParam.bIsReInit)
this.workbook.handlers.trigger("reInit");
this.workbook.handlers.trigger("drawWS");
/* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */
buildRecalc(this.workbook);
unLockDraw(this.workbook);
if(oRedoObjectParam.bIsOn)
this.TurnOn();
UndoRedoEnd: function (Point, oRedoObjectParam, bUndo) {
if (!bUndo && null == Point) {
this._checkCurPoint();
Point = this.Points[this.Index];
CollaborativeEditing.Apply_LinkData();
var wsViews = Asc["editor"].wb.wsViews;
for (var i = 0; i < wsViews.length; ++i) {
if (wsViews[i]) {
wsViews[i].objectRender.controller.recalculate(true, null);
}
}
}
if (null != Point) {
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;
if (null != Point.SelectRangeRedo)
oSelectRange = Point.SelectRangeRedo;
else if (null != Point.SelectRange)
oSelectRange = Point.SelectRange;
if (null != oSelectRange)
this.workbook.handlers.trigger("setSelection", oSelectRange.clone());
}
for (var i in oRedoObjectParam.oChangeWorksheetUpdate)
this.workbook.handlers.trigger("changeWorksheetUpdate", oRedoObjectParam.oChangeWorksheetUpdate[i]);
if (oRedoObjectParam.bUpdateWorksheetByModel)
this.workbook.handlers.trigger("updateWorksheetByModel");
if (oRedoObjectParam.bOnSheetsChanged)
this.workbook.handlers.trigger("asc_onSheetsChanged");
for (var i in oRedoObjectParam.oOnUpdateTabColor) {
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();
if (bUndo)
this.workbook.bUndoChanges = false;
else
this.workbook.bRedoChanges = false;
if (oRedoObjectParam.bIsReInit)
this.workbook.handlers.trigger("reInit");
this.workbook.handlers.trigger("drawWS");
if (bUndo) {
if (isRealObject(this.lastDrawingObjects)) {
this.lastDrawingObjects.sendGraphicObjectProps();
this.lastDrawingObjects = null;
}
}
}
/* возвращаем отрисовку. и перерисовываем ячейки с предварительным пересчетом */
buildRecalc(this.workbook);
unLockDraw(this.workbook);
if (oRedoObjectParam.bIsOn)
this.TurnOn();
},
Redo : function()
{
......@@ -651,7 +582,7 @@ CHistory.prototype =
return null;
var oRedoObjectParam = new Asc.RedoObjectParam();
this.RedoPrepare(oRedoObjectParam);
this.UndoRedoPrepare(oRedoObjectParam, false);
this.CurPoint = null;
var Point = this.Points[++this.Index];
......@@ -661,9 +592,26 @@ CHistory.prototype =
this.workbook.handlers.trigger("showWorksheet", Point.nLastSheetId);
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)
{
//if ( this.Index >= 0 )
......
......@@ -1647,7 +1647,7 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
History.SetSelectionRedo(null);
var oHistoryPositions = null;//нужен самый последний historyitem_Workbook_SheetPositions
var oRedoObjectParam = new Asc.RedoObjectParam();
History.RedoPrepare(oRedoObjectParam);
History.UndoRedoPrepare(oRedoObjectParam, false);
for(var i = 0, length = aChanges.length; i < length; ++i)
{
var sChange = aChanges[i];
......@@ -1673,7 +1673,7 @@ Workbook.prototype.DeserializeHistory = function(aChanges, fCallback){
if(null != oHistoryPositions)
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;
History.Clear();
if(null != fCallback)
......@@ -2117,8 +2117,8 @@ Woorksheet.prototype.setTabColor=function(color){
new UndoRedoData_FromTo(this.sheetPr.TabColor ? this.sheetPr.TabColor.clone() : null, color ? color.clone() : null));
this.sheetPr.TabColor = color;
this.workbook.handlers.trigger("asc_onUpdateTabColor", this.getIndex());
if (!this.workbook.bUndoChanges && !this.workbook.bRedoChanges)
this.workbook.handlers.trigger("asc_onUpdateTabColor", this.getIndex());
};
Woorksheet.prototype.renameWsToCollaborate=function(name){
var lastname = this.getName();
......@@ -2218,7 +2218,8 @@ Woorksheet.prototype.setSheetViewSettings = function (options) {
History.Add(g_oUndoRedoWorksheet, historyitem_Worksheet_SetViewSettings, this.getId(), null, new UndoRedoData_FromTo(current, options.clone()));
this.sheetViews[0].setSettings(options);
this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings");
if (!this.workbook.bUndoChanges && !this.workbook.bRedoChanges)
this.workbook.handlers.trigger("asc_onUpdateSheetViewSettings");
};
Woorksheet.prototype.getRowsCount=function(){
return this.nRowsCount;
......
......@@ -1159,10 +1159,11 @@
this.bIsOn = false;
this.bIsReInit = false;
this.bChangeWorksheetUpdate = false;
this.oChangeWorksheetUpdate = {};
this.bUpdateWorksheetByModel = false;
this.bOnSheetsChanged = false;
this.oOnUpdateTabColor = {};
this.oOnUpdateSheetViewSettings = {};
}
/** @constructor */
......
......@@ -3297,7 +3297,7 @@
this.draw();
// Эвент на обновление
if (isUpdate)
if (isUpdate && !this.model.workbook.bUndoChanges && !this.model.workbook.bRedoChanges)
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