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

ctrPrp и runPrp (промежуточная версия)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50740 954022d7-b5bf-4e40-9824-e11837661b57
parent 96cf2ebf
......@@ -24,7 +24,7 @@ function CMathBase()
this.CtrPrp =
{
RunPrp: null
RunPrp: new CTextPr()
};
//this.textPrp = new CMathTextPrp(); // для рассчета размера расстояний
......@@ -59,8 +59,8 @@ CMathBase.prototype =
for(var j = 0; j < this.nCol; j++)
{
this.elements[i][j] = new CMathContent();
this.elements[i][j].setComposition(this.Composition);
this.elements[i][j].relate(this);
this.elements[i][j].setComposition(this.Composition);
/*if( !this.elements[i][j].IsJustDraw())
this.elements[i][j].setComposition(this.Composition);*/
//this.elements[i][j].setTxtPrp(this.TxtPrp);
......@@ -84,29 +84,38 @@ CMathBase.prototype =
this.alignment.wdt[u] = CENTER;
},
setCtrPrp: function(props)
setCtrPrp: function(runPrp)
{
this.CtrPrp.RunPrp = props.RunPrp; // only runPrp for paragraph
this.CtrPrp.RunPrp = runPrp; // only runPrp for paragraph
},
getCtrPrp: function()
{
var ctrPrp = new CTextPr();
ctrPrp.Merge(DEFAULT_RUN_PRP);
ctrPrp.Merge(this.CtrPrp.RunPrp);
return ctrPrp;
},
getPrpToControlLetter: function()
{
var rPrp = new CTextPr();
rPrp.Merge(DEFAULT_RUN_PRP);
this.getCtrPrp();
ctrPrp.Merge( this.Composition.GetFirstPrp() );
//rPrp.Merge(DEFAULT_RUN_PRP);
rPrp.Merge( this.getCtrPrp() );
rPrp.Merge( this.Composition.GetFirstPrp() );
return ctrPrp;
return rPrp;
},
setComposition: function(composition)
{
this.Composition = composition;
},
setReferenceComp: function(Comp)
{
this.Composition = Comp;
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].setReferenceComp(Comp);
},
/*old_getTxtPrp: function()
{
var txtPrp = new CMathTextPrp();
......@@ -211,6 +220,7 @@ CMathBase.prototype =
this.setContent();
}
},
relate: function(parent)
{
this.Parent = parent;
......
......@@ -48,7 +48,8 @@ CFraction.prototype.getCenter = function()
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{
var penW = this.getTxtPrp().FontSize* 25.4/96 * 0.08 /2;
//var penW = this.getTxtPrp().FontSize* 25.4/96 * 0.08 /2;
var penW = this.getPrpToControlLetter().FontSize* 25.4/96 * 0.08 /2;
center = this.elements[0][0].size.height + penW;
}
else if(this.type == SKEWED_FRACTION)
......@@ -73,7 +74,8 @@ CFraction.prototype.draw = function(pGraphics)
}
CFraction.prototype.drawBarFraction = function(pGraphics)
{
var penW = this.getTxtPrp().FontSize* this.reduct* 25.4/96 * 0.08;
var ctrPrp = this.getPrpToControlLetter();
var penW = ctrPrp.FontSize* this.reduct* 25.4/96 * 0.08;
var x1 = this.pos.x,
x2 = this.pos.x + this.size.width,
......@@ -81,6 +83,8 @@ CFraction.prototype.drawBarFraction = function(pGraphics)
if( !this.bHideBar )
{
pGraphics.SetFont(ctrPrp);
pGraphics.p_color(0,0,0, 255);
pGraphics.b_color1(0,0,0, 255);
pGraphics.drawHorLine(0, y1, x1, x2, penW);
......@@ -90,11 +94,12 @@ CFraction.prototype.drawBarFraction = function(pGraphics)
}
CFraction.prototype.drawSkewedFraction = function(pGraphics)
{
var fontSize = this.getTxtPrp().FontSize;
var penW = fontSize/12.5*g_dKoef_pix_to_mm;
var ctrPrp = this.getPrpToControlLetter();
//var fontSize = this.getTxtPrp().FontSize;
var penW = ctrPrp.FontSize/12.5*g_dKoef_pix_to_mm;
var gap = this.gapSlash/2 - penW/7.5;
var plh = 9.877777777777776 * fontSize / 36;
var plh = 9.877777777777776 * ctrPrp.FontSize / 36;
var minHeight = 2*this.gapSlash,
middleHeight = plh*4/3,
......@@ -165,6 +170,8 @@ CFraction.prototype.drawSkewedFraction = function(pGraphics)
}
pGraphics.SetFont(ctrPrp);
pGraphics.p_width(penW*1000);
pGraphics.p_color(0,0,0, 255);
......@@ -192,8 +199,10 @@ CFraction.prototype.drawLinearFraction = function(pGraphics)
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;
var ctrPrp = this.getPrpToControlLetter();
var penW = ctrPrp.FontSize/12.5*g_dKoef_pix_to_mm;
pGraphics.SetFont(ctrPrp);
pGraphics.p_width(penW*1000);
pGraphics.p_color(0,0,0, 255);
......@@ -239,7 +248,8 @@ CFraction.prototype.recalculateSize = function()
}
CFraction.prototype.recalculateSkewed = function()
{
this.gapSlash = 5.011235894097222 * this.getTxtPrp().FontSize/36;
var ctrPrp = this.getPrpToControlLetter();
this.gapSlash = 5.011235894097222 * ctrPrp.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();
......@@ -249,9 +259,10 @@ CFraction.prototype.recalculateSkewed = function()
CFraction.prototype.recalculateLinear = 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 txtPrp = this.getTxtPrp();
var ctrPrp = this.getPrpToControlLetter();
var gap = 5.011235894097222*txtPrp.FontSize/36;
var gap = 5.011235894097222*ctrPrp.FontSize/36;
var H3 = gap*4.942252165543792,
H4 = gap*7.913378248315688,
......@@ -380,12 +391,13 @@ CNumerator.prototype.init = function()
CNumerator.prototype.recalculateSize = function()
{
var arg = this.elements[0][0].size;
var txtPrp = this.getTxtPrp();
txtPrp.FontSize *= this.Parent.reduct;
//var txtPrp = this.getTxtPrp();
//txtPrp.FontSize *= this.Parent.reduct;
var ctrPrp = this.getCtrPrp();
var Descent = arg.height - arg.ascent; // baseLine
var gap = 7.832769097222222 * txtPrp.FontSize/36,
minGap = txtPrp.FontSize* 25.4/96 * 0.16;
var gap = 7.832769097222222 * ctrPrp.FontSize/36,
minGap = ctrPrp.FontSize* 25.4/96 * 0.16;
// var delta = 0.65*gap - Descent;
var delta = 0.8076354679802956*gap - Descent;
......@@ -418,14 +430,14 @@ CNumerator.prototype.getElement = function()
{
return this.elements[0][0];
}
CNumerator.prototype.getTxtPrp = function()
{
return this.Parent.getTxtPrp();
}
CNumerator.prototype.getReduct = function()
{
return this.Parent.getReduct();
}
CNumerator.prototype.getCtrPrp = function()
{
return this.Parent.getCtrPrp();
}
function CDenominator()
{
......@@ -440,12 +452,13 @@ CDenominator.prototype.init = function()
CDenominator.prototype.recalculateSize = function()
{
var arg = this.elements[0][0].size;
var txtPrp = this.getTxtPrp();
txtPrp.FontSize *= this.Parent.reduct;
/*var txtPrp = this.getTxtPrp();
txtPrp.FontSize *= this.Parent.reduct;*/
var ctrPrp = this.getCtrPrp();
var gap = 7.832769097222222 * txtPrp.FontSize/36,
Ascent = arg.center - 4.938888888888888*txtPrp.FontSize/36,
minGap = txtPrp.FontSize* 25.4/96 * 0.24;
var gap = 7.832769097222222 * ctrPrp.FontSize/36,
Ascent = arg.center - 4.938888888888888*ctrPrp.FontSize/36,
minGap = ctrPrp.FontSize* 25.4/96 * 0.24;
var delta = 0.47*gap - Ascent;
var GapDen = delta > minGap ? delta : minGap;
......@@ -481,14 +494,14 @@ CDenominator.prototype.getElement = function(txt)
{
return this.elements[0][0];
}
CDenominator.prototype.getTxtPrp = function()
{
return this.Parent.getTxtPrp();
}
CDenominator.prototype.getReduct = function()
{
return this.Parent.getReduct();
}
CDenominator.prototype.getCtrPrp = function()
{
return this.Parent.getCtrPrp();
}
//////////
......
......@@ -19,7 +19,9 @@ var DEFAULT_RUN_PRP =
FontFamily: {Name : "Cambria Math", Index : -1 },
FontSize: 11,
Italic: true,
Bold: false
Bold: false,
RFonts: {},
Lang: {}
};
var StartTextElement = 0x2B1A; // Cambria Math
......@@ -108,7 +110,7 @@ function CMathContent()
//this.TxtPrp = new CMathTextPrp();
//this.OwnTPrp = new CMathTextPrp();
//this.Composition = null; // ссылка на общую формулу
this.Composition = null; // ссылка на общую формулу
this.reduct = 1; // индефикатор для степени (уменьшение размера шрифта)
this.rInterval =
......@@ -452,9 +454,9 @@ CMathContent.prototype =
var ctrPrp = new CTextPr();
if(this.CurPоs > 1) // т.к. всегда добавляем только в текущий контент, то если контент не пуст, в начале стоят либо runPrp, либо другой MathObj
if(this.CurPos > 1) // т.к. всегда добавляем только в текущий контент, то если контент не пуст, в начале стоят либо runPrp, либо другой MathObj
{
ctrPrp = this.getCurrRunPrp();
}
else if(!this.bRoot && this.content.length == 1)
{
......@@ -470,6 +472,8 @@ CMathContent.prototype =
}
mathElem.setCtrPrp(ctrPrp);
mathElem.setComposition(this.Composition);
this.addToContent(mathElem);
var empty = new CEmpty();
......@@ -497,7 +501,11 @@ CMathContent.prototype =
{
var elem = new mathElem(obj);
if(obj.typeObj === MATH_COMP)
{
obj.relate(this);
//obj.setReferenceComp(this.Composition);
obj.setComposition(this.Composition);
}
/*var runPrp = this.getRunPrp(this.CurPos);
element.setTxtPrp( runPrp );*/
......@@ -543,20 +551,28 @@ CMathContent.prototype =
{
var runPrp = new CTextPr();
if(this.content.lenght > 0)
if(this.content.length > 1)
{
for(var i = this.CurPos; i > 0; i--)
if( this.IsPlaceholder())
{
var obj = this.content[i].value;
if(obj.typeObj == MATH_RUN_PRP)
{
runPrp.Merge(obj.getRunPrp());
break;
}
else if(obj.typeObj == MATH_COMP)
runPrp.Merge(this.Parent.getCtrPrp());
}
else
{
for(var i = this.CurPos; i > 0; i--)
{
runPrp.Merge(obj.getCtrPrp());
break;
var obj = this.content[i].value;
if(obj.typeObj == MATH_RUN_PRP)
{
runPrp.Merge(obj.getRunPrp());
break;
}
else if(obj.typeObj == MATH_COMP)
{
runPrp.Merge(obj.getCtrPrp());
break;
}
}
}
}
......@@ -2473,7 +2489,7 @@ CMathContent.prototype =
{
chrType: BRACKET_CURLY_TOP,
location: LOCATION_TOP,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
delim.init(props);
delim.fillPlaceholders();
......@@ -2483,7 +2499,7 @@ CMathContent.prototype =
var props =
{
location: LOCATION_BOT,
vertJust: VJUST_TOP
vertJc: VJUST_TOP
};
delim.init(props);
delim.fillPlaceholders();
......@@ -2504,7 +2520,7 @@ CMathContent.prototype =
{
chrType: BRACKET_CURLY_TOP,
location: LOCATION_TOP,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
grCh.init(props2);
grCh.fillPlaceholders();
......@@ -2525,7 +2541,7 @@ CMathContent.prototype =
{
chrType: BRACKET_CURLY_BOTTOM,
location: LOCATION_BOT,
vertJust: VJUST_TOP
vertJc: VJUST_TOP
};
grCh.init(props2);
grCh.fillPlaceholders();
......@@ -2906,7 +2922,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_LEFT,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -2923,7 +2939,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_RIGHT,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -2967,7 +2983,7 @@ CMathContent.prototype =
var props =
{
chrType: DOUBLE_LEFT_ARROW,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -2984,7 +3000,7 @@ CMathContent.prototype =
var props =
{
chrType: DOUBLE_RIGHT_ARROW,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -3018,7 +3034,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_LR,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -3052,7 +3068,7 @@ CMathContent.prototype =
var props =
{
chrType: DOUBLE_ARROW_LR,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -3069,7 +3085,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_RIGHT,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
var base = arrow.getBase();
......@@ -3087,7 +3103,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_RIGHT,
vertJust: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
var base = arrow.getBase();
......@@ -4065,7 +4081,6 @@ CMathContent.prototype =
width += oSize.width + gps.left + gps.right;
if(type == MATH_COMP)
{
width += oSize.width + gps.left + gps.right;
ascent = ascent > oSize.center ? ascent : oSize.center;
descent = descent < ( oSize.height - oSize.center + gps.bottom) ? (oSize.height - oSize.center + gps.bottom ) : descent;
}
......@@ -4160,12 +4175,31 @@ CMathContent.prototype =
{
pGraphics.b_color1(0,0,0,255);
var rPrp = this.content[i].value.getRunPrp();
var rPrp = new CMathTextPrp();
rPrp.Merge(DEFAULT_RUN_PRP);
rPrp.Merge( this.content[i].value.getRunPrp() );
var ital = rPrp.Italic;
rPrp.Italic = false;
pGraphics.SetFont(rPrp);
rPrp.Italic = ital;
}
else if(this.content[i].value.typeObj == MATH_PLACEHOLDER)
{
pGraphics.b_color1(0,0,0,255);
var ctrPrp = this.Parent.getCtrPrp();
var rPrp = new CMathTextPrp();
rPrp.Merge(DEFAULT_RUN_PRP);
rPrp.Merge(ctrPrp);
//var ital = rPrp.Italic;
rPrp.Italic = false;
pGraphics.SetFont(rPrp);
//rPrp.Italic = ital;
this.content[i].value.draw(pGraphics);
}
else
this.content[i].value.draw(pGraphics);
}
......@@ -4466,7 +4500,7 @@ CMathContent.prototype =
var items = null;
if(!bSelect && bMEDirect)
if(!bSelect && bMEDirect) // если курсор после мат. объекта
{
this.setStart_Selection(this.CurPos);
this.setEnd_Selection( this.CurPos-2 );
......@@ -4516,6 +4550,21 @@ CMathContent.prototype =
var Content_end = this.content.slice(end, this.content.length);
this.content = Content_start.concat(Content_end);*/
if(this.content[start-1].value.typeObj === MATH_RUN_PRP)
{
if(end === this.content.length )
start--;
else
for(var i = start; i < end; i++)
{
if(this.content[i].value.typeObj === MATH_RUN_PRP)
{
start--;
break;
}
}
}
items = this.content.splice(start, end - start);
if(!TEST)
......@@ -4635,15 +4684,16 @@ CMathContent.prototype =
//g_oTextMeasurer.SetFont ( txtPrp );
//var baseLine = DIV_CENT*g_oTextMeasurer.GetHeight();
var rPrp = this.getCurrRunPrp();
/*var rPrp = this.getCurrRunPrp();
g_oTextMeasurer.SetFont ( rPrp );
//var baseLine = DIV_CENT*g_oTextMeasurer.GetHeight();
var baseLine = DIV_CENT*g_oTextMeasurer.GetHeight();*/
//var baseLine = 0;
var baseLine = 0;
for(var i=1; i < this.content.length;i++)
{
var t = {x: this.pos.x + this.content[i-1].widthToEl + this.content[i].g_mContext.left, y: this.pos.y + max_cent };
if( ! this.content[i].value.SUBCONTENT )
if( this.content[i].value.typeObj !== MATH_COMP )
t.y += baseLine;
this.content[i].value.setPosition(t);
......@@ -4961,8 +5011,8 @@ CMathContent.prototype =
}
else if(this.content[1].value.typeObj === MATH_COMP)
{
var runPrp = this.content[1].value.getRunPrp();
txtPrp.Merge(runPrp);
var ctrPrp = this.content[1].value.getCtrPrp();
txtPrp.Merge(ctrPrp);
}
}
......@@ -4971,6 +5021,15 @@ CMathContent.prototype =
IsEmpty: function()
{
return this.content.length == 1;
},
setReferenceComp: function(Comp)
{
this.Composition = Comp;
for(var i = 0; i < this.content.length; i++)
{
if(this.content[i].value.type == MATH_COMP)
this.contetn[i].value.setReferenceComp(Comp);
}
}
}
//todo
......@@ -4991,7 +5050,7 @@ function CMathComposition()
Italic: true,
Bold: false,
RFonts: {},
Lang: {}
Lang: {}
};
this.Init();
......@@ -5620,9 +5679,14 @@ CMathComposition.prototype =
RecalculateComposition: function()
{
//this.Root.setTxtPrp(this.TxtPrp);
this.SetReferenceComposition();
this.Root.Resize();
this.Root.setPosition(this.pos);
this.UpdateCursor();
},
SetReferenceComposition: function()
{
this.Root.setReferenceComp(this);
}
}
......
......@@ -16,6 +16,8 @@ function CMathTextPrp()
this.FontSize = undefined;
this.Bold = undefined;
this.Italic = undefined;
this.RFonts = {};
this.Lang = {};
}
CMathTextPrp.prototype =
{
......@@ -321,13 +323,17 @@ CMathText.prototype =
//pGraphics.FillTextCode(xx, yy , this.value);
},
setPosition: function(pos)
old_setPosition: function(pos)
{
if( ! this.bJDraw) // for text
this.pos = {x : pos.x, y: pos.y };
else // for symbol only drawing
this.pos = {x: pos.x , y: pos.y + this.size.center};
},
setPosition: function(pos)
{
this.pos = {x: pos.x , y: pos.y};
},
setCoeffTransform: function(sx, shx, shy, sy)
{
this.transform = {sx: sx, shx: shx, shy: shy, sy: sy};
......
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