Commit dfa158b5 authored by Ilya Kirillov's avatar Ilya Kirillov

Changes for classes Numbering, Comments and DocumentContent were replaced with a new classes.

parent 02502cb3
...@@ -79,6 +79,7 @@ ...@@ -79,6 +79,7 @@
"../word/Editor/CollaborativeEditing.js", "../word/Editor/CollaborativeEditing.js",
"../word/Editor/Comments.js", "../word/Editor/Comments.js",
"../word/Editor/CommentsChanges.js",
"../word/Editor/History.js", "../word/Editor/History.js",
"../word/Editor/Styles.js", "../word/Editor/Styles.js",
"../word/Editor/FlowObjects.js", "../word/Editor/FlowObjects.js",
...@@ -98,11 +99,13 @@ ...@@ -98,11 +99,13 @@
"../word/Editor/Paragraph_Recalculate.js", "../word/Editor/Paragraph_Recalculate.js",
"../word/Editor/Sections.js", "../word/Editor/Sections.js",
"../word/Editor/Numbering.js", "../word/Editor/Numbering.js",
"../word/Editor/NumberingChanges.js",
"../word/Editor/HeaderFooter.js", "../word/Editor/HeaderFooter.js",
"../word/Editor/DocumentContentBase.js", "../word/Editor/DocumentContentBase.js",
"../word/Editor/Document.js", "../word/Editor/Document.js",
"../word/Editor/DocumentChanges.js", "../word/Editor/DocumentChanges.js",
"../word/Editor/DocumentContent.js", "../word/Editor/DocumentContent.js",
"../word/Editor/DocumentContentChanges.js",
"../word/Editor/DocumentControllerBase.js", "../word/Editor/DocumentControllerBase.js",
"../word/Editor/LogicDocumentController.js", "../word/Editor/LogicDocumentController.js",
"../word/Editor/DrawingsController.js", "../word/Editor/DrawingsController.js",
......
...@@ -129,6 +129,7 @@ ...@@ -129,6 +129,7 @@
"../cell/model/DrawingObjects/Format/ChartSpacePrototype.js", "../cell/model/DrawingObjects/Format/ChartSpacePrototype.js",
"../word/Editor/Comments.js", "../word/Editor/Comments.js",
"../word/Editor/CommentsChanges.js",
"../word/Editor/Styles.js", "../word/Editor/Styles.js",
"../word/Editor/FlowObjects.js", "../word/Editor/FlowObjects.js",
"../word/Editor/ParagraphContent.js", "../word/Editor/ParagraphContent.js",
...@@ -147,11 +148,13 @@ ...@@ -147,11 +148,13 @@
"../word/Editor/Paragraph_Recalculate.js", "../word/Editor/Paragraph_Recalculate.js",
"../word/Editor/Sections.js", "../word/Editor/Sections.js",
"../word/Editor/Numbering.js", "../word/Editor/Numbering.js",
"../word/Editor/NumberingChanges.js",
"../word/Editor/HeaderFooter.js", "../word/Editor/HeaderFooter.js",
"../word/Editor/DocumentContentBase.js", "../word/Editor/DocumentContentBase.js",
"../word/Editor/Document.js", "../word/Editor/Document.js",
"../word/Editor/DocumentChanges.js", "../word/Editor/DocumentChanges.js",
"../word/Editor/DocumentContent.js", "../word/Editor/DocumentContent.js",
"../word/Editor/DocumentContentChanges.js",
"../word/Editor/DocumentControllerBase.js", "../word/Editor/DocumentControllerBase.js",
"../word/Editor/LogicDocumentController.js", "../word/Editor/LogicDocumentController.js",
"../word/Editor/DrawingsController.js", "../word/Editor/DrawingsController.js",
......
...@@ -126,6 +126,7 @@ ...@@ -126,6 +126,7 @@
"../slide/Editor/Format/Comments.js", "../slide/Editor/Format/Comments.js",
"../word/Editor/Styles.js", "../word/Editor/Styles.js",
"../word/Editor/Numbering.js", "../word/Editor/Numbering.js",
"../word/Editor/NumberingChanges.js",
"../word/Editor/ParagraphContent.js", "../word/Editor/ParagraphContent.js",
"../word/Editor/ParagraphContentBase.js", "../word/Editor/ParagraphContentBase.js",
"../word/Editor/Paragraph/ParaTextPr.js", "../word/Editor/Paragraph/ParaTextPr.js",
...@@ -157,6 +158,7 @@ ...@@ -157,6 +158,7 @@
"../word/Editor/Document.js", "../word/Editor/Document.js",
"../word/Editor/DocumentChanges.js", "../word/Editor/DocumentChanges.js",
"../word/Editor/DocumentContent.js", "../word/Editor/DocumentContent.js",
"../word/Editor/DocumentContentChanges.js",
"../word/Editor/DocumentControllerBase.js", "../word/Editor/DocumentControllerBase.js",
"../word/Editor/LogicDocumentController.js", "../word/Editor/LogicDocumentController.js",
"../word/Editor/DrawingsController.js", "../word/Editor/DrawingsController.js",
......
...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
"../word/Editor/GraphicObjects/GraphicPage.js", "../word/Editor/GraphicObjects/GraphicPage.js",
"../word/Editor/GraphicObjects/WrapManager.js", "../word/Editor/GraphicObjects/WrapManager.js",
"../word/Editor/Comments.js", "../word/Editor/Comments.js",
"../word/Editor/CommentsChanges.js",
"../word/Editor/Styles.js", "../word/Editor/Styles.js",
"../word/Editor/FlowObjects.js", "../word/Editor/FlowObjects.js",
"../word/Editor/ParagraphContent.js", "../word/Editor/ParagraphContent.js",
...@@ -120,11 +121,13 @@ ...@@ -120,11 +121,13 @@
"../word/Editor/Paragraph_Recalculate.js", "../word/Editor/Paragraph_Recalculate.js",
"../word/Editor/Sections.js", "../word/Editor/Sections.js",
"../word/Editor/Numbering.js", "../word/Editor/Numbering.js",
"../word/Editor/NumberingChanges.js",
"../word/Editor/HeaderFooter.js", "../word/Editor/HeaderFooter.js",
"../word/Editor/DocumentContentBase.js", "../word/Editor/DocumentContentBase.js",
"../word/Editor/Document.js", "../word/Editor/Document.js",
"../word/Editor/DocumentChanges.js", "../word/Editor/DocumentChanges.js",
"../word/Editor/DocumentContent.js", "../word/Editor/DocumentContent.js",
"../word/Editor/DocumentContentChanges.js",
"../word/Editor/DocumentControllerBase.js", "../word/Editor/DocumentControllerBase.js",
"../word/Editor/LogicDocumentController.js", "../word/Editor/LogicDocumentController.js",
"../word/Editor/DrawingsController.js", "../word/Editor/DrawingsController.js",
......
...@@ -1420,10 +1420,6 @@ ...@@ -1420,10 +1420,6 @@
window['AscDFH'].historyitem_Comments_Add = window['AscDFH'].historyitem_type_Comments | 1; window['AscDFH'].historyitem_Comments_Add = window['AscDFH'].historyitem_type_Comments | 1;
window['AscDFH'].historyitem_Comments_Remove = window['AscDFH'].historyitem_type_Comments | 2; window['AscDFH'].historyitem_Comments_Remove = window['AscDFH'].historyitem_type_Comments | 2;
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
// Типы изменений в классе CGraphicObjects
//------------------------------------------------------------------------------------------------------------------
window['AscDFH'].historyitem_ChangeColorScheme = window['AscDFH'].historyitem_type_GrObjects | 1;
//------------------------------------------------------------------------------------------------------------------
// Типы изменений в классе ParaHyperlink // Типы изменений в классе ParaHyperlink
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
window['AscDFH'].historyitem_Hyperlink_Value = window['AscDFH'].historyitem_type_Hyperlink | 1; window['AscDFH'].historyitem_Hyperlink_Value = window['AscDFH'].historyitem_type_Hyperlink | 1;
...@@ -1629,6 +1625,10 @@ ...@@ -1629,6 +1625,10 @@
window['AscDFH'].historyitem_Footnotes_SetFootnotePrNumRestart = window['AscDFH'].historyitem_type_Footnotes | 7; window['AscDFH'].historyitem_Footnotes_SetFootnotePrNumRestart = window['AscDFH'].historyitem_type_Footnotes | 7;
window['AscDFH'].historyitem_Footnotes_SetFootnotePrNumFormat = window['AscDFH'].historyitem_type_Footnotes | 8; window['AscDFH'].historyitem_Footnotes_SetFootnotePrNumFormat = window['AscDFH'].historyitem_type_Footnotes | 8;
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
// Типы изменений в классе CGraphicObjects
//------------------------------------------------------------------------------------------------------------------
window['AscDFH'].historyitem_ChangeColorScheme = window['AscDFH'].historyitem_type_GrObjects | 1;
//------------------------------------------------------------------------------------------------------------------
// Графические классы общего назначение (без привязки к конкретному классу) // Графические классы общего назначение (без привязки к конкретному классу)
//------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------
window['AscDFH'].historyitem_AutoShapes_SetDrawingBaseCoors = window['AscDFH'].historyitem_type_CommonShape | 101; window['AscDFH'].historyitem_AutoShapes_SetDrawingBaseCoors = window['AscDFH'].historyitem_type_CommonShape | 101;
......
This diff is collapsed.
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
/**
* User: Ilja.Kirillov
* Date: 08.11.2016
* Time: 15:59
*/
AscDFH.changesFactory[AscDFH.historyitem_Comment_Change] = CChangesCommentChange;
AscDFH.changesFactory[AscDFH.historyitem_Comment_TypeInfo] = CChangesCommentTypeInfo;
AscDFH.changesFactory[AscDFH.historyitem_Comments_Add] = CChangesCommentsAdd;
AscDFH.changesFactory[AscDFH.historyitem_Comments_Remove] = CChangesCommentsRemove;
AscDFH.changesFactory[AscDFH.historyitem_ParaComment_CommentId] = CChangesParaCommentCommentId;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesCommentChange(Class, Old, New)
{
CChangesCommentChange.superclass.constructor.call(this, Class, Old, New);
}
AscCommon.extendClass(CChangesCommentChange, AscDFH.CChangesBaseProperty);
CChangesCommentChange.prototype.Type = AscDFH.historyitem_Comment_Change;
CChangesCommentChange.prototype.WriteToBinary = function(Writer)
{
// Variable : New data
// Variable : Old data
this.New.Write_ToBinary2(Writer);
this.Old.Write_ToBinary2(Writer);
};
CChangesCommentChange.prototype.ReadFromBinary = function(Reader)
{
// Variable : New data
// Variable : Old data
this.New = new AscCommon.CCommentData();
this.Old = new AscCommon.CCommentData();
this.New.Read_FromBinary2(Reader);
this.Old.Read_FromBinary2(Reader);
};
CChangesCommentChange.prototype.private_SetValue = function(Value)
{
this.Class.Data = Value;
editor.sync_ChangeCommentData(this.Class.Id, Value);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesCommentTypeInfo(Class, Old, New)
{
CChangesCommentTypeInfo.superclass.constructor.call(this, Class, Old, New);
}
AscCommon.extendClass(CChangesCommentTypeInfo, AscDFH.CChangesBaseProperty);
CChangesCommentTypeInfo.prototype.Type = AscDFH.historyitem_Comment_TypeInfo;
CChangesCommentTypeInfo.prototype.WriteToBinary = function(Writer)
{
// Variable : New data
// Variable : Old data
Writer.WriteLong(this.New.Type);
if (comment_type_HdrFtr === this.New.Type)
Writer.WriteString2(this.New.Data.Get_Id());
Writer.WriteLong(this.Old.Type);
if (comment_type_HdrFtr === this.Old.Type)
Writer.WriteString2(this.Old.Data.Get_Id());
};
CChangesCommentTypeInfo.prototype.ReadFromBinary = function(Reader)
{
// Variable : New data
// Variable : Old data
this.New = {
Type : 0,
Data : null
};
this.Old = {
Type : 0,
Data : null
};
this.New.Type = Reader.GetLong();
if (comment_type_HdrFtr === this.New.Type)
this.New.Data = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
this.Old.Type = Reader.GetLong();
if (comment_type_HdrFtr === this.Old.Type)
this.Old.Data = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesCommentTypeInfo.prototype.private_SetValue = function(Value)
{
this.Class.m_oTypeInfo = Value;
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
*/
function CChangesCommentsAdd(Class, Id, Comment)
{
CChangesCommentsAdd.superclass.constructor.call(this, Class);
this.Id = Id;
this.Comment = Comment;
}
AscCommon.extendClass(CChangesCommentsAdd, AscDFH.CChangesBase);
CChangesCommentsAdd.prototype.Type = AscDFH.historyitem_Comments_Add;
CChangesCommentsAdd.prototype.Undo = function()
{
var oComments = this.Class;
delete oComments.m_aComments[this.Id];
editor.sync_RemoveComment(this.Id);
};
CChangesCommentsAdd.prototype.Redo = function()
{
this.Class.m_aComments[this.Id] = this.Comment;
editor.sync_AddComment(this.Id, this.Comment.Data);
};
CChangesCommentsAdd.prototype.WriteToBinary = function(Writer)
{
// String : Id комментария
Writer.WriteString2(this.Id);
};
CChangesCommentsAdd.prototype.ReadFromBinary = function(Reader)
{
// String : Id комментария
this.Id = Reader.GetString2();
this.Comment = AscCommon.g_oTableId.Get_ById(this.Id);
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
*/
function CChangesCommentsRemove(Class, Id, Comment)
{
CChangesCommentsRemove.superclass.constructor.call(this, Class);
this.Id = Id;
this.Comment = Comment;
}
AscCommon.extendClass(CChangesCommentsRemove, AscDFH.CChangesBase);
CChangesCommentsRemove.prototype.Type = AscDFH.historyitem_Comments_Remove;
CChangesCommentsRemove.prototype.Undo = function()
{
this.Class.m_aComments[this.Id] = this.Comment;
editor.sync_AddComment(this.Id, this.Comment.Data);
};
CChangesCommentsRemove.prototype.Redo = function()
{
delete this.Class.m_aComments[this.Id];
editor.sync_RemoveComment(this.Id);
};
CChangesCommentsRemove.prototype.WriteToBinary = function(Writer)
{
// String : Id комментария
Writer.WriteString2(this.Id);
};
CChangesCommentsRemove.prototype.ReadFromBinary = function(Reader)
{
// String : Id комментария
this.Id = Reader.GetString2();
this.Comment = AscCommon.g_oTableId.Get_ById(this.Id);
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesParaCommentCommentId(Class, Old, New)
{
CChangesParaCommentCommentId.superclass.constructor.call(this, Class, Old, New);
}
AscCommon.extendClass(CChangesParaCommentCommentId, AscDFH.CChangesBaseProperty);
CChangesParaCommentCommentId.prototype.Type = AscDFH.historyitem_ParaComment_CommentId;
CChangesParaCommentCommentId.prototype.WriteToBinary = function(Writer)
{
// String : New Id
// String : Old Id
Writer.WriteString2(this.New);
Writer.WriteString2(this.Old);
};
CChangesParaCommentCommentId.prototype.ReadFromBinary = function(Reader)
{
// String : New Id
// String : Old Id
this.New = Reader.GetString2();
this.Old = Reader.GetString2();
};
CChangesParaCommentCommentId.prototype.private_SetValue = function(Value)
{
this.Class.CommentId = Value;
};
CChangesParaCommentCommentId.prototype.Load = function()
{
this.Redo();
var Comment = AscCommon.g_oTableId.Get_ById(this.New);
if (null !== this.Class.Paragraph && null !== Comment && Comment instanceof CComment)
{
if (true === this.Class.Start)
Comment.Set_StartId(this.Class.Paragraph.Get_Id());
else
Comment.Set_EndId(this.Class.Paragraph.Get_Id());
}
};
\ No newline at end of file
...@@ -135,7 +135,7 @@ CChangesDocumentAddItem.prototype.ReadFromBinary = function(Reader) ...@@ -135,7 +135,7 @@ CChangesDocumentAddItem.prototype.ReadFromBinary = function(Reader)
this.UseArray = false; this.UseArray = false;
this.Pos = Reader.GetLong(); this.Pos = Reader.GetLong();
this.PosArray = [this.Pos]; this.PosArray = [this.Pos];
this.Item = g_oTableId.Get_ById(Reader.GetString2()); this.Item = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}; };
CChangesDocumentAddItem.prototype.Load = function(Color) CChangesDocumentAddItem.prototype.Load = function(Color)
{ {
...@@ -308,7 +308,7 @@ CChangesDocumentRemoveItem.prototype.ReadFromBinary = function(Reader) ...@@ -308,7 +308,7 @@ CChangesDocumentRemoveItem.prototype.ReadFromBinary = function(Reader)
for (var nIndex = 0; nIndex < nCount; ++nIndex) for (var nIndex = 0; nIndex < nCount; ++nIndex)
{ {
this.PosArray[nIndex] = Reader.GetLong(); this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = g_oTableId.Get_ById(Reader.GetString2()); this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
} }
}; };
CChangesDocumentRemoveItem.prototype.Load = function(Color) CChangesDocumentRemoveItem.prototype.Load = function(Color)
......
...@@ -8330,7 +8330,7 @@ CDocumentContent.prototype.Internal_Content_Add = function(Position, NewOb ...@@ -8330,7 +8330,7 @@ CDocumentContent.prototype.Internal_Content_Add = function(Position, NewOb
NextObj = null; NextObj = null;
this.private_RecalculateNumbering([NewObject]); this.private_RecalculateNumbering([NewObject]);
History.Add(this, {Type : AscDFH.historyitem_DocumentContent_AddItem, Pos : Position, Item : NewObject}); History.Add(new CChangesDocumentContentAddItem(this, Position, NewObject));
this.Content.splice(Position, 0, NewObject); this.Content.splice(Position, 0, NewObject);
NewObject.Set_Parent(this); NewObject.Set_Parent(this);
NewObject.Set_DocumentNext(NextObj); NewObject.Set_DocumentNext(NextObj);
...@@ -8368,11 +8368,7 @@ CDocumentContent.prototype.Internal_Content_Remove = function(Position, Count ...@@ -8368,11 +8368,7 @@ CDocumentContent.prototype.Internal_Content_Remove = function(Position, Count
for (var Index = 0; Index < Count; Index++) for (var Index = 0; Index < Count; Index++)
this.Content[Position + Index].PreDelete(); this.Content[Position + Index].PreDelete();
History.Add(this, { History.Add(new CChangesDocumentContentRemoveItem(this, Position, this.Content.slice(Position, Position + Count)));
Type : AscDFH.historyitem_DocumentContent_RemoveItem,
Pos : Position,
Items : this.Content.slice(Position, Position + Count)
});
var Elements = this.Content.splice(Position, Count); var Elements = this.Content.splice(Position, Count);
this.private_RecalculateNumbering(Elements); this.private_RecalculateNumbering(Elements);
...@@ -8406,11 +8402,7 @@ CDocumentContent.prototype.Internal_Content_RemoveAll = function() ...@@ -8406,11 +8402,7 @@ CDocumentContent.prototype.Internal_Content_RemoveAll = function()
for (var Index = 0; Index < Count; Index++) for (var Index = 0; Index < Count; Index++)
this.Content[Index].PreDelete(); this.Content[Index].PreDelete();
History.Add(this, { History.Add(new CChangesDocumentRemoveItem(this, 0, this.Content.slice(0, this.Content.length)));
Type : AscDFH.historyitem_DocumentContent_RemoveItem,
Pos : 0,
Items : this.Content.slice(0, this.Content.length)
});
this.Content = []; this.Content = [];
}; };
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
...@@ -8473,58 +8465,6 @@ CDocumentContent.prototype.private_GetColumnIndex = function(CurPage) ...@@ -8473,58 +8465,6 @@ CDocumentContent.prototype.private_GetColumnIndex = function(CurPage)
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Undo/Redo функции // Undo/Redo функции
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
CDocumentContent.prototype.Undo = function(Data)
{
var Type = Data.Type;
switch (Type)
{
case AscDFH.historyitem_DocumentContent_AddItem:
{
var Elements = this.Content.splice(Data.Pos, 1);
this.private_RecalculateNumbering(Elements);
break;
}
case AscDFH.historyitem_DocumentContent_RemoveItem:
{
var Pos = Data.Pos;
var Array_start = this.Content.slice(0, Pos);
var Array_end = this.Content.slice(Pos);
this.Content = Array_start.concat(Data.Items, Array_end);
this.private_RecalculateNumbering(Data.Items);
break;
}
}
};
CDocumentContent.prototype.Redo = function(Data)
{
var Type = Data.Type;
switch (Type)
{
case AscDFH.historyitem_DocumentContent_AddItem:
{
var Pos = Data.Pos;
this.Content.splice(Pos, 0, Data.Item);
this.private_RecalculateNumbering([Data.Item]);
break;
}
case AscDFH.historyitem_DocumentContent_RemoveItem:
{
var Elements = this.Content.splice(Data.Pos, Data.Items.length);
this.private_RecalculateNumbering(Elements);
break;
}
}
};
CDocumentContent.prototype.Get_SelectionState = function() CDocumentContent.prototype.Get_SelectionState = function()
{ {
var DocState = {}; var DocState = {};
...@@ -8825,184 +8765,6 @@ CDocumentContent.prototype.Hyperlink_Check = function(bCheckEnd) ...@@ -8825,184 +8765,6 @@ CDocumentContent.prototype.Hyperlink_Check = function(bCheckEnd)
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Функции для работы с совместным редактирования // Функции для работы с совместным редактирования
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
CDocumentContent.prototype.Save_Changes = function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong(AscDFH.historyitem_type_DocumentContent);
var Type = Data.Type;
// Пишем тип
Writer.WriteLong(Type);
switch (Type)
{
case AscDFH.historyitem_DocumentContent_AddItem:
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// String : Id элемента
// }
var bArray = Data.UseArray;
var Count = 1;
Writer.WriteLong(Count);
for (var Index = 0; Index < Count; Index++)
{
if (true === bArray)
Writer.WriteLong(Data.PosArray[Index]);
else
Writer.WriteLong(Data.Pos + Index);
Writer.WriteString2(Data.Item.Get_Id());
}
break;
}
case AscDFH.historyitem_DocumentContent_RemoveItem:
{
// Long : Количество удаляемых элементов
// Array of Long : позиции удаляемых элементов
var bArray = Data.UseArray;
var Count = Data.Items.length;
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var RealCount = Count;
for (var Index = 0; Index < Count; Index++)
{
if (true === bArray)
{
if (false === Data.PosArray[Index])
RealCount--;
else
Writer.WriteLong(Data.PosArray[Index]);
}
else
Writer.WriteLong(Data.Pos);
}
var EndPos = Writer.GetCurPosition();
Writer.Seek(StartPos);
Writer.WriteLong(RealCount);
Writer.Seek(EndPos);
break;
}
}
return Writer;
};
CDocumentContent.prototype.Load_Changes = function(Reader, Reader2)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if (AscDFH.historyitem_type_DocumentContent != ClassType)
return;
var Type = Reader.GetLong();
switch (Type)
{
case AscDFH.historyitem_DocumentContent_AddItem:
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// String : Id элемента
// }
var Count = Reader.GetLong();
for (var Index = 0; Index < Count; Index++)
{
var Pos = this.m_oContentChanges.Check(AscCommon.contentchanges_Add, Reader.GetLong());
var Element = g_oTableId.Get_ById(Reader.GetString2());
if (null != Element)
{
if (Pos > 0)
{
this.Content[Pos - 1].Next = Element;
Element.Prev = this.Content[Pos - 1];
}
if (Pos <= this.Content.length - 1)
{
this.Content[Pos].Prev = Element;
Element.Next = this.Content[Pos];
}
Element.Parent = this;
this.Content.splice(Pos, 0, Element);
this.private_RecalculateNumbering([Element]);
AscCommon.CollaborativeEditing.Update_DocumentPositionsOnAdd(this, Pos);
this.private_ReindexContent(Pos);
}
}
break;
}
case AscDFH.historyitem_DocumentContent_RemoveItem:
{
// Long : Количество удаляемых элементов
// Array of Long : позиции удаляемых элементов
var Count = Reader.GetLong();
for (var Index = 0; Index < Count; Index++)
{
var Pos = this.m_oContentChanges.Check(AscCommon.contentchanges_Remove, Reader.GetLong());
// действие совпало, не делаем его
if (false === Pos)
continue;
var Elements = this.Content.splice(Pos, 1);
this.private_RecalculateNumbering(Elements);
AscCommon.CollaborativeEditing.Update_DocumentPositionsOnRemove(this, Pos, 1);
this.private_ReindexContent(Pos);
if (Pos > 0)
{
if (Pos <= this.Content.length - 1)
{
this.Content[Pos - 1].Next = this.Content[Pos];
this.Content[Pos].Prev = this.Content[Pos - 1];
}
else
{
this.Content[Pos - 1].Next = null;
}
}
else if (Pos <= this.Content.length - 1)
{
this.Content[Pos].Prev = null;
}
}
break;
}
}
return true;
};
CDocumentContent.prototype.Write_ToBinary2 = function(Writer) CDocumentContent.prototype.Write_ToBinary2 = function(Writer)
{ {
Writer.WriteLong(AscDFH.historyitem_type_DocumentContent); Writer.WriteLong(AscDFH.historyitem_type_DocumentContent);
......
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
/**
* User: Ilja.Kirillov
* Date: 08.11.2016
* Time: 14:03
*/
AscDFH.changesFactory[AscDFH.historyitem_DocumentContent_AddItem] = CChangesDocumentContentAddItem;
AscDFH.changesFactory[AscDFH.historyitem_DocumentContent_RemoveItem] = CChangesDocumentContentRemoveItem;
/**
* @constructor
* @extends {AscDFH.CChangesBase}
*/
function CChangesDocumentContentAddItem(Class, Pos, Item)
{
CChangesDocumentContentAddItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Item = Item;
this.UseArray = false;
this.PosArray = [];
}
AscCommon.extendClass(CChangesDocumentContentAddItem, AscDFH.CChangesBase);
CChangesDocumentContentAddItem.prototype.Type = AscDFH.historyitem_DocumentContent_AddItem;
CChangesDocumentContentAddItem.prototype.Undo = function()
{
var oDocument = this.Class;
var Elements = oDocument.Content.splice(this.Pos, 1);
oDocument.private_RecalculateNumbering(Elements);
var Pos = this.Pos;
if (Pos > 0)
{
if (Pos <= oDocument.Content.length - 1)
{
oDocument.Content[Pos - 1].Next = oDocument.Content[Pos];
oDocument.Content[Pos].Prev = oDocument.Content[Pos - 1];
}
else
{
oDocument.Content[Pos - 1].Next = null;
}
}
else if (Pos <= oDocument.Content.length - 1)
{
oDocument.Content[Pos].Prev = null;
}
};
CChangesDocumentContentAddItem.prototype.Redo = function()
{
var oDocument = this.Class;
oDocument.Content.splice(this.Pos, 0, this.Item);
oDocument.private_RecalculateNumbering([this.Item]);
var Element = this.Item;
var Pos = this.Pos;
if (Pos > 0)
{
oDocument.Content[Pos - 1].Next = Element;
Element.Prev = oDocument.Content[Pos - 1];
}
else
{
Element.Prev = null;
}
if (Pos < oDocument.Content.length - 1)
{
oDocument.Content[Pos + 1].Prev = Element;
Element.Next = oDocument.Content[Pos + 1];
}
else
{
Element.Next = null;
}
Element.Parent = oDocument;
};
CChangesDocumentContentAddItem.prototype.WriteToBinary = function(Writer)
{
// Long : Pos
// String : Id элемента
if (true === this.UseArray)
Writer.WriteLong(this.PosArray[0]);
else
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Item.Get_Id());
};
CChangesDocumentContentAddItem.prototype.ReadFromBinary = function(Reader)
{
// Long : Pos
// String : Id элемента
this.UseArray = false;
this.Pos = Reader.GetLong();
this.PosArray = [this.Pos];
this.Item = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
};
CChangesDocumentContentAddItem.prototype.Load = function(Color)
{
var oDocument = this.Class;
var Pos = oDocument.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.Pos);
var Element = this.Item;
Pos = Math.min(Pos, oDocument.Content.length);
if (null != Element)
{
if (Pos > 0)
{
oDocument.Content[Pos - 1].Next = Element;
Element.Prev = oDocument.Content[Pos - 1];
}
else
{
Element.Prev = null;
}
if (Pos <= oDocument.Content.length - 1)
{
oDocument.Content[Pos].Prev = Element;
Element.Next = oDocument.Content[Pos];
}
else
{
Element.Next = null;
}
Element.Parent = oDocument;
oDocument.Content.splice(Pos, 0, Element);
oDocument.private_RecalculateNumbering([Element]);
oDocument.private_ReindexContent(Pos);
AscCommon.CollaborativeEditing.Update_DocumentPositionsOnAdd(oDocument, Pos);
}
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
*/
function CChangesDocumentContentRemoveItem(Class, Pos, Items)
{
CChangesDocumentContentRemoveItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
}
AscCommon.extendClass(CChangesDocumentContentRemoveItem, AscDFH.CChangesBase);
CChangesDocumentContentRemoveItem.prototype.Type = AscDFH.historyitem_DocumentContent_RemoveItem;
CChangesDocumentContentRemoveItem.prototype.Undo = function()
{
if (!this.Items || this.Items.length <= 0)
return;
var oDocument = this.Class;
var Array_start = oDocument.Content.slice(0, this.Pos);
var Array_end = oDocument.Content.slice(this.Pos);
oDocument.private_RecalculateNumbering(this.Items);
oDocument.Content = Array_start.concat(this.Items, Array_end);
var nStartIndex = Math.max(this.Pos - 1, 0);
var nEndIndex = Math.min(oDocument.Content.length - 1, this.Pos + this.Items.length + 1);
for (var nIndex = nStartIndex; nIndex <= nEndIndex; ++nIndex)
{
var oElement = oDocument.Content[nIndex];
if (nIndex > 0)
oElement.Prev = oDocument.Content[nIndex - 1];
else
oElement.Prev = null;
if (nIndex < oDocument.Content.length - 1)
oElement.Next = oDocument.Content[nIndex + 1];
else
oElement.Next = null;
oElement.Parent = oDocument;
}
};
CChangesDocumentContentRemoveItem.prototype.Redo = function()
{
if (!this.Items || this.Items.length <= 0)
return;
var oDocument = this.Class;
var Elements = oDocument.Content.splice(this.Pos, this.Items.length);
oDocument.private_RecalculateNumbering(Elements);
var Pos = this.Pos;
if (Pos > 0)
{
if (Pos <= oDocument.Content.length - 1)
{
oDocument.Content[Pos - 1].Next = oDocument.Content[Pos];
oDocument.Content[Pos].Prev = oDocument.Content[Pos - 1];
}
else
{
oDocument.Content[Pos - 1].Next = null;
}
}
else if (Pos <= oDocument.Content.length - 1)
{
oDocument.Content[Pos].Prev = null;
}
};
CChangesDocumentContentRemoveItem.prototype.WriteToBinary = function(Writer)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемого элемента
// }
var bArray = this.UseArray;
var Count = this.Items.length;
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var RealCount = Count;
for (var Index = 0; Index < Count; Index++)
{
if (true === bArray)
{
if (false === this.PosArray[Index])
{
RealCount--;
}
else
{
Writer.WriteLong(this.PosArray[Index]);
Writer.WriteString2(this.Items[Index]);
}
}
else
{
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Items[Index]);
}
}
var EndPos = Writer.GetCurPosition();
Writer.Seek(StartPos);
Writer.WriteLong(RealCount);
Writer.Seek(EndPos);
};
CChangesDocumentContentRemoveItem.prototype.ReadFromBinary = function(Reader)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемого элемента
// }
this.UseArray = true;
this.PosArray = [];
this.Items = [];
var nCount = Reader.GetLong();
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
};
CChangesDocumentContentRemoveItem.prototype.Load = function(Color)
{
var oDocument = this.Class;
for (var nIndex = 0, nCount = this.Items.length; nIndex < nCount; ++nIndex)
{
var Pos = oDocument.m_oContentChanges.Check(AscCommon.contentchanges_Remove, this.PosArray[nIndex]);
// действие совпало, не делаем его
if (false === Pos)
continue;
var Elements = oDocument.Content.splice(Pos, 1);
oDocument.private_RecalculateNumbering(Elements);
AscCommon.CollaborativeEditing.Update_DocumentPositionsOnRemove(oDocument, Pos, 1);
if (Pos > 0)
{
if (Pos <= oDocument.Content.length - 1)
{
oDocument.Content[Pos - 1].Next = oDocument.Content[Pos];
oDocument.Content[Pos].Prev = oDocument.Content[Pos - 1];
}
else
{
oDocument.Content[Pos - 1].Next = null;
}
}
else if (Pos <= oDocument.Content.length - 1)
{
oDocument.Content[Pos].Prev = null;
}
oDocument.private_ReindexContent(Pos);
}
};
\ No newline at end of file
This diff is collapsed.
/*
* (c) Copyright Ascensio System SIA 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
"use strict";
/**
* User: Ilja.Kirillov
* Date: 08.11.2016
* Time: 14:37
*/
AscDFH.changesFactory[AscDFH.historyitem_AbstractNum_LvlChange] = CChangesAbstractNumLvlChange;
AscDFH.changesFactory[AscDFH.historyitem_AbstractNum_TextPrChange] = CChangesAbstractNumTextPrChange;
AscDFH.changesFactory[AscDFH.historyitem_AbstractNum_ParaPrChange] = CChangesAbstractNumParaPrChange;
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesAbstractNumLvlChange(Class, Old, New, Index)
{
CChangesAbstractNumLvlChange.superclass.constructor.call(this, Class, Old, New);
this.Index = Index;
}
AscCommon.extendClass(CChangesAbstractNumLvlChange, AscDFH.CChangesBaseProperty);
CChangesAbstractNumLvlChange.prototype.Type = AscDFH.historyitem_AbstractNum_LvlChange;
CChangesAbstractNumLvlChange.prototype.WriteToBinary = function(Writer)
{
var oAbstractNum = this.Class;
// Long : Lvl index
// Variable : New Lvl
// Variable : Old Lvl
Writer.WriteLong(this.Index);
oAbstractNum.Write_Lvl_ToBinary(this.New, Writer);
oAbstractNum.Write_Lvl_ToBinary(this.Old, Writer);
};
CChangesAbstractNumLvlChange.prototype.ReadFromBinary = function(Reader)
{
var oAbstractNum = this.Class;
// Long : Lvl index
// Variable : New Lvl
// Variable : Old Lvl
this.New = {};
this.Old = {};
this.Index = Reader.GetLong();
oAbstractNum.Read_Lvl_FromBinary(this.New, Reader);
oAbstractNum.Read_Lvl_FromBinary(this.Old, Reader);
};
CChangesAbstractNumLvlChange.prototype.private_SetValue = function(Value)
{
var oAbstractNum = this.Class;
oAbstractNum.Internal_SetLvl(this.Index, Value);
oAbstractNum.Recalc_CompiledPr(this.Index);
};
CChangesAbstractNumLvlChange.prototype.Load = function(Color)
{
var oAbstractNum = this.Class;
oAbstractNum.Internal_SetLvl(this.Index, this.New);
// Сразу нельзя запускать пересчет, т.к. возможно еще не все ссылки проставлены
AscCommon.CollaborativeEditing.Add_EndActions(this.Class, {iLvl : this.Index});
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesAbstractNumTextPrChange(Class, Old, New, Index)
{
CChangesAbstractNumTextPrChange.superclass.constructor.call(this, Class, Old, New);
this.Index = Index;
}
AscCommon.extendClass(CChangesAbstractNumTextPrChange, AscDFH.CChangesBaseProperty);
CChangesAbstractNumTextPrChange.prototype.Type = AscDFH.historyitem_AbstractNum_TextPrChange;
CChangesAbstractNumTextPrChange.prototype.WriteToBinary = function(Writer)
{
// Long : Lvl index
// TextPr : New TextPr
// TextPr : Old TextPr
Writer.WriteLong(this.Index);
this.New.Write_ToBinary(Writer);
this.Old.Write_ToBinary(Writer);
};
CChangesAbstractNumTextPrChange.prototype.ReadFromBinary = function(Reader)
{
// Long : Lvl index
// TextPr : New TextPr
// TextPr : Old TextPr
this.New = new CTextPr();
this.Old = new CTextPr();
this.Index = Reader.GetLong();
this.New.Read_FromBinary(Reader);
this.Old.Read_FromBinary(Reader);
};
CChangesAbstractNumTextPrChange.prototype.private_SetValue = function(Value)
{
var oAbstractNum = this.Class;
oAbstractNum.Lvl[this.Index].TextPr = Value;
oAbstractNum.Recalc_CompiledPr(this.Index);
};
CChangesAbstractNumTextPrChange.prototype.Load = function(Color)
{
var oAbstractNum = this.Class;
oAbstractNum.Lvl[this.Index].TextPr = this.New;
// Сразу нельзя запускать пересчет, т.к. возможно еще не все ссылки проставлены
AscCommon.CollaborativeEditing.Add_EndActions(this.Class, {iLvl : this.Index});
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesAbstractNumParaPrChange(Class, Old, New, Index)
{
CChangesAbstractNumParaPrChange.superclass.constructor.call(this, Class, Old, New);
this.Index = Index;
}
AscCommon.extendClass(CChangesAbstractNumParaPrChange, AscDFH.CChangesBaseProperty);
CChangesAbstractNumParaPrChange.prototype.Type = AscDFH.historyitem_AbstractNum_ParaPrChange;
CChangesAbstractNumParaPrChange.prototype.WriteToBinary = function(Writer)
{
// Long : Lvl index
// ParaPr : New ParaPr
// ParaPr : Old ParaPr
Writer.WriteLong(this.Index);
this.New.Write_ToBinary(Writer);
this.Old.Write_ToBinary(Writer);
};
CChangesAbstractNumParaPrChange.prototype.ReadFromBinary = function(Reader)
{
// Long : Lvl index
// ParaPr : New ParaPr
// ParaPr : Old ParaPr
this.New = new CParaPr();
this.Old = new CParaPr();
this.Index = Reader.GetLong();
this.New.Read_FromBinary(Reader);
this.Old.Read_FromBinary(Reader);
};
CChangesAbstractNumParaPrChange.prototype.private_SetValue = function(Value)
{
var oAbstractNum = this.Class;
oAbstractNum.Lvl[this.Index].ParaPr = Value;
oAbstractNum.Recalc_CompiledPr(this.Index);
};
CChangesAbstractNumParaPrChange.prototype.Load = function(Color)
{
var oAbstractNum = this.Class;
oAbstractNum.Lvl[this.Index].ParaPr = this.New;
// Сразу нельзя запускать пересчет, т.к. возможно еще не все ссылки проставлены
AscCommon.CollaborativeEditing.Add_EndActions(this.Class, {iLvl : this.Index});
};
\ 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