Commit 976769a1 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented the transition to internal links through a complex field PAGEREF.

parent 239f7231
......@@ -113,6 +113,24 @@ CParagraphBookmark.prototype.GetXY = function()
{
return {X : this.X, Y : this.Y};
};
CParagraphBookmark.prototype.GoToBookmark = function()
{
var oParagraph = this.Paragraph;
if (!oParagraph)
return;
var oLogicDocument = oParagraph.LogicDocument;
if (!oLogicDocument)
return;
var oCurPos = oParagraph.Get_PosByElement(this);
if (!oCurPos)
return;
oLogicDocument.RemoveSelection();
oParagraph.Set_ParaContentPos(oCurPos, false, -1, -1, true); // Корректировать позицию нужно обязательно
oParagraph.Document_SetThisElementCurrent(true);
};
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -5312,12 +5312,18 @@ CDocument.prototype.Selection_SetStart = function(X, Y, MouseEvent)
if (type_Paragraph === Item.GetType() && true === MouseEvent.CtrlKey)
{
var Hyperlink = Item.CheckHyperlink(X, Y, ElementPageIndex);
if (null != Hyperlink)
var oHyperlink = Item.CheckHyperlink(X, Y, ElementPageIndex);
var oPageRefLink = Item.CheckPageRefLink(X, Y, ElementPageIndex);
if (null != oHyperlink)
{
this.Selection.Data = {
Hyperlink : true,
Value : Hyperlink
Hyperlink : oHyperlink
};
}
else if (null !== oPageRefLink)
{
this.Selection.Data = {
PageRef : oPageRefLink
};
}
}
......@@ -5471,16 +5477,26 @@ CDocument.prototype.Selection_SetEnd = function(X, Y, MouseEvent)
{
this.Selection.Use = false;
if (null != this.Selection.Data && true === this.Selection.Data.Hyperlink)
if (null != this.Selection.Data && this.Selection.Data.Hyperlink)
{
editor.sync_HyperlinkClickCallback(this.Selection.Data.Value.Get_Value());
this.Selection.Data.Value.Set_Visited(true);
editor.sync_HyperlinkClickCallback(this.Selection.Data.Hyperlink.Get_Value());
this.Selection.Data.Hyperlink.Set_Visited(true);
for (var PageIdx = Item.Get_StartPage_Absolute(); PageIdx < Item.Get_StartPage_Absolute() + Item.Pages.length; PageIdx++)
this.DrawingDocument.OnRecalculatePage(PageIdx, this.Pages[PageIdx]);
this.DrawingDocument.OnEndRecalculate(false, true);
}
else if (null !== this.Selection.Data && this.Selection.Data.PageRef)
{
var oInstruction = this.Selection.Data.PageRef.GetInstruction();
if (oInstruction && fieldtype_PAGEREF === oInstruction.GetType())
{
var oBookmark = this.BookmarksManager.GetBookmarkByName(oInstruction.GetBookmarkName());
if (oBookmark)
oBookmark[0].GoToBookmark();
}
}
}
else
{
......@@ -15769,6 +15785,14 @@ CDocument.prototype.AddField = function(nType, oPr)
oRun.Add_ToContent(++nIndex, new ParaInstrText("R"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("E"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("F"));
oRun.Add_ToContent(++nIndex, new ParaInstrText(" "));
oRun.Add_ToContent(++nIndex, new ParaInstrText("T"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("e"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("s"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("t"));
oRun.Add_ToContent(++nIndex, new ParaInstrText(" "));
oRun.Add_ToContent(++nIndex, new ParaInstrText("\\"));
oRun.Add_ToContent(++nIndex, new ParaInstrText("p"));
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_Separate, this));
oRun.Add_ToContent(++nIndex, new ParaText("1"));
oRun.Add_ToContent(++nIndex, new ParaFieldChar(fldchartype_End, this));
......
......@@ -6520,12 +6520,18 @@ CDocumentContent.prototype.Selection_SetStart = function(X, Y, CurPage, MouseEve
if (type_Paragraph === Item.GetType() && true === MouseEvent.CtrlKey)
{
var Hyperlink = Item.CheckHyperlink(X, Y, ElementPageIndex);
if (null != Hyperlink)
var oHyperlink = Item.CheckHyperlink(X, Y, ElementPageIndex);
var oPageRefLink = Item.CheckPageRefLink(X, Y, ElementPageIndex);
if (null != oHyperlink)
{
this.Selection.Data = {
Hyperlink : true,
Value : Hyperlink
Hyperlink : oHyperlink
};
}
else if (null !== oPageRefLink)
{
this.Selection.Data = {
PageRef : oPageRefLink
};
}
}
......@@ -6652,10 +6658,10 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, MouseEvent
{
this.Selection.Use = false;
if (null != this.Selection.Data && true === this.Selection.Data.Hyperlink)
if (null != this.Selection.Data && this.Selection.Data.Hyperlink)
{
editor && editor.sync_HyperlinkClickCallback(this.Selection.Data.Value.Get_Value());
this.Selection.Data.Value.Set_Visited(true);
editor && editor.sync_HyperlinkClickCallback(this.Selection.Data.Hyperlink.Get_Value());
this.Selection.Data.Hyperlink.Set_Visited(true);
if (this.DrawingDocument.m_oLogicDocument)
{
......@@ -6671,6 +6677,16 @@ CDocumentContent.prototype.Selection_SetEnd = function(X, Y, CurPage, MouseEvent
this.DrawingDocument.OnEndRecalculate(false, true);
}
}
else if (null !== this.Selection.Data && this.Selection.Data.PageRef)
{
var oInstruction = this.Selection.Data.PageRef.GetInstruction();
if (oInstruction && fieldtype_PAGEREF === oInstruction.GetType())
{
var oBookmark = this.BookmarksManager.GetBookmarkByName(oInstruction.GetBookmarkName());
if (oBookmark)
oBookmark[0].GoToBookmark();
}
}
}
else
{
......
......@@ -9254,6 +9254,19 @@ Paragraph.prototype.UpdateCursorType = function(X, Y, CurPage)
var oInfo = new CSelectedElementsInfo();
this.GetElementsInfoByXY(oInfo, X, Y, CurPage);
var bPageRefLink = false;
var arrComplexFields = this.GetComplexFieldsByXY(X, Y, CurPage);
for (var nIndex = 0, nCount = arrComplexFields.length; nIndex < nCount; ++nIndex)
{
var oComplexField = arrComplexFields[nIndex];
var oInstruction = oComplexField.GetInstruction();
if (oInstruction && fieldtype_PAGEREF === oInstruction.GetType() && oInstruction.IsHyperlink())
{
bPageRefLink = true;
break;
}
}
var oContentControl = oInfo.GetInlineLevelSdt();
var oHyperlink = oInfo.Get_Hyperlink();
if (oContentControl)
......@@ -9275,7 +9288,7 @@ Paragraph.prototype.UpdateCursorType = function(X, Y, CurPage)
else
MMData.Type = AscCommon.c_oAscMouseMoveDataTypes.Common;
if (null != oHyperlink && true === AscCommon.global_keyboardEvent.CtrlKey)
if ((null != oHyperlink || bPageRefLink) && true === AscCommon.global_keyboardEvent.CtrlKey)
this.DrawingDocument.SetCursorType("pointer", MMData);
else
this.DrawingDocument.SetCursorType("default", MMData);
......@@ -12385,6 +12398,11 @@ Paragraph.prototype.GetComplexFieldsByPos = function(oParaPos, bReturnFieldPos)
this.Set_ParaContentPos(oCurrentPos, false, -1, -1, false);
return arrComplexFields;
};
Paragraph.prototype.GetComplexFieldsByXY = function(X, Y, CurPage, bReturnFieldPos)
{
var SearchPosXY = this.Get_ParaContentPosByXY(X, Y, CurPage, false, false);
return this.GetComplexFieldsByPos(SearchPosXY.Pos, bReturnFieldPos);
};
Paragraph.prototype.GetOutlineParagraphs = function(arrOutline)
{
var nOutlineLvl = this.GetOutlineLvl();
......@@ -12446,6 +12464,26 @@ Paragraph.prototype.AddBookmarkChar = function(oBookmarkChar, isUseSelection, is
return true;
};
/**
* Проверяем есть ли у нас в заданной точке сложное поле типа PAGEREF с флагом hyperlink = true
* @param X
* @param Y
* @param CurPage
* @returns {CComplexField?}
*/
Paragraph.prototype.CheckPageRefLink = function(X, Y, CurPage)
{
var arrComplexFields = this.GetComplexFieldsByXY(X, Y, CurPage);
for (var nIndex = 0, nCount = arrComplexFields.length; nIndex < nCount; ++nIndex)
{
var oComplexField = arrComplexFields[nIndex];
var oInstruction = oComplexField.GetInstruction();
if (oInstruction && fieldtype_PAGEREF === oInstruction.GetType() && oInstruction.IsHyperlink())
return oComplexField;
}
return null;
};
var pararecalc_0_All = 0;
var pararecalc_0_None = 1;
......
......@@ -229,11 +229,7 @@ CComplexField.prototype.SetSeparateChar = function(oChar)
};
CComplexField.prototype.Update = function()
{
if (!this.Instruction)
{
var oParser = new CFieldInstructionParser();
this.Instruction = oParser.GetInstructionClass(this.InstructionLine);
}
this.private_UpdateInstruction();
if (!this.Instruction || !this.BeginChar || !this.EndChar || !this.SeparateChar)
return;
......@@ -243,7 +239,7 @@ CComplexField.prototype.Update = function()
if (true === this.LogicDocument.Document_Is_SelectionLocked(changestype_Paragraph_Content))
return;
var nFieldCode = this.Instruction.GetFieldCode();
var nFieldCode = this.Instruction.GetType();
if (fieldtype_PAGENUM === nFieldCode)
{
var oRun = this.BeginChar.GetRun();
......@@ -418,6 +414,19 @@ CComplexField.prototype.IsValid = function()
{
return this.IsUse() && this.BeginChar && this.SeparateChar && this.EndChar;
};
CComplexField.prototype.GetInstruction = function()
{
this.private_UpdateInstruction();
return this.Instruction;
};
CComplexField.prototype.private_UpdateInstruction = function()
{
if (!this.Instruction && this.InstructionLine)
{
var oParser = new CFieldInstructionParser();
this.Instruction = oParser.GetInstructionClass(this.InstructionLine);
}
};
function CComplexFieldStatePos(oComplexField, isFieldCode)
{
......
......@@ -54,7 +54,7 @@ function CFieldInstructionBase()
{
}
CFieldInstructionBase.prototype.Type = fieldtype_UNKNOWN;
CFieldInstructionBase.prototype.GetFieldCode = function()
CFieldInstructionBase.prototype.GetType = function()
{
return this.Type;
};
......
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