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

1. Поправила многочисленные баги, связанные с амперсандами (в связи с тем что...

1. Поправила многочисленные баги, связанные с амперсандами (в связи с тем что не хватало некоторых функций, которые есть в CMathText)
2. Вынесла общий функционал классов CMathText и CMathAmp в общий класс CMathBaseText

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62824 954022d7-b5bf-4e40-9824-e11837661b57
parent 46bb66b3
...@@ -604,15 +604,12 @@ ParaMath.prototype.Add = function(Item) ...@@ -604,15 +604,12 @@ ParaMath.prototype.Add = function(Item)
var NewElement = null; var NewElement = null;
if (para_Text === Type) if (para_Text === Type)
{ {
// заглушка для текстовых настроек плейсхолдера // заглушка для текстовых настроек плейсхолдера
if(oContent.bRoot == false && Run.IsPlaceholder()) if(oContent.bRoot == false && Run.IsPlaceholder())
{ {
var ctrPrp = oContent.Parent.Get_CtrPrp(); // копия ctrPrp var ctrPrp = oContent.Parent.Get_CtrPrp(); // копия ctrPrp
Run.Apply_TextPr(ctrPrp, undefined, true); Run.Apply_TextPr(ctrPrp, undefined, true);
//Run.Apply_TextPr();
} }
if(Item.Value == 38) if(Item.Value == 38)
...@@ -3203,7 +3200,6 @@ CMathRecalculateInfo.prototype.ClearRecalculate = function() ...@@ -3203,7 +3200,6 @@ CMathRecalculateInfo.prototype.ClearRecalculate = function()
this.bCorrect_FontSize = false; this.bCorrect_FontSize = false;
}; };
function CMathRecalculateObject() function CMathRecalculateObject()
{ {
this.WrapState = ALIGN_EMPTY; this.WrapState = ALIGN_EMPTY;
......
...@@ -1994,8 +1994,6 @@ CMathBase.prototype.UpdateMetrics = function(PRS, Size) ...@@ -1994,8 +1994,6 @@ CMathBase.prototype.UpdateMetrics = function(PRS, Size)
if(PRS.LineDescent < Size.height - Size.ascent) if(PRS.LineDescent < Size.height - Size.ascent)
PRS.LineDescent = Size.height - Size.ascent; PRS.LineDescent = Size.height - Size.ascent;
//PRS.ContentMetrics.UpdateMetrics(Size);
}; };
CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange) CMathBase.prototype.Recalculate_Range_Width = function(PRSC, _CurLine, _CurRange)
{ {
......
...@@ -37,12 +37,103 @@ CMathSize.prototype.Set = function(size) ...@@ -37,12 +37,103 @@ CMathSize.prototype.Set = function(size)
this.ascent = size.ascent; this.ascent = size.ascent;
}; };
function CMathBaseText()
{
this.Type = null;
this.bJDraw = false;
this.value = null;
this.bEmptyGapLeft = false;
this.bEmptyGapRight = false;
this.ParaMath = null;
this.Parent = null;
this.Flags = 0;
this.size = new CMathSize();
this.Width = 0; // special for Run размер буквы без Gaps
// в действительности это поле не должно использоваться, нужно использовать функциии Get_Width, Get_Width_2 ,Get_WidthVisible
this.pos = new CMathPosition();
this.GapLeft = 0;
this.GapRight = 0;
}
CMathBaseText.prototype.Get_Width = function() // работаем через функцию, т.к. поля GapLeft и GapRight могут измениться из-за изменения переноса, а пересчет (Measure) в этом случае не прийдет
{
var Width = this.size.width;
if(this.bEmptyGapLeft == false)
Width += this.GapLeft;
if(this.bEmptyGapRight == false)
Width += this.GapRight;
return (Width*TEXTWIDTH_DIVIDER) | 0;
};
CMathBaseText.prototype.Get_Width2 = function() // работаем через функцию, т.к. поля GapLeft и GapRight могут измениться из-за изменения переноса, а пересчет (Measure) в этом случае не прийдет
{
return ( (this.size.width + this.GapLeft + this.GapRight)* TEXTWIDTH_DIVIDER ) | 0;
};
CMathBaseText.prototype.Get_WidthVisible = function()
{
var Width = this.size.width;
if(this.bEmptyGapLeft == false)
Width += this.GapLeft;
if(this.bEmptyGapRight == false)
Width += this.GapRight;
return Width;
};
CMathBaseText.prototype.Update_StateGapLeft = function(bState)
{
this.bEmptyGapLeft = bState;
};
CMathBaseText.prototype.Update_StateGapRight = function(bState)
{
this.bEmptyGapRight = bState;
};
CMathBaseText.prototype.GetLocationOfLetter = function()
{
var pos = new CMathPosition();
pos.x = this.pos.x;
pos.y = this.pos.y;
return pos;
};
CMathBaseText.prototype.IsPlaceholder = function()
{
return this.Type == para_Math_Placeholder;
};
CMathBaseText.prototype.IsJustDraw = function()
{
return false;
};
// For ParaRun
CMathBaseText.prototype.Is_Punctuation = function()
{
var bPunc = 1 === g_aPunctuation[this.value],
bMathSign = this.value == 0x2217 || this.value == 0x2212;
return bPunc || bMathSign;
};
CMathBaseText.prototype.Is_NBSP = function()
{
return false;
};
CMathBaseText.prototype.Can_AddNumbering = function()
{
return true;
};
function CMathText(bJDraw) function CMathText(bJDraw)
{ {
// для Para_Run CMathText.superclass.constructor.call(this);
this.Type = para_Math_Text; this.Type = para_Math_Text;
this.bJDraw = (undefined === bJDraw ? false : bJDraw); this.bJDraw = (undefined === bJDraw ? false : bJDraw);
this.value = null;
this.RecalcInfo = this.RecalcInfo =
{ {
...@@ -53,21 +144,8 @@ function CMathText(bJDraw) ...@@ -53,21 +144,8 @@ function CMathText(bJDraw)
bSpecialOperator: false bSpecialOperator: false
}; };
this.bEmptyGapLeft = false;
this.bEmptyGapRight = false;
this.ParaMath = null;
this.Flags = 0;
this.Parent = null;
this.size = new CMathSize();
this.Width = 0; // для Recalculate_Range
this.pos = new CMathPosition();
this.rasterOffsetX = 0; this.rasterOffsetX = 0;
this.rasterOffsetY = 0; this.rasterOffsetY = 0;
this.GapLeft = 0;
this.GapRight = 0;
this.FontSlot = fontslot_ASCII; this.FontSlot = fontslot_ASCII;
...@@ -83,1146 +161,849 @@ function CMathText(bJDraw) ...@@ -83,1146 +161,849 @@ function CMathText(bJDraw)
};*/ };*/
} }
CMathText.prototype = Asc.extendClass(CMathText, CMathBaseText);
CMathText.prototype.add = function(code)
{ {
constructor: CMathText, this.value = code;
add: function(code)
{
this.value = code;
if( this.Is_BreakOperator(code) )
this.Type = para_Math_BreakOperator;
},
addTxt: function(txt)
{
var code = txt.charCodeAt(0);
this.add(code);
},
getCode: function()
{
var code = this.value;
var bNormal = this.bJDraw ? null : this.Parent.IsNormalText(); if( this.private_Is_BreakOperator(code) )
this.Type = para_Math_BreakOperator;
};
CMathText.prototype.addTxt = function(txt)
{
var code = txt.charCodeAt(0);
this.add(code);
};
CMathText.prototype.getCodeChr = function()
{
return this.value;
};
CMathText.prototype.private_getCode = function()
{
var code = this.value;
var bNormal = this.bJDraw ? null : this.Parent.IsNormalText();
if(this.Type === para_Math_Placeholder || this.bJDraw || bNormal) if(this.Type === para_Math_Placeholder || this.bJDraw || bNormal)
return code; return code;
var Compiled_MPrp = this.Parent.GetCompiled_ScrStyles(); var Compiled_MPrp = this.Parent.GetCompiled_ScrStyles();
var bAccent = this.Parent.IsAccent(); var bAccent = this.Parent.IsAccent();
var bCapitale = (code > 0x0040 && code < 0x005B), var bCapitale = (code > 0x0040 && code < 0x005B),
bSmall = (code > 0x0060 && code < 0x007b), bSmall = (code > 0x0060 && code < 0x007b),
bDigit = (code > 0x002F && code < 0x003A); bDigit = (code > 0x002F && code < 0x003A);
var bCapGreek = (code > 0x0390 && code < 0x03AA), var bCapGreek = (code > 0x0390 && code < 0x03AA),
bSmallGreek = (code > 0x03B0 && code < 0x03CA); bSmallGreek = (code > 0x03B0 && code < 0x03CA);
var Scr = Compiled_MPrp.scr, var Scr = Compiled_MPrp.scr,
Sty = Compiled_MPrp.sty; Sty = Compiled_MPrp.sty;
// 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(code == 0x2A) // "*" if(code == 0x2A) // "*"
code = 0x2217; code = 0x2217;
else if(code == 0x2D) // "-" else if(code == 0x2D) // "-"
code = 0x2212; code = 0x2212;
else if(Scr == TXT_ROMAN) else if(Scr == TXT_ROMAN)
{
if(Sty == STY_ITALIC)
{ {
if(Sty == STY_ITALIC) if(code == 0x68) // h
{ code = 0x210E;
if(code == 0x68) // h /*else if((code == 0x69 && bAccent) || code == 0x131) // "i" with dot || "i" dotless plain => "i" dotless italic
code = 0x210E; code = 0x1D6A4;
/*else if((code == 0x69 && bAccent) || code == 0x131) // "i" with dot || "i" dotless plain => "i" dotless italic else if((code == 0x6A && bAccent) ||code == 0x237) // "j" with dot || "j" dotless plain => "j" dotless italic
code = 0x1D6A4; code = 0x1D6A5;*/
else if((code == 0x6A && bAccent) ||code == 0x237) // "j" with dot || "j" dotless plain => "j" dotless italic else if(code == 0x69 && bAccent)
code = 0x1D6A5;*/ code = 2835;
else if(code == 0x69 && bAccent) else if(code == 0x6A && bAccent)
code = 2835; code = 2836;
else if(code == 0x6A && bAccent) else if(bCapitale)
code = 2836; code = code + 0x1D3F3;
else if(bCapitale) else if(bSmall)
code = code + 0x1D3F3; code = code + 0x1D3ED;
else if(bSmall) else if(code == 0x3F4) // Capital THETA special
code = code + 0x1D3ED; code = 0x1D6F3;
else if(code == 0x3F4) // Capital THETA special else if(code == 0x2207) // Capital NABLA
code = 0x1D6F3; code = 0x1D6FB;
else if(code == 0x2207) // Capital NABLA else if(bCapGreek)
code = 0x1D6FB; code = code + 0x1D351;
else if(bCapGreek) else if(bSmallGreek)
code = code + 0x1D351; code = code + 0x1D34B;
else if(bSmallGreek) else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = code + 0x1D34B; code = 0x1D715;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL else if(code == 0x3F5) // small EPSILON
code = 0x1D715; code = 0x1D716;
else if(code == 0x3F5) // small EPSILON else if(code == 0x3D1) // small THETA
code = 0x1D716; code = 0x1D717;
else if(code == 0x3D1) // small THETA else if(code == 0x3F0) // small KAPPA
code = 0x1D717; code = 0x1D718;
else if(code == 0x3F0) // small KAPPA else if(code == 0x3D5) // small PHI
code = 0x1D718; code = 0x1D719;
else if(code == 0x3D5) // small PHI else if(code == 0x3F1) // small RHO
code = 0x1D719; code = 0x1D71A;
else if(code == 0x3F1) // small RHO else if(code == 0x3D6) // small PI
code = 0x1D71A; code = 0x1D71B;
else if(code == 0x3D6) // small PI
code = 0x1D71B;
}
else if(Sty == STY_BI)
{
if(code == 0x69 && bAccent)
code = 2841;
else if(code == 0x6A && bAccent)
code = 2842;
else if(bCapitale)
code = code + 0x1D427;
else if(bSmall)
code = code + 0x1D421;
else if(bDigit)
code = code + 0x1D79E;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D72D;
else if(code == 0x2207) // Capital NABLA
code = 0x1D735;
else if(bCapGreek)
code = code + 0x1D38B;
else if(bSmallGreek)
code = code + 0x1D385;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D74F;
else if(code == 0x3F5) // small EPSILON
code = 0x1D750;
else if(code == 0x3D1) // small THETA
code = 0x1D751;
else if(code == 0x3F0) // small KAPPA
code = 0x1D752;
else if(code == 0x3D5) // small PHI
code = 0x1D753;
else if(code == 0x3F1) // small RHO
code = 0x1D754;
else if(code == 0x3D6) // small PI
code = 0x1D755;
}
else if(Sty == STY_BOLD)
{
if(code == 0x69 && bAccent)
code = 2829;
else if(code == 0x6A && bAccent)
code = 2830;
else if(bCapitale)
code = code + 0x1D3BF;
else if(bSmall)
code = code + 0x1D3B9;
else if(bDigit)
code = code + 0x1D79E;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D6B9;
else if(code == 0x2207) // Capital NABLA
code = 0x1D6C1;
else if(bCapGreek)
code = code + 0x1D317;
else if(bSmallGreek)
code = code + 0x1D311;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D6DB;
else if(code == 0x3F5) // small EPSILON
code = 0x1D6DC;
else if(code == 0x3D1) // small THETA
code = 0x1D6DD;
else if(code == 0x3F0) // small KAPPA
code = 0x1D6DE;
else if(code == 0x3D5) // small PHI
code = 0x1D6DF;
else if(code == 0x3F1) // small RHO
code = 0x1D6E0;
else if(code == 0x3D6) // small PI
code = 0x1D6E1;
else if(code == 0x3DC) // CAPITAL DIGAMMA
code = 0x1D7CA;
else if(code == 0x3DD) // SMALL DIGAMMA
code = 0x1D7CB;
}
else // PLAIN
{
if(bAccent)
{
/*if(code == 0x69) // "i" with dot => "i" dotless plain
code = 0x131;
else if(code == 0x6A) // "j" with dot => "j" dotless plain
code = 0x237;*/
if(code == 0x69 && bAccent)
code = 199;
else if(code == 0x6A && bAccent)
code = 2828;
}
}
} }
else if(Scr == TXT_DOUBLE_STRUCK) else if(Sty == STY_BI)
{ {
if(code == 0x69 && bAccent) if(code == 0x69 && bAccent)
code = 2851; code = 2841;
else if(code == 0x6A && bAccent) else if(code == 0x6A && bAccent)
code = 2852; code = 2842;
else if(code == 0x43) // C
code = 0x2102;
else if(code == 0x48) // H
code = 0x210D;
else if(code == 0x4E) // N
code = 0x2115;
else if(code == 0x50) // P
code = 0x2119;
else if(code == 0x51) // Q
code = 0x211A;
else if(code == 0x52) // R
code = 0x211D;
else if(code == 0x5A) // Z
code = 0x2124;
else if(bCapitale) else if(bCapitale)
code = code + 0x1D4F7; code = code + 0x1D427;
else if(bSmall) else if(bSmall)
code = code + 0x1D4F1; code = code + 0x1D421;
else if(bDigit) else if(bDigit)
code = code + 0x1D7A8; code = code + 0x1D79E;
else if(code == 0x3F4) // Capital THETA special
// arabic mathematical symbols code = 0x1D72D;
else if(code == 0x2207) // Capital NABLA
else if(code == 0x628) code = 0x1D735;
code = 0x1EEA1; else if(bCapGreek)
else if(code == 0x062C) code = code + 0x1D38B;
code = 0x1EEA2; else if(bSmallGreek)
else if(code == 0x062F) code = code + 0x1D385;
code = 0x1EEA3; else if(code == 0x2202) // PARTIAL DIFFERENTIAL
else if(code == 0x0648) code = 0x1D74F;
code = 0x1EEA5; else if(code == 0x3F5) // small EPSILON
else if(code == 0x0632) code = 0x1D750;
code = 0x1EEA6; else if(code == 0x3D1) // small THETA
else if(code == 0x062D) code = 0x1D751;
code = 0x1EEA7; else if(code == 0x3F0) // small KAPPA
else if(code == 0x0637) code = 0x1D752;
code = 0x1EEA8; else if(code == 0x3D5) // small PHI
else if(code == 0x064A) code = 0x1D753;
code = 0x1EEA9; else if(code == 0x3F1) // small RHO
code = 0x1D754;
else if(code == 0x0644) else if(code == 0x3D6) // small PI
code = 0x1EEAB; code = 0x1D755;
else if(code == 0x0645)
code = 0x1EEAC;
else if(code == 0x0646)
code = 0x1EEAD;
else if(code == 0x0633)
code = 0x1EEAE;
else if(code == 0x0639)
code = 0x1EEAF;
else if(code == 0x0641)
code = 0x1EEB0;
else if(code == 0x0635)
code = 0x1EEB1;
else if(code == 0x0642)
code = 0x1EEB2;
else if(code == 0x0631)
code = 0x1EEB3;
else if(code == 0x0634)
code = 0x1EEB4;
else if(code == 0x062A)
code = 0x1EEB5;
else if(code == 0x062B)
code = 0x1EEB6;
else if(code == 0x062E)
code = 0x1EEB7;
else if(code == 0x0630)
code = 0x1EEB8;
else if(code == 0x0636)
code = 0x1EEB9;
else if(code == 0x0638)
code = 0x1EEBA;
else if(code == 0x063A)
code = 0x1EEBB;
} }
else if(Scr == TXT_MONOSPACE) else if(Sty == STY_BOLD)
{ {
if(code == 0x69 && bAccent) if(code == 0x69 && bAccent)
code = 4547; code = 2829;
else if(code == 0x6A && bAccent) else if(code == 0x6A && bAccent)
code = 4548; code = 2830;
else if(bCapitale) else if(bCapitale)
code = code + 0x1D62F; code = code + 0x1D3BF;
else if(bSmall) else if(bSmall)
code = code + 0x1D629; code = code + 0x1D3B9;
else if(bDigit) else if(bDigit)
code = code + 0x1D7C6; code = code + 0x1D79E;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D6B9;
else if(code == 0x2207) // Capital NABLA
code = 0x1D6C1;
else if(bCapGreek)
code = code + 0x1D317;
else if(bSmallGreek)
code = code + 0x1D311;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D6DB;
else if(code == 0x3F5) // small EPSILON
code = 0x1D6DC;
else if(code == 0x3D1) // small THETA
code = 0x1D6DD;
else if(code == 0x3F0) // small KAPPA
code = 0x1D6DE;
else if(code == 0x3D5) // small PHI
code = 0x1D6DF;
else if(code == 0x3F1) // small RHO
code = 0x1D6E0;
else if(code == 0x3D6) // small PI
code = 0x1D6E1;
else if(code == 0x3DC) // CAPITAL DIGAMMA
code = 0x1D7CA;
else if(code == 0x3DD) // SMALL DIGAMMA
code = 0x1D7CB;
} }
else if(Scr == TXT_FRAKTUR) else // PLAIN
{ {
if(Sty == STY_BOLD ||Sty == STY_BI) if(bAccent)
{ {
if(code == 0x69 && bAccent) /*if(code == 0x69) // "i" with dot => "i" dotless plain
code = 2849; code = 0x131;
else if(code == 0x6A && bAccent) else if(code == 0x6A) // "j" with dot => "j" dotless plain
code = 2850; code = 0x237;*/
else if(bCapitale)
code = code + 0x1D52B;
else if(bSmall)
code = code + 0x1D525;
}
else
{
if(code == 0x69 && bAccent)
code = 2847;
else if(code == 0x6A && bAccent)
code = 2848;
else if(code == 0x43) // C
code = 0x212D;
else if(code == 0x48) // H
code = 0x210C;
else if(code == 0x49) // I
code = 0x2111;
else if(code == 0x52) // R
code = 0x211C;
else if(code == 0x5A) // Z
code = 0x2128;
else if(bCapitale)
code = code + 0x1D4C3;
else if(bSmall)
code = code + 0x1D4BD;
}
}
else if(Scr == TXT_SANS_SERIF)
{
if(Sty == STY_ITALIC)
{
if(code == 0x69 && bAccent)
code = 2857;
else if(code == 0x6A && bAccent)
code = 2858;
else if(bCapitale)
code = code + 0x1D5C7;
else if(bSmall)
code = code + 0x1D5C1;
else if(bDigit)
code = code + 0x1D7B2;
}
else if(Sty == STY_BOLD)
{
if(code == 0x69 && bAccent) if(code == 0x69 && bAccent)
code = 2855; code = 199;
else if(code == 0x6A && bAccent) else if(code == 0x6A && bAccent)
code = 2856; code = 2828;
else if(bCapitale)
code = code + 0x1D593;
else if(bSmall)
code = code + 0x1D58D;
else if(bDigit)
code = code + 0x1D7BC;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D767;
else if(code == 0x2207) // Capital NABLA
code = 0x1D76F;
else if(bCapGreek)
code = code + 0x1D3C5;
else if(bSmallGreek)
code = code + 0x1D3BF;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D789;
else if(code == 0x3F5) // small EPSILON
code = 0x1D78A;
else if(code == 0x3D1) // small THETA
code = 0x1D78B;
else if(code == 0x3F0) // small KAPPA
code = 0x1D78C;
else if(code == 0x3D5) // small PHI
code = 0x1D78D;
else if(code == 0x3F1) // small RHO
code = 0x1D78E;
else if(code == 0x3D6) // small PI
code = 0x1D78F;
}
else if(Sty == STY_BI)
{
if(code == 0x69 && bAccent)
code = 2859;
else if(code == 0x6A && bAccent)
code = 2860;
else if(bCapitale)
code = code + 0x1D5FB;
else if(bSmall)
code = code + 0x1D5F5;
else if(bDigit)
code = code + 0x1D7BC;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D7A1;
else if(code == 0x2207) // Capital NABLA
code = 0x1D7A9;
else if(bCapGreek)
code = code + 0x1D3FF;
else if(bSmallGreek)
code = code + 0x1D3F9;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D7C3;
else if(code == 0x3F5) // small EPSILON
code = 0x1D7C4;
else if(code == 0x3D1) // small THETA
code = 0x11D7C5;
else if(code == 0x3F0) // small KAPPA
code = 0x1D7C6;
else if(code == 0x3D5) // small PHI
code = 0x1D7C7;
else if(code == 0x3F1) // small RHO
code = 0x1D7C8;
else if(code == 0x3D6) // small PI
code = 0x1D7C9;
}
else
{
if(code == 0x69 && bAccent)
code = 2853;
else if(code == 0x6A && bAccent)
code = 2854;
else if(bCapitale)
code = code + 0x1D55F;
else if(bSmall)
code = code + 0x1D559;
else if(bDigit)
code = code + 0x1D7B2;
}
}
else if(Scr == TXT_SCRIPT)
{
if(Sty == STY_ITALIC || Sty == STY_PLAIN)
{
if(code == 0x69 && bAccent)
code = 2843;
else if(code == 0x6A && bAccent)
code = 2844;
else if(code == 0x42) // B
code = 0x212C;
else if(code == 0x45) // E
code = 0x2130;
else if(code == 0x46) // F
code = 0x2131;
else if(code == 0x48) // H
code = 0x210B;
else if(code == 0x49) // I
code = 0x2110;
else if(code == 0x4C) // L
code = 0x2112;
else if(code == 0x4D) // M
code = 0x2133;
else if(code == 0x52) // R
code = 0x211B;
else if(code == 0x65) // e
code = 0x212F;
else if(code == 0x67) // g
code = 0x210A;
else if(code == 0x6F) // o
code = 0x2134;
else if(bCapitale)
code = code + 0x1D45B;
else if(bSmall)
code = code + 0x1D455;
}
else
{
if(code == 0x69 && bAccent)
code = 2845;
else if(code == 0x6A && bAccent)
code = 2846;
else if(bCapitale)
code = code + 0x1D48F;
else if(bSmall)
code = code + 0x1D489;
} }
} }
}
/*if(!bNormal && code == 0x27) else if(Scr == TXT_DOUBLE_STRUCK)
{
// рисовать в Calibri
code = 3; GID
this.RecalcInfo.bApostrophe = true;
}*/
return code;
},
getCodeChr: function()
{ {
return this.value; if(code == 0x69 && bAccent)
}, code = 2851;
fillPlaceholders: function() else if(code == 0x6A && bAccent)
code = 2852;
else if(code == 0x43) // C
code = 0x2102;
else if(code == 0x48) // H
code = 0x210D;
else if(code == 0x4E) // N
code = 0x2115;
else if(code == 0x50) // P
code = 0x2119;
else if(code == 0x51) // Q
code = 0x211A;
else if(code == 0x52) // R
code = 0x211D;
else if(code == 0x5A) // Z
code = 0x2124;
else if(bCapitale)
code = code + 0x1D4F7;
else if(bSmall)
code = code + 0x1D4F1;
else if(bDigit)
code = code + 0x1D7A8;
// arabic mathematical symbols
else if(code == 0x628)
code = 0x1EEA1;
else if(code == 0x062C)
code = 0x1EEA2;
else if(code == 0x062F)
code = 0x1EEA3;
else if(code == 0x0648)
code = 0x1EEA5;
else if(code == 0x0632)
code = 0x1EEA6;
else if(code == 0x062D)
code = 0x1EEA7;
else if(code == 0x0637)
code = 0x1EEA8;
else if(code == 0x064A)
code = 0x1EEA9;
else if(code == 0x0644)
code = 0x1EEAB;
else if(code == 0x0645)
code = 0x1EEAC;
else if(code == 0x0646)
code = 0x1EEAD;
else if(code == 0x0633)
code = 0x1EEAE;
else if(code == 0x0639)
code = 0x1EEAF;
else if(code == 0x0641)
code = 0x1EEB0;
else if(code == 0x0635)
code = 0x1EEB1;
else if(code == 0x0642)
code = 0x1EEB2;
else if(code == 0x0631)
code = 0x1EEB3;
else if(code == 0x0634)
code = 0x1EEB4;
else if(code == 0x062A)
code = 0x1EEB5;
else if(code == 0x062B)
code = 0x1EEB6;
else if(code == 0x062E)
code = 0x1EEB7;
else if(code == 0x0630)
code = 0x1EEB8;
else if(code == 0x0636)
code = 0x1EEB9;
else if(code == 0x0638)
code = 0x1EEBA;
else if(code == 0x063A)
code = 0x1EEBB;
}
else if(Scr == TXT_MONOSPACE)
{ {
this.Type = para_Math_Placeholder; if(code == 0x69 && bAccent)
this.value = StartTextElement; code = 4547;
}, else if(code == 0x6A && bAccent)
Measure: function(oMeasure, TextPr, InfoMathText) code = 4548;
else if(bCapitale)
code = code + 0x1D62F;
else if(bSmall)
code = code + 0x1D629;
else if(bDigit)
code = code + 0x1D7C6;
}
else if(Scr == TXT_FRAKTUR)
{ {
/* if(Sty == STY_BOLD ||Sty == STY_BI)
var metricsTxt = g_oTextMeasurer.Measure2Code(letter);
var _width = metricsTxt.Width;
height = g_oTextMeasurer.GetHeight();
*/
var metricsTxt;
// measure
if(this.bJDraw)
{ {
// Font выставляется на соответствующей функции SetFont в родительском классе (в общем случае в CMathBase) if(code == 0x69 && bAccent)
code = 2849;
this.RecalcInfo.StyleCode = this.value; else if(code == 0x6A && bAccent)
metricsTxt = oMeasure.Measure2Code(this.value); code = 2850;
} else if(bCapitale)
code = code + 0x1D52B;
else if(bSmall)
code = code + 0x1D525;
}
else else
{ {
var ascent, width, height, descent; if(code == 0x69 && bAccent)
code = 2847;
this.FontSlot = InfoMathText.GetFontSlot(this.value); // возвращает fontslot_ASCII || fontslot_EastAsia || fontslot_CS || fontslot_HAnsi else if(code == 0x6A && bAccent)
code = 2848;
var letter = this.getCode(); else if(code == 0x43) // C
code = 0x212D;
// в не математическом тексте i и j не подменяются на i и j без точек else if(code == 0x48) // H
var bAccentIJ = !InfoMathText.bNormalText && this.Parent.IsAccent() && (this.value == 0x69 || this.value == 0x6A); code = 0x210C;
else if(code == 0x49) // I
this.RecalcInfo.StyleCode = letter; code = 0x2111;
this.RecalcInfo.bAccentIJ = bAccentIJ; else if(code == 0x52) // R
code = 0x211C;
if(bAccentIJ || this.RecalcInfo.bApostrophe) else if(code == 0x5A) // Z
oMeasure.SetStringGid(true); code = 0x2128;
else if(bCapitale)
if( InfoMathText.NeedUpdateFont(this.value, this.FontSlot, this.IsPlaceholder()) ) code = code + 0x1D4C3;
{ else if(bSmall)
g_oTextMeasurer.SetFont(InfoMathText.Font); code = code + 0x1D4BD;
//g_oTextMeasurer.SetTextPr(InfoTextPr.CurrentTextPr, InfoTextPr.Theme);
}
else if(InfoMathText.CurrType == MathTextInfo_NormalText)
{
var FontKoef = InfoMathText.GetFontKoef(this.FontSlot);
g_oTextMeasurer.SetFontSlot(this.FontSlot, FontKoef);
}
metricsTxt = oMeasure.MeasureCode(letter);
if(bAccentIJ || this.RecalcInfo.bApostrophe)
oMeasure.SetStringGid(false);
} }
if(letter == 0x2061) }
else if(Scr == TXT_SANS_SERIF)
{
if(Sty == STY_ITALIC)
{ {
width = 0; if(code == 0x69 && bAccent)
height = 0; code = 2857;
ascent = 0; else if(code == 0x6A && bAccent)
code = 2858;
this.RecalcInfo.bSpaceSpecial = true; else if(bCapitale)
code = code + 0x1D5C7;
else if(bSmall)
code = code + 0x1D5C1;
else if(bDigit)
code = code + 0x1D7B2;
}
else if(Sty == STY_BOLD)
{
if(code == 0x69 && bAccent)
code = 2855;
else if(code == 0x6A && bAccent)
code = 2856;
else if(bCapitale)
code = code + 0x1D593;
else if(bSmall)
code = code + 0x1D58D;
else if(bDigit)
code = code + 0x1D7BC;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D767;
else if(code == 0x2207) // Capital NABLA
code = 0x1D76F;
else if(bCapGreek)
code = code + 0x1D3C5;
else if(bSmallGreek)
code = code + 0x1D3BF;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D789;
else if(code == 0x3F5) // small EPSILON
code = 0x1D78A;
else if(code == 0x3D1) // small THETA
code = 0x1D78B;
else if(code == 0x3F0) // small KAPPA
code = 0x1D78C;
else if(code == 0x3D5) // small PHI
code = 0x1D78D;
else if(code == 0x3F1) // small RHO
code = 0x1D78E;
else if(code == 0x3D6) // small PI
code = 0x1D78F;
}
else if(Sty == STY_BI)
{
if(code == 0x69 && bAccent)
code = 2859;
else if(code == 0x6A && bAccent)
code = 2860;
else if(bCapitale)
code = code + 0x1D5FB;
else if(bSmall)
code = code + 0x1D5F5;
else if(bDigit)
code = code + 0x1D7BC;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D7A1;
else if(code == 0x2207) // Capital NABLA
code = 0x1D7A9;
else if(bCapGreek)
code = code + 0x1D3FF;
else if(bSmallGreek)
code = code + 0x1D3F9;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D7C3;
else if(code == 0x3F5) // small EPSILON
code = 0x1D7C4;
else if(code == 0x3D1) // small THETA
code = 0x11D7C5;
else if(code == 0x3F0) // small KAPPA
code = 0x1D7C6;
else if(code == 0x3D5) // small PHI
code = 0x1D7C7;
else if(code == 0x3F1) // small RHO
code = 0x1D7C8;
else if(code == 0x3D6) // small PI
code = 0x1D7C9;
} }
else else
{ {
// смещения if(code == 0x69 && bAccent)
this.rasterOffsetX = metricsTxt.rasterOffsetX; code = 2853;
this.rasterOffsetY = metricsTxt.rasterOffsetY; else if(code == 0x6A && bAccent)
code = 2854;
ascent = metricsTxt.Ascent; else if(bCapitale)
descent = (metricsTxt.Height - metricsTxt.Ascent); code = code + 0x1D55F;
height = ascent + descent; else if(bSmall)
code = code + 0x1D559;
else if(bDigit)
if(this.bJDraw) code = code + 0x1D7B2;
width = metricsTxt.WidthG;
else
width = metricsTxt.Width;
} }
this.size.width = width; }
this.size.height = height; else if(Scr == TXT_SCRIPT)
this.size.ascent = ascent;
this.Width = (this.size.width * TEXTWIDTH_DIVIDER) | 0;
},
PreRecalc: function(Parent, ParaMath, ArgSize, RPI)
{ {
this.ParaMath = ParaMath; if(Sty == STY_ITALIC || Sty == STY_PLAIN)
if(!this.bJDraw) {
this.Parent = Parent; if(code == 0x69 && bAccent)
code = 2843;
else if(code == 0x6A && bAccent)
code = 2844;
else if(code == 0x42) // B
code = 0x212C;
else if(code == 0x45) // E
code = 0x2130;
else if(code == 0x46) // F
code = 0x2131;
else if(code == 0x48) // H
code = 0x210B;
else if(code == 0x49) // I
code = 0x2110;
else if(code == 0x4C) // L
code = 0x2112;
else if(code == 0x4D) // M
code = 0x2133;
else if(code == 0x52) // R
code = 0x211B;
else if(code == 0x65) // e
code = 0x212F;
else if(code == 0x67) // g
code = 0x210A;
else if(code == 0x6F) // o
code = 0x2134;
else if(bCapitale)
code = code + 0x1D45B;
else if(bSmall)
code = code + 0x1D455;
}
else else
this.Parent = null; {
}, if(code == 0x69 && bAccent)
Get_Width: function() // работаем через функцию, т.к. поля GapLeft и GapRight могут измениться из-за изменения переноса, а пересчет (Measure) в этом случае не прийдет code = 2845;
{ else if(code == 0x6A && bAccent)
var Width = this.size.width; code = 2846;
else if(bCapitale)
if(this.bEmptyGapLeft == false) code = code + 0x1D48F;
Width += this.GapLeft; else if(bSmall)
code = code + 0x1D489;
if(this.bEmptyGapRight == false) }
Width += this.GapRight; }
return (Width*TEXTWIDTH_DIVIDER) | 0; /*if(!bNormal && code == 0x27)
},
Get_Width2: function() // работаем через функцию, т.к. поля GapLeft и GapRight могут измениться из-за изменения переноса, а пересчет (Measure) в этом случае не прийдет
{
return ( (this.size.width + this.GapLeft + this.GapRight)* TEXTWIDTH_DIVIDER ) | 0;
},
Get_WidthVisible: function()
{ {
var Width = this.size.width; // рисовать в Calibri
code = 3; GID
this.RecalcInfo.bApostrophe = true;
}*/
if(this.bEmptyGapLeft == false) return code;
Width += this.GapLeft; };
CMathText.prototype.fillPlaceholders = function()
{
this.Type = para_Math_Placeholder;
this.value = StartTextElement;
};
CMathText.prototype.Measure = function(oMeasure, TextPr, InfoMathText)
{
/*
var metricsTxt = g_oTextMeasurer.Measure2Code(letter);
var _width = metricsTxt.Width;
height = g_oTextMeasurer.GetHeight();
*/
if(this.bEmptyGapRight == false) var metricsTxt;
Width += this.GapRight;
return Width; // measure
}, if(this.bJDraw)
Update_StateGapLeft: function(bState)
{
this.bEmptyGapLeft = bState;
},
Update_StateGapRight: function(bState)
{ {
this.bEmptyGapRight = bState; // Font выставляется на соответствующей функции SetFont в родительском классе (в общем случае в CMathBase)
},
Draw_Elements: function(PDSE)
{
var PosLine = this.ParaMath.GetLinePosition(PDSE.Line);
this.Draw(PosLine.x, PosLine.y, PDSE.Graphics);
},
Draw: function(x, y, pGraphics, InfoTextPr)
{
var X = this.pos.x + x,
Y = this.pos.y + y;
if(this.bEmptyGapLeft == false)
X += this.GapLeft;
/*var tx = 0;
var ty = 0;
var x = (X*sy - Y*shx - tx*sy)/(sx*sy- shy*shx);
var y = (Y - x*shy - ty*shx)/sy;*/
/*var invert = new CMatrix(); this.RecalcInfo.StyleCode = this.value;
invert.sx = this.transform.sx; metricsTxt = oMeasure.Measure2Code(this.value);
invert.sy = this.transform.sy; }
invert.shx = this.transform.shx; else
invert.shy = this.transform.shy; {
invert.tx = 0; var ascent, width, height, descent;
invert.ty = 0;
invert.Invert();
var xx = invert.TransformPointX(X, Y); this.FontSlot = InfoMathText.GetFontSlot(this.value); // возвращает fontslot_ASCII || fontslot_EastAsia || fontslot_CS || fontslot_HAnsi
var yy = invert.TransformPointY(X, Y);
var letter = this.private_getCode();
var sx = this.transform.sx, shx = this.transform.shx, // в не математическом тексте i и j не подменяются на i и j без точек
shy = this.transform.shy, sy = this.transform.sy; var bAccentIJ = !InfoMathText.bNormalText && this.Parent.IsAccent() && (this.value == 0x69 || this.value == 0x6A);
pGraphics.transform(sx, shy, shx, sy, 0, 0);*/ this.RecalcInfo.StyleCode = letter;
this.RecalcInfo.bAccentIJ = bAccentIJ;
if(bAccentIJ || this.RecalcInfo.bApostrophe)
oMeasure.SetStringGid(true);
if(this.bJDraw) if( InfoMathText.NeedUpdateFont(this.value, this.FontSlot, this.IsPlaceholder()) )
{ {
pGraphics.FillTextCode(X, Y, this.RecalcInfo.StyleCode); //на отрисовку символа отправляем положение baseLine g_oTextMeasurer.SetFont(InfoMathText.Font);
//g_oTextMeasurer.SetTextPr(InfoTextPr.CurrentTextPr, InfoTextPr.Theme);
} }
else if(this.RecalcInfo.bSpaceSpecial == false) else if(InfoMathText.CurrType == MathTextInfo_NormalText)
{ {
if( InfoTextPr.NeedUpdateFont(this.value, this.FontSlot, this.IsPlaceholder()) ) var FontKoef = InfoMathText.GetFontKoef(this.FontSlot);
{
pGraphics.SetFont(InfoTextPr.Font);
//pGraphics.SetTextPr(InfoTextPr.CurrentTextPr, InfoTextPr.Theme);
}
else if(InfoTextPr.CurrType == MathTextInfo_NormalText)
{
var FontKoef = InfoTextPr.GetFontKoef(this.FontSlot);
pGraphics.SetFontSlot(this.FontSlot, FontKoef);
}
if(this.RecalcInfo.bAccentIJ || this.RecalcInfo.bApostrophe)
pGraphics.tg(this.RecalcInfo.StyleCode, X, Y);
else
pGraphics.FillTextCode(X, Y, this.RecalcInfo.StyleCode); //на отрисовку символа отправляем положение baseLine
g_oTextMeasurer.SetFontSlot(this.FontSlot, FontKoef);
} }
},
setPosition: function(pos)
{
if (!this.bJDraw) // for text metricsTxt = oMeasure.MeasureCode(letter);
{
this.pos.x = pos.x;
this.pos.y = pos.y;
}
else // for symbol only drawing
{
this.pos.x = pos.x - this.rasterOffsetX;
this.pos.y = pos.y - this.rasterOffsetY + this.size.ascent;
}
if(bAccentIJ || this.RecalcInfo.bApostrophe)
oMeasure.SetStringGid(false);
}
}, if(letter == 0x2061)
GetLocationOfLetter: function()
{ {
var pos = new CMathPosition(); width = 0;
height = 0;
ascent = 0;
pos.x = this.pos.x; this.RecalcInfo.bSpaceSpecial = true;
pos.y = this.pos.y; }
else
return pos;
},
Is_InclineLetter: function()
{ {
var code = this.value; // смещения
this.rasterOffsetX = metricsTxt.rasterOffsetX;
this.rasterOffsetY = metricsTxt.rasterOffsetY;
var bCapitale = (code > 0x0040 && code < 0x005B), ascent = metricsTxt.Ascent;
bSmall = (code > 0x0060 && code < 0x007b) || code == 0x131 || code == 0x237; descent = (metricsTxt.Height - metricsTxt.Ascent);
height = ascent + descent;
var bCapGreek = (code > 0x0390 && code < 0x03AA),
bSmallGreek = (code > 0x03B0 && code < 0x03CA);
var bAlphabet = bCapitale || bSmall || bCapGreek || bSmallGreek; if(this.bJDraw)
width = metricsTxt.WidthG;
var MPrp = this.Parent.GetCompiled_ScrStyles(); else
width = metricsTxt.Width;
var bRomanSerif = (MPrp.sty == STY_BI || MPrp.sty == STY_ITALIC) && (MPrp.scr == TXT_ROMAN || MPrp.scr == TXT_SANS_SERIF), }
bScript = MPrp.scr == TXT_SCRIPT;
return bAlphabet && (bRomanSerif || bScript); this.size.width = width;
}, this.size.height = height;
setCoeffTransform: function(sx, shx, shy, sy) this.size.ascent = ascent;
{
this.transform = {sx: sx, shx: shx, shy: shy, sy: sy};
//здесь надо будет по-другому считать размер, после трансформации размер будет выставляться в g_oTextMeasurer this.Width = (this.size.width * TEXTWIDTH_DIVIDER) | 0;
//
//MathControl.pGraph.transform(sx, shy, shx, sy, 0, 0);
this.applyTransformation();
},
applyTransformation: function()
{
var sx = this.transform.sx, shx = this.transform.shx,
shy = this.transform.shy, sy = this.transform.sy;
sy = (sy < 0) ? -sy : sy;
this.size.width = this.size.width*sx + (-1)*this.size.width*shx;
this.size.height = this.size.height*sy + this.size.height*shy;
this.size.ascent = this.size.ascent*(sy + shy);
this.size.descent = this.size.descent*(sy + shy);
this.size.center = this.size.center*(sy + shy);
},
IsJustDraw: function()
{
return this.bJDraw;
},
relate: function(parent) // for symbol only drawing
{
this.Parent = parent;
},
IsPlaceholder: function()
{
return this.Type == para_Math_Placeholder;
},
IsAlignPoint: function()
{
return false;
},
IsText: function()
{
return true;
},
Is_BreakOperator: function(val)
{
var bSimpleOper = val == 0x2D || val == 0x2B || val == 0x3D || val == 0x2A || val == 0x2F || val == 0x5C || val == 0x3C || val == 0x3E || val == 0xB1 || val == 0x2213 || val == 0x2219,
bArrows = (val >= 0x2190 && val <= 0x21B3) || val == 0x21B6 || val == 0x21B7 || (val >= 0x21BA && val <= 0x21E9) || (val >= 0x21F4 && val <= 0x21FF),
bOtherSymbols = (val >= 0x2234 && val <= 0x2237) || val == 0x2239 || (val >= 0x223B && val <= 0x228B) || (val >= 0x228F && val <= 0x2292) || (val >= 0x22A2 && val <= 0x22B9),
bFishes = (val >= 0x22C8 && val <= 0x22CD) || val == 0x22D0 ||val == 0x22D1 || (val >= 0x22D5 && val <= 0x22EE) || (val >= 0x22F0 && val <= 0x22FF) || (val >= 0x27F0 && val <= 0x297F ) || ( val >= 0x29CE && val <= 0x29D5);
return bSimpleOper || bArrows || bOtherSymbols || bFishes;
},
Is_CompareOperator: function()
{
return this.value == 0x3C || this.value == 0x3D || this.value == 0x3E;
},
// For ParaRun
Is_Punctuation: function()
{
var bPunc = 1 === g_aPunctuation[this.value],
bMathSign = this.value == 0x2217 || this.value == 0x2212;
return bPunc || bMathSign;
},
Is_NBSP: function()
{
return false;
},
Is_SpecilalOperator: function()
{
var val = this.value,
bSpecialOperator = val == 0x21 || val == 0x23 || (val >= 0x28 && val <= 0x2F) || (val >= 0x3A && val <= 0x3F) || (val >=0x5B && val <= 0x5F) || (val >= 0x7B && val <= 0xA1) || val == 0xAC || val == 0xB1 || val == 0xB7 || val == 0xBF || val == 0xD7 || val == 0xF7 || (val >= 0x2010 && val <= 0x2014) || val == 0x2016 || (val >= 0x2020 && val <= 0x2022) || val == 0x2026,
bSpecialArrow = val >= 0x2190 && val <= 0x21FF,
bSpecialSymbols = val == 0x2200 || val == 0x2201 || val == 0x2203 || val == 0x2204 || val == 0x2206|| (val >= 0x2208 && val <= 0x220D) || (val >= 0x220F && val <= 0x221E) || (val >= 0x2223 && val <= 0x223E) || (val >= 0x223F && val <= 0x22BD) || (val >= 0x22C0 && val <= 0x22FF) || val == 0x2305 || val == 0x2306 || (val >= 0x2308 && val <= 0x230B) || (val >= 0x231C && val <= 0x231F) || val == 0x2322 || val == 0x2323 || val == 0x2329 || val == 0x232A ||val == 0x233F || val == 0x23B0 || val == 0x23B1,
bOtherArrows = (val >= 0x27D1 && val <= 0x2980) || (val >= 0x2982 && val <= 0x299A) || (val >= 0x29B6 && val <= 0x29B9) || val == 0x29C0 || val == 0x29C1 || (val >= 0x29C4 && val <= 0x29C8) || (val >= 0x29CE && val <= 0x29DB) || val == 0x29DF || (val >= 0x29E1 && val <= 0x29E6) || val == 0x29EB || (val >= 0x29F4 && val <= 0x2AFF && val !== 0x2AE1 && val !== 0x2AF1) || (val >= 0x3014 && val <= 0x3017);
// apostrophe
// отдельно Cambria Math 0x27
return bSpecialOperator || bSpecialArrow || bSpecialSymbols || bOtherArrows;
},
Can_AddNumbering: function()
{
return true;
},
////
Copy: function()
{
var NewLetter = new CMathText(this.bJDraw);
NewLetter.Type = this.Type;
NewLetter.value = this.value;
return NewLetter;
},
Write_ToBinary : function(Writer)
{
// Пишем тип дла раза, 1 раз для общей функции чтения, второй раз
// для разделения обычного MathText от PlaceHolder
Writer.WriteLong(this.Type);
// Long : Type
// Long : value
Writer.WriteLong(this.Type);
Writer.WriteLong(this.value) ;
},
Read_FromBinary : function(Reader)
{
this.Type = Reader.GetLong();
this.value = Reader.GetLong();
}
}; };
CMathText.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
function CMathAmp()
{ {
this.bEqArray = false; this.ParaMath = ParaMath;
this.Type = para_Math_Ampersand; if(!this.bJDraw)
this.Parent = Parent;
else
this.Parent = null;
};
CMathText.prototype.Draw = function(x, y, pGraphics, InfoTextPr)
{
var X = this.pos.x + x,
Y = this.pos.y + y;
this.GapLeft = 0; if(this.bEmptyGapLeft == false)
this.GapRight = 0; X += this.GapLeft;
this.pos = new CMathPosition(); /*var tx = 0;
var ty = 0;
this.AmpText = new CMathText(false); var x = (X*sy - Y*shx - tx*sy)/(sx*sy- shy*shx);
this.AmpText.add(0x26); var y = (Y - x*shy - ty*shx)/sy;*/
this.size = null; /*var invert = new CMatrix();
this.Parent = null; invert.sx = this.transform.sx;
invert.sy = this.transform.sy;
invert.shx = this.transform.shx;
invert.shy = this.transform.shy;
invert.tx = 0;
invert.ty = 0;
invert.Invert();
this.Width = 0; var xx = invert.TransformPointX(X, Y);
} var yy = invert.TransformPointY(X, Y);
CMathAmp.prototype =
{
Measure: function(oMeasure, TextPr, InfoMathText)
{
this.bEqArray = InfoMathText.bEqArray;
this.AmpText.Measure(oMeasure, TextPr, InfoMathText);
if(this.bEqArray) var sx = this.transform.sx, shx = this.transform.shx,
{ shy = this.transform.shy, sy = this.transform.sy;
this.size =
{
width: 0,
height: 0,
ascent: 0
};
this.Width = 0; pGraphics.transform(sx, shy, shx, sy, 0, 0);*/
}
else
{
this.size =
{
width: this.AmpText.size.width/* + this.GapLeft + this.GapRight*/,
height: this.AmpText.size.height,
ascent: this.AmpText.size.ascent
};
this.Width = this.AmpText.Width;
}
}, if(this.bJDraw)
PreRecalc: function(Parent, ParaMath, ArgSize, RPI)
{ {
this.Parent = Parent; pGraphics.FillTextCode(X, Y, this.RecalcInfo.StyleCode); //на отрисовку символа отправляем положение baseLine
}
this.AmpText.PreRecalc(Parent, ParaMath, ArgSize, RPI); else if(this.RecalcInfo.bSpaceSpecial == false)
},
getCodeChr: function()
{
var code = null;
if(!this.bEqArray)
code = this.AmpText.getCodeChr();
return code;
},
IsText: function()
{
return !this.bEqArray;
},
// special for Run
Get_WidthVisible: function()
{
return this.size.width + this.GapLeft + this.GapRight;
},
// работаем через функцию, т.к. поля GapLeft и GapRight могут измениться из-за изменения переноса, а пересчет (Measure) в этом случае не прийдет
Get_Width: function()
{
return this.size.width + this.GapLeft + this.GapRight;
},
Get_Width2: function()
{
return ( (this.size.width + this.GapLeft + this.GapRight)* TEXTWIDTH_DIVIDER ) | 0;
},
Update_GapLeft: function(Gap)
{
this.GapLeft = Gap;
},
Update_GapRight: function(Gap)
{
this.GapRight = Gap;
},
relate: function(parent)
{
this.Parent = parent;
},
setPosition: function(pos)
{
this.pos.x = pos.x;
this.pos.y = pos.y;
if(this.bEqArray==false)
this.AmpText.setPosition(pos);
},
Draw: function(x, y, pGraphics, InfoTextPr)
{ {
if(this.bEqArray==false) if( InfoTextPr.NeedUpdateFont(this.value, this.FontSlot, this.IsPlaceholder()) )
this.AmpText.Draw(x + this.GapLeft, y, pGraphics, InfoTextPr);
else if(editor.ShowParaMarks) // показать метки выравнивания, если включена отметка о знаках параграфа
{ {
var X = x + this.pos.x + this.Get_Width(), pGraphics.SetFont(InfoTextPr.Font);
Y = y + this.pos.y, //pGraphics.SetTextPr(InfoTextPr.CurrentTextPr, InfoTextPr.Theme);
Y2 = y + this.pos.y - this.AmpText.size.height; }
else if(InfoTextPr.CurrType == MathTextInfo_NormalText)
pGraphics.drawVerLine(0, X, Y, Y2, 0.1); {
var FontKoef = InfoTextPr.GetFontKoef(this.FontSlot);
pGraphics.SetFontSlot(this.FontSlot, FontKoef);
} }
},
GetLocationOfLetter: function()
{
var pos = new CMathPosition();
pos.x = this.pos.x;
pos.y = this.pos.y;
return pos; if(this.RecalcInfo.bAccentIJ || this.RecalcInfo.bApostrophe)
}, pGraphics.tg(this.RecalcInfo.StyleCode, X, Y);
IsPlaceholder: function() else
{ pGraphics.FillTextCode(X, Y, this.RecalcInfo.StyleCode); //на отрисовку символа отправляем положение baseLine
return false;
},
GetCompiled_ScrStyles: function()
{
return this.Parent.GetCompiled_ScrStyles();
},
IsAccent: function()
{
return this.Parent.IsAccent();
},
IsAlignPoint: function()
{
return this.bEqArray;
},
Copy : function()
{
return new CMathAmp();
},
Can_AddNumbering: function()
{
return false;
},
Write_ToBinary : function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
},
Read_FromBinary : function(Reader)
{
} }
}; };
CMathText.prototype.setPosition = function(pos)
var MathFont_ForMathText = 1;
var MathFont_ForSpecialOperator = 2;
function GetMathModifiedFont(type, TextPr, Class)
{ {
var NewMathTextPr = new CTextPr(); if (!this.bJDraw) // for text
if(type == MathFont_ForMathText)
{ {
// RFonts влияют на отрисовку текста в формулах this.pos.x = pos.x;
this.pos.y = pos.y;
NewMathTextPr.RFonts = TextPr.RFonts;
NewMathTextPr.FontFamily = TextPr.FontFamily;
NewMathTextPr.Bold = TextPr.Bold;
NewMathTextPr.Italic = TextPr.Italic;
NewMathTextPr.FontSize = MathApplyArgSize(TextPr.FontSize, Class.Parent.Compiled_ArgSz.value);
// скопируем эти свойства для SetFontSlot
// для SpecialOperator нужны уже скомпилированные для мат текста текстовые настройки, поэтому важно эи свойства скопировать именно здесь, а не передавать в MathText обычные текст. настройки
NewMathTextPr.CS = TextPr.CS;
NewMathTextPr.bRTL = TextPr.RTL;
NewMathTextPr.Lang = TextPr.Lang;
//if(Class.IsMathematicalText())
if(!Class.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам
{
NewMathTextPr.Italic = false;
NewMathTextPr.Bold = false;
}
} }
else if(type == MathFont_ForSpecialOperator) else // for symbol only drawing
{ {
NewMathTextPr.FontFamily = {Name : "Cambria Math", Index : -1}; this.pos.x = pos.x - this.rasterOffsetX;
NewMathTextPr.RFonts.Set_All("Cambria Math",-1); this.pos.y = pos.y - this.rasterOffsetY + this.size.ascent;
NewMathTextPr.FontSize = TextPr.FontSize;
NewMathTextPr.Bold = TextPr.Bold;
NewMathTextPr.Italic = TextPr.Italic;
//pGraphics.SetFont(FFont);
} }
};
CMathText.prototype.Is_InclineLetter = function()
{
var code = this.value;
return NewMathTextPr; var bCapitale = (code > 0x0040 && code < 0x005B),
} bSmall = (code > 0x0060 && code < 0x007b) || code == 0x131 || code == 0x237;
function CMathInfoTextPr(TextPr, ArgSize, bNormalText, Theme) var bCapGreek = (code > 0x0390 && code < 0x03AA),
{ bSmallGreek = (code > 0x03B0 && code < 0x03CA);
this.BFirstSetTextPr = true;
this.TextPr = new CTextPr();
this.CurrentTextPr = new CTextPr();
this.bNormalText = bNormalText; var bAlphabet = bCapitale || bSmall || bCapGreek || bSmallGreek;
this.bSpecialOperator = false;
this.Theme = Theme; var MPrp = this.Parent.GetCompiled_ScrStyles();
this.RFontsCompare = []; var bRomanSerif = (MPrp.sty == STY_BI || MPrp.sty == STY_ITALIC) && (MPrp.scr == TXT_ROMAN || MPrp.scr == TXT_SANS_SERIF),
bScript = MPrp.scr == TXT_SCRIPT;
this.SetTextPr(TextPr, ArgSize); return bAlphabet && (bRomanSerif || bScript);
};
CMathText.prototype.IsJustDraw = function()
{
return this.bJDraw;
};
CMathText.prototype.relate = function(Parent)
{
this.Parent = Parent;
};
CMathText.prototype.IsAlignPoint = function()
{
return false;
};
CMathText.prototype.IsText = function()
{
return true;
};
CMathText.prototype.private_Is_BreakOperator = function(val)
{
var bSimpleOper = val == 0x2D || val == 0x2B || val == 0x3D || val == 0x2A || val == 0x2F || val == 0x5C || val == 0x3C || val == 0x3E || val == 0xB1 || val == 0x2213 || val == 0x2219,
bArrows = (val >= 0x2190 && val <= 0x21B3) || val == 0x21B6 || val == 0x21B7 || (val >= 0x21BA && val <= 0x21E9) || (val >= 0x21F4 && val <= 0x21FF),
bOtherSymbols = (val >= 0x2234 && val <= 0x2237) || val == 0x2239 || (val >= 0x223B && val <= 0x228B) || (val >= 0x228F && val <= 0x2292) || (val >= 0x22A2 && val <= 0x22B9),
bFishes = (val >= 0x22C8 && val <= 0x22CD) || val == 0x22D0 ||val == 0x22D1 || (val >= 0x22D5 && val <= 0x22EE) || (val >= 0x22F0 && val <= 0x22FF) || (val >= 0x27F0 && val <= 0x297F ) || ( val >= 0x29CE && val <= 0x29D5);
} return bSimpleOper || bArrows || bOtherSymbols || bFishes;
CMathInfoTextPr.prototype.SetTextPr = function(TextPr, ArgSize) };
CMathText.prototype.Is_CompareOperator = function()
{ {
this.TextPr.RFonts = TextPr.RFonts; return this.value == 0x3C || this.value == 0x3D || this.value == 0x3E;
this.TextPr.FontFamily = TextPr.FontFamily; };
this.TextPr.Bold = TextPr.Bold; CMathText.prototype.Is_SpecilalOperator = function()
this.TextPr.Italic = TextPr.Italic; {
this.TextPr.FontSize = MathApplyArgSize(TextPr.FontSize, ArgSize); var val = this.value,
bSpecialOperator = val == 0x21 || val == 0x23 || (val >= 0x28 && val <= 0x2F) || (val >= 0x3A && val <= 0x3F) || (val >=0x5B && val <= 0x5F) || (val >= 0x7B && val <= 0xA1) || val == 0xAC || val == 0xB1 || val == 0xB7 || val == 0xBF || val == 0xD7 || val == 0xF7 || (val >= 0x2010 && val <= 0x2014) || val == 0x2016 || (val >= 0x2020 && val <= 0x2022) || val == 0x2026,
bSpecialArrow = val >= 0x2190 && val <= 0x21FF,
bSpecialSymbols = val == 0x2200 || val == 0x2201 || val == 0x2203 || val == 0x2204 || val == 0x2206|| (val >= 0x2208 && val <= 0x220D) || (val >= 0x220F && val <= 0x221E) || (val >= 0x2223 && val <= 0x223E) || (val >= 0x223F && val <= 0x22BD) || (val >= 0x22C0 && val <= 0x22FF) || val == 0x2305 || val == 0x2306 || (val >= 0x2308 && val <= 0x230B) || (val >= 0x231C && val <= 0x231F) || val == 0x2322 || val == 0x2323 || val == 0x2329 || val == 0x232A ||val == 0x233F || val == 0x23B0 || val == 0x23B1,
bOtherArrows = (val >= 0x27D1 && val <= 0x2980) || (val >= 0x2982 && val <= 0x299A) || (val >= 0x29B6 && val <= 0x29B9) || val == 0x29C0 || val == 0x29C1 || (val >= 0x29C4 && val <= 0x29C8) || (val >= 0x29CE && val <= 0x29DB) || val == 0x29DF || (val >= 0x29E1 && val <= 0x29E6) || val == 0x29EB || (val >= 0x29F4 && val <= 0x2AFF && val !== 0x2AE1 && val !== 0x2AF1) || (val >= 0x3014 && val <= 0x3017);
// скопируем эти свойства для SetFontSlot // apostrophe
// для SpecialOperator нужны уже скомпилированные для мат текста текстовые настройки, поэтому важно эи свойства скопировать именно здесь, а не передавать в MathText обычные текст. настройки // отдельно Cambria Math 0x27
this.TextPr.CS = TextPr.CS; return bSpecialOperator || bSpecialArrow || bSpecialSymbols || bOtherArrows;
this.TextPr.RTL = TextPr.RTL; };
this.TextPr.Lang = TextPr.Lang; ////
CMathText.prototype.setCoeffTransform = function(sx, shx, shy, sy)
{
this.transform = {sx: sx, shx: shx, shy: shy, sy: sy};
this.RFontsCompare[fontslot_ASCII] = undefined !== this.TextPr.RFonts.Ascii && this.TextPr.RFonts.Ascii.Name == "Cambria Math"; //здесь надо будет по-другому считать размер, после трансформации размер будет выставляться в g_oTextMeasurer
this.RFontsCompare[fontslot_HAnsi] = undefined !== this.TextPr.RFonts.HAnsi && this.TextPr.RFonts.HAnsi.Name == "Cambria Math"; //
this.RFontsCompare[fontslot_CS] = undefined !== this.TextPr.RFonts.CS && this.TextPr.RFonts.CS.Name == "Cambria Math"; //MathControl.pGraph.transform(sx, shy, shx, sy, 0, 0);
this.RFontsCompare[fontslot_EastAsia] = undefined !== this.TextPr.RFonts.EastAsia && this.TextPr.RFonts.EastAsia.Name == "Cambria Math"; this.applyTransformation();
this.CurrentTextPr.Merge(this.TextPr);
}; };
CMathInfoTextPr.prototype.NeedUpdateTextPrp = function(code, fontSlot, IsPlaceholder) CMathText.prototype.applyTransformation = function()
{ {
var NeedUpdate = false; var sx = this.transform.sx, shx = this.transform.shx,
shy = this.transform.shy, sy = this.transform.sy;
sy = (sy < 0) ? -sy : sy;
if(this.BFirstSetTextPr == true) this.size.width = this.size.width*sx + (-1)*this.size.width*shx;
{ this.size.height = this.size.height*sy + this.size.height*shy;
this.BFirstSetTextPr = false; this.size.ascent = this.size.ascent*(sy + shy);
NeedUpdate = true; this.size.descent = this.size.descent*(sy + shy);
} this.size.center = this.size.center*(sy + shy);
// IsMathematicalText || Placeholder ? };
if(this.bNormalText == false || IsPlaceholder) CMathText.prototype.Copy = function()
{ {
var BoldItalicForMath = this.RFontsCompare[fontSlot] == true && (this.CurrentTextPr.Bold !== false || this.CurrentTextPr.Italic !== false), var NewLetter = new CMathText(this.bJDraw);
BoldItalicForOther = this.RFontsCompare[fontSlot] == false && (this.CurrentTextPr.Bold !== this.TextPr.Bold || this.CurrentTextPr.Italic !== this.TextPr.Italic); NewLetter.Type = this.Type;
NewLetter.value = this.value;
var BoldItalicPlh = IsPlaceholder && (this.CurrentTextPr.Bold !== false || this.CurrentTextPr.Italic !== false); return NewLetter;
};
CMathText.prototype.Write_ToBinary = function(Writer)
{
// Пишем тип дла раза, 1 раз для общей функции чтения, второй раз
// для разделения обычного MathText от PlaceHolder
Writer.WriteLong(this.Type);
// Long : Type
// Long : value
Writer.WriteLong(this.Type);
Writer.WriteLong(this.value) ;
};
CMathText.prototype.Read_FromBinary = function(Reader)
{
this.Type = Reader.GetLong();
this.value = Reader.GetLong();
};
if(BoldItalicForMath || BoldItalicPlh) // Cambria Math
{
this.CurrentTextPr.Italic = false;
this.CurrentTextPr.Bold = false;
NeedUpdate = true; function CMathAmp()
} {
else if(BoldItalicForOther) // Not Cambria Math CMathAmp.superclass.constructor.call(this);
{
this.CurrentTextPr.Bold = this.TextPr.Bold;
this.CurrentTextPr.Italic = this.TextPr.Italic;
NeedUpdate = true; this.bEqArray = false;
} this.Type = para_Math_Ampersand;
var checkSpOperator = Math_Is_SpecilalOperator(code), this.value = 0x26;
IsPlh = IsPlaceholder && this.RFontsCompare[fontSlot] == false;
if( checkSpOperator !== this.bSpecialOperator || IsPlh) this.AmpText = new CMathText(false);
{ this.AmpText.add(this.value);
if(checkSpOperator == false) }
{ Asc.extendClass(CMathAmp, CMathBaseText);
this.CurrentTextPr.FontFamily = this.TextPr.FontFamily; CMathAmp.prototype.Measure = function(oMeasure, TextPr, InfoMathText)
this.CurrentTextPr.RFonts.Set_FromObject(this.TextPr.RFonts); {
this.bEqArray = InfoMathText.bEqArray;
this.AmpText.Measure(oMeasure, TextPr, InfoMathText);
this.bSpecialOperator = false; if(this.bEqArray)
{
this.size.width = 0;
this.size.ascent = 0;
this.size.height = 0;
}
else
{
this.size.width = this.AmpText.size.width;
this.size.height = this.AmpText.size.height;
this.size.ascent = this.AmpText.size.ascent;
}
NeedUpdate = true; this.Width = (this.size.width * TEXTWIDTH_DIVIDER) | 0;
} };
else if(this.RFontsCompare[fontSlot] == false) CMathAmp.prototype.PreRecalc = function(Parent, ParaMath, ArgSize, RPI)
{ {
this.CurrentTextPr.FontFamily = {Name : "Cambria Math", Index : -1}; this.Parent = Parent;
this.CurrentTextPr.RFonts.Set_All("Cambria Math",-1); this.AmpText.PreRecalc(Parent, ParaMath, ArgSize, RPI);
};
CMathAmp.prototype.getCodeChr = function()
{
var code = null;
if(!this.bEqArray)
code = this.AmpText.getCodeChr();
this.bSpecialOperator = true; return code;
};
CMathAmp.prototype.IsText = function()
{
return !this.bEqArray;
};
CMathAmp.prototype.setPosition = function(pos)
{
this.pos.x = pos.x;
this.pos.y = pos.y;
NeedUpdate = true; if(this.bEqArray == false)
} this.AmpText.setPosition(pos);
} };
CMathAmp.prototype.relate = function(Parent)
{
this.Parent = Parent;
this.AmpText.relate(Parent);
};
CMathAmp.prototype.Draw = function(x, y, pGraphics, InfoTextPr)
{
if(this.bEqArray==false)
this.AmpText.Draw(x + this.GapLeft, y, pGraphics, InfoTextPr);
else if(editor.ShowParaMarks) // показать метки выравнивания, если включена отметка о знаках параграфа
{
var X = x + this.pos.x + this.Get_Width(),
Y = y + this.pos.y,
Y2 = y + this.pos.y - this.AmpText.size.height;
pGraphics.drawVerLine(0, X, Y, Y2, 0.1);
} }
return NeedUpdate;
}; };
CMathInfoTextPr.prototype.GetFontSlot = function(code) CMathAmp.prototype.Is_InclineLetter = function()
{
return false;
};
CMathAmp.prototype.IsAlignPoint = function()
{
return this.bEqArray;
};
CMathAmp.prototype.Copy = function()
{
return new CMathAmp();
};
CMathAmp.prototype.Write_ToBinary = function(Writer)
{
// Long : Type
Writer.WriteLong( this.Type );
};
CMathAmp.prototype.Read_FromBinary = function(Reader)
{ {
var Hint = this.TextPr.RFonts.Hint;
var bCS = this.TextPr.CS;
var bRTL = this.TextPr.RTL;
var lcid = this.TextPr.Lang.EastAsia;
return g_font_detector.Get_FontClass(code, Hint, lcid, bCS, bRTL);
}; };
var MathTextInfo_MathText = 1; var MathTextInfo_MathText = 1;
......
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