Commit b9c1e1ec authored by GoshaZotov's avatar GoshaZotov

+ previous revision

parent a3994c6d
......@@ -2504,7 +2504,7 @@ PasteProcessor.prototype =
{
//TODO пока добавляю функцию здесь. должна она находиться в Math.js
var res = paraMath.Root.GetTextContent();
console.log(res);
console.log(res.str);
return res;
},
......
......@@ -7239,22 +7239,14 @@ CMathContent.prototype.ReplaceAutoCorrect = function(AutoCorrectEngine, bCursorS
}
};
CMathContent.prototype.GetTextContent = function(arr, str)
CMathContent.prototype.GetTextContent = function()
{
var arr = [], str = "", bIsContainsOperator = false;
if(!arr)
{
arr = [];
}
if(!str)
{
str = "";
}
var addText = function(value, bIsAddParenthesis)
{
if(bIsAddParenthesis && value.length > 1)
if(bIsAddParenthesis && value.length > 1 && value.match())
{
arr.push("(");
str += "(";
......@@ -7284,7 +7276,6 @@ CMathContent.prototype.GetTextContent = function(arr, str)
if(elem instanceof CDegree)
{
if(DEGREE_SUPERSCRIPT === elem.Pr.type)
{
res.push(getVal("^"));
......@@ -7331,7 +7322,7 @@ CMathContent.prototype.GetTextContent = function(arr, str)
}
else if(elem instanceof CMathMatrix)
{
res.push(getVal("", true));
res[-1] = getVal("", true);
for(var row = 0; row < elem.nRow; row++)
{
for(var col = 1; col < elem.nCol; col++)
......@@ -7348,60 +7339,35 @@ CMathContent.prototype.GetTextContent = function(arr, str)
return res;
};
var tempStr;
for(var i = 0; i < this.Content.length; i++)
{
switch(this.Content[i].Type)
{
case para_Math_Run:
{
if(this.Content[i].Content.length)
{
var string = "";
for(var j = 0; j < this.Content[i].Content.length; j++)
{
if(para_Math_Text === this.Content[i].Content[j].Type)
{
string += String.fromCharCode(this.Content[i].Content[j].value);
}
else if(para_Math_BreakOperator === this.Content[i].Content[j].Type)
{
string += String.fromCharCode(this.Content[i].Content[j].value);
}
}
addText(string);
}
break;
}
case para_Math_Composition:
var parseMathComposition = function(elem)
{
var elem = this.Content[i];
var tempStr;
var symbol = getMathSymbol(elem);
if(elem instanceof CDegree)//степень
{
//основание
tempStr = elem.Content[0].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
addText(symbol[0].value);
//показатель
tempStr = elem.Content[1].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
else if(elem instanceof CDelimiter)
{
tempStr = elem.Content[0].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
else if(elem instanceof CNary)//сумма
......@@ -7414,48 +7380,48 @@ CMathContent.prototype.GetTextContent = function(arr, str)
addText(symbol[1].value);
tempStr = elem.Content[0].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
//верхняя граница суммирования
if(null !== symbol[2])
{
addText(symbol[2].value);
//верхняя граница суммирования
tempStr = elem.Content[1].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
addText(symbol[3].value);
tempStr = elem.Content[2].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
else if(elem instanceof CFraction)//дробь
{
//числитель
tempStr = elem.Content[0].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
addText(symbol[0].value);
//знаменатель
tempStr = elem.Content[1].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
else if(elem instanceof CRadical)//корень
......@@ -7463,9 +7429,9 @@ CMathContent.prototype.GetTextContent = function(arr, str)
addText(symbol[0].value);
//степень корня
tempStr = elem.Content[0].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
if(tempStr)
......@@ -7475,35 +7441,29 @@ CMathContent.prototype.GetTextContent = function(arr, str)
//подкоренное выражение
tempStr = elem.Content[1].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
else if(elem instanceof CMathMatrix)
{
for(var j = 0; j < this.Content[i].Content.length; j++)
{
if(para_Math_Content === this.Content[i].Content[j].Type)
addText(symbol[-1].value);
addText("(");
for(var j = 0; j < elem.Content.length; j++)
{
if(j === 0 && symbol[-1] && symbol[-1].prePosition)
if(para_Math_Content === elem.Content[j].Type)
{
addText(symbol[-1].value);
}
if(symbol[j] && symbol[j].prePosition)
{
addText(symbol[j].value);
}
var tempStr = this.Content[i].Content[j].GetTextContent();
tempStr = elem.Content[j].GetTextContent();
if(tempStr)
if(tempStr.str)
{
if(tempStr.length > 1)
addText("(");
addText(tempStr);
if(tempStr.length > 1)
addText(")");
addText(tempStr.str, tempStr.bIsContainsOperator);
}
......@@ -7513,8 +7473,25 @@ CMathContent.prototype.GetTextContent = function(arr, str)
}
}
}
addText(")");
}
else if(elem instanceof CMathFunc)
{
//функция
tempStr = elem.Content[0].GetTextContent();
if(tempStr.str)
{
addText(tempStr.str);
}
//аргумент
tempStr = elem.Content[1].GetTextContent();
if(tempStr.str)
{
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
else if(elem instanceof CLimit)
{
//функция
tempStr = elem.Content[0].GetTextContent();
......@@ -7525,19 +7502,49 @@ CMathContent.prototype.GetTextContent = function(arr, str)
//аргумент
tempStr = elem.Content[1].GetTextContent();
if(tempStr)
if(tempStr.str)
{
addText(tempStr, true);
addText(tempStr.str, tempStr.bIsContainsOperator);
}
}
};
for(var i = 0; i < this.Content.length; i++)
{
switch(this.Content[i].Type)
{
case para_Math_Run:
{
if(this.Content[i].Content.length)
{
var string = "";
for(var j = 0; j < this.Content[i].Content.length; j++)
{
if(para_Math_Text === this.Content[i].Content[j].Type)
{
string += String.fromCharCode(this.Content[i].Content[j].value);
}
else if(para_Math_BreakOperator === this.Content[i].Content[j].Type)
{
string += String.fromCharCode(this.Content[i].Content[j].value);
bIsContainsOperator = true;
}
}
addText(string);
}
break;
}
case para_Math_Composition:
{
parseMathComposition(this.Content[i]);
break;
}
}
}
return str;
return {str: str, bIsContainsOperator: bIsContainsOperator};
};
CMathContent.prototype.GetTextContent3 = function(arr, str)
......
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