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

Math для ParaRun

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55162 954022d7-b5bf-4e40-9824-e11837661b57
parent dac65d5a
This diff is collapsed.
......@@ -6363,4 +6363,70 @@ function CRunCollaborativeRange(PosS, PosE)
{
this.PosS = PosS;
this.PosE = PosE;
}
ParaRun.prototype.Math_SetPosition = function(pos)
{
for(var i = 0; i < this.Content.length; i++)
{
this.Content[i].setPosition(pos);
}
}
ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
{
if(this.bMathRun)
{
var X = x;
var Y = y + this.size.ascent;
pGraphics.b_color1(0,0,0,255);
for(var i=1; i < this.Content.length;i++)
{
var oWPrp = this.Get_CompiledPr(false);
g_oTextMeasurer.SetFont(oWPrp);
X += this.Content[i].size.width;
this.Content[i].draw(X, Y, pGraphics);
}
}
}
ParaRun.prototype.Math_Recalculate = function()
{
var RangeStartPos = 0;
var RangeEndPos = this.Content.length;
this.Lines[0].Add_Range( 0, RangeStartPos, RangeEndPos );
var width = 0,
ascent = 0, descent = 0;
for (var Pos = 0 ; Pos < this.Content.length; Pos++ )
{
// var oWPrp = new CTextPr();
// oWPrp.Merge(this.Parent.Composition.DEFAULT_RUN_PRP);
var oWPrp = this.Get_CompiledPr(false);
oWPrp.Merge(this.Parent.Composition.DEFAULT_RUN_PRP.getTxtPrp());
g_oTextMeasurer.SetFont(oWPrp);
this.Content[Pos].Resize(g_oTextMeasurer);
var oSize = this.Content[Pos].size;
//var gps = this.Content[Pos].gaps;
//width += oSize.width + gps.left + gps.right;
width += oSize.width;
ascent = ascent > oSize.ascent ? ascent : oSize.ascent;
var oDescent = oSize.height - oSize.ascent;
descent = descent < oDescent ? oDescent : descent;
}
this.size = {width: width, height: ascent + descent, ascent: ascent};
}
\ No newline at end of file
......@@ -687,7 +687,8 @@ CMathContent.prototype =
addElementToContent: function(obj) //for "read"
{
var element = new mathElem(obj);
obj.relate(this);
//obj.relate(this);
obj.Parent = this;
if(obj.typeObj === MATH_COMP)
obj.setComposition(this.Composition);
......@@ -703,9 +704,6 @@ CMathContent.prototype =
if(obj.typeObj == MATH_COMP)
obj.setArgSize(this.argSize);
//this.length = this.content.length;
},
addToContent: function(obj, shift) // for "edit", letters
{
......@@ -4836,6 +4834,10 @@ CMathContent.prototype =
this.content[i].value.Resize(oMeasure);
}
}
else if(type == MATH_PARA_RUN)
{
this.content[i].value.Math_Recalculate();
}
}
this.recalculateSize();
......@@ -5375,6 +5377,11 @@ CMathContent.prototype =
this.content[i].value.draw(x, y, pGraphics);
}
else if(this.content[i].value.typeObj == MATH_PARA_RUN)
{
var PSDE = {X: x, Y: y, Graphics: pGraphics};
this.content[i].value.Math_Draw(x, y, pGraphics);
}
else
this.content[i].value.draw(x, y, pGraphics);
......@@ -6190,7 +6197,10 @@ CMathContent.prototype =
y: this.pos.y + this.size.ascent //baseline
};
this.content[i].value.setPosition(t);
if(this.content[i].value.typeObj == MATH_PARA_RUN)
this.content[i].value.Math_SetPosition(pos);
else
this.content[i].value.setPosition(t);
}
},
old_drawSelect: function()
......@@ -6774,7 +6784,7 @@ CMathContent.prototype =
}
}
},
Save_Changes: function(Data, Writer)
Save_Changes: function(Data, Writer)
{
Writer.WriteLong( historyitem_type_Math );
......@@ -7194,10 +7204,20 @@ CMathContent.prototype =
},
get_ParaContentPos: function(bSelection, bStart, ContentPos)
{
if( bSelection && this.RealSelect.startPos !== this.RealSelect.endPos )
if( bSelection )
{
var pos = bStart ? this.RealSelect.startPos : this.RealSelect.endPos;
ContentPos.Add(pos);
if(this.RealSelect.startPos == this.RealSelect.endPos)
{
var blen = this.RealSelect.startPos < this.content.length;
var bComp = blen ? this.content[this.RealSelect.startPos].value.typeObj == MATH_COMP : false;
if(bComp)
this.content[this.RealSelect.startPos].value.get_ParaContentPos(bSelection, bStart, ContentPos);
}
}
else
{
......@@ -7266,9 +7286,9 @@ CMathContent.prototype =
{
var pos = ContentPos.Get(Depth);
Depth++;
this.LogicalSelect.start = this.LogicalSelect.end = pos;
this.LogicalSelect.start = pos;
if(this.RealSelect.startPos === this.RealSelect.endPos && this.content[pos].value.typeObj === MATH_COMP)
if(pos < this.content.length && this.RealSelect.startPos === this.RealSelect.endPos && this.content[pos].value.typeObj === MATH_COMP)
this.content[pos].value.set_StartSelectContent(ContentPos, Depth);
}
},
......@@ -7291,9 +7311,11 @@ CMathContent.prototype =
this.LogicalSelect.end = posEnd;
Depth++;
//var blen = this.RealSelect.startPos < this.content.length;
//селект внутри мат. объекта
if(posStart === posEnd && this.content[posEnd].value.typeObj === MATH_COMP)
if(posStart < this.content.length && posStart === posEnd && this.content[posEnd].value.typeObj === MATH_COMP)
{
var result = this.content[posEnd].value.set_EndSelectContent(ContentPos, Depth);
this.setStartPos_Selection(posStart-1);
......@@ -7312,27 +7334,34 @@ CMathContent.prototype =
SelectContent = this;
var direction = (posStart < posEnd) ? 1 : -1;
if( this.content[posStart].value.typeObj === MATH_COMP )
if(posStart < this.content.length)
{
if( direction == 1 )
this.setStartPos_Selection( posStart - 1);
else if( direction == -1 )
this.setStartPos_Selection( posStart + 1);
if(this.content[posStart].value.typeObj === MATH_COMP )
{
if( direction == 1 )
this.setStartPos_Selection( posStart - 1);
else if( direction == -1 )
this.setStartPos_Selection( posStart + 1);
}
else
this.setStartPos_Selection(posStart);
}
else
this.setStartPos_Selection(posStart);
if( this.content[posEnd].value.typeObj === MATH_COMP )
if(posEnd < this.content.length)
{
if( direction == 1 )
this.setEndPos_Selection(posEnd + 1);
else if( direction == -1 )
this.setEndPos_Selection(posEnd - 1);
if(this.content[posEnd].value.typeObj === MATH_COMP )
{
if( direction == 1 )
this.setEndPos_Selection(posEnd + 1);
else if( direction == -1 )
this.setEndPos_Selection(posEnd - 1);
}
else
this.setEndPos_Selection(posEnd);
}
else
this.setEndPos_Selection(posEnd);
}
return {state: state, SelectContent: SelectContent};
......
......@@ -237,7 +237,6 @@ CMathText.prototype =
// rasterOffsetX
// rasterOffsetY
var letter = this.getCode();
var metricsTxt = oMeasure.Measure2Code(letter);
......@@ -424,6 +423,8 @@ CMathText.prototype =
setComposition: function() // заглушка
{},
setReferenceComposition: function() // заглушка
{},
Write_ToBinary: function()
{}
/*draw2: function()
......
......@@ -150,6 +150,7 @@ var MATH_RUN_PRP = 1;
var MATH_COMP = 2;
var MATH_EMPTY = 3;
var MATH_PLACEHOLDER = 4;
var MATH_PARA_RUN = 5;
////////////////////////////////////////
......
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