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

курсор и селект для формулы ( для ParaMath )

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55130 954022d7-b5bf-4e40-9824-e11837661b57
parent b567eef2
...@@ -5,13 +5,17 @@ ...@@ -5,13 +5,17 @@
function ParaMath(bAddMenu, bCollaborative) function ParaMath(bAddMenu, bCollaborative)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
this.Type = para_Math; this.Type = para_Math;
this.Jc = undefined; this.Jc = undefined;
this.Math = new CMathComposition(bCollaborative); this.Math = new CMathComposition(bCollaborative);
this.Math.Parent = this; this.Math.Parent = this;
this.Content = this.Math.Root.content; // Root.content this.RootComposition = this.Math.Root;
this.CurrentContent = this.RootComposition;
this.SelectContent = this.RootComposition;
this.bSelectionUse = false;
this.State = new CParaRunState(); // Положение курсора и селекта для данного run this.State = new CParaRunState(); // Положение курсора и селекта для данного run
this.Paragraph = null; this.Paragraph = null;
...@@ -405,7 +409,7 @@ ParaMath.prototype = ...@@ -405,7 +409,7 @@ ParaMath.prototype =
if ( true !== PRS.NewRange ) if ( true !== PRS.NewRange )
{ {
RangeEndPos = this.Content.length; // RangeEndPos = 1; to RangeEndPos = this.Content.length; RangeEndPos = this.RootComposition.content.length; // RangeEndPos = 1; to RangeEndPos = this.Content.length;
// Удаляем лишние строки, оставшиеся после предыдущего пересчета в самом конце // Удаляем лишние строки, оставшиеся после предыдущего пересчета в самом конце
if ( this.Lines.length > this.LinesLength ) if ( this.Lines.length > this.LinesLength )
...@@ -583,9 +587,9 @@ ParaMath.prototype = ...@@ -583,9 +587,9 @@ ParaMath.prototype =
var StartPos = this.Lines[CurLine].Ranges[CurRange].StartPos; var StartPos = this.Lines[CurLine].Ranges[CurRange].StartPos;
var EndPos = this.Lines[CurLine].Ranges[CurRange].EndPos; var EndPos = this.Lines[CurLine].Ranges[CurRange].EndPos;
if ( EndPos >= 1 ) if ( EndPos >= 1)
{ {
return this.Math.UpdateCursor(); return this.CurrentContent.update_Cursor(_CurPage, UpdateTarget);
} }
return {X : X }; return {X : X };
...@@ -704,7 +708,7 @@ ParaMath.prototype = ...@@ -704,7 +708,7 @@ ParaMath.prototype =
this.Math.Cursor_MoveToEndPos(); this.Math.Cursor_MoveToEndPos();
}, },
Get_ParaContentPosByXY : function(SearchPos, Depth, _CurLine, _CurRange, StepEnd) Get_ParaContentPosByXY : function(SearchPos, Depth, _CurLine, _CurRange, StepEnd) // получить логическую позицию по XY
{ {
// TODO: ParaMath.Get_ParaContentPosByXY // TODO: ParaMath.Get_ParaContentPosByXY
...@@ -723,23 +727,38 @@ ParaMath.prototype = ...@@ -723,23 +727,38 @@ ParaMath.prototype =
var Dx = this.Math.Size.WidthVisible; var Dx = this.Math.Size.WidthVisible;
var D = SearchPos.X - SearchPos.CurX; var D = SearchPos.X - SearchPos.CurX;
//var Diff = Math.abs(D) < Math.abs(D - Dx) ? Math.abs(D) : Math.abs(D - Dx); var Diff = Math.abs(D) < Math.abs(D + Dx) ? Math.abs(D) : Math.abs(D + Dx);
var Diff = SearchPos.X - SearchPos.CurX; //var Diff = SearchPos.X - SearchPos.CurX;
if(Math.abs(Diff) < SearchPos.DiffX + 0.001 ) if(Math.abs(Diff) < SearchPos.DiffX + 0.001 )
{ {
SearchPos.DiffX = Math.abs(Diff); var X = SearchPos.X - this.Math.absPos.x,
this.Math.Selection_SetStart(SearchPos.X, SearchPos.Y); Y = SearchPos.Y - this.Math.absPos.y;
this.Math.Selection_SetEnd(SearchPos.X, SearchPos.Y);
this.Math.Root.get_ParaContentPos(false, SearchPos.Pos); SearchPos.DiffX = Diff;
this.RootComposition.get_ParaContentPosByXY(SearchPos.Pos, X, Y);
//this.Math.Selection_SetStart(SearchPos.X, SearchPos.Y);
//this.Math.Selection_SetEnd(SearchPos.X, SearchPos.Y);
//this.Math.Root.get_ParaContentPos(false, SearchPos.Pos);
Result = true; Result = true;
if ( Diff >= - 0.001 && Diff <= Dx + 0.001 ) if ( D >= - 0.001 && D <= Dx + 0.001 )
{ {
SearchPos.InText = true; SearchPos.InText = true;
SearchPos.DiffX = 0.001; // сравниваем расстояние до ближайшего элемента
} }
} }
// var str = "";
// for(var i = 0; i < SearchPos.Pos.Data.length; i++)
// {
// str += SearchPos.Pos.Data[i] + ", ";
//
// }
// console.log(str);
//console.log("Pos [" + i + "] = " + SearchPos.Pos[i]);
SearchPos.CurX += Dx; SearchPos.CurX += Dx;
/*for(var CurPos = StartPos; CurPos < EndPos; CurPos++) /*for(var CurPos = StartPos; CurPos < EndPos; CurPos++)
...@@ -785,24 +804,22 @@ ParaMath.prototype = ...@@ -785,24 +804,22 @@ ParaMath.prototype =
return Result; return Result;
}, },
Get_ParaContentPos : function(bSelection, bStart, ContentPos) // получение позиции контентов Get_ParaContentPos : function(bSelection, bStart, ContentPos) // получить текущую логическую позицию
{ {
// TODO: ParaMath.Get_ParaContentPos // TODO: ParaMath.Get_ParaContentPos
this.Math.Root.get_ParaContentPos(bStart, ContentPos); this.RootComposition.get_ParaContentPos(bSelection, bStart, ContentPos);
}, },
Set_ParaContentPos : function(ContentPos, Depth) // выставить логическую позицию в контенте
Set_ParaContentPos : function(ContentPos, Depth) // выставить позицию в конетенте
{ {
// TODO: ParaMath.Set_ParaContentPos // TODO: ParaMath.Set_ParaContentPos
var Pos = ContentPos.Get(Depth); var Pos = ContentPos.Get(Depth);
this.State.ContentPos = Pos; this.State.ContentPos = Pos;
this.Math.Root.set_ParaContentPos(ContentPos, Depth); this.RootComposition.set_ParaContentPos(ContentPos, Depth);
}, },
Get_PosByElement : function(Class, ContentPos, Depth, UseRange, Range, Line) Get_PosByElement : function(Class, ContentPos, Depth, UseRange, Range, Line)
{ {
if ( this === Class ) if ( this === Class )
...@@ -868,23 +885,58 @@ ParaMath.prototype = ...@@ -868,23 +885,58 @@ ParaMath.prototype =
Set_SelectionContentPos : function(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag) Set_SelectionContentPos : function(StartContentPos, EndContentPos, Depth, StartFlag, EndFlag)
{ {
// TODO: ParaMath.Set_SelectionContentPos // TODO: ParaMath.Set_SelectionContentPos
this.SelectContent = this.RootComposition;
switch (StartFlag)
{
case 1:
this.RootComposition.setLogicalPosition(1);
break;
case -1:
this.RootComposition.setLogicalPosition(this.RootComposition.length - 1);
break;
case 0:
this.RootComposition.set_StartSelectContent(StartContentPos, Depth);
break;
}
switch (EndFlag)
{
case 1:
this.RootComposition.set_SelectEndExtreme(false);
break;
case -1:
this.RootComposition.set_SelectEndExtreme(true);
break;
case 0:
var result = this.RootComposition.set_EndSelectContent(EndContentPos, Depth);
this.SelectContent = result.SelectContent;
break;
}
this.bSelectionUse = true;
}, },
Selection_IsUse : function() Selection_IsUse : function()
{ {
// TODO: ParaMath.Selection_IsUse // TODO: ParaMath.Selection_IsUse
return false; return this.bSelectionUse;
}, },
Selection_Stop : function() Selection_Stop : function()
{ {
},
},
Selection_Remove : function() Selection_Remove : function()
{ {
// TODO: ParaMath.Selection_Remove // TODO: ParaMath.Selection_Remove
},
this.bSelectionUse = false;
},
Select_All : function(Direction) Select_All : function(Direction)
{ {
// TODO: ParaMath.Select_All // TODO: ParaMath.Select_All
...@@ -898,16 +950,42 @@ ParaMath.prototype = ...@@ -898,16 +950,42 @@ ParaMath.prototype =
var StartPos = this.Lines[CurLine].Ranges[CurRange].StartPos; var StartPos = this.Lines[CurLine].Ranges[CurRange].StartPos;
var EndPos = this.Lines[CurLine].Ranges[CurRange].EndPos; var EndPos = this.Lines[CurLine].Ranges[CurRange].EndPos;
if ( EndPos >= 1 ) if ( EndPos >= 1 )
{
if ( true === this.bSelectionUse )
{ {
// TODO: ParaMath.Selection_Draw_Range // TODO: ParaMath.Selection_Draw_Range
if(SelectionDraw.FindStart == true)
{
if(this.SelectContent.selectUse())
{
SelectionDraw.FindStart = false;
this.SelectContent.drawSelect(SelectionDraw);
}
}
else
{
if(this.RootComposition.selectUse())
SelectionDraw.W += this.RootComposition.size.width;
}
}
else
{
if ( true === SelectionDraw.FindStart )
SelectionDraw.StartX += this.Width;
}
} }
}, },
Selection_IsEmpty : function(CheckEnd) Selection_IsEmpty : function(CheckEnd)
{ {
// TODO: ParaMath.Selection_IsEmpty // TODO: ParaMath.Selection_IsEmpty
return true;
return !this.SelectContent.selectUse();
}, },
Selection_CheckParaEnd : function() Selection_CheckParaEnd : function()
......
...@@ -10608,7 +10608,7 @@ function Binary_oMathReader(stream) ...@@ -10608,7 +10608,7 @@ function Binary_oMathReader(stream)
props.init = true; props.init = true;
} }
var oDeg = oRad.getDegree(); var oDeg = oRad.getDegree();
if (oDeg && length == 0) if (oDeg && length == 0 && props.degHide !== true)
oDeg.fillPlaceholders(); oDeg.fillPlaceholders();
res = this.bcr.Read1(length, function(t, l){ res = this.bcr.Read1(length, function(t, l){
return oThis.ReadMathArg(t,l,oDeg); return oThis.ReadMathArg(t,l,oDeg);
......
...@@ -851,6 +851,58 @@ CMathBase.prototype = ...@@ -851,6 +851,58 @@ CMathBase.prototype =
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag}; return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}, },
excludeJDElement: function(Cur_X, Cur_Y)
{
var pos_X = Cur_X,
pos_Y = Cur_Y;
if( this.elements[Cur_X][Cur_Y].IsJustDraw() )
{
if(this.nRow > 1)
{
if(Cur_X == 0)
pos_X = 1;
else if(Cur_X == this.nRow - 1)
pos_X = this.nRow - 2;
else
{
// пока так
pos_X = Cur_X + 1;
/* if( mCoord.y < (_h - Heights[posCurs.x]/2) )
posCurs.x--;
else
posCurs.x++;*/
}
pos_Y = Cur_Y;
}
else if(this.nCol > 1)
{
if(Cur_Y == 0)
pos_Y = 1;
else if(Cur_Y == this.nCol - 1)
pos_Y = this.nCol - 2;
else
{
// пока так
pos_Y = Cur_Y + 1;
/*if( mCoord.x < (_w - Widths[u]/2) )
posCurs.y = u - 1;
else
posCurs.y = u + 1;*/
}
}
else
return; // не самое лучшее решение, в идеале если у нас если такая ситуация получилась
// (что сомнительно, в контенте один элемент с которым ничего нельзя сделать),
// то вставать после этого элемента в контенте на уровень выше
// лучше следить за подобными ситуациями, чтобы такого не было
}
return {x: pos_X, y: pos_Y};
},
setPosition: function(pos) setPosition: function(pos)
{ {
if(this.bMObjs === true) if(this.bMObjs === true)
...@@ -1180,22 +1232,83 @@ CMathBase.prototype = ...@@ -1180,22 +1232,83 @@ CMathBase.prototype =
/// Position for Paragraph /// Position for Paragraph
get_ParaContentPosByXY: function(ContentPos, X, Y)
{
/// элементов just-draw не должно прийти
var disp = this.findDisposition({x: X, y: Y});
ContentPos.Add(disp.pos.x);
ContentPos.Add(disp.pos.y);
get_ParaContentPos: function(bStart, ContentPos) this.elements[disp.pos.x][disp.pos.y].get_ParaContentPosByXY(ContentPos, disp.mCoord.x, disp.mCoord.y);
},
get_ParaContentPos: function(bSelection, bStart, ContentPos)
{ {
ContentPos.Add(this.CurPos_X); ContentPos.Add(this.CurPos_X);
ContentPos.Add(this.CurPos_Y); ContentPos.Add(this.CurPos_Y);
this.elements[this.CurPos_X][this.CurPos_Y].get_ParaContentPos(bStart, ContentPos); this.elements[this.CurPos_X][this.CurPos_Y].get_ParaContentPos(bSelection, bStart, ContentPos);
}, },
set_ParaContentPos: function(ContentPos, Depth) set_ParaContentPos: function(ContentPos, Depth)
{ {
this.CurPos_X = ContentPos.Get(Depth); var CurPos_X = ContentPos.Get(Depth);
this.CurPos_Y = ContentPos.Get(Depth + 1); var CurPos_Y = ContentPos.Get(Depth + 1);
if(!this.elements[CurPos_X][CurPos_Y].IsJustDraw())
{
var disp = this.excludeJDElement(CurPos_X, CurPos_Y);
CurPos_X = disp.x;
CurPos_Y = disp.y;
}
this.CurPos_X = CurPos_X;
this.CurPos_Y = CurPos_Y;
Depth += 2;
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; Depth += 2;
this.elements[this.CurPos_X][this.CurPos_Y].set_ParaContentPos(ContentPos, Depth); 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};
} }
////////////////////////// //////////////////////////
......
This diff is collapsed.
...@@ -232,6 +232,12 @@ CMathText.prototype = ...@@ -232,6 +232,12 @@ CMathText.prototype =
}, },
Resize: function(oMeasure) Resize: function(oMeasure)
{ {
// смещения
// rasterOffsetX
// rasterOffsetY
var letter = this.getCode(); var letter = this.getCode();
var metricsTxt = oMeasure.Measure2Code(letter); var metricsTxt = oMeasure.Measure2Code(letter);
......
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