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

gaps for degree

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54077 954022d7-b5bf-4e40-9824-e11837661b57
parent a2203be5
......@@ -9,17 +9,23 @@ function CBorderBox()
this.bTop = true;
this.bBot = true;
/*this.bLeft = false;
this.bRight = false;
this.bTop = true;
this.bBot = false;*/
this.bLDiag = false;
this.bRDiag = false;
/*this.bHor = false;
this.bVert = false;*/
this.bHor = false;
this.bVert = false;
/*this.bLDiag = true;
this.bRDiag = true;*/
this.bHor = true;
this.bVert = true;
/*this.bHor = true;
this.bVert = true;*/
CMathBase.call(this);
}
......@@ -81,26 +87,30 @@ CBorderBox.prototype.recalculateSize = function()
CBorderBox.prototype.draw = function(x, y, pGraphics)
{
this.elements[0][0].draw(x, y, pGraphics);
var penW = this.getCtrPrp().FontSize* 25.4/96 * 0.08 ;
//var penW = this.getCtrPrp().FontSize* 25.4/72 * 0.06 ;
var penW = this.getCtrPrp().FontSize*0.02;
if(this.bTop)
{
var x1 = this.pos.x + x,
//x2 = this.pos.x + x + this.size.width - 25.4/96,
x2 = this.pos.x + x + this.size.width - penW,
x2 = this.pos.x + x + this.size.width - penW/2,
y1 = this.pos.y + y;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawHorLine(0, y1, x1, x2, penW);
/*pGraphics.p_color(255,0,0, 255);
pGraphics.drawHorLine(0, y1 - 25.4/96, x1 + 2*25.4/96, x2, 25.4/96);
pGraphics.p_color(255,0,0, 255);
pGraphics.drawHorLine(0, y1 + penW, x1 + 2*25.4/96, x2 , 25.4/96);*/
}
if(this.bBot)
{
var x1 = this.pos.x + x,
//x2 = this.pos.x + x + this.size.width - 25.4/96,
x2 = this.pos.x + x + this.size.width - penW,
y1 = this.pos.y + y + this.size.height - penW;
x2 = this.pos.x + x + this.size.width - penW/2,
y1 = this.pos.y + y + this.size.height - penW/2;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawHorLine(0, y1, x1, x2, penW);
......@@ -110,8 +120,7 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
{
var x1 = this.pos.x + x,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - penW;
//y2 = this.pos.y + y + this.size.height - 25.4/96;
y2 = this.pos.y + y + this.size.height - penW/2;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......@@ -119,10 +128,9 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
if(this.bRight)
{
var x1 = this.pos.x + x + this.size.width - penW,
var x1 = this.pos.x + x + this.size.width - penW/2,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - penW;
//y2 = this.pos.y + y + this.size.height - 25.4/96 ;
y2 = this.pos.y + y + this.size.height - penW/2;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......@@ -133,7 +141,6 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
var pW = penW*0.8;
var x1 = this.pos.x + x , y1 = this.pos.y + y,
x2 = x1 + pW, y2 = y1,
//x3 = x1 + this.size.width - 25.4/96, y3 = y1 + this.size.height - pW - 25.4/96,
x3 = x1 + this.size.width - penW, y3 = y1 + this.size.height - pW - penW,
x4 = x3, y4 = y3 + pW,
x5 = x4 - pW, y5 = y4,
......@@ -159,11 +166,9 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
{
var pW = penW*0.8;
var x1 = this.pos.x + x + this.size.width - pW - penW, y1 = this.pos.y + y,
//x1 = this.pos.x + x + this.size.width - pW - 25.4/96, y1 = this.pos.y + y,
x2 = x1 + pW, y2 = y1,
x3 = x2, y3 = y2 + pW,
x4 = this.pos.x + x + pW, y4 = this.pos.y + y + this.size.height - penW,
//x4 = this.pos.x + x + pW, y4 = this.pos.y + y + this.size.height - 25.4/96,
x5 = x4 - pW, y5 = y4,
x6 = x5, y6 = y5 - pW,
x7 = x1, y7 = y1;
......@@ -187,7 +192,6 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
{
var x1 = this.pos.x + x,
x2 = this.pos.x + x + this.size.width - penW,
//x2 = this.pos.x + x + this.size.width - 25.4/96,
y1 = this.pos.y + y + this.size.height/2 - penW/2;
pGraphics.p_color(0,0,0, 255);
......@@ -199,7 +203,6 @@ CBorderBox.prototype.draw = function(x, y, pGraphics)
var x1 = this.pos.x + x + this.size.width/2 - penW/2,
y1 = this.pos.y + y,
y2 = this.pos.y + y + this.size.height - penW;
//y2 = this.pos.y + y + this.size.height - 25.4/96;
pGraphics.p_color(0,0,0, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
......
......@@ -44,17 +44,16 @@ CDegree.prototype.recalculateSup = function(oMeasure)
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var width = base.width + iter.width;
var mgCtrPrp = this.mergeCtrTPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
//this.dW = 0.216*shCenter;
var height = 0,
ascent = 0;
var descIter = iter.height - iter.ascent;
//var ctrPrp = this.getCtrPrp();
var mgCtrPrp = this.mergeCtrTPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var upper = 0;
if(descIter + shCenter > 2/3*base.height)
......@@ -79,6 +78,17 @@ CDegree.prototype.recalculateSup = function(oMeasure)
ascent = base.ascent;
}
this.dW = 0.2*shCenter;
/*var smallAsc = mgCtrPrp.FontSize*0.23;
if(base.ascent < smallAsc)
this.dW = 0.3*shCenter;
else
this.dW = 0.15*shCenter;*/
var width = base.width + iter.width + this.dW;
this.size = {width: width, height: height, ascent: ascent};
}
CDegree.prototype.recalculateSubScript = function(oMeasure)
......@@ -86,17 +96,18 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var width = base.width + iter.width;
var height = 0,
ascent = 0;
/*var FontSize = this.getCtrPrp().FontSize,
shiftCenter = 0.5*DIV_CENT*FontSize;*/
//var ctrPrp = this.getCtrPrp(); // выставить потом размер шрифта для итератора
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.mergeCtrTPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
//this.dW = 0.216*shCenter;
this.dW = 0;
var width = base.width + iter.width + this.dW;
var low = 0;
if(iter.ascent - shCenter > 2/3*base.height)
......@@ -108,8 +119,8 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
low = iter.height - iter.ascent + shCenter;
}
height = base.height + low;
ascent = base.ascent;
var height = base.height + low;
var ascent = base.ascent;
this.upper = -(height - iter.height);
......@@ -356,8 +367,6 @@ CIterators.prototype.setDistanceIters = function(oMeasure)
{
this.dH = up + down;
}
this.dW = 0;
}
/*CIterators.prototype.getAscent = function()
{
......@@ -477,7 +486,15 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure)
iters.setDistanceIters(oMeasure);
iters.recalculateSize();
this.dW = 0.18*shCenter;
//this.dW = 0.18*shCenter;
//this.dW = 0;
var smallAsc = mgCtrPrp.FontSize*0.23;
if(base.ascent < smallAsc)
this.dW = 0;
else
this.dW = 0.2*shCenter;
width = iters.size.width + base.size.width + this.dW;
//height = shCenter + iters.lUp;
......
......@@ -5067,30 +5067,33 @@ CMathContent.prototype =
var kind = MComp.kind;
var checkGap = this.checkGapKind(kind);
var coeffLeft = 0,
coeffRight = 0;
var bNeedGap = !checkGap.bEmptyGaps && !checkGap.bChildGaps;
if(checkGap.bEmptyGaps)
var coeffLeft = 0.001,
coeffRight = 0; // for checkGap.bEmptyGaps
if(checkGap.bChildGaps)
{
coeffLeft = 0.05;
}
else if(checkGap.bChildGaps)
if(kind == MATH_DEGREE || kind == MATH_DEGREESubSup)
{
var gaps = MComp.getGapsInside();
coeffLeft = 0.0;
coeffRight = 0.15;
}
coeffLeft = gaps.left;
coeffRight = gaps.right;
var gapsChild = MComp.getGapsInside();
coeffLeft = coeffLeft < gapsChild.left ? gapsChild.left : coeffLeft;
coeffRight = coeffRight < gapsChild.right ? gapsChild.right : coeffRight;
}
else
else if(bNeedGap)
{
coeffLeft = 0.4;
coeffRight = 0.26;
}
return {left: coeffLeft, right: coeffRight};
},
getGapsInside: function()
getGapsInside: function() // учитываем gaps внутренних объектов
{
var bFirstComp = this.content[1].value.typeObj == MATH_COMP,
bLastComp = false;
......@@ -5103,7 +5106,7 @@ CMathContent.prototype =
bLastComp = this.content[posLComp].value.typeObj == MATH_COMP;
}
var gaps = {left: 0.05, right: 0};
var gaps = {left: 0, right: 0};
var checkGap;
......@@ -5182,7 +5185,7 @@ CMathContent.prototype =
var bHidePlh = this.plhHide && this.IsPlaceholder();
// TEST
//var bOnlySimpleObjs = true;
var bOnlySimpleObjs = true;
if( !bHidePlh )
{
......@@ -5216,10 +5219,12 @@ CMathContent.prototype =
else
this.content[i].value.draw(x, y, pGraphics);
/*if(this.content[i].value.typeObj == MATH_COMP)
if(this.content[i].value.typeObj == MATH_COMP)
{
bOnlySimpleObjs = false;
}*/
}
/*if(this.content[i].value.typeObj == MATH_COMP)
{
......@@ -5237,7 +5242,7 @@ CMathContent.prototype =
}
/// TEST
/*if(bOnlySimpleObjs)
if(!bOnlySimpleObjs)
{
var penW = 25.4/96;
var x1 = this.pos.x + x - penW,
......@@ -5248,9 +5253,9 @@ CMathContent.prototype =
pGraphics.p_color(0,0,255, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
pGraphics.drawVerLine(0, x2, y1, y2, penW);
}*/
}
if(this.bRoot)
/*if(this.bRoot)
{
var penW = 25.4/96;
var x1 = this.pos.x + x - penW,
......@@ -5261,7 +5266,7 @@ CMathContent.prototype =
pGraphics.p_color(0,0,255, 255);
pGraphics.drawVerLine(0, x1, y1, y2, penW);
pGraphics.drawVerLine(0, x2, y1, y2, penW);
}
}*/
},
update_widthContent: function()
......@@ -6175,6 +6180,28 @@ CMathContent.prototype =
tPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
tPrp.Merge(txtPrp);
var FSize = tPrp.FontSize;
if(this.argSize == -1)
{
// aa: 0.0013 bb: 0.66 cc: 0.5
FSize = 0.001*FSize*FSize + 0.723*FSize - 1.318;
//FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53;
tPrp.FontSize = FSize;
}
else if(this.argSize == -2)
//tPrp.FontSize *= 0.65;
tPrp.FontSize *= 0.53;
//tPrp.FontSize *= 0.473;
return tPrp;
},
old_mergeTxtPrp: function(txtPrp)
{
var tPrp = new CTextPr();
tPrp.Merge(this.Composition.DEFAULT_RUN_PRP);
tPrp.Merge(txtPrp);
if(this.argSize == -1)
//tPrp.FontSize *= 0.8;
tPrp.FontSize *= 0.728;
......@@ -6973,7 +7000,10 @@ function CMathComposition()
this.props =
{
naryLim: NARY_UndOvr,
intLim: NARY_SubSup
intLim: NARY_SubSup,
brkBin: BREAK_BEFORE,
brkSubBin: BREAK_MIN_MIN,
smallFrac: false
};
this.CurrentContent = null;
......@@ -7017,11 +7047,13 @@ CMathComposition.prototype =
// rMargin
// lMargin
// mathFont возможно будет полноценно поддержан MS в будущем
// mathFont: в качестве font поддерживается только Cambria Math
// остальные шрифты возможно будут поддержаны MS в будущем
// Default font for math zones
// Gives a drop-down list of math fonts that can be used as the default math font to be used in the document.
// Currently only Cambria Math has thorough math support, but others such as the STIX fonts are coming soon.
// http://blogs.msdn.com/b/murrays/archive/2008/10/27/default-document-math-properties.aspx
// RichEdit Hot Keys
......@@ -7034,6 +7066,18 @@ CMathComposition.prototype =
if(props.intLim == NARY_UndOvr || props.intLim == NARY_SubSup)
this.props.intLim = props.intLim;
if(props.brkBin == BREAK_BEFORE || props.brkBin == BREAK_AFTER || props.brkBin == BREAK_REPEAT)
this.props.brkBin = props.brkBin;
// for minus operator
// when brkBin is set to repeat
if(props.brkSubBin == BREAK_MIN_MIN || props.brkSubBin == BREAK_PLUS_MIN || props.brkSubBin == BREAK_MIN_PLUS)
this.props.brkSubBin = props.brkSubBin;
// в случае если smallFrac = true,
if(props.smallFrac == true || props.smallFrac == false)
this.props.smallFrac = props.smallFrac;
},
GetShiftCenter: function(oMeasure, font)
{
......@@ -8005,3 +8049,70 @@ function GetShiftCenter()
console.log(i + ": " + shift);
}
}
function TEST_COEFF_ITERATORS()
{
// a*36*36 + b*36 + c = 0.728*tPrp.FontSize = 26
// a*14*14 + b*14 + c = 9
// a*72*72 + b*72 + c = 55
//FSize = 0.0006*FSize*FSize + 0.743*FSize - 1.53;
var x1 = 36, x2 = 14, x3 = 72;
var d1 = 26, d2 = 10, d3 = 55;
// || x1*x1 x1 1 ||
// || x2*x2 x2 1 ||
// || x3*x3 x3 1 ||
var D = x1*x1*x2 + x1*x3*x3 + x2*x2*x3 - x3*x3*x2 - x3*x1*x1 - x2*x2*x1,
Da = d1*x2 + x1*d3 + d2*x3 - d3*x2 - x3*d1 - d2*x1,
Db = x1*x1*d2 + d1*x3*x3 + x2*x2*d3 - x3*x3*d2 - d3*x1*x1 - x2*x2*d1,
Dc = x1*x1*x2*d3 + x1*x3*x3*d2 + x2*x2*x3*d1 - x3*x3*x2*d1 - x3*x1*x1*d2 - x2*x2*x1*d3;
var a = Da/D,
b = Db/D,
c = Dc/D;
console.log("a: " + a + " b: " + b + " c: " + c);
var check1 = a*x1*x1 + b*x1 + c - d1,
check2 = a*x2*x2 + b*x2 + c - d2,
check3 = a*x3*x3 + b*x3 + c - d3;
console.log("check1: " + check1);
console.log("check2: " + check2);
console.log("check3: " + check3);
var aa = Math.round(a*10000)/10000;
var dd1 = d1 - a*x1*x1,
dd2 = d2 - a*x2*x2;
var DD = x1 - x2,
Dbb = dd1 - dd2,
Dcc = x1*dd2 - x2*dd1;
var bb = Dbb/DD,
cc = Dcc/DD;
bb = Math.round(bb*100)/100;
cc = Math.round(cc*100)/100;
console.log("aa: " + aa + " bb: " + bb + " cc: " + cc);
var check11 = aa*x1*x1 + bb*x1 + cc - d1,
check22 = aa*x2*x2 + bb*x2 + cc - d2,
check33 = aa*x3*x3 + bb*x3 + cc - d3;
console.log("check11: " + check11);
console.log("check22: " + check22);
console.log("check33: " + check33);
}
\ No newline at end of file
......@@ -143,3 +143,12 @@ var MATH_COMP = 2;
var MATH_EMPTY = 3;
var MATH_PLACEHOLDER = 4;
////////////////////////////////////////
var BREAK_BEFORE = 0;
var BREAK_AFTER = 1;
var BREAK_REPEAT = 2;
var BREAK_MIN_MIN = 0;
var BREAK_PLUS_MIN = 1;
var BREAK_MIN_PLUS = 2;
\ No newline at end of file
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