Commit 2328b023 authored by Ilya Kirillov's avatar Ilya Kirillov

Рефакторинг функций связанных с обновлением интерфейса.

parent e857a6e9
......@@ -7819,62 +7819,18 @@ CDocument.prototype.Document_UpdateInterfaceState = function(bSaveCurRevis
return;
// Удаляем весь список
editor.sync_BeginCatchSelectedElements();
this.Api.sync_BeginCatchSelectedElements();
this.TrackRevisionsManager.Begin_CollectChanges(bSaveCurRevisionChange);
// Уберем из интерфейса записи о том где мы находимся (параграф, таблица, картинка или колонтитул)
editor.ClearPropObjCallback();
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
{
this.Interface_Update_HdrFtrPr();
this.HdrFtr.Document_UpdateInterfaceState();
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
var drawin_objects = this.DrawingObjects;
var oTargetTextObject = AscFormat.getTargetTextObject(this.DrawingObjects);
if (oTargetTextObject)
{
this.Interface_Update_DrawingPr();
this.DrawingObjects.documentUpdateInterfaceState();
}
else
{
this.DrawingObjects.resetInterfaceTextPr();
this.DrawingObjects.updateTextPr();
this.Interface_Update_DrawingPr();
this.DrawingObjects.updateParentParagraphParaPr();
}
}
else if (docpostype_Content == this.CurPos.Type && ( ( true === this.Selection.Use && this.Selection.StartPos == this.Selection.EndPos && type_Table == this.Content[this.Selection.StartPos].GetType() ) || ( false == this.Selection.Use && type_Table == this.Content[this.CurPos.ContentPos].GetType() ) ))
{
this.Interface_Update_TablePr();
if (true == this.Selection.Use)
this.Content[this.Selection.StartPos].Document_UpdateInterfaceState();
else
this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState();
}
else
{
this.Interface_Update_ParaPr();
this.Interface_Update_TextPr();
// Если у нас в выделении находится 1 параграф, или курсор находится в параграфе
if (docpostype_Content == this.CurPos.Type && ( ( true === this.Selection.Use && this.Selection.StartPos == this.Selection.EndPos && type_Paragraph == this.Content[this.Selection.StartPos].GetType() ) || ( false == this.Selection.Use && type_Paragraph == this.Content[this.CurPos.ContentPos].GetType() ) ))
{
if (true == this.Selection.Use)
this.Content[this.Selection.StartPos].Document_UpdateInterfaceState();
else
this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState();
}
}
this.Api.ClearPropObjCallback();
this.Controller.UpdateInterfaceState();
this.TrackRevisionsManager.End_CollectChanges(editor);
// Сообщаем, что список составлен
editor.sync_EndCatchSelectedElements();
this.Api.sync_EndCatchSelectedElements();
this.Document_UpdateUndoRedoState();
this.Document_UpdateCanAddHyperlinkState();
......@@ -7890,94 +7846,7 @@ CDocument.prototype.Document_UpdateRulersState = function()
return;
this.DrawingDocument.Set_RulerState_Start();
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
{
this.DrawingDocument.Set_RulerState_Paragraph(null);
this.HdrFtr.Document_UpdateRulersState(this.CurPage);
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
// Вызываем данную функцию, чтобы убрать рамку буквицы
this.DrawingDocument.Set_RulerState_Paragraph(null);
this.Document_UpdateRulersStateBySection(this.CurPos.ContentPos);
this.DrawingObjects.documentUpdateRulersState();
}
else //if ( docpostype_Content === this.CurPos.Type )
{
if (true === this.Selection.Use)
{
if (this.Selection.StartPos == this.Selection.EndPos && type_Table === this.Content[this.Selection.StartPos].GetType())
{
var PagePos = this.Get_DocumentPagePositionByContentPosition(this.Get_ContentPosition(true, true));
var Page = PagePos ? PagePos.Page : this.CurPage;
var Column = PagePos ? PagePos.Column : 0;
var ElementPos = this.Selection.StartPos;
var Element = this.Content[ElementPos];
var ElementPageIndex = this.private_GetElementPageIndex(ElementPos, Page, Column, Element.Get_ColumnsCount());
Element.Document_UpdateRulersState(ElementPageIndex);
}
else
{
var StartPos = ( this.Selection.EndPos <= this.Selection.StartPos ? this.Selection.EndPos : this.Selection.StartPos );
var EndPos = ( this.Selection.EndPos <= this.Selection.StartPos ? this.Selection.StartPos : this.Selection.EndPos );
var FramePr = undefined;
for (var Pos = StartPos; Pos <= EndPos; Pos++)
{
var Element = this.Content[Pos];
if (type_Paragraph != Element.GetType())
{
FramePr = undefined;
break;
}
else
{
var TempFramePr = Element.Get_FramePr();
if (undefined === FramePr)
{
if (undefined === TempFramePr)
break;
FramePr = TempFramePr;
}
else if (undefined === TempFramePr || false === FramePr.Compare(TempFramePr))
{
FramePr = undefined;
break;
}
}
}
if (undefined === FramePr)
this.Document_UpdateRulersStateBySection();
else
this.Content[StartPos].Document_UpdateRulersState();
}
}
else
{
this.Internal_CheckCurPage();
if (this.CurPos.ContentPos >= 0 && (null === this.FullRecalc.Id || this.FullRecalc.StartIndex > this.CurPos.ContentPos))
{
var PagePos = this.Get_DocumentPagePositionByContentPosition(this.Get_ContentPosition(false));
var Page = PagePos ? PagePos.Page : this.CurPage;
var Column = PagePos ? PagePos.Column : 0;
var ElementPos = this.CurPos.ContentPos;
var Element = this.Content[ElementPos];
var ElementPageIndex = this.private_GetElementPageIndex(ElementPos, Page, Column, Element.Get_ColumnsCount());
Element.Document_UpdateRulersState(ElementPageIndex);
}
}
}
this.Controller.UpdateRulersState();
this.DrawingDocument.Set_RulerState_End();
};
CDocument.prototype.Document_UpdateRulersStateBySection = function(Pos)
......@@ -8018,87 +7887,19 @@ CDocument.prototype.Document_UpdateSelectionState = function()
return;
this.DrawingDocument.UpdateTargetTransform(null);
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
{
this.HdrFtr.Document_UpdateSelectionState();
this.private_UpdateTracks(this.Is_SelectionUse(), this.Selection_IsEmpty());
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
this.DrawingObjects.documentUpdateSelectionState();
this.private_UpdateTracks(this.Is_SelectionUse(), this.Selection_IsEmpty());
}
else //if ( docpostype_Content === this.CurPos.Type )
{
if (true === this.Selection.Use)
{
// Выделение нумерации
if (selectionflag_Numbering == this.Selection.Flag)
{
this.DrawingDocument.TargetEnd();
this.DrawingDocument.SelectEnabled(true);
this.DrawingDocument.SelectShow();
}
// Обрабатываем движение границы у таблиц
else if (true === this.Selection_Is_TableBorderMove())
{
// Убираем курсор, если он был
this.DrawingDocument.TargetEnd();
this.DrawingDocument.SetCurrentPage(this.CurPage);
}
else
{
if (false === this.Selection_IsEmpty())
{
if (true !== this.Selection.Start)
{
this.Internal_CheckCurPage();
this.RecalculateCurPos();
}
this.private_UpdateTracks(true, false);
this.DrawingDocument.TargetEnd();
this.DrawingDocument.SelectEnabled(true);
this.DrawingDocument.SelectShow();
}
else
{
if (true !== this.Selection.Start)
{
this.Selection_Remove();
}
this.Internal_CheckCurPage();
this.RecalculateCurPos();
this.private_UpdateTracks(true, true);
this.DrawingDocument.SelectEnabled(false);
this.DrawingDocument.TargetStart();
this.DrawingDocument.TargetShow();
}
}
}
else
{
this.Selection_Remove();
this.Internal_CheckCurPage();
this.RecalculateCurPos();
this.private_UpdateTracks(false, false);
this.DrawingDocument.SelectEnabled(false);
this.DrawingDocument.TargetShow();
}
}
this.Controller.UpdateSelectionState();
// Обновим состояние кнопок Copy/Cut
this.Document_UpdateCopyCutState();
};
CDocument.prototype.Document_UpdateTracks = function()
{
this.private_UpdateTracks(this.Is_SelectionUse(), this.Selection_IsEmpty());
};
CDocument.prototype.private_UpdateTracks = function(bSelection, bEmptySelection)
{
var Pos = (true === this.Selection.Use && selectionflag_Numbering !== this.Selection.Flag ? this.Selection.EndPos : this.CurPos.ContentPos);
if (docpostype_Content === this.CurPos.Type && !(Pos >= 0 && (null === this.FullRecalc.Id || this.FullRecalc.StartIndex > Pos)))
if (docpostype_Content === this.Get_DocPosType() && !(Pos >= 0 && (null === this.FullRecalc.Id || this.FullRecalc.StartIndex > Pos)))
return;
// Обновляем трэк формул
......@@ -8130,9 +7931,9 @@ CDocument.prototype.Document_UpdateUndoRedoState = function()
// данные события при изменении значения History.Index
// Проверяем состояние Undo/Redo
editor.sync_CanUndoCallback(this.History.Can_Undo());
editor.sync_CanRedoCallback(this.History.Can_Redo());
editor.CheckChangedDocument();
this.Api.sync_CanUndoCallback(this.History.Can_Undo());
this.Api.sync_CanRedoCallback(this.History.Can_Redo());
this.Api.CheckChangedDocument();
};
CDocument.prototype.Document_UpdateCopyCutState = function()
{
......@@ -8146,7 +7947,7 @@ CDocument.prototype.Document_UpdateCopyCutState = function()
if (true === this.Selection.Start)
return;
editor.sync_CanCopyCutCallback(this.Can_CopyCut());
this.Api.sync_CanCopyCutCallback(this.Can_CopyCut());
};
CDocument.prototype.Document_UpdateCanAddHyperlinkState = function()
{
......@@ -8157,7 +7958,7 @@ CDocument.prototype.Document_UpdateCanAddHyperlinkState = function()
return;
// Проверяем можно ли добавить гиперссылку
editor.sync_CanAddHyperlinkCallback(this.Hyperlink_CanAdd(false));
this.Api.sync_CanAddHyperlinkCallback(this.Hyperlink_CanAdd(false));
};
CDocument.prototype.Document_UpdateSectionPr = function()
{
......@@ -8241,23 +8042,23 @@ CDocument.prototype.Can_CopyCut = function()
var LogicDocument = null;
var DrawingObjects = null;
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
var nDocPosType = this.Get_DocPosType();
if (docpostype_HdrFtr === nDocPosType)
{
var CurHdrFtr = this.HdrFtr.CurHdrFtr;
if (null !== CurHdrFtr)
{
if (docpostype_DrawingObjects === CurHdrFtr.Content.CurPos.Type)
if (docpostype_DrawingObjects === CurHdrFtr.Content.Get_DocPosType())
DrawingObjects = this.DrawingObjects;
else
LogicDocument = CurHdrFtr.Content;
}
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
else if (docpostype_DrawingObjects === nDocPosType)
{
DrawingObjects = this.DrawingObjects;
}
else //if ( docpostype_Content === this.CurPos.Type )
else //if (docpostype_Content === nDocPosType)
{
LogicDocument = this;
}
......@@ -8307,7 +8108,7 @@ CDocument.prototype.Set_CurPage = function(PageNum)
CDocument.prototype.Get_CurPage = function()
{
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
if (docpostype_HdrFtr === this.Get_DocPosType())
return this.HdrFtr.Get_CurPage();
return this.CurPage;
......@@ -15772,6 +15573,167 @@ CDocument.prototype.controller_CanSplitTableCells = function()
return false;
};
CDocument.prototype.controller_UpdateInterfaceState = function()
{
if ((true === this.Selection.Use && this.Selection.StartPos == this.Selection.EndPos && type_Table == this.Content[this.Selection.StartPos].GetType())
|| (false == this.Selection.Use && type_Table == this.Content[this.CurPos.ContentPos].GetType()))
{
this.Interface_Update_TablePr();
if (true == this.Selection.Use)
this.Content[this.Selection.StartPos].Document_UpdateInterfaceState();
else
this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState();
}
else
{
this.Interface_Update_ParaPr();
this.Interface_Update_TextPr();
// Если у нас в выделении находится 1 параграф, или курсор находится в параграфе
if (docpostype_Content == this.CurPos.Type && ( ( true === this.Selection.Use && this.Selection.StartPos == this.Selection.EndPos && type_Paragraph == this.Content[this.Selection.StartPos].GetType() ) || ( false == this.Selection.Use && type_Paragraph == this.Content[this.CurPos.ContentPos].GetType() ) ))
{
if (true == this.Selection.Use)
this.Content[this.Selection.StartPos].Document_UpdateInterfaceState();
else
this.Content[this.CurPos.ContentPos].Document_UpdateInterfaceState();
}
}
};
CDocument.prototype.controller_UpdateRulersState = function()
{
if (true === this.Selection.Use)
{
if (this.Selection.StartPos == this.Selection.EndPos && type_Table === this.Content[this.Selection.StartPos].GetType())
{
var PagePos = this.Get_DocumentPagePositionByContentPosition(this.Get_ContentPosition(true, true));
var Page = PagePos ? PagePos.Page : this.CurPage;
var Column = PagePos ? PagePos.Column : 0;
var ElementPos = this.Selection.StartPos;
var Element = this.Content[ElementPos];
var ElementPageIndex = this.private_GetElementPageIndex(ElementPos, Page, Column, Element.Get_ColumnsCount());
Element.Document_UpdateRulersState(ElementPageIndex);
}
else
{
var StartPos = ( this.Selection.EndPos <= this.Selection.StartPos ? this.Selection.EndPos : this.Selection.StartPos );
var EndPos = ( this.Selection.EndPos <= this.Selection.StartPos ? this.Selection.StartPos : this.Selection.EndPos );
var FramePr = undefined;
for (var Pos = StartPos; Pos <= EndPos; Pos++)
{
var Element = this.Content[Pos];
if (type_Paragraph != Element.GetType())
{
FramePr = undefined;
break;
}
else
{
var TempFramePr = Element.Get_FramePr();
if (undefined === FramePr)
{
if (undefined === TempFramePr)
break;
FramePr = TempFramePr;
}
else if (undefined === TempFramePr || false === FramePr.Compare(TempFramePr))
{
FramePr = undefined;
break;
}
}
}
if (undefined === FramePr)
this.Document_UpdateRulersStateBySection();
else
this.Content[StartPos].Document_UpdateRulersState();
}
}
else
{
this.Internal_CheckCurPage();
if (this.CurPos.ContentPos >= 0 && (null === this.FullRecalc.Id || this.FullRecalc.StartIndex > this.CurPos.ContentPos))
{
var PagePos = this.Get_DocumentPagePositionByContentPosition(this.Get_ContentPosition(false));
var Page = PagePos ? PagePos.Page : this.CurPage;
var Column = PagePos ? PagePos.Column : 0;
var ElementPos = this.CurPos.ContentPos;
var Element = this.Content[ElementPos];
var ElementPageIndex = this.private_GetElementPageIndex(ElementPos, Page, Column, Element.Get_ColumnsCount());
Element.Document_UpdateRulersState(ElementPageIndex);
}
}
};
CDocument.prototype.controller_UpdateSelectionState = function()
{
if (true === this.Selection.Use)
{
// Выделение нумерации
if (selectionflag_Numbering == this.Selection.Flag)
{
this.DrawingDocument.TargetEnd();
this.DrawingDocument.SelectEnabled(true);
this.DrawingDocument.SelectShow();
}
// Обрабатываем движение границы у таблиц
else if (true === this.Selection_Is_TableBorderMove())
{
// Убираем курсор, если он был
this.DrawingDocument.TargetEnd();
this.DrawingDocument.SetCurrentPage(this.CurPage);
}
else
{
if (false === this.Selection_IsEmpty())
{
if (true !== this.Selection.Start)
{
this.Internal_CheckCurPage();
this.RecalculateCurPos();
}
this.private_UpdateTracks(true, false);
this.DrawingDocument.TargetEnd();
this.DrawingDocument.SelectEnabled(true);
this.DrawingDocument.SelectShow();
}
else
{
if (true !== this.Selection.Start)
{
this.Selection_Remove();
}
this.Internal_CheckCurPage();
this.RecalculateCurPos();
this.private_UpdateTracks(true, true);
this.DrawingDocument.SelectEnabled(false);
this.DrawingDocument.TargetStart();
this.DrawingDocument.TargetShow();
}
}
}
else
{
this.Selection_Remove();
this.Internal_CheckCurPage();
this.RecalculateCurPos();
this.private_UpdateTracks(false, false);
this.DrawingDocument.SelectEnabled(false);
this.DrawingDocument.TargetShow();
}
};
CDocument.prototype.controller_AddToParagraph = function(ParaItem, bRecalculate)
{
......
......@@ -626,6 +626,18 @@ CDocumentControllerBase.prototype.CanMergeTableCells = function(){return false;}
* @returns {boolean}
*/
CDocumentControllerBase.prototype.CanSplitTableCells = function(){return false;};
/**
* Обновляем состояние интерфейса.
*/
CDocumentControllerBase.prototype.UpdateInterfaceState = function(){};
/**
* Обновляем состояние линеек.
*/
CDocumentControllerBase.prototype.UpdateRulersState = function(){};
/**
* Обновляем состояние селекта и курсора.
*/
CDocumentControllerBase.prototype.UpdateSelectionState = function(){};
/**
* Добавляем элемент в параграф.
* @param oItem
......
......@@ -372,6 +372,34 @@ CDrawingsController.prototype.CanSplitTableCells = function()
{
return this.DrawingObjects.tableCheckSplit();
};
CDrawingsController.prototype.UpdateInterfaceState = function()
{
var oTargetTextObject = AscFormat.getTargetTextObject(this.DrawingObjects);
if (oTargetTextObject)
{
this.LogicDocument.Interface_Update_DrawingPr();
this.DrawingObjects.documentUpdateInterfaceState();
}
else
{
this.DrawingObjects.resetInterfaceTextPr();
this.DrawingObjects.updateTextPr();
this.LogicDocument.Interface_Update_DrawingPr();
this.DrawingObjects.updateParentParagraphParaPr();
}
};
CDrawingsController.prototype.UpdateRulersState = function()
{
// Вызываем данную функцию, чтобы убрать рамку буквицы
this.DrawingDocument.Set_RulerState_Paragraph(null);
this.LogicDocument.Document_UpdateRulersStateBySection(this.LogicDocument.CurPos.ContentPos);
this.DrawingObjects.documentUpdateRulersState();
};
CDrawingsController.prototype.UpdateSelectionState = function()
{
this.DrawingObjects.documentUpdateSelectionState();
this.LogicDocument.Document_UpdateTracks();
};
CDrawingsController.prototype.AddToParagraph = function(oItem, bRecalculate)
{
......
......@@ -987,6 +987,18 @@ CFootnotesController.prototype.CanSplitTableCells = function()
// TODO: Реализовать
return false;
};
CFootnotesController.prototype.UpdateInterfaceState = function()
{
// TODO: Реализовать
};
CFootnotesController.prototype.UpdateRulersState = function()
{
// TODO: Реализовать
};
CFootnotesController.prototype.UpdateSelectionState = function()
{
// TODO: Реализовать
};
CFootnotesController.prototype.AddToParagraph = function(oItem, bRecalculate)
{
......
......@@ -321,6 +321,21 @@ CHdrFtrController.prototype.CanSplitTableCells = function()
{
return this.HdrFtr.Table_CheckSplit();
};
CHdrFtrController.prototype.UpdateInterfaceState = function()
{
this.LogicDocument.Interface_Update_HdrFtrPr();
this.HdrFtr.Document_UpdateInterfaceState();
};
CHdrFtrController.prototype.UpdateRulersState = function()
{
this.DrawingDocument.Set_RulerState_Paragraph(null);
this.HdrFtr.Document_UpdateRulersState(this.LogicDocument.CurPage);
};
CHdrFtrController.prototype.UpdateSelectionState = function()
{
this.HdrFtr.Document_UpdateSelectionState();
this.LogicDocument.Document_UpdateTracks();
};
......
......@@ -297,7 +297,18 @@ CLogicDocumentController.prototype.CanSplitTableCells = function()
{
return this.LogicDocument.controller_CanSplitTableCells();
};
CLogicDocumentController.prototype.UpdateInterfaceState = function()
{
this.LogicDocument.controller_UpdateInterfaceState();
};
CLogicDocumentController.prototype.UpdateRulersState = function()
{
this.LogicDocument.controller_UpdateRulersState();
};
CLogicDocumentController.prototype.UpdateSelectionState = function()
{
this.LogicDocument.controller_UpdateSelectionState();
};
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