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

1. Реализовала функцию fillMathComposition в качестве эмулятора конструктора...

1. Реализовала функцию fillMathComposition в качестве эмулятора конструктора классов (для совместного редактирования и т.п.) для accent, borderBox, bar, box, degree, degreeSubSup, limit, math function, matrix
2. Поправила баг с lineGap у матриц (не подхватывались)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56531 954022d7-b5bf-4e40-9824-e11837661b57
parent 9b531a9e
...@@ -510,10 +510,6 @@ function CAccent(props) ...@@ -510,10 +510,6 @@ function CAccent(props)
chrType: null chrType: null
}; };
/*this.chr = null;
this.chrType = null;
this.loc = LOCATION_TOP;*/
///////////////// /////////////////
this.operator = new COperator(OPER_ACCENT); this.operator = new COperator(OPER_ACCENT);
...@@ -532,19 +528,12 @@ function CAccent(props) ...@@ -532,19 +528,12 @@ function CAccent(props)
extend(CAccent, CMathBase); extend(CAccent, CMathBase);
CAccent.prototype.init = function(props) CAccent.prototype.init = function(props)
{ {
this.Pr.chr = props.chr; this.setProperties(props);
this.Pr.chrType = props.chrType;
//this.operator.init(prp, defaultPrp);
//this.operator.relate(this);
this.setDimension(1, 1); this.setDimension(1, 1);
this.setContent(); this.setContent();
this.elements[0][0].SetDot(true); this.elements[0][0].SetDot(true);
if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined")
this.setCtrPrp(props.ctrPrp);
} }
CAccent.prototype.setChr = function(chr) CAccent.prototype.setChr = function(chr)
{ {
...@@ -1138,7 +1127,7 @@ CAccent.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -1138,7 +1127,7 @@ CAccent.prototype.Resize = function(Parent, ParaMath, oMeasure)
type: ACCENT_CIRCUMFLEX type: ACCENT_CIRCUMFLEX
}; };
this.operator.setProperties(prp, defaultPrp); this.operator.mergeProperties(prp, defaultPrp);
this.Pr.chr = String.fromCharCode(this.operator.code); this.Pr.chr = String.fromCharCode(this.operator.code);
this.Pr.chrType = this.operator.typeOper; this.Pr.chrType = this.operator.typeOper;
...@@ -1229,6 +1218,22 @@ CAccent.prototype.findDisposition = function(pos) ...@@ -1229,6 +1218,22 @@ CAccent.prototype.findDisposition = function(pos)
return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag}; return {pos: posCurs, mCoord: mouseCoord, inside_flag: inside_flag};
} }
CAccent.prototype.setProperties = function(props)
{
this.Pr.chr = props.chr;
this.Pr.chrType = props.chrType;
this.setCtrPrp(props.ctrPrp);
this.RecalcInfo.bProps = true;
}
CAccent.prototype.fillMathComposition = function(props, contents /*array*/)
{
this.init(props);
// Base
this.elements[0][0] = contents[0];
}
CAccent.prototype.Save_Changes = function(Data, Writer) CAccent.prototype.Save_Changes = function(Data, Writer)
{ {
Writer.WriteLong( historyitem_type_acc ); Writer.WriteLong( historyitem_type_acc );
......
...@@ -101,8 +101,8 @@ CMathBase.prototype = ...@@ -101,8 +101,8 @@ CMathBase.prototype =
///////// RunPrp, CtrPrp ///////// RunPrp, CtrPrp
setCtrPrp: function(txtPrp) // выставляем ctrPrp на чтение setCtrPrp: function(txtPrp) // выставляем ctrPrp на чтение
{ {
this.CtrPrp.Merge(txtPrp); if(txtPrp !== null && typeof(txtPrp) !== "undefined")
//this.RunPrp.setTxtPrp(txtPrp); this.CtrPrp.Merge(txtPrp);
}, },
Get_CtrPrp: function() Get_CtrPrp: function()
{ {
......
...@@ -38,66 +38,42 @@ function CBorderBox(props) ...@@ -38,66 +38,42 @@ function CBorderBox(props)
extend(CBorderBox, CMathBase); extend(CBorderBox, CMathBase);
CBorderBox.prototype.init = function(props) CBorderBox.prototype.init = function(props)
{ {
/*if(typeof(props) !== "undefined" && props !== null) this.setProperties(props);
{ this.fillContent();
if(props.hideLeft === true || props.hideLeft === 1) }
this.bLeft = false; CBorderBox.prototype.fillContent = function()
if(props.hideRight === true || props.hideRight === 1) {
this.bRight = false;
if(props.hideTop === true || props.hideTop === 1)
this.bTop = false;
if(props.hideBot === true || props.hideBot === 1)
this.bBot = false;
if(props.strikeBLTR === true || props.strikeBLTR === 1)
this.bRDiag = true;
if(props.strikeTLBR === true || props.strikeTLBR === 1)
this.bLDiag = true;
if(props.strikeH === true || props.strikeH === 1)
this.bHor = true;
if(props.strikeV === true || props.strikeV === 1)
this.bVert = true;
}*/
this.setBorders(props);
this.setDimension(1, 1); this.setDimension(1, 1);
this.setContent(); this.setContent();
if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined")
this.setCtrPrp(props.ctrPrp);
} }
CBorderBox.prototype.setBorders = function(props) CBorderBox.prototype.setProperties = function(props)
{ {
if(typeof(props) !== "undefined" && props !== null) if(typeof(props.hideLeft) !== "undefined" && props.hideLeft !== null)
{ this.Pr.hideLeft = props.hideLeft;
if(typeof(props.hideLeft) !== "undefined" && props.hideLeft !== null)
this.Pr.hideLeft = props.hideLeft;
if(typeof(props.hideRight) !== "undefined" && props.hideRight !== null) if(typeof(props.hideRight) !== "undefined" && props.hideRight !== null)
this.Pr.hideRight = props.hideRight; this.Pr.hideRight = props.hideRight;
if(typeof(props.hideTop) !== "undefined" && props.hideTop !== null) if(typeof(props.hideTop) !== "undefined" && props.hideTop !== null)
this.Pr.hideTop = props.hideTop; this.Pr.hideTop = props.hideTop;
if(typeof(props.hideBot) !== "undefined" && props.hideBot !== null) if(typeof(props.hideBot) !== "undefined" && props.hideBot !== null)
this.Pr.hideBot = props.hideBot; this.Pr.hideBot = props.hideBot;
if(typeof(props.strikeBLTR) !== "undefined" && props.strikeBLTR !== null) // right diagonal if(typeof(props.strikeBLTR) !== "undefined" && props.strikeBLTR !== null) // right diagonal
this.Pr.strikeBLTR = props.strikeBLTR; this.Pr.strikeBLTR = props.strikeBLTR;
if(typeof(props.strikeTLBR) !== "undefined" && props.strikeTLBR !== null) // left diagonal if(typeof(props.strikeTLBR) !== "undefined" && props.strikeTLBR !== null) // left diagonal
this.Pr.strikeTLBR = props.strikeTLBR; this.Pr.strikeTLBR = props.strikeTLBR;
if(typeof(props.strikeH) !== "undefined" && props.strikeH !== null) if(typeof(props.strikeH) !== "undefined" && props.strikeH !== null)
this.Pr.strikeH = props.strikeH; this.Pr.strikeH = props.strikeH;
if(typeof(props.strikeV) !== "undefined" && props.strikeV !== null)
this.Pr.strikeV = props.strikeV;
this.setCtrPrp(props.ctrPrp);
if(typeof(props.strikeV) !== "undefined" && props.strikeV !== null)
this.Pr.strikeV = props.strikeV;
}
this.RecalcInfo.bProps = true; this.RecalcInfo.bProps = true;
} }
...@@ -458,6 +434,14 @@ CBorderBox.prototype.getBase = function() ...@@ -458,6 +434,14 @@ CBorderBox.prototype.getBase = function()
{ {
return this.elements[0][0]; return this.elements[0][0];
} }
CBorderBox.prototype.fillMathComposition = function(props, contents /*array*/)
{
this.setProperties(props);
this.fillContent();
// Base
this.elements[0][0] = contents[0];
}
CBorderBox.prototype.getPropsForWrite = function() CBorderBox.prototype.getPropsForWrite = function()
{ {
/*var props = {}; /*var props = {};
...@@ -572,6 +556,8 @@ CBorderBox.prototype.Get_Id = function() ...@@ -572,6 +556,8 @@ CBorderBox.prototype.Get_Id = function()
return this.Id; return this.Id;
} }
function CBox(props) function CBox(props)
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
...@@ -592,6 +578,19 @@ function CBox(props) ...@@ -592,6 +578,19 @@ function CBox(props)
} }
extend(CBox, CMathBase); extend(CBox, CMathBase);
CBox.prototype.init = function(props) CBox.prototype.init = function(props)
{
this.setProperties(props);
this.fillContent();
}
CBox.prototype.fillContent = function()
{
this.setDimension(1, 1);
this.setContent();
if(this.opEmu)
this.elements[0][0].decreaseArgSize();
}
CBox.prototype.setProperties = function(props)
{ {
if(props.opEmu === true || props.opEmu === 1) if(props.opEmu === true || props.opEmu === 1)
this.opEmu = true; this.opEmu = true;
...@@ -608,14 +607,17 @@ CBox.prototype.init = function(props) ...@@ -608,14 +607,17 @@ CBox.prototype.init = function(props)
if(props.aln === true || props.aln === 1) if(props.aln === true || props.aln === 1)
this.aln = true; this.aln = true;
this.setDimension(1, 1); this.setCtrPrp(props.ctrPrp);
this.setContent();
if(this.opEmu) this.RecalcInfo.bProps = true;
this.elements[0][0].decreaseArgSize(); }
CBox.prototype.fillMathComposition = function(props, contents /*array*/)
{
this.setProperties(props);
this.fillContent();
if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined") // Base
this.setCtrPrp(props.ctrPrp); this.elements[0][0] = contents[0];
} }
CBox.prototype.getBase = function() CBox.prototype.getBase = function()
{ {
...@@ -732,32 +734,13 @@ function CBar(props) ...@@ -732,32 +734,13 @@ function CBar(props)
extend(CBar, CCharacter); extend(CBar, CCharacter);
CBar.prototype.init = function(props) CBar.prototype.init = function(props)
{ {
if(props.pos === LOCATION_TOP || props.location === LOCATION_TOP) this.setProperties(props);
this.Pr.pos = LOCATION_TOP; this.fillContent();
else if(props.pos === LOCATION_BOT || props.location === LOCATION_BOT)
this.Pr.pos = LOCATION_BOT;
var prp =
{
loc: this.Pr.pos,
type: DELIMITER_LINE
};
var defaultProps =
{
loc: LOCATION_BOT
};
this.setCharacter(prp, defaultProps);
if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined")
this.setCtrPrp(props.ctrPrp);
} }
CBar.prototype.setLocation = function(pos) CBar.prototype.fillContent = function()
{ {
this.Pr.pos = pos; this.setDimension(1, 1);
this.RecalcInfo.bProps = true; this.setContent();
} }
CBar.prototype.Resize = function(Parent, ParaMath, oMeasure) CBar.prototype.Resize = function(Parent, ParaMath, oMeasure)
{ {
...@@ -791,6 +774,23 @@ CBar.prototype.getAscent = function() ...@@ -791,6 +774,23 @@ CBar.prototype.getAscent = function()
return ascent; return ascent;
} }
CBar.prototype.setProperties = function(props)
{
if(props.pos === LOCATION_TOP || props.pos === LOCATION_BOT)
this.Pr.pos = LOCATION_TOP;
this.setCtrPrp(props.ctrPrp);
this.RecalcInfo.bProps = true;
}
CBar.prototype.fillMathComposition = function(props, contents /*array*/)
{
this.setProperties(props);
this.fillContent();
// Base
this.elements[0][0] = contents[0];
}
CBar.prototype.getPropsForWrite = function() CBar.prototype.getPropsForWrite = function()
{ {
return this.Pr; return this.Pr;
...@@ -850,30 +850,68 @@ function CPhantom(props) ...@@ -850,30 +850,68 @@ function CPhantom(props)
this.props = null; this.props = null;
CMathBase.call(this); CMathBase.call(this);
this.init(props); this.Pr =
{
show: true,
transp: false,
zeroAsc: false,
zeroDesc: false,
zeroWid: false
};
if(props !== null && typeof(props) !== "undefined") if(props !== null && typeof(props) !== "undefined")
this.setCtrPrp(props.ctrPrp); this.init(props);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CPhantom, CMathBase); extend(CPhantom, CMathBase);
CPhantom.prototype.init = function(props) CPhantom.prototype.init = function(props)
{ {
this.props = props; this.setProperties(props);
this.fillContent();
}
CPhantom.prototype.fillContent = function()
{
this.setDimension(1, 1); this.setDimension(1, 1);
this.setContent(); this.setContent();
}
CPhantom.prototype.getBase = function()
{
return this.elements[0][0];
}
CPhantom.prototype.setProperties = function(props)
{
if(props.show == true || props.show == false)
this.Pr.show = props.show;
if(props.transp == false || props.transp == true)
this.Pr.transp = props.transp;
if(props.zeroAsc == false || props.zeroAsc == true)
this.Pr.zeroAsc = props.zeroAsc;
if(props.zeroDesc == false || props.zeroDesc == true)
this.Pr.zeroDesc = props.zeroDesc;
if(props.zeroWid == false || props.zeroWid == true)
this.Pr.zeroWid = props.zeroWid;
if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined")
this.setCtrPrp(props.ctrPrp); this.setCtrPrp(props.ctrPrp);
this.RecalcInfo.bProps = true;
} }
CPhantom.prototype.getPropsForWrite = function() CPhantom.prototype.fillMathComposition = function(props, contents /*array*/)
{ {
return this.props; this.setProperties(props);
this.fillContent();
// Base
this.elements[0][0] = contents[0];
} }
CPhantom.prototype.getBase = function() CPhantom.prototype.getPropsForWrite = function()
{ {
return this.elements[0][0]; return this.props;
} }
CPhantom.prototype.Save_Changes = function(Data, Writer) CPhantom.prototype.Save_Changes = function(Data, Writer)
{ {
......
...@@ -3,10 +3,8 @@ function CDegree(props) ...@@ -3,10 +3,8 @@ function CDegree(props)
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_DEGREE; this.kind = MATH_DEGREE;
//this.type = DEGREE_SUPERSCRIPT;
this.upBase = 0; // отступ сверху для основания this.upBase = 0; // отступ сверху для основания
this.upIter = 0; // отступ сверху для итератора this.upIter = 0; // отступ сверху для итератора
//this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
this.Pr = this.Pr =
{ {
...@@ -15,27 +13,26 @@ function CDegree(props) ...@@ -15,27 +13,26 @@ function CDegree(props)
CMathBase.call(this); CMathBase.call(this);
this.init(props); if(props !== null && typeof(props) !== "undefined")
this.setCtrPrp(props.ctrPrp); this.init(props);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CDegree, CMathBase); extend(CDegree, CMathBase);
CDegree.prototype.init = function(props) CDegree.prototype.init = function(props)
{ {
/*if(props.alnScr === true || props.alnScr === 1) this.setProperties(props);
this.alnScr = true; this.fillContent();
else if(props.alnScr === false || props.alnScr === 0) }
this.alnScr = false;*/ CDegree.prototype.fillContent = function()
{
var oBase = new CMathContent(); var oBase = new CMathContent();
if(props.indef == 2) /// props include Base for CNary if(props.indef == 2) /// props include Base for CNary
{
oBase = props.oBase; oBase = props.oBase;
oBase.setCtrPrp(props.ctrPrp);
if(props.type === DEGREE_SUPERSCRIPT) }
this.Pr.type = DEGREE_SUPERSCRIPT;
else if(props.type === DEGREE_SUBSCRIPT)
this.Pr.type = DEGREE_SUBSCRIPT;
this.setDimension(1, 2); this.setDimension(1, 2);
...@@ -44,20 +41,6 @@ CDegree.prototype.init = function(props) ...@@ -44,20 +41,6 @@ CDegree.prototype.init = function(props)
this.addMCToContent(oBase, oDegree); this.addMCToContent(oBase, oDegree);
} }
/*CDegree.prototype.init_2 = function(props, oBase)
{
if(props.type === DEGREE_SUPERSCRIPT)
this.type = DEGREE_SUPERSCRIPT;
else if(props.type === DEGREE_SUBSCRIPT)
this.type = DEGREE_SUBSCRIPT;
this.setDimension(1, 2);
var oDegree = new CMathContent();
oDegree.decreaseArgSize();
this.addMCToContent(oBase, oDegree);
}*/
CDegree.prototype.recalculateSize = function(oMeasure) CDegree.prototype.recalculateSize = function(oMeasure)
{ {
if(this.Pr.type === DEGREE_SUPERSCRIPT) if(this.Pr.type === DEGREE_SUPERSCRIPT)
...@@ -458,22 +441,35 @@ CDegree.prototype.getBase = function() ...@@ -458,22 +441,35 @@ CDegree.prototype.getBase = function()
{ {
return this.elements[0][0]; return this.elements[0][0];
} }
/*CDegree.prototype.getPropsForWrite = function() CDegree.prototype.IsPlhIterator = function()
{
return this.elements[0][1].IsPlaceholder();
}
CDegree.prototype.setProperties = function(props)
{ {
var props = {}; if(props.type === DEGREE_SUPERSCRIPT)
this.Pr.type = DEGREE_SUPERSCRIPT;
else if(props.type === DEGREE_SUBSCRIPT)
this.Pr.type = DEGREE_SUBSCRIPT;
props.type = this.type; this.setCtrPrp(props.ctrPrp);
//props.alnScr = this.alnScr;
return props; this.RecalcInfo.bProps = true;
}*/ }
CDegree.prototype.getPropsForWrite = function() CDegree.prototype.fillMathComposition = function(props, contents /*array*/)
{ {
return this.Pr; this.setProperties(props);
this.fillContent();
// Base
this.elements[0][0] = contents[0];
// Iterator
this.elements[0][1] = contents[1];
} }
CDegree.prototype.IsPlhIterator = function() CDegree.prototype.getPropsForWrite = function()
{ {
return this.elements[0][1].IsPlaceholder(); return this.Pr;
} }
CDegree.prototype.Save_Changes = function(Data, Writer) CDegree.prototype.Save_Changes = function(Data, Writer)
{ {
...@@ -643,6 +639,11 @@ CIterators.prototype.Get_CompiledCtrPrp = function() ...@@ -643,6 +639,11 @@ CIterators.prototype.Get_CompiledCtrPrp = function()
{ {
return this.Parent.Get_CompiledCtrPrp(); return this.Parent.Get_CompiledCtrPrp();
} }
CIterators.prototype.fillMathComposition = function(upperIterator, lowerIterator)
{
this.elements[0][0] = upperIterator;
this.elements[1][0] = lowerIterator;
}
function CDegreeSubSup(props) function CDegreeSubSup(props)
{ {
...@@ -662,25 +663,26 @@ function CDegreeSubSup(props) ...@@ -662,25 +663,26 @@ function CDegreeSubSup(props)
CMathBase.call(this); CMathBase.call(this);
this.init(props); if(props !== null && typeof(props) !== "undefined")
this.setCtrPrp(props.ctrPrp); this.init(props);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CDegreeSubSup, CMathBase); extend(CDegreeSubSup, CMathBase);
CDegreeSubSup.prototype.init = function(props) CDegreeSubSup.prototype.init = function(props)
{ {
if(props.alnScr === true || props.alnScr === 1) this.setProperties(props);
this.Pr.alnScr = true; this.fillContent();
else if(props.alnScr === false || props.alnScr === 0) }
this.Pr.alnScr = false; CDegreeSubSup.prototype.fillContent = function()
{
var oBase = new CMathContent(); var oBase = new CMathContent();
if(props.indef == 2) /// props include Base for CNary if(props.indef == 2) /// props include Base for CNary
{
oBase = props.oBase; oBase = props.oBase;
oBase.setCtrPrp(props.ctrPrp);
if(props.type === DEGREE_SubSup || props.type === DEGREE_PreSubSup) }
this.Pr.type = props.type;
this.setDimension(1, 2); this.setDimension(1, 2);
...@@ -702,41 +704,7 @@ CDegreeSubSup.prototype.init = function(props) ...@@ -702,41 +704,7 @@ CDegreeSubSup.prototype.init = function(props)
oIters.alignHor(-1, 1); oIters.alignHor(-1, 1);
this.addMCToContent(oIters, oBase); this.addMCToContent(oIters, oBase);
} }
/// вызов этой функции обязательно в конце
//this.WriteContentsToHistory();
} }
/*CDegreeSubSup.prototype.init_2 = function(props, oBase)
{
if(props.type === DEGREE_SubSup)
this.type = DEGREE_SubSup;
else if(props.type === DEGREE_PreSubSup)
this.type = DEGREE_PreSubSup;
this.setDimension(1, 2);
var oIters = new CIterators();
oIters.init();
oIters.decreaseArgSize();
oIters.lUp = 0;
oIters.lD = 0;
if(this.type == DEGREE_SubSup)
{
oIters.alignHor(-1, 0);
this.addMCToContent(oBase, oIters);
}
else if(this.type == DEGREE_PreSubSup)
{
oIters.alignHor(-1, 1);
this.addMCToContent(oIters, oBase);
}
/// вызов этой функции обязательно в конце
this.WriteContentsToHistory();
}*/
CDegreeSubSup.prototype.old_old_recalculateSize = function(oMeasure) CDegreeSubSup.prototype.old_old_recalculateSize = function(oMeasure)
{ {
var mgCtrPrp = this.Get_CompiledCtrPrp(); var mgCtrPrp = this.Get_CompiledCtrPrp();
...@@ -1130,15 +1098,44 @@ CDegreeSubSup.prototype.getLowerIterator = function() ...@@ -1130,15 +1098,44 @@ CDegreeSubSup.prototype.getLowerIterator = function()
return iter; return iter;
} }
CDegreeSubSup.prototype.getPropsForWrite = function() CDegreeSubSup.prototype.setProperties = function(props)
{
if(props.alnScr === true || props.alnScr === 1)
this.Pr.alnScr = true;
else if(props.alnScr === false || props.alnScr === 0)
this.Pr.alnScr = false;
if(props.type === DEGREE_SubSup || props.type === DEGREE_PreSubSup)
this.Pr.type = props.type;
this.setCtrPrp(props.ctrPrp);
this.RecalcInfo.bProps = true;
}
CDegreeSubSup.prototype.fillMathComposition = function(props, contents /*array*/)
{ {
/*var props = {}; this.setProperties(props);
this.fillContent();
props.type = this.type; if(this.Pr.type == DEGREE_SubSup)
props.alnScr = this.alnScr; {
// Base
this.elements[0][0] = contents[0];
return props;*/ // Iterators
this.elements[0][1].fillMathComposition(contents[1]/*upper iterator*/, contents[2]/*lower iterator*/);
}
else
{
// Base
this.elements[0][1] = contents[0];
// Iterators
this.elements[0][0].fillMathComposition(contents[1]/*upper iterator*/, contents[2]/*lower iterator*/);
}
}
CDegreeSubSup.prototype.getPropsForWrite = function()
{
return this.Pr; return this.Pr;
} }
CDegreeSubSup.prototype.Save_Changes = function(Data, Writer) CDegreeSubSup.prototype.Save_Changes = function(Data, Writer)
...@@ -1198,16 +1195,3 @@ CDegreeSubSup.prototype.Get_Id = function() ...@@ -1198,16 +1195,3 @@ CDegreeSubSup.prototype.Get_Id = function()
{ {
return this.Id; return this.Id;
} }
//выяcнить: почему и с этой ф-ией и без нее работает всё ok...
//всё ok, т.к. в контенте 2 элемента, и их center сравниваем
/*CDegreeSubSup.prototype.getCenter = function()
{
var center = 0;
if(this.type == 0)
center = this.elements[0][1].size.center;
else
center = this.elements[0][0].size.center;
return center;
}*/
...@@ -13,55 +13,16 @@ function CFraction(props) ...@@ -13,55 +13,16 @@ function CFraction(props)
CMathBase.call(this); CMathBase.call(this);
this.init(props); if(props !== null && typeof(props) !== "undefined")
this.init(props);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CFraction, CMathBase); extend(CFraction, CMathBase);
CFraction.prototype.init = function(props) CFraction.prototype.init = function(props)
{ {
this.setType(props.type); this.setProperties(props);
this.fillContent();
if(props.ctrPrp !== null && typeof(props.ctrPrp) !== "undefined")
this.setCtrPrp(props.ctrPrp);
}
CFraction.prototype.setType = function(type)
{
var bValid = typeof(type) !== "undefined" && type !== null;
if(bValid)
{
var bBar = type === BAR_FRACTION || type === NO_BAR_FRACTION,
bSkew = type === SKEWED_FRACTION,
bLin = type === LINEAR_FRACTION;
if(bBar || bSkew || bLin) // на всякий случай
this.Pr.type = type;
}
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
{
var num = new CNumerator();
var den = new CDenominator();
this.setDimension(2, 1);
if(this.Pr.type == NO_BAR_FRACTION)
this.bHideBar = true;
this.addMCToContent(num, den);
}
else if(this.Pr.type == SKEWED_FRACTION)
{
this.setDimension(1, 2);
this.setContent();
}
else if(this.Pr.type == LINEAR_FRACTION)
{
this.setDimension(1, 2);
this.setContent();
}
} }
CFraction.prototype.getType = function() CFraction.prototype.getType = function()
{ {
...@@ -424,11 +385,71 @@ CFraction.prototype.findDisposition = function( mCoord ) ...@@ -424,11 +385,71 @@ CFraction.prototype.findDisposition = function( mCoord )
return disposition; return disposition;
} }
CFraction.prototype.setProperties = function(props)
{
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.Pr.type = props.type;
this.setCtrPrp(props.ctrPrp);
}
CFraction.prototype.fillContent = function()
{
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
{
var num = new CNumerator();
var den = new CDenominator();
this.setDimension(2, 1);
if(this.Pr.type == NO_BAR_FRACTION)
this.bHideBar = true;
this.addMCToContent(num, den);
}
else if(this.Pr.type == SKEWED_FRACTION)
{
this.setDimension(1, 2);
this.setContent();
}
else if(this.Pr.type == LINEAR_FRACTION)
{
this.setDimension(1, 2);
this.setContent();
}
}
CFraction.prototype.fillMathComposition = function(props, contents /*array*/)
{
this.setProperties(props);
this.fillContent();
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION)
{
// Numerator
this.elements[0][0].fillMathComposition(contents[0]);
// Denominator
this.elements[1][0].fillMathComposition(contents[1]);
}
else
{
// Numerator
this.elements[0][0] = contents[0];
// Denominator
this.elements[0][1] = contents[1];
}
}
CFraction.prototype.getPropsForWrite = function() CFraction.prototype.getPropsForWrite = function()
{ {
return this.Pr; return this.Pr;
} }
CFraction.prototype.Save_Changes = function(Data, Writer) CFraction.prototype.Save_Changes = function(Data, Writer)
{ {
Writer.WriteLong( historyitem_type_frac ); Writer.WriteLong( historyitem_type_frac );
...@@ -587,6 +608,10 @@ CNumerator.prototype.getElement = function() ...@@ -587,6 +608,10 @@ CNumerator.prototype.getElement = function()
{ {
return this.elements[0][0]; return this.elements[0][0];
} }
CNumerator.prototype.fillMathComposition = function(content)
{
this.elements[0][0] = content;
}
CNumerator.prototype.Get_CompiledCtrPrp = function() CNumerator.prototype.Get_CompiledCtrPrp = function()
{ {
return this.Parent.Get_CompiledCtrPrp(); return this.Parent.Get_CompiledCtrPrp();
...@@ -664,6 +689,10 @@ CDenominator.prototype.getElement = function(txt) ...@@ -664,6 +689,10 @@ CDenominator.prototype.getElement = function(txt)
{ {
return this.elements[0][0]; return this.elements[0][0];
} }
CDenominator.prototype.fillMathComposition = function(content)
{
this.elements[0][0] = content;
}
CDenominator.prototype.Get_CompiledCtrPrp = function() CDenominator.prototype.Get_CompiledCtrPrp = function()
{ {
return this.Parent.Get_CompiledCtrPrp(); return this.Parent.Get_CompiledCtrPrp();
......
...@@ -11,26 +11,17 @@ function CLimit(props) ...@@ -11,26 +11,17 @@ function CLimit(props)
CMathBase.call(this); CMathBase.call(this);
if(props.type === LIMIT_UP || props.type === LIMIT_LOW) if(props !== null && typeof(props) !== "undefined")
this.Pr.type = props.type; this.init(props);
this.setDimension(2, 1);
var oBase = new CMathContent();
var oIter = new CMathContent();
oIter.decreaseArgSize();
if(this.Pr.type == LIMIT_LOW)
this.addMCToContent(oBase, oIter);
else if(this.Pr.type == LIMIT_UP)
this.addMCToContent(oIter, oBase);
this.setCtrPrp(props.ctrPrp);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CLimit, CMathBase); extend(CLimit, CMathBase);
CLimit.prototype.init = function(props)
{
this.setProperties(props);
this.fillContent();
}
CLimit.prototype.getAscent = function() CLimit.prototype.getAscent = function()
{ {
var ascent; var ascent;
...@@ -65,6 +56,50 @@ CLimit.prototype.setDistance = function() ...@@ -65,6 +56,50 @@ CLimit.prototype.setDistance = function()
{ {
this.dH = 0.03674768518518519*this.Get_CompiledCtrPrp().FontSize; this.dH = 0.03674768518518519*this.Get_CompiledCtrPrp().FontSize;
} }
CLimit.prototype.setProperties = function(props)
{
if(props.type === LIMIT_UP || props.type === LIMIT_LOW)
this.Pr.type = props.type;
this.setCtrPrp(props.ctrPrp);
}
CLimit.prototype.fillContent = function()
{
this.setDimension(2, 1);
var oBase = new CMathContent();
var oIter = new CMathContent();
oIter.decreaseArgSize();
if(this.Pr.type == LIMIT_LOW)
this.addMCToContent(oBase, oIter);
else if(this.Pr.type == LIMIT_UP)
this.addMCToContent(oIter, oBase);
}
CLimit.prototype.fillMathComposition = function(props, contents /*array*/)
{
this.setProperties(props);
this.fillContent();
if(this.Pr.type == LIMIT_LOW)
{
// Base
this.elements[0][0] = contents[0];
// Iterator
this.elements[1][0] = contents[1];
}
else
{
// Iterator
this.elements[0][0] = contents[1];
// Base
this.elements[1][0] = contents[0];
}
}
CLimit.prototype.getPropsForWrite = function() CLimit.prototype.getPropsForWrite = function()
{ {
return this.Pr; return this.Pr;
...@@ -115,14 +150,17 @@ function CMathFunc(props) ...@@ -115,14 +150,17 @@ function CMathFunc(props)
CMathBase.call(this); CMathBase.call(this);
this.setDimension(1, 2); if(props !== null && typeof(props) !== "undefined")
this.setContent(); this.init(props);
this.setCtrPrp(props.ctrPrp);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CMathFunc, CMathBase); extend(CMathFunc, CMathBase);
CMathFunc.prototype.init = function(props)
{
this.setProperties(props);
this.fillContent();
}
CMathFunc.prototype.setDistance = function() CMathFunc.prototype.setDistance = function()
{ {
this.dW = this.Get_CompiledCtrPrp().FontSize/6*g_dKoef_pt_to_mm; this.dW = this.Get_CompiledCtrPrp().FontSize/6*g_dKoef_pt_to_mm;
...@@ -135,6 +173,27 @@ CMathFunc.prototype.getArgument = function() ...@@ -135,6 +173,27 @@ CMathFunc.prototype.getArgument = function()
{ {
return this.elements[0][1]; return this.elements[0][1];
} }
CMathFunc.prototype.setProperties = function(props)
{
this.setCtrPrp(props.ctrPrp);
}
CMathFunc.prototype.fillContent = function()
{
this.setDimension(1, 2);
this.setContent();
}
CMathFunc.prototype.fillMathComposition = function(props, contents /*array*/)
{
this.setProperties(props);
this.fillContent();
// FName
this.elements[0][0] = contents[0];
// Argument
this.element[0][1] = contents[1];
}
CMathFunc.prototype.getPropsForWrite = function() CMathFunc.prototype.getPropsForWrite = function()
{ {
var props = {}; var props = {};
......
This diff is collapsed.
...@@ -18,25 +18,18 @@ function CNary(props) ...@@ -18,25 +18,18 @@ function CNary(props)
limLoc: null limLoc: null
}; };
//this.limLoc = null;
//this.type = null;
//this.code = null; // for "read"
//this.grow = false;
//this.supHide = false;
//this.subHide = false;
CMathBase.call(this); CMathBase.call(this);
this.init(props); if(props !== null && typeof(props) !== "undefined")
//this.setCtrPrp(props.ctrPrp); this.init(props);
g_oTableId.Add( this, this.Id ); g_oTableId.Add( this, this.Id );
} }
extend(CNary, CMathBase); extend(CNary, CMathBase);
CNary.prototype.init = function(props) CNary.prototype.init = function(props)
{ {
if(props.ctrPrp !== null && typeof(props.ctrPrp)!== "undefined") this.setCtrPrp(props.ctrPrp);
this.setCtrPrp(props.ctrPrp);
if(props.supHide === true || props.supHide === 1) if(props.supHide === true || props.supHide === 1)
this.Pr.supHide = true; this.Pr.supHide = true;
...@@ -51,8 +44,6 @@ CNary.prototype.init = function(props) ...@@ -51,8 +44,6 @@ CNary.prototype.init = function(props)
var oSign = this.getSign(props.chr, props.signType); var oSign = this.getSign(props.chr, props.signType);
//this.Pr.chrType = oSign.chrType;
//this.Pr.chr = String.fromCharCode(oSign.chrCode);
this.Pr.chrType = props.chrType; this.Pr.chrType = props.chrType;
this.Pr.chr = props.chr; this.Pr.chr = props.chr;
...@@ -65,8 +56,6 @@ CNary.prototype.init = function(props) ...@@ -65,8 +56,6 @@ CNary.prototype.init = function(props)
{ {
var bIntegral = oSign.chrCode > 0x222A && oSign.chrCode < 0x2231; var bIntegral = oSign.chrCode > 0x222A && oSign.chrCode < 0x2231;
//var MPrp = this.Parent.Composition.GetMathPr();
if(bIntegral) if(bIntegral)
this.Pr.limLoc = g_oMathSettings.intLim; this.Pr.limLoc = g_oMathSettings.intLim;
else else
...@@ -106,19 +95,20 @@ CNary.prototype.init = function(props) ...@@ -106,19 +95,20 @@ CNary.prototype.init = function(props)
} }
else else
{ {
var prp;
if( this.Pr.supHide && !this.Pr.subHide ) if( this.Pr.supHide && !this.Pr.subHide )
{ {
var prp = {type: DEGREE_SUBSCRIPT, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy() }; prp = {type: DEGREE_SUBSCRIPT, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy() };
base = new CDegree(prp); base = new CDegree(prp);
} }
else if( !this.Pr.supHide && this.Pr.subHide ) else if( !this.Pr.supHide && this.Pr.subHide )
{ {
var prp = {type: DEGREE_SUPERSCRIPT, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy()}; prp = {type: DEGREE_SUPERSCRIPT, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy()};
base = new CDegree(prp); base = new CDegree(prp);
} }
else else
{ {
var prp = {type: DEGREE_SubSup, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy()}; prp = {type: DEGREE_SubSup, indef: 2, oBase: oSign.operator, ctrPrp: this.CtrPrp.Copy()};
base = new CDegreeSubSup(prp); base = new CDegreeSubSup(prp);
} }
} }
...@@ -283,14 +273,7 @@ CNary.prototype.getLowerIterator = function() ...@@ -283,14 +273,7 @@ CNary.prototype.getLowerIterator = function()
} }
CNary.prototype.getPropsForWrite = function() CNary.prototype.getPropsForWrite = function()
{ {
var props = { return this.Pr;
chr: String.fromCharCode(this.code),
grow: this.grow,
limLoc: this.limLoc,
subHide: this.subHide,
supHide: this.supHide
};
return props;
} }
CNary.prototype.Save_Changes = function(Data, Writer) CNary.prototype.Save_Changes = function(Data, Writer)
{ {
......
...@@ -2267,7 +2267,7 @@ function COperator(type) ...@@ -2267,7 +2267,7 @@ function COperator(type)
this.shiftAccent = 0; this.shiftAccent = 0;
} }
COperator.prototype.setProperties = function(properties, defaultProps) // props (chr, type, location), defaultProps (chr, location) COperator.prototype.mergeProperties = function(properties, defaultProps) // props (chr, type, location), defaultProps (chr, location)
{ {
var props = this.getProps(properties, defaultProps); var props = this.getProps(properties, defaultProps);
...@@ -3522,7 +3522,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3522,7 +3522,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure)
{ {
type: PARENTHESIS_LEFT type: PARENTHESIS_LEFT
}; };
this.begOper.setProperties(begPrp, begDefaultPrp); this.begOper.mergeProperties(begPrp, begDefaultPrp);
this.begOper.relate(this); this.begOper.relate(this);
var endPrp = var endPrp =
...@@ -3536,7 +3536,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3536,7 +3536,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure)
type: PARENTHESIS_RIGHT type: PARENTHESIS_RIGHT
}; };
this.endOper.setProperties(endPrp, endDefaultPrp); this.endOper.mergeProperties(endPrp, endDefaultPrp);
this.endOper.relate(this); this.endOper.relate(this);
var sepPrp = var sepPrp =
...@@ -3553,7 +3553,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure) ...@@ -3553,7 +3553,7 @@ CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure)
if(this.nCol == 1 ) if(this.nCol == 1 )
sepPrp.type = OPERATOR_EMPTY; sepPrp.type = OPERATOR_EMPTY;
this.sepOper.setProperties(sepPrp, sepDefaultPrp); this.sepOper.mergeProperties(sepPrp, sepDefaultPrp);
this.sepOper.relate(this); this.sepOper.relate(this);
...@@ -3983,11 +3983,11 @@ function CCharacter() ...@@ -3983,11 +3983,11 @@ function CCharacter()
extend(CCharacter, CMathBase); extend(CCharacter, CMathBase);
CCharacter.prototype.setCharacter = function(props, defaultProps) CCharacter.prototype.setCharacter = function(props, defaultProps)
{ {
this.operator.setProperties(props, defaultProps); this.operator.mergeProperties(props, defaultProps);
this.operator.relate(this); this.operator.relate(this);
this.setDimension(1, 1); //this.setDimension(1, 1);
this.setContent(); //this.setContent();
} }
CCharacter.prototype.Resize = function(Parent, ParaMath, oMeasure) CCharacter.prototype.Resize = function(Parent, ParaMath, oMeasure)
{ {
......
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