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,6 +290,8 @@ CMathBase.prototype.align = function(pos_x, pos_y) ...@@ -282,6 +290,8 @@ CMathBase.prototype.align = function(pos_x, pos_y)
}; };
CMathBase.prototype.setPosition = function(pos, Line, Range) CMathBase.prototype.setPosition = function(pos, Line, Range)
{ {
if(this.bOneLine)
{
this.pos.x = pos.x; this.pos.x = pos.x;
if(this.bInside === true) if(this.bInside === true)
...@@ -316,37 +326,32 @@ CMathBase.prototype.setPosition = function(pos, Line, Range) ...@@ -316,37 +326,32 @@ CMathBase.prototype.setPosition = function(pos, Line, Range)
} }
pos.x += this.size.width; pos.x += this.size.width;
}
};
CMathBase.prototype.old_setPosition = function(pos)
{
this.pos.x = pos.x;
if(this.bInside === true)
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,6 +380,8 @@ CMathBase.prototype.draw = function(x, y, pGraphics, PDSE) ...@@ -375,6 +380,8 @@ CMathBase.prototype.draw = function(x, y, pGraphics, PDSE)
}; };
CMathBase.prototype.Draw_Elements = function(PDSE) CMathBase.prototype.Draw_Elements = function(PDSE)
{ {
if(this.bOneLine)
{
var X = PDSE.X; var X = PDSE.X;
this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp()); // для Just-Draw элементов this.Make_ShdColor(PDSE, this.Get_CompiledCtrPrp()); // для Just-Draw элементов
...@@ -403,6 +410,33 @@ CMathBase.prototype.Draw_Elements = function(PDSE) ...@@ -403,6 +410,33 @@ CMathBase.prototype.Draw_Elements = function(PDSE)
} }
PDSE.X = X + this.size.width; 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);
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,6 +1063,8 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang ...@@ -1029,6 +1063,8 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang
{ {
var WidthVisible; var WidthVisible;
if(this.bOneLine)
{
if ( 0 !== PRSA.LettersSkip ) if ( 0 !== PRSA.LettersSkip )
{ {
WidthVisible = this.size.width; WidthVisible = this.size.width;
...@@ -1039,12 +1075,56 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang ...@@ -1039,12 +1075,56 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang
PRSA.X += WidthVisible; PRSA.X += WidthVisible;
PRSA.LastW = WidthVisible; PRSA.LastW = WidthVisible;
}
else
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
if(CurLine == 0 && CurRange == 0)
PRSA.X += this.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);
var LinesCount = this.protected_GetLinesCount();
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,6 +1488,8 @@ CMathBase.prototype.Set_ParaContentPos = function(ContentPos, Depth) ...@@ -1403,6 +1488,8 @@ 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 SelectionStartPos = this.Selection.StartPos; var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos; var SelectionEndPos = this.Selection.EndPos;
...@@ -1432,7 +1519,57 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio ...@@ -1432,7 +1519,57 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio
{ {
SelectionDraw.StartX += this.size.width; 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 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;
}
}
}; };
CMathBase.prototype.Selection_IsEmpty = function() CMathBase.prototype.Selection_IsEmpty = function()
{ {
...@@ -1645,17 +1782,16 @@ CMathBase.prototype.GetFirstElement = function() ...@@ -1645,17 +1782,16 @@ 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;
if(this.bOneLine == true)
{
PRS.bMath_OneLine = this.bOneLine;
for(var i=0; i < this.nRow; i++) for(var i=0; i < this.nRow; i++)
{ {
...@@ -1681,15 +1817,8 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -1681,15 +1817,8 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
} }
else else
{ {
// когда мат объект будет разбиваться на строки
// var CurLine = PRS.Line - this.StartLine;
// var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
//if ( Item.Type == para_Math_Content && ( 0 === CurLine && 0 === CurRange ) ) // CMathContent для первой строки нужно обновить Lines
if(Item.Type == para_Math_Content) 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);
} }
...@@ -1698,10 +1827,74 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth) ...@@ -1698,10 +1827,74 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
this.recalculateSize(g_oTextMeasurer); this.recalculateSize(g_oTextMeasurer);
PRS.bMath_OneLine = bMath_OneLine;
this.Update_WordLen(PRS, WordLen); 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);
PRS.bMath_OneLine = false;
}
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(bOneLineContent == true)
{
if(true !== PRS.Word)
{
PRS.WordLen = Item.size.width;
PRS.Word = true;
}
else
{
PRS.WordLen += Item.size.width;
}
}
if(true === PRS.NewRange)
{
RangeEndPos = Numb;
break;
}
}
if(PRS.NewRange == false)
{
PRS.WordLen += this.GapRight;
}
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
}
PRS.bMath_OneLine = bOneLine;
}; };
CMathBase.prototype.Math_GetWidth = function(_CurLine, _CurRange) CMathBase.prototype.Math_GetWidth = function(_CurLine, _CurRange)
{ {
...@@ -1727,196 +1920,18 @@ CMathBase.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth) ...@@ -1727,196 +1920,18 @@ 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(this.bOneLine)
{
if ( PRS.LineAscent < this.size.ascent ) if ( PRS.LineAscent < this.size.ascent )
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);
};
CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{
PRSC.Range.W += this.size.width;
};
CMathBase.prototype.Is_EmptyRange = function()
{
return false;
};
CMathBase.prototype.Get_CurrentParaPos = CMathContent.prototype.Get_CurrentParaPos;
CMathBase.prototype.private_UpdatePosOnAdd = CMathContent.prototype.private_UpdatePosOnAdd;
CMathBase.prototype.private_UpdatePosOnRemove = CMathContent.prototype.private_UpdateOnRemove;
CMathBase.prototype.private_CorrectSelectionPos = CMathContent.prototype.private_CorrectSelectionPos;
CMathBase.prototype.private_CorrectSelectionPos = CMathContent.prototype.private_CorrectSelectionPos;
CMathBase.prototype.private_SetNeedResize = CMathContent.prototype.private_SetNeedResize;
CMathBase.prototype.private_CorrectCurPos = function()
{
if (this.CurPos > this.Content.length - 1)
{
this.CurPos = this.Content.length - 1;
this.Content[this.CurPos].Cursor_MoveToEndPos(false);
}
if (this.CurPos < 0)
{
this.CurPos = this.Content.length - 1;
this.Content[this.CurPos].Cursor_MoveToStartPos();
}
};
CMathBase.prototype.Search = CParagraphContentWithParagraphLikeContent.prototype.Search;
CMathBase.prototype.Add_SearchResult = CParagraphContentWithParagraphLikeContent.prototype.Add_SearchResult;
CMathBase.prototype.Clear_SearchResults = CParagraphContentWithParagraphLikeContent.prototype.Clear_SearchResults;
CMathBase.prototype.Remove_SearchResult = CParagraphContentWithParagraphLikeContent.prototype.Remove_SearchResult;
CMathBase.prototype.Search_GetId = CParagraphContentWithParagraphLikeContent.prototype.Search_GetId;
CMathBase.prototype.Set_SelectionContentPos = CParagraphContentWithParagraphLikeContent.prototype.Set_SelectionContentPos;
CMathBase.prototype.Get_LeftPos = CParagraphContentWithParagraphLikeContent.prototype.Get_LeftPos;
CMathBase.prototype.Get_RightPos = CParagraphContentWithParagraphLikeContent.prototype.Get_RightPos;
CMathBase.prototype.Get_WordStartPos = CParagraphContentWithParagraphLikeContent.prototype.Get_WordStartPos;
CMathBase.prototype.Get_WordEndPos = CParagraphContentWithParagraphLikeContent.prototype.Get_WordEndPos;
CMathBase.prototype.Selection_Remove = CParagraphContentWithParagraphLikeContent.prototype.Selection_Remove;
CMathBase.prototype.Select_All = CParagraphContentWithParagraphLikeContent.prototype.Select_All;
CMathBase.prototype.Check_NearestPos = CParagraphContentWithParagraphLikeContent.prototype.Check_NearestPos;
CMathBase.prototype.Get_SelectionDirection = CParagraphContentWithParagraphLikeContent.prototype.Get_SelectionDirection;
CMathBase.prototype.Selection_CheckParaContentPos = function(ContentPos, Depth, bStart, bEnd)
{
if (true !== this.Selection.Use)
return false;
var CurPos = ContentPos.Get(Depth);
if (this.Selection.StartPos === this.Selection.EndPos && this.Selection.StartPos === CurPos)
return this.Content[CurPos].Selection_CheckParaContentPos(ContentPos, Depth + 1, bStart, bEnd);
if (this.Selection.StartPos !== this.Selection.EndPos)
return true;
return false;
};
CMathBase.prototype.Document_UpdateInterfaceState = function(MathProps)
{
};
CMathBase.prototype.Is_ContentUse = function(MathContent)
{
for (var Pos = 0, Count = this.Content.length; Pos < Count; Pos++)
{
if (MathContent === this.Content[Pos])
return true;
}
return false;
};
function CMathBasePr()
{
}
CMathBasePr.prototype.Set_FromObject = function(Obj){};
CMathBasePr.prototype.Copy = function(){return new CMathBasePr();};
CMathBasePr.prototype.Write_ToBinary = function(Writer){};
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 StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange); var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
...@@ -1925,7 +1940,7 @@ CMathBase_2.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, ...@@ -1925,7 +1940,7 @@ CMathBase_2.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine,
{ {
var Item = this.Content[CurPos]; var Item = this.Content[CurPos];
if(CurPos == this.NumberBreak) if(CurPos == this.NumBreakContent)
{ {
Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange); Item.Recalculate_LineMetrics(PRS, ParaPr, _CurLine, _CurRange);
} }
...@@ -1938,89 +1953,17 @@ CMathBase_2.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine, ...@@ -1938,89 +1953,17 @@ CMathBase_2.prototype.Recalculate_LineMetrics = function(PRS, ParaPr, _CurLine,
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) CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{ {
var CurLine = _CurLine - this.StartLine; if(this.bOneLine)
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 ); PRSC.Range.W += this.size.width;
}
else
{
if ( 0 !== PRSA.LettersSkip )
{
WidthVisible = Item.size.width;
PRSA.LettersSkip--;
} }
else 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 CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange ); var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
...@@ -2036,7 +1979,7 @@ CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRan ...@@ -2036,7 +1979,7 @@ CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRan
{ {
var Item = this.Content[CurPos]; var Item = this.Content[CurPos];
if(CurPos == this.NumberBreak) if(CurPos == this.NumBreakContent)
{ {
Item.Recalculate_Range_Width( PRSC, _CurLine, _CurRange ); Item.Recalculate_Range_Width( PRSC, _CurLine, _CurRange );
} }
...@@ -2056,80 +1999,81 @@ CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRan ...@@ -2056,80 +1999,81 @@ CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRan
} }
this.LinesWidths[CurLine] = PRSC.Range.W - RangeW; this.LinesWidths[CurLine] = PRSC.Range.W - RangeW;
}
}; };
CMathBase_2.prototype.Draw_Elements = function(PDSE) CMathBase.prototype.Is_EmptyRange = function()
{ {
var CurLine = PDSE.Line - this.StartLine; return false;
var CurRange = ( 0 === CurLine ? PDSE.Range - this.StartRange : PDSE.Range ); };
CMathBase.prototype.Get_CurrentParaPos = CMathContent.prototype.Get_CurrentParaPos;
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange); CMathBase.prototype.private_UpdatePosOnAdd = CMathContent.prototype.private_UpdatePosOnAdd;
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange); CMathBase.prototype.private_UpdatePosOnRemove = CMathContent.prototype.private_UpdateOnRemove;
CMathBase.prototype.private_CorrectSelectionPos = CMathContent.prototype.private_CorrectSelectionPos;
if(CurLine == 0 && CurRange == 0) CMathBase.prototype.private_CorrectSelectionPos = CMathContent.prototype.private_CorrectSelectionPos;
PDSE.X += this.GapLeft; CMathBase.prototype.private_SetNeedResize = CMathContent.prototype.private_SetNeedResize;
CMathBase.prototype.private_CorrectCurPos = function()
this.Content[StartPos].Draw_Elements(PDSE); {
if (this.CurPos > this.Content.length - 1)
for (var CurPos = StartPos + 1; CurPos <= EndPos; CurPos++ )
{ {
PDSE.X += this.dW; this.CurPos = this.Content.length - 1;
this.Content[CurPos].Draw_Elements(PDSE); this.Content[this.CurPos].Cursor_MoveToEndPos(false);
} }
var LinesCount = this.protected_GetLinesCount(); if (this.CurPos < 0)
if(LinesCount - 1 == CurLine)
{ {
PDSE.X += this.GapRight; this.CurPos = this.Content.length - 1;
this.Content[this.CurPos].Cursor_MoveToStartPos();
} }
}; };
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(); CMathBase.prototype.Search = CParagraphContentWithParagraphLikeContent.prototype.Search;
CMathBase.prototype.Add_SearchResult = CParagraphContentWithParagraphLikeContent.prototype.Add_SearchResult;
var SelectionStartPos = this.Selection.StartPos; CMathBase.prototype.Clear_SearchResults = CParagraphContentWithParagraphLikeContent.prototype.Clear_SearchResults;
var SelectionEndPos = this.Selection.EndPos; CMathBase.prototype.Remove_SearchResult = CParagraphContentWithParagraphLikeContent.prototype.Remove_SearchResult;
var SelectionUse = this.Selection.Use; CMathBase.prototype.Search_GetId = CParagraphContentWithParagraphLikeContent.prototype.Search_GetId;
CMathBase.prototype.Set_SelectionContentPos = CParagraphContentWithParagraphLikeContent.prototype.Set_SelectionContentPos;
CMathBase.prototype.Get_LeftPos = CParagraphContentWithParagraphLikeContent.prototype.Get_LeftPos;
CMathBase.prototype.Get_RightPos = CParagraphContentWithParagraphLikeContent.prototype.Get_RightPos;
CMathBase.prototype.Get_WordStartPos = CParagraphContentWithParagraphLikeContent.prototype.Get_WordStartPos;
CMathBase.prototype.Get_WordEndPos = CParagraphContentWithParagraphLikeContent.prototype.Get_WordEndPos;
CMathBase.prototype.Selection_Remove = CParagraphContentWithParagraphLikeContent.prototype.Selection_Remove;
CMathBase.prototype.Select_All = CParagraphContentWithParagraphLikeContent.prototype.Select_All;
CMathBase.prototype.Check_NearestPos = CParagraphContentWithParagraphLikeContent.prototype.Check_NearestPos;
CMathBase.prototype.Get_SelectionDirection = CParagraphContentWithParagraphLikeContent.prototype.Get_SelectionDirection;
CMathBase.prototype.Selection_CheckParaContentPos = function(ContentPos, Depth, bStart, bEnd)
{
if (true !== this.Selection.Use)
return false;
if(SelectionUse == true && SelectionStartPos !== SelectionEndPos) var CurPos = ContentPos.Get(Depth);
{
SelectionDraw.FindStart = false;
SelectionDraw.W += this.LinesWidths[CurLine];
} if (this.Selection.StartPos === this.Selection.EndPos && this.Selection.StartPos === CurPos)
else return this.Content[CurPos].Selection_CheckParaContentPos(ContentPos, Depth + 1, bStart, bEnd);
{
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); if (this.Selection.StartPos !== this.Selection.EndPos)
return true;
var Len = SelectionUse == true ? Math.min(EndPos, SelectionStartPos) : EndPos; return false;
};
CMathBase.prototype.Document_UpdateInterfaceState = function(MathProps)
{
};
for(var Pos = StartPos + 1; Pos <= Len; Pos++) CMathBase.prototype.Is_ContentUse = function(MathContent)
{
for (var Pos = 0, Count = this.Content.length; Pos < Count; Pos++)
{ {
var Item = this.Content[Pos]; if (MathContent === this.Content[Pos])
return true;
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) return false;
SelectionDraw.StartX += this.GapRight;
}
}; };
function CMathBasePr()
{
}
CMathBasePr.prototype.Set_FromObject = function(Obj){};
CMathBasePr.prototype.Copy = function(){return new CMathBasePr();};
CMathBasePr.prototype.Write_ToBinary = function(Writer){};
CMathBasePr.prototype.Read_FromBinary = function(Reader){};
...@@ -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