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

1. Поправлен баг с неправильным расчетом Recalculate_Range для степени

2. В связи с использованием функций для ускорения внесен ряд правок для корректной работы пересчета формул
3. Поправлен баг: падение документа(с амперсандами) на открытии
4. При принятии решения о быстром пересчете учитываются изменение макс ширины формулы на странице(для выравнивания формулы), изменение wrapIndent 


git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62697 954022d7-b5bf-4e40-9824-e11837661b57
parent cb0c3320
This diff is collapsed.
......@@ -13290,9 +13290,12 @@ function CParagraphGetDropCapText()
function CRunRecalculateObject(StartLine, StartRange)
{
this.StartLine = StartLine;
this.StartRange = StartRange
this.StartRange = StartRange;
this.Lines = [];
this.Content = [];
this.MathInfo = null;
//this.WrapState = ALIGN_EMPTY;
}
CRunRecalculateObject.prototype =
......@@ -13322,6 +13325,13 @@ CRunRecalculateObject.prototype =
}
},
Save_MathInfo: function(Obj, Copy)
{
this.MathInfo = Obj.Save_MathInfo(Copy);
//this.WrapState = Obj.GetCurrentWrapState();
},
Load_Lines : function(Obj)
{
Obj.StartLine = this.StartLine;
......@@ -13338,6 +13348,11 @@ CRunRecalculateObject.prototype =
}
},
Load_MathInfo: function(Obj)
{
Obj.Load_MathInfo(this.MathInfo);
},
Save_RunContent : function(Run, Copy)
{
var ContentLen = Run.Content.length;
......@@ -13376,7 +13391,12 @@ CRunRecalculateObject.prototype =
Compare : function(_CurLine, _CurRange, OtherLinesInfo)
{
var OLI = OtherLinesInfo;
var OLI = para_Math === OtherLinesInfo.Type ? OtherLinesInfo.Root : OtherLinesInfo;
if(para_Math === OtherLinesInfo.Type && OtherLinesInfo.CompareMathInfo(this.MathInfo) == false /*this.WrapState !== OtherLinesInfo.GetCurrentWrapState()*/)
{
return false;
}
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -13385,9 +13405,11 @@ CRunRecalculateObject.prototype =
if ( ( 0 === this.Lines.length || 0 === this.LinesLength ) && ( 0 === OLI.Lines.length || 0 === OLI.LinesLength ) )
return true;
if ( this.StartLine !== OLI.StartLine || this.StartRange !== OLI.StartRange || CurLine < 0 || CurLine >= this.private_Get_LinesCount() || CurLine >= OLI.protected_GetLinesCount() || CurRange < 0 || CurRange >= this.private_Get_RangesCount(CurLine) || CurRange >= OLI.protected_GetRangesCount(CurLine) )
return false;
var ThisSP = this.private_Get_RangeStartPos(CurLine, CurRange);
var ThisEP = this.private_Get_RangeEndPos(CurLine, CurRange);
......@@ -13397,7 +13419,7 @@ CRunRecalculateObject.prototype =
if ( ThisSP !== OtherSP || ThisEP !== OtherEP )
return false;
if ( ( (OLI.Content === undefined || para_Run === OLI.Type) && this.Content.length > 0 ) || ( OLI.Content !== undefined && para_Run !== OLI.Type && OLI.Content.length !== this.Content.length) )
if ( ( (OLI.Content === undefined || para_Run === OLI.Type || para_Math_Run === OLI.Type) && this.Content.length > 0 ) || ( OLI.Content !== undefined && para_Run !== OLI.Type && para_Math_Run !== OLI.Type && OLI.Content.length !== this.Content.length) )
return false;
var ContentLen = this.Content.length;
......
......@@ -424,6 +424,7 @@ Paragraph.prototype.private_RecalculateFastRange = function(CurRange, CurL
{
// TODO: Надо бы перенести эту проверку на изменение контента параграфа
Item.Set_Inline(true === this.Check_MathPara(Pos)? false : true);
PRS.bFastRecalculate = true; // чтобы не обновить случайно StartLine (Recalculate_Reset)
}
PRS.Update_CurPos( Pos, 0 );
......@@ -2181,6 +2182,7 @@ function CParagraphRecalculateStateWrap(Para)
this.OperGapRight = 0;
this.OperGapLeft = 0;
this.bInsideOper = false; // учитываем есть ли разбивка внутри мат объекта, чтобы случайно не вставить в конец пред оператора (при Brk_Before == false)
this.bFastRecalculate = false;
}
CParagraphRecalculateStateWrap.prototype =
......@@ -2213,7 +2215,8 @@ CParagraphRecalculateStateWrap.prototype =
this.OperGapLeft = 0;
this.WrapIndent = 0;
this.bFirstCompareOper = true;
this.bInsideOper = false;
this.bInsideOper = false;
this.bFastRecalculate = false;
},
// Обнуляем некоторые параметры перед новым отрезком
......@@ -2242,10 +2245,11 @@ CParagraphRecalculateStateWrap.prototype =
this.PosEndRun = new CParagraphContentPos();
this.OperGapRight = 0;
this.OperGapLeft = 0;
this.OperGapLeft = 0;
this.WrapIndent = 0;
this.bFirstCompareOper = true;
this.bInsideOper = false;
this.bFastRecalculate = false;
},
Reset_PrevLineRecalcInfo : function()
......
......@@ -97,9 +97,15 @@ ParaRun.prototype.Set_Paragraph = function(Paragraph)
this.Paragraph = Paragraph;
};
ParaRun.prototype.Set_ParaMath = function(ParaMath)
ParaRun.prototype.Set_ParaMath = function(ParaMath, Parent)
{
this.ParaMath = ParaMath;
this.Parent = Parent;
for(var i = 0; i < this.Content.length; i++)
{
this.Content[i].relate(this);
}
};
ParaRun.prototype.Save_StartState = function()
{
......
......@@ -550,7 +550,7 @@ CAccent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
PRS.bInsideOper = false;
var oBase = this.getBase();
oBase.Recalculate_Reset(PRS.Range, PRS.Line ); // обновим StartLine и StartRange
oBase.Recalculate_Reset(PRS.Range, PRS.Line, PRS ); // обновим StartLine и StartRange
oBase.Recalculate_Range(PRS, ParaPr, Depth);
this.operator.fixSize(g_oTextMeasurer, oBase.size.width);
......
......@@ -1104,23 +1104,32 @@ CMathBase.prototype.Get_Width = function(_CurLine)
var CurLine = _CurLine - this.StartLine;
return this.Bounds.GetWidth(CurLine);
};
CMathBase.prototype.Set_Paragraph = CParagraphContentWithParagraphLikeContent.prototype.Set_Paragraph;
CMathBase.prototype.Get_ElementByPos = CParagraphContentWithParagraphLikeContent.prototype.Get_ElementByPos;
CMathBase.prototype.Get_ParaPosByContentPos = CParagraphContentWithParagraphLikeContent.prototype.Get_ParaPosByContentPos;
CMathBase.prototype.Set_ParaMath = CMathContent.prototype.Set_ParaMath;
CMathBase.prototype.Recalculate_Reset = function(StartRange, StartLine)
CMathBase.prototype.Save_RecalculateObject = function(Copy)
{
this.StartLine = StartLine;
this.StartRange = StartRange;
var RecalcObj;
if(this.bOneLine)
{
RecalcObj = new CEmptyRunRecalculateObject(this.StartLine, this.StartRange);
}
else
{
RecalcObj = CMathBase.superclass.Save_RecalculateObject.call(this, Copy);
}
this.protected_ClearLines();
return RecalcObj;
};
CMathBase.prototype.Load_RecalculateObject = function(RecalcObj)
{
if(this.bOneLine == false)
CMathBase.superclass.Load_RecalculateObject.call(this, RecalcObj);
/*for (var nPos = 0, nCount = this.Content.length; nPos < nCount; nPos++)
{
this.Content[nPos].Recalculate_Reset(StartRange, StartLine);
}*/
};
CMathBase.prototype.Set_Paragraph = CParagraphContentWithParagraphLikeContent.prototype.Set_Paragraph;
CMathBase.prototype.Get_ElementByPos = CParagraphContentWithParagraphLikeContent.prototype.Get_ElementByPos;
CMathBase.prototype.Get_ParaPosByContentPos = CParagraphContentWithParagraphLikeContent.prototype.Get_ParaPosByContentPos;
CMathBase.prototype.Set_ParaMath = CMathContent.prototype.Set_ParaMath;
CMathBase.prototype.Recalculate_Reset = CMathContent.prototype.Recalculate_Reset;
CMathBase.prototype.Fill_LogicalContent = function(nCount)
{
for (var nIndex = 0; nIndex < nCount; nIndex++)
......@@ -1765,7 +1774,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
}
else
{
Item.Recalculate_Reset(PRS.Range, PRS.Line); // обновим StartLine и StartRange
Item.Recalculate_Reset(PRS.Range, PRS.Line, PRS); // обновим StartLine и StartRange
Item.Recalculate_Range(PRS, ParaPr, Depth);
}
}
......@@ -1805,7 +1814,7 @@ CMathBase.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
var NeedSetReset = CurLine == 0 && CurRange == 0 || Pos !== RangeStartPos;
if(Item.Type == para_Math_Content && NeedSetReset)
Item.Recalculate_Reset(PRS.Range, PRS.Line); // обновим StartLine и StartRange
Item.Recalculate_Reset(PRS.Range, PRS.Line, PRS); // обновим StartLine и StartRange
if(Pos == Numb)
{
......@@ -2270,3 +2279,68 @@ CMathBoundsMeasures.prototype.GetY = function()
{
return this.Y + this.Asc;
};
function CEmptyRunRecalculateObject(StartLine, StartRange)
{
this.StartLine = StartLine;
this.StartRange = StartRange;
this.Lines = [];
this.Content = [];
this.WrapState = ALIGN_EMPTY;
}
CEmptyRunRecalculateObject.prototype =
{
Save_Lines : function(Obj, Copy)
{
},
Save_Content : function(Obj, Copy)
{
},
Save_WrapState: function(Obj, Copy)
{
},
Load_Lines : function(Obj)
{
},
Load_Content : function(Obj)
{
},
Load_WrapState: function(Obj)
{
},
Save_RunContent : function(Run, Copy)
{
},
Load_RunContent : function(Run)
{
},
Get_DrawingFlowPos : function(FlowPos)
{
},
Compare : function(_CurLine, _CurRange, OtherLinesInfo)
{
return true;
}
};
\ No newline at end of file
......@@ -91,6 +91,8 @@ CDegreeBase.prototype.Resize = function(oMeasure, RPI)
this.iterContent.Resize(oMeasure, RPI);
this.setDistance();
if(this.Pr.type === DEGREE_SUPERSCRIPT)
this.GetSizeSup(oMeasure);
else if(this.Pr.type === DEGREE_SUBSCRIPT)
......@@ -102,6 +104,8 @@ CDegreeBase.prototype.recalculateSize = function(oMeasure)
Metric.UpdateMetrics(this.baseContent.size);
Metric.UpdateWidth(this.baseContent.size.width);
this.setDistance();
var ResultSize;
if(this.Pr.type === DEGREE_SUPERSCRIPT)
......@@ -189,11 +193,6 @@ CDegreeBase.prototype.GetSizeSup = function(oMeasure, Metric)
this.upIter -= ascent;
if( this.bNaryInline)
this.dW = 0.17*PlH;
else
this.dW = 0.056*PlH;
var width = baseWidth + iter.width + this.dW;
width += this.GapLeft + this.GapRight;
......@@ -273,11 +272,6 @@ CDegreeBase.prototype.GetSizeSubScript = function(oMeasure, Metric)
this.upIter -= ascent;
if( this.bNaryInline)
this.dW = 0.17*PlH;
else
this.dW = 0.056*PlH;
var width = baseWidth + iter.width + this.dW;
width += this.GapLeft + this.GapRight;
......@@ -289,6 +283,16 @@ CDegreeBase.prototype.GetSizeSubScript = function(oMeasure, Metric)
return ResultSize;
};
CDegreeBase.prototype.setDistance = function()
{
var mgCtrPrp = this.Get_TxtPrControlLetter();
var PlH = 0.64*this.ParaMath.GetPlh(g_oTextMeasurer, mgCtrPrp);
if( this.bNaryInline)
this.dW = 0.17*PlH;
else
this.dW = 0.056*PlH;
};
CDegreeBase.prototype.setPosition = function(pos, PRSA, Line, Range, Page)
{
this.UpdatePosBound(pos, PRSA, Line, Range, Page);
......@@ -886,7 +890,7 @@ CDegreeSubSup.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if(CurLine == 0 && CurRange == 0)
{
PRS.WordLen += this.BrGapLeft;
this.baseContent.Recalculate_Reset(PRS.Range, PRS.Line);
this.baseContent.Recalculate_Reset(PRS.Range, PRS.Line, PRS);
}
PRS.Update_CurPos(0, Depth);
......
......@@ -7,7 +7,7 @@ function CRPI()
this.bInline = false;
this.bChangeInline = false;
this.bNaryInline = false; /*для CDegreeSupSub внутри N-арного оператора, этот флаг необходим, чтобы итераторы максимально близко друг к другу расположить*/
this.bEqArray = false; /*для амперсанда*/
this.bEqArray = false; /*для амперсанда*/
this.bMathFunc = false;
this.bRecalcCtrPrp = false; // пересчет ctrPrp нужен, когда на Undo и тп изменился размер первого Run, а ctrPrp уже для мат объектов пересчитались
this.PRS = null;
......@@ -21,9 +21,9 @@ CRPI.prototype.Copy = function()
RPI.bDecreasedComp = this.bDecreasedComp;
RPI.bChangeInline = this.bChangeInline;
RPI.bNaryInline = this.bNaryInline;
RPI.bEqArray = this.bEqArray;
RPI.bEqArray = this.bEqArray;
RPI.bMathFunc = this.bMathFunc;
RPI.bRecalcCtrPrp = this.bRecalcCtrPrp;
RPI.bRecalcCtrPrp = this.bRecalcCtrPrp;
RPI.PRS = this.PRS;
return RPI;
......@@ -189,6 +189,12 @@ AmperWidths.prototype.SetDefault = function()
this.Widths.length = 0;
};
function CGeneralObjectGaps(Left, Right)
{
this.left = Left;
this.right = Right;
}
function CGaps(oSign, oEqual, oZeroOper, oLett)
{
......@@ -200,29 +206,25 @@ function CGaps(oSign, oEqual, oZeroOper, oLett)
function CCoeffGaps()
{
this.Sign =
{
left: new CGaps(0.52, 0.26, 0, 0.52),
right: new CGaps(0.49, 0, 0, 0.49)
};
var LeftSign = new CGaps(0.52, 0.26, 0, 0.52),
RightSign = new CGaps(0.49, 0, 0, 0.49);
this.Mult =
{
left: new CGaps(0, 0, 0, 0.46),
right: new CGaps(0, 0, 0, 0.49)
};
this.Sign = new CGeneralObjectGaps(LeftSign, RightSign);
this.Equal =
{
left: new CGaps(0, 0, 0, 0.7),
right: new CGaps(0, 0, 0, 0.5)
};
var LeftMult = new CGaps(0, 0, 0, 0.46),
RightMult = new CGaps(0, 0, 0, 0.49);
this.Default =
{
left: new CGaps(0, 0, 0, 0),
right: new CGaps(0, 0, 0, 0)
};
this.Mult = new CGeneralObjectGaps(LeftMult, RightMult);
var LeftEqual = new CGaps(0, 0, 0, 0.7),
RightEqual = new CGaps(0, 0, 0, 0.5);
this.Equal = new CGeneralObjectGaps(LeftEqual, RightEqual);
var LeftDefault = new CGaps(0, 0, 0, 0),
RightDefault = new CGaps(0, 0, 0, 0);
this.Default = new CGeneralObjectGaps(LeftDefault, RightDefault);
}
CCoeffGaps.prototype =
{
......@@ -3938,7 +3940,7 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
// для однострочных мат объектов обновляем CurLine и CurRange, Run в этом случае не могут разбиваться на несколько строк
if (this.bOneLine || (0 === Pos && 0 === CurLine && 0 === CurRange ) || Pos !== RangeStartPos)
Item.Recalculate_Reset( PRS.Range, PRS.Line );
Item.Recalculate_Reset( PRS.Range, PRS.Line, PRS );
PRS.Update_CurPos( Pos, Depth );
......@@ -4087,6 +4089,17 @@ CMathContent.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
};
CMathContent.prototype.Recalculate_Reset = function(StartRange, StartLine, PRS)
{
var bNotUpdate = PRS !== null && PRS!== undefined && PRS.bFastRecalculate == true;
if(bNotUpdate == false)
{
this.StartLine = StartLine;
this.StartRange = StartRange;
this.protected_ClearLines();
}
};
CMathContent.prototype.IsEmptyLine = function(_CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
......@@ -4315,10 +4328,9 @@ CMathContent.prototype.Math_Is_End = function(_CurLine, _CurRange)
return result;
};
CMathContent.prototype.IsFirstLine = function(Line)
CMathContent.prototype.IsStartLine = function(Line)
{
var CurLine = Line - this.StartLine;
return CurLine == 0;
return Line - this.StartLine == 0;
};
CMathContent.prototype.IsFirstRange = function(Line, Range)
{
......
......@@ -741,24 +741,19 @@ CMathText.prototype =
},
setPosition: function(pos)
{
try
if (!this.bJDraw) // for text
{
if (!this.bJDraw) // for text
{
this.pos.x = pos.x;
this.pos.y = pos.y;
}
else // for symbol only drawing
{
this.pos.x = pos.x - this.rasterOffsetX;
this.pos.y = pos.y - this.rasterOffsetY + this.size.ascent;
}
this.pos.x = pos.x;
this.pos.y = pos.y;
}
catch(e)
else // for symbol only drawing
{
this.pos.x = pos.x - this.rasterOffsetX;
this.pos.y = pos.y - this.rasterOffsetY + this.size.ascent;
}
},
GetLocationOfLetter: function()
{
......@@ -978,6 +973,14 @@ CMathAmp.prototype =
{
return this.size.width + this.GapLeft + this.GapRight;
},
Get_Width2: function()
{
return ( (this.size.width + this.GapLeft + this.GapRight)* TEXTWIDTH_DIVIDER ) | 0;
},
relate: function(parent)
{
this.Parent = parent;
},
setPosition: function(pos)
{
this.pos.x = pos.x;
......
......@@ -490,9 +490,9 @@ CNary.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
else
{
PRS.bMath_OneLine = true;
this.Base.Recalculate_Reset(PRS.Range, PRS.Line);
this.LowerIterator.Recalculate_Reset(PRS.Range, PRS.Line);
this.UpperIterator.Recalculate_Reset(PRS.Range, PRS.Line);
this.Base.Recalculate_Reset(PRS.Range, PRS.Line, PRS);
this.LowerIterator.Recalculate_Reset(PRS.Range, PRS.Line, PRS);
this.UpperIterator.Recalculate_Reset(PRS.Range, PRS.Line, PRS);
this.Base.Recalculate_Range(PRS, ParaPr, Depth);
}
......@@ -509,7 +509,7 @@ CNary.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
PRS.WordLen += this.dW;
this.Arg.Recalculate_Reset(PRS.Range, PRS.Line); // обновим StartLine и StartRange
this.Arg.Recalculate_Reset(PRS.Range, PRS.Line, PRS); // обновим StartLine и StartRange
}
PRS.Update_CurPos(2, Depth); // this.Arg = this.Content[2]
......
......@@ -3472,7 +3472,7 @@ CDelimiter.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
this.BrGapRight = this.GapRight + this.endOper.size.width;
//
Content.Recalculate_Reset(PRS.Range, PRS.Line);
Content.Recalculate_Reset(PRS.Range, PRS.Line, PRS);
PRS.WordLen = WordLen + this.BrGapLeft;
PRS.SpaceLen = SpaceLen;
......
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