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()
case historyitem_type_Style : Element = new CStyle(); break;
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_Math : Element = new ParaMath(false, true); break;
case historyitem_type_CommentMark : Element = new ParaComment(); break;
case historyitem_type_ParaRun : Element = new ParaRun(); break;
}
......
......@@ -2,14 +2,14 @@
* Created by Ilja.Kirillov on 18.03.14.
*/
function ParaMath()
function ParaMath(bAddMenu, bCollaborative)
{
this.Id = g_oIdCounter.Get_NewId();
this.Type = para_Math;
this.Jc = undefined;
this.Math = new CMathComposition();
this.Math = new CMathComposition(bCollaborative);
this.Math.Parent = this;
this.Content = this.Math.Root.content; // Root.content
this.State = new CParaRunState(); // Положение курсора и селекта для данного run
......@@ -916,13 +916,37 @@ ParaMath.prototype =
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
Write_ToBinary : function(Writer)
{
// Long : Type
// String : Id
Writer.WriteLong( this.Type );
Writer.WriteString2( this.Id );
},
Write_ToBinary2 : function(Writer)
{
// TODO: ParaMath.Write_ToBinary2
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)
{
// 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 =
};
// Класс ParaMath
function ParaMath(bAddMenu)
function ParaMath(bAddMenu, bCollaborative)
{
this.Id = g_oIdCounter.Get_NewId();
this.Type = para_Math;
this.Jc = undefined;
this.Math = new CMathComposition();
this.Math = new CMathComposition(bCollaborative);
this.Math.Parent = this;
this.Inline = false; // внутристроковая формула или нет (проверяемся внутри Internal_Recalculate_0)
......@@ -7800,7 +7800,7 @@ ParaMath.prototype =
this.Id = newId;
},
Draw : function( X, Y, Context )
Draw : function( X, Y, Context)
{
this.Math.Draw( X, Y, Context );
},
......@@ -8073,8 +8073,7 @@ ParaMath.prototype =
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.Math);});
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteOMathParaCollaborative(oThis.Math);});//WriteOMathParaCollaborative
},
/*Write_ElemToBinary2 : function(Writer, elem)
......@@ -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)
{
......@@ -8107,7 +8099,7 @@ ParaMath.prototype =
var res = false;
Reader.cur += 3;
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 =
});
},*/
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)
{
......
This diff is collapsed.
......@@ -52,7 +52,7 @@ function CMathBase()
}
CMathBase.prototype =
{
setContent: function()
setContent: function(bColl)
{
this.elements = new Array();
......@@ -61,7 +61,7 @@ CMathBase.prototype =
this.elements[i] = new Array();
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].setComposition(this.Composition);
/*if( !this.elements[i][j].IsJustDraw())
......
......@@ -7,7 +7,7 @@ function CFraction()
CMathBase.call(this);
}
extend(CFraction, CMathBase);
CFraction.prototype.init = function(props)
CFraction.prototype.init = function(props, bColl)
{
var bValid = typeof(props.type) !== "undefined" && props.type !== null;
......@@ -24,10 +24,10 @@ CFraction.prototype.init = function(props)
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{
var num = new CNumerator();
num.init();
num.init(bColl);
var den = new CDenominator();
den.init();
den.init(bColl);
this.setDimension(2, 1);
......@@ -440,10 +440,10 @@ function CNumerator()
CMathBase.call(this);
}
extend(CNumerator, CMathBase);
CNumerator.prototype.init = function()
CNumerator.prototype.init = function(bColl)
{
this.setDimension(1, 1);
this.setContent();
this.setContent(bColl);
}
CNumerator.prototype.recalculateSize = function()
{
......@@ -505,10 +505,10 @@ function CDenominator()
CMathBase.call(this);
}
extend(CDenominator, CMathBase);
CDenominator.prototype.init = function()
CDenominator.prototype.init = function(bColl)
{
this.setDimension(1, 1);
this.setContent();
this.setContent(bColl);
}
CDenominator.prototype.recalculateSize = function()
{
......
......@@ -358,8 +358,14 @@ CMPrp.prototype =
// 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.plhHide = false;
this.bRoot = false;
......@@ -6757,8 +6763,6 @@ CMathContent.prototype =
// Пишем тип
Writer.WriteLong( Type );
var Math = this.Composition.Parent;
switch ( Type )
{
case historyitem_Math_AddItem:
......@@ -6775,7 +6779,7 @@ CMathContent.prototype =
else
Writer.WriteLong( Data.Pos + Index );
Math.Write_MathElemToBinary(Writer, Data.Items[Index]);
this.Write_MathElemToBinary(Writer, Data.Items[Index]);
}
break;
}
......@@ -6828,7 +6832,6 @@ CMathContent.prototype =
if ( historyitem_type_Math != ClassType )
return;
var paraMath = this.Composition.Parent;
var Type = Reader.GetLong();
switch ( Type )
......@@ -6837,23 +6840,13 @@ CMathContent.prototype =
{
var Count = Reader.GetLong();
//var oMathComp = new CMathComposition;
for ( var Index = 0; Index < Count; Index++ )
{
var Pos = Reader.GetLong()
var elem = paraMath.Read_MathElemFromBinary(Reader);
var elem = this.Read_MathElemFromBinary(Reader);
if ( null != elem )
{
//paraMath.Math.AddToComposition(Item.Math.Root);
// 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() );
this.content.splice( Pos, 0, elem );
CollaborativeEditing.Add_ChangedClass(this);
}
}
......@@ -6863,6 +6856,36 @@ CMathContent.prototype =
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()
{
......@@ -7326,7 +7349,7 @@ CMathContent.prototype =
}
function CMathComposition()
function CMathComposition(bCollaborative)
{
this.Parent = undefined;
......@@ -7359,11 +7382,7 @@ function CMathComposition()
this.DEFAULT_RUN_PRP = new CMathRunPrp();
this.Init();
//для совместного редактирования каждый элемент записываем в глобальную таблицу
//this.Id = g_oIdCounter.Get_NewId();
//g_oTableId.Add( this, this.Id );
this.Init(bCollaborative);
}
CMathComposition.prototype =
{
......@@ -7982,9 +8001,9 @@ CMathComposition.prototype =
},*/
//////////////* end of test functions *//////////////////
Init: function()
Init: function(bCollaborative)
{
this.Root = new CMathContent();
this.Root = new CMathContent(bCollaborative);
//this.Root.gaps = gps;
this.Root.setComposition(this);
//this.SetTestRunPrp();
......@@ -8202,8 +8221,6 @@ CMathComposition.prototype =
var Pos = this.SelectContent.CurPos,
EndPos = this.SelectContent.CurPos + 1;
//для совместного редактирования
this.CurrentContent.Id = this.Id;
History.Add(this.CurrentContent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: EndPos});
},
CreateEquation: function(indef)
......@@ -8353,6 +8370,37 @@ CMathComposition.prototype =
GetCurrentRunPrp: function()
{
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