Commit 8934ea55 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander.Trofimov

Переделано совместное редактирования для нового параграфа.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54981 954022d7-b5bf-4e40-9824-e11837661b57
parent 995fa441
......@@ -133,7 +133,7 @@ function CTableId()
{
case historyitem_type_Paragraph : Element = new Paragraph(); break;
case historyitem_type_TextPr : Element = new ParaTextPr(); break;
case historyitem_type_Hyperlink : Element = new ParaHyperlinkStart(); break;
case historyitem_type_Hyperlink : if ( true !== Debug_ParaRunMode ) Element = new ParaHyperlinkStart(); else Element = new ParaHyperlink(); break;
case historyitem_type_Drawing : Element = new ParaDrawing(); break;
case historyitem_type_DrawingObjects : Element = new CDrawingObjects(); break;
case historyitem_type_FlowObjects : Element = new FlowObjects(); break;
......@@ -156,6 +156,8 @@ function CTableId()
case historyitem_type_TextBody : Element = new CTextBody(); break;
case historyitem_type_ChartTitle : Element = new CChartTitle(); break;
case historyitem_type_Math : Element = new ParaMath(); break;
case historyitem_type_CommentMark : Element = new ParaComment(); break;
case historyitem_type_ParaRun : Element = new ParaRun(); break;
}
Element.Read_FromBinary2(Reader);
......
......@@ -901,8 +901,10 @@ function CComments()
function ParaComment(Start, Id)
{
this.Start = Start;
this.Id = Id;
this.Id = g_oIdCounter.Get_NewId();
this.Start = Start;
this.CommentId = Id;
this.Type = para_Comment;
......@@ -911,10 +913,17 @@ function ParaComment(Start, Id)
this.Lines = new Array();
this.LinesLength = 0;
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
ParaComment.prototype =
{
Get_Id : function()
{
return this.Id;
},
Set_Paragraph : function()
{
......@@ -1001,17 +1010,17 @@ ParaComment.prototype =
var Page = Para.Get_StartPage_Absolute() + CurPage;
if ( true === this.Start )
DocumentComments.Set_StartInfo( this.Id, Page, X, Y, H, Para.Get_Id() );
DocumentComments.Set_StartInfo( this.CommentId, Page, X, Y, H, Para.Get_Id() );
else
DocumentComments.Set_EndInfo( this.Id, Page, X, Y, H, Para.Get_Id() );
DocumentComments.Set_EndInfo( this.CommentId, Page, X, Y, H, Para.Get_Id() );
},
Recalculate_PageEndInfo : function(PRSI, _CurLine, _CurRange)
{
if ( true === this.Start )
PRSI.Add_Comment( this.Id );
PRSI.Add_Comment( this.CommentId );
else
PRSI.Remove_Comment( this.Id );
PRSI.Remove_Comment( this.CommentId );
},
Save_Lines : function()
......@@ -1049,9 +1058,9 @@ ParaComment.prototype =
Draw_HighLights : function(PDSH)
{
if ( true === this.Start )
PDSH.Add_Comment( this.Id );
PDSH.Add_Comment( this.CommentId );
else
PDSH.Remove_Comment( this.Id );
PDSH.Remove_Comment( this.CommentId );
},
Draw_Elements : function(PDSE)
......@@ -1191,14 +1200,24 @@ ParaComment.prototype =
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
Write_ToBinary : function(Writer)
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_CommentMark );
// String : Id
// String : Id комментария
// Bool : Start
Writer.WriteString2( "" + this.Id );
Writer.WriteString2( "" + this.CommentId );
Writer.WriteBool( this.Start );
},
Read_FromBinary : function(Reader)
Read_FromBinary2 : function(Reader)
{
this.Id = Reader.GetString2();
this.CommentId = Reader.GetString2();
this.Start = Reader.GetBool();
}
};
......
......@@ -187,18 +187,22 @@ CHistory.prototype =
( Class instanceof CDocumentContent && ( historyitem_DocumentContent_AddItem === Data.Type || historyitem_DocumentContent_RemoveItem === Data.Type ) ) ||
( Class instanceof CTable && ( historyitem_Table_AddRow === Data.Type || historyitem_Table_RemoveRow === Data.Type ) ) ||
( Class instanceof CTableRow && ( historyitem_TableRow_AddCell === Data.Type || historyitem_TableRow_RemoveCell === Data.Type ) ) ||
( Class instanceof Paragraph && ( historyitem_Paragraph_AddItem === Data.Type || historyitem_Paragraph_RemoveItem === Data.Type ) ) )
( Class instanceof Paragraph && ( historyitem_Paragraph_AddItem === Data.Type || historyitem_Paragraph_RemoveItem === Data.Type ) ) ||
( Class instanceof ParaHyperlink && ( historyitem_Hyperlink_AddItem === Data.Type || historyitem_Hyperlink_RemoveItem === Data.Type ) ) ||
( Class instanceof ParaRun && ( historyitem_ParaRun_AddItem === Data.Type || historyitem_ParaRun_RemoveItem === Data.Type ) ) )
{
var bAdd = ( ( Class instanceof CDocument && historyitem_Document_AddItem === Data.Type ) ||
( Class instanceof CDocumentContent && historyitem_DocumentContent_AddItem === Data.Type ) ||
( Class instanceof CTable && historyitem_Table_AddRow === Data.Type ) ||
( Class instanceof CTableRow && historyitem_TableRow_AddCell === Data.Type ) ||
( Class instanceof Paragraph && historyitem_Paragraph_AddItem === Data.Type )
( Class instanceof Paragraph && historyitem_Paragraph_AddItem === Data.Type ) ||
( Class instanceof ParaHyperlink && historyitem_Hyperlink_AddItem === Data.Type ) ||
( Class instanceof ParaRun && historyitem_ParaRun_AddItem === Data.Type )
) ? true : false;
var Count = 1;
if ( ( Class instanceof Paragraph ) ||
if ( ( Class instanceof Paragraph ) || ( Class instanceof ParaHyperlink) || ( Class instanceof ParaRun ) ||
( Class instanceof CDocument && historyitem_Document_RemoveItem === Data.Type ) ||
( Class instanceof CDocumentContent && historyitem_DocumentContent_RemoveItem === Data.Type ) )
Count = Data.Items.length;
......
......@@ -16,6 +16,8 @@ function ParaHyperlink()
this.Content = new Array();
this.m_oContentChanges = new CContentChanges(); // список изменений(добавление/удаление элементов)
this.StartLine = 0;
this.StartRange = 0;
......@@ -40,6 +42,21 @@ ParaHyperlink.prototype =
return this.Id;
},
Clear_ContentChanges : function()
{
this.m_oContentChanges.Clear();
},
Add_ContentChanges : function(Changes)
{
this.m_oContentChanges.Add( Changes );
},
Refresh_ContentChanges : function()
{
this.m_oContentChanges.Refresh();
},
Copy : function(Selected)
{
var NewHyperlink = new ParaHyperlink();
......@@ -679,6 +696,12 @@ ParaHyperlink.prototype =
{
var PRS = g_oPRSW;
if ( this.Paragraph !== PRS.Paragraph )
{
this.Paragraph = PRS.Paragraph;
this.Paragraph.RecalcInfo.Set_Type_0_Spell( pararecalc_0_Spell_All );
}
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
......@@ -1639,33 +1662,224 @@ ParaHyperlink.prototype =
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
Write_ToBinary : function(Writer)
Save_Changes : function(Data, Writer)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
Writer.WriteLong( historyitem_type_Hyperlink );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
switch(Type)
{
case 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 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 historyitem_Hyperlink_Value :
{
// String : Value
Writer.WriteString2( Data.New );
break;
}
case historyitem_Hyperlink_ToolTip :
{
// String : ToolTip
Writer.WriteString2( Data.New );
break;
}
}
},
Read_FromBinary : function(Reader)
Load_Changes : function(Reader)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_Hyperlink != ClassType )
return;
var Type = Reader.GetLong();
switch ( Type )
{
case 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( contentchanges_Add, Reader.GetLong() );
var Element = g_oTableId.Get_ById( Reader.GetString2() );
if ( null != Element )
{
this.Content.splice( Pos, 0, Element );
}
}
if ( null !== this.Paragraph && undefined !== this.Paragraph )
this.Paragraph.RecalcInfo.Set_Type_0_Spell( pararecalc_0_Spell_All );
break;
}
case historyitem_Hyperlink_RemoveItem:
{
// Long : Количество удаляемых элементов
// Array of Long : позиции удаляемых элементов
var Count = Reader.GetLong();
for ( var Index = 0; Index < Count; Index++ )
{
var ChangesPos = this.m_oContentChanges.Check( contentchanges_Remove, Reader.GetLong() );
// действие совпало, не делаем его
if ( false === ChangesPos )
continue;
this.Content.splice( ChangesPos, 1 );
}
if ( null !== this.Paragraph && undefined !== this.Paragraph )
this.Paragraph.RecalcInfo.Set_Type_0_Spell( pararecalc_0_Spell_All );
break;
}
case historyitem_Hyperlink_Value:
{
// String : Value
this.Value = Reader.GetString2();
break;
}
case historyitem_Hyperlink_ToolTip :
{
// String : ToolTip
this.ToolTip = Reader.GetString2();
break;
}
}
},
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_Hyperlink );
},
// String : Id
// String : Value
// String : ToolTip
// Long : Количество элементов
// Array of Strings : массив с Id элементов
Read_FromBinary2 : function(Reader)
{
Writer.WriteString2( this.Id );
Writer.WriteString2( this.Value );
Writer.WriteString2( this.ToolTip );
var Count = this.Content.length;
Writer.WriteLong( Count );
for ( var Index = 0; Index < Count; Index++ )
{
Writer.WriteString2( this.Content[Index].Get_Id() );
}
},
Save_Changes : function(Data, Writer)
Read_FromBinary2 : function(Reader)
{
// String : Id
// String : Value
// String : ToolTip
// Long : Количество элементов
// Array of Strings : массив с Id элементов
},
this.Id = Reader.GetString2();
this.Value = Reader.GetString2();
this.ToolTip = Reader.GetString2();
Load_Changes : function(Reader)
{
var Count = Reader.GetLong();
this.Content = new Array();
for ( var Index = 0; Index < Count; Index++ )
{
var Element = g_oTableId.Get_ById( Reader.GetString2() );
if ( null !== Element )
this.Content.push( Element );
}
}
};
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