Commit 93a4d3c9 authored by Ilya Kirillov's avatar Ilya Kirillov

Рефакторинг.

parent e3730702
......@@ -5256,7 +5256,7 @@ CDocument.prototype.Selection_Is_TableBorderMove = function()
* Проверяем попали ли мы в селект.
* @param X
* @param Y
* @param Page_Abs
* @param PageAbs
* @param NearPos
* @returns {boolean}
*/
......@@ -5387,40 +5387,7 @@ CDocument.prototype.Get_SelectedContent = function(bUseHistory)
}
var SelectedContent = new CSelectedContent();
// Заполняем выделенный контент
if (docpostype_HdrFtr === this.CurPos.Type)
this.HdrFtr.Get_SelectedContent(SelectedContent);
else if (docpostype_DrawingObjects === this.CurPos.Type)
this.DrawingObjects.Get_SelectedContent(SelectedContent);
else
{
if (true !== this.Selection.Use || this.Selection.Flag !== selectionflag_Common)
{
if (!bUseHistory)
History.TurnOn();
if (bNeedTurnOffTableId)
{
g_oTableId.m_bTurnOff = false;
}
return null;
}
var StartPos = this.Selection.StartPos;
var EndPos = this.Selection.EndPos;
if (StartPos > EndPos)
{
StartPos = this.Selection.EndPos;
EndPos = this.Selection.StartPos;
}
for (var Index = StartPos; Index <= EndPos; Index++)
{
this.Content[Index].Get_SelectedContent(SelectedContent);
}
}
this.Controller.GetSelectedContent(SelectedContent);
SelectedContent.On_EndCollectElements(this, false);
if (!bUseHistory)
......@@ -5715,8 +5682,6 @@ CDocument.prototype.Document_SelectNumbering = function(NumPr, Index)
this.Selection.StartPos = Index;
this.Selection.EndPos = Index;
//var
for (var Index = 0; Index < this.Content.length; Index++)
{
var Item = this.Content[Index];
......@@ -5738,44 +5703,22 @@ CDocument.prototype.Remove_NumberingSelection = function()
if (true === this.Selection.Use && selectionflag_Numbering == this.Selection.Flag)
this.Selection_Remove();
};
CDocument.prototype.Update_CursorType = function(X, Y, PageIndex, MouseEvent)
CDocument.prototype.Update_CursorType = function(X, Y, PageAbs, MouseEvent)
{
if (null !== this.FullRecalc.Id && this.FullRecalc.PageIndex <= PageIndex)
if (null !== this.FullRecalc.Id && this.FullRecalc.PageIndex <= PageAbs)
return;
editor.sync_MouseMoveStartCallback();
this.Api.sync_MouseMoveStartCallback();
// Ничего не делаем
if (true === this.DrawingDocument.IsCursorInTableCur(X, Y, PageIndex))
if (true === this.DrawingDocument.IsCursorInTableCur(X, Y, PageAbs))
{
this.DrawingDocument.SetCursorType("default", new AscCommon.CMouseMoveData());
editor.sync_MouseMoveEndCallback();
this.Api.sync_MouseMoveEndCallback();
return;
}
if (docpostype_HdrFtr === this.CurPos.Type)
{
this.HdrFtr.Update_CursorType(X, Y, PageIndex);
}
else
{
var bInText = (null === this.Is_InText(X, Y, PageIndex) ? false : true);
var bTableBorder = (null === this.Is_TableBorder(X, Y, PageIndex) ? false : true);
// Ничего не делаем
if (true === this.DrawingObjects.updateCursorType(PageIndex, X, Y, MouseEvent, ( true === bInText || true === bTableBorder ? true : false )))
{
editor.sync_MouseMoveEndCallback();
return;
}
var ContentPos = this.Internal_GetContentPosByXY(X, Y, PageIndex);
var Item = this.Content[ContentPos];
var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, PageIndex);
Item.Update_CursorType(X, Y, ElementPageIndex);
}
editor.sync_MouseMoveEndCallback();
this.Controller.UpdateCursorType(X, Y, PageAbs, MouseEvent);
this.Api.sync_MouseMoveEndCallback();
};
/**
* Проверяем попадание в границу таблицы.
......@@ -5789,11 +5732,14 @@ CDocument.prototype.Is_TableBorder = function(X, Y, PageIndex)
if (PageIndex >= this.Pages.length || PageIndex < 0)
return null;
if (docpostype_HdrFtr === this.CurPos.Type)
if (docpostype_HdrFtr === this.Get_DocPosType())
{
return this.HdrFtr.Is_TableBorder(X, Y, PageIndex);
}
else if (-1 != this.DrawingObjects.isPointInDrawingObjects(X, Y, PageIndex, this))
else
{
// TODO: Добавить обработку сносок
if (-1 != this.DrawingObjects.isPointInDrawingObjects(X, Y, PageIndex, this))
{
return null;
}
......@@ -5809,6 +5755,7 @@ CDocument.prototype.Is_TableBorder = function(X, Y, PageIndex)
else
return null;
}
}
return null;
};
......@@ -5824,12 +5771,14 @@ CDocument.prototype.Is_InText = function(X, Y, PageIndex)
if (PageIndex >= this.Pages.length || PageIndex < 0)
return null;
if (docpostype_HdrFtr === this.CurPos.Type)
if (docpostype_HdrFtr === this.Get_DocPosType())
{
return this.HdrFtr.Is_InText(X, Y, PageIndex);
}
else
{
// TODO: Добавить обработку сносок
var ContentPos = this.Internal_GetContentPosByXY(X, Y, PageIndex);
var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, PageIndex);
var Item = this.Content[ContentPos];
......@@ -5853,7 +5802,10 @@ CDocument.prototype.Is_InDrawing = function(X, Y, PageIndex)
{
return this.HdrFtr.Is_InDrawing(X, Y, PageIndex);
}
else if (-1 != this.DrawingObjects.isPointInDrawingObjects(X, Y, this.CurPage, this))
else
{
// TODO: Добавить обработку сносок
if (-1 != this.DrawingObjects.isPointInDrawingObjects(X, Y, this.CurPage, this))
{
return true;
}
......@@ -5869,6 +5821,7 @@ CDocument.prototype.Is_InDrawing = function(X, Y, PageIndex)
return false;
}
}
};
CDocument.prototype.Is_UseInDocument = function(Id)
{
......@@ -7107,9 +7060,9 @@ CDocument.prototype.OnMouseMove = function(e, X, Y, PageIndex)
this.Selection.DragDrop.Data = null;
// Вызываем стандартное событие mouseMove, чтобы сбросить различные подсказки, если они были
editor.sync_MouseMoveStartCallback();
editor.sync_MouseMoveCallback(new AscCommon.CMouseMoveData());
editor.sync_MouseMoveEndCallback();
this.Api.sync_MouseMoveStartCallback();
this.Api.sync_MouseMoveCallback(new AscCommon.CMouseMoveData());
this.Api.sync_MouseMoveEndCallback();
this.DrawingDocument.StartTrackText();
}
......@@ -7215,8 +7168,8 @@ CDocument.prototype.Get_NearestPos = function(PageNum, X, Y, bAnchor, Drawing)
if (undefined === bAnchor)
bAnchor = false;
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
// TODO: Доработать сноски
if (docpostype_HdrFtr === this.Get_DocPosType())
return this.HdrFtr.Get_NearestPos(PageNum, X, Y, bAnchor, Drawing);
var bInText = (null === this.Is_InText(X, Y, PageNum) ? false : true);
......@@ -7354,7 +7307,7 @@ CDocument.prototype.Document_AddPageNum = function(AlignV, AlignH)
if (AlignV >= 0)
{
var PageIndex = this.CurPage;
if (docpostype_HdrFtr === this.CurPos.Type)
if (docpostype_HdrFtr === this.Get_DocPosType())
PageIndex = this.HdrFtr.Get_CurPage();
if (PageIndex < 0)
......@@ -7537,7 +7490,7 @@ CDocument.prototype.Document_SetHdrFtrBounds = function(Y0, Y1)
CDocument.prototype.Document_SetHdrFtrLink = function(bLinkToPrevious)
{
var CurHdrFtr = this.HdrFtr.CurHdrFtr;
if (docpostype_HdrFtr !== this.CurPos.Type || null === CurHdrFtr || -1 === CurHdrFtr.RecalcInfo.CurPage)
if (docpostype_HdrFtr !== this.Get_DocPosType() || null === CurHdrFtr || -1 === CurHdrFtr.RecalcInfo.CurPage)
return;
var PageIndex = CurHdrFtr.RecalcInfo.CurPage;
......@@ -7617,7 +7570,7 @@ CDocument.prototype.Document_Format_Copy = function()
};
CDocument.prototype.Document_End_HdrFtrEditing = function()
{
if (docpostype_HdrFtr === this.CurPos.Type)
if (docpostype_HdrFtr === this.Get_DocPosType())
{
this.Set_DocPosType(docpostype_Content);
var CurHdrFtr = this.HdrFtr.Get_CurHdrFtr();
......@@ -15893,7 +15846,38 @@ CDocument.prototype.controller_SelectAll = function()
this.Content[Index].Select_All();
}
};
CDocument.prototype.controller_GetSelectedContent = function(SelectedContent)
{
if (true !== this.Selection.Use || this.Selection.Flag !== selectionflag_Common)
return;
var StartPos = this.Selection.StartPos;
var EndPos = this.Selection.EndPos;
if (StartPos > EndPos)
{
StartPos = this.Selection.EndPos;
EndPos = this.Selection.StartPos;
}
for (var Index = StartPos; Index <= EndPos; Index++)
{
this.Content[Index].Get_SelectedContent(SelectedContent);
}
};
CDocument.prototype.controller_UpdateCursorType = function(X, Y, PageAbs, MouseEvent)
{
var bInText = (null === this.Is_InText(X, Y, PageAbs) ? false : true);
var bTableBorder = (null === this.Is_TableBorder(X, Y, PageAbs) ? false : true);
// Ничего не делаем
if (true === this.DrawingObjects.updateCursorType(PageAbs, X, Y, MouseEvent, ( true === bInText || true === bTableBorder ? true : false )))
return;
var ContentPos = this.Internal_GetContentPosByXY(X, Y, PageAbs);
var Item = this.Content[ContentPos];
var ElementPageIndex = this.private_GetElementPageIndexByXY(ContentPos, X, Y, PageAbs);
Item.Update_CursorType(X, Y, ElementPageIndex);
};
CDocument.prototype.controller_AddToParagraph = function(ParaItem, bRecalculate)
......
......@@ -536,6 +536,16 @@ CDocumentControllerBase.prototype.CheckPosInSelection = function(X, Y, PageAbs,
* Выделяем все содержимое.
*/
CDocumentControllerBase.prototype.SelectAll = function(){};
/**
* Получаем выделенный контент.
* @param SelectedContent
*/
CDocumentControllerBase.prototype.GetSelectedContent = function(SelectedContent){};
/**
* Обновляем вид курсора.
*/
CDocumentControllerBase.prototype.UpdateCursorType = function(X, Y, PageAbs, MouseEvent){};
/**
* Добавляем элемент в параграф.
* @param oItem
......
......@@ -295,6 +295,15 @@ CDrawingsController.prototype.SelectAll = function()
{
this.DrawingObjects.selectAll();
};
CDrawingsController.prototype.GetSelectedContent = function(SelectedContent)
{
this.DrawingObjects.Get_SelectedContent(SelectedContent);
};
CDrawingsController.prototype.UpdateCursorType = function(X, Y, PageAbs, MouseEvent)
{
// TODO: Надо вызывать не у LogicDocument, а у DocumentContent заданного
this.LogicDocument.controller_UpdateCursorType(X, Y, PageAbs, MouseEvent);
};
CDrawingsController.prototype.AddToParagraph = function(oItem, bRecalculate)
{
......
......@@ -880,7 +880,30 @@ CFootnotesController.prototype.SelectAll = function()
this.CurFootnote.Select_All();
}
};
CFootnotesController.prototype.GetSelectedContent = function(SelectedContent)
{
// TODO: Доделать селект и курсор
if (true === this.Selection.Use)
{
}
else
{
if (null !== this.CurFootnote)
this.CurFootnote.Get_SelectedContent(SelectedContent);
}
};
CFootnotesController.prototype.UpdateCursorType = function(X, Y, PageAbs, MouseEvent)
{
// TODO: Доделать селект и курсор
if (true === this.Selection.Use)
{
}
else
{
if (null !== this.CurFootnote)
this.CurFootnote.Update_CursorType(X, Y, PageAbs, MouseEvent);
}
};
CFootnotesController.prototype.AddToParagraph = function(oItem, bRecalculate)
{
......
......@@ -245,6 +245,14 @@ CHdrFtrController.prototype.SelectAll = function()
{
this.HdrFtr.Select_All();
};
CHdrFtrController.prototype.GetSelectedContent = function(SelectedContent)
{
this.HdrFtr.Get_SelectedContent(SelectedContent);
};
CHdrFtrController.prototype.UpdateCursorType = function(X, Y, PageAbs, MouseEvent)
{
this.HdrFtr.Update_CursorType(X, Y, PageAbs, MouseEvent);
};
CHdrFtrController.prototype.AddToParagraph = function(oItem, bRecalculate)
{
......
......@@ -221,6 +221,14 @@ CLogicDocumentController.prototype.SelectAll = function()
{
this.LogicDocument.controller_SelectAll();
};
CLogicDocumentController.prototype.GetSelectedContent = function(SelectedContent)
{
this.LogicDocument.controller_GetSelectedContent(SelectedContent);
};
CLogicDocumentController.prototype.UpdateCursorType = function(X, Y, PageAbs, MouseEvent)
{
this.LogicDocument.controller_UpdateCursorType(X, Y, PageAbs, MouseEvent);
};
......
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