lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 03a8b4b7 authored by Anna.Pavlova's avatar Anna.Pavlova

1. Поправила поиск позиций в целом для EqqArray и для мат объектов в контенте

(можно встать в пустой Run, как и раньше,при этом для EqqArray правильно выставляется курсор, т.е. на поиске проходим по всем Run контента)
2. Поправила баг, в случае когда степень в основании диакритического элемента (итератор уезжал наверх, когда в основании диакритического элемента был мат объект, по высоте больше текста)
3. Поправила баг для степени: теперь осуществляется более общая проверка для смещения итератора,
проверка на наличии текста в контенте либо на наличие мат. элементов занимающих не более одной строки
и содержащих только текст в контентах либо аналогичные мат объекты
4. Поправила баг для поиска позиции в матрицы: неправильно рассчитывался CurX для SearchPos в матрице

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58078 954022d7-b5bf-4e40-9824-e11837661b57
parent 181bfb1c
...@@ -1335,6 +1335,14 @@ ParaMath.prototype = ...@@ -1335,6 +1335,14 @@ ParaMath.prototype =
SearchPos.DiffX = 0.001; SearchPos.DiffX = 0.001;
} }
/*var str = "";
for(var i = 0; i < SearchPos.Pos.Data.length; i++)
{
str += SearchPos.Pos.Data[i] + " ";
}
console.log(str);*/
/*if(Math.abs(Diff) < SearchPos.DiffX + 0.001) /*if(Math.abs(Diff) < SearchPos.DiffX + 0.001)
{ {
......
...@@ -14474,9 +14474,7 @@ function CParagraphSearchPosXY() ...@@ -14474,9 +14474,7 @@ function CParagraphSearchPosXY()
this.CurX = 0; this.CurX = 0;
this.CurY = 0; this.CurY = 0;
this.X = 0; this.X = 0;
this.Y = 0;
this.DiffX = 1000000; // километра для ограничения должно хватить this.DiffX = 1000000; // километра для ограничения должно хватить
this.DiffY = 1000000;
this.NumberingDiffX = 1000000; // километра для ограничения должно хватить this.NumberingDiffX = 1000000; // километра для ограничения должно хватить
this.Line = 0; this.Line = 0;
......
...@@ -3719,16 +3719,7 @@ ParaRun.prototype = ...@@ -3719,16 +3719,7 @@ ParaRun.prototype =
var CurPos = StartPos; var CurPos = StartPos;
//only for para_Math_Run var bNotUpdate = SearchPos.InText && this.Type === 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++ ) for (; CurPos < EndPos; CurPos++ )
{ {
...@@ -3749,9 +3740,69 @@ ParaRun.prototype = ...@@ -3749,9 +3740,69 @@ ParaRun.prototype =
// Проверяем, попали ли мы в данный элемент // Проверяем, попали ли мы в данный элемент
var Diff = SearchPos.X - SearchPos.CurX; var Diff = SearchPos.X - SearchPos.CurX;
if ( Math.abs( Diff ) < SearchPos.DiffX + 0.001 /*&& bUpdateDiffY*/) /*if(this.Type == para_Math_Run)
{
var r0 = SearchPos.Y - (SearchPos.CurY - this.size.ascent),
r1 = r0 - this.size.height;
var DiffY = Math.abs(r0) < Math.abs(r1) ? Math.abs(r0) : Math.abs(r1);
if (Diff*Diff + DiffY*DiffY < SearchPos.DiffXY + 0.001)
{
SearchPos.DiffXY = Diff*Diff + DiffY*DiffY;
SearchPos.Pos.Update( CurPos, Depth );
Result = true;
if(Diff >= - 0.001 && Diff <= TempDx + 0.001 && r0 > - 0.001 && r1 < -0.001)
{
SearchPos.InTextPos.Update( CurPos, Depth );
SearchPos.InText = true;
}
}
//SearchPos.DiffX = Math.abs( Diff );
//SearchPos.Pos.Update( CurPos, Depth );
//Result = true;
// almost work
/*//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//*/
*//*var r0 = SearchPos.Y - (SearchPos.CurY - this.size.ascent),
r1 = r0 - this.size.height;
var DiffY = Math.abs(r0) < Math.abs(r1) ? Math.abs(r0) : Math.abs(r1);
if(Math.abs( Diff ) < SearchPos.DiffX + 0.001)
{
var delta = Math.abs( Diff ) - SearchPos.DiffX;
var bUpdate = !(Math.abs(delta) < 0.1 && (DiffY > SearchPos.DiffY));
if( bUpdate )
{
SearchPos.DiffX = Math.abs( Diff );
SearchPos.DiffY = DiffY;
SearchPos.Pos.Update( CurPos, Depth );
Result = true;
if(Diff >= - 0.001 && Diff <= TempDx + 0.001)
{
SearchPos.InTextPos.Update( CurPos, Depth );
SearchPos.InText = true;
}
}
}*//*
/*//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//**//*/
*//*if ( Diff >= - 0.001 && Diff <= TempDx + 0.001 )
{
SearchPos.InTextPos.Update( CurPos, Depth );
SearchPos.InText = true;
}*//*
}
else*/
if ( Math.abs( Diff ) < SearchPos.DiffX + 0.001 && !bNotUpdate)
{ {
//SearchPos.DiffY = Math.abs(DiffY);
SearchPos.DiffX = Math.abs( Diff ); SearchPos.DiffX = Math.abs( Diff );
SearchPos.Pos.Update( CurPos, Depth ); SearchPos.Pos.Update( CurPos, Depth );
Result = true; Result = true;
...@@ -3766,7 +3817,7 @@ ParaRun.prototype = ...@@ -3766,7 +3817,7 @@ ParaRun.prototype =
SearchPos.CurX += TempDx; SearchPos.CurX += TempDx;
// Заглушка для знака параграфа и конца строки // Заглушка для знака параграфа и конца строки
if ( Math.abs( SearchPos.X - SearchPos.CurX ) < SearchPos.DiffX /*&& bUpdateDiffY*/) if ( Math.abs( SearchPos.X - SearchPos.CurX ) < SearchPos.DiffX && !bNotUpdate)
{ {
if ( para_End === Item.Type ) if ( para_End === Item.Type )
{ {
...@@ -3789,22 +3840,83 @@ ParaRun.prototype = ...@@ -3789,22 +3840,83 @@ ParaRun.prototype =
// Такое возможно, если все раны до этого (в том числе и этот) были пустыми, тогда, чтобы не возвращать // Такое возможно, если все раны до этого (в том числе и этот) были пустыми, тогда, чтобы не возвращать
// неправильную позицию вернем позицию начала данного путого рана. // неправильную позицию вернем позицию начала данного путого рана.
if ( SearchPos.DiffX > 1000000 - 1 )
if ( SearchPos.DiffX > 1000000 - 1)
{ {
SearchPos.Pos.Update( StartPos, Depth ); SearchPos.Pos.Update( StartPos, Depth );
Result = true; Result = true;
} }
if (this.Type == para_Math_Run /*&& bUpdateDiffY*/ /*&& this.Is_Empty()*/) // не только для пустых Run, но и для проверки на конец Run (т.к. Diff не обновляется) if (this.Type == para_Math_Run) // не только для пустых Run, но и для проверки на конец Run
{ {
var Diff = SearchPos.X - SearchPos.CurX; var Diff = SearchPos.X - SearchPos.CurX;
if ( Math.abs( Diff ) < SearchPos.DiffX + 0.001 )
/* var r0 = SearchPos.Y - (SearchPos.CurY - this.size.ascent),
r1 = r0 - this.size.height;
var DiffY = Math.abs(r0) < Math.abs(r1) ? Math.abs(r0) : Math.abs(r1);
if (Diff*Diff + DiffY*DiffY < SearchPos.DiffXY + 0.001)
{
SearchPos.DiffXY = Diff*Diff + DiffY*DiffY;
SearchPos.Pos.Update( CurPos, Depth );
Result = true;
if(Diff >= - 0.001 && Diff <= TempDx + 0.001 && r0 > - 0.001 && r1 < -0.001)
{
SearchPos.InTextPos.Update( CurPos, Depth );
SearchPos.InText = true;
}
}*/
if ( Math.abs( Diff ) < SearchPos.DiffX + 0.001 && !bNotUpdate)
{ {
//SearchPos.DiffY = Math.abs(DiffY);
SearchPos.DiffX = Math.abs( Diff ); SearchPos.DiffX = Math.abs( Diff );
SearchPos.Pos.Update( CurPos, Depth ); SearchPos.Pos.Update( CurPos, Depth );
Result = true; Result = true;
/*if ( Diff >= - 0.001 && Diff <= TempDx + 0.001 )
{
SearchPos.InTextPos.Update( CurPos, Depth );
SearchPos.InText = true;
}*/
} }
// almost work
//**//**//**//**//**//**//**//**//**//**//**//**//
/*var r0 = SearchPos.Y - (SearchPos.CurY - this.size.ascent),
r1 = r0 - this.size.height;
var DiffY;
if(r0 > 0 && r1 < 0)
DiffY = 0; // In Content
else
DiffY = Math.abs(r0) < Math.abs(r1) ? Math.abs(r0) : Math.abs(r1);
Diff = SearchPos.X - SearchPos.CurX;
if(Math.abs( Diff ) < SearchPos.DiffX + 0.001)
{
var delta = Math.abs( Diff ) - SearchPos.DiffX;
var bUpdate = !(Math.abs(delta) < 0.1 && (DiffY > SearchPos.DiffY));
if( bUpdate )
{
SearchPos.DiffX = Math.abs( Diff );
SearchPos.DiffY = DiffY;
SearchPos.Pos.Update( CurPos, Depth );
Result = true;
if(Diff >= - 0.001 && Diff <= TempDx + 0.001)
{
SearchPos.InTextPos.Update( CurPos, Depth );
SearchPos.InText = true;
}
}
}*/
//**//**//**//**//**//**//**//**//**//**//**//**//
} }
return Result; return Result;
......
...@@ -476,7 +476,26 @@ CMathBase.prototype = ...@@ -476,7 +476,26 @@ CMathBase.prototype =
{ {
return this.elements[x][y]; return this.elements[x][y];
}, },
IsOneLineText: function() // for degree
{
var bOneLineText = true;
if(this.nRow == 1)
{
for(var j = 0; j < this.nCol; j++)
{
if( !this.elements[0][j].IsOneLineText() )
{
bOneLineText = false;
break;
}
}
}
else
bOneLineText = false;
return bOneLineText;
},
//// For Edit ///// //// For Edit /////
getGapsInside: function(GapsInfo) getGapsInside: function(GapsInfo)
...@@ -900,9 +919,6 @@ CMathBase.prototype = ...@@ -900,9 +919,6 @@ CMathBase.prototype =
} }
/*var str = "Start: Outside " + this.SelectStart.bOutside + ", X " + this.SelectStart.X + ", Y " + this.SelectStart.Y + " ; " + "End: Outside " + this.SelectEnd.bOutside + ", X " + this.SelectEnd.X + ", Y " + this.SelectEnd.Y;
console.log(str);*/
return SearchPos.Found; return SearchPos.Found;
}, },
Get_WordStartPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun) Get_WordStartPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
......
...@@ -136,9 +136,11 @@ CDegree.prototype.recalculateSup = function(oMeasure) ...@@ -136,9 +136,11 @@ CDegree.prototype.recalculateSup = function(oMeasure)
this.upIter = 0; this.upIter = 0;
var oBase = this.elements[0][0]; var oBase = this.elements[0][0];
var bBaseOnlyText = oBase.IsJustDraw() ? false : oBase.IsOnlyText(); // у Just-Draw элементов нет ф-ии IsOnlyText //var bBaseOnlyText = oBase.IsJustDraw() ? false : oBase.IsOnlyText(); // у Just-Draw элементов нет ф-ии IsOnlyText
if(bBaseOnlyText) var bOneLineText = oBase.IsJustDraw() ? false : oBase.IsOneLineText();
if(bOneLineText)
{ {
//var UpBaseline = 1.786*shCenter; // baseline итератора //var UpBaseline = 1.786*shCenter; // baseline итератора
var UpBaseline = 1.65*shCenter; // baseline итератора var UpBaseline = 1.65*shCenter; // baseline итератора
...@@ -156,6 +158,8 @@ CDegree.prototype.recalculateSup = function(oMeasure) ...@@ -156,6 +158,8 @@ CDegree.prototype.recalculateSup = function(oMeasure)
{ {
this.upBase = iter.ascent - 1.2*shCenter; this.upBase = iter.ascent - 1.2*shCenter;
var ascBase = base.ascent - shCenter > 0.27*mgCtrPrp.FontSize ? base.ascent - shCenter : 2/3*base.ascent; var ascBase = base.ascent - shCenter > 0.27*mgCtrPrp.FontSize ? base.ascent - shCenter : 2/3*base.ascent;
// ограничение для случая, когда дескент итератора >> высоты основания
if(iter.height - this.upBase > ascBase) if(iter.height - this.upBase > ascBase)
this.upBase = iter.height - ascBase; this.upBase = iter.height - ascBase;
} }
...@@ -187,9 +191,11 @@ CDegree.prototype.recalculateSubScript = function(oMeasure) ...@@ -187,9 +191,11 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
width += this.GapLeft + this.GapRight; width += this.GapLeft + this.GapRight;
var oBase = this.elements[0][0]; var oBase = this.elements[0][0];
var bBaseOnlyText = oBase.IsJustDraw() ? false : oBase.IsOnlyText(); // у Just-Draw элементов нет ф-ии IsOnlyText //var bBaseOnlyText = oBase.IsJustDraw() ? false : oBase.IsOnlyText(); // у Just-Draw элементов нет ф-ии IsOnlyText
var bOneLineText = oBase.IsJustDraw() ? false : oBase.IsOneLineText();
if(bBaseOnlyText) if(bOneLineText)
{ {
var DownBaseline = 0.9*shCenter; var DownBaseline = 0.9*shCenter;
...@@ -202,8 +208,15 @@ CDegree.prototype.recalculateSubScript = function(oMeasure) ...@@ -202,8 +208,15 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
{ {
this.upIter = base.height + 0.9*shCenter - iter.ascent; this.upIter = base.height + 0.9*shCenter - iter.ascent;
if(base.ascent - shCenter > this.upIter) /*if(base.ascent - shCenter > this.upIter)
this.upIter = base.height - base.ascent + shCenter; this.upIter = base.height - base.ascent + shCenter;*/
// ограничение для случая, когда аскент итератора >> высоты основания
/*if(base.ascent - shCenter > this.upIter)
this.upIter = base.ascent - shCenter;*/
if(base.ascent - 2*shCenter > this.upIter)
this.upIter = base.ascent - 2*shCenter;
} }
var height = this.upIter + iter.height; var height = this.upIter + iter.height;
...@@ -833,7 +846,7 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure, RPI) ...@@ -833,7 +846,7 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure, RPI)
var upDesc = 0, var upDesc = 0,
downAsc = 0; downAsc = 0;
if(!base.IsJustDraw() && base.IsOnlyText()) if(!base.IsJustDraw() && base.IsOneLineText())
{ {
upDesc = 1.5*shIter; upDesc = 1.5*shIter;
downAsc = 1.2*shIter; downAsc = 1.2*shIter;
......
...@@ -4126,19 +4126,23 @@ CMathContent.prototype = ...@@ -4126,19 +4126,23 @@ CMathContent.prototype =
return gaps; return gaps;
}, },
IsOnlyText: function() IsOneLineText: function() // for degree
{ {
var bOnlyText = true; var bOneLineText = true;
for(var i = 0; i < this.content.length; i++) for(var i = 0; i < this.content.length; i++)
{ {
if(this.content[i].Type == para_Math_Composition) if(this.content[i].Type == para_Math_Composition)
{ {
bOnlyText = false; if(!this.content[i].IsOneLineText())
break; {
bOneLineText = false;
break;
}
} }
} }
return bOnlyText; return bOneLineText;
}, },
draw: function(x, y, pGraphics) draw: function(x, y, pGraphics)
{ {
...@@ -4217,11 +4221,6 @@ CMathContent.prototype = ...@@ -4217,11 +4221,6 @@ CMathContent.prototype =
PosInfo.SetInfoPoints(this.InfoPoints); PosInfo.SetInfoPoints(this.InfoPoints);
PosInfo.ApplyAlign(); PosInfo.ApplyAlign();
if(this.Id == "91")
{
console.log("setPosition " + PosInfo.x);
}
} }
for(var i=0; i < this.content.length; i++) for(var i=0; i < this.content.length; i++)
...@@ -4317,32 +4316,34 @@ CMathContent.prototype = ...@@ -4317,32 +4316,34 @@ CMathContent.prototype =
return result; return result;
}, },
Recalculate_CurPos : function(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget) Recalculate_CurPos : function(X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget)
{ {
_X = this.pos.x + this.ParaMath.X; X = this.pos.x + this.ParaMath.X;
Y = this.pos.y + this.ParaMath.Y + this.size.ascent; Y = this.pos.y + this.ParaMath.Y + this.size.ascent;
if(this.RecalcInfo.bEqqArray) if(this.RecalcInfo.bEqqArray)
{ {
var PointInfo = new CMathPointInfo(); var PointInfo = new CMathPointInfo();
PointInfo.SetInfoPoints(this.InfoPoints); PointInfo.SetInfoPoints(this.InfoPoints);
_X += PointInfo.GetAlign(); X += PointInfo.GetAlign();
for(var i = 0; i < this.CurPos; i++) for(var i = 0; i < this.CurPos; i++)
{ {
if(this.content[this.CurPos].Type == para_Math_Run) if(this.content[i].Type == para_Math_Run)
this.content[i].Recalculate_CurPos(_X, Y, false, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget, PointInfo); {
var res = this.content[i].Recalculate_CurPos(X, Y, false, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget, PointInfo);
X = res.X;
}
else else
_X += this.content[i].size.width; X += this.content[i].size.width;
} }
} }
else else
_X += this.WidthToElement[this.CurPos]; X += this.WidthToElement[this.CurPos];
return this.content[this.CurPos].Recalculate_CurPos(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget, PointInfo); return this.content[this.CurPos].Recalculate_CurPos(X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget, PointInfo);
}, },
Check_NearestPos: function(ParaNearPos, Depth) Check_NearestPos: function(ParaNearPos, Depth)
...@@ -4800,6 +4801,31 @@ CMathContent.prototype = ...@@ -4800,6 +4801,31 @@ CMathContent.prototype =
SearchPos.Pos.Update(pos, Depth); SearchPos.Pos.Update(pos, Depth);
result = true; result = true;
} }
if(SearchPos.InText == false)
{
if(this.content[pos-1].Is_Empty())
{
SearchPos.CurX -= this.content[pos].size.width;
if( this.content[pos-1].Get_ParaContentPosByXY(SearchPos, Depth+1, _CurLine, _CurRange, StepEnd))
{
SearchPos.Pos.Update(pos-1, Depth);
result = true;
}
SearchPos.CurX += this.content[pos].size.width;
}
/*if(this.content[pos+1].Is_Empty())
{
if( this.content[pos+1].Get_ParaContentPosByXY(SearchPos, Depth+1, _CurLine, _CurRange, StepEnd))
{
SearchPos.Pos.Update(pos, Depth);
result = true;
}
}*/
}
} }
else else
{ {
......
...@@ -283,7 +283,11 @@ CMathMatrix.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLi ...@@ -283,7 +283,11 @@ CMathMatrix.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLi
H += Heights[i] + this.gaps.row[i]; H += Heights[i] + this.gaps.row[i];
} }
var SearchCurX = SearchPos.CurX + this.GapLeft + W_CurX ; var PrevSearchCurX = SearchPos.CurX;
SearchPos.CurX += this.GapLeft + W_CurX;
//var SearchCurX = SearchPos.CurX + this.GapLeft + W_CurX ;
if(this.kind === MATH_MATRIX) if(this.kind === MATH_MATRIX)
{ {
...@@ -299,10 +303,9 @@ CMathMatrix.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLi ...@@ -299,10 +303,9 @@ CMathMatrix.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLi
SearchPos.Pos.Update(CurrY, Depth + 1); SearchPos.Pos.Update(CurrY, Depth + 1);
} }
SearchPos.CurX = SearchCurX + this.size.width; SearchPos.CurX = PrevSearchCurX + this.size.width;
return result; return result;
} }
CMathMatrix.prototype.getMetrics = function(RPI) CMathMatrix.prototype.getMetrics = function(RPI)
{ {
......
...@@ -1854,14 +1854,14 @@ CSurface.prototype.getCoord = function() ...@@ -1854,14 +1854,14 @@ CSurface.prototype.getCoord = function()
X[42] = 24855.55; Y[42] = 312.82; X[42] = 24855.55; Y[42] = 312.82;
var t = Y[1]; /*var t = Y[1];
for(var i = 0 ; i < X.length; i++) for(var i = 0 ; i < X.length; i++)
{ {
var yy = Math.round((Y[i] - t)*100)/100; var yy = Math.round((Y[i] - t)*100)/100;
var str = "X[" + i + "] = " + X[i] + "; Y[" + i + "] = " + yy + ";"; var str = "X[" + i + "] = " + X[i] + "; Y[" + i + "] = " + yy + ";";
console.log(str); console.log(str);
} }*/
var W = X[11], var W = X[11],
H = Y[21]; H = Y[21];
......
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