Commit 54dcf197 authored by Sergey.Tsarkov's avatar Sergey.Tsarkov Committed by Alexander.Trofimov

совместное редактирование формул

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55059 954022d7-b5bf-4e40-9824-e11837661b57
parent e44af7b3
...@@ -155,7 +155,7 @@ function CTableId() ...@@ -155,7 +155,7 @@ function CTableId()
case historyitem_type_Style : Element = new CStyle(); break; case historyitem_type_Style : Element = new CStyle(); break;
case historyitem_type_TextBody : Element = new CTextBody(); break; case historyitem_type_TextBody : Element = new CTextBody(); break;
case historyitem_type_ChartTitle : Element = new CChartTitle(); break; case historyitem_type_ChartTitle : Element = new CChartTitle(); break;
case historyitem_type_Math : Element = new ParaMath(); break; case historyitem_type_Math : Element = new ParaMath(false, true); break;
case historyitem_type_CommentMark : Element = new ParaComment(); break; case historyitem_type_CommentMark : Element = new ParaComment(); break;
case historyitem_type_ParaRun : Element = new ParaRun(); break; case historyitem_type_ParaRun : Element = new ParaRun(); break;
} }
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
* Created by Ilja.Kirillov on 18.03.14. * Created by Ilja.Kirillov on 18.03.14.
*/ */
function ParaMath() function ParaMath(bAddMenu, bCollaborative)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
this.Type = para_Math; this.Type = para_Math;
this.Jc = undefined; this.Jc = undefined;
this.Math = new CMathComposition(); this.Math = new CMathComposition(bCollaborative);
this.Math.Parent = this; this.Math.Parent = this;
this.Content = this.Math.Root.content; // Root.content this.Content = this.Math.Root.content; // Root.content
this.State = new CParaRunState(); // Положение курсора и селекта для данного run this.State = new CParaRunState(); // Положение курсора и селекта для данного run
...@@ -916,13 +916,37 @@ ParaMath.prototype = ...@@ -916,13 +916,37 @@ ParaMath.prototype =
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования // Функции совместного редактирования
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
Write_ToBinary2 : function(Writer) Write_ToBinary : function(Writer)
{ {
// TODO: ParaMath.Write_ToBinary2 // Long : Type
// String : Id
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
},
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_Math );
var oThis = this;
this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer);
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteOMathParaCollaborative(oThis.Math);});//WriteOMathParaCollaborative
}, },
Read_FromBinary2 : function(Reader) Read_FromBinary2 : function(Reader)
{ {
// TODO: ParaMath.Read_FromBinary2 var oThis = this;
} this.boMathr = new Binary_oMathReader(Reader);
this.bcr = new Binary_CommonReader(Reader);
var length = Reader.GetUChar();
var res = false;
Reader.cur += 3;
res = this.bcr.Read1(length, function(t, l){
return oThis.boMathr.ReadMathOMathParaCollaborative(t,l,oThis.Math);
});
},
}; };
\ No newline at end of file
...@@ -7750,14 +7750,14 @@ ParaPresentationNumbering.prototype = ...@@ -7750,14 +7750,14 @@ ParaPresentationNumbering.prototype =
}; };
// Класс ParaMath // Класс ParaMath
function ParaMath(bAddMenu) function ParaMath(bAddMenu, bCollaborative)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
this.Type = para_Math; this.Type = para_Math;
this.Jc = undefined; this.Jc = undefined;
this.Math = new CMathComposition(); this.Math = new CMathComposition(bCollaborative);
this.Math.Parent = this; this.Math.Parent = this;
this.Inline = false; // внутристроковая формула или нет (проверяемся внутри Internal_Recalculate_0) this.Inline = false; // внутристроковая формула или нет (проверяемся внутри Internal_Recalculate_0)
...@@ -7800,9 +7800,9 @@ ParaMath.prototype = ...@@ -7800,9 +7800,9 @@ ParaMath.prototype =
this.Id = newId; this.Id = newId;
}, },
Draw : function( X, Y, Context ) Draw : function( X, Y, Context)
{ {
this.Math.Draw( X, Y, Context ); this.Math.Draw( X, Y, Context );
}, },
Measure : function( Context, TextPr ) Measure : function( Context, TextPr )
...@@ -8072,9 +8072,8 @@ ParaMath.prototype = ...@@ -8072,9 +8072,8 @@ ParaMath.prototype =
var oThis = this; var oThis = this;
this.bs = new BinaryCommonWriter(Writer); this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer); this.boMaths = new Binary_oMathWriter(Writer);
//this.bs.WriteItem(c_oSerParType.OMathPara, function(){oThis.boMaths.WriteOMathPara(oThis.Math);}); this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteOMathParaCollaborative(oThis.Math);});//WriteOMathParaCollaborative
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteOMathPara(oThis.Math);});
}, },
/*Write_ElemToBinary2 : function(Writer, elem) /*Write_ElemToBinary2 : function(Writer, elem)
...@@ -8087,14 +8086,7 @@ ParaMath.prototype = ...@@ -8087,14 +8086,7 @@ ParaMath.prototype =
},*/ },*/
//добавление формулы в формулу //добавление формулы в формулу
Write_MathElemToBinary : function(Writer, elem)
{
var oThis = this;
this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer);
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteMathElem(elem);});
},
Read_FromBinary2 : function(Reader) Read_FromBinary2 : function(Reader)
{ {
...@@ -8107,7 +8099,7 @@ ParaMath.prototype = ...@@ -8107,7 +8099,7 @@ ParaMath.prototype =
var res = false; var res = false;
Reader.cur += 3; Reader.cur += 3;
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.boMathr.ReadMathOMathPara(t,l,oThis.Math); return oThis.boMathr.ReadMathOMathParaCollaborative(t,l,oThis.Math);
}); });
}, },
...@@ -8126,23 +8118,7 @@ ParaMath.prototype = ...@@ -8126,23 +8118,7 @@ ParaMath.prototype =
}); });
},*/ },*/
Read_MathElemFromBinary : function(Reader)
{
var oThis = this;
this.boMathr = new Binary_oMathReader(Reader);
this.bcr = new Binary_CommonReader(Reader);
var length = Reader.GetUChar();
var res = false;
Reader.cur += 3;
var obj = null;
var elem = null;
res = this.bcr.Read1(length, function(t, l){
elem = oThis.boMathr.ReadMathArg(t,l,obj);
});
return elem;
},
Save_Changes : function(Data, Writer) Save_Changes : function(Data, Writer)
{ {
......
This diff is collapsed.
...@@ -52,7 +52,7 @@ function CMathBase() ...@@ -52,7 +52,7 @@ function CMathBase()
} }
CMathBase.prototype = CMathBase.prototype =
{ {
setContent: function() setContent: function(bColl)
{ {
this.elements = new Array(); this.elements = new Array();
...@@ -61,7 +61,7 @@ CMathBase.prototype = ...@@ -61,7 +61,7 @@ CMathBase.prototype =
this.elements[i] = new Array(); this.elements[i] = new Array();
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
{ {
this.elements[i][j] = new CMathContent(); this.elements[i][j] = new CMathContent(bColl);
this.elements[i][j].relate(this); this.elements[i][j].relate(this);
this.elements[i][j].setComposition(this.Composition); this.elements[i][j].setComposition(this.Composition);
/*if( !this.elements[i][j].IsJustDraw()) /*if( !this.elements[i][j].IsJustDraw())
......
...@@ -7,7 +7,7 @@ function CFraction() ...@@ -7,7 +7,7 @@ function CFraction()
CMathBase.call(this); CMathBase.call(this);
} }
extend(CFraction, CMathBase); extend(CFraction, CMathBase);
CFraction.prototype.init = function(props) CFraction.prototype.init = function(props, bColl)
{ {
var bValid = typeof(props.type) !== "undefined" && props.type !== null; var bValid = typeof(props.type) !== "undefined" && props.type !== null;
...@@ -24,10 +24,10 @@ CFraction.prototype.init = function(props) ...@@ -24,10 +24,10 @@ CFraction.prototype.init = function(props)
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{ {
var num = new CNumerator(); var num = new CNumerator();
num.init(); num.init(bColl);
var den = new CDenominator(); var den = new CDenominator();
den.init(); den.init(bColl);
this.setDimension(2, 1); this.setDimension(2, 1);
...@@ -440,10 +440,10 @@ function CNumerator() ...@@ -440,10 +440,10 @@ function CNumerator()
CMathBase.call(this); CMathBase.call(this);
} }
extend(CNumerator, CMathBase); extend(CNumerator, CMathBase);
CNumerator.prototype.init = function() CNumerator.prototype.init = function(bColl)
{ {
this.setDimension(1, 1); this.setDimension(1, 1);
this.setContent(); this.setContent(bColl);
} }
CNumerator.prototype.recalculateSize = function() CNumerator.prototype.recalculateSize = function()
{ {
...@@ -505,10 +505,10 @@ function CDenominator() ...@@ -505,10 +505,10 @@ function CDenominator()
CMathBase.call(this); CMathBase.call(this);
} }
extend(CDenominator, CMathBase); extend(CDenominator, CMathBase);
CDenominator.prototype.init = function() CDenominator.prototype.init = function(bColl)
{ {
this.setDimension(1, 1); this.setDimension(1, 1);
this.setContent(); this.setContent(bColl);
} }
CDenominator.prototype.recalculateSize = function() CDenominator.prototype.recalculateSize = function()
{ {
......
...@@ -358,8 +358,14 @@ CMPrp.prototype = ...@@ -358,8 +358,14 @@ CMPrp.prototype =
// 1. (!!) повтор IsIncline, IsHighElement // 1. (!!) повтор IsIncline, IsHighElement
function CMathContent() function CMathContent(bCollaborative)
{ {
if (!bCollaborative)
{
this.Id = g_oIdCounter.Get_NewId();
g_oTableId.m_aPairs[this.Id] = this;
}
this.bDot = false; this.bDot = false;
this.plhHide = false; this.plhHide = false;
this.bRoot = false; this.bRoot = false;
...@@ -6749,7 +6755,7 @@ CMathContent.prototype = ...@@ -6749,7 +6755,7 @@ CMathContent.prototype =
} }
} }
}, },
Save_Changes: function(Data, Writer) Save_Changes: function(Data, Writer)
{ {
Writer.WriteLong( historyitem_type_Math ); Writer.WriteLong( historyitem_type_Math );
...@@ -6757,8 +6763,6 @@ CMathContent.prototype = ...@@ -6757,8 +6763,6 @@ CMathContent.prototype =
// Пишем тип // Пишем тип
Writer.WriteLong( Type ); Writer.WriteLong( Type );
var Math = this.Composition.Parent;
switch ( Type ) switch ( Type )
{ {
case historyitem_Math_AddItem: case historyitem_Math_AddItem:
...@@ -6775,7 +6779,7 @@ CMathContent.prototype = ...@@ -6775,7 +6779,7 @@ CMathContent.prototype =
else else
Writer.WriteLong( Data.Pos + Index ); Writer.WriteLong( Data.Pos + Index );
Math.Write_MathElemToBinary(Writer, Data.Items[Index]); this.Write_MathElemToBinary(Writer, Data.Items[Index]);
} }
break; break;
} }
...@@ -6828,7 +6832,6 @@ CMathContent.prototype = ...@@ -6828,7 +6832,6 @@ CMathContent.prototype =
if ( historyitem_type_Math != ClassType ) if ( historyitem_type_Math != ClassType )
return; return;
var paraMath = this.Composition.Parent;
var Type = Reader.GetLong(); var Type = Reader.GetLong();
switch ( Type ) switch ( Type )
...@@ -6837,23 +6840,13 @@ CMathContent.prototype = ...@@ -6837,23 +6840,13 @@ CMathContent.prototype =
{ {
var Count = Reader.GetLong(); var Count = Reader.GetLong();
//var oMathComp = new CMathComposition;
for ( var Index = 0; Index < Count; Index++ ) for ( var Index = 0; Index < Count; Index++ )
{ {
var Pos = Reader.GetLong() var Pos = Reader.GetLong()
var elem = paraMath.Read_MathElemFromBinary(Reader); var elem = this.Read_MathElemFromBinary(Reader);
if ( null != elem ) if ( null != elem )
{ {
//paraMath.Math.AddToComposition(Item.Math.Root); this.content.splice( Pos, 0, elem );
// TODO: Подумать над тем как по минимуму вставлять отметки совместного редактирования
var Element = new mathElem(elem);
this.content.splice( Pos, 0, new ParaCollaborativeChangesEnd() );
this.content.splice( Pos, 0, Element );
this.content.splice( Pos, 0, new ParaCollaborativeChangesStart() );
CollaborativeEditing.Add_ChangedClass(this); CollaborativeEditing.Add_ChangedClass(this);
} }
} }
...@@ -6863,6 +6856,36 @@ CMathContent.prototype = ...@@ -6863,6 +6856,36 @@ CMathContent.prototype =
break; break;
} }
} }
this.Composition.Resize(g_oTextMeasurer);
},
Write_MathElemToBinary : function(Writer, elem)
{
var oThis = this;
this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer);
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteMathElemCollaborative(elem);});
},
Read_MathElemFromBinary : function(Reader)
{
var oThis = this;
this.boMathr = new Binary_oMathReader(Reader);
this.bcr = new Binary_CommonReader(Reader);
var length = Reader.GetUChar();
var res = false;
Reader.cur += 3;
//var obj = null;
var bCollaborative = true;
var obj = new CMathContent(bCollaborative);
obj.setReferenceComposition(this.Composition);
var elem = null;
res = this.bcr.Read1(length, function(t, l){
oThis.boMathr.ReadMathArgCollaborative(t,l,obj);
});
elem = obj.content[1];
return elem;
}, },
Refresh_RecalcData: function() Refresh_RecalcData: function()
{ {
...@@ -7326,7 +7349,7 @@ CMathContent.prototype = ...@@ -7326,7 +7349,7 @@ CMathContent.prototype =
} }
function CMathComposition() function CMathComposition(bCollaborative)
{ {
this.Parent = undefined; this.Parent = undefined;
...@@ -7359,11 +7382,7 @@ function CMathComposition() ...@@ -7359,11 +7382,7 @@ function CMathComposition()
this.DEFAULT_RUN_PRP = new CMathRunPrp(); this.DEFAULT_RUN_PRP = new CMathRunPrp();
this.Init(); this.Init(bCollaborative);
//для совместного редактирования каждый элемент записываем в глобальную таблицу
//this.Id = g_oIdCounter.Get_NewId();
//g_oTableId.Add( this, this.Id );
} }
CMathComposition.prototype = CMathComposition.prototype =
{ {
...@@ -7982,9 +8001,9 @@ CMathComposition.prototype = ...@@ -7982,9 +8001,9 @@ CMathComposition.prototype =
},*/ },*/
//////////////* end of test functions *////////////////// //////////////* end of test functions *//////////////////
Init: function() Init: function(bCollaborative)
{ {
this.Root = new CMathContent(); this.Root = new CMathContent(bCollaborative);
//this.Root.gaps = gps; //this.Root.gaps = gps;
this.Root.setComposition(this); this.Root.setComposition(this);
//this.SetTestRunPrp(); //this.SetTestRunPrp();
...@@ -8202,8 +8221,6 @@ CMathComposition.prototype = ...@@ -8202,8 +8221,6 @@ CMathComposition.prototype =
var Pos = this.SelectContent.CurPos, var Pos = this.SelectContent.CurPos,
EndPos = this.SelectContent.CurPos + 1; EndPos = this.SelectContent.CurPos + 1;
//для совместного редактирования
this.CurrentContent.Id = this.Id;
History.Add(this.CurrentContent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: EndPos}); History.Add(this.CurrentContent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: EndPos});
}, },
CreateEquation: function(indef) CreateEquation: function(indef)
...@@ -8353,7 +8370,38 @@ CMathComposition.prototype = ...@@ -8353,7 +8370,38 @@ CMathComposition.prototype =
GetCurrentRunPrp: function() GetCurrentRunPrp: function()
{ {
return this.CurrentContent.getRunPrp(this.CurrentContent.CurPos); return this.CurrentContent.getRunPrp(this.CurrentContent.CurPos);
} },
//совместное редактирование
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_Math );
var oThis = this;
this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer);
//this.bs.WriteItem(c_oSerParType.OMathPara, function(){oThis.boMaths.WriteOMathPara(oThis.Math);});
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteOMathPara(oThis);});
},
Read_FromBinary2 : function(Reader)
{
var oThis = this;
this.boMathr = new Binary_oMathReader(Reader);
this.bcr = new Binary_CommonReader(Reader);
var length = Reader.GetUChar();
var res = false;
Reader.cur += 3;
res = this.bcr.Read1(length, function(t, l){
return oThis.boMathr.ReadMathOMathPara(t,l,oThis);
});
},
Load_Changes : function( Reader )
{
this.CurrentContent.Load_Changes(Reader)
}
////////////////////////////// //////////////////////////////
} }
......
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