Commit c50ad0a2 authored by Ilya Kirillov's avatar Ilya Kirillov

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

parent 2328b023
...@@ -8180,7 +8180,7 @@ CDocument.prototype.Get_SelectionState = function() ...@@ -8180,7 +8180,7 @@ CDocument.prototype.Get_SelectionState = function()
DocState.CurComment = this.Comments.Get_CurrentId(); DocState.CurComment = this.Comments.Get_CurrentId();
var State = null; var State = null;
if (true === editor.isStartAddShape && docpostype_DrawingObjects === this.CurPos.Type) if (true === editor.isStartAddShape && docpostype_DrawingObjects === this.Get_DocPosType())
{ {
DocState.CurPos.Type = docpostype_Content; DocState.CurPos.Type = docpostype_Content;
DocState.Selection.Start = false; DocState.Selection.Start = false;
...@@ -8191,43 +8191,7 @@ CDocument.prototype.Get_SelectionState = function() ...@@ -8191,43 +8191,7 @@ CDocument.prototype.Get_SelectionState = function()
} }
else else
{ {
// Работаем с колонтитулом State = this.Controller.GetSelectionState();
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 = [];
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();
}
} }
State.push(DocState); State.push(DocState);
...@@ -8236,7 +8200,7 @@ CDocument.prototype.Get_SelectionState = function() ...@@ -8236,7 +8200,7 @@ CDocument.prototype.Get_SelectionState = function()
}; };
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)
...@@ -8266,50 +8230,7 @@ CDocument.prototype.Set_SelectionState = function(State) ...@@ -8266,50 +8230,7 @@ CDocument.prototype.Set_SelectionState = function(State)
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)
{ {
...@@ -8460,10 +8381,12 @@ CDocument.prototype.Refresh_RecalcData = function(Data) ...@@ -8460,10 +8381,12 @@ CDocument.prototype.Refresh_RecalcData = function(Data)
} }
if (-1 != ChangePos) if (-1 != ChangePos)
{
this.History.RecalcData_Add({ this.History.RecalcData_Add({
Type : AscDFH.historyitem_recalctype_Inline, Type : AscDFH.historyitem_recalctype_Inline,
Data : {Pos : ChangePos, PageNum : 0} Data : {Pos : ChangePos, PageNum : 0}
}); });
}
}; };
CDocument.prototype.Refresh_RecalcData2 = function(Index, Page_rel) CDocument.prototype.Refresh_RecalcData2 = function(Index, Page_rel)
{ {
...@@ -8490,103 +8413,27 @@ CDocument.prototype.Hyperlink_Add = function(HyperProps) ...@@ -8490,103 +8413,27 @@ CDocument.prototype.Hyperlink_Add = function(HyperProps)
this.Selection_Remove(); this.Selection_Remove();
} }
// Работаем с колонтитулом this.Controller.AddHyperlink(HyperProps);
if (docpostype_HdrFtr === this.CurPos.Type) this.Recalculate();
{
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.Recalculate(true);
}
this.Document_UpdateInterfaceState(); this.Document_UpdateInterfaceState();
this.Document_UpdateSelectionState(); 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.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.Recalculate();
this.Document_UpdateInterfaceState(); 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;
}; };
/** /**
* Проверяем, находимся ли мы в гиперссылке сейчас. * Проверяем, находимся ли мы в гиперссылке сейчас.
...@@ -8595,36 +8442,10 @@ CDocument.prototype.Hyperlink_CanAdd = function(bCheckInHyperlink) ...@@ -8595,36 +8442,10 @@ CDocument.prototype.Hyperlink_CanAdd = function(bCheckInHyperlink)
*/ */
CDocument.prototype.Hyperlink_Check = function(bCheckEnd) CDocument.prototype.Hyperlink_Check = function(bCheckEnd)
{ {
if ("undefined" === typeof(bCheckEnd)) if (undefined === bCheckEnd)
bCheckEnd = true; bCheckEnd = true;
// Работаем с колонтитулом return this.Controller.IsCursorInHyperlink(bCheckEnd);
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;
}; };
//---------------------------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------------------------
// Функции для работы с совместным редактирования // Функции для работы с совместным редактирования
...@@ -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