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

1. Переделан плейсхолдер : теперь плейсхолдер лежит в ParaRun

2. typeObj -> Type
3. Поправлен баг с delimiters, для случая когда оператор отсутствует (chr = -1)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57108 954022d7-b5bf-4e40-9824-e11837661b57
parent b02eca98
......@@ -2,7 +2,8 @@
function CMathBase()
{
this.typeObj = MATH_COMP;
//this.typeObj = MATH_COMP;
this.Type = para_Math_Composition;
this.pos = new CMathPosition();
this.size = null;
......@@ -123,7 +124,7 @@ CMathBase.prototype =
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
if(this.elements[i][j].typeObj === MATH_COMP)
if(this.elements[i][j].Type === para_Math_Composition)
this.elements[i][j].Set_CompiledCtrPrp(ParaMath);
},
......@@ -157,7 +158,7 @@ CMathBase.prototype =
return rPrp;
},
setRPrp: function(rPrp)
/*setRPrp: function(rPrp)
{
//this.RunPrp.mathPrp.bold = rPrp.mathPrp.bold; // как в Ворде, все остальные стили не поддерживаются
//this.RunPrp.setTxtPrp(rPrp.textPrp); // Merge wTxtPrp
......@@ -172,7 +173,7 @@ CMathBase.prototype =
if( !this.elements[i][j].IsJustDraw())
this.elements[i][j].setRPrp(rPrp);
}
},
},*/
increaseArgSize: function()
{
for(var i=0; i < this.nRow; i++)
......@@ -1297,7 +1298,7 @@ CMathBase.prototype =
},
GetParent: function()
{
return (this.Parent.typeObj !== MATH_COMP ? this : this.Parent.GetParent());
return (this.Parent.Type !== para_Math_Composition ? this : this.Parent.GetParent());
},
Copy: function(Selected)
{
......@@ -1418,7 +1419,7 @@ CMathBase.prototype =
},
Create_FontMap : function(Map)
{
var CtrPrp = this.Get_CompiledCtrPrp(false);
var CtrPrp = this.Get_CompiledCtrPrp();
CtrPrp.Document_CreateFontMap( Map, this.ParaMath.Paragraph.Get_Theme().themeElements.fontScheme);
for(var i=0; i < this.nRow; i++)
......@@ -1428,6 +1429,17 @@ CMathBase.prototype =
this.elements[i][j].Create_FontMap( Map );
}
},
Get_AllFontNames: function(AllFonts)
{
this.CtrPrp.Document_Get_AllFontNames( AllFonts );
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
{
if(!this.elements[i][j].IsJustDraw())
this.elements[i][j].Get_AllFontNames(AllFonts);
}
}
//////////////////////////
......
......@@ -410,14 +410,14 @@ CRecalculateInfo.prototype =
var leftCode;
if(this.Current.typeObj == MATH_TEXT)
if(this.Current.Type == para_Math_Text)
{
var currCode = this.Current.getCodeChr();
if(this.Left !== null)
{
if(this.Left.typeObj == MATH_COMP)
if(this.Left.Type == para_Math_Composition)
{
rightCoeff = this.getGapsMComp(this.Left, 1);
leftCoeff = COEFF_GAPS.getCoeff(currCode, -1, -1);
......@@ -441,7 +441,7 @@ CRecalculateInfo.prototype =
if(this.Left != null)
{
if(this.Left.typeObj == MATH_COMP)
if(this.Left.Type == para_Math_Composition)
{
rightCoeff = this.getGapsMComp(this.Left, 1);
......@@ -529,6 +529,7 @@ CRecalculateInfo.prototype =
return {bEmptyGaps: bEmptyGaps, bChildGaps: bChildGaps};
}
}
// TO DO
......@@ -829,7 +830,7 @@ function CMathContent()
this.content = []; // array of mathElem
this.CurPos = -1;
this.CurPos = 0;
this.WidthToElement = [];
this.pos = new CMathPosition(); // относительная позиция
......@@ -890,7 +891,7 @@ CMathContent.prototype =
for(var i = 0; i < this.content.length; i++)
{
if(this.content[i].typeObj == MATH_COMP)
if(this.content[i].Type == para_Math_Composition)
this.content[i].setArgSize(argSize);
}
}
......@@ -953,13 +954,9 @@ CMathContent.prototype =
},
addElementToContent: function(obj) //for "read"
{
obj.Parent = this;
if(obj.typeObj === MATH_COMP)
if(obj.Type === para_Math_Composition)
{
//obj.setComposition(this.Composition);
obj.setArgSize(this.argSize);
this.content.push(obj);
}
else
......@@ -3927,7 +3924,7 @@ CMathContent.prototype =
return items;
},
removeAreaSelect: function()
/*removeAreaSelect: function()
{
if( this.IsPlaceholder() ) //удаляем тагет
{
......@@ -3938,14 +3935,20 @@ CMathContent.prototype =
}
else if( this.selectUse() ) //т.к. после того как удалили тагет у нас эти 2 значения не равны, равенство их выставляется позднее, после добавления символа
this.remove(1);
},
},*/
fillPlaceholders: function()
{
var placeholder = new CMathText(false);
this.content.length = 0;
var oMRun = new ParaRun(null, true);
oMRun.fillPlaceholders();
this.addElementToContent(oMRun);
/*var placeholder = new CMathText(false);
//placeholder.relate(this);
placeholder.fillPlaceholders();
this.content.push( placeholder );
this.content.push( placeholder );*/
},
//////////////////////////////////////
......@@ -3962,12 +3965,14 @@ CMathContent.prototype =
for(var i = 0; i < this.content.length; i++)
{
if(this.content[i].typeObj == MATH_COMP)
if(this.content[i].Type == para_Math_Composition)
{
this.content[i].Resize(this, ParaMath, oMeasure);
this.content[i].ApplyGaps();
}
else if(this.content[i].typeObj == MATH_PLACEHOLDER)
else
this.content[i].Math_Recalculate(this, ParaMath.Paragraph, oMeasure);
/*else if(this.content[i].typeObj == MATH_PLACEHOLDER)
{
if(!this.bRoot)
{
......@@ -3984,7 +3989,7 @@ CMathContent.prototype =
else
{
this.content[i].Math_Recalculate(this, ParaMath.Paragraph, oMeasure);
}
}*/
this.WidthToElement[i] = width;
......@@ -4012,22 +4017,19 @@ CMathContent.prototype =
this.Parent = Parent;
}
if (!this.bRoot && this.content.length == 0)
{
this.CurPos = 0;
this.fillPlaceholders();
}
var lng = this.content.length;
for(var pos = 0; pos < lng; pos++)
{
if(this.content[pos].typeObj == MATH_COMP)
if(this.content[pos].Type == para_Math_Composition)
{
// мержим ctrPrp до того, как добавим Gaps !
this.content[pos].Set_CompiledCtrPrp(ParaMath); // без ParaMath несмержим ctrPrp
this.content[pos].SetGaps(this, ParaMath, RecalcInfo);
}
else if(this.content[pos].typeObj == MATH_PARA_RUN /*&& !this.content[pos].Is_Empty()*/)
else if(this.content[pos].Type == para_Math_Run /*&& !this.content[pos].Is_Empty()*/)
this.content[pos].Math_SetGaps(this, ParaMath.Paragraph, RecalcInfo);
}
......@@ -4035,28 +4037,9 @@ CMathContent.prototype =
if(RecalcInfo.Current !== null)
RecalcInfo.Current.GapRight = 0;
/*if(this.bRoot)
{
for(var pos = 0; pos < lng; pos++)
{
if(this.content[pos].typeObj == MATH_COMP)
console.log("Gap left " + this.content[pos].GapLeft + " Gap Right " + this.content[pos].GapRight);
}
console.log("");
}*/
this.recalculateSize(ParaMath, oMeasure);
},
IsEmptyRun: function(pos) // пустой Para_Run
{
var result = false;
if(pos < this.content.length)
result = this.content[pos].typeObj !== MATH_COMP && this.content[pos].Is_Empty();
return result;
},
getGapsInside: function(RecalcInfo) // учитываем gaps внутренних объектов
{
var gaps = {left: 0, right: 0};
......@@ -4068,10 +4051,10 @@ CMathContent.prototype =
if(len > 1)
{
var bFRunEmpty = this.content[0].Is_Empty();
bFirstComp = bFRunEmpty && this.content[1].typeObj == MATH_COMP; // первый всегда идет Run
bFirstComp = bFRunEmpty && this.content[1].Type == para_Math_Composition; // первый всегда идет Run
var bLastRunEmpty = this.content[len - 1].Is_Empty(); // т.к. после мат. объекта стоит пустой Run
bLastComp = bLastRunEmpty && this.content[len - 2].typeObj == MATH_COMP;
bLastComp = bLastRunEmpty && this.content[len - 2].Type == para_Math_Composition;
}
var checkGap;
......@@ -4105,7 +4088,7 @@ CMathContent.prototype =
var bOnlyText = true;
for(var i = 0; i < this.content.length; i++)
{
if(this.content[i].typeObj == MATH_COMP)
if(this.content[i].Type == para_Math_Composition)
{
bOnlyText = false;
break;
......@@ -4114,67 +4097,25 @@ CMathContent.prototype =
return bOnlyText;
},
old_checkSignComp: function(pos)
{
var bPlus = false, bMinus = false,
bMult = false, bDivision = false,
bEqual = false;
var currType = pos > 0 && pos < this.content.length ? this.content[pos].value.typeObj : null;
if(currType == MATH_TEXT)
{
var code = this.content[pos].value.getCodeChr();
bPlus = code === 0x2B;
bMinus = code === 0x2212;
bMult = code === 0x2217;
bDivision = code === 0x002F;
bEqual = code === 0x3D;
}
return (bPlus || bMinus || bEqual);
},
draw: function(x, y, pGraphics)
{
var bHidePlh = this.plhHide && this.IsPlaceholder();
if( !bHidePlh )
{
var oWPrp;
for(var i=0; i < this.content.length;i++)
{
if(this.content[i].typeObj == MATH_RUN_PRP)
{
pGraphics.b_color1(0,0,0,255);
var mgWPrp = this.content[i].value.getMergedWPrp();
oWPrp = new CTextPr();
oWPrp.Merge(mgWPrp);
this.ParaMath.ApplyArgSize(oWPrp, this.argSize);
pGraphics.SetFont(oWPrp);
}
else if(this.content[i].typeObj == MATH_PLACEHOLDER)
if(this.content[i].Type == para_Math_Composition)
{
pGraphics.b_color1(0,0,0,255);
oWPrp = this.Parent.Get_CompiledCtrPrp_2();
this.ParaMath.ApplyArgSize(oWPrp, this.argSize);
oWPrp.Italic = false;
pGraphics.SetFont(oWPrp);
pGraphics.SetFont(oWPrp);
this.content[i].draw(x, y, pGraphics);
}
else if(this.content[i].typeObj == MATH_PARA_RUN)
else
this.content[i].Math_Draw(x, y, pGraphics);
/*else if(this.content[i].typeObj == MATH_PARA_RUN)
this.content[i].Math_Draw(x, y, pGraphics);
else
this.content[i].draw(x, y, pGraphics);
this.content[i].draw(x, y, pGraphics);*/
}
}
......@@ -4183,11 +4124,11 @@ CMathContent.prototype =
update_Cursor: function(CurPage, UpdateTarget)
{
var result;
if(this.content[this.CurPos].typeObj == MATH_COMP)
if(this.content[this.CurPos].Type == para_Math_Composition)
{
result = this.content[this.CurPos].update_Cursor(CurPage, UpdateTarget);
}
else if(this.content[this.CurPos].typeObj == MATH_PARA_RUN)
else
{
var X = this.pos.x + this.ParaMath.X + this.WidthToElement[this.CurPos],
Y = this.pos.y + this.ParaMath.Y + this.size.ascent;
......@@ -4209,7 +4150,7 @@ CMathContent.prototype =
pos = i;
}
if( this.content[pos].typeObj === MATH_COMP )
if( this.content[pos].Type === para_Math_Composition )
{
if(X < W - width + this.content[pos].GapLeft)
pos--;
......@@ -4219,13 +4160,13 @@ CMathContent.prototype =
return pos;
},
remove: function(order)
/*remove: function(order)
{
var state =
{
bDelete: false, /* нужно ли пересчитывать позицию или нет, работает при backspace */
bBegin: false, /* в начале контента или нет */
bEnd: false, /* в конце */
bDelete: false, *//* нужно ли пересчитывать позицию или нет, работает при backspace *//*
bBegin: false, *//* в начале контента или нет *//*
bEnd: false, *//* в конце *//*
bAddRPrp: false
};
......@@ -4524,13 +4465,13 @@ CMathContent.prototype =
}
return result;
},
setPlaceholderAfterRemove: function() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
},*/
/*setPlaceholderAfterRemove: function() // чтобы не выставлялся тагет при вставке, когда заселекчен весь контент и мы добавляем, например, другой мат элемент
{
if(this.content.length == 1 && !this.bRoot )//только CEmpty
this.fillPlaceholders();
},
selectUse: function()
},*/
/*selectUse: function()
{
var result;
......@@ -4549,7 +4490,7 @@ CMathContent.prototype =
result = true;
return result;
},
},*/
setCtrPrp: function()
{
......@@ -4558,7 +4499,7 @@ CMathContent.prototype =
{
var flag = false;
if(!this.bRoot && this.content.length == 1)
flag = this.content[0].typeObj === MATH_PLACEHOLDER;
flag = this.content[0].IsPlaceholder();
return flag;
},
......@@ -4580,36 +4521,13 @@ CMathContent.prototype =
NewPos.x = pos.x;
NewPos.y = pos.y + this.size.ascent; // y по baseline;
//console.log("SetPosition");
var check = this.content.length > 1 && this.content[1].typeObj == MATH_COMP && !this.bRoot;
var check2 = this.bRoot;
for(var i=0; i < this.content.length; i++)
{
if(this.content[i].typeObj == MATH_COMP)
{
this.content[i].setPosition(NewPos);
NewPos.x += this.content[i].size.width;
}
else if(this.content[i].typeObj == MATH_PARA_RUN)
{
this.content[i].Math_SetPosition(NewPos);
NewPos.x += this.content[i].size.width;
}
else if(this.content[i].typeObj == MATH_PLACEHOLDER)
this.content[i].setPosition(NewPos);
if(check2)
{
if(this.content[i].typeObj == MATH_COMP)
console.log("X " + NewPos.x);
}
}
if(check2)
console.log("");
},
///// properties /////
......@@ -4631,16 +4549,24 @@ CMathContent.prototype =
if(this.content.length > 1)
{
// первый объект всегда para_Math_Run
this.content[0].Get_CompiledPr(true);
/*
var obj = this.content[1];
if(obj.typeObj === MATH_RUN_PRP) // если первый объект - буква
if(obj.Type === MATH_RUN_PRP) // если первый объект - буква
{
rPrp.Merge(obj);
}
else if(obj.typeObj === MATH_COMP)
else if(obj.Type === MATH_COMP)
{
var FirstRPrp = obj.getCtrPrpForFirst(ParaMath);// иначе зациклимся на getCtrPrp
rPrp.Merge(FirstRPrp);
}
}*/
}
return rPrp;
......@@ -4655,7 +4581,7 @@ CMathContent.prototype =
if( this.argSize > -2 )
this.argSize--;
},
setItalic: function(flag)
/*setItalic: function(flag)
{
var rPrp = new CTextPr();
rPrp.Italic = flag;
......@@ -4673,7 +4599,7 @@ CMathContent.prototype =
}
}
},
setRPrp: function(RunPrp) //object CMathRun
setRPrp: function(RunPrp) // object CMathRun
{
for(var i = 0; i < this.content.length; i++)
{
......@@ -4687,15 +4613,23 @@ CMathContent.prototype =
obj.setRPrp(RunPrp);
}
}
},
apply_RunPr: function(RunPrp)
},*/
/*apply_RunPr: function(RunPrp)
{
this.setRPrp(RunPrp);
},*/
GetCtrPrp: function() // for placeholder
{
var ctrPrp = new CTextPr();
if(!this.bRoot)
ctrPrp.Merge( this.Parent.Get_CompiledCtrPrp_2() );
return ctrPrp;
},
////////////////////////
//////// /////////
getMetricsLetter: function(pos)
/*getMetricsLetter: function(pos)
{
return this.content[pos+1].value.getMetrics();
},
......@@ -4713,10 +4647,10 @@ CMathContent.prototype =
}
return res;
},
},*/
// (!) повторяется функция (IsHighElement)
IsIncline: function()
/*IsIncline: function()
{
var bIncline = false;
......@@ -4724,7 +4658,7 @@ CMathContent.prototype =
bIncline = this.content[1].value.IsIncline();
return bIncline;
},
},*/
/// For Para Math
......@@ -4732,11 +4666,11 @@ CMathContent.prototype =
{
var result;
if(this.content[this.CurPos].typeObj == MATH_COMP)
if(this.content[this.CurPos].Type == para_Math_Composition)
{
result = this.content[this.CurPos].Recalculate_CurPos(_X, Y, CurrentRun, _CurRange, _CurLine, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
}
else if(this.content[this.CurPos].typeObj == MATH_PARA_RUN)
else if(this.content[this.CurPos].Type == para_Math_Run)
{
Y = this.pos.y + this.ParaMath.Y + this.size.ascent;
_X = this.pos.x + this.ParaMath.X + this.WidthToElement[this.CurPos];
......@@ -4744,13 +4678,13 @@ CMathContent.prototype =
result = this.content[this.CurPos].Recalculate_CurPos(_X, Y, CurrentRun, 0, 0, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
}
else
/*else
{
Y = this.pos.y + this.ParaMath.Y + this.size.ascent;
_X = this.pos.x + this.ParaMath.X + this.size.width;
/*var ctrPrp = this.Parent.getCtrPrp();
this.ParaMath.ApplyArgSize(ctrPrp);*/
*//*var ctrPrp = this.Parent.getCtrPrp();
this.ParaMath.ApplyArgSize(ctrPrp);*//*
var ctrPrp = this.Parent.Get_CompiledCtrPrp();
......@@ -4764,7 +4698,7 @@ CMathContent.prototype =
result = {X: _X, Y: Y};
}
}*/
return result;
},
......@@ -4785,7 +4719,7 @@ CMathContent.prototype =
{
for(var i = 0; i < this.content.length; i++)
{
if(this.content[i].typeObj !== MATH_PLACEHOLDER)
//if(this.content[i].typeObj !== MATH_PLACEHOLDER)
this.content[i].Recalculate_Reset(StartRange, StartLine);
}
},
......@@ -4884,7 +4818,7 @@ CMathContent.prototype =
var bEqual = startPos == endPos,
bNotSelectComp = bEqual ? this.content[startPos].typeObj === MATH_COMP && this.content[startPos].IsSelectEmpty() : false;
bNotSelectComp = bEqual ? this.content[startPos].Type === para_Math_Composition && this.content[startPos].IsSelectEmpty() : false;
var result;
......@@ -4901,10 +4835,12 @@ CMathContent.prototype =
this.SelectStartPos = 0;
this.SelectEndPos = this.content.length - 1;
if(this.content[this.SelectStartPos].typeObj == MATH_PARA_RUN)
this.bSelectionUse = true;
if(this.content[this.SelectStartPos].Type == para_Math_Run)
this.content[this.SelectStartPos].Select_All();
if(this.content[this.SelectEndPos].typeObj == MATH_PARA_RUN)
if(this.content[this.SelectEndPos].Type == para_Math_Run)
this.content[this.SelectEndPos].Select_All();
},
......@@ -4914,12 +4850,12 @@ CMathContent.prototype =
if(this.SelectStartPos == 0 && this.SelectEndPos == this.content.length - 1)
{
if(this.content[this.SelectStartPos].typeObj == MATH_PARA_RUN)
if(this.content[this.SelectStartPos].Type == para_Math_Run)
bFirst = this.content[this.SelectStartPos].Is_SelectedAll(Props);
else
bFirst = true;
if(this.content[this.SelectEndPos].typeObj == MATH_PARA_RUN)
if(this.content[this.SelectEndPos].Type == para_Math_Run)
bEnd = this.content[this.SelectEndPos].Is_SelectedAll(Props);
else
bEnd = true;
......@@ -4935,6 +4871,9 @@ CMathContent.prototype =
var result = false;
if(startPos == endPos)
result = this.content[startPos].Selection_IsEmpty();
/*if(startPos == endPos)
{
var bRunPrp = this.content[startPos].typeObj == MATH_RUN_PRP,
bComp = this.content[startPos].typeObj == MATH_COMP;
......@@ -4943,7 +4882,7 @@ CMathContent.prototype =
result = this.content[startPos].Selection_IsEmpty();
else
result = false; // placeholder
}
}*/
return result;
},
......@@ -4992,22 +4931,24 @@ CMathContent.prototype =
var len = this.content.length;
var emptyRun, txtPrp;
for(var i = 0; i < len; i++)
{
current = this.content[i];
var bLeftRun = left !== null ? left.typeObj == MATH_PARA_RUN : false,
bRightRun = i < len - 1 ? this.content[i + 1].typeObj === MATH_PARA_RUN : false;
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.typeObj == MATH_COMP,
bCurrEmptyRun = current.typeObj == MATH_PARA_RUN && current.Is_Empty();
var bCurrComp = current.Type == para_Math_Composition,
bCurrEmptyRun = current.Type == para_Math_Run && current.Is_Empty();
var bDeleteEmptyRun = bCurrEmptyRun && (bLeftRun || bRightRun);
if(bCurrComp && !bLeftRun) // добавление пустого Run перед мат объектом
{
var emptyRun = new ParaRun(null, true);
var txtPrp = current.Get_CtrPrp();
emptyRun = new ParaRun(null, true);
txtPrp = current.Get_CtrPrp();
emptyRun.Set_Pr(txtPrp);
NewContent.push(emptyRun);
......@@ -5027,12 +4968,12 @@ CMathContent.prototype =
this.content[i].SetRunEmptyToContent(bAll);
}
if(len > 0 && this.content[len - 1].typeObj == MATH_COMP)
if(len > 0 && this.content[len - 1].Type == para_Math_Composition)
{
var emptyRun = new ParaRun(null, true);
emptyRun = new ParaRun(null, true);
//var emptyRun = new ParaRun(this.ParaMath.Paragraph, true);
var txtPrp = current.Get_CtrPrp();
txtPrp = current.Get_CtrPrp();
emptyRun.Set_Pr(txtPrp);
NewContent.push(emptyRun);
......@@ -5043,15 +4984,15 @@ CMathContent.prototype =
},
Create_FontMap : function(Map)
{
// TODO
// заделать для плейсхолдера
// т.к. для TXT_NORMAL можно выставить другой шрифт для одного плейсхолдера
for (var index = 0; index < this.content.length; index++)
if(this.content[index].typeObj !== MATH_PLACEHOLDER)
this.content[index].Create_FontMap( Map );
},
Get_AllFontNames: function(AllFonts)
{
for (var index = 0; index < this.content.length; index++)
this.content[index].Get_AllFontNames(AllFonts);
},
/// функции для работы с курсором
Get_ParaContentPosByXY: function(SearchPos, Depth, _CurLine, _CurRange, StepEnd)
......@@ -5062,25 +5003,24 @@ CMathContent.prototype =
SearchPos.Pos.Update( pos, Depth );
Depth++;
//ContentPos.Add(pos);
SearchPos.X -= this.WidthToElement[pos];
if(this.content[pos].typeObj == MATH_COMP)
if(this.content[pos].Type == para_Math_Composition)
{
SearchPos.Y -= this.size.ascent - this.content[pos].size.ascent;
this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
}
else if(this.content[pos].typeObj == MATH_PARA_RUN) // проверка на gaps в findDisposition
else if(this.content[pos].Type == para_Math_Run) // проверка на gaps в findDisposition
{
SearchPos.X += this.pos.x + this.ParaMath.X + this.WidthToElement[pos];
SearchPos.CurX += this.pos.x + this.WidthToElement[pos];
this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
}
else
/*else
{
this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth, _CurLine, _CurRange, StepEnd);
}
}*/
}
},
Get_ParaContentPos: function(bSelection, bStart, ContentPos)
......@@ -5102,17 +5042,13 @@ CMathContent.prototype =
Set_ParaContentPos: function(ContentPos, Depth)
{
this.CurPos = ContentPos.Get(Depth);
/*this.SelectStartPos = this.CurPos;
this.SelectEndPos = this.CurPos;*/
Depth++;
var curr = this.content[this.CurPos];
if(this.content.length > 0)
{
if(curr.typeObj == MATH_COMP || curr.typeObj == MATH_PARA_RUN)
curr.Set_ParaContentPos(ContentPos, Depth);
this.content[this.CurPos].Set_ParaContentPos(ContentPos, Depth);
}
},
......@@ -5245,9 +5181,9 @@ CMathContent.prototype =
{
for ( var i = 0; i < this.content.length; i++ )
{
var typeElem = this.content[i].typeObj;
//var typeElem = this.content[i].typeObj;
if( typeElem == MATH_COMP || typeElem == MATH_PARA_RUN)
//if( typeElem == MATH_COMP || typeElem == MATH_PARA_RUN)
this.content[i].Apply_TextPr( TextPr, IncFontSize, true );
}
}
......@@ -5265,28 +5201,38 @@ CMathContent.prototype =
StartPos = temp;
}
if ( StartPos === EndPos )
for(var i = StartPos; i <= EndPos; i++)
{
var elem = this.content[StartPos];
var elem = this.content[i];
if( elem.typeObj == MATH_COMP)
if( elem.Type == para_Math_Composition)
elem.Apply_TextPr( TextPr, IncFontSize, true );
else if(elem.typeObj == MATH_PARA_RUN)
else if(elem.Type == para_Math_Run)
elem.Apply_TextPr( TextPr, IncFontSize, false );
}
/*if ( StartPos === EndPos )
{
elem = this.content[StartPos];
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 );
}
else
{
for(var i = StartPos; i <= EndPos; i++)
{
var elem = this.content[i];
elem = this.content[i];
if( elem.typeObj == MATH_COMP)
if( elem.Type == para_Math_Composition)
elem.Apply_TextPr( TextPr, IncFontSize, true );
else if(elem.typeObj == MATH_PARA_RUN)
else if(elem.Type == para_Math_Run)
elem.Apply_TextPr( TextPr, IncFontSize, false );
}
}
}*/
}
else
{
......@@ -5298,10 +5244,11 @@ CMathContent.prototype =
{
return this.ParaMath.Get_Default_TPrp();
},
//////////////////////////////
// Перемещение по стрелкам
////////////////////
Get_LeftPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
old_Get_LeftPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
{
var CurPos = UseContentPos ? ContentPos.Get(Depth) : this.content.length-1;
......@@ -5350,7 +5297,56 @@ CMathContent.prototype =
return SearchPos.Found;
},
Get_RightPos: function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd, BegRun)
Get_LeftPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
{
var CurPos = UseContentPos ? ContentPos.Get(Depth) : this.content.length-1;
while(CurPos >= 0 && SearchPos.Found == false)
{
var curType = this.content[CurPos].Type,
prevType = CurPos > 0 ? this.content[CurPos - 1].Type : null;
/*if(curType == MATH_PLACEHOLDER)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else */
if(curType == para_Math_Composition)
{
var bNotshift = SearchPos.ForSelection == false,
bShiftCurrObj = (SearchPos.ForSelection == true && this.SelectStartPos == CurPos);
if( bNotshift || bShiftCurrObj )
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, UseContentPos, EndRun);
}
else if(EndRun)
{
SearchPos.Pos.Update(this.content[CurPos].Content.length, Depth + 1);
SearchPos.Found = true;
}
else
{
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, UseContentPos);
}
SearchPos.Pos.Update(CurPos, Depth);
// если перемещаемся между контентами мат объекта, то надо выставить курсор в конец следующего контента, в конечную позицию последнего рана
EndRun = (curType == para_Math_Run && prevType == para_Math_Run) ? false : true;
CurPos--;
UseContentPos = false;
}
/// для коррекции позиции курсора в начале Run
// используется функция Correct_ContentPos в Paragraph
return SearchPos.Found;
},
old_Get_RightPos: function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd, BegRun)
{
var CurPos = UseContentPos ? ContentPos.Get(Depth) : 0;
......@@ -5394,22 +5390,68 @@ CMathContent.prototype =
return SearchPos.Found;
},
Get_RightPos: function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd, BegRun)
{
var CurPos = UseContentPos ? ContentPos.Get(Depth) : 0;
while(CurPos < this.content.length && SearchPos.Found == false)
{
var curType = this.content[CurPos].Type,
nextType = CurPos < this.content.length - 1 ? this.content[CurPos + 1].Type : null;
/*if(curType == MATH_PLACEHOLDER)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else */
if(curType == para_Math_Composition)
{
var bNotshift = SearchPos.ForSelection == false,
bShiftCurrObj = SearchPos.ForSelection == true && this.SelectStartPos == CurPos;
if( bNotshift || bShiftCurrObj )
this.content[CurPos].Get_RightPos(SearchPos, ContentPos, Depth + 1, UseContentPos, StepEnd, BegRun);
}
else if(BegRun)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else
{
this.content[CurPos].Get_RightPos(SearchPos, ContentPos, Depth + 1, UseContentPos, StepEnd);
}
SearchPos.Pos.Update(CurPos, Depth);
// если перемещаемся между контентами мат объекта, то надо выставить курсор в начало следующего контента, в начальную позицию первого рана
BegRun = (curType == para_Math_Run && nextType == para_Math_Run) ? false : true;
CurPos++;
UseContentPos = false;
}
return SearchPos.Found;
},
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
{
var CurPos = UseContentPos ? ContentPos.Get(Depth) : this.content.length-1;
while(CurPos >= 0 && SearchPos.Found == false)
{
var curType = this.content[CurPos].typeObj,
prevType = CurPos > 0 ? this.content[CurPos - 1].typeObj : null;
var curType = this.content[CurPos].Type,
prevType = CurPos > 0 ? this.content[CurPos - 1].Type : null;
if(curType == MATH_PLACEHOLDER)
/*if(curType == MATH_PLACEHOLDER)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else if(curType == MATH_COMP)
else*/
if(curType == para_Math_Composition)
{
var bNotshift = SearchPos.ForSelection == false,
bShiftCurrObj = (SearchPos.ForSelection == true && this.SelectStartPos == CurPos);
......@@ -5436,7 +5478,7 @@ CMathContent.prototype =
SearchPos.Pos.Update(CurPos, Depth);
// если перемещаемся между контентами мат объекта, то надо выставить курсор в конец следующего контента, в конечную позицию последнего рана
EndRun = (curType == MATH_PARA_RUN && prevType == MATH_PARA_RUN) ? false : true;
EndRun = (curType == para_Math_Run && prevType == para_Math_Run) ? false : true;
CurPos--;
......@@ -5450,15 +5492,17 @@ CMathContent.prototype =
while(CurPos < this.content.length && SearchPos.Found == false)
{
var curType = this.content[CurPos].typeObj,
nextType = CurPos < this.content.length - 1 ? this.content[CurPos + 1].typeObj : null;
var curType = this.content[CurPos].Type,
nextType = CurPos < this.content.length - 1 ? this.content[CurPos + 1].Type : null;
if(curType == MATH_PLACEHOLDER)
/*if(curType == MATH_PLACEHOLDER)
{
SearchPos.Pos.Update(0, Depth + 1);
SearchPos.Found = true;
}
else if(curType == MATH_COMP)
else */
if(curType == para_Math_Composition)
{
var bNotshift = SearchPos.ForSelection == false,
bShiftCurrObj = SearchPos.ForSelection == true && this.SelectStartPos == CurPos;
......@@ -5485,7 +5529,7 @@ CMathContent.prototype =
SearchPos.Pos.Update(CurPos, Depth);
// если перемещаемся между контентами мат объекта, то надо выставить курсор в начало следующего контента, в начальную позицию первого рана
BegRun = (curType == MATH_PARA_RUN && nextType == MATH_PARA_RUN) ? false : true;
BegRun = (curType == para_Math_Run && nextType == para_Math_Run) ? false : true;
CurPos++;
......@@ -5544,7 +5588,7 @@ CMathContent.prototype =
for(var i = start; i <= end; i++)
{
var element;
if(this.content[i].typeObj == MATH_PARA_RUN)
if(this.content[i].Type == para_Math_Run)
element = this.content[i].Copy(Selected);
else
element = this.content[i].Copy(false);
......@@ -5560,12 +5604,12 @@ CMathContent.prototype =
var start = this.SelectStartPos,
end = this.SelectEndPos;
if(this.content[start].typeObj !== MATH_PLACEHOLDER)
//if(this.content[start].typeObj !== MATH_PLACEHOLDER)
this.content[start].Selection_Remove();
if(start !== end)
{
if(this.content[end].typeObj !== MATH_PLACEHOLDER)
//if(this.content[end].typeObj !== MATH_PLACEHOLDER)
this.content[end].Selection_Remove();
}
......@@ -5579,22 +5623,22 @@ CMathContent.prototype =
{
this.bSelectionUse = true;
if(this.content[this.CurPos].typeObj == MATH_PARA_RUN)
if(this.content[this.CurPos].Type == para_Math_Run)
{
if(Direction < 0 && this.CurPos > 0 && this.content[this.CurPos - 1].typeObj == MATH_COMP)
if(Direction < 0 && this.CurPos > 0 && this.content[this.CurPos - 1].Type == para_Math_Composition)
{
this.SelectStartPos = this.SelectEndPos = this.CurPos - 1;
this.content[this.CurPos - 1].SetSelectAll();
}
else if(this.CurPos < this.content.length - 1 && this.content[this.CurPos + 1].typeObj == MATH_COMP)
else if(this.CurPos < this.content.length - 1 && this.content[this.CurPos + 1].Type == para_Math_Composition)
{
this.SelectStartPos = this.SelectEndPos = this.CurPos + 1;
this.content[this.CurPos + 1].SetSelectAll();
}
}
else if(this.content[this.CurPos].typeObj == MATH_COMP)
else if(this.content[this.CurPos].Type == para_Math_Composition)
{
if(this.content[this.CurPos].IsCurrentPlh())
if(this.content[this.CurPos].IsPlaceholder())
{
this.SelectStartPos = this.SelectEndPos = this.CurPos;
this.content[this.CurPos].SetSelectAll();
......
......@@ -62,28 +62,20 @@ function CMathPosition()
function CMathText(bJDraw)
{
this.typeObj = MATH_TEXT;
// для Para_Run
this.Type = para_Math_Text;
this.bJDraw = bJDraw;
this.size = null;
this.value = null;
this.pos = new CMathPosition();
// if(bJDraw === false || bJDraw === true)
// this.bJDraw = bJDraw;
this.type = TXT_ROMAN;
this.rasterOffsetX = 0;
this.rasterOffsetY = 0;
this.GapLeft = 0;
this.GapRight = 0;
this.WidthVisible = 0;
// для Para_Run
this.Type = para_Math_Text;
// TO DO
// убрать
......@@ -117,19 +109,21 @@ CMathText.prototype =
{
var code = this.value;
if(this.typeObj === MATH_PLACEHOLDER || this.bJDraw)
if(this.Type === para_Math_Placeholder || this.bJDraw)
return code;
var bCapitale = (code > 0x0040 && code < 0x005B),
bSmall = (code > 0x0060 && code < 0x007b);
bSmall = (code > 0x0060 && code < 0x007b),
bDigit = (code > 0x002F && code < 0x003A);
var Type = this.Parent.Math_GetTypeText();
var Scr = this.Parent.Math_GetTypeText();
// Mathematical Alphanumeric Characters
// http://www.w3.org/TR/2014/REC-xml-entity-names-20140410/Overview.html#alphabets
if(Type == TXT_ROMAN )
if(Scr == TXT_ROMAN)
{
var bDigit = (code > 0x002F && code < 0x003A),
bCapGreek = (code > 0x0390 && code < 0x03AA ),
var bCapGreek = (code > 0x0390 && code < 0x03AA ),
bSmallGreek = (code > 0x03B0 && code < 0x03CA);
if(code == 0x68) // h
......@@ -138,91 +132,172 @@ CMathText.prototype =
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(Type == TXT_DOUBLE_STRUCK)
else if(Scr == TXT_DOUBLE_STRUCK)
{
if(code == 0x43)
if(code == 0x43) // C
code = 0x2102;
else if(code == 0x48)
else if(code == 0x48) // H
code = 0x210D;
else if(code == 0x4E)
else if(code == 0x4E) // N
code = 0x2115;
else if(code == 0x50)
else if(code == 0x50) // P
code = 0x2119;
else if(code == 0x51)
else if(code == 0x51) // Q
code = 0x211A;
else if(code == 0x52)
else if(code == 0x52) // R
code = 0x211D;
else if(code == 0x5A)
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(Type == TXT_MONOSPACE)
else if(Scr == TXT_MONOSPACE)
{
if(bCapitale)
code = code + 0x1D62F;
else if(bSmall)
code = code + 0x1D629;
else if(bDigit)
code = code + 0x1D7C6;
}
else if(Type == TXT_FRAKTUR)
else if(Scr == TXT_FRAKTUR)
{
if(code == 0x43)
if(code == 0x43) // C
code = 0x212D;
else if(code == 0x48)
else if(code == 0x48) // H
code = 0x210C;
else if(code == 0x49)
else if(code == 0x49) // I
code = 0x2111;
else if(code == 0x52)
else if(code == 0x52) // R
code = 0x211C;
else if(code == 0x5A)
else if(code == 0x5A) // Z
code = 0x2128;
else if(bCapitale)
code = code + 0x1D4C3;
else if(bSmall)
code = code + 0x1D4BD;
}
else if(Type == TXT_SANS_SERIF)
else if(Scr == TXT_SANS_SERIF)
{
if(bCapitale)
code = code + 0x1D5C7;
else if(bSmall)
code = code + 0x1D5C1;
else if(bDigit)
code = code + 0x1D7B2;
}
else if(Type == TXT_SCRIPT)
else if(Scr == TXT_SCRIPT)
{
if(code == 0x42)
if(code == 0x42) // B
code = 0x212C;
else if(code == 0x45)
else if(code == 0x45) // E
code = 0x2130;
else if(code == 0x46)
else if(code == 0x46) // F
code = 0x2131;
else if(code == 0x48)
else if(code == 0x48) // H
code = 0x210B;
else if(code == 0x49)
else if(code == 0x49) // I
code = 0x2110;
else if(code == 0x4C)
else if(code == 0x4C) // L
code = 0x2112;
else if(code == 0x4D)
else if(code == 0x4D) // M
code = 0x2133;
else if(code == 0x52)
else if(code == 0x52) // R
code = 0x211B;
else if(code == 0x65)
else if(code == 0x65) // e
code = 0x212F;
else if(code == 0x67)
else if(code == 0x67) // g
code = 0x210A;
else if(code == 0x6F)
else if(code == 0x6F) // o
code = 0x2134;
else if(bCapitale)
code = code + 0x1D45B;
......@@ -238,7 +313,7 @@ CMathText.prototype =
},
fillPlaceholders: function()
{
this.typeObj = MATH_PLACEHOLDER;
this.Type = para_Math_Placeholder;
this.value = StartTextElement;
},
Resize: function(Run, oMeasure)
......@@ -376,7 +451,7 @@ CMathText.prototype =
{
this.Parent = parent;
},
IsIncline: function()
/*IsIncline: function()
{
// возвращаем не Italic, т.к. могут быть мат. текст, но буквы без наклона (placeholder и т.п.)
......@@ -394,12 +469,11 @@ CMathText.prototype =
setJustDraw: function(bJustDraw)
{
this.bJDraw = bJustDraw;
},
SetTypeText: function(type)
},*/
IsPlaceholder: function()
{
this.type = type;
return this.Type == para_Math_Placeholder;
},
// For ParaRun
Is_Punctuation: function()
{
......
......@@ -684,7 +684,7 @@ function CNaryOperator(flip)
}
CNaryOperator.prototype.draw = function(x, y, pGraphics)
{
if(this.typeObj == MATH_TEXT)
if(this.Type == para_Math_Text)
this.drawTextElem(x, y, pGraphics);
else
this.drawGlyph(x, y, pGraphics);
......
......@@ -2867,7 +2867,7 @@ COperator.prototype.getProps = function(props, defaultProps)
//var code = bCode ? chr.charCodeAt(0) : null;
if(bDelimiter && bUnicodeChr == -1) // empty operator
if(bDelimiter && props.chr == -1) // empty operator
{
type = OPERATOR_EMPTY;
}
......
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