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

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

parent e857a6e9
...@@ -7751,461 +7751,262 @@ CDocument.prototype.Check_TableCoincidence = function(Table) ...@@ -7751,461 +7751,262 @@ CDocument.prototype.Check_TableCoincidence = function(Table)
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Дополнительные функции // Дополнительные функции
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
CDocument.prototype.Document_CreateFontMap = function() CDocument.prototype.Document_CreateFontMap = function()
{ {
var StartTime = new Date().getTime(); var StartTime = new Date().getTime();
var FontMap = {}; var FontMap = {};
this.SectionsInfo.Document_CreateFontMap(FontMap); this.SectionsInfo.Document_CreateFontMap(FontMap);
var CurPage = 0; var CurPage = 0;
this.DrawingObjects.documentCreateFontMap(CurPage, FontMap); this.DrawingObjects.documentCreateFontMap(CurPage, FontMap);
var Count = this.Content.length; var Count = this.Content.length;
for (var Index = 0; Index < Count; Index++) for (var Index = 0; Index < Count; Index++)
{ {
var Element = this.Content[Index]; var Element = this.Content[Index];
Element.Document_CreateFontMap(FontMap); Element.Document_CreateFontMap(FontMap);
if (Element.Pages.length > 1) if (Element.Pages.length > 1)
{ {
for (var TempIndex = 1; TempIndex < Element.Pages.length - 1; TempIndex++) for (var TempIndex = 1; TempIndex < Element.Pages.length - 1; TempIndex++)
this.DrawingObjects.documentCreateFontMap(++CurPage, FontMap); this.DrawingObjects.documentCreateFontMap(++CurPage, FontMap);
} }
} }
AscFormat.checkThemeFonts(FontMap, this.theme.themeElements.fontScheme); AscFormat.checkThemeFonts(FontMap, this.theme.themeElements.fontScheme);
return FontMap; return FontMap;
}; };
CDocument.prototype.Document_CreateFontCharMap = function(FontCharMap) CDocument.prototype.Document_CreateFontCharMap = function(FontCharMap)
{ {
this.SectionsInfo.Document_CreateFontCharMap(FontCharMap); this.SectionsInfo.Document_CreateFontCharMap(FontCharMap);
this.DrawingObjects.documentCreateFontCharMap(FontCharMap); this.DrawingObjects.documentCreateFontCharMap(FontCharMap);
var Count = this.Content.length; var Count = this.Content.length;
for (var Index = 0; Index < Count; Index++) for (var Index = 0; Index < Count; Index++)
{ {
var Element = this.Content[Index]; var Element = this.Content[Index];
Element.Document_CreateFontCharMap(FontCharMap); Element.Document_CreateFontCharMap(FontCharMap);
} }
}; };
CDocument.prototype.Document_Get_AllFontNames = function() CDocument.prototype.Document_Get_AllFontNames = function()
{ {
var AllFonts = {}; var AllFonts = {};
this.SectionsInfo.Document_Get_AllFontNames(AllFonts); this.SectionsInfo.Document_Get_AllFontNames(AllFonts);
this.Numbering.Document_Get_AllFontNames(AllFonts); this.Numbering.Document_Get_AllFontNames(AllFonts);
this.Styles.Document_Get_AllFontNames(AllFonts); this.Styles.Document_Get_AllFontNames(AllFonts);
this.theme.Document_Get_AllFontNames(AllFonts); this.theme.Document_Get_AllFontNames(AllFonts);
var Count = this.Content.length; var Count = this.Content.length;
for (var Index = 0; Index < Count; Index++) for (var Index = 0; Index < Count; Index++)
{ {
var Element = this.Content[Index]; var Element = this.Content[Index];
Element.Document_Get_AllFontNames(AllFonts); Element.Document_Get_AllFontNames(AllFonts);
} }
AscFormat.checkThemeFonts(AllFonts, this.theme.themeElements.fontScheme); AscFormat.checkThemeFonts(AllFonts, this.theme.themeElements.fontScheme);
return AllFonts; return AllFonts;
}; };
/** /**
* Обновляем текущее состояние (определяем где мы находимся, картинка/параграф/таблица/колонтитул) * Обновляем текущее состояние (определяем где мы находимся, картинка/параграф/таблица/колонтитул)
* @param bSaveCurRevisionChange * @param bSaveCurRevisionChange
*/ */
CDocument.prototype.Document_UpdateInterfaceState = function(bSaveCurRevisionChange) CDocument.prototype.Document_UpdateInterfaceState = function(bSaveCurRevisionChange)
{ {
if (true === this.TurnOffInterfaceEvents) if (true === this.TurnOffInterfaceEvents)
return; return;
if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection) if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection)
return; return;
// Удаляем весь список // Удаляем весь список
editor.sync_BeginCatchSelectedElements(); this.Api.sync_BeginCatchSelectedElements();
this.TrackRevisionsManager.Begin_CollectChanges(bSaveCurRevisionChange); this.TrackRevisionsManager.Begin_CollectChanges(bSaveCurRevisionChange);
// Уберем из интерфейса записи о том где мы находимся (параграф, таблица, картинка или колонтитул) // Уберем из интерфейса записи о том где мы находимся (параграф, таблица, картинка или колонтитул)
editor.ClearPropObjCallback(); this.Api.ClearPropObjCallback();
// Работаем с колонтитулом this.Controller.UpdateInterfaceState();
if (docpostype_HdrFtr === this.CurPos.Type) this.TrackRevisionsManager.End_CollectChanges(editor);
{
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.TrackRevisionsManager.End_CollectChanges(editor); // Сообщаем, что список составлен
// Сообщаем, что список составлен this.Api.sync_EndCatchSelectedElements();
editor.sync_EndCatchSelectedElements();
this.Document_UpdateUndoRedoState(); this.Document_UpdateUndoRedoState();
this.Document_UpdateCanAddHyperlinkState(); this.Document_UpdateCanAddHyperlinkState();
this.Document_UpdateSectionPr(); this.Document_UpdateSectionPr();
this.Document_UpdateStylesPanel(); this.Document_UpdateStylesPanel();
}; };
CDocument.prototype.Document_UpdateRulersState = function() CDocument.prototype.Document_UpdateRulersState = function()
{ {
if (true === this.TurnOffInterfaceEvents) if (true === this.TurnOffInterfaceEvents)
return; return;
if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection)
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; if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection)
var Element = this.Content[ElementPos]; return;
var ElementPageIndex = this.private_GetElementPageIndex(ElementPos, Page, Column, Element.Get_ColumnsCount());
Element.Document_UpdateRulersState(ElementPageIndex);
}
}
}
this.DrawingDocument.Set_RulerState_End(); this.DrawingDocument.Set_RulerState_Start();
this.Controller.UpdateRulersState();
this.DrawingDocument.Set_RulerState_End();
}; };
CDocument.prototype.Document_UpdateRulersStateBySection = function(Pos) CDocument.prototype.Document_UpdateRulersStateBySection = function(Pos)
{ {
// В данной функции мы уже точно знаем, что нам секцию нужно выбирать исходя из текущего параграфа // В данной функции мы уже точно знаем, что нам секцию нужно выбирать исходя из текущего параграфа
var CurPos = undefined === Pos ? ( this.Selection.Use === true ? this.Selection.EndPos : this.CurPos.ContentPos ) : Pos; var CurPos = undefined === Pos ? ( this.Selection.Use === true ? this.Selection.EndPos : this.CurPos.ContentPos ) : Pos;
var SectPr = this.SectionsInfo.Get_SectPr(CurPos).SectPr; var SectPr = this.SectionsInfo.Get_SectPr(CurPos).SectPr;
var L = SectPr.Get_PageMargin_Left(); var L = SectPr.Get_PageMargin_Left();
var T = SectPr.Get_PageMargin_Top(); var T = SectPr.Get_PageMargin_Top();
var R = SectPr.Get_PageWidth() - SectPr.Get_PageMargin_Right(); var R = SectPr.Get_PageWidth() - SectPr.Get_PageMargin_Right();
var B = SectPr.Get_PageHeight() - SectPr.Get_PageMargin_Bottom(); var B = SectPr.Get_PageHeight() - SectPr.Get_PageMargin_Bottom();
var ColumnsCount = SectPr.Get_ColumnsCount(); var ColumnsCount = SectPr.Get_ColumnsCount();
if (ColumnsCount > 1) if (ColumnsCount > 1)
{ {
this.ColumnsMarkup.Update_FromSectPr(SectPr); this.ColumnsMarkup.Update_FromSectPr(SectPr);
var Element = this.Content[CurPos]; var Element = this.Content[CurPos];
if (type_Paragraph === Element.Get_Type()) if (type_Paragraph === Element.Get_Type())
this.ColumnsMarkup.Set_CurCol(Element.Get_CurrentColumn()); this.ColumnsMarkup.Set_CurCol(Element.Get_CurrentColumn());
this.DrawingDocument.Set_RulerState_Columns(this.ColumnsMarkup); this.DrawingDocument.Set_RulerState_Columns(this.ColumnsMarkup);
} }
else else
{ {
this.DrawingDocument.Set_RulerState_Paragraph({L : L, T : T, R : R, B : B}, true); this.DrawingDocument.Set_RulerState_Paragraph({L : L, T : T, R : R, B : B}, true);
} }
}; };
CDocument.prototype.Document_UpdateSelectionState = function() CDocument.prototype.Document_UpdateSelectionState = function()
{ {
if (true === this.TurnOffInterfaceEvents) if (true === this.TurnOffInterfaceEvents)
return; return;
if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection)
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); if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection)
this.DrawingDocument.TargetStart(); return;
this.DrawingDocument.TargetShow();
}
}
}
else
{
this.Selection_Remove();
this.Internal_CheckCurPage();
this.RecalculateCurPos();
this.private_UpdateTracks(false, false);
this.DrawingDocument.SelectEnabled(false); this.DrawingDocument.UpdateTargetTransform(null);
this.DrawingDocument.TargetShow(); this.Controller.UpdateSelectionState();
}
}
// Обновим состояние кнопок Copy/Cut // Обновим состояние кнопок Copy/Cut
this.Document_UpdateCopyCutState(); this.Document_UpdateCopyCutState();
}; };
CDocument.prototype.private_UpdateTracks = function(bSelection, bEmptySelection) CDocument.prototype.Document_UpdateTracks = function()
{ {
var Pos = (true === this.Selection.Use && selectionflag_Numbering !== this.Selection.Flag ? this.Selection.EndPos : this.CurPos.ContentPos); this.private_UpdateTracks(this.Is_SelectionUse(), this.Selection_IsEmpty());
if (docpostype_Content === this.CurPos.Type && !(Pos >= 0 && (null === this.FullRecalc.Id || this.FullRecalc.StartIndex > Pos))) };
return; 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.Get_DocPosType() && !(Pos >= 0 && (null === this.FullRecalc.Id || this.FullRecalc.StartIndex > Pos)))
return;
// Обновляем трэк формул // Обновляем трэк формул
var oSelectedInfo = this.Get_SelectedElementsInfo(); var oSelectedInfo = this.Get_SelectedElementsInfo();
var Math = oSelectedInfo.Get_Math(); var Math = oSelectedInfo.Get_Math();
if (null !== Math) if (null !== Math)
this.DrawingDocument.Update_MathTrack(true, (false === bSelection || true === bEmptySelection ? true : false), Math); this.DrawingDocument.Update_MathTrack(true, (false === bSelection || true === bEmptySelection ? true : false), Math);
else else
this.DrawingDocument.Update_MathTrack(false); this.DrawingDocument.Update_MathTrack(false);
var oField = oSelectedInfo.Get_Field(); var oField = oSelectedInfo.Get_Field();
if (null !== oField && (fieldtype_MERGEFIELD !== oField.Get_FieldType() || true !== this.MailMergeFieldsHighlight)) if (null !== oField && (fieldtype_MERGEFIELD !== oField.Get_FieldType() || true !== this.MailMergeFieldsHighlight))
{ {
var aBounds = oField.Get_Bounds(); var aBounds = oField.Get_Bounds();
this.DrawingDocument.Update_FieldTrack(true, aBounds); this.DrawingDocument.Update_FieldTrack(true, aBounds);
} }
else else
this.DrawingDocument.Update_FieldTrack(false); this.DrawingDocument.Update_FieldTrack(false);
}; };
CDocument.prototype.Document_UpdateUndoRedoState = function() CDocument.prototype.Document_UpdateUndoRedoState = function()
{ {
if (true === this.TurnOffInterfaceEvents) if (true === this.TurnOffInterfaceEvents)
return; return;
if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection) if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection)
return; return;
// TODO: Возможно стоит перенсти эту проверку в класс CHistory и присылать // TODO: Возможно стоит перенсти эту проверку в класс CHistory и присылать
// данные события при изменении значения History.Index // данные события при изменении значения History.Index
// Проверяем состояние Undo/Redo // Проверяем состояние Undo/Redo
editor.sync_CanUndoCallback(this.History.Can_Undo()); this.Api.sync_CanUndoCallback(this.History.Can_Undo());
editor.sync_CanRedoCallback(this.History.Can_Redo()); this.Api.sync_CanRedoCallback(this.History.Can_Redo());
editor.CheckChangedDocument(); this.Api.CheckChangedDocument();
}; };
CDocument.prototype.Document_UpdateCopyCutState = function() CDocument.prototype.Document_UpdateCopyCutState = function()
{ {
if (true === this.TurnOffInterfaceEvents) if (true === this.TurnOffInterfaceEvents)
return; return;
if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection) if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection)
return; return;
// Во время работы селекта не обновляем состояние // Во время работы селекта не обновляем состояние
if (true === this.Selection.Start) if (true === this.Selection.Start)
return; return;
editor.sync_CanCopyCutCallback(this.Can_CopyCut()); this.Api.sync_CanCopyCutCallback(this.Can_CopyCut());
}; };
CDocument.prototype.Document_UpdateCanAddHyperlinkState = function() CDocument.prototype.Document_UpdateCanAddHyperlinkState = function()
{ {
if (true === this.TurnOffInterfaceEvents) if (true === this.TurnOffInterfaceEvents)
return; return;
if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection) if (true === AscCommon.CollaborativeEditing.m_bGlobalLockSelection)
return; return;
// Проверяем можно ли добавить гиперссылку // Проверяем можно ли добавить гиперссылку
editor.sync_CanAddHyperlinkCallback(this.Hyperlink_CanAdd(false)); this.Api.sync_CanAddHyperlinkCallback(this.Hyperlink_CanAdd(false));
}; };
CDocument.prototype.Document_UpdateSectionPr = function() CDocument.prototype.Document_UpdateSectionPr = function()
{ {
if (true === this.TurnOffInterfaceEvents) if (true === this.TurnOffInterfaceEvents)
return; return;
if (true === this.CollaborativeEditing.m_bGlobalLockSelection) if (true === this.CollaborativeEditing.m_bGlobalLockSelection)
return; return;
// Обновляем ориентацию страницы // Обновляем ориентацию страницы
this.Api.sync_PageOrientCallback(this.Get_DocumentOrientation()); this.Api.sync_PageOrientCallback(this.Get_DocumentOrientation());
// Обновляем размер страницы // Обновляем размер страницы
var PageSize = this.Get_DocumentPageSize(); var PageSize = this.Get_DocumentPageSize();
this.Api.sync_DocSizeCallback(PageSize.W, PageSize.H); this.Api.sync_DocSizeCallback(PageSize.W, PageSize.H);
// Обновляем настройки колонок // Обновляем настройки колонок
var CurPos = this.CurPos.ContentPos; var CurPos = this.CurPos.ContentPos;
var SectPr = this.SectionsInfo.Get_SectPr(CurPos).SectPr; var SectPr = this.SectionsInfo.Get_SectPr(CurPos).SectPr;
if (SectPr) if (SectPr)
{ {
var ColumnsPr = new CDocumentColumnsProps(); var ColumnsPr = new CDocumentColumnsProps();
ColumnsPr.From_SectPr(SectPr); ColumnsPr.From_SectPr(SectPr);
this.Api.sync_ColumnsPropsCallback(ColumnsPr); this.Api.sync_ColumnsPropsCallback(ColumnsPr);
this.Api.sync_SectionPropsCallback(new CDocumentSectionProps(SectPr)); this.Api.sync_SectionPropsCallback(new CDocumentSectionProps(SectPr));
} }
}; };
CDocument.prototype.Get_ColumnsProps = function() CDocument.prototype.Get_ColumnsProps = function()
{ {
// Обновляем настройки колонок // Обновляем настройки колонок
var CurPos = this.CurPos.ContentPos; var CurPos = this.CurPos.ContentPos;
var SectPr = this.SectionsInfo.Get_SectPr(CurPos).SectPr; var SectPr = this.SectionsInfo.Get_SectPr(CurPos).SectPr;
var ColumnsPr = new CDocumentColumnsProps(); var ColumnsPr = new CDocumentColumnsProps();
if (SectPr) if (SectPr)
{ {
ColumnsPr.From_SectPr(SectPr); ColumnsPr.From_SectPr(SectPr);
} }
return ColumnsPr; return ColumnsPr;
}; };
/** /**
* Отключаем отсылку сообщений в интерфейс. * Отключаем отсылку сообщений в интерфейс.
*/ */
CDocument.prototype.TurnOff_InterfaceEvents = function() CDocument.prototype.TurnOff_InterfaceEvents = function()
{ {
this.TurnOffInterfaceEvents = true; this.TurnOffInterfaceEvents = true;
}; };
/** /**
* Включаем отсылку сообщений в интерфейс. * Включаем отсылку сообщений в интерфейс.
...@@ -8214,103 +8015,103 @@ CDocument.prototype.TurnOff_InterfaceEvents = function() ...@@ -8214,103 +8015,103 @@ CDocument.prototype.TurnOff_InterfaceEvents = function()
*/ */
CDocument.prototype.TurnOn_InterfaceEvents = function(bUpdate) CDocument.prototype.TurnOn_InterfaceEvents = function(bUpdate)
{ {
this.TurnOffInterfaceEvents = false; this.TurnOffInterfaceEvents = false;
if (true === bUpdate) if (true === bUpdate)
{ {
this.Document_UpdateInterfaceState(); this.Document_UpdateInterfaceState();
this.Document_UpdateSelectionState(); this.Document_UpdateSelectionState();
this.Document_UpdateRulersState(); this.Document_UpdateRulersState();
} }
}; };
CDocument.prototype.TurnOff_RecalculateCurPos = function() CDocument.prototype.TurnOff_RecalculateCurPos = function()
{ {
this.TurnOffRecalcCurPos = true; this.TurnOffRecalcCurPos = true;
}; };
CDocument.prototype.TurnOn_RecalculateCurPos = function(bUpdate) CDocument.prototype.TurnOn_RecalculateCurPos = function(bUpdate)
{ {
this.TurnOffRecalcCurPos = false; this.TurnOffRecalcCurPos = false;
if (true === bUpdate) if (true === bUpdate)
this.Document_UpdateSelectionState(); this.Document_UpdateSelectionState();
}; };
CDocument.prototype.Can_CopyCut = function() CDocument.prototype.Can_CopyCut = function()
{ {
var bCanCopyCut = false; var bCanCopyCut = false;
var LogicDocument = null; var LogicDocument = null;
var DrawingObjects = null; var DrawingObjects = null;
// Работаем с колонтитулом var nDocPosType = this.Get_DocPosType();
if (docpostype_HdrFtr === this.CurPos.Type) if (docpostype_HdrFtr === nDocPosType)
{ {
var CurHdrFtr = this.HdrFtr.CurHdrFtr; var CurHdrFtr = this.HdrFtr.CurHdrFtr;
if (null !== CurHdrFtr) if (null !== CurHdrFtr)
{ {
if (docpostype_DrawingObjects === CurHdrFtr.Content.CurPos.Type) if (docpostype_DrawingObjects === CurHdrFtr.Content.Get_DocPosType())
DrawingObjects = this.DrawingObjects; DrawingObjects = this.DrawingObjects;
else else
LogicDocument = CurHdrFtr.Content; LogicDocument = CurHdrFtr.Content;
} }
} }
else if (docpostype_DrawingObjects === this.CurPos.Type) else if (docpostype_DrawingObjects === nDocPosType)
{ {
DrawingObjects = this.DrawingObjects; DrawingObjects = this.DrawingObjects;
} }
else //if ( docpostype_Content === this.CurPos.Type ) else //if (docpostype_Content === nDocPosType)
{ {
LogicDocument = this; LogicDocument = this;
} }
if (null !== DrawingObjects) if (null !== DrawingObjects)
{ {
if (true === DrawingObjects.isSelectedText()) if (true === DrawingObjects.isSelectedText())
LogicDocument = DrawingObjects.getTargetDocContent(); LogicDocument = DrawingObjects.getTargetDocContent();
else else
bCanCopyCut = true; bCanCopyCut = true;
} }
if (null !== LogicDocument) if (null !== LogicDocument)
{ {
if (true === LogicDocument.Is_SelectionUse() && true !== LogicDocument.Selection_IsEmpty(true)) if (true === LogicDocument.Is_SelectionUse() && true !== LogicDocument.Selection_IsEmpty(true))
{ {
if (selectionflag_Numbering === LogicDocument.Selection.Flag) if (selectionflag_Numbering === LogicDocument.Selection.Flag)
bCanCopyCut = false; bCanCopyCut = false;
else if (LogicDocument.Selection.StartPos !== LogicDocument.Selection.EndPos || type_Paragraph === LogicDocument.Content[LogicDocument.Selection.StartPos].Get_Type()) else if (LogicDocument.Selection.StartPos !== LogicDocument.Selection.EndPos || type_Paragraph === LogicDocument.Content[LogicDocument.Selection.StartPos].Get_Type())
bCanCopyCut = true; bCanCopyCut = true;
else else
bCanCopyCut = LogicDocument.Content[LogicDocument.Selection.StartPos].Can_CopyCut(); bCanCopyCut = LogicDocument.Content[LogicDocument.Selection.StartPos].Can_CopyCut();
} }
} }
return bCanCopyCut; return bCanCopyCut;
}; };
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции для работы с номерами страниц // Функции для работы с номерами страниц
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
CDocument.prototype.Get_StartPage_Absolute = function() CDocument.prototype.Get_StartPage_Absolute = function()
{ {
return 0; return 0;
}; };
CDocument.prototype.Get_StartPage_Relative = function() CDocument.prototype.Get_StartPage_Relative = function()
{ {
return 0; return 0;
}; };
CDocument.prototype.Get_AbsolutePage = function(CurPage) CDocument.prototype.Get_AbsolutePage = function(CurPage)
{ {
return CurPage; return CurPage;
}; };
CDocument.prototype.Set_CurPage = function(PageNum) CDocument.prototype.Set_CurPage = function(PageNum)
{ {
this.CurPage = Math.min(this.Pages.length - 1, Math.max(0, PageNum)); this.CurPage = Math.min(this.Pages.length - 1, Math.max(0, PageNum));
}; };
CDocument.prototype.Get_CurPage = function() CDocument.prototype.Get_CurPage = function()
{ {
// Работаем с колонтитулом // Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type) if (docpostype_HdrFtr === this.Get_DocPosType())
return this.HdrFtr.Get_CurPage(); return this.HdrFtr.Get_CurPage();
return this.CurPage; return this.CurPage;
}; };
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Undo/Redo функции // Undo/Redo функции
...@@ -15772,6 +15573,167 @@ CDocument.prototype.controller_CanSplitTableCells = function() ...@@ -15772,6 +15573,167 @@ CDocument.prototype.controller_CanSplitTableCells = function()
return false; 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) CDocument.prototype.controller_AddToParagraph = function(ParaItem, bRecalculate)
{ {
......
...@@ -626,6 +626,18 @@ CDocumentControllerBase.prototype.CanMergeTableCells = function(){return false;} ...@@ -626,6 +626,18 @@ CDocumentControllerBase.prototype.CanMergeTableCells = function(){return false;}
* @returns {boolean} * @returns {boolean}
*/ */
CDocumentControllerBase.prototype.CanSplitTableCells = function(){return false;}; CDocumentControllerBase.prototype.CanSplitTableCells = function(){return false;};
/**
* Обновляем состояние интерфейса.
*/
CDocumentControllerBase.prototype.UpdateInterfaceState = function(){};
/**
* Обновляем состояние линеек.
*/
CDocumentControllerBase.prototype.UpdateRulersState = function(){};
/**
* Обновляем состояние селекта и курсора.
*/
CDocumentControllerBase.prototype.UpdateSelectionState = function(){};
/** /**
* Добавляем элемент в параграф. * Добавляем элемент в параграф.
* @param oItem * @param oItem
......
...@@ -372,6 +372,34 @@ CDrawingsController.prototype.CanSplitTableCells = function() ...@@ -372,6 +372,34 @@ CDrawingsController.prototype.CanSplitTableCells = function()
{ {
return this.DrawingObjects.tableCheckSplit(); 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) CDrawingsController.prototype.AddToParagraph = function(oItem, bRecalculate)
{ {
......
...@@ -987,6 +987,18 @@ CFootnotesController.prototype.CanSplitTableCells = function() ...@@ -987,6 +987,18 @@ CFootnotesController.prototype.CanSplitTableCells = function()
// TODO: Реализовать // TODO: Реализовать
return false; return false;
}; };
CFootnotesController.prototype.UpdateInterfaceState = function()
{
// TODO: Реализовать
};
CFootnotesController.prototype.UpdateRulersState = function()
{
// TODO: Реализовать
};
CFootnotesController.prototype.UpdateSelectionState = function()
{
// TODO: Реализовать
};
CFootnotesController.prototype.AddToParagraph = function(oItem, bRecalculate) CFootnotesController.prototype.AddToParagraph = function(oItem, bRecalculate)
{ {
......
...@@ -321,6 +321,21 @@ CHdrFtrController.prototype.CanSplitTableCells = function() ...@@ -321,6 +321,21 @@ CHdrFtrController.prototype.CanSplitTableCells = function()
{ {
return this.HdrFtr.Table_CheckSplit(); 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() ...@@ -297,7 +297,18 @@ CLogicDocumentController.prototype.CanSplitTableCells = function()
{ {
return this.LogicDocument.controller_CanSplitTableCells(); 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) 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