Commit 40ba835a 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@54207 954022d7-b5bf-4e40-9824-e11837661b57
parent 3b1532ff
......@@ -8000,6 +8000,25 @@ ParaMath.prototype =
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteOMathPara(oThis.Math);});
},
/*Write_ElemToBinary2 : function(Writer, elem)
{
var oThis = this;
this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer);
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteArgNodes(elem);});
},*/
//добавление формулы в формулу
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)
{
var oThis = this;
......@@ -8013,7 +8032,39 @@ ParaMath.prototype =
res = this.bcr.Read1(length, function(t, l){
return oThis.boMathr.ReadMathOMathPara(t,l,oThis.Math);
});
},
/*Read_ElemFromBinary2 : function(Reader, elem)
{
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.ReadMathArg(t,l,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 elem = null;
res = this.bcr.Read1(length, function(t, l){
elem = oThis.boMathr.ReadMathArg(t,l,obj);
});
return elem;
},
Save_Changes : function(Data, Writer)
......@@ -8023,6 +8074,7 @@ ParaMath.prototype =
Load_Changes : function(Reader)
{
this.Math.CurrentContent.Load_Changes(Reader);
}
};
......
......@@ -1552,19 +1552,10 @@ function Binary_oMathWriter(memory, oMathPara)
this.bs = new BinaryCommonWriter(this.memory);
this.brPrs = new Binary_rPrWriter(this.memory);
this.WriteArgNodes = function(oElem)
{
if (oElem)
this.WriteMathElem = function(mathElem)
{
var oThis = this;
var nStart = 0;
var nEnd = oElem.content.length - 1;
var nCurPos = 0;
for(var i = nStart; i <= nEnd; i++)
{
var item = oElem.content[i].value;
var item = mathElem.value;
switch ( item.typeObj)
{
case MATH_COMP:
......@@ -1610,13 +1601,36 @@ function Binary_oMathWriter(memory, oMathPara)
}
break;
}
case MATH_TEXT: //сюда попадаем только при совместном редактировании
{
this.bs.WriteItem(c_oSer_OMathContentType.MText, function(){ oThis.memory.WriteString2(String.fromCharCode(item.value));}); //m:t
}
break
case MATH_RUN_PRP:
case MATH_PLACEHOLDER:
case MATH_EMPTY:
break;
}
}
this.WriteArgNodes = function(oElem)
{
if (oElem)
{
var oThis = this;
var nStart = 0;
var nEnd = oElem.content.length - 1;
for(var i = nStart; i <= nEnd; i++)
{
var item = oElem.content[i];
if (MATH_RUN_PRP == item.value.typeObj)
{
var nCurPos = 0;
this.memory.WriteByte(c_oSer_OMathContentType.MRun);
nCurPos = this.bs.WriteItemWithLengthStart();
var props = item.getPropsForWrite();
var props = item.value.getPropsForWrite();
oThis.bs.WriteItem(c_oSerRunType.rPr, function(){oThis.brPrs.Write_rPr(props.textPrp);}); // w:rPr
if ( props.mathRunPrp != null)
this.bs.WriteItem(c_oSer_OMathContentType.MRPr, function(){oThis.WriteMRPr(props.mathRunPrp);}); // m:rPr
......@@ -1625,19 +1639,15 @@ function Binary_oMathWriter(memory, oMathPara)
while (oElem.content[i+1] != null && oElem.content[i+1].value.typeObj == MATH_TEXT)
{
oText += String.fromCharCode(oElem.content[i+1].value.value);
i++
i++;
}
if (null != oText)
this.bs.WriteItem(c_oSer_OMathContentType.MText, function(){ oThis.memory.WriteString2(oText);}); //m:t
this.bs.WriteItemEnd(nCurPos);
}
break;
case MATH_TEXT:
case MATH_PLACEHOLDER:
case MATH_EMPTY:
break;
}
else
this.WriteMathElem(item);
}
}
......@@ -7549,6 +7559,10 @@ function Binary_oMathReader(stream)
res = c_oSerConstants.ReadUnknown;
return res;
};
this.WriteMathElem = function()
{
return ;
}
this.ReadMathArg = function(type, length, oElem)
{
var res = c_oSerConstants.ReadOk;
......@@ -7715,6 +7729,14 @@ function Binary_oMathReader(stream)
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathSSup(t,l,oSSup,props,oElem);
});
}
//для совместного редактирования
else if (c_oSer_OMathContentType.MText === type)
{
var text = this.stream.GetString2LE(length);
var oElem1 = new CMathText();
oElem1.addTxt(text);
return oElem1;
}
else
res = c_oSerConstants.ReadUnknown;
......
......@@ -418,9 +418,6 @@ CControlComposition.prototype =
this.Content[this.CurPos].UpdateCursor();
}
}
var MathControl = new CControlComposition();
MathControl.AddComposition();
MathControl.SetPosition({x: 27.5 - 6, y: 25.3 });
var inherit = function(obj, extObj)
{
......@@ -1145,9 +1142,6 @@ function Create_Structures()
}
var MathComposition = new CMathComposition();
MathComposition.SetPosition({x: 27.5 - 6, y: 25.3 });
function MathRecalculate()
{
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, { Width : Page_Width, Height : Page_Height, Margins : {
......
......@@ -6587,7 +6587,118 @@ CMathContent.prototype =
},
Save_Changes: function(Data, Writer)
{
Writer.WriteLong( historyitem_type_Math );
var Type = Data.Type;
// Пишем тип
Writer.WriteLong( Type );
var Math = this.Composition.Parent;
switch ( Type )
{
case historyitem_Math_AddItem:
{
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 );
Math.Write_MathElemToBinary(Writer, Data.Items[Index]);
}
break;
}
case historyitem_Math_RemoveItem:
{
/*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;*/
}
}
/*var oThis = this;
this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer);
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteArgNodes(oThis.Data);});
*/
},
Load_Changes : function(Reader)
{
// Сохраняем изменения из тех, которые используются для Undo/Redo в бинарный файл.
// Long : тип класса
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_Math != ClassType )
return;
var paraMath = this.Composition.Parent;
var Type = Reader.GetLong();
switch ( Type )
{
case historyitem_Math_AddItem:
{
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);
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() );
CollaborativeEditing.Add_ChangedClass(this);
}
}
this.DeleteCollaborativeMarks = false;
break;
}
}
},
Refresh_RecalcData: function()
{
......@@ -6980,6 +7091,14 @@ CMathContent.prototype =
this.setEndPos_Selection(1);
//this.setEnd_Selection(1);
//this.selection.active = false;
},
Get_Id : function()
{
return this.GetId();
},
GetId : function()
{
return this.Id;
}
/////////////////////////////////////////////////////////////////
......@@ -7035,6 +7154,10 @@ function CMathComposition()
};
this.Init();
//для совместного редактирования каждый элемент записываем в глобальную таблицу
//this.Id = g_oIdCounter.Get_NewId();
//g_oTableId.Add( this, this.Id );
}
CMathComposition.prototype =
{
......@@ -7784,6 +7907,8 @@ 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)
......
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