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

1. Функция для записи в файл из мат. контента (в тч передача типа объекта)

2. Добавила дефолтные значения для delimiters, поправила баг для delimiters, когда вместо оператора передается текст
3. Добавила в тестовый пример для чтения оператор

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@52031 954022d7-b5bf-4e40-9824-e11837661b57
parent 468169a1
function CMathBase()
{
this.typeObj = MATH_COMP;
this.typeElement = null; // для чтения
// {align: {height: alpha, width: betta}} alpha & betta коэффициенты в интервале от 0 до 1, либо CENTER
CENTER = -1;
......@@ -81,7 +83,6 @@ CMathBase.prototype =
},
///////// RunPrp, CtrPrp
setCtrPrp: function(runPrp)
{
......@@ -124,7 +125,6 @@ CMathBase.prototype =
},
/////////
setComposition: function(composition)
{
this.Composition = composition;
......@@ -972,5 +972,14 @@ CMathBase.prototype =
var content = this.elements[pos.X][pos.Y].getContent(stack, bCurrent);
return content;
},
setTypeElement: function(type)
{
this.typeElement = type;
},
getTypeElement: function()
{
return this.typeElement;
}
}
function CDegree()
{
this.type = null;
this.shiftDegree = null;
this.type = DEGREE_SUPERSCRIPT ;
this.shiftDegree = 0;
CMathBase.call(this);
}
extend(CDegree, CMathBase);
......@@ -11,7 +11,9 @@ CDegree.prototype.init = function(props)
}
CDegree.prototype.init_2 = function(props, oBase)
{
this.type = props.type;
if( typeof(props.type)!=="undefined"|| props.type !== null)
this.type = props.type;
this.setDimension(1, 2);
var oDegree = new CMathContent();
......@@ -369,7 +371,7 @@ CIterators.prototype.getCtrPrp = function()
function CDegreeSubSup()
{
this.type = null;
this.type = DEGREE_SubSup;
CSubMathBase.call(this);
}
extend(CDegreeSubSup, CSubMathBase);
......@@ -380,7 +382,9 @@ CDegreeSubSup.prototype.init = function(props)
}
CDegreeSubSup.prototype.init_2 = function(props, oBase)
{
this.type = props.type;
if( typeof(props.type)!=="undefined"|| props.type !== null)
this.type = props.type;
this.setDimension(1, 2);
var oIters = new CIterators();
......
function CFraction()
{
this.type = null;
this.type = BAR_FRACTION;
this.bHideBar = false;
CMathBase.call(this);
}
......@@ -9,8 +9,6 @@ CFraction.prototype.init = function(props)
{
if( typeof(props.type) !== "undefined" && props.type !== null )
this.type = props.type;
else
this.type = BAR_FRACTION;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{
......
......@@ -139,7 +139,7 @@ CMathFunc.prototype.setDistance = function()
{
this.dW = this.getTxtPrp().FontSize/6*g_dKoef_pt_to_mm;
}
CMathFunc.prototype.getFunction = function()
CMathFunc.prototype.getFName = function()
{
return this.elements[0][0];
}
......
......@@ -19,8 +19,7 @@
/// TODO (tomorrow)
// 1. Посмотреть стрелки и прочее для delimiters (которые используются для accent), при необходимости привести к одному типу
// 2. Дефолтовые значения для delimiters
// 3. Дописать тестовый пример(добавить операторы)
// 2. Посмотреть дефолтовые значения для остальных мат. объектов
var historyitem_Math_AddItem = 1; // Добавляем элемент
var historyitem_Math_RemoveItem = 2; // Удаляем элемент
......@@ -81,6 +80,11 @@ CMathRunPrp.prototype =
{
return this.runPrp;
},
getMathRunPrp: function()
{
// заглушка
},
draw: function() {},
setPosition: function() {},
relate: function() {}
......@@ -457,6 +461,7 @@ CMathContent.prototype =
//l_gap = r_gap = Math.floor( this.font.FontSize / 5 )*g_dKoef_pix_to_mm;
mathElem.relate(this);
mathElem.setTypeElement(ind);
//mathElem.setComposition(this.Composition);
var ctrPrp = new CTextPr();
......@@ -2490,7 +2495,7 @@ CMathContent.prototype =
{
chrType: BRACKET_CURLY_TOP,
location: LOCATION_TOP,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
delim.init(props);
delim.fillPlaceholders();
......@@ -2936,7 +2941,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_LEFT,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -2953,7 +2958,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_RIGHT,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -2997,7 +3002,7 @@ CMathContent.prototype =
var props =
{
chrType: DOUBLE_LEFT_ARROW,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -3014,7 +3019,7 @@ CMathContent.prototype =
var props =
{
chrType: DOUBLE_RIGHT_ARROW,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -3048,7 +3053,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_LR,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -3082,7 +3087,7 @@ CMathContent.prototype =
var props =
{
chrType: DOUBLE_ARROW_LR,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
arrow.fillPlaceholders();
......@@ -3099,7 +3104,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_RIGHT,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
var base = arrow.getBase();
......@@ -3117,7 +3122,7 @@ CMathContent.prototype =
var props =
{
chrType: ARROW_RIGHT,
vertJc: VJUST_BOT
vertJc: VJUST_BOT
};
arrow.init(props);
var base = arrow.getBase();
......@@ -5278,7 +5283,7 @@ CMathContent.prototype =
this.content.length = 0;
this.content = tmp;
},
addRunPrpToContent_2: function(runPrp) // for "read"
/*addRunPrpToContent_2: function(runPrp) // for "read"
{
var rPrp = new CMathRunPrp();
rPrp.Merge(runPrp);
......@@ -5287,6 +5292,35 @@ CMathContent.prototype =
this.content.push(element);
this.CurPos++;
},*/
readContent: function() // for "read"
{
var result = new Array();
for(var i=0; i < this.content.length; i++)
{
if(this.content[i].value.typeObj === MATH_RUN_PRP)
{
var run = new CRun();
run.setRunPrp(this.content[i].value);
run.setMathRunPrp(this.content[i].value);
while(this.content[i + 1].value.typeObj === MATH_TEXT)
{
run.addLetter(this.content[i + 1].value);
i++;
}
result.push(run);
}
else if(this.content[i].value.typeObj === MATH_COMP)
{
result.push(this.content[i].value);
}
}
return result;
},
getCurrRunPrp: function()
{
......@@ -6513,5 +6547,43 @@ function CEmpty()
}
function CRun()
{
this.text = "";
this.runPrp = null;
this.mathRunPrp = null;
}
CRun.prototype =
{
getText: function()
{
return this.text;
},
getRunPrp: function()
{
return this.runPrp;
},
getMathRunPrp: function()
{
return this.mathRunPrp;
},
getTypeElement: function()
{
return MATH_RUN;
},
setRunPrp: function(oRunPrp)
{
this.runPrp = oRunPrp.getRunPrp();
},
addLetter: function(oMText)
{
this.text += String.fromCharCode(oMText.value);
},
setMathRunPrp: function(oRunPrp)
{
this.mathRunPrp = oRunPrp.getMathRunPrp();
}
}
......@@ -15,6 +15,8 @@ var MATH_EQ_ARRAY = 13;
var MATH_BAR = 14;
var MATH_PHANTOM = 15;
var MATH_RUN = 16;
var BAR_FRACTION = 0;
var SKEWED_FRACTION = 1;
var LINEAR_FRACTION = 2;
......
......@@ -78,7 +78,7 @@ CNary.prototype.init = function(props)
var arg = new CMathContent(),
base;
if(this.limLoc === 0)
if(this.limLoc === NARY_UndOvr)
{
if(this.supHide && this.subHide)
{
......@@ -144,7 +144,6 @@ CNary.prototype.getLowerIterator = function()
return this.elements[0][0].getLowerIterator();
}
function old_CNary()
{
CSubMathBase.call(this);
......
......@@ -3823,6 +3823,15 @@ CDelimiter.prototype.init = function(props)
else if(props.grow == false || props.grow == 0)
this.grow = false;
if(typeof(props.begChr) === "string" && props.begChr.length == 0)
props.begChrType = PARENTHESIS_LEFT;
if(typeof(props.endChr) === "string" && props.endChr.length == 0)
props.endChrType = PARENTHESIS_RIGHT;
if(typeof(props.endChr) === "string" && props.endChr.length == 0)
props.sepChrType = DELIMITER_LINE;
var begGlyph = this.getGlyph(props.begChr, props.begChrType, LOCATION_LEFT);
this.begOper = new COperator (begGlyph);
this.begOper.relate(this);
......@@ -4154,7 +4163,7 @@ CDelimiter.prototype.getBase = function(numb)
CDelimiter.prototype.getGlyph = function(chr, type, location)
{
var operator;
var code = typeof(chr) === "string" ? chr.charCodeAt(0) : null;
var code = typeof(chr) === "string" && chr.length > 0 ? chr.charCodeAt(0) : null;
if( code === 0x28 || type === PARENTHESIS_LEFT)
{
......@@ -4326,12 +4335,12 @@ CDelimiter.prototype.getGlyph = function(chr, type, location)
};
operator.init(props);
}
else if( code === "" || type === BRACKET_EMPTY)
else if(type === BRACKET_EMPTY)
operator = -1;
else if(code !== null)
{
operator = new CMathText();
operator.add(code.charCodeAt(0));
operator.add(code);
}
else
operator = -1;
......@@ -4623,6 +4632,12 @@ CGroupCharacter.prototype.init = function(props)
var type = props.chrType;
var code = typeof(props.chr) === "string" ? props.chr.charCodeAt(0) : null;
if( typeof(type) === "undefined"|| type === null && code === null )
{
type = BRACKET_CURLY_BOTTOM;
this.loc = LOCATION_BOT;
}
var glyph = this.getGlyph(code, type);
if(glyph.bArrow)
......
......@@ -11,14 +11,14 @@ function simulatorRead()
var ctrPrp = new CTextPr();
ctrPrp.FontSize = 36;
addToContent_ForRead( MathComposition.Root, accent, props, ctrPrp );
addToContent_ForRead(MathComposition.Root, accent, props, ctrPrp);
props =
{
type: BAR_FRACTION
};
var fract = new CFraction();
addToContent_ForRead( accent.getBase(), fract, props );
addToContent_ForRead(accent.getBase(), fract, props);
fract.getDenominator().fillPlaceholders();
var content = fract.getNumerator();
......@@ -27,7 +27,7 @@ function simulatorRead()
{
type: SKEWED_FRACTION
};
addToContent_ForRead( content, fract2, props );
addToContent_ForRead(content, fract2, props);
var num1 = fract2.getNumerator();
var den1 = fract2.getDenominator();
......@@ -221,6 +221,23 @@ function simulatorRead()
matrix.getElement(1,0).fillPlaceholders();
matrix.getElement(2,0).fillPlaceholders();
var lastElem = matrix.getElement(3, 0);
lastElem.addTxt("w");
var oper = new CGroupCharacter();
props =
{
chrType: DOUBLE_ARROW_LR,
location: LOCATION_TOP
};
addToContent_ForRead(lastElem, oper, props);
oper.getBase().addTxt("a");
lastElem.addTxt("y");
//////////////////////////////////////////////////////////////////
MathComposition.RecalculateComposition();
......
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