Commit 778f1a27 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

1. Поправлен баг с удалением : если degreeSubSup в результате удаления...

1. Поправлен баг с удалением : если degreeSubSup в результате удаления располагается на другой строке, то было падение
2. Поправила Draw_Lines в связи с разбивкой формул на строки (UnderLine, Strikeout, DoubleStrikeout)
3. Поправила баг для итераторов (ArgSize !== 1) неправильно вычислялось смещение для отрисовки Strikeout, DoubleStrikeout

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62104 954022d7-b5bf-4e40-9824-e11837661b57
parent 59828f2a
......@@ -217,7 +217,6 @@ function ParaMath()
this.Y = 0;
this.FirstPage = -1;
//this.Bounds = [];
this.CurPageInfo =
{
......@@ -1472,27 +1471,11 @@ ParaMath.prototype.Draw_Elements = function(PDSE)
};
ParaMath.prototype.GetLinePosition = function(Line)
{
/*var CurLine = Line - this.Root.StartLine;
var Bounds = this.Root.Get_Bounds();
Bounds.Get_LineBound(CurLine);
var Pos = new CMathPosition();
Pos.x = this.Bounds[CurLine].X;
Pos.y = this.Bounds[CurLine].Y + RootLineMetrics.ascent;*/
return this.Root.GetPos(Line);
};
ParaMath.prototype.Draw_Lines = function(PDSL)
{
var CurLine = PDSL.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSL.Range - this.StartRange : PDSL.Range );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if ( EndPos >= 1 )
if(false == this.Root.IsEmptyLine(PDSL.Line, PDSL.Range))
{
// Underline всей формулы
var FirstRPrp = this.GetFirstRPrp();
......@@ -1533,13 +1516,16 @@ ParaMath.prototype.Draw_Lines = function(PDSL)
}
}
var Bound = this.Root.Get_LineBound(PDSL.Line),
Width = Bound.W;
if ( true === FirstRPrp.Underline )
aUnderline.Add( UnderlineY, UnderlineY, X, X + this.Width, LineW, CurColor.r, CurColor.g, CurColor.b );
aUnderline.Add( UnderlineY, UnderlineY, X, X + Width, LineW, CurColor.r, CurColor.g, CurColor.b );
this.Root.Draw_Lines(PDSL);
PDSL.X = this.X + this.Width;
PDSL.X = Bound.X + Width;
}
};
......@@ -1990,16 +1976,8 @@ ParaMath.prototype.Get_Bounds = function()
return {X : 0, Y : 0, W : 0, H : 0, Page : 0};
else
{
//var LinesCount = this.Root.protected_GetLinesCount();
/*if(LinesCount < this.Bounds.length)
this.Bounds.splice(LinesCount, this.Bounds.length - LinesCount);
return this.Bounds[LinesCount - 1];*/
var LinesCount = this.Root.protected_GetLinesCount();
//var PosLine = Math.min(3, LinesCount - 1);
return this.Root.Get_Bounds()[LinesCount - 1];
}
......
......@@ -4008,15 +4008,20 @@ ParaRun.prototype.Draw_Lines = function(PDSL)
var aSpelling = PDSL.Spelling;
var CurTextPr = this.Get_CompiledPr( false );
var StrikeoutY = Y - this.YOffset;
var fontCoeff = 1; // учтем ArgSize
if(this.Type == para_Math_Run)
{
var ArgSize = this.Parent.Compiled_ArgSz;
fontCoeff = MatGetKoeffArgSize(CurTextPr.FontSize, ArgSize.value);
}
switch(CurTextPr.VertAlign)
{
case vertalign_Baseline : StrikeoutY += -CurTextPr.FontSize * g_dKoef_pt_to_mm * 0.27; break;
case vertalign_SubScript : StrikeoutY += -CurTextPr.FontSize * vertalign_Koef_Size * g_dKoef_pt_to_mm * 0.27 - vertalign_Koef_Sub * CurTextPr.FontSize * g_dKoef_pt_to_mm; break;
case vertalign_SuperScript: StrikeoutY += -CurTextPr.FontSize * vertalign_Koef_Size * g_dKoef_pt_to_mm * 0.27 - vertalign_Koef_Super * CurTextPr.FontSize * g_dKoef_pt_to_mm; break;
case vertalign_Baseline : StrikeoutY += -CurTextPr.FontSize * fontCoeff * g_dKoef_pt_to_mm * 0.27; break;
case vertalign_SubScript : StrikeoutY += -CurTextPr.FontSize * fontCoeff * vertalign_Koef_Size * g_dKoef_pt_to_mm * 0.27 - vertalign_Koef_Sub * CurTextPr.FontSize * fontCoeff * g_dKoef_pt_to_mm; break;
case vertalign_SuperScript: StrikeoutY += -CurTextPr.FontSize * fontCoeff * vertalign_Koef_Size * g_dKoef_pt_to_mm * 0.27 - vertalign_Koef_Super * CurTextPr.FontSize * fontCoeff * g_dKoef_pt_to_mm; break;
}
var UnderlineY = Y + UndOff - this.YOffset;
......@@ -8635,6 +8640,16 @@ ParaRun.prototype.Math_Is_End = function(_CurLine, _CurRange)
return EndPos == this.Content.length;
};
ParaRun.prototype.IsEmptyLine = function(_CurLine, _CurRange)
{
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);
return StartPos == EndPos;
};
ParaRun.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth)
{
// данная функция используется только для мат объектов, которые на строки не разбиваются
......
......@@ -1429,24 +1429,19 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio
// для каждой новой строки в ParaMath FindStart будет true независимо от того нашли или нет начало селекта на предыдущей строке
// поэтому для контентов разбивающихся на несколько строк сделаем проверку, чтобы не попасть в контенты, которые не относятся к текущей строке
var ContentSelect = this.IsContentSelect(SelectionStartPos, SelectionEndPos, _CurLine, _CurRange);
var ContentSelect = true;
if(SelectionUse == true && SelectionStartPos !== SelectionEndPos)
if(this.bOneLine == false)
{
var Bound = this.Bounds.Get_LineBound(CurLine);
/*var Bound = this.Bounds.Get_LineBound(CurLine);
var ParentBound = this.Parent.Get_LineBound(_CurLine);
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
SelectionDraw.StartY = ParentBound.Y;
SelectionDraw.H = ParentBound.H;*/
ContentSelect = SelectionStartPos >= StartPos && SelectionEndPos <= EndPos;
}
/*if(this.bOneLine)
{
//SelectionDraw.StartY = Bound.Y;
//SelectionDraw.H = Bound.H;
SelectionDraw.StartY = ParentBound.Y;
SelectionDraw.H = ParentBound.H;
}*/
if(SelectionUse == true && SelectionStartPos !== SelectionEndPos)
{
var Bound = this.Bounds.Get_LineBound(CurLine);
SelectionDraw.FindStart = false;
SelectionDraw.W += Bound.W;
......@@ -1454,21 +1449,10 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio
else if(SelectionUse == true && ContentSelect == true)
{
var Item = this.Content[SelectionStartPos];
//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;
var BoundItem = Item.Get_LineBound(_CurLine);
SelectionDraw.StartX = BoundItem.X;
/*if(this.bOneLine)
{
SelectionDraw.StartY = BoundItem.Y;
SelectionDraw.H = BoundItem.H;
}*/
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
......@@ -1478,7 +1462,7 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio
}
};
CMathBase.prototype.IsContentSelect = function(SelectionStartPos, SelectionEndPos, _CurLine, _CurRange)
/*CMathBase.prototype.IsContentSelect = function(SelectionStartPos, SelectionEndPos, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -1494,7 +1478,7 @@ CMathBase.prototype.IsContentSelect = function(SelectionStartPos, SelectionEndPo
}
return ContentSelect;
};
};*/
CMathBase.prototype.Selection_IsEmpty = function()
{
if (true !== this.Selection.Use)
......@@ -1567,8 +1551,11 @@ CMathBase.prototype.Draw_Lines = function(PDSL)
var aStrikeout = PDSL.Strikeout;
var aDStrikeout = PDSL.DStrikeout;
var ArgSize = this.Get_CompiledArgSize();
var fontCoeff = MatGetKoeffArgSize(CtrPrp.FontSize, ArgSize.value);
var X = PDSL.X;
var Y = PDSL.Baseline - CtrPrp.FontSize * g_dKoef_pt_to_mm * 0.27;
var Y = PDSL.Baseline - CtrPrp.FontSize * fontCoeff * g_dKoef_pt_to_mm * 0.27;
var LineW = (CtrPrp.FontSize / 18) * g_dKoef_pt_to_mm;
......@@ -1599,15 +1586,34 @@ CMathBase.prototype.Draw_Lines = function(PDSL)
}
}
var CurLine = PDSL.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSL.Range - this.StartRange : PDSL.Range );
var Bound = this.Bounds.Get_LineBound(CurLine);
if ( true === CtrPrp.DStrikeout )
aDStrikeout.Add( Y, Y, X, X + this.size.width, LineW, CurColor.r, CurColor.g, CurColor.b );
aDStrikeout.Add( Y, Y, X, X + Bound.W, LineW, CurColor.r, CurColor.g, CurColor.b );
else if ( true === CtrPrp.Strikeout )
aStrikeout.Add( Y, Y, X, X + this.size.width, LineW, CurColor.r, CurColor.g, CurColor.b );
aStrikeout.Add( Y, Y, X, X + Bound.W, LineW, CurColor.r, CurColor.g, CurColor.b );
var StartPos, EndPos;
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 = 0; CurPos < this.Content.length; CurPos++ )
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
this.Content[CurPos].Draw_Lines(PDSL);
PDSL.X = this.pos.x + this.ParaMath.X + this.size.width;
PDSL.X = Bound.X + Bound.W;
};
CMathBase.prototype.Make_ShdColor = function(PDSE, CurTextPr)
{
......
......@@ -800,7 +800,7 @@ CDegreeSubSup.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine
this.Bounds.Reset();
}
if(this.bOneLine == false && this.Check_UpdateIter(_CurLine, _CurRange))
if(this.bOneLine == false && this.Need_Iters(_CurLine, _CurRange))
{
this.Content[0].Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
this.Content[1].Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
......@@ -812,6 +812,7 @@ CDegreeSubSup.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine
this.Bounds.UpdateMetrics(CurLine, Bound);
PRS.ContentMetrics.UpdateMetrics(Bound);
this.iters.Bounds.Reset();
this.iters.Bounds.UpdateMetrics(0, this.iters.size);
this.UpdatePRS(PRS, Bound);
......@@ -911,7 +912,7 @@ CDegreeSubSup.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurR
if(this.Pr.type == DEGREE_SubSup) // baseContent, iters
this.baseContent.Recalculate_Range_Width(PRSC, _CurLine, _CurRange);
if(this.Check_UpdateIter(_CurLine, _CurRange))
if(this.Need_Iters(_CurLine, _CurRange))
{
var RangeW2 = PRSC.Range.W;
......@@ -991,29 +992,22 @@ CDegreeSubSup.prototype.Draw_Elements = function(PDSE)
{
this.baseContent.Draw_Elements(PDSE);
if(this.Check_UpdateIter(PDSE.Line, PDSE.Range))
if(this.Need_Iters(PDSE.Line, PDSE.Range))
this.iters.Draw_Elements(PDSE);
};
CDegreeSubSup.prototype.Check_UpdateIter = function(_CurLine, _CurRange)
CDegreeSubSup.prototype.Need_Iters = function(_CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
return (this.Pr.type == DEGREE_SubSup && this.baseContent.Math_Is_End(_CurLine, _CurRange)) || (CurLine == 0 && CurRange == 0 && this.Pr.type == DEGREE_PreSubSup);
};
CDegreeSubSup.prototype.IsContentSelect = function(SelectionStartPos, SelectionEndPos, _CurLine, _CurRange)
CDegreeSubSup.prototype.protected_GetRangeEndPos = function(CurLine, CurRange)
{
var ContentSelect = true;
var _CurLine = CurLine + this.StartLine;
var _CurRange = ( 0 === CurLine ? CurRange + this.StartRange : CurRange );
if(this.bOneLine == false)
{
var StartPos = 0,
EndPos = this.Check_UpdateIter(_CurLine, _CurRange) ? 2 : 0;
ContentSelect = SelectionStartPos >= StartPos && SelectionEndPos <= EndPos;
}
return ContentSelect;
return this.Need_Iters(_CurLine, _CurRange) ? 2 : 0;
};
CDegreeSubSup.prototype.Document_UpdateInterfaceState = function(MathProps)
{
......
......@@ -3117,33 +3117,6 @@ CMathContent.prototype.Recalculate_CurPos = function(_X, _Y, CurrentRun, _CurRan
return this.Content[_EndPos].Recalculate_CurPos(_X, _Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
};
CMathContent.prototype.n_Recalculate_CurPos = function(_X, _Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var X = _X,
Y = _Y;
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var bCurr = false;
for ( var CurPos = StartPos; CurPos <= EndPos && bCurr !== true; CurPos++ )
{
bCurr = CurrentRun == true && this.CurPos == CurPos;
if(para_Math_Composition == this.Content[CurPos].Type && bCurr !== true)
_X += this.Content[CurPos].size.width;
else
{
var Res = this.Content[CurPos].Recalculate_CurPos(_X, _Y, bCurr, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
_X = Res.X;
}
}
return Res;
};
CMathContent.prototype.Get_CurrentParaPos = function()
{
if ( this.CurPos >= 0 && this.CurPos < this.Content.length )
......@@ -3663,17 +3636,24 @@ CMathContent.prototype.Draw_HighLights = function(PDSH, bAll)
};
CMathContent.prototype.Draw_Lines = function(PDSL)
{
var lng = this.Content.length;
var CurLine = PDSL.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSL.Range - this.StartRange : PDSL.Range );
var X = PDSL.X = this.pos.x + this.ParaMath.X,
Y = PDSL.Baseline = this.pos.y + this.ParaMath.Y + this.size.ascent;
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var Bound = this.Get_LineBound(PDSL.Line);
var Baseline = Bound.Y + Bound.Asc;
for ( var CurPos = 0; CurPos < lng; CurPos++ )
PDSL.Baseline = Baseline;
PDSL.X = Bound.X;
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
this.Content[CurPos].Draw_Lines(PDSL);
PDSL.Baseline = Y;
PDSL.Baseline = Baseline;
}
};
CMathContent.prototype.Selection_Remove = function()
{
......@@ -4104,6 +4084,21 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
};
CMathContent.prototype.IsEmptyLine = function(_CurLine, _CurRange)
{
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 bEmpty = false;
if(StartPos == EndPos)
bEmpty = this.Content[StartPos].IsEmptyLine(_CurLine, _CurRange);
return bEmpty;
};
CMathContent.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
var RangeW = PRSC.Range.W;
......
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