Commit 6d86d906 authored by Anna.Pavlova's avatar Anna.Pavlova Committed by Alexander.Trofimov

1. Поправила Gaps для элементов в CMathContent

2. Поправила отрисовку линии для BarFraction, без учета gaps
3. Recalculate_Reset

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56614 954022d7-b5bf-4e40-9824-e11837661b57
parent ecd85949
......@@ -189,24 +189,6 @@ CMathBase.prototype =
if( !this.elements[i][j].IsJustDraw() )
this.elements[i][j].setArgSize(argSize);
},
// TO DO
// посмотреть для всех мат. объектов, где используется эта функция
/*Get_FullCtrPrp: function() // учитываем ArgSize
{
var tPrp = this.Get_CompiledCtrPrp(true);
this.ParaMath.ApplyArgSize(tPrp);
*//*if(this.argSize == -1)
//tPrp.FontSize *= 0.8;
tPrp.FontSize *= 0.728;
else if(this.argSize == -2)
//tPrp.FontSize *= 0.65;
tPrp.FontSize *= 0.53;*//*
return tPrp;
},*/
/////////
/*setComposition: function(Composition)
{
this.Composition = Composition;
......@@ -686,10 +668,11 @@ CMathBase.prototype =
if(this.alignment.hgt[pos_y] == CENTER)
{
var maxAsc = 0;
var _ascent;
for(var j = 0; j < this.nCol; j++)
{
var _ascent = this.elements[pos_x][j].size.ascent;
_ascent = this.elements[pos_x][j].size.ascent;
maxAsc = ( maxAsc > _ascent ) ? maxAsc : _ascent;
}
PosAlign.y = (maxAsc - this.elements[pos_x][pos_y].size.ascent);
......@@ -697,8 +680,9 @@ CMathBase.prototype =
else
{
var maxH = 0;
var _h;
for(j=0; j < this.nCol; j++)
for(var j=0; j < this.nCol; j++)
{
var _h = this.elements[pos_x][j].size.height;
maxH = ( maxH > _h ) ? maxH : _h;
......@@ -976,7 +960,7 @@ CMathBase.prototype =
width += Widths[i];
width += this.dW*(this.nCol - 1);
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
var ascent = this.getAscent(oMeasure, height);
......@@ -1458,7 +1442,32 @@ CMathBase.prototype =
{
return this.elements[this.CurPos_X][this.CurPos_Y].IsCurrentPlh();
},
SetGaps: function(Parent, ParaMath, RecalcInfo)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
RecalcInfo.Left = RecalcInfo.Current;
RecalcInfo.leftRunPrp = RecalcInfo.currRunPrp;
RecalcInfo.Current = this;
RecalcInfo.currRunPrp = this.Get_CompiledCtrPrp();
RecalcInfo.setGaps();
},
ApplyGaps: function()
{
this.size.width += this.GapLeft + this.GapRight;
},
Recalculate_Reset: function(StartRange, StartLine)
{
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
if(this.elements[i][j].IsJustDraw() == false)
this.elements[i][j].Recalculate_Reset(StartRange, StartLine);
},
// Перемещение по стрелкам
Get_LeftPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
......
......@@ -102,7 +102,7 @@ CBorderBox.prototype.recalculateSize = function()
if(this.Pr.hideRight == false)
width += this.gapBrd;
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
this.size = {width : width, height: height, ascent: ascent};
}
......
......@@ -170,7 +170,7 @@ CDegree.prototype.recalculateSup = function(oMeasure)
this.dW = 0.01*mgCtrPrp.FontSize;
var width = base.width + iter.width + this.dW;
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
......@@ -183,7 +183,7 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var width = base.width + iter.width + this.dW;
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
var bBaseOnlyText = this.elements[0][0].IsOnlyText();
......
......@@ -46,28 +46,11 @@ CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
var numHeight = this.elements[0][0].size.height;
var x1 = this.pos.x + x ,
x2 = this.pos.x + x + this.size.width,
y1 = this.pos.y + y + numHeight- penW;
/*var xx1 = x1, yy1 = this.pos.y + y,
xx2 = xx1 + this.size.width, yy2 = yy1 + this.elements[0][0].size.height;
var xxx1 = x1, yyy1 = this.pos.y + y + this.elements[0][0].size.height,
xxx2 = xxx1 + this.size.width, yyy2 = yyy1 + this.elements[1][0].size.height;
var width = this.size.width - this.GapLeft - this.GapRight;
pGraphics.p_color(255,0,0, 255);
pGraphics.drawHorLine(0, yy1, xx1, xx2, 0.1);
pGraphics.drawVerLine(0, xx2, yy1, yy2, 0.1);
pGraphics.drawHorLine(0, yy2, xx1, xx2, 0.1);
pGraphics.drawVerLine(0, xx1, yy1, yy2, 0.1);
pGraphics.p_color(0,255,0, 255);
pGraphics.drawHorLine(0, yyy1, xxx1, xxx2, 0.1);
pGraphics.drawVerLine(0, xxx2, yyy1, yyy2, 0.1);
pGraphics.drawHorLine(0, yyy2, xxx1, xxx2, 0.1);
pGraphics.drawVerLine(0, xxx1, yyy1, yyy2, 0.1);*/
var x1 = this.pos.x + x + this.GapLeft,
x2 = x1 + width,
y1 = this.pos.y + y + numHeight- penW;
if( !this.bHideBar )
{
......@@ -242,7 +225,7 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure)
var height = num.height + den.height;
var ascent = num.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
......@@ -256,7 +239,7 @@ CFraction.prototype.recalculateSkewed = function(oMeasure)
var height = this.elements[0][0].size.height + this.elements[0][1].size.height;
var ascent = this.elements[0][0].size.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
......@@ -293,7 +276,7 @@ CFraction.prototype.recalculateLinear = function()
var width = this.elements[0][0].size.width + this.dW + this.elements[0][1].size.width;
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
this.size = {height: height, width: width, ascent: ascent};
}
......
......@@ -477,6 +477,8 @@ CRecalculateInfo.prototype =
this.Left.GapRight = Math.ceil(rightCoeff*RGapSign*10)/10;
}
}
this.bResize = true;
},
getGapsMComp: function(MComp, direct)
{
......@@ -802,21 +804,12 @@ CMPrp.prototype =
}
//TODO
// доделать GroupCharacter / Delimiter в качестве character может быть любой символ
//TODO
//переделать/продумать DotIndef, т.к. при перетаскивании из одного места в другое флаг DotIndef может измениться для другого контента
//TODO
//пересмотреть this.dW и this.dH
//TODO
//добавить gaps для мат элементов и математических знаков
//TODO
//сделать, чтобы курсор выставлялся только, где это действительно необходимо
//в качетве позиции для контента передавать положение baseLine для него
//в качеcтве позиции для контента передавать положение baseLine для него
......@@ -4999,7 +4992,7 @@ CMathContent.prototype =
//////////////////////////////////////
recalculateSize: function()
recalculateSize: function(ParaMath, oMeasure)
{
var width = 0 ;
var ascent = 0 ;
......@@ -5011,10 +5004,35 @@ CMathContent.prototype =
for(var i = 0; i < this.content.length; i++)
{
if(this.content[i].typeObj == MATH_COMP)
{
this.content[i].Resize(this, ParaMath, oMeasure);
this.content[i].ApplyGaps();
}
else if(this.content[i].typeObj == MATH_PLACEHOLDER)
{
if(!this.bRoot)
{
var oWPrp = this.Parent.Get_CompiledCtrPrp();
this.ParaMath.ApplyArgSize(oWPrp, this.argSize);
oWPrp.Italic = false;
oMeasure.SetFont(oWPrp);
this.content[i].Resize(this, oMeasure);
}
}
else
{
this.content[i].Math_Recalculate(this, ParaMath.Paragraph, oMeasure);
}
this.WidthToElement[i] = width;
oSize = this.content[i].size;
width += oSize.width;
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
......@@ -5038,58 +5056,21 @@ CMathContent.prototype =
if (this.content.length == 0)
this.fillPlaceholders();
for(var pos = 0; pos < this.content.length; pos++)
var lng = this.content.length;
for(var pos = 0; pos < lng; pos++)
{
if(this.content[pos].typeObj == MATH_COMP)
{
RecalcInfo.Left = RecalcInfo.Current;
RecalcInfo.leftRunPrp = RecalcInfo.currRunPrp;
RecalcInfo.Current = this.content[pos];
this.content[pos].Resize(this, ParaMath, oMeasure);
/*var runPrp = this.content[pos].getCtrPrp();
this.ParaMath.ApplyArgSize(runPrp); // в ParaMath*/
var ctrPrp = this.content[pos].Get_CompiledCtrPrp();
RecalcInfo.currRunPrp = ctrPrp;
RecalcInfo.setGaps();
}
else if(this.content[pos].typeObj == MATH_PLACEHOLDER)
{
if(!this.bRoot)
{
//var oWPrp = this.Parent.Get_CtrPrp();
var oWPrp = this.Parent.Get_CompiledCtrPrp();
//this.applyArgSize(oWPrp);
this.ParaMath.ApplyArgSize(oWPrp, this.argSize);
oWPrp.Italic = false;
/*var ctrPrp = this.Parent.Get_CompiledCtrPrp();
ctrPrp.Italic = false;*/
oMeasure.SetFont(oWPrp);
this.content[pos].Resize(this, oMeasure);
}
}
this.content[pos].SetGaps(this, ParaMath, RecalcInfo);
else
{
//this.content[pos].Set_Paragraph(this.ParaMath.Paragraph);
this.content[pos].Math_Recalculate(this, ParaMath.Paragraph, oMeasure, RecalcInfo);
}
this.content[pos].Math_SetGaps(ParaMath.Paragraph, RecalcInfo);
}
if(RecalcInfo.Current !== null)
RecalcInfo.Current.GapRight = 0;
this.recalculateSize();
this.recalculateSize(ParaMath, oMeasure);
},
IsEmptyRun: function(pos) // пустой Para_Run
{
......@@ -5886,6 +5867,14 @@ CMathContent.prototype =
var CurPos = ParaNearPos.NearPos.ContentPos.Get(Depth);
this.Content[CurPos].Check_NearestPos( ParaNearPos, Depth + 1 );
},
Recalculate_Reset: function(StartRange, StartLine)
{
for(var i = 0; i < this.content.length; i++)
{
if(this.content[i].typeObj !== MATH_PLACEHOLDER)
this.content[i].Recalculate_Reset(StartRange, StartLine);
}
},
// Поиск позиции, селект
......@@ -6748,7 +6737,7 @@ CMathContent.prototype =
else
{
this.content.push(obj);
}
}
},
Save_Changes: function(Data, Writer)
{
......
......@@ -271,14 +271,22 @@ CMathText.prototype =
var width;
if(this.bJDraw)
width = metricsTxt.WidthG + this.GapLeft + this.GapRight;
width = metricsTxt.WidthG;
//width = metricsTxt.WidthG + this.GapLeft + this.GapRight;
else
width = metricsTxt.Width + this.GapLeft + this.GapRight;
width = metricsTxt.Width;
//width = metricsTxt.Width + this.GapLeft + this.GapRight;
this.WidthVisible = width;
this.size = {width: width, widthG: width, height: height, ascent: ascent};
},
ApplyGaps: function()
{
this.size.width += this.GapLeft + this.GapRight;
this.WidthVisible = this.size.width;
},
draw: function(x, y, pGraphics)
{
var X = this.pos.x + x,
......
......@@ -144,7 +144,7 @@ CMathMatrix.prototype.recalculateSize = function(oMeasure)
ascent = this.getAscent(oMeasure, height);
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
this.size = {width: width, height: height, ascent: ascent};
}
......
......@@ -499,7 +499,7 @@ CNaryOvr.prototype.recalculateSize = function()
var ascent = nOper.ascent;
var width = nOper.width > iter.width ? nOper.width : iter.width;
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
var height = nOper.height + this.dH + iter.height;
......@@ -567,7 +567,7 @@ CNaryUndOvr.prototype.recalculateSize = function()
height += this.elements[i][0].size.height;
}
width += this.GapLeft + this.GapRight;
//width += this.GapLeft + this.GapRight;
height += this.gapTop + this.gapBottom;
this.size = {width: width, height: height, ascent: ascent};
......
......@@ -3750,7 +3750,6 @@ CDelimiter.prototype.setPosition = function(position)
var x = this.pos.x + this.GapLeft,
y = this.pos.y;
var PosBegOper = new CMathPosition();
PosBegOper.x = x;
PosBegOper.y = y + this.alignOperator(this.begOper);
......
......@@ -974,16 +974,19 @@ CRadical.prototype.recalculateSize = function(oMeasure)
var gapBase = gSign + gArg;
var base, degr, shTop,
height, width, ascent;
if(this.Pr.type == SQUARE_RADICAL)
{
var base = this.elements[0][0].size;
var shTop = (sign.height - gSign - base.height)/2;
base = this.elements[0][0].size;
shTop = (sign.height - gSign - base.height)/2;
shTop = shTop > 0 ? shTop : 0;
var height = sign.height,
width = sign.width,
ascent = gapBase + shTop + base.ascent;
//ascent = height - (base.height - base.ascent);
height = sign.height;
width = sign.width;
ascent = gapBase + shTop + base.ascent;
//ascent = height - (base.height - base.ascent);
width += this.GapLeft + this.GapRight;
......@@ -991,8 +994,8 @@ CRadical.prototype.recalculateSize = function(oMeasure)
}
else if(this.Pr.type == DEGREE_RADICAL)
{
var degr = this.elements[0][0].size,
base = this.elements[0][1].size;
degr = this.elements[0][0].size;
base = this.elements[0][1].size;
var wTick = this.signRadical.measure.widthTick,
hTick = this.signRadical.measure.heightTick;
......@@ -1004,7 +1007,7 @@ CRadical.prototype.recalculateSize = function(oMeasure)
this.gapWidth = 0.011*txtPrp.FontSize;
var wDegree = degr.width > wTick ? degr.width - wTick : 0;
var width = wDegree + sign.width + this.gapWidth;
width = wDegree + sign.width + this.gapWidth;
width += this.GapLeft + this.GapRight;
......@@ -1017,9 +1020,7 @@ CRadical.prototype.recalculateSize = function(oMeasure)
var h1 = gapHeight + degr.height + gapDegree + hTick,
h2 = sign.height;
var height, ascent;
var shTop = (sign.height - gSign - base.height)/2;
shTop = (sign.height - gSign - base.height)/2;
if(h1 > h2)
{
......@@ -1091,12 +1092,12 @@ CRadical.prototype.setPosition = function(pos)
CRadical.prototype.findDisposition = function(mCoord)
{
var disposition;
var inside_flag = -1;
if(this.Pr.type == SQUARE_RADICAL)
{
var sizeBase = this.elements[0][0].size;
var X, Y;
var inside_flag = -1;
var gapLeft = this.size.width - this.elements[0][0].size.width;
var gapTop = this.size.ascent - this.elements[0][0].size.ascent;
......@@ -1132,8 +1133,7 @@ CRadical.prototype.findDisposition = function(mCoord)
else if(this.Pr.type == DEGREE_RADICAL)
{
var mouseCoord = {x: null, y: null},
posCurs = {x: 0, y: null},
inside_flag = -1;
posCurs = {x: 0, y: null};
var degr = this.elements[0][0].size,
base = this.elements[0][1].size;
......
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