Commit 5fe30e2d authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented moving cursor up/down in footnotes. Fixed bugs with moving cursor...

Implemented moving cursor up/down in footnotes. Fixed bugs with moving cursor up/down in drawing objects and header/footer.
parent 20350ffe
......@@ -1936,23 +1936,119 @@ CDocumentContent.prototype.Cursor_MoveToEndPos = function(AddToSelect,
};
CDocumentContent.prototype.Cursor_MoveUp_To_LastRow = function(X, Y, AddToSelect)
{
// Такого не должно быть
this.Set_CurPosXY(X, Y);
if (true === AddToSelect)
return;
{
if (true !== this.Selection.Use)
{
this.CurPos.ContentPos = this.Content.length - 1;
this.Set_DocPosType(docpostype_Content);
this.Selection.Use = true;
this.Selection.Start = false;
this.Selection.StartPos = this.CurPos.ContentPos;
this.Selection.EndPos = this.CurPos.ContentPos;
this.Selection.Flag = selectionflag_Common;
this.Set_CurPosXY(X, Y);
this.Content[this.CurPos.ContentPos].Cursor_MoveToEndPos(false, true);
this.Content[this.CurPos.ContentPos].Cursor_MoveUp_To_LastRow(X, Y, true);
}
else
{
var StartPos = this.Selection.StartPos;
var EndPos = this.Content.length - 1;
this.CurPos.ContentPos = EndPos;
// Очистим старый селект кроме начального элемента
var _S = this.Selection.StartPos <= this.Selection.EndPos ? this.Selection.StartPos : this.Selection.EndPos;
var _E = this.Selection.StartPos <= this.Selection.EndPos ? this.Selection.EndPos : this.Selection.StartPos;
for (var nPos = _S; nPos <= _E; ++nPos)
{
if (nPos !== StartPos)
this.Content[nPos].Selection_Remove();
}
if (StartPos === EndPos)
{
this.Selection.StartPos = StartPos;
this.Selection.EndPos = StartPos;
this.Content[StartPos].Cursor_MoveUp_To_LastRow(X, Y, true);
}
else
{
this.Content[StartPos].Cursor_MoveToEndPos(true);
for (var nPos = StartPos + 1; nPos <= EndPos; ++nPos)
{
this.Content[nPos].Select_All(1);
}
this.Content[EndPos].Cursor_MoveUp_To_LastRow(X, Y, true);
}
}
}
else
{
this.CurPos.ContentPos = this.Content.length - 1;
this.Content[this.CurPos.ContentPos].Cursor_MoveUp_To_LastRow(X, Y, false);
}
};
CDocumentContent.prototype.Cursor_MoveDown_To_FirstRow = function(X, Y, AddToSelect)
{
// Такого не должно быть
this.Set_CurPosXY(X, Y);
if (true === AddToSelect)
return;
{
if (true !== this.Selection.Use)
{
this.CurPos.ContentPos = 0;
this.Set_DocPosType(docpostype_Content);
this.Selection.Use = true;
this.Selection.Start = false;
this.Selection.StartPos = 0;
this.Selection.EndPos = 0;
this.Selection.Flag = selectionflag_Common;
this.Set_CurPosXY(X, Y);
this.Content[0].Cursor_MoveToStartPos(false);
this.Content[0].Cursor_MoveDown_To_FirstRow(X, Y, true);
}
else
{
var StartPos = this.Selection.StartPos;
var EndPos = 0;
this.CurPos.ContentPos = EndPos;
// Очистим старый селект кроме начального элемента
var _S = this.Selection.StartPos <= this.Selection.EndPos ? this.Selection.StartPos : this.Selection.EndPos;
var _E = this.Selection.StartPos <= this.Selection.EndPos ? this.Selection.EndPos : this.Selection.StartPos;
for (var nPos = _S; nPos <= _E; ++nPos)
{
if (nPos !== StartPos)
this.Content[nPos].Selection_Remove();
}
if (StartPos === EndPos)
{
this.Selection.StartPos = StartPos;
this.Selection.EndPos = StartPos;
this.Content[StartPos].Cursor_MoveDown_To_FirstRow(X, Y, true);
}
else
{
this.Content[StartPos].Cursor_MoveToStartPos(true);
for (var nPos = EndPos; nPos < StartPos; ++nPos)
{
this.Content[nPos].Select_All(-1);
}
this.Content[EndPos].Cursor_MoveDown_To_FirstRow(X, Y, true);
}
}
}
else
{
this.CurPos.ContentPos = 0;
this.Content[this.CurPos.ContentPos].Cursor_MoveDown_To_FirstRow(X, Y, false);
}
};
CDocumentContent.prototype.Cursor_MoveToCell = function(bNext)
{
......@@ -3519,7 +3615,8 @@ CDocumentContent.prototype.Cursor_MoveUp = function(AddToSe
{
if (true === AddToSelect)
{
// Добавляем к селекту
var SelectDirection = this.Selection.StartPos === this.Selection.EndPos ? 0 : this.Selection.StartPos < this.Selection.EndPos ? 1 : -1;
var Item = this.Content[this.Selection.EndPos];
if (false === Item.Cursor_MoveUp(1, true))
{
......@@ -3529,6 +3626,9 @@ CDocumentContent.prototype.Cursor_MoveUp = function(AddToSe
this.CurPos.RealX = TempXY.X;
this.CurPos.RealY = TempXY.Y;
if (1 === SelectDirection)
Item.Selection_Remove();
this.Selection.EndPos--;
Item = this.Content[this.Selection.EndPos];
Item.Cursor_MoveUp_To_LastRow(this.CurPos.RealX, this.CurPos.RealY, true);
......@@ -3656,7 +3756,8 @@ CDocumentContent.prototype.Cursor_MoveDown = function(AddToSe
{
if (true === AddToSelect)
{
// Добавляем к селекту
var SelectDirection = this.Selection.StartPos === this.Selection.EndPos ? 0 : this.Selection.StartPos < this.Selection.EndPos ? 1 : -1;
var Item = this.Content[this.Selection.EndPos];
if (false === Item.Cursor_MoveDown(1, true))
{
......@@ -3666,6 +3767,9 @@ CDocumentContent.prototype.Cursor_MoveDown = function(AddToSe
this.CurPos.RealX = TempXY.X;
this.CurPos.RealY = TempXY.Y;
if (-1 === SelectDirection)
Item.Selection_Remove();
this.Selection.EndPos++;
Item = this.Content[this.Selection.EndPos];
Item.Cursor_MoveDown_To_FirstRow(this.CurPos.RealX, this.CurPos.RealY, true);
......
......@@ -1058,37 +1058,243 @@ CFootnotesController.prototype.MoveCursorRight = function(AddToSelect, Word, Fro
};
CFootnotesController.prototype.MoveCursorUp = function(AddToSelect)
{
var bRetValue = false;
if (true === this.Selection.Use)
{
if (true === AddToSelect)
{
var oFootnote = this.Selection.End.Footnote;
var oPos = oFootnote.Cursor_GetPos();
// TODO: Доделать селект и курсор
if (false === oFootnote.Cursor_MoveUp(true))
{
var oPrevFootnote = this.private_GetPrevFootnote(oFootnote);
if (null === oPrevFootnote)
return false;
if (true === this.Selection.Use)
oFootnote.Cursor_MoveToStartPos(true);
if (1 !== this.Selection.Direction)
{
this.Selection.End.Footnote = oPrevFootnote;
this.Selection.Direction = -1;
this.CurFootnote = oPrevFootnote;
this.Selection.Footnotes[oPrevFootnote.Get_Id()] = oPrevFootnote;
oPrevFootnote.Cursor_MoveUp_To_LastRow(oPos.X, oPos.Y, true);
}
else
{
if (null !== this.CurFootnote)
bRetValue = this.CurFootnote.Cursor_MoveUp(AddToSelect);
this.Selection.End.Footnote = oPrevFootnote;
this.CurFootnote = oPrevFootnote;
if (oPrevFootnote === this.Selection.Start.Footnote)
this.Selection.Direction = 0;
oFootnote.Selection_Remove();
delete this.Selection.Footnotes[oFootnote.Get_Id()];
oPrevFootnote.Cursor_MoveUp_To_LastRow(oPos.X, oPos.Y, true);
}
return bRetValue;
}
}
else
{
var oFootnote = this.CurFootnote;
if (0 === this.Selection.Direction)
oFootnote = this.CurFootnote;
else if (1 === this.Selection.Direction)
oFootnote = this.Selection.Start.Footnote;
else
oFootnote = this.Selection.End.Footnote;
for (var sId in this.Selection.Footnotes)
{
if (oFootnote !== this.Selection.Footnotes[sId])
this.Selection.Footnotes[sId].Selection_Remove();
}
oFootnote.Cursor_MoveLeft(false, false);
oFootnote.Selection_Remove();
this.private_SetCurrentFootnoteNoSelection(oFootnote);
}
}
else
{
if (true === AddToSelect)
{
var oFootnote = this.CurFootnote;
var oPos = oFootnote.Cursor_GetPos();
this.Selection.Use = true;
this.Selection.Start.Footnote = oFootnote;
this.Selection.End.Footnote = oFootnote;
this.Selection.Footnotes = {};
this.Selection.Direction = 0;
this.Selection.Footnotes[oFootnote.Get_Id()] = oFootnote;
if (false === oFootnote.Cursor_MoveUp(true))
{
var oPrevFootnote = this.private_GetPrevFootnote(oFootnote);
if (null === oPrevFootnote)
return false;
oFootnote.Cursor_MoveToStartPos(true);
this.Selection.End.Footnote = oPrevFootnote;
this.Selection.Direction = -1;
this.CurFootnote = oPrevFootnote;
this.Selection.Footnotes[oPrevFootnote.Get_Id()] = oPrevFootnote;
oPrevFootnote.Cursor_MoveUp_To_LastRow(oPos.X, oPos.Y, true);
}
}
else
{
var oFootnote = this.CurFootnote;
var oPos = oFootnote.Cursor_GetPos();
if (false === oFootnote.Cursor_MoveUp(false))
{
var oPrevFootnote = this.private_GetPrevFootnote(oFootnote);
if (null === oPrevFootnote)
return false;
this.Selection.Start.Footnote = oPrevFootnote;
this.Selection.End.Footnote = oPrevFootnote;
this.Selection.Direction = 0;
this.CurFootnote = oPrevFootnote;
this.Selection.Footnotes = {};
this.Selection.Footnotes[oPrevFootnote.Get_Id()] = oPrevFootnote;
oPrevFootnote.Cursor_MoveUp_To_LastRow(oPos.X, oPos.Y, false);
}
}
}
return true;
};
CFootnotesController.prototype.MoveCursorDown = function(AddToSelect)
{
var bRetValue = false;
if (true === this.Selection.Use)
{
if (true === AddToSelect)
{
var oFootnote = this.Selection.End.Footnote;
var oPos = oFootnote.Cursor_GetPos();
// TODO: Доделать селект и курсор
if (false === oFootnote.Cursor_MoveDown(true))
{
var oNextFootnote = this.private_GetNextFootnote(oFootnote);
if (null === oNextFootnote)
return false;
if (true === this.Selection.Use)
oFootnote.Cursor_MoveToEndPos(true);
if (-1 !== this.Selection.Direction)
{
this.Selection.End.Footnote = oNextFootnote;
this.Selection.Direction = 1;
this.CurFootnote = oNextFootnote;
this.Selection.Footnotes[oNextFootnote.Get_Id()] = oNextFootnote;
oNextFootnote.Cursor_MoveDown_To_FirstRow(oPos.X, oPos.Y, true);
}
else
{
if (null !== this.CurFootnote)
bRetValue = this.CurFootnote.Cursor_MoveDown(AddToSelect);
this.Selection.End.Footnote = oNextFootnote;
this.CurFootnote = oNextFootnote;
if (oNextFootnote === this.Selection.Start.Footnote)
this.Selection.Direction = 0;
oFootnote.Selection_Remove();
delete this.Selection.Footnotes[oFootnote.Get_Id()];
oNextFootnote.Cursor_MoveDown_To_FirstRow(oPos.X, oPos.Y, true);
}
return bRetValue;
}
}
else
{
var oFootnote = this.CurFootnote;
if (0 === this.Selection.Direction)
oFootnote = this.CurFootnote;
else if (1 === this.Selection.Direction)
oFootnote = this.Selection.End.Footnote;
else
oFootnote = this.Selection.Start.Footnote;
for (var sId in this.Selection.Footnotes)
{
if (oFootnote !== this.Selection.Footnotes[sId])
this.Selection.Footnotes[sId].Selection_Remove();
}
oFootnote.Cursor_MoveRight(false, false);
oFootnote.Selection_Remove();
this.private_SetCurrentFootnoteNoSelection(oFootnote);
}
}
else
{
if (true === AddToSelect)
{
var oFootnote = this.CurFootnote;
var oPos = oFootnote.Cursor_GetPos();
this.Selection.Use = true;
this.Selection.Start.Footnote = oFootnote;
this.Selection.End.Footnote = oFootnote;
this.Selection.Footnotes = {};
this.Selection.Direction = 0;
this.Selection.Footnotes[oFootnote.Get_Id()] = oFootnote;
if (false === oFootnote.Cursor_MoveDown(true))
{
var oNextFootnote = this.private_GetNextFootnote(oFootnote);
if (null === oNextFootnote)
return false;
oFootnote.Cursor_MoveToEndPos(true, false);
this.Selection.End.Footnote = oNextFootnote;
this.Selection.Direction = 1;
this.CurFootnote = oNextFootnote;
this.Selection.Footnotes[oNextFootnote.Get_Id()] = oNextFootnote;
oNextFootnote.Cursor_MoveDown_To_FirstRow(oPos.X, oPos.Y, true);
}
}
else
{
var oFootnote = this.CurFootnote;
var oPos = oFootnote.Cursor_GetPos();
if (false === oFootnote.Cursor_MoveDown(false))
{
var oNextFootnote = this.private_GetNextFootnote(oFootnote);
if (null === oNextFootnote)
return false;
this.Selection.Start.Footnote = oNextFootnote;
this.Selection.End.Footnote = oNextFootnote;
this.Selection.Direction = 0;
this.CurFootnote = oNextFootnote;
this.Selection.Footnotes = {};
this.Selection.Footnotes[oNextFootnote.Get_Id()] = oNextFootnote;
oNextFootnote.Cursor_MoveDown_To_FirstRow(oPos.X, oPos.Y, false);
}
}
}
return true;
};
CFootnotesController.prototype.MoveCursorToEndOfLine = function(AddToSelect)
{
......
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