Commit 9d56cf52 authored by Ilya Kirillov's avatar Ilya Kirillov

Changes for classes Hyperlink/Style/Styles were replaced with a new classes.

parent dfa158b5
......@@ -82,6 +82,7 @@
"../word/Editor/CommentsChanges.js",
"../word/Editor/History.js",
"../word/Editor/Styles.js",
"../word/Editor/StylesChanges.js",
"../word/Editor/FlowObjects.js",
"../word/Editor/ParagraphContent.js",
"../word/Editor/ParagraphContentBase.js",
......@@ -90,6 +91,7 @@
"../word/Editor/Paragraph/ParaDrawing.js",
"../word/Editor/Paragraph/ParaDrawingChanges.js",
"../word/Editor/Hyperlink.js",
"../word/Editor/HyperlinkChanges.js",
"../word/Editor/Field.js",
"../word/Editor/Run.js",
"../word/Editor/RunChanges.js",
......
......@@ -131,6 +131,7 @@
"../word/Editor/Comments.js",
"../word/Editor/CommentsChanges.js",
"../word/Editor/Styles.js",
"../word/Editor/StylesChanges.js",
"../word/Editor/FlowObjects.js",
"../word/Editor/ParagraphContent.js",
"../word/Editor/ParagraphContentBase.js",
......@@ -139,6 +140,7 @@
"../word/Editor/Paragraph/ParaDrawing.js",
"../word/Editor/Paragraph/ParaDrawingChanges.js",
"../word/Editor/Hyperlink.js",
"../word/Editor/HyperlinkChanges.js",
"../word/Editor/Field.js",
"../word/Editor/Run.js",
"../word/Editor/RunChanges.js",
......
......@@ -125,6 +125,7 @@
"../slide/Editor/Format/Layout.js",
"../slide/Editor/Format/Comments.js",
"../word/Editor/Styles.js",
"../word/Editor/StylesChanges.js",
"../word/Editor/Numbering.js",
"../word/Editor/NumberingChanges.js",
"../word/Editor/ParagraphContent.js",
......@@ -134,6 +135,7 @@
"../word/Editor/Paragraph/ParaDrawing.js",
"../word/Editor/Paragraph/ParaDrawingChanges.js",
"../word/Editor/Hyperlink.js",
"../word/Editor/HyperlinkChanges.js",
"../word/Editor/Field.js",
"../word/Editor/Run.js",
"../word/Editor/RunChanges.js",
......
......@@ -104,6 +104,7 @@
"../word/Editor/Comments.js",
"../word/Editor/CommentsChanges.js",
"../word/Editor/Styles.js",
"../word/Editor/StylesChanges.js",
"../word/Editor/FlowObjects.js",
"../word/Editor/ParagraphContent.js",
"../word/Editor/ParagraphContentBase.js",
......@@ -112,6 +113,7 @@
"../word/Editor/Paragraph/ParaDrawing.js",
"../word/Editor/Paragraph/ParaDrawingChanges.js",
"../word/Editor/Hyperlink.js",
"../word/Editor/HyperlinkChanges.js",
"../word/Editor/Field.js",
"../word/Editor/Run.js",
"../word/Editor/RunChanges.js",
......
......@@ -3391,4 +3391,31 @@
return true;
};
window['AscDFH'].CChangesBaseObjectValue = CChangesBaseObjectValue;
/**
* Базовый класс для изменения числовых(long) значений.
* @constructor
* @extends {AscDFH.CChangesBaseProperty}
*/
function CChangesBaseStringValue(Class, Old, New, Color)
{
CChangesBaseStringValue.superclass.constructor.call(this, Class, Old, New, Color);
}
AscCommon.extendClass(CChangesBaseStringValue, CChangesBaseProperty);
CChangesBaseStringValue.prototype.WriteToBinary = function(Writer)
{
// String : New
// String : Old
Writer.WriteString2(this.New);
Writer.WriteString2(this.Old);
};
CChangesBaseStringValue.prototype.ReadFromBinary = function(Reader)
{
// String : New
// String : Old
this.New = Reader.WriteString2();
this.Old = Reader.WriteString2();
};
window['AscDFH'].CChangesBaseStringValue = CChangesBaseStringValue;
})(window);
......@@ -91,7 +91,7 @@ ParaHyperlink.prototype.Add_ToContent = function(Pos, Item, UpdatePosition)
return;
}
History.Add( this, { Type : AscDFH.historyitem_Hyperlink_AddItem, Pos : Pos, EndPos : Pos, Items : [ Item ] } );
History.Add(new CChangesHyperlinkAddItem(this, Pos, [Item]));
ParaHyperlink.superclass.Add_ToContent.apply(this, arguments);
};
......@@ -100,7 +100,7 @@ ParaHyperlink.prototype.Remove_FromContent = function(Pos, Count, UpdatePosition
{
// Получим массив удаляемых элементов
var DeletedItems = this.Content.slice( Pos, Pos + Count );
History.Add( this, { Type : AscDFH.historyitem_Hyperlink_RemoveItem, Pos : Pos, EndPos : Pos + Count - 1, Items : DeletedItems } );
History.Add(new CChangesHyperlinkRemoveItem(this, Pos, DeletedItems));
ParaHyperlink.superclass.Remove_FromContent.apply(this, arguments);
};
......@@ -296,7 +296,7 @@ ParaHyperlink.prototype.Get_Visited = function()
ParaHyperlink.prototype.Set_ToolTip = function(ToolTip)
{
History.Add( this, { Type : AscDFH.historyitem_Hyperlink_ToolTip, New : ToolTip, Old : this.ToolTip } );
History.Add(new CChangesHyperlinkToolTip(this, this.ToolTip, ToolTip));
this.ToolTip = ToolTip;
};
......@@ -320,268 +320,12 @@ ParaHyperlink.prototype.Get_Value = function()
ParaHyperlink.prototype.Set_Value = function(Value)
{
History.Add( this, { Type : AscDFH.historyitem_Hyperlink_Value, New : Value, Old : this.Value } );
History.Add(new CChangesHyperlinkValue(this, this.Value, Value));
this.Value = Value;
};
//-----------------------------------------------------------------------------------
// Undo/Redo функции
//-----------------------------------------------------------------------------------
ParaHyperlink.prototype.Undo = function(Data)
{
var Type = Data.Type;
switch(Type)
{
case AscDFH.historyitem_Hyperlink_AddItem :
{
this.Content.splice( Data.Pos, Data.EndPos - Data.Pos + 1 );
this.private_UpdateTrackRevisions();
this.protected_UpdateSpellChecking();
break;
}
case AscDFH.historyitem_Hyperlink_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_UpdateTrackRevisions();
this.protected_UpdateSpellChecking();
break;
}
case AscDFH.historyitem_Hyperlink_Value :
{
this.Value = Data.Old;
break;
}
case AscDFH.historyitem_Hyperlink_ToolTip :
{
this.ToolTip = Data.Old;
break;
}
}
};
ParaHyperlink.prototype.Redo = function(Data)
{
var Type = Data.Type;
switch(Type)
{
case AscDFH.historyitem_Hyperlink_AddItem :
{
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_UpdateTrackRevisions();
this.protected_UpdateSpellChecking();
break;
}
case AscDFH.historyitem_Hyperlink_RemoveItem :
{
this.Content.splice( Data.Pos, Data.EndPos - Data.Pos + 1 );
this.private_UpdateTrackRevisions();
this.protected_UpdateSpellChecking();
break;
}
case AscDFH.historyitem_Hyperlink_Value :
{
this.Value = Data.New;
break;
}
case AscDFH.historyitem_Hyperlink_ToolTip :
{
this.ToolTip = Data.New;
break;
}
}
};
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
ParaHyperlink.prototype.Save_Changes = function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong( AscDFH.historyitem_type_Hyperlink );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
switch(Type)
{
case AscDFH.historyitem_Hyperlink_AddItem :
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Id элемента
// }
var bArray = Data.UseArray;
var Count = Data.Items.length;
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.Items[Index].Get_Id() );
}
break;
}
case AscDFH.historyitem_Hyperlink_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;
}
case AscDFH.historyitem_Hyperlink_Value :
{
// String : Value
Writer.WriteString2( Data.New );
break;
}
case AscDFH.historyitem_Hyperlink_ToolTip :
{
// String : ToolTip
Writer.WriteString2( Data.New );
break;
}
}
};
ParaHyperlink.prototype.Load_Changes = function(Reader)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( AscDFH.historyitem_type_Hyperlink != ClassType )
return;
var Type = Reader.GetLong();
switch ( Type )
{
case AscDFH.historyitem_Hyperlink_AddItem :
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : 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 = AscCommon.g_oTableId.Get_ById( Reader.GetString2() );
if ( null != Element )
{
this.Content.splice( Pos, 0, Element );
AscCommon.CollaborativeEditing.Update_DocumentPositionsOnAdd(this, Pos);
}
}
this.private_UpdateTrackRevisions();
this.protected_UpdateSpellChecking();
break;
}
case AscDFH.historyitem_Hyperlink_RemoveItem:
{
// Long : Количество удаляемых элементов
// Array of Long : позиции удаляемых элементов
var Count = Reader.GetLong();
for ( var Index = 0; Index < Count; Index++ )
{
var ChangesPos = this.m_oContentChanges.Check( AscCommon.contentchanges_Remove, Reader.GetLong() );
// действие совпало, не делаем его
if ( false === ChangesPos )
continue;
this.Content.splice( ChangesPos, 1 );
AscCommon.CollaborativeEditing.Update_DocumentPositionsOnRemove(this, ChangesPos, 1);
}
this.private_UpdateTrackRevisions();
this.protected_UpdateSpellChecking();
break;
}
case AscDFH.historyitem_Hyperlink_Value:
{
// String : Value
this.Value = Reader.GetString2();
break;
}
case AscDFH.historyitem_Hyperlink_ToolTip :
{
// String : ToolTip
this.ToolTip = Reader.GetString2();
break;
}
}
};
ParaHyperlink.prototype.Write_ToBinary2 = function(Writer)
{
Writer.WriteLong( AscDFH.historyitem_type_Hyperlink );
......
/*
* (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: 18:59
*/
AscDFH.changesFactory[AscDFH.historyitem_Hyperlink_Value] = CChangesHyperlinkValue;
AscDFH.changesFactory[AscDFH.historyitem_Hyperlink_ToolTip] = CChangesHyperlinkToolTip;
AscDFH.changesFactory[AscDFH.historyitem_Hyperlink_AddItem] = CChangesHyperlinkAddItem;
AscDFH.changesFactory[AscDFH.historyitem_Hyperlink_RemoveItem] = CChangesHyperlinkRemoveItem;
/**
* @constructor
* @extends {AscDFH.CChangesBaseStringValue}
*/
function CChangesHyperlinkValue(Class, Old, New, Color)
{
CChangesHyperlinkValue.superclass.constructor.call(this, Class, Old, New, Color);
}
AscCommon.extendClass(CChangesHyperlinkValue, AscDFH.CChangesBaseStringValue);
CChangesHyperlinkValue.prototype.Type = AscDFH.historyitem_Hyperlink_Value;
CChangesHyperlinkValue.prototype.private_SetValue = function(Value)
{
this.Class.Value = Value;
};
/**
* @constructor
* @extends {AscDFH.CChangesBaseStringValue}
*/
function CChangesHyperlinkToolTip(Class, Old, New, Color)
{
CChangesHyperlinkToolTip.superclass.constructor.call(this, Class, Old, New, Color);
}
AscCommon.extendClass(CChangesHyperlinkToolTip, AscDFH.CChangesBaseStringValue);
CChangesHyperlinkToolTip.prototype.Type = AscDFH.historyitem_Hyperlink_ToolTip;
CChangesHyperlinkToolTip.prototype.private_SetValue = function(Value)
{
this.Class.ToolTip = Value;
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
*/
function CChangesHyperlinkAddItem(Class, Pos, Items)
{
CChangesHyperlinkAddItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
}
AscCommon.extendClass(CChangesHyperlinkAddItem, AscDFH.CChangesBase);
CChangesHyperlinkAddItem.prototype.Type = AscDFH.historyitem_Hyperlink_AddItem;
CChangesHyperlinkAddItem.prototype.Undo = function()
{
var oHyperlink = this.Class;
oHyperlink.Content.splice(this.Pos, this.Items.length);
oHyperlink.private_UpdateTrackRevisions();
oHyperlink.protected_UpdateSpellChecking();
};
CChangesHyperlinkAddItem.prototype.Redo = function()
{
var oHyperlink = this.Class;
var Array_start = oHyperlink.Content.slice(0, this.Pos);
var Array_end = oHyperlink.Content.slice(this.Pos);
oHyperlink.Content = Array_start.concat(this.Items, Array_end);
oHyperlink.private_UpdateTrackRevisions();
oHyperlink.protected_UpdateSpellChecking();
};
CChangesHyperlinkAddItem.prototype.WriteToBinary = function(Writer)
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Id элемента
// }
var bArray = this.UseArray;
var nCount = this.Items.length;
Writer.WriteLong(nCount);
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
if (true === bArray)
Writer.WriteLong(this.PosArray[nIndex]);
else
Writer.WriteLong(this.Pos + nIndex);
Writer.WriteString2(this.Items[nIndex].Get_Id());
}
};
CChangesHyperlinkAddItem.prototype.ReadFromBinary = function(Reader)
{
// Long : Количество элементов
// Array of :
// {
// Long : Позиция
// Variable : Id Элемента
// }
this.UseArray = true;
this.Items = [];
this.PosArray = [];
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());
}
};
CChangesHyperlinkAddItem.prototype.Load = function(Color)
{
var oHyperlink = this.Class;
for (var nIndex = 0, nCount = this.Items.length; nIndex < nCount; ++nIndex)
{
var Pos = oHyperlink.m_oContentChanges.Check(AscCommon.contentchanges_Add, this.PosArray[nIndex]);
var Element = this.Items[nIndex];
if (null != Element)
{
oHyperlink.Content.splice(Pos, 0, Element);
AscCommon.CollaborativeEditing.Update_DocumentPositionsOnAdd(oHyperlink, Pos);
}
}
oHyperlink.private_UpdateTrackRevisions();
oHyperlink.protected_UpdateSpellChecking();
};
/**
* @constructor
* @extends {AscDFH.CChangesBase}
*/
function CChangesHyperlinkRemoveItem(Class, Pos, Items)
{
CChangesHyperlinkRemoveItem.superclass.constructor.call(this, Class);
this.Pos = Pos;
this.Items = Items;
this.UseArray = false;
this.PosArray = [];
}
AscCommon.extendClass(CChangesHyperlinkRemoveItem, AscDFH.CChangesBase);
CChangesHyperlinkRemoveItem.prototype.Type = AscDFH.historyitem_Hyperlink_RemoveItem;
CChangesHyperlinkRemoveItem.prototype.Undo = function()
{
var oHyperlink = this.Class;
var Array_start = oHyperlink.Content.slice(0, this.Pos);
var Array_end = oHyperlink.Content.slice(this.Pos);
oHyperlink.Content = Array_start.concat(this.Items, Array_end);
oHyperlink.private_UpdateTrackRevisions();
oHyperlink.protected_UpdateSpellChecking();
};
CChangesHyperlinkRemoveItem.prototype.Redo = function()
{
var oHyperlink = this.Class;
oHyperlink.Content.splice(this.Pos, this.Items.length);
oHyperlink.private_UpdateTrackRevisions();
oHyperlink.protected_UpdateSpellChecking();
};
CChangesHyperlinkRemoveItem.prototype.WriteToBinary = function(Writer)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемых элементов
// }
var bArray = this.UseArray;
var nCount = this.Items.length;
var nStartPos = Writer.GetCurPosition();
Writer.Skip(4);
var nRealCount = nCount;
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
if (true === bArray)
{
if (false === this.PosArray[nIndex])
{
nRealCount--;
}
else
{
Writer.WriteLong(this.PosArray[nIndex]);
Writer.WriteString2(this.Items[nIndex]);
}
}
else
{
Writer.WriteLong(this.Pos);
Writer.WriteString2(this.Items[nIndex]);
}
}
var nEndPos = Writer.GetCurPosition();
Writer.Seek(nStartPos);
Writer.WriteLong(nRealCount);
Writer.Seek(nEndPos);
};
CChangesHyperlinkRemoveItem.prototype.ReadFromBinary = function(Reader)
{
// Long : Количество удаляемых элементов
// Array of
// {
// Long : позиции удаляемых элементов
// String : id удаляемых элементов
// }
this.UseArray = true;
this.Items = [];
this.PosArray = [];
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());
}
};
CChangesHyperlinkRemoveItem.prototype.Load = function(Color)
{
var oHyperlink = this.Class;
for (var nIndex = 0, nCount = this.Items.length; nIndex < nCount; ++nIndex)
{
var ChangesPos = oHyperlink.m_oContentChanges.Check(AscCommon.contentchanges_Remove, this.PosArray[nIndex]);
if (false === ChangesPos)
continue;
oHyperlink.Content.splice(ChangesPos, 1);
AscCommon.CollaborativeEditing.Update_DocumentPositionsOnRemove(oHyperlink, ChangesPos, 1);
}
oHyperlink.private_UpdateTrackRevisions();
oHyperlink.protected_UpdateSpellChecking();
};
\ No newline at end of file
......@@ -161,7 +161,7 @@ CChangesParagraphAddItem.prototype.ReadFromBinary = function(Reader)
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = g_oTableId.Get_ById(Reader.GetString2());
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
};
CChangesParagraphAddItem.prototype.Load = function(Color)
......@@ -176,7 +176,7 @@ CChangesParagraphAddItem.prototype.Load = function(Color)
{
if (para_Comment === Element.Type)
{
var Comment = g_oTableId.Get_ById(Element.CommentId);
var Comment = AscCommon.g_oTableId.Get_ById(Element.CommentId);
// При копировании не всегда сразу заполняется правильно CommentId
if (null != Comment && Comment instanceof CComment)
......@@ -296,7 +296,7 @@ CChangesParagraphRemoveItem.prototype.ReadFromBinary = function(Reader)
for (var nIndex = 0; nIndex < nCount; ++nIndex)
{
this.PosArray[nIndex] = Reader.GetLong();
this.Items[nIndex] = g_oTableId.Get_ById(Reader.GetString2());
this.Items[nIndex] = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
}
};
CChangesParagraphRemoveItem.prototype.Load = function(Color)
......@@ -1101,12 +1101,12 @@ CChangesParagraphSectPr.prototype.ReadFromBinary = function(Reader)
var nFlags = Reader.GetLong();
if (nFlags & 1)
this.New = g_oTableId.Get_ById(Reader.GetString2());
this.New = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
else
this.New = undefined;
if (nFlags & 2)
this.Old = g_oTableId.Get_ById(Reader.GetString2());
this.Old = AscCommon.g_oTableId.Get_ById(Reader.GetString2());
else
this.Old = undefined;
};
......
This diff is collapsed.
This diff is collapsed.
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