Commit 241e7393 authored by Ilya Kirillov's avatar Ilya Kirillov

Рефакторинг оставишихся функий. Теперь класс CDocument полностью работает через Controller.

parent eca88479
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -258,8 +258,9 @@ CDocumentControllerBase.prototype.Get_PageContentStartPos = function(PageAbs) ...@@ -258,8 +258,9 @@ CDocumentControllerBase.prototype.Get_PageContentStartPos = function(PageAbs)
CDocumentControllerBase.prototype.CanTargetUpdate = function(){return true;}; CDocumentControllerBase.prototype.CanTargetUpdate = function(){return true;};
/** /**
* Пересчитываем текущую позицию. * Пересчитываем текущую позицию.
* @returns {{X: number, Y: number, Height: number, PageNum: number, Internal: {Line: number, Page: number, Range: number}, Transform: null}}
*/ */
CDocumentControllerBase.prototype.RecalculateCurPos = function(){}; CDocumentControllerBase.prototype.RecalculateCurPos = function(){return {X : 0, Y : 0, Height : 0, PageNum : 0, Internal : {Line : 0, Page : 0, Range : 0}, Transform : null};};
/** /**
* Получаем текущий номер страницы. * Получаем текущий номер страницы.
* @returns {number} -1 - значит, номер страницы определеить невозможно * @returns {number} -1 - значит, номер страницы определеить невозможно
...@@ -687,6 +688,20 @@ CDocumentControllerBase.prototype.CanAddComment = function(){return false;}; ...@@ -687,6 +688,20 @@ CDocumentControllerBase.prototype.CanAddComment = function(){return false;};
* @returns {{X0: number, X1: number, Y: number, Page: number}} * @returns {{X0: number, X1: number, Y: number, Page: number}}
*/ */
CDocumentControllerBase.prototype.GetSelectionAnchorPos = function(){return {X0 : 0, X1 : 0, Y : 0, Page : 0};}; CDocumentControllerBase.prototype.GetSelectionAnchorPos = function(){return {X0 : 0, X1 : 0, Y : 0, Page : 0};};
/**
* Начинаем селект с текущей позиции.
*/
CDocumentControllerBase.prototype.StartSelectionFromCurPos = function(){};
/**
* Сохраняем состояние документа изменения перед принятием чужих изменений.
* @param State
*/
CDocumentControllerBase.prototype.SaveDocumentStateBeforeLoadChanges = function(State){};
/**
* Восстанавливаем состояние документа после загрузки изменений.
* @param State
*/
CDocumentControllerBase.prototype.RestoreDocumentStateAfterLoadChanges = function(State){};
/** /**
* Добавляем элемент в параграф. * Добавляем элемент в параграф.
......
...@@ -26,7 +26,7 @@ CDrawingsController.prototype.CanTargetUpdate = function() ...@@ -26,7 +26,7 @@ CDrawingsController.prototype.CanTargetUpdate = function()
}; };
CDrawingsController.prototype.RecalculateCurPos = function() CDrawingsController.prototype.RecalculateCurPos = function()
{ {
this.DrawingObjects.recalculateCurPos(); return this.DrawingObjects.recalculateCurPos();
}; };
CDrawingsController.prototype.GetCurPage = function() CDrawingsController.prototype.GetCurPage = function()
{ {
...@@ -461,6 +461,32 @@ CDrawingsController.prototype.GetSelectionAnchorPos = function() ...@@ -461,6 +461,32 @@ CDrawingsController.prototype.GetSelectionAnchorPos = function()
Page : ParaDrawing.PageNum Page : ParaDrawing.PageNum
}; };
}; };
CDrawingsController.prototype.StartSelectionFromCurPos = function()
{
this.DrawingObjects.startSelectionFromCurPos();
};
CDrawingsController.prototype.SaveDocumentStateBeforeLoadChanges = function(State)
{
this.DrawingObjects.Save_DocumentStateBeforeLoadChanges(State);
};
CDrawingsController.prototype.RestoreDocumentStateAfterLoadChanges = function(State)
{
if (true !== this.DrawingObjects.Load_DocumentStateAfterLoadChanges(State))
{
this.Set_DocPosType(docpostype_Content);
var LogicDocument = this.LogicDocument;
var ContentPos = 0;
if (LogicDocument.Pages[LogicDocument.CurPage])
ContentPos = LogicDocument.Pages[LogicDocument.CurPage].Pos + 1;
else
ContentPos = 0;
ContentPos = Math.max(0, Math.min(LogicDocument.Content.length - 1, ContentPos));
LogicDocument.CurPos.ContentPos = ContentPos;
LogicDocument.Content[ContentPos].Cursor_MoveToStartPos(false);
}
};
CDrawingsController.prototype.AddToParagraph = function(oItem, bRecalculate) CDrawingsController.prototype.AddToParagraph = function(oItem, bRecalculate)
......
...@@ -285,8 +285,11 @@ CFootnotesController.prototype.CanTargetUpdate = function() ...@@ -285,8 +285,11 @@ CFootnotesController.prototype.CanTargetUpdate = function()
}; };
CFootnotesController.prototype.RecalculateCurPos = function() CFootnotesController.prototype.RecalculateCurPos = function()
{ {
// TODO: Доделать селект и курсор
if (null !== this.CurFootnote) if (null !== this.CurFootnote)
this.CurFootnote.RecalculateCurPos(); return this.CurFootnote.RecalculateCurPos();
return {X : 0, Y : 0, Height : 0, PageNum : 0, Internal : {Line : 0, Page : 0, Range : 0}, Transform : null};
}; };
CFootnotesController.prototype.GetCurPage = function() CFootnotesController.prototype.GetCurPage = function()
{ {
...@@ -1048,6 +1051,18 @@ CFootnotesController.prototype.GetSelectionAnchorPos = function() ...@@ -1048,6 +1051,18 @@ CFootnotesController.prototype.GetSelectionAnchorPos = function()
Page : 0 Page : 0
}; };
}; };
CFootnotesController.prototype.StartSelectionFromCurPos = function()
{
// TODO: Реализовать
};
CFootnotesController.prototype.SaveDocumentStateBeforeLoadChanges = function(State)
{
// TODO: Реализовать
};
CFootnotesController.prototype.RestoreDocumentStateAfterLoadChanges = function(State)
{
// TODO: Реализовать
};
CFootnotesController.prototype.AddToParagraph = function(oItem, bRecalculate) CFootnotesController.prototype.AddToParagraph = function(oItem, bRecalculate)
{ {
......
...@@ -29,7 +29,7 @@ CHdrFtrController.prototype.CanTargetUpdate = function() ...@@ -29,7 +29,7 @@ CHdrFtrController.prototype.CanTargetUpdate = function()
}; };
CHdrFtrController.prototype.RecalculateCurPos = function() CHdrFtrController.prototype.RecalculateCurPos = function()
{ {
this.HdrFtr.RecalculateCurPos(); return this.HdrFtr.RecalculateCurPos();
}; };
CHdrFtrController.prototype.GetCurPage = function() CHdrFtrController.prototype.GetCurPage = function()
{ {
...@@ -376,6 +376,71 @@ CHdrFtrController.prototype.GetSelectionAnchorPos = function() ...@@ -376,6 +376,71 @@ CHdrFtrController.prototype.GetSelectionAnchorPos = function()
{ {
return this.HdrFtr.Get_SelectionAnchorPos(); return this.HdrFtr.Get_SelectionAnchorPos();
}; };
CHdrFtrController.prototype.StartSelectionFromCurPos = function()
{
this.HdrFtr.Start_SelectionFromCurPos();
};
CHdrFtrController.prototype.SaveDocumentStateBeforeLoadChanges = function(State)
{
var HdrFtr = this.HdrFtr.Get_CurHdrFtr();
if (null !== HdrFtr)
{
var HdrFtrContent = HdrFtr.Get_DocumentContent();
State.HdrFtr = HdrFtr;
State.HdrFtrDocPosType = HdrFtrContent.CurPos.Type;
State.HdrFtrSelection = HdrFtrContent.Selection.Use;
if (docpostype_Content === HdrFtrContent.Get_DocPosType())
{
State.Pos = HdrFtrContent.Get_ContentPosition(false, false, undefined);
State.StartPos = HdrFtrContent.Get_ContentPosition(true, true, undefined);
State.EndPos = HdrFtrContent.Get_ContentPosition(true, false, undefined);
}
else if (docpostype_DrawingObjects === HdrFtrContent.Get_DocPosType())
{
this.LogicDocument.DrawingObjects.Save_DocumentStateBeforeLoadChanges(State);
}
}
};
CHdrFtrController.prototype.RestoreDocumentStateAfterLoadChanges = function(State)
{
var HdrFtr = State.HdrFtr;
if (null !== HdrFtr && undefined !== HdrFtr && true === HdrFtr.Is_UseInDocument())
{
this.HdrFtr.Set_CurHdrFtr(HdrFtr);
var HdrFtrContent = HdrFtr.Get_DocumentContent();
if (docpostype_Content === State.HdrFtrDocPosType)
{
HdrFtrContent.Set_DocPosType(docpostype_Content);
HdrFtrContent.Selection.Use = State.HdrFtrSelection;
if (true === HdrFtrContent.Selection.Use)
{
HdrFtrContent.Set_ContentPosition(State.StartPos, 0, 0);
HdrFtrContent.Set_ContentSelection(State.StartPos, State.EndPos, 0, 0, 0);
}
else
{
HdrFtrContent.Set_ContentPosition(State.Pos, 0, 0);
this.LogicDocument.NeedUpdateTarget = true;
}
}
else if (docpostype_DrawingObjects === State.HdrFtrDocPosType)
{
HdrFtrContent.Set_DocPosType(docpostype_DrawingObjects);
if (true !== this.LogicDocument.DrawingObjects.Load_DocumentStateAfterLoadChanges(State))
{
HdrFtrContent.Set_DocPosType(docpostype_Content);
this.LogicDocument.Cursor_MoveAt(State.X ? State.X : 0, State.Y ? State.Y : 0, false);
}
}
}
else
{
this.LogicDocument.Document_End_HdrFtrEditing();
}
};
CHdrFtrController.prototype.AddToParagraph = function(oItem, bRecalculate) CHdrFtrController.prototype.AddToParagraph = function(oItem, bRecalculate)
......
...@@ -23,7 +23,7 @@ CLogicDocumentController.prototype.CanTargetUpdate = function() ...@@ -23,7 +23,7 @@ CLogicDocumentController.prototype.CanTargetUpdate = function()
}; };
CLogicDocumentController.prototype.RecalculateCurPos = function() CLogicDocumentController.prototype.RecalculateCurPos = function()
{ {
this.LogicDocument.controller_RecalculateCurPos(); return this.LogicDocument.controller_RecalculateCurPos();
}; };
CLogicDocumentController.prototype.GetCurPage = function() CLogicDocumentController.prototype.GetCurPage = function()
{ {
...@@ -349,6 +349,18 @@ CLogicDocumentController.prototype.GetSelectionAnchorPos = function() ...@@ -349,6 +349,18 @@ CLogicDocumentController.prototype.GetSelectionAnchorPos = function()
{ {
return this.LogicDocument.controller_GetSelectionAnchorPos(); return this.LogicDocument.controller_GetSelectionAnchorPos();
}; };
CLogicDocumentController.prototype.StartSelectionFromCurPos = function()
{
this.LogicDocument.controller_StartSelectionFromCurPos();
};
CLogicDocumentController.prototype.SaveDocumentStateBeforeLoadChanges = function(State)
{
this.LogicDocument.controller_SaveDocumentStateBeforeLoadChanges(State);
};
CLogicDocumentController.prototype.RestoreDocumentStateAfterLoadChanges = function(State)
{
this.LogicDocument.controller_RestoreDocumentStateAfterLoadChanges(State);
};
CLogicDocumentController.prototype.AddToParagraph = function(oItem) CLogicDocumentController.prototype.AddToParagraph = function(oItem)
......
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