Commit 6882edb8 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@61456 954022d7-b5bf-4e40-9824-e11837661b57
parent d04a9285
...@@ -26,7 +26,8 @@ function CMathBase(bInside) ...@@ -26,7 +26,8 @@ function CMathBase(bInside)
this.bInside = bInside === true; this.bInside = bInside === true;
this.bMath_OneLine = true; this.bMath_OneLine = true;
this.elements = []; this.elements = [];
this.LinesWidths = [];
this.dW = 0; //column gap, gap width this.dW = 0; //column gap, gap width
this.dH = 0; //row gap, gap height this.dH = 0; //row gap, gap height
...@@ -998,7 +999,6 @@ CMathBase.prototype.NeedUpdate_CtrPrp = function() ...@@ -998,7 +999,6 @@ CMathBase.prototype.NeedUpdate_CtrPrp = function()
if(null !== this.ParaMath) if(null !== this.ParaMath)
this.ParaMath.SetNeedResize(); this.ParaMath.SetNeedResize();
}; };
CMathBase.prototype.SelectToParent = function(bCorrect) CMathBase.prototype.SelectToParent = function(bCorrect)
{ {
...@@ -1040,6 +1040,22 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang ...@@ -1040,6 +1040,22 @@ CMathBase.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRang
PRSA.X += WidthVisible; PRSA.X += WidthVisible;
PRSA.LastW = WidthVisible; PRSA.LastW = WidthVisible;
}; };
CMathBase.prototype.Get_Width = function(_CurLine)
{
var Width = 0;
if(this.bMath_OneLine)
{
Width = this.size.width;
}
else
{
var CurLine = _CurLine - this.StartLine;
Width = this.LinesWidths[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;
CMathBase.prototype.Get_ParaPosByContentPos = CParagraphContentWithParagraphLikeContent.prototype.Get_ParaPosByContentPos; CMathBase.prototype.Get_ParaPosByContentPos = CParagraphContentWithParagraphLikeContent.prototype.Get_ParaPosByContentPos;
...@@ -1392,108 +1408,30 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio ...@@ -1392,108 +1408,30 @@ CMathBase.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selectio
var SelectionUse = this.Selection.Use; var SelectionUse = this.Selection.Use;
if(this.bMath_OneLine) if(SelectionUse == true)
{ {
if(SelectionUse == true) if(SelectionStartPos !== SelectionEndPos)
{ {
if(SelectionStartPos !== SelectionEndPos) SelectionDraw.FindStart = false;
{ SelectionDraw.W += this.size.width;
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
{
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();
if(SelectionUse == true)
{
if(SelectionStartPos !== SelectionEndPos)
{
SelectionDraw.FindStart = false;
var Direction = SelectionStartPos > SelectionEndPos ? - 1 : 1;
this.Select_All(Direction);
if(CurLine == 0)
SelectionDraw.W += this.GapLeft;
for(var Pos = StartPos; Pos <= EndPos; Pos++)
{
this.Content[Pos].Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
SelectionDraw.W += this.dW*(EndPos - StartPos);
if(LinesCount - 1 == CurLine)
SelectionDraw.W += this.GapRight;
}
else
{
if(CurLine == 0)
{
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.GapLeft;
else
SelectionDraw.W += this.GapLeft;
}
this.Content[StartPos].Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
for(var Pos = StartPos + 1; Pos <= SelectionStartPos; Pos++)
{
var Item = this.Content[Pos];
if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.dW;
else
SelectionDraw.W += this.dW;
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
}
} }
else if(SelectionDraw.FindStart == true) else
{ {
if(CurLine == 0) var Item = this.Content[SelectionStartPos];
SelectionDraw.StartX += this.GapLeft;
this.Content[StartPos].Selection_DrawRange(_CurLine, _CurRange, SelectionDraw); var PosLine = this.ParaMath.GetLinePosition(_CurLine);
for(var Pos = StartPos + 1; Pos <= EndPos; Pos++) SelectionDraw.StartX = PosLine.x + Item.pos.x;
{ SelectionDraw.StartY = PosLine.y + Item.pos.y - Item.size.ascent;
var Item = this.Content[Pos]; SelectionDraw.H = Item.size.height;
SelectionDraw.StartX += this.dW;
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
if(LinesCount - 1 == CurLine) Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
SelectionDraw.StartX += this.GapRight;
} }
} }
else if(SelectionDraw.FindStart == true)
{
SelectionDraw.StartX += this.size.width;
}
}; };
CMathBase.prototype.Selection_IsEmpty = function() CMathBase.prototype.Selection_IsEmpty = function()
...@@ -2089,6 +2027,8 @@ CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRan ...@@ -2089,6 +2027,8 @@ CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRan
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.GapLeft; PRSC.Range.W += this.GapLeft;
...@@ -2114,6 +2054,8 @@ CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRan ...@@ -2114,6 +2054,8 @@ CMathBase_2.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRan
{ {
PRSC.Range.W += this.GapRight; PRSC.Range.W += this.GapRight;
} }
this.LinesWidths[CurLine] = PRSC.Range.W - RangeW;
}; };
CMathBase_2.prototype.Draw_Elements = function(PDSE) CMathBase_2.prototype.Draw_Elements = function(PDSE)
{ {
...@@ -2141,7 +2083,7 @@ CMathBase_2.prototype.Draw_Elements = function(PDSE) ...@@ -2141,7 +2083,7 @@ CMathBase_2.prototype.Draw_Elements = function(PDSE)
PDSE.X += this.GapRight; PDSE.X += this.GapRight;
} }
}; };
CMathBase_2.prototype.Selection_DrawRange_2 = function(_CurLine, _CurRange, SelectionDraw) CMathBase_2.prototype.Selection_DrawRange = function(_CurLine, _CurRange, SelectionDraw)
{ {
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 );
...@@ -2149,59 +2091,45 @@ CMathBase_2.prototype.Selection_DrawRange_2 = function(_CurLine, _CurRange, Sele ...@@ -2149,59 +2091,45 @@ CMathBase_2.prototype.Selection_DrawRange_2 = function(_CurLine, _CurRange, Sele
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 LinesCount = this.protected_GetLinesCount();
var SelectionStartPos = this.Selection.StartPos; var SelectionStartPos = this.Selection.StartPos;
var SelectionEndPos = this.Selection.EndPos; var SelectionEndPos = this.Selection.EndPos;
var SelectionUse = this.Selection.Use; var SelectionUse = this.Selection.Use;
var LenContent = this.Content.length;
var LinesCount = this.protected_GetLinesCount();
if(SelectionStartPos !== SelectionEndPos && SelectionUse == true) if(SelectionUse == true && SelectionStartPos !== SelectionEndPos)
{ {
SelectionDraw.FindStart = false; SelectionDraw.FindStart = false;
SelectionDraw.DrawSelection = true; SelectionDraw.W += this.LinesWidths[CurLine];
this.Select_All();
if(CurLine == 0)
SelectionDraw.W += this.GapLeft;
for(var Pos = StartPos; Pos <= EndPos; Pos++)
{
SelectionDraw.W += this.dW*Pos;
this.Content[Pos].Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
if(SelectionUse == false && LinesCount - 1 == CurLine)
SelectionDraw.W += this.GapRight;
} }
else else
{ {
if(CurLine == 0) if(CurLine == 0)
SelectionDraw.StartX += this.GapLeft; {
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 == false ? EndPos : Math.min(EndPos, SelectionStartPos); var Len = SelectionUse == true ? Math.min(EndPos, SelectionStartPos) : EndPos;
for(var Pos = StartPos; Pos <= Len; Pos++) for(var Pos = StartPos + 1; Pos <= Len; Pos++)
{ {
var Item = this.Content[Pos]; var Item = this.Content[Pos];
SelectionDraw.StartX += this.dW*Pos; if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += this.dW;
var bNeed_changeSelection = Item.bOneLine == false || (SelectionUse == true && Pos == SelectionStartPos); else if(SelectionUse == true)
SelectionDraw.W += this.dW;
if(bNeed_changeSelection) Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
{
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
else
{
SelectionDraw.StartX += Item.size.width;
}
} }
if(SelectionUse == false && LinesCount - 1 == CurLine) if(SelectionDraw.FindStart == true && LinesCount - 1 == CurLine)
SelectionDraw.StartX += this.GapRight; SelectionDraw.StartX += this.GapRight;
} }
}; };
\ No newline at end of file
...@@ -3812,15 +3812,6 @@ CMathContent.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selec ...@@ -3812,15 +3812,6 @@ CMathContent.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selec
SelectionEndPos = this.Selection.Start; SelectionEndPos = this.Selection.Start;
} }
// Выставляем высоту селекта. В верхнем контенте высота задается параграфом
/*if(true !== this.bRoot)
{
var PosLine = this.ParaMath.GetLinePosition(_CurLine);
SelectionDraw.StartX = PosLine.x + this.pos.x;
SelectionDraw.StartY = PosLine.y + this.pos.y - this.size.ascent;
SelectionDraw.H = this.size.height;
}*/
var SelectionUse = this.Selection.Use; var SelectionUse = this.Selection.Use;
var CurLine = _CurLine - this.StartLine; var CurLine = _CurLine - this.StartLine;
...@@ -3837,29 +3828,11 @@ CMathContent.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selec ...@@ -3837,29 +3828,11 @@ CMathContent.prototype.Selection_DrawRange = function(_CurLine, _CurRange, Selec
if(Item.Type == para_Math_Composition && bSelectAll) if(Item.Type == para_Math_Composition && bSelectAll)
{ {
var Direction = SelectionStartPos > SelectionEndPos ? -1 : 1; SelectionDraw.FindStart = false;
Item.Select_All(Direction); SelectionDraw.W += Item.Get_Width(_CurLine);
}
Item.Selection_DrawRange( _CurLine, _CurRange, SelectionDraw );
/*if(Item.Type == para_Math_Composition)
{
if(SelectionUse && SelectionStartPos == CurPos && SelectionStartPos == SelectionEndPos)
{
Item.Selection_DrawRange(_CurLine, _CurRange, SelectionDraw);
}
else if(SelectionUse && SelectionStartPos <= CurPos && CurPos <= SelectionEndPos)
{
SelectionDraw.FindStart = false;
SelectionDraw.DrawSelection = true;
SelectionDraw.W += Item.size.width;
}
else if(SelectionDraw.FindStart == true)
SelectionDraw.StartX += Item.size.width;
} }
else else
Item.Selection_DrawRange( _CurLine, _CurRange, SelectionDraw );*/ Item.Selection_DrawRange( _CurLine, _CurRange, SelectionDraw );
} }
}; };
CMathContent.prototype.Select_ElementByPos = function(nPos, bWhole) CMathContent.prototype.Select_ElementByPos = function(nPos, bWhole)
......
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