Commit c50ad0a2 authored by Ilya Kirillov's avatar Ilya Kirillov

Рефакторинг функций, работающих с гиперссылками.

parent 2328b023
...@@ -8116,515 +8116,336 @@ CDocument.prototype.Get_CurPage = function() ...@@ -8116,515 +8116,336 @@ CDocument.prototype.Get_CurPage = function()
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Undo/Redo функции // Undo/Redo функции
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
CDocument.prototype.Create_NewHistoryPoint = function(Description) CDocument.prototype.Create_NewHistoryPoint = function(Description)
{ {
this.History.Create_NewPoint(Description); this.History.Create_NewPoint(Description);
}; };
CDocument.prototype.Document_Undo = function(Options) CDocument.prototype.Document_Undo = function(Options)
{ {
if (true === AscCommon.CollaborativeEditing.Get_GlobalLock()) if (true === AscCommon.CollaborativeEditing.Get_GlobalLock())
return; return;
this.DrawingDocument.EndTrackTable(null, true); this.DrawingDocument.EndTrackTable(null, true);
this.DrawingObjects.TurnOffCheckChartSelection(); this.DrawingObjects.TurnOffCheckChartSelection();
this.History.Undo(Options); this.History.Undo(Options);
this.DrawingObjects.TurnOnCheckChartSelection(); this.DrawingObjects.TurnOnCheckChartSelection();
this.Recalculate(false, false, this.History.RecalculateData); this.Recalculate(false, false, this.History.RecalculateData);
this.Document_UpdateSelectionState(); this.Document_UpdateSelectionState();
this.Document_UpdateInterfaceState(); this.Document_UpdateInterfaceState();
this.Document_UpdateRulersState(); this.Document_UpdateRulersState();
}; };
CDocument.prototype.Document_Redo = function() CDocument.prototype.Document_Redo = function()
{ {
if (true === AscCommon.CollaborativeEditing.Get_GlobalLock()) if (true === AscCommon.CollaborativeEditing.Get_GlobalLock())
return; return;
this.DrawingDocument.EndTrackTable(null, true); this.DrawingDocument.EndTrackTable(null, true);
this.DrawingObjects.TurnOffCheckChartSelection(); this.DrawingObjects.TurnOffCheckChartSelection();
this.History.Redo(); this.History.Redo();
this.DrawingObjects.TurnOnCheckChartSelection(); this.DrawingObjects.TurnOnCheckChartSelection();
this.Recalculate(false, false, this.History.RecalculateData); this.Recalculate(false, false, this.History.RecalculateData);
this.Document_UpdateSelectionState(); this.Document_UpdateSelectionState();
this.Document_UpdateInterfaceState(); this.Document_UpdateInterfaceState();
this.Document_UpdateRulersState(); this.Document_UpdateRulersState();
}; };
CDocument.prototype.Get_SelectionState = function() CDocument.prototype.Get_SelectionState = function()
{ {
var DocState = {}; var DocState = {};
DocState.CurPos = DocState.CurPos =
{ {
X : this.CurPos.X, X : this.CurPos.X,
Y : this.CurPos.Y, Y : this.CurPos.Y,
ContentPos : this.CurPos.ContentPos, ContentPos : this.CurPos.ContentPos,
RealX : this.CurPos.RealX, RealX : this.CurPos.RealX,
RealY : this.CurPos.RealY, RealY : this.CurPos.RealY,
Type : this.CurPos.Type Type : this.CurPos.Type
}; };
DocState.Selection = DocState.Selection =
{ {
Start : this.Selection.Start,
Use : this.Selection.Use,
StartPos : this.Selection.StartPos,
EndPos : this.Selection.EndPos,
Flag : this.Selection.Flag,
Data : this.Selection.Data
};
DocState.CurPage = this.CurPage;
DocState.CurComment = this.Comments.Get_CurrentId();
var State = null;
if (true === editor.isStartAddShape && docpostype_DrawingObjects === this.CurPos.Type)
{
DocState.CurPos.Type = docpostype_Content;
DocState.Selection.Start = false;
DocState.Selection.Use = false;
this.Content[DocState.CurPos.ContentPos].Selection_Remove(); Start : this.Selection.Start,
State = this.Content[this.CurPos.ContentPos].Get_SelectionState(); Use : this.Selection.Use,
} StartPos : this.Selection.StartPos,
else EndPos : this.Selection.EndPos,
{ Flag : this.Selection.Flag,
// Работаем с колонтитулом Data : this.Selection.Data
if (docpostype_HdrFtr === this.CurPos.Type) };
State = this.HdrFtr.Get_SelectionState();
else if (docpostype_DrawingObjects == this.CurPos.Type)
State = this.DrawingObjects.getSelectionState();
else //if ( docpostype_Content === this.CurPos.Type )
{
if (true === this.Selection.Use)
{
// Выделение нумерации
if (selectionflag_Numbering == this.Selection.Flag)
State = [];
else
{
var StartPos = this.Selection.StartPos;
var EndPos = this.Selection.EndPos;
if (StartPos > EndPos)
{
var Temp = StartPos;
StartPos = EndPos;
EndPos = Temp;
}
State = []; DocState.CurPage = this.CurPage;
DocState.CurComment = this.Comments.Get_CurrentId();
var TempState = []; var State = null;
for (var Index = StartPos; Index <= EndPos; Index++) if (true === editor.isStartAddShape && docpostype_DrawingObjects === this.Get_DocPosType())
{ {
TempState.push(this.Content[Index].Get_SelectionState()); DocState.CurPos.Type = docpostype_Content;
} DocState.Selection.Start = false;
DocState.Selection.Use = false;
State.push(TempState); this.Content[DocState.CurPos.ContentPos].Selection_Remove();
} State = this.Content[this.CurPos.ContentPos].Get_SelectionState();
} }
else else
State = this.Content[this.CurPos.ContentPos].Get_SelectionState(); {
} State = this.Controller.GetSelectionState();
} }
State.push(DocState); State.push(DocState);
return State; return State;
}; };
CDocument.prototype.Set_SelectionState = function(State) CDocument.prototype.Set_SelectionState = function(State)
{ {
if (docpostype_DrawingObjects === this.CurPos.Type) if (docpostype_DrawingObjects === this.Get_DocPosType())
this.DrawingObjects.resetSelection(); this.DrawingObjects.resetSelection();
if (State.length <= 0) if (State.length <= 0)
return; return;
var DocState = State[State.length - 1]; var DocState = State[State.length - 1];
this.CurPos.X = DocState.CurPos.X; this.CurPos.X = DocState.CurPos.X;
this.CurPos.Y = DocState.CurPos.Y; this.CurPos.Y = DocState.CurPos.Y;
this.CurPos.ContentPos = DocState.CurPos.ContentPos; this.CurPos.ContentPos = DocState.CurPos.ContentPos;
this.CurPos.RealX = DocState.CurPos.RealX; this.CurPos.RealX = DocState.CurPos.RealX;
this.CurPos.RealY = DocState.CurPos.RealY; this.CurPos.RealY = DocState.CurPos.RealY;
this.Set_DocPosType(DocState.CurPos.Type); this.Set_DocPosType(DocState.CurPos.Type);
this.Selection.Start = DocState.Selection.Start; this.Selection.Start = DocState.Selection.Start;
this.Selection.Use = DocState.Selection.Use; this.Selection.Use = DocState.Selection.Use;
this.Selection.StartPos = DocState.Selection.StartPos; this.Selection.StartPos = DocState.Selection.StartPos;
this.Selection.EndPos = DocState.Selection.EndPos; this.Selection.EndPos = DocState.Selection.EndPos;
this.Selection.Flag = DocState.Selection.Flag; this.Selection.Flag = DocState.Selection.Flag;
this.Selection.Data = DocState.Selection.Data; this.Selection.Data = DocState.Selection.Data;
this.Selection.DragDrop.Flag = 0; this.Selection.DragDrop.Flag = 0;
this.Selection.DragDrop.Data = null; this.Selection.DragDrop.Data = null;
this.CurPage = DocState.CurPage; this.CurPage = DocState.CurPage;
this.Comments.Set_Current(DocState.CurComment); this.Comments.Set_Current(DocState.CurComment);
var StateIndex = State.length - 2; var StateIndex = State.length - 2;
// Работаем с колонтитулом this.Controller.SetSelectionState(State, State.length - 2);
if (docpostype_HdrFtr === this.CurPos.Type)
this.HdrFtr.Set_SelectionState(State, StateIndex);
else if (docpostype_DrawingObjects === this.CurPos.Type)
this.DrawingObjects.setSelectionState(State, StateIndex);
else //if ( docpostype_Content === this.CurPos.Type )
{
if (true === this.Selection.Use)
{
// Выделение нумерации
if (selectionflag_Numbering == this.Selection.Flag)
{
if (type_Paragraph === this.Content[this.Selection.StartPos].Get_Type())
{
var NumPr = this.Content[this.Selection.StartPos].Numbering_Get();
if (undefined !== NumPr)
this.Document_SelectNumbering(NumPr, this.Selection.StartPos);
else
this.Selection_Remove();
}
else
this.Selection_Remove();
}
else
{
var StartPos = this.Selection.StartPos;
var EndPos = this.Selection.EndPos;
if (StartPos > EndPos)
{
var Temp = StartPos;
StartPos = EndPos;
EndPos = Temp;
}
var CurState = State[StateIndex];
for (var Index = StartPos; Index <= EndPos; Index++)
{
this.Content[Index].Set_SelectionState(CurState[Index - StartPos], CurState[Index - StartPos].length - 1);
}
}
}
else
this.Content[this.CurPos.ContentPos].Set_SelectionState(State, StateIndex);
}
}; };
CDocument.prototype.Undo = function(Data) CDocument.prototype.Undo = function(Data)
{ {
var Type = Data.Type; var Type = Data.Type;
switch (Type) switch (Type)
{ {
case AscDFH.historyitem_Document_AddItem: case AscDFH.historyitem_Document_AddItem:
{ {
var Pos = Data.Pos; var Pos = Data.Pos;
var Elements = this.Content.splice(Pos, 1); var Elements = this.Content.splice(Pos, 1);
this.private_RecalculateNumbering(Elements); this.private_RecalculateNumbering(Elements);
// Обновим информацию о секциях // Обновим информацию о секциях
this.SectionsInfo.Update_OnRemove(Pos, 1); this.SectionsInfo.Update_OnRemove(Pos, 1);
break; break;
} }
case AscDFH.historyitem_Document_RemoveItem: case AscDFH.historyitem_Document_RemoveItem:
{ {
var Pos = Data.Pos; var Pos = Data.Pos;
var Array_start = this.Content.slice(0, Pos); var Array_start = this.Content.slice(0, Pos);
var Array_end = this.Content.slice(Pos); var Array_end = this.Content.slice(Pos);
this.private_RecalculateNumbering(Data.Items); this.private_RecalculateNumbering(Data.Items);
this.Content = Array_start.concat(Data.Items, Array_end); this.Content = Array_start.concat(Data.Items, Array_end);
// Обновим информацию о секциях // Обновим информацию о секциях
this.SectionsInfo.Update_OnAdd(Data.Pos, Data.Items); this.SectionsInfo.Update_OnAdd(Data.Pos, Data.Items);
break; break;
} }
case AscDFH.historyitem_Document_DefaultTab: case AscDFH.historyitem_Document_DefaultTab:
{ {
Default_Tab_Stop = Data.Old; Default_Tab_Stop = Data.Old;
break; break;
} }
case AscDFH.historyitem_Document_EvenAndOddHeaders: case AscDFH.historyitem_Document_EvenAndOddHeaders:
{ {
EvenAndOddHeaders = Data.Old; EvenAndOddHeaders = Data.Old;
break; break;
} }
case AscDFH.historyitem_Document_DefaultLanguage: case AscDFH.historyitem_Document_DefaultLanguage:
{ {
this.Styles.Default.TextPr.Lang.Val = Data.Old; this.Styles.Default.TextPr.Lang.Val = Data.Old;
this.Restart_CheckSpelling(); this.Restart_CheckSpelling();
break; break;
} }
case AscDFH.historyitem_Document_MathSettings: case AscDFH.historyitem_Document_MathSettings:
{ {
this.Settings.MathSettings.SetPr(Data.OldPr); this.Settings.MathSettings.SetPr(Data.OldPr);
break; break;
} }
} }
}; };
CDocument.prototype.Redo = function(Data) CDocument.prototype.Redo = function(Data)
{ {
var Type = Data.Type; var Type = Data.Type;
switch (Type) switch (Type)
{ {
case AscDFH.historyitem_Document_AddItem: case AscDFH.historyitem_Document_AddItem:
{ {
var Pos = Data.Pos; var Pos = Data.Pos;
this.Content.splice(Pos, 0, Data.Item); this.Content.splice(Pos, 0, Data.Item);
this.private_RecalculateNumbering([Data.Item]); this.private_RecalculateNumbering([Data.Item]);
// Обновим информацию о секциях // Обновим информацию о секциях
this.SectionsInfo.Update_OnAdd(Data.Pos, [Data.Item]); this.SectionsInfo.Update_OnAdd(Data.Pos, [Data.Item]);
break; break;
} }
case AscDFH.historyitem_Document_RemoveItem: case AscDFH.historyitem_Document_RemoveItem:
{ {
var Elements = this.Content.splice(Data.Pos, Data.Items.length); var Elements = this.Content.splice(Data.Pos, Data.Items.length);
this.private_RecalculateNumbering(Elements); this.private_RecalculateNumbering(Elements);
// Обновим информацию о секциях // Обновим информацию о секциях
this.SectionsInfo.Update_OnRemove(Data.Pos, Data.Items.length); this.SectionsInfo.Update_OnRemove(Data.Pos, Data.Items.length);
break; break;
} }
case AscDFH.historyitem_Document_DefaultTab: case AscDFH.historyitem_Document_DefaultTab:
{ {
Default_Tab_Stop = Data.New; Default_Tab_Stop = Data.New;
break; break;
} }
case AscDFH.historyitem_Document_EvenAndOddHeaders: case AscDFH.historyitem_Document_EvenAndOddHeaders:
{ {
EvenAndOddHeaders = Data.New; EvenAndOddHeaders = Data.New;
break; break;
} }
case AscDFH.historyitem_Document_DefaultLanguage: case AscDFH.historyitem_Document_DefaultLanguage:
{ {
this.Styles.Default.TextPr.Lang.Val = Data.New; this.Styles.Default.TextPr.Lang.Val = Data.New;
this.Restart_CheckSpelling(); this.Restart_CheckSpelling();
break; break;
} }
case AscDFH.historyitem_Document_MathSettings: case AscDFH.historyitem_Document_MathSettings:
{ {
this.Settings.MathSettings.SetPr(Data.NewPr); this.Settings.MathSettings.SetPr(Data.NewPr);
break; break;
} }
} }
}; };
CDocument.prototype.Get_ParentObject_or_DocumentPos = function(Index) CDocument.prototype.Get_ParentObject_or_DocumentPos = function(Index)
{ {
return {Type : AscDFH.historyitem_recalctype_Inline, Data : Index}; return {Type : AscDFH.historyitem_recalctype_Inline, Data : Index};
}; };
CDocument.prototype.Refresh_RecalcData = function(Data) CDocument.prototype.Refresh_RecalcData = function(Data)
{ {
var ChangePos = -1; var ChangePos = -1;
var bNeedRecalcHdrFtr = false; var bNeedRecalcHdrFtr = false;
var Type = Data.Type; var Type = Data.Type;
switch (Type) switch (Type)
{ {
case AscDFH.historyitem_Document_AddItem: case AscDFH.historyitem_Document_AddItem:
case AscDFH.historyitem_Document_RemoveItem: case AscDFH.historyitem_Document_RemoveItem:
{ {
ChangePos = Data.Pos; ChangePos = Data.Pos;
break; break;
} }
case AscDFH.historyitem_Document_DefaultTab: case AscDFH.historyitem_Document_DefaultTab:
case AscDFH.historyitem_Document_EvenAndOddHeaders: case AscDFH.historyitem_Document_EvenAndOddHeaders:
case AscDFH.historyitem_Document_MathSettings: case AscDFH.historyitem_Document_MathSettings:
{ {
ChangePos = 0; ChangePos = 0;
break; break;
} }
} }
if (-1 != ChangePos) if (-1 != ChangePos)
this.History.RecalcData_Add({ {
Type : AscDFH.historyitem_recalctype_Inline, this.History.RecalcData_Add({
Data : {Pos : ChangePos, PageNum : 0} Type : AscDFH.historyitem_recalctype_Inline,
}); Data : {Pos : ChangePos, PageNum : 0}
});
}
}; };
CDocument.prototype.Refresh_RecalcData2 = function(Index, Page_rel) CDocument.prototype.Refresh_RecalcData2 = function(Index, Page_rel)
{ {
this.History.RecalcData_Add({ this.History.RecalcData_Add({
Type : AscDFH.historyitem_recalctype_Inline, Type : AscDFH.historyitem_recalctype_Inline,
Data : {Pos : Index, PageNum : Page_rel} Data : {Pos : Index, PageNum : Page_rel}
}); });
}; };
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции для работы с гиперссылками // Функции для работы с гиперссылками
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
CDocument.prototype.Hyperlink_Add = function(HyperProps) CDocument.prototype.Hyperlink_Add = function(HyperProps)
{ {
// Проверку, возможно ли добавить гиперссылку, должны были вызвать до этой функции // Проверку, возможно ли добавить гиперссылку, должны были вызвать до этой функции
if (null != HyperProps.Text && "" != HyperProps.Text && true === this.Is_SelectionUse()) if (null != HyperProps.Text && "" != HyperProps.Text && true === this.Is_SelectionUse())
{ {
// Корректировка в данном случае пройдет при добавлении гиперссылки. // Корректировка в данном случае пройдет при добавлении гиперссылки.
var SelectionInfo = this.Get_SelectedElementsInfo(); var SelectionInfo = this.Get_SelectedElementsInfo();
var Para = SelectionInfo.Get_Paragraph(); var Para = SelectionInfo.Get_Paragraph();
if (null !== Para) if (null !== Para)
HyperProps.TextPr = Para.Get_TextPr(Para.Get_ParaContentPos(true, true)); HyperProps.TextPr = Para.Get_TextPr(Para.Get_ParaContentPos(true, true));
this.Remove(1, false, false, true);
this.Selection_Remove();
}
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
{
this.HdrFtr.Hyperlink_Add(HyperProps);
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
this.DrawingObjects.hyperlinkAdd(HyperProps);
}
// Либо у нас нет выделения, либо выделение внутри одного элемента
else if (docpostype_Content == this.CurPos.Type && ( ( true === this.Selection.Use && this.Selection.StartPos == this.Selection.EndPos ) || ( false == this.Selection.Use ) ))
{
var Pos = ( true == this.Selection.Use ? this.Selection.StartPos : this.CurPos.ContentPos );
this.Content[Pos].Hyperlink_Add(HyperProps);
this.ContentLastChangePos = Pos; this.Remove(1, false, false, true);
this.Recalculate(true); this.Selection_Remove();
} }
this.Document_UpdateInterfaceState(); this.Controller.AddHyperlink(HyperProps);
this.Document_UpdateSelectionState(); this.Recalculate();
this.Document_UpdateInterfaceState();
this.Document_UpdateSelectionState();
}; };
CDocument.prototype.Hyperlink_Modify = function(HyperProps) CDocument.prototype.Hyperlink_Modify = function(HyperProps)
{ {
// Работаем с колонтитулом this.Controller.ModifyHyperlink(HyperProps);
if (docpostype_HdrFtr === this.CurPos.Type) this.Recalculate();
{
this.HdrFtr.Hyperlink_Modify(HyperProps);
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
this.DrawingObjects.hyperlinkModify(HyperProps);
}
// Либо у нас нет выделения, либо выделение внутри одного элемента
else if (docpostype_Content == this.CurPos.Type && ( ( true === this.Selection.Use && this.Selection.StartPos == this.Selection.EndPos ) || ( false == this.Selection.Use ) ))
{
var Pos = ( true == this.Selection.Use ? this.Selection.StartPos : this.CurPos.ContentPos );
if (true === this.Content[Pos].Hyperlink_Modify(HyperProps))
{
this.ContentLastChangePos = Pos;
this.Recalculate(true);
}
}
this.Document_UpdateSelectionState(); this.Document_UpdateSelectionState();
this.Document_UpdateInterfaceState(); this.Document_UpdateInterfaceState();
}; };
CDocument.prototype.Hyperlink_Remove = function() CDocument.prototype.Hyperlink_Remove = function()
{ {
// Работаем с колонтитулом this.Controller.RemoveHyperlink();
if (docpostype_HdrFtr === this.CurPos.Type) this.Recalculate();
{ this.Document_UpdateInterfaceState();
this.HdrFtr.Hyperlink_Remove();
}
else if (docpostype_DrawingObjects === this.CurPos.Type)
{
this.DrawingObjects.hyperlinkRemove();
}
// Либо у нас нет выделения, либо выделение внутри одного элемента
else if (docpostype_Content == this.CurPos.Type && ( ( true === this.Selection.Use && this.Selection.StartPos == this.Selection.EndPos ) || ( false == this.Selection.Use ) ))
{
var Pos = ( true == this.Selection.Use ? this.Selection.StartPos : this.CurPos.ContentPos );
this.Content[Pos].Hyperlink_Remove();
}
this.Recalculate();
this.Document_UpdateInterfaceState();
}; };
CDocument.prototype.Hyperlink_CanAdd = function(bCheckInHyperlink) CDocument.prototype.Hyperlink_CanAdd = function(bCheckInHyperlink)
{ {
// Проверим можно ли добавлять гиперссылку return this.Controller.CanAddHyperlink(bCheckInHyperlink);
if (docpostype_HdrFtr === this.CurPos.Type)
return this.HdrFtr.Hyperlink_CanAdd(bCheckInHyperlink);
else if (docpostype_DrawingObjects === this.CurPos.Type)
return this.DrawingObjects.hyperlinkCanAdd(bCheckInHyperlink);
else //if ( docpostype_Content === this.CurPos.Type )
{
if (true === this.Selection.Use)
{
switch (this.Selection.Flag)
{
case selectionflag_Numbering:
return false;
case selectionflag_Common:
{
if (this.Selection.StartPos != this.Selection.EndPos)
return false;
return this.Content[this.Selection.StartPos].Hyperlink_CanAdd(bCheckInHyperlink);
}
}
}
else
return this.Content[this.CurPos.ContentPos].Hyperlink_CanAdd(bCheckInHyperlink);
}
return false;
}; };
/** /**
* Проверяем, находимся ли мы в гиперссылке сейчас. * Проверяем, находимся ли мы в гиперссылке сейчас.
* @param bCheckEnd * @param bCheckEnd
* @returns {*} * @returns {*}
*/ */
CDocument.prototype.Hyperlink_Check = function(bCheckEnd) CDocument.prototype.Hyperlink_Check = function(bCheckEnd)
{ {
if ("undefined" === typeof(bCheckEnd)) if (undefined === bCheckEnd)
bCheckEnd = true; bCheckEnd = true;
// Работаем с колонтитулом
if (docpostype_HdrFtr === this.CurPos.Type)
return this.HdrFtr.Hyperlink_Check(bCheckEnd);
else if (docpostype_DrawingObjects === this.CurPos.Type)
return this.DrawingObjects.hyperlinkCheck(bCheckEnd);
else //if ( docpostype_Content == this.CurPos.Type )
{
if (true === this.Selection.Use)
{
switch (this.Selection.Flag)
{
case selectionflag_Numbering:
return null;
case selectionflag_Common:
{
if (this.Selection.StartPos != this.Selection.EndPos)
return null;
return this.Content[this.Selection.StartPos].Hyperlink_Check(bCheckEnd);
}
}
}
else
return this.Content[this.CurPos.ContentPos].Hyperlink_Check(bCheckEnd);
}
return null; return this.Controller.IsCursorInHyperlink(bCheckEnd);
}; };
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции для работы с совместным редактирования // Функции для работы с совместным редактирования
...@@ -15734,6 +15555,142 @@ CDocument.prototype.controller_UpdateSelectionState = function() ...@@ -15734,6 +15555,142 @@ CDocument.prototype.controller_UpdateSelectionState = function()
this.DrawingDocument.TargetShow(); this.DrawingDocument.TargetShow();
} }
}; };
CDocument.prototype.controller_GetSelectionState = function()
{
var State;
if (true === this.Selection.Use)
{
// Выделение нумерации
if (selectionflag_Numbering == this.Selection.Flag)
State = [];
else
{
var StartPos = this.Selection.StartPos;
var EndPos = this.Selection.EndPos;
if (StartPos > EndPos)
{
var Temp = StartPos;
StartPos = EndPos;
EndPos = Temp;
}
State = [];
var TempState = [];
for (var Index = StartPos; Index <= EndPos; Index++)
{
TempState.push(this.Content[Index].Get_SelectionState());
}
State.push(TempState);
}
}
else
State = this.Content[this.CurPos.ContentPos].Get_SelectionState();
return State;
};
CDocument.prototype.controller_SetSelectionState = function(State, StateIndex)
{
if (true === this.Selection.Use)
{
// Выделение нумерации
if (selectionflag_Numbering == this.Selection.Flag)
{
if (type_Paragraph === this.Content[this.Selection.StartPos].Get_Type())
{
var NumPr = this.Content[this.Selection.StartPos].Numbering_Get();
if (undefined !== NumPr)
this.Document_SelectNumbering(NumPr, this.Selection.StartPos);
else
this.Selection_Remove();
}
else
this.Selection_Remove();
}
else
{
var StartPos = this.Selection.StartPos;
var EndPos = this.Selection.EndPos;
if (StartPos > EndPos)
{
var Temp = StartPos;
StartPos = EndPos;
EndPos = Temp;
}
var CurState = State[StateIndex];
for (var Index = StartPos; Index <= EndPos; Index++)
{
this.Content[Index].Set_SelectionState(CurState[Index - StartPos], CurState[Index - StartPos].length - 1);
}
}
}
else
this.Content[this.CurPos.ContentPos].Set_SelectionState(State, StateIndex);
};
CDocument.prototype.controller_AddHyperlink = function(Props)
{
if (false == this.Selection.Use || this.Selection.StartPos == this.Selection.EndPos)
{
var Pos = ( true == this.Selection.Use ? this.Selection.StartPos : this.CurPos.ContentPos );
this.Content[Pos].Hyperlink_Add(Props);
}
};
CDocument.prototype.controller_ModifyHyperlink = function(Props)
{
if (false == this.Selection.Use || this.Selection.StartPos == this.Selection.EndPos)
{
var Pos = ( true == this.Selection.Use ? this.Selection.StartPos : this.CurPos.ContentPos );
this.Content[Pos].Hyperlink_Modify(Props);
}
};
CDocument.prototype.controller_RemoveHyperlink = function()
{
if (false == this.Selection.Use || this.Selection.StartPos == this.Selection.EndPos)
{
var Pos = ( true == this.Selection.Use ? this.Selection.StartPos : this.CurPos.ContentPos );
this.Content[Pos].Hyperlink_Remove();
}
};
CDocument.prototype.controller_CanAddHyperlink = function(bCheckInHyperlink)
{
if (true === this.Selection.Use)
{
if (selectionflag_Common === this.Selection.Flag)
{
if (this.Selection.StartPos != this.Selection.EndPos)
return false;
return this.Content[this.Selection.StartPos].Hyperlink_CanAdd(bCheckInHyperlink);
}
}
else
{
return this.Content[this.CurPos.ContentPos].Hyperlink_CanAdd(bCheckInHyperlink);
}
return false;
};
CDocument.prototype.controller_IsCursorInHyperlink = function(bCheckEnd)
{
if (true === this.Selection.Use)
{
if (selectionflag_Common === this.Selection.Flag)
{
if (this.Selection.StartPos != this.Selection.EndPos)
return null;
return this.Content[this.Selection.StartPos].Hyperlink_Check(bCheckEnd);
}
}
else
{
return this.Content[this.CurPos.ContentPos].Hyperlink_Check(bCheckEnd);
}
return null;
};
CDocument.prototype.controller_AddToParagraph = function(ParaItem, bRecalculate) CDocument.prototype.controller_AddToParagraph = function(ParaItem, bRecalculate)
{ {
......
...@@ -638,6 +638,41 @@ CDocumentControllerBase.prototype.UpdateRulersState = function(){}; ...@@ -638,6 +638,41 @@ CDocumentControllerBase.prototype.UpdateRulersState = function(){};
* Обновляем состояние селекта и курсора. * Обновляем состояние селекта и курсора.
*/ */
CDocumentControllerBase.prototype.UpdateSelectionState = function(){}; CDocumentControllerBase.prototype.UpdateSelectionState = function(){};
/**
* Получаем текущее состоянии селекта и курсора.
*/
CDocumentControllerBase.prototype.GetSelectionState = function(){return [];};
/**
* Выставляем текущее состояние селекта и курсора.
* @param State
* @param StateIndex
*/
CDocumentControllerBase.prototype.SetSelectionState = function(State, StateIndex){};
/**
* Добавляем гиперссылку.
* @param Props
*/
CDocumentControllerBase.prototype.AddHyperlink = function(Props){};
/**
* Изменяем гиперссылку.
* @param Props
*/
CDocumentControllerBase.prototype.ModifyHyperlink = function(Props){};
/**
* Удаляем гиперссылку.
*/
CDocumentControllerBase.prototype.RemoveHyperlink = function(){};
/**
* Проверяем можно ли добавить гиперссылку.
* @returns {boolean}
*/
CDocumentControllerBase.prototype.CanAddHyperlink = function(bCheckInHyperlink){return false;};
/**
* Проверяем находится ли курсор сейчас в гиперссылке.
* @returns {?ParaHyperlink}
*/
CDocumentControllerBase.prototype.IsCursorInHyperlink = function(bCheckEnd){return false;};
/** /**
* Добавляем элемент в параграф. * Добавляем элемент в параграф.
* @param oItem * @param oItem
......
...@@ -400,6 +400,35 @@ CDrawingsController.prototype.UpdateSelectionState = function() ...@@ -400,6 +400,35 @@ CDrawingsController.prototype.UpdateSelectionState = function()
this.DrawingObjects.documentUpdateSelectionState(); this.DrawingObjects.documentUpdateSelectionState();
this.LogicDocument.Document_UpdateTracks(); this.LogicDocument.Document_UpdateTracks();
}; };
CDrawingsController.prototype.GetSelectionState = function()
{
return this.DrawingObjects.getSelectionState();
};
CDrawingsController.prototype.SetSelectionState = function(State, StateIndex)
{
this.DrawingObjects.setSelectionState(State, StateIndex);
};
CDrawingsController.prototype.AddHyperlink = function(Props)
{
this.DrawingObjects.hyperlinkAdd(Props);
};
CDrawingsController.prototype.ModifyHyperlink = function(Props)
{
this.DrawingObjects.hyperlinkModify(Props);
};
CDrawingsController.prototype.RemoveHyperlink = function()
{
this.DrawingObjects.hyperlinkRemove();
};
CDrawingsController.prototype.CanAddHyperlink = function(bCheckInHyperlink)
{
return this.DrawingObjects.hyperlinkCanAdd(bCheckInHyperlink);
};
CDrawingsController.prototype.IsCursorInHyperlink = function(bCheckEnd)
{
return this.DrawingObjects.hyperlinkCheck(bCheckEnd);
};
CDrawingsController.prototype.AddToParagraph = function(oItem, bRecalculate) CDrawingsController.prototype.AddToParagraph = function(oItem, bRecalculate)
{ {
......
...@@ -999,6 +999,37 @@ CFootnotesController.prototype.UpdateSelectionState = function() ...@@ -999,6 +999,37 @@ CFootnotesController.prototype.UpdateSelectionState = function()
{ {
// TODO: Реализовать // TODO: Реализовать
}; };
CFootnotesController.prototype.GetSelectionState = function()
{
// TODO: Реализовать
return [];
};
CFootnotesController.prototype.SetSelectionState = function(State, StateIndex)
{
// TODO: Реализовать
};
CFootnotesController.prototype.AddHyperlink = function(Props)
{
// TODO: Реализовать
};
CFootnotesController.prototype.ModifyHyperlink = function(Props)
{
// TODO: Реализовать
};
CFootnotesController.prototype.RemoveHyperlink = function()
{
// TODO: Реализовать
};
CFootnotesController.prototype.CanAddHyperlink = function(bCheckInHyperlink)
{
// TODO: Реализовать
return false;
};
CFootnotesController.prototype.IsCursorInHyperlink = function(bCheckEnd)
{
// TODO: Реализовать
return false;
};
CFootnotesController.prototype.AddToParagraph = function(oItem, bRecalculate) CFootnotesController.prototype.AddToParagraph = function(oItem, bRecalculate)
{ {
......
...@@ -336,7 +336,34 @@ CHdrFtrController.prototype.UpdateSelectionState = function() ...@@ -336,7 +336,34 @@ CHdrFtrController.prototype.UpdateSelectionState = function()
this.HdrFtr.Document_UpdateSelectionState(); this.HdrFtr.Document_UpdateSelectionState();
this.LogicDocument.Document_UpdateTracks(); this.LogicDocument.Document_UpdateTracks();
}; };
CHdrFtrController.prototype.GetSelectionState = function()
{
return this.HdrFtr.Get_SelectionState();
};
CHdrFtrController.prototype.SetSelectionState = function(State, StateIndex)
{
this.HdrFtr.Set_SelectionState(State, StateIndex);
};
CHdrFtrController.prototype.AddHyperlink = function(Props)
{
this.HdrFtr.Hyperlink_Add(Props);
};
CHdrFtrController.prototype.ModifyHyperlink = function(Props)
{
this.HdrFtr.Hyperlink_Modify(Props);
};
CHdrFtrController.prototype.RemoveHyperlink = function()
{
this.HdrFtr.Hyperlink_Remove();
};
CHdrFtrController.prototype.CanAddHyperlink = function(bCheckInHyperlink)
{
return this.HdrFtr.Hyperlink_CanAdd(bCheckInHyperlink);
};
CHdrFtrController.prototype.IsCursorInHyperlink = function(bCheckEnd)
{
return this.HdrFtr.Hyperlink_Check(bCheckEnd);
};
......
...@@ -309,6 +309,35 @@ CLogicDocumentController.prototype.UpdateSelectionState = function() ...@@ -309,6 +309,35 @@ CLogicDocumentController.prototype.UpdateSelectionState = function()
{ {
this.LogicDocument.controller_UpdateSelectionState(); this.LogicDocument.controller_UpdateSelectionState();
}; };
CLogicDocumentController.prototype.GetSelectionState = function()
{
return this.LogicDocument.controller_GetSelectionState();
};
CLogicDocumentController.prototype.SetSelectionState = function(State, StateIndex)
{
this.LogicDocument.controller_SetSelectionState(State, StateIndex);
};
CLogicDocumentController.prototype.AddHyperlink = function(Props)
{
this.LogicDocument.controller_AddHyperlink(Props);
};
CLogicDocumentController.prototype.ModifyHyperlink = function(Props)
{
this.LogicDocument.controller_ModifyHyperlink(Props);
};
CLogicDocumentController.prototype.RemoveHyperlink = function()
{
this.LogicDocument.controller_RemoveHyperlink();
};
CLogicDocumentController.prototype.CanAddHyperlink = function(bCheckInHyperlink)
{
return this.LogicDocument.controller_CanAddHyperlink(bCheckInHyperlink);
};
CLogicDocumentController.prototype.IsCursorInHyperlink = function(bCheckEnd)
{
return this.LogicDocument.controller_IsCursorInHyperlink(bCheckEnd);
};
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