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

1. Переделала функцию добавление/удаления пустых Run в контент(с записью...

1. Переделала функцию добавление/удаления пустых Run в контент(с записью изменений в историю), при этом реализовала смещения текущей позиции контента, начальной и конечной позиций селекта
2. Pеализовала компиляцию настроек для MathPrp (теперь поля могут быть undefined)
3. Переделала Apply_Pr (для Bold и Italic)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57291 954022d7-b5bf-4e40-9824-e11837661b57
parent 1b9cb0ff
......@@ -4473,7 +4473,7 @@ ParaRun.prototype =
if(!this.IsNormalText()) // math text
{
var MPrp = this.MathPrp.getTxtPrp();
var MPrp = this.MathPrp.GetTxtPrp();
TextPr.Merge(MPrp); // bold, italic
}
......@@ -4698,7 +4698,7 @@ ParaRun.prototype =
NewRun.Set_Pr( this.Pr.Copy() );
if(bMathRun)
NewRun.Set_MathPrp(this.MathPrp.Copy());
NewRun.Set_MathPr(this.MathPrp.Copy());
var OldCrPos = this.State.ContentPos;
......@@ -4784,19 +4784,56 @@ ParaRun.prototype =
// В данной функции мы применяем приходящие настройки поверх старых, т.е. старые не удаляем
Apply_Pr : function(TextPr)
{
if ( undefined != TextPr.Bold )
if(this.Type == para_Math_Run && !this.IsNormalText())
{
if(this.Type == para_Math_Run && !this.IsNormalText())
this.Apply_StyleBold(null === TextPr.Bold ? undefined : TextPr.Bold);
if(null === TextPr.Bold && null === TextPr.Italic)
this.Math_Apply_Style(undefined);
else
this.Set_Bold( null === TextPr.Bold ? undefined : TextPr.Bold );
}
{
if(undefined != TextPr.Bold)
{
if(TextPr.Bold == true)
{
if(this.MathPrp.sty == STY_ITALIC)
this.Math_Apply_Style(STY_BI);
else if(this.MathPrp.sty == STY_PLAIN || this.MathPrp.sty == undefined)
this.Math_Apply_Style(STY_BOLD);
if ( undefined != TextPr.Italic )
}
else if(TextPr.Bold == false || TextPr.Bold == null)
{
if(this.MathPrp.sty == STY_BI)
this.Math_Apply_Style(STY_ITALIC);
else if(this.MathPrp.sty == STY_BOLD || this.MathPrp.sty == undefined)
this.Math_Apply_Style(STY_PLAIN);
}
}
if(undefined != TextPr.Italic)
{
if(TextPr.Italic == true)
{
if(this.MathPrp.sty == STY_BOLD)
this.Math_Apply_Style(STY_BI);
else if(this.MathPrp.sty == STY_PLAIN || this.MathPrp.sty == undefined)
this.Math_Apply_Style(STY_ITALIC);
}
else if(TextPr.Italic == false || TextPr.Italic == null)
{
if(this.MathPrp.sty == STY_BI)
this.Math_Apply_Style(STY_BOLD);
else if(this.MathPrp.sty == STY_ITALIC || this.MathPrp.sty == undefined)
this.Math_Apply_Style(STY_PLAIN);
}
}
}
}
else
{
if(this.Type == para_Math_Run && !this.IsNormalText())
this.Apply_StyleItalic(null === TextPr.Italic ? undefined : TextPr.Italic);
else
if ( undefined != TextPr.Bold )
this.Set_Bold( null === TextPr.Bold ? undefined : TextPr.Bold );
if( undefined != TextPr.Italic )
this.Set_Italic( null === TextPr.Italic ? undefined : TextPr.Italic );
}
......@@ -5649,6 +5686,14 @@ ParaRun.prototype =
break;
}
case historyitem_ParaRun_MathPrp:
{
this.MathPrp = Data.Old;
this.Recalc_CompiledPr(true);
break;
}
}
},
......@@ -6010,6 +6055,14 @@ ParaRun.prototype =
break;
}
case historyitem_ParaRun_MathPrp:
{
this.MathPrp = Data.New;
this.Recalc_CompiledPr(true);
break;
}
}
},
......@@ -7460,7 +7513,7 @@ ParaRun.prototype.Set_MathPrp = function(props)
{
this.MathPrp.setMathProps(props);
}
ParaRun.prototype.Apply_StyleBold = function(Value)
/*ParaRun.prototype.Apply_StyleBold = function(Value)
{
if(Value == undefined)
Value = false;
......@@ -7486,13 +7539,14 @@ 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
this.Apply_Style(STY_ITALIC);
}
else if(Value == false)
{
......@@ -7500,9 +7554,12 @@ ParaRun.prototype.Apply_StyleItalic = function(Value)
this.Apply_Style(STY_BOLD);
else if(this.MathPrp.sty == STY_ITALIC)
this.Apply_Style(STY_PLAIN);
else
this.Apply_Style(STY_PLAIN);
}
}
ParaRun.prototype.Apply_Style = function(Value)
}*/
ParaRun.prototype.Math_Apply_Style = function(Value)
{
if(Value !== this.MathPrp.sty)
{
......@@ -7516,7 +7573,8 @@ ParaRun.prototype.Apply_Style = function(Value)
}
ParaRun.prototype.IsNormalText = function()
{
return this.MathPrp.nor == true;
var comp_MPrp = this.MathPrp.GetCompiled_ScrStyles();
return comp_MPrp.nor == true;
}
ParaRun.prototype.getPropsForWrite = function()
{
......@@ -7561,4 +7619,12 @@ ParaRun.prototype.fillPlaceholders = function()
placeholder.fillPlaceholders();
this.Add_ToContent(0, placeholder, false);
}
ParaRun.prototype.Set_MathPr = function(MPrp)
{
var OldValue = this.MathPrp;
this.MathPrp = MPrp;
History.Add( this, { Type : historyitem_ParaRun_MathPrp, New : MPrp, Old : OldValue } );
this.Recalc_CompiledPr(true);
}
\ No newline at end of file
......@@ -136,7 +136,7 @@ var COEFF_GAPS = new CCoeffGaps();
// TODO
// проконтролировать GapLeft и GapRight для setPosition всех элементов
function CRecalculateInfo(oMeasure, argSize)
function CMathRecalculateInfo(oMeasure, argSize)
{
this.measure = oMeasure;
......@@ -151,7 +151,7 @@ function CRecalculateInfo(oMeasure, argSize)
this.Current = null; // текущий элемент
}
CRecalculateInfo.prototype =
CMathRecalculateInfo.prototype =
{
old_checkGapsSign: function(oMeasure, posCurr)
{
......@@ -523,14 +523,22 @@ CRecalculateInfo.prototype =
function CMPrp()
{
this.sty = STY_ITALIC;
this.sty = undefined;
this.scr = undefined;
this.nor = undefined;
this.aln = undefined;
this.brk = undefined;
this.lit = undefined;
/*this.sty = STY_ITALIC;
this.scr = TXT_ROMAN;
this.nor = false;
this.aln = false;
this.brk = false;
this.lit = false;
this.lit = false;*/
// TXT_NORMAL
// если normal == false, то берем TextPrp отсюда (в wRunPrp bold/italic не учитываем, выставляем отсюда)
......@@ -541,12 +549,6 @@ function CMPrp()
// буквы берутся обычные, не специальные для Cambria Math : то есть как для TXT_NORMAL
// отличие от TXT_NORMAL w:rPrp в этом случае не учитываются !
//this.typeText = TXT_ROMAN;
//this.italic = true;
//this.bold = false;
//this.nor = false;
//this.plain = false;
}
CMPrp.prototype =
{
......@@ -592,7 +594,7 @@ CMPrp.prototype =
return props;
},
getTxtPrp: function()
GetTxtPrp: function()
{
var textPrp = new CTextPr();
......@@ -613,6 +615,27 @@ CMPrp.prototype =
NewMPrp.scr = this.scr;
return NewMPrp;
},
GetCompiled_ScrStyles : function()
{
var nor = this.nor == undefined ? false : this.nor;
var scr = this.scr == undefined ? TXT_ROMAN : this.scr;
var sty = this.sty == undefined ? STY_ITALIC : this.sty;
return {nor: nor, scr: scr, sty: sty};
},
SetStyle: function(Bold, Italic) /// из ctrPrp получить style для MathPrp
{
if(Bold == true && Italic == true)
this.sty = STY_BI;
else if(Italic == true)
this.sty = STY_ITALIC;
else if(Bold == true)
this.sty = STY_BOLD;
else
this.sty = STY_PLAIN;
}
}
......@@ -3794,7 +3817,7 @@ CMathContent.prototype =
},
Resize: function(Parent, ParaMath, oMeasure) // пересчитываем всю формулу
{
var RecalcInfo = new CRecalculateInfo(oMeasure, this.argSize);
var RecalcInfo = new CMathRecalculateInfo(oMeasure, this.argSize);
this.ParaMath = ParaMath;
......@@ -4289,7 +4312,7 @@ CMathContent.prototype =
{
return this.Id;
},
SetRunEmptyToContent: function(bAll)
old_SetRunEmptyToContent: function(bAll)
{
var current = null, left = null;
......@@ -4358,6 +4381,75 @@ CMathContent.prototype =
this.content = NewContent;
},
SetRunEmptyToContent: function(bAll)
{
var len = this.content.length;
var current = null, left = null;
var emptyRun, ctrPrp, mathPrp, txtPrp;
for(var i = 0; i < len; i++)
{
current = this.content[i];
var bLeftRun = left !== null ? left.Type == para_Math_Run : false,
bRightRun = i < len - 1 ? this.content[i + 1].Type === para_Math_Run : false;
var bCurrComp = current.Type == para_Math_Composition,
bCurrEmptyRun = current.Type == para_Math_Run && current.Is_Empty();
var bDeleteEmptyRun = bCurrEmptyRun && (bLeftRun || bRightRun);
if(bCurrComp && bAll == true)
this.content[i].SetRunEmptyToContent(bAll);
if(bCurrComp && !bLeftRun) // добавление пустого Run перед мат объектом
{
emptyRun = new ParaRun(null, true);
ctrPrp = current.Get_CtrPrp();
mathPrp = new CMPrp();
mathPrp.SetStyle(ctrPrp.Bold, ctrPrp.Italic);
emptyRun.Set_MathPr(mathPrp);
ctrPrp.Bold = undefined;
ctrPrp.Italic = undefined;
emptyRun.Set_Pr(ctrPrp);
this.Internal_Content_Add(i, emptyRun);
}
else if(bDeleteEmptyRun)
{
this.Remove_FromContent(i, 1);
}
}
len = this.content.length;
if(len > 0 && this.content[len - 1].Type == para_Math_Composition)
{
emptyRun = new ParaRun(null, true);
ctrPrp = current.Get_CtrPrp();
mathPrp = new CMPrp();
mathPrp.SetStyle(ctrPrp.Bold, ctrPrp.Italic);
emptyRun.Set_MathPr(mathPrp);
ctrPrp.Bold = undefined;
ctrPrp.Italic = undefined;
emptyRun.Set_Pr(ctrPrp);
this.Internal_Content_Add(len, emptyRun);
}
},
Create_FontMap : function(Map)
{
......@@ -4709,6 +4801,39 @@ CMathContent.prototype =
if ( this.Selection.End >= Pos )
this.Selection.End++;
},
Remove_FromContent : function(Pos, Count)
{
var DeletedItems = this.content.slice( Pos, Pos + Count );
History.Add( this, { Type : historyitem_Math_RemoveItem, Pos : Pos, EndPos : Pos + Count - 1, Items : DeletedItems } );
if(this.CurPos > Pos)
{
if(this.CurPos >= Pos + Count)
this.CurPos -= Count;
else
this.CurPos = Pos;
}
if ( true === this.Selection.Use )
{
if(this.Selection.Start > Pos)
{
if(this.Selection.Start >= Pos + Count)
this.Selection.Start -= Count;
else
this.Selection.Start = Pos;
}
if(this.Selection.End > Pos)
{
if(this.Selection.End >= Pos + Count)
this.Selection.End -= Count;
else
this.Selection.End = Pos;
}
}
},
Get_Default_TPrp: function()
{
......
......@@ -113,18 +113,20 @@ CMathText.prototype =
{
var code = this.value;
if(this.Type === para_Math_Placeholder || this.bJDraw || this.Parent.MathPrp.nor)
var Compiled_MPrp = this.Parent.MathPrp.GetCompiled_ScrStyles();
if(this.Type === para_Math_Placeholder || this.bJDraw || Compiled_MPrp.nor)
return code;
var bCapitale = (code > 0x0040 && code < 0x005B),
bSmall = (code > 0x0060 && code < 0x007b),
bDigit = (code > 0x002F && code < 0x003A);
var bCapGreek = (code > 0x0390 && code < 0x03AA ),
var bCapGreek = (code > 0x0390 && code < 0x03AA),
bSmallGreek = (code > 0x03B0 && code < 0x03CA);
var Scr = this.Parent.MathPrp.scr,
Sty = this.Parent.MathPrp.sty;
var Scr = Compiled_MPrp.scr,
Sty = Compiled_MPrp.sty;
// Mathematical Alphanumeric Characters
// http://www.w3.org/TR/2014/REC-xml-entity-names-20140410/Overview.html#alphabets
......@@ -680,7 +682,6 @@ CMathText.prototype =
else
ContentPos.Add(0);
},
Get_ParaContentPosByXY: function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
{
......
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