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
...@@ -1934,25 +1934,121 @@ CDocumentContent.prototype.Cursor_MoveToEndPos = function(AddToSelect, ...@@ -1934,25 +1934,121 @@ CDocumentContent.prototype.Cursor_MoveToEndPos = function(AddToSelect,
} }
} }
}; };
CDocumentContent.prototype.Cursor_MoveUp_To_LastRow = function(X, Y, AddToSelect) CDocumentContent.prototype.Cursor_MoveUp_To_LastRow = function(X, Y, AddToSelect)
{ {
// Такого не должно быть this.Set_CurPosXY(X, Y);
if (true === AddToSelect) 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.CurPos.ContentPos = this.Content.length - 1; this.Content[this.CurPos.ContentPos].Cursor_MoveUp_To_LastRow(X, Y, true);
this.Content[this.CurPos.ContentPos].Cursor_MoveUp_To_LastRow(X, Y, false); }
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) CDocumentContent.prototype.Cursor_MoveDown_To_FirstRow = function(X, Y, AddToSelect)
{ {
// Такого не должно быть this.Set_CurPosXY(X, Y);
if (true === AddToSelect) 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.CurPos.ContentPos = 0; this.Content[0].Cursor_MoveDown_To_FirstRow(X, Y, true);
this.Content[this.CurPos.ContentPos].Cursor_MoveDown_To_FirstRow(X, Y, false); }
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) CDocumentContent.prototype.Cursor_MoveToCell = function(bNext)
{ {
...@@ -3519,7 +3615,8 @@ CDocumentContent.prototype.Cursor_MoveUp = function(AddToSe ...@@ -3519,7 +3615,8 @@ CDocumentContent.prototype.Cursor_MoveUp = function(AddToSe
{ {
if (true === AddToSelect) 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]; var Item = this.Content[this.Selection.EndPos];
if (false === Item.Cursor_MoveUp(1, true)) if (false === Item.Cursor_MoveUp(1, true))
{ {
...@@ -3529,6 +3626,9 @@ CDocumentContent.prototype.Cursor_MoveUp = function(AddToSe ...@@ -3529,6 +3626,9 @@ CDocumentContent.prototype.Cursor_MoveUp = function(AddToSe
this.CurPos.RealX = TempXY.X; this.CurPos.RealX = TempXY.X;
this.CurPos.RealY = TempXY.Y; this.CurPos.RealY = TempXY.Y;
if (1 === SelectDirection)
Item.Selection_Remove();
this.Selection.EndPos--; this.Selection.EndPos--;
Item = this.Content[this.Selection.EndPos]; Item = this.Content[this.Selection.EndPos];
Item.Cursor_MoveUp_To_LastRow(this.CurPos.RealX, this.CurPos.RealY, true); Item.Cursor_MoveUp_To_LastRow(this.CurPos.RealX, this.CurPos.RealY, true);
...@@ -3656,7 +3756,8 @@ CDocumentContent.prototype.Cursor_MoveDown = function(AddToSe ...@@ -3656,7 +3756,8 @@ CDocumentContent.prototype.Cursor_MoveDown = function(AddToSe
{ {
if (true === AddToSelect) 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]; var Item = this.Content[this.Selection.EndPos];
if (false === Item.Cursor_MoveDown(1, true)) if (false === Item.Cursor_MoveDown(1, true))
{ {
...@@ -3666,6 +3767,9 @@ CDocumentContent.prototype.Cursor_MoveDown = function(AddToSe ...@@ -3666,6 +3767,9 @@ CDocumentContent.prototype.Cursor_MoveDown = function(AddToSe
this.CurPos.RealX = TempXY.X; this.CurPos.RealX = TempXY.X;
this.CurPos.RealY = TempXY.Y; this.CurPos.RealY = TempXY.Y;
if (-1 === SelectDirection)
Item.Selection_Remove();
this.Selection.EndPos++; this.Selection.EndPos++;
Item = this.Content[this.Selection.EndPos]; Item = this.Content[this.Selection.EndPos];
Item.Cursor_MoveDown_To_FirstRow(this.CurPos.RealX, this.CurPos.RealY, true); Item.Cursor_MoveDown_To_FirstRow(this.CurPos.RealX, this.CurPos.RealY, true);
......
...@@ -1058,37 +1058,243 @@ CFootnotesController.prototype.MoveCursorRight = function(AddToSelect, Word, Fro ...@@ -1058,37 +1058,243 @@ CFootnotesController.prototype.MoveCursorRight = function(AddToSelect, Word, Fro
}; };
CFootnotesController.prototype.MoveCursorUp = function(AddToSelect) CFootnotesController.prototype.MoveCursorUp = function(AddToSelect)
{ {
var bRetValue = false;
// TODO: Доделать селект и курсор
if (true === this.Selection.Use) if (true === this.Selection.Use)
{ {
if (true === AddToSelect)
{
var oFootnote = this.Selection.End.Footnote;
var oPos = oFootnote.Cursor_GetPos();
if (false === oFootnote.Cursor_MoveUp(true))
{
var oPrevFootnote = this.private_GetPrevFootnote(oFootnote);
if (null === oPrevFootnote)
return false;
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
{
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);
}
}
}
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 else
{ {
if (null !== this.CurFootnote) if (true === AddToSelect)
bRetValue = this.CurFootnote.Cursor_MoveUp(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 bRetValue; return true;
}; };
CFootnotesController.prototype.MoveCursorDown = function(AddToSelect) CFootnotesController.prototype.MoveCursorDown = function(AddToSelect)
{ {
var bRetValue = false;
// TODO: Доделать селект и курсор
if (true === this.Selection.Use) if (true === this.Selection.Use)
{ {
if (true === AddToSelect)
{
var oFootnote = this.Selection.End.Footnote;
var oPos = oFootnote.Cursor_GetPos();
if (false === oFootnote.Cursor_MoveDown(true))
{
var oNextFootnote = this.private_GetNextFootnote(oFootnote);
if (null === oNextFootnote)
return false;
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
{
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);
}
}
}
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 else
{ {
if (null !== this.CurFootnote) if (true === AddToSelect)
bRetValue = this.CurFootnote.Cursor_MoveDown(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 bRetValue; return true;
}; };
CFootnotesController.prototype.MoveCursorToEndOfLine = function(AddToSelect) 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