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];
......
This diff is collapsed.
...@@ -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