Commit 0350c8e8 authored by Anna.Pavlova's avatar Anna.Pavlova

1. Прокинула свойства для элементов : fraction, degree, degreeSubSup radical,...

1. Прокинула свойства для элементов : fraction, degree, degreeSubSup radical, N-ary, accent, delimiters (для чтения)
2. Исправила баг при удалении: когда удаляли контент из начала контента, неправильно выставлялся курсор (перед RunPrp), текст из-за этого не отображался
3. Исправила баг при добавлении мат. элемента, не добавлялись RunPrp для текста 
4. Для n-арных операторов добавила возможность вместо n-арного оператора отрисовать любую букву
5. Поправила баг с расстоянием для n-арных операторов с один оператором (они не отрисовывались)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52120 954022d7-b5bf-4e40-9824-e11837661b57
parent 2db459ef
...@@ -597,6 +597,10 @@ CSign.prototype.relate = function(parent) ...@@ -597,6 +597,10 @@ CSign.prototype.relate = function(parent)
{ {
this.Parent = parent; this.Parent = parent;
} }
CSign.prototype.getCodeAccent = function()
{
return this.sign.value;
}
function old_CAccent() function old_CAccent()
{ {
...@@ -845,7 +849,8 @@ CAccent.prototype.draw = function() ...@@ -845,7 +849,8 @@ CAccent.prototype.draw = function()
function CAccent() function CAccent()
{ {
this. type = null; this.code = null; // храним код буквы и тип здесь
this. type = null; // т.к в класах, которые вызываем, не учитываем случаи, когда элементы (стрелки/скобки) переворачиваются
this.loc = LOCATION_TOP; this.loc = LOCATION_TOP;
CCharacter.call(this); CCharacter.call(this);
} }
...@@ -880,6 +885,7 @@ CAccent.prototype.init = function(props) ...@@ -880,6 +885,7 @@ CAccent.prototype.init = function(props)
if(code === 0x302 || type === ACCENT_CIRCUMFLEX) if(code === 0x302 || type === ACCENT_CIRCUMFLEX)
{ {
this.type = ACCENT_CIRCUMFLEX; this.type = ACCENT_CIRCUMFLEX;
this.code = 0x302;
accent = new CCircumflex(); accent = new CCircumflex();
accent.setTurn(TURN_0); accent.setTurn(TURN_0);
...@@ -887,6 +893,7 @@ CAccent.prototype.init = function(props) ...@@ -887,6 +893,7 @@ CAccent.prototype.init = function(props)
else if(code === 0x30C || type === ACCENT_COMB_CARON) else if(code === 0x30C || type === ACCENT_COMB_CARON)
{ {
this.type = ACCENT_COMB_CARON; this.type = ACCENT_COMB_CARON;
this.code = 0x30C;
accent = new CCircumflex(); accent = new CCircumflex();
accent.setTurn(TURN_MIRROR_0); accent.setTurn(TURN_MIRROR_0);
...@@ -894,24 +901,28 @@ CAccent.prototype.init = function(props) ...@@ -894,24 +901,28 @@ CAccent.prototype.init = function(props)
else if(code === 0x332 || type === ACCENT_LINE) else if(code === 0x332 || type === ACCENT_LINE)
{ {
this.type = ACCENT_LINE; this.type = ACCENT_LINE;
this.code = 0x332;
accent = new CLine(); accent = new CLine();
} }
else if(code === 0x333 || type === ACCENT_DOUBLE_LINE) else if(code === 0x333 || type === ACCENT_DOUBLE_LINE)
{ {
this.type = ACCENT_DOUBLE_LINE; this.type = ACCENT_DOUBLE_LINE;
this.code = 0x333;
accent = new CDoubleLine(); accent = new CDoubleLine();
} }
else if(code === 0x303 || type === ACCENT_TILDE) else if(code === 0x303 || type === ACCENT_TILDE)
{ {
this.type = ACCENT_TILDE; this.type = ACCENT_TILDE;
this.code = 0x303;
accent = new CTilde(); accent = new CTilde();
} }
else if(code === 0x306 || type === ACCENT_BREVE) else if(code === 0x306 || type === ACCENT_BREVE)
{ {
this.type = ACCENT_BREVE; this.type = ACCENT_BREVE;
this.code = 0x306;
accent = new CBreve(); accent = new CBreve();
accent.setTurn(TURN_MIRROR_0); accent.setTurn(TURN_MIRROR_0);
...@@ -919,6 +930,7 @@ CAccent.prototype.init = function(props) ...@@ -919,6 +930,7 @@ CAccent.prototype.init = function(props)
else if(code == 0x311 || type == ACCENT_INVERT_BREVE) else if(code == 0x311 || type == ACCENT_INVERT_BREVE)
{ {
this.type = ACCENT_INVERT_BREVE; this.type = ACCENT_INVERT_BREVE;
this.code = 0x311;
accent = new CBreve(); accent = new CBreve();
accent.setTurn(TURN_0); accent.setTurn(TURN_0);
...@@ -926,141 +938,152 @@ CAccent.prototype.init = function(props) ...@@ -926,141 +938,152 @@ CAccent.prototype.init = function(props)
else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT) else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
{ {
this.type = ACCENT_ARROW_LEFT; this.type = ACCENT_ARROW_LEFT;
this.code = 0x20D6;
glyph = new CCombiningArrow(); glyph = new CCombiningArrow();
props = var prp =
{ {
location: LOCATION_TOP, location: LOCATION_TOP,
turn: TURN_0 turn: TURN_0
}; };
glyph.init(props); glyph.init(prp);
accent = new COperator(glyph); accent = new COperator(glyph);
} }
else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT) else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
{ {
this.type = ACCENT_ARROW_RIGHT; this.type = ACCENT_ARROW_RIGHT;
this.code = 0x20D7;
glyph = new CCombiningArrow(); glyph = new CCombiningArrow();
props = var prp =
{ {
location: LOCATION_TOP, location: LOCATION_TOP,
turn: TURN_180 turn: TURN_180
}; };
glyph.init(props); glyph.init(prp);
accent = new COperator(glyph); accent = new COperator(glyph);
} }
else if(code === 0x20E1 || type === ACCENT_ARROW_LR) else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
{ {
this.type = ACCENT_ARROW_LR; this.type = ACCENT_ARROW_LR;
this.code = 0x20E1;
glyph = new CCombining_LR_Arrow(); glyph = new CCombining_LR_Arrow();
props = var prp =
{ {
location: LOCATION_TOP, location: LOCATION_TOP,
turn: TURN_0 turn: TURN_0
}; };
glyph.init(props); glyph.init(prp);
accent = new COperator(glyph); accent = new COperator(glyph);
} }
else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT) else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
{ {
this.type = ACCENT_HALF_ARROW_LEFT; this.type = ACCENT_HALF_ARROW_LEFT;
this.code = 0x20D0;
glyph = new CCombiningHalfArrow(); glyph = new CCombiningHalfArrow();
props = var prp =
{ {
location: LOCATION_TOP, location: LOCATION_TOP,
turn: TURN_0 turn: TURN_0
}; };
glyph.init(props); glyph.init(prp);
accent = new COperator(glyph); accent = new COperator(glyph);
} }
else if(code === 0x20D1 || type === ACCENT_HALF_ARROW_RIGHT) else if(code === 0x20D1 || type === ACCENT_HALF_ARROW_RIGHT)
{ {
this.type = ACCENT_HALF_ARROW_RIGHT; this.type = ACCENT_HALF_ARROW_RIGHT;
this.code = 0x20D1;
glyph = new CCombiningHalfArrow(); glyph = new CCombiningHalfArrow();
props = var prp =
{ {
location: LOCATION_TOP, location: LOCATION_TOP,
turn: TURN_180 turn: TURN_180
}; };
glyph.init(props); glyph.init(prp);
accent = new COperator(glyph); accent = new COperator(glyph);
} }
///// group characters ///// ///// group characters /////
else if(code === 0x2190 || type === ARROW_LEFT) else if(code === 0x2190 || type === ARROW_LEFT)
{ {
this.type = ARROW_LEFT; this.type = ARROW_LEFT;
this.code = 0x2190;
glyph = new CSingleArrow(); glyph = new CSingleArrow();
props = var prp =
{ {
location: this.loc, location: this.loc,
turn: TURN_0 turn: TURN_0
}; };
glyph.init(props); glyph.init(prp);
} }
else if(code === 0x2192 || type === ARROW_RIGHT) else if(code === 0x2192 || type === ARROW_RIGHT)
{ {
this.type = ARROW_RIGHT; this.type = ARROW_RIGHT;
this.code = 0x2192;
glyph = new CSingleArrow(); glyph = new CSingleArrow();
props = var prp =
{ {
location: this.loc, location: this.loc,
turn: TURN_180 turn: TURN_180
}; };
glyph.init(props); glyph.init(prp);
} }
else if(code === 0x2194 || type === ARROW_LR) else if(code === 0x2194 || type === ARROW_LR)
{ {
this.type = ARROW_LR; this.type = ARROW_LR;
this.code = 0x2194;
glyph = new CLeftRightArrow(); glyph = new CLeftRightArrow();
props = var prp =
{ {
location: this.loc, location: this.loc,
turn: TURN_0 turn: TURN_0
}; };
glyph.init(props); glyph.init(prp);
} }
else if(code === 0x21D0 || type === DOUBLE_LEFT_ARROW) else if(code === 0x21D0 || type === DOUBLE_LEFT_ARROW)
{ {
this.type = DOUBLE_LEFT_ARROW; this.type = DOUBLE_LEFT_ARROW;
this.code = 0x21D0;
glyph = new CDoubleArrow(); glyph = new CDoubleArrow();
props = var prp =
{ {
location: this.loc, location: this.loc,
turn: TURN_0 turn: TURN_0
}; };
glyph.init(props); glyph.init(prp);
} }
else if(code === 0x21D2 || type === DOUBLE_RIGHT_ARROW) else if(code === 0x21D2 || type === DOUBLE_RIGHT_ARROW)
{ {
this.type = DOUBLE_RIGHT_ARROW; this.type = DOUBLE_RIGHT_ARROW;
this.code = 0x21D2;
glyph = new CDoubleArrow(); glyph = new CDoubleArrow();
props = var prp =
{ {
location: this.loc, location: this.loc,
turn: TURN_180 turn: TURN_180
}; };
glyph.init(props); glyph.init(prp);
} }
else if(code === 0x21D4 || type === DOUBLE_ARROW_LR) else if(code === 0x21D4 || type === DOUBLE_ARROW_LR)
{ {
this.type = DOUBLE_ARROW_LR; this.type = DOUBLE_ARROW_LR;
this.code = 0x21D4;
glyph = new CLR_DoubleArrow(); glyph = new CLR_DoubleArrow();
props = var prp =
{ {
location: this.loc, location: this.loc,
turn: TURN_0 turn: TURN_0
}; };
glyph.init(props); glyph.init(prp);
} }
///// /////
else if(bCode || bType) else if(bCode || bType)
...@@ -1068,16 +1091,19 @@ CAccent.prototype.init = function(props) ...@@ -1068,16 +1091,19 @@ CAccent.prototype.init = function(props)
this.type = ACCENT_SIGN; this.type = ACCENT_SIGN;
accent = new CSign(); accent = new CSign();
var props = var prp =
{ {
type: type, type: type,
code: code code: code
}; };
accent.setSign(props); accent.setSign(prp);
this.code = accent.getCodeAccent();
} }
else else
{ {
this.type = ACCENT_COMB_CARON; this.type = ACCENT_COMB_CARON;
this.code = 0x30C;
accent = new CCircumflex(); accent = new CCircumflex();
accent.setTurn(TURN_MIRROR_0); accent.setTurn(TURN_MIRROR_0);
...@@ -1097,7 +1123,10 @@ CAccent.prototype.getCenter = function() ...@@ -1097,7 +1123,10 @@ CAccent.prototype.getCenter = function()
return center; return center;
} }
CAccent.prototype.getProps = function() CAccent.prototype.getPropsForWrite = function()
{ {
var prps = {}; var props = {};
props.chr = String.fromCharCode(this.code);
return props;
} }
...@@ -11,8 +11,13 @@ CDegree.prototype.init = function(props) ...@@ -11,8 +11,13 @@ CDegree.prototype.init = function(props)
} }
CDegree.prototype.init_2 = function(props, oBase) CDegree.prototype.init_2 = function(props, oBase)
{ {
if( typeof(props.type)!=="undefined"|| props.type !== null) /*if( typeof(props.type)!=="undefined"|| props.type !== null)
this.type = props.type; this.type = props.type;*/
if(props.type === DEGREE_SUPERSCRIPT)
this.type = DEGREE_SUPERSCRIPT;
else if(props.type === DEGREE_SUBSCRIPT)
this.type = DEGREE_SUBSCRIPT;
this.setDimension(1, 2); this.setDimension(1, 2);
...@@ -37,12 +42,12 @@ CDegree.prototype.recalculateSize = function() ...@@ -37,12 +42,12 @@ CDegree.prototype.recalculateSize = function()
_width += this.dW; _width += this.dW;
if(this.type === DEGREE_SUPERSCRIPT ) if(this.type === DEGREE_SUPERSCRIPT)
{ {
this.shiftDegree = 0; this.shiftDegree = 0;
_center = _height - (this.elements[0][0].size.height - this.elements[0][0].size.center); _center = _height - (this.elements[0][0].size.height - this.elements[0][0].size.center);
} }
else if(this.type === DEGREE_SUBSCRIPT ) else if(this.type === DEGREE_SUBSCRIPT)
{ {
this.shiftDegree = _height - this.elements[0][1].size.height; this.shiftDegree = _height - this.elements[0][1].size.height;
_center = this.elements[0][0].size.center; _center = this.elements[0][0].size.center;
...@@ -136,6 +141,13 @@ CDegree.prototype.getBase = function() ...@@ -136,6 +141,13 @@ CDegree.prototype.getBase = function()
{ {
return this.elements[0][0]; return this.elements[0][0];
} }
CDegree.prototype.getPropsForWrite = function()
{
var props = {};
props.type = this.type;
return props;
}
function old_CDegreeOrdinary() function old_CDegreeOrdinary()
{ {
...@@ -372,6 +384,7 @@ CIterators.prototype.getCtrPrp = function() ...@@ -372,6 +384,7 @@ CIterators.prototype.getCtrPrp = function()
function CDegreeSubSup() function CDegreeSubSup()
{ {
this.type = DEGREE_SubSup; this.type = DEGREE_SubSup;
this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
CSubMathBase.call(this); CSubMathBase.call(this);
} }
extend(CDegreeSubSup, CSubMathBase); extend(CDegreeSubSup, CSubMathBase);
...@@ -382,8 +395,18 @@ CDegreeSubSup.prototype.init = function(props) ...@@ -382,8 +395,18 @@ CDegreeSubSup.prototype.init = function(props)
} }
CDegreeSubSup.prototype.init_2 = function(props, oBase) CDegreeSubSup.prototype.init_2 = function(props, oBase)
{ {
if( typeof(props.type)!=="undefined"|| props.type !== null) /*if( typeof(props.type)!=="undefined"|| props.type !== null)
this.type = props.type; this.type = props.type;*/
if(props.type === DEGREE_SubSup)
this.type = DEGREE_SubSup;
else if(props.type === DEGREE_PreSubSup)
this.type = DEGREE_PreSubSup;
if(props.alnScr === true || props.alnScr === 1)
this.alnScr = true;
else if(props.alnScr === false || props.alnScr === 0)
this.alnScr = false;
this.setDimension(1, 2); this.setDimension(1, 2);
...@@ -404,6 +427,7 @@ CDegreeSubSup.prototype.init_2 = function(props, oBase) ...@@ -404,6 +427,7 @@ CDegreeSubSup.prototype.init_2 = function(props, oBase)
oIters.alignHor(-1, 1); oIters.alignHor(-1, 1);
this.addMCToContent(oIters, oBase); this.addMCToContent(oIters, oBase);
} }
} }
CDegreeSubSup.prototype.recalculateSize = function() CDegreeSubSup.prototype.recalculateSize = function()
{ {
...@@ -457,6 +481,15 @@ CDegreeSubSup.prototype.getLowerIterator = function() ...@@ -457,6 +481,15 @@ CDegreeSubSup.prototype.getLowerIterator = function()
return iter; return iter;
} }
CDegreeSubSup.prototype.getPropsForWrite = function()
{
var props = {};
props.type = this.type;
props.alnScr = this.alnScr;
return props;
}
//выяcнить: почему и с этой ф-ией и без нее работает всё ok... //выяcнить: почему и с этой ф-ией и без нее работает всё ok...
//всё ok, т.к. в контенте 2 элемента, и их center сравниваем //всё ok, т.к. в контенте 2 элемента, и их center сравниваем
......
...@@ -7,8 +7,17 @@ function CFraction() ...@@ -7,8 +7,17 @@ function CFraction()
extend(CFraction, CMathBase); extend(CFraction, CMathBase);
CFraction.prototype.init = function(props) CFraction.prototype.init = function(props)
{ {
if( typeof(props.type) !== "undefined" && props.type !== null ) var bValid = typeof(props.type) !== "undefined" && props.type !== null;
if(bValid)
{
var bBar = props.type === BAR_FRACTION || props.type === NO_BAR_FRACTION,
bSkew = props.type === SKEWED_FRACTION,
bLin = props.type === LINEAR_FRACTION;
if(bBar || bSkew || bLin) // на всякий случай
this.type = props.type; this.type = props.type;
}
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{ {
......
...@@ -60,7 +60,6 @@ CLimit.prototype.init = function(props) ...@@ -60,7 +60,6 @@ CLimit.prototype.init = function(props)
this.setDimension(2, 1); this.setDimension(2, 1);
var oBase = new CMathContent(); var oBase = new CMathContent();
//oBase.setOwnTPrp({Italic: false});
var oIter = new CMathContent(); var oIter = new CMathContent();
oIter.setReduct(DEGR_REDUCT); oIter.setReduct(DEGR_REDUCT);
...@@ -148,14 +147,6 @@ CMathFunc.prototype.init = function() ...@@ -148,14 +147,6 @@ CMathFunc.prototype.init = function()
{ {
this.setDimension(1, 2); this.setDimension(1, 2);
this.setContent(); this.setContent();
//var runPrp = new CTextPr();
//runPrp.Italic = false;
//this.elements[0][0].addToBeginningRPrp(runPrp);
//this.elements[0][0].setOwnTPrp({Italic: false}); // trigonometrical function
//this.elements[0][0].mergeTxtPrp({Italic: false}); // trigonometrical function
} }
CMathFunc.prototype.setDistance = function() CMathFunc.prototype.setDistance = function()
{ {
......
...@@ -18,17 +18,16 @@ ...@@ -18,17 +18,16 @@
/// TODO (tomorrow) /// TODO (tomorrow)
// !!! Проверить типы для groupCharacter, delimiters и accent
// 1. Посмотреть стрелки и прочее для delimiters (которые используются для accent), при необходимости привести к одному типу // 1. Посмотреть стрелки и прочее для delimiters (которые используются для accent), при необходимости привести к одному типу
// 2. Посмотреть дефолтовые значения для остальных мат. объектов // 2. Убрать ненужные(!!) setTxtPrp и getTxtPrp
// 3. Проверить что будет, если какие-то настройки убрать/добавить из ctrPrp, влияют ли они на отрисовку управляющих элементов (например, Italic, Bold)
// 4. Протестировать n-арные операторы, когда добавляется текст вместо оператора (mouseDown не работает, выровнено как alignTop)
var historyitem_Math_AddItem = 1; // Добавляем элемент var historyitem_Math_AddItem = 1; // Добавляем элемент
var historyitem_Math_RemoveItem = 2; // Удаляем элемент var historyitem_Math_RemoveItem = 2; // Удаляем элемент
var Test_Time = null;
var bool_Test_Shift = false;
var bool_Test_Ctr = false;
var bool_Test_V = false;
var TEST = true; var TEST = true;
var TEST_2 = true; var TEST_2 = true;
...@@ -67,18 +66,19 @@ function mathElem(val) ...@@ -67,18 +66,19 @@ function mathElem(val)
function CMathRunPrp() function CMathRunPrp()
{ {
this.typeObj = MATH_RUN_PRP; this.typeObj = MATH_RUN_PRP;
this.runPrp = new CTextPr(); this.textPrp = new CTextPr();
this.mathRunPrp = null;
this.size = {width: 0, height: 0, center: 0, ascent: 0}; this.size = {width: 0, height: 0, center: 0, ascent: 0};
} }
CMathRunPrp.prototype = CMathRunPrp.prototype =
{ {
Merge: function(rPrp) Merge: function(rPrp)
{ {
this.runPrp.Merge(rPrp); this.textPrp.Merge(rPrp);
}, },
getRunPrp: function() getTextPrp: function()
{ {
return this.runPrp; return this.textPrp;
}, },
getMathRunPrp: function() getMathRunPrp: function()
{ {
...@@ -518,7 +518,6 @@ CMathContent.prototype = ...@@ -518,7 +518,6 @@ CMathContent.prototype =
if(obj.typeObj === MATH_COMP) if(obj.typeObj === MATH_COMP)
this.addElementToContent( new CEmpty() ); this.addElementToContent( new CEmpty() );
//this.setStart_Selection(this.CurPos); //this.setStart_Selection(this.CurPos);
//this.selection.active = false; //this.selection.active = false;
}, },
...@@ -536,9 +535,6 @@ CMathContent.prototype = ...@@ -536,9 +535,6 @@ CMathContent.prototype =
if(!(bDef || bNum || bCont)) if(!(bDef || bNum || bCont))
shift = 0; shift = 0;
/*var runPrp = this.getRunPrp(this.CurPos);
element.setTxtPrp( runPrp );*/
var tmp = this.content.splice(0, this.CurPos + 1 + shift ); var tmp = this.content.splice(0, this.CurPos + 1 + shift );
tmp.push(elem); tmp.push(elem);
tmp = tmp.concat( this.content.splice(0, this.content.length) ); tmp = tmp.concat( this.content.splice(0, this.content.length) );
...@@ -3579,7 +3575,6 @@ CMathContent.prototype = ...@@ -3579,7 +3575,6 @@ CMathContent.prototype =
//placeholder.setTxtPrp(this.getTxtPrp()); //placeholder.setTxtPrp(this.getTxtPrp());
this.content.push( new mathElem( placeholder ) ); this.content.push( new mathElem( placeholder ) );
}, },
///////// перемещение ////////// ///////// перемещение //////////
...@@ -4183,7 +4178,7 @@ CMathContent.prototype = ...@@ -4183,7 +4178,7 @@ CMathContent.prototype =
} }
else if(type == MATH_RUN_PRP) else if(type == MATH_RUN_PRP)
{ {
var runPrp = this.content[i].value.getRunPrp(); var runPrp = this.content[i].value.getTextPrp();
var txtPrp = new CMathTextPrp(); var txtPrp = new CMathTextPrp();
txtPrp.Merge(DEFAULT_RUN_PRP); txtPrp.Merge(DEFAULT_RUN_PRP);
...@@ -4228,7 +4223,7 @@ CMathContent.prototype = ...@@ -4228,7 +4223,7 @@ CMathContent.prototype =
var rPrp = new CMathTextPrp(); var rPrp = new CMathTextPrp();
rPrp.Merge(DEFAULT_RUN_PRP); rPrp.Merge(DEFAULT_RUN_PRP);
rPrp.Merge( this.content[i].value.getRunPrp() ); rPrp.Merge( this.content[i].value.getTextPrp() );
rPrp.Italic = false; rPrp.Italic = false;
pGraphics.SetFont(rPrp); pGraphics.SetFont(rPrp);
...@@ -4444,16 +4439,16 @@ CMathContent.prototype = ...@@ -4444,16 +4439,16 @@ CMathContent.prototype =
next2_Type = this.CurPos + 2 < this.content.length ? this.content[this.CurPos + 2].value.typeObj : null, next2_Type = this.CurPos + 2 < this.content.length ? this.content[this.CurPos + 2].value.typeObj : null,
next3_Type = this.CurPos + 3 < this.content.length ? this.content[this.CurPos + 3].value.typeObj : null; next3_Type = this.CurPos + 3 < this.content.length ? this.content[this.CurPos + 3].value.typeObj : null;
var bDirectlyBegin = this.CurPos == 0 || (currType == MATH_EMPTY && this.CurPos == 1) && bMEDirect,
bReverseEnd = this.CurPos == this.content.length - 1 && bMEReverse;
var bNotRemove = bDirectlyBegin || bReverseEnd;
var bMEDirect = order == 1, var bMEDirect = order == 1,
bMEReverse = order == -1; bMEReverse = order == -1;
var bDirectlyBegin = this.CurPos == 0 || (currType == MATH_RUN_PRP && this.CurPos == 1) && bMEDirect, // Empty или RunPrp в начале, значит курсор в начале контента
bReverseEnd = this.CurPos == this.content.length - 1 && bMEReverse;
var bNotRemove = bDirectlyBegin || bReverseEnd && !bSelect;
// directly // directly
var bDirectly_CurrComp = bMEDirect && currType == MATH_EMPTY && prevType == MATH_COMP , var bDirectly_CurrComp = bMEDirect && currType == MATH_EMPTY && prevType == MATH_COMP,
bDirectly_RPrpComp = bMEDirect && currType == MATH_RUN_PRP && prevType == MATH_EMPTY && prev2_Type == MATH_COMP; bDirectly_RPrpComp = bMEDirect && currType == MATH_RUN_PRP && prevType == MATH_EMPTY && prev2_Type == MATH_COMP;
// reverse // reverse
...@@ -4566,17 +4561,7 @@ CMathContent.prototype = ...@@ -4566,17 +4561,7 @@ CMathContent.prototype =
var bDirRPrp = currType === MATH_RUN_PRP && bMEDirect, var bDirRPrp = currType === MATH_RUN_PRP && bMEDirect,
bRevRPrp = nextType === MATH_RUN_PRP && bMEReverse; bRevRPrp = nextType === MATH_RUN_PRP && bMEReverse;
if(bDirRPrp) // проверку на начало прошли if(bSelect)
{
start = this.CurPos - 1;
end = this.CurPos;
}
else if(bRevRPrp) // на всякий случай, может получится, что после удаления элемента, стоим после RunPrp
{
start = this.CurPos + 2;
end = this.CurPos + 3;
}
else if(bSelect)
{ {
start = this.selection.startPos; start = this.selection.startPos;
end = this.selection.endPos; end = this.selection.endPos;
...@@ -4589,6 +4574,17 @@ CMathContent.prototype = ...@@ -4589,6 +4574,17 @@ CMathContent.prototype =
end = tmp; end = tmp;
} }
} }
else if(bDirRPrp) // проверку на начало прошли, не формула (иначе бы зашли в ветку с bRemoveFormula)
{ // то есть стоим перед RunPrp, а слева текст и нет селекта
start = this.CurPos - 1;
end = this.CurPos;
}
else if(bRevRPrp) // на всякий случай, может получится, что после удаления элемента, стоим после RunPrp
{
start = this.CurPos + 2;
end = this.CurPos + 3;
}
else if(bMEReverse) else if(bMEReverse)
{ {
if(nextType == MATH_RUN_PRP && next3_Type !== MATH_TEXT) //единственная буква в Run if(nextType == MATH_RUN_PRP && next3_Type !== MATH_TEXT) //единственная буква в Run
...@@ -4627,7 +4623,12 @@ CMathContent.prototype = ...@@ -4627,7 +4623,12 @@ CMathContent.prototype =
} }
if(bSelect) if(bSelect)
{
this.CurPos = this.selection.startPos - 1; this.CurPos = this.selection.startPos - 1;
if(!this.IsEmpty() && this.CurPos == 0 && this.content[this.CurPos+1].value.typeObj === MATH_RUN_PRP) // если удалили мат. объект и стоим в начале, то поизиция курсор будет перед RunPrp, нужно после
this.CurPos++;
}
else if(bMEDirect) else if(bMEDirect)
this.CurPos -= end - start; this.CurPos -= end - start;
...@@ -4850,7 +4851,8 @@ CMathContent.prototype = ...@@ -4850,7 +4851,8 @@ CMathContent.prototype =
var bAfterRPrp = next2_Type == MATH_RUN_PRP, var bAfterRPrp = next2_Type == MATH_RUN_PRP,
bPrevTxt = prevType == MATH_TEXT; bPrevTxt = prevType == MATH_TEXT;
var bRemoveRPrp = bAfterRPrp && bPrevTxt; var bRemoveRPrp = bAfterRPrp && bPrevTxt; // удалить RunPrp нужно только в одном случае, если справо и слево текст, к которому применяются одни и те же RunPrp
// здесь делаем только проверку, находится ли текст перед формулой, и идут ли RunPrp после формулы
if(bMFormula) if(bMFormula)
{ {
...@@ -4863,9 +4865,9 @@ CMathContent.prototype = ...@@ -4863,9 +4865,9 @@ CMathContent.prototype =
{ {
if(this.content[i].value.typeObj === MATH_RUN_PRP) if(this.content[i].value.typeObj === MATH_RUN_PRP)
{ {
currRPrp = this.content[pos+2].value; var currTPrp = this.content[pos+2].value.getTextPrp();
prevRPrp = this.content[i].value; var prevTPrp = this.content[i].value.getTextPrp();
bSelectRunPrp = currRPrp.isEqual(currRPrp, prevRPrp); bSelectRunPrp = currTPrp.isEqual(currTPrp, prevTPrp);
break; break;
} }
} }
...@@ -5303,7 +5305,7 @@ CMathContent.prototype = ...@@ -5303,7 +5305,7 @@ CMathContent.prototype =
{ {
var run = new CRun(); var run = new CRun();
run.setRunPrp(this.content[i].value); run.setTxtPrp(this.content[i].value);
run.setMathRunPrp(this.content[i].value); run.setMathRunPrp(this.content[i].value);
while(this.content[i + 1].value.typeObj === MATH_TEXT) while(this.content[i + 1].value.typeObj === MATH_TEXT)
...@@ -5344,7 +5346,7 @@ CMathContent.prototype = ...@@ -5344,7 +5346,7 @@ CMathContent.prototype =
if(obj.typeObj == MATH_RUN_PRP) if(obj.typeObj == MATH_RUN_PRP)
{ {
runPrp.Merge(obj.getRunPrp()); runPrp.Merge(obj.getTextPrp());
break; break;
} }
else if(obj.typeObj == MATH_COMP) else if(obj.typeObj == MATH_COMP)
...@@ -5372,7 +5374,7 @@ CMathContent.prototype = ...@@ -5372,7 +5374,7 @@ CMathContent.prototype =
{ {
if(this.content[1].value.typeObj === MATH_RUN_PRP) // если первый объект - буква if(this.content[1].value.typeObj === MATH_RUN_PRP) // если первый объект - буква
{ {
var runPrp = this.content[1].value.getRunPrp(); var runPrp = this.content[1].value.getTextPrp();
txtPrp.Merge(runPrp); txtPrp.Merge(runPrp);
} }
else if(this.content[1].value.typeObj === MATH_COMP) else if(this.content[1].value.typeObj === MATH_COMP)
...@@ -5464,7 +5466,7 @@ CMathContent.prototype = ...@@ -5464,7 +5466,7 @@ CMathContent.prototype =
verifyRPrp_MC: function(rPrp) verifyRPrp_MC: function(rPrp)
{ {
// добавляем RunPrp для текста, они будут такие же как и ctrPrp // добавляем RunPrp для текста, они будут такие же как и ctrPrp
if(this.CurPos !== this.content.length - 1 && this.content[this.CurPos].value.typeObj == MATH_TEXT) // после того как добавили мат. объект, текущий объект не RunPrp, а текст if(this.CurPos !== this.content.length - 1 && this.content[this.CurPos].value.typeObj !== MATH_RUN_PRP) // после того как добавили мат. объект, текущий объект не RunPrp, а текст
{ {
var runPrp = Common_CopyObj(rPrp); var runPrp = Common_CopyObj(rPrp);
this.addRunPrp(runPrp); this.addRunPrp(runPrp);
...@@ -6550,7 +6552,7 @@ function CEmpty() ...@@ -6550,7 +6552,7 @@ function CEmpty()
function CRun() function CRun()
{ {
this.text = ""; this.text = "";
this.runPrp = null; this.txtPrp = null;
this.mathRunPrp = null; this.mathRunPrp = null;
} }
CRun.prototype = CRun.prototype =
...@@ -6561,7 +6563,7 @@ CRun.prototype = ...@@ -6561,7 +6563,7 @@ CRun.prototype =
}, },
getRunPrp: function() getRunPrp: function()
{ {
return this.runPrp; return this.txtPrp;
}, },
getMathRunPrp: function() getMathRunPrp: function()
{ {
...@@ -6573,9 +6575,9 @@ CRun.prototype = ...@@ -6573,9 +6575,9 @@ CRun.prototype =
}, },
setRunPrp: function(oRunPrp) setTxtPrp: function(oRunPrp)
{ {
this.runPrp = oRunPrp.getRunPrp(); this.txtPrp = oRunPrp.getTextPrp();
}, },
addLetter: function(oMText) addLetter: function(oMText)
{ {
......
...@@ -394,7 +394,12 @@ CMathText.prototype = ...@@ -394,7 +394,12 @@ CMathText.prototype =
setMText: function(flag) setMText: function(flag)
{ {
this.bMText = flag; this.bMText = flag;
} },
// заглушка для текста (для n-арных операторов, когда выставляется текст вместо оператора)
setComposition: function() // заглушка
{},
setReferenceComposition: function() // заглушка
{}
/*draw2: function() /*draw2: function()
{ {
......
...@@ -44,6 +44,7 @@ var NARY_UNION = 9; ...@@ -44,6 +44,7 @@ var NARY_UNION = 9;
var NARY_INTERSECTION = 10; var NARY_INTERSECTION = 10;
var NARY_LOGICAL_OR = 11; var NARY_LOGICAL_OR = 11;
var NARY_LOGICAL_AND = 12; var NARY_LOGICAL_AND = 12;
var NARY_TEXT_OPER = 13;
var NARY_UndOvr = 0; var NARY_UndOvr = 0;
var NARY_SubSup = 1; var NARY_SubSup = 1;
...@@ -80,6 +81,9 @@ var DOUBLE_LEFT_ARROW = 21; ...@@ -80,6 +81,9 @@ var DOUBLE_LEFT_ARROW = 21;
var DOUBLE_RIGHT_ARROW = 22; var DOUBLE_RIGHT_ARROW = 22;
var DOUBLE_ARROW_LR = 23; var DOUBLE_ARROW_LR = 23;
var DELIM_OPERATOR = 0;
var DELIM_SEPARATOR = 1;
var TURN_0 = 0; var TURN_0 = 0;
var TURN_180 = 1; var TURN_180 = 1;
...@@ -112,6 +116,7 @@ var ACCENT_ARROW_LR = 16; ...@@ -112,6 +116,7 @@ var ACCENT_ARROW_LR = 16;
var ACCENT_HALF_ARROW_LEFT = 17; var ACCENT_HALF_ARROW_LEFT = 17;
var ACCENT_HALF_ARROW_RIGHT = 18; var ACCENT_HALF_ARROW_RIGHT = 18;
var ACCENT_SIGN = 19; var ACCENT_SIGN = 19;
var ACCENT_TEXT = 20;
var BASEJC_CENTER = 0; var BASEJC_CENTER = 0;
var BASEJC_TOP = 1; var BASEJC_TOP = 1;
......
...@@ -36,11 +36,6 @@ function CMathMatrix() ...@@ -36,11 +36,6 @@ function CMathMatrix()
CMathBase.call(this); CMathBase.call(this);
} }
extend(CMathMatrix, CMathBase); extend(CMathMatrix, CMathBase);
CMathMatrix.prototype.old_init = function(countRow, countCol)
{
this.setDimension(countRow, countCol);
this.setContent();
}
CMathMatrix.prototype.init = function(props) CMathMatrix.prototype.init = function(props)
{ {
if(typeof(props.row) === "undefined" || props.row === null) if(typeof(props.row) === "undefined" || props.row === null)
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
function CNary() function CNary()
{ {
this.type = null;
this.code = null; // for "read"
this.grow = false;
this.supHide = false; this.supHide = false;
this.subHide = false; this.subHide = false;
this.limLoc = NARY_SubSup; this.limLoc = NARY_SubSup;
...@@ -21,13 +24,6 @@ function CNary() ...@@ -21,13 +24,6 @@ function CNary()
extend(CNary, CSubMathBase); extend(CNary, CSubMathBase);
CNary.prototype.init = function(props) CNary.prototype.init = function(props)
{ {
/*if(props.limLoc == "undOvr" || props.limLocType == NARY_UndOvr)
this.limLoc = 0;
else if(props.limLoc === "subSup"|| props.limLocType == NARY_SubSup)
this.limLoc = 1;
else
this.limLoc = 1;*/
if(props.limLoc == NARY_UndOvr) if(props.limLoc == NARY_UndOvr)
this.limLoc = NARY_UndOvr; this.limLoc = NARY_UndOvr;
else if(props.limLoc == NARY_SubSup) else if(props.limLoc == NARY_SubSup)
...@@ -39,41 +35,112 @@ CNary.prototype.init = function(props) ...@@ -39,41 +35,112 @@ CNary.prototype.init = function(props)
if(props.subHide === true || props.subHide === 1) if(props.subHide === true || props.subHide === 1)
this.subHide = true; this.subHide = true;
if(props.grow === true || props.grow === 1)
this.grow = true;
this.setDimension(1, 2); this.setDimension(1, 2);
var signChr, sign; var signCode, sign;
var bChr = false;
if(typeof(props.chr) === "string") if(typeof(props.chr) === "string")
signChr = props.chr.charCodeAt(0); {
signCode = props.chr.charCodeAt(0);
bChr = true;
}
if(signChr == 0x222B || props.signType == NARY_INTEGRAL) if(signCode == 0x222B || props.signType == NARY_INTEGRAL)
{
this.code = 0x222B;
this.type = NARY_INTEGRAL;
sign = new CIntegral(); sign = new CIntegral();
else if(signChr == 0x222C || props.signType == NARY_DOUBLE_INTEGRAL) }
else if(signCode == 0x222C || props.signType == NARY_DOUBLE_INTEGRAL)
{
this.code = 0x222C;
this.type = NARY_DOUBLE_INTEGRAL;
sign = new CDoubleIntegral(); sign = new CDoubleIntegral();
else if(signChr == 0x222D || props.signType == NARY_TRIPLE_INTEGRAL) }
else if(signCode == 0x222D || props.signType == NARY_TRIPLE_INTEGRAL)
{
this.code = 0x222D;
this.type = NARY_TRIPLE_INTEGRAL;
sign = new CTripleIntegral(); sign = new CTripleIntegral();
else if(signChr == 0x222E || props.signType == NARY_CONTOUR_INTEGRAL ) }
else if(signCode == 0x222E || props.signType == NARY_CONTOUR_INTEGRAL )
{
this.code = 0x222E;
this.type = NARY_CONTOUR_INTEGRAL;
sign = new CContourIntegral(); sign = new CContourIntegral();
else if(signChr == 0x222F || props.signType == NARY_SURFACE_INTEGRAL ) }
else if(signCode == 0x222F || props.signType == NARY_SURFACE_INTEGRAL )
{
this.code = 0x222F;
this.type = NARY_SURFACE_INTEGRAL;
sign = new CSurfaceIntegral(); sign = new CSurfaceIntegral();
else if(signChr == 0x2230 || props.signType == NARY_VOLUME_INTEGRAL) }
else if(signCode == 0x2230 || props.signType == NARY_VOLUME_INTEGRAL)
{
this.code = 0x2230;
this.type = NARY_VOLUME_INTEGRAL;
sign = new CVolumeIntegral(); sign = new CVolumeIntegral();
else if(signChr ==0x2211 || props.signType == NARY_SIGMA) }
else if(signCode == 0x2211 || props.signType == NARY_SIGMA)
{
this.code = 0x2211;
this.type = NARY_SIGMA;
sign = new CSigma(); sign = new CSigma();
else if(signChr == 0x220F || props.signType == NARY_PRODUCT) }
else if(signCode == 0x220F || props.signType == NARY_PRODUCT)
{
this.code = 0x220F;
this.type = NARY_PRODUCT;
sign = new CProduct(); sign = new CProduct();
else if(signChr ==0x2210 || props.signType == NARY_COPRODUCT) }
else if(signCode == 0x2210 || props.signType == NARY_COPRODUCT)
{
this.code = 0x2210;
this.type = NARY_COPRODUCT;
sign = new CProduct(-1); sign = new CProduct(-1);
else if(signChr == 0x22C3 || props.signType == NARY_UNION) }
else if(signCode == 0x22C3 || props.signType == NARY_UNION)
{
this.code = 0x22C3;
this.type = NARY_UNION;
sign = new CUnion(); sign = new CUnion();
else if(signChr == 0x22C2 || props.signType == NARY_INTERSECTION) }
else if(signCode == 0x22C2 || props.signType == NARY_INTERSECTION)
{
this.code = 0x22C2;
this.type = NARY_INTERSECTION;
sign = new CUnion(-1); sign = new CUnion(-1);
else if(signChr == 0x22C1 || props.signType == NARY_LOGICAL_OR) }
else if(signCode == 0x22C1 || props.signType == NARY_LOGICAL_OR)
{
this.code = 0x22C1;
this.type = NARY_LOGICAL_OR;
sign = new CLogicalOr(); sign = new CLogicalOr();
else if(signChr == 0x22C0 || props.signType == NARY_LOGICAL_AND) }
else if(signCode == 0x22C0 || props.signType == NARY_LOGICAL_AND)
{
this.code = 0x22C0;
this.type = NARY_LOGICAL_AND;
sign = new CLogicalOr(-1); sign = new CLogicalOr(-1);
}
else if(bChr)
{
this.code = signCode;
this.type = NARY_TEXT_OPER;
sign = new CMathText();
sign.add(signCode);
}
else else
{
this.code = 0x222B;
this.type = NARY_INTEGRAL;
sign = new CIntegral(); sign = new CIntegral();
}
var arg = new CMathContent(), var arg = new CMathContent(),
base; base;
...@@ -105,25 +172,25 @@ CNary.prototype.init = function(props) ...@@ -105,25 +172,25 @@ CNary.prototype.init = function(props)
if( this.supHide && !this.subHide ) if( this.supHide && !this.subHide )
{ {
base = new CDegree(); base = new CDegree();
props = {type: DEGREE_SUPERSCRIPT}; var prp = {type: DEGREE_SUPERSCRIPT};
base.init_2(props, sign); base.init_2(prp, sign);
} }
else if( !this.supHide && this.subHide ) else if( !this.supHide && this.subHide )
{ {
base = new CDegree(); base = new CDegree();
props = {type: DEGREE_SUBSCRIPT}; var prp = {type: DEGREE_SUBSCRIPT};
base.init_2(props, sign); base.init_2(prp, sign);
} }
else else
{ {
base = new CDegreeSubSup(); base = new CDegreeSubSup();
props = {type: DEGREE_SubSup}; var prp = {type: DEGREE_SubSup};
base.init_2(props, sign); base.init_2(prp, sign);
} }
} }
if(!this.supHide && !this.subHide) /*if(!this.supHide && !this.subHide)
base.setCtrPrp(this.CtrPrp); // выставляем аналогично как в CMathContent при добавлении элемента в addMComponent base.setCtrPrp(this.CtrPrp);*/ // выставляем аналогично как в CMathContent при добавлении элемента в addMComponent
this.addMCToContent(base, arg); this.addMCToContent(base, arg);
} }
...@@ -143,6 +210,18 @@ CNary.prototype.getLowerIterator = function() ...@@ -143,6 +210,18 @@ CNary.prototype.getLowerIterator = function()
{ {
return this.elements[0][0].getLowerIterator(); return this.elements[0][0].getLowerIterator();
} }
CNary.prototype.getPropsForWhite = function()
{
var props = {};
props.limLoc = (this.limLoc == NARY_UndOvr) ? NARY_UndOvr : NARY_SubSup;
props.chr = String.fromCharCode(this.code);
props.supHide = this.supHide === true ? 1: 0;
props.subHide = this.subHide === true ? 1: 0;
props.grow = this.grow === true ? 1 : 0;
return props;
}
function old_CNary() function old_CNary()
{ {
...@@ -260,7 +339,7 @@ CNaryUnd.prototype.init = function(sign) ...@@ -260,7 +339,7 @@ CNaryUnd.prototype.init = function(sign)
} }
CNaryUnd.prototype.setDistance = function() CNaryUnd.prototype.setDistance = function()
{ {
var zetta = this.getTxtPrp().FontSize* 25.4/96; var zetta = this.getCtrPrp().FontSize* 25.4/96;
this.dH = zetta*0.25; this.dH = zetta*0.25;
} }
CNaryUnd.prototype.getCenter = function() CNaryUnd.prototype.getCenter = function()
...@@ -289,7 +368,7 @@ CNaryOvr.prototype.init = function(sign) ...@@ -289,7 +368,7 @@ CNaryOvr.prototype.init = function(sign)
} }
CNaryOvr.prototype.setDistance = function() CNaryOvr.prototype.setDistance = function()
{ {
var zetta = this.getTxtPrp().FontSize* 25.4/96; var zetta = this.getCtrPrp().FontSize* 25.4/96;
this.dH = zetta*0.1; this.dH = zetta*0.1;
} }
CNaryOvr.prototype.getCenter = function() CNaryOvr.prototype.getCenter = function()
...@@ -322,7 +401,6 @@ CNaryUndOvr.prototype.init = function(sign) ...@@ -322,7 +401,6 @@ CNaryUndOvr.prototype.init = function(sign)
} }
CNaryUndOvr.prototype.recalculateSize = function() CNaryUndOvr.prototype.recalculateSize = function()
{ {
//var zetta = this.getTxtPrp().FontSize* 25.4/96;
var zetta = this.getCtrPrp().FontSize* 25.4/96; var zetta = this.getCtrPrp().FontSize* 25.4/96;
this.gapTop = zetta*0.25; this.gapTop = zetta*0.25;
this.gapBottom = zetta*0.1; this.gapBottom = zetta*0.1;
...@@ -413,7 +491,6 @@ CNaryUndOvr.prototype.getUpperIterator = function() ...@@ -413,7 +491,6 @@ CNaryUndOvr.prototype.getUpperIterator = function()
} }
function CNaryOperator(flip) function CNaryOperator(flip)
{ {
this.Composition = null; this.Composition = null;
...@@ -421,6 +498,13 @@ function CNaryOperator(flip) ...@@ -421,6 +498,13 @@ function CNaryOperator(flip)
this.sizeGlyph = null; this.sizeGlyph = null;
} }
CNaryOperator.prototype.draw = function(pGraphics) CNaryOperator.prototype.draw = function(pGraphics)
{
if(this.typeObj == MATH_TEXT)
this.drawTextElem(pGraphics);
else
this.drawGlyph(pGraphics);
}
CNaryOperator.prototype.drawGlyph = function(pGraphics)
{ {
var coord = this.getCoord(); var coord = this.getCoord();
...@@ -466,7 +550,18 @@ CNaryOperator.prototype.draw = function(pGraphics) ...@@ -466,7 +550,18 @@ CNaryOperator.prototype.draw = function(pGraphics)
pGraphics.df(); pGraphics.df();
pGraphics.SetIntegerGrid(intGrid); pGraphics.SetIntegerGrid(intGrid);
}
CNaryOperator.prototype.drawTextElem = function(pGraphics)
{
pGraphics.b_color1(0,0,0,255);
var rPrp = new CTextPr();
rPrp.Merge( this.getCtrPrp() );
rPrp.Italic = false;
rPrp.Bold = false;
pGraphics.SetFont(rPrp);
CNaryOperator.superclass.call.draw(this, pGraphics);
} }
CNaryOperator.prototype.IsJustDraw = function() CNaryOperator.prototype.IsJustDraw = function()
{ {
......
...@@ -3623,13 +3623,13 @@ old_CSeparatorDelimiter.prototype.mouseMove = function(mCoord) ...@@ -3623,13 +3623,13 @@ old_CSeparatorDelimiter.prototype.mouseMove = function(mCoord)
} }
function old_CSeparator() function old_old_CSeparator()
{ {
this.sepChr = 0x7C; // default this.sepChr = 0x7C; // default
CMathBase.call(this); CMathBase.call(this);
} }
extend(old_CSeparator, CMathBase); extend(old_old_CSeparator, CMathBase);
old_CSeparator.prototype.init = function(sepChr, column) old_old_CSeparator.prototype.init = function(sepChr, column)
{ {
if(sepChr !== "undefined" && sepChr !== null) if(sepChr !== "undefined" && sepChr !== null)
this.sepChr = sepChr.charCodeAt(0); this.sepChr = sepChr.charCodeAt(0);
...@@ -3637,17 +3637,17 @@ old_CSeparator.prototype.init = function(sepChr, column) ...@@ -3637,17 +3637,17 @@ old_CSeparator.prototype.init = function(sepChr, column)
this.setDimension(1, column); this.setDimension(1, column);
this.setContent(); this.setContent();
} }
old_CSeparator.prototype.setDistance = function() old_old_CSeparator.prototype.setDistance = function()
{ {
this.dW = this.getTxtPrp().FontSize/3*g_dKoef_pt_to_mm; this.dW = this.getTxtPrp().FontSize/3*g_dKoef_pt_to_mm;
} }
old_CSeparator.prototype.draw = function() old_old_CSeparator.prototype.draw = function()
{ {
//if(this.sepChr == ) //if(this.sepChr == )
old_CSeparator.superclass.draw.call(this); old_old_CSeparator.superclass.draw.call(this);
} }
old_CSeparator.prototype.drawHorLine = function() old_old_CSeparator.prototype.drawHorLine = function()
{ {
var x = this.pos.x, var x = this.pos.x,
y = this.pos.y; y = this.pos.y;
...@@ -3685,15 +3685,269 @@ old_CSeparator.prototype.drawHorLine = function() ...@@ -3685,15 +3685,269 @@ old_CSeparator.prototype.drawHorLine = function()
} }
function COperator(glyph) function COperator(type)
{ {
this.glyph = glyph; this.type = type;
this.glyph = -1;
this.code = null;
this.typeOper = null;
this.pos = null; this.pos = null;
this.coordGlyph = null; this.coordGlyph = null;
this.size = {width: 0, height: 0}; this.size = {width: 0, height: 0};
} }
COperator.prototype.init = function(chr, type, location)
{
var operator;
var code = typeof(chr) === "string" && chr.length > 0 ? chr.charCodeAt(0) : null;
var typeOper = null,
codeChr = null;
if( code === 0x28 || type === PARENTHESIS_LEFT)
{
codeChr = 0x28;
typeOper = PARENTHESIS_LEFT;
operator = new COperatorParenthesis();
var props =
{
location: location,
turn: TURN_0
};
operator.init(props);
}
else if( code === 0x29 || type === PARENTHESIS_RIGHT)
{
codeChr = 0x29;
typeOper = PARENTHESIS_RIGHT;
operator = new COperatorParenthesis();
var props =
{
location: location,
turn: TURN_180
};
operator.init(props);
}
else if( code == 0x7B || type === BRACKET_CURLY_LEFT)
{
codeChr = 0x7B;
typeOper = BRACKET_CURLY_LEFT;
operator = new COperatorBracket();
var props =
{
location: location,
turn: TURN_0
};
operator.init(props);
}
else if( code === 0x7D || type === BRACKET_CURLY_RIGHT)
{
codeChr = 0x7D;
typeOper = BRACKET_CURLY_RIGHT;
operator = new COperatorBracket();
var props =
{
location: location,
turn: TURN_180
};
operator.init(props);
}
else if( code === 0x5B || type === BRACKET_SQUARE_LEFT)
{
codeChr = 0x5B;
typeOper = BRACKET_SQUARE_LEFT;
operator = new CSquareBracket();
var props =
{
location: location,
turn: TURN_0
};
operator.init(props);
}
else if( code === 0x5D || type === BRACKET_SQUARE_RIGHT)
{
codeChr = 0x5D;
typeOper = BRACKET_SQUARE_RIGHT;
operator = new CSquareBracket();
var props =
{
location: location,
turn: TURN_180
};
operator.init(props);
}
else if( code === 0x3C || type === BRACKET_ANGLE_LEFT)
{
codeChr = 0x3C;
typeOper = BRACKET_ANGLE_LEFT;
operator = new COperatorAngleBracket();
var props =
{
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: TURN_0
};
operator.init(props);
}
else if( code === 0x3E || type === BRACKET_ANGLE_RIGHT)
{
codeChr = 0x3E;
typeOper = BRACKET_ANGLE_RIGHT;
operator = new COperatorAngleBracket();
var props =
{
//location: DELIMITER_LOCATION_RIGHT,
location: location,
turn: TURN_180
};
operator.init(props);
}
else if(code === 0x7C || type === DELIMITER_LINE)
{
codeChr = 0x7C;
typeOper = DELIMITER_LINE;
operator = new COperatorLine();
var props =
{
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x230A || type === HALF_SQUARE_LEFT)
{
codeChr = 0x230A;
typeOper = HALF_SQUARE_LEFT;
operator = new CHalfSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x230B || type == HALF_SQUARE_RIGHT)
{
codeChr = 0x230B;
typeOper = HALF_SQUARE_RIGHT;
operator = new CHalfSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_180
};
operator.init(props);
}
else if(code === 0x2308 || type == HALF_SQUARE_LEFT_UPPER)
{
codeChr = 0x2308;
typeOper = HALF_SQUARE_LEFT_UPPER;
operator = new CHalfSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_MIRROR_0
};
operator.init(props);
}
else if(code === 0x2309 || type == HALF_SQUARE_RIGHT_UPPER)
{
codeChr = 0x2309;
typeOper = HALF_SQUARE_RIGHT_UPPER;
operator = new CHalfSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_MIRROR_180
};
operator.init(props);
}
else if(code === 0x2016 || type == DELIMITER_DOUBLE_LINE)
{
codeChr = 0x2016;
typeOper = DELIMITER_DOUBLE_LINE;
operator = new COperatorDoubleLine();
var props =
{
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x27E6 || type == WHITE_SQUARE_LEFT)
{
codeChr = 0x27E6;
typeOper = WHITE_SQUARE_LEFT;
operator = new CWhiteSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x27E7 || type == WHITE_SQUARE_RIGHT)
{
codeChr = 0x27E7;
typeOper = WHITE_SQUARE_RIGHT;
operator = new CWhiteSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_180
};
operator.init(props);
}
else if(type === BRACKET_EMPTY)
{
typeOper = BRACKET_EMPTY;
operator = -1;
}
else if(code !== null)
{
operator = new CMathText();
operator.add(code);
}
else
operator = -1;
this.glyph = operator;
this.code = codeChr;
this.typeOper = typeOper;
}
COperator.prototype.draw = function(pGraphics) COperator.prototype.draw = function(pGraphics)
{
if(this.type === DELIM_OPERATOR)
this.drawOperator(pGraphics);
else if(this.type === DELIM_SEPARATOR)
this.drawSeparator(pGraphics);
}
COperator.prototype.drawOperator = function(pGraphics)
{ {
if(this.glyph !== -1) if(this.glyph !== -1)
{ {
...@@ -3710,6 +3964,26 @@ COperator.prototype.draw = function(pGraphics) ...@@ -3710,6 +3964,26 @@ COperator.prototype.draw = function(pGraphics)
this.glyph.draw(pGraphics, X, Y); this.glyph.draw(pGraphics, X, Y);
} }
} }
COperator.prototype.drawSeparator = function(pGraphics)
{
if(this.glyph !== -1)
{
var lng = this.coordGlyph.XX.length;
for(var i = 0; i < this.positions.length; i++)
{
var X = new Array(),
Y = new Array();
for(var j = 0; j < lng; j++)
{
X.push(this.positions[i].x + this.coordGlyph.XX[j]);
Y.push(this.positions[i].y + this.coordGlyph.YY[j]);
}
this.glyph.draw(pGraphics, X, Y);
}
}
}
COperator.prototype.fixSize = function(measure) COperator.prototype.fixSize = function(measure)
{ {
if(this.glyph !== -1) if(this.glyph !== -1)
...@@ -3742,7 +4016,8 @@ COperator.prototype.fixSize = function(measure) ...@@ -3742,7 +4016,8 @@ COperator.prototype.fixSize = function(measure)
} }
COperator.prototype.setPosition = function(pos) COperator.prototype.setPosition = function(pos)
{ {
this.pos = pos; this.pos = pos; // для оператора, это будет просто позиция
// для сепаратора - массив позиций
} }
COperator.prototype.IsJustDraw = function() COperator.prototype.IsJustDraw = function()
{ {
...@@ -3770,13 +4045,22 @@ COperator.prototype.getCtrPrp = function() ...@@ -3770,13 +4045,22 @@ COperator.prototype.getCtrPrp = function()
{ {
return this.Parent.getCtrPrp(); return this.Parent.getCtrPrp();
} }
COperator.prototype.getChr = function(defaultCode)
{
var chr = null; //если glyph не определен, то this.code = null
function CSeparator(glyph) if(this.code !== null)
chr = this.code == defaultCode ? "" : String.fromCharCode(this.code);
return chr;
}
function old_CSeparator(glyph)
{ {
COperator.call(this, glyph); COperator.call(this, glyph);
} }
extend(CSeparator, COperator); extend(old_CSeparator, COperator);
CSeparator.prototype.draw = function(pGraphics) old_CSeparator.prototype.draw = function(pGraphics)
{ {
if(this.glyph !== -1) if(this.glyph !== -1)
{ {
...@@ -3796,19 +4080,23 @@ CSeparator.prototype.draw = function(pGraphics) ...@@ -3796,19 +4080,23 @@ CSeparator.prototype.draw = function(pGraphics)
} }
} }
} }
CSeparator.prototype.setPosition = function(pos) old_CSeparator.prototype.setPosition = function(pos)
{ {
this.positions = pos; this.positions = pos;
} }
function CDelimiter() function CDelimiter()
{ {
this.begOper = new COperator (-1); this.begOper = new COperator (DELIM_OPERATOR);
this.endOper = new COperator (-1); this.endOper = new COperator (DELIM_OPERATOR);
this.sepOper = new COperator (-1); this.sepOper = new COperator (DELIM_SEPARATOR);
this.shape = DELIMITER_SHAPE_CENTERED; this.shape = DELIMITER_SHAPE_CENTERED;
this.grow = true; this.grow = true;
this.code = null;
this.typeOper = null;
//// special for "read" //// //// special for "read" ////
this.column = 0; this.column = 0;
//// ////
...@@ -3832,16 +4120,14 @@ CDelimiter.prototype.init = function(props) ...@@ -3832,16 +4120,14 @@ CDelimiter.prototype.init = function(props)
if(typeof(props.endChr) === "string" && props.endChr.length == 0) if(typeof(props.endChr) === "string" && props.endChr.length == 0)
props.sepChrType = DELIMITER_LINE; props.sepChrType = DELIMITER_LINE;
var begGlyph = this.getGlyph(props.begChr, props.begChrType, LOCATION_LEFT);
this.begOper = new COperator (begGlyph); this.begOper.init(props.begChr, props.begChrType, LOCATION_LEFT);
this.begOper.relate(this); this.begOper.relate(this);
var endGlyph = this.getGlyph(props.endChr, props.endChrType, LOCATION_RIGHT); this.endOper.init(props.endChr, props.endChrType, LOCATION_RIGHT);
this.endOper = new COperator (endGlyph);
this.endOper.relate(this); this.endOper.relate(this);
var sepGlyph = this.getGlyph(props.sepChr, props.sepChrType, LOCATION_SEP); this.endOper.init(props.sepChr, props.sepChrType, LOCATION_SEP);
this.sepOper = new CSeparator (sepGlyph);
this.sepOper.relate(this); this.sepOper.relate(this);
if(props.shape == DELIMITER_SHAPE_MATH || props.shp == DELIMITER_SHAPE_MATH) if(props.shape == DELIMITER_SHAPE_MATH || props.shp == DELIMITER_SHAPE_MATH)
...@@ -4127,19 +4413,6 @@ CDelimiter.prototype.draw = function(pGraphics) ...@@ -4127,19 +4413,6 @@ CDelimiter.prototype.draw = function(pGraphics)
for(var j = 0; j < this.nCol; j++) for(var j = 0; j < this.nCol; j++)
this.elements[0][j].draw(pGraphics); this.elements[0][j].draw(pGraphics);
} }
CDelimiter.prototype.drawOperator = function(pos, coord, glyph)
{
var X = new Array(),
Y = new Array();
for(var i = 0; i < coord.XX.length; i++)
{
X[i] = pos.x + coord.XX[i];
Y[i] = pos.y + coord.YY[i];
}
glyph.drawGlyph(X, Y);
}
CDelimiter.prototype.align = function(element) CDelimiter.prototype.align = function(element)
{ {
var align = 0; var align = 0;
...@@ -4160,193 +4433,19 @@ CDelimiter.prototype.getBase = function(numb) ...@@ -4160,193 +4433,19 @@ CDelimiter.prototype.getBase = function(numb)
return this.elements[0][numb]; return this.elements[0][numb];
} }
CDelimiter.prototype.getGlyph = function(chr, type, location) CDelimiter.prototype.getPropsForWrite = function()
{ {
var operator; var props = {};
var code = typeof(chr) === "string" && chr.length > 0 ? chr.charCodeAt(0) : null;
if( code === 0x28 || type === PARENTHESIS_LEFT) props.grow = this.grow == true ? 1 : 0;
{ props.column = this.nCol;
operator = new COperatorParenthesis(); props.shp = this.shape;
var props =
{
location: location,
turn: TURN_0
};
operator.init(props);
}
else if( code === 0x29 || type === PARENTHESIS_RIGHT)
{
operator = new COperatorParenthesis();
var props =
{
location: location,
turn: TURN_180
};
operator.init(props);
}
else if( code == 0x7B || type === BRACKET_CURLY_LEFT)
{
operator = new COperatorBracket();
var props =
{
location: location,
turn: TURN_0
};
operator.init(props);
}
else if( code === 0x7D || type === BRACKET_CURLY_RIGHT)
{
operator = new COperatorBracket();
var props =
{
location: location,
turn: TURN_180
};
operator.init(props);
}
else if( code === 0x5B || type === BRACKET_SQUARE_LEFT)
{
operator = new CSquareBracket();
var props =
{
location: location,
turn: TURN_0
};
operator.init(props);
}
else if( code === 0x5D || type === BRACKET_SQUARE_RIGHT)
{
operator = new CSquareBracket();
var props =
{
location: location,
turn: TURN_180
};
operator.init(props);
}
else if( code === 0x3C || type === BRACKET_ANGLE_LEFT)
{
operator = new COperatorAngleBracket();
var props =
{
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: TURN_0
};
operator.init(props);
}
else if( code === 0x3E || type === BRACKET_ANGLE_RIGHT)
{
operator = new COperatorAngleBracket();
var props =
{
//location: DELIMITER_LOCATION_RIGHT,
location: location,
turn: TURN_180
};
operator.init(props);
}
else if(code === 0x7C || type === DELIMITER_LINE)
{
operator = new COperatorLine();
var props =
{
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x230A || type === HALF_SQUARE_LEFT)
{
operator = new CHalfSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x230B || type == HALF_SQUARE_RIGHT)
{
operator = new CHalfSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_180
};
operator.init(props);
}
else if(code === 0x2308 || type == HALF_SQUARE_LEFT_UPPER)
{
operator = new CHalfSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_MIRROR_0
};
operator.init(props);
}
else if(code === 0x2309 || type == HALF_SQUARE_RIGHT_UPPER)
{
operator = new CHalfSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_MIRROR_180
};
operator.init(props);
}
else if(code === 0x2016 || type == DELIMITER_DOUBLE_LINE)
{
operator = new COperatorDoubleLine();
var props =
{
location: location,
//location: DELIMITER_LOCATION_LEFT,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x27E6 || type == WHITE_SQUARE_LEFT)
{
operator = new CWhiteSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x27E7 || type == WHITE_SQUARE_RIGHT)
{
operator = new CWhiteSquareBracket();
var props =
{
//location: DELIMITER_LOCATION_LEFT,
location: location,
turn: TURN_180
};
operator.init(props);
}
else if(type === BRACKET_EMPTY)
operator = -1;
else if(code !== null)
{
operator = new CMathText();
operator.add(code);
}
else
operator = -1;
props.begChr = this.begOper.getChr(0x28); // PARENTHESIS_LEFT
props.endChr = this.endOper.getChr(0x29); // PARENTHESIS_RIGHT
props.sepChr = this.sepOper.getChr(0x7C); // DELIMITER_LINE
return operator; return props;
} }
......
...@@ -168,14 +168,25 @@ CSignRadical.prototype.relate = function(parent) ...@@ -168,14 +168,25 @@ CSignRadical.prototype.relate = function(parent)
function CRadical() function CRadical()
{ {
this.type = SQUARE_RADICAL; // default this.type = SQUARE_RADICAL; // default
this.degHide = false;
this.signRadical = null; this.signRadical = null;
CMathBase.call(this); CMathBase.call(this);
} }
extend(CRadical, CMathBase); extend(CRadical, CMathBase);
CRadical.prototype.init = function(props) CRadical.prototype.init = function(props)
{ {
if(typeof(props.type) !== "undefined" && props.type !== null) /*if(typeof(props.type) !== "undefined" && props.type !== null)
this.type = props.type; this.type = props.type;*/
/*if(props.type === SQUARE_RADICAL)
this.type = SQUARE_RADICAL;
else if(props.type === DEGREE_RADICAL)
this.type = DEGREE_RADICAL;*/
if(props.degHide === true && props.degHide === 1)
this.type = SQUARE_RADICAL;
else if(props.degHide == false && props.degHide === 0)
this.type = DEGREE_RADICAL;
this.setDimension(1, 1); this.setDimension(1, 1);
this.setContent(); this.setContent();
...@@ -416,11 +427,23 @@ CRadical.prototype.getBase = function() ...@@ -416,11 +427,23 @@ CRadical.prototype.getBase = function()
} }
CRadical.prototype.getDegree = function() CRadical.prototype.getDegree = function()
{ {
var degree = null; /*var degree = null;
if(this.type == DEGREE_RADICAL) if(this.type == DEGREE_RADICAL)
degree = this.elements[0][0]; degree = this.elements[0][0];
else if(this.type = SQUARE_RADICAL)
degree = this.elements[0][0];*/
// для стремной ситуации, когда руками в xml выставили в degHide true, а объект со степенью имеется. Возвращаем основание
return this.elements[0][0];
}
CRadical.prototype.getPropsForWhite = function()
{
var props = {};
props.degHide = this.type == SQUARE_RADICAL ? 1 : 0;
return degree; return props;
} }
function old_CRadical() function old_CRadical()
......
...@@ -50,7 +50,8 @@ function simulatorRead() ...@@ -50,7 +50,8 @@ function simulatorRead()
props = props =
{ {
begChrType: PARENTHESIS_LEFT, begChrType: PARENTHESIS_LEFT,
endChrType: PARENTHESIS_RIGHT, //endChrType: PARENTHESIS_RIGHT,
endChr: ")",
sepChrType: DELIMITER_LINE, sepChrType: DELIMITER_LINE,
column: 2 column: 2
}; };
...@@ -109,7 +110,8 @@ function simulatorRead() ...@@ -109,7 +110,8 @@ function simulatorRead()
var integral = new CNary(); var integral = new CNary();
props = props =
{ {
signType: NARY_INTEGRAL, //signType: NARY_INTEGRAL,
chr: "B",
limLoc: NARY_SubSup limLoc: NARY_SubSup
}; };
integral.init(props); integral.init(props);
......
...@@ -195,6 +195,7 @@ ...@@ -195,6 +195,7 @@
<script type="text/javascript" src = "Math/drawingUnion.js"></script> <script type="text/javascript" src = "Math/drawingUnion.js"></script>
<script type="text/javascript" src = "Math/borderBox.js"></script> <script type="text/javascript" src = "Math/borderBox.js"></script>
<script type="text/javascript" src = "Math/test_for_read.js"></script>
<!----> <!---->
......
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