Commit 49d5cf7b authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander.Trofimov

Переделано добавление формулы в формулу. Добавлена корректировка контента...

Переделано добавление формулы в формулу. Добавлена корректировка контента формулы после ее добавления/чтения (старый вариант удален). Временно убран вариант класса CRadical, при котором контент степени рисовался внутри корня.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58811 954022d7-b5bf-4e40-9824-e11837661b57
parent b8809161
......@@ -125,7 +125,6 @@ function CTableId()
//-----------------------------------------------------------------------------------
this.Read_Class_FromBinary = function(Reader)
{
var props = null;
var ElementType = Reader.GetLong();
var Element = null;
......
......@@ -3220,6 +3220,7 @@ CDocument.prototype =
Item.CurPos.RealY = Item.CurPos.Y;
}
this.Document_UpdateSelectionState();
this.Document_UpdateInterfaceState();
}
......
......@@ -164,80 +164,43 @@ ParaMath.prototype.Add = function(Item)
this.NeedResize = true;
var Type = Item.Type;
var oContent = this.GetSelectContent();
var oStartContent = oContent.Content.content[oContent.Start];
var oEndContent = oContent.Content.content[oContent.End];
var oSelectedContent = this.GetSelectContent();
var oContent = oSelectedContent.Content;
var StartPos = oSelectedContent.Start;
var Run = oContent.content[StartPos];
// Мы вставляем только в Run
if (para_Math_Run !== Run.Type)
return;
if ( para_Text === Type)
if (para_Text === Type)
{
var oText = new CMathText(false);
oText.add(Item.Value);
oStartContent.Add(oText, true);
Run.Add(oText, true);
}
else if ( para_Space === Type )
else if (para_Space === Type)
{
//var oSpace = new ParaSpace(1);
var oText = new CMathText(false);
oText.addTxt(" ");
oStartContent.Add(oText, true);
Run.Add(oText, true);
}
else if ( para_Math === Type )
else if (para_Math === Type)
{
if (oStartContent.Type == para_Math_Run && oStartContent.IsPlaceholder())
{
var Items = [];
Items.push(oContent.Content.content[0]);
oContent.Content.content.splice( 0, 1 );
History.Add(oContent.Content, {Type: historyitem_Math_RemoveItem, Items:Items, Pos: 0});
oContent.Content.Load_FromMenu(Item.Menu, this.Paragraph);
}
else
{
var nPosStart = oStartContent.State.ContentPos,
nLenStart = oStartContent.Content.length,
nPosEnd = oEndContent.State.ContentPos;
if(nPosStart != nLenStart) //вставка идет в mathcontent
{
var oMRun = new ParaRun(this.Paragraph, true);
oMRun.Pr = oStartContent.Pr;
for (var i=nLenStart-1; i>=nPosStart; i--)
{
var Pos = oMRun.Content.length;
var EndPos = Pos + 1;
var oItem = oStartContent.Content[i];
oMRun.Add(oItem, true);
oStartContent.Remove_FromContent(i, 1, false);
}
oStartContent.Selection_Remove();
oMRun.State.ContentPos = 0;
}
oContent.Content.Load_FromMenu(Item.Menu, this.Paragraph);
if(nPosStart != nLenStart)
{
var items = [];
oContent.Content.Add(oMRun,oContent.Content.CurPos+1);
items.push(oMRun);
var Pos = oContent.Content.CurPos,
PosEnd = Pos + 1;
History.Add(oContent.Content, {Type: historyitem_Math_AddItem, Items: items, Pos: Pos, PosEnd: PosEnd});
}
else
oContent.Content.CurPos++;
}
oContent.Content.SetRunEmptyToContent(true);
// Нам нужно разделить данный Run на 2 части
var RightRun = Run.Split2(Run.State.ContentPos);
oContent.Internal_Content_Add(StartPos + 1, RightRun, false);
oContent.CurPos = StartPos;
oContent.Load_FromMenu(Item.Menu, this.Paragraph);
oContent.CurPos = StartPos + 2; // позиция RightRun
RightRun.Cursor_MoveToStartPos();
}
oContent.Content.Correct_Content();
// Корректируем данный контент
oContent.Correct_Content(true);
};
ParaMath.prototype.Remove = function(Direction, bOnAddText)
......
......@@ -564,7 +564,8 @@ ParaRun.prototype.Remove_FromContent = function(Pos, Count, UpdatePosition)
ContentPos.Data[Depth] = Math.max( 0 , Pos );
}
this.Paragraph.SpellChecker.Update_OnRemove( this, Pos, Count );
if(null !== this.Paragraph)
this.Paragraph.SpellChecker.Update_OnRemove( this, Pos, Count );
// Обновляем позиции меток совместного редактирования
this.CollaborativeMarks.Update_OnRemove( Pos, Count );
......
......@@ -7445,7 +7445,9 @@ function Binary_DocumentTableReader(doc, oReadResult, openParams, stream, bAllow
res = this.bcr.Read1(length, function(t, l){
return oThis.boMathr.ReadMathArg(t,l,oMath.Root, oParStruct);
});
});
oMath.Root.Correct_Content(true);
}
else if (c_oSerParType.Hyperlink == type) {
var oHyperlinkObj = {Link: null, Anchor: null, Tooltip: null, History: null, DocLocation: null, TgtFrame: null};
......@@ -8336,8 +8338,6 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -8644,8 +8644,6 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -8709,8 +8707,6 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -8797,8 +8793,6 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -8965,8 +8959,6 @@ function Binary_oMathReader(stream)
else if (c_oSer_OMathContentType.Element === type)
{
var lColumn = props.counter;
if (arrContent[lColumn] && length == 0)
arrContent[lColumn].fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,arrContent[lColumn]);
});
......@@ -9072,8 +9064,6 @@ function Binary_oMathReader(stream)
else if (c_oSer_OMathContentType.Element === type)
{
var lRow = props.counter;
if (arrContent[lRow] && length == 0)
arrContent[lRow].fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,arrContent[lRow]);
});
......@@ -9166,16 +9156,12 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Den === type)
{
if (oElemDen.content && length == 0)
oElemDen.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oElemDen.content);
});
}
else if (c_oSer_OMathContentType.Num === type)
{
if (oElemNum.content && length == 0)
oElemNum.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oElemNum.content);
});
......@@ -9221,16 +9207,12 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
}
else if (c_oSer_OMathContentType.FName === type)
{
if (oName.content && length == 0)
oName.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oName.content);
});
......@@ -9281,8 +9263,6 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -9407,16 +9387,12 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
}
else if (c_oSer_OMathContentType.Lim === type)
{
if (oLim.content && length == 0)
oLim.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oLim.content);
});
......@@ -9457,16 +9433,12 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content .fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content );
});
}
else if (c_oSer_OMathContentType.Lim === type)
{
if (oLim.content && length == 0)
oLim.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oLim.content);
});
......@@ -9710,8 +9682,6 @@ function Binary_oMathReader(stream)
var lRow = oMatrix.row;
var lColumn = oMatrix.column;
if (arrContent[lRow][lColumn] && length == 0)
arrContent[lRow][lColumn].fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,arrContent[lRow][lColumn]);
});
......@@ -9864,24 +9834,18 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Sub === type)
{
if (oSub.content && length == 0)
oSub.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oSub.content);
});
}
else if (c_oSer_OMathContentType.Sup === type)
{
if (oSup.content && length == 0)
oSup.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oSup.content);
});
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -9989,6 +9953,8 @@ function Binary_oMathReader(stream)
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oMath.Root,oParStruct);
});
oMath.Root.Correct_Content(true);
}
else if (c_oSer_OMathContentType.OMathParaPr === type)
{
......@@ -10042,8 +10008,6 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -10143,19 +10107,12 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Deg === type)
{
if (oDeg.content && length == 0 && props.degHide !== true)
oDeg.content.fillPlaceholders();
if (props.degHide == true)
oRad.content.Iterator = null;
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oDeg.content);
});
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -10299,24 +10256,18 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Sub === type)
{
if (oSub.content && length == 0)
oSub.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oSub.content);
});
}
else if (c_oSer_OMathContentType.Sup === type)
{
if (oSup.content && length == 0)
oSup.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oSup.content);
});
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -10357,16 +10308,12 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Sub === type)
{
if (oSub.content && length == 0)
oSub.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oSub.content);
});
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -10419,8 +10366,6 @@ function Binary_oMathReader(stream)
oContent.content = oSSubSup.getBase();
}
if (oSub.content && length == 0)
oSub.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oSub.content);
});
......@@ -10438,8 +10383,6 @@ function Binary_oMathReader(stream)
oContent.content = oSSubSup.getBase();
}
if (oSup.content && length == 0)
oSup.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oSup.content);
});
......@@ -10457,8 +10400,6 @@ function Binary_oMathReader(stream)
oContent.content = oSSubSup.getBase();
}
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......@@ -10505,16 +10446,12 @@ function Binary_oMathReader(stream)
}
else if (c_oSer_OMathContentType.Sup === type)
{
if (oSup.conten && length == 0)
oSup.conten.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oSup.conten);
});
}
else if (c_oSer_OMathContentType.Element === type)
{
if (oContent.content && length == 0)
oContent.content.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oContent.content);
});
......
......@@ -1267,11 +1267,6 @@ CMathContent.prototype =
return result;
},
setPlaceholderAfterRemove: function() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
{
if(this.content.length == 1 && !this.bRoot )//только CEmpty
this.fillPlaceholders();
},
setCtrPrp: function()
{
......@@ -1509,7 +1504,6 @@ CMathContent.prototype =
else
startPos = endPos = this.CurPos;
var bEqual = startPos == endPos,
bNotSelectComp = bEqual ? this.content[startPos].Type === para_Math_Composition && this.content[startPos].IsSelectEmpty() : false;
......@@ -2916,7 +2910,6 @@ CMathContent.prototype =
case 18: props = {ctrPrp: new CTextPr(), type:SQUARE_RADICAL, degHide:true};
var oRadical = new CRadical(props);
this.CreateRadical(oRadical, this, null, null);
oRadical.Iterator = null;
break;
case 19: props = {ctrPrp: new CTextPr(), type:DEGREE_RADICAL};
var oRadical = new CRadical(props);
......@@ -2945,7 +2938,6 @@ CMathContent.prototype =
var oRadical = new CRadical(props);
this.CreateElem(oRadical, oElemNum);
var oElem = oRadical.getBase();
oRadical.Iterator = null;
props = {ctrPrp: new CTextPr(), type:DEGREE_SUPERSCRIPT};
var oDegree = new CDegree(props);
......@@ -2963,7 +2955,6 @@ CMathContent.prototype =
case 23: props = {ctrPrp: new CTextPr(), type:SQUARE_RADICAL, degHide:true};
var oRadical = new CRadical(props);
this.CreateElem(oRadical, this);
oRadical.Iterator = null;
var oElem = oRadical.getBase();
props = {ctrPrp: new CTextPr(), type:DEGREE_SUPERSCRIPT};
......
......@@ -394,7 +394,6 @@ CMathRadicalPr.prototype.Read_FromBinary = function(Reader)
this.degHide = Reader.GetBool();
};
function CRadical(props)
{
CRadical.superclass.constructor.call(this);
......@@ -441,21 +440,29 @@ CRadical.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
this.setDimension(1, 1);
if(this.Iterator !== null)
{
var Item = new CMathBase(true);
Item.setDimension(1, 2);
Item.elements[0][0] = this.Iterator;
Item.elements[0][1] = this.Base;
//Item.addMCToContent(this.Iterator, this.Base);
this.elements[0][0] = Item;
}
else
{
this.elements[0][0] = this.Base;
}
// TODO: IlyaKirillov: Пока убрал данный вариант, потому что у обычного пользователя он
// не встретится с вероятностью 99%, а обработка данного случая в текущей реализации
// приводит к багам в совместном редактировании.
// if(this.Iterator !== null)
// {
// var Item = new CMathBase(true);
// Item.setDimension(1, 2);
// Item.elements[0][0] = this.Iterator;
// Item.elements[0][1] = this.Base;
//
// //Item.addMCToContent(this.Iterator, this.Base);
//
// this.elements[0][0] = Item;
// }
// else
// {
// this.elements[0][0] = this.Base;
// }
this.elements[0][0] = this.Base;
//---------------------
this.RealBase = this.elements[0][0];
}
......
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