Commit 0d19f6c3 authored by Sergey.Tsarkov's avatar Sergey.Tsarkov Committed by Alexander.Trofimov

переделаны вставка и удаление элементов в формулах

добавлен mathrun на запись

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55621 954022d7-b5bf-4e40-9824-e11837661b57
parent b7c43ecf
......@@ -109,7 +109,7 @@ ParaMath.prototype =
oText.addTxt(" ");
oStartContent.Add(oText);
}
/*else if ( para_Math === Type )
else if ( para_Math === Type )
{
nPosStart = oStartContent.State.ContentPos;
nLenStart = oStartContent.Content.length;
......@@ -137,7 +137,7 @@ ParaMath.prototype =
oContent.Content.content.push(oMRun);
oContent.Content.SetRunEmptyToContent(false);
}*/
}
},
AddText : function(oElem, sText, props)
......@@ -149,51 +149,20 @@ ParaMath.prototype =
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]);
MathRun.Content.splice( Pos, 0, oText );
//var element = new mathElem(oText);
items.push(oText);
}
oElem.addElementToContent(MathRun);
History.Add(oElem, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: PosEnd});
}
/*if(sText)
{
var rPr = new CTextPr();
var oMRun = new CMathRunPrp();
if (props)
oMRun.setMathRunPrp(props);
oMRun.setTxtPrp(rPr);
if (oElem)
{
oElem.addElementToContent(oMRun);
for (var i=0;i<sText.length;i++)
{
*//*text[i].replace("&", "&amp;");
text[i].Replace("'", "&apos;");
text[i].Replace("<", "&lt;");
text[i].Replace(">", "&gt;");
text[i].Replace("\"", "&quot;");*//*
oText = new CMathText();
oText.addTxt(sText[i]);
oElem.addElementToContent(oText);
}
}
}*/
},
CreateElem : function (oElem, oParent, props)
{
/*var ctrPrp = new CTextPr();
oElem.setCtrPrp(ctrPrp);*/
oElem.relate(oParent);
oElem.init(props);
......@@ -204,9 +173,7 @@ ParaMath.prototype =
if (oParent)
{
oParent.addElementToContent(oElem);
var element = new mathElem(oElem);
items.push(element);
items.push(oElem);
History.Add(oParent, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: PosEnd});
}
......@@ -272,7 +239,17 @@ ParaMath.prototype =
Remove : function(Direction, bOnAddText)
{
return this.Math.Remove(Direction, bOnAddText);
var oContent = this.GetSelectContent();
if (oContent.Start == oContent.End)
{
var oElem = oContent.Content.getElem(oContent.Start);
if (oElem.typeObj == MATH_COMP)
this.Math.Remove(oContent, Direction, bOnAddText);
else //mathrun
oElem.Remove(Direction, bOnAddText);
}
else
return this.Math.Remove(oContent, Direction, bOnAddText);
},
GetSelectContent: function()
......
......@@ -1716,13 +1716,14 @@ 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
}
this.bs.WriteItem(c_oSer_OMathContentType.MText, function(){ oThis.memory.WriteString2(String.fromCharCode(item.value));}); //m:t
break;
case MATH_PARA_RUN:
this.bs.WriteItem(c_oSer_OMathContentType.MRun, function(){oThis.WriteMRun(item);});
break;
case MATH_RUN_PRP:
case MATH_PLACEHOLDER:
case MATH_EMPTY:
case MATH_EMPTY:
break;
}
},
......@@ -1829,12 +1830,26 @@ function Binary_oMathWriter(memory, oMathPara)
this.WriteMRun = function(oMRun)
{
var oThis = this;
var oText = oMRun.getText();
//var oText = {Text: ""};
//oMRun.Get_Text(oText);
var props = oMRun.getPropsForWrite();
var oText = null;
var ContentLen = oMRun.Content.length;
for ( var CurPos = 0; CurPos < ContentLen; CurPos++ )
{
var Item = oMRun.Content[CurPos];
switch ( Item.type )
{
case para_Text : oText += String.fromCharCode(Item.value); break;
case para_Space:
case para_Tab : oText += " "; break;
}
}
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.bs.WriteItem(c_oSer_OMathContentType.RPr, function(){oThis.brPrs.Write_rPr(props.wRPrp);}); // w:rPr
this.bs.WriteItem(c_oSer_OMathContentType.MRPr, function(){oThis.WriteMRPr(props.mathRPrp);}); // m:rPr
if (oText != null)
this.bs.WriteItem(c_oSer_OMathContentType.MText, function(){ oThis.memory.WriteString2(oText);});
}
this.WriteArgNodesCollaborative = function(oElem)
{
......
......@@ -7859,8 +7859,12 @@ CMathContent.prototype =
this.setEndPos_Selection(1);
//this.setEnd_Selection(1);
//this.selection.active = false;
}
},
getElem: function(nNum)
{
return this.content[nNum];
}
/////////////////////////////////////////////////////////////////
//// test function for me ////
......@@ -8650,52 +8654,20 @@ CMathComposition.prototype =
return size;
},
Remove: function(order, bOnAdd)
Remove: function(oContent, nCount, bOnAdd)
{
//
////* History */////
History.Create_NewPoint();
var start = this.SelectContent.RealSelect.startPos,
end = this.SelectContent.RealSelect.endPos;
var Pos;
if(start !== end)
Pos = start < end ? start: end;
else if(order == 1)
Pos = this.SelectContent.CurPos;
else
Pos = this.SelectContent.CurPos + 1;
///////////////////////////
var removeMComp = true;
if(bOnAdd)
{
this.SelectContent.removeAreaSelect();
}
else
{
var result = this.SelectContent.remove(order);
var bRoot = this.SelectContent.bRoot === true,
bToUpper = result.state.bBegin || result.state.bEnd, // наверх нужно ли прокидовать
bAddRPrp = result.state.bAddRPrp;
if( result.state.bDelete )
History.Add(this.CurrentContent, {Type: historyitem_Math_RemoveItem, Items: result.items, Pos: Pos, bAddRPrp: bAddRPrp});
this.CurrentContent = result.CurrContent;
this.SelectContent = result.SelectContent;
this.CurrentContent.setPlaceholderAfterRemove(); // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
removeMComp = !(bRoot && bToUpper); // посылаем false, если в начале + backspace или в конце + delete
}
return removeMComp;
var oStartContent = oContent.Content.content[oContent.Start];
var oEndContent = oContent.Content.content[oContent.End];
var Items = new Array();
for (var i=oContent.Start; i<=oContent.End; i++)
{
Items.push(oContent.Content.content[i]);
oContent.Content.content.splice( i, 1 );
}
History.Add(oContent.Content, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: oContent.Start});
return;
},
AddLetter: function(code)
{
......
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