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