Commit 810226e9 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@55382 954022d7-b5bf-4e40-9824-e11837661b57
parent cf964989
......@@ -62,7 +62,7 @@ ParaMath.prototype =
Is_Empty : function()
{
return this.Math.Is_Empty();
return this.Root.content.length == 0;
},
Is_StartFromNewLine : function()
......@@ -792,24 +792,32 @@ ParaMath.prototype =
if(Math.abs(Diff) < SearchPos.DiffX + 0.001 )
{
var X = SearchPos.X,
Y = SearchPos.Y;
if ( D >= - 0.001 && D <= Dx + 0.001 )
{
var X = SearchPos.X,
Y = SearchPos.Y;
SearchPos.X -= this.Math.absPos.x;
SearchPos.Y -= this.Math.absPos.y;
SearchPos.DiffX = Diff;
SearchPos.X -= this.Math.absPos.x;
SearchPos.Y -= this.Math.absPos.y;
this.Root.Get_ParaContentPosByXY(SearchPos, Depth);
SearchPos.DiffX = Diff;
SearchPos.X = X;
SearchPos.Y = Y;
//console.log("SearchPos.X : " + SearchPos.X);
//console.log("SearchPos.Y : " + SearchPos.Y);
this.Root.Get_ParaContentPosByXY(SearchPos, Depth);
SearchPos.X = X;
SearchPos.Y = Y;
Result = true;
//////////
Result = true;
if ( D >= - 0.001 && D <= Dx + 0.001 )
{
SearchPos.InText = true;
SearchPos.DiffX = 0.001; // сравниваем расстояние до ближайшего элемента
}
......@@ -930,6 +938,8 @@ ParaMath.prototype =
Select_All : function(Direction)
{
// TODO: ParaMath.Select_All
this.bSelectionUse = true;
this.Root.Select_All();
},
Selection_DrawRange : function(_CurLine, _CurRange, SelectionDraw)
......@@ -947,14 +957,20 @@ ParaMath.prototype =
{
// TODO: ParaMath.Selection_Draw_Range
var SelectH = SelectionDraw.H,
SelectStartY = SelectionDraw.StartY;
this.Root.Selection_DrawRange(SelectionDraw);
if(this.Root.selectUse())
{
SelectionDraw.H = SelectH;
SelectionDraw.StartY = SelectStartY;
}
}
else
{
console.log(SelectionDraw.FindStart);
if ( true === SelectionDraw.FindStart )
{
SelectionDraw.StartX += this.Width;
......@@ -980,7 +996,7 @@ ParaMath.prototype =
Is_SelectedAll : function(Props)
{
// TODO: ParaMath.Is_SelectedAll
return false;
return this.Root.Is_SelectedAll(Props);
},
Selection_CorrectLeftPos : function(Direction)
......
......@@ -1246,8 +1246,8 @@ CMathBase.prototype =
Get_ParaContentPosByXY: function(SearchPos, Depth)
{
/// элементов just-draw не должно прийти
//var disp = this.findDisposition({x: X, y: Y});
var disp = this.findDisposition({ x: SearchPos.X, y: SearchPos.Y});
var disp = this.findDisposition({ x: SearchPos.X - this.GapLeft, y: SearchPos.Y});
// TO DO
// Рассмотреть дурацкий случай, если контент не заполнен, то тогда перейти в другой элемент
......@@ -1262,25 +1262,44 @@ CMathBase.prototype =
Depth +=2;
//SearchPos.CurX += SearchPos.X - disp.mCoord.x;
//SearchPos.CurX += this.align(pos.x, pos.y).x;
SearchPos.X = disp.mCoord.x;
SearchPos.Y = disp.mCoord.y;
//ContentPos.Add(disp.pos.x);
//ContentPos.Add(disp.pos.y);
this.elements[disp.pos.x][disp.pos.y].Get_ParaContentPosByXY(SearchPos, Depth);
},
Get_ParaContentPos: function(bSelection, bStart, ContentPos)
{
ContentPos.Add(this.CurPos_X);
ContentPos.Add(this.CurPos_Y);
if( bSelection )
{
var SelectX, SelectY;
this.elements[this.CurPos_X][this.CurPos_Y].Get_ParaContentPos(bSelection, bStart, ContentPos);
if(bStart)
{
SelectX = this.SelectStart_X;
SelectY = this.SelectStart_Y;
}
else
{
SelectX = this.SelectEnd_X;
SelectY = this.SelectEnd_Y;
}
ContentPos.Add(SelectX);
ContentPos.Add(SelectY);
if(SelectX !== -1 && SelectY !== -1)
this.elements[SelectX][SelectY].Get_ParaContentPos(bSelection, bStart, ContentPos);
}
else
{
ContentPos.Add(this.CurPos_X);
ContentPos.Add(this.CurPos_Y);
this.elements[this.CurPos_X][this.CurPos_Y].Get_ParaContentPos(bSelection, bStart, ContentPos);
}
},
Set_ParaContentPos: function(ContentPos, Depth)
{
......@@ -1304,47 +1323,6 @@ CMathBase.prototype =
return this.elements[this.CurPos_X][this.CurPos_Y].Set_ParaContentPos(ContentPos, Depth);
},
set_StartSelectContent: function(ContentPos, Depth)
{
var Pos_X = ContentPos.Get(Depth),
Pos_Y = ContentPos.Get(Depth+1);
Depth += 2;
this.selectPos.startX = Pos_X;
this.selectPos.startY = Pos_Y;
if(!this.elements[Pos_X][Pos_Y].IsJustDraw())
this.elements[Pos_X][Pos_Y].set_StartSelectContent(ContentPos, Depth);
},
set_EndSelectContent: function(ContentPos, Depth)
{
var state = true, SelectContent = null;
var endX = ContentPos.Get(Depth),
endY = ContentPos.Get(Depth+1),
startX = this.selectPos.startX,
startY = this.selectPos.startY;
Depth += 2;
var bJustDraw = this.elements[endX][endY].IsJustDraw();
// пока так
if(startX == endX && startY == endY && !bJustDraw)
{
//this.CurPos_X = startX;
//this.CurPos_Y = startY;
var movement = this.elements[endX][endY].set_EndSelectContent(ContentPos, Depth);
SelectContent = movement.SelectContent;
state = movement.state;
}
else
state = false;
return {state: state, SelectContent: SelectContent};
},
Set_SelectionContentPos: function(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag)
{
var startX = StartContentPos.Get(Depth),
......@@ -1369,6 +1347,25 @@ CMathBase.prototype =
this.SelectEnd_X = endX;
this.SelectEnd_Y = endY;
var str = "";
if(this.constructor.name == "CFraction")
{
if(startX == 0 && startY == 0)
str += "StartContentPos = Numerator; ";
else
str += "StartContentPos = Denominator; ";
if(endX == 0 && endY == 0)
str += "EndContentPos = Numerator ";
else
str += "EndContentPos = Denominator ";
console.log(str);
}
Depth += 2;
var bJustDraw = this.elements[startX][startY].IsJustDraw();
......@@ -1390,8 +1387,12 @@ CMathBase.prototype =
},
Selection_IsEmpty: function()
{
var result = false;
if(this.IsSelectEmpty())
this.elements[this.SelectStart_X][this.SelectStart_Y].Selection_IsEmpty();
result = this.elements[this.SelectStart_X][this.SelectStart_Y].Selection_IsEmpty();
return result;
},
IsSelectEmpty: function()
{
......
......@@ -5780,24 +5780,14 @@ CMathContent.prototype =
pos = i;
}
if( this.content[pos].typeObj === MATH_COMP )
{
if(X < W - width + this.GapLeft)
if(X < W - width + this.content[pos].GapLeft)
pos--;
else if(X >= W - this.GapRight)
else if(X >= W - this.content[pos].GapRight)
pos++;
}
/*else
{
if( !(W - width/2 < mouseX) )
pos--;
}*/
// проверка на RunPrp, смещенная позиция
//pos = this.verifyCurPos(pos);
return pos;
},
verifyCurPos: function(pos) // проверка на RunPrp, смещенная позиция
......@@ -6374,36 +6364,25 @@ CMathContent.prototype =
},
old_selectUse: function()
{
//return (this.selection.startPos !== this.selection.endPos);
//console.log("start pos "+ this.RealSelect.startPos);
//console.log("end pos " + this.RealSelect.endPos);
return this.RealSelect.startPos !== this.RealSelect.endPos;
},
selectUse: function()
{
return this.SelectStartPos !== this.SelectEndPos;
//return this.SelectStartPos !== this.SelectEndPos;
},
Selection_IsEmpty: function()
{
var startPos = this.SelectStartPos,
endPos = this.SelectEndPos;
var result = false;
var result;
if(startPos == endPos)
if(this.SelectStartPos == this.SelectEndPos)
{
var bRunPrp = this.content[startPos].typeObj == MATH_RUN_PRP,
bComp = this.content[startPos].typeObj == MATH_COMP,
bSelectComp = bComp ? this.content[startPos].IsSelectEmpty() : false;
if(bRunPrp || bSelectComp)
result = this.content[startPos].Selection_IsEmpty();
else
result = false;
if(this.content[this.SelectStartPos].typeObj == MATH_PARA_RUN)
{
result = this.content[this.SelectStartPos].Selection_IsUse();
}
else if(this.content[this.SelectStartPos].typeObj == MATH_COMP)
{
result = ! this.content[this.SelectStartPos].IsSelectEmpty();
}
}
else
result = true;
return result;
},
......@@ -7519,7 +7498,6 @@ CMathContent.prototype =
//ContentPos.Add(pos);
SearchPos.X -= this.WidthToElement[pos];
//SearchPos.CurX += this.WidthToElement[pos];
if(this.content[pos].typeObj == MATH_COMP)
{
......@@ -7542,16 +7520,6 @@ CMathContent.prototype =
ContentPos.Add(pos);
this.content[pos].Get_ParaContentPos(bSelection, bStart, ContentPos);
/*if(this.RealSelect.startPos == this.RealSelect.endPos)
{
var blen = pos < this.content.length;
var bComp = blen ? this.content[pos].typeObj == MATH_COMP : false;
if(bComp)
this.content[pos].Get_ParaContentPos(bSelection, bStart, ContentPos);
}*/
}
else
{
......@@ -7576,208 +7544,6 @@ CMathContent.prototype =
}
},
set_SelectEndExtreme: function(bEnd)
{
if(bEnd === false)
{
this.LogicalSelect.end = 1;
this.RealSelect.endPos = 1;
// проверка на то, чтобы CEmpty был включен !!! когда идем из мат объекта(например из числителя) и идем наверх, выходим за пределы формулы
// если стоим в конце, то this.RealSelect.endPos равен this.content.length и соответственно, нужно сделать проверку на то, что запрашиваем у существующего объекта typeObj (!)
var start = this.RealSelect.startPos; // проверяем именно тот, который идет на отрисовку, т.к. логический мб выставлен на мат. объект
if(start < this.content.length)
{
var current = this.content[this.CurPos].value.typeObj;
var selectStart = this.content[start].value.typeObj; // only for draw select
if(current == MATH_COMP && selectStart == MATH_COMP)
{
this.RealSelect.startPos++;
}
}
}
else
{
this.LogicalSelect.end = this.content.length - 1;
this.RealSelect.endPos = this.content.length;
var start = this.RealSelect.startPos - 2,
current = this.content[this.CurPos].value.typeObj,
selectStart = start > 0 ? this.content[start].value.typeObj : null;
if(current == MATH_COMP && selectStart == MATH_COMP)
{
this.RealSelect.startPos -= 2;
}
}
},
set_StartSelectContent: function(ContentPos, Depth)
{
if(this.IsPlaceholder())
{
this.LogicalSelect.start = 1;
this.LogicalSelect.end = 2;
}
else
{
var pos = ContentPos.Get(Depth);
Depth++;
this.LogicalSelect.start = pos;
if(pos < this.content.length && this.RealSelect.startPos === this.RealSelect.endPos && this.content[pos].typeObj === MATH_COMP)
{
this.content[pos].set_StartSelectContent(ContentPos, Depth);
}
}
},
old_set_EndSelectContent: function(ContentPos, Depth)
{
/*var msCoord = {x: x, y: y};
var posEnd = this.findPosition(msCoord),
posStart = this.LogicalSelect.start;
this.CurPos = posStart;
this.LogicalSelect.end = posEnd;*/
var state = true; // вышли / не вышли за переделы контента
// актуально для мат. объекта
var SelectContent = null;
var posEnd = ContentPos.Get(Depth),
posStart = this.LogicalSelect.start;
this.LogicalSelect.end = posEnd;
Depth++;
//var blen = this.RealSelect.startPos < this.content.length;
//селект внутри мат. объекта
if(posStart < this.content.length && posStart === posEnd && this.content[posEnd].value.typeObj === MATH_COMP)
{
var result = this.content[posEnd].value.set_EndSelectContent(ContentPos, Depth);
this.setStartPos_Selection(posStart-1);
if( !result.state )
{
this.setEndPos_Selection(posEnd + 1);
SelectContent = this;
}
else
SelectContent = result.SelectContent;
}
//селект элементов контента
else
{
SelectContent = this;
var direction = (posStart < posEnd) ? 1 : -1;
if(posStart < this.content.length)
{
if(this.content[posStart].value.typeObj === MATH_COMP )
{
if( direction == 1 )
this.setStartPos_Selection( posStart - 1);
else if( direction == -1 )
this.setStartPos_Selection( posStart + 1);
}
else
this.setStartPos_Selection(posStart);
}
if(posEnd < this.content.length)
{
if(this.content[posEnd].value.typeObj === MATH_COMP )
{
if( direction == 1 )
this.setEndPos_Selection(posEnd + 1);
else if( direction == -1 )
this.setEndPos_Selection(posEnd - 1);
}
else
this.setEndPos_Selection(posEnd);
}
}
return {state: state, SelectContent: SelectContent};
},
set_EndSelectContent: function(ContentPos, Depth)
{
/*var msCoord = {x: x, y: y};
var posEnd = this.findPosition(msCoord),
posStart = this.LogicalSelect.start;
this.CurPos = posStart;
this.LogicalSelect.end = posEnd;*/
var state = true; // вышли / не вышли за переделы контента
// актуально для мат. объектов !!
var SelectContent = null;
var posEnd = ContentPos.Get(Depth),
posStart = this.LogicalSelect.start;
this.LogicalSelect.end = posEnd;
Depth++;
//var blen = this.RealSelect.startPos < this.content.length;
//селект внутри мат. объекта
// возможны две ситуации:
// 1. мы нашли нужный контенте posStart !== posEnd или posStart === posEnd и находимся в одном Para_Run
// 2. posStart === posEnd и это мат объект и ищем дальше
if(posStart < this.content.length && posStart === posEnd && this.content[posEnd].typeObj === MATH_COMP)
{
var result = this.content[posEnd].value.set_EndSelectContent(ContentPos, Depth);
this.setStartPos_Selection(posStart-1);
if( !result.state )
{
this.setEndPos_Selection(posEnd + 1);
SelectContent = this;
}
else
SelectContent = result.SelectContent;
}
//селект элементов контента
else
{
SelectContent = this;
/*var direction = (posStart < posEnd) ? 1 : -1;
if(posStart < this.content.length)
{
if(this.content[posStart].value.typeObj === MATH_COMP )
{
if( direction == 1 )
this.setStartPos_Selection( posStart - 1);
else if( direction == -1 )
this.setStartPos_Selection( posStart + 1);
}
else
this.setStartPos_Selection(posStart);
}
if(posEnd < this.content.length)
{
if(this.content[posEnd].value.typeObj === MATH_COMP )
{
if( direction == 1 )
this.setEndPos_Selection(posEnd + 1);
else if( direction == -1 )
this.setEndPos_Selection(posEnd - 1);
}
else
this.setEndPos_Selection(posEnd);
}*/
}
return {state: state, SelectContent: SelectContent};
},
Set_SelectionContentPos: function(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag)
{
var posStart, posEnd;
......@@ -7845,7 +7611,6 @@ CMathContent.prototype =
},
Selection_DrawRange: function(SelectionDraw)
{
if(this.SelectStartPos !== this.SelectEndPos)
{
var startPos = this.SelectStartPos,
......@@ -7858,7 +7623,6 @@ CMathContent.prototype =
endPos = temp;
}
if(this.content[startPos].typeObj === MATH_PARA_RUN)
{
SelectionDraw.StartX += this.pos.x + this.WidthToElement[startPos];
......@@ -7876,7 +7640,11 @@ CMathContent.prototype =
if(this.content[endPos].typeObj === MATH_PARA_RUN)
{
var StartX = SelectionDraw.StartX;
this.content[endPos].Selection_DrawRange(0, 0, SelectionDraw);
SelectionDraw.StartX = StartX;
}
else
SelectionDraw.W += this.content[endPos].size.width;
......@@ -7888,7 +7656,6 @@ CMathContent.prototype =
{
var pos = this.SelectStartPos;
if(this.content[pos].typeObj === MATH_COMP)
{
if(this.content[pos].IsSelectEmpty())
......@@ -7901,7 +7668,7 @@ CMathContent.prototype =
SelectionDraw.W = this.content[pos].size.width;
SelectionDraw.H = this.size.height;
SelectionDraw.StartX += this.pos.x + this.WidthToElement[pos];
SelectionDraw.StartX = this.pos.x + this.Composition.absPos.x + this.WidthToElement[pos];
SelectionDraw.StartY = this.pos.y + this.Composition.absPos.y;
}
......@@ -7917,41 +7684,56 @@ CMathContent.prototype =
}
},
drawSelect: function(SelectionDraw)
Select_All: function()
{
var start = this.RealSelect.startPos,
end = this.RealSelect.endPos;
this.SelectStartPos = 0;
this.SelectEndPos = this.content.length - 1;
if( start > end)
{
var tmp = start;
start = end;
end = tmp;
}
if(this.content[this.SelectStartPos].typeObj == MATH_PARA_RUN)
this.content[this.SelectStartPos].Select_All();
if(this.IsPlaceholder())
if(this.content[this.SelectEndPos].typeObj == MATH_PARA_RUN)
this.content[this.SelectEndPos].Select_All();
},
Is_SelectedAll: function(Props)
{
var bFirst = false, bEnd = false;
if(this.SelectStartPos == 0 && this.SelectEndPos == this.content.length - 1)
{
start = 1;
end = 2;
}
if(this.content[this.SelectStartPos].typeObj == MATH_PARA_RUN)
bFirst = this.content[this.SelectStartPos].Is_SelectedAll(Props);
else
bFirst = true;
//var heightSelect = this.size.ascent + this.size.descent;
var heightSelect = this.size.height;
var widthSelect = 0;
if(this.content[this.SelectEndPos].typeObj == MATH_PARA_RUN)
bEnd = this.content[this.SelectEndPos].Is_SelectedAll(Props);
else
bEnd = true;
}
for(var j= start; j < end ; j++)
widthSelect += this.content[j].widthToEl - this.content[j-1].widthToEl;
return bFirst && bEnd;
},
Selection_IsEmpty: function()
{
var startPos = this.SelectStartPos,
endPos = this.SelectEndPos;
var startPos = start > 0 ? start-1 : start;
var X = this.pos.x + this.Composition.absPos.x + this.content[startPos].widthToEl,
Y = this.pos.y + this.Composition.absPos.y;
var result = false;
SelectionDraw.StartX = X;
SelectionDraw.StartY = Y;
if(startPos == endPos)
{
var bRunPrp = this.content[startPos].typeObj == MATH_RUN_PRP,
bComp = this.content[startPos].typeObj == MATH_COMP;
SelectionDraw.W = widthSelect;
SelectionDraw.H = heightSelect;
if(bRunPrp || bComp)
result = this.content[startPos].Selection_IsEmpty();
else
result = false; // placeholder
}
return result;
},
Get_Id : function()
{
......
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