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

Для совместного редактирования :

1. ссылка на родительский класс и ссылка на ParaMath прокидываются каждый раз на Resize
2. ctrPrp мержатся на Resize (при изменении ctrPrp)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56239 954022d7-b5bf-4e40-9824-e11837661b57
parent 7267c0f2
......@@ -13,7 +13,7 @@ function ParaMath(bAddMenu)
//this.Root = this.Math.Root;
this.Root = new CMathContent();
this.Root.setComposition(this);
//this.Root.setComposition(this);
this.X = 0;
this.Y = 0;
......@@ -35,6 +35,8 @@ function ParaMath(bAddMenu)
this.Range = this.Lines[0].Ranges[0];
this.NearPosArray = new Array();
this.Width = 0;
this.WidthVisible = 0;
this.Height = 0;
......@@ -352,7 +354,7 @@ ParaMath.prototype =
{
// TODO: ParaMath.Apply_TextPr
this.Root.Apply_TextPr();
this.Root.Apply_TextPr(TextPr, IncFontSize, ApplyToAll);
},
......@@ -363,6 +365,16 @@ ParaMath.prototype =
Check_NearestPos : function(ParaNearPos, Depth)
{
var MathNearPos = new CParagraphElementNearPos();
MathNearPos.NearPos = ParaNearPos.NearPos;
MathNearPos.Depth = Depth;
// CParagraphNearPos for ParaNearPos
this.NearPosArray.push( MathNearPos );
ParaNearPos.Classes.push( this );
var CurPos = ParaNearPos.NearPos.ContentPos.Get(Depth);
this.Content[CurPos].Check_NearestPos( ParaNearPos, Depth + 1 );
},
Get_DrawingObjectRun : function(Id)
......@@ -395,6 +407,9 @@ ParaMath.prototype =
Create_FontMap : function(Map)
{
// TODO: ParaMath.Create_FontMap
this.Root.Create_FontMap(Map);
},
Get_AllFontNames : function(AllFonts)
......@@ -429,7 +444,11 @@ ParaMath.prototype =
{
if ( true === DropCapText.Check )
DropCapText.Mixed = true;
},
},
Add_ToContent : function(Pos, Item, UpdatePosition)
{
},
//-----------------------------------------------------------------------------------
// Функции пересчета
//-----------------------------------------------------------------------------------
......@@ -464,7 +483,7 @@ ParaMath.prototype =
//this.Math.RecalculateComposition(g_oTextMeasurer, TextPr);
this.Root.Resize(g_oTextMeasurer, TextPr);
this.Root.Resize(null, this, g_oTextMeasurer, TextPr);
this.Root.setPosition({x: 0, y: 0});
this.Width = this.Root.size.width;
......@@ -1047,7 +1066,7 @@ ParaMath.prototype =
this.bSelectionUse = true;
this.Root.Set_Select_ToMComp(Direction);
console.log("bSelectionUse : " + this.bSelectionUse);
//console.log("bSelectionUse : " + this.bSelectionUse);
},
//-----------------------------------------------------------------------------------
// Функции отрисовки
......@@ -1272,27 +1291,43 @@ ParaMath.prototype =
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
{
// TODO: ParaMath.Get_StartEndPos
this.Root.Get_WordStartPos(SearchPos, ContentPos, Depth, UseContentPos);
},
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd)
{
// TODO: ParaMath.Get_WordEndPos
this.Root.Get_WordEndPos(SearchPos, ContentPos, Depth, UseContentPos, StepEnd);
},
Get_EndRangePos : function(_CurLine, _CurRange, SearchPos, Depth)
{
// TODO: ParaMath.Get_EndRangePos
// Сделать для случая, когда формула будет занимать несколько строк
this.Root.Get_EndPos(false, SearchPos, Depth);
},
Get_StartRangePos : function(_CurLine, _CurRange, SearchPos, Depth)
{
// TODO: ParaMath.Get_StartRangePos
// Сделать для случая, когда формула будет занимать несколько строк, переделать
this.Root.Get_StartPos(SearchPos, Depth);
},
Get_StartRangePos2 : function(_CurLine, _CurRange, ContentPos, Depth)
{
// TODO: ParaMath.Get_StartRangePos2
// Сделать для случая, когда формула будет занимать несколько строк, переделать
this.Root.Get_StartPos(ContentPos, Depth);
},
Get_StartPos : function(ContentPos, Depth)
......
......@@ -4293,7 +4293,7 @@ ParaRun.prototype =
TextPr.Merge(MPrp); // bold, italic
}
this.Parent.Composition.ApplyArgSize(TextPr);
this.Parent.ParaMath.ApplyArgSize(TextPr);
}
else
TextPr.Merge( this.Pr ); // Мержим прямые настройки данного рана
......@@ -4553,6 +4553,14 @@ 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 );
......@@ -7004,8 +7012,7 @@ CRunCollaborativeMarks.prototype =
{
this.Ranges.splice( Index, 1 );
Len--;
Index--;
continue;
Index--;continue;
}
else
{
......@@ -7090,12 +7097,14 @@ ParaRun.prototype.Math_Draw = function(x, y, pGraphics)
}
}
ParaRun.prototype.Math_Recalculate = function(RecalcInfo)
ParaRun.prototype.Math_Recalculate = function(Parent, Paragraph, oMeasure, RecalcInfo)
{
var RangeStartPos = 0;
var RangeEndPos = this.Content.length;
this.Parent = RecalcInfo.Parent;
this.Paragraph = Paragraph;
this.Parent = Parent;
// обновляем позиции start и end для Range
this.Lines[0].Add_Range(0, RangeStartPos, RangeEndPos);
......@@ -7120,8 +7129,7 @@ ParaRun.prototype.Math_Recalculate = function(RecalcInfo)
RecalcInfo.Current = this.Content[Pos];
RecalcInfo.setGaps();
this.Content[Pos].relate(this);
this.Content[Pos].Resize(g_oTextMeasurer);
this.Content[Pos].Resize(this, oMeasure);
var oSize = this.Content[Pos].size;
width += oSize.width;
......
......@@ -26,7 +26,7 @@ CCircumflex.prototype.init = function(props)
}
CCircumflex.prototype.fixSize = function(oMeasure, stretch, bIncl)
{
var alpha = this.Parent.getCtrPrp().FontSize/36;
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var width = 3.88*alpha;
var height = 3.175*alpha;
......@@ -78,7 +78,7 @@ CCircumflex.prototype.draw = function(x, y, pGraphics)
var xx = this.pos.x + x,
yy = this.pos.y + y;
var fontSize = this.Parent.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
penW *= 96/25.4;
......@@ -190,7 +190,7 @@ function CAccentCircumflex()
extend(CAccentCircumflex, CGlyphOperator);
CAccentCircumflex.prototype.calcSize = function(stretch)
{
var alpha = this.getCtrPrp().FontSize/36;
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var width = 3.88*alpha;
var height = 3.175*alpha;
......@@ -208,7 +208,7 @@ CAccentCircumflex.prototype.calcSize = function(stretch)
}
CAccentCircumflex.prototype.calcCoord = function(stretch)
{
var fontSize = this.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
//var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
//penW *= 96/25.4;
......@@ -297,7 +297,7 @@ CLine.prototype.init = function(props)
}
CLine.prototype.fixSize = function(oMeasure, stretch)
{
var alpha = this.Parent.getCtrPrp().FontSize/36;
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var height = 1.68*alpha;
var width = 4.938*alpha;
......@@ -308,7 +308,7 @@ CLine.prototype.fixSize = function(oMeasure, stretch)
}
CLine.prototype.draw = function(x, y, pGraphics)
{
var fontSize = this.Parent.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
//penW *= 96/25.4;
......@@ -348,7 +348,7 @@ function CAccentLine()
extend(CAccentLine, CGlyphOperator);
CAccentLine.prototype.calcSize = function(stretch)
{
var alpha = this.Parent.getCtrPrp().FontSize/36;
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var height = 1.68*alpha;
var width = 4.938*alpha;
......@@ -359,7 +359,7 @@ CAccentLine.prototype.calcSize = function(stretch)
}
CAccentLine.prototype.calcCoord = function(stretch)
{
var fontSize = this.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var X = new Array(),
Y = new Array();
......@@ -395,7 +395,7 @@ CDoubleLine.prototype.init = function(props)
}
CDoubleLine.prototype.fixSize = function(oMeasure, stretch)
{
var alpha = this.Parent.getCtrPrp().FontSize/36;
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var height = 2.843*alpha;
var width = 4.938*alpha;
......@@ -410,7 +410,7 @@ CDoubleLine.prototype.setPosition = function(pos)
}
CDoubleLine.prototype.draw = function(x, y, pGraphics)
{
var fontSize = this.Parent.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var penW = fontSize*g_dKoef_pt_to_mm*this.PEN_W;
//penW *= 96/25.4;
......@@ -448,7 +448,7 @@ function CAccentDoubleLine()
extend(CAccentDoubleLine, CGlyphOperator);
CAccentDoubleLine.prototype.calcSize = function(stretch)
{
var alpha = this.getCtrPrp().FontSize/36;
var alpha = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var height = 2.843*alpha;
var width = 4.938*alpha;
......@@ -459,7 +459,7 @@ CAccentDoubleLine.prototype.calcSize = function(stretch)
}
CAccentDoubleLine.prototype.calcCoord = function(stretch)
{
var fontSize = this.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var X = new Array(),
Y = new Array();
......@@ -508,7 +508,7 @@ CTilde.prototype.init = function(props)
}
CTilde.prototype.fixSize = function()
{
var betta = this.Parent.getCtrPrp().FontSize/36;
var betta = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var width = 9.047509765625*betta; // реальная на отрисовке width 7.495282031249999
var height = 2.469444444444444*betta;
......@@ -552,7 +552,7 @@ CTilde.prototype.draw = function(x, y, pGraphics)
var XX = new Array(),
YY = new Array();
var fontSize = this.Parent.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var textScale = fontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96
......@@ -614,7 +614,7 @@ function CAccentTilde()
extend(CAccentTilde, CGlyphOperator);
CAccentTilde.prototype.calcSize = function(stretch)
{
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var width = 9.047509765625*betta; // реальная на отрисовке width 7.495282031249999
var height = 2.469444444444444*betta;
......@@ -658,7 +658,7 @@ CAccentTilde.prototype.calcCoord = function(stretch)
var XX = new Array(),
YY = new Array();
var fontSize = this.Parent.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var textScale = fontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96
......@@ -703,7 +703,7 @@ CBreve.prototype.init = function(props)
}
CBreve.prototype.fixSize = function()
{
var betta = this.Parent.getCtrPrp().FontSize/36;
var betta = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var width = 4.2333333333333325*betta;
var height = 2.469444444444445*betta;
......@@ -747,7 +747,7 @@ CBreve.prototype.draw = function(x, y, pGraphics)
var XX = new Array(),
YY = new Array();
var fontSize = this.Parent.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var textScale = fontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96
......@@ -816,7 +816,7 @@ function CAccentBreve()
extend(CAccentBreve, CGlyphOperator);
CAccentBreve.prototype.calcSize = function(stretch)
{
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Parent.Get_CompiledCtrPrp().FontSize/36;
var width = 4.2333333333333325*betta;
var height = 2.469444444444445*betta;
......@@ -856,7 +856,7 @@ CAccentBreve.prototype.calcCoord = function(stretch)
var XX = new Array(),
YY = new Array();
var fontSize = this.getCtrPrp().FontSize;
var fontSize = this.Parent.Get_CompiledCtrPrp().FontSize;
var textScale = fontSize/1000, // 1000 pt
alpha = textScale*25.4/96 /64 ; // g_dKoef_px_to_mm = 25.4/96
......@@ -961,10 +961,10 @@ CSign.prototype.setPosition = function(pos)
}*/
CSign.prototype.fixSize = function(oMeasure, stretch, bIncline)
{
var ctrPrp = this.Parent.getCtrPrp();
var ctrPrp = this.Parent.Get_CompiledCtrPrp();
var rPrp = new CTextPr();
var defaultRPrp = this.Parent.Composition.Get_Default_TPrp();
var defaultRPrp = this.Parent.ParaMath.Get_Default_TPrp();
rPrp.Merge(defaultRPrp);
rPrp.Merge(ctrPrp);
rPrp.Italic = false; // не меняем значок
......@@ -972,7 +972,7 @@ CSign.prototype.fixSize = function(oMeasure, stretch, bIncline)
oMeasure.SetFont(rPrp);
this.sign.Resize(oMeasure);
this.sign.Resize(this, oMeasure);
/*if(this.typeOper == ACCENT_THREE_DOTS)
this.dH = 1.2*ctrPrp.FontSize/36;
......@@ -1604,25 +1604,34 @@ CAccent.prototype.getPropsForWrite = function()
return props;
}
CAccent.prototype.Resize = function(oMeasure)
CAccent.prototype.Resize = function(Parent, ParaMath, oMeasure)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.RecalcInfo.bCtrPrp == true)
{
this.Set_CompiledCtrPrp();
this.RecalcInfo.bCtrPrp = false;
}
var base = this.elements[0][0];
base.Resize(oMeasure);
base.Resize(this, ParaMath, oMeasure);
this.operator.fixSize(oMeasure, base.size.width);
var ctrPrp = this.Get_CompiledCtrPrp();
oMeasure.SetFont(ctrPrp);
this.operator.fixSize(ParaMath, oMeasure, base.size.width);
var letterX = new CMathText(true);
letterX.add(0x78);
letterX.Resize(oMeasure);
letterX.Resize(null, oMeasure);
this.shiftX = base.size.ascent - letterX.size.ascent;
var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width,
height = base.size.height + this.operator.size.height + this.shiftX,
ascent = this.getAscent(oMeasure);
var ctrPrp = this.mergeCtrTPrp();
oMeasure.SetFont(ctrPrp);
this.size = {height: height, width: width, ascent: ascent};
}
CAccent.prototype.getBase = function()
......@@ -1633,8 +1642,8 @@ CAccent.prototype.draw = function(x, y, pGraphics)
{
this.elements[0][0].draw(x, y, pGraphics);
var mgCtrPrp = this.mergeCtrTPrp();
var FontSize = mgCtrPrp.FontSize,
var MergedCtrPrp = this.Get_CompiledCtrPrp();
var FontSize = MergedCtrPrp.FontSize,
FontFamily = {Name: "Cambria Math", Index: -1};
var obj = {FontSize: FontSize, FontFamily: FontFamily};
......
......@@ -12,9 +12,10 @@ function CMathBase()
// Properties
this.argSize = 0;
this.Parent = null;
this.Composition = null; // ссылка на общую формулу
this.ParaMath = null; // ссылка на общую формулу
this.CtrPrp = new CTextPr();
this.CompiledCtrPrp = new CTextPr();
/////////////////
//this.RunPrp = new CMathRunPrp();
......@@ -23,11 +24,11 @@ function CMathBase()
this.CurPos_Y = 0;
this.selectPos =
/*this.selectPos =
{
startX: 0,
startY: 0
};
};*/
this.SelectStart_X = 0;
this.SelectStart_Y = 0;
......@@ -58,6 +59,11 @@ function CMathBase()
this.GapLeft = 0;
this.GapRight = 0;
this.RecalcInfo =
{
bCtrPrp: true
};
return this;
}
CMathBase.prototype =
......@@ -72,12 +78,8 @@ CMathBase.prototype =
for(var j = 0; j < this.nCol; j++)
{
this.elements[i][j] = new CMathContent();
this.elements[i][j].relate(this);
this.elements[i][j].setComposition(this.Composition);
/*if( !this.elements[i][j].IsJustDraw())
this.elements[i][j].setComposition(this.Composition);*/
//this.elements[i][j].setTxtPrp(this.TxtPrp);
//this.elements[i][j].setRunPrp(this.RunPrp);
//this.elements[i][j].relate(this);
//this.elements[i][j].setComposition(this.Composition);
}
}
},
......@@ -96,33 +98,35 @@ CMathBase.prototype =
this.alignment.wdt[u] = CENTER;
},
///////// RunPrp, CtrPrp
setCtrPrp: function(txtPrp)
setCtrPrp: function(txtPrp) // выставляем ctrPrp на чтение
{
this.CtrPrp.Merge(txtPrp); // only runPrp for paragraph
this.CtrPrp.Merge(txtPrp);
//this.RunPrp.setTxtPrp(txtPrp);
},
getCtrPrp: function()
Get_CtrPrp: function()
{
var ctrPrp = new CTextPr();
var defaultRPrp = this.Composition.GetFirstRPrp();
//var gWPrp = defaultRPrp.getMergedWPrp();
ctrPrp.Merge(defaultRPrp);
ctrPrp.Merge(this.CtrPrp);
return ctrPrp;
return this.CtrPrp.Copy();
},
Set_CompiledCtrPrp: function()
{
var defaultRPrp = this.ParaMath.GetFirstRPrp();
this.CompiledCtrPrp.Merge(defaultRPrp);
this.CompiledCtrPrp.Merge(this.CtrPrp);
},
getRunPrp: function()
Get_CompiledCtrPrp: function()
{
var runPrp = new CMathRunPrp();
var defaultRPrp = this.Composition.GetFirstRPrp();
runPrp.Merge(defaultRPrp);
runPrp.Merge(this.RunPrp);
var CompiledCtrPrp = this.CompiledCtrPrp.Copy();
this.ParaMath.ApplyArgSize(CompiledCtrPrp);
return runPrp;
return CompiledCtrPrp;
},
// TO DO
// пересмотреть
getCtrPrpForFirst: function()
{
var ctrPrp = new CTextPr();
var defaultRPrp = this.Composition.Get_Default_TPrp();
var defaultRPrp = this.ParaMath.Get_Default_TPrp();
//var gWPrp = defaultRPrp.getMergedWPrp();
ctrPrp.Merge(defaultRPrp);
ctrPrp.Merge(this.CtrPrp);
......@@ -134,7 +138,7 @@ CMathBase.prototype =
getPrpToControlLetter: function()
{
var rPrp = new CTextPr();
rPrp.Merge( this.Composition.GetFirstRPrp() );
rPrp.Merge( this.ParaMath.GetFirstRPrp() );
return rPrp;
},
......@@ -184,23 +188,23 @@ CMathBase.prototype =
},
// TO DO
// посмотреть для всех мат. объектов, где используется эта функция
mergeCtrTPrp: function()
/*Get_FullCtrPrp: function() // учитываем ArgSize
{
var tPrp = this.getCtrPrp();
this.Composition.ApplyArgSize(tPrp);
var tPrp = this.Get_CompiledCtrPrp(true);
this.ParaMath.ApplyArgSize(tPrp);
/*if(this.argSize == -1)
*//*if(this.argSize == -1)
//tPrp.FontSize *= 0.8;
tPrp.FontSize *= 0.728;
else if(this.argSize == -2)
//tPrp.FontSize *= 0.65;
tPrp.FontSize *= 0.53;*/
tPrp.FontSize *= 0.53;*//*
return tPrp;
},
},*/
/////////
setComposition: function(Composition)
/*setComposition: function(Composition)
{
this.Composition = Composition;
......@@ -215,7 +219,7 @@ CMathBase.prototype =
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].setReferenceComposition(Comp);
},
},*/
/*old_getTxtPrp: function()
{
var txtPrp = new CMathTextPrp();
......@@ -288,11 +292,8 @@ CMathBase.prototype =
for(var j = 0; j < this.nCol; j++)
{
this.elements[i][j] = arguments[j + i*this.nCol];
this.elements[i][j].relate(this);
this.elements[i][j].setComposition(this.Composition);
/*if( !this.elements[i][j].IsJustDraw())
this.elements[i][j].setComposition(this.Composition);*/
//this.elements[i][j].setTxtPrp(this.getTxtPrp());
//this.elements[i][j].relate(this);
//this.elements[i][j].setComposition(this.Composition);
this.elements[i][j].bMObjs = true;
}
}
......@@ -302,10 +303,10 @@ CMathBase.prototype =
this.setContent();
}
},
relate: function(parent)
/*relate: function(parent)
{
this.Parent = parent;
},
},*/
old_cursor_moveLeft: function()
{
var bUpperLevel = false;
......@@ -983,11 +984,20 @@ CMathBase.prototype =
this.recalculateSize();
this.Parent.RecalculateReverse(oMeasure);
},*/
Resize: function(oMeasure)
Resize: function(Parent, ParaMath, oMeasure)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.RecalcInfo.bCtrPrp == true)
{
this.Set_CompiledCtrPrp();
this.RecalcInfo.bCtrPrp = false;
}
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
this.elements[i][j].Resize(oMeasure);
this.elements[i][j].Resize(this, ParaMath, oMeasure);
this.recalculateSize(oMeasure); // передаем oMeasure, для
},
......@@ -1012,8 +1022,8 @@ CMathBase.prototype =
{
Ascent = _height || this.size.height;
Ascent /=2;
var mgCtrPrp = this.mergeCtrTPrp();
Ascent += this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var MergedCtrPrp = this.Get_CompiledCtrPrp();
Ascent += this.ParaMath.GetShiftCenter(oMeasure, MergedCtrPrp);
}
else
for(var i=0; i< this.nCol; i++)
......@@ -1438,6 +1448,9 @@ CMathBase.prototype =
this.bSelectionUse = false;
},
// Перемещение по стрелкам
Get_LeftPos: function(SearchPos, ContentPos, Depth, UseContentPos, EndRun)
{
var CurPos_X, CurPos_Y;
......@@ -1463,7 +1476,7 @@ CMathBase.prototype =
var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(),
usePlh = !bJDraw && bUseContent && this.elements[CurPos_X][CurPos_Y].IsPlaceholder();
if(!bJDraw && ! usePlh)
if(!bJDraw && !usePlh)
{
this.elements[CurPos_X][CurPos_Y].Get_LeftPos(SearchPos, ContentPos, Depth + 2, bUseContent, EndRun);
SearchPos.Pos.Update(CurPos_X, Depth);
......@@ -1545,15 +1558,61 @@ CMathBase.prototype =
return result;
},
IsPlaceholder: function()
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
{
return false;
var CurPos_X, CurPos_Y;
if(UseContentPos === true)
{
CurPos_X = ContentPos.Get(Depth);
CurPos_Y = ContentPos.Get(Depth + 1);
}
else
{
CurPos_X = this.nRow - 1;
CurPos_Y = this.nCol - 1;
}
this.elements[CurPos_X][CurPos_Y].Get_WordStartPos(SearchPos, ContentPos, Depth + 2, UseContentPos);
while(CurPos_X >= 0)
{
var bJDraw = this.elements[CurPos_X][CurPos_Y].IsJustDraw(),
usePlh = !bJDraw && UseContentPos && this.elements[CurPos_X][CurPos_Y].IsPlaceholder(); // при первом проходе на плейсхолдере Get_WordStartPos не произойдет (если UseContentPos = true)
// на втором проходе UseContentPos = false
if(!bJDraw && !usePlh)
{
this.elements[CurPos_X][CurPos_Y].Get_WordStartPos(SearchPos, ContentPos, Depth + 2, UseContentPos);
SearchPos.Pos.Update(CurPos_X, Depth);
SearchPos.Pos.Update(CurPos_Y, Depth+1);
}
if(SearchPos.Found === true)
break;
UseContentPos = false;
CurPos_Y--;
if(CurPos_Y < 0)
{
CurPos_X--;
CurPos_Y = this.nCol - 1;
}
}
},
Get_TxtPrp: function()
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd)
{
return this.getCtrPrp();
},
Copy: function(Selected, Composition)
//////////////////////////////////
IsPlaceholder: function()
{
return false;
},
Copy: function(Selected)
{
var props = this.getPropsForWrite();
......@@ -1561,7 +1620,7 @@ CMathBase.prototype =
NewObj.init(props);
NewObj.argSize = this.argSize;
NewObj.Composition = Composition;
//NewObj.Composition = Composition;
var CtrPrp = this.CtrPrp.Copy();
NewObj.setCtrPrp(CtrPrp);
......@@ -1569,10 +1628,7 @@ CMathBase.prototype =
for(var i=0; i < this.nRow; i++)
for(var j = 0; j < this.nCol; j++)
{
NewObj.elements[i][j] = this.elements[i][j].Copy(Selected, Composition);
NewObj.elements[i][j].argSize = this.elements[i][j].argSize;
NewObj.elements[i][j].relate(NewObj);
NewObj.elements[i][j] = this.elements[i][j].Copy(Selected);
}
return NewObj;
......@@ -1627,6 +1683,19 @@ CMathBase.prototype =
{
return this.Get_CompiledTextPr(Copy);
},
Apply_TextPr: function(TextPr, IncFontSize, ApplyToAll)
{
this.CtrPrp.Merge(TextPr);
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].Apply_TextPr(TextPr, IncFontSize, ApplyToAll);
}
}
},
Set_Select_ToMComp: function(Direction)
{
this.SelectStart_X = this.SelectEnd_X = this.CurPos_X;
......@@ -1642,6 +1711,34 @@ CMathBase.prototype =
this.SelectEnd_X = this.nRow - 1;
this.SelectEnd_Y = this.nCol - 1;
},
Check_NearestPos: function(ParaNearPos, Depth)
{
var ContentNearPos = new CParagraphElementNearPos();
ContentNearPos.NearPos = ParaNearPos.NearPos;
ContentNearPos.Depth = Depth;
// CParagraphNearPos for ParaNearPos
this.NearPosArray.push( ContentNearPos );
ParaNearPos.Classes.push( this );
var CurPos_X = ParaNearPos.NearPos.ContentPos.Get(Depth),
CurPos_Y = ParaNearPos.NearPos.ContentPos.Get(Depth + 1);
this.Content[CurPos_X][CurPos_Y].Check_NearestPos( ParaNearPos, Depth + 2 );
},
Create_FontMap : function(Map)
{
var CtrPrp = this.Get_CompiledCtrPrp(false);
CtrPrp.Document_CreateFontMap( Map, this.ParaMath.Paragraph.Get_Theme().themeElements.fontScheme);
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].Create_FontMap( Map );
}
}
//////////////////////////
......
......@@ -75,7 +75,7 @@ CBorderBox.prototype.recalculateSize = function()
var height = base.height;
var ascent = base.ascent;
this.gapBrd = this.getCtrPrp().FontSize*0.08104587131076388;
this.gapBrd = this.Get_CompiledCtrPrp().FontSize*0.08104587131076388;
if(this.bTop)
{
......@@ -97,8 +97,8 @@ CBorderBox.prototype.recalculateSize = function()
CBorderBox.prototype.draw = function(x, y, pGraphics)
{
this.elements[0][0].draw(x, y, pGraphics);
//var penW = this.getCtrPrp().FontSize* 25.4/72 * 0.06 ;
var penW = this.getCtrPrp().FontSize*0.02;
//var penW = this.Get_CompiledCtrPrp().FontSize* 25.4/72 * 0.06 ;
var penW = this.Get_CompiledCtrPrp().FontSize*0.02;
if(this.bTop)
{
......
......@@ -68,7 +68,7 @@ CDegree.prototype.old__recalculateSup = function(oMeasure)
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var height = 0,
......@@ -109,12 +109,12 @@ CDegree.prototype.old_recalculateSubScript = function(oMeasure)
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
/*var FontSize = this.getCtrPrp().FontSize,
/*var FontSize = this.Get_CompiledCtrPrp().FontSize,
shiftCenter = 0.5*DIV_CENT*FontSize;*/
//var ctrPrp = this.getCtrPrp(); // выставить потом размер шрифта для итератора
//var ctrPrp = this.Get_CompiledCtrPrp(); // выставить потом размер шрифта для итератора
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var width = base.width + iter.width + this.dW;
......@@ -143,8 +143,8 @@ CDegree.prototype.recalculateSup = function(oMeasure)
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var mgCtrPrp = this.mergeCtrTPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
this.upBase = 0;
this.upIter = 0;
......@@ -192,8 +192,8 @@ CDegree.prototype.recalculateSubScript = function(oMeasure)
var base = this.elements[0][0].size,
iter = this.elements[0][1].size;
var mgCtrPrp = this.mergeCtrTPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var width = base.width + iter.width + this.dW;
width += this.GapLeft + this.GapRight;
......@@ -541,7 +541,7 @@ CIterators.prototype.old_old_setDistanceIters = function(oMeasure)
var upIter = this.elements[0][0].size,
lowIter = this.elements[1][0].size;
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
......@@ -580,7 +580,7 @@ CIterators.prototype.old_setDistanceIters = function(oMeasure)
var upIter = this.elements[0][0].size,
lowIter = this.elements[1][0].size;
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
......@@ -620,7 +620,7 @@ CIterators.prototype._setDistanceIters = function(oMeasure)
var upIter = this.elements[0][0].size,
lowIter = this.elements[1][0].size;
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
......@@ -649,9 +649,9 @@ CIterators.prototype.getLowerIterator = function()
{
return this.elements[1][0];
}
CIterators.prototype.getCtrPrp = function()
CIterators.prototype.Get_CompiledCtrPrp = function()
{
return this.Parent.getCtrPrp();
return this.Parent.Get_CompiledCtrPrp();
}
CIterators.prototype.Save_Changes = function(Data, Writer)
{
......@@ -777,7 +777,7 @@ CDegreeSubSup.prototype.init = function(props)
}*/
CDegreeSubSup.prototype.old_old_recalculateSize = function(oMeasure)
{
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
shCenter *= 1.2;
......@@ -820,7 +820,7 @@ CDegreeSubSup.prototype.old_old_recalculateSize = function(oMeasure)
}
CDegreeSubSup.prototype.old_recalculateSize = function(oMeasure)
{
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
shCenter *= 1.2;
......@@ -849,7 +849,7 @@ CDegreeSubSup.prototype.old_recalculateSize = function(oMeasure)
var lUp = base.size.ascent - shCenter; // center of base
var lDown = base.size.height - lUp; // height - center of base
var ctrPrpIter = iters.mergeCtrTPrp();
var ctrPrpIter = iters.Get_CompiledCtrPrp();
var shIter = this.Composition.GetShiftCenter(oMeasure, ctrPrpIter); //смещение
//var upDesc = iterUp.height - iterUp.ascent + 1.2*shIter, // смещенный descent верхнего итератора
......@@ -901,7 +901,7 @@ CDegreeSubSup.prototype.old_recalculateSize = function(oMeasure)
}
CDegreeSubSup.prototype._recalculateSize = function(oMeasure)
{
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
shCenter *= 1.4;
......@@ -930,7 +930,7 @@ CDegreeSubSup.prototype._recalculateSize = function(oMeasure)
var lUp = base.size.ascent - shCenter; // center of base
var lDown = base.size.height - lUp; // height - center of base
var ctrPrpIter = iters.mergeCtrTPrp();
var ctrPrpIter = iters.Get_CompiledCtrPrp();
var shIter = this.Composition.GetShiftCenter(oMeasure, ctrPrpIter); //смещение
//var upDesc = iterUp.height - iterUp.ascent + 1.2*shIter, // смещенный descent верхнего итератора
......@@ -1015,9 +1015,9 @@ CDegreeSubSup.prototype._recalculateSize = function(oMeasure)
}
CDegreeSubSup.prototype.recalculateSize = function(oMeasure)
{
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
shCenter *= 1.4;
var iters, base;
......@@ -1041,8 +1041,8 @@ CDegreeSubSup.prototype.recalculateSize = function(oMeasure)
var lUp = base.size.ascent - shCenter; // center of base
var lDown = base.size.height - lUp; // height - center of base
var ctrPrpIter = iters.mergeCtrTPrp();
var shIter = this.Composition.GetShiftCenter(oMeasure, ctrPrpIter); //смещение
var ctrPrpIter = iters.Get_CompiledCtrPrp();
var shIter = this.ParaMath.GetShiftCenter(oMeasure, ctrPrpIter); //смещение
var minGap = 0.7*shIter;
......
......@@ -71,7 +71,7 @@ CFraction.prototype.draw = function(x, y, pGraphics)
}
CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
{
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var penW = mgCtrPrp.FontSize* 25.4/96 * 0.08;
var numHeight = this.elements[0][0].size.height;
......@@ -112,8 +112,8 @@ CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
}
CFraction.prototype.drawSkewedFraction = function(x, y, pGraphics)
{
//var ctrPrp = this.getCtrPrp();
var mgCtrPrp = this.mergeCtrTPrp();
//var ctrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var penW = mgCtrPrp.FontSize/12.5*g_dKoef_pix_to_mm;
......@@ -211,8 +211,8 @@ CFraction.prototype.drawLinearFraction = function(x, y, pGraphics)
x2 = this.pos.x + x + this.elements[0][0].size.width + shift,
y2 = this.pos.y + y + this.size.height;
//var ctrPrp = this.getCtrPrp();
var mgCtrPrp = this.mergeCtrTPrp();
//var ctrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var penW = mgCtrPrp.FontSize/12.5*g_dKoef_pix_to_mm;
pGraphics.SetFont(mgCtrPrp);
......@@ -264,12 +264,12 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure)
var num = this.elements[0][0].size,
den = this.elements[1][0].size;
//var ctrPrp = this.getCtrPrp();
var mgCtrPrp = this.mergeCtrTPrp();
//var ctrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var width = num.width > den.width ? num.width : den.width;
var height = num.height + den.height;
var ascent = num.height + this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var ascent = num.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
width += this.GapLeft + this.GapRight;
......@@ -277,13 +277,13 @@ CFraction.prototype.recalculateBarFraction = function(oMeasure)
}
CFraction.prototype.recalculateSkewed = function(oMeasure)
{
//var ctrPrp = this.getCtrPrp();
var mgCtrPrp = this.mergeCtrTPrp();
//var ctrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
this.gapSlash = 5.011235894097222 * mgCtrPrp.FontSize/36;
var width = this.elements[0][0].size.width + this.gapSlash + this.elements[0][1].size.width;
var height = this.elements[0][0].size.height + this.elements[0][1].size.height;
var ascent = this.elements[0][0].size.height + this.Composition.GetShiftCenter(oMeasure, mgCtrPrp);
var ascent = this.elements[0][0].size.height + this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
width += this.GapLeft + this.GapRight;
......@@ -297,8 +297,8 @@ CFraction.prototype.recalculateLinear = function()
DescentSecond = this.elements[0][1].size.height - this.elements[0][1].size.ascent;
var H = AscentFirst + DescentSecond;
//var ctrPrp = this.getCtrPrp();
var mgCtrPrp = this.mergeCtrTPrp();
//var ctrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var gap = 5.011235894097222*mgCtrPrp.FontSize/36;
......@@ -476,8 +476,8 @@ CNumerator.prototype.recalculateSize = function()
{
var arg = this.elements[0][0].size;
//var ctrPrp = this.getCtrPrp();
var mgCtrPrp = this.mergeCtrTPrp();
//var ctrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var Descent = arg.height - arg.ascent; // baseLine
var gapNum = 7.832769097222222 * mgCtrPrp.FontSize/36,
......@@ -517,13 +517,9 @@ CNumerator.prototype.getElement = function()
{
return this.elements[0][0];
}
CNumerator.prototype.getCtrPrp = function()
CNumerator.prototype.Get_CompiledCtrPrp = function()
{
return this.Parent.getCtrPrp();
}
CNumerator.prototype.getRunPrp = function()
{
return this.Parent.getRunPrp();
return this.Parent.Get_CompiledCtrPrp();
}
CNumerator.prototype.getPropsForWrite = function()
{
......@@ -549,8 +545,8 @@ CDenominator.prototype.init = function()
CDenominator.prototype.recalculateSize = function()
{
var arg = this.elements[0][0].size;
//var ctrPrp = this.getCtrPrp();
var mgCtrPrp = this.mergeCtrTPrp();
//var ctrPrp = this.Get_CompiledCtrPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var gapDen = 7.325682539682539 * mgCtrPrp.FontSize/36,
Ascent = arg.ascent - 4.938888888888888*mgCtrPrp.FontSize/36,
......@@ -596,13 +592,9 @@ CDenominator.prototype.getElement = function(txt)
{
return this.elements[0][0];
}
CDenominator.prototype.getCtrPrp = function()
{
return this.Parent.getCtrPrp();
}
CDenominator.prototype.getRunPrp = function()
CDenominator.prototype.Get_CompiledCtrPrp = function()
{
return this.Parent.getRunPrp();
return this.Parent.Get_CompiledCtrPrp();
}
CDenominator.prototype.getPropsForWrite = function()
{
......
......@@ -5,8 +5,6 @@ function CLimit(props)
this.type = LIMIT_LOW;
CMathBase.call(this);
this.init(props);
if(props.type === LIMIT_UP || props.type === LIMIT_LOW)
this.type = props.type;
......@@ -61,7 +59,7 @@ CLimit.prototype.getIterator = function()
}
CLimit.prototype.setDistance = function()
{
this.dH = 0.03674768518518519*this.getCtrPrp().FontSize;
this.dH = 0.03674768518518519*this.Get_CompiledCtrPrp().FontSize;
}
CLimit.prototype.getPropsForWrite = function()
{
......@@ -123,7 +121,7 @@ function CMathFunc(props)
extend(CMathFunc, CMathBase);
CMathFunc.prototype.setDistance = function()
{
this.dW = this.getCtrPrp().FontSize/6*g_dKoef_pt_to_mm;
this.dW = this.Get_CompiledCtrPrp().FontSize/6*g_dKoef_pt_to_mm;
}
CMathFunc.prototype.getFName = function()
{
......
......@@ -145,13 +145,14 @@ var COEFF_GAPS = new CCoeffGaps();
// TODO
// проконтролировать GapLeft и GapRight для setPosition всех элементов
function CRecalculateInfo(oMeasure, Parent)
function CRecalculateInfo(oMeasure, argSize)
{
this.measure = oMeasure;
this.Parent = Parent;
this.Composition = this.Parent.Composition; // для Para_Run
this.argSize = this.Parent.argSize; // argSize выставляем один раз для всего контента
//this.Parent = Parent;
//this.ParaMath = this.Parent.ParaMath; // для Para_Run
this.argSize = argSize; // argSize выставляем один раз для всего контента
this.leftRunPrp = null; // Run_Prp левого элемента
this.currRunPrp = null;
......@@ -526,7 +527,7 @@ CRecalculateInfo.prototype =
// TO DO
// убрать
function dist(_left, _right, _top, _bottom)
/*function dist(_left, _right, _top, _bottom)
{
this.left = _left;
this.right = _right;
......@@ -544,9 +545,9 @@ function mathElem(val)
top: 0,
bottom: 0
}; //mm
}
}*/
function CMathRunPrp()
/*function CMathRunPrp()
{
this.typeObj = MATH_RUN_PRP;
this.textPrp = new CTextPr();
......@@ -570,11 +571,11 @@ CMathRunPrp.prototype =
{
this.textPrp.Merge(oWPrp);
},
/*getWRunPrp: function()
*//*getWRunPrp: function()
{
// смержить c MRunPrp
return this.textPrp;
},*/
},*//*
getMergedWPrp: function()
{
var oWPrp = new CTextPr();
......@@ -621,7 +622,7 @@ CMathRunPrp.prototype =
{
return this.mathPrp.getTxtSettings();
}
}
}*/
function CMPrp()
{
......@@ -692,7 +693,6 @@ CMPrp.prototype =
this.SetBProp(this.brk, props.brk);
this.SetBProp(this.lit, props.lit);
// если приходит несколько параметров style из xml, то запоминается последний
if(props.sty === STY_ITALIC)
this.italic = true;
......@@ -710,7 +710,6 @@ CMPrp.prototype =
{
this.typeText = TXT_PLAIN; // буквы берутся обычные, не специальные для Cambria Math : то есть как для TXT_NORMAL
// отличие от TXT_NORMAL w:rPrp не учитываются !
}
// TXT_DOUBLE_STRUCK U+1D538 - U+1D56B
......@@ -726,6 +725,15 @@ CMPrp.prototype =
if(props.nor)
this.typeText = TXT_NORMAL;
},
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()
{
......@@ -842,22 +850,25 @@ function CMathContent()
this.content = new Array(); // array of mathElem
//this.length = 0;
this.CurPos = 0;
this.WidthToElement = [];
this.pos = {x:0, y:0}; // относительная позиция
// Properties
this.Composition = null; // ссылка на общую формулу
//this.Composition = null; // ссылка на общую формулу
this.ParaMath = null;
this.argSize = 0;
this.bDot = false;
this.plhHide = false;
this.bRoot = false;
//////////////////
/*
////** real select **////
///*/
/** real select **//*
///
this.RealSelect =
{
startPos: 0, // эти позиции идут на отрисовку селекта
......@@ -865,7 +876,9 @@ function CMathContent()
};
///////////////////////////////
////** logical select **////
///*/
/** logical select **//*
///
this.LogicalSelect =
{
start: 0, // логические позиции селекта !!
......@@ -876,9 +889,17 @@ function CMathContent()
///////////////////////////////
*/
this.bSelectionUse = false;
this.SelectStartPos = 0;
this.SelectEndPos = 0;
this.RecalcInfo =
{
TextPr: true
};
this.NearPosArray = new Array();
this.size =
{
......@@ -1071,7 +1092,7 @@ CMathContent.prototype =
if(obj.typeObj === MATH_COMP)
{
obj.setComposition(this.Composition);
//obj.setComposition(this.Composition);
obj.setArgSize(this.argSize);
this.content.push(obj);
......@@ -1084,7 +1105,7 @@ CMathContent.prototype =
this.CurPos = this.content.length-1;
},
addToContent_2: function(oSub) // for "menu"
/*addToContent_2: function(oSub) // for "menu"
{
// добавление к контенту элементов из другого контента в текущую позицию
// первый элемент в добавляемом контенте CEmpty пропускаем
......@@ -1149,8 +1170,8 @@ CMathContent.prototype =
this.CurPos = pos;
return middleContent;
},
setComposition: function(Composition)
},*/
/*setComposition: function(Composition)
{
this.Composition = Composition;
},
......@@ -1162,7 +1183,7 @@ CMathContent.prototype =
if(this.content[i].value.typeObj == MATH_COMP)
this.content[i].value.setReferenceComposition(Comp);
}
},
},*/
createEquation: function(ind)
{
var Pos = this.CurPos + 1;
......@@ -4132,7 +4153,7 @@ CMathContent.prototype =
else if( this.selectUse() ) //т.к. после того как удалили тагет у нас эти 2 значения не равны, равенство их выставляется позднее, после добавления символа
this.remove(1);
},
relate: function(parent)
/*relate: function(parent)
{
if(parent === -1)
{
......@@ -4144,11 +4165,11 @@ CMathContent.prototype =
this.bRoot = false;
this.Parent = parent;
}
},
},*/
fillPlaceholders: function()
{
var placeholder = new CMathText(false);
placeholder.relate(this);
//placeholder.relate(this);
placeholder.fillPlaceholders();
this.content.push( placeholder );
......@@ -5045,9 +5066,17 @@ CMathContent.prototype =
this.size = {width: width, height: ascent + descent, ascent: ascent};
},
Resize: function(oMeasure) // пересчитываем всю формулу
Resize: function(Parent, ParaMath, oMeasure) // пересчитываем всю формулу a
{
var RecalcInfo = new CRecalculateInfo(oMeasure, this);
var RecalcInfo = new CRecalculateInfo(oMeasure, this.argSize);
this.ParaMath = ParaMath;
if(Parent !== null)
{
this.bRoot = false;
this.Parent = Parent;
}
for(var pos = 0; pos < this.content.length; pos++)
{
......@@ -5058,39 +5087,40 @@ CMathContent.prototype =
RecalcInfo.Current = this.content[pos];
//var currRPrp = this.content[pos].getRunPrp();
this.content[pos].Resize(this, ParaMath, oMeasure);
var runPrp = this.content[pos].getCtrPrp();
//var runPrp = this.content[pos].getRunPrp();
//var currRPrp = runPrp.getMergedWPrp();
//this.applyArgSize(currRPrp);
this.Composition.ApplyArgSize(runPrp); // в ParaMath
/*var runPrp = this.content[pos].getCtrPrp();
RecalcInfo.currRunPrp = runPrp;
this.ParaMath.ApplyArgSize(runPrp); // в ParaMath*/
RecalcInfo.setGaps();
var ctrPrp = this.content[pos].Get_CompiledCtrPrp();
this.content[pos].Resize(oMeasure);
RecalcInfo.currRunPrp = ctrPrp;
RecalcInfo.setGaps();
}
else if(this.content[pos].typeObj == MATH_PLACEHOLDER)
{
if(!this.bRoot)
{
var oWPrp = this.Parent.getCtrPrp();
/*var oWPrp = this.Parent.getCtrPrp();
//this.applyArgSize(oWPrp);
this.Composition.ApplyArgSize(oWPrp);
oWPrp.Italic = false;
this.ParaMath.ApplyArgSize(oWPrp);*/
oMeasure.SetFont(oWPrp);
var ctrPrp = this.Parent.Get_CompiledCtrPrp();
ctrPrp.Italic = false;
this.content[pos].Resize(oMeasure);
oMeasure.SetFont(ctrPrp);
this.content[pos].Resize(this, oMeasure);
}
}
else
{
this.content[pos].Set_Paragraph(this.Composition.Paragraph);
this.content[pos].Math_Recalculate(RecalcInfo);
//this.content[pos].Set_Paragraph(this.ParaMath.Paragraph);
this.content[pos].Math_Recalculate(this, ParaMath.Paragraph, oMeasure, RecalcInfo);
}
}
......@@ -5202,7 +5232,7 @@ CMathContent.prototype =
oWPrp.Merge(mgWPrp);
//this.applyArgSize(oWPrp);
this.Composition.ApplyArgSize(oWPrp);
this.ParaMath.ApplyArgSize(oWPrp);
pGraphics.SetFont(oWPrp);
}
......@@ -5210,13 +5240,18 @@ CMathContent.prototype =
{
pGraphics.b_color1(0,0,0,255);
var oWPrp = this.Parent.getCtrPrp();
/*var oWPrp = this.Parent.getCtrPrp();
//this.applyArgSize(oWPrp);
this.Composition.ApplyArgSize(oWPrp);
this.ParaMath.ApplyArgSize(oWPrp);
oWPrp.Italic = false;
pGraphics.SetFont(oWPrp);
pGraphics.SetFont(oWPrp);*/
var ctrPrp = this.Parent.Get_CompiledCtrPrp();
ctrPrp.Italic = false;
pGraphics.SetFont(ctrPrp);
this.content[i].draw(x, y, pGraphics);
}
......@@ -5238,9 +5273,8 @@ CMathContent.prototype =
}
else if(this.content[this.CurPos].typeObj == MATH_PARA_RUN)
{
//var absPos = this.Composition.absPos;
var X = this.pos.x + this.Composition.X + this.WidthToElement[this.CurPos],
Y = this.pos.y + this.Composition.Y + this.size.ascent;
var X = this.pos.x + this.ParaMath.X + this.WidthToElement[this.CurPos],
Y = this.pos.y + this.ParaMath.Y + this.size.ascent;
result = this.content[this.CurPos].Math_Update_Cursor(X, Y, CurPage, UpdateTarget);
}
......@@ -5724,7 +5758,7 @@ CMathContent.prototype =
{
//var rPrp = new CMathRunPrp();
var rPrp = new CTextPr();
var defaultRPrp = this.Composition.Get_Default_TPrp();
var defaultRPrp = this.ParaMath.Get_Default_TPrp();
rPrp.Merge(defaultRPrp);
if(this.content.length > 1)
......@@ -5836,32 +5870,29 @@ CMathContent.prototype =
}
else if(this.content[this.CurPos].typeObj == MATH_PARA_RUN)
{
//var absPos = this.Composition.absPos;
Y = this.pos.y + this.Composition.Y + this.size.ascent;
_X = this.pos.x + this.Composition.X + this.WidthToElement[this.CurPos];
Y = this.pos.y + this.ParaMath.Y + this.size.ascent;
_X = this.pos.x + this.ParaMath.X + this.WidthToElement[this.CurPos];
result = this.content[this.CurPos].Recalculate_CurPos(_X, Y, CurrentRun, 0, 0, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
}
else
{
//var absPos = this.Composition.absPos;
Y = this.pos.y + this.ParaMath.Y + this.size.ascent;
_X = this.pos.x + this.ParaMath.X + this.size.width;
Y = this.pos.y + this.Composition.Y + this.size.ascent;
_X = this.pos.x + this.Composition.X + this.size.width;
/*var ctrPrp = this.Parent.getCtrPrp();
this.ParaMath.ApplyArgSize(ctrPrp);*/
var ctrPrp = this.Parent.getCtrPrp();
this.Composition.ApplyArgSize(ctrPrp);
//this.applyArgSize(ctrPrp);
var ctrPrp = this.Parent.Get_CompiledCtrPrp();
var sizeCursor = ctrPrp.FontSize*g_dKoef_pt_to_mm;
Y -= sizeCursor*0.8;
this.Composition.Paragraph.DrawingDocument.SetTargetSize(sizeCursor);
this.ParaMath.Paragraph.DrawingDocument.SetTargetSize(sizeCursor);
//Para.DrawingDocument.UpdateTargetFromPaint = true;
this.Composition.Paragraph.DrawingDocument.UpdateTarget( _X, Y, this.Composition.Paragraph.Get_StartPage_Absolute() + _CurPage );
this.ParaMath.Paragraph.DrawingDocument.UpdateTarget( _X, Y, this.ParaMath.Paragraph.Get_StartPage_Absolute() + _CurPage );
result = {X: _X, Y: Y};
......@@ -5869,6 +5900,20 @@ CMathContent.prototype =
return result;
},
Check_NearestPos: function(ParaNearPos, Depth)
{
var ContentNearPos = new CParagraphElementNearPos();
ContentNearPos.NearPos = ParaNearPos.NearPos;
ContentNearPos.Depth = Depth;
// CParagraphNearPos for ParaNearPos
this.NearPosArray.push( ContentNearPos );
ParaNearPos.Classes.push( this );
var CurPos = ParaNearPos.NearPos.ContentPos.Get(Depth);
this.Content[CurPos].Check_NearestPos( ParaNearPos, Depth + 1 );
},
// Поиск позиции, селект
......@@ -6071,9 +6116,9 @@ CMathContent.prototype =
if(bCurrComp && !bLeftRun) // добавление пустого Run перед мат объектом
{
var emptyRun = new ParaRun(this.Composition.Paragraph, true);
var txtPrp = current.Get_TxtPrp();
emptyRun.Set_Pr(txtPrp);
var emptyRun = new ParaRun(null, true);
//var txtPrp = current.Get_TxtPrp();
//emptyRun.Set_Pr(txtPrp);
NewContent.push(emptyRun);
NewContent.push(this.content[i]); // Math Object
......@@ -6094,15 +6139,28 @@ CMathContent.prototype =
if(len > 0 && this.content[len - 1].typeObj == MATH_COMP)
{
var emptyRun = new ParaRun(this.Composition.Paragraph, true);
var txtPrp = current.Get_TxtPrp();
emptyRun.Set_Pr(txtPrp);
var emptyRun = new ParaRun(null, true);
//var emptyRun = new ParaRun(this.ParaMath.Paragraph, true);
//var txtPrp = current.Get_TxtPrp();
//emptyRun.Set_Pr(txtPrp);
NewContent.push(emptyRun);
}
this.content = NewContent;
},
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 );
},
/// функции для работы с курсором
......@@ -6125,7 +6183,7 @@ CMathContent.prototype =
}
else if(this.content[pos].typeObj == MATH_PARA_RUN) // проверка на gaps в findDisposition
{
SearchPos.X += this.pos.x + this.Composition.X + this.WidthToElement[pos];
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, 0, 0);
}
......@@ -6288,9 +6346,64 @@ CMathContent.prototype =
return TextPr;
},
Apply_TextPr: function(TextPr, IncFontSize, ApplyToAll)
{
if ( true === ApplyToAll )
{
for ( var i = 0; i < this.content.length; i++ )
{
var typeElem = this.content[i].typeObj;
if( typeElem == MATH_COMP || typeElem == MATH_PARA_RUN)
this.content[i].Apply_TextPr( TextPr, IncFontSize, true );
}
}
else
{
if(this.bSelectionUse == true)
{
var StartPos = this.SelectStartPos;
var EndPos = this.SelectEndPos;
if(StartPos > EndPos)
{
var temp = StartPos;
EndPos = StartPos;
StartPos = temp;
}
if ( StartPos === EndPos )
{
var elem = this.content[StartPos];
if( elem.typeObj == MATH_COMP)
elem.Apply_TextPr( TextPr, IncFontSize, true );
else if(elem.typeObj == MATH_PARA_RUN)
elem.Apply_TextPr( TextPr, IncFontSize, false );
}
else
{
for(var i = StartPos; i <= EndPos; i++)
{
var elem = this.content[i];
if( elem.typeObj == MATH_COMP)
elem.Apply_TextPr( TextPr, IncFontSize, true );
else if(elem.typeObj == MATH_PARA_RUN)
elem.Apply_TextPr( TextPr, IncFontSize, false );
}
}
}
else
{
this.content[this.CurPos].Apply_TextPr( TextPr, IncFontSize, false );
}
}
},
Get_Default_TPrp: function()
{
return this.Composition.Get_Default_TPrp();
return this.ParaMath.Get_Default_TPrp();
},
//////////////////////////////
// Перемещение по стрелкам
......@@ -6327,7 +6440,6 @@ CMathContent.prototype =
this.content[CurPos].Get_LeftPos(SearchPos, ContentPos, Depth + 1, bUseContent);
}
SearchPos.Pos.Update(CurPos, Depth);
......@@ -6395,6 +6507,51 @@ CMathContent.prototype =
result = SearchPos.Found;
return result;
},
Get_WordStartPos : function(SearchPos, ContentPos, Depth, UseContentPos)
{
var CurPos = ( true === UseContentPos ? ContentPos.Get(Depth) : this.content.length - 1 );
//this.content[CurPos].Get_WordStartPos(SearchPos, ContentPos, Depth + 1, UseContentPos);
//CurPos--;
//if ( true === SearchPos.UpdatePos )
// SearchPos.Pos.Update( CurPos, Depth );
while(CurPos >= 0 && SearchPos.Found == false)
{
var item = this.content[CurPos];
SearchPos.Pos.Update(CurPos, Depth);
if(item.typeObj == MATH_PLACEHOLDER)
{
SearchPos.UpdatePos = true;
SearchPos.Found = true;
break;
}
else if(item.typeObj == MATH_COMP)
{
SearchPos.UpdatePos = true;
SearchPos.Found = true;
break;
}
else if(item.typeObj == MATH_PARA_RUN)
{
item.Get_WordStartPos(SearchPos, ContentPos, Depth + 1, UseContentPos);
if(true === SearchPos.UpdatePos)
break;
}
CurPos--;
}
},
Get_WordEndPos : function(SearchPos, ContentPos, Depth, UseContentPos, StepEnd)
{
},
/////////////////////////
getContent: function(stack, bCurrent)
......@@ -6417,7 +6574,7 @@ CMathContent.prototype =
{
return this.content.length == 1;
},
Copy: function(Selected, Composition)
Copy: function(Selected)
{
var start, end;
......@@ -6442,7 +6599,6 @@ CMathContent.prototype =
}
var NewContent = new CMathContent();
NewContent.setComposition(Composition);
NewContent.plhHide = this.plhHide;
for(var i = start; i <= end; i++)
......@@ -6454,8 +6610,8 @@ CMathContent.prototype =
}
else
{
element = this.content[i].Copy(false, Composition);
element.relate(this);
element = this.content[i].Copy(false);
//element.relate(this);
}
NewContent.content.push(element);
......@@ -7698,7 +7854,7 @@ CMathComposition.prototype =
}*/
function CEmpty()
/*function CEmpty()
{
this.typeObj = MATH_EMPTY;
this.pos = null;
......@@ -7720,7 +7876,7 @@ function CEmpty()
this.IsHighElement = function() { return false; };
this.relate = function() {};
}
}*/
......
......@@ -235,7 +235,7 @@ CMathText.prototype =
{
this.bIterator = bIterator; // символы другие , чуть толще
},
Resize: function(oMeasure)
Resize: function(Run, oMeasure)
{
/*
var metricsTxt = g_oTextMeasurer.Measure2Code(letter);
......@@ -243,6 +243,8 @@ CMathText.prototype =
height = g_oTextMeasurer.GetHeight();
*/
this.Parent = Run;
var letter = this.getCode();
var metricsTxt;
......
......@@ -184,7 +184,7 @@ CMathMatrix.prototype.setRuleGap = function(space, rule, gap, minGap)
}
CMathMatrix.prototype.recalculateSize = function(oMeasure)
{
var txtPrp = this.mergeCtrTPrp();
var txtPrp = this.Get_CompiledCtrPrp();
var interval = this.getLineGap(txtPrp);
this.gaps.column[0] = 0;
......@@ -392,8 +392,7 @@ CMathMatrix.prototype.addRow = function()
for(var j = 0; j < this.nCol; j++)
{
this.elements[this.nRow-1][j] = new CMathContent();
this.elements[this.nRow-1][j].relate(this);
this.elements[this.nRow-1][j].setComposition(this.Composition);
//this.elements[this.nRow-1][j].relate(this);
//this.elements[this.nRow-1][j].setComposition(this.Composition);
}
......
......@@ -173,39 +173,45 @@ CNary.prototype.init = function(props)
{
base = new CNaryOvr();
base.init(sign);
base.setCtrPrp(this.CtrPrp.Copy());
}
else if( !this.supHide && this.subHide )
{
base = new CNaryUnd();
base.init(sign);
base.setCtrPrp(this.CtrPrp.Copy());
}
else
{
base = new CNaryUndOvr();
base.init(sign);
base.setCtrPrp(this.CtrPrp.Copy());
}
}
else
{
if( this.supHide && !this.subHide )
{
var prp = {type: DEGREE_SUBSCRIPT, indef: 2, oBase: sign};
var prp = {type: DEGREE_SUBSCRIPT, indef: 2, oBase: sign, ctrPrp: this.CtrPrp.Copy() };
base = new CDegree(prp);
}
else if( !this.supHide && this.subHide )
{
var prp = {type: DEGREE_SUPERSCRIPT, indef: 2, oBase: sign};
var prp = {type: DEGREE_SUPERSCRIPT, indef: 2, oBase: sign, ctrPrp: this.CtrPrp.Copy()};
base = new CDegree(prp);
}
else
{
var prp = {type: DEGREE_SubSup, indef: 2, oBase: sign};
var prp = {type: DEGREE_SubSup, indef: 2, oBase: sign, ctrPrp: this.CtrPrp.Copy()};
base = new CDegreeSubSup(prp);
}
}
if(!this.supHide || !this.subHide)
base.setCtrPrp(this.CtrPrp); // выставляем аналогично как в CMathContent при добавлении элемента в addMComponent
/*if(!this.supHide || !this.subHide)
base.setCtrPrp(this.CtrPrp); */ // выставляем аналогично как в CMathContent при добавлении элемента в addMComponent
this.addMCToContent(base, arg);
......@@ -217,14 +223,14 @@ CNary.prototype.setCtrPrp = function(txtPrp)
this.CtrPrp.Merge(txtPrp); // only runPrp for paragraph
//this.RunPrp.setTxtPrp(txtPrp);
if(this.elements !== null)
if(this.elements !== null && !this.elements[0][0].IsJustDraw())
{
this.elements[0][0].setCtrPrp(this.CtrPrp);
}
}
CNary.prototype.setDistance = function()
{
this.dW = this.getCtrPrp().FontSize/36*2.45;
this.dW = this.Get_CompiledCtrPrp().FontSize/36*2.45;
}
CNary.prototype.getBase = function()
{
......@@ -296,11 +302,13 @@ CNaryUnd.prototype.init = function(sign)
var iter = new CMathContent();
iter.decreaseArgSize();
//sign.relate(this);
this.addMCToContent(iter, sign);
}
CNaryUnd.prototype.setDistance = function()
{
var zetta = this.getCtrPrp().FontSize* 25.4/96;
var zetta = this.Get_CompiledCtrPrp().FontSize* 25.4/96;
this.dH = zetta*0.25;
}
CNaryUnd.prototype.getAscent = function()
......@@ -324,16 +332,18 @@ CNaryOvr.prototype.init = function(sign)
var iter = new CMathContent();
iter.decreaseArgSize();
//sign.relate(this);
this.addMCToContent(sign, iter);
}
CNaryOvr.prototype.old_setDistance = function()
{
var zetta = this.getCtrPrp().FontSize* 25.4/96;
var zetta = this.Get_CompiledCtrPrp().FontSize* 25.4/96;
this.dH = zetta*0.1;
}
CNaryOvr.prototype.recalculateSize = function()
{
var FontSize = this.getCtrPrp().FontSize;
var FontSize = this.Get_CompiledCtrPrp().FontSize;
var zetta = FontSize*25.4/96;
var minGapBottom = zetta*0.1,
......@@ -382,7 +392,7 @@ CNaryUndOvr.prototype.init = function(sign)
}
CNaryUndOvr.prototype.recalculateSize = function()
{
var FontSize = this.getCtrPrp().FontSize;
var FontSize = this.Get_CompiledCtrPrp().FontSize;
var zetta = FontSize*25.4/96;
this.gapTop = zetta*0.25;
//this.gapBottom = zetta*0.1;
......@@ -484,7 +494,7 @@ CNaryUndOvr.prototype.getUpperIterator = function()
function CNaryOperator(flip)
{
this.Composition = null;
this.ParaMath = null;
this.bFlip = (flip == -1);
this.sizeGlyph = null;
}
......@@ -506,7 +516,7 @@ CNaryOperator.prototype.drawGlyph = function(x, y,pGraphics)
YY = new Array();
//var textScale = this.getTxtPrp().FontSize/850; // 1000 pt
var textScale = this.getCtrPrp().FontSize/850; // 1000 pt
var textScale = this.Get_CompiledCtrPrp().FontSize/850; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
// g_dKoef_px_to_mm = 25.4/96
......@@ -546,7 +556,7 @@ CNaryOperator.prototype.drawTextElem = function(x, y, pGraphics)
{
pGraphics.b_color1(0,0,0,255);
var rPrp = new CTextPr();
rPrp.Merge( this.getCtrPrp() );
rPrp.Merge( this.Get_CompiledCtrPrp() );
rPrp.Italic = false;
rPrp.Bold = false;
......@@ -558,10 +568,10 @@ CNaryOperator.prototype.IsJustDraw = function()
{
return true;
}
CNaryOperator.prototype.relate = function(parent)
/*CNaryOperator.prototype.relate = function(parent)
{
this.Parent = parent;
}
}*/
CNaryOperator.prototype.setPosition = function(pos)
{
this.pos = {x: pos.x , y: pos.y};
......@@ -572,26 +582,35 @@ CNaryOperator.prototype.recalculateSize = function()
var height = this.sizeGlyph.height,
width = this.sizeGlyph.width,
ascent = this.sizeGlyph.height/2 + DIV_CENT*this.getCtrPrp().FontSize;
ascent = this.sizeGlyph.height/2 + DIV_CENT*this.Get_CompiledCtrPrp().FontSize;
this.size = {height: height, width: width, ascent: ascent};
}
CNaryOperator.prototype.Resize = function()
CNaryOperator.prototype.Resize = function(Parent, ParaMath, oMeasure)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.RecalcInfo.bCtrPrp == true)
{
this.Set_CompiledCtrPrp();
this.RecalcInfo.bCtrPrp = false;
}
this.recalculateSize(); //обычный пересчет, oMeasure не нужен
}
CNaryOperator.prototype.setComposition = function(Compos)
/*CNaryOperator.prototype.setComposition = function(Compos)
{
this.Composition = Compos;
}
CNaryOperator.prototype.getCtrPrp = function()
}*/
CNaryOperator.prototype.Get_CompiledCtrPrp = function()
{
return this.Parent.getCtrPrp();
return this.Parent.Get_CompiledCtrPrp();
}
CNaryOperator.prototype.setReferenceComposition = function(Compos)
/*CNaryOperator.prototype.setReferenceComposition = function(Compos)
{
this.Composition = Compos;
}
}*/
CNaryOperator.prototype.IsOnlyText = function()
{
return false;
......@@ -713,7 +732,7 @@ CSigma.prototype.getCoord = function()
//var textScale = this.getTxtPrp().FontSize/850; // 1000 pt
var textScale = this.getCtrPrp().FontSize/850; // 1000 pt
var textScale = this.Get_CompiledCtrPrp().FontSize/850; // 1000 pt
var alpha = textScale*25.4/96 /64;
var h1 = Y[0] - Y[21],
......@@ -785,7 +804,7 @@ CSigma.prototype.calculateSizeGlyph = function()
// пока размер не меняем в зависимости от высоты аргумента
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 8.997900390624999*betta,
_height = 11.994444444444444*betta;
......@@ -917,7 +936,7 @@ CProduct.prototype.getCoord = function()
//var textScale = this.getTxtPrp().FontSize/850, // 1000 pt
var textScale = this.getCtrPrp().FontSize/850, // 1000 pt
var textScale = this.Get_CompiledCtrPrp().FontSize/850, // 1000 pt
alpha = textScale*25.4/96 /64;
var h1 = Y[9],
......@@ -948,7 +967,7 @@ CProduct.prototype.getCoord = function()
CProduct.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 10.312548828125*betta,
_height = 11.994444444444444*betta;
......@@ -1020,7 +1039,7 @@ CUnion.prototype.getCoord = function()
CUnion.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
this.gap = 0.93*betta;
var _width = 9.38*betta,
......@@ -1139,7 +1158,7 @@ CLogicalOr.prototype.getCoord = function()
X[7] = 0; Y[7] = 0;
//var textScale = this.getTxtPrp().FontSize/850, // 1000 pt
var textScale = this.getCtrPrp().FontSize/850, // 1000 pt
var textScale = this.Get_CompiledCtrPrp().FontSize/850, // 1000 pt
alpha = textScale*25.4/96 /64;
var w1 = X[1],
......@@ -1171,7 +1190,7 @@ CLogicalOr.prototype.getCoord = function()
CLogicalOr.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 9.6159*betta,
_height = 11.994444444444444*betta;
......@@ -1403,7 +1422,7 @@ CIntegral.prototype.old_drawPath = function(XX, YY)
CIntegral.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 8.624*betta,
_height = 13.7*betta;
......@@ -1468,7 +1487,7 @@ CDoubleIntegral.prototype.drawPath = function(pGraphics, XX, YY)
CDoubleIntegral.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 14.2296*betta,
_height = 13.7*betta;
......@@ -1543,7 +1562,7 @@ CTripleIntegral.prototype.drawPath = function(pGraphics, XX, YY)
CTripleIntegral.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 18.925368*betta,
_height = 13.7*betta;
......@@ -3009,7 +3028,7 @@ CContourIntegral.prototype.draw = function(x, y, pGraphics)
HH = coord2.H;
//var textScale = this.getTxtPrp().FontSize/850;// 1000 pt
var FontSize = this.getCtrPrp().FontSize;
var FontSize = this.Get_CompiledCtrPrp().FontSize;
var textScale = FontSize/850;// 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
......@@ -3057,7 +3076,7 @@ CContourIntegral.prototype.draw = function(x, y, pGraphics)
CContourIntegral.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 8.624*betta,
_height = 13.7*betta;
......@@ -3538,7 +3557,7 @@ CSurfaceIntegral.prototype.draw = function(x, y, pGraphics)
WW = 1.6*coord2.W,
HH = coord2.H;
var FontSize = this.getCtrPrp().FontSize;
var FontSize = this.Get_CompiledCtrPrp().FontSize;
var textScale = FontSize/850; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
......@@ -3586,7 +3605,7 @@ CSurfaceIntegral.prototype.draw = function(x, y, pGraphics)
CSurfaceIntegral.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 14.2296*betta,
_height = 13.7*betta;
......@@ -4137,7 +4156,7 @@ CVolumeIntegral.prototype.draw = function(x, y, pGraphics)
WW = 2.1*coord2.W,
HH = coord2.H;
var FontSize = this.getCtrPrp().FontSize;
var FontSize = this.Get_CompiledCtrPrp().FontSize;
var textScale = FontSize/850; // 1000 pt
var alpha = textScale*25.4/96 /64; // коэффициент; используется для того чтобы перевести координаты в миллиметры
......@@ -4184,7 +4203,7 @@ CVolumeIntegral.prototype.draw = function(x, y, pGraphics)
CVolumeIntegral.prototype.calculateSizeGlyph = function()
{
//var betta = this.getTxtPrp().FontSize/36;
var betta = this.getCtrPrp().FontSize/36;
var betta = this.Get_CompiledCtrPrp().FontSize/36;
var _width = 18.925368*betta,
_height = 13.7*betta;
......
......@@ -396,7 +396,7 @@ CGlyphOperator.prototype.draw = function(pGraphics, XX, YY)
}
CGlyphOperator.prototype.getCtrPrp = function()
{
return this.Parent.getCtrPrp();
return this.Parent.Get_CompiledCtrPrp();
}
CGlyphOperator.prototype.relate = function(parent)
{
......@@ -2943,9 +2943,6 @@ COperator.prototype.init_2 = function(props)
this.operator = operator;
this.code = codeChr;
this.typeOper = typeOper;
this.operator.relate(this);
}
COperator.prototype.getProps = function(props, defaultProps)
{
......@@ -2993,7 +2990,7 @@ COperator.prototype.draw = function(x, y, pGraphics)
{
// выставляем font, если нужно отрисовать текст
pGraphics.b_color1(0,0,0,255);
var ctrPrp = this.getCtrPrp();
var ctrPrp = this.Get_CompiledCtrPrp();
var rPrp = new CTextPr();
//var defaultRPrp = this.Parent.Composition.DEFAULT_RUN_PRP;
......@@ -3077,7 +3074,7 @@ COperator.prototype.old_fixSize = function(oMeasure, stretch)
oMeasure.SetFont(rPrp);
this.operator.Resize(oMeasure);
this.operator.Resize(this, oMeasure);
if(this.operator.loc == 0 || this.operator.loc == 1)
{
......@@ -3129,7 +3126,7 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
if(this.typeOper == OPERATOR_TEXT) // отдельный случай для текста в качестве оператора
{
var ctrPrp = this.getCtrPrp();
var ctrPrp = this.Get_CompiledCtrPrp();
var rPrp = new CTextPr();
//var defaultRPrp = this.Parent.Composition.DEFAULT_RUN_PRP;
......@@ -3141,7 +3138,7 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
oMeasure.SetFont(rPrp);
this.operator.Resize(oMeasure);
this.operator.Resize(this, oMeasure);
if(this.operator.loc == 0 || this.operator.loc == 1)
{
......@@ -3156,7 +3153,7 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
var letterX = new CMathText(true);
letterX.add(0x78);
letterX.Resize(oMeasure);
letterX.Resize(null, oMeasure);
this.shiftAccent = letterX.size.ascent;
}
else
......@@ -3180,7 +3177,7 @@ COperator.prototype.fixSize = function(ParaMath, oMeasure, stretch)
}
var mgCtrPrp = this.Parent.mergeCtrTPrp();
var mgCtrPrp = this.Parent.Get_CompiledCtrPrp();
var shCenter = this.Parent.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
if(this.operator.loc == 0 || this.operator.loc == 1) // horizontal
......@@ -3210,7 +3207,7 @@ COperator.prototype.setPosition = function(pos)
if(this.type == OPER_ACCENT)
{
this.operator.setPosition({x: pos.x, y: pos.y + this.shiftAccent});
this.operator.setPosition({x: pos.x, y: pos.y + this.shiftAccent + this.operator.size.height});
}
else
this.operator.setPosition(pos);
......@@ -3221,9 +3218,16 @@ COperator.prototype.IsJustDraw = function()
{
return true;
}
COperator.prototype.Resize = function(ParaMath, oMeasure)
COperator.prototype.Resize = function(Parent, ParaMath, oMeasure)
{
this.ParaMath = ParaMath;
this.Parent = Parent;
if(this.RecalcInfo.bCtrPrp == true)
{
this.Set_CompiledCtrPrp();
this.RecalcInfo.bCtrPrp = false;
}
if(this.operator !== -1)
{
......@@ -3235,15 +3239,15 @@ COperator.prototype.Resize = function(ParaMath, oMeasure)
this.fixSize(ParaMath, oMeasure, this.size.height);
}
}
/*COperator.prototype.relate = function(parent)
COperator.prototype.relate = function(parent)
{
this.Parent = parent;
if(this.operator !== -1)
this.operator.relate(this);
}*/
COperator.prototype.getCtrPrp = function()
}
COperator.prototype.Get_CompiledCtrPrp = function()
{
return this.Parent.getCtrPrp();
return this.Parent.Get_CompiledCtrPrp();
}
COperator.prototype.getChr = function()
{
......@@ -3523,10 +3527,17 @@ CDelimiter.prototype.old_recalculateSize = function()
this.size = {width: width, height: height, center: center};
}
CDelimiter.prototype.Resize = function(ParaMath, oMeasure)
CDelimiter.prototype.Resize = function(Parent, ParaMath, oMeasure)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.RecalcInfo.bCtrPrp == true)
{
this.Set_CompiledCtrPrp();
this.RecalcInfo.bCtrPrp = false;
}
// размеры аргумента
var heightG = 0, widthG = 0,
ascentG = 0, descentG = 0;
......@@ -3535,7 +3546,7 @@ CDelimiter.prototype.Resize = function(ParaMath, oMeasure)
for(var j = 0; j < this.nCol; j++)
{
this.elements[0][j].Resize(ParaMath, oMeasure);
this.elements[0][j].Resize(this, ParaMath, oMeasure);
var content = this.elements[0][j].size;
widthG += content.width;
ascentG = content.ascent > ascentG ? content.ascent : ascentG;
......@@ -3545,7 +3556,7 @@ CDelimiter.prototype.Resize = function(ParaMath, oMeasure)
heightG = ascentG + descentG;
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var shCenter = this.ParaMath.GetShiftCenter(oMeasure, mgCtrPrp);
var maxAD = ascentG - shCenter > descentG + shCenter ? ascentG - shCenter: descentG + shCenter;
......@@ -3631,148 +3642,6 @@ CDelimiter.prototype.Resize = function(ParaMath, oMeasure)
this.size = {width: width, height: height, ascent: ascent};
}
CDelimiter.prototype.old_Resize = function(oMeasure)
{
var height = 0,
width = 0;
var ascent = 0,
descent = 0;
for(var j = 0; j < this.nCol; j++)
this.elements[0][j].Resize(oMeasure);
// временно
var FontSize = this.getCtrPrp().FontSize;
var Height = 0.4*FontSize; // g_oTextMeasurer.GetHeight()
var plH = 0.275*FontSize, // плейсхолдер
H2 = 0.05*FontSize; // временно baseLine
if(this.shape == DELIMITER_SHAPE_CENTERED)
{
for(var j = 0; j < this.nCol; j++)
{
var content = this.elements[0][j].size;
width += content.width;
ascent = content.ascent > ascent ? content.ascent : ascent;
descent = content.height - content.ascent > descent ? content.height - content.ascent: descent;
}
_ascent = ascent - DIV_CENT*FontSize;
_descent = descent + DIV_CENT*FontSize;
var maxDim = _ascent > _descent ? _ascent : _descent;
// для случая, когда в контенте степень и пр. элементы где нужно учитовать baseLine
if(_descent < plH || _ascent < plH)
{
if(maxDim < plH)
{
height = _ascent + _descent;
}
else
{
var div = _ascent - plH;
height = _ascent + _descent + div;
}
}
else
{
height = 2*maxDim;
ascent = height/2 + DIV_CENT*FontSize;
}
}
else
{
for(var j = 0; j < this.nCol; j++)
{
var content = this.elements[0][j].size;
width += content.width;
ascent = content.ascent > ascent ? content.ascent : ascent;
descent = content.height - content.ascent > descent ? content.height - content.ascent: descent;
}
height = ascent + descent;
}
this.begOper.fixSize(oMeasure, height);
width += this.begOper.size.width;
if(height < this.begOper.size.height)
{
ascent = this.begOper.size.height - H2;
height = this.begOper.size.height;
//center = this.begOper.size.center;
}
this.endOper.fixSize(oMeasure, height);
width += this.endOper.size.width;
if(height < this.endOper.size.height)
{
//center += (height - this.endOper.size.height)/2;
ascent = this.endOper.size.height - H2;
height = this.endOper.size.height;
//center = this.endOper.size.center;
}
this.sepOper.fixSize(oMeasure, height);
width += (this.nCol - 1)*this.sepOper.size.width;
if(height < this.sepOper.size.height)
{
//center += (height - this.sepOper.size.height)/2;
ascent = this.sepOper.size.height - H2;
height = this.sepOper.size.height;
//center = this.sepOper.size.center;
}
/*if(this.begOper !== -1)
{
this.begOper.fixSize(height);
width += this.begOper.size.width;
if(height < this.begOper.size.height)
{
center = this.begOper.size.center;
height = this.begOper.size.height;
}
//height = (height < this.begOper.size.height) ? this.begOper.size.height : height;
//center = (center < this.begOper.size.center) ? this.begOper.size.center : center;
}
if(this.endOper !== -1)
{
this.endOper.fixSize(height);
width += this.endOper.size.width;
//height = (height < this.endOper.size.height) ? this.endOper.size.height : height;
//center = (center < this.endOper.size.center) ? this.endOper.size.center : center;
if(height < this.endOper.size.height)
{
center = this.endOper.size.center;
height = this.endOper.size.height;
}
}
if(this.sepOper !== -1)
{
this.sepOper.fixSize(height);
width += (this.nCol - 1)*this.sepOper.size.width;
height = (height < this.sepOper.size.height) ? this.sepOper.size.height : height;
center = (center < this.sepOper.size.center) ? this.sepOper.size.center : center;
}*/
this.size = {width: width, height: height, ascent: ascent};
}
CDelimiter.prototype.old_alignOperator = function(height)
{
......@@ -4017,25 +3886,32 @@ CCharacter.prototype.setCharacter = function(props, defaultProps)
this.setDimension(1, 1);
this.setContent();
}
CCharacter.prototype.Resize = function(ParaMath, oMeasure)
CCharacter.prototype.Resize = function(Parent, ParaMath, oMeasure)
{
this.Parent = Parent;
this.ParaMath = ParaMath;
if(this.RecalcInfo.bCtrPrp == true)
{
this.Set_CompiledCtrPrp();
this.RecalcInfo.bCtrPrp = false;
}
var base = this.elements[0][0];
base.Resize(ParaMath, oMeasure);
base.Resize(this, ParaMath, oMeasure);
this.operator.fixSize(ParaMath, oMeasure, base.size.width);
var letterX = new CMathText(true);
letterX.add(0x78);
letterX.Resize(oMeasure);
letterX.Resize(null, oMeasure);
this.shiftX = base.size.ascent - letterX.size.ascent;
var width = base.size.width > this.operator.size.width ? base.size.width : this.operator.size.width,
height = base.size.height + this.operator.size.height + this.shiftX,
ascent = this.getAscent(oMeasure);
var ctrPrp = this.mergeCtrTPrp();
var ctrPrp = this.Get_CompiledCtrPrp();
oMeasure.SetFont(ctrPrp);
this.size = {height: height, width: width, ascent: ascent};
......@@ -4080,7 +3956,7 @@ CCharacter.prototype.draw = function(x, y, pGraphics)
{
this.elements[0][0].draw(x, y, pGraphics);
var mgCtrPrp = this.mergeCtrTPrp();
var mgCtrPrp = this.Get_CompiledCtrPrp();
var FontSize = mgCtrPrp.FontSize,
FontFamily = {Name: "Cambria Math", Index: -1};
......@@ -4199,7 +4075,7 @@ CGroupCharacter.prototype.getAscent = function(oMeasure)
var ascent;
//var shCent = DIV_CENT*this.getCtrPrp().FontSize;
var ctrPrp = this.getCtrPrp();
var ctrPrp = this.Get_CompiledCtrPrp();
var shCent = this.ParaMath.GetShiftCenter(oMeasure, ctrPrp);
if(this.vertJust === VJUST_TOP && this.loc === LOCATION_TOP)
......
......@@ -65,7 +65,7 @@ function CSignRadical()
}
CSignRadical.prototype.new_draw = function(x, y, pGraphics)
{
var txtPrp = this.Parent.getCtrPrp();
var txtPrp = this.Parent.Get_CompiledCtrPrp();
//var txtPrp = this.Parent.getTxtPrp();
var penW = txtPrp.FontSize*g_dKoef_pt_to_mm*0.042;
......@@ -158,7 +158,7 @@ CSignRadical.prototype.new_draw = function(x, y, pGraphics)
}
CSignRadical.prototype.draw = function(x, y, pGraphics)
{
var txtPrp = this.Parent.getCtrPrp();
var txtPrp = this.Parent.Get_CompiledCtrPrp();
//var txtPrp = this.Parent.getTxtPrp();
var penW = txtPrp.FontSize*g_dKoef_pt_to_mm*0.042;
......@@ -256,7 +256,7 @@ CSignRadical.prototype.draw = function(x, y, pGraphics)
}
CSignRadical.prototype.recalculateSize = function()
{
var txtPrp = this.Parent.getCtrPrp();
var txtPrp = this.Parent.Get_CompiledCtrPrp();
var sizeArg = this.Parent.getBase().size;
var height, width;
......@@ -380,7 +380,7 @@ CSignRadical.prototype.recalculateSize = function()
}
CSignRadical.prototype.old_recalculateSize = function()
{
var txtPrp = this.Parent.getCtrPrp();
var txtPrp = this.Parent.Get_CompiledCtrPrp();
var sizeArg = this.Parent.getBase().size;
var height, width;
......@@ -559,7 +559,7 @@ CSignRadical.prototype.old_recalculateSize = function()
}
CSignRadical.prototype.old_old_recalculateSize = function()
{
var txtPrp = this.Parent.getCtrPrp();
var txtPrp = this.Parent.Get_CompiledCtrPrp();
var sizeArg = this.Parent.getBase().size;
var height, width;
......@@ -719,7 +719,7 @@ CSignRadical.prototype.old_old_recalculateSize = function()
}
CSignRadical.prototype.old_draw = function(x, y, pGraphics)
{
var txtPrp = this.Parent.getCtrPrp();
var txtPrp = this.Parent.Get_CompiledCtrPrp();
//var txtPrp = this.Parent.getTxtPrp();
var penW = txtPrp.FontSize*g_dKoef_pt_to_mm*0.042;
......@@ -794,7 +794,7 @@ CSignRadical.prototype.old_draw = function(x, y, pGraphics)
CSignRadical.prototype.old_recalculateSize = function()
{
//var txtPrp = this.Parent.getTxtPrp();
var txtPrp = this.Parent.getCtrPrp();
var txtPrp = this.Parent.Get_CompiledCtrPrp();
var sizeArg = this.Parent.getBase().size;
var height, width;
......@@ -939,7 +939,7 @@ CRadical.prototype.recalculateSize = function(oMeasure)
{
this.signRadical.recalculateSize(oMeasure);
var txtPrp = this.getCtrPrp();
var txtPrp = this.Get_CompiledCtrPrp();
var sign = this.signRadical.size,
gSign = this.signRadical.gapSign,
// в случае смещения baseline контента тоже смещается, и по высоте артгумент может выйти чуть за пределы (т.о. значок интеграла будет расположен чуть выше, чем следовало бы, и размер аргумента выйде за аграницы)
......
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