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

удалила CMathComposition

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@55948 954022d7-b5bf-4e40-9824-e11837661b57
parent 89b57a9b
...@@ -8,9 +8,15 @@ function ParaMath(bAddMenu) ...@@ -8,9 +8,15 @@ function ParaMath(bAddMenu)
this.Type = para_Math; this.Type = para_Math;
this.Jc = undefined; this.Jc = undefined;
this.Math = new CMathComposition(); //this.Math = new CMathComposition();
this.Math.Parent = this; //this.Math.Parent = this;
this.Root = this.Math.Root; //this.Root = this.Math.Root;
this.Root = new CMathContent();
this.X = 0;
this.Y = 0;
//this.CurrentContent = this.RootComposition; //this.CurrentContent = this.RootComposition;
//this.SelectContent = this.RootComposition; //this.SelectContent = this.RootComposition;
this.bSelectionUse = false; this.bSelectionUse = false;
...@@ -51,7 +57,17 @@ ParaMath.prototype = ...@@ -51,7 +57,17 @@ ParaMath.prototype =
// TODO: ParaMath.Copy // TODO: ParaMath.Copy
var NewMath = new ParaMath(); var NewMath = new ParaMath();
this.Root.Copy(Selected); var NewRoot;
if(Selected)
{
var Content = this.GetSelectContent();
NewRoot = Content.Copy(Selected, this);
}
else
{
NewRoot = this.Root.Copy(Selected, this);
}
return NewMath; return NewMath;
}, },
...@@ -388,15 +404,16 @@ ParaMath.prototype = ...@@ -388,15 +404,16 @@ ParaMath.prototype =
var TextPr = new CTextPr(); var TextPr = new CTextPr();
TextPr.Init_Default(); TextPr.Init_Default();
this.Math.RecalculateComposition(g_oTextMeasurer, TextPr); //this.Math.RecalculateComposition(g_oTextMeasurer, TextPr);
var Size = this.Math.Size; this.Root.Resize(g_oTextMeasurer, TextPr);
this.Root.setPosition({x: 0, y: 0});
this.Width = Size.Width; this.Width = this.Root.size.width;
this.Height = Size.Height; this.Height = this.Root.size.height;
this.WidthVisible = Size.WidthVisible; this.WidthVisible = this.Root.size.width;
this.Ascent = Size.Ascent; this.Ascent = this.Root.size.ascent;
this.Descent = Size.Descent; this.Descent = this.Root.size.height - this.Root.size.ascent;
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// TODO: ParaMath.Recalculate_Range // TODO: ParaMath.Recalculate_Range
...@@ -594,7 +611,9 @@ ParaMath.prototype = ...@@ -594,7 +611,9 @@ ParaMath.prototype =
this.WidthVisible = this.Width + PRSA.JustifyWord; this.WidthVisible = this.Width + PRSA.JustifyWord;
// Позиция в документе для формулы // Позиция в документе для формулы
this.Math.absPos = {x: PRSA.X, y: PRSA.Y - this.Root.size.ascent}; //this.Math.absPos = {x: PRSA.X, y: PRSA.Y - this.Root.size.ascent};
this.X = PRSA.X;
this.Y = PRSA.Y - this.Root.size.ascent;
PRSA.X += this.WidthVisible; PRSA.X += this.WidthVisible;
PRSA.LastW = this.WidthVisible; PRSA.LastW = this.WidthVisible;
...@@ -828,9 +847,8 @@ ParaMath.prototype = ...@@ -828,9 +847,8 @@ ParaMath.prototype =
if ( EndPos >= 1 ) if ( EndPos >= 1 )
{ {
//this.Math.Draw( PDSE.X, PDSE.Y - this.Root.size.ascent, PDSE.Graphics ); //this.Math.Draw( PDSE.X, PDSE.Y, PDSE.Graphics );
this.Root.draw( PDSE.X, PDSE.Y, PDSE.Graphics );
this.Math.Draw( PDSE.X, PDSE.Y, PDSE.Graphics );
PDSE.X += this.Width; PDSE.X += this.Width;
} }
}, },
...@@ -923,8 +941,11 @@ ParaMath.prototype = ...@@ -923,8 +941,11 @@ ParaMath.prototype =
var X = SearchPos.X, var X = SearchPos.X,
Y = SearchPos.Y; Y = SearchPos.Y;
SearchPos.X -= this.Math.absPos.x; //SearchPos.X -= this.Math.absPos.x;
SearchPos.Y -= this.Math.absPos.y; //SearchPos.Y -= this.Math.absPos.y;
SearchPos.X -= this.X;
SearchPos.Y -= this.Y;
...@@ -1135,8 +1156,8 @@ ParaMath.prototype = ...@@ -1135,8 +1156,8 @@ ParaMath.prototype =
if(!oCont.bRoot) if(!oCont.bRoot)
{ {
//SelectionDraw.StartY += oCont.pos.y; //SelectionDraw.StartY = this.Math.absPos.y + oCont.pos.y; // выставляем так, чтобы для формул с различной высотой в одной строке, всё было ok
SelectionDraw.StartY = this.Math.absPos.y + oCont.pos.y; // выставляем так, чтобы для формул с различной высотой в одной строке, всё было ok SelectionDraw.StartY = this.Y + oCont.pos.y; // выставляем так, чтобы для формул с различной высотой в одной строке, всё было ok
SelectionDraw.H = oCont.size.height; SelectionDraw.H = oCont.size.height;
} }
......
...@@ -64,10 +64,6 @@ function CMathBase() ...@@ -64,10 +64,6 @@ function CMathBase()
} }
CMathBase.prototype = CMathBase.prototype =
{ {
init_2: function(props)
{
this.Pr = Common_CopyObj(props);
},
setContent: function() setContent: function()
{ {
this.elements = new Array(); this.elements = new Array();
...@@ -100,7 +96,6 @@ CMathBase.prototype = ...@@ -100,7 +96,6 @@ CMathBase.prototype =
for(u=0; u < this.nRow; u++) for(u=0; u < this.nRow; u++)
this.alignment.wdt[u] = CENTER; this.alignment.wdt[u] = CENTER;
}, },
///////// RunPrp, CtrPrp ///////// RunPrp, CtrPrp
setCtrPrp: function(txtPrp) setCtrPrp: function(txtPrp)
...@@ -1554,6 +1549,10 @@ CMathBase.prototype = ...@@ -1554,6 +1549,10 @@ CMathBase.prototype =
IsPlaceholder: function() IsPlaceholder: function()
{ {
return false; return false;
},
Get_TxtPrp: function()
{
return this.getCtrPrp();
} }
////////////////////////// //////////////////////////
......
...@@ -43,7 +43,7 @@ CBorderBox.prototype.init = function(props) ...@@ -43,7 +43,7 @@ CBorderBox.prototype.init = function(props)
if(props.hideBot === true || props.hideBot === 1) if(props.hideBot === true || props.hideBot === 1)
this.bBot = false; this.bBot = false;
/*if(props.strikeBLTR === true || props.strikeBLTR === 1) if(props.strikeBLTR === true || props.strikeBLTR === 1)
this.bRDiag = true; this.bRDiag = true;
if(props.strikeTLBR === true || props.strikeTLBR === 1) if(props.strikeTLBR === true || props.strikeTLBR === 1)
...@@ -53,7 +53,7 @@ CBorderBox.prototype.init = function(props) ...@@ -53,7 +53,7 @@ CBorderBox.prototype.init = function(props)
this.bHor = true; this.bHor = true;
if(props.strikeV === true || props.strikeV === 1) if(props.strikeV === true || props.strikeV === 1)
this.bVert = true;*/ this.bVert = true;
} }
this.setDimension(1, 1); this.setDimension(1, 1);
......
...@@ -22,10 +22,10 @@ CFraction.prototype.init = function(props) ...@@ -22,10 +22,10 @@ CFraction.prototype.init = function(props)
bLin = props.type === LINEAR_FRACTION; bLin = props.type === LINEAR_FRACTION;
if(bBar || bSkew || bLin) // на всякий случай if(bBar || bSkew || bLin) // на всякий случай
this.Pr.type = props.type; this.type = props.type;
} }
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
{ {
var num = new CNumerator(); var num = new CNumerator();
num.init(); num.init();
...@@ -35,17 +35,17 @@ CFraction.prototype.init = function(props) ...@@ -35,17 +35,17 @@ CFraction.prototype.init = function(props)
this.setDimension(2, 1); this.setDimension(2, 1);
if(this.Pr.type == NO_BAR_FRACTION) if(this.type == NO_BAR_FRACTION)
this.bHideBar = true; this.bHideBar = true;
this.addMCToContent(num, den); this.addMCToContent(num, den);
} }
else if(this.Pr.type == SKEWED_FRACTION) else if(this.type == SKEWED_FRACTION)
{ {
this.setDimension(1, 2); this.setDimension(1, 2);
this.setContent(); this.setContent();
} }
else if(this.Pr.type == LINEAR_FRACTION) else if(this.type == LINEAR_FRACTION)
{ {
this.setDimension(1, 2); this.setDimension(1, 2);
this.setContent(); this.setContent();
...@@ -56,15 +56,15 @@ CFraction.prototype.init = function(props) ...@@ -56,15 +56,15 @@ CFraction.prototype.init = function(props)
} }
CFraction.prototype.getType = function() CFraction.prototype.getType = function()
{ {
return this.Pr.type; return this.type;
} }
CFraction.prototype.draw = function(x, y, pGraphics) CFraction.prototype.draw = function(x, y, pGraphics)
{ {
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
this.drawBarFraction(x, y, pGraphics); this.drawBarFraction(x, y, pGraphics);
else if(this.Pr.type == SKEWED_FRACTION) else if(this.type == SKEWED_FRACTION)
this.drawSkewedFraction(x, y, pGraphics); this.drawSkewedFraction(x, y, pGraphics);
else if(this.Pr.type == LINEAR_FRACTION) else if(this.type == LINEAR_FRACTION)
this.drawLinearFraction(x, y, pGraphics); this.drawLinearFraction(x, y, pGraphics);
} }
CFraction.prototype.drawBarFraction = function(x, y, pGraphics) CFraction.prototype.drawBarFraction = function(x, y, pGraphics)
...@@ -230,7 +230,7 @@ CFraction.prototype.getNumerator = function() ...@@ -230,7 +230,7 @@ CFraction.prototype.getNumerator = function()
{ {
var numerator; var numerator;
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
numerator = this.elements[0][0].getElement(); numerator = this.elements[0][0].getElement();
else else
numerator = this.elements[0][0]; numerator = this.elements[0][0];
...@@ -241,7 +241,7 @@ CFraction.prototype.getDenominator = function() ...@@ -241,7 +241,7 @@ CFraction.prototype.getDenominator = function()
{ {
var denominator; var denominator;
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
denominator = this.elements[1][0].getElement(); denominator = this.elements[1][0].getElement();
else else
denominator = this.elements[0][1]; denominator = this.elements[0][1];
...@@ -250,11 +250,11 @@ CFraction.prototype.getDenominator = function() ...@@ -250,11 +250,11 @@ CFraction.prototype.getDenominator = function()
} }
CFraction.prototype.recalculateSize = function(oMeasure) CFraction.prototype.recalculateSize = function(oMeasure)
{ {
if(this.Pr.type == BAR_FRACTION || this.Pr.type == NO_BAR_FRACTION) if(this.type == BAR_FRACTION || this.type == NO_BAR_FRACTION)
this.recalculateBarFraction(oMeasure); this.recalculateBarFraction(oMeasure);
else if(this.Pr.type == SKEWED_FRACTION) else if(this.type == SKEWED_FRACTION)
this.recalculateSkewed(oMeasure); this.recalculateSkewed(oMeasure);
else if(this.Pr.type == LINEAR_FRACTION) else if(this.type == LINEAR_FRACTION)
this.recalculateLinear(oMeasure); this.recalculateLinear(oMeasure);
} }
CFraction.prototype.recalculateBarFraction = function(oMeasure) CFraction.prototype.recalculateBarFraction = function(oMeasure)
...@@ -326,7 +326,7 @@ CFraction.prototype.recalculateLinear = function() ...@@ -326,7 +326,7 @@ CFraction.prototype.recalculateLinear = function()
} }
CFraction.prototype.setPosition = function(pos) CFraction.prototype.setPosition = function(pos)
{ {
if(this.Pr.type == SKEWED_FRACTION) if(this.type == SKEWED_FRACTION)
{ {
this.pos = {x: pos.x, y: pos.y - this.size.ascent}; this.pos = {x: pos.x, y: pos.y - this.size.ascent};
...@@ -347,7 +347,7 @@ CFraction.prototype.findDisposition = function( mCoord ) ...@@ -347,7 +347,7 @@ CFraction.prototype.findDisposition = function( mCoord )
{ {
var disposition; var disposition;
if(this.Pr.type == SKEWED_FRACTION) if(this.type == SKEWED_FRACTION)
{ {
var mouseCoord = {x: mCoord.x, y: mCoord.y}, var mouseCoord = {x: mCoord.x, y: mCoord.y},
posCurs = {x: null, y: null}, posCurs = {x: null, y: null},
...@@ -413,13 +413,13 @@ CFraction.prototype.findDisposition = function( mCoord ) ...@@ -413,13 +413,13 @@ CFraction.prototype.findDisposition = function( mCoord )
CFraction.prototype.getPropsForWrite = function() CFraction.prototype.getPropsForWrite = function()
{ {
var type = null; var type = null;
if (this.Pr.type == BAR_FRACTION) if (this.type == BAR_FRACTION)
type = 0; type = 0;
else if (this.Pr.type == LINEAR_FRACTION) else if (this.type == LINEAR_FRACTION)
type = 1; type = 1;
else if (this.Pr.type == NO_BAR_FRACTION) else if (this.type == NO_BAR_FRACTION)
type = 2; type = 2;
else if (this.Pr.type == SKEWED_FRACTION) else if (this.type == SKEWED_FRACTION)
type = 3; type = 3;
var props = { var props = {
......
...@@ -823,9 +823,6 @@ CMPrp.prototype = ...@@ -823,9 +823,6 @@ CMPrp.prototype =
// 1. (!!) повтор IsIncline, IsHighElement // 1. (!!) повтор IsIncline, IsHighElement
// TODO List
// посмотреть баг, когда выходим за пределы мат объекта и добавляем букву
function CMathContent() function CMathContent()
{ {
this.Id = g_oIdCounter.Get_NewId(); this.Id = g_oIdCounter.Get_NewId();
...@@ -5227,9 +5224,9 @@ CMathContent.prototype = ...@@ -5227,9 +5224,9 @@ CMathContent.prototype =
} }
else if(this.content[this.CurPos].typeObj == MATH_PARA_RUN) else if(this.content[this.CurPos].typeObj == MATH_PARA_RUN)
{ {
var absPos = this.Composition.absPos; //var absPos = this.Composition.absPos;
var X = this.pos.x + absPos.x + this.WidthToElement[this.CurPos], var X = this.pos.x + this.Composition.X + this.WidthToElement[this.CurPos],
Y = this.pos.y + absPos.y + this.size.ascent; Y = this.pos.y + this.Composition.Y + this.size.ascent;
result = this.content[this.CurPos].Math_Update_Cursor(X, Y, CurPage, UpdateTarget); result = this.content[this.CurPos].Math_Update_Cursor(X, Y, CurPage, UpdateTarget);
} }
...@@ -5824,20 +5821,20 @@ CMathContent.prototype = ...@@ -5824,20 +5821,20 @@ CMathContent.prototype =
} }
else if(this.content[this.CurPos].typeObj == MATH_PARA_RUN) else if(this.content[this.CurPos].typeObj == MATH_PARA_RUN)
{ {
var absPos = this.Composition.absPos; //var absPos = this.Composition.absPos;
Y = this.pos.y + absPos.y + this.size.ascent; Y = this.pos.y + this.Composition.Y + this.size.ascent;
_X = this.pos.x + absPos.x + this.WidthToElement[this.CurPos]; _X = this.pos.x + this.Composition.X + this.WidthToElement[this.CurPos];
result = this.content[this.CurPos].Recalculate_CurPos(_X, Y, CurrentRun, 0, 0, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget); result = this.content[this.CurPos].Recalculate_CurPos(_X, Y, CurrentRun, 0, 0, _CurPage, UpdateCurPos, UpdateTarget, ReturnTarget);
} }
else else
{ {
var absPos = this.Composition.absPos; //var absPos = this.Composition.absPos;
Y = this.pos.y + absPos.y + this.size.ascent; Y = this.pos.y + this.Composition.Y + this.size.ascent;
_X = this.pos.x + absPos.x + this.size.width; _X = this.pos.x + this.Composition.X + this.size.width;
var ctrPrp = this.Parent.getCtrPrp(); var ctrPrp = this.Parent.getCtrPrp();
this.Composition.Parent.ApplyArgSize(ctrPrp); this.Composition.Parent.ApplyArgSize(ctrPrp);
...@@ -6059,8 +6056,12 @@ CMathContent.prototype = ...@@ -6059,8 +6056,12 @@ CMathContent.prototype =
if(bCurrComp && !bLeftRun) // добавление пустого Run перед мат объектом if(bCurrComp && !bLeftRun) // добавление пустого Run перед мат объектом
{ {
NewContent.push( new ParaRun(this.Composition.Parent.Paragraph, true) ); var emptyRun = new ParaRun(this.Composition.Parent.Paragraph, true);
NewContent.push( this.content[i] ); // Math Object var txtPrp = current.Get_TxtPrp();
emptyRun.Set_Pr(txtPrp);
NewContent.push(emptyRun);
NewContent.push(this.content[i]); // Math Object
left = current; left = current;
...@@ -6078,7 +6079,11 @@ CMathContent.prototype = ...@@ -6078,7 +6079,11 @@ CMathContent.prototype =
if(len > 0 && this.content[len - 1].typeObj == MATH_COMP) if(len > 0 && this.content[len - 1].typeObj == MATH_COMP)
{ {
NewContent.push( new ParaRun(this.Composition.Parent.Paragraph, true) ); var emptyRun = new ParaRun(this.Composition.Parent.Paragraph, true);
var txtPrp = current.Get_TxtPrp();
emptyRun.Set_Pr(txtPrp);
NewContent.push(emptyRun);
} }
this.content = NewContent; this.content = NewContent;
...@@ -6105,7 +6110,7 @@ CMathContent.prototype = ...@@ -6105,7 +6110,7 @@ CMathContent.prototype =
} }
else if(this.content[pos].typeObj == MATH_PARA_RUN) // проверка на gaps в findDisposition else if(this.content[pos].typeObj == MATH_PARA_RUN) // проверка на gaps в findDisposition
{ {
SearchPos.X += this.pos.x + this.Composition.absPos.x + this.WidthToElement[pos]; SearchPos.X += this.pos.x + this.Composition.X + this.WidthToElement[pos];
SearchPos.CurX += this.pos.x + this.WidthToElement[pos]; SearchPos.CurX += this.pos.x + this.WidthToElement[pos];
this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth, 0, 0); this.content[pos].Get_ParaContentPosByXY(SearchPos, Depth, 0, 0);
} }
...@@ -6345,6 +6350,28 @@ CMathContent.prototype = ...@@ -6345,6 +6350,28 @@ CMathContent.prototype =
}, },
Copy: function(Selected) Copy: function(Selected)
{ {
var start, end;
if(Selected)
{
start = this.SelectStartPos;
end = this.SelectEndPos;
}
else
{
start = 0;
end = this.content.length - 1;
}
var content = new CMathContent();
for(var i = start; i < end; i++)
{
var element = this.content[i].Copy(Selected);
content.Copy(element);
}
}, },
Selection_Remove: function() Selection_Remove: function()
......
...@@ -55,6 +55,11 @@ var BOX_ALIGN = 2; ...@@ -55,6 +55,11 @@ var BOX_ALIGN = 2;
var BOX_BREAK = 3; var BOX_BREAK = 3;
var BOX_NOBREAK = 4; var BOX_NOBREAK = 4;
////////////////////////////////////////////////////
// operators:
// accent, delimiters, group character
var OPERATOR_EMPTY = -1; var OPERATOR_EMPTY = -1;
var OPERATOR_TEXT = 0; var OPERATOR_TEXT = 0;
var PARENTHESIS_LEFT = 1; var PARENTHESIS_LEFT = 1;
...@@ -87,6 +92,26 @@ var ACCENT_ARROW_LR = 28; ...@@ -87,6 +92,26 @@ var ACCENT_ARROW_LR = 28;
var ACCENT_HALF_ARROW_LEFT = 29; var ACCENT_HALF_ARROW_LEFT = 29;
var ACCENT_HALF_ARROW_RIGHT = 30; var ACCENT_HALF_ARROW_RIGHT = 30;
var ACCENT_ONE_DOT = 31;
var ACCENT_TWO_DOTS = 32;
var ACCENT_THREE_DOTS = 33;
var ACCENT_GRAVE = 34;
var ACCENT_ACUTE = 35;
var ACCENT_CIRCUMFLEX = 36;
var ACCENT_COMB_CARON = 37;
var ACCENT_LINE = 38;
var ACCENT_DOUBLE_LINE = 39;
var SINGLE_LINE = 40;
var DOUBLE_LINE = 41;
var ACCENT_TILDE = 42;
var ACCENT_BREVE = 43;
var ACCENT_INVERT_BREVE = 44;
var ACCENT_SIGN = 45;
var ACCENT_TEXT = 46;
///////////////////////////////////////////////////
var TXT_NORMAL = 0; var TXT_NORMAL = 0;
var TXT_ROMAN = 1; // math roman var TXT_ROMAN = 1; // math roman
var TXT_SCRIPT = 2; var TXT_SCRIPT = 2;
...@@ -113,25 +138,6 @@ var DELIMITER_SHAPE_CENTERED = 1; ...@@ -113,25 +138,6 @@ var DELIMITER_SHAPE_CENTERED = 1;
var LIMIT_LOW = 0; var LIMIT_LOW = 0;
var LIMIT_UP = 1; var LIMIT_UP = 1;
//////////////////////////////////////////
var ACCENT_ONE_DOT = 0;
var ACCENT_TWO_DOTS = 1;
var ACCENT_THREE_DOTS = 2;
var ACCENT_GRAVE = 3;
var ACCENT_ACUTE = 4;
var ACCENT_CIRCUMFLEX = 5;
var ACCENT_COMB_CARON = 6;
var ACCENT_LINE = 7;
var ACCENT_DOUBLE_LINE = 8;
var SINGLE_LINE = 9;
var DOUBLE_LINE = 10;
var ACCENT_TILDE = 11;
var ACCENT_BREVE = 12;
var ACCENT_INVERT_BREVE = 13;
var ACCENT_SIGN = 19;
var ACCENT_TEXT = 20;
///////////////////////////////////////// /////////////////////////////////////////
var MCJC_CENTER = 0; var MCJC_CENTER = 0;
......
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