Commit b0995d63 authored by Ilya Kirillov's avatar Ilya Kirillov

For all changes added a function which returns a reverse change.

parent 8e1a0373
......@@ -2874,6 +2874,10 @@
{
return false;
};
CChangesBase.prototype.CreateReverseChange = function()
{
return null;
};
window['AscDFH'].CChangesBase = CChangesBase;
/**
* Базовый класс для изменений, которые меняют содержимое родительского класса.*
......@@ -3033,6 +3037,21 @@
return true;
};
CChangesBaseContentChange.prototype.private_CreateReverseChange = function(fConstructor)
{
var oChange = new fConstructor();
oChange.Pos = this.Pos;
oChange.Items = this.Items;
oChange.Add = !this.Add;
oChange.UseArray = this.UseArray;
oChange.PosArray = [];
for (var nIndex = 0, nCount = this.PosArray.length; nIndex < nCount; ++nIndex)
oChange.PosArray[nIndex] = this.PosArray[nIndex];
return oChange;
};
window['AscDFH'].CChangesBaseContentChange = CChangesBaseContentChange;
/**
* Базовый класс для изменения свойств.
......@@ -3060,6 +3079,10 @@
{
// Эту функцию нужно переопределить в дочернем классе
};
CChangesBaseProperty.prototype.CreateReverseChange = function()
{
return new this.constructor(this.Class, this.New, this.Old, this.Color);
};
window['AscDFH'].CChangesBaseProperty = CChangesBaseProperty;
/**
* Базовый класс для изменения булевых свойств.
......
......@@ -102,6 +102,10 @@
return Element;
};
CChangesTableIdAdd.prototype.CreateReverseChange = function()
{
return null;
};
window["AscCommon"].CChangesTableIdAdd = CChangesTableIdAdd;
/**
* @constructor
......@@ -153,6 +157,10 @@
CChangesTableIdReset.prototype.RefreshRecalcData = function()
{
};
CChangesTableIdReset.prototype.CreateReverseChange = function()
{
return new CChangesTableIdReset(this.Class, this.NewId, this.OldId);
};
window["AscCommon"].CChangesTableIdReset = CChangesTableIdReset;
/**
* @constructor
......@@ -277,6 +285,10 @@
CChangesTableIdDescription.prototype.RefreshRecalcData = function()
{
};
CChangesTableIdDescription.prototype.CreateReverseChange = function()
{
return null;
};
window["AscCommon"].CChangesTableIdDescription = CChangesTableIdDescription;
/**
* @constructor
......@@ -352,6 +364,10 @@
CChangesCommonAddWaterMark.prototype.RefreshRecalcData = function()
{
};
CChangesCommonAddWaterMark.prototype.CreateReverseChange = function()
{
return null;
};
window["AscCommon"].CChangesCommonAddWaterMark = CChangesCommonAddWaterMark;
})(window);
......
......@@ -164,6 +164,10 @@ CChangesCommentsAdd.prototype.ReadFromBinary = function(Reader)
this.Id = Reader.GetString2();
this.Comment = AscCommon.g_oTableId.Get_ById(this.Id);
};
CChangesCommentsAdd.prototype.CreateReverseChange = function()
{
return new CChangesCommentsRemove(this.Class, this.Id, this.Comment);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -198,6 +202,10 @@ CChangesCommentsRemove.prototype.ReadFromBinary = function(Reader)
this.Id = Reader.GetString2();
this.Comment = AscCommon.g_oTableId.Get_ById(this.Id);
};
CChangesCommentsRemove.prototype.CreateReverseChange = function()
{
return new CChangesCommentsAdd(this.Class, this.Id, this.Comment);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......
......@@ -174,6 +174,10 @@ CChangesDocumentAddItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesDocumentAddItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesDocumentRemoveItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -290,6 +294,10 @@ CChangesDocumentRemoveItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesDocumentRemoveItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesDocumentAddItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -325,6 +333,10 @@ CChangesDocumentDefaultTab.prototype.ReadFromBinary = function(Reader)
this.New = Reader.GetDouble();
this.Old = Reader.GetDouble();
};
CChangesDocumentDefaultTab.prototype.CreateReverseChange = function()
{
return new CChangesDocumentDefaultTab(this.Class, this.New, this.Old);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -360,6 +372,10 @@ CChangesDocumentEvenAndOddHeaders.prototype.ReadFromBinary = function(Reader)
this.New = Reader.GetBool();
this.Old = Reader.GetBool();
};
CChangesDocumentEvenAndOddHeaders.prototype.CreateReverseChange = function()
{
return new CChangesDocumentEvenAndOddHeaders(this.Class, this.New, this.Old);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -399,6 +415,10 @@ CChangesDocumentDefaultLanguage.prototype.ReadFromBinary = function(Reader)
this.New = Reader.GetBool();
this.Old = Reader.GetBool();
};
CChangesDocumentDefaultLanguage.prototype.CreateReverseChange = function()
{
return new CChangesDocumentDefaultLanguage(this.Class, this.New, this.Old);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -438,3 +458,7 @@ CChangesDocumentMathSettings.prototype.ReadFromBinary = function(Reader)
this.Old = new CMathSettings();
this.Old.Read_FromBinary(Reader);
};
CChangesDocumentMathSettings.prototype.CreateReverseChange = function()
{
return new CChangesDocumentMathSettings(this.Class, this.New, this.Old);
};
\ No newline at end of file
......@@ -167,6 +167,10 @@ CChangesDocumentContentAddItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesDocumentContentAddItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesDocumentContentRemoveItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -285,3 +289,7 @@ CChangesDocumentContentRemoveItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesDocumentContentRemoveItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesDocumentContentAddItem);
};
\ No newline at end of file
......@@ -101,6 +101,10 @@ CChangesParaFieldAddItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesParaFieldAddItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesParaFieldRemoveItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -160,3 +164,7 @@ CChangesParaFieldRemoveItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesParaFieldRemoveItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesParaFieldAddItem);
};
\ No newline at end of file
......@@ -76,6 +76,10 @@ CChangesParaFieldAddItem.prototype.ReadFromBinary = function(Reader)
// String : Id
this.Id = Reader.GetString2();
};
CChangesParaFieldAddItem.prototype.CreateReverseChange = function()
{
return null;
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......
......@@ -130,6 +130,10 @@ CChangesHyperlinkAddItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesHyperlinkAddItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesHyperlinkRemoveItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -188,3 +192,7 @@ CChangesHyperlinkRemoveItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesHyperlinkRemoveItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesHyperlinkAddItem);
};
\ No newline at end of file
......@@ -152,6 +152,10 @@ CChangesMathContentAddItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesMathContentAddItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesMathContentRemoveItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -208,6 +212,10 @@ CChangesMathContentRemoveItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesMathContentRemoveItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesMathContentAddItem);
};
/**
* Изменение настроек ArgSize в классе CMathContent
* @constructor
......@@ -294,6 +302,10 @@ CChangesMathBaseAddItems.prototype.IsRelated = function(oChanges)
return false;
};
CChangesMathBaseAddItems.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesMathBaseRemoveItems);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -341,6 +353,10 @@ CChangesMathBaseRemoveItems.prototype.IsRelated = function(oChanges)
return false;
};
CChangesMathBaseRemoveItems.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesMathBaseAddItems);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseLongProperty}
......@@ -721,9 +737,9 @@ CChangesMathBaseHighLight.prototype.ReadFromBinary = function(Reader)
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesMathBaseReviewType(Class, OldType, OldInfo, NewType, NewInfo)
function CChangesMathBaseReviewType(Class, Old, New)
{
CChangesMathBaseReviewType.superclass.constructor.call(this, Class, {Type : OldType, Info : OldInfo}, {Type : NewType, Info : NewInfo});
CChangesMathBaseReviewType.superclass.constructor.call(this, Class, Old, New);
}
AscCommon.extendClass(CChangesMathBaseReviewType, AscDFH.CChangesBaseProperty);
CChangesMathBaseReviewType.prototype.Type = AscDFH.historyitem_MathBase_ReviewType;
......@@ -1238,6 +1254,11 @@ CChangesMathMatrixAddRow.prototype.ReadFromBinary = function(Reader)
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
};
CChangesMathMatrixAddRow.prototype.CreateReverseChange = function()
{
// TODO: Это изменение надо целиком переделать
return new CChangesMathMatrixRemoveRow(this.Class, this.Pos, this.Items);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -1324,6 +1345,11 @@ CChangesMathMatrixRemoveRow.prototype.ReadFromBinary = function(Reader)
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
};
CChangesMathMatrixRemoveRow.prototype.CreateReverseChange = function()
{
// TODO: Это изменение надо целиком переделать
return new CChangesMathMatrixAddRow(this.Class, this.Pos, this.Items);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -1350,6 +1376,11 @@ CChangesMathMatrixAddColumn.prototype.Redo = function()
};
CChangesMathMatrixAddColumn.prototype.WriteToBinary = CChangesMathMatrixAddRow.prototype.WriteToBinary;
CChangesMathMatrixAddColumn.prototype.ReadFromBinary = CChangesMathMatrixAddRow.prototype.ReadFromBinary;
CChangesMathMatrixAddColumn.prototype.CreateReverseChange = function()
{
// TODO: Это изменение надо целиком переделать
return new CChangesMathMatrixRemoveColumn(this.Class, this.Pos, this.Items);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -1376,6 +1407,11 @@ CChangesMathMatrixRemoveColumn.prototype.Redo = function()
};
CChangesMathMatrixRemoveColumn.prototype.WriteToBinary = CChangesMathMatrixRemoveRow.prototype.WriteToBinary;
CChangesMathMatrixRemoveColumn.prototype.ReadFromBinary = CChangesMathMatrixRemoveRow.prototype.ReadFromBinary;
CChangesMathMatrixRemoveColumn.prototype.CreateReverseChange = function()
{
// TODO: Это изменение надо целиком переделать
return new CChangesMathMatrixAddColumn(this.Class, this.Pos, this.Items);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseLongProperty}
......@@ -1466,6 +1502,10 @@ CChangesMathMatrixColumnJc.prototype.ReadFromBinary = function(Reader)
this.ColumnIndex = Reader.GetLong();
};
CChangesMathMatrixColumnJc.prototype.CreateReverseChange = function()
{
return new CChangesMathMatrixColumnJc(this.Class, this.New, this.Old, this.ColumnIndex);
};
/**
* @constructor
......@@ -1558,6 +1598,10 @@ CChangesMathMatrixInterval.prototype.ReadFromBinary = function(Reader)
if (!(nFlags & 8))
this.Old.Gap = Reader.GetLong();
};
CChangesMathMatrixInterval.prototype.CreateReverseChange = function()
{
return new CChangesMathMatrixInterval(this.Class, this.ItemType, this.New.Rule, this.New.Gap, this.Old.Rule, this.Old.Gap);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseBoolProperty}
......
......@@ -94,6 +94,10 @@ CChangesAbstractNumLvlChange.prototype.Load = function(Color)
// Сразу нельзя запускать пересчет, т.к. возможно еще не все ссылки проставлены
AscCommon.CollaborativeEditing.Add_EndActions(this.Class, {iLvl : this.Index});
};
CChangesAbstractNumLvlChange.prototype.CreateReverseChange = function()
{
return new CChangesAbstractNumLvlChange(this.Class, this.New, this.Old, this.Index);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -143,6 +147,10 @@ CChangesAbstractNumTextPrChange.prototype.Load = function(Color)
// Сразу нельзя запускать пересчет, т.к. возможно еще не все ссылки проставлены
AscCommon.CollaborativeEditing.Add_EndActions(this.Class, {iLvl : this.Index});
};
CChangesAbstractNumTextPrChange.prototype.CreateReverseChange = function()
{
return new CChangesAbstractNumTextPrChange(this.Class, this.New, this.Old, this.Index);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......@@ -192,3 +200,7 @@ CChangesAbstractNumParaPrChange.prototype.Load = function(Color)
// Сразу нельзя запускать пересчет, т.к. возможно еще не все ссылки проставлены
AscCommon.CollaborativeEditing.Add_EndActions(this.Class, {iLvl : this.Index});
};
CChangesAbstractNumParaPrChange.prototype.CreateReverseChange = function()
{
return new CChangesAbstractNumParaPrChange(this.Class, this.New, this.Old, this.Index);
};
\ No newline at end of file
......@@ -170,6 +170,10 @@ CChangesParagraphAddItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesParagraphAddItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesParagraphRemoveItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -230,6 +234,10 @@ CChangesParagraphRemoveItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesParagraphRemoveItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesParagraphAddItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseObjectProperty}
......@@ -1023,6 +1031,10 @@ CChangesParagraphSectPr.prototype.ReadFromBinary = function(Reader)
else
this.Old = undefined;
};
CChangesParagraphSectPr.prototype.CreateReverseChange = function()
{
return new CChangesParagraphSectPr(this.Class, this.New, this.Old);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -1143,6 +1155,10 @@ CChangesParagraphPrChange.prototype.ReadFromBinary = function(Reader)
this.Old.ReviewInfo.Read_FromBinary(Reader);
}
};
CChangesParagraphPrChange.prototype.CreateReverseChange = function()
{
return new CChangesParagraphPrChange(this.Class, this.New, this.Old);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseObjectProperty}
......
......@@ -159,6 +159,10 @@ CChangesRunAddItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesRunAddItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesRunRemoveItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -229,6 +233,10 @@ CChangesRunRemoveItem.prototype.IsRelated = function(oChanges)
return false;
};
CChangesRunRemoveItem.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesRunAddItem);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseBoolProperty}
......@@ -1663,6 +1671,10 @@ CChangesRunOnStartSplit.prototype.Load = function()
if (AscCommon.CollaborativeEditing)
AscCommon.CollaborativeEditing.OnStart_SplitRun(this.Class, this.Pos);
};
CChangesRunOnStartSplit.prototype.CreateReverseChange = function()
{
return null;
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -1694,26 +1706,23 @@ CChangesRunOnEndSplit.prototype.Load = function()
if (AscCommon.CollaborativeEditing)
AscCommon.CollaborativeEditing.OnEnd_SplitRun(this.NewRun);
};
CChangesRunOnEndSplit.prototype.CreateReverseChange = function()
{
return null;
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesRunMathAlnAt(Class, Old, New)
{
CChangesRunMathAlnAt.superclass.constructor.call(this, Class);
this.Old = Old;
this.New = New;
CChangesRunMathAlnAt.superclass.constructor.call(this, Class, Old, New);
}
AscCommon.extendClass(CChangesRunMathAlnAt, AscDFH.CChangesBase);
AscCommon.extendClass(CChangesRunMathAlnAt, AscDFH.CChangesBaseProperty);
CChangesRunMathAlnAt.prototype.Type = AscDFH.historyitem_ParaRun_MathAlnAt;
CChangesRunMathAlnAt.prototype.Undo = function()
CChangesRunMathAlnAt.prototype.private_SetValue = function(Value)
{
this.Class.MathPrp.Apply_AlnAt(this.Old);
};
CChangesRunMathAlnAt.prototype.Redo = function()
{
this.Class.MathPrp.Apply_AlnAt(this.Old);
this.Class.MathPrp.Apply_AlnAt(Value);
};
CChangesRunMathAlnAt.prototype.WriteToBinary = function(Writer)
{
......@@ -1827,5 +1836,9 @@ CChangesRunMathForcedBreak.prototype.ReadFromBinary = function(Reader)
else
this.alnAt = Reader.GetLong();
};
CChangesRunMathForcedBreak.prototype.CreateReverseChange = function()
{
return new CChangesRunMathForcedBreak(this.Class, !this.bInsert, this.alnAt);
};
......@@ -642,6 +642,10 @@ CChangesSectionColumnsCol.prototype.ReadFromBinary = function(Reader)
this.Old.Read_FromBinary(Reader);
}
};
CChangesSectionColumnsCol.prototype.CreateReverseChange = function()
{
return new CChangesSectionColumnsCol(this.Class, this.New, this.Old, this.Index);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......
......@@ -811,6 +811,10 @@ CChangesStylesAdd.prototype.Load = function()
this.Redo();
AscCommon.CollaborativeEditing.Add_LinkData(this.Class, {UpdateStyleId : this.Id});
};
CChangesStylesAdd.prototype.CreateReverseChange = function()
{
return new CChangesStylesRemove(this.Class, this.Id, this.Style);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
......@@ -850,6 +854,10 @@ CChangesStylesRemove.prototype.Load = function()
this.Redo();
AscCommon.CollaborativeEditing.Add_LinkData(this.Class, {UpdateStyleId : this.Id});
};
CChangesStylesRemove.prototype.CreateReverseChange = function()
{
return new CChangesStylesAdd(this.Class, this.Id, this.Style);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseObjectValue}
......
......@@ -522,6 +522,10 @@ CChangesTableAddRow.prototype.IsRelated = function(oChanges)
return false;
};
CChangesTableAddRow.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesTableRemoveRow);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -592,6 +596,10 @@ CChangesTableRemoveRow.prototype.IsRelated = function(oChanges)
return false;
};
CChangesTableRemoveRow.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesTableAddRow);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
......
......@@ -409,6 +409,10 @@ CChangesTableRowAddCell.prototype.IsRelated = function(oChanges)
return false;
};
CChangesTableRowAddCell.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesTableRowRemoveCell);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseContentChange}
......@@ -470,6 +474,10 @@ CChangesTableRowRemoveCell.prototype.IsRelated = function(oChanges)
return false;
};
CChangesTableRowRemoveCell.prototype.CreateReverseChange = function()
{
return this.private_CreateReverseChange(CChangesTableRowAddCell);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseBoolProperty}
......
......@@ -2560,7 +2560,7 @@ CMathBase.prototype.Set_ReviewType = function(Type, isSetToContent)
var NewInfo = new CReviewInfo();
NewInfo.Update();
History.Add(new CChangesMathBaseReviewType(this, this.ReviewType, this.ReviewInfo, Type, NewInfo));
History.Add(new CChangesMathBaseReviewType(this, {Type : this.ReviewType, Info : this.ReviewInfo}, {Type : Type, Info : NewInfo}));
this.raw_SetReviewType(Type, NewInfo);
}
};
......@@ -2571,7 +2571,7 @@ CMathBase.prototype.Set_ReviewTypeWithInfo = function(ReviewType, ReviewInfo)
CMathBase.superclass.Set_ReviewTypeWithInfo.apply(this, arguments);
History.Add(new CChangesMathBaseReviewType(this, this.ReviewType, this.ReviewInfo, ReviewType, ReviewInfo));
History.Add(new CChangesMathBaseReviewType(this, {Type : this.ReviewType, Info : this.ReviewInfo}, {Type : ReviewType, Info : ReviewInfo}));
this.raw_SetReviewType(ReviewType, ReviewInfo);
};
CMathBase.prototype.Check_RevisionsChanges = function(Checker, ContentPos, Depth)
......
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