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

Поправила баг : некорректная работа с формулой, которая может разбиваться на...

Поправила баг : некорректная работа с формулой, которая может разбиваться на строки(мат ф-ии), при добавлении в контент формулы, которая не бьется на строки

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61466 954022d7-b5bf-4e40-9824-e11837661b57
parent 02666472
...@@ -24,7 +24,10 @@ function CMathBase(bInside) ...@@ -24,7 +24,10 @@ function CMathBase(bInside)
this.nCol = 0; this.nCol = 0;
this.bInside = bInside === true; this.bInside = bInside === true;
this.bMath_OneLine = true;
this.bOneLine = true;
this.bCanBreak = false;
this.NumBreakContent = -1;
this.elements = []; this.elements = [];
this.LinesWidths = []; this.LinesWidths = [];
...@@ -91,6 +94,11 @@ CMathBase.prototype.setDimension = function(countRow, countCol) ...@@ -91,6 +94,11 @@ CMathBase.prototype.setDimension = function(countRow, countCol)
} }
}; };
CMathBase.prototype.NeedBreakContent = function(Number)
{
this.bCanBreak = true;
this.NumBreakContent = Number;
};
///////// RunPrp, CtrPrp ///////// RunPrp, CtrPrp
CMathBase.prototype.setCtrPrp = function(txtPrp) // выставляем ctrPrp на чтение CMathBase.prototype.setCtrPrp = function(txtPrp) // выставляем ctrPrp на чтение
{ {
...@@ -282,71 +290,68 @@ CMathBase.prototype.align = function(pos_x, pos_y) ...@@ -282,71 +290,68 @@ CMathBase.prototype.align = function(pos_x, pos_y)
}; };
CMathBase.prototype.setPosition = function(pos, Line, Range) CMathBase.prototype.setPosition = function(pos, Line, Range)
{ {
this.pos.x = pos.x; if(this.bOneLine)
{
this.pos.x = pos.x;
if(this.bInside === true) if(this.bInside === true)
this.pos.y = pos.y; this.pos.y = pos.y;
else else
this.pos.y = pos.y - this.size.ascent; ///!!!! this.pos.y = pos.y - this.size.ascent; ///!!!!
var maxWH = this.getWidthsHeights(); var maxWH = this.getWidthsHeights();
var Widths = maxWH.widths; var Widths = maxWH.widths;
var Heights = maxWH.heights; var Heights = maxWH.heights;
var h = 0, w = 0; var h = 0, w = 0;
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
{
w = 0;
for(var j = 0; j < this.nCol; j++)
{ {
var NewPos = new CMathPosition(); w = 0;
var al = this.align(i, j); for(var j = 0; j < this.nCol; j++)
{
var NewPos = new CMathPosition();
var al = this.align(i, j);
NewPos.x = this.pos.x + this.GapLeft + al.x + this.dW*j + w; NewPos.x = this.pos.x + this.GapLeft + al.x + this.dW*j + w;
NewPos.y = this.pos.y + al.y + this.dH*i + h; NewPos.y = this.pos.y + al.y + this.dH*i + h;
if(this.elements[i][j].Type == para_Math_Content) // прибавим ascent только для контентов, для вложенных мат объектов не добавляем ! if(this.elements[i][j].Type == para_Math_Content) // прибавим ascent только для контентов, для вложенных мат объектов не добавляем !
NewPos.y += this.elements[i][j].size.ascent; NewPos.y += this.elements[i][j].size.ascent;
this.elements[i][j].setPosition(NewPos, Line, Range); this.elements[i][j].setPosition(NewPos, Line, Range);
w += Widths[j]; w += Widths[j];
}
h += Heights[i];
} }
h += Heights[i];
}
pos.x += this.size.width;
};
CMathBase.prototype.old_setPosition = function(pos)
{
this.pos.x = pos.x;
if(this.bInside === true) pos.x += this.size.width;
this.pos.y = pos.y; }
else else
this.pos.y = pos.y - this.size.ascent; ///!!!! {
var CurLine = Line - this.StartLine;
var CurRange = ( 0 === CurLine ? Range - this.StartRange : Range );
var maxWH = this.getWidthsHeights(); var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var Widths = maxWH.widths; var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
var Heights = maxWH.heights;
var h = 0, w = 0; if(CurLine == 0 && CurRange == 0)
var NewPos = new CMathPosition(); pos.x += this.GapLeft;
for(var i=0; i < this.nRow; i++) this.Content[StartPos].setPosition(pos, Line, Range);
{
w = 0; for(var Pos = StartPos + 1; Pos <= EndPos; Pos++)
for(var j = 0; j < this.nCol; j++)
{ {
var al = this.align(i, j); pos.x += this.dW;
NewPos.x = this.pos.x + this.GapLeft + al.x + this.dW*j + w; this.Content[Pos].setPosition(pos, Line, Range);
NewPos.y = this.pos.y + al.y + this.dH*i + h;
this.elements[i][j].setPosition(NewPos);
w += Widths[j];
} }
h += Heights[i];
var LinesCount = this.protected_GetLinesCount();
if(LinesCount - 1 == CurLine)
pos.x += this.GapRight;
} }
}; };
CMathBase.prototype.draw = function(x, y, pGraphics, PDSE) CMathBase.prototype.draw = function(x, y, pGraphics, PDSE)
{ {
...@@ -375,34 +380,63 @@ CMathBase.prototype.draw = function(x, y, pGraphics, PDSE) ...@@ -375,34 +380,63 @@ CMathBase.prototype.draw = function(x, y, pGraphics, PDSE)
}; };
CMathBase.prototype.Draw_Elements = function(PDSE) CMathBase.prototype.Draw_Elements = function(PDSE)
{ {
var X = PDSE.X; if(this.bOneLine)
{
var X = PDSE.X;
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp()); // для Just-Draw элементов this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp()); // для Just-Draw элементов
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
{
for(var j = 0; j < this.nCol; j++)
{ {
if(this.elements[i][j].IsJustDraw()) // для Just-Draw элементов надо выставить Font for(var j = 0; j < this.nCol; j++)
{ {
var ctrPrp = this.Get_TxtPrControlLetter(); if(this.elements[i][j].IsJustDraw()) // для Just-Draw элементов надо выставить Font
var Font =
{ {
FontSize: ctrPrp.FontSize, var ctrPrp = this.Get_TxtPrControlLetter();
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
PDSE.Graphics.SetFont(Font); var Font =
} {
FontSize: ctrPrp.FontSize,
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
PDSE.Graphics.SetFont(Font);
}
this.elements[i][j].Draw_Elements(PDSE); this.elements[i][j].Draw_Elements(PDSE);
}
} }
PDSE.X = X + this.size.width;
} }
else
{
var CurLine = PDSE.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSE.Range - this.StartRange : PDSE.Range );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
PDSE.X += this.GapLeft;
this.Content[StartPos].Draw_Elements(PDSE);
PDSE.X = X + this.size.width; for (var CurPos = StartPos + 1; 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.GapRight;
}
}
}; };
CMathBase.prototype.remove = function(order) CMathBase.prototype.remove = function(order)
{ {
...@@ -1029,22 +1063,68 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang ...@@ -1029,22 +1063,68 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang
{ {
var WidthVisible; var WidthVisible;
if ( 0 !== PRSA.LettersSkip ) if(this.bOneLine)
{ {
WidthVisible = this.size.width; if ( 0 !== PRSA.LettersSkip )
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.size.width + 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.GapLeft;
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);
PRSA.X += WidthVisible; var LinesCount = this.protected_GetLinesCount();
PRSA.LastW = WidthVisible;
if(LinesCount - 1 == CurLine)
{
PRSA.X += this.GapRight;
}
}
}; };
CMathBase.prototype.Get_Width = function(_CurLine) CMathBase.prototype.Get_Width = function(_CurLine)
{ {
var Width = 0; var Width = 0;
if(this.bMath_OneLine) if(this.bOneLine)
{ {
Width = this.size.width; Width = this.size.width;
} }
...@@ -1063,6 +1143,11 @@ CMathBase.prototype.Get_ParaPosByContentPos = CParagraphContentWithParagraphLike ...@@ -1063,6 +1143,11 @@ CMathBase.prototype.Get_ParaPosByContentPos = CParagraphContentWithParagraphLike
CMathBase.prototype.Set_ParaMath = CMathContent.prototype.Set_ParaMath; CMathBase.prototype.Set_ParaMath = CMathContent.prototype.Set_ParaMath;
CMathBase.prototype.Recalculate_Reset = function(StartRange, StartLine) CMathBase.prototype.Recalculate_Reset = function(StartRange, StartLine)
{ {
this.StartLine = StartLine;
this.StartRange = StartRange;
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);
...@@ -1285,7 +1370,7 @@ CMathBase.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine ...@@ -1285,7 +1370,7 @@ CMathBase.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine
if (nCount <= 0) if (nCount <= 0)
return false; return false;
if(this.bMath_OneLine) if(this.bOneLine)
{ {
var aBounds = []; var aBounds = [];
for (var nIndex = 0; nIndex < nCount; nIndex++) for (var nIndex = 0; nIndex < nCount; nIndex++)
...@@ -1403,36 +1488,88 @@ CMathBase.prototype.Set_ParaContentPos = function(ContentPos, Depth) ...@@ -1403,36 +1488,88 @@ CMathBase.prototype.Set_ParaContentPos = function(ContentPos, Depth)
}; };
CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw) CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{ {
var SelectionStartPos = this.Selection.StartPos; if(this.bOneLine)
var SelectionEndPos = this.Selection.EndPos; {
var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos;
var SelectionUse = this.Selection.Use; var SelectionUse = this.Selection.Use;
if(SelectionUse == true) if(SelectionUse == true)
{
if(SelectionStartPos !== SelectionEndPos)
{
SelectionDraw.FindStart = false;
SelectionDraw.W += this.size.width;
}
else
{
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;
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
}
else if(SelectionDraw.FindStart == true)
{
SelectionDraw.StartX += this.size.width;
}
}
else
{ {
if(SelectionStartPos !== SelectionEndPos) 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 LinesCount = this.protected_GetLinesCount();
var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos;
var SelectionUse = this.Selection.Use;
if(SelectionUse == true && SelectionStartPos !== SelectionEndPos)
{ {
SelectionDraw.FindStart = false; SelectionDraw.FindStart = false;
SelectionDraw.W += this.size.width; SelectionDraw.W += this.LinesWidths[CurLine];
} }
else else
{ {
var Item = this.Content[SelectionStartPos]; if(CurLine == 0)
{
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.GapLeft;
else if(SelectionUse == true)
SelectionDraw.W += this.GapLeft;
}
var PosLine = this.ParaMath.GetLinePosition(_CurLine); this.Content[StartPos].Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
SelectionDraw.StartX = PosLine.x + Item.pos.x; var Len = SelectionUse == true ? Math.min(EndPos, SelectionStartPos) : EndPos;
SelectionDraw.StartY = PosLine.y + Item.pos.y - Item.size.ascent;
SelectionDraw.H = Item.size.height;
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw); for(var Pos = StartPos + 1; Pos <= Len; Pos++)
{
var Item = this.Content[Pos];
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.dW;
else if(SelectionUse == true)
SelectionDraw.W += this.dW;
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
if(SelectionDraw.FindStart == true && LinesCount - 1 == CurLine)
SelectionDraw.StartX += this.GapRight;
} }
} }
else if(SelectionDraw.FindStart == true)
{
SelectionDraw.StartX += this.size.width;
}
}; };
CMathBase.prototype.Selection_IsEmpty = function() CMathBase.prototype.Selection_IsEmpty = function()
{ {
...@@ -1645,63 +1782,119 @@ CMathBase.prototype.GetFirstElement = function() ...@@ -1645,63 +1782,119 @@ CMathBase.prototype.GetFirstElement = function()
}; };
CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{ {
//var ParaRange = PRS.Range;
//var ParaLine = PRS.Line;
var CurLine = PRS.Line - this.StartLine; var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range ); var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
var bMath_OneLine = PRS.bMath_OneLine;
var WordLen = PRS.WordLen; // запоминаем, чтобы внутр мат объекты не увеличили WordLen var WordLen = PRS.WordLen; // запоминаем, чтобы внутр мат объекты не увеличили WordLen
this.bMath_OneLine = true; var bOneLine = PRS.bMath_OneLine;
PRS.bMath_OneLine = true; this.bOneLine = this.bCanBreak == false || PRS.bMath_OneLine == true;
for(var i=0; i < this.nRow; i++) if(this.bOneLine == true)
{ {
for(var j = 0; j < this.nCol; j++) PRS.bMath_OneLine = this.bOneLine;
{
var Item = this.elements[i][j];
if(Item.IsJustDraw()) // для Just-Draw элементов надо выставить Font for(var i=0; i < this.nRow; i++)
{
for(var j = 0; j < this.nCol; j++)
{ {
var ctrPrp = this.Get_TxtPrControlLetter(); var Item = this.elements[i][j];
var Font = if(Item.IsJustDraw()) // для Just-Draw элементов надо выставить Font
{ {
FontSize: ctrPrp.FontSize, var ctrPrp = this.Get_TxtPrControlLetter();
FontFamily: {Name : ctrPrp.FontFamily.Name, Index : ctrPrp.FontFamily.Index},
Italic: false,
Bold: false //ctrPrp.Bold
};
g_oTextMeasurer.SetFont(Font); 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); Item.Measure(g_oTextMeasurer);
}
else
{
if(Item.Type == para_Math_Content)
Item.Recalculate_Reset( PRS.Range, PRS.Line ); // обновим StartLine и StartRange
Item.Recalculate_Range(PRS, ParaPr, Depth);
}
} }
else }
this.recalculateSize(g_oTextMeasurer);
this.Update_WordLen(PRS, WordLen);
}
else
{
this.setDistance();
var Numb = this.NumBreakContent;
var Len = this.Content.length;
var RangeStartPos = this.protected_AddRange(CurLine, CurRange),
RangeEndPos = Len - 1;
if(CurLine == 0 && CurRange == 0)
{
PRS.WordLen += this.GapLeft;
}
for(var Pos = RangeStartPos; Pos < Len; Pos++)
{
var Item = this.Content[Pos];
PRS.bMath_OneLine = true;
var bOneLineContent = Pos !== Numb;
if(bOneLineContent == false)
{ {
// когда мат объект будет разбиваться на строки PRS.Update_CurPos(Pos, Depth);
// var CurLine = PRS.Line - this.StartLine; PRS.bMath_OneLine = false;
// var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
//if ( Item.Type == para_Math_Content && ( 0 === CurLine && 0 === CurRange ) ) // CMathContent для первой строки нужно обновить Lines }
var NeedSetReset = CurLine == 0 && CurRange == 0 || Pos !== RangeStartPos;
if(Item.Type == para_Math_Content && NeedSetReset)
Item.Recalculate_Reset( PRS.Range, PRS.Line ); // обновим StartLine и StartRange
Item.Recalculate_Range(PRS, ParaPr, Depth+1);
if(Item.Type == para_Math_Content) if(bOneLineContent == true)
{
if(true !== PRS.Word)
{
PRS.WordLen = Item.size.width;
PRS.Word = true;
}
else
{ {
Item.Recalculate_Reset( PRS.Range, PRS.Line ); // обновим StartLine и StartRange PRS.WordLen += Item.size.width;
} }
}
Item.Recalculate_Range(PRS, ParaPr, Depth); if(true === PRS.NewRange)
{
RangeEndPos = Numb;
break;
} }
} }
}
this.recalculateSize(g_oTextMeasurer); if(PRS.NewRange == false)
{
PRS.WordLen += this.GapRight;
}
PRS.bMath_OneLine = bMath_OneLine; this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
}
this.Update_WordLen(PRS, WordLen);
PRS.bMath_OneLine = bOneLine;
}; };
CMathBase.prototype.Math_GetWidth = function(_CurLine, _CurRange) CMathBase.prototype.Math_GetWidth = function(_CurLine, _CurRange)
{ {
...@@ -1727,21 +1920,86 @@ CMathBase.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth) ...@@ -1727,21 +1920,86 @@ CMathBase.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth)
}; };
CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange) CMathBase.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, _CurRange)
{ {
if ( PRS.LineAscent < this.size.ascent ) if(this.bOneLine)
PRS.LineAscent = this.size.ascent; {
if ( PRS.LineAscent < this.size.ascent )
PRS.LineAscent = this.size.ascent;
if ( PRS.LineDescent < this.size.height - this.size.ascent ) if ( PRS.LineDescent < this.size.height - this.size.ascent )
PRS.LineDescent = this.size.height - this.size.ascent; PRS.LineDescent = this.size.height - this.size.ascent;
}; }
CMathBase.prototype.Recalculate_Reset = function() else
{ {
//TODO 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);
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
if(CurPos == this.NumBreakContent)
{
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
}
else
{
if ( PRS.LineAscent < Item.size.ascent )
PRS.LineAscent = Item.size.ascent;
if ( PRS.LineDescent < Item.size.height - Item.size.ascent )
PRS.LineDescent = Item.size.height - Item.size.ascent;
}
}
}
}; };
CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange) CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{ {
PRSC.Range.W += this.size.width; if(this.bOneLine)
{
PRSC.Range.W += 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.GapLeft;
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;
}
}
PRSC.Range.W += this.dW*(EndPos - StartPos);
var LinesCount = this.protected_GetLinesCount();
if(LinesCount - 1 == CurLine)
{
PRSC.Range.W += this.GapRight;
}
this.LinesWidths[CurLine] = PRSC.Range.W - RangeW;
}
}; };
CMathBase.prototype.Is_EmptyRange = function() CMathBase.prototype.Is_EmptyRange = function()
{ {
...@@ -1819,317 +2077,3 @@ CMathBasePr.prototype.Set_FromObject = function(Obj){}; ...@@ -1819,317 +2077,3 @@ CMathBasePr.prototype.Set_FromObject = function(Obj){};
CMathBasePr.prototype.Copy = function(){return new CMathBasePr();}; CMathBasePr.prototype.Copy = function(){return new CMathBasePr();};
CMathBasePr.prototype.Write_ToBinary = function(Writer){}; CMathBasePr.prototype.Write_ToBinary = function(Writer){};
CMathBasePr.prototype.Read_FromBinary = function(Reader){}; CMathBasePr.prototype.Read_FromBinary = function(Reader){};
function CMathBase_2()
{
CMathBase_2.superclass.constructor.call(this);
this.NumberBreak = -1;
}
Asc.extendClass(CMathBase_2, CMathBase);
CMathBase_2.prototype.Set_NumberBreakContent = function(Numb)
{
this.NumberBreak = Numb;
};
CMathBase_2.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
this.setDistance();
if(PRS.bMath_OneLine == false)
{
this.bMath_OneLine = false;
var CurLine = PRS.Line - this.StartLine;
var CurRange = (0 === CurLine ? PRS.Range - this.StartRange : PRS.Range);
var Numb = this.NumberBreak;
var RangeStartPos = this.protected_AddRange(CurLine, CurRange),
RangeEndPos = 0;
if(CurLine == 0 && CurRange == 0)
{
this.Recalculate_Range_OneLineContents(0, Numb, PRS, ParaPr, Depth);
this.Content[Numb].Recalculate_Reset(PRS.Range, PRS.Line);
PRS.WordLen += this.GapLeft;
}
PRS.Update_CurPos(Numb, Depth);
PRS.bMath_OneLine = false;
this.Content[Numb].Recalculate_Range(PRS, ParaPr, Depth+1);
if(true === PRS.NewRange)
{
RangeEndPos = Numb;
}
else
{
var Len = this.Content.length;
this.Recalculate_Range_OneLineContents(Numb+1, Len, PRS, ParaPr, Depth);
RangeEndPos = Len - 1;
PRS.WordLen += this.GapRight;
}
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
PRS.bMath_OneLine = false;
}
else
{
CMathBase_2.superclass.Recalculate_Range.call(this, PRS, ParaPr, Depth);
}
};
CMathBase_2.prototype.Recalculate_Range_OneLineContents = function(FirstPos, EndPos, PRS, ParaPr, Depth)
{
var WordLen = PRS.WordLen;
var Word = PRS.Word;
PRS.bMath_OneLine = true;
for(var Pos = FirstPos; Pos < EndPos; Pos++)
{
var Item = this.Content[Pos];
if(Item.Type == para_Math_Content)
Item.Recalculate_Reset( PRS.Range, PRS.Line ); // обновим StartLine и StartRange
Item.Recalculate_Range(PRS, ParaPr, Depth);
if(true !== PRS.Word)
{
WordLen = Item.size.width;
Word = true;
}
else
{
WordLen += Item.size.width;
}
}
PRS.WordLen = WordLen + (EndPos - FirstPos)*this.dW;
PRS.Word = Word;
};
CMathBase_2.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _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);
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
var Item = this.Content[CurPos];
if(CurPos == this.NumberBreak)
{
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
}
else
{
if ( PRS.LineAscent < Item.size.ascent )
PRS.LineAscent = Item.size.ascent;
if ( PRS.LineDescent < Item.size.height - Item.size.ascent )
PRS.LineDescent = Item.size.height - Item.size.ascent;
}
}
};
CMathBase_2.prototype.Recalculate_Reset = function(StartRange, StartLine)
{
this.StartLine = StartLine;
this.StartRange = StartRange;
this.protected_ClearLines();
for (var nPos = 0, nCount = this.Content.length; nPos < nCount; nPos++)
{
this.Content[nPos].Recalculate_Reset(StartRange, StartLine);
}
};
CMathBase_2.prototype.setPosition = function(pos, Line, Range)
{
var CurLine = Line - this.StartLine;
var CurRange = ( 0 === CurLine ? Range - this.StartRange : Range );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
pos.x += this.GapLeft;
this.Content[StartPos].setPosition(pos, Line, Range);
for(var Pos = StartPos + 1; Pos <= EndPos; Pos++)
{
pos.x += this.dW;
this.Content[Pos].setPosition(pos, Line, Range);
}
var LinesCount = this.protected_GetLinesCount();
if(LinesCount - 1 == CurLine)
pos.x += this.GapRight;
};
CMathBase_2.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRange, _CurPage)
{
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.GapLeft;
var WidthVisible;
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
var Item = this.Content[CurPos];
if(CurPos == this.NumberBreak)
{
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 LinesCount = this.protected_GetLinesCount();
if(LinesCount - 1 == CurLine)
{
PRSA.X += this.GapRight;
}
};
CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _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 RangeW = PRSC.Range.W;
if(CurLine == 0 && CurRange == 0)
PRSC.Range.W += this.GapLeft;
for ( var CurPos = StartPos; CurPos <= EndPos; CurPos++ )
{
var Item = this.Content[CurPos];
if(CurPos == this.NumberBreak)
{
Item.Recalculate_Range_Width( PRSC, _CurLine, _CurRange );
}
else
{
PRSC.Range.W += Item.size.width;
}
}
PRSC.Range.W += this.dW*(EndPos - StartPos);
var LinesCount = this.protected_GetLinesCount();
if(LinesCount - 1 == CurLine)
{
PRSC.Range.W += this.GapRight;
}
this.LinesWidths[CurLine] = PRSC.Range.W - RangeW;
};
CMathBase_2.prototype.Draw_Elements = function(PDSE)
{
var CurLine = PDSE.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PDSE.Range - this.StartRange : PDSE.Range );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
PDSE.X += this.GapLeft;
this.Content[StartPos].Draw_Elements(PDSE);
for (var CurPos = StartPos + 1; 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.GapRight;
}
};
CMathBase_2.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{
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 LinesCount = this.protected_GetLinesCount();
var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos;
var SelectionUse = this.Selection.Use;
if(SelectionUse == true && SelectionStartPos !== SelectionEndPos)
{
SelectionDraw.FindStart = false;
SelectionDraw.W += this.LinesWidths[CurLine];
}
else
{
if(CurLine == 0)
{
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.GapLeft;
else if(SelectionUse == true)
SelectionDraw.W += this.GapLeft;
}
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 Item = this.Content[Pos];
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.dW;
else if(SelectionUse == true)
SelectionDraw.W += this.dW;
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
if(SelectionDraw.FindStart == true && LinesCount - 1 == CurLine)
SelectionDraw.StartX += this.GapRight;
}
};
\ No newline at end of file
...@@ -206,7 +206,7 @@ function CMathFunc(props) ...@@ -206,7 +206,7 @@ function CMathFunc(props)
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
Asc.extendClass(CMathFunc, CMathBase_2); Asc.extendClass(CMathFunc, CMathBase);
CMathFunc.prototype.ClassType = historyitem_type_mathFunc; CMathFunc.prototype.ClassType = historyitem_type_mathFunc;
CMathFunc.prototype.kind = MATH_FUNCTION; CMathFunc.prototype.kind = MATH_FUNCTION;
...@@ -218,7 +218,7 @@ CMathFunc.prototype.init = function(props) ...@@ -218,7 +218,7 @@ CMathFunc.prototype.init = function(props)
this.setProperties(props); this.setProperties(props);
this.fillContent(); this.fillContent();
this.Set_NumberBreakContent(1); this.NeedBreakContent(1);
}; };
CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo) CMathFunc.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI, GapsInfo)
{ {
......
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