Commit 2325792f authored by Sergey.Tsarkov's avatar Sergey.Tsarkov Committed by Alexander.Trofimov

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

новая вставка формулы в параграф. для совместного редактирования теперь для каждого MathContent создается свой id/
добавлена обертка MatRun для чтения и записи

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55189 954022d7-b5bf-4e40-9824-e11837661b57
parent 7a8fec11
......@@ -1143,6 +1143,7 @@ var historyitem_type_ChartTitle = 32;
var historyitem_type_Math = 33;
var historyitem_type_CommentMark = 34;
var historyitem_type_ParaRun = 35;
var historyitem_type_MathContent = 36;
//Типы изменений в классе CChartAsGroup
var historyitem_SetCahrtLayout = 1000;
......
......@@ -155,7 +155,8 @@ 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(false, true); break;
case historyitem_type_Math : Element = new ParaMath(false); break;
case historyitem_type_MathContent : Element = new CMathContent(); break;
case historyitem_type_CommentMark : Element = new ParaComment(); break;
case historyitem_type_ParaRun : Element = new ParaRun(); break;
}
......
......@@ -2,7 +2,7 @@
* Created by Ilja.Kirillov on 18.03.14.
*/
function ParaMath(bAddMenu, bCollaborative)
function ParaMath(bAddMenu)
{
this.Id = g_oIdCounter.Get_NewId();
this.Type = para_Math;
......@@ -35,7 +35,8 @@ function ParaMath(bAddMenu, bCollaborative)
this.Descent = 0;
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
if (!bAddMenu)
g_oTableId.Add( this, this.Id );
}
ParaMath.prototype =
......@@ -129,24 +130,31 @@ ParaMath.prototype =
}
},
AddText : function(oElem, sText, props)
{
{
if(sText)
{
{
var MathRun = new ParaRun();
var Pos = oElem.CurPos,
PosEnd = Pos + 1;
var items = new Array();
for (var Pos=0; Pos < sText.length; Pos++)
{
var oText = new CMathText();
oText.addTxt(sText[Pos]);
oText.addTxt(sText[Pos]);
MathRun.Content.splice( Pos, 0, oText );
var element = new mathElem(oText);
items.push(element);
}
MathRun.bMathRun = true;
MathRun.typeObj = MATH_PARA_RUN;
oElem.addElementToContent(MathRun);
}
History.Add(oElem, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: PosEnd});
}
/*if(sText)
{
......@@ -809,7 +817,7 @@ ParaMath.prototype =
{
this.Paragraph.Refresh_RecalcData2(0);
},
Refresh_RecalcData2 : function(Data)
{
this.Paragraph.Refresh_RecalcData2(0);
......@@ -1224,7 +1232,16 @@ ParaMath.prototype =
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
Write_ToBinary : function(Writer)
/*Save_Changes : function(Data, Writer)
{
},
Load_Changes : function(Reader)
{
this.Math.CurrentContent.Load_Changes(Reader);
}*/
Write_ToBinary : function(Writer)
{
// Long : Type
// String : Id
......@@ -1236,16 +1253,17 @@ ParaMath.prototype =
{
Writer.WriteLong( historyitem_type_Math );
var oThis = this;
/*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)
{
var oThis = this;
/*var oThis = this;
this.boMathr = new Binary_oMathReader(Reader);
this.bcr = new Binary_CommonReader(Reader);
......@@ -1256,5 +1274,6 @@ ParaMath.prototype =
res = this.bcr.Read1(length, function(t, l){
return oThis.boMathr.ReadMathOMathParaCollaborative(t,l,oThis.Math);
});
*/
}
};
\ No newline at end of file
......@@ -1595,7 +1595,7 @@ function Binary_oMathWriter(memory, oMathPara)
case "OMath" : this.bs.WriteItem(c_oSer_OMathContentType.OMath, function(){oThis.WriteArgNodes(item);}); break;
case "OMathPara" : this.bs.WriteItem(c_oSer_OMathContentType.OMathPara, function(){oThis.WriteOMathPara(item);});break;
case MATH_PHANTOM : this.bs.WriteItem(c_oSer_OMathContentType.Phant, function(){oThis.WritePhant(item);}); break;
//case "MRun" : this.bs.WriteItem(c_oSer_OMathContentType.MRun, function(){oThis.WriteMRun(item);}); break;
case MATH_RUN : this.bs.WriteItem(c_oSer_OMathContentType.MRun, function(){oThis.WriteMRun(item);}); break;
case MATH_RADICAL : this.bs.WriteItem(c_oSer_OMathContentType.Rad, function(){oThis.WriteRad(item);}); break;
case MATH_DEGREESubSup :
if (DEGREE_PreSubSup == item.type)
......@@ -1611,18 +1611,18 @@ function Binary_oMathWriter(memory, oMathPara)
break;
}
break;
}
case MATH_TEXT: //сюда попадаем только при совместном редактировании
}
case MATH_TEXT:
{
this.bs.WriteItem(c_oSer_OMathContentType.MText, function(){ oThis.memory.WriteString2(String.fromCharCode(item.value));}); //m:t
}
break
break;
case MATH_RUN_PRP:
case MATH_PLACEHOLDER:
case MATH_EMPTY:
break;
}
}
},
this.WriteMathElemCollaborative = function(mathElem)
{
var oThis = this;
......@@ -1676,13 +1676,13 @@ function Binary_oMathWriter(memory, oMathPara)
{
this.bs.WriteItem(c_oSer_OMathContentType.MText, function(){ oThis.memory.WriteString2(String.fromCharCode(item.value));}); //m:t
}
break
break;
case MATH_RUN_PRP:
case MATH_PLACEHOLDER:
case MATH_EMPTY:
break;
}
}
}
this.WriteArgNodes = function(oElem)
{
if (oElem)
......@@ -1695,7 +1695,7 @@ function Binary_oMathWriter(memory, oMathPara)
{
var item = oElem.content[i];
if (MATH_RUN_PRP == item.value.typeObj)
/*if (MATH_RUN_PRP == item.value.typeObj)
{
var nCurPos = 0;
this.memory.WriteByte(c_oSer_OMathContentType.MRun);
......@@ -1717,12 +1717,22 @@ function Binary_oMathWriter(memory, oMathPara)
this.bs.WriteItemEnd(nCurPos);
}
else
else*/
this.WriteMathElem(item);
}
}
}
this.WriteMRun = function(oMRun)
{
var oThis = this;
var oText = oMRun.getText();
var props = oMRun.getPropsForWrite();
this.bs.WriteItem(c_oSer_OMathContentType.RPr, function(){oThis.brPrs.Write_rPr(props.textPrp);}); // w:rPr
this.bs.WriteItem(c_oSer_OMathContentType.MRPr, function(){oThis.WriteMRPr(props.mathRunPrp);}); // m:rPr
this.bs.WriteItem(c_oSer_OMathContentType.MText,function(){oThis.WriteMText(oText);});
}
this.WriteArgNodesCollaborative = function(oElem)
{
if (oElem)
......@@ -1780,7 +1790,7 @@ function Binary_oMathWriter(memory, oMathPara)
this.bs.WriteItem(c_oSer_OMathContentType.AccPr, function(){oThis.WriteAccPr(props, oAcc);});
this.bs.WriteItem(c_oSer_OMathContentType.Id, function(){oThis.memory.WriteString2(oAcc.Id);});
this.bs.WriteItem(c_oSer_OMathContentType.Element, function(){oThis.WriteArgNodesCollaborative(oElem);});
}
}
this.WriteAccPr = function(props,oAcc)
{
var oThis = this;
......@@ -1788,7 +1798,7 @@ function Binary_oMathWriter(memory, oMathPara)
this.bs.WriteItem(c_oSer_OMathBottomNodesType.Chr, function(){oThis.WriteChr(props.chr);});
if (null != oAcc.CtrPrp)
this.bs.WriteItem(c_oSer_OMathBottomNodesType.CtrlPr, function(){oThis.WriteCtrlPr(oAcc);});
}
}
this.WriteAln = function(Aln)
{
this.memory.WriteByte(c_oSer_OMathBottomNodesValType.Val);
......@@ -8180,7 +8190,6 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.MRun === type)
{
var props = new Object();
var oMRun = new ParaRun();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathMRun(t,l,oMRun,props,oElem);
......
......@@ -360,6 +360,7 @@ CMPrp.prototype =
function CMathContent()
{
this.Id = g_oIdCounter.Get_NewId();
this.bDot = false;
this.plhHide = false;
this.bRoot = false;
......@@ -401,7 +402,9 @@ function CMathContent()
};
this.init();
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id );
}
CMathContent.prototype =
{
......@@ -6781,7 +6784,7 @@ CMathContent.prototype =
},
Save_Changes: function(Data, Writer)
{
Writer.WriteLong( historyitem_type_Math );
Writer.WriteLong( historyitem_type_MathContent );
var Type = Data.Type;
// Пишем тип
......@@ -6809,7 +6812,7 @@ CMathContent.prototype =
}
case historyitem_Math_RemoveItem:
{
/*var bArray = Data.UseArray;
var bArray = Data.UseArray;
var Count = Data.Items.length;
var StartPos = Writer.GetCurPosition();
......@@ -6835,7 +6838,7 @@ CMathContent.prototype =
Writer.WriteLong( RealCount );
Writer.Seek( EndPos );
break;*/
break;
}
}
......@@ -6853,7 +6856,7 @@ CMathContent.prototype =
// Long : тип изменений
var ClassType = Reader.GetLong();
if ( historyitem_type_Math != ClassType )
if ( historyitem_type_MathContent != ClassType )
return;
var Type = Reader.GetLong();
......@@ -6880,7 +6883,7 @@ CMathContent.prototype =
break;
}
}
this.Composition.Resize(g_oTextMeasurer);
//this.Composition.Resize(g_oTextMeasurer);
},
Write_MathElemToBinary : function(Writer, elem)
{
......@@ -6888,7 +6891,7 @@ CMathContent.prototype =
this.bs = new BinaryCommonWriter(Writer);
this.boMaths = new Binary_oMathWriter(Writer);
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteMathElemCollaborative(elem);});
this.bs.WriteItemWithLength ( function(){oThis.boMaths.WriteMathElem(elem);});
},
Read_MathElemFromBinary : function(Reader)
{
......@@ -6902,15 +6905,42 @@ CMathContent.prototype =
//var obj = null;
var bCollaborative = true;
var obj = new CMathContent(bCollaborative);
var obj = new CMathContent();
obj.setReferenceComposition(this.Composition);
var elem = null;
res = this.bcr.Read1(length, function(t, l){
oThis.boMathr.ReadMathArgCollaborative(t,l,obj);
oThis.boMathr.ReadMathArg(t,l,obj);
});
elem = obj.content[1];
return elem;
},
//добавление cmathcontent в формулу
Write_ToBinary2 : function(Writer)
{
Writer.WriteLong( historyitem_type_MathContent );
/*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 i=1;
/*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);
});*/
},
Refresh_RecalcData: function()
{
this.Composition.Refresh_RecalcData2(); // Refresh_RecalcData сообщает родительскому классу, что у него произошли изменения, нужно пересчитать
......@@ -8575,40 +8605,7 @@ 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