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

1. Добавила gaps для пересечений, стрелок, различных знаков раенств etc

2. Перенесла подмену кодов знаков умножить и минус в getCode (mathText)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58556 954022d7-b5bf-4e40-9824-e11837661b57
parent 04000ff3
...@@ -242,10 +242,16 @@ function CCoeffGaps() ...@@ -242,10 +242,16 @@ function CCoeffGaps()
right: new CGaps(0, 0, 0, 0.49) right: new CGaps(0, 0, 0, 0.49)
}; };
this.Equal = /*this.Equal =
{ {
left: new CGaps(0.35, 0, 0, 0.7), left: new CGaps(0.35, 0, 0, 0.7),
right: new CGaps(0.25, 0, 0, 0.5) right: new CGaps(0.25, 0, 0, 0.5)
};*/
this.Equal =
{
left: new CGaps(0, 0, 0, 0.7),
right: new CGaps(0, 0, 0, 0.5)
}; };
this.Default = this.Default =
...@@ -260,11 +266,12 @@ CCoeffGaps.prototype = ...@@ -260,11 +266,12 @@ CCoeffGaps.prototype =
{ {
var operator = null; var operator = null;
if(codeCurr == 0x3D) //if(codeCurr == 0x3D)
if(this.checkEqualSign(codeCurr))
operator = this.Equal; operator = this.Equal;
else if(this.checkOperSign(codeCurr)) else if(this.checkOperSign(codeCurr))
operator = this.Sign; operator = this.Sign;
else if(codeCurr == 0x2217) else if(codeCurr == 0x2A)
operator = this.Mult; operator = this.Mult;
else else
operator = this.Default; operator = this.Default;
...@@ -276,9 +283,10 @@ CCoeffGaps.prototype = ...@@ -276,9 +283,10 @@ CCoeffGaps.prototype =
coeff = part.letters; coeff = part.letters;
else if(this.checkOperSign(codeLR)) else if(this.checkOperSign(codeLR))
coeff = part.sign; coeff = part.sign;
else if(codeLR == 0x3D ) //else if(codeLR == 0x3D )
else if(this.checkEqualSign(codeLR))
coeff = part.equal; coeff = part.equal;
else if(codeLR == this.checkZEROSign(codeLR)) else if(this.checkZeroSign(codeLR, direct))
coeff = part.zeroOper; coeff = part.zeroOper;
else else
coeff = part.letters; coeff = part.letters;
...@@ -289,42 +297,44 @@ CCoeffGaps.prototype = ...@@ -289,42 +297,44 @@ CCoeffGaps.prototype =
checkOperSign: function(code) // "+", "-", "<", ">", "±" checkOperSign: function(code) // "+", "-", "<", ">", "±"
{ {
var PLUS = 0x2B, var PLUS = 0x2B,
MINUS = 0x2212, //MINUS = 0x2212,
MINUS = 0x2D,
LESS = 0x3C, LESS = 0x3C,
GREATER = 0x3E, GREATER = 0x3E,
PLUS_MINUS = 0xB1; PLUS_MINUS = 0xB1;
return code == PLUS || code == MINUS || code == LESS || code == GREATER || code == PLUS_MINUS; return code == PLUS || code == MINUS || code == LESS || code == GREATER || code == PLUS_MINUS;
}, },
new_checkOperSign: function(code) // "+", "-", "<", ">", "±" new_checkOperSign: function(code) // "+", "-", "±"
{ {
var PLUS = 0x2B, var PLUS = 0x2B,
MINUS = 0x2212, MINUS = 0x2D,
LESS = 0x3C,
GREATER = 0x3E,
PLUS_MINUS = 0xB1; PLUS_MINUS = 0xB1;
var MATH_SiGN = code == PLUS || code == MINUS || code == LESS || code == GREATER || code == PLUS_MINUS; return code == PLUS || code == MINUS || code == PLUS_MINUS;
var ARROWS = (code >= 0x2190 && code <= 0x21B3) || (code == 0x21B6) || (code == 0x21B7) || (code >= 0x21BA && code <= 0x21E9) && (code >=0x21F4 && code <=0x21FF); },
checkEqualSign: function(code)
{
var COMPARE = code == 0x3C || code == 0x3E; // LESS, GREATER
var ARROWS = (code >= 0x2190 && code <= 0x21B3) || (code == 0x21B6) || (code == 0x21B7) || (code >= 0x21BA && code <= 0x21E9) || (code >=0x21F4 && code <= 0x21FF);
var INTERSECTION = code >= 0x2223 && code <= 0x222A;
var EQUALS = (code >= 0x2234 && code <= 0x22BD) || (code >= 0x22C4 && code <= 0x22FF); var EQUALS = (code >= 0x2234 && code <= 0x22BD) || (code >= 0x22C4 && code <= 0x22FF);
var ARR_FISHES = (code >= 0x27DA && code <= 0x27E5) || (code >= 0x27EC && code <= 0x297F); var ARR_FISHES = (code >= 0x27DA && code <= 0x27E5) || (code >= 0x27EC && code <= 0x297F);
var TRIANGLE_SYMB = code >= 0x29CE && code <= 0x29D7; var TRIANGLE_SYMB = code >= 0x29CE && code <= 0x29D7;
var OTH_SYMB = code == 0x29DF || (code >= 0x29E1 && code <= 0x29E7) || (code >= 0x29F4 && code <= 0x29F8) || (code >= 0x2A22 && code <= 0x2AF0) || (code >= 0x2AF2 && code <= 0x2AFB)|| code == 0x2AFD || code == 0x2AFE; var OTH_SYMB = code == 0x29DF || (code >= 0x29E1 && code <= 0x29E7) || (code >= 0x29F4 && code <= 0x29F8) || (code >= 0x2A22 && code <= 0x2AF0) || (code >= 0x2AF2 && code <= 0x2AFB) || code == 0x2AFD || code == 0x2AFE;
return MATH_SiGN || ARROWS || EQUALS || ARR_FISHES || TRIANGLE_SYMB || OTH_SYMB; return COMPARE || ARROWS || INTERSECTION || EQUALS || ARR_FISHES || TRIANGLE_SYMB || OTH_SYMB;
//return code == PLUS || code == MINUS || code == LESS || code == GREATER || code == PLUS_MINUS;
}, },
checkZEROSign: function(code, direct) // "*", "/", "\" checkZeroSign: function(code, direct) // "*", "/", "\"
{ {
var MULT = 0x2217, //var MULT = 0x2217,
var MULT = 0x2A,
DIVISION = 0x2F, DIVISION = 0x2F,
B_SLASH = 0x5C; B_SLASH = 0x5C;
var bOper = code == MULT || code == DIVISION || code == B_SLASH; var bOper = code == MULT || code == DIVISION || code == B_SLASH;
var bLeftBracket = direct == -1 && (code == 0x28 || code == 0x5B || code == 0x7B); var bLeftBracket = direct == -1 && (code == 0x28 || code == 0x5B || code == 0x7B);
var bRightBracket = direct == 1 && (code == 0x29 || code == 0x5D || code == 0x7D); var bRightBracket = direct == 1 && (code == 0x29 || code == 0x5D || code == 0x7D);
...@@ -394,7 +404,7 @@ function CMathGapsInfo(oMeasure, Parent, argSize) ...@@ -394,7 +404,7 @@ function CMathGapsInfo(oMeasure, Parent, argSize)
} }
CMathGapsInfo.prototype = CMathGapsInfo.prototype =
{ {
old_checkGapsSign: function(oMeasure, posCurr) /*old_checkGapsSign: function(oMeasure, posCurr)
{ {
var left = null, var left = null,
right = null; right = null;
...@@ -473,7 +483,7 @@ CMathGapsInfo.prototype = ...@@ -473,7 +483,7 @@ CMathGapsInfo.prototype =
if(bLeft) if(bLeft)
{ {
if(this.checkZEROSign(leftCode)) if(this.checkZeroSign(leftCode))
coeffLeft = 0; coeffLeft = 0;
else if(leftCode == EQUAL) else if(leftCode == EQUAL)
coeffLeft = 0.26; coeffLeft = 0.26;
...@@ -483,7 +493,7 @@ CMathGapsInfo.prototype = ...@@ -483,7 +493,7 @@ CMathGapsInfo.prototype =
if(bRight) if(bRight)
{ {
var bZero = this.checkZEROSign(rightCode); var bZero = this.checkZeroSign(rightCode);
if(rightCode == EQUAL || bZero) if(rightCode == EQUAL || bZero)
coeffRight = 0; coeffRight = 0;
else else
...@@ -496,7 +506,7 @@ CMathGapsInfo.prototype = ...@@ -496,7 +506,7 @@ CMathGapsInfo.prototype =
if(bLeft) if(bLeft)
{ {
var bZeroLeft = this.checkZEROSign(leftCode), var bZeroLeft = this.checkZeroSign(leftCode),
bOperLeft = this.checkOperSign(leftCode); bOperLeft = this.checkOperSign(leftCode);
if(leftCode == EQUAL || bOperLeft || bZeroLeft) if(leftCode == EQUAL || bOperLeft || bZeroLeft)
...@@ -507,7 +517,7 @@ CMathGapsInfo.prototype = ...@@ -507,7 +517,7 @@ CMathGapsInfo.prototype =
if(bRight) if(bRight)
{ {
var bZeroRight = this.checkZEROSign(rightCode), var bZeroRight = this.checkZeroSign(rightCode),
bOperRight = this.checkOperSign(rightCode); bOperRight = this.checkOperSign(rightCode);
if(rightCode == EQUAL || bOperRight || bZeroRight) if(rightCode == EQUAL || bOperRight || bZeroRight)
...@@ -523,7 +533,7 @@ CMathGapsInfo.prototype = ...@@ -523,7 +533,7 @@ CMathGapsInfo.prototype =
if(bLeft) if(bLeft)
{ {
var bZero = this.checkZEROSign(leftCode); var bZero = this.checkZeroSign(leftCode);
if(leftCode == EQUAL || bZero) if(leftCode == EQUAL || bZero)
coeffLeft = 0; coeffLeft = 0;
else if(this.checkOperSign(leftCode)) else if(this.checkOperSign(leftCode))
...@@ -534,7 +544,7 @@ CMathGapsInfo.prototype = ...@@ -534,7 +544,7 @@ CMathGapsInfo.prototype =
if(bRight) if(bRight)
{ {
var bZero = this.checkZEROSign(rightCode); var bZero = this.checkZeroSign(rightCode);
if(rightCode == EQUAL || bZero) if(rightCode == EQUAL || bZero)
coeffRight = 0; coeffRight = 0;
else if(this.checkOperSign(rightCode)) else if(this.checkOperSign(rightCode))
...@@ -602,7 +612,7 @@ CMathGapsInfo.prototype = ...@@ -602,7 +612,7 @@ CMathGapsInfo.prototype =
this.content[posCurr].gaps.left = Math.ceil(coeffLeft*gapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте this.content[posCurr].gaps.left = Math.ceil(coeffLeft*gapSign*10)/10; // если ни один случай не выполнился, выставляем "нулевые" gaps (default): необходимо, если что-то удалили и объект стал первый или последним в контенте
this.content[posCurr].gaps.right = Math.ceil(coeffRight*gapSign*10)/10; this.content[posCurr].gaps.right = Math.ceil(coeffRight*gapSign*10)/10;
/*if(this.bRoot) *//*if(this.bRoot)
{ {
if(bSign) if(bSign)
{ {
...@@ -620,10 +630,10 @@ CMathGapsInfo.prototype = ...@@ -620,10 +630,10 @@ CMathGapsInfo.prototype =
console.log("gap left : " + this.content[posCurr].gaps.left + ", gap right : " + this.content[posCurr].gaps.right); console.log("gap left : " + this.content[posCurr].gaps.left + ", gap right : " + this.content[posCurr].gaps.right);
console.log(""); console.log("");
} }
}*/ }*//*
} }
}, },*/
setGaps: function() setGaps: function()
{ {
if(this.argSize < 0) if(this.argSize < 0)
...@@ -644,7 +654,6 @@ CMathGapsInfo.prototype = ...@@ -644,7 +654,6 @@ CMathGapsInfo.prototype =
{ {
var currCode = this.Current.getCodeChr(); var currCode = this.Current.getCodeChr();
if(this.Left !== null) if(this.Left !== null)
{ {
if(this.Left.Type == para_Math_Composition) if(this.Left.Type == para_Math_Composition)
...@@ -884,7 +893,6 @@ CMPrp.prototype = ...@@ -884,7 +893,6 @@ CMPrp.prototype =
//пересмотреть this.dW и this.dH //пересмотреть this.dW и this.dH
function CMathContent() function CMathContent()
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
......
...@@ -67,13 +67,7 @@ CMathText.prototype = ...@@ -67,13 +67,7 @@ CMathText.prototype =
constructor: CMathText, constructor: CMathText,
add: function(code) add: function(code)
{ {
if(code == 0x2A) // "*"
code = 0x2217;
else if(code == 0x2D) // "-"
code = 0x2212;
this.value = code; this.value = code;
}, },
addTxt: function(txt) addTxt: function(txt)
{ {
...@@ -104,7 +98,12 @@ CMathText.prototype = ...@@ -104,7 +98,12 @@ CMathText.prototype =
// Mathematical Alphanumeric Characters // Mathematical Alphanumeric Characters
// http://www.w3.org/TR/2014/REC-xml-entity-names-20140410/Overview.html#alphabets // http://www.w3.org/TR/2014/REC-xml-entity-names-20140410/Overview.html#alphabets
if(Scr == TXT_ROMAN) if(code == 0x2A) // "*"
code = 0x2217;
else if(code == 0x2D) // "-"
code = 0x2212;
else if(Scr == TXT_ROMAN)
{ {
if(Sty == STY_ITALIC) if(Sty == STY_ITALIC)
{ {
......
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