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

1. Удалила gap для контента, и соответственно coordWOGaps

2. Center => Baseline
3. Поправила отрисовку знаменателя для текста по baseline
4. поправила баг на findDisposition(mouseDown, mouseMove) для fraction (ошибка возникала, когда координата совпадала с шириной/высотой элемента по x/y)
5. изменила положение линий на отрисовке(draw) у CBorderBox

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53514 954022d7-b5bf-4e40-9824-e11837661b57
parent 35d27d27
......@@ -691,7 +691,7 @@ CMathBase.prototype =
{
_h += Heights[j];
_h += this.dH/2;
if( mCoord.y <= _h )
if( mCoord.y <= _h + 0.000001) // если придет координата совпадающая с высотой элемента, чтобы не возникало проблем с погрешностью при сравнении
{
posCurs.x = j;
break;
......@@ -713,7 +713,7 @@ CMathBase.prototype =
{
_w +=Widths[u];
_w += this.dW/2;
if( mCoord.x <= _w )
if( mCoord.x <= _w + 0.000001) // если придет координата совпадающая с высотой элемента, чтобы не возникало проблем с погрешностью при сравнении
{
if( this.elements[posCurs.x][u].IsJustDraw() )
......
......@@ -12,8 +12,14 @@ function CBorderBox()
this.bLDiag = false;
this.bRDiag = false;
this.bHor = false;
this.bVert = false;
/*this.bHor = false;
this.bVert = false;*/
/*this.bLDiag = true;
this.bRDiag = true;*/
this.bHor = true;
this.bVert = true;
CMathBase.call(this);
}
......@@ -31,7 +37,7 @@ CBorderBox.prototype.init = function(props)
if(props.hideBot === true || props.hideBot === 1)
this.bBot = false;
if(props.strikeBLTR === true || props.strikeBLTR === 1)
/*if(props.strikeBLTR === true || props.strikeBLTR === 1)
this.bRDiag = true;
if(props.strikeTLBR === true || props.strikeTLBR === 1)
......@@ -41,7 +47,7 @@ CBorderBox.prototype.init = function(props)
this.bHor = true;
if(props.strikeV === true || props.strikeV === 1)
this.bVert = true;
this.bVert = true;*/
}
this.setDimension(1, 1);
......@@ -81,7 +87,8 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
{
var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - 25.4/96,
//x2 = this.pos.x + x + this.size.width - 25.4/96,
x2 = this.pos.x + x + this.size.width - penW,
y1 = this.pos.y + y;
pGraphics.p_color(0,0,0, 255);
......@@ -91,7 +98,8 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
if(this.bBot)
{
var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - 25.4/96,
//x2 = this.pos.x + x + this.size.width - 25.4/96,
x2 = this.pos.x + x + this.size.width - penW,
y1 = this.pos.y + y + this.size.height - penW;
pGraphics.p_color(0,0,0, 255);
......@@ -102,7 +110,8 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
{
var x1 = this.pos.x + x,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - 25.4/96;
y2 = this.pos.y + y + this.size.height - penW;
//y2 = this.pos.y + y + this.size.height - 25.4/96;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......@@ -110,9 +119,10 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
if(this.bRight)
{
var x1 = this.pos.x + x + this.size.width - penW ,
var x1 = this.pos.x + x + this.size.width - penW,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - 25.4/96 ;
y2 = this.pos.y + y + this.size.height - penW;
//y2 = this.pos.y + y + this.size.height - 25.4/96 ;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......@@ -123,7 +133,8 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
var pW = penW*0.8;
var x1 = this.pos.x + x , y1 = this.pos.y + y,
x2 = x1 + pW, y2 = y1,
x3 = x1 + x + this.size.width - 25.4/96, y3 = y1 + this.size.height - pW - 25.4/96,
//x3 = x1 + this.size.width - 25.4/96, y3 = y1 + this.size.height - pW - 25.4/96,
x3 = x1 + this.size.width - penW, y3 = y1 + this.size.height - pW - penW,
x4 = x3, y4 = y3 + pW,
x5 = x4 - pW, y5 = y4,
x6 = x1, y6 = y1 + pW,
......@@ -147,10 +158,12 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
if(this.bRDiag)
{
var pW = penW*0.8;
var x1 = this.pos.x + x + this.size.width - pW - 25.4/96, y1 = this.pos.y + y,
var x1 = this.pos.x + x + this.size.width - pW - penW, y1 = this.pos.y + y,
//x1 = this.pos.x + x + this.size.width - pW - 25.4/96, y1 = this.pos.y + y,
x2 = x1 + pW, y2 = y1,
x3 = x2, y3 = y2 + pW,
x4 = this.pos.x + x + pW, y4 = this.pos.y + y + this.size.height - 25.4/96,
x4 = this.pos.x + x + pW, y4 = this.pos.y + y + this.size.height - penW,
//x4 = this.pos.x + x + pW, y4 = this.pos.y + y + this.size.height - 25.4/96,
x5 = x4 - pW, y5 = y4,
x6 = x5, y6 = y5 - pW,
x7 = x1, y7 = y1;
......@@ -173,7 +186,8 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
if(this.bHor)
{
var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - 25.4/96,
x2 = this.pos.x + x + this.size.width - penW,
//x2 = this.pos.x + x + this.size.width - 25.4/96,
y1 = this.pos.y + y + this.size.height/2 - penW/2;
pGraphics.p_color(0,0,0, 255);
......@@ -184,7 +198,8 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
{
var x1 = this.pos.x + x + this.size.width/2 - penW/2,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - 25.4/96;
y2 = this.pos.y + y + this.size.height - penW;
//y2 = this.pos.y + y + this.size.height - 25.4/96;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......
......@@ -465,10 +465,13 @@ CNumerator.prototype.findDisposition = function(mCoord)
{
var arg = this.elements[0][0].size;
var posCurs = {x: 0, y: 0};
var inside_flag = -1;
if(mCoord.y > arg.height)
mCoord.y = arg.height;
return CNumerator.superclass.findDisposition.call(this, mCoord);
return {pos: posCurs, mCoord: mCoord, inside_flag: inside_flag};
}
CNumerator.prototype.setPosition = function(pos)
{
......@@ -523,14 +526,21 @@ CDenominator.prototype.findDisposition = function(mCoord)
{
var arg = this.elements[0][0].size;
var posCurs = {x: 0, y: 0};
var inside_flag = -1;
if(mCoord.y < this.gap)
{
mCoord.y = 0;
}
else if (mCoord.y > arg.height + this.gap)
{
mCoord.y = arg.height;
}
else
mCoord.y -= this.gap;
return CDenominator.superclass.findDisposition.call(this, mCoord);
return {pos: posCurs, mCoord: mCoord, inside_flag: inside_flag};
}
CDenominator.prototype.setPosition = function(pos)
{
......
......@@ -31,6 +31,7 @@
// 12. объединение формул на remove и add
// 13. Для N-арных операторов в случае со степенью : итераторы занимают не 2/3 от основание, а примерно половину (когда один итератор сверху или снизу)
// 14. Для дробей, n-арных операторов и пр. считать расстояние исходя из shiftCenter
// 15. Для числителя/знаменателя сделать меньшие расстояния для внутренних дробей, меньшие по размеру n-арные операторы, значок радикала
// TODO Refactoring
......@@ -4649,6 +4650,8 @@ CMathContent.prototype =
{
var bItalic = true;
var posPrev = -1;
for(var i = 0; i < this.content.length; i++)
{
var type = this.content[i].value.typeObj;
......@@ -4658,12 +4661,16 @@ CMathContent.prototype =
this.content[i].value.setMText(bItalic);
this.content[i].value.Resize(oMeasure);
this.checkGapsSign(oMeasure, i);
this.checkGapsSign(oMeasure, posPrev, i);
posPrev = i;
}
else if(type == MATH_COMP)
{
this.content[i].value.Resize(oMeasure);
this.checkGapsSign(oMeasure, i);
this.checkGapsSign(oMeasure, posPrev, i);
posPrev = i;
}
else if(type == MATH_RUN_PRP)
{
......@@ -4697,7 +4704,7 @@ CMathContent.prototype =
this.recalculateSize();
},
checkGapsSign: function(oMeasure, pos)
old_checkGapsSign: function(oMeasure, pos)
{
/*var leftType = pos > 0 ? this.content[pos - 1].value.typeObj : null,
......@@ -4747,7 +4754,6 @@ CMathContent.prototype =
bRightGapObj = this.checkSignComp(pos + 1);
var bFirstLetter = currType == MATH_TEXT && pos == 2,
bFirstComp = currType == MATH_COMP && pos == 1,
bLastLetter = currType == MATH_TEXT && pos == this.content.length - 1,
......@@ -4841,6 +4847,68 @@ CMathContent.prototype =
}
},
checkGapsSign: function(oMeasure, posLeft, posCurr)
{
if(posLeft > 0 && posLeft < this.content.length)
{
var typePrev = this.content[posLeft].value.typeObj,
typeCurr = this.content[posCurr].value.typeObj;
var bPrevSign = this.checkSignComp(posLeft),
bCurrSign = this.checkSignComp(posCurr);
var bPrevComp = typePrev === MATH_COMP,
bCurrComp = typeCurr === MATH_COMP;
var gapSign = 0;
var bNeedGap = bPrevSign || bPrevComp || bCurrSign || bCurrComp;
if(bPrevComp || bPrevSign)
{
var rPrp = this.getRPrpByPosition(posLeft);
var txtPrp = new CMathTextPrp();
txtPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
txtPrp.Merge(rPrp);
gapSign = this.Composition.GetGapSign(oMeasure, txtPrp);
var coeff = 0;
if(bCurrComp)
coeff = 0.2;
else if(bCurrSign)
coeff = 0.4;
else
coeff = 0.4;
this.content[posLeft].gaps.right = coeff*gapSign;
}
if(bCurrSign || bCurrComp)
{
var rPrp = this.getRPrpByPosition(posCurr);
var txtPrp = new CMathTextPrp();
txtPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
txtPrp.Merge(rPrp);
gapSign = this.Composition.GetGapSign(oMeasure, txtPrp);
var coeff = 0;
if(bPrevComp)
coeff = 0.3;
else if(bCurrSign)
coeff = 0.5;
else
coeff = 0.45;
this.content[posCurr].gaps.left = coeff*gapSign;
}
}
},
checkSignComp: function(pos)
{
var bPlus = false, bMinus = false,
......@@ -4859,10 +4927,8 @@ CMathContent.prototype =
bDivision = code === 0x002F;
bEqual = code === 0x3D;
}
var bSign = (bPlus || bMinus || bEqual),
bComp = currType == MATH_COMP;
return bSign || bComp;
return (bPlus || bMinus || bEqual);
},
old_draw: function(pGraphics)
{
......@@ -6875,6 +6941,39 @@ CMathComposition.prototype =
{
this.TEST_SELECT_ACTIVE = false;
},
TestMouseDown: function()
{
var txtPrp = this.Root.getFirstPrp();
txtPrp.Merge(this.DEFAULT_RUN_PRP);
var sh = txtPrp.FontSize*0.017;
var k = 0, m = 0;
for(var x = 0; x < this.Root.size.width; x += sh)
{
k++;
for(var y = 0; y < this.Root.size.height; y += sh - 0.1)
{
this.Root.selection_Start(x, y);
var result = this.Root.selection_End(x, y);
this.SelectContent = result.SelectContent;
if(!this.SelectContent.selectUse())
this.CurrentContent = this.SelectContent;
m++;
/*if(k%10 == 0 && m%10 == 0)
console.log("k: " + k, "m: " + m);*/
// x = 53.10799999999981
// y = 18.008999999999965
}
}
},
Remove_2: function(order)
{
if(TEST)
......@@ -7338,6 +7437,8 @@ CMathComposition.prototype =
y = Y - this.absPos.y;
this.Root.selection_Start(x, y);
//console.log("X: " + X, "Y: " + Y);
},
Selection_SetEnd: function(X, Y, PageNum, MouseEvent)
{
......
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