diff --git a/word/Editor/Paragraph_Recalculate.js b/word/Editor/Paragraph_Recalculate.js index 0af51d1d1f..58185d8602 100644 --- a/word/Editor/Paragraph_Recalculate.js +++ b/word/Editor/Paragraph_Recalculate.js @@ -1282,11 +1282,41 @@ Paragraph.prototype.private_RecalculateLineMetrics = function(CurLine, CurPa // текста, на котором закончилась данная строка. if ( true === PRS.EmptyLine || (PRS.LineAscent < 0.001 && PRS.LineDescent < 0.001) || (true === PRS.End && true !== PRS.TextOnLine)) { - var LastItem = (true === PRS.End ? this.Content[this.Content.length - 1] : this.Content[this.Lines[CurLine].Ranges[this.Lines[CurLine].Ranges.length - 1].EndPos]); - - if (true === PRS.End) + let useParaEnd = true; + if (true !== PRS.End) + { + let lastRange = this.Lines[CurLine].Ranges.length - 1; + let lastItem = this.Content[this.Lines[CurLine].Ranges[lastRange].EndPos]; + let lastRun = lastItem.Get_LastRunInRange(CurLine, lastRange); + if (lastRun && lastRun instanceof AscWord.CRun) + { + let metrics = lastRun.getTextMetrics(true); + + let textDescent = metrics.Descent; + let textAscent = metrics.Ascent + metrics.LineGap; + let textAscent2 = metrics.Ascent; + + if (PRS.LineTextAscent < textAscent) + PRS.LineTextAscent = textAscent; + + if (PRS.LineTextAscent2 < textAscent2) + PRS.LineTextAscent2 = textAscent2; + + if (PRS.LineTextDescent < textDescent) + PRS.LineTextDescent = textDescent; + + if (PRS.LineAscent < textAscent) + PRS.LineAscent = textAscent; + + if (PRS.LineDescent < textDescent) + PRS.LineDescent = textDescent; + + useParaEnd = false; + } + } + + if (useParaEnd || (PRS.LineAscent < 0.001 && PRS.LineDescent < 0.001)) { - // TODO: Как только переделаем para_End переделать тут let oTextPr = this.GetParaEndCompiledPr(); let oMetrics = oTextPr.GetTextMetrics(oTextPr.CS || oTextPr.RTL ? AscWord.fontslot_CS : AscWord.fontslot_ASCII, this.GetTheme()); @@ -1304,33 +1334,6 @@ Paragraph.prototype.private_RecalculateLineMetrics = function(CurLine, CurPa if (PRS.LineDescent < EndTextDescent) PRS.LineDescent = EndTextDescent; } - else if (undefined !== LastItem) - { - let lastRun = LastItem.Get_LastRunInRange(PRS.Line, PRS.Range); - if (lastRun && lastRun instanceof AscWord.CRun) - { - let metrics = lastRun.getTextMetrics(); - - let textDescent = metrics.Descent; - let textAscent = metrics.Ascent + metrics.LineGap; - let textAscent2 = metrics.Ascent; - - if (PRS.LineTextAscent < textAscent) - PRS.LineTextAscent = textAscent; - - if (PRS.LineTextAscent2 < textAscent2) - PRS.LineTextAscent2 = textAscent2; - - if (PRS.LineTextDescent < textDescent) - PRS.LineTextDescent = textDescent; - - if (PRS.LineAscent < textAscent) - PRS.LineAscent = textAscent; - - if (PRS.LineDescent < textDescent) - PRS.LineDescent = textDescent; - } - } } // Рассчитаем метрики строки diff --git a/word/Editor/Run.js b/word/Editor/Run.js index 872f1ab6c0..42bb57b5ce 100644 --- a/word/Editor/Run.js +++ b/word/Editor/Run.js @@ -2224,7 +2224,7 @@ ParaRun.prototype.Get_ParaPosByContentPos = function(ContentPos, Depth) } } - return new CParaPos((LinesCount === 1 ? this.protected_GetRangesCount(0) - 1 + this.StartRange : this.protected_GetRangesCount(0) - 1), LinesCount - 1 + this.StartLine, 0, 0); + return new CParaPos((LinesCount === 1 ? this.protected_GetRangesCount(0) - 1 + this.StartRange : this.protected_GetRangesCount(LinesCount - 1) - 1), LinesCount - 1 + this.StartLine, 0, 0); }; ParaRun.prototype.recalculateCursorPosition = function(positionCalculator, isCurrent) @@ -3437,7 +3437,7 @@ ParaRun.prototype.Recalculate_MeasureContent = function() this.RecalcInfo.Recalc = true; this.RecalcInfo.ResetMeasure(); }; -ParaRun.prototype.getTextMetrics = function() +ParaRun.prototype.getTextMetrics = function(isForceEmpty) { let textPr = this.Get_CompiledPr(false); if (this.IsUseAscFont(textPr)) @@ -3453,7 +3453,7 @@ ParaRun.prototype.getTextMetrics = function() fontSlot |= this.Content[nPos].GetFontSlot(textPr); } - if (AscWord.fontslot_Unknown === fontSlot) + if ((AscWord.fontslot_Unknown === fontSlot) || (AscWord.fontslot_None === fontSlot && isForceEmpty)) fontSlot = textPr.CS || textPr.RTL ? AscWord.fontslot_CS : AscWord.fontslot_ASCII; return textPr.GetTextMetrics(fontSlot, this.Paragraph.GetTheme());