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

Поправила работу Home и End (функции Get_StartRangePos и Get_EndRangePos)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@63713 954022d7-b5bf-4e40-9824-e11837661b57
parent 7505f40c
......@@ -9002,7 +9002,7 @@ ParaRun.prototype.Math_GetWidth = function(_CurLine, _CurRange)
return W;
};
ParaRun.prototype.Math_Get_StartRangePos = function(bStartLine, _CurLine, _CurRange, SearchPos, Depth)
ParaRun.prototype.Math_Get_StartRangePos = function(_CurLine, _CurRange, SearchPos, Depth, bStartLine)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -9023,7 +9023,7 @@ ParaRun.prototype.Math_Get_StartRangePos = function(bStartLine, _CurLine, _CurRa
return Result;
};
ParaRun.prototype.Math_Get_EndRangePos = function(bEndLine, _CurLine, _CurRange, SearchPos, Depth)
ParaRun.prototype.Math_Get_EndRangePos = function(_CurLine, _CurRange, SearchPos, Depth, bEndLine)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -9087,11 +9087,11 @@ ParaRun.prototype.Recalculate_Range_OneLine = function(PRS, ParaPr, Depth)
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
this.Math_RecalculateContent();
this.Math_RecalculateContent(PRS);
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
};
ParaRun.prototype.Math_RecalculateContent = function()
ParaRun.prototype.Math_RecalculateContent = function(PRS)
{
var WidthPoints = this.Parent.Get_WidthPoints();
this.bEqArray = this.Parent.IsEqArray();
......@@ -9103,10 +9103,11 @@ ParaRun.prototype.Math_RecalculateContent = function()
for(var i = 0 ; i < Lng; i++)
{
var size = this.Content[i].size,
Type = this.Content[i].Type;
var Item = this.Content[i];
var size = Item.size,
Type = Item.Type;
var WidthItem = this.Content[i].Get_WidthVisible(); // Get_Width => Get_WidthVisible
var WidthItem = Item.Get_WidthVisible(); // Get_Width => Get_WidthVisible
// Get_WidthVisible - Width + Gaps с учетом настроек состояния
width += WidthItem;
......
......@@ -1118,22 +1118,26 @@ CMathBase.prototype.SelectToParent = function(bCorrect)
this.bSelectionUse = true;
this.Parent.SelectToParent(bCorrect);
};
CMathBase.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchPos, Depth)
CMathBase.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchPos, Depth, bStartPos)
{
var Result = this.Content[this.CurPos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth+1);
var Pos = bStartPos == true ? this.NumBreakContent : this.CurPos;
var Result = this.Content[Pos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth+1, bStartPos);
if ( true === Result )
SearchPos.Pos.Update( this.CurPos, Depth );
SearchPos.Pos.Update(Pos, Depth );
return Result;
};
CMathBase.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos, Depth)
CMathBase.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos, Depth, bEndPos)
{
var Result = this.Content[this.CurPos].Get_EndRangePos(_CurLine, _CurRange, SearchPos, Depth+1);
var Pos = bEndPos == true ? this.NumBreakContent : this.CurPos;
var Result = this.Content[Pos].Get_EndRangePos(_CurLine, _CurRange, SearchPos, Depth+1, bEndPos);
if ( true === Result )
SearchPos.Pos.Update( this.CurPos, Depth );
SearchPos.Pos.Update( Pos, Depth );
return Result;
......
......@@ -4258,7 +4258,7 @@ CMathContent.prototype.GetDescent = function(_CurLine, _CurRange)
return this.Bounds.GetDescent(CurLine, CurRange);
};
CMathContent.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchPos, Depth)
CMathContent.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchPos, Depth, bStartPos)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -4267,20 +4267,23 @@ CMathContent.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchP
var CurPos = this.CurPos;
var Result;
if(this.Content[CurPos].Type == para_Math_Composition)
var bStart = this.bRoot ? CurRange == 0 : bStartPos;
if(this.Content[CurPos].Type == para_Math_Composition && bStartPos !== true)
{
Result = this.Content[CurPos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1); // пытаемся встать в начало внутреннего контента
bStart = bStart && CurPos == StartPos;
Result = this.Content[CurPos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, bStart); // пытаемся встать в начало внутреннего контента
if ( true === Result )
{
SearchPos.Pos.Update( CurPos, Depth );
}
else if(this.bRoot)
else if(this.bRoot && CurPos !== StartPos)
{
if(this.Content[StartPos].Type == para_Math_Composition)
Result = this.Content[StartPos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1);
Result = this.Content[StartPos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, true);
else
Result = this.Content[StartPos].Math_Get_StartRangePos(true, _CurLine, _CurRange, SearchPos, Depth + 1);
Result = this.Content[StartPos].Math_Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, true);
if ( true === Result )
SearchPos.Pos.Update(StartPos, Depth);
......@@ -4288,11 +4291,15 @@ CMathContent.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchP
}
else
{
// в начале контента может стоять пустой Run перед мат объектом, поэтому здесь важно различать две ситуации: мы стоим в начале контента или нет(когда нажата клавиша Home). В последнем случае нужно встать в пустой Run в начале контента, если в начале стоит мат объект.
var bUpdStartLine = StartPos < CurPos;
var bUpdNotFirstLine = this.bRoot && CurLine !== 0;
if(this.bRoot && CurLine == 0)
{
bStart = bStart && StartPos < CurPos;
}
Result = this.Content[StartPos].Math_Get_StartRangePos(bUpdStartLine || bUpdNotFirstLine, _CurLine, _CurRange, SearchPos, Depth + 1);
if(this.Content[StartPos].Type == para_Math_Composition)
Result = this.Content[StartPos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, bStart); // может произойти, если мат объект разбивается на строки
else
Result = this.Content[StartPos].Math_Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, bStart);
if ( true === Result )
SearchPos.Pos.Update(StartPos, Depth );
......@@ -4300,7 +4307,7 @@ CMathContent.prototype.Get_StartRangePos = function(_CurLine, _CurRange, SearchP
return Result;
};
CMathContent.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos, Depth)
CMathContent.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos, Depth, bEndPos)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = ( 0 === CurLine ? _CurRange - this.StartRange : _CurRange );
......@@ -4309,7 +4316,11 @@ CMathContent.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos
var CurPos = this.CurPos;
var Result;
if(this.Content[CurPos].Type == para_Math_Composition)
var bLastRange = CurRange == this.protected_GetRangesCount(CurLine) - 1;
var bEnd = this.bRoot ? bLastRange : bEndPos;
if(this.Content[CurPos].Type == para_Math_Composition && bEndPos !== true)
{
Result = this.Content[CurPos].Get_EndRangePos(_CurLine, _CurRange, SearchPos, Depth + 1); // пытаемся встать в конец внутреннего контента
......@@ -4317,12 +4328,12 @@ CMathContent.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos
{
SearchPos.Pos.Update( CurPos, Depth );
}
else if(this.bRoot)
else if(this.bRoot && CurPos !== EndPos)
{
if(this.Content[EndPos].Type == para_Math_Composition) /// убрать
Result = this.Content[EndPos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1);
if(this.Content[EndPos].Type == para_Math_Composition)
Result = this.Content[EndPos].Get_StartRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, true);
else
Result = this.Content[EndPos].Math_Get_EndRangePos(true, _CurLine, _CurRange, SearchPos, Depth + 1);
Result = this.Content[EndPos].Math_Get_EndRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, true);
if ( true === Result )
SearchPos.Pos.Update(EndPos, Depth );
......@@ -4330,10 +4341,12 @@ CMathContent.prototype.Get_EndRangePos = function(_CurLine, _CurRange, SearchPos
}
else
{
var bUpdEndLine = CurPos < EndPos;
var bUpdNotLastLine = this.bRoot && CurLine !== this.protected_GetLinesCount() - 1;
bEnd = this.bRoot && bLastRange ? true /*иначе после того как встанем после формулы перед знаком параграфа, на следующем End встанем перед формулой*/ : bEnd || CurPos < EndPos;
Result = this.Content[EndPos].Math_Get_EndRangePos(bUpdEndLine || bUpdNotLastLine, _CurLine, _CurRange, SearchPos, Depth + 1);
if(this.Content[EndPos].Type == para_Math_Composition)
Result = this.Content[EndPos].Get_EndRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, bEnd); // может произойти, если мат объект разбивается на строки
else
Result = this.Content[EndPos].Math_Get_EndRangePos(_CurLine, _CurRange, SearchPos, Depth + 1, bEnd);
if ( true === Result )
SearchPos.Pos.Update(EndPos, Depth );
......
......@@ -921,7 +921,25 @@ CMathText.prototype.Read_FromBinary = function(Reader)
this.Type = Reader.GetLong();
this.value = Reader.GetLong();
};
/*CMathText.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();
}
};
CMathText.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
{
var CurLine = PRS.Line - this.StartLine;
var CurRange = ( 0 === CurLine ? PRS.Range - this.StartRange : PRS.Range );
var RangeStartPos = this.protected_AddRange(CurLine, CurRange);
this.protected_FillRange(CurLine, CurRange, RangeStartPos, RangeEndPos);
};*/
function CMathAmp()
{
......
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