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

Реализовала поиск по позиции для EqqArray с учетом выравниваний (поправила...

Реализовала поиск по позиции для EqqArray с учетом выравниваний (поправила Recalculate_CurPos, Get_ParaContentPosByXY)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58058 954022d7-b5bf-4e40-9824-e11837661b57
parent 2afdd9bb
......@@ -25,8 +25,6 @@ function ParaMath()
this.Root = new CMathContent();
this.Root.bRoot = true;
this.NotDraw = false;
//this.Root.setComposition(this);
this.X = 0;
this.Y = 0;
......@@ -548,20 +546,15 @@ ParaMath.prototype =
this.Root.Resize(g_oTextMeasurer, null, this, RPI/*recalculate properties info*/, ArgSize, TextPr);
this.NotDraw = RPI.bManyRuns;
//this.Root.Resize(null, this, g_oTextMeasurer, RPI/*recalculate properties info*/, TextPr);
this.OldMathPara = this.MathPara;
var PosInfo = new CMathPosInfo();
var pos = new CMathPosition();
pos.x = 0;
pos.y = 0;
this.Root.setPosition(pos, PosInfo);
this.Root.setPosition(pos);
this.Width = this.Root.size.width;
this.Height = this.Root.size.height;
......@@ -1235,8 +1228,7 @@ ParaMath.prototype =
// this.absPos.x ~> this.X
// this.absPos.y ~> this.Y
//if(this.NotDraw == false)
this.Root.draw( PDSE.X, PDSE.Y - this.Ascent, PDSE.Graphics);
this.Root.draw( PDSE.X, PDSE.Y - this.Ascent, PDSE.Graphics);
PDSE.X += this.Width;
......@@ -1338,18 +1330,6 @@ ParaMath.prototype =
Result = this.Root.Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
/*var str = "Get_ParaContentPosByXY :";
//console.log("Get_ParaContentPosByXY");
for(var i = 0; i < SearchPos.Pos.Data.length; i++)
{
str += SearchPos.Pos.Data[i] + " ";
}
if(this.Id == "80")
console.log(str);*/
if ( D >= - 0.001 && D <= Dx + 0.001 )
{
SearchPos.DiffX = 0.001;
......@@ -1407,14 +1387,6 @@ ParaMath.prototype =
this.Root.Get_ParaContentPos(bSelection, bStart, ContentPos);
/*console.log("Get_ParaContentPos");
var str = "";
for(var i = 0; i < ContentPos.Data.length; i++)
{
str += ContentPos.Data[i] + ", ";
}
console.log(str);*/
return ContentPos;
},
......@@ -1479,15 +1451,6 @@ ParaMath.prototype =
{
// TODO: ParaMath.Get_StartEndPos
this.Root.Get_WordStartPos(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);*/
},
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd)
......
......@@ -14299,9 +14299,11 @@ function CParagraphSearchPosXY()
this.InTextPos = new CParagraphContentPos();
this.CurX = 0;
this.CurY = 0;
this.X = 0;
this.Y = 0;
this.DiffX = 1000000; // километра для ограничения должно хватить
this.DiffY = 1000000;
this.NumberingDiffX = 1000000; // километра для ограничения должно хватить
this.Line = 0;
......
......@@ -50,11 +50,11 @@ function ParaRun(Paragraph, bMathRun)
if(bMathRun)
{
this.Type = para_Math_Run;
this.MathPrp = new CMPrp();
this.Parent = null;
this.bEqqArray = false;
//this.WidthsPoints = [];
this.size = new CMathSize();
this.MathPrp = new CMPrp();
}
this.StartState = null;
......@@ -625,7 +625,7 @@ ParaRun.prototype =
return new CParaPos( ( LinesCount === 1 ? this.Lines[0].RangesLength - 1 + this.StartRange : this.Lines[0].RangesLength - 1 ), LinesCount - 1 + this.StartLine, 0, 0 );
},
Recalculate_CurPos : function(X, Y, CurrentRun, _CurRange, _CurLine, CurPage, UpdateCurPos, UpdateTarget, ReturnTarget)
Recalculate_CurPos : function(X, Y, CurrentRun, _CurRange, _CurLine, CurPage, UpdateCurPos, UpdateTarget, ReturnTarget, PointInfo)
{
var Para = this.Paragraph;
......@@ -664,9 +664,16 @@ ParaRun.prototype =
X += Item.WidthVisible;
break;
}
case para_Math_Ampersand:
{
PointInfo.NextAlignRange();
X += PointInfo.GetAlign();
}
}
}
if ( true === CurrentRun && Pos === this.State.ContentPos )
{
if ( true === UpdateCurPos )
......@@ -801,7 +808,6 @@ ParaRun.prototype =
}
}
return { X : X, Y : TargetY, Height : Height, Internal : { Line : CurLine, Page : CurPage, Range : CurRange } };
}
else
......@@ -809,6 +815,7 @@ ParaRun.prototype =
}
return { X : X, Y: Y, Internal : { Line : CurLine, Page : CurPage, Range : CurRange } };
},
......@@ -3659,7 +3666,7 @@ ParaRun.prototype =
}
},
Get_ParaContentPosByXY : function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
Get_ParaContentPosByXY : function(SearchPos, Depth, _CurLine, _CurRange, StepEnd, PointInfo)
{
var Result = false;
......@@ -3671,21 +3678,40 @@ ParaRun.prototype =
var EndPos = Range.EndPos;
var CurPos = StartPos;
//only for para_Math_Run
var bUpdateDiffY = true,
DiffY;
/*if(this.Type == para_Math_Run)
{
DiffY = SearchPos.Y - SearchPos.CurY;
if(Math.abs(DiffY) > SearchPos.DiffY)
bUpdateDiffY = false;
}*/
for (; CurPos < EndPos; CurPos++ )
{
var Item = this.Content[CurPos];
var TempDx = 0;
if ( para_Drawing != Item.Type || true === Item.Is_Inline() )
if(Item.Type == para_Math_Ampersand)
{
PointInfo.NextAlignRange();
TempDx = PointInfo.GetAlign();
}
else if ( para_Drawing != Item.Type || true === Item.Is_Inline() )
{
TempDx = Item.WidthVisible;
}
// Проверяем, попали ли мы в данный элемент
var Diff = SearchPos.X - SearchPos.CurX;
if ( Math.abs( Diff ) < SearchPos.DiffX + 0.001 )
if ( Math.abs( Diff ) < SearchPos.DiffX + 0.001 /*&& bUpdateDiffY*/)
{
//SearchPos.DiffY = Math.abs(DiffY);
SearchPos.DiffX = Math.abs( Diff );
SearchPos.Pos.Update( CurPos, Depth );
Result = true;
......@@ -3700,7 +3726,7 @@ ParaRun.prototype =
SearchPos.CurX += TempDx;
// Заглушка для знака параграфа и конца строки
if ( Math.abs( SearchPos.X - SearchPos.CurX ) < SearchPos.DiffX )
if ( Math.abs( SearchPos.X - SearchPos.CurX ) < SearchPos.DiffX /*&& bUpdateDiffY*/)
{
if ( para_End === Item.Type )
{
......@@ -3729,11 +3755,12 @@ ParaRun.prototype =
Result = true;
}
if (this.Type == para_Math_Run /*&& this.Is_Empty()*/) // не только для пустых Run, но и для проверки на конец Run (т.к. Diff не обновляется)
if (this.Type == para_Math_Run /*&& bUpdateDiffY*/ /*&& this.Is_Empty()*/) // не только для пустых Run, но и для проверки на конец Run (т.к. Diff не обновляется)
{
var Diff = SearchPos.X - SearchPos.CurX;
if ( Math.abs( Diff ) < SearchPos.DiffX + 0.001 )
{
//SearchPos.DiffY = Math.abs(DiffY);
SearchPos.DiffX = Math.abs( Diff );
SearchPos.Pos.Update( CurPos, Depth );
Result = true;
......@@ -4053,7 +4080,7 @@ ParaRun.prototype =
while ( CurPos < ContentLen - 1 )
{
CurPos++;
var Item = this.Content[CurPos]
var Item = this.Content[CurPos];
var TempType = Item.Type;
if ( (true !== StepEnd && para_End === TempType) || !( para_Space === TempType || ( para_Text === TempType && true === Item.Is_NBSP() ) ) )
......@@ -4385,7 +4412,7 @@ ParaRun.prototype =
{
for ( var CurPos = StartPos; CurPos < EndPos; CurPos++ )
{
if ( para_End !== this.Content[CurPos].Type )
if ( para_End !== this.Content[CurPos].Type && para_Math_Ampersand !== this.Content[CurPos].Type) // para_math_Ampersand имеет нулевую ширину, поэтому чтобы не случилось так что не было ни селекта, ни курсора, не учитываем para_Math_Ampersand
return false;
}
}
......@@ -7577,7 +7604,7 @@ ParaRun.prototype.Math_SetPosition = function(PosInfo)
if(this.Content[Pos].Type == para_Math_Ampersand)
{
PosInfo.UpdatePoint();
PosInfo.NextAlignRange();
PosInfo.ApplyAlign();
NewPos.x = PosInfo.x;
......@@ -7595,7 +7622,6 @@ ParaRun.prototype.Math_SetPosition = function(PosInfo)
PosInfo.UpdateX(CurrElem.size.width);
}
}
else
{
......
This diff is collapsed.
......@@ -745,11 +745,13 @@ CMathAmp.prototype =
{
this.size =
{
width: this.AmpText.size.width,
height: this.AmpText.size.height,
ascent: this.AmpText.size.ascent
width: this.AmpText.size.width,
height: this.AmpText.size.height,
ascent: this.AmpText.size.ascent
};
}
this.WidthVisible = this.size.width;
},
setPosition: function(pos)
{
......
......@@ -283,10 +283,13 @@ CMathMatrix.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLi
H += Heights[i] + this.gaps.row[i];
}
var SearchCurX = SearchPos.CurX;
var align = this.align(CurrX, CurrY);
var SearchCurX = SearchPos.CurX + this.GapLeft + W_CurX ;
if(this.kind === MATH_MATRIX)
{
SearchPos.CurX += this.align(CurrX, CurrY).x;
}
SearchPos.CurX += this.GapLeft + W_CurX + align.x;
var result = this.elements[CurrX][CurrY].Get_ParaContentPosByXY(SearchPos, Depth+2, _CurLine, _CurRange, StepEnd);
......@@ -770,7 +773,7 @@ CEqArray.prototype.getMetrics = function(RPI)
for(var i = 0; i < this.nRow; i++)
{
var WidthsRow = this.elements[i][0].WidthPoints.Widths,
var WidthsRow = this.elements[i][0].getWidthsPoints(),
len = WidthsRow.length;
if(Pos < len)
......
......@@ -3760,8 +3760,6 @@ CDelimiter.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLin
sepWidth = this.sepOper.size.width,
endWidth = this.endOper.size.width;
SearchPos.Pos.Update(0, Depth);
SearchPos.CurX += begWidth + this.GapLeft;
var result;
......@@ -3770,6 +3768,7 @@ CDelimiter.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLin
{
if(this.elements[0][j].Get_ParaContentPosByXY(SearchPos, Depth+2, _CurLine, _CurRange, StepEnd))
{
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(j, Depth+1);
result = true;
}
......@@ -3987,13 +3986,16 @@ CCharacter.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLin
{
var align = (this.size.width - this.elements[0][0].size.width)/2;
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(0, Depth+1);
SearchPos.CurX += this.GapLeft + align;
var result = this.elements[0][0].Get_ParaContentPosByXY(SearchPos, Depth+2, _CurLine, _CurRange, StepEnd);
if(result)
{
SearchPos.Pos.Update(0, Depth);
SearchPos.Pos.Update(0, Depth+1);
}
SearchPos.CurX += this.GapRight + align;
return result;
......
......@@ -1150,10 +1150,6 @@ CRadical.prototype.setPosition = function(pos, PosInfo)
}
else if(this.Pr.type == DEGREE_RADICAL)
{
/*var degr = this.elements[0][0].size,
base = this.elements[0][1].size,
sign = this.signRadical.size;*/
var wTick = this.signRadical.measure.widthTick;
var PosDegree = new CMathPosition();
......@@ -1216,54 +1212,15 @@ CRadical.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine,
}
CRadical.prototype.draw = function(x, y, pGraphics)
{
////// test //////
/*var xx = x + this.pos.x,
yy = y + this.pos.y,
w = this.size.width,
h = this.size.height;
pGraphics.p_width(1000);
pGraphics.b_color1(0,0,250, 255);
pGraphics._s();
pGraphics._m(xx, yy);
pGraphics._l(xx + w, yy);
pGraphics._l(xx + w, yy + h);
pGraphics._l(xx, yy + h);
pGraphics._l(xx, yy);
pGraphics.df();*/
this.signRadical.draw(x, y, pGraphics);
CRadical.superclass.draw.call(this, x, y, pGraphics);
}
CRadical.prototype.getBase = function()
{
/*var base = null;
if(this.Pr.type == SQUARE_RADICAL)
base = this.elements[0][0];
else if(this.Pr.type == DEGREE_RADICAL)
base = this.elements[0][1];*/
return this.Base;
}
CRadical.prototype.getDegree = function()
{
/*var degree = null;
if(this.type == DEGREE_RADICAL)
degree = this.elements[0][0];
else if(this.type = SQUARE_RADICAL)
degree = this.elements[0][0];*/
// для стремной ситуации, когда руками в xml выставили в degHide true, а объект со степенью имеется, возвращаем основание
/*var iterator = null;
if(this.Pr.degHide == false)
iterator = this.elements[0][0];*/
return this.Iterator;
}
CRadical.prototype.getPropsForWrite = 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