Commit 8923c35b authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Bug 30880 - Теряется последнее изменение в документе

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@66443 954022d7-b5bf-4e40-9824-e11837661b57
parent b895857b
...@@ -110,7 +110,6 @@ function CHistory(workbook) ...@@ -110,7 +110,6 @@ function CHistory(workbook)
this.workbook = workbook; this.workbook = workbook;
this.Index = -1; this.Index = -1;
this.Points = []; this.Points = [];
this.CurPoint = null;
this.TurnOffHistory = 0; this.TurnOffHistory = 0;
this.Transaction = 0; this.Transaction = 0;
this.LocalChange = false;//если true все добавленный изменения не пойдут в совместное редактирование. this.LocalChange = false;//если true все добавленный изменения не пойдут в совместное редактирование.
...@@ -134,7 +133,6 @@ CHistory.prototype.Clear = function() ...@@ -134,7 +133,6 @@ CHistory.prototype.Clear = function()
{ {
this.Index = -1; this.Index = -1;
this.Points.length = 0; this.Points.length = 0;
this.CurPoint = null;
this.TurnOffHistory = 0; this.TurnOffHistory = 0;
this.Transaction = 0; this.Transaction = 0;
this.LoadFonts = {}; this.LoadFonts = {};
...@@ -149,12 +147,12 @@ CHistory.prototype.Clear = function() ...@@ -149,12 +147,12 @@ CHistory.prototype.Clear = function()
/** @returns {boolean} */ /** @returns {boolean} */
CHistory.prototype.Can_Undo = function() CHistory.prototype.Can_Undo = function()
{ {
return ((null != this.CurPoint && this.CurPoint.Items.length > 0) || this.Index >= 0); return this.Index >= 0;
}; };
/** @returns {boolean} */ /** @returns {boolean} */
CHistory.prototype.Can_Redo = function() CHistory.prototype.Can_Redo = function()
{ {
return ((null == this.CurPoint || 0 == this.CurPoint.Items.length) && this.Points.length > 0 && this.Index < this.Points.length - 1); return this.Points.length > 0 && this.Index < this.Points.length - 1;
}; };
CHistory.prototype.Undo = function() CHistory.prototype.Undo = function()
...@@ -166,8 +164,6 @@ CHistory.prototype.Undo = function() ...@@ -166,8 +164,6 @@ CHistory.prototype.Undo = function()
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();
var Point = this.Points[this.Index--]; var Point = this.Points[this.Index--];
var oRedoObjectParam = new Asc.RedoObjectParam(); var oRedoObjectParam = new Asc.RedoObjectParam();
this.UndoRedoPrepare(oRedoObjectParam, true); this.UndoRedoPrepare(oRedoObjectParam, true);
...@@ -248,7 +244,10 @@ CHistory.prototype.RedoAdd = function(oRedoObjectParam, Class, Type, sheetid, ra ...@@ -248,7 +244,10 @@ CHistory.prototype.RedoAdd = function(oRedoObjectParam, Class, Type, sheetid, ra
} }
} }
} }
this._addRedoObjectParam(oRedoObjectParam, this.CurPoint.Items[this.CurPoint.Items.length - 1]); var curPoint = this.Points[this.Index];
if (curPoint) {
this._addRedoObjectParam(oRedoObjectParam, curPoint.Items[curPoint.Items.length - 1]);
}
}; };
CHistory.prototype.CheckXfrmChanges = function(xfrm) CHistory.prototype.CheckXfrmChanges = function(xfrm)
...@@ -289,7 +288,6 @@ CHistory.prototype.RedoExecute = function(Point, oRedoObjectParam) ...@@ -289,7 +288,6 @@ CHistory.prototype.RedoExecute = function(Point, oRedoObjectParam)
CHistory.prototype.UndoRedoEnd = function (Point, oRedoObjectParam, bUndo) { CHistory.prototype.UndoRedoEnd = function (Point, oRedoObjectParam, bUndo) {
var wsViews, i, oState = null, bCoaut = false; var wsViews, i, oState = null, bCoaut = false;
if (!bUndo && null == Point) { if (!bUndo && null == Point) {
this._checkCurPoint();
Point = this.Points[this.Index]; Point = this.Points[this.Index];
CollaborativeEditing.Apply_LinkData(); CollaborativeEditing.Apply_LinkData();
bCoaut = true; bCoaut = true;
...@@ -415,7 +413,6 @@ CHistory.prototype.Redo = function() ...@@ -415,7 +413,6 @@ CHistory.prototype.Redo = function()
var oRedoObjectParam = new Asc.RedoObjectParam(); var oRedoObjectParam = new Asc.RedoObjectParam();
this.UndoRedoPrepare(oRedoObjectParam, false); this.UndoRedoPrepare(oRedoObjectParam, false);
this.CurPoint = null;
var Point = this.Points[++this.Index]; var Point = this.Points[++this.Index];
this.RedoExecute(Point, oRedoObjectParam); this.RedoExecute(Point, oRedoObjectParam);
...@@ -456,7 +453,7 @@ CHistory.prototype.Get_RecalcData = function(Point2) ...@@ -456,7 +453,7 @@ CHistory.prototype.Get_RecalcData = function(Point2)
} }
else else
{ {
Point = this.CurPoint; Point = this.Points[this.Index];
} }
if(Point) if(Point)
{ {
...@@ -561,7 +558,6 @@ CHistory.prototype.Create_NewPoint = function() ...@@ -561,7 +558,6 @@ CHistory.prototype.Create_NewPoint = function()
if (null !== this.SavedIndex && this.Index < this.SavedIndex) if (null !== this.SavedIndex && this.Index < this.SavedIndex)
this.Set_SavedIndex(this.Index); this.Set_SavedIndex(this.Index);
this._checkCurPoint();
var Items = []; var Items = [];
var UpdateRigions = {}; var UpdateRigions = {};
var Time = new Date().getTime(); var Time = new Date().getTime();
...@@ -573,7 +569,8 @@ CHistory.prototype.Create_NewPoint = function() ...@@ -573,7 +569,8 @@ CHistory.prototype.Create_NewPoint = function()
if (wsActive) if (wsActive)
UndoSheetId = wsActive.getId(); UndoSheetId = wsActive.getId();
this.CurPoint = { // Создаем новую точку
this.Points[++this.Index] = {
Items : Items, // Массив изменений, начиная с текущего момента Items : Items, // Массив изменений, начиная с текущего момента
UpdateRigions : UpdateRigions, UpdateRigions : UpdateRigions,
UndoSheetId: UndoSheetId, UndoSheetId: UndoSheetId,
...@@ -584,6 +581,9 @@ CHistory.prototype.Create_NewPoint = function() ...@@ -584,6 +581,9 @@ CHistory.prototype.Create_NewPoint = function()
SelectionState : oSelectionState SelectionState : oSelectionState
}; };
// Удаляем ненужные точки
this.Points.length = this.Index + 1;
this._addFonts(true); this._addFonts(true);
}; };
...@@ -592,13 +592,9 @@ CHistory.prototype.Create_NewPoint = function() ...@@ -592,13 +592,9 @@ CHistory.prototype.Create_NewPoint = function()
// Data - сами изменения // Data - сами изменения
CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange) CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange)
{ {
if ( 0 !== this.TurnOffHistory ) if ( 0 !== this.TurnOffHistory || this.Index < 0 )
return; return;
if ( null == this.CurPoint )
return;
var oCurPoint = this.CurPoint;
var Item; var Item;
if ( this.RecIndex >= this.Index ) if ( this.RecIndex >= this.Index )
this.RecIndex = this.Index - 1; this.RecIndex = this.Index - 1;
...@@ -633,19 +629,20 @@ CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange ...@@ -633,19 +629,20 @@ CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange
if(null != LocalChange) if(null != LocalChange)
Item.LocalChange = LocalChange; Item.LocalChange = LocalChange;
oCurPoint.Items.push( Item ); var curPoint = this.Points[this.Index];
curPoint.Items.push( Item );
if (null != range && null != sheetid) if (null != range && null != sheetid)
{ {
var updateRange = oCurPoint.UpdateRigions[sheetid]; var updateRange = curPoint.UpdateRigions[sheetid];
if(null != updateRange) if(null != updateRange)
updateRange.union2(range); updateRange.union2(range);
else else
updateRange = range.clone(); updateRange = range.clone();
oCurPoint.UpdateRigions[sheetid] = updateRange; curPoint.UpdateRigions[sheetid] = updateRange;
} }
if (null != sheetid) if (null != sheetid)
oCurPoint.UndoSheetId = sheetid; curPoint.UndoSheetId = sheetid;
if(1 == oCurPoint.Items.length) if(1 == curPoint.Items.length)
this._sendCanUndoRedo(); this._sendCanUndoRedo();
}; };
...@@ -655,64 +652,56 @@ CHistory.prototype._sendCanUndoRedo = function() ...@@ -655,64 +652,56 @@ CHistory.prototype._sendCanUndoRedo = function()
this.workbook.handlers.trigger("setCanRedo", this.Can_Redo()); this.workbook.handlers.trigger("setCanRedo", this.Can_Redo());
this.workbook.handlers.trigger("setDocumentModified", this.Is_Modified()); this.workbook.handlers.trigger("setDocumentModified", this.Is_Modified());
}; };
CHistory.prototype._checkCurPoint = function()
{
if(null != this.CurPoint && this.CurPoint.Items.length > 0)
{
// Создаем новую точку
this.Points[++this.Index] = this.CurPoint;
// Удаляем ненужные точки
this.Points.length = this.Index + 1;
this.CurPoint = null;
}
};
CHistory.prototype.SetSelection = function(range) CHistory.prototype.SetSelection = function(range)
{ {
if ( 0 !== this.TurnOffHistory ) if ( 0 !== this.TurnOffHistory )
return; return;
var curPoint = this.Points[this.Index];
if ( null == this.CurPoint ) if (curPoint) {
return; curPoint.SelectRange = range;
this.CurPoint.SelectRange = range; }
}; };
CHistory.prototype.SetSelectionRedo = function(range) CHistory.prototype.SetSelectionRedo = function(range)
{ {
if ( 0 !== this.TurnOffHistory ) if ( 0 !== this.TurnOffHistory )
return; return;
var curPoint = this.Points[this.Index];
if ( null == this.CurPoint ) if (curPoint) {
return; curPoint.SelectRangeRedo = range;
this.CurPoint.SelectRangeRedo = range; }
}; };
CHistory.prototype.GetSelection = function() CHistory.prototype.GetSelection = function()
{ {
var oRes = null; var oRes = null;
if(null != this.CurPoint) var curPoint = this.Points[this.Index];
oRes = this.CurPoint.SelectRange; if(curPoint)
oRes = curPoint.SelectRange;
return oRes; return oRes;
}; };
CHistory.prototype.GetSelectionRedo = function() CHistory.prototype.GetSelectionRedo = function()
{ {
var oRes = null; var oRes = null;
if(null != this.CurPoint) var curPoint = this.Points[this.Index];
oRes = this.CurPoint.SelectRangeRedo; if (curPoint) {
oRes = curPoint.SelectRangeRedo;
}
return oRes; return oRes;
}; };
CHistory.prototype.SetSheetRedo = function (sheetId) { CHistory.prototype.SetSheetRedo = function (sheetId) {
if (0 !== this.TurnOffHistory) if (0 !== this.TurnOffHistory)
return; return;
var curPoint = this.Points[this.Index];
if (null == this.CurPoint) if (curPoint) {
return; curPoint.RedoSheetId = sheetId;
this.CurPoint.RedoSheetId = sheetId; }
}; };
CHistory.prototype.SetSheetUndo = function (sheetId) { CHistory.prototype.SetSheetUndo = function (sheetId) {
if (0 !== this.TurnOffHistory) if (0 !== this.TurnOffHistory)
return; return;
var curPoint = this.Points[this.Index];
if (null == this.CurPoint) if (curPoint) {
return; curPoint.UndoSheetId = sheetId;
this.CurPoint.UndoSheetId = sheetId; }
}; };
CHistory.prototype.TurnOff = function() CHistory.prototype.TurnOff = function()
{ {
...@@ -798,7 +787,6 @@ CHistory.prototype.Is_Modified = function(IsUserSave) { ...@@ -798,7 +787,6 @@ CHistory.prototype.Is_Modified = function(IsUserSave) {
CHistory.prototype.GetSerializeArray = function() CHistory.prototype.GetSerializeArray = function()
{ {
var aRes = []; var aRes = [];
this._checkCurPoint();
var i = 0; var i = 0;
if (null != this.SavedIndex) if (null != this.SavedIndex)
i = this.SavedIndex + 1; i = this.SavedIndex + 1;
...@@ -818,10 +806,11 @@ CHistory.prototype.GetSerializeArray = function() ...@@ -818,10 +806,11 @@ CHistory.prototype.GetSerializeArray = function()
//функция, которая перемещает последнее действие на первую позицию(в текущей точке) //функция, которая перемещает последнее действие на первую позицию(в текущей точке)
CHistory.prototype.ChangeActionsEndToStart = function() CHistory.prototype.ChangeActionsEndToStart = function()
{ {
if(null != this.CurPoint && this.CurPoint.Items.length > 0) var curPoint = this.Points[this.Index];
if(curPoint && curPoint.Items.length > 0)
{ {
var endAction = this.CurPoint.Items.pop(); var endAction = curPoint.Items.pop();
this.CurPoint.Items.unshift(endAction); curPoint.Items.unshift(endAction);
} }
}; };
CHistory.prototype.loadFonts = function (fonts) { CHistory.prototype.loadFonts = function (fonts) {
......
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