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

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@48420 954022d7-b5bf-4e40-9824-e11837661b57
parent 580014ec
......@@ -384,6 +384,17 @@ CControlComposition.prototype =
{
this.coord = pos;
this.Content[this.CurPos].SetPosition(pos);
},
SetTxtPrp: function(txtPrp)
{
this.Content[this.CurPos].SetTxtPrp(txtPrp);
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, { Width : Page_Width, Height : Page_Height, Margins : {
Left : X_Left_Field,
Right : X_Right_Field,
Top : Y_Top_Field,
Bottom : Y_Bottom_Field
} } );
}
}
var MathControl = new CControlComposition();
......
......@@ -19,7 +19,8 @@ function CMathBase()
this.Parent = null;
this.Composition = null; // ссылка на общую формулу
this.textPrp = new CMathTextPrp();
this.textPrp = new CMathTextPrp(); // для рассчета размера расстояний
this.RunPrp = new CMathTextPrp(); // запоминаем, если передаются спец. настройки для контента
//todo
//переделать
......@@ -54,6 +55,7 @@ CMathBase.prototype =
this.elements[i][j].relate(this);
this.elements[i][j].setReduct(this.reduct);
this.elements[i][j].setComposition(this.Composition);
this.elements[i][j].setRunPrp(this.RunPrp);
}
}
......@@ -102,9 +104,13 @@ CMathBase.prototype =
this.elements[i][j].setComposition(Compos);
}
},
setTxtPr: function(prp)
getRunPrp: function()
{
this.txtPrp.Set(prp);
return this.textPrp;
},
setRunPrp: function(txtPrp)
{
this.RunPrp.Merge(txtPrp);
},
fillPlaceholders: function()
{
......@@ -141,6 +147,7 @@ CMathBase.prototype =
this.elements[i][j].setReduct(this.reduct);
}
this.elements[i][j].bMObjs = true;
this.elements[i][j].setRunPrp(this.RunPrp);
}
}
}
......@@ -861,6 +868,13 @@ CMathBase.prototype =
getElement: function(x, y)
{
return this.elements[x][y];
},
setTxtPrp: function(txtPrp)
{
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].setTxtPrp(txtPrp);
}
}
......
......@@ -157,7 +157,7 @@ CNumerator.prototype.setPosition = function(pos)
this.elements[0][0].setPosition({x: x, y: y});
}
CNumerator.prototype.getElement = function(txt)
CNumerator.prototype.getElement = function()
{
return this.elements[0][0];
}
......
......@@ -113,21 +113,65 @@ CMathContent.prototype =
this.g_mContext = new dist(0,0,0,0);
this.content.push( new mathElem(new CEmpty(), new dist(0,0,0,0), 0) );
},
setTxtPrp: function(txtPrp)
ChangeTxtPrp: function(txtPrp)
{
this.textPrp.Set(txtPrp);
var start, end;
if( this.selection.startPos != this.selection.endPos )
{
start = this.selection.startPos;
end = this.selection.endPos;
if(start > end)
{
tmp = start;
start = end;
end = tmp;
}
}
for(var i = start; i < end; i++)
this.content[i].value.setTxtPrp(txtPrp);
},
setTxtPrp: function(txtPrp) // для всего контента, в случае, когда селект вышел за пределы контента, когда начинали селект + когда в коннтенте есть мат. элементы
{
this.textPrp.Merge(txtPrp);
for(var i = 0; i < this.content.length; i++)
this.content[i].value.setTxtPrp(txtPrp);
},
setRunPrp: function(txtPrp)
{
this.setTxtPrp(txtPrp);
},
mergeTxtPrp: function(txtPrp)
{
this.textPrp.Merge(txtPrp);
},
getRunPrp: function(pos)
{
var runPrp = new CMathTextPrp();
if(this.content.length > 1)
{
if(pos == 1) //берем справa
{
var rPrp = this.content[pos].value.getRunPrp();
runPrp.Merge(rPrp);
}
else
{
var rPrp = this.content[pos].value.getRunPrp();
runPrp.Merge(rPrp);
}
}
return runPrp;
},
setComposition: function(Compos)
{
this.Composition = Compos;
},
addTxt: function(txt)
{
for(var i = 0; i < txt.length; i++)
{
this.addLetter( txt.charCodeAt(i));
......@@ -168,7 +212,12 @@ CMathContent.prototype =
var symb = new CMathText();
symb.relate(this);
symb.addCode(code);
symb.add(code);
symb.setTxtPrp( this.getRunPrp(this.CurPos) );
// txt properties
this.addElementToContent(symb, gps);
......@@ -260,10 +309,14 @@ CMathContent.prototype =
mathElem.relate(this);
mathElem.setComposition(this.Composition);
mathElem.setReduct(this.reduct);
var runPrp = this.getRunPrp(this.CurPos);
mathElem.setRunPrp( runPrp );
//l_gap = r_gap = Math.floor( this.font.FontSize / 5 )*g_dKoef_pix_to_mm;
this.addElementToContent( mathElem, new dist(l_gap, r_gap, 0, 0) );
this.addElementToContent(new CEmpty());
var empty = new CEmpty();
empty.setTxtPrp(runPrp);
this.addElementToContent(empty);
this.rInterval.endPos += 2;
}
......@@ -2580,7 +2633,7 @@ CMathContent.prototype =
else
sAscent = Size.center;
_ascent = Size.ascent > sAscent ? Size.ascent : sAscent;
_ascent = _ascent > sAscent ? _ascent : sAscent;
}
_width += this.g_mContext.left + this.g_mContext.right;
......@@ -2688,7 +2741,7 @@ CMathContent.prototype =
return pos;
},
getCoordElem: function(index, mCoord) // without gaps of Math Component ( напримет, если справа/слева есть относительно мат элемента компонент, то добавляем gaps справа/слева для этого мат элемента )
getCoordElem: function(index, mCoord) // without gaps of Math Component ( например, если справа/слева есть относительно мат элемента компонент, то добавляем gaps справа/слева для этого мат элемента )
{
var widthToPrev = this.content[index-1].widthToEl;
var widthToCur = this.content[index].widthToEl;
......@@ -2918,14 +2971,34 @@ CMathContent.prototype =
this.setEnd_Selection(1);
this.selection.active = false;
},
old_setPosition: function( _pos )
{
this.pos = { x: _pos.x + this.g_mContext.left, y: _pos.y};
var max_cent = this.size.center;
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 };
this.content[i].value.setPosition(t);
}
},
setPosition: function( _pos )
{
this.pos = { x: _pos.x + this.g_mContext.left, y: _pos.y};
var max_cent = this.size.center;
//var baseLine = 0;
var txtPrp = this.getTxtPrp();
g_oTextMeasurer.SetFont ( txtPrp );
var baseLine = DIV_CENT*g_oTextMeasurer.GetHeight();
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 )
t.y += baseLine;
this.content[i].value.setPosition(t);
}
},
......@@ -3307,13 +3380,13 @@ CMathContent.prototype =
fillPlaceholder: function()
{
this.fillMComponent(0);
this.addCode(StartTextElement);
this.add(StartTextElement);
},
fillText: function(txt)
{
for(var i = 0; i < txt.length; i++)
{
this.addCode( txt.charCodeAt(i) );
this.add( txt.charCodeAt(i) );
}
// ?? this.recalculate();
......@@ -3415,7 +3488,7 @@ CMathContent.prototype =
{
component = new CMathText();
component.init(this.params);
component.addCode(StartTextElement);
component.add(StartTextElement);
result = this;
}
else if(type == 1)
......@@ -3589,10 +3662,6 @@ CMathComposition.prototype =
this.TxtPrp.Italic = true;
this.TxtPrp.Bold = false;
},
SetTxtPrp: function(TxtPrp)
{
this.TxtPrp = TxtPrp;
},
Draw: function(context)
{
if(this.Root.content.length > 1)
......@@ -3833,6 +3902,18 @@ CMathComposition.prototype =
editor.WordControl.m_oLogicDocument.DrawingDocument.SelectEnabled(false);
}
},
SetTxtPrp: function(txtPrp)
{
this.SelectContent.ChangeTxtPrp(txtPrp);
this.Resize();
this.UpdatePosition();
this.UpdateCursor();
},
UpdateCursor: function()
{
this.CurrentContent.update_Cursor();
this.ShowCursor();
},
//// test function ////
TestSetPostion: function()
......@@ -4647,7 +4728,8 @@ function CEmpty()
{
this.SUBCONTENT = false;
this.empty = true;
this.pos;
this.pos = null;
this.textPrp = new CMathTextPrp();
//this.size = {width: 0, ascent:0, descent: 0, height: 0, center: 0};
this.size = {width: 0, height: 0, center: 0, ascent: 0};
this.selection =
......@@ -4657,14 +4739,17 @@ function CEmpty()
endPos: 0
};
this.draw = function(nothing) {}
this.mouseMove = function(nothing1, nothing2) { return true; }
this.setFont = function() {}
this.draw = function(nothing) {};
this.mouseMove = function(nothing1, nothing2) { return true; };
this.setFont = function() {};
this.setPosition = function (_pos) { this.pos = _pos; };
this.Resize = function(){};
this.setPosition = function (_pos) { this.pos = _pos; }
this.Resize = function(){}
this.IsHighElement = function() { return false; };
this.setTxtPrp = function(txtPrp) { this.textPrp.Merge(txtPrp); };
this.getRunPrp = function() {return this.textPrp;};
this.IsHighElement = function() { return false; }
}
function AddEquation(ind)
......
......@@ -8,6 +8,8 @@
//api 2212: asc_docs_api.prototype.sync_TextPrFontFamilyCallBack
// возвращает название шрифта
var DIV_CENT = 0.2487852283770651;
function CMathTextPrp()
{
this.FontFamily = undefined;
......@@ -66,12 +68,14 @@ function CMathText()
}
CMathText.prototype =
{
addCode: function(code)
add: function(code)
{
var Italic = this.textPrp.Italic;
if(Italic === "undefinded" || Italic == null)
Italic = this.Parent.getTxtPrp().Italic;
this.value = code;
},
getCode: function()
{
var code = this.value;
var Italic = this.getTxtPrp().Italic;
if(Italic)
{
......@@ -99,34 +103,30 @@ CMathText.prototype =
code = 0x1D6A5;
}
else
{
if(code == 0x210E) // h
code = 0x0068;
var bCapitale = (code >= 0x1D434 && code <= 0x1D44D),
bSmall = (code >= 0x1D44E && code <= 0x1D467);
if(bCapitale)
code = code - 0x1D3F3;
else if(bSmall)
code = code - 0x1D3ED;
else if(bCapGreek)
code = code - 0x1D351;
else if(bSmallGreek)
code = code - 0x1D34B;
if(code == 0x1D6A4) // "i" without dot
code = 0x131;
else if(code == 0x1D6A5) // "j" without dot
code = 0x237;
}
this.value = code;
},
add: function(code)
{
this.value = code;
/*else
{
if(code == 0x210E) // h
code = 0x0068;
var bCapitale = (code >= 0x1D434 && code <= 0x1D44D),
bSmall = (code >= 0x1D44E && code <= 0x1D467);
if(bCapitale)
code = code - 0x1D3F3;
else if(bSmall)
code = code - 0x1D3ED;
else if(bCapGreek)
code = code - 0x1D351;
else if(bSmallGreek)
code = code - 0x1D34B;
if(code == 0x1D6A4) // "i" without dot
code = 0x131;
else if(code == 0x1D6A5) // "j" without dot
code = 0x237;
}*/
return code;
},
fillPlaceholders: function()
{
......@@ -137,18 +137,22 @@ CMathText.prototype =
var txtPrp = this.Parent.getTxtPrp();
txtPrp.Merge(this.textPrp);
txtPrp.Italic = false; // всегда отправляем "false"!!
//txtPrp.Italic = false; // всегда отправляем "false"!!
return txtPrp;
},
setTxtPrp: function(txtPrp)
{
this.textPrp.Set(txtPrp);
this.textPrp.Merge(txtPrp);
},
setLIterator: function(bIterator)
{
this.bIterator = bIterator; // символы другие , чуть толще
},
getRunPrp: function()
{
return this.textPrp;
},
// ascent = Symbol.Ascent // = Placeholder.Ascent (= Placeholder.Height)
// descent = FontAscent - Placeholder.Height (FontAscent = FontHeight - FontDescent)
......@@ -159,10 +163,12 @@ CMathText.prototype =
recalculateSize: function()
{
var txtPrp = this.getTxtPrp();
txtPrp.Italic = false;
g_oTextMeasurer.SetFont ( txtPrp );
var metricsTxt = g_oTextMeasurer.Measure2Code(this.value);
var letter = this.getCode();
var metricsTxt = g_oTextMeasurer.Measure2Code(letter);
var _width = metricsTxt.Width;
//var _ascent = g_oTextMeasurer.GetHeight() + g_oTextMeasurer.GetDescender();
......@@ -183,11 +189,12 @@ CMathText.prototype =
this.size = {width: _width, widthG: widthG, height: _height, center: _center, ascent: _ascent, descent: _descent};
},
draw: function()
old_draw: function()
{
var txtPrp = this.getTxtPrp();
g_oTextMeasurer.SetFont ( txtPrp );
MathControl.pGraph.b_color1(0,0,0,255);
MathControl.pGraph.SetFont(txtPrp);
......@@ -228,7 +235,56 @@ CMathText.prototype =
MathControl.pGraph.transform(sx, shy, shx, sy, 0, 0);
MathControl.pGraph.FillTextCode(xx, yy , this.value);
MathControl.pGraph.FillTextCode(xx, yy , this.getCode());
},
draw: function()
{
var txtPrp = this.getTxtPrp();
txtPrp.Italic = false;
g_oTextMeasurer.SetFont ( txtPrp );
MathControl.pGraph.b_color1(0,0,0,255);
MathControl.pGraph.SetFont(txtPrp);
var X = this.pos.x ,
Y = this.pos.y;
var invert = new CMatrix();
invert.sx = this.transform.sx;
invert.sy = this.transform.sy;
invert.shx = this.transform.shx;
invert.shy = this.transform.shy;
invert.tx = 0;
invert.ty = 0;
invert.Invert();
var xx = invert.TransformPointX(X, Y);
var yy = invert.TransformPointY(X, Y);
/*var invert1= new CMatrix();
invert1.sx = this.transform.sx;
invert1.sy = this.transform.sy;
invert1.shx = this.transform.shx;
invert1.shy = this.transform.shy;
invert1.tx = 0;
invert1.ty = 0;
var xxx = invert1.TransformPointX(xx, yy);
var yyy = invert1.TransformPointY(xx, yy);*/
var sx = this.transform.sx, shx = this.transform.shx,
shy = this.transform.shy, sy = this.transform.sy;
/*var tx = 0;
var ty = 0;
var x = (X*sy - Y*shx - tx*sy)/(sx*sy- shy*shx);
var y = (Y - x*shy - ty*shx)/sy;*/
MathControl.pGraph.transform(sx, shy, shx, sy, 0, 0);
MathControl.pGraph.FillTextCode(xx, yy , this.getCode());
},
setPosition: function( pos )
......@@ -550,7 +606,7 @@ old_CMathText.prototype =
//MathControl.pGraph.transform(sx, shy, shx, sy, tx, ty);
//MathControl.pGraph.FillTextCode(x, y , this.value); // прибавляем аскент, тк на отрисовку символа отправляем положение baseLine
},
draw: function()
old_old_draw: function()
{
MathControl.pGraph.b_color1(0,0,0,255);
MathControl.pGraph.SetFont(this.font);
......@@ -593,6 +649,54 @@ old_CMathText.prototype =
MathControl.pGraph.transform(sx, shy, shx, sy, 0, 0);
MathControl.pGraph.FillTextCode(xx, yy , this.value);
},
draw: function()
{
var txtPrp = this.getTxtPrp();
g_oTextMeasurer.SetFont ( txtPrp );
MathControl.pGraph.b_color1(0,0,0,255);
MathControl.pGraph.SetFont(txtPrp);
var X = this.pos.x ,
Y = this.pos.y; // прибавляем аскент, тк на отрисовку символа отправляем положение baseLine
var invert = new CMatrix();
invert.sx = this.transform.sx;
invert.sy = this.transform.sy;
invert.shx = this.transform.shx;
invert.shy = this.transform.shy;
invert.tx = 0;
invert.ty = 0;
invert.Invert();
var xx = invert.TransformPointX(X, Y);
var yy = invert.TransformPointY(X, Y);
/*var invert1= new CMatrix();
invert1.sx = this.transform.sx;
invert1.sy = this.transform.sy;
invert1.shx = this.transform.shx;
invert1.shy = this.transform.shy;
invert1.tx = 0;
invert1.ty = 0;
var xxx = invert1.TransformPointX(xx, yy);
var yyy = invert1.TransformPointY(xx, yy);*/
var sx = this.transform.sx, shx = this.transform.shx,
shy = this.transform.shy, sy = this.transform.sy;
/*var tx = 0;
var ty = 0;
var x = (X*sy - Y*shx - tx*sy)/(sx*sy- shy*shx);
var y = (Y - x*shy - ty*shx)/sy;*/
MathControl.pGraph.transform(sx, shy, shx, sy, 0, 0);
MathControl.pGraph.FillTextCode(xx, yy , this.getCode() );
},
draw2: function()
{
......@@ -622,7 +726,7 @@ old_CMathText.prototype =
this.font = font;
this.recalculateSize();
},
setPosition: function( _pos )
old_setPosition: function( _pos )
{
/*if(this.value == 0x307)
this.pos = {x : _pos.x + this.size.width, y: _pos.y };
......@@ -632,6 +736,13 @@ old_CMathText.prototype =
this.pos = {x : _pos.x, y: _pos.y };
},
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};
},
setIndefSize: function(indef)
{
if(indef == indef - 0 && indef > 0 && indef < 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