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

1. RecalculateComposition_2() -> RecalculateComposition(oMeasure, TextPr)

2. Протащила коорданату в Draw
3. Properties для delimiters (для записи в файл)
4. В ревизии 52173 убрала старый код  для CAccent, CDegreeOrdinary, CNary, CNaryOperator, 
CDelimiter, CGlyphOperator, COperator, COperatorArrow, GroupCharacter, CStructArrow, CStructCombiningArrow,
CRadical, CDegreeRadical, CSubMathBase

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52259 954022d7-b5bf-4e40-9824-e11837661b57
parent 34e215f1
......@@ -602,251 +602,6 @@ CSign.prototype.getCodeAccent = function()
return this.sign.value;
}
function old_CAccent()
{
this.index = null;
this.DIACR_ANGLE = 0.1;
CMathBase.call(this);
}
// посмотреть смещение у диакритических знаков
extend(old_CAccent, CMathBase);
old_CAccent.prototype.init = function(index)
{
this.index = index;
this.setDimension(2, 1);
var oBase = new CMathContent();
oBase.SetDot(true);
var oAccent = new CMathText();
oAccent.setJustDraw(true);
if(this.index == 1)
oAccent.add(0x300);
else if(this.index == 2)
oAccent.add(0x301);
else if(this.index == 3)
oAccent.add(0x307);
else if(this.index == 4)
oAccent.add(0x308);
else if(this.index == 5)
oAccent.add(0x20DB);
this.addMCToContent(oAccent, oBase);
}
old_CAccent.prototype.recalculateSize = function()
{
var first = this.elements[0][0].size,
second = this.elements[1][0].size;
this.setDistance();
var height = first.height + second.height + this.dH;
var center = this.getCenter();
var incline = 0;
if( this.IsIncline() )
incline = second.height*this.DIACR_ANGLE; // смещение
var align1 = 0,
align2 = 0;
if(second.width > first.widthG + incline)
{
align1 = (second.width - first.widthG)/2 + incline;
}
else
{
align1 = incline;
align2 = (first.width - second.widthG)/2;
}
var w1 = first.widthG + align1,
w2 = second.width + align2;
var width = w2 > w1 ? w2 : w1;
this.size = {width: width, height: height, center: center};
}
old_CAccent.prototype.getCenter = function()
{
return this.elements[0][0].size.height + this.elements[1][0].size.center + this.dH;
}
old_CAccent.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
var first = this.elements[0][0].size,
second = this.elements[1][0].size;
//для отрисовки (т.к. у некоторых значков ширина "нулевая")
var shX = 0;
if(this.index == 1)
shX = 1.1*first.widthG;
else if(this.index == 2)
shX = 1.25*first.widthG;
else if(this.index == 3)
shX = 1.53*first.widthG;
else if(this.index == 4)
shX = 0.95*first.widthG;
else if(this.index == 5)
shX = 0.015*first.widthG;
else
shX = 0;
// учитываем наклон буквы
var incline = 0;
if( this.IsIncline() )
incline = this.DIACR_ANGLE*second.height;
var align1 = 0,
align2 = 0;
if(second.width > first.widthG + incline)
{
align1 = (second.width - first.widthG)/2 + incline;
}
else
{
align1 = incline;
align2 = (first.widthG - second.width)/2;
}
/* var pos1 = {x: this.pos.x + shX + align1, y: this.pos.y},
pos2 = {x: this.pos.x + align2, y: this.pos.y + first.height + this.dH};*/
var pos1 = {x: this.pos.x + shX + align1, y: this.pos.y + first.ascent - first.center},
pos2 = {x: this.pos.x + align2, y: this.pos.y + first.height + this.dH};
this.elements[0][0].setPosition(pos1);
this.elements[1][0].setPosition(pos2);
}
old_CAccent.prototype.IsIncline = function()
{
return this.elements[1][0].IsIncline();
}
old_CAccent.prototype.setDistance = function()
{
this.dH = 0.7*this.getTxtPrp().FontSize/36;
}
/*function CAccent()
{
this.bDiacritic = true;
this.type = null;
this.accent = null;
CMathBase.call(this);
}
extend(CAccent, CMathBase);
CAccent.prototype.init = function(props)
{
var code;
if(typeof(props.chr.value) === "string")
code = props.chr.value.charCodeAt(0);
// var code = props.chr.value.charCodeAt(0);
var bDot = code === 0x307 || props.chr.type === ACCENT_ONE_DOT,
b2Dots = code === 0x308 || props.chr.type === ACCENT_TWO_DOTS,
b3Dots = code === 0x20DB || props.chr.type === ACCENT_THREE_DOTS,
bAccGrave = code === 0x300 || props.chr.type === ACCENT_GRAVE,
bAccAcute = code === 0x301 || props.chr.type === ACCENT;
if(bDot || b2Dots || b3Dots || bAccGrave || bAccAcute)
{
this.accent = new CMathText();
this.accent.add(code);
this.type = props.chr.type;
}
else if(code === 0x302 || props.chr.type === ACCENT_CIRCUMFLEX)
{
this.accent = new CCircumflex();
this.accent.setTurn(TURN_0);
}
else if(code === 0x30C || props.chr.type === ACCENT_COMB_CARON)
{
this.accent = new CCircumflex();
this.accent.setTurn(TURN_MIRROR_0);
}
else if(code === 0x332 || props.chr.type === ACCENT_LINE)
{
this.accent = new CLine();
this.accent.setPrp(SINGLE_LINE);
}
else if(code === 0x333 || props.chr.type === ACCENT_DOUBLE_LINE)
{
this.accent = new CLine();
this.accent.setPrp(DOUBLE_LINE);
}
else if(code === 0x303 || props.chr.type === ACCENT_TILDE)
{
this.accent = new CTilde();
}
else
{
this.accent = new CMathText();
this.accent.add(code);
this.type = MATH_TEXT;
this.bDiacritic = false;
}
var tPrp = this.getTxtPrp();
this.accent.setTxtPrp(tPrp);
this.setDimension(1, 1);
this.setContent();
}
CAccent.prototype.recalculateSize = function()
{
var content = this.elements[0][0];
this.dH = 0.7*this.getTxtPrp().FontSize/36;
if(this.bDiacritic)
this.accent.fixSize(content.size.width, content.IsIncline());
var height = this.accent.size.height + content.size.height,
center = this.accent.size.height + content.size.center;
var accW;
if(this.bDiacritic)
accW = this.accent.size.width + this.accent.incline;
else
accW = this.accent.size.width;
var width = accW > content.size.width ? accW : content.size.width;
this.size = {width: width, height: height, center: center};
//var height = first.height + second.height + this.dH;
//var center = this.elements[0][0].size.height + this.elements[1][0].size.center + this.dH;
}
CAccent.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
var pos =
{
x: this.pos.x + (this.size.width - this.accent.size.width)/2,
y: this.pos.y
};
this.accent.setPosition(pos);
var content = this.elements[0][0];
pos =
{
x: this.pos.x + (this.size.width - content.size.width)/2,
y: this.pos.y + this.accent.size.height
};
this.elements[0][0].setPosition(pos);
}
CAccent.prototype.draw = function()
{
this.accent.draw();
this.elements[0][0].draw();
}*/
function CAccent()
{
this.code = null; // храним код буквы и тип здесь
......
......@@ -354,7 +354,7 @@ CControlComposition.prototype =
{
for(var i = 0; i < this.Content.length; i++)
{
this.Content[i].Draw(pGraph);
this.Content[i].Draw_2(pGraph);
if(pGraph != "undefined" && pGraph !== null)
this.pGraph = pGraph;
}
......@@ -371,10 +371,11 @@ CControlComposition.prototype =
return {x: _x, y: _y};
},
// AddMathComponent -> CreateEquation
// recalculate Equation
CreateEquation: function(indef)
{
this.Content[this.CurPos].CreateEquation(indef);
this.Content[this.CurPos].RecalculateReverse();
this.Content[this.CurPos].RecalculateReverse(oMeasure);
this.Content[this.CurPos].UpdatePosition();
},
Paragraph_Add: function(TextPr)
......@@ -429,7 +430,7 @@ CControlComposition.prototype =
}
var MathControl = new CControlComposition();
MathControl.AddComposition();
MathControl.SetPosition({x: 21.5, y: 25.3 });
MathControl.SetPosition({x: 27.5 - 6, y: 25.3 });
var inherit = function(obj, extObj)
{
......
......@@ -870,16 +870,16 @@ CMathBase.prototype =
this.size = {width: _width, height: _height, center: _center};
},
RecalculateReverse: function()
RecalculateReverse: function(oMeasure)
{
this.recalculateSize();
this.Parent.RecalculateReverse();
this.Parent.RecalculateReverse(oMeasure);
},
Resize: function()
Resize: function(oMeasure)
{
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].Resize();
this.elements[i][j].Resize(oMeasure);
this.recalculateSize();
},
......
......@@ -149,181 +149,6 @@ CDegree.prototype.getPropsForWrite = function()
return props;
}
function old_CDegreeOrdinary()
{
this.index = null;
this.shiftDegree = null;
CMathBase.call(this);
}
extend(old_CDegreeOrdinary, CMathBase);
old_CDegreeOrdinary.prototype.init = function()
{
var oBase = new CMathContent();
this.init_2(oBase);
}
old_CDegreeOrdinary.prototype.init_2 = function(base)
{
this.setDimension(1, 2);
var degree = new CMathContent();
degree.setReduct(DEGR_REDUCT);
this.addMCToContent(base, degree);
}
old_CDegreeOrdinary.prototype.setIndex = function(index)
{
this.index = index;
}
old_CDegreeOrdinary.prototype.recalculateSize = function()
{
var Widths = this.getWidthsHeights().widths;
var Heights = [this.elements[0][0].size.height, this.elements[0][1].size.height];
var _center;
var middle = ((Heights[0] > Heights[1]) ? Heights[1] : Heights[0])* 2/3; /// 2/3 от высоты
var _height = Heights[0] + Heights[1] - middle;
var _width = 0;
for( var i = 0; i < Widths.length; i++ )
_width += Widths[i];
_width += this.dW;
if(this.index === 1 )
{
this.shiftDegree = 0;
_center = _height - (this.elements[0][0].size.height - this.elements[0][0].size.center);
}
else if(this.index === -1 )
{
this.shiftDegree = _height - this.elements[0][1].size.height;
_center = this.elements[0][0].size.center;
}
this.size = {width: _width,height: _height, center: _center};
}
old_CDegreeOrdinary.prototype.setPosition = function(_pos)
{
var pos = _pos;
if(this.bMObjs === true)
{
pos = {x: pos.x, y: pos.y + this.size.center };
}
this.elements[0][0].setPosition({x: pos.x, y: pos.y - this.elements[0][0].size.center });
this.elements[0][1].setPosition({x: pos.x + this.elements[0][0].size.width + this.dW, y: pos.y + this.shiftDegree - this.size.center});
}
old_CDegreeOrdinary.prototype.old_findDisposition = function( mCoord )
{
var posCurs = null, mouseCoord = null, inside_flag = -1;
if( mCoord.x < this.elements[0][0].size.width )
{
if( this.elements[0][0].IsJustDraw() )
{
posCurs = {x: 0, y: 1};
mouseCoord = {x: 0, y: mCoord.y - this.shiftDegree};
inside_flag = 0;
}
else
{
posCurs = {x: 0, y: 0};
mouseCoord = {x: mCoord.x, y: mCoord.y - ( this.size.center - this.elements[0][0].size.center)};
inside_flag = -1;
}
}
else if(mCoord.x < (this.elements[0][0].size.width + this.dW ) )
{
posCurs = {x:0, y:1};
mouseCoord = {x: 0, y: mCoord.y - this.shiftDegree};
inside_flag = 0;
}
else
{
posCurs = {x:0, y:1};
mouseCoord = {x: mCoord.x - (this.elements[0][0].size.width + this.dW ), y: mCoord.y - this.shiftDegree};
inside_flag = -1;
}
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
old_CDegreeOrdinary.prototype.findDisposition = function( mCoord )
{
var coordX, coordY;
var X, Y;
var inside_flag = -1;
if( mCoord.x < this.elements[0][0].size.width)
{
if( this.elements[0][0].IsJustDraw() )
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 0;
}
else
{
X = 0; Y = 0; // встаем в первый элемент
coordX = mCoord.x;
coordY = mCoord.y - ( this.size.center - this.elements[0][0].size.center);
}
}
else if(mCoord.x < (this.elements[0][0].size.width + this.dW ))
{
X = 0; Y = 1; // встаем во второй элемент
coordX = 0;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 0;
}
else if(mCoord.x > this.size.width)
{
X = 0; Y = 1; // встаем во второй элемент
coordX = this.size.width;
coordY = mCoord.y - this.shiftDegree;
inside_flag = 1;
}
else
{
X = 0; Y = 1; // встаем во второй элемент
coordX = mCoord.x - (this.elements[0][0].size.width + this.dW);
coordY = mCoord.y - this.shiftDegree;
}
if(coordY < 0)
{
coordY = 0;
inside_flag = 2;
}
else if(coordY > this.elements[X][Y].size.height)
{
coordY = this.elements[X][Y].size.height;
inside_flag = 2;
}
var mCoord = {x: coordX, y: coordY};
return {pos: {x: X, y: Y}, mCoord: mCoord, inside_flag: inside_flag};
}
old_CDegreeOrdinary.prototype.getIterator = function()
{
return this.elements[0][1];
}
old_CDegreeOrdinary.prototype.getUpperIterator = function()
{
return this.elements[0][1];
}
old_CDegreeOrdinary.prototype.getLowerIterator = function()
{
return this.elements[0][1];
}
old_CDegreeOrdinary.prototype.getBase = function()
{
return this.elements[0][0];
}
function CIterators()
{
......
......@@ -660,7 +660,7 @@ CDocument.prototype =
//var StartTime = new Date().getTime();
//**
MathComposition.RecalculateComposition();
MathComposition.RecalculateComposition_2(g_oTextMeasurer);
//**
if ( true === this.TurnOffRecalc )
......@@ -1462,7 +1462,7 @@ CDocument.prototype =
nPageIndex = this.CurPage;
if(nPageIndex === 0)
MathComposition.Draw_2(21.5, 25.3, pGraphics);
MathComposition.Draw(21.5, 25.3, pGraphics);
//MathComposition.Draw(pGraphics);
......
......@@ -7186,14 +7186,8 @@ asc_docs_api.prototype.asc_getChartObject = function()
this.isChartEditor = true; // Для совместного редактирования
var graphicObject = this.WordControl.m_oLogicDocument.Get_ChartObject();
var oColor, oNewColor;
for (var i = 0; i < this.WordControl.m_oDrawingDocument.GuiControlColorsMap.length; i++) {
oColor = this.WordControl.m_oDrawingDocument.GuiControlColorsMap[i];
oNewColor = new CRGBColor();
oNewColor.RGBA.R = oColor.r;
oNewColor.RGBA.G = oColor.g;
oNewColor.RGBA.B = oColor.b;
graphicObject.chart.themeColors.push(oNewColor);
graphicObject.chart.themeColors.push( this.WordControl.m_oDrawingDocument.GuiControlColorsMap[i].get_hex() );
}
return graphicObject;
}
......
......@@ -15,9 +15,11 @@
//При добавлении в началло контента элемента , он вставляется с размером шрифта 11, посмотреть getCurrRunPrp
// При удаление из начала контента элемента, у всех остальных автоматом 11 размер шрифта
/// TODO (завтра)
// 1. протащить через все recalculateSize oMeasure
// 2. убрать slashWidth
/// TODO (tomorrow)
/// TODO (послезавтра)
// !!! Проверить типы для groupCharacter, delimiters и accent
// 1. Посмотреть стрелки и прочее для delimiters (которые используются для accent), при необходимости привести к одному типу
......@@ -4145,21 +4147,21 @@ CMathContent.prototype =
this.update_widthContent(); /// !!!!
},
RecalculateReverse: function()
RecalculateReverse: function(oMeasure)
{
// for add component, set Txt Properties
var start = this.rInterval.startPos,
end = this.rInterval.endPos;
for(var i = start; i < end; i++)
this.content[i].value.Resize();
this.content[i].value.Resize(oMeasure);
this.rInterval.startPos = this.rInterval.endPos = this.CurPos;
this.recalculateSize();
if(! this.bRoot )
this.Parent.RecalculateReverse();
this.Parent.RecalculateReverse(oMeasure);
},
Resize: function() // for "read"
Resize: function(oMeasure) // пересчитываем всю формулу
{
var bItalic = true;
......@@ -4170,11 +4172,11 @@ CMathContent.prototype =
if(type == MATH_TEXT)
{
this.content[i].value.setMText(bItalic);
this.content[i].value.recalculateSize();
this.content[i].value.resize(oMeasure);
}
else if(type == MATH_COMP)
{
this.content[i].value.Resize();
this.content[i].value.Resize(oMeasure);
}
else if(type == MATH_RUN_PRP)
{
......@@ -4201,7 +4203,7 @@ CMathContent.prototype =
txtPrp.Italic = false;
g_oTextMeasurer.SetFont(txtPrp);
this.content[i].value.recalculateSize();
this.content[i].value.resize(oMeasure);
}
}
}
......@@ -5808,7 +5810,7 @@ CMathContent.prototype =
{
// временно
//this.RecalculateReverse();
this.Root.Resize();
//this.Root.Resize();
},
_Check_HistoryUninon: function(Data1, Data2)
{
......@@ -5879,6 +5881,9 @@ function CMathComposition()
}
CMathComposition.prototype =
{
// сделать глобальную булевскую переменную для того, чтобы запоминать нужен пересчет контента или нет
// необходима тк на backspace может не быть реального удаления переменных, а только селект
Init: function()
{
// TODO
......@@ -5908,7 +5913,10 @@ CMathComposition.prototype =
{
return this.DefaultTxtPrp;
},
Draw: function(pGraphics)
//TODO
// переделать Draw (для режима редактирования передавать координату для отрисовки формулы) !!
// position вычислить естественно до того, как придет Draw, чтобы не пришлось пересчитывать при изменении в тексте документа
Draw_2: function(pGraphics)
{
if(this.Root.content.length > 1)
{
......@@ -5927,7 +5935,7 @@ CMathComposition.prototype =
this.Root.draw(pGraphics);
},
Draw_2: function(x, y, pGraphics)
Draw: function(x, y, pGraphics)
{
if(this.Root.content.length > 1)
{
......@@ -6063,7 +6071,7 @@ CMathComposition.prototype =
// временно
//this.CurrentContent.RecalculateReverse();
this.Root.Resize();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
}
......@@ -6081,13 +6089,13 @@ CMathComposition.prototype =
this.pos = pos;
this.Root.setPosition(this.pos);
},
RecalculateReverse: function() // for edit
RecalculateReverse: function(oMeasure) // for edit
{
this.SelectContent.RecalculateReverse();
this.SelectContent.RecalculateReverse(oMeasure);
},
Resize: function()
Resize: function(oMeasure)
{
this.Root.Resize();
this.Root.Resize(oMeasure);
},
//// edit ////
AddLetter: function(code)
......@@ -6109,7 +6117,7 @@ CMathComposition.prototype =
// временно
//this.RecalculateReverse();
this.Root.Resize();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
///
......@@ -6146,7 +6154,8 @@ CMathComposition.prototype =
///
// временно
//this.RecalculateReverse();
this.Root.Resize();
//this.Root.Resize();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
///
......@@ -6191,7 +6200,8 @@ CMathComposition.prototype =
this.ClearSelect();
// временно
//this.RecalculateReverse();
this.Root.Resize();
//this.Root.Resize();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
var stackSelect = Common_CopyObj(State.Select.stack),
......@@ -6358,7 +6368,8 @@ CMathComposition.prototype =
// временно
//this.RecalculateReverse();
this.Root.Resize();
//this.Root.Resize();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
//this.SelectContent.drawSelect();
this.CheckTarget();
......@@ -6440,7 +6451,7 @@ CMathComposition.prototype =
if(e.CtrlKey == true && e.KeyCode == 81)
{
simulatorMComposition(MATH_READ);
simulatorMComposition(this, MATH_READ);
return false;
}
......@@ -6504,19 +6515,36 @@ CMathComposition.prototype =
// временно
//this.RecalculateReverse();
//this.Root.Resize();
this.Resize(g_oTextMeasurer);
this.UpdatePosition();
},
RecalculateComposition: function()
RecalculateComposition_2: function(oMeasure)
{
//this.Root.setTxtPrp(this.TxtPrp);
//this.SetReferenceComposition();
this.Root.Resize();
this.Root.Resize(oMeasure);
this.Root.setPosition(this.pos);
this.UpdateCursor();
},
RecalculateComposition_2: function()
RecalculateComposition: function(oMeasure, TextPr) // textPrp в тестовом режиме, просто отрисуем с ними формулу
{
this.Root.Resize();
////* test *////
/*var textPrp = new TextPr();
this.DefaultTxtPrp.FontSize = 11;
textPrp.Marge(this.DefaultTxtPrp);
textPrp.Merge(TextPr);
this.DefaultTxtPrp = textPrp;*/
///////////////////////
this.Root.Resize(oMeasure); // пересчитываем всю формулу
var width = this.Root.size.width,
height = this.Root.size.height;
return {Width: width, Height: height, WidthVisible: width };
},
SetReferenceComposition: function()
{
......@@ -6542,6 +6570,7 @@ CMathComposition.prototype =
}
function CEmpty()
{
this.typeObj = MATH_EMPTY;
......@@ -6569,7 +6598,6 @@ function CEmpty()
this.getRunPrp = function() {return this.TxtPrp; };
this.setOwnTPrp = function() {};*/
this.relate = function() {};
}
function CRun()
......@@ -6596,8 +6624,6 @@ CRun.prototype =
{
return MATH_RUN;
},
setTxtPrp: function(oRunPrp)
{
this.txtPrp = oRunPrp.getTextPrp();
......@@ -6612,11 +6638,12 @@ CRun.prototype =
}
}
function TEST_COMPOSITION()
function TEST_MATH_EDIT()
{
//MathComposition.test_for_edit();
MathComposition.test_for_edit_2();
MathComposition.RecalculateComposition_2();
MathComposition.test_for_edit();
MathComposition.RecalculateComposition(g_oTextMeasurer, MathComposition.DefaultTxtPrp);
//MathComposition.Draw_2(x, y, )
......
......@@ -141,49 +141,11 @@ CMathText.prototype =
this.typeObj = MATH_PLACEHOLDER;
this.value = StartTextElement;
},
/*old_getTxtPrp: function()
{
var txtPrp = this.Parent.getTxtPrp();
txtPrp.Merge(this.textPrp);
var reduct = this.Parent.getReduct(); // чтобы не перекрывать
txtPrp.FontSize *= reduct;
//txtPrp.FontSize *= this.Parent.getReduct(); // чтобы не перекрывать
//txtPrp.Italic = false; // всегда отправляем "false"!!
return txtPrp;
},*/
/*setTxtPrp: function(txtPrp)
{
this.TxtPrp = new CMathTextPrp();
this.TxtPrp.Merge(txtPrp);
},
setOwnTPrp: function(txtPrp)
{
this.OwnTPrp.Merge(txtPrp);
},*/
setLIterator: function(bIterator)
{
this.bIterator = bIterator; // символы другие , чуть толще
},
/*getRunPrp: function()
{
return this.TxtPrp;
},
getTxtPrp: function()
{
var txtPrp = new CMathTextPrp();
txtPrp.Merge(this.TxtPrp);
txtPrp.Merge(this.OwnTPrp);
return txtPrp ;
},
getOwnTPrp: function()
{
return this.textPrp;
},*/
// ascent = Symbol.Ascent // = Placeholder.Ascent (= Placeholder.Height)
// descent = FontAscent - Placeholder.Height (FontAscent = FontHeight - FontDescent)
......@@ -220,6 +182,25 @@ CMathText.prototype =
var _cent = placeholder.Height*0.375;
var HH = g_oTextMeasurer.GetHeight();*/
this.size = {width: _width, widthG: widthG, height: _height, center: _center, ascent: _ascent, descent: _descent};
},
resize: function(oMeasure)
{
var letter = this.getCode();
var metricsTxt = oMeasure.Measure2Code(letter);
var _width = metricsTxt.Width;
var _ascent = metricsTxt.Ascent;
var _descent = (metricsTxt.Height - metricsTxt.Ascent);
var _height = _ascent + _descent;
var widthG = metricsTxt.WidthG;
// TODO
// убрать это смещение
var _center = _ascent - 0.2487852283770651*oMeasure.GetHeight(); // смещаем центр
this.size = {width: _width, widthG: widthG, height: _height, center: _center, ascent: _ascent, descent: _descent};
},
old_draw: function()
......@@ -320,14 +301,14 @@ CMathText.prototype =
//pGraphics.FillTextCode(xx, yy , this.value);
},
old_setPosition: function(pos)
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)
new_setPosition: function(pos)
{
this.pos = {x: pos.x , y: pos.y};
},
......@@ -360,9 +341,9 @@ CMathText.prototype =
this.size.center = this.size.center*(this.transform.sy + this.transform.shy);*/
},
Resize: function()
Resize: function(oMeasure)
{
this.recalculateSize();
this.resize(oMeasure);
},
IsJustDraw: function()
{
......
......@@ -81,8 +81,9 @@ var DOUBLE_LEFT_ARROW = 21;
var DOUBLE_RIGHT_ARROW = 22;
var DOUBLE_ARROW_LR = 23;
var DELIM_OPERATOR = 0;
var DELIM_SEPARATOR = 1;
var OPER_DELIMITER = 0;
var OPER_SEPARATOR = 1;
var OPER_GROUP_CHAR = 2;
var TURN_0 = 0;
......
This diff is collapsed.
This diff is collapsed.
......@@ -446,252 +446,4 @@ CRadical.prototype.getPropsForWhite = function()
return props;
}
function old_CRadical()
{
this.signRadical = null;
CMathBase.call(this);
}
extend(old_CRadical, CMathBase);
old_CRadical.prototype.init = function()
{
this.setDimension(1, 1);
this.setContent();
this.signRadical = new CSignRadical();
this.signRadical.relate(this);
}
old_CRadical.prototype.recalculateSize = function()
{
this.signRadical.recalculateSize();
var sign = this.signRadical.size;
var arg = this.elements[0][0].size;
var height = sign.height,
width = sign.width,
center = (height - arg.height)*0.6 + arg.center;
this.size = {width: width, height: height, center: center};
}
old_CRadical.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
this.gapLeft = this.size.width - this.elements[0][0].size.width;
this.gapTop = this.size.center - this.elements[0][0].size.center;
var x = this.pos.x + this.gapLeft,
y = this.pos.y + this.gapTop;
this.signRadical.setPosition(this.pos);
this.elements[0][0].setPosition({x: x, y: y });
}
old_CRadical.prototype.findDisposition = function(mCoord)
{
var sizeBase = this.elements[0][0].size;
var X, Y;
var inside_flag = -1;
if(mCoord.x < this.gapLeft)
{
X = 0;
inside_flag = 0;
}
else if(mCoord.x > this.gapLeft + sizeBase.width)
{
X = sizeBase.width;
inside_flag = 1;
}
else
X = mCoord.x - this.gapLeft;
if(mCoord.y < this.gapTop)
{
Y = 0;
inside_flag = 2;
}
else if(mCoord.y > this.gapTop + sizeBase.height)
{
Y = sizeBase.height;
inside_flag = 2;
}
else
Y = mCoord.y - this.gapTop;
return {pos: {x:0, y:0}, mCoord: {x: X, y: Y}, inside_flag: inside_flag};
}
old_CRadical.prototype.draw = function()
{
this.elements[0][0].draw();
this.signRadical.draw();
}
old_CRadical.prototype.getBase = function()
{
return this.elements[0][0];
}
function old_CDegreeRadical()
{
this.signRadical = null;
this.gap = null;
this.topDegr = null;
CMathBase.call(this);
}
extend(old_CDegreeRadical, CMathBase);
old_CDegreeRadical.prototype.init = function()
{
this.setDimension(1, 2);
this.signRadical = new CSignRadical();
this.signRadical.relate(this);
var oBase = new CMathContent();
var oDegree = new CMathContent();
oDegree.setReduct(DEGR_REDUCT);
this.addMCToContent(oDegree, oBase);
}
old_CDegreeRadical.prototype.recalculateSize = function()
{
this.signRadical.recalculateSize();
var degr = this.elements[0][0].size,
base = this.elements[0][1].size,
sign = this.signRadical.size;
var wTick = this.signRadical.sizeTick.width,
hTick = this.signRadical.sizeTick.height;
var width = degr.width - wTick + sign.width;
var txtPrp = this.getTxtPrp();
var plH = 9.877777777777776 * txtPrp.FontSize /36;
if( sign.height < plH )
this.gap = 1.5*txtPrp.FontSize/36;
else
this.gap = 3.5*txtPrp.FontSize/36;
var h1 = degr.height + this.gap + hTick,
h2 = sign.height;
var height, center;
if(h1 > h2)
{
height = h1;
center = h1 - h2 + (sign.height - base.height)*0.6 + base.center;
}
else
{
height = h2;
center = (sign.height - base.height)*0.6 + base.center;
}
this.size = {width: width, height: height, center: center};
}
old_CDegreeRadical.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.center};
var degr = this.elements[0][0].size,
base = this.elements[0][1].size,
sign = this.signRadical.size;
var hDg = degr.height + this.gap + this.signRadical.sizeTick.height;
this.topDegr = this.size.height - hDg;
var x1 = this.pos.x,
y1 = this.pos.y + this.topDegr;
this.elements[0][0].setPosition({x: x1, y: y1});
var x2 = this.pos.x + degr.width - this.signRadical.sizeTick.width,
y2 = this.pos.y + this.size.height - sign.height;
this.signRadical.setPosition({x: x2, y: y2});
var x3 = this.pos.x + this.size.width - base.width,
y3 = this.pos.y + this.size.center - base.center;
this.elements[0][1].setPosition({x: x3, y: y3});
}
old_CDegreeRadical.prototype.draw = function(pGraphics)
{
this.signRadical.draw();
old_CDegreeRadical.superclass.draw.call(this, pGraphics);
}
old_CDegreeRadical.prototype.findDisposition = function(mCoord)
{
var mouseCoord = {x: null, y: null},
posCurs = {x: 0, y: null},
inside_flag = -1;
var degr = this.elements[0][0].size,
base = this.elements[0][1].size;
if(mCoord.x < this.size.width - base.width)
{
posCurs.y = 0;
if(mCoord.x > degr.width)
{
mouseCoord.x = degr.width;
inside_flag = 1;
}
else
{
mouseCoord.x = mCoord.x;
}
mouseCoord.x = mCoord.x;
if(mCoord.y < this.topDegr)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > degr.height + this.topDegr)
{
mouseCoord.y = degr.height;
inside_flag = 2;
}
else
{
mouseCoord.y = mCoord.y - this.topDegr;
}
}
else
{
posCurs.y = 1;
mouseCoord.x = mCoord.x - (this.size.width - base.width);
var topBase = this.size.center - base.center;
if(mCoord.y < topBase)
{
mouseCoord.y = 0;
inside_flag = 2;
}
else if(mCoord.y > base.height + topBase)
{
mouseCoord.y = base.height;
inside_flag = 2;
}
else
mouseCoord.y = mCoord.y - topBase;
}
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
}
old_CDegreeRadical.prototype.getBase = function()
{
return this.elements[0][1];
}
old_CDegreeRadical.prototype.getDegree = function()
{
return this.elements[0][0];
}
......@@ -22,69 +22,3 @@ CSubMathBase.prototype.mouseMove = function( mCoord )
return {state: state, SelectContent: SelectContent};
}
function old_CSubMathBase(countRow, countCol)
{
CMathBase.call(this, countRow, countCol );
}
extend(old_CSubMathBase, CMathBase);
/*old_CSubMathBase.prototype.remove = function()
{
var result = this.elements[this.CurPos_X][this.CurPos_Y].remove();
this.recalculateSize();
return result;
}*/
//выставим позиции каждого элемента, для того, чтобы не вычесть лишний раз "центр" объекта
/*old_CSubMathBase.prototype.setPosition = function(pos)
{
this.pos = pos;
var w = 0;
var h = 0;
var maxWH = this.getWidthsHeights();
for(var i=0; i < this.nRow; i++)
{
w = 0;
for(var j = 0 ; j < this.nCol; j++)
{
this.elements[i][j].setPosition( {x: this.pos.x + this.dW*j + w , y: this.pos.y + this.dH*i + h } );
w += maxWH.widths[j];
}
h += maxWH.heights[i];
}
}*/
old_CSubMathBase.prototype.old_mouseMove = function( mCoord )
{
var res = true;
var elem = this.findDisposition( mCoord);
if(elem.pos.x == this.CurPos_X && elem.pos.y == this.CurPos_Y && elem.inside_flag === -1 )
res = this.elements[this.CurPos_X][this.CurPos_Y].mouseMove(elem.mCoord);
else
res = false;
return res;
}
old_CSubMathBase.prototype.mouseMove = function( mCoord )
{
var elem = this.findDisposition( mCoord);
var state = true,
SelectContent = null;
if(elem.pos.x == this.CurPos_X && elem.pos.y == this.CurPos_Y && elem.inside_flag === -1 )
{
movement = this.elements[this.CurPos_X][this.CurPos_Y].mouseMove(elem.mCoord);
SelectContent = movement.SelectContent;
state = movement.state;
}
else
{
state = false;
}
return {state: state, SelectContent: SelectContent};
}
\ No newline at end of file
......@@ -253,7 +253,7 @@ function simulatorMComposition( MComposition, ttype)
function RecalculateMComposition(MComposition)
{
MComposition.RecalculateComposition();
MComposition.RecalculateComposition_2(g_oTextMeasurer);
editor.WordControl.m_oLogicDocument.DrawingDocument.OnRecalculatePage(0, { Width : Page_Width, Height : Page_Height, Margins : {
Left : X_Left_Field,
......@@ -302,7 +302,7 @@ function addToContent_ForRead(content, elem, props, ctrPrp)
{
if(elem.typeObj == MATH_COMP)
{
elem.Resize();
elem.Resize(g_oTextMeasurer);
}
}
catch(e)
......
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