Commit 1754c0d3 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

1. Реализовала разбивку N-арных операторов на строки

2. Рефакторинг Recalculate_Range, Get_ParaContentPosByXY, Selection_DrawRange, Get_Width, Draw_Elements, Recalculate_Range_Spaces (в классе CMathBase)
3. Поправила баг с высотой рамки : не учитывалась высота начальной/конечной скобки, в случае когда delimiters разбивается на строки
4. Поправлен баг 29085 (при совместном редактировании не создавалось поле CMathPosition)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61868 954022d7-b5bf-4e40-9824-e11837661b57
parent 4ee96381
......@@ -939,6 +939,7 @@ ParaMath.prototype.Recalculate_Set_RangeEndPos = function(PRS, PRP, Depth)
};
ParaMath.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
{
PRS.ContentMetrics = new CMathBoundsMeasures();
this.Root.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
};
ParaMath.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
......@@ -1497,8 +1498,12 @@ ParaMath.prototype.Draw_Elements = function(PDSE)
/*PDSE.Graphics.p_color(255,0,0, 255);
PDSE.Graphics.drawHorLine(0, PDSE.Y - this.Ascent, PDSE.X - 30, PDSE.X + this.Width + 30 , 1);*/
var X = PDSE.X;
this.Root.Draw_Elements(PDSE);
PDSE.X = X + this.Root.Get_LineBound(PDSE.Line).W;
/*PDSE.Graphics.p_color(255,0,0, 255);
PDSE.Graphics.drawHorLine(0, PDSE.Y - this.Ascent + this.Height, PDSE.X - 30, PDSE.X + this.Width + 30 , 1);*/
};
......@@ -1877,7 +1882,7 @@ ParaMath.prototype.Get_ContentSelection = function()
var LinesCount = oContent.protected_GetLinesCount();
return Bounds[LinesCount - 1];
return Bounds[0];
};
ParaMath.prototype.Recalc_RunsCompiledPr = function()
......@@ -2031,7 +2036,9 @@ ParaMath.prototype.Get_Bounds = function()
var LinesCount = this.Root.protected_GetLinesCount();
return this.Root.Get_Bounds()[LinesCount - 1];
var PosLine = Math.min(3, LinesCount - 1);
return this.Root.Get_Bounds()[PosLine];
}
};
......
......@@ -8032,6 +8032,7 @@ ParaRun.prototype.Read_FromBinary2 = function(Reader)
{
this.MathPrp = new CMPrp();
this.size = new CMathSize();
this.pos = new CMathPosition();
}
if(undefined !== editor && true === editor.isDocumentEditor)
......
......@@ -472,6 +472,8 @@ CAccent.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
var width = this.size.width - this.GapLeft - this.GapRight;
var oBase = this.Content[0];
......
......@@ -297,6 +297,8 @@ CMathBase.prototype.align = function(pos_x, pos_y)
};
CMathBase.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
if(this.bOneLine)
{
this.pos.x = pos.x;
......@@ -306,9 +308,6 @@ CMathBase.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
else
this.pos.y = pos.y - this.size.ascent; ///!!!!
this.Bounds.SetPos(0, pos, PRSA);
this.Bounds.SetPage(0, Page);
var maxWH = this.getWidthsHeights();
var Widths = maxWH.widths;
var Heights = maxWH.heights;
......@@ -336,16 +335,12 @@ CMathBase.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
}
pos.x += this.size.width;
}
else
{
var CurLine = Line - this.StartLine;
var CurRange = ( 0 === CurLine ? Range - this.StartRange : Range );
this.Bounds.SetPos(CurLine, pos, PRSA);
this.Bounds.SetPage(CurLine, Page);
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
......@@ -360,13 +355,20 @@ CMathBase.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
this.Content[Pos].setPosition(pos, PRSA, Line, Range, Page);
}
var LinesCount = this.protected_GetLinesCount();
var Len = this.Content.length;
if(LinesCount - 1 == CurLine)
if(EndPos == Len - 1 && this.Content[EndPos].Math_Is_End( Line, Range))
pos.x += this.BrGapRight;
}
};
CMathBase.prototype.UpdatePosBound = function(pos, PRSA, Line, Range, Page)
{
var CurLine = Line - this.StartLine;
this.Bounds.SetPos(CurLine, pos, PRSA);
this.Bounds.SetPage(CurLine, Page);
};
CMathBase.prototype.draw = function(x, y, pGraphics, PDSE)
{
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp()); // для Just-Draw элементов
......@@ -433,23 +435,10 @@ CMathBase.prototype.Draw_Elements = function(PDSE)
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
PDSE.X += this.BrGapLeft;
this.Content[StartPos].Draw_Elements(PDSE);
for (var CurPos = StartPos + 1; CurPos <= EndPos; CurPos++ )
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
PDSE.X += this.dW;
this.Content[CurPos].Draw_Elements(PDSE);
}
var LinesCount = this.protected_GetLinesCount();
if(LinesCount - 1 == CurLine)
{
PDSE.X += this.BrGapRight;
}
}
};
CMathBase.prototype.remove = function(order)
......@@ -1080,87 +1069,26 @@ CMathBase.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos, D
};
CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRange, _CurPage)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var WidthVisible;
if(this.bOneLine)
if ( 0 !== PRSA.LettersSkip )
{
if ( 0 !== PRSA.LettersSkip )
{
WidthVisible = this.size.width;
PRSA.LettersSkip--;
}
else
WidthVisible = this.size.width + PRSA.JustifyWord;
PRSA.X += WidthVisible;
PRSA.LastW = WidthVisible;
WidthVisible = this.Bounds.GetWidth(CurLine);
PRSA.LettersSkip--;
}
else
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
PRSA.X += this.BrGapLeft;
WidthVisible = this.Bounds.GetWidth(CurLine) + PRSA.JustifyWord;
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
var Item = this.Content[CurPos];
if(CurPos == this.NumBreakContent)
{
Item.Recalculate_Range_Spaces( PRSA, _CurLine, _CurRange, _CurPage );
}
else
{
if ( 0 !== PRSA.LettersSkip )
{
WidthVisible = Item.size.width;
PRSA.LettersSkip--;
}
else
WidthVisible = Item.size.width + PRSA.JustifyWord;
PRSA.LastW = WidthVisible;
PRSA.X += WidthVisible;
}
}
PRSA.X += this.dW*(EndPos - StartPos);
var Len = this.Content.length;
// Здесь проверяем не на колво строк, т.к. на данном этапе еще идет вычисление строк, а на конец контента !
if(EndPos == Len - 1)
{
var EndBrContentEnd = this.NumBreakContent == EndPos && this.Content[EndPos].Math_Is_End( _CurLine, _CurRange),
NotBrContent = this.NumBreakContent !== EndPos;
if(EndBrContentEnd || NotBrContent)
PRSA.X += this.BrGapRight;
}
}
PRSA.X += WidthVisible;
PRSA.LastW = WidthVisible;
};
CMathBase.prototype.Get_Width = function(_CurLine)
{
var Width = 0;
if(this.bOneLine)
{
Width = this.size.width;
}
else
{
var CurLine = _CurLine - this.StartLine;
Width = this.Bounds.GetWidth(CurLine);
//Width = this.LineMetrics.GetWidth(CurLine);
}
return Width;
var CurLine = _CurLine - this.StartLine;
return this.Bounds.GetWidth(CurLine);
};
CMathBase.prototype.Set_Paragraph = CParagraphContentWithParagraphLikeContent.prototype.Set_Paragraph;
CMathBase.prototype.Get_ElementByPos = CParagraphContentWithParagraphLikeContent.prototype.Get_ElementByPos;
......@@ -1174,10 +1102,10 @@ CMathBase.prototype.Recalculate_Reset = function(StartRange, StartLine)
this.protected_ClearLines();
for (var nPos = 0, nCount = this.Content.length; nPos < nCount; nPos++)
/*for (var nPos = 0, nCount = this.Content.length; nPos < nCount; nPos++)
{
this.Content[nPos].Recalculate_Reset(StartRange, StartLine);
}
}*/
};
CMathBase.prototype.Fill_LogicalContent = function(nCount)
{
......@@ -1252,7 +1180,7 @@ CMathBase.prototype.Read_FromBinary2 = function( Reader )
this.CtrPrp.Read_FromBinary(Reader);
this.fillContent();
}
};
CMathBase.prototype.Get_Id = function()
{
return this.Id;
......@@ -1396,92 +1324,69 @@ CMathBase.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine
if (nCount <= 0)
return false;
if(this.bOneLine)
var aBounds = [];
for (var nIndex = 0; nIndex < nCount; nIndex++)
{
var aBounds = [];
for (var nIndex = 0; nIndex < nCount; nIndex++)
{
var oBounds = this.Content[nIndex].Get_LineBound(_CurLine);
if (oBounds.W > 0.001 && oBounds.H > 0.001)
aBounds.push(oBounds);
else
aBounds.push(null);
}
var oBounds = this.Content[nIndex].Get_LineBound(_CurLine);
if (oBounds.W > 0.001 && oBounds.H > 0.001)
aBounds.push(oBounds);
else
aBounds.push(null);
}
var X = SearchPos.X;
var Y = SearchPos.Y;
var X = SearchPos.X;
var Y = SearchPos.Y;
var dDiff = null;
var dDiff = null;
var nCurIndex = 0;
var nFindIndex = 0;
var nCurIndex = 0;
var nFindIndex = 0;
//var PosLine = this.ParaMath.GetLinePosition(_CurLine);
while (nCurIndex < nCount)
{
var oBounds = aBounds[nCurIndex];
while (nCurIndex < nCount)
if (null !== oBounds)
{
var oBounds = aBounds[nCurIndex];
var _X = oBounds.X,
_Y = oBounds.Y;
if (null !== oBounds)
if (_X <= X && X <= _X + oBounds.W && _Y <= Y && Y <= _Y + oBounds.H)
{
var _X = oBounds.X,
_Y = oBounds.Y;
nFindIndex = nCurIndex;
break;
}
else
{
var dCurDiffX = X - (_X + oBounds.W / 2);
var dCurDiffY = Y - (_Y + oBounds.H / 2);
var dCurDiff = dCurDiffX * dCurDiffX + dCurDiffY * dCurDiffY;
if (_X <= X && X <= _X + oBounds.W && _Y <= Y && Y <= _Y + oBounds.H)
if (null === dDiff || dDiff > dCurDiff)
{
dDiff = dCurDiff;
nFindIndex = nCurIndex;
break;
}
else
{
var dCurDiffX = X - (_X + oBounds.W / 2);
var dCurDiffY = Y - (_Y + oBounds.H / 2);
var dCurDiff = dCurDiffX * dCurDiffX + dCurDiffY * dCurDiffY;
if (null === dDiff || dDiff > dCurDiff)
{
dDiff = dCurDiff;
nFindIndex = nCurIndex;
}
}
}
nCurIndex++;
}
if (null === aBounds[nFindIndex])
return false;
SearchPos.CurX = aBounds[nFindIndex].X;
SearchPos.CurY = aBounds[nFindIndex].Y;
bResult = this.Content[nFindIndex].Get_ParaContentPosByXY(SearchPos, Depth + 1, _CurLine, _CurRange, StepEnd);
if(true === bResult)
{
SearchPos.Pos.Update2(nFindIndex, Depth);
}
nCurIndex++;
}
else
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if (null === aBounds[nFindIndex])
return false;
for (var Pos = StartPos; Pos <= EndPos; Pos++)
{
if ( false === SearchPos.InText )
SearchPos.InTextPos.Update2( Pos, Depth );
SearchPos.CurX = aBounds[nFindIndex].X;
SearchPos.CurY = aBounds[nFindIndex].Y;
if(true == this.Content[Pos].Get_ParaContentPosByXY(SearchPos, Depth + 1, _CurLine, _CurRange, StepEnd))
{
SearchPos.Pos.Update2( Pos, Depth );
bResult = true;
}
}
bResult = this.Content[nFindIndex].Get_ParaContentPosByXY(SearchPos, Depth + 1, _CurLine, _CurRange, StepEnd);
if(true === bResult)
{
SearchPos.Pos.Update2(nFindIndex, Depth);
}
return bResult;
};
CMathBase.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos)
......@@ -1514,90 +1419,72 @@ CMathBase.prototype.Set_ParaContentPos = function(ContentPos, Depth)
};
CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{
if(this.bOneLine)
{
var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos;
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var SelectionUse = this.Selection.Use;
var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos;
if(SelectionUse == true)
{
if(SelectionStartPos !== SelectionEndPos)
{
SelectionDraw.FindStart = false;
SelectionDraw.W += this.size.width;
}
else
{
var Item = this.Content[SelectionStartPos];
var SelectionUse = this.Selection.Use;
// для каждой новой строки в ParaMath FindStart будет true независимо от того нашли или нет начало селекта на предыдущей строке
// поэтому для контентов разбивающихся на несколько строк сделаем проверку, чтобы не попасть в контенты, которые не относятся к текущей строке
var PosLine = this.ParaMath.GetLinePosition(_CurLine);
var ContentSelect = true;
SelectionDraw.StartX = PosLine.x + Item.pos.x;
SelectionDraw.StartY = PosLine.y + Item.pos.y - Item.size.ascent;
SelectionDraw.H = Item.size.height;
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
}
else if(SelectionDraw.FindStart == true)
{
SelectionDraw.StartX += this.size.width;
}
}
else
if(this.bOneLine == false)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
ContentSelect = SelectionStartPos >= StartPos && SelectionEndPos <= EndPos;
}
if(SelectionUse == true && SelectionStartPos !== SelectionEndPos)
{
var Bound = this.Bounds.Get_LineBound(CurLine);
/*var Bound = this.Bounds.Get_LineBound(CurLine);
var ParentBound = this.Parent.Get_LineBound(_CurLine);
var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos;
var SelectionUse = this.Selection.Use;
SelectionDraw.StartY = ParentBound.Y;
SelectionDraw.H = ParentBound.H;*/
if(SelectionUse == true && SelectionStartPos !== SelectionEndPos)
/*if(this.bOneLine)
{
SelectionDraw.FindStart = false;
SelectionDraw.W += this.Bounds.GetWidth(CurLine);
//SelectionDraw.StartY = Bound.Y;
//SelectionDraw.H = Bound.H;
SelectionDraw.StartY = ParentBound.Y;
SelectionDraw.H = ParentBound.H;
}*/
}
else
{
if(CurLine == 0)
{
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.BrGapLeft;
else if(SelectionUse == true)
SelectionDraw.W += this.BrGapLeft;
}
this.Content[StartPos].Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
var Len = SelectionUse == true ? Math.min(EndPos, SelectionStartPos) : EndPos;
SelectionDraw.FindStart = false;
SelectionDraw.W += Bound.W;
}
else if(SelectionUse == true && ContentSelect == true)
{
var Item = this.Content[SelectionStartPos];
for(var Pos = StartPos + 1; Pos <= Len; Pos++)
{
var Item = this.Content[Pos];
//var PosLine = this.ParaMath.GetLinePosition(_CurLine);
//SelectionDraw.StartX = PosLine.x + Item.pos.x;
//SelectionDraw.StartY = PosLine.y + Item.pos.y - Item.size.ascent;
//SelectionDraw.H = Item.size.height;
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.dW;
else if(SelectionUse == true)
SelectionDraw.W += this.dW;
var BoundItem = Item.Get_LineBound(_CurLine);
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
SelectionDraw.StartX = BoundItem.X;
var LinesCount = this.protected_GetLinesCount();
/*if(this.bOneLine)
{
SelectionDraw.StartY = BoundItem.Y;
SelectionDraw.H = BoundItem.H;
}*/
if(SelectionDraw.FindStart == true && LinesCount - 1 == CurLine)
SelectionDraw.StartX += this.BrGapRight;
}
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
else if(SelectionDraw.FindStart == true)
{
SelectionDraw.StartX += this.Bounds.GetWidth(CurLine);
}
};
CMathBase.prototype.Selection_IsEmpty = function()
{
......@@ -1827,25 +1714,11 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if(Item.IsJustDraw()) // для Just-Draw элементов надо выставить Font
{
var ctrPrp = this.Get_TxtPrControlLetter();
var Font =
{
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
g_oTextMeasurer.SetFont(Font);
Item.Measure(g_oTextMeasurer);
this.MeasureJustDraw(Item);
}
else
{
if(Item.Type == para_Math_Content)
Item.Recalculate_Reset( PRS.Range, PRS.Line ); // обновим StartLine и StartRange
Item.Recalculate_Reset( PRS.Range, PRS.Line ); // обновим StartLine и StartRange
Item.Recalculate_Range(PRS, ParaPr, Depth);
}
}
......@@ -1883,7 +1756,45 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
var Item = this.Content[Pos];
PRS.bMath_OneLine = true;
var NeedSetReset = CurLine == 0 && CurRange == 0 || Pos !== RangeStartPos;
if(Item.Type == para_Math_Content && NeedSetReset)
Item.Recalculate_Reset(PRS.Range, PRS.Line); // обновим StartLine и StartRange
if(Pos == Numb)
{
PRS.Update_CurPos(Pos, Depth);
PRS.bMath_OneLine = false;
Item.Recalculate_Range(PRS, ParaPr, Depth+1);
if(true === PRS.NewRange)
{
RangeEndPos = Numb;
break;
}
}
else
{
PRS.bMath_OneLine = true;
Item.Recalculate_Range(PRS, ParaPr, Depth+1);
if(true !== PRS.Word)
{
PRS.WordLen = Item.size.width;
PRS.Word = true;
}
else
{
PRS.WordLen += Item.size.width;
}
if(Pos < Len - 1)
PRS.WordLen += this.dW;
}
/*PRS.bMath_OneLine = true;
var bOneLineContent = Pos !== Numb;
......@@ -1916,7 +1827,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
RangeEndPos = Numb;
break;
}
}*/
}
......@@ -1930,6 +1841,22 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
PRS.bMath_OneLine = bOneLine;
};
CMathBase.prototype.MeasureJustDraw = function(Item)
{
var ctrPrp = this.Get_TxtPrControlLetter();
var Font =
{
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
g_oTextMeasurer.SetFont(Font);
Item.Measure(g_oTextMeasurer);
};
CMathBase.prototype.Math_GetWidth = function(_CurLine, _CurRange)
{
return this.size.width;
......@@ -1952,13 +1879,14 @@ CMathBase.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth)
{
this.Recalculate_Range(PRS, ParaPr, Depth);
};
CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
CMathBase.prototype.old_Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
{
if(this.bOneLine)
{
this.UpdateMetrics(PRS, this.size);
this.Bounds.UpdateMetrics(0, this.size);
PRS.ContentMetrics.UpdateMetrics(this.size);
}
else
{
......@@ -1968,7 +1896,6 @@ CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _C
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
......@@ -1985,6 +1912,178 @@ CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _C
}
}
}
};
CMathBase.prototype.Recalculate_LineMetrics_3 = function(PRS, ParaPr, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
if(CurLine == 0 && CurRange == 0)
{
this.Bounds.Reset();
}
var StartPos, EndPos;
if(this.bOneLine)
{
for (var CurPos = 0; CurPos <= this.Content.length - 1; CurPos++)
{
var Item = this.Content[CurPos];
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
}
PRS.ContentMetrics.UpdateMetrics(this.size);
this.Bounds.UpdateMetrics(CurLine, this.size);
if(PRS.LineAscent < this.size.ascent)
PRS.LineAscent = this.size.ascent;
if(PRS.LineDescent < this.size.height - this.size.ascent)
PRS.LineDescent = this.size.height - this.size.ascent;
}
else
{
StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
}
this.Bounds.UpdateMetrics(CurLine, PRS.ContentMetrics);
}
if(this.bOneLine)
{
StartPos = 0;
EndPos = this.Content.length - 1;
}
else
{
StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
}
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
//PRS.ContentMetrics.UpdateMetrics(Size);
}
if(this.bOneLine)
{
PRS.ContentMetrics.UpdateMetrics(this.size);
this.Bounds.UpdateMetrics(CurLine, this.size);
if(PRS.LineAscent < this.size.ascent)
PRS.LineAscent = this.size.ascent;
if(PRS.LineDescent < this.size.height - this.size.ascent)
PRS.LineDescent = this.size.height - this.size.ascent;
}
else
this.Bounds.UpdateMetrics(CurLine, PRS.ContentMetrics);
/*for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
if(CurPos == this.NumBreakContent)
{
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
this.Bounds.UpdateMetrics(CurLine, PRS.ContentMetrics);
}
else
{
this.UpdateMetrics(PRS, Item.size);
this.Bounds.UpdateMetrics(CurLine, Item.size);
}
}*/
};
CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
if(CurLine == 0 && CurRange == 0)
{
this.Bounds.Reset();
}
var StartPos, EndPos;
if(this.bOneLine)
{
for (var CurPos = 0; CurPos <= this.Content.length - 1; CurPos++)
{
var Item = this.Content[CurPos];
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
}
this.Bounds.UpdateMetrics(CurLine, this.size);
PRS.ContentMetrics.UpdateMetrics(this.size);
this.UpdatePRS(PRS, this.size);
/*if(PRS.LineAscent < this.size.ascent)
PRS.LineAscent = this.size.ascent;
if(PRS.LineDescent < this.size.height - this.size.ascent)
PRS.LineDescent = this.size.height - this.size.ascent;*/
}
else
{
StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
var BoundItem = Item.Get_LineBound(_CurLine);
this.Bounds.UpdateMetrics(CurLine, BoundItem);
PRS.ContentMetrics.UpdateMetrics(BoundItem);
this.UpdatePRS(PRS, BoundItem);
/*if(PRS.LineAscent < BoundItem.Asc)
PRS.LineAscent = BoundItem.Asc;
if(PRS.LineDescent < BoundItem.H - BoundItem.Asc)
PRS.LineDescent = BoundItem.H - BoundItem.Asc;*/
}
}
};
CMathBase.prototype.Get_LineBound = function(_CurLine)
{
var CurLine = _CurLine - this.StartLine;
return this.Bounds.Get_LineBound(CurLine);
};
CMathBase.prototype.UpdatePRS = function(PRS, Metric)
{
var MetricAsc = Metric.Type == MATH_SIZE ? Metric.ascent : Metric.Asc;
var MetricDesc = Metric.Type == MATH_SIZE ? Metric.height - Metric.ascent : Metric.H - Metric.Asc;
if(PRS.LineAscent < MetricAsc)
PRS.LineAscent = MetricAsc;
if(PRS.LineDescent < MetricDesc)
PRS.LineDescent = MetricDesc;
};
CMathBase.prototype.UpdateMetrics = function(PRS, Size)
{
......@@ -1998,35 +2097,33 @@ CMathBase.prototype.UpdateMetrics = function(PRS, Size)
};
CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
var RangeW = PRSC.Range.W;
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
if(this.bOneLine)
{
PRSC.Range.W += this.size.width;
for ( var CurPos = 0; CurPos <= this.Content.length - 1; CurPos++ )
{
var Item = this.Content[CurPos];
Item.Recalculate_Range_Width( PRSC, _CurLine, _CurRange );
}
PRSC.Range.W = RangeW + this.size.width;
}
else
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var RangeW = PRSC.Range.W;
if(CurLine == 0 && CurRange == 0)
PRSC.Range.W += this.BrGapLeft;
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
var Item = this.Content[CurPos];
if(CurPos == this.NumBreakContent)
{
Item.Recalculate_Range_Width( PRSC, _CurLine, _CurRange );
}
else
{
PRSC.Range.W += Item.size.width;
}
Item.Recalculate_Range_Width( PRSC, _CurLine, _CurRange );
}
PRSC.Range.W += this.dW*(EndPos - StartPos);
......@@ -2044,9 +2141,9 @@ CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange
if(EndBrContentEnd || NotBrContent)
PRSC.Range.W += this.BrGapRight;
}
this.Bounds.SetWidth(CurLine, PRSC.Range.W - RangeW);
}
this.Bounds.SetWidth(CurLine, PRSC.Range.W - RangeW);
};
CMathBase.prototype.Is_EmptyRange = function()
{
......
......@@ -366,6 +366,8 @@ CBorderBox.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
var NewPos = new CMathPosition();
var Base = this.Content[0];
......
......@@ -48,7 +48,6 @@ function CDegreeBase(props, bInside)
if(props !== null && typeof(props) !== "undefined")
this.init(props);
//CDegreeBase.prototype.init.call(this, props);
}
Asc.extendClass(CDegreeBase, CMathBase);
CDegreeBase.prototype.init = function(props)
......@@ -378,6 +377,8 @@ CDegreeBase.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
else
this.pos.y = pos.y - this.size.ascent;
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
var oBase = this.elements[0][0],
oIter = this.elements[0][1];
......
......@@ -388,6 +388,8 @@ CFraction.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
if(this.Pr.type == SKEWED_FRACTION)
{
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
var Numerator = this.Content[0],
Denominator = this.Content[1];
......
......@@ -3806,6 +3806,14 @@ CMathContent.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selec
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(this.bRoot == false)
{
var Bound = this.Get_LineBound(_CurLine);
SelectionDraw.StartY = Bound.Y;
SelectionDraw.H = Bound.H;
}
for(var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
......
......@@ -473,6 +473,8 @@ CMathMatrix.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
else
this.pos.y = pos.y - this.size.ascent; ///!!!!
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
var maxWH = this.getWidthsHeights();
var Widths = maxWH.widths;
var Heights = maxWH.heights;
......@@ -842,6 +844,8 @@ CEqArray.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
else
this.pos.y = pos.y - this.size.ascent; ///!!!!
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
var maxWH = this.getWidthsHeights();
var Heights = maxWH.heights;
......
......@@ -455,7 +455,237 @@ CNary.prototype.Is_ContentUse = function(MathContent)
return false;
};
CNary.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
this.bOneLine = PRS.bMath_OneLine;
if(this.bOneLine === true)
{
CNary.superclass.Recalculate_Range.call(this, PRS, ParaPr, Depth);
}
else
{
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
this.setDistance();
var RangeStartPos = this.protected_AddRange(CurLine, CurRange),
RangeEndPos = 2;
if(CurLine == 0 && CurRange == 0)
{
PRS.WordLen += this.BrGapLeft;
}
if(CurLine == 0 && CurRange == 0)
{
if(this.Base.IsJustDraw())
{
this.MeasureJustDraw(this.Base);
}
else
{
PRS.bMath_OneLine = true;
this.Base.Recalculate_Range(PRS, ParaPr, Depth);
}
if(true !== PRS.Word)
{
PRS.WordLen = this.Base.size.width;
PRS.Word = true;
}
else
{
PRS.WordLen += this.Base.size.width;
}
PRS.WordLen += this.dW;
this.Arg.Recalculate_Reset(PRS.Range, PRS.Line); // обновим StartLine и StartRange
}
PRS.Update_CurPos(2, Depth); // this.Arg = this.Content[2]
PRS.bMath_OneLine = false;
this.Arg.Recalculate_Range(PRS, ParaPr, Depth+1);
if(PRS.NewRange == false)
{
PRS.WordLen += this.BrGapRight;
}
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
PRS.bMath_OneLine = false;
}
};
CNary.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
if(this.bOneLine == true)
{
CNary.superclass.Recalculate_Range_Width.call(this, PRSC, _CurLine, _CurRange);
}
else
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var RangeW = PRSC.Range.W;
if(CurLine == 0 && CurRange == 0)
{
PRSC.Range.W += this.BrGapLeft;
var RangeW2 = PRSC.Range.W;
if(this.Base.IsJustDraw() == false)
{
this.Content[0].Recalculate_Range_Width(PRSC, _CurLine, _CurRange);
this.Content[1].Recalculate_Range_Width(PRSC, _CurLine, _CurRange);
this.Base.Bounds.SetWidth(CurLine, this.Base.size.width);
}
PRSC.Range.W = RangeW2 + this.Base.size.width + this.dW;
}
this.Arg.Recalculate_Range_Width( PRSC, _CurLine, _CurRange );
if(this.Arg.Math_Is_End( _CurLine, _CurRange))
{
PRSC.Range.W += this.BrGapRight;
}
this.Bounds.SetWidth(CurLine, PRSC.Range.W - RangeW);
}
};
CNary.prototype.Draw_Elements = function(PDSE)
{
var CurLine = PDSE.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSE.Range - this.StartRange : PDSE.Range );
if(CurLine == 0 && CurRange == 0)
{
this.Base.Draw_Elements(PDSE);
}
this.Arg.Draw_Elements(PDSE);
};
CNary.prototype.Recalculate_LineMetrics_2 = function(PRS, ParaPr, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
if(CurLine == 0 && CurRange == 0)
{
this.Bounds.Reset();
if(this.Base.IsJustDraw())
{
PRS.ContentMetrics.UpdateMetrics(this.Base.size);
}
else
{
this.Base.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
}
}
var ParentContentMetric = PRS.ContentMetrics;
PRS.ContentMetrics = new CMathBoundsMeasures();
this.Arg.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
this.Bounds.UpdateMetrics(CurLine, PRS.ContentMetrics);
ParentContentMetric.UpdateMetrics(PRS.ContentMetrics);
PRS.ContentMetrics = ParentContentMetric;
};
CNary.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
{
if(this.bOneLine)
{
CNary.superclass.Recalculate_LineMetrics.call(this, PRS, ParaPr, _CurLine, _CurRange);
}
else
{
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
// т.к. ParaNumbering привязывается к первому текстовому элементы, он может находится в аргументе
// обновляем LineMetrics для Base после того, как обновим метрики для аргумента
this.Arg.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
var BoundArg = this.Arg.Get_LineBound(_CurLine);
this.Bounds.UpdateMetrics(CurLine, BoundArg);
PRS.ContentMetrics.UpdateMetrics(BoundArg);
this.UpdatePRS(PRS, BoundArg);
if(CurLine == 0 && CurRange == 0)
{
this.Bounds.Reset();
if(this.Base.IsJustDraw())
{
this.Bounds.UpdateMetrics(CurLine, this.Base.size);
PRS.ContentMetrics.UpdateMetrics(this.Base.size);
this.UpdatePRS(PRS, this.Base.size);
}
else
{
this.Base.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
this.Content[0].Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
this.Content[1].Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
this.Bounds.UpdateMetrics(CurLine, this.Base.size);
PRS.ContentMetrics.UpdateMetrics(this.Base.size);
this.UpdatePRS(PRS, this.Base.size);
}
}
}
};
CNary.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
if(this.bOneLine)
{
CNary.superclass.setPosition.call(this, pos, PRSA, Line, Range, Page);
}
else
{
var CurLine = Line - this.StartLine;
var CurRange = ( 0 === CurLine ? Range - this.StartRange : Range );
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
if(CurLine == 0 && CurRange == 0)
{
pos.x += this.BrGapLeft;
var PosBase = new CMathPosition();
PosBase.x = pos.x;
PosBase.y = pos.y - this.Base.size.ascent;
this.Base.setPosition(PosBase, PRSA, Line, Range, Page);
pos.x += this.Base.size.width + this.dW;
}
this.Arg.setPosition(pos, PRSA, Line, Range, Page);
if(this.Arg.Math_Is_End(Line, Range))
{
pos.x += this.BrGapRight;
}
}
};
function CNaryUnd(bInside)
{
......
......@@ -3497,6 +3497,8 @@ CDelimiter.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
CDelimiter.superclass.Recalculate_LineMetrics.call(this, PRS, ParaPr, _CurLine, _CurRange);
if(CurLine == 0 && CurRange == 0)
{
var BegHeight = this.begOper.size.height;
......@@ -3508,6 +3510,8 @@ CDelimiter.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _
if ( PRS.LineDescent < BegDescent )
PRS.LineDescent = BegDescent;
PRS.ContentMetrics.UpdateMetrics(this.begOper.size);
}
var bEnd = this.Content[0].Math_Is_End(_CurLine, _CurRange);
......@@ -3523,9 +3527,9 @@ CDelimiter.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _
if ( PRS.LineDescent < EndDescent )
PRS.LineDescent = EndDescent;
}
CDelimiter.superclass.Recalculate_LineMetrics.call(this, PRS, ParaPr, _CurLine, _CurRange);
PRS.ContentMetrics.UpdateMetrics(this.endOper.size);
}
};
CDelimiter.prototype.RecalculateGeneralSize = function(oMeasure, height, ascent) // здесь пересчитываем скобки, общий максимальный размер delimiters
{
......@@ -3659,6 +3663,8 @@ CDelimiter.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
var CurLine = Line - this.StartLine;
var CurRange = ( 0 === CurLine ? Range - this.StartRange : Range );
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
if(this.bOneLine == false)
{
var LinesCount = this.protected_GetLinesCount();
......@@ -3868,6 +3874,8 @@ CCharacter.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
var width = this.size.width - this.GapLeft - this.GapRight;
var alignOp = (width - this.operator.size.width)/2,
......
......@@ -593,6 +593,8 @@ CRadical.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
this.pos.x = pos.x;
this.pos.y = pos.y - this.size.ascent;
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
var PosBase = new CMathPosition(),
PosRadical = new CMathPosition();
......
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