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

степень(верхний индекс!), поправлены баги связанные с baseline для итератора,...

степень(верхний индекс!), поправлены баги связанные с baseline для итератора, соответственно степень выравнена по высоте (алгоритм отрисовки итератора такой же, как в Ворде)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54158 954022d7-b5bf-4e40-9824-e11837661b57
parent 2ca49ca7
...@@ -3,7 +3,8 @@ function CDegree() ...@@ -3,7 +3,8 @@ function CDegree()
this.kind = MATH_DEGREE; this.kind = MATH_DEGREE;
this.type = DEGREE_SUPERSCRIPT ; this.type = DEGREE_SUPERSCRIPT ;
this.upper = 0; this.upBase = 0; // отступ сверху для основания
this.upIter = 0; // отступ сверху для итератора
this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
CMathBase.call(this); CMathBase.call(this);
...@@ -39,7 +40,7 @@ CDegree.prototype.recalculateSize = function(oMeasure) ...@@ -39,7 +40,7 @@ CDegree.prototype.recalculateSize = function(oMeasure)
else if(this.type === DEGREE_SUBSCRIPT) else if(this.type === DEGREE_SUBSCRIPT)
this.recalculateSubScript(oMeasure); this.recalculateSubScript(oMeasure);
} }
CDegree.prototype.recalculateSup = function(oMeasure) CDegree.prototype.old__recalculateSup = function(oMeasure)
{ {
var base = this.elements[0][0].size, var base = this.elements[0][0].size,
iter = this.elements[0][1].size; iter = this.elements[0][1].size;
...@@ -80,6 +81,37 @@ CDegree.prototype.recalculateSup = function(oMeasure) ...@@ -80,6 +81,37 @@ CDegree.prototype.recalculateSup = function(oMeasure)
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
CDegree.prototype.recalculateSup = function(oMeasure)
{
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var mgCtrPrp = this.mergeCtrTPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
this.upBase = 0;
this.upIter = 0;
var bBaseOnlyText = this.elements[0][0].IsOnlyText();
if(bBaseOnlyText)
{
var TxtAsc = 1.786*shCenter;
if(TxtAsc + iter.ascent> base.ascent)
this.upBase = TxtAsc + iter.ascent - base.ascent;
else
this.upIter = base.ascent - TxtAsc - iter.ascent;
}
else
this.upBase = iter.ascent - 1.2*shCenter;
var height = this.upBase + base.height;
var ascent = this.upBase + base.ascent;
var width = base.width + iter.width + this.dW;
this.size = {width: width, height: height, ascent: ascent};
}
CDegree.prototype.recalculateSubScript = function(oMeasure) CDegree.prototype.recalculateSubScript = function(oMeasure)
{ {
var base = this.elements[0][0].size, var base = this.elements[0][0].size,
...@@ -114,7 +146,7 @@ CDegree.prototype.recalculateSubScript = function(oMeasure) ...@@ -114,7 +146,7 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
this.size = {width: width, height: height, ascent: ascent}; this.size = {width: width, height: height, ascent: ascent};
} }
CDegree.prototype.old_setPosition = function(_pos) CDegree.prototype.old_old_setPosition = function(_pos)
{ {
var pos = _pos; var pos = _pos;
if(this.bMObjs === true) if(this.bMObjs === true)
...@@ -125,7 +157,7 @@ CDegree.prototype.old_setPosition = function(_pos) ...@@ -125,7 +157,7 @@ CDegree.prototype.old_setPosition = function(_pos)
this.elements[0][0].setPosition({x: pos.x, y: pos.y - this.elements[0][0].size.center }); this.elements[0][0].setPosition({x: pos.x, y: pos.y - this.elements[0][0].size.center });
this.elements[0][1].setPosition({x: pos.x + this.elements[0][0].size.width + this.dW, y: pos.y + this.shiftDegree - this.size.center}); this.elements[0][1].setPosition({x: pos.x + this.elements[0][0].size.width + this.dW, y: pos.y + this.shiftDegree - this.size.center});
} }
CDegree.prototype.setPosition = function(pos) CDegree.prototype.old_setPosition = function(pos)
{ {
if(this.bMObjs === true) if(this.bMObjs === true)
this.pos = pos; this.pos = pos;
...@@ -143,7 +175,17 @@ CDegree.prototype.setPosition = function(pos) ...@@ -143,7 +175,17 @@ CDegree.prototype.setPosition = function(pos)
this.elements[0][0].setPosition({x: this.pos.x, y: this.pos.y + shBase}); this.elements[0][0].setPosition({x: this.pos.x, y: this.pos.y + shBase});
this.elements[0][1].setPosition({x: this.pos.x + this.elements[0][0].size.width + this.dW, y: this.pos.y + shIter}); this.elements[0][1].setPosition({x: this.pos.x + this.elements[0][0].size.width + this.dW, y: this.pos.y + shIter});
} }
CDegree.prototype.findDisposition = function(mCoord) CDegree.prototype.setPosition = function(pos)
{
if(this.bMObjs === true)
this.pos = pos;
else
this.pos = {x: pos.x, y: pos.y - this.size.ascent};
this.elements[0][0].setPosition({x: this.pos.x, y: this.pos.y + this.upBase});
this.elements[0][1].setPosition({x: this.pos.x + this.elements[0][0].size.width + this.dW, y: this.pos.y + this.upIter});
}
CDegree.prototype.old_findDisposition = function(mCoord)
{ {
var coordX, coordY; var coordX, coordY;
var X, Y; var X, Y;
...@@ -211,6 +253,66 @@ CDegree.prototype.findDisposition = function(mCoord) ...@@ -211,6 +253,66 @@ CDegree.prototype.findDisposition = function(mCoord)
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag}; return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
} }
CDegree.prototype.findDisposition = function(mCoord)
{
var coordX, coordY;
var X, Y;
var inside_flag = -1;
if( mCoord.x < this.elements[0][0].size.width)
{
if( this.elements[0][0].IsJustDraw() )
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - this.upIter;
inside_flag = 0;
}
else
{
X = 0; Y = 0; // встаем в первый элемент
coordX = mCoord.x;
coordY = mCoord.y - this.upBase;
}
}
else if(mCoord.x < (this.elements[0][0].size.width + this.dW ))
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - this.upIter;
inside_flag = 0;
}
else if(mCoord.x > this.size.width)
{
X = 0; Y = 1; // встаем во второй элемент
coordX = this.size.width;
coordY = mCoord.y - this.upIter;
inside_flag = 1;
}
else
{
X = 0; Y = 1; // встаем во второй элемент
coordX = mCoord.x - (this.elements[0][0].size.width + this.dW);
coordY = mCoord.y - this.upIter;
}
if(coordY < 0)
{
coordY = 0;
inside_flag = 2;
}
else if(coordY > this.elements[X][Y].size.height)
{
coordY = this.elements[X][Y].size.height;
inside_flag = 2;
}
var mCoord = {x: coordX, y: coordY};
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
}
CDegree.prototype.old_findDisposition = function(mCoord) CDegree.prototype.old_findDisposition = function(mCoord)
{ {
var coordX, coordY; var coordX, coordY;
......
...@@ -5069,7 +5069,8 @@ CMathContent.prototype = ...@@ -5069,7 +5069,8 @@ CMathContent.prototype =
var coeffLeft = 0.001, var coeffLeft = 0.001,
coeffRight = 0; // for checkGap.bEmptyGaps coeffRight = 0; // for checkGap.bEmptyGaps
var bDegree = kind == MATH_DEGREE || kind == MATH_DEGREESubSup; //var bDegree = kind == MATH_DEGREE || kind == MATH_DEGREESubSup;
var bDegree = kind == MATH_DEGREE;
if(checkGap.bChildGaps) if(checkGap.bChildGaps)
{ {
...@@ -5163,6 +5164,20 @@ CMathContent.prototype = ...@@ -5163,6 +5164,20 @@ CMathContent.prototype =
return code == PLUS || code == MINUS || code == LESS || code == GREATER; return code == PLUS || code == MINUS || code == LESS || code == GREATER;
}, },
IsOnlyText: function()
{
var bOnlyText = true;
for(var i = 0; i < this.content.length; i++)
{
if(this.content[i].value.typeObj == MATH_COMP)
{
bOnlyText = false;
break;
}
}
return bOnlyText;
},
old_checkSignComp: function(pos) old_checkSignComp: function(pos)
{ {
var bPlus = false, bMinus = false, var bPlus = false, bMinus = false,
...@@ -5188,9 +5203,6 @@ CMathContent.prototype = ...@@ -5188,9 +5203,6 @@ CMathContent.prototype =
{ {
var bHidePlh = this.plhHide && this.IsPlaceholder(); var bHidePlh = this.plhHide && this.IsPlaceholder();
// TEST
var bOnlySimpleObjs = true;
if( !bHidePlh ) if( !bHidePlh )
{ {
for(var i=1; i < this.content.length;i++) for(var i=1; i < this.content.length;i++)
...@@ -5225,11 +5237,6 @@ CMathContent.prototype = ...@@ -5225,11 +5237,6 @@ CMathContent.prototype =
if(this.content[i].value.typeObj == MATH_COMP)
{
bOnlySimpleObjs = false;
}
/*if(this.content[i].value.typeObj == MATH_COMP) /*if(this.content[i].value.typeObj == MATH_COMP)
{ {
var penW = 25.4/96; var penW = 25.4/96;
...@@ -5246,7 +5253,7 @@ CMathContent.prototype = ...@@ -5246,7 +5253,7 @@ CMathContent.prototype =
} }
/// TEST /// TEST
if(!bOnlySimpleObjs) if(!this.IsOnlyText())
{ {
var penW = 25.4/96; var penW = 25.4/96;
var x1 = this.pos.x + x - penW, var x1 = this.pos.x + x - penW,
...@@ -6193,12 +6200,18 @@ CMathContent.prototype = ...@@ -6193,12 +6200,18 @@ CMathContent.prototype =
FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26; FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26;
//FSize = 0.001*FSize*FSize + 0.723*FSize - 1.318; //FSize = 0.001*FSize*FSize + 0.723*FSize - 1.318;
//FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53; //FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53;
tPrp.FontSize = FSize;
} }
else if(this.argSize == -2) else if(this.argSize == -2)
//tPrp.FontSize *= 0.65; {
tPrp.FontSize *= 0.53; // aa: -0.0004 bb: 0.66 cc: 0.87
// aa: -0.0014 bb: 0.71 cc: 0.39
// aa: 0 bb: 0.63 cc: 1.11
//FSize = 0.63*FSize + 1.11;
FSize = -0.0004*FSize*FSize + 0.66*FSize + 0.87;
//tPrp.FontSize *= 0.473; //tPrp.FontSize *= 0.473;
}
tPrp.FontSize = FSize;
return tPrp; return tPrp;
}, },
...@@ -8066,8 +8079,15 @@ function TEST_COEFF_ITERATORS() ...@@ -8066,8 +8079,15 @@ function TEST_COEFF_ITERATORS()
//FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53; //FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53;
// argSize = -1
//var x1 = 36, x2 = 14, x3 = 72;
//var d1 = 26, d2 = 10, d3 = 54; // если еще подгонять, то можно d3 = 53,52 взять
var x1 = 36, x2 = 14, x3 = 72; var x1 = 36, x2 = 14, x3 = 72;
var d1 = 26, d2 = 10, d3 = 54; var d1 = 24, d2 = 10, d3 = 47;
// || x1*x1 x1 1 || // || x1*x1 x1 1 ||
// || x2*x2 x2 1 || // || x2*x2 x2 1 ||
......
...@@ -518,6 +518,10 @@ CNaryOperator.prototype.setReferenceComposition = function(Compos) ...@@ -518,6 +518,10 @@ CNaryOperator.prototype.setReferenceComposition = function(Compos)
{ {
this.Composition = Compos; this.Composition = Compos;
} }
CNaryOperator.prototype.IsOnlyText = function()
{
return false;
}
function CSigma() function CSigma()
{ {
......
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