Commit 52fc3438 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander.Trofimov

В классах CDegree и CDegreeSubSup выделены базовые классы CDegreeBase и...

В классах CDegree и CDegreeSubSup выделены базовые классы CDegreeBase и CDegreeSubSupBase, которые можно использовать для отрисовки не нарушая логики совместного редактирования. Переделано совместное редактирование в классе CNary.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58697 954022d7-b5bf-4e40-9824-e11837661b57
parent 7915cac8
"use strict";
function CDegree(props, bInside)
function CDegreeBase(props, bInside)
{
CDegree.superclass.constructor.call(this);
CDegreeBase.superclass.constructor.call(this);
this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_DEGREE;
this.upBase = 0; // отступ сверху для основания
......@@ -15,27 +14,25 @@ function CDegree(props, bInside)
type: DEGREE_SUPERSCRIPT
};
this.baseContent = new CMathContent();
this.iterContent = new CMathContent();
this.baseContent = null;
this.iterContent = null;
if(props !== null && typeof(props) !== "undefined")
this.init(props);
g_oTableId.Add( this, this.Id );
}
Asc.extendClass(CDegree, CMathBase);
CDegree.prototype.init = function(props)
Asc.extendClass(CDegreeBase, CMathBase);
CDegreeBase.prototype.init = function(props)
{
this.setProperties(props);
this.fillContent();
this.setDimension(1, 2);
};
CDegree.prototype.fillContent = function()
CDegreeBase.prototype.fillContent = function()
{
this.setDimension(1, 2);
this.elements[0][0] = this.baseContent;
this.elements[0][1] = this.iterContent;
};
CDegree.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
CDegreeBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
......@@ -54,81 +51,7 @@ CDegree.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
else if(this.Pr.type === DEGREE_SUBSCRIPT)
this.recalculateSubScript(oMeasure);
};
CDegree.prototype.old__recalculateSup = function(oMeasure)
{
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var height = 0,
ascent = 0;
var descIter = iter.height - iter.ascent;
var upper = 0;
if(descIter + shCenter > 2/3*base.height)
{
upper = iter.height - 2/3*base.height;
}
else
{
upper = iter.ascent - shCenter;
}
this.upper = upper;
if(upper > 0)
{
height = this.upper + base.height;
ascent = this.upper + base.ascent;
}
else
{
height = base.height;
ascent = base.ascent;
}
var width = base.width + iter.width + this.dW;
this.size = {width: width, height: height, ascent: ascent};
};
CDegree.prototype.old_recalculateSubScript = function(oMeasure)
{
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
/*var FontSize = this.Get_CompiledCtrPrp().FontSize,
shiftCenter = 0.5*DIV_CENT*FontSize;*/
//var ctrPrp = this.Get_CompiledCtrPrp(); // выставить потом размер шрифта для итератора
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var width = base.width + iter.width + this.dW;
var low = 0;
if(iter.ascent - shCenter > 2/3*base.height)
{
low = iter.height - 2/3*base.height;
}
else
{
low = iter.height - iter.ascent + shCenter;
}
var height = base.height + low;
var ascent = base.ascent;
this.upper = -(height - iter.height);
this.size = {width: width, height: height, ascent: ascent};
};
CDegree.prototype.recalculateSup = function(oMeasure)
CDegreeBase.prototype.recalculateSup = function(oMeasure)
{
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
......@@ -183,7 +106,7 @@ CDegree.prototype.recalculateSup = function(oMeasure)
this.size = {width: width, height: height, ascent: ascent};
};
CDegree.prototype.recalculateSubScript = function(oMeasure)
CDegreeBase.prototype.recalculateSubScript = function(oMeasure)
{
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
......@@ -228,7 +151,7 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
this.size = {width: width, height: height, ascent: ascent};
};
CDegree.prototype.setPosition = function(pos, PosInfo)
CDegreeBase.prototype.setPosition = function(pos, PosInfo)
{
this.pos.x = pos.x;
......@@ -250,27 +173,27 @@ CDegree.prototype.setPosition = function(pos, PosInfo)
this.elements[0][0].setPosition(PosBase, PosInfo);
this.elements[0][1].setPosition(PosIter, PosInfo);
};
CDegree.prototype.getIterator = function()
CDegreeBase.prototype.getIterator = function()
{
return this.elements[0][1];
return this.iterContent;
};
CDegree.prototype.getUpperIterator = function()
CDegreeBase.prototype.getUpperIterator = function()
{
return this.elements[0][1];
return this.iterContent;
};
CDegree.prototype.getLowerIterator = function()
CDegreeBase.prototype.getLowerIterator = function()
{
return this.elements[0][1];
return this.iterContent;
};
CDegree.prototype.getBase = function()
CDegreeBase.prototype.getBase = function()
{
return this.elements[0][0];
return this.baseContent;
};
CDegree.prototype.IsPlhIterator = function()
CDegreeBase.prototype.IsPlhIterator = function()
{
return this.elements[0][1].IsPlaceholder();
};
CDegree.prototype.setProperties = function(props)
CDegreeBase.prototype.setProperties = function(props)
{
if(props.type === DEGREE_SUPERSCRIPT || props.type === DEGREE_SUBSCRIPT)
this.Pr.type = props.type;
......@@ -281,13 +204,35 @@ CDegree.prototype.setProperties = function(props)
this.RecalcInfo.bProps = true;
};
CDegree.prototype.setBase = function(base)
CDegreeBase.prototype.setBase = function(base)
{
this.elements[0][0] = base;
this.baseContent = base;
};
CDegree.prototype.setIterator = function(iterator)
CDegreeBase.prototype.setIterator = function(iterator)
{
this.iterContent = iterator;
};
function CDegree(props, bInside)
{
this.Id = g_oIdCounter.Get_NewId();
CDegree.superclass.constructor.call(this, props, bInside);
this.baseContent = new CMathContent();
this.iterContent = new CMathContent();
if(props !== null && typeof(props) !== "undefined")
this.init(props);
g_oTableId.Add( this, this.Id );
}
Asc.extend(CDegree, CDegreeBase);
CDegree.prototype.init = function(props)
{
this.elements[0][1] = iterator;
this.setProperties(props);
this.fillContent();
};
CDegree.prototype.getPropsForWrite = function()
{
......@@ -330,7 +275,7 @@ CDegree.prototype.Get_Id = function()
return this.Id;
};
function CIterators()
function CIterators(iterUp, iterDn)
{
CIterators.superclass.constructor.call(this);
......@@ -348,111 +293,6 @@ CIterators.prototype.init = function()
this.elements[0][0] = this.iterUp;
this.elements[1][0] = this.iterDn;
};
CIterators.prototype.old_old_setDistanceIters = function(oMeasure)
{
var upIter = this.elements[0][0].size,
lowIter = this.elements[1][0].size;
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var upDesc = upIter.height - upIter.ascent + shCenter,
lowAsc = 1.2*(lowIter.ascent - shCenter);
var up = 0;
var down = 0;
if(this.lUp > upDesc)
{
up = this.lUp - upDesc;
this.upper = upIter.height - upDesc;
}
else
{
up = 0;
this.upper = upIter.height - this.lUp;
}
if( this.lD > lowAsc )
down = this.lD - lowAsc;
var minGap = 1.1*shCenter;
if( up + down < minGap)
{
this.dH = minGap;
}
else
{
this.dH = up + down;
}
};
CIterators.prototype.old_setDistanceIters = function(oMeasure)
{
var upIter = this.elements[0][0].size,
lowIter = this.elements[1][0].size;
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var upDesc = upIter.height - upIter.ascent + shCenter,
lowAsc = 1.2*(lowIter.ascent - shCenter);
var up = 0;
var down = 0;
if(this.lUp > upDesc)
{
up = this.lUp - upDesc;
this.upper = upIter.height - upDesc;
}
else
{
up = 0;
this.upper = upIter.height - this.lUp;
}
if( this.lD > lowAsc )
down = this.lD - lowAsc;
var minGap = 0.78*shCenter;
if( up + down < minGap)
{
this.dH = minGap;
}
else
{
this.dH = up + down;
}
};
CIterators.prototype._setDistanceIters = function(oMeasure)
{
var upIter = this.elements[0][0].size,
lowIter = this.elements[1][0].size;
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var upDesc = upIter.height - upIter.ascent + 1.1*shCenter,
lowAsc = 1.2*(lowIter.ascent - shCenter);
var minGap = 0.78*shCenter;
var gapUpper = upIter.height - 1.668*shCenter,
gapLower = lowIter.height - 1.668*shCenter;
this.dH = 0.78*shCenter;
if(gapUpper > 0)
{
this.upper = gapUpper;
}
else
this.upper = 0;
};
CIterators.prototype.getUpperIterator = function()
{
return this.elements[0][0];
......@@ -478,12 +318,10 @@ CIterators.prototype.alignIterators = function(mcJc)
this.alignment.wdt[0] = mcJc;
};
function CDegreeSubSup(props, bInside)
function CDegreeSubSupBase(props, bInside)
{
CDegreeSubSup.superclass.constructor.call(this);
CDegreeSubSupBase.superclass.constructor.call(this);
this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_DEGREESubSup;
this.gapBase = 0;
......@@ -491,27 +329,22 @@ function CDegreeSubSup(props, bInside)
this.Pr =
{
type: DEGREE_SubSup,
alnScr: false
alnScr: false // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
};
this.baseContent = new CMathContent();
this.iters = new CIterators();
//this.type = DEGREE_SubSup;
//this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
this.baseContent = null;
this.iters = new CIterators(null, null);
if(props !== null && typeof(props) !== "undefined")
this.init(props);
g_oTableId.Add( this, this.Id );
}
Asc.extendClass(CDegreeSubSup, CMathBase);
CDegreeSubSup.prototype.init = function(props)
Asc.extendClass(CDegreeSubSupBase, CMathBase);
CDegreeSubSupBase.prototype.init = function(props)
{
this.setProperties(props);
this.fillContent();
this.setDimension(1, 2);
};
CDegreeSubSup.prototype.fillContent = function()
CDegreeSubSupBase.prototype.fillContent = function()
{
var oBase = this.baseContent;
var oIters = this.iters;
......@@ -519,7 +352,6 @@ CDegreeSubSup.prototype.fillContent = function()
this.setDimension(1, 2);
oIters.init();
//oIters.decreaseArgSize();
oIters.lUp = 0;
oIters.lD = 0;
......@@ -535,7 +367,7 @@ CDegreeSubSup.prototype.fillContent = function()
oIters.alignIterators(MCJC_RIGHT);
}
};
CDegreeSubSup.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
CDegreeSubSupBase.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
......@@ -558,245 +390,7 @@ CDegreeSubSup.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSi
this.recalculateSize(oMeasure, RPI);
};
CDegreeSubSup.prototype.old_old_recalculateSize = function(oMeasure)
{
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
shCenter *= 1.2;
var width = 0, height = 0,
ascent = 0;
var iters, base;
if(this.Pr.type == DEGREE_SubSup)
{
iters = this.elements[0][1];
base = this.elements[0][0];
}
else if(this.Pr.type == DEGREE_PreSubSup)
{
iters = this.elements[0][0];
base = this.elements[0][1];
}
iters.lUp = base.size.ascent - shCenter; // center of base
iters.lD = base.size.height - iters.lUp; // height - center of base
iters.setDistanceIters(oMeasure);
iters.recalculateSize();
var smallAsc = mgCtrPrp.FontSize*0.23;
if(base.ascent < smallAsc)
this.dW = 0;
else
this.dW = 0.2*shCenter;
width = iters.size.width + base.size.width + this.dW;
height = iters.size.height;
ascent = iters.upper + base.size.ascent;
this.size = {width: width, height: height, ascent: ascent};
};
CDegreeSubSup.prototype.old_recalculateSize = function(oMeasure)
{
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
shCenter *= 1.2;
var width = 0, height = 0,
ascent = 0;
var iters, base;
if(this.Pr.type == DEGREE_SubSup)
{
iters = this.elements[0][1];
base = this.elements[0][0];
}
else if(this.Pr.type == DEGREE_PreSubSup)
{
iters = this.elements[0][0];
base = this.elements[0][1];
}
// distance for iterators
var iterUp = iters.elements[0][0].size,
iterDown = iters.elements[1][0].size;
var lUp = base.size.ascent - shCenter; // center of base
var lDown = base.size.height - lUp; // height - center of base
var ctrPrpIter = iters.Get_CompiledCtrPrp();
var shIter = this.Composition.GetShiftCenter(oMeasure, ctrPrpIter); //смещение
//var upDesc = iterUp.height - iterUp.ascent + 1.2*shIter, // смещенный descent верхнего итератора
// downAsc = iterDown.ascent + 0.6*shIter; // смещенный ascent нижнего оператора
var upDesc = iterUp.height - shIter,
downAsc = iterDown.height - shIter;
var up = 0, // расстояние от центра основания до верхнего итератора
down = 0; // расстояние от центра основания до нижнего итератора
if(lUp > upDesc)
{
up = lUp - upDesc;
this.gapBase = iterUp.height - upDesc;
}
else
{
up = 0;
this.gapBase = iterUp.height - lUp;
}
if( lDown > downAsc )
down = lDown - downAsc;
var minGap = 0.78*shIter;
if( up + down < minGap)
iters.dH = minGap;
else
iters.dH = up + down;
iters.recalculateSize();
/*var smallAsc = mgCtrPrp.FontSize*0.23;
if(base.ascent < smallAsc)
this.dW = 0;
else
this.dW = 0.2*shCenter;*/
width = iters.size.width + base.size.width + this.dW;
height = iters.size.height;
ascent = base.size.ascent + this.gapBase;
this.size = {width: width, height: height, ascent: ascent};
};
CDegreeSubSup.prototype._recalculateSize = function(oMeasure)
{
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
shCenter *= 1.4;
var width = 0, height = 0,
ascent = 0;
var iters, base;
if(this.Pr.type == DEGREE_SubSup)
{
iters = this.elements[0][1];
base = this.elements[0][0];
}
else if(this.Pr.type == DEGREE_PreSubSup)
{
iters = this.elements[0][0];
base = this.elements[0][1];
}
// distance for iterators
var iterUp = iters.elements[0][0].size,
iterDown = iters.elements[1][0].size;
var lUp = base.size.ascent - shCenter; // center of base
var lDown = base.size.height - lUp; // height - center of base
var ctrPrpIter = iters.Get_CompiledCtrPrp();
var shIter = this.Composition.GetShiftCenter(oMeasure, ctrPrpIter); //смещение
//var upDesc = iterUp.height - iterUp.ascent + 1.2*shIter, // смещенный descent верхнего итератора
// downAsc = iterDown.ascent + 0.6*shIter; // смещенный ascent нижнего оператора
var up = 0, // расстояние от центра основания до верхнего итератора
down = 0; // расстояние от центра основания до нижнего итератора
var minGap = 0.7*shIter;
/*if(base.size.height > upDesc + downAsc + minGap)
{
iters.dH = base.size.height - upDesc - downAsc;
this.gapBase = iterUp.height - upDesc;
}
else
{
iters.dH = minGap;
this.gapBase = iterUp.height - (lUp - minGap/2);
}*/
if(base.IsPlaceholder())
{
iters.dH = minGap;
this.gapBase = iterUp.height - (lUp - minGap/2);
}
else
{
var upDesc = iterUp.height - 0.5*shIter,
downAsc = iterDown.height - shIter;
if(base.size.ascent > upDesc + downAsc + minGap )
{
iters.dH = base.size.height - upDesc - downAsc;
this.gapBase = iterUp.height - upDesc;
}
else
{
iters.dH = minGap;
this.gapBase = iterUp.height - (lUp - minGap/2);
}
}
/*if(lUp > upDesc)
{
up = lUp - upDesc;
this.gapBase = iterUp.height - upDesc;
}
else
{
up = 0;
this.gapBase = iterUp.height - lUp;
}
if( lDown > downAsc )
down = lDown - downAsc;*/
/*if( up + down < minGap)
iters.dH = minGap;
else
iters.dH = up + down;*/
iters.recalculateSize();
/*var smallAsc = mgCtrPrp.FontSize*0.23;
if(base.ascent < smallAsc)
this.dW = 0;
else
this.dW = 0.2*shCenter;*/
width = iters.size.width + base.size.width + this.dW;
height = iters.size.height;
ascent = base.size.ascent + this.gapBase;
this.size = {width: width, height: height, ascent: ascent};
};
CDegreeSubSup.prototype.recalculateSize = function(oMeasure, RPI)
CDegreeSubSupBase.prototype.recalculateSize = function(oMeasure, RPI)
{
var mgCtrPrp = this.Get_CompiledCtrPrp();
......@@ -879,44 +473,11 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure, RPI)
this.size = {width: width, height: height, ascent: ascent};
};
CDegreeSubSup.prototype.setPosition = function(pos, PosInfo)
CDegreeSubSupBase.prototype.setPosition = function(pos, PosInfo)
{
CDegreeSubSup.superclass.setPosition.call(this, pos, PosInfo);
};
CDegreeSubSup.prototype.old_setPosition = function(pos)
{
this.pos = {x: pos.x, y: pos.y - this.size.ascent};
if(this.Pr.type == DEGREE_SubSup)
{
var iters = this.elements[0][1],
base = this.elements[0][0];
var posBase = {x: this.pos.x, y: this.pos.y + iters.upper},
posIters = {x: this.pos.x + base.size.width, y: this.pos.y};
base.setPosition(posBase);
iters.setPosition(posIters);
}
};
CDegreeSubSup.prototype.old_align = function(x, y)
{
var _x = 0, _y = 0;
if(this.Pr.type == DEGREE_SubSup)
{
if(x == 0 && y == 0)
_y = this.elements[0][1].upper;
}
else
{
if(x == 0 && y == 1)
_y = this.elements[0][0].upper;
}
return {x: _x, y: _y};
};
CDegreeSubSup.prototype.align = function(x, y)
CDegreeSubSupBase.prototype.align = function(x, y)
{
var _x = 0, _y = 0;
......@@ -933,61 +494,31 @@ CDegreeSubSup.prototype.align = function(x, y)
return {x: _x, y: _y};
};
CDegreeSubSup.prototype.getBase = function()
CDegreeSubSupBase.prototype.getBase = function()
{
var base;
if(this.Pr.type == DEGREE_SubSup)
base = this.elements[0][0];
else if(this.Pr.type == DEGREE_PreSubSup)
base = this.elements[0][1];
return base;
return this.baseContent;
};
CDegreeSubSup.prototype.getUpperIterator = function()
CDegreeSubSupBase.prototype.getUpperIterator = function()
{
var iter;
if(this.Pr.type == DEGREE_SubSup)
iter = this.elements[0][1].getUpperIterator();
else if(this.Pr.type == DEGREE_PreSubSup)
iter = this.elements[0][0].getUpperIterator();
return iter;
return this.iters.iterUp;
};
CDegreeSubSup.prototype.getLowerIterator = function()
CDegreeSubSupBase.prototype.getLowerIterator = function()
{
var iter;
if(this.Pr.type == DEGREE_SubSup)
iter = this.elements[0][1].getLowerIterator();
else if(this.Pr.type == DEGREE_PreSubSup)
iter = this.elements[0][0].getLowerIterator();
return iter;
return this.iters.iterDn;
};
CDegreeSubSup.prototype.setBase = function(base)
CDegreeSubSupBase.prototype.setBase = function(base)
{
if(this.Pr.type == DEGREE_SubSup)
this.elements[0][0] = base;
else
this.elements[0][1] = base;
this.baseContent = base;
};
CDegreeSubSup.prototype.setUpperIterator = function(iterator)
CDegreeSubSupBase.prototype.setUpperIterator = function(iterator)
{
if(this.Pr.type == DEGREE_SubSup)
this.elements[0][1].setUpperIterator(iterator);
else
this.elements[0][0].setUpperIterator(iterator);
this.iters.iterUp = iterator;
};
CDegreeSubSup.prototype.setLowerIterator = function(iterator)
CDegreeSubSupBase.prototype.setLowerIterator = function(iterator)
{
if(this.Pr.type == DEGREE_SubSup)
this.elements[0][1].setLowerIterator(iterator);
else
this.elements[0][0].setLowerIterator(iterator);
this.iters.iterDn = iterator;
};
CDegreeSubSup.prototype.setProperties = function(props)
CDegreeSubSupBase.prototype.setProperties = function(props)
{
if(props.alnScr === true || props.alnScr === 1)
this.Pr.alnScr = true;
......@@ -1001,13 +532,34 @@ CDegreeSubSup.prototype.setProperties = function(props)
this.RecalcInfo.bProps = true;
};
function CDegreeSubSup(props, bInside)
{
this.Id = g_oIdCounter.Get_NewId();
CDegreeSubSup.superclass.constructor.call(this, props, bInside);
this.baseContent = new CMathContent();
this.iters = new CIterators(new CMathContent(), new CMathContent());
if(props !== null && typeof(props) !== "undefined")
this.init(props);
g_oTableId.Add( this, this.Id );
}
Asc.extendClass(CDegreeSubSup, CDegreeSubSupBase);
CDegreeSubSup.prototype.init = function(props)
{
this.setProperties(props);
this.fillContent();
};
CDegreeSubSup.prototype.getPropsForWrite = function()
{
return this.Pr;
};
CDegreeSubSup.prototype.Save_Changes = function(Data, Writer)
{
Writer.WriteLong( historyitem_type_deg_subsup );
Writer.WriteLong( historyitem_type_deg_subsup );
};
CDegreeSubSup.prototype.Load_Changes = function(Reader)
{
......@@ -1017,29 +569,29 @@ CDegreeSubSup.prototype.Refresh_RecalcData = function(Data)
};
CDegreeSubSup.prototype.Write_ToBinary2 = function( Writer )
{
Writer.WriteLong( historyitem_type_deg_subsup );
Writer.WriteLong( historyitem_type_deg_subsup );
Writer.WriteString2(this.Id);
Writer.WriteString2(this.baseContent.Id);
Writer.WriteString2(this.iters.iterDn.Id);
Writer.WriteString2(this.iters.iterUp.Id);
this.CtrPrp.Write_ToBinary(Writer);
Writer.WriteLong( this.Pr.type );
if ( this.Pr.type == DEGREE_SubSup )
{
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var Flags = 0;
if ( undefined != this.Pr.alnScr )
{
Writer.WriteBool( this.Pr.alnScr );
Flags |= 1;
}
var EndPos = Writer.GetCurPosition();
Writer.Seek( StartPos );
Writer.WriteLong( Flags );
Writer.Seek( EndPos );
}
Writer.WriteString2(this.baseContent.Id);
Writer.WriteString2(this.iters.iterDn.Id);
Writer.WriteString2(this.iters.iterUp.Id);
this.CtrPrp.Write_ToBinary(Writer);
Writer.WriteLong( this.Pr.type );
if ( this.Pr.type == DEGREE_SubSup )
{
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var Flags = 0;
if ( undefined != this.Pr.alnScr )
{
Writer.WriteBool( this.Pr.alnScr );
Flags |= 1;
}
var EndPos = Writer.GetCurPosition();
Writer.Seek( StartPos );
Writer.WriteLong( Flags );
Writer.Seek( EndPos );
}
};
CDegreeSubSup.prototype.Read_FromBinary2 = function( Reader )
{
......@@ -1049,20 +601,20 @@ CDegreeSubSup.prototype.Read_FromBinary2 = function( Reader )
this.iters.iterDn = g_oTableId.Get_ById(Reader.GetString2());
this.iters.iterUp = g_oTableId.Get_ById(Reader.GetString2());
var props = {ctrPrp: new CTextPr()};
props.ctrPrp.Read_FromBinary(Reader);
var props = {ctrPrp: new CTextPr()};
props.ctrPrp.Read_FromBinary(Reader);
props.type = Reader.GetLong();
if ( props.type == DEGREE_SubSup )
{
var Flags = Reader.GetLong();
if ( Flags & 1 )
props.alnScr = Reader.GetBool();
}
if ( props.type == DEGREE_SubSup )
{
var Flags = Reader.GetLong();
if ( Flags & 1 )
props.alnScr = Reader.GetBool();
}
this.init(props);
this.iters.init();
};
CDegreeSubSup.prototype.Get_Id = function()
{
return this.Id;
return this.Id;
};
......@@ -4,21 +4,82 @@
//если не выставлено в настройках
/////////////////////****//////////////////////////
function CMathNaryPr()
{
this.chr = null;
this.chrType = NARY_INTEGRAL;
this.grow = false;
this.limLoc = null;
this.subHide = false;
this.supHide = false;
}
CMathNaryPr.prototype.Set_FromObject = function(Obj)
{
this.chr = Obj.chr;
this.chrType = Obj.chrType;
if(true === Obj.grow === true || 1 === Obj.grow)
this.grow = true;
if(NARY_UndOvr === Obj.limLoc || NARY_SubSup === Obj.limLoc)
this.limLoc = Obj.limLoc;
if(true === Obj.subHide === true || 1 === Obj.subHide)
this.subHide = true;
if(true === Obj.supHide === true || 1 === Obj.supHide)
this.supHide = true;
};
CMathNaryPr.prototype.Write_ToBinary = function(Writer)
{
// Long : chr
// Long : chrType
// Bool : grow
// Long : limLoc
// Bool : subHide
// Bool : supHide
Writer.WriteLong(this.chr === null ? -1 : this.chr);
Writer.WriteLong(this.chrType);
Writer.WriteBool(this.grow);
Writer.WriteLong(this.limLoc === null ? -1 : this.limLoc);
Writer.WriteBool(this.subHide);
Writer.WriteBool(this.supHide);
};
CMathNaryPr.prototype.Read_FromBinary = function(Reader)
{
// Long : chr
// Long : chrType
// Bool : grow
// Long : limLoc
// Bool : subHide
// Bool : supHide
this.chr = Reader.GetLong();
this.chrType = Reader.GetLong();
this.grow = Reader.GetBool();
this.limLoc = Reader.GetLong();
this.subHide = Reader.GetBool();
this.supHide = Reader.GetBool();
if (-1 === this.chr)
this.chr = null;
if (-1 === this.limLoc)
this.limLoc = null;
};
function CNary(props)
{
CNary.superclass.constructor.call(this);
this.Id = g_oIdCounter.Get_NewId();
this.kind = MATH_NARY;
this.Pr =
{
chr: null,
chrType: NARY_INTEGRAL,
supHide: false,
subHide: false,
grow: false,
limLoc: null
};
this.Pr = new CMathNaryPr();
this.Base = null;
this.Sign = null;
......@@ -26,8 +87,6 @@ function CNary(props)
this.UpperIterator = new CMathContent();
this.Arg = new CMathContent();
CMathBase.call(this);
if(props !== null && typeof(props) !== "undefined")
this.init(props);
......@@ -37,27 +96,11 @@ Asc.extendClass(CNary, CMathBase);
CNary.prototype.init = function(props)
{
this.setProperties(props);
//this.fillContent();
}
CNary.prototype.setProperties = function(props)
{
this.setCtrPrp(props.ctrPrp);
if(props.supHide === true || props.supHide === 1)
this.Pr.supHide = true;
if(props.subHide === true || props.subHide === 1)
this.Pr.subHide = true;
if(props.grow === true || props.grow === 1)
this.Pr.grow = true;
this.Pr.chrType = props.chrType;
this.Pr.chr = props.chr;
if(props.limLoc == NARY_UndOvr || props.limLoc == NARY_SubSup)
this.Pr.limLoc = props.limLoc;
this.Pr.Set_FromObject(props);
}
CNary.prototype.fillContent = function(PropsInfo)
{
......@@ -101,14 +144,15 @@ CNary.prototype.fillContent = function(PropsInfo)
if( PropsInfo.supHide && !PropsInfo.subHide )
{
prp = {type: DEGREE_SUBSCRIPT, ctrPrp: ctrPrp};
base = new CDegree(prp, true);
base = new CDegreeBase(prp, true);
base.setBase(Sign);
base.setIterator(this.LowerIterator);
base.fillContent();
}
else if( !PropsInfo.supHide && PropsInfo.subHide )
{
prp = {type: DEGREE_SUPERSCRIPT, ctrPrp: ctrPrp};
base = new CDegree(prp, true);
base = new CDegreeBase(prp, true);
base.setBase(Sign);
base.setIterator(this.UpperIterator);
}
......@@ -119,10 +163,11 @@ CNary.prototype.fillContent = function(PropsInfo)
else
{
prp = {type: DEGREE_SubSup, ctrPrp: ctrPrp};
base = new CDegreeSubSup(prp, true);
base = new CDegreeSubSupBase(prp, true);
base.setBase(Sign);
base.setLowerIterator(this.LowerIterator);
base.setUpperIterator(this.UpperIterator);
base.fillContent();
}
}
......@@ -130,36 +175,6 @@ CNary.prototype.fillContent = function(PropsInfo)
this.addMCToContent( [base, this.Arg] );
}
CNary.prototype.fillMathComposition = function(props, contents /*array*/)
{
this.setProperties(props);
this.RecalcInfo.bProps = true;
this.Arg = contents[0];
this.UpperIterator = contents[1];
this.LowerIterator = contents[2];
}
CNary.prototype.old_fillMathComposition = function(props, contents /*array*/)
{
this.setProperties(props);
this.fillContent();
// Base
this.elements[0][1] = contents[0];
// Upper iterator
if(!this.Pr.subHide)
this.elements[0][0].changeUpperIterator(contents[1]);
// Lower iterator
if(!this.Pr.subHide)
this.elements[0][0].changeLowerIterator(contents[2]);
}
CNary.prototype.Resize = function(oMeasure, Parent, ParaMath, RPI, ArgSize)
{
......@@ -342,19 +357,16 @@ CNary.prototype.setDistance = function()
CNary.prototype.getBase = function()
{
return this.Arg;
//return this.elements[0][1];
}
CNary.prototype.getUpperIterator = function()
{
if (!this.Pr.supHide)
return this.UpperIterator;
//return this.elements[0][0].getUpperIterator();
}
CNary.prototype.getLowerIterator = function()
{
if (!this.Pr.subHide)
return this.LowerIterator;
//return this.elements[0][0].getLowerIterator();
}
CNary.prototype.getPropsForWrite = function()
{
......@@ -373,82 +385,27 @@ CNary.prototype.Refresh_RecalcData = function(Data)
CNary.prototype.Write_ToBinary2 = function( Writer )
{
Writer.WriteLong( historyitem_type_nary );
Writer.WriteString2( this.getBase().Id );
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var Flags = 0;
if ( undefined != this.getUpperIterator() )
{
Writer.WriteString2(this.getUpperIterator().Id);
Flags |= 1;
}
if ( undefined != this.getLowerIterator())
{
Writer.WriteString2(this.getLowerIterator().Id);
Flags |= 2;
}
var EndPos = Writer.GetCurPosition();
Writer.Seek( StartPos );
Writer.WriteLong( Flags );
Writer.Seek( EndPos );
Writer.WriteString2(this.Id);
Writer.WriteString2(this.Arg.Id);
Writer.WriteString2(this.LowerIterator.Id);
Writer.WriteString2(this.UpperIterator.Id);
this.CtrPrp.Write_ToBinary(Writer);
var StartPos = Writer.GetCurPosition();
Writer.Skip(4);
var Flags = 0;
if ( undefined != this.Pr.chr )
{
Writer.WriteLong(this.Pr.chr);
Flags |= 1;
}
if ( undefined != this.Pr.limLoc )
{
Writer.WriteLong(this.Pr.limLoc);
Flags |= 2;
}
if ( undefined != this.Pr.subHide )
{
Writer.WriteBool(this.Pr.subHide);
Flags |= 4;
}
if ( undefined != this.Pr.supHide )
{
Writer.WriteBool(this.Pr.supHide);
Flags |= 8;
}
var EndPos = Writer.GetCurPosition();
Writer.Seek( StartPos );
Writer.WriteLong( Flags );
Writer.Seek( EndPos );
this.Pr.Write_ToBinary(Writer);
}
CNary.prototype.Read_FromBinary2 = function( Reader )
{
var props = {ctrPrp: new CTextPr()};
var arrElems = [];
arrElems.push(g_oTableId.Get_ById( Reader.GetString2()));
var Flags = Reader.GetLong();
if ( Flags & 1 )
arrElems.push(g_oTableId.Get_ById( Reader.GetString2()));
if ( Flags & 2 )
arrElems.push(g_oTableId.Get_ById( Reader.GetString2()));
props.ctrPrp.Read_FromBinary(Reader);
var Flags = Reader.GetLong();
if ( Flags & 1 )
props.chr = Reader.GetLong();
if ( Flags & 2 )
props.limLoc = Reader.GetLong();
if ( Flags & 4 )
props.subHide = Reader.GetBool();
if ( Flags & 8 )
props.supHide = Reader.GetBool();
this.fillMathComposition (props, arrElems);
this.Id = Reader.GetString2();
this.Arg = g_oTableId.Get_ById(Reader.GetString2());
this.LowerIterator = g_oTableId.Get_ById(Reader.GetString2());
this.UpperIterator = g_oTableId.Get_ById(Reader.GetString2());
this.CtrPrp.Read_FromBinary(Reader);
this.Pr.Read_FromBinary(Reader);
this.RecalcInfo.bProps = true;
}
CNary.prototype.Get_Id = function()
{
......@@ -464,16 +421,6 @@ function CNaryUnd(bInside)
//this.init();
}
Asc.extendClass(CNaryUnd, CMathBase);
/*CNaryUnd.prototype.old_init = function()
{
this.setDimension(2,1);
var iter = new CMathContent();
iter.decreaseArgSize();
var base = new CMathContent();
this.addMCToContent(iter, base);
}*/
CNaryUnd.prototype.setDistance = function()
{
var zetta = this.Get_CompiledCtrPrp().FontSize*25.4/96;
......@@ -517,16 +464,6 @@ function CNaryOvr(bInside)
this.setDimension(2, 1);
}
Asc.extendClass(CNaryOvr, CMathBase);
/*CNaryOvr.prototype.old_init = function()
{
this.setDimension(2,1);
var iter = new CMathContent();
iter.decreaseArgSize();
var base = new CMathContent();
this.addMCToContent(base, iter);
}*/
CNaryOvr.prototype.old_setDistance = function()
{
var zetta = this.Get_CompiledCtrPrp().FontSize* 25.4/96;
......
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