Commit 038831a2 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил в апи функции asc_getCanUndo и asc_getCanRedo

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57618 954022d7-b5bf-4e40-9824-e11837661b57
parent 1e804d12
......@@ -1154,6 +1154,13 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
return false;
},
asc_getCanUndo: function () {
return History.Can_Undo();
},
asc_getCanRedo: function () {
return History.Can_Redo();
},
// Actions and callbacks interface
......@@ -3626,6 +3633,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
prot["asc_getDocumentName"] = prot.asc_getDocumentName;
prot["asc_getDocumentFormat"] = prot.asc_getDocumentFormat;
prot["asc_isDocumentModified"] = prot.asc_isDocumentModified;
prot["asc_getCanUndo"] = prot.asc_getCanUndo;
prot["asc_getCanRedo"] = prot.asc_getCanRedo;
prot["asc_setAutoSaveGap"] = prot.asc_setAutoSaveGap;
......
......@@ -186,10 +186,8 @@ function CHistory(workbook)
this.SavedIndex = null; // Номер точки отката, на которой произошло последнее сохранение
}
CHistory.prototype =
CHistory.prototype.Clear = function()
{
Clear : function()
{
this.Index = -1;
this.SavePoint = null;
this.Points.length = 0;
......@@ -201,28 +199,23 @@ CHistory.prototype =
this.SavedIndex = null;
this._sendCanUndoRedo();
},
Can_Undo : function()
{
if ( (null != this.CurPoint && this.CurPoint.Items.length > 0) || this.Index >= 0 )
return true;
return false;
},
Can_Redo : function()
{
if ( (null == this.CurPoint || 0 == this.CurPoint.Items.length) && this.Points.length > 0 && this.Index < this.Points.length - 1 )
return true;
return false;
},
};
/** @returns {boolean} */
CHistory.prototype.Can_Undo = function()
{
return ((null != this.CurPoint && this.CurPoint.Items.length > 0) || this.Index >= 0);
};
/** @returns {boolean} */
CHistory.prototype.Can_Redo = function()
{
return ((null == this.CurPoint || 0 == this.CurPoint.Items.length) && this.Points.length > 0 && this.Index < this.Points.length - 1);
};
Undo : function()
{
CHistory.prototype.Undo = function()
{
// Проверяем можно ли сделать Undo
if ( true != this.Can_Undo() )
return null;
return;
if (this.Index === this.Points.length - 1)
this.LastState = this.workbook.handlers.trigger("getSelectionState");
......@@ -244,8 +237,8 @@ CHistory.prototype =
this._addRedoObjectParam(oRedoObjectParam, Item);
}
this.UndoRedoEnd(Point, oRedoObjectParam, true);
},
UndoRedoPrepare : function (oRedoObjectParam, bUndo) {
};
CHistory.prototype.UndoRedoPrepare = function (oRedoObjectParam, bUndo) {
if (this.Is_On()) {
oRedoObjectParam.bIsOn = true;
this.TurnOff();
......@@ -257,9 +250,9 @@ CHistory.prototype =
this.workbook.bUndoChanges = true;
else
this.workbook.bRedoChanges = true;
},
RedoAdd : function(oRedoObjectParam, Class, Type, sheetid, range, Data, LocalChange)
{
};
CHistory.prototype.RedoAdd = function(oRedoObjectParam, Class, Type, sheetid, range, Data, LocalChange)
{
//todo сделать что-нибудь с Is_On
var bNeedOff = false;
if(false == this.Is_On())
......@@ -297,15 +290,14 @@ CHistory.prototype =
}
}
this._addRedoObjectParam(oRedoObjectParam, this.CurPoint.Items[this.CurPoint.Items.length - 1]);
},
CheckXfrmChanges: function(xfrm)
{
};
},
CHistory.prototype.CheckXfrmChanges = function(xfrm)
{
};
RedoExecute : function(Point, oRedoObjectParam)
{
CHistory.prototype.RedoExecute = function(Point, oRedoObjectParam)
{
// Выполняем все действия в прямом порядке
for ( var Index = 0; Index < Point.Items.length; Index++ )
{
......@@ -334,8 +326,8 @@ CHistory.prototype =
wsViews[i].objectRender.controller.recalculate2(undefined);
}
}
},
UndoRedoEnd: function (Point, oRedoObjectParam, bUndo) {
};
CHistory.prototype.UndoRedoEnd = function (Point, oRedoObjectParam, bUndo) {
var wsViews, i, oState;
if (!bUndo && null == Point) {
this._checkCurPoint();
......@@ -435,12 +427,12 @@ CHistory.prototype =
unLockDraw(this.workbook);
if (oRedoObjectParam.bIsOn)
this.TurnOn();
},
Redo : function()
{
};
CHistory.prototype.Redo = function()
{
// Проверяем можно ли сделать Redo
if ( true != this.Can_Redo() )
return null;
return;
var oRedoObjectParam = new Asc.RedoObjectParam();
this.UndoRedoPrepare(oRedoObjectParam, false);
......@@ -451,8 +443,8 @@ CHistory.prototype =
this.RedoExecute(Point, oRedoObjectParam);
this.UndoRedoEnd(Point, oRedoObjectParam, false);
},
_addRedoObjectParam: function (oRedoObjectParam, Point) {
};
CHistory.prototype._addRedoObjectParam = function (oRedoObjectParam, Point) {
if (g_oUndoRedoWorksheet === Point.Class && historyitem_Worksheet_SetViewSettings === Point.Type) {
oRedoObjectParam.bIsReInit = true;
oRedoObjectParam.oOnUpdateSheetViewSettings[Point.SheetId] = Point.SheetId;
......@@ -469,9 +461,9 @@ CHistory.prototype =
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)
{
};
CHistory.prototype.Get_RecalcData = function(Point2)
{
//if ( this.Index >= 0 )
{
//for ( var Pos = this.RecIndex + 1; Pos <= this.Index; Pos++ )
......@@ -510,20 +502,22 @@ CHistory.prototype =
}
}
}
},
};
Reset_RecalcIndex : function()
{
CHistory.prototype.Reset_RecalcIndex = function()
{
this.RecIndex = this.Index;
},
};
Set_Additional_ExtendDocumentToPos: function()
{},
CHistory.prototype.Set_Additional_ExtendDocumentToPos = function()
{
};
Check_UninonLastPoints : function()
{
CHistory.prototype.Check_UninonLastPoints = function()
{
// Не объединяем точки истории, если на предыдущей точке произошло сохранение
if ( this.Points.length < 2)
return;
......@@ -577,10 +571,10 @@ CHistory.prototype =
this.Index += DiffIndex;
this.RecIndex += Math.max( -1, this.RecIndex + DiffIndex);
}
},
};
Create_NewPoint : function()
{
CHistory.prototype.Create_NewPoint = function()
{
if ( 0 !== this.TurnOffHistory || 0 !== this.Transaction )
return;
......@@ -608,13 +602,13 @@ CHistory.prototype =
Time : Time, // Текущее время
SelectionState : oSelectionState
};
},
};
// Регистрируем новое изменение:
// Class - объект, в котором оно произошло
// Data - сами изменения
Add : function(Class, Type, sheetid, range, Data, LocalChange)
{
// Регистрируем новое изменение:
// Class - объект, в котором оно произошло
// Data - сами изменения
CHistory.prototype.Add = function(Class, Type, sheetid, range, Data, LocalChange)
{
if ( 0 !== this.TurnOffHistory )
return;
......@@ -670,10 +664,10 @@ CHistory.prototype =
oCurPoint.nLastSheetId = sheetid;
if(1 == oCurPoint.Items.length)
this._sendCanUndoRedo();
},
};
_sendCanUndoRedo : function()
{
CHistory.prototype._sendCanUndoRedo = function()
{
this.workbook.handlers.trigger("setCanUndo", this.Can_Undo());
this.workbook.handlers.trigger("setCanRedo", this.Can_Redo());
if(this.IsModify != this.Is_Modified())
......@@ -681,9 +675,9 @@ CHistory.prototype =
this.IsModify = !this.IsModify;
this.workbook.handlers.trigger("setDocumentModified", this.IsModify);
}
},
_checkCurPoint : function()
{
};
CHistory.prototype._checkCurPoint = function()
{
if(null != this.CurPoint && this.CurPoint.Items.length > 0)
{
// Создаем новую точку
......@@ -692,69 +686,69 @@ CHistory.prototype =
this.Points.length = this.Index + 1;
this.CurPoint = null;
}
},
SetSelection : function(range)
{
};
CHistory.prototype.SetSelection = function(range)
{
if ( 0 !== this.TurnOffHistory )
return;
if ( null == this.CurPoint )
return;
this.CurPoint.SelectRange = range;
},
SetSelectionRedo : function(range)
{
};
CHistory.prototype.SetSelectionRedo = function(range)
{
if ( 0 !== this.TurnOffHistory )
return;
if ( null == this.CurPoint )
return;
this.CurPoint.SelectRangeRedo = range;
},
GetSelection : function(range)
{
};
CHistory.prototype.GetSelection = function()
{
var oRes = null;
if(null != this.CurPoint)
oRes = this.CurPoint.SelectRange;
return oRes;
},
GetSelectionRedo : function(range)
{
};
CHistory.prototype.GetSelectionRedo = function()
{
var oRes = null;
if(null != this.CurPoint)
oRes = this.CurPoint.SelectRangeRedo;
return oRes;
},
TurnOff : function()
{
};
CHistory.prototype.TurnOff = function()
{
this.TurnOffHistory++;
},
};
TurnOn : function()
{
CHistory.prototype.TurnOn = function()
{
this.TurnOffHistory--;
if(this.TurnOffHistory < 0)
this.TurnOffHistory = 0;
},
};
StartTransaction : function()
{
CHistory.prototype.StartTransaction = function()
{
this.Transaction++;
},
};
EndTransaction : function()
{
CHistory.prototype.EndTransaction = function()
{
this.Transaction--;
if(this.Transaction < 0)
this.Transaction = 0;
},
Is_On : function()
{
return ( 0 === this.TurnOffHistory ? true : false ) ;
},
Save : function()
{
};
/** @returns {boolean} */
CHistory.prototype.Is_On = function()
{
return (0 === this.TurnOffHistory);
};
CHistory.prototype.Save = function()
{
if(null != this.CurPoint && this.CurPoint.Items.length > 0)
this.SavePoint = this.CurPoint;
else if(this.Index >= 0 && this.Index < this.Points.length)
......@@ -764,13 +758,14 @@ CHistory.prototype =
this.IsModify = !this.IsModify;
this.workbook.handlers.trigger("setDocumentModified", this.IsModify);
}
},
Reset_SavedIndex : function()
{
};
CHistory.prototype.Reset_SavedIndex = function()
{
this.SavedIndex = this.Index;
},
Is_Modified : function()
{
};
/** @returns {boolean} */
CHistory.prototype.Is_Modified = function()
{
if(null != this.CurPoint && this.CurPoint.Items.length > 0)
{
if(null != this.SavePoint)
......@@ -788,13 +783,12 @@ CHistory.prototype =
else if(null != this.SavePoint)
return true;
return false;
},
GetSerializeArray : function()
{
};
CHistory.prototype.GetSerializeArray = function()
{
var aRes = [];
this._checkCurPoint();
var i = 0, t;
var worksheets = Asc["editor"].wbModel.aWorksheets;
var i = 0;
if (null != this.SavedIndex)
i = this.SavedIndex + 1;
for(; i <= this.Index; ++i)
......@@ -810,14 +804,13 @@ CHistory.prototype =
aRes.push(aPointChanges);
}
return aRes;
},
//функция, которая перемещает последнее действие на первую позицию(в текущей точке)
ChangeActionsEndToStart : function()
{
};
//функция, которая перемещает последнее действие на первую позицию(в текущей точке)
CHistory.prototype.ChangeActionsEndToStart = function()
{
if(null != this.CurPoint && this.CurPoint.Items.length > 0)
{
var endAction = this.CurPoint.Items.pop();
this.CurPoint.Items.unshift(endAction);
}
}
};
\ No newline at end of file
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