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

1. Поправила баг : отображались дробные значения размера шрифта для итераторов

2. Поправила баг на Get_StartRangePos и Get_EndRangePos
3. Переделала полностью MathProperties (для текста)
4. Добавила в Run Apply_Style (для применения текстовых настроек к MathPrp)
5. Добавила перевод юникодов символов из Basic Multilingual Plane в юникодные значения из расширенной таблицы 
в зависимости от свойств style и script для шрифта Cambria Math (для остальных шрифтов символы не подменяются),
а именно Roman - Bold, Roman - Bold Italic, расширила DOUBLE STRUCK, FRAKTUR - BOLD, SANS SERIF - BOLD,
SANS SERIF - BOLD ITALIC, SANS SERIF - PLAIN, SCRIPT - BOLD
6. Поправила баг: для Normal Text подхватываем font из w:rPr, иначе всегда Cambria Math

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57166 954022d7-b5bf-4e40-9824-e11837661b57
parent 6b192f6e
......@@ -59,7 +59,6 @@ function ParaMath()
this.DefaultTextPr.RFonts.Set_All("Cambria Math", -1);
this.MathPr =
{
naryLim: NARY_UndOvr,
......@@ -381,7 +380,8 @@ ParaMath.prototype =
{
// TODO: ParaMath.Apply_TextPr
this.Root.Apply_TextPr(TextPr, IncFontSize, ApplyToAll);
var content = this.GetSelectContent().Content;
content.Apply_TextPr(TextPr, IncFontSize, ApplyToAll);
},
......@@ -954,21 +954,22 @@ ParaMath.prototype =
tPrp.Merge(this.DefaultTextPr);
tPrp.Merge(oWPrp);
var FSize = tPrp.FontSize;
//var FSize = tPrp.FontSize;
if(argSize == -1)
{
//FSize = 0.0009*FSize*FSize + 0.68*FSize + 0.26;
FSize = 0.76*FSize;
tPrp.FontSize = 0.76*tPrp.FontSize;
tPrp.FontSizeCS = 0.76*tPrp.FontSizeCS;
}
else if(argSize == -2)
{
//FSize = -0.0004*FSize*FSize + 0.66*FSize + 0.87;
FSize = 0.76*0.855*FSize;
tPrp.FontSize = 0.76*0.855*tPrp.FontSize;
tPrp.FontSizeCS = 0.76*0.855*tPrp.FontSizeCS;
}
tPrp.FontSize = FSize;
//tPrp.FontSize = FSize;
oWPrp.Merge(tPrp);
......@@ -1254,57 +1255,61 @@ ParaMath.prototype =
// Проверяем, попали ли мы в формулу
var Dx = this.Root.size.width;
var D = SearchPos.X - SearchPos.CurX;
if ( EndPos >= 1 )
{
var Dx = this.Root.size.width;
var D = SearchPos.X - SearchPos.CurX;
var startDx = Math.abs(D),
endDx = Math.abs(D - Dx);
var startDx = Math.abs(D),
endDx = Math.abs(D - Dx);
var Diff = startDx < endDx ? startDx : endDx;
var Diff = startDx < endDx ? startDx : endDx;
var CurX = SearchPos.CurX;
var CurX = SearchPos.CurX;
if(Math.abs(Diff) < SearchPos.DiffX + 0.001)
{
if ( D >= - 0.001 && D <= Dx + 0.001 )
if(Math.abs(Diff) < SearchPos.DiffX + 0.001)
{
var X = SearchPos.X,
Y = SearchPos.Y;
if ( D >= - 0.001 && D <= Dx + 0.001 )
{
var X = SearchPos.X,
Y = SearchPos.Y;
SearchPos.X -= this.X;
SearchPos.Y -= this.Y;
SearchPos.X -= this.X;
SearchPos.Y -= this.Y;
this.Root.Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
this.Root.Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
SearchPos.X = X;
SearchPos.Y = Y;
SearchPos.X = X;
SearchPos.Y = Y;
//////////
//////////
SearchPos.InText = true;
SearchPos.DiffX = 0.001; // сравниваем расстояние до ближайшего элемента
SearchPos.InText = true;
SearchPos.DiffX = 0.001; // сравниваем расстояние до ближайшего элемента
}
else if(startDx < endDx)
{
this.Get_StartPos(SearchPos.Pos, Depth);
SearchPos.DiffX = Diff;
}
else
{
this.Get_EndPos(false, SearchPos.Pos, Depth);
SearchPos.DiffX = Diff - 0.0015;
}
else if(startDx < endDx)
{
this.Get_StartPos(SearchPos.Pos, Depth);
SearchPos.DiffX = Diff;
}
else
{
this.Get_EndPos(false, SearchPos.Pos, Depth);
SearchPos.DiffX = Diff - 0.0015;
}
}
Result = true;
Result = true;
}
SearchPos.CurX = CurX + Dx;
}
SearchPos.CurX = CurX + Dx;
return Result;
},
......@@ -1408,7 +1413,7 @@ ParaMath.prototype =
// Сделать для случая, когда формула будет занимать несколько строк
this.Root.Get_EndPos(false, SearchPos, Depth);
this.Root.Get_EndPos(false, SearchPos.Pos, Depth);
},
......@@ -1418,7 +1423,7 @@ ParaMath.prototype =
// Сделать для случая, когда формула будет занимать несколько строк, переделать
this.Root.Get_StartPos(SearchPos, Depth);
this.Root.Get_StartPos(SearchPos.Pos, Depth);
},
......
......@@ -29,7 +29,7 @@ function ParaRun(Paragraph, bMathRun)
this.YOffset = 0; // смещение по Y
this.NeedAddNumbering = false; // Нужно ли добавлять нумерацию (true - нужно, false - не нужно, первый элемент,
// у которого будет false и будет элемент с нумерацией)
// у которого будет false и будет элемент с нумерацией)
this.Lines = []; // Массив CParaRunLine
this.Lines[0] = new CParaRunLine();
......@@ -97,7 +97,7 @@ ParaRun.prototype =
NewRun.Set_Pr( this.Pr.Copy() );
if(this.Type == para_Math_Run || this.Type == para_Math_Placeholder)
if(this.Type == para_Math_Run)
{
NewRun.MathPrp = this.MathPrp.Copy();
}
......@@ -639,6 +639,8 @@ ParaRun.prototype =
case para_Tab:
case para_End:
case para_NewLine:
case para_Math_Text:
case para_Math_Placeholder:
{
X += Item.WidthVisible;
break;
......@@ -651,11 +653,11 @@ ParaRun.prototype =
X += Item.WidthVisible;
break;
}
case para_Math_Text:
/*case para_Math_Text:
{
X += Item.WidthVisible;
break;
}
}*/
}
}
......@@ -671,7 +673,16 @@ ParaRun.prototype =
if ( true === UpdateTarget )
{
var CurTextPr = this.Get_CompiledPr(false);
var CurTextPr;
if(this.Type == para_Math_Run)
{
CurTextPr = this.Get_CompiledPr(true);
this.Parent.ParaMath.ApplyArgSize(CurTextPr, this.Parent.argSize);
}
else
CurTextPr = this.Get_CompiledPr(false);
g_oTextMeasurer.SetTextPr( CurTextPr, this.Paragraph.Get_Theme() );
g_oTextMeasurer.SetFontSlot( fontslot_ASCII, CurTextPr.Get_FontKoef() );
var Height = g_oTextMeasurer.GetHeight();
......@@ -764,7 +775,18 @@ ParaRun.prototype =
if ( true === ReturnTarget )
{
var CurTextPr = this.Get_CompiledPr(false);
var CurTextPr;
if(this.Type == para_Math_Run)
{
CurTextPr = this.Get_CompiledPr(true);
this.Parent.ParaMath.ApplyArgSize(CurTextPr, this.Parent.argSize);
}
else
CurTextPr = this.Get_CompiledPr(false);
g_oTextMeasurer.SetTextPr( CurTextPr, this.Paragraph.Get_Theme() );
g_oTextMeasurer.SetFontSlot( fontslot_ASCII, CurTextPr.Get_FontKoef() );
......@@ -1157,7 +1179,15 @@ ParaRun.prototype =
// для Math_Para_Pun argSize учитывается, когда мержатся текстовые настройки в Internal_Compile_Pr()
if ( undefined !== this.Paragraph && null !== this.Paragraph )
{
var TextPr = this.Get_CompiledPr(false);
var TextPr;
if(this.Type === para_Math_Run)
{
TextPr = this.Get_CompiledPr(true);
this.Parent.ParaMath.ApplyArgSize(TextPr, this.Parent.argSize);
}
else
TextPr = this.Get_CompiledPr(false);
TextPr.Document_CreateFontMap( Map, this.Paragraph.Get_Theme().themeElements.fontScheme);
var Count = this.Content.length;
for (var Index = 0; Index < Count; Index++)
......@@ -3594,7 +3624,7 @@ ParaRun.prototype =
Result = true;
}
if (this.Type == para_Math_Run || this.Type == para_Math_Placeholder)
if (this.Type == para_Math_Run)
{
var Diff = SearchPos.X - SearchPos.CurX;
if ( Math.abs( Diff ) < SearchPos.DiffX + 0.001 )
......@@ -4364,31 +4394,38 @@ ParaRun.prototype =
if(this.Type == para_Math_Run)
{
// Not Apply ArgSize !
var oWPrp = this.Parent.Get_Default_TPrp();
TextPr.Merge(oWPrp);
TextPr.Merge( this.Pr ); // Мержим прямые настройки данного рана
if(TXT_NORMAL !== this.Math_GetTypeText()) // math text
if(this.IsPlaceholder())
{
var MPrp = this.MathPrp.getTxtPrp();
TextPr.Merge(MPrp); // bold, italic
}
/*oWPrp = this.Parent.Get_Default_TPrp();
TextPr.Merge(oWPrp);*/
TextPr.Merge(this.Parent.GetCtrPrp());
TextPr.Merge( this.Pr ); // Мержим прямые настройки данного рана
this.Parent.ParaMath.ApplyArgSize(TextPr, this.Parent.argSize);
}
else if(this.Type == para_Math_Placeholder)
{
var oWPrp = this.Parent.Get_Default_TPrp();
TextPr.Merge(oWPrp);
TextPr.Merge(this.Parent.GetCtrPrp());
TextPr.Merge( this.Pr ); // Мержим прямые настройки данного рана
// special for placeholder
// special for placeholder
TextPr.Italic = false;
TextPr.Bold = false;
TextPr.Italic = false;
TextPr.Bold = false;
//this.Parent.ParaMath.ApplyArgSize(TextPr, this.Parent.argSize);
}
else
{
/*oWPrp = this.Parent.Get_Default_TPrp();
TextPr.Merge(oWPrp);*/
TextPr.Merge( this.Pr ); // Мержим прямые настройки данного рана
this.Parent.ParaMath.ApplyArgSize(TextPr, this.Parent.argSize);
if(!this.IsNormalText()) // math text
{
var MPrp = this.MathPrp.getTxtPrp();
TextPr.Merge(MPrp); // bold, italic
}
//this.Parent.ParaMath.ApplyArgSize(TextPr, this.Parent.argSize);
}
}
else
{
......@@ -4601,11 +4638,15 @@ ParaRun.prototype =
Split_Run : function(Pos)
{
// Создаем новый ран
var NewRun = new ParaRun(this.Paragraph);
var NewRun = new ParaRun(this.Paragraph, this.Type == para_Math_Run);
// Копируем настройки
NewRun.Set_Pr( this.Pr.Copy() );
if(this.Type == para_Math_Run)
NewRun.Set_MathPrp(this.MathPrp.Copy());
var OldCrPos = this.State.ContentPos;
var OldSSPos = this.State.Selection.StartPos;
var OldSEPos = this.State.Selection.EndPos;
......@@ -4689,19 +4730,21 @@ ParaRun.prototype =
// В данной функции мы применяем приходящие настройки поверх старых, т.е. старые не удаляем
Apply_Pr : function(TextPr)
{
/*if(this.typeObj == MATH_PARA_RUN)
{
this.MathPrp.Apply_Pr(TextPr);
this.Recalc_CompiledPr(true);
return;
}*/
if ( undefined != TextPr.Bold )
this.Set_Bold( null === TextPr.Bold ? undefined : TextPr.Bold );
{
if(this.Type == para_Math_Run && !this.IsNormalText())
this.Apply_StyleBold(null === TextPr.Bold ? undefined : TextPr.Bold);
else
this.Set_Bold( null === TextPr.Bold ? undefined : TextPr.Bold );
}
if ( undefined != TextPr.Italic )
this.Set_Italic( null === TextPr.Italic ? undefined : TextPr.Italic );
{
if(this.Type == para_Math_Run && !this.IsNormalText())
this.Apply_StyleItalic(null === TextPr.Italic ? undefined : TextPr.Italic);
else
this.Set_Italic( null === TextPr.Italic ? undefined : TextPr.Italic );
}
if ( undefined != TextPr.Strikeout )
this.Set_Strikeout( null === TextPr.Strikeout ? undefined : TextPr.Strikeout );
......@@ -7232,9 +7275,22 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
var Y = y + this.size.ascent;
var oWPrp = this.Get_CompiledPr(true);
this.Parent.ParaMath.ApplyArgSize(oWPrp, this.Parent.argSize);
if(TXT_NORMAL !== this.Math_GetTypeText()) // выставляем false, чтобы не применился наклон к спец символам
if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам
{
oWPrp.Italic = false;
oWPrp.Bold = false;
// TO DO
// реализовать получше
// пока так
var defaultTxtPrp = this.Parent.ParaMath.Get_Default_TPrp();
oWPrp.FontFamily = defaultTxtPrp.FontFamily;
oWPrp.RFonts.Set_All(defaultTxtPrp.FontFamily.Name, defaultTxtPrp.FontFamily.Index);
}
pGraphics.SetFont(oWPrp);
pGraphics.b_color1(0,0,0,255);
......@@ -7245,10 +7301,16 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
}
ParaRun.prototype.Math_Recalculate = function(Parent, Paragraph, oMeasure, RecalcInfo)
{
if(this.IsPlaceholder())
this.Type = para_Math_Placeholder;
else
this.Type = para_Math_Run;
// пересчет элементов контента в Run
// Recalculate_MeasureContent
// ParaText (ParagraphContent.js)
// для настройки TextPr
// Measure
// FontClassification.js
// Get_FontClass
var RangeStartPos = 0;
......@@ -7266,9 +7328,19 @@ ParaRun.prototype.Math_Recalculate = function(Parent, Paragraph, oMeasure, Recal
var oWPrp = this.Get_CompiledPr(true);
this.Parent.ParaMath.ApplyArgSize(oWPrp, this.Parent.argSize);
if(TXT_NORMAL !== this.Math_GetTypeText()) // выставляем false, чтобы не применился наклон к спец символам
if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам
{
oWPrp.Italic = false;
oWPrp.Bold = false;
var defaultTxtPrp = this.Parent.ParaMath.Get_Default_TPrp();
oWPrp.FontFamily = defaultTxtPrp.FontFamily;
oWPrp.RFonts.Set_All(defaultTxtPrp.FontFamily.Name, defaultTxtPrp.FontFamily.Index);
}
g_oTextMeasurer.SetFont(oWPrp);
......@@ -7292,8 +7364,9 @@ ParaRun.prototype.Math_Recalculate = function(Parent, Paragraph, oMeasure, Recal
ParaRun.prototype.Math_Update_Cursor = function(X, Y, CurPage, UpdateTarget)
{
// TODO
// поставить заглушку на плейсхолдер, когда при перемещении всегда будет отрисовываться селкт на плейсхолдере
// поставить заглушку на плейсхолдер, когда при перемещении всегда будет отрисовываться селект на плейсхолдере
var runPrp = this.Get_CompiledPr(true);
this.Parent.ParaMath.ApplyArgSize(runPrp, this.Parent.argSize);
var sizeCursor = runPrp.FontSize*g_dKoef_pt_to_mm;
......@@ -7315,11 +7388,66 @@ ParaRun.prototype.Math_Update_Cursor = function(X, Y, CurPage, UpdateTarget)
}
ParaRun.prototype.Set_MathPrp = function(props)
{
//History.Add( this, { Type : historyitem_ParaRun_TextPr, New : TextPr, Old : OldValue } );
this.MathPrp.setMathProps(props);
}
ParaRun.prototype.Math_GetTypeText = function()
ParaRun.prototype.Apply_StyleBold = function(Value)
{
return this.MathPrp.getTypeText();
if(Value == undefined)
Value = false;
if(Value == true)
{
if(this.MathPrp.sty == STY_ITALIC)
this.Apply_Style(STY_BI);
else if(this.MathPrp.sty == STY_PLAIN)
this.Apply_Style(STY_BOLD);
}
else if(Value == false)
{
if(this.MathPrp.sty == STY_BI)
this.Apply_Style(STY_ITALIC);
else if(this.MathPrp.sty == STY_BOLD)
this.Apply_Style(STY_PLAIN);
}
}
ParaRun.prototype.Apply_StyleItalic = function(Value)
{
if(Value == undefined)
Value = true;
if(Value == true)
{
if(this.MathPrp.sty == STY_BOLD)
this.Apply_Style(STY_BI);
else if(this.MathPrp.sty == STY_PLAIN)
this.Apply_Style(STY_ITALIC);
}
else if(Value == false)
{
if(this.MathPrp.sty == STY_BI)
this.Apply_Style(STY_BOLD);
else if(this.MathPrp.sty == STY_ITALIC)
this.Apply_Style(STY_PLAIN);
}
}
ParaRun.prototype.Apply_Style = function(Value)
{
if(Value !== this.MathPrp.sty)
{
var OldValue = this.MathPrp.sty;
this.MathPrp = Value;
History.Add( this, { Type : historyitem_Math_Style, New : Value, Old : OldValue } );
this.Recalc_CompiledPr(true);
}
}
ParaRun.prototype.IsNormalText = function()
{
return this.MathPrp.nor == true;
}
ParaRun.prototype.getPropsForWrite = function()
{
......@@ -7334,9 +7462,13 @@ ParaRun.prototype.Math_SetGaps = function(Parent, Paragraph, RecalcInfo)
this.Paragraph = Paragraph;
var oWPrp = this.Get_CompiledPr(true);
this.Parent.ParaMath.ApplyArgSize(oWPrp, this.Parent.argSize);
if(TXT_NORMAL !== this.Math_GetTypeText()) // выставляем false, чтобы не применился наклон к спец символам
/*if(!this.IsNormalText()) // выставляем false, чтобы не применился наклон к спец символам
{
oWPrp.Italic = false;
oWPrp.Bold = false;
}*/
g_oTextMeasurer.SetFont(oWPrp);
......
......@@ -33,6 +33,7 @@
var historyitem_Math_AddItem = 1; // Добавляем элемент
var historyitem_Math_RemoveItem = 2; // Удаляем элемент
var historyitem_Math_Style = 3; // Меняем стиль MathPr
......@@ -614,6 +615,11 @@ CMathRunPrp.prototype =
function CMPrp()
{
this.sty = STY_ITALIC;
this.scr = TXT_ROMAN;
this.nor = false;
this.aln = false;
this.brk = false;
this.lit = false;
......@@ -627,16 +633,16 @@ function CMPrp()
// буквы берутся обычные, не специальные для Cambria Math : то есть как для TXT_NORMAL
// отличие от TXT_NORMAL w:rPrp в этом случае не учитываются !
this.typeText = TXT_ROMAN;
this.italic = true;
this.bold = false;
//this.typeText = TXT_ROMAN;
//this.italic = true;
//this.bold = false;
//this.nor = false;
//this.plain = false;
}
CMPrp.prototype =
{
Merge: function(mPrp)
/*Merge: function(mPrp)
{
// выравнивание
this.aln = mPrp.aln;
......@@ -658,8 +664,8 @@ CMPrp.prototype =
obj = true;
else if(prp === 0 || prp === false)
obj = false;
},
getProps: function()
},*/
/*getProps: function()
{
var props =
{
......@@ -674,15 +680,36 @@ CMPrp.prototype =
};
return props;
},
},*/
setMathProps: function(props)
{
this.SetBProp(this.aln, props.aln);
this.SetBProp(this.brk, props.brk);
this.SetBProp(this.lit, props.lit);
if(props.aln === true || props.aln == false)
this.aln = props.aln;
if(props.brk === true || props.brk == false)
this.brk = props.brk;
if(props.lit === true || props.lit == false)
this.lit = props.lit;
if(props.nor === true || props.nor == false)
this.nor = props.nor;
if(props.sty !== null && props.sty !== undefined)
this.sty = props.sty;
// TXT_DOUBLE_STRUCK U+1D538 - U+1D56B
// TXT_MONOSPACE U+1D670 - U+1D6A3
// TXT_FRAKTUR U+1D504 - U+1D537
// TXT_SANS_SERIF U+1D608 - U+1D63B
// TXT_SCRIPT U+1D49C - U+1D4CF
if(props.scr !== null && props.scr !== undefined)
this.scr = props.scr;
// если приходит несколько параметров style из xml, то запоминается последний
if(props.sty === STY_ITALIC)
/*if(props.sty === STY_ITALIC)
this.italic = true;
else if(props.sty === STY_BI)
{
......@@ -700,11 +727,7 @@ CMPrp.prototype =
// отличие от TXT_NORMAL w:rPrp не учитываются !
}
// TXT_DOUBLE_STRUCK U+1D538 - U+1D56B
// TXT_MONOSPACE U+1D670 - U+1D6A3
// TXT_FRAKTUR U+1D504 - U+1D537
// TXT_SANS_SERIF U+1D608 - U+1D63B
// TXT_SCRIPT U+1D49C - U+1D4CF
if(typeof(props.scr)!=="undefined" && props.scr !== null)
this.typeText = props.scr;
......@@ -712,22 +735,29 @@ CMPrp.prototype =
if(props.nor)
this.typeText = TXT_NORMAL;
*/
},
Apply_Pr: function(TextPr)
/*Apply_Pr: function(TextPr)
{
if(TextPr.Bold !== null && typeof(TextPr.Bold) !== "undefined")
this.bold = TextPr.Bold;
if(TextPr.Italic !== null && typeof(TextPr.Italic) !== "undefined")
this.italic = TextPr.Italic;
},
},*/
getPropsForWrite: function()
{
var props = {};
var props =
{
aln: this.aln,
brk: this.brk,
lit: this.lit,
nor: this.nor,
sty: this.sty,
scr: this.scr
};
var Italic = this.italic && !this.bold,
/*var Italic = this.italic && !this.bold,
BoldItalic = this.italic && this.bold,
Bold = this.bold && !this.italic,
Plain = this.plain;
......@@ -757,35 +787,16 @@ CMPrp.prototype =
if(this.lit)
props.lit = 1;
props.scr = this.typeText;
props.scr = this.typeText;*/
return props;
},
getTypeText: function()
{
return this.typeText;
},
getTxtSettings: function()
{
var type = this.typeText;
if(type == TXT_ROMAN && this.italic == false) // если MATH TEXT и не курсив, то подменяем на NORMAL TEXT
type = TXT_NORMAL;
var settings =
{
type: type,
lit: this.lit
};
return settings;
},
getTxtPrp: function()
{
var textPrp = new CTextPr();
textPrp.Italic = this.italic;
textPrp.Bold = this.bold;
textPrp.Italic = this.sty == STY_BI || this.sty == STY_ITALIC;
textPrp.Bold = this.sty == STY_BI || this.sty == STY_BOLD;
return textPrp;
},
......@@ -797,10 +808,8 @@ CMPrp.prototype =
NewMPrp.brk = this.brk;
NewMPrp.lit = this.lit;
NewMPrp.nor = this.nor;
NewMPrp.typeText = this.typeText;
NewMPrp.italic = this.italic;
NewMPrp.bold = this.bold;
NewMPrp.plain = this.plain;
NewMPrp.typeText = this.sty;
NewMPrp.italic = this.scr;
return NewMPrp;
}
......@@ -4900,18 +4909,16 @@ CMathContent.prototype =
Get_StartPos: function(ContentPos, Depth)
{
ContentPos.Update( 0, Depth );
Depth++;
this.content[0].Get_StartPos(ContentPos, Depth);
this.content[0].Get_StartPos(ContentPos, Depth + 1);
},
Get_EndPos: function(BehindEnd, ContentPos, Depth)
{
var len = this.content.length - 1;
ContentPos.Update(len, Depth);
Depth++;
if(len > 0)
this.content[len].Get_EndPos(BehindEnd, ContentPos, Depth);
this.content[len].Get_EndPos(BehindEnd, ContentPos, Depth + 1);
},
Get_Id : function()
{
......@@ -5194,23 +5201,61 @@ CMathContent.prototype =
var StartPos = this.SelectStartPos;
var EndPos = this.SelectEndPos;
if(StartPos > EndPos)
var NewRuns;
var LRun, CRun, RRun;
if(StartPos == EndPos)
{
var temp = StartPos;
EndPos = StartPos;
StartPos = temp;
}
NewRuns = this.content[StartPos].Apply_TextPr(TextPr, IncFontSize, false);
LRun = NewRuns[0];
CRun = NewRuns[1];
RRun = NewRuns[2];
var CRunPos = StartPos;
var Pos;
if(LRun !== null)
{
Pos = StartPos + 1;
History.Add(this, {Type: historyitem_Math_AddItem, Pos: Pos, PosEnd: Pos+1, Items: [CRun]});
this.content.splice(Pos, 0, CRun);
CRunPos = Pos + 1;
}
if(RRun !== null)
{
Pos = CRunPos + 1;
History.Add(this, {Type: historyitem_Math_AddItem, Pos: Pos, PosEnd: Pos+1, Items: [RRun]});
this.content.splice(Pos, 0, RRun);
}
for(var i = StartPos; i <= EndPos; i++)
this.CurPos = CRunPos;
this.SelectStartPos = CRunPos;
this.SelectEndPos = CRunPos;
}
else
{
var elem = this.content[i];
if(StartPos > EndPos)
{
var temp = StartPos;
EndPos = StartPos;
StartPos = temp;
}
if( elem.Type == para_Math_Composition)
elem.Apply_TextPr( TextPr, IncFontSize, true );
else if(elem.Type == para_Math_Run)
elem.Apply_TextPr( TextPr, IncFontSize, false );
for(var i = StartPos; i <= EndPos; i++)
{
var elem = this.content[i];
if( elem.Type == para_Math_Composition)
elem.Apply_TextPr( TextPr, IncFontSize, true );
else if(elem.Type == para_Math_Run)
elem.Apply_TextPr( TextPr, IncFontSize, false );
}
}
/*if ( StartPos === EndPos )
{
elem = this.content[StartPos];
......
......@@ -109,57 +109,126 @@ CMathText.prototype =
{
var code = this.value;
if(this.Type === para_Math_Placeholder || this.bJDraw)
if(this.Type === para_Math_Placeholder || this.bJDraw || this.Parent.MathPrp.nor)
return code;
var bCapitale = (code > 0x0040 && code < 0x005B),
bSmall = (code > 0x0060 && code < 0x007b),
bDigit = (code > 0x002F && code < 0x003A);
var Scr = this.Parent.Math_GetTypeText();
var bCapGreek = (code > 0x0390 && code < 0x03AA ),
bSmallGreek = (code > 0x03B0 && code < 0x03CA);
var Scr = this.Parent.MathPrp.scr,
Sty = this.Parent.MathPrp.sty;
// Mathematical Alphanumeric Characters
// http://www.w3.org/TR/2014/REC-xml-entity-names-20140410/Overview.html#alphabets
if(Scr == TXT_ROMAN)
{
var bCapGreek = (code > 0x0390 && code < 0x03AA ),
bSmallGreek = (code > 0x03B0 && code < 0x03CA);
if(Sty == STY_ITALIC)
{
if(code == 0x68) // h
code = 0x210E;
else if(bCapitale)
code = code + 0x1D3F3;
else if(bSmall)
code = code + 0x1D3ED;
else if(code == 0x131) // "i" without dot
code = 0x1D6A4;
else if(code == 0x237) // "j" without dot
code = 0x1D6A5;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D6F3;
else if(code == 0x2207) // Capital NABLA
code = 0x1D6FB;
else if(bCapGreek)
code = code + 0x1D351;
else if(bSmallGreek)
code = code + 0x1D34B;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D715;
else if(code == 0x3F5) // small EPSILON
code = 0x1D716;
else if(code == 0x3D1) // small THETA
code = 0x1D717;
else if(code == 0x3F0) // small KAPPA
code = 0x1D718;
else if(code == 0x3D5) // small PHI
code = 0x1D719;
else if(code == 0x3F1) // small RHO
code = 0x1D71A;
else if(code == 0x3D6) // small PI
code = 0x1D71B;
if(code == 0x68) // h
code = 0x210E;
else if(bCapitale)
code = code + 0x1D3F3;
else if(bSmall)
code = code + 0x1D3ED;
else if(code == 0x3F4) // Capital THETA special
code = 0x1D6F3;
else if(code == 0x2207) // Capital NABLA
code = 0x1D6FB;
else if(bCapGreek)
code = code + 0x1D351;
else if(bSmallGreek)
code = code + 0x1D34B;
else if(code == 0x2202) // PARTIAL DIFFERENTIAL
code = 0x1D715;
else if(code == 0x3F5) // small EPSILON
code = 0x1D716;
else if(code == 0x3D1) // small THETA
code = 0x1D717;
else if(code == 0x3F0) // small KAPPA
code = 0x1D718;
else if(code == 0x3D5) // small PHI
code = 0x1D719;
else if(code == 0x3F1) // small RHO
code = 0x1D71A;
else if(code == 0x3D6) // small PI
code = 0x1D71B;
if(code == 0x131) // "i" without dot
code = 0x1D6A4;
else if(code == 0x237) // "j" without dot
code = 0x1D6A5;
}
else if(Sty == STY_BI)
{
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(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 if(Scr == TXT_DOUBLE_STRUCK)
{
......@@ -247,62 +316,159 @@ CMathText.prototype =
else if(bSmall)
code = code + 0x1D629;
else if(bDigit)
code = code + 0x1D7C6;
code = code + 0x1D7C6;
}
else if(Scr == TXT_FRAKTUR)
{
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;
if(Sty == STY_BOLD ||Sty == STY_BI)
{
if(bCapitale)
code = code + 0x1D52B;
else if(bSmall)
code = code + 0x1D525;
}
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(bCapitale)
code = code + 0x1D5C7;
else if(bSmall)
code = code + 0x1D5C1;
else if(bDigit)
code = code + 0x1D7B2;
if(Sty == STY_ITALIC)
{
if(bCapitale)
code = code + 0x1D5C7;
else if(bSmall)
code = code + 0x1D5C1;
else if(bDigit)
code = code + 0x1D7B2;
}
else if(Sty == STY_BOLD)
{
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(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(bCapitale)
code = code + 0x1D55F;
else if(bSmall)
code = code + 0x1D559;
else if(bDigit)
code = code + 0x1D7B2;
}
}
else if(Scr == TXT_SCRIPT)
{
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;
if(Sty == STY_ITALIC || Sty == STY_PLAIN)
{
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(bCapitale)
code = code + 0x1D48F;
else if(bSmall)
code = code + 0x1D489;
}
}
return code;
......@@ -403,15 +569,11 @@ CMathText.prototype =
{
this.pos.x = pos.x + this.GapLeft;
this.pos.y = pos.y;
//console.log("Placeholder : " + this.pos.y);
}
else // for symbol only drawing
{
this.pos.x = pos.x - this.rasterOffsetX;
this.pos.y = pos.y - this.rasterOffsetY;
//console.log("Dot : " + this.pos.y);
}
}
catch(e)
......
......@@ -114,14 +114,16 @@ var ACCENT_TEXT = 46;
///////////////////////////////////////////////////
var TXT_NORMAL = 0;
var TXT_PLAIN = 1;
var TXT_ROMAN = 2; // math roman
var TXT_SCRIPT = 3;
var TXT_FRAKTUR = 4;
var TXT_DOUBLE_STRUCK = 5;
var TXT_SANS_SERIF = 6;
var TXT_MONOSPACE = 7;
/*var TXT_NORMAL = 0;
var TXT_PLAIN = 1;*/
var TXT_ROMAN = 0; // math roman
var TXT_SCRIPT = 1;
var TXT_FRAKTUR = 2;
var TXT_DOUBLE_STRUCK = 3;
var TXT_SANS_SERIF = 4;
var TXT_MONOSPACE = 5;
var OPER_DELIMITER = 0;
var OPER_SEPARATOR = 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