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;
......
This diff is collapsed.
...@@ -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