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

переделаны Recalculate, setPostion, Draw для PARA_RUN

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55283 954022d7-b5bf-4e40-9824-e11837661b57
parent 61db8995
...@@ -6366,10 +6366,12 @@ function CRunCollaborativeRange(PosS, PosE) ...@@ -6366,10 +6366,12 @@ function CRunCollaborativeRange(PosS, PosE)
} }
// добавлены поля
// size, Parent
ParaRun.prototype.Math_SetPosition = function(_pos) ParaRun.prototype.Math_SetPosition = function(_pos)
{ {
var pos = {x: _pos.x, y: _pos.y - this.size.ascent}; var pos = {x: _pos.x, y: _pos.y - this.Math_GetSize().ascent};
for(var i = 0; i < this.Content.length; i++) for(var i = 0; i < this.Content.length; i++)
{ {
...@@ -6382,35 +6384,49 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics) ...@@ -6382,35 +6384,49 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
if(this.bMathRun) if(this.bMathRun)
{ {
var X = x; var X = x;
var Y = y + this.size.ascent; var Y = y + this.Math_GetSize().ascent;
pGraphics.b_color1(0,0,0,255); pGraphics.b_color1(0,0,0,255);
for(var i=0; i < this.Content.length;i++) for(var i=0; i < this.Content.length;i++)
{ {
var oWPrp = this.Get_CompiledPr(false); var oWPrp = this.Get_CompiledPr(false);
oWPrp.Merge(this.Parent.Composition.DEFAULT_RUN_PRP.getTxtPrp());
g_oTextMeasurer.SetFont(oWPrp); g_oTextMeasurer.SetFont(oWPrp);
this.Content[i].draw(X, Y, pGraphics); this.Content[i].draw(X, Y, pGraphics);
} }
} }
} }
ParaRun.prototype.Math_Recalculate = function() ParaRun.prototype.Math_Recalculate = function(RecalcInfo)
{ {
var RangeStartPos = 0; var RangeStartPos = 0;
var RangeEndPos = this.Content.length; var RangeEndPos = this.Content.length;
this.Lines[0].Add_Range( 0, RangeStartPos, RangeEndPos ); // ??
this.Lines[0].Add_Range(0, RangeStartPos, RangeEndPos);
var width = 0, var width = 0,
ascent = 0, descent = 0; ascent = 0, descent = 0;
var oWPrp = this.Get_CompiledPr(false); var oWPrp = this.Get_CompiledPr(true);
oWPrp.Merge(this.Parent.Composition.DEFAULT_RUN_PRP.getTxtPrp()); oWPrp.Merge(RecalcInfo.Composition.DEFAULT_RUN_PRP.getTxtPrp());
// TODO
// смержить еще с math_Run_Prp
g_oTextMeasurer.SetFont(oWPrp); g_oTextMeasurer.SetFont(oWPrp);
for (var Pos = 0 ; Pos < this.Content.length; Pos++ ) for (var Pos = 0 ; Pos < this.Content.length; Pos++ )
{ {
RecalcInfo.leftRunPrp = RecalcInfo.currRunPrp;
RecalcInfo.Left = RecalcInfo.Current;
RecalcInfo.currRunPrp = oWPrp;
RecalcInfo.Current = this.Content[Pos];
RecalcInfo.setGaps();
this.Content[Pos].Resize(g_oTextMeasurer); this.Content[Pos].Resize(g_oTextMeasurer);
var oSize = this.Content[Pos].size; var oSize = this.Content[Pos].size;
...@@ -6424,6 +6440,24 @@ ParaRun.prototype.Math_Recalculate = function() ...@@ -6424,6 +6440,24 @@ ParaRun.prototype.Math_Recalculate = function()
descent = descent < oDescent ? oDescent : descent; descent = descent < oDescent ? oDescent : descent;
} }
this.size = {width: width, height: ascent + descent, ascent: ascent}; //this.size = {width: width, height: ascent + descent, ascent: ascent};
}
ParaRun.prototype.Math_GetSize = function()
{
var width = 0,
ascent = 0, descent = 0;
for (var Pos = 0 ; Pos < this.Content.length; Pos++ )
{
this.Content[Pos].Resize(g_oTextMeasurer);
var oSize = this.Content[Pos].size;
width += oSize.width;
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
var oDescent = oSize.height - oSize.ascent;
descent = descent < oDescent ? oDescent : descent;
}
return {width: width, height: ascent + descent, ascent: ascent};
} }
\ No newline at end of file
...@@ -1566,7 +1566,7 @@ function Binary_oMathWriter(memory, oMathPara) ...@@ -1566,7 +1566,7 @@ function Binary_oMathWriter(memory, oMathPara)
this.WriteMathElem = function(mathElem) this.WriteMathElem = function(mathElem)
{ {
var oThis = this; var oThis = this;
var item = mathElem.value; var item = mathElem;
switch ( item.typeObj) switch ( item.typeObj)
{ {
case MATH_COMP: case MATH_COMP:
...@@ -1626,7 +1626,7 @@ function Binary_oMathWriter(memory, oMathPara) ...@@ -1626,7 +1626,7 @@ function Binary_oMathWriter(memory, oMathPara)
this.WriteMathElemCollaborative = function(mathElem) this.WriteMathElemCollaborative = function(mathElem)
{ {
var oThis = this; var oThis = this;
var item = mathElem.value; var item = mathElem;
switch ( item.typeObj) switch ( item.typeObj)
{ {
case MATH_COMP: case MATH_COMP:
...@@ -1745,7 +1745,7 @@ function Binary_oMathWriter(memory, oMathPara) ...@@ -1745,7 +1745,7 @@ function Binary_oMathWriter(memory, oMathPara)
{ {
var item = oElem.content[i]; var item = oElem.content[i];
if (MATH_RUN_PRP == item.value.typeObj) if (MATH_RUN_PRP == item.typeObj)
{ {
var nCurPos = 0; var nCurPos = 0;
this.memory.WriteByte(c_oSer_OMathContentType.MRun); this.memory.WriteByte(c_oSer_OMathContentType.MRun);
......
...@@ -48,6 +48,9 @@ function CMathBase() ...@@ -48,6 +48,9 @@ function CMathBase()
wdt: null wdt: null
}; };
this.GapLeft = 0;
this.GapRight = 0;
return this; return this;
} }
CMathBase.prototype = CMathBase.prototype =
...@@ -939,8 +942,8 @@ CMathBase.prototype = ...@@ -939,8 +942,8 @@ CMathBase.prototype =
}, },
recalculateSize: function(oMeasure) recalculateSize: function(oMeasure)
{ {
var _width = 0; var width = 0;
var _height = 0; var height = 0;
var maxWH = this.getWidthsHeights(); var maxWH = this.getWidthsHeights();
...@@ -950,18 +953,19 @@ CMathBase.prototype = ...@@ -950,18 +953,19 @@ CMathBase.prototype =
var Heights = maxWH.heights; var Heights = maxWH.heights;
for( j = 0 ; j < this.nRow; j++ ) for( j = 0 ; j < this.nRow; j++ )
_height += Heights[j]; height += Heights[j];
_height += this.dH*(this.nRow - 1); height += this.dH*(this.nRow - 1);
for( i=0; i < this.nCol ; i++) for(var i=0; i < this.nCol ; i++)
_width += Widths[i]; width += Widths[i];
_width += this.dW*(this.nCol - 1); width += this.dW*(this.nCol - 1);
width += this.GapLeft + this.GapRight;
var _ascent = this.getAscent(_height, oMeasure); var ascent = this.getAscent(height, oMeasure);
this.size = {width: _width, height: _height, ascent: _ascent}; this.size = {width: width, height: height, ascent: ascent};
}, },
/*RecalculateReverse: function(oMeasure) /*RecalculateReverse: function(oMeasure)
{ {
...@@ -1215,7 +1219,7 @@ CMathBase.prototype = ...@@ -1215,7 +1219,7 @@ CMathBase.prototype =
return content; return content;
}, },
getGapsInside: function() getGapsInside: function(RecalcInfo)
{ {
var kind = this.kind; var kind = this.kind;
var gaps = {left: 0, right: 0}; var gaps = {left: 0, right: 0};
...@@ -1224,7 +1228,7 @@ CMathBase.prototype = ...@@ -1224,7 +1228,7 @@ CMathBase.prototype =
if(checkBase) if(checkBase)
{ {
var base = this.getBase(); var base = this.getBase();
gaps = base.getGapsInside(); gaps = base.getGapsInside(RecalcInfo);
} }
return gaps; return gaps;
......
...@@ -66,6 +66,477 @@ var SELECT_CHILD = 1; ...@@ -66,6 +66,477 @@ var SELECT_CHILD = 1;
var StartTextElement = 0x2B1A; // Cambria Math var StartTextElement = 0x2B1A; // Cambria Math
function CGaps(oSign, oEqual, oZeroOper, oLett)
{
this.sign = oSign;
this.equal = oEqual;
this.zeroOper = oZeroOper;
this.letters = oLett;
}
function CCoeffGaps()
{
this.Sign =
{
left: new CGaps(0.52, 0.26, 0, 0.52),
right: new CGaps(0.49, 0, 0, 0.49)
};
this.Mult =
{
left: new CGaps(0, 0, 0, 0.46),
right: new CGaps(0, 0, 0, 0.49)
};
this.Equal =
{
left: new CGaps(0.35, 0, 0, 0.7),
right: new CGaps(0.25, 0, 0, 0.5)
};
this.Default =
{
left: new CGaps(0, 0, 0, 0),
right: new CGaps(0, 0, 0, 0)
};
}
CCoeffGaps.prototype =
{
getCoeff: function(codeCurr, codeLR , direct) // obj - либо codeChar, либо мат объект
{
var operator = null;
if(codeCurr == 0x3D)
operator = this.Equal;
else if(this.checkOperSign(codeCurr))
operator = this.Sign;
else if(codeCurr == 0x2217)
operator = this.Mult;
else
operator = this.Default;
var part = direct == -1 ? operator.left : operator.right;
var coeff = 0;
if(codeLR == -1) // мат объект
coeff = part.letters;
else if(this.checkOperSign(codeLR))
coeff = part.sign;
else if(codeLR == 0x3D )
coeff = part.equal;
else if(codeLR == this.checkZEROSign(codeLR))
coeff = part.zeroOper;
else
coeff = part.letters;
return coeff;
},
checkOperSign: function(code) // "+", "-", "<", ">", "±"
{
var PLUS = 0x2B,
MINUS = 0x2212,
LESS = 0x3C,
GREATER = 0x3E,
PLUS_MINUS = 0xB1;
return code == PLUS || code == MINUS || code == LESS || code == GREATER || code == PLUS_MINUS;
},
checkZEROSign: function(code, direct) // "*", "/", "\"
{
var MULT = 0x2217,
DIVISION = 0x2F,
B_SLASH = 0x5C;
var bOper = code == MULT || code == DIVISION || code == B_SLASH;
var bLeftBracket = direct == -1 && (code == 0x28 || code == 0x5B || code == 0x7B);
var bRightBracket = direct == 1 && (code == 0x29 || code == 0x5D || code == 0x7D);
return bOper || bLeftBracket || bRightBracket;
}
}
var COEFF_GAPS = new CCoeffGaps();
function CRecalculateInfo(oMeasure, argSize, Composition)
{
this.measure = oMeasure;
this.Composition = Composition; // для Para_Run
this.argSize = argSize; // argSize выставляем один раз для всего контента
this.leftRunPrp = null; // Run_Prp левого элемента
this.currRunPrp = null;
this.Left = null; // элемент слева
this.Current = null; // текущий элемент
}
CRecalculateInfo.prototype =
{
old_checkGapsSign: function(oMeasure, posCurr)
{
var left = null,
right = null;
var curr = this.content[posCurr].value;
if(this.argSize < 0)
{
// выставим нулевые gaps для случая, если при копировании/вставки часть контента добавили в итератор
this.content[posCurr].gaps.left = 0;
this.content[posCurr].gaps.right = 0;
}
else
{
var EQUAL = 0x3D,
PLUS = 0x2B,
MINUS = 0x2212,
MULT = 0x2217,
LESS = 0x3C,
GREATER = 0x3E;
var t = posCurr - 1;
while( t > 0 )
{
if(this.content[t].value.typeObj == MATH_TEXT || this.content[t].value.typeObj == MATH_COMP)
{
left = this.content[t].value;
break;
}
t--;
}
t = posCurr + 1;
while( t < this.content.length )
{
if(this.content[t].value.typeObj == MATH_TEXT || this.content[t].value.typeObj == MATH_COMP)
{
right = this.content[t].value;
break;
}
t++;
}
var coeffLeft = 0,
coeffRight = 0;
var bLeft = left !== null,
bRight = right !== null;
var bLeftComp = bLeft ? left.typeObj == MATH_COMP : false,
bRightComp = bRight ? right.typeObj == MATH_COMP : false,
bLeftText = bLeft ? left.typeObj == MATH_TEXT : false,
bRightText = bRight ? right.typeObj == MATH_TEXT : false;
var currCode = curr.typeObj == MATH_TEXT ? curr.getCodeChr() : null,
leftCode = bLeftText ? left.getCodeChr() : null,
rightCode = bRightText ? right.getCodeChr() : null;
var gapLeftComp = 0,
gapRightComp = 0;
if(bLeftComp)
gapLeftComp = this.getGapsMComp(left).right;
if(bRightComp)
gapRightComp = this.getGapsMComp(right).left;
if(curr.typeObj == MATH_TEXT)
{
var bSign = false;
if(this.checkOperSign(currCode)) // plus, minus, greater, less
{
bSign = true;
if(bLeft)
{
if(this.checkZEROSign(leftCode))
coeffLeft = 0;
else if(leftCode == EQUAL)
coeffLeft = 0.26;
else
coeffLeft = 0.52;
}
if(bRight)
{
var bZero = this.checkZEROSign(rightCode);
if(rightCode == EQUAL || bZero)
coeffRight = 0;
else
coeffRight = 0.49;
}
}
else if(currCode === MULT) // multiplication
{
bSign = true;
if(bLeft)
{
var bZeroLeft = this.checkZEROSign(leftCode),
bOperLeft = this.checkOperSign(leftCode);
if(leftCode == EQUAL || bOperLeft || bZeroLeft)
coeffLeft = 0;
else if(bLeft)
coeffLeft = 0.46;
}
if(bRight)
{
var bZeroRight = this.checkZEROSign(rightCode),
bOperRight = this.checkOperSign(rightCode);
if(rightCode == EQUAL || bOperRight || bZeroRight)
coeffRight = 0;
else if(bRight)
coeffRight = 0.49;
}
}
else if(currCode === EQUAL) // equal
{
bSign = true;
if(bLeft)
{
var bZero = this.checkZEROSign(leftCode);
if(leftCode == EQUAL || bZero)
coeffLeft = 0;
else if(this.checkOperSign(leftCode))
coeffLeft = 0.35;
else
coeffLeft = 0.7;
}
if(bRight)
{
var bZero = this.checkZEROSign(rightCode);
if(rightCode == EQUAL || bZero)
coeffRight = 0;
else if(this.checkOperSign(rightCode))
coeffRight = 0.25;
else
coeffRight = 0.5;
}
}
if(bSign && bLeftComp)
coeffLeft = coeffLeft - gapLeftComp;
if(bSign && bRightComp)
coeffRight = coeffRight - gapRightComp;
coeffLeft = Math.ceil(coeffLeft*10)/10;
coeffRight = Math.ceil(coeffRight*10)/10;
}
else if(curr.typeObj == MATH_COMP)
{
var currGaps = this.getGapsMComp(curr);
if(bLeft)
{
coeffLeft = currGaps.left;
if(bLeftComp)
{
if(gapLeftComp/2 < coeffLeft)
coeffLeft = gapLeftComp/2;
}
}
if(bRight)
{
coeffRight = currGaps.right;
if(bRightComp)
{
if(coeffRight/2 > gapRightComp )
coeffRight -= gapRightComp;
else
coeffRight /=2;
}
}
}
if(bLeftText)
{
if(leftCode == 0x28 || leftCode == 0x5B || leftCode == 0x7B)
coeffLeft = 0;
}
if(bRightText)
{
if(rightCode == 0x29 || rightCode == 0x5D || rightCode == 0x7D)
coeffRight = 0;
}
var runPrp = this.getRunPrp(posCurr);
var oWPrp = runPrp.getMergedWPrp();
this.applyArgSize(oWPrp);
var gapSign = 0.1513*oWPrp.FontSize;
this.content[posCurr].gaps.left = Math.ceil(coeffLeft*gapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте
this.content[posCurr].gaps.right = Math.ceil(coeffRight*gapSign*10)/10;
/*if(this.bRoot)
{
if(bSign)
{
var code = this.content[posCurr].value.getCodeChr();
console.log(" " + String.fromCharCode(code));
}
else if(curr.typeObj == MATH_COMP)
{
console.log(curr.constructor.name + " :")
}
if(bSign || curr.typeObj == MATH_COMP)
{
console.log("coeff left " + coeffLeft + ", coeff right " + coeffRight );
console.log("gap left : " + this.content[posCurr].gaps.left + ", gap right : " + this.content[posCurr].gaps.right);
console.log("");
}
}*/
}
},
setGaps: function()
{
if(this.argSize < 0)
{
this.Current.GapLeft = 0;
if(this.Left !== null)
this.Left.GapRight = 0;
}
else
{
var currCoeff = 0,
rightCoeff = 0;
if(this.Current.typeObj == MATH_TEXT)
{
var currCode = this.Current.getCodeChr();
if(this.Left !== null)
{
if(this.Left.typeObj == MATH_COMP)
{
rightCoeff = this.getGapsMComp(this.Left, 1);
currCoeff = COEFF_GAPS.getCoeff(currCode, -1, -1);
currCoeff -= rightCoeff;
}
else
{
var leftCode = this.Left.getCodeChr();
currCoeff = COEFF_GAPS.getCoeff(currCode, leftCode, -1);
rightCoeff = COEFF_GAPS.getCoeff(leftCode, currCode, 1);
}
}
else
this.Current.GapLeft = 0;
}
else
{
currCoeff = this.getGapsMComp(this.Current, -1);
if(this.Left != null)
{
if(this.Left.typeObj == MATH_COMP)
{
rightCoeff = this.getGapsMComp(this.Left, 1);
if(rightCoeff/2 > currCoeff)
rightCoeff -= currCoeff;
else
rightCoeff /= 2;
if(currCoeff < rightCoeff/2)
{
currCoeff = rightCoeff/2;
}
}
else
{
rightCoeff -= currCoeff;
}
}
else
currCoeff = 0;
}
currCoeff = Math.ceil(currCoeff*10)/10;
rightCoeff = Math.ceil(rightCoeff*10)/10;
var LGapSign = 0.1513*this.currRunPrp.FontSize;
this.Current.GapLeft = Math.ceil(currCoeff*LGapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте
if(this.Left != null)
{
var RGapSign = 0.1513*this.leftRunPrp.FontSize;
this.Left.GapRight = Math.ceil(rightCoeff*RGapSign*10)/10;
}
}
},
getGapsMComp: function(MComp, direct)
{
var kind = MComp.kind;
var checkGap = this.checkGapKind(kind);
var bNeedGap = !checkGap.bEmptyGaps && !checkGap.bChildGaps;
var coeffLeft = 0.001,
coeffRight = 0; // for checkGap.bEmptyGaps
//var bDegree = kind == MATH_DEGREE || kind == MATH_DEGREESubSup;
var bDegree = kind == MATH_DEGREE;
if(checkGap.bChildGaps)
{
if(bDegree)
{
coeffLeft = 0.03;
if(MComp.IsPlhIterator())
coeffRight = 0.12;
else
coeffRight = 0.16;
}
var gapsChild = MComp.getGapsInside(this);
coeffLeft = coeffLeft < gapsChild.left ? gapsChild.left : coeffLeft;
coeffRight = coeffRight < gapsChild.right ? gapsChild.right : coeffRight;
}
else if(bNeedGap)
{
coeffLeft = 0.4;
coeffRight = 0.3;
}
var result = direct == -1 ? coeffLeft : coeffRight;
return result;
},
checkGapKind: function(kind)
{
var bEmptyGaps = kind == MATH_DELIMITER || kind == MATH_MATRIX,
bChildGaps = kind == MATH_DEGREE || kind == MATH_DEGREESubSup || kind == MATH_ACCENT || kind == MATH_RADICAL|| kind == MATH_BOX || kind == MATH_BORDER_BOX;
return {bEmptyGaps: bEmptyGaps, bChildGaps: bChildGaps};
}
}
function dist(_left, _right, _top, _bottom) function dist(_left, _right, _top, _bottom)
{ {
this.left = _left; this.left = _left;
...@@ -401,7 +872,6 @@ function CMathContent() ...@@ -401,7 +872,6 @@ function CMathContent()
center: 0 center: 0
}; };
this.init();
// Добавляем данный класс в таблицу Id (обязательно в конце конструктора) // Добавляем данный класс в таблицу Id (обязательно в конце конструктора)
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
...@@ -410,7 +880,7 @@ CMathContent.prototype = ...@@ -410,7 +880,7 @@ CMathContent.prototype =
{ {
init: function() init: function()
{ {
this.content.push( new mathElem(new CEmpty(), new dist(0,0,0,0), 0) );
}, },
setArgSize: function(argSize) setArgSize: function(argSize)
{ {
...@@ -421,6 +891,7 @@ CMathContent.prototype = ...@@ -421,6 +891,7 @@ CMathContent.prototype =
// складываем здесь, чтобы не потерять собственные настройки argSize: при добавлении в итератор формулы из меню; при добавлении готовых формул, когда есть вложенность формул с итераторами // складываем здесь, чтобы не потерять собственные настройки argSize: при добавлении в итератор формулы из меню; при добавлении готовых формул, когда есть вложенность формул с итераторами
// не будет работать при копиравнии в случае, если argSize будет отличатся от нуля для копируемой части контента // не будет работать при копиравнии в случае, если argSize будет отличатся от нуля для копируемой части контента
// поэтому при копировании свойство argSize не учитываем (копируем только массив элекентов вместе с Run Properties) // поэтому при копировании свойство argSize не учитываем (копируем только массив элекентов вместе с Run Properties)
var val = this.argSize + argSize; var val = this.argSize + argSize;
if(val < -2) if(val < -2)
...@@ -681,7 +1152,7 @@ CMathContent.prototype = ...@@ -681,7 +1152,7 @@ CMathContent.prototype =
return mathElem; // for finished equation return mathElem; // for finished equation
}, },
addElementToContent: function(obj) //for "read" old_addElementToContent: function(obj) //for "read"
{ {
var element = new mathElem(obj); var element = new mathElem(obj);
//obj.relate(this); //obj.relate(this);
...@@ -702,6 +1173,34 @@ CMathContent.prototype = ...@@ -702,6 +1173,34 @@ CMathContent.prototype =
obj.setArgSize(this.argSize); obj.setArgSize(this.argSize);
}, },
addElementToContent: function(obj) //for "read"
{
obj.Parent = this;
if(obj.typeObj === MATH_COMP)
{
obj.setComposition(this.Composition);
obj.setArgSize(this.argSize);
if(this.content.length == 0)
{
this.content.push(new ParaRun());
this.CurPos++;
}
this.content.push(obj);
this.content.push(new ParaRun());
this.CurPos += 2;
}
else
{
this.content.push(obj);
this.CurPos++;
}
this.setLogicalPosition(this.CurPos);
},
addToContent: function(obj, shift) // for "edit", letters addToContent: function(obj, shift) // for "edit", letters
{ {
var elem = new mathElem(obj); var elem = new mathElem(obj);
...@@ -3796,7 +4295,7 @@ CMathContent.prototype = ...@@ -3796,7 +4295,7 @@ CMathContent.prototype =
placeholder.relate(this); placeholder.relate(this);
placeholder.fillPlaceholders(); placeholder.fillPlaceholders();
this.content.push( new mathElem( placeholder ) ); this.content.push( placeholder );
}, },
///////// перемещение ////////// ///////// перемещение //////////
old_old_cursor_moveRight: function() old_old_cursor_moveRight: function()
...@@ -4715,40 +5214,6 @@ CMathContent.prototype = ...@@ -4715,40 +5214,6 @@ CMathContent.prototype =
return content; return content;
}, },
old_recalculateSize: function() old_recalculateSize: function()
{
var _width = 0 ;
var _ascent = 0 ;
var _descent = 0 ;
var _center = 0 ;
var _height = 0 ;
for(var i=0; i< this.content.length; i++)
{
var Size = this.content[i].value.size;
var gps = this.content[i].gaps;
_width += Size.width + gps.left + gps.right;
_descent = ( _descent < ( Size.height - Size.center + gps.bottom) ) ? ( Size.height - Size.center + gps.bottom): _descent;
_center = ( _center < (Size.center + gps.top) ) ? ( Size.center + gps.top) : _center;
var sAscent;
if( !this.content[i].value.typeObj === MATH_COMP )
sAscent = Size.ascent;
else
sAscent = Size.center;
_ascent = _ascent > sAscent ? _ascent : sAscent;
}
_width += this.gaps.left + this.gaps.right;
_height = _center + _descent + this.gaps.top + this.gaps.bottom;
_center += this.gaps.top;
this.size = {width: _width, height: _height, center: _center, ascent: _ascent};
this.update_widthContent(); /// !!!!
},
recalculateSize: function()
{ {
var width = 0 ; var width = 0 ;
var ascent = 0 ; var ascent = 0 ;
...@@ -4770,523 +5235,270 @@ CMathContent.prototype = ...@@ -4770,523 +5235,270 @@ CMathContent.prototype =
this.update_widthContent(); /// !!!! this.update_widthContent(); /// !!!!
}, },
Resize: function(oMeasure) // пересчитываем всю формулу recalculateSize: function()
{ {
// default для случая с плейсхолдером, RunPrp в контенте отсутствуют var width = 0 ;
var TxtSettings = var ascent = 0 ;
{ var descent = 0 ;
type: TXT_ROMAN,
lit: false
}; // default type is TXT_ROMAN (MATH Text)
//var posPrev = -1;
var oSize;
for(var i = 0; i < this.content.length; i++) for(var i = 0; i < this.content.length; i++)
{ {
var obj = this.content[i].value, if(this.content[i].typeObj === MATH_COMP)
type = obj.typeObj; oSize = this.content[i].size;
else
if(type == MATH_TEXT) oSize = this.content[i].Math_GetSize();
{
this.content[i].value.setMText(TxtSettings.type);
this.content[i].value.Resize(oMeasure);
if(TxtSettings.type !== TXT_NORMAL && TxtSettings.lit === false)
this.checkGapsSign(oMeasure, i);
}
else if(type == MATH_COMP)
{
this.content[i].value.Resize(oMeasure);
this.checkGapsSign(oMeasure, i);
}
else if(type == MATH_RUN_PRP)
{
var mergedWPrp = obj.getMergedWPrp();
var oWPrp = new CTextPr();
oWPrp.Merge(mergedWPrp);
this.applyArgSize(oWPrp); // здесь мержим с DEFAULT_RUN_PRP
TxtSettings = obj.getTxtSettings();
/*if(typeTxt == TXT_ROMAN) // MATH TEXT, наклон не меняем, если italic
oWPrp.Italic = false;*/
oMeasure.SetFont(oWPrp);
}
else if(type == MATH_PLACEHOLDER)
{
if(!this.bRoot)
{
var oWPrp = this.Parent.getCtrPrp();
/*var txtPrp = new CMathTextPrp();
txtPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
txtPrp.Merge(ctrPrp);*/
this.applyArgSize(oWPrp);
oWPrp.Italic = false;
oMeasure.SetFont(oWPrp); width += oSize.width;
this.content[i].value.Resize(oMeasure); ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
} var oDescent = oSize.height - oSize.ascent;
} descent = descent < oDescent ? oDescent : descent;
else if(type == MATH_PARA_RUN)
{
this.content[i].value.Math_Recalculate();
}
} }
this.recalculateSize(); this.size = {width: width, height: ascent + descent, ascent: ascent};
},
old_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 prevKind = bPrevComp ? this.content[posLeft].value.kind : null,
currKind = bCurrComp ? this.content[posCurr].value.kind : null;
var gapSign = 0;
var bNeedGap = bPrevSign || bPrevComp || bCurrSign || bCurrComp;
if(bPrevComp || bPrevSign)
{
var coeff = 0;
var oWPrp = this.getTextPrpMObj(posLeft);
this.applyArgSize(oWPrp);
gapSign = this.Composition.GetGapSign(oMeasure, oWPrp);
if(bPrevComp)
{
if(prevKind == MATH_DEGREE)
coeff = 0.15;
else if(prevKind == MATH_ACCENT || prevKind == MATH_DELIMITER || prevKind == MATH_MATRIX || prevKind == MATH_RADICAL)
{
coeff = 0;
}
else if(prevKind == MATH_BOX)
{
//TEST
/*var txtPrp = this.getTextPrpMObj(posLeft);
var wTextRPrp = this.applyArgSize(txtPrp);
oMeasure.SetFont ( wTextRPrp );
var height = g_oTextMeasurer.GetHeight();*/
var txtHeight = 2.3622*gapSign;
if(this.content[posLeft].value.size.height < txtHeight)
coeff = 0;
else
coeff = 0.2;
}
else
coeff = 0.2;
}
else if(bCurrSign)
coeff = 0.33;
else
coeff = 0.4;
this.content[posLeft].gaps.right = coeff*gapSign;
}
if(bCurrSign || bCurrComp)
{
var coeff = 0;
if(bCurrComp)
{
if(currKind == MATH_DEGREE)
coeff = 0.15;
else if(prevKind == MATH_ACCENT || prevKind == MATH_DELIMITER || prevKind == MATH_MATRIX || prevKind == MATH_RADICAL)
{
coeff = 0;
}
else if(prevKind == MATH_BOX)
{
var txtHeight = 2.3622*gapSign;
if(this.content[posLeft].value.size.height < txtHeight)
coeff = 0;
else
coeff = 0.2;
}
else
coeff = 0.3;
}
else if(bCurrSign)
coeff = 0.45;
else
coeff = 0.45;
var txtPrp = this.getTextPrpMObj(posCurr);
var wTextRPrp = this.applyArgSize(txtPrp);
gapSign = this.Composition.GetGapSign(oMeasure, wTextRPrp);
this.content[posCurr].gaps.left = coeff*gapSign;
}
}
}, },
checkGapsSign: function(oMeasure, posCurr) old_Resize: function(oMeasure) // пересчитываем всю формулу
{ {
var left = null, // default для случая с плейсхолдером, RunPrp в контенте отсутствуют
right = null; var TxtSettings =
var curr = this.content[posCurr].value; {
type: TXT_ROMAN,
if(this.argSize < 0) lit: false
{ };
// выставим нулевые gaps для случая, если при копировании/вставки часть контента добавили в итератор
this.content[posCurr].gaps.left = 0;
this.content[posCurr].gaps.right = 0;
}
else
{
var EQUAL = 0x3D,
PLUS = 0x2B,
MINUS = 0x2212,
MULT = 0x2217,
LESS = 0x3C,
GREATER = 0x3E;
var t = posCurr - 1;
while( t > 0 )
{
if(this.content[t].value.typeObj == MATH_TEXT || this.content[t].value.typeObj == MATH_COMP)
{
left = this.content[t].value;
break;
}
t--;
}
t = posCurr + 1;
while( t < this.content.length )
{
if(this.content[t].value.typeObj == MATH_TEXT || this.content[t].value.typeObj == MATH_COMP)
{
right = this.content[t].value;
break;
}
t++;
}
var coeffLeft = 0,
coeffRight = 0;
var bLeft = left !== null,
bRight = right !== null;
var bLeftComp = bLeft ? left.typeObj == MATH_COMP : false,
bRightComp = bRight ? right.typeObj == MATH_COMP : false,
bLeftText = bLeft ? left.typeObj == MATH_TEXT : false,
bRightText = bRight ? right.typeObj == MATH_TEXT : false;
var currCode = curr.typeObj == MATH_TEXT ? curr.getCodeChr() : null,
leftCode = bLeftText ? left.getCodeChr() : null,
rightCode = bRightText ? right.getCodeChr() : null;
var gapLeftComp = 0,
gapRightComp = 0;
if(bLeftComp)
gapLeftComp = this.getGapsMComp(left).right;
if(bRightComp)
gapRightComp = this.getGapsMComp(right).left;
if(curr.typeObj == MATH_TEXT)
{
var bSign = false;
if(this.checkOperSign(currCode)) // plus, minus, greater, less
{
bSign = true;
if(bLeft)
{
if(this.checkZEROSign(leftCode))
coeffLeft = 0;
else if(leftCode == EQUAL)
coeffLeft = 0.26;
else
coeffLeft = 0.52;
}
if(bRight) var RecalcInfo = new CRecalculateInfo(this.argSize, oMeasure);
{
var bZero = this.checkZEROSign(rightCode);
if(rightCode == EQUAL || bZero)
coeffRight = 0;
else
coeffRight = 0.49;
}
}
else if(currCode === MULT) // multiplication
{
bSign = true;
if(bLeft) if(this.content.length > 1)
{ {
var bZeroLeft = this.checkZEROSign(leftCode), if(this.IsEmptyRun(0))
bOperLeft = this.checkOperSign(leftCode); {
RecalcInfo.Current = this.content[1];
if(leftCode == EQUAL || bOperLeft || bZeroLeft) if(this.IsEmptyRun(2))
coeffLeft = 0; RecalcInfo.Right = this.content[2];
else if(bLeft) }
coeffLeft = 0.46; else
} RecalcInfo.Current = this.content[0]; // right не прописываем
}
if(bRight) for(var i = 0; i < this.content.length; i++)
{ {
var bZeroRight = this.checkZEROSign(rightCode),
bOperRight = this.checkOperSign(rightCode);
if(rightCode == EQUAL || bOperRight || bZeroRight) if(RecalcInfo.Current.typeObj == MATH_TEXT)
coeffRight = 0; {
else if(bRight) this.content[i].setMText(TxtSettings.type);
coeffRight = 0.49; this.content[i].Resize(oMeasure);
}
} if(TxtSettings.type !== TXT_NORMAL && TxtSettings.lit === false)
else if(currCode === EQUAL) // equal this.checkGapsSign(oMeasure, i);
{ }
bSign = true; else if(RecalcInfo.Current.typeObj == MATH_COMP)
{
RecalcInfo.Current.Resize(oMeasure);
if(bLeft) RecalcInfo.checkGapsSign(oMeasure);
{ }
var bZero = this.checkZEROSign(leftCode); else if(RecalcInfo.Current.typeObj == MATH_RUN_PRP)
if(leftCode == EQUAL || bZero) {
coeffLeft = 0; var mergedWPrp = obj.getMergedWPrp();
else if(this.checkOperSign(leftCode)) var oWPrp = new CTextPr();
coeffLeft = 0.35; oWPrp.Merge(mergedWPrp);
else
coeffLeft = 0.7;
}
if(bRight) this.applyArgSize(oWPrp); // здесь мержим с DEFAULT_RUN_PRP
{
var bZero = this.checkZEROSign(rightCode);
if(rightCode == EQUAL || bZero)
coeffRight = 0;
else if(this.checkOperSign(rightCode))
coeffRight = 0.25;
else
coeffRight = 0.5;
}
}
if(bSign && bLeftComp) TxtSettings = obj.getTxtSettings();
coeffLeft = coeffLeft - gapLeftComp;
if(bSign && bRightComp) /*if(typeTxt == TXT_ROMAN) // MATH TEXT, наклон не меняем, если italic
coeffRight = coeffRight - gapRightComp; oWPrp.Italic = false;*/
coeffLeft = Math.ceil(coeffLeft*10)/10;
coeffRight = Math.ceil(coeffRight*10)/10;
oMeasure.SetFont(oWPrp);
} }
else if(curr.typeObj == MATH_COMP) else if(RecalcInfo.Current.typeObj == MATH_PLACEHOLDER)
{ {
var currGaps = this.getGapsMComp(curr); if(!this.bRoot)
if(bLeft)
{ {
coeffLeft = currGaps.left; var oWPrp = this.Parent.getCtrPrp();
if(bLeftComp) /*var txtPrp = new CMathTextPrp();
{ txtPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
if(gapLeftComp/2 < coeffLeft) txtPrp.Merge(ctrPrp);*/
coeffLeft = gapLeftComp/2;
}
}
if(bRight)
{
coeffRight = currGaps.right;
if(bRightComp) this.applyArgSize(oWPrp);
{ oWPrp.Italic = false;
if(coeffRight/2 > gapRightComp )
coeffRight -= gapRightComp; oMeasure.SetFont(oWPrp);
else
coeffRight /=2; this.content[i].Resize(oMeasure);
}
} }
} }
else if(RecalcInfo.Current.typeObj == MATH_PARA_RUN)
if(bLeftText)
{ {
if(leftCode == 0x28 || leftCode == 0x5B || leftCode == 0x7B) RecalcInfo.Current.Math_Recalculate(RecalcInfo);
coeffLeft = 0;
} }
if(bRightText) RecalcInfo.Left = RecalcInfo.Сurrent;
RecalcInfo.Сurrent = RecalcInfo.Right;
if( i+1 == this.content.length )
RecalcInfo.Right = null;
else if(this.IsEmptyRun(i+1))
{ {
if(rightCode == 0x29 || rightCode == 0x5D || rightCode == 0x7D) if(i + 2 == this.content.length)
coeffRight = 0; RecalcInfo.Right = null;
else
RacalcInfo.Right = this.content[i+2];
} }
}
var runPrp = this.getRunPrp(posCurr); this.recalculateSize();
var oWPrp = runPrp.getMergedWPrp(); },
this.applyArgSize(oWPrp); Resize: function(oMeasure) // пересчитываем всю формулу
{
// default для случая с плейсхолдером, RunPrp в контенте отсутствуют
/*var TxtSettings =
{
type: TXT_ROMAN,
lit: false
};*/
var gapSign = 0.1513*oWPrp.FontSize; var RecalcInfo = new CRecalculateInfo(oMeasure, this.argSize, this.Composition);
this.content[posCurr].gaps.left = Math.ceil(coeffLeft*gapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте /*if(this.content.length > 1)
this.content[posCurr].gaps.right = Math.ceil(coeffRight*gapSign*10)/10; {
if(this.IsEmptyRun(0))
{
RecalcInfo.Current = this.content[1];
/*if(this.bRoot) if(this.IsEmptyRun(2))
{ RecalcInfo.Right = this.content[2];
if(bSign) }
{ else
var code = this.content[posCurr].value.getCodeChr(); RecalcInfo.Current = this.content[0]; // right не прописываем
console.log(" " + String.fromCharCode(code)); }*/
}
else if(curr.typeObj == MATH_COMP)
{
console.log(curr.constructor.name + " :")
}
if(bSign || curr.typeObj == MATH_COMP) for(var pos = 0; pos < this.content.length; pos++)
{ {
console.log("coeff left " + coeffLeft + ", coeff right " + coeffRight ); if(this.content[pos].typeObj == MATH_COMP)
console.log("gap left : " + this.content[posCurr].gaps.left + ", gap right : " + this.content[posCurr].gaps.right); {
console.log(""); this.content[pos].Resize(oMeasure);
}
}*/
}
}, RecalcInfo.Left = RecalcInfo.Current;
getGapsMComp: function(MComp) RecalcInfo.leftRunPrp = RecalcInfo.currRunPrp;
{
var kind = MComp.kind;
var checkGap = this.checkGapKind(kind);
var bNeedGap = !checkGap.bEmptyGaps && !checkGap.bChildGaps; RecalcInfo.Current = this.content[pos];
var coeffLeft = 0.001, //var currRPrp = this.content[pos].getRunPrp();
coeffRight = 0; // for checkGap.bEmptyGaps
//var bDegree = kind == MATH_DEGREE || kind == MATH_DEGREESubSup; var runPrp =this.content[pos].getRunPrp();
var bDegree = kind == MATH_DEGREE; var currRPrp = runPrp.getMergedWPrp();
this.applyArgSize(currRPrp);
if(checkGap.bChildGaps)
{ RecalcInfo.currRunPrp = currRPrp;
if(bDegree)
RecalcInfo.setGaps();
}
else if(this.content[pos].typeObj == MATH_PLACEHOLDER)
{ {
coeffLeft = 0.03; if(!this.bRoot)
{
var oWPrp = this.Parent.getCtrPrp();
if(MComp.IsPlhIterator()) this.applyArgSize(oWPrp);
coeffRight = 0.12; oWPrp.Italic = false;
else
coeffRight = 0.16; oMeasure.SetFont(oWPrp);
this.content[pos].Resize(oMeasure);
}
}
else if(this.content[pos].typeObj == MATH_PARA_RUN)
{
this.content[pos].Math_Recalculate(RecalcInfo);
} }
var gapsChild = MComp.getGapsInside(); /*RecalcInfo.Left = RecalcInfo.Сurrent;
RecalcInfo.Сurrent = RecalcInfo.Right;*/
coeffLeft = coeffLeft < gapsChild.left ? gapsChild.left : coeffLeft; /*if( pos+1 == this.content.length )
coeffRight = coeffRight < gapsChild.right ? gapsChild.right : coeffRight; RecalcInfo.Right = null;
} else if(this.IsEmptyRun(pos+1))
else if(bNeedGap) {
{ if(pos+2 == this.content.length)
coeffLeft = 0.4; RecalcInfo.Right = null;
//coeffRight = 0.26; else
coeffRight = 0.3; RecalcInfo.Right = this.content[pos+2];
}
else
pos++;*/
} }
return {left: coeffLeft, right: coeffRight}; if(RecalcInfo.Current !== null)
RecalcInfo.Current.GapRight = 0;
this.recalculateSize();
}, },
getGapsInside: function() // учитываем gaps внутренних объектов IsEmptyRun: function(pos) // пустой Para_Run
{ {
var typeFirst = this.content.length > 1 ? this.content[1].value.typeObj : null; var result = false;
var bFirstComp = typeFirst == MATH_COMP, if(pos < this.content.length)
result = this.content[pos].typeObj !== MATH_COMP && this.content[pos].Is_Empty();
return result;
},
getGapsInside: function(RecalcInfo) // учитываем gaps внутренних объектов
{
var gaps = {left: 0, right: 0};
var bFirstComp = false,
bLastComp = false; bLastComp = false;
var posLComp = -1; var len = this.content.length;
if( this.content.length > 1 ) if(len > 1)
{ {
posLComp = this.content.length - 2; var bFRunEmpty = this.content[0].Is_Empty();
bLastComp = this.content[posLComp].value.typeObj == MATH_COMP; bFirstComp = bFRunEmpty && this.content[1].typeObj == MATH_COMP; // первый всегда идет Run
}
var gaps = {left: 0, right: 0}; var bLastRunEmpty = this.content[len - 1].Is_Empty(); // т.к. после мат. объекта стоит пустой Run
bLastComp = bLastRunEmpty && this.content[len - 2].typeObj == MATH_COMP;
}
var checkGap; var checkGap;
if(bFirstComp) if(bFirstComp)
{ {
checkGap = this.checkGapKind(this.content[0].value.kind); checkGap = RecalcInfo.checkGapKind(this.content[1].kind);
if(!checkGap.bChildGaps) if(!checkGap.bChildGaps)
{ {
var gapsMComp = this.getGapsMComp(this.content[0].value); var gapsMComp = RecalcInfo.getGapsMComp(this.content[1]);
gaps.left = gapsMComp.left; gaps.left = gapsMComp.left;
} }
} }
if(bLastComp) if(bLastComp)
{ {
checkGap = this.checkGapKind(this.content[posLComp].value.kind); checkGap = RecalcInfo.checkGapKind(this.content[len - 1].kind);
if(!checkGap.bChildGaps) if(!checkGap.bChildGaps)
{ {
var gapsMComp = this.getGapsMComp(this.content[0].value); var gapsMComp = RecalcInfo.getGapsMComp(this.content[len - 1]);
gaps.right = gapsMComp.right; gaps.right = gapsMComp.right;
} }
} }
return gaps; return gaps;
}, },
checkGapKind: function(kind)
{
var bEmptyGaps = kind == MATH_DELIMITER || kind == MATH_MATRIX,
bChildGaps = kind == MATH_DEGREE || kind == MATH_DEGREESubSup || kind == MATH_ACCENT || kind == MATH_RADICAL|| kind == MATH_BOX || kind == MATH_BORDER_BOX;
return {bEmptyGaps: bEmptyGaps, bChildGaps: bChildGaps};
},
checkZEROSign: function(code) // "*", "/", "\"
{
var MULT = 0x2217,
DIVISION = 0x2F,
B_SLASH = 0x5C;
return code == MULT || code == DIVISION || code == B_SLASH;
},
checkOperSign: function(code) // "+", "-", "<", ">", "±"
{
var PLUS = 0x2B,
MINUS = 0x2212,
LESS = 0x3C,
GREATER = 0x3E,
PLUS_MINUS = 0xB1;
return code == PLUS || code == MINUS || code == LESS || code == GREATER || code == PLUS_MINUS;;
},
IsOnlyText: function() IsOnlyText: function()
{ {
var bOnlyText = true; var bOnlyText = true;
for(var i = 0; i < this.content.length; i++) for(var i = 0; i < this.content.length; i++)
{ {
if(this.content[i].value.typeObj == MATH_COMP) if(this.content[i].typeObj == MATH_COMP)
{ {
bOnlyText = false; bOnlyText = false;
break; break;
...@@ -5346,7 +5558,7 @@ CMathContent.prototype = ...@@ -5346,7 +5558,7 @@ CMathContent.prototype =
{ {
for(var i=0; i < this.content.length;i++) for(var i=0; i < this.content.length;i++)
{ {
if(this.content[i].value.typeObj == MATH_RUN_PRP) if(this.content[i].typeObj == MATH_RUN_PRP)
{ {
pGraphics.b_color1(0,0,0,255); pGraphics.b_color1(0,0,0,255);
var mgWPrp = this.content[i].value.getMergedWPrp(); var mgWPrp = this.content[i].value.getMergedWPrp();
...@@ -5357,7 +5569,7 @@ CMathContent.prototype = ...@@ -5357,7 +5569,7 @@ CMathContent.prototype =
pGraphics.SetFont(oWPrp); pGraphics.SetFont(oWPrp);
} }
else if(this.content[i].value.typeObj == MATH_PLACEHOLDER) else if(this.content[i].typeObj == MATH_PLACEHOLDER)
{ {
pGraphics.b_color1(0,0,0,255); pGraphics.b_color1(0,0,0,255);
...@@ -5373,15 +5585,12 @@ CMathContent.prototype = ...@@ -5373,15 +5585,12 @@ CMathContent.prototype =
oWPrp.Italic = false; oWPrp.Italic = false;
pGraphics.SetFont(oWPrp); pGraphics.SetFont(oWPrp);
this.content[i].value.draw(x, y, pGraphics); this.content[i].draw(x, y, pGraphics);
}
else if(this.content[i].value.typeObj == MATH_PARA_RUN)
{
var PSDE = {X: x, Y: y, Graphics: pGraphics};
this.content[i].value.Math_Draw(x, y, pGraphics);
} }
else else if(this.content[i].typeObj == MATH_COMP)
this.content[i].value.draw(x, y, pGraphics); this.content[i].draw(x, y, pGraphics);
else // MATH_PARA_RUN
this.content[i].Math_Draw(x, y, pGraphics);
/*if(this.content[i].value.typeObj == MATH_COMP) /*if(this.content[i].value.typeObj == MATH_COMP)
{ {
...@@ -5430,7 +5639,7 @@ CMathContent.prototype = ...@@ -5430,7 +5639,7 @@ CMathContent.prototype =
{ {
for(var i = 1; i <this.content.length; i++) for(var i = 1; i <this.content.length; i++)
{ {
this.content[i].widthToEl = this.content[i-1].widthToEl + this.content[i].value.size.width + this.content[i].gaps.left + this.content[i].gaps.right; this.content[i].widthToEl = this.content[i-1].widthToEl + this.content[i].value.size.width + this.content[i].GapLeft + this.content[i].GapRight;
} }
}, },
old_update_Cursor: function() old_update_Cursor: function()
...@@ -6191,14 +6400,19 @@ CMathContent.prototype = ...@@ -6191,14 +6400,19 @@ CMathContent.prototype =
for(var i=0; i < this.content.length; i++) for(var i=0; i < this.content.length; i++)
{ {
_pos.x += this.content[i].gaps.left; if(this.content[i].typeObj == MATH_COMP)
{
if(this.content[i].value.typeObj == MATH_PARA_RUN) _pos.x += this.content[i].GapLeft;
this.content[i].value.Math_SetPosition(_pos); this.content[i].setPosition(_pos);
_pos.x += this.content[i].size.width + this.content[i].GapRight;
}
else else
this.content[i].value.setPosition(_pos); {
this.content[i].Math_SetPosition(_pos);
_pos.x += this.content[i].Math_GetSize().width;
}
_pos.x += this.content[i].value.size.width;
} }
}, },
old_drawSelect: function() old_drawSelect: function()
...@@ -6387,7 +6601,7 @@ CMathContent.prototype = ...@@ -6387,7 +6601,7 @@ CMathContent.prototype =
if(this.content.length > 1) if(this.content.length > 1)
{ {
var obj = this.content[1].value; var obj = this.content[1];
if(obj.typeObj === MATH_RUN_PRP) // если первый объект - буква if(obj.typeObj === MATH_RUN_PRP) // если первый объект - буква
{ {
rPrp.Merge(obj); rPrp.Merge(obj);
...@@ -8237,7 +8451,7 @@ CMathComposition.prototype = ...@@ -8237,7 +8451,7 @@ CMathComposition.prototype =
//////////////* end of test functions *////////////////// //////////////* end of test functions *//////////////////
Init: function() Init: function()
{ {
this.Root = new CMathContent(); this.Root = new CMathContent();
//this.Root.gaps = gps; //this.Root.gaps = gps;
this.Root.setComposition(this); this.Root.setComposition(this);
......
...@@ -58,6 +58,9 @@ function CMathText() ...@@ -58,6 +58,9 @@ function CMathText()
this.bJDraw = false; this.bJDraw = false;
this.type = TXT_ROMAN; this.type = TXT_ROMAN;
this.GapLeft = 0;
this.GapRight = 0;
//this.Parent = null; //this.Parent = null;
/*this.TxtPrp = new CMathTextPrp(); /*this.TxtPrp = new CMathTextPrp();
...@@ -65,6 +68,10 @@ function CMathText() ...@@ -65,6 +68,10 @@ function CMathText()
//this.sizeSymbol = null; // размер символа без учета трансформации //this.sizeSymbol = null; // размер символа без учета трансформации
// TO DO
// убрать
this.transform = this.transform =
{ {
sx: 1, sx: 1,
...@@ -99,8 +106,6 @@ CMathText.prototype = ...@@ -99,8 +106,6 @@ CMathText.prototype =
if(this.type == TXT_ROMAN ) if(this.type == TXT_ROMAN )
{ {
var bDigit = (code > 0x002F && code < 0x003A), var bDigit = (code > 0x002F && code < 0x003A),
bCapGreek = (code > 0x0390 && code < 0x03AA ), bCapGreek = (code > 0x0390 && code < 0x03AA ),
bSmallGreek = (code > 0x03B0 && code < 0x03CA); bSmallGreek = (code > 0x03B0 && code < 0x03CA);
...@@ -248,6 +253,8 @@ CMathText.prototype = ...@@ -248,6 +253,8 @@ CMathText.prototype =
var widthG = metricsTxt.WidthG; var widthG = metricsTxt.WidthG;
width += this.GapLeft + this.GapRight;
this.size = {width: width, widthG: widthG, height: height, ascent: ascent}; this.size = {width: width, widthG: widthG, height: height, ascent: ascent};
}, },
old_draw: function() old_draw: 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