Commit 7d32ae57 authored by Anna.Pavlova's avatar Anna.Pavlova

1. поправила перемещение по стрелкам для плейсхолдера (пока выставляется курсор вместо селекта)

2. поправила функцию для смерженных текстовых настроек (applyArgSize) в base.js

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55817 954022d7-b5bf-4e40-9824-e11837661b57
parent 7b388fff
...@@ -183,16 +183,19 @@ CMathBase.prototype = ...@@ -183,16 +183,19 @@ CMathBase.prototype =
if( !this.elements[i][j].IsJustDraw()) if( !this.elements[i][j].IsJustDraw())
this.elements[i][j].setArgSize(argSize); this.elements[i][j].setArgSize(argSize);
}, },
// TO DO
// посмотреть для всех мат. объектов, где используется эта функция
mergeCtrTPrp: function() mergeCtrTPrp: function()
{ {
var tPrp = this.getCtrPrp(); var tPrp = this.getCtrPrp();
this.Composition.Parent.ApplyArgSize(tPrp);
if(this.argSize == -1) /*if(this.argSize == -1)
//tPrp.FontSize *= 0.8; //tPrp.FontSize *= 0.8;
tPrp.FontSize *= 0.728; tPrp.FontSize *= 0.728;
else if(this.argSize == -2) else if(this.argSize == -2)
//tPrp.FontSize *= 0.65; //tPrp.FontSize *= 0.65;
tPrp.FontSize *= 0.53; tPrp.FontSize *= 0.53;*/
return tPrp; return tPrp;
}, },
...@@ -1443,7 +1446,10 @@ CMathBase.prototype = ...@@ -1443,7 +1446,10 @@ CMathBase.prototype =
{ {
while(CurPos_Y >= 0) while(CurPos_Y >= 0)
{ {
if( ! this.elements[CurPos_X][CurPos_Y].IsJustDraw() ) var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(),
usePlh = bUseContent && this.elements[CurPos_X][CurPos_Y].IsPlaceholder();
if(!bJDraw && ! usePlh)
{ {
this.elements[CurPos_X][CurPos_Y].Get_LeftPos(SearchPos, ContentPos, Depth + 2, bUseContent, EndRun); this.elements[CurPos_X][CurPos_Y].Get_LeftPos(SearchPos, ContentPos, Depth + 2, bUseContent, EndRun);
SearchPos.Pos.Update(CurPos_X, Depth); SearchPos.Pos.Update(CurPos_X, Depth);
...@@ -1469,48 +1475,6 @@ CMathBase.prototype = ...@@ -1469,48 +1475,6 @@ CMathBase.prototype =
result = SearchPos.Found; result = SearchPos.Found;
/*if( ! this.elements[CurPos_X][CurPos_Y].IsJustDraw() )
{
this.elements[CurPos_X][CurPos_Y].Get_LeftPos(SearchPos, ContentPos, Depth + 2, UseContentPos, EndRun);
SearchPos.Pos.Update(CurPos_X, Depth);
SearchPos.Pos.Update(CurPos_Y, Depth+1);
if(SearchPos.Found === true)
result = true;
}
if( result == false)
{
while(CurPos_Y >= 0)
{
while(CurPos_X >= 0)
{
if( this.elements[CurPos_X][CurPos_Y].IsJustDraw() == false)
{
this.elements[CurPos_X][CurPos_Y].Get_LeftPos(SearchPos, ContentPos, Depth + 2, false, true);
SearchPos.Pos.Update(CurPos_X, Depth);
SearchPos.Pos.Update(CurPos_Y, Depth+1);
}
if(SearchPos.Found === true)
{
result = true;
break;
}
CurPos_X--;
}
if(SearchPos.Found === true)
break;
CurPos_Y--;
CurPos_X = this.nRow;
}
}*/
return result; return result;
}, },
Get_RightPos: function(SearchPos, ContentPos, Depth, UseContentPos, BegRun) Get_RightPos: function(SearchPos, ContentPos, Depth, UseContentPos, BegRun)
...@@ -1535,7 +1499,10 @@ CMathBase.prototype = ...@@ -1535,7 +1499,10 @@ CMathBase.prototype =
{ {
while(CurPos_Y < this.nCol) while(CurPos_Y < this.nCol)
{ {
if( ! this.elements[CurPos_X][CurPos_Y].IsJustDraw() ) var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(),
usePlh = bUseContent && this.elements[CurPos_X][CurPos_Y].IsPlaceholder();
if(!bJDraw && ! usePlh)
{ {
this.elements[CurPos_X][CurPos_Y].Get_RightPos(SearchPos, ContentPos, Depth + 2, bUseContent, BegRun); this.elements[CurPos_X][CurPos_Y].Get_RightPos(SearchPos, ContentPos, Depth + 2, bUseContent, BegRun);
SearchPos.Pos.Update(CurPos_X, Depth); SearchPos.Pos.Update(CurPos_X, Depth);
......
...@@ -2,8 +2,12 @@ function CFraction() ...@@ -2,8 +2,12 @@ function CFraction()
{ {
this.kind = MATH_FRACTION; this.kind = MATH_FRACTION;
this.type = BAR_FRACTION; this.Pr =
this.bHideBar = false; {
type: BAR_FRACTION,
bHideBar: false
};
CMathBase.call(this); CMathBase.call(this);
} }
extend(CFraction, CMathBase); extend(CFraction, CMathBase);
...@@ -18,10 +22,10 @@ CFraction.prototype.init = function(props) ...@@ -18,10 +22,10 @@ CFraction.prototype.init = function(props)
bLin = props.type === LINEAR_FRACTION; bLin = props.type === LINEAR_FRACTION;
if(bBar || bSkew || bLin) // на всякий случай if(bBar || bSkew || bLin) // на всякий случай
this.type = props.type; this.Pr.type = props.type;
} }
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
{ {
var num = new CNumerator(); var num = new CNumerator();
num.init(); num.init();
...@@ -31,17 +35,17 @@ CFraction.prototype.init = function(props) ...@@ -31,17 +35,17 @@ CFraction.prototype.init = function(props)
this.setDimension(2, 1); this.setDimension(2, 1);
if(this.type == NO_BAR_FRACTION) if(this.Pr.type == NO_BAR_FRACTION)
this.bHideBar = true; this.bHideBar = true;
this.addMCToContent(num, den); this.addMCToContent(num, den);
} }
else if(this.type == SKEWED_FRACTION) else if(this.Pr.type == SKEWED_FRACTION)
{ {
this.setDimension(1, 2); this.setDimension(1, 2);
this.setContent(); this.setContent();
} }
else if(this.type == LINEAR_FRACTION) else if(this.Pr.type == LINEAR_FRACTION)
{ {
this.setDimension(1, 2); this.setDimension(1, 2);
this.setContent(); this.setContent();
...@@ -50,37 +54,21 @@ CFraction.prototype.init = function(props) ...@@ -50,37 +54,21 @@ CFraction.prototype.init = function(props)
/// вызов этой функции обязательно в конце /// вызов этой функции обязательно в конце
this.WriteContentsToHistory(); this.WriteContentsToHistory();
} }
CFraction.prototype.getType = function() CFraction.prototype.init_2 = function(props)
{ {
return this.type;
} }
CFraction.prototype.old_getCenter = function() CFraction.prototype.getType = function()
{ {
var center; return this.Pr.type;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{
var penW = this.getCtrPrp().FontSize* 25.4/96 * 0.08 /2;
center = this.elements[0][0].size.height + penW;
}
else if(this.type == SKEWED_FRACTION)
{
center = this.elements[0][0].size.height;
}
else if(this.type == LINEAR_FRACTION)
{
center = CFraction.superclass.getCenter.call(this);
}
return center;
} }
CFraction.prototype.draw = function(x, y, pGraphics) CFraction.prototype.draw = function(x, y, pGraphics)
{ {
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
this.drawBarFraction(x, y, pGraphics); this.drawBarFraction(x, y, pGraphics);
else if(this.type == SKEWED_FRACTION) else if(this.Pr.type == SKEWED_FRACTION)
this.drawSkewedFraction(x, y, pGraphics); this.drawSkewedFraction(x, y, pGraphics);
else if(this.type == LINEAR_FRACTION) else if(this.Pr.type == LINEAR_FRACTION)
this.drawLinearFraction(x, y, pGraphics); this.drawLinearFraction(x, y, pGraphics);
} }
CFraction.prototype.drawBarFraction = function(x, y, pGraphics) CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
...@@ -246,7 +234,7 @@ CFraction.prototype.getNumerator = function() ...@@ -246,7 +234,7 @@ CFraction.prototype.getNumerator = function()
{ {
var numerator; var numerator;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
numerator = this.elements[0][0].getElement(); numerator = this.elements[0][0].getElement();
else else
numerator = this.elements[0][0]; numerator = this.elements[0][0];
...@@ -257,7 +245,7 @@ CFraction.prototype.getDenominator = function() ...@@ -257,7 +245,7 @@ CFraction.prototype.getDenominator = function()
{ {
var denominator; var denominator;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
denominator = this.elements[1][0].getElement(); denominator = this.elements[1][0].getElement();
else else
denominator = this.elements[0][1]; denominator = this.elements[0][1];
...@@ -266,11 +254,11 @@ CFraction.prototype.getDenominator = function() ...@@ -266,11 +254,11 @@ CFraction.prototype.getDenominator = function()
} }
CFraction.prototype.recalculateSize = function(oMeasure) CFraction.prototype.recalculateSize = function(oMeasure)
{ {
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
this.recalculateBarFraction(oMeasure); this.recalculateBarFraction(oMeasure);
else if(this.type == SKEWED_FRACTION) else if(this.Pr.type == SKEWED_FRACTION)
this.recalculateSkewed(oMeasure); this.recalculateSkewed(oMeasure);
else if(this.type == LINEAR_FRACTION) else if(this.Pr.type == LINEAR_FRACTION)
this.recalculateLinear(oMeasure); this.recalculateLinear(oMeasure);
} }
CFraction.prototype.recalculateBarFraction = function(oMeasure) CFraction.prototype.recalculateBarFraction = function(oMeasure)
...@@ -342,7 +330,7 @@ CFraction.prototype.recalculateLinear = function() ...@@ -342,7 +330,7 @@ CFraction.prototype.recalculateLinear = function()
} }
CFraction.prototype.setPosition = function(pos) CFraction.prototype.setPosition = function(pos)
{ {
if(this.type == SKEWED_FRACTION) if(this.Pr.type == SKEWED_FRACTION)
{ {
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; this.pos = {x: pos.x, y: pos.y - this.size.ascent};
...@@ -363,7 +351,7 @@ CFraction.prototype.findDisposition = function( mCoord ) ...@@ -363,7 +351,7 @@ CFraction.prototype.findDisposition = function( mCoord )
{ {
var disposition; var disposition;
if(this.type == SKEWED_FRACTION) if(this.Pr.type == SKEWED_FRACTION)
{ {
var mouseCoord = {x: mCoord.x, y: mCoord.y}, var mouseCoord = {x: mCoord.x, y: mCoord.y},
posCurs = {x: null, y: null}, posCurs = {x: null, y: null},
...@@ -429,13 +417,13 @@ CFraction.prototype.findDisposition = function( mCoord ) ...@@ -429,13 +417,13 @@ CFraction.prototype.findDisposition = function( mCoord )
CFraction.prototype.getPropsForWrite = function() CFraction.prototype.getPropsForWrite = function()
{ {
var type = null; var type = null;
if (this.type == BAR_FRACTION) if (this.Pr.type == BAR_FRACTION)
type = 0; type = 0;
else if (this.type == LINEAR_FRACTION) else if (this.Pr.type == LINEAR_FRACTION)
type = 1; type = 1;
else if (this.type == NO_BAR_FRACTION) else if (this.Pr.type == NO_BAR_FRACTION)
type = 2; type = 2;
else if (this.type == SKEWED_FRACTION) else if (this.Pr.type == SKEWED_FRACTION)
type = 3; type = 3;
var props = { var props = {
...@@ -581,358 +569,3 @@ CDenominator.prototype.getRunPrp = function() ...@@ -581,358 +569,3 @@ CDenominator.prototype.getRunPrp = function()
} }
////////// //////////
function old_CBarFraction()
{
this.bHide = false;
this.bSimple = false;
CMathBase.call(this);
}
extend(old_CBarFraction, CMathBase);
old_CBarFraction.prototype.init = function()
{
var num = new CNumerator();
num.init();
var den = new CDenominator();
den.init();
this.setDimension(2, 1);
this.addMCToContent(num, den);
}
old_CBarFraction.prototype.getCenter = function()
{
var penW = this.getTxtPrp().FontSize* 25.4/96 * 0.08 /2;
return this.elements[0][0].size.height + penW;
}
old_CBarFraction.prototype.draw = function()
{
var penW = this.getTxtPrp().FontSize* this.reduct* 25.4/96 * 0.08;
var x1 = this.pos.x,
x2 = this.pos.x + this.size.width,
y1 = y2 = this.pos.y + this.size.center - penW/2;
if(!this.bHide)
{
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph.drawHorLine(0, y1, x1, x2, penW);
}
old_CBarFraction.superclass.draw.call(this);
}
old_CBarFraction.prototype.getNumerator = function()
{
return this.elements[0][0].getElement();
}
old_CBarFraction.prototype.getDenominator = function()
{
return this.elements[1][0].getElement();
}
old_CBarFraction.prototype.hideBar = function(flag)
{
this.bHide = flag;
}
old_CBarFraction.prototype.setSimple = function(flag)
{
this.bSimple = flag;
if(flag)
this.setReduct(DEGR_REDUCT);
else
this.setReduct(1);
this.Resize();
}
//////////
function old_CSkewedFraction()
{
this.gapSlash = 0;
CMathBase.call(this);
}
extend(old_CSkewedFraction, CMathBase);
old_CSkewedFraction.prototype.init = function()
{
this.setDimension(1, 2);
this.setContent();
}
old_CSkewedFraction.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
this.elements[0][0].setPosition(this.pos);
var x = this.pos.x + this.elements[0][0].size.width + this.gapSlash,
y = this.pos.y + this.size.center;
this.elements[0][1].setPosition({x: x, y: y});
/* var WidthSlash = this.size.width - this.elements[0][0].size.width - this.elements[0][2].size.width; //т.к. расстояние между элементами не равно ширине слеша
var shiftWidth = (WidthSlash < this.elements[0][1].size.width) ? (this.elements[0][1].size.width - WidthSlash)/2 : 0;
var ratio = this.elements[0][0].size.height / this.size.height;
var shiftHeight = (this.size.height - this.elements[0][1].size.height)*ratio;
this.elements[0][1].setPosition({x: this.pos.x + this.elements[0][0].size.width - shiftWidth, y: this.pos.y + shiftHeight });
this.elements[0][2].setPosition({x: this.pos.x + this.elements[0][0].size.width + WidthSlash, y: this.pos.y + this.size.center});*/
}
old_CSkewedFraction.prototype.recalculateSize = function()
{
this.gapSlash = 5.011235894097222 * this.getTxtPrp().FontSize/36;
var _width = this.elements[0][0].size.width + this.gapSlash + this.elements[0][1].size.width;
var _height = this.elements[0][0].size.height + this.elements[0][1].size.height;
var _center = this.getCenter();
this.size = {width: _width, height: _height, center: _center};
}
old_CSkewedFraction.prototype.getCenter = function()
{
return this.elements[0][0].size.height;
};
old_CSkewedFraction.prototype.findDisposition = function( mCoord )
{
var mouseCoord = {x: mCoord.x, y: mCoord.y},
posCurs = {x: null, y: null},
inside_flag = -1;
posCurs.x = 0;
if( mCoord.x < (this.elements[0][0].size.width + this.gapSlash/2))
{
var sizeFirst = this.elements[0][0].size;
if(sizeFirst.width < mCoord.x)
{
mouseCoord.x = sizeFirst.width;
inside_flag = 1;
}
if(sizeFirst.height < mCoord.y)
{
mouseCoord.y = sizeFirst.height;
inside_flag = 2;
}
posCurs.y = 0;
}
else
{
var sizeSec = this.elements[0][1].size;
if(mCoord.x < this.size.width - sizeSec.width)
{
mouseCoord.x = 0;
inside_flag = 0;
}
else if( mCoord.x > this.size.width)
{
mouseCoord.x = sizeSec.width;
inside_flag = 1;
}
else
mouseCoord.x = mCoord.x - this.elements[0][0].size.width - this.gapSlash;
if( mCoord.y < this.size.height - this.elements[0][1].size.height)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > this.size.height)
{
mouseCoord.y = sizeSec.height;
inside_flag = 2;
}
else
mouseCoord.y = mCoord.y - this.elements[0][0].size.height;
posCurs.y = 1;
}
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
old_CSkewedFraction.prototype.draw = function()
{
var fontSize = this.getTxtPrp().FontSize;
var penW = fontSize/12.5*g_dKoef_pix_to_mm;
//to do
//переделать
var gap = this.gapSlash/2 - penW/7.5;
var plh = 9.877777777777776 * fontSize / 36;
var minHeight = 2*this.gapSlash,
middleHeight = plh*4/3,
maxHeight = (3*this.gapSlash + 5*plh)*2/3;
var tg1 = -2.22,
tg2 = -3.7;
var heightSlash = this.size.height*2/3;
if(heightSlash < maxHeight)
{
if(heightSlash < minHeight)
{
heightSlash = minHeight;
tg = tg1;
}
else
{
heightSlash = this.size.height*2/3;
tg = (heightSlash - maxHeight)*(tg1 - tg2)/(middleHeight - maxHeight) + tg2;
}
var b = this.elements[0][0].size.height - tg*(this.elements[0][0].size.width + gap);
var y1 = this.elements[0][0].size.height/3,
y2 = this.elements[0][0].size.height/3 + heightSlash;
var x1 = (y1 - b)/tg,
x2 = (y2 - b)/tg;
var xx1 = this.pos.x + x1,
xx2 = this.pos.x + x2;
var yy1 = this.pos.y + y1,
yy2 = this.pos.y + y2;
}
else
{
heightSlash = maxHeight;
tg = tg2;
coeff = this.elements[0][0].size.height/this.size.height;
shift = heightSlash*coeff;
var minVal = plh/2,
maxVal = heightSlash - minVal;
if(shift < minVal)
shift = minVal;
else if(shift > maxVal)
shift = maxVal;
var y0 = this.elements[0][0].size.height - shift;
var b = this.elements[0][0].size.height - tg*(this.elements[0][0].size.width + gap);
var y1 = y0,
y2 = y0 + heightSlash;
var x1 = (y1 - b)/tg,
x2 = (y2 - b)/tg;
var xx1 = this.pos.x + x1,
xx2 = this.pos.x + x2;
var yy1 = this.pos.y + y1 ,
yy2 = this.pos.y + y2;
}
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(xx1, yy1);
MathControl.pGraph._l(xx2, yy2);
MathControl.pGraph.ds();
old_CSkewedFraction.superclass.draw.call(this);
}
old_CSkewedFraction.prototype.getNumerator = function()
{
return this.elements[0][0];
}
old_CSkewedFraction.prototype.getDenominator = function()
{
return this.elements[0][1];
}
//////////
function old_CLinearFraction()
{
CMathBase.call(this);
}
extend(old_CLinearFraction, CMathBase);
old_CLinearFraction.prototype.init = function()
{
this.setDimension(1, 2);
this.setContent();
}
old_CLinearFraction.prototype.recalculateSize = function()
{
var H = this.elements[0][0].size.center + this.elements[0][1].size.height - this.elements[0][1].size.center;
var txtPrp = this.getTxtPrp();
var gap = 5.011235894097222*txtPrp.FontSize/36;
var H3 = gap*4.942252165543792,
H4 = gap*7.913378248315688,
H5 = gap*9.884504331087584;
if( H < H3 )
this.dW = gap;
else if( H < H4 )
this.dW = 2*gap;
else if( H < H5 )
this.dW = 2.8*gap;
else
this.dW = 3.4*gap;
var h1 = this.elements[0][0].size.height,
h2 = this.elements[0][1].size.height;
var c1 = this.elements[0][0].size.center,
c2 = this.elements[0][1].size.center;
var asc = c1 > c2 ? c1 : c2;
var desc = h1 - c1 > h2 - c2 ? h1- c1 : h2 - c2;
var height = asc + desc;
var width = this.elements[0][0].size.width + this.dW + this.elements[0][1].size.width;
var center = this.getCenter();
this.size = {height: height, width: width, center: center};
}
old_CLinearFraction.prototype.draw = function()
{
var first = this.elements[0][0].size,
sec = this.elements[0][1].size;
var cent = first.center > sec.center ? first.center : sec.center,
desc1 = first.height - first.center, desc2 = sec.height - sec.center,
desc = desc1 > desc2 ? desc1 : desc2;
var shift = 0.1*this.dW;
var x1 = this.pos.x + this.elements[0][0].size.width + this.dW - shift,
y1 = this.pos.y + this.size.center - cent,
x2 = this.pos.x + this.elements[0][0].size.width + shift,
y2 = this.pos.y + this.size.center + desc;
var penW = this.getTxtPrp().FontSize/12.5*g_dKoef_pix_to_mm;
MathControl.pGraph.p_width(penW*1000);
MathControl.pGraph.p_color(0,0,0, 255);
MathControl.pGraph.b_color1(0,0,0, 255);
MathControl.pGraph._s();
MathControl.pGraph._m(x1, y1);
MathControl.pGraph._l(x2, y2);
MathControl.pGraph.ds();
old_CLinearFraction.superclass.draw.call(this);
}
old_CLinearFraction.prototype.getNumerator = function()
{
return this.elements[0][0];
}
old_CLinearFraction.prototype.getDenominator = function()
{
return this.elements[0][1];
}
...@@ -142,6 +142,9 @@ CCoeffGaps.prototype = ...@@ -142,6 +142,9 @@ CCoeffGaps.prototype =
var COEFF_GAPS = new CCoeffGaps(); var COEFF_GAPS = new CCoeffGaps();
// TODO
// проконтролировать GapLeft и GapRight для setPosition всех элементов
function CRecalculateInfo(oMeasure, Parent) function CRecalculateInfo(oMeasure, Parent)
{ {
this.measure = oMeasure; this.measure = oMeasure;
...@@ -5045,7 +5048,8 @@ CMathContent.prototype = ...@@ -5045,7 +5048,8 @@ CMathContent.prototype =
var runPrp = this.content[pos].getRunPrp(); var runPrp = this.content[pos].getRunPrp();
var currRPrp = runPrp.getMergedWPrp(); var currRPrp = runPrp.getMergedWPrp();
this.applyArgSize(currRPrp); //this.applyArgSize(currRPrp);
this.Composition.Parent.ApplyArgSize(currRPrp); // в ParaMath
RecalcInfo.currRunPrp = currRPrp; RecalcInfo.currRunPrp = currRPrp;
...@@ -5059,7 +5063,8 @@ CMathContent.prototype = ...@@ -5059,7 +5063,8 @@ CMathContent.prototype =
{ {
var oWPrp = this.Parent.getCtrPrp(); var oWPrp = this.Parent.getCtrPrp();
this.applyArgSize(oWPrp); //this.applyArgSize(oWPrp);
this.Composition.Parent.ApplyArgSize(oWPrp);
oWPrp.Italic = false; oWPrp.Italic = false;
oMeasure.SetFont(oWPrp); oMeasure.SetFont(oWPrp);
...@@ -5181,7 +5186,8 @@ CMathContent.prototype = ...@@ -5181,7 +5186,8 @@ CMathContent.prototype =
var oWPrp = new CTextPr(); var oWPrp = new CTextPr();
oWPrp.Merge(mgWPrp); oWPrp.Merge(mgWPrp);
this.applyArgSize(oWPrp); //this.applyArgSize(oWPrp);
this.Composition.Parent.ApplyArgSize(oWPrp);
pGraphics.SetFont(oWPrp); pGraphics.SetFont(oWPrp);
} }
...@@ -5191,7 +5197,9 @@ CMathContent.prototype = ...@@ -5191,7 +5197,9 @@ CMathContent.prototype =
var oWPrp = this.Parent.getCtrPrp(); var oWPrp = this.Parent.getCtrPrp();
this.applyArgSize(oWPrp); //this.applyArgSize(oWPrp);
this.Composition.Parent.ApplyArgSize(oWPrp);
oWPrp.Italic = false; oWPrp.Italic = false;
pGraphics.SetFont(oWPrp); pGraphics.SetFont(oWPrp);
...@@ -5719,48 +5727,6 @@ CMathContent.prototype = ...@@ -5719,48 +5727,6 @@ CMathContent.prototype =
return rPrp; return rPrp;
}, },
applyArgSize: function(oWPrp)
{
var tPrp = new CTextPr();
var defaultRPrp = this.Composition.GetDefaultRunPrp();
var gWPrp = defaultRPrp.getMergedWPrp();
tPrp.Merge(gWPrp);
tPrp.Merge(oWPrp);
var FSize = tPrp.FontSize;
if(this.argSize == -1)
{
//aa: 0.0013 bb: 0.66 cc: 0.5
//aa: 0.0009 bb: 0.68 cc: 0.26
FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26;
//FSize = 0.001*FSize*FSize + 0.723*FSize - 1.318;
//FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53;
}
else if(this.argSize == -2)
{
// 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 = FSize;
oWPrp.Merge(tPrp);
/*
if(this.argSize == -1)
//tPrp.FontSize *= 0.8;
tPrp.FontSize *= 0.728;
//tPrp.FontSize *= 0.65;
else if(this.argSize == -2)
//tPrp.FontSize *= 0.65;
tPrp.FontSize *= 0.53;
//tPrp.FontSize *= 0.473;*/
},
increaseArgSize: function() increaseArgSize: function()
{ {
if(this.argSize < 2) if(this.argSize < 2)
...@@ -5868,7 +5834,21 @@ CMathContent.prototype = ...@@ -5868,7 +5834,21 @@ CMathContent.prototype =
Y = this.pos.y + absPos.y + this.size.ascent; Y = this.pos.y + absPos.y + this.size.ascent;
_X = this.pos.x + absPos.x + this.size.width; _X = this.pos.x + absPos.x + this.size.width;
result = { X: _X}; var ctrPrp = this.Parent.getCtrPrp();
this.Composition.Parent.ApplyArgSize(ctrPrp);
//this.applyArgSize(ctrPrp);
var sizeCursor = ctrPrp.FontSize*g_dKoef_pt_to_mm;
Y -= sizeCursor*0.8;
this.Composition.Parent.Paragraph.DrawingDocument.SetTargetSize(sizeCursor);
//Para.DrawingDocument.UpdateTargetFromPaint = true;
this.Composition.Parent.Paragraph.DrawingDocument.UpdateTarget( _X, Y, this.Composition.Parent.Paragraph.Get_StartPage_Absolute() + _CurPage );
//console.log("X of placeholder " + _X);
result = {X: _X, Y: Y};
} }
return result; return result;
...@@ -6241,7 +6221,13 @@ CMathContent.prototype = ...@@ -6241,7 +6221,13 @@ CMathContent.prototype =
var curType = this.content[CurPos].typeObj, var curType = this.content[CurPos].typeObj,
prevType = CurPos > 0 ? this.content[CurPos - 1].typeObj : null; prevType = CurPos > 0 ? this.content[CurPos - 1].typeObj : null;
if(curType == MATH_COMP) if(curType == MATH_PLACEHOLDER)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else if(curType == MATH_COMP)
{ {
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, bUseContent, EndRun); this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, bUseContent, EndRun);
} }
...@@ -6273,37 +6259,6 @@ CMathContent.prototype = ...@@ -6273,37 +6259,6 @@ CMathContent.prototype =
/// для коррекции позиции курсора в начале Run /// для коррекции позиции курсора в начале Run
// используется функция Correct_ContentPos в Paragraph // используется функция Correct_ContentPos в Paragraph
/*if ( true === SearchPos.Found )
result = true;
if(this.content[CurPos].typeObj == MATH_COMP)
EndRun = true;
CurPos--;
if(result == false)
{
while ( CurPos >= 0 )
{
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, false, EndRun);
SearchPos.Pos.Update( CurPos, Depth );
if ( true === SearchPos.Found )
{
result = true;
break;
}
if(this.content[CurPos].typeObj == MATH_COMP)
EndRun = true;
else
EndRun = false;
CurPos--;
}
}*/
return result; return result;
}, },
...@@ -6319,7 +6274,12 @@ CMathContent.prototype = ...@@ -6319,7 +6274,12 @@ CMathContent.prototype =
var curType = this.content[CurPos].typeObj, var curType = this.content[CurPos].typeObj,
nextType = CurPos < this.content.length - 1 ? this.content[CurPos + 1].typeObj : null; nextType = CurPos < this.content.length - 1 ? this.content[CurPos + 1].typeObj : null;
if(curType == MATH_COMP) if(curType == MATH_PLACEHOLDER)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else if(curType == MATH_COMP)
{ {
this.content[CurPos].Get_RightPos(SearchPos, ContentPos, Depth + 1, bUseContent, BegRun); this.content[CurPos].Get_RightPos(SearchPos, ContentPos, Depth + 1, bUseContent, BegRun);
} }
...@@ -7289,7 +7249,6 @@ CMathComposition.prototype = ...@@ -7289,7 +7249,6 @@ CMathComposition.prototype =
this.SelectContent.RecalculateReverse(oMeasure); this.SelectContent.RecalculateReverse(oMeasure);
},*/ },*/
//////////////* end of test functions *////////////////// //////////////* end of test functions *//////////////////
Init: function() Init: function()
{ {
this.Root = new CMathContent(); this.Root = new CMathContent();
......
...@@ -13,6 +13,9 @@ var DIV_CENT = 0.1386; ...@@ -13,6 +13,9 @@ var DIV_CENT = 0.1386;
var StartTextElement = 0x2B1A; // Cambria Math var StartTextElement = 0x2B1A; // Cambria Math
// TODO
// убрать CMathTextPrp
function CMathTextPrp() function CMathTextPrp()
{ {
this.FontFamily = undefined; this.FontFamily = undefined;
...@@ -305,7 +308,7 @@ CMathText.prototype = ...@@ -305,7 +308,7 @@ CMathText.prototype =
setPosition: function(pos) setPosition: function(pos)
{ {
if( ! this.bJDraw) // for text if( ! this.bJDraw) // for text
this.pos = {x : pos.x, y: pos.y}; this.pos = {x : pos.x + this.GapLeft, y: pos.y};
else // for symbol only drawing else // for symbol only drawing
{ {
var x = pos.x - this.rasterOffsetX, var x = pos.x - this.rasterOffsetX,
......
...@@ -184,3 +184,6 @@ var extend = function(Child, Parent) ...@@ -184,3 +184,6 @@ var extend = function(Child, Parent)
Child.superclass = Parent.prototype; Child.superclass = Parent.prototype;
} }
// default Txt Prp
// argSize
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