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