Commit 308bb93a authored by Anna.Pavlova's avatar Anna.Pavlova

1. Реализовала getPropsForWhite на запись в файл

2. Поправила CAccent 
3. Поправила CBar

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53207 954022d7-b5bf-4e40-9824-e11837661b57
parent 35c9c87b
......@@ -20,18 +20,18 @@ function CCircumflex()
this.Parent = null;
this.turn = TURN_0;
}
CCircumflex.prototype.setTurn = function(turn)
CCircumflex.prototype.init = function(props)
{
this.turn = turn;
this.turn = props.turn;
}
CCircumflex.prototype.fixSize = function(mesure, bIncl)
CCircumflex.prototype.fixSize = function(oMeasure, stretch, bIncl)
{
var alpha = this.Parent.getCtrPrp().FontSize/36;
var width = 3.88*alpha;
var height = 3.175*alpha;
var augm = 0.9*mesure/width;
var augm = 0.9*stretch/width;
if(augm < 1)
augm = 1;
......@@ -189,14 +189,18 @@ function CLine()
this.PEN_W = 0.04;
this.Parent = null;
}
CLine.prototype.fixSize = function(measure)
CLine.prototype.init = function(props)
{
}
CLine.prototype.fixSize = function(oMeasure, stretch)
{
var alpha = this.Parent.getCtrPrp().FontSize/36;
var height = 1.68*alpha;
var width = 4.938*alpha;
width = measure > width ? measure : width;
width = stretch > width ? stretch : width;
this.size = {width: width, height: height}
}
......@@ -240,14 +244,18 @@ function CDoubleLine()
this.PEN_W = 0.04;
this.Parent = null;
}
CDoubleLine.prototype.fixSize = function(measure)
CDoubleLine.prototype.init = function(props)
{
}
CDoubleLine.prototype.fixSize = function(oMeasure, stretch)
{
var alpha = this.Parent.getCtrPrp().FontSize/36;
var height = 2.843*alpha;
var width = 4.938*alpha;
width = measure > width ? measure : width;
width = stretch > width ? stretch : width;
this.size = {width: width, height: height}
}
......@@ -290,6 +298,10 @@ CDoubleLine.prototype.relate = function(parent)
function CTilde()
{
}
CTilde.prototype.init = function(props)
{
}
CTilde.prototype.fixSize = function()
{
......@@ -396,9 +408,9 @@ function CBreve()
{
this.turn = TURN_MIRROR_0;
}
CBreve.prototype.setTurn = function(tturn)
CBreve.prototype.init = function(props)
{
this.turn = tturn;
this.turn = props.turn;
}
CBreve.prototype.fixSize = function()
{
......@@ -511,10 +523,10 @@ CBreve.prototype.relate = function(parent)
function CSign()
{
this.sign = new CMathText();
this.type = null;
this.typeOper = null;
this.Parent = null;
}
CSign.prototype.setSign = function(props)
CSign.prototype.init = function(props)
{
var bDot = props.code === 0x307 || props.type === ACCENT_ONE_DOT,
b2Dots = props.code === 0x308 || props.type === ACCENT_TWO_DOTS,
......@@ -524,32 +536,32 @@ CSign.prototype.setSign = function(props)
if(bDot)
{
this.type = ACCENT_ONE_DOT;
this.typeOper = ACCENT_ONE_DOT;
this.sign.add(0x307);
}
else if(b2Dots)
{
this.type = ACCENT_TWO_DOTS;
this.typeOper = ACCENT_TWO_DOTS;
this.sign.add(0x308);
}
else if(b3Dots)
{
this.type = ACCENT_THREE_DOTS;
this.typeOper = ACCENT_THREE_DOTS;
this.sign.add(0x20DB);
}
else if(bAccGrave)
{
this.type = ACCENT_GRAVE;
this.typeOper = ACCENT_GRAVE;
this.sign.add(0x300);
}
else if(bAccAcute)
{
this.type = ACCENT_ACUTE;
this.typeOper = ACCENT_ACUTE;
this.sign.add(0x301);
}
else
{
this.type = ACCENT_TEXT;
this.typeOper = ACCENT_TEXT;
this.sign.add(props.code);
}
}
......@@ -557,25 +569,25 @@ CSign.prototype.setPosition = function(pos)
{
var shX = 0;
if(this.type == ACCENT_GRAVE)
if(this.typeOper == ACCENT_GRAVE)
shX = 1.1*this.sign.size.widthG;
else if(this.type == ACCENT_ACUTE)
else if(this.typeOper == ACCENT_ACUTE)
shX = 1.25*this.sign.size.widthG;
else if(this.type == ACCENT_ONE_DOT)
else if(this.typeOper == ACCENT_ONE_DOT)
shX = 1.53*this.sign.size.widthG;
else if(this.type == ACCENT_TWO_DOTS)
else if(this.typeOper == ACCENT_TWO_DOTS)
shX = 0.95*this.sign.size.widthG;
else if(this.type == ACCENT_THREE_DOTS)
else if(this.typeOper == ACCENT_THREE_DOTS)
shX = 0.015*this.sign.size.widthG;
var position =
{
x: pos.x + shX ,
x: pos.x + shX,
y: pos.y + this.sign.size.ascent
};
this.sign.setPosition(position);
}
CSign.prototype.fixSize = function(bIncline)
CSign.prototype.old_fixSize = function(bIncline)
{
this.sign.recalculateSize();
......@@ -589,6 +601,32 @@ CSign.prototype.fixSize = function(bIncline)
this.size = {width: width, height: height};
}
CSign.prototype.fixSize = function(oMeasure, stretch, bIncline)
{
var ctrPrp = this.Parent.getCtrPrp();
var rPrp = new CMathTextPrp();
rPrp.Merge(DEFAULT_RUN_PRP);
rPrp.Merge(ctrPrp);
rPrp.Italic = false;
oMeasure.SetFont(rPrp);
this.sign.Resize(oMeasure);
if(this.typeOper == ACCENT_THREE_DOTS)
this.dH = 1.2*ctrPrp.FontSize/36;
else
this.dH = 1.2*ctrPrp.FontSize/36;
var height = this.sign.size.height + this.dH,
width = this.sign.size.widthG;
if(bIncline)
width += 0.1 * this.sign.size.height; // incline
this.size = {width: width, height: height};
}
CSign.prototype.draw = function(pGraphics)
{
this.sign.draw(pGraphics);
......@@ -597,7 +635,7 @@ CSign.prototype.relate = function(parent)
{
this.Parent = parent;
}
CSign.prototype.getCodeAccent = function()
CSign.prototype.getCodeCharacter = function()
{
return this.sign.value;
}
......@@ -606,24 +644,45 @@ function CAccent()
{
this.kind = MATH_ACCENT;
this.operator = new COperator(OPER_ACCENT);
this.code = null; // храним код буквы и тип здесь
this. type = null; // т.к в класах, которые вызываем, не учитываем случаи, когда элементы (стрелки/скобки) переворачиваются
this.loc = LOCATION_TOP;
CCharacter.call(this);
}
extend(CAccent, CCharacter);
CAccent.prototype.init = function(props)
CAccent.prototype._for_operator_init = function(props)
{
var code, accent;
var type = props.chrType;
var prp =
{
chr: props.chr,
type: props.chrType
};
var defaultPrp =
{
type: ACCENT_COMB_CARON
};
this.setCharacter(prp, defaultPrp);
}
CAccent.prototype.init = function(properties)
{
var type = properties.chrType,
code;
var typeOper, codeChr;
var operator;
//// ВРЕМЕННО !!!!
var bCode = false,
bType = typeof(type) !== "undefined" && type !== null;
if(typeof(props.chr) === "string")
if(typeof(properties.chr) === "string")
{
bCode = true;
code = props.chr.charCodeAt(0);
code = properties.chr.charCodeAt(0);
}
/*var bDot = code === 0x307 || props.chr.type === ACCENT_ONE_DOT,
......@@ -636,12 +695,234 @@ CAccent.prototype.init = function(props)
{
this.accent = new CMathText();
this.accent.add(code);
this.type = props.chr.type;
typeOper = props.chr.type;
}*/
if(code === 0x302 || type === ACCENT_CIRCUMFLEX)
{
this.type = ACCENT_CIRCUMFLEX;
typeOper = ACCENT_CIRCUMFLEX;
codeChr = 0x302;
operator = new CCircumflex();
var props =
{
turn: TURN_MIRROR_0
};
operator.init(props);
}
else if(code === 0x30C || type === ACCENT_COMB_CARON)
{
typeOper = ACCENT_COMB_CARON;
codeChr = 0x30C;
operator = new CCircumflex();
var props =
{
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x305 || type === ACCENT_LINE)
{
typeOper = ACCENT_LINE;
//codeChr = 0x332;
codeChr = 0x305;
operator = new CLine();
}
else if(code === 0x33F || type === ACCENT_DOUBLE_LINE)
{
typeOper = ACCENT_DOUBLE_LINE;
//codeChr = 0x333;
codeChr = 0x33F;
operator = new CDoubleLine();
}
else if(code === 0x303 || type === ACCENT_TILDE)
{
typeOper = ACCENT_TILDE;
codeChr = 0x303;
operator = new CTilde();
}
else if(code === 0x306 || type === ACCENT_BREVE)
{
typeOper = ACCENT_BREVE;
codeChr = 0x306;
operator = new CBreve();
var props =
{
turn: TURN_MIRROR_0
};
operator.init(props);
}
else if(code == 0x311 || type == ACCENT_INVERT_BREVE)
{
typeOper = ACCENT_INVERT_BREVE;
codeChr = 0x311;
operator = new CBreve();
var props =
{
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
{
typeOper = ACCENT_ARROW_LEFT;
codeChr = 0x20D6;
/*var glyph = new CCombiningArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
glyph.init(props);*/
operator = new COperator(OPER_ACCENT);
var props =
{
type: properties.chrType,
chr: properties.chr
};
var defaultProps =
{
loc: LOCATION_TOP
};
operator.init(props, defaultProps);
}
else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
{
typeOper = ACCENT_ARROW_RIGHT;
codeChr = 0x20D7;
/*var glyph = new CCombiningArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_180
};
glyph.init(props);
operator = new COperator(glyph);*/
operator = new COperator(OPER_ACCENT);
var props =
{
type: properties.chrType,
chr: properties.chr
};
var defaultProps =
{
loc: LOCATION_TOP
};
operator.init(props, defaultProps);
}
else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
{
typeOper = ACCENT_ARROW_LR;
codeChr = 0x20E1;
/*var glyph = new CCombining_LR_Arrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
glyph.init(props);
operator = new COperator(glyph);*/
operator = new COperator(OPER_ACCENT);
var props =
{
type: properties.chrType,
chr: properties.chr
};
var defaultProps =
{
loc: LOCATION_TOP
};
operator.init(props, defaultProps);
}
else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
{
typeOper = ACCENT_HALF_ARROW_LEFT;
codeChr = 0x20D0;
/*var glyph = new CCombiningHalfArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
glyph.init(props);
operator = new COperator(glyph);*/
operator = new COperator(OPER_ACCENT);
var props =
{
type: properties.chrType,
chr: properties.chr
};
var defaultProps =
{
loc: LOCATION_TOP
};
operator.init(props, defaultProps);
}
else if(code === 0x20D1 || type === ACCENT_HALF_ARROW_RIGHT)
{
typeOper = ACCENT_HALF_ARROW_RIGHT;
codeChr = 0x20D1;
/*var glyph = new CCombiningHalfArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_180
};
glyph.init(props);
operator = new COperator(glyph);*/
operator = new COperator(OPER_ACCENT);
var props =
{
type: properties.chrType,
chr: properties.chr
};
var defaultProps =
{
loc: LOCATION_TOP
};
operator.init(props, defaultProps);
}
/*if(code === 0x302 || type === ACCENT_CIRCUMFLEX)
{
typeOper = ACCENT_CIRCUMFLEX;
this.code = 0x302;
accent = new CCircumflex();
......@@ -649,7 +930,7 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x30C || type === ACCENT_COMB_CARON)
{
this.type = ACCENT_COMB_CARON;
typeOper = ACCENT_COMB_CARON;
this.code = 0x30C;
accent = new CCircumflex();
......@@ -657,28 +938,28 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x332 || type === ACCENT_LINE)
{
this.type = ACCENT_LINE;
typeOper = ACCENT_LINE;
this.code = 0x332;
accent = new CLine();
}
else if(code === 0x333 || type === ACCENT_DOUBLE_LINE)
{
this.type = ACCENT_DOUBLE_LINE;
typeOper = ACCENT_DOUBLE_LINE;
this.code = 0x333;
accent = new CDoubleLine();
}
else if(code === 0x303 || type === ACCENT_TILDE)
{
this.type = ACCENT_TILDE;
typeOper = ACCENT_TILDE;
this.code = 0x303;
accent = new CTilde();
}
else if(code === 0x306 || type === ACCENT_BREVE)
{
this.type = ACCENT_BREVE;
typeOper = ACCENT_BREVE;
this.code = 0x306;
accent = new CBreve();
......@@ -686,7 +967,7 @@ CAccent.prototype.init = function(props)
}
else if(code == 0x311 || type == ACCENT_INVERT_BREVE)
{
this.type = ACCENT_INVERT_BREVE;
typeOper = ACCENT_INVERT_BREVE;
this.code = 0x311;
accent = new CBreve();
......@@ -694,7 +975,7 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
{
this.type = ACCENT_ARROW_LEFT;
typeOper = ACCENT_ARROW_LEFT;
this.code = 0x20D6;
glyph = new CCombiningArrow();
......@@ -708,7 +989,7 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
{
this.type = ACCENT_ARROW_RIGHT;
typeOper = ACCENT_ARROW_RIGHT;
this.code = 0x20D7;
glyph = new CCombiningArrow();
......@@ -722,7 +1003,7 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
{
this.type = ACCENT_ARROW_LR;
typeOper = ACCENT_ARROW_LR;
this.code = 0x20E1;
glyph = new CCombining_LR_Arrow();
......@@ -736,7 +1017,7 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
{
this.type = ACCENT_HALF_ARROW_LEFT;
typeOper = ACCENT_HALF_ARROW_LEFT;
this.code = 0x20D0;
glyph = new CCombiningHalfArrow();
......@@ -750,7 +1031,7 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x20D1 || type === ACCENT_HALF_ARROW_RIGHT)
{
this.type = ACCENT_HALF_ARROW_RIGHT;
typeOper = ACCENT_HALF_ARROW_RIGHT;
this.code = 0x20D1;
glyph = new CCombiningHalfArrow();
......@@ -761,26 +1042,26 @@ CAccent.prototype.init = function(props)
};
glyph.init(prp);
accent = new COperator(glyph);
}
}*/
///// group characters /////
else if(code === 0x2190 || type === ARROW_LEFT)
/*else if(code === 0x2190 || type === ARROW_LEFT)
{
this.type = ARROW_LEFT;
this.code = 0x2190;
typeOper = ARROW_LEFT;
codeChr = 0x2190;
glyph = new CSingleArrow();
operator = new CSingleArrow();
var prp =
var props =
{
location: this.loc,
turn: TURN_0
};
glyph.init(prp);
operator.init(props);
}
else if(code === 0x2192 || type === ARROW_RIGHT)
{
this.type = ARROW_RIGHT;
this.code = 0x2192;
typeOper = ARROW_RIGHT;
codeChr = 0x2192;
glyph = new CSingleArrow();
var prp =
......@@ -792,8 +1073,8 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x2194 || type === ARROW_LR)
{
this.type = ARROW_LR;
this.code = 0x2194;
typeOper = ARROW_LR;
codeChr = 0x2194;
glyph = new CLeftRightArrow();
var prp =
......@@ -805,8 +1086,8 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x21D0 || type === DOUBLE_LEFT_ARROW)
{
this.type = DOUBLE_LEFT_ARROW;
this.code = 0x21D0;
typeOper = DOUBLE_LEFT_ARROW;
codeChr = 0x21D0;
glyph = new CDoubleArrow();
var prp =
......@@ -818,8 +1099,8 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x21D2 || type === DOUBLE_RIGHT_ARROW)
{
this.type = DOUBLE_RIGHT_ARROW;
this.code = 0x21D2;
typeOper = DOUBLE_RIGHT_ARROW;
codeChr = 0x21D2;
glyph = new CDoubleArrow();
var prp =
......@@ -831,8 +1112,8 @@ CAccent.prototype.init = function(props)
}
else if(code === 0x21D4 || type === DOUBLE_ARROW_LR)
{
this.type = DOUBLE_ARROW_LR;
this.code = 0x21D4;
typeOper = DOUBLE_ARROW_LR;
codeChr = 0x21D4;
glyph = new CLR_DoubleArrow();
var prp =
......@@ -841,32 +1122,54 @@ CAccent.prototype.init = function(props)
turn: TURN_0
};
glyph.init(prp);
}
}*/
/////
else if(bCode || bType)
{
this.type = ACCENT_SIGN;
typeOper = ACCENT_SIGN;
accent = new CSign();
var prp =
operator = new CSign();
var props =
{
type: type,
code: code
};
accent.setSign(prp);
this.code = accent.getCodeAccent();
operator.init(props);
codeChr = operator.getCodeCharacter();
}
else
{
this.type = ACCENT_COMB_CARON;
this.code = 0x30C;
/*typeOper = ACCENT_COMB_CARON;
codeChr = 0x30C;
accent = new CCircumflex();
accent.setTurn(TURN_MIRROR_0);
operator = new CCircumflex();
var props =
{
turn: TURN_MIRROR_0
};
operator.init(props);*/
typeOper = ACCENT_CIRCUMFLEX;
codeChr = 0x302;
operator = new CCircumflex();
var props =
{
turn: TURN_MIRROR_0
};
operator.init(props);
}
this.setOperator(accent);
this.operator = operator;
this.operator.relate(this);
this.typeOper = typeOper;
this.code = codeChr;
this.setDimension(1, 1);
this.setContent();
//this.setOperator(accent);
this.elements[0][0].SetDot(true);
}
CAccent.prototype.getCenter = function()
......
......@@ -262,17 +262,19 @@ CBorderBox.prototype.getBase = function()
}
CBorderBox.prototype.getPropsForWrite = function()
{
var props = {
hideBot: !this.bBot,
hideLeft: !this.bLeft,
hideRight: !this.bRight,
hideTop: !this.bTop,
strikeBLTR: this.bLDiag,
strikeH: this.bHor,
strikeTLBR: this.bRDiag,
strikeV: this.bVert
};
return props;
var props = {};
props.hideLeft = !this.bLeft;
props.hideRight = !this.bRight;
props.hideTop = !this.bTop;
props.hideBot = !this.bBot;
props.strikeBLTR = this.bRDiag;
props.strikeTLBR = this.bLDiag;
props.strikeH = this.bHor;
props.strikeV = this.bVert;
return props;
}
......@@ -280,9 +282,11 @@ function CBox()
{
this.kind = MATH_BOX;
this.aln = false;
this.opEmu = false;
this.diff = false;
this.noBreak = false;
this.brk = false;
CMathBase.call(this);
}
......@@ -298,6 +302,12 @@ CBox.prototype.init = function(props)
if(props.noBreak === true || props.noBreak === 1)
this.noBreak = true;
if(props.brk === true || props.brk === 1)
this.brk = true;
if(props.aln === true || props.aln === 1)
this.aln = true;
this.setDimension(1, 1);
this.setContent();
}
......@@ -307,14 +317,16 @@ CBox.prototype.getBase = function()
}
CBox.prototype.getPropsForWrite = function()
{
var props = {
aln: null,
brk: null,
diff: this.diff,
noBreak: this.noBreak,
opEmu: this.opEmu
};
return props;
var props =
{
aln: this.aln,
opEmu: this.opEmu,
diff: this.diff,
noBreak: this.noBreak,
brk: this.brk
};
return props;
}
function CBar()
......@@ -322,6 +334,8 @@ function CBar()
this.kind = MATH_BAR;
this.loc = LOCATION_BOT;
this.operator = new COperator(OPER_BAR);
CCharacter.call(this);
}
extend(CBar, CCharacter);
......@@ -332,7 +346,7 @@ CBar.prototype.init = function(props)
else if(props.pos === LOCATION_BOT || props.location === LOCATION_BOT)
this.loc = LOCATION_BOT;
var glyph = new COperatorLine();
/*var glyph = new COperatorLine();
var props =
{
location: this.loc,
......@@ -340,7 +354,20 @@ CBar.prototype.init = function(props)
};
glyph.init(props);
this.setOperator( new COperator(glyph) );
this.setOperator( new COperator(glyph) );*/
var props =
{
location: this.loc,
type: DELIMITER_LINE
};
var defaultProps =
{
loc: LOCATION_BOT
};
this.setCharacter(props, defaultProps);
}
CBar.prototype.getCenter = function()
{
......@@ -353,15 +380,29 @@ CBar.prototype.getCenter = function()
return center;
}
CBar.prototype.getPropsForWrite = function()
{
var props =
{
pos: this.loc
};
return props;
}
function CPhantom()
{
this.props = null;
CMathBase.call(this);
}
extend(CPhantom, CMathBase);
CPhantom.prototype.init = function(props)
{
this.props = props;
this.setDimension(1, 1);
this.setContent();
}
CPhantom.prototype.getPropsForWrite = function()
{
return this.props;
}
\ No newline at end of file
......@@ -4,11 +4,18 @@ function CDegree()
this.type = DEGREE_SUPERSCRIPT ;
this.shiftDegree = 0;
this.alnScr = false; // не выровнены, итераторы идут в соответствии с наклоном буквы/мат. объекта
CMathBase.call(this);
}
extend(CDegree, CMathBase);
CDegree.prototype.init = function(props)
{
if(props.alnScr === true || props.alnScr === 1)
this.alnScr = true;
else if(props.alnScr === false || props.alnScr === 0)
this.alnScr = false;
this.init_2( props, new CMathContent() );
}
CDegree.prototype.init_2 = function(props, oBase)
......@@ -68,7 +75,7 @@ CDegree.prototype.setPosition = function(_pos)
this.elements[0][0].setPosition({x: pos.x, y: pos.y - this.elements[0][0].size.center });
this.elements[0][1].setPosition({x: pos.x + this.elements[0][0].size.width + this.dW, y: pos.y + this.shiftDegree - this.size.center});
}
CDegree.prototype.findDisposition = function( mCoord )
CDegree.prototype.findDisposition = function(mCoord)
{
var coordX, coordY;
var X, Y;
......@@ -143,6 +150,14 @@ CDegree.prototype.getBase = function()
{
return this.elements[0][0];
}
CDegree.prototype.getPropsForWrite = function()
{
var props = {};
props.type = this.type;
props.alnScr = this.alnScr;
return props;
}
function CIterators()
{
......@@ -211,6 +226,11 @@ function CDegreeSubSup()
extend(CDegreeSubSup, CSubMathBase);
CDegreeSubSup.prototype.init = function(props)
{
if(props.alnScr === true || props.alnScr === 1)
this.alnScr = true;
else if(props.alnScr === false || props.alnScr === 0)
this.alnScr = false;
var oBase = new CMathContent();
this.init_2(props, oBase);
}
......@@ -224,11 +244,6 @@ CDegreeSubSup.prototype.init_2 = function(props, oBase)
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);
var oIters = new CIterators();
......@@ -304,9 +319,11 @@ CDegreeSubSup.prototype.getLowerIterator = function()
}
CDegreeSubSup.prototype.getPropsForWrite = function()
{
var props = {
alnScr: this.alnScr
};
var props = {};
props.type = this.type;
props.alnScr = this.alnScr;
return props;
}
......
......@@ -386,18 +386,9 @@ CFraction.prototype.findDisposition = function( mCoord )
}
CFraction.prototype.getPropsForWrite = function()
{
var type = null;
if (this.type == BAR_FRACTION)
type = 0;
else if (this.type == LINEAR_FRACTION)
type = 1;
else if (this.type == NO_BAR_FRACTION)
type = 2;
else if (this.type == SKEWED_FRACTION)
type = 3;
var props = {
type: type
var props =
{
type: this.type
};
return props;
}
......
......@@ -8,7 +8,7 @@ function CLimit()
extend(CLimit, CMathBase);
CLimit.prototype.init = function(props)
{
if( typeof(props.type) !== "undefined" && props.type !== null)
if(props.type === LIMIT_UP || props.type === LIMIT_LOW)
this.type = props.type;
this.setDimension(2, 1);
......@@ -57,7 +57,15 @@ CLimit.prototype.setDistance = function()
{
this.dH = 0.03674768518518519*this.getCtrPrp().FontSize;
}
CLimit.prototype.getPropsForWrite = function()
{
var props =
{
type: this.type
};
return props;
}
function CMathFunc()
{
......@@ -83,5 +91,10 @@ CMathFunc.prototype.getArgument = function()
{
return this.elements[0][1];
}
CMathFunc.prototype.getPropsForWrite = function()
{
var props = {};
return props;
}
......@@ -26,9 +26,13 @@
// 6. баг с отрисовкой кругового интеграла
// 7. cursor_Up, cursor_Down (+ c зажитым shift)
// 8. Merge textPrp и mathTextPrp (bold, italic)
// 9. Для управляющих символов запрашивать не getCtrPrp, getPrpToControlLetter (реализована, нужно только протащить для всех управляющих элементов)
// 10. объединение формул на remove и add
// 9. Поправить баги для CAccent с точками : смещение, когда идут подряд с одной точкой, двумя и тремя они перекрываются
// 10. Для управляющих символов запрашивать не getCtrPrp, getPrpToControlLetter (реализована, нужно только протащить для всех управляющих элементов)
// 11. объединение формул на remove и add
// TODO Refactoring
// 1. CAccent ~> COperator
// 2. COperator : объединить все классы связанные с отрисовкой и пересчетом операторов в один
/// TODO
......
......@@ -81,6 +81,11 @@ var ARROW_LR = 21;
var DOUBLE_LEFT_ARROW = 22;
var DOUBLE_RIGHT_ARROW = 23;
var DOUBLE_ARROW_LR = 24;
var ACCENT_ARROW_LEFT = 26;
var ACCENT_ARROW_RIGHT = 27;
var ACCENT_ARROW_LR = 28;
var ACCENT_HALF_ARROW_LEFT = 29;
var ACCENT_HALF_ARROW_RIGHT = 30;
var SCR_ROMAN = 0;
var SCR_SCRIPT = 1;
......@@ -92,6 +97,8 @@ var SCR_MONOSPACE = 5;
var OPER_DELIMITER = 0;
var OPER_SEPARATOR = 1;
var OPER_GROUP_CHAR = 2;
var OPER_ACCENT = 3;
var OPER_BAR = 4;
var TURN_0 = 0;
......@@ -105,6 +112,7 @@ var DELIMITER_SHAPE_CENTERED = 1;
var LIMIT_LOW = 0;
var LIMIT_UP = 1;
//////////////////////////////////////////
var ACCENT_ONE_DOT = 0;
var ACCENT_TWO_DOTS = 1;
var ACCENT_THREE_DOTS = 2;
......@@ -119,14 +127,12 @@ var DOUBLE_LINE = 10;
var ACCENT_TILDE = 11;
var ACCENT_BREVE = 12;
var ACCENT_INVERT_BREVE = 13;
var ACCENT_ARROW_LEFT = 14;
var ACCENT_ARROW_RIGHT = 15;
var ACCENT_ARROW_LR = 16;
var ACCENT_HALF_ARROW_LEFT = 17;
var ACCENT_HALF_ARROW_RIGHT = 18;
var ACCENT_SIGN = 19;
var ACCENT_TEXT = 20;
/////////////////////////////////////////
var BASEJC_CENTER = 0;
var BASEJC_TOP = 1;
var BASEJC_BOTTOM = 2;
......
......@@ -59,12 +59,15 @@ CMathMatrix.prototype.init = function(props)
this.baseJc = MATRIX_BOTTOM;
}*/
if(props.baseJc === BASEJC_CENTER)
/*if(props.baseJc === BASEJC_CENTER)
this.baseJc = BASEJC_CENTER;
else if(props.baseJc === BASEJC_TOP)
this.baseJc = BASEJC_TOP;
else if(props.baseJc === BASEJC_BOTTOM)
this.baseJc = BASEJC_BOTTOM;
this.baseJc = BASEJC_BOTTOM;*/
if(props.baseJc === BASEJC_CENTER || props.baseJc === BASEJC_TOP || props.baseJc === BASEJC_BOTTOM)
this.baseJc = props.baseJc;
this.setRuleGap(this.spaceColumn, props.cGpRule, props.cGp, props.cSp);
this.setRuleGap(this.spaceRow, props.rSpRule, props.rSp);
......@@ -75,8 +78,6 @@ CMathMatrix.prototype.init = function(props)
this.hidePlaceholder(true);
}
//if(props.)
/*if(props.cGpRule !== "undefined" && props.cGpRule !== null)
{
......@@ -127,12 +128,13 @@ CMathMatrix.prototype.setRuleGap = function(space, rule, gap, minGap)
if(gap == gap - 0 && gap == gap^0)
space.value = gap;
space.gap = gap;
else
space.value = 0;
space.gap = 0;
if(minGap == minGap - 0 && minGap == minGap^0)
space.minGap = gap;
/*else
space.minGap = 0;*/
......@@ -466,28 +468,34 @@ CMathMatrix.prototype.baseJustification = function(type)
this.baseJc = type;
}
////
CMathMatrix.prototype.getPropsForWrite = function()
{
var props = {
baseJc: this.baseJc,
cGp: this.spaceColumn.gap,
cGpRule: this.spaceColumn.rule,
cSp: null,
column: this.nCol,
plcHide: this.plcHide,
rSp: null,
rSpRule: null
};
return props;
}
////
var props = {};
props.baseJc = this.baseJc;
props.row = this.nRow;
props.column = this.nCol;
props.plcHide = this.plcHide;
props.cGpRule = this.spaceColumn.rule;
props.cGp = this.spaceColumn.gap;
props.cSp = this.spaceColumn.minGap;
props.rSpRule = this.spaceRow.rule;
props.rSp = this.spaceRow.gap;
return props;
}
////
function CEqArray()
{
this.kind = MATH_EQ_ARRAY;
this.maxDist = 0;
this.objDist = 0;
CMathMatrix.call(this);
}
extend(CEqArray, CMathMatrix);
......@@ -516,10 +524,10 @@ CEqArray.prototype.init = function(props)
Pr.baseJc = props.baseJc;
if(props.maxDist !== "undefined" && props.maxDist !== null)
Pr.maxDist = props.maxDist;
this.maxDist = props.maxDist;
if(props.objDist !== "undefined" && props.objDist !== null)
Pr.objDist = props.objDist;
this.objDist = props.objDist;
CEqArray.superclass.init.call(this, Pr);
}
......@@ -540,4 +548,18 @@ CEqArray.prototype.old_init = function(props)
CEqArray.prototype.getElement = function(num)
{
return this.elements[num][0];
}
CEqArray.prototype.getPropsForWrite = function()
{
var props = {};
props.row = this.nRow;
props.baseJc = this.baseJc;
props.rSpRule = this.spaceRow.rule;
props.rSp = this.spaceRow.gap;
props.maxDist = this.maxDist;
props.objDist = this.objDist;
return props;
}
\ No newline at end of file
......@@ -214,20 +214,16 @@ CNary.prototype.getLowerIterator = function()
if (!this.subHide)
return this.elements[0][0].getLowerIterator();
}
CNary.prototype.getPropsForWrite = function()
{
var limloc = null;
if (this.limLoc == NARY_SubSup)
limLoc = 0;
else if (this.limLoc == NARY_UndOvr)
limLoc = 1;
var props = {
chr: String.fromCharCode(this.code),
grow: this.grow,
limLoc: limLoc,
subHide: this.subHide,
supHide: this.supHide
};
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;
props.subHide = this.subHide;
props.grow = this.grow;
return props;
}
......
......@@ -13,7 +13,7 @@ function CGlyphOperator()
this.turn = null;
this.size = null;
this.measure = 0;
this.stretch = 0;
this.penW = 1; // px
}
......@@ -36,9 +36,9 @@ CGlyphOperator.prototype.init = function(props)
this.loc = props.location;
this.turn = props.turn;
}
CGlyphOperator.prototype.fixSize = function(measure)
CGlyphOperator.prototype.fixSize = function(stretch)
{
var sizeGlyph = this.calcSize(measure);
var sizeGlyph = this.calcSize(stretch);
var width, height, center;
//var betta = this.getTxtPrp().FontSize/36;
......@@ -50,7 +50,7 @@ CGlyphOperator.prototype.fixSize = function(measure)
height = sizeGlyph.height;
center = height/2;
this.measure = measure > width ? measure : width;
this.stretch = stretch > width ? stretch : width;
}
else
{
......@@ -61,14 +61,14 @@ CGlyphOperator.prototype.fixSize = function(measure)
// плейсхолдер из-за этого располагается чуть выше, как в Ворде
//center = height/2 - 1.234722222222222*betta;
center = height/2;
this.measure = measure > height ? measure : height;
this.stretch = stretch > height ? stretch : height;
}
this.size = {width: width, height: height, center: center};
}
CGlyphOperator.prototype.draw_other = function() // с выравниванием к краю (относительно аргумента)
{
var coord = this.calcCoord(this.measure);
var coord = this.calcCoord(this.stretch);
var X = coord.XX, Y = coord.YY,
W = this.size.width, H = this.size.height,
......@@ -202,7 +202,7 @@ CGlyphOperator.prototype.draw_other = function() // с выравнивание
}
CGlyphOperator.prototype.getCoordinateGlyph = function()
{
var coord = this.calcCoord(this.measure);
var coord = this.calcCoord(this.stretch);
var X = coord.XX, Y = coord.YY,
W = this.size.width, H = this.size.height;
......@@ -331,7 +331,7 @@ function COperatorBracket()
CGlyphOperator.call(this);
}
extend(COperatorBracket, CGlyphOperator);
COperatorBracket.prototype.calcSize = function( measure )
COperatorBracket.prototype.calcSize = function( stretch )
{
var betta = this.getCtrPrp().FontSize/36;
......@@ -339,7 +339,7 @@ COperatorBracket.prototype.calcSize = function( measure )
var minBoxH = 4.917529296874999 *betta, //width of 0x28
widthBr = 12.347222222222221*betta;
var rx = measure / widthBr;
var rx = stretch / widthBr;
if(rx < 1)
rx = 1;
......@@ -357,7 +357,7 @@ COperatorBracket.prototype.calcSize = function( measure )
return {width: widthBr, height: heightBr};
}
COperatorBracket.prototype.calcCoord = function(measure)
COperatorBracket.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -423,7 +423,7 @@ COperatorBracket.prototype.calcCoord = function(measure)
var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры
var augm = measure/((X[52] + (X[0] - X[1])/2 + X[1] - X[52])*alpha*2);
var augm = stretch/((X[52] + (X[0] - X[1])/2 + X[1] - X[52])*alpha*2);
if(augm < 1)
augm = 1;
......@@ -848,7 +848,7 @@ function COperatorParenthesis()
CGlyphOperator.call(this);
}
extend(COperatorParenthesis, CGlyphOperator);
COperatorParenthesis.prototype.calcSize = function(measure)
COperatorParenthesis.prototype.calcSize = function(stretch)
{
var betta = this.getCtrPrp().FontSize/36;
......@@ -856,7 +856,7 @@ COperatorParenthesis.prototype.calcSize = function(measure)
minBoxH = 5.27099609375 *betta, //width of 0x28
widthBr = 11.99444444444 *betta;
var ry = measure / widthBr,
var ry = stretch / widthBr,
delta = maxBoxH - minBoxH;
var heightBr = delta/4.3 * (ry - 1) + minBoxH;
......@@ -864,7 +864,7 @@ COperatorParenthesis.prototype.calcSize = function(measure)
return {height: heightBr, width : widthBr};
}
COperatorParenthesis.prototype.calcCoord = function(measure)
COperatorParenthesis.prototype.calcCoord = function(stretch)
{
//cкобка перевернутая на 90 градусов
......@@ -885,7 +885,7 @@ COperatorParenthesis.prototype.calcCoord = function(measure)
var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры
var aug = measure/(X[9]*alpha)/2; //Y[9]*alpha - высота скобки
var aug = stretch/(X[9]*alpha)/2; //Y[9]*alpha - высота скобки
var RX, RY;
if(aug > 6.53)
......@@ -942,7 +942,7 @@ COperatorParenthesis.prototype.calcCoord = function(measure)
{
YY[19 - i] = YY[i] = shiftY - Y[i]*alpha;
XX[19 - i] = X[i]*alpha;
XX[i] = measure - X[i]*alpha;
XX[i] = stretch - X[i]*alpha;
}
YY[20] = YY[0];
......@@ -978,21 +978,22 @@ function COperatorAngleBracket()
CGlyphOperator.call(this);
}
extend(COperatorAngleBracket, CGlyphOperator);
COperatorAngleBracket.prototype.calcSize = function(measure)
COperatorAngleBracket.prototype.calcSize = function(stretch)
{
//скобка перевернутая
var betta = this.getCtrPrp().FontSize/36;
var widthBr = 11.994444444444444*betta;
var heightBr;
if( measure/widthBr > 3.768 )
if( stretch/widthBr > 3.768 )
heightBr = 5.3578125*betta;
else
heightBr = 4.828645833333333*betta;
return {width : widthBr, height: heightBr};
}
COperatorAngleBracket.prototype.calcCoord = function(measure)
COperatorAngleBracket.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1009,7 +1010,7 @@ COperatorAngleBracket.prototype.calcCoord = function(measure)
var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры
var augm = measure/(X[5]*alpha);
var augm = stretch/(X[5]*alpha);
if(augm < 1)
augm = 1;
......@@ -1088,7 +1089,7 @@ function CSquareBracket()
CGlyphOperator.call(this);
}
extend(CSquareBracket, CGlyphOperator);
CSquareBracket.prototype.calcCoord = function(measure)
CSquareBracket.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1106,7 +1107,7 @@ CSquareBracket.prototype.calcCoord = function(measure)
var textScale = this.getCtrPrp().FontSize/1000; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент используется для того, чтобы перевести координаты в миллиметры
var lng = measure/alpha - X[4] - 2*X[0];
var lng = stretch/alpha - X[4] - 2*X[0];
if(lng < 0)
lng = 0;
......@@ -1159,7 +1160,7 @@ function CHalfSquareBracket()
CGlyphOperator.call(this);
}
extend(CHalfSquareBracket, CGlyphOperator);
CHalfSquareBracket.prototype.calcCoord = function(measure)
CHalfSquareBracket.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1177,7 +1178,7 @@ CHalfSquareBracket.prototype.calcCoord = function(measure)
var w1 = X[4],
w2 = X[4] - X[3];
var lng = measure/alpha - w1 - w2;
var lng = stretch/alpha - w1 - w2;
if(lng < 0)
lng = 0;
......@@ -1240,7 +1241,7 @@ COperatorLine.prototype.calcSize = function()
return {width: width, height: height};
}
COperatorLine.prototype.calcCoord = function(measure)
COperatorLine.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1265,7 +1266,7 @@ COperatorLine.prototype.calcCoord = function(measure)
YY[i] = Y[i]*alpha + shY;
}
var lng = measure - X[2]*alpha;
var lng = stretch - X[2]*alpha;
if(lng < 0)
lng = 0;
......@@ -1303,7 +1304,7 @@ CWhiteSquareBracket.prototype.calcSize = function()
return {width: width, height: height};
}
CWhiteSquareBracket.prototype.calcCoord = function(measure)
CWhiteSquareBracket.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1353,7 +1354,7 @@ CWhiteSquareBracket.prototype.calcCoord = function(measure)
YY[i] = Y[i]*alpha + shY;
}
var lngY = measure - X[4]*alpha;
var lngY = stretch - X[4]*alpha;
for(var i = 0; i < 4; i++)
XX[4+i] += lngY;
......@@ -1402,7 +1403,7 @@ COperatorDoubleLine.prototype.calcSize = function()
return {width: width, height: height};
}
COperatorDoubleLine.prototype.calcCoord = function(measure)
COperatorDoubleLine.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1437,8 +1438,8 @@ COperatorDoubleLine.prototype.calcCoord = function(measure)
for(var i = 0; i < 2; i++)
{
XX[2+i] = measure;
XX[7+i] = measure;
XX[2+i] = stretch;
XX[7+i] = stretch;
}
var W = XX[7],
......@@ -1477,7 +1478,7 @@ CSingleArrow.prototype.calcSize = function()
return {width: width, height: height};
}
CSingleArrow.prototype.calcCoord = function(measure)
CSingleArrow.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1506,8 +1507,8 @@ CSingleArrow.prototype.calcCoord = function(measure)
YY[i] = Y[i]*alpha;
}
//var lng = measure - 10000*alpha;
var lng = measure;
//var lng = stretch - 10000*alpha;
var lng = stretch;
if(lng > XX[9])
{
......@@ -1554,7 +1555,7 @@ CLeftRightArrow.prototype.calcSize = function()
return {width: width, height: height};
}
CLeftRightArrow.prototype.calcCoord = function(measure)
CLeftRightArrow.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1591,7 +1592,7 @@ CLeftRightArrow.prototype.calcCoord = function(measure)
var w = X[10]*alpha;
var lng = measure - w;
var lng = stretch - w;
if(lng > 0)
for(var i = 0; i < 8; i++)
......@@ -1643,7 +1644,7 @@ CDoubleArrow.prototype.calcSize = function()
return {width: width, height: height};
}
CDoubleArrow.prototype.calcCoord = function(measure)
CDoubleArrow.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1680,7 +1681,7 @@ CDoubleArrow.prototype.calcCoord = function(measure)
YY[i] = Y[i]*alpha;
}
var lng = measure - 10000*alpha;
var lng = stretch - 10000*alpha;
if(lng > XX[16])
{
......@@ -1742,7 +1743,7 @@ CLR_DoubleArrow.prototype.calcSize = function()
return {width: width, height: height};
}
CLR_DoubleArrow.prototype.calcCoord = function(measure)
CLR_DoubleArrow.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -1786,7 +1787,7 @@ CLR_DoubleArrow.prototype.calcCoord = function(measure)
}
var w = XX[4];
var lng = measure - 10000*alpha - w;
var lng = stretch - 10000*alpha - w;
for(var i = 1; i < 9; i++)
XX[i] += lng;
......@@ -1853,7 +1854,7 @@ CCombiningArrow.prototype.calcSize = function()
return {width: width, height: height};
}
CCombiningArrow.prototype.calcCoord = function(measure)
CCombiningArrow.prototype.calcCoord = function(stretch)
{
// px mm
// XX[..] width
......@@ -1887,7 +1888,7 @@ CCombiningArrow.prototype.calcCoord = function(measure)
YY[i] = Y[i]*alpha;
}
XX[4] = XX[5] = measure;
XX[4] = XX[5] = stretch;
var W = XX[4],
H = YY[8];
......@@ -1936,7 +1937,7 @@ CCombiningHalfArrow.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[6], YY[6]);
pGraphics._l(XX[7], YY[7]);
}
CCombiningHalfArrow.prototype.calcCoord = function(measure)
CCombiningHalfArrow.prototype.calcCoord = function(stretch)
{
// px mm
// XX[..] width
......@@ -1967,7 +1968,7 @@ CCombiningHalfArrow.prototype.calcCoord = function(measure)
YY[i] = Y[i]*alpha;
}
XX[4] = XX[5] = measure;
XX[4] = XX[5] = stretch;
var W = XX[4],
H = YY[5];
......@@ -2010,7 +2011,7 @@ CCombining_LR_Arrow.prototype.drawPath = function(pGraphics, XX, YY)
pGraphics._l(XX[16], YY[16]);
}
CCombining_LR_Arrow.prototype.calcCoord = function(measure)
CCombining_LR_Arrow.prototype.calcCoord = function(stretch)
{
var X = new Array(),
Y = new Array();
......@@ -2045,7 +2046,7 @@ CCombining_LR_Arrow.prototype.calcCoord = function(measure)
YY[i] = Y[i]*alpha;
}
var lng = measure - XX[7];
var lng = stretch - XX[7];
for(var i = 0; i < 8; i++)
{
......@@ -2164,8 +2165,8 @@ old_old_CSeparator.prototype.drawHorLine = function()
function COperator(type)
{
this.type = type; // delimiter, separator, group character
this.glyph = -1;
this.type = type; // delimiter, separator, group character, accent
this.operator = -1;
this.code = null;
this.typeOper = null; // тип скобки : круглая и т.п.
......@@ -2175,13 +2176,13 @@ function COperator(type)
this.coordGlyph = null;
this.size = {width: 0, height: 0};
}
COperator.prototype.init = function(props, defaultProps) // props (chr, type, location), defaultProps (chr, location)
COperator.prototype.init = function(properties, defaultProps) // props (chr, type, location), defaultProps (chr, location)
{
var operator = null,
typeOper = null,
codeChr = null;
var prp = this.getProps(props, defaultProps);
var prp = this.getProps(properties, defaultProps);
//var code = typeof(prp.chr) === "string" && prp.chr.length > 0 ? prp.chr.charCodeAt(0) : null;
......@@ -2420,6 +2421,213 @@ COperator.prototype.init = function(props, defaultProps) // props (chr, t
//////////// accents /////////////
/////// only arrows /////
else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
{
codeChr = 0x20D6;
typeOper = ACCENT_ARROW_LEFT;
operator = new CCombiningArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
{
typeOper = ACCENT_ARROW_RIGHT;
codeChr = 0x20D7;
operator = new CCombiningArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_180
};
operator.init(props);
}
else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
{
typeOper = ACCENT_ARROW_LR;
codeChr = 0x20E1;
operator = new CCombining_LR_Arrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
{
typeOper = ACCENT_HALF_ARROW_LEFT;
codeChr = 0x20D0;
operator = new CCombiningHalfArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x20D1 || type === ACCENT_HALF_ARROW_RIGHT)
{
typeOper = ACCENT_HALF_ARROW_RIGHT;
codeChr = 0x20D1;
operator = new CCombiningHalfArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_180
};
operator.init(props);
}
/////////////////////////
/*else if(code === 0x302 || type === ACCENT_CIRCUMFLEX)
{
typeOper = ACCENT_CIRCUMFLEX;
codeChr = 0x302;
operator = new CCircumflex();
var props =
{
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x30C || type === ACCENT_COMB_CARON)
{
typeOper = ACCENT_COMB_CARON;
codeChr = 0x30C;
operator = new CCircumflex();
var props =
{
turn: TURN_MIRROR_0
};
operator.init(props);
}
else if(code === 0x332 || type === ACCENT_LINE)
{
typeOper = ACCENT_LINE;
codeChr = 0x332;
operator = new CLine();
}
else if(code === 0x333 || type === ACCENT_DOUBLE_LINE)
{
typeOper = ACCENT_DOUBLE_LINE;
codeChr = 0x333;
operator = new CDoubleLine();
}
else if(code === 0x303 || type === ACCENT_TILDE)
{
typeOper = ACCENT_TILDE;
codeChr = 0x303;
operator = new CTilde();
}
else if(code === 0x306 || type === ACCENT_BREVE)
{
typeOper = ACCENT_BREVE;
codeChr = 0x306;
operator = new CBreve();
var props =
{
turn: TURN_MIRROR_0
};
operator.init(props);
}
else if(code == 0x311 || type == ACCENT_INVERT_BREVE)
{
typeOper = ACCENT_INVERT_BREVE;
codeChr = 0x311;
operator = new CBreve();
var props =
{
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
{
typeOper = ACCENT_ARROW_LEFT;
codeChr = 0x20D6;
operator = new CCombiningArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
{
typeOper = ACCENT_ARROW_RIGHT;
codeChr = 0x20D7;
operator = new CCombiningArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_180
};
operator.init(props);
}
else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
{
typeOper = ACCENT_ARROW_LR;
codeChr = 0x20E1;
operator = new CCombining_LR_Arrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
{
typeOper = ACCENT_HALF_ARROW_LEFT;
codeChr = 0x20D0;
operator = new CCombiningHalfArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_0
};
operator.init(props);
}
else if(code === 0x20D1 || type === ACCENT_HALF_ARROW_RIGHT)
{
typeOper = ACCENT_HALF_ARROW_RIGHT;
codeChr = 0x20D1;
operator = new CCombiningHalfArrow();
var props =
{
location: LOCATION_TOP,
turn: TURN_180
};
operator.init(props);
}*/
//////////////////////////////////////////
////////// group characters //////////
......@@ -2544,7 +2752,7 @@ COperator.prototype.init = function(props, defaultProps) // props (chr, t
else
operator = -1;
this.glyph = operator;
this.operator = operator;
this.code = codeChr;
this.typeOper = typeOper;
......@@ -2605,20 +2813,20 @@ COperator.prototype.draw = function(pGraphics)
////////////////////////////////////////////////
this.glyph.draw(pGraphics);
this.operator.draw(pGraphics);
}
else
{
if(this.type === OPER_DELIMITER || this.type == OPER_GROUP_CHAR)
this.drawOperator(pGraphics);
else if(this.type === OPER_SEPARATOR)
if(this.type === OPER_SEPARATOR)
this.drawSeparator(pGraphics);
else
this.drawOperator(pGraphics);
}
}
COperator.prototype.drawOperator = function(pGraphics)
{
if(this.glyph !== -1)
if(this.operator !== -1)
{
var lng = this.coordGlyph.XX.length;
......@@ -2630,12 +2838,12 @@ COperator.prototype.drawOperator = function(pGraphics)
Y.push(this.pos.y + this.coordGlyph.YY[j]);
}
this.glyph.draw(pGraphics, X, Y);
this.operator.draw(pGraphics, X, Y);
}
}
COperator.prototype.drawSeparator = function(pGraphics)
{
if(this.glyph !== -1)
if(this.operator !== -1)
{
var lng = this.coordGlyph.XX.length;
......@@ -2649,13 +2857,13 @@ COperator.prototype.drawSeparator = function(pGraphics)
Y.push(this.pos[i].y + this.coordGlyph.YY[j]);
}
this.glyph.draw(pGraphics, X, Y);
this.operator.draw(pGraphics, X, Y);
}
}
}
COperator.prototype.fixSize = function(stretch, oMeasure)
COperator.prototype.fixSize = function(oMeasure, stretch)
{
if(this.glyph !== -1)
if(this.operator !== -1)
{
var width, height;
......@@ -2670,37 +2878,37 @@ COperator.prototype.fixSize = function(stretch, oMeasure)
oMeasure.SetFont(rPrp);
this.glyph.Resize();
this.operator.Resize();
if(this.glyph.loc == 0 || this.glyph.loc == 1)
if(this.operator.loc == 0 || this.operator.loc == 1)
{
height = this.glyph.size.height;
width = stretch > this.glyph.size.width ? stretch : this.glyph.size.width;
height = this.operator.size.height;
width = stretch > this.operator.size.width ? stretch : this.operator.size.width;
center = height/2;
}
else
{
width = this.glyph.size.width;
height = stretch > this.glyph.size.height ? stretch : this.glyph.size.height;
center = this.glyph.size.height/2;
width = this.operator.size.width;
height = stretch > this.operator.size.height ? stretch : this.operator.size.height;
center = this.operator.size.height/2;
}
}
else
{
this.glyph.fixSize(stretch);
var dims = this.glyph.getCoordinateGlyph();
this.operator.fixSize(stretch);
var dims = this.operator.getCoordinateGlyph();
this.coordGlyph = {XX: dims.XX, YY: dims.YY};
if(this.glyph.loc == 0 || this.glyph.loc == 1)
if(this.operator.loc == 0 || this.operator.loc == 1)
{
//width = stretch > this.glyph.size.width ? stretch : this.glyph.size.width;
//width = stretch > this.operator.size.width ? stretch : this.operator.size.width;
width = dims.Width;
height = this.glyph.size.height;
height = this.operator.size.height;
}
else
{
width = this.glyph.size.width;
//height = stretch > this.glyph.size.height ? stretch : this.glyph.size.height;
width = this.operator.size.width;
//height = stretch > this.operator.size.height ? stretch : this.operator.size.height;
height = dims.Height;
//height = dims.Height > stretch ? stretch : dims.Height;
}
......@@ -2710,7 +2918,6 @@ COperator.prototype.fixSize = function(stretch, oMeasure)
}
this.size = { width: width, height: height, center: center};
}
}
COperator.prototype.setPosition = function(pos)
......@@ -2720,13 +2927,13 @@ COperator.prototype.setPosition = function(pos)
if(this.typeOper == OPERATOR_TEXT)
{
this.glyph.setPosition({x: pos.x, y: pos.y});
//this.glyph.setPosition(pos);
this.operator.setPosition({x: pos.x, y: pos.y});
//this.operator.setPosition(pos);
}
//this.glyph.setPosition({x: pos.x, y: pos.y + this.size.center});
//this.operator.setPosition({x: pos.x, y: pos.y + this.size.center});
/*if(this.typeOper == OPERATOR_TEXT)
this.glyph.setPosition(pos);*/
this.operator.setPosition(pos);*/
}
COperator.prototype.IsJustDraw = function()
{
......@@ -2734,21 +2941,21 @@ COperator.prototype.IsJustDraw = function()
}
COperator.prototype.Resize = function(oMeasure)
{
if(this.glyph !== -1)
if(this.operator !== -1)
{
var bHor = this.glyph.loc == 0 || this.glyph.loc == 1;
var bHor = this.operator.loc == 0 || this.operator.loc == 1;
if(bHor)
this.fixSize(this.size.width, oMeasure);
this.fixSize(oMeasure, this.size.width);
else
this.fixSize(this.size.height, oMeasure);
this.fixSize(oMeasure, this.size.height);
}
}
COperator.prototype.relate = function(parent)
{
this.Parent = parent;
if(this.glyph !== -1)
this.glyph.relate(this);
if(this.operator !== -1)
this.operator.relate(this);
}
COperator.prototype.getCtrPrp = function()
{
......@@ -2756,7 +2963,7 @@ COperator.prototype.getCtrPrp = function()
}
COperator.prototype.getChr = function()
{
var chr = null; //если glyph не определен, то this.code = null
var chr = null; //если operator не определен, то this.code = null
if(this.code !== null)
chr = this.typeOper == this.defaultType ? "" : String.fromCharCode(this.code);
......@@ -2765,17 +2972,17 @@ COperator.prototype.getChr = function()
}
COperator.prototype.IsArrow = function()
{
return this.glyph.IsArrow();
return this.operator.IsArrow();
}
function old_CSeparator(glyph)
function old_CSeparator(operator)
{
COperator.call(this, glyph);
COperator.call(this, operator);
}
extend(old_CSeparator, COperator);
old_CSeparator.prototype.draw = function(pGraphics)
{
if(this.glyph !== -1)
if(this.operator !== -1)
{
var lng = this.coordGlyph.XX.length;
......@@ -2789,7 +2996,7 @@ old_CSeparator.prototype.draw = function(pGraphics)
Y.push(this.positions[i].y + this.coordGlyph.YY[j]);
}
this.glyph.draw(pGraphics, X, Y);
this.operator.draw(pGraphics, X, Y);
}
}
}
......@@ -3089,7 +3296,7 @@ CDelimiter.prototype.Resize = function(oMeasure)
center = ascent;
}
this.begOper.fixSize(height, oMeasure);
this.begOper.fixSize(oMeasure, height);
width += this.begOper.size.width;
if(height < this.begOper.size.height)
......@@ -3100,7 +3307,7 @@ CDelimiter.prototype.Resize = function(oMeasure)
}
this.endOper.fixSize(height, oMeasure);
this.endOper.fixSize(oMeasure, height);
width += this.endOper.size.width;
if(height < this.endOper.size.height)
{
......@@ -3110,7 +3317,7 @@ CDelimiter.prototype.Resize = function(oMeasure)
//center = this.endOper.size.center;
}
this.sepOper.fixSize(height, oMeasure);
this.sepOper.fixSize(oMeasure, height);
width += (this.nCol - 1)*this.sepOper.size.width;
if(height < this.endOper.size.height)
{
......@@ -3336,7 +3543,7 @@ function CCharacter()
CSubMathBase.call(this);
}
extend(CCharacter, CSubMathBase);
CCharacter.prototype.setOperator = function(props, defaultProps)
CCharacter.prototype.setCharacter = function(props, defaultProps)
{
this.operator.init(props, defaultProps);
this.operator.relate(this);
......@@ -3349,7 +3556,7 @@ CCharacter.prototype.Resize = function(oMeasure)
var base = this.elements[0][0];
base.Resize(oMeasure);
this.operator.fixSize(base.size.width, oMeasure);
this.operator.fixSize(oMeasure, base.size.width);
var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width,
height = base.size.height + this.operator.size.height,
......@@ -3446,6 +3653,7 @@ CCharacter.prototype.getBase = function()
}
function CGroupCharacter()
{
this.kind = MATH_GROUP_CHARACTER;
......@@ -3475,10 +3683,11 @@ CGroupCharacter.prototype.init = function(props)
var operProps =
{
type: props.chrType,
chr: props.chr
chr: props.chr,
loc: this.loc
};
this.setOperator(operProps, operDefaultPrp);
this.setCharacter(operProps, operDefaultPrp);
/*var type = props.chrType;
var code = typeof(props.chr) === "string" ? props.chr.charCodeAt(0) : null;
......@@ -3489,12 +3698,12 @@ CGroupCharacter.prototype.init = function(props)
this.loc = LOCATION_BOT;
}
var glyph = this.getGlyph(code, type);
var operator = this.getGlyph(code, type);
if(glyph.bArrow)
if(operator.bArrow)
this.setReduct(DEGR_REDUCT);*/
/*this.setOperator(new COperator(glyph));*/
/*this.setOperator(new COperator(operator));*/
/*if(this.operator.IsArrow())
this.setReduct(DEGR_REDUCT);*/
......@@ -3516,183 +3725,171 @@ CGroupCharacter.prototype.getCenter = function()
}
CGroupCharacter.prototype.old_getGlyph = function(code, type)
{
var glyph, props;
var operator, props;
if(code === 0x23DE || type == BRACKET_CURLY_TOP)
{
glyph = new COperatorBracket();
operator = new COperatorBracket();
props =
{
location: this.loc,
turn: TURN_0
};
glyph.init(props);
operator.init(props);
}
else if(code === 0x23DF || type === BRACKET_CURLY_BOTTOM )
{
glyph = new COperatorBracket();
operator = new COperatorBracket();
props =
{
location: this.loc,
turn: TURN_MIRROR_0
};
glyph.init(props);
operator.init(props);
}
else if(code === 0x2190 || type === ARROW_LEFT)
{
glyph = new CSingleArrow();
operator = new CSingleArrow();
props =
{
location: this.loc,
turn: TURN_0
};
glyph.init(props);
operator.init(props);
}
else if(code === 0x2192 || type === ARROW_RIGHT)
{
glyph = new CSingleArrow();
operator = new CSingleArrow();
props =
{
location: this.loc,
turn: TURN_180
};
glyph.init(props);
operator.init(props);
}
else if(code === 0x2194 || type === ARROW_LR)
{
glyph = new CLeftRightArrow();
operator = new CLeftRightArrow();
props =
{
location: this.loc,
turn: TURN_0
};
glyph.init(props);
operator.init(props);
}
else if(code === 0x21D0 || type === DOUBLE_LEFT_ARROW)
{
glyph = new CDoubleArrow();
operator = new CDoubleArrow();
props =
{
location: this.loc,
turn: TURN_0
};
glyph.init(props);
operator.init(props);
}
else if(code === 0x21D2 || type === DOUBLE_RIGHT_ARROW)
{
glyph = new CDoubleArrow();
operator = new CDoubleArrow();
props =
{
location: this.loc,
turn: TURN_180
};
glyph.init(props);
operator.init(props);
}
else if(code === 0x21D4 || type === DOUBLE_ARROW_LR)
{
glyph = new CLR_DoubleArrow();
operator = new CLR_DoubleArrow();
props =
{
location: this.loc,
turn: TURN_0
};
glyph.init(props);
operator.init(props);
}
///// accents /////
else if(code === 0x20D6 || type === ACCENT_ARROW_LEFT)
{
glyph = new CCombiningArrow();
operator = new CCombiningArrow();
props =
{
location: LOCATION_TOP,
turn: TURN_0
};
glyph.init(props);
accent = new COperator(glyph);
operator.init(props);
accent = new COperator(operator);
}
else if(code === 0x20D7 || type === ACCENT_ARROW_RIGHT)
{
glyph = new CCombiningArrow();
operator = new CCombiningArrow();
props =
{
location: LOCATION_TOP,
turn: TURN_180
};
glyph.init(props);
accent = new COperator(glyph);
operator.init(props);
accent = new COperator(operator);
}
else if(code === 0x20E1 || type === ACCENT_ARROW_LR)
{
glyph = new CCombining_LR_Arrow();
operator = new CCombining_LR_Arrow();
props =
{
location: LOCATION_TOP,
turn: TURN_0
};
glyph.init(props);
accent = new COperator(glyph);
operator.init(props);
accent = new COperator(operator);
}
else if(code === 0x20D0 || type === ACCENT_HALF_ARROW_LEFT)
{
glyph = new CCombiningHalfArrow();
operator = new CCombiningHalfArrow();
props =
{
location: LOCATION_TOP,
turn: TURN_0
};
glyph.init(props);
accent = new COperator(glyph);
operator.init(props);
accent = new COperator(operator);
}
else if(code === 0x20D1 || type === ACCENT_HALF_ARROW_RIGHT)
{
glyph = new CCombiningHalfArrow();
operator = new CCombiningHalfArrow();
props =
{
location: LOCATION_TOP,
turn: TURN_180
};
glyph.init(props);
accent = new COperator(glyph);
operator.init(props);
accent = new COperator(operator);
}
/////
else if(typeof(code) !=="undefined" && code !== null)
{
glyph = new CMathText();
glyph.add(code);
operator = new CMathText();
operator.add(code);
}
else
{
glyph = new COperatorBracket();
operator = new COperatorBracket();
props =
{
location: LOCATION_BOT,
turn: TURN_MIRROR_0
};
glyph.init(props);
operator.init(props);
}
return glyph;
return operator;
}
CGroupCharacter.prototype.getPropsForWrite = function()
{
var vertJc = null;
if (this.vertJc == VJUST_BOT)
vertJc = 0;
else if ( this.vertJc == VJUST_TOP)
vertJc = 1;
var pos = null;
if (this.loc == LOCATION_BOT)
pos = 0;
else if ( this.loc == LOCATION_TOP)
pos = 1;
var props = {
chr: String.fromCharCode(this.operator.code),
pos: pos,
vertJc: vertJc
};
return props;
var props = {};
props.vertJ = this.vertJust;
props.pos = this.loc;
props.chr = this.operator.getChr();
return props;
}
\ No newline at end of file
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