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

1. Поправила селект

2. Реализовала SelectToParent для селекта мат объекта из внутреннего контента (плейсхолдер и т.п.)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56872 954022d7-b5bf-4e40-9824-e11837661b57
parent a9e294ef
......@@ -94,10 +94,12 @@ ParaMath.prototype =
{
var result = this.GetSelectContent();
NewMath.Root = result.Content.Copy(Selected);
NewMath.Root.bRoot = true;
}
else
{
NewMath.Root = this.Root.Copy(Selected);
NewMath.Root.bRoot = true;
}
/// argSize, bDot и bRoot выставить на объединении контентов
......@@ -223,6 +225,14 @@ ParaMath.prototype =
Remove : function(Direction, bOnAddText)
{
var oContent = this.GetSelectContent();
/*var Comp = oContent.Content.GetParent();
Comp.SetSelectAll();
Comp.SelectToParent();
this.bSelectionUse = true;*/
if (oContent.Start == oContent.End)
{
var oElem = oContent.Content.getElem(oContent.Start);
......@@ -445,7 +455,6 @@ ParaMath.prototype =
this.Root.Resize(null, this, g_oTextMeasurer, TextPr);
BFIRST = false;
var pos = new CMathPosition();
pos.x = 0;
......@@ -1149,6 +1158,8 @@ ParaMath.prototype =
{
// TODO: ParaMath.Cursor_MoveToStartPos
//console.log("Cursor_MoveToStartPos");
this.Root.Cursor_MoveToStartPos();
},
......@@ -1296,14 +1307,38 @@ ParaMath.prototype =
{
// TODO: ParaMath.Get_LeftPos
return this.Root.Get_LeftPos(SearchPos, ContentPos, Depth, UseContentPos, false);
var result = this.Root.Get_LeftPos(SearchPos, ContentPos, Depth, UseContentPos, false);
/*var str = "";
for(var i = 0; i < SearchPos.Pos.Data.length; i++)
{
str += SearchPos.Pos.Data[i] + " ";
}
console.log(str);*/
BFIRST = false;
return result;
},
Get_RightPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd)
{
// TODO: ParaMath.Get_RightPos
return this.Root.Get_RightPos(SearchPos, ContentPos, Depth, UseContentPos, StepEnd, false);
var result = this.Root.Get_RightPos(SearchPos, ContentPos, Depth, UseContentPos, StepEnd, false);
var str = "";
for(var i = 0; i < SearchPos.Pos.Data.length; i++)
{
str += SearchPos.Pos.Data[i] + " ";
}
console.log(str);
return result;
},
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
......@@ -1351,7 +1386,17 @@ ParaMath.prototype =
Get_StartPos : function(ContentPos, Depth)
{
// TODO: ParaMath.Get_StartPos
this.Root.Get_StartPos(ContentPos, Depth);
/*var str = "";
for(var i = 0 ; i < ContentPos.Data.length; i++)
{
}*/
//console.log("Get_StartPos");
},
Get_EndPos : function(BehindEnd, ContentPos, Depth)
......@@ -1366,6 +1411,8 @@ ParaMath.prototype =
{
// TODO: ParaMath.Set_SelectionContentPos
//console.log(" Set_SelectionContentPos " );
this.Root.Set_SelectionContentPos(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag);
this.bSelectionUse = true;
},
......
......@@ -15,16 +15,30 @@ function CMathBase()
this.CtrPrp = new CTextPr();
this.CompiledCtrPrp = new CTextPr();
/////////////////
/////////////////
this.CurPos_X = 0;
this.CurPos_Y = 0;
this.SelectStart_X = 0;
this.SelectStart_Y = 0;
//this.SelectStart_X = 0;
//this.SelectStart_Y = 0;
this.SelectEnd_X = 0;
this.SelectEnd_Y = 0;
this.SelectStart =
{
X: 0,
Y: 0,
bOutside: false
};
this.SelectEnd =
{
X: 0,
Y: 0,
bOutside: false
};
//this.SelectEnd_X = 0;
//this.SelectEnd_Y = 0;
this.bSelectionUse = false;
......@@ -1263,9 +1277,6 @@ CMathBase.prototype =
// в случае, если в xml отсутствуют элементы в контенте, то выставляются плейсхолдеры
/*if(this.Parent.constructor.name == "CRadical")
console.log("X : " + disp.pos.x + ", " + " Y : " + disp.pos.y);*/
var pos = disp.pos;
SearchPos.Pos.Update(pos.x, Depth);
......@@ -1284,24 +1295,33 @@ CMathBase.prototype =
{
if( bSelection )
{
var SelectX, SelectY;
//var SelectX, SelectY;
var oSelect;
if(bStart)
{
SelectX = this.SelectStart_X;
SelectY = this.SelectStart_Y;
//SelectX = this.SelectStart_X;
//SelectY = this.SelectStart_Y;
oSelect = this.SelectStart;
//SelectX = this.SelectStart.X;
//SelectY = this.SelectStart.Y;
}
else
{
SelectX = this.SelectEnd_X;
SelectY = this.SelectEnd_Y;
oSelect = this.SelectEnd;
//SelectX = this.SelectEnd.X;
//SelectY = this.SelectEnd.Y;
}
ContentPos.Add(SelectX);
ContentPos.Add(SelectY);
ContentPos.Add(oSelect.X);
ContentPos.Add(oSelect.Y);
if(SelectX !== -1 && SelectY !== -1 && !this.elements[SelectX][SelectY].IsJustDraw())
this.elements[SelectX][SelectY].Get_ParaContentPos(bSelection, bStart, ContentPos);
if(!oSelect.bOutside && !this.elements[oSelect.X][oSelect.Y].IsJustDraw())
this.elements[oSelect.X][oSelect.Y].Get_ParaContentPos(bSelection, bStart, ContentPos);
}
else
......@@ -1329,65 +1349,75 @@ CMathBase.prototype =
this.CurPos_Y = CurPos_Y;
}
/*this.SelectStart_X = this.CurPos_X;
this.SelectStart_Y = this.CurPos_Y;
this.SelectEnd_X = this.CurPos_X;
this.SelectEnd_Y = this.CurPos_Y;*/
Depth += 2;
return this.elements[this.CurPos_X][this.CurPos_Y].Set_ParaContentPos(ContentPos, Depth);
},
Set_SelectionContentPos: function(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag)
{
var startX, startY;
var bJustDraw = false;
//var startX, startY;
//var bJustDraw = false;
if(StartFlag === 0)
{
startX = StartContentPos.Get(Depth);
startY = StartContentPos.Get(Depth + 1);
bJustDraw = this.elements[startX][startY].IsJustDraw();
this.SelectStart.X = StartContentPos.Get(Depth);
this.SelectStart.Y = StartContentPos.Get(Depth + 1);
this.SelectStart.bOutside = false;
}
else
{
startX = -1;
startY = -1;
this.SelectStart.bOutside = true;
/*startX = -1;
startY = -1;*/
}
this.SelectStart_X = startX;
this.SelectStart_Y = startY;
/*this.SelectStart.X = startX;
this.SelectStart.Y = startY;*/
//this.SelectStart_X = startX;
//this.SelectStart_Y = startY;
var endX, endY;
if(EndFlag === 0)
{
endX = EndContentPos.Get(Depth);
endY = EndContentPos.Get(Depth + 1);
this.SelectEnd.X = EndContentPos.Get(Depth);
this.SelectEnd.Y = EndContentPos.Get(Depth + 1);
this.SelectEnd.bOutside = false;
}
else /// в случае, если закончили селект на уровень выше, а нужно выставить начало селекта во внутреннем элементе мат объекта
{
endX = -1;
endY = -1;
this.SelectEnd.bOutside = true;
/*endX = -1;
endY = -1;*/
}
this.SelectEnd_X = endX;
this.SelectEnd_Y = endY;
/*this.SelectEnd_X = endX;
this.SelectEnd_Y = endY;*/
Depth += 2;
if(startX == endX && startY == endY && !bJustDraw)
if(!this.SelectEnd.bOutside && !this.SelectStart.bOutside)
{
this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag);
}
else if(startX !== -1 && startY !== -1)
{
this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, null, Depth, StartFlag, -1);
var startX = this.SelectStart.X,
startY = this.SelectStart.Y;
var endX = this.SelectEnd.X,
endY = this.SelectEnd.Y;
var bJustDraw = this.elements[this.SelectStart.X][this.SelectStart.Y].IsJustDraw();
if(startX == endX && startY == endY && !bJustDraw)
{
this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag);
}
else /*if(startX !== -1 && startY !== -1)*/
{
this.elements[startX][startY].Set_SelectionContentPos(StartContentPos, null, Depth, StartFlag, -1);
}
}
this.bSelectionUse = true;
},
......@@ -1396,13 +1426,13 @@ CMathBase.prototype =
var result = false;
if(this.IsSelectEmpty())
result = 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()
{
return (this.SelectStart_X == this.SelectEnd_X) && (this.SelectStart_Y == this.SelectEnd_Y) && (this.SelectStart_X !== -1 && this.SelectStart_Y !== -1);
return (!this.SelectStart.bOutside && !this.SelectEnd.bOutside) && (this.SelectStart.X == this.SelectEnd.X) && (this.SelectStart.Y == this.SelectEnd.Y);
},
Recalculate_CurPos: function(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget)
{
......@@ -1413,7 +1443,7 @@ CMathBase.prototype =
var result;
if(this.bSelectionUse)
result = this.elements[this.SelectStart_X][this.SelectStart_Y].GetSelectContent();
result = this.elements[this.SelectStart.X][this.SelectStart.Y].GetSelectContent();
else
result = this.elements[this.CurPos_X][this.CurPos_Y].GetSelectContent();
......@@ -1433,8 +1463,8 @@ CMathBase.prototype =
},
Selection_Remove: function()
{
var start_X = this.SelectStart_X,
start_Y = this.SelectStart_Y;
var start_X = this.SelectStart.X,
start_Y = this.SelectStart.Y;
if(start_X !== -1 && start_Y !== -1)
this.elements[start_X][start_Y].Selection_Remove();
......@@ -1489,29 +1519,30 @@ CMathBase.prototype =
CurPos_Y = this.nCol - 1;
}
var bUseContent = UseContentPos;
//var bUseContent = UseContentPos;
while(CurPos_X >= 0)
{
while(CurPos_Y >= 0)
{
var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(),
usePlh = !bJDraw && bUseContent && this.elements[CurPos_X][CurPos_Y].IsPlaceholder();
usePlh = !bJDraw && UseContentPos && this.elements[CurPos_X][CurPos_Y].IsPlaceholder();
if(!bJDraw && !usePlh)
{
this.elements[CurPos_X][CurPos_Y].Get_LeftPos(SearchPos, ContentPos, Depth + 2, bUseContent, EndRun);
this.elements[CurPos_X][CurPos_Y].Get_LeftPos(SearchPos, ContentPos, Depth + 2, UseContentPos, EndRun);
SearchPos.Pos.Update(CurPos_X, Depth);
SearchPos.Pos.Update(CurPos_Y, Depth+1);
}
if(SearchPos.Found === true)
if(SearchPos.Found === true || SearchPos.ForSelection == true)
break;
CurPos_Y--;
bUseContent = false;
UseContentPos = false;
EndRun = true;
}
if(SearchPos.Found === true)
......@@ -1558,7 +1589,7 @@ CMathBase.prototype =
SearchPos.Pos.Update(CurPos_Y, Depth+1);
}
if(SearchPos.Found === true)
if(SearchPos.Found === true || SearchPos.ForSelection == true)
break;
CurPos_Y++;
......@@ -1726,9 +1757,13 @@ CMathBase.prototype =
{
return false;
},
GetParent: function()
{
return (this.Parent.typeObj !== MATH_COMP ? this : this.Parent.GetParent());
},
Copy: function(Selected)
{
var props = this.getPropsForWrite();
var props = Common_CopyObj(this.Pr);
var NewObj = new this.constructor();
NewObj.init(props);
......@@ -1752,9 +1787,8 @@ CMathBase.prototype =
var row = ContentPos.Get(Depth),
col = ContentPos.Get(Depth+1);
var TextPr = this.elements[row][col].Get_TextPr(ContentPos, Depth + 2);
return TextPr;
return this.elements[row][col].Get_TextPr(ContentPos, Depth + 2);
},
Get_CompiledTextPr : function(Copy)
{
......@@ -1812,20 +1846,35 @@ CMathBase.prototype =
},
Set_Select_ToMComp: function(Direction)
{
this.SelectStart_X = this.SelectEnd_X = this.CurPos_X;
this.SelectStart_Y = this.SelectEnd_Y = this.CurPos_Y;
this.SelectStart.X = this.SelectEnd.X = this.CurPos_X;
this.SelectStart.Y = this.SelectEnd.Y = this.CurPos_Y;
this.elements[this.CurPos_X][this.CurPos_Y].Set_Select_ToMComp(Direction);
},
SetSelectAll: function()
{
this.SelectStart_X = -1;
this.SelectStart_Y = -1;
/*this.SelectStart_X = -1;
this.SelectStart_Y = -1;*/
this.SelectStart.bOutside = true;
this.SelectEnd.bOutside = true;
this.bSelectionUse = true;
this.SelectEnd_X = this.nRow - 1;
this.SelectEnd_Y = this.nCol - 1;
/*this.SelectEnd_X = this.nRow - 1;
this.SelectEnd_Y = this.nCol - 1;*/
},
SelectToParent: function()
{
/*this.SelectStart.bOutside = true;
this.SelectEnd.bOutside = true;
this.bSelectionUse = true;*/
this.bSelectionUse = true;
this.Parent.SelectToParent();
},
Check_NearestPos: function(ParaNearPos, Depth)
{
var ContentNearPos = new CParagraphElementNearPos();
......
......@@ -5869,6 +5869,10 @@ CMathContent.prototype =
this.content[i].Recalculate_Reset(StartRange, StartLine);
}
},
GetParent: function()
{
return this.Parent.GetParent();
},
// Поиск позиции, селект
......@@ -6021,6 +6025,14 @@ CMathContent.prototype =
return result;
},
SelectToParent : function()
{
this.bSelectionUse = true;
if(!this.bRoot)
this.Parent.SelectToParent();
},
///////////////////////
......@@ -6369,7 +6381,6 @@ CMathContent.prototype =
var result = false;
var CurPos = UseContentPos ? ContentPos.Get(Depth) : this.content.length-1;
var bUseContent = UseContentPos;
while(CurPos >= 0 && SearchPos.Found == false)
{
......@@ -6384,7 +6395,13 @@ CMathContent.prototype =
}
else if(curType == MATH_COMP)
{
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, bUseContent, EndRun);
var bNotshift = SearchPos.ForSelection == false,
bShiftCurrObj = (SearchPos.ForSelection == true && this.SelectStartPos == CurPos);
//console.log("Get_LeftPos : CurPos " + CurPos + " SelectStartPos " + this.SelectStartPos);
if( bNotshift || bShiftCurrObj )
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, UseContentPos, EndRun);
}
else if(EndRun)
{
......@@ -6393,7 +6410,7 @@ CMathContent.prototype =
}
else
{
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, bUseContent);
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, UseContentPos);
}
SearchPos.Pos.Update(CurPos, Depth);
......@@ -6405,7 +6422,7 @@ CMathContent.prototype =
EndRun = true;
CurPos--;
bUseContent = false;
UseContentPos = false;
}
result = SearchPos.Found;
......@@ -6435,7 +6452,13 @@ CMathContent.prototype =
}
else if(curType == MATH_COMP)
{
this.content[CurPos].Get_RightPos(SearchPos, ContentPos, Depth + 1, bUseContent, StepEnd, BegRun);
var bNotshift = SearchPos.ForSelection == false,
bShiftCurrObj = SearchPos.ForSelection == true && this.SelectStartPos == CurPos;
//console.log("Get_RightPos : CurPos " + CurPos + " SelectStartPos " + this.SelectStartPos);
if( bNotshift || bShiftCurrObj )
this.content[CurPos].Get_RightPos(SearchPos, ContentPos, Depth + 1, bUseContent, StepEnd, BegRun);
}
else if(BegRun)
{
......@@ -6710,7 +6733,7 @@ CMathContent.prototype =
this.content[this.CurPos + 1].SetSelectAll();
}
}
else if(this.content[this.CurPos].typeObj == MATH_COMP )
else if(this.content[this.CurPos].typeObj == MATH_COMP)
{
if(this.content[this.CurPos].IsCurrentPlh())
{
......
......@@ -1015,10 +1015,6 @@ CRadical.prototype.Resize = function(Parent, ParaMath, oMeasure)
this.RecalcInfo.bCtrPrp = false;
}
//var base, degr;
var shTop,
height, width, ascent;
if(this.RecalcInfo.bProps)
{
if(this.Pr.degHide == true)
......@@ -1064,7 +1060,8 @@ CRadical.prototype.Resize = function(Parent, ParaMath, oMeasure)
this.Iterator.Resize(this, ParaMath, oMeasure);
this.RealBase.Resize(this, ParaMath, oMeasure);
}
var shTop,
height, width, ascent;
this.signRadical.recalculateSize(oMeasure, this.RealBase.size);
......
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