Commit cecf15e5 authored by Anna.Pavlova's avatar Anna.Pavlova

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 4edd9d27
function CMathBase() function CMathBase()
{ {
this.typeObj = MATH_COMP; this.typeObj = MATH_COMP;
this.typeElement = null; // для чтения
// {align: {height: alpha, width: betta}} alpha & betta коэффициенты в интервале от 0 до 1, либо CENTER // {align: {height: alpha, width: betta}} alpha & betta коэффициенты в интервале от 0 до 1, либо CENTER
CENTER = -1; CENTER = -1;
...@@ -81,7 +83,6 @@ CMathBase.prototype = ...@@ -81,7 +83,6 @@ CMathBase.prototype =
}, },
///////// RunPrp, CtrPrp ///////// RunPrp, CtrPrp
setCtrPrp: function(runPrp) setCtrPrp: function(runPrp)
{ {
...@@ -124,7 +125,6 @@ CMathBase.prototype = ...@@ -124,7 +125,6 @@ CMathBase.prototype =
}, },
///////// /////////
setComposition: function(composition) setComposition: function(composition)
{ {
this.Composition = composition; this.Composition = composition;
...@@ -972,5 +972,14 @@ CMathBase.prototype = ...@@ -972,5 +972,14 @@ CMathBase.prototype =
var content = this.elements[pos.X][pos.Y].getContent(stack, bCurrent); var content = this.elements[pos.X][pos.Y].getContent(stack, bCurrent);
return content; return content;
},
setTypeElement: function(type)
{
this.typeElement = type;
},
getTypeElement: function()
{
return this.typeElement;
} }
} }
function CDegree() function CDegree()
{ {
this.type = null; this.type = DEGREE_SUPERSCRIPT ;
this.shiftDegree = null; this.shiftDegree = 0;
CMathBase.call(this); CMathBase.call(this);
} }
extend(CDegree, CMathBase); extend(CDegree, CMathBase);
...@@ -11,7 +11,9 @@ CDegree.prototype.init = function(props) ...@@ -11,7 +11,9 @@ CDegree.prototype.init = function(props)
} }
CDegree.prototype.init_2 = function(props, oBase) CDegree.prototype.init_2 = function(props, oBase)
{ {
if( typeof(props.type)!=="undefined"|| props.type !== null)
this.type = props.type; this.type = props.type;
this.setDimension(1, 2); this.setDimension(1, 2);
var oDegree = new CMathContent(); var oDegree = new CMathContent();
...@@ -369,7 +371,7 @@ CIterators.prototype.getCtrPrp = function() ...@@ -369,7 +371,7 @@ CIterators.prototype.getCtrPrp = function()
function CDegreeSubSup() function CDegreeSubSup()
{ {
this.type = null; this.type = DEGREE_SubSup;
CSubMathBase.call(this); CSubMathBase.call(this);
} }
extend(CDegreeSubSup, CSubMathBase); extend(CDegreeSubSup, CSubMathBase);
...@@ -380,7 +382,9 @@ CDegreeSubSup.prototype.init = function(props) ...@@ -380,7 +382,9 @@ CDegreeSubSup.prototype.init = function(props)
} }
CDegreeSubSup.prototype.init_2 = function(props, oBase) CDegreeSubSup.prototype.init_2 = function(props, oBase)
{ {
if( typeof(props.type)!=="undefined"|| props.type !== null)
this.type = props.type; this.type = props.type;
this.setDimension(1, 2); this.setDimension(1, 2);
var oIters = new CIterators(); var oIters = new CIterators();
......
function CFraction() function CFraction()
{ {
this.type = null; this.type = BAR_FRACTION;
this.bHideBar = false; this.bHideBar = false;
CMathBase.call(this); CMathBase.call(this);
} }
...@@ -9,8 +9,6 @@ CFraction.prototype.init = function(props) ...@@ -9,8 +9,6 @@ CFraction.prototype.init = function(props)
{ {
if( typeof(props.type) !== "undefined" && props.type !== null ) if( typeof(props.type) !== "undefined" && props.type !== null )
this.type = props.type; this.type = props.type;
else
this.type = BAR_FRACTION;
if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION) if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{ {
......
...@@ -139,7 +139,7 @@ CMathFunc.prototype.setDistance = function() ...@@ -139,7 +139,7 @@ CMathFunc.prototype.setDistance = function()
{ {
this.dW = this.getTxtPrp().FontSize/6*g_dKoef_pt_to_mm; this.dW = this.getTxtPrp().FontSize/6*g_dKoef_pt_to_mm;
} }
CMathFunc.prototype.getFunction = function() CMathFunc.prototype.getFName = function()
{ {
return this.elements[0][0]; return this.elements[0][0];
} }
......
...@@ -19,8 +19,7 @@ ...@@ -19,8 +19,7 @@
/// TODO (tomorrow) /// TODO (tomorrow)
// 1. Посмотреть стрелки и прочее для delimiters (которые используются для accent), при необходимости привести к одному типу // 1. Посмотреть стрелки и прочее для delimiters (которые используются для accent), при необходимости привести к одному типу
// 2. Дефолтовые значения для delimiters // 2. Посмотреть дефолтовые значения для остальных мат. объектов
// 3. Дописать тестовый пример(добавить операторы)
var historyitem_Math_AddItem = 1; // Добавляем элемент var historyitem_Math_AddItem = 1; // Добавляем элемент
var historyitem_Math_RemoveItem = 2; // Удаляем элемент var historyitem_Math_RemoveItem = 2; // Удаляем элемент
...@@ -81,6 +80,11 @@ CMathRunPrp.prototype = ...@@ -81,6 +80,11 @@ CMathRunPrp.prototype =
{ {
return this.runPrp; return this.runPrp;
}, },
getMathRunPrp: function()
{
// заглушка
},
draw: function() {}, draw: function() {},
setPosition: function() {}, setPosition: function() {},
relate: function() {} relate: function() {}
...@@ -457,6 +461,7 @@ CMathContent.prototype = ...@@ -457,6 +461,7 @@ CMathContent.prototype =
//l_gap = r_gap = Math.floor( this.font.FontSize / 5 )*g_dKoef_pix_to_mm; //l_gap = r_gap = Math.floor( this.font.FontSize / 5 )*g_dKoef_pix_to_mm;
mathElem.relate(this); mathElem.relate(this);
mathElem.setTypeElement(ind);
//mathElem.setComposition(this.Composition); //mathElem.setComposition(this.Composition);
var ctrPrp = new CTextPr(); var ctrPrp = new CTextPr();
...@@ -5278,7 +5283,7 @@ CMathContent.prototype = ...@@ -5278,7 +5283,7 @@ CMathContent.prototype =
this.content.length = 0; this.content.length = 0;
this.content = tmp; this.content = tmp;
}, },
addRunPrpToContent_2: function(runPrp) // for "read" /*addRunPrpToContent_2: function(runPrp) // for "read"
{ {
var rPrp = new CMathRunPrp(); var rPrp = new CMathRunPrp();
rPrp.Merge(runPrp); rPrp.Merge(runPrp);
...@@ -5287,6 +5292,35 @@ CMathContent.prototype = ...@@ -5287,6 +5292,35 @@ CMathContent.prototype =
this.content.push(element); this.content.push(element);
this.CurPos++; 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() getCurrRunPrp: function()
{ {
...@@ -6513,5 +6547,43 @@ function CEmpty() ...@@ -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; ...@@ -15,6 +15,8 @@ var MATH_EQ_ARRAY = 13;
var MATH_BAR = 14; var MATH_BAR = 14;
var MATH_PHANTOM = 15; var MATH_PHANTOM = 15;
var MATH_RUN = 16;
var BAR_FRACTION = 0; var BAR_FRACTION = 0;
var SKEWED_FRACTION = 1; var SKEWED_FRACTION = 1;
var LINEAR_FRACTION = 2; var LINEAR_FRACTION = 2;
......
...@@ -78,7 +78,7 @@ CNary.prototype.init = function(props) ...@@ -78,7 +78,7 @@ CNary.prototype.init = function(props)
var arg = new CMathContent(), var arg = new CMathContent(),
base; base;
if(this.limLoc === 0) if(this.limLoc === NARY_UndOvr)
{ {
if(this.supHide && this.subHide) if(this.supHide && this.subHide)
{ {
...@@ -144,7 +144,6 @@ CNary.prototype.getLowerIterator = function() ...@@ -144,7 +144,6 @@ CNary.prototype.getLowerIterator = function()
return this.elements[0][0].getLowerIterator(); return this.elements[0][0].getLowerIterator();
} }
function old_CNary() function old_CNary()
{ {
CSubMathBase.call(this); CSubMathBase.call(this);
......
...@@ -3823,6 +3823,15 @@ CDelimiter.prototype.init = function(props) ...@@ -3823,6 +3823,15 @@ CDelimiter.prototype.init = function(props)
else if(props.grow == false || props.grow == 0) else if(props.grow == false || props.grow == 0)
this.grow = false; 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); var begGlyph = this.getGlyph(props.begChr, props.begChrType, LOCATION_LEFT);
this.begOper = new COperator (begGlyph); this.begOper = new COperator (begGlyph);
this.begOper.relate(this); this.begOper.relate(this);
...@@ -4154,7 +4163,7 @@ CDelimiter.prototype.getBase = function(numb) ...@@ -4154,7 +4163,7 @@ CDelimiter.prototype.getBase = function(numb)
CDelimiter.prototype.getGlyph = function(chr, type, location) CDelimiter.prototype.getGlyph = function(chr, type, location)
{ {
var operator; 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) if( code === 0x28 || type === PARENTHESIS_LEFT)
{ {
...@@ -4326,12 +4335,12 @@ CDelimiter.prototype.getGlyph = function(chr, type, location) ...@@ -4326,12 +4335,12 @@ CDelimiter.prototype.getGlyph = function(chr, type, location)
}; };
operator.init(props); operator.init(props);
} }
else if( code === "" || type === BRACKET_EMPTY) else if(type === BRACKET_EMPTY)
operator = -1; operator = -1;
else if(code !== null) else if(code !== null)
{ {
operator = new CMathText(); operator = new CMathText();
operator.add(code.charCodeAt(0)); operator.add(code);
} }
else else
operator = -1; operator = -1;
...@@ -4623,6 +4632,12 @@ CGroupCharacter.prototype.init = function(props) ...@@ -4623,6 +4632,12 @@ CGroupCharacter.prototype.init = function(props)
var type = props.chrType; var type = props.chrType;
var code = typeof(props.chr) === "string" ? props.chr.charCodeAt(0) : null; 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); var glyph = this.getGlyph(code, type);
if(glyph.bArrow) if(glyph.bArrow)
......
...@@ -11,14 +11,14 @@ function simulatorRead() ...@@ -11,14 +11,14 @@ function simulatorRead()
var ctrPrp = new CTextPr(); var ctrPrp = new CTextPr();
ctrPrp.FontSize = 36; ctrPrp.FontSize = 36;
addToContent_ForRead( MathComposition.Root, accent, props, ctrPrp ); addToContent_ForRead(MathComposition.Root, accent, props, ctrPrp);
props = props =
{ {
type: BAR_FRACTION type: BAR_FRACTION
}; };
var fract = new CFraction(); var fract = new CFraction();
addToContent_ForRead( accent.getBase(), fract, props ); addToContent_ForRead(accent.getBase(), fract, props);
fract.getDenominator().fillPlaceholders(); fract.getDenominator().fillPlaceholders();
var content = fract.getNumerator(); var content = fract.getNumerator();
...@@ -27,7 +27,7 @@ function simulatorRead() ...@@ -27,7 +27,7 @@ function simulatorRead()
{ {
type: SKEWED_FRACTION type: SKEWED_FRACTION
}; };
addToContent_ForRead( content, fract2, props ); addToContent_ForRead(content, fract2, props);
var num1 = fract2.getNumerator(); var num1 = fract2.getNumerator();
var den1 = fract2.getDenominator(); var den1 = fract2.getDenominator();
...@@ -221,6 +221,23 @@ function simulatorRead() ...@@ -221,6 +221,23 @@ function simulatorRead()
matrix.getElement(1,0).fillPlaceholders(); matrix.getElement(1,0).fillPlaceholders();
matrix.getElement(2,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(); 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