Commit 959222f1 authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed bug #33524. Added correction on positioning cursor in Math object on removing selection.

parent c163d10b
......@@ -329,7 +329,7 @@ ParaComment.prototype =
return false;
},
Get_ParaContentPos : function(bSelection, bStart, ContentPos)
Get_ParaContentPos : function(bSelection, bStart, ContentPos, bUseCorrection)
{
},
......
......@@ -932,7 +932,7 @@ ParaComment.prototype =
return false;
},
Get_ParaContentPos : function(bSelection, bStart, ContentPos)
Get_ParaContentPos : function(bSelection, bStart, ContentPos, bUseCorrection)
{
},
......
......@@ -2873,9 +2873,9 @@ ParaMath.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine,
return Result;
};
ParaMath.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos) // получить текущую логическую позицию
ParaMath.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos, bUseCorrection)
{
this.Root.Get_ParaContentPos(bSelection, bStart, ContentPos);
this.Root.Get_ParaContentPos(bSelection, bStart, ContentPos, bUseCorrection);
};
ParaMath.prototype.Set_ParaContentPos = function(ContentPos, Depth) // выставить логическую позицию в контенте
......
......@@ -3748,15 +3748,15 @@ Paragraph.prototype =
this.CurPos.ContentPos = CurPos;
},
Get_ParaContentPos : function(bSelection, bStart)
Get_ParaContentPos : function(bSelection, bStart, bUseCorrection)
{
var ContentPos = new CParagraphContentPos();
var Pos = ( true !== bSelection ? this.CurPos.ContentPos : ( false !== bStart ? this.Selection.StartPos : this.Selection.EndPos ) );
ContentPos.Add( Pos );
ContentPos.Add(Pos);
this.Content[Pos].Get_ParaContentPos( bSelection, bStart, ContentPos );
this.Content[Pos].Get_ParaContentPos(bSelection, bStart, ContentPos, true === bUseCorrection ? true : false);
return ContentPos;
},
......@@ -4106,13 +4106,16 @@ Paragraph.prototype =
if ( true !== AddToSelect )
{
// Найдем левую точку селекта
var SelectPos = StartSelectionPos;
if ( StartSelectionPos.Compare( EndSelectionPos ) > 0 )
SelectPos = EndSelectionPos;
// Иногда нужно скоректировать позицию, например в формулах
var CorrectedStartPos = this.Get_ParaContentPos(true, true, true);
var CorrectedEndPos = this.Get_ParaContentPos(true, false, true);
var SelectPos = CorrectedStartPos;
if (CorrectedStartPos.Compare(CorrectedEndPos) > 0)
SelectPos = CorrectedEndPos;
this.Selection_Remove();
this.Set_ParaContentPos( SelectPos, true, -1, -1 );
this.Set_ParaContentPos(SelectPos, true, -1, -1);
}
else
{
......@@ -4207,14 +4210,16 @@ Paragraph.prototype =
}
else
{
// Найдем левую точку селекта
var SelectPos = EndSelectionPos;
if ( StartSelectionPos.Compare( EndSelectionPos ) > 0 )
SelectPos = StartSelectionPos;
// Иногда нужно скоректировать позицию, например в формулах
var CorrectedStartPos = this.Get_ParaContentPos(true, true, true);
var CorrectedEndPos = this.Get_ParaContentPos(true, false, true);
this.Selection_Remove();
var SelectPos = CorrectedEndPos;
if (CorrectedStartPos.Compare(CorrectedEndPos) > 0)
SelectPos = CorrectedStartPos;
this.Set_ParaContentPos( SelectPos, true, -1, -1 );
this.Selection_Remove();
this.Set_ParaContentPos(SelectPos, true, -1, -1);
}
}
else
......
......@@ -1583,12 +1583,12 @@ CParagraphContentWithParagraphLikeContent.prototype.Get_ParaContentPosByXY = fun
return Result;
};
CParagraphContentWithParagraphLikeContent.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos)
CParagraphContentWithParagraphLikeContent.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos, bUseCorrection)
{
var Pos = ( true === bSelection ? ( true === bStart ? this.State.Selection.StartPos : this.State.Selection.EndPos ) : this.State.ContentPos );
ContentPos.Add( Pos );
ContentPos.Add(Pos);
this.Content[Pos].Get_ParaContentPos( bSelection, bStart, ContentPos );
this.Content[Pos].Get_ParaContentPos(bSelection, bStart, ContentPos, bUseCorrection);
};
CParagraphContentWithParagraphLikeContent.prototype.Set_ParaContentPos = function(ContentPos, Depth)
{
......
......@@ -1717,13 +1717,13 @@ CMathBase.prototype.Get_ParaContentPosByXY = function(SearchPos, Depth, _CurLine
return bResult;
};
CMathBase.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos)
CMathBase.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos, bUseCorrection)
{
var nPos = (true !== bSelection ? this.CurPos : (false !== bStart ? this.Selection.StartPos : this.Selection.EndPos));
ContentPos.Add(nPos);
if (undefined !== this.Content[nPos])
this.Content[nPos].Get_ParaContentPos(bSelection, bStart, ContentPos);
this.Content[nPos].Get_ParaContentPos(bSelection, bStart, ContentPos, bUseCorrection);
};
CMathBase.prototype.Set_ParaContentPos = function(ContentPos, Depth)
{
......
......@@ -3529,13 +3529,43 @@ CMathContent.prototype.Get_CurrentParaPos = function()
return new CParaPos( this.StartRange, this.StartLine, 0, 0 );
};
CMathContent.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos)
CMathContent.prototype.Get_ParaContentPos = function(bSelection, bStart, ContentPos, bUseCorrection)
{
if (true === bUseCorrection && true === bSelection)
{
var nPos = false !== bStart ? this.Selection.StartPos : this.Selection.EndPos;
if (para_Math_Run !== this.Content[nPos].Type
&& (this.Selection.StartPos !== this.Selection.EndPos || true !== this.Content[nPos].Is_InnerSelection())
&& ((true === bStart && nPos > 0) || (true !== bStart && nPos < this.Content.length - 1)))
{
if (true === bStart && nPos > 0)
{
ContentPos.Add(nPos - 1);
this.Content[nPos - 1].Get_EndPos(false, ContentPos, ContentPos.Get_Depth() + 1);
}
else
{
ContentPos.Add(nPos + 1);
this.Content[nPos + 1].Get_StartPos(ContentPos, ContentPos.Get_Depth() + 1);
}
}
else
{
ContentPos.Add(nPos);
if (undefined !== this.Content[nPos])
this.Content[nPos].Get_ParaContentPos(bSelection, bStart, ContentPos, bUseCorrection);
}
}
else
{
var nPos = (true !== bSelection ? this.CurPos : (false !== bStart ? this.Selection.StartPos : this.Selection.EndPos));
ContentPos.Add(nPos);
if (undefined !== this.Content[nPos])
this.Content[nPos].Get_ParaContentPos(bSelection, bStart, ContentPos);
this.Content[nPos].Get_ParaContentPos(bSelection, bStart, ContentPos, bUseCorrection);
}
};
CMathContent.prototype.Set_ParaContentPos = function(ContentPos, Depth)
{
......
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