Commit 4d0b8ca3 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented a hint for a footnote reference.

parent 84c44abe
......@@ -2412,27 +2412,40 @@
//-----------------------------------------------------------------
// События движения мыши
//-----------------------------------------------------------------
function CMouseMoveData(obj) {
if (obj) {
function CMouseMoveData(obj)
{
if (obj)
{
this.Type = ( undefined != obj.Type ) ? obj.Type : c_oAscMouseMoveDataTypes.Common;
this.X_abs = ( undefined != obj.X_abs ) ? obj.X_abs : 0;
this.Y_abs = ( undefined != obj.Y_abs ) ? obj.Y_abs : 0;
switch (this.Type) {
case c_oAscMouseMoveDataTypes.Hyperlink : {
switch (this.Type)
{
case c_oAscMouseMoveDataTypes.Hyperlink :
{
this.Hyperlink = ( undefined != obj.PageNum ) ? obj.PageNum : 0;
break;
}
case c_oAscMouseMoveDataTypes.LockedObject : {
case c_oAscMouseMoveDataTypes.LockedObject :
{
this.UserId = ( undefined != obj.UserId ) ? obj.UserId : "";
this.HaveChanges = ( undefined != obj.HaveChanges ) ? obj.HaveChanges : false;
this.LockedObjectType =
( undefined != obj.LockedObjectType ) ? obj.LockedObjectType : Asc.c_oAscMouseMoveLockedObjectType.Common;
break;
}
case c_oAscMouseMoveDataTypes.Footnote:
{
this.Text = "";
this.Number = 1;
break;
}
}
} else {
}
else
{
this.Type = c_oAscMouseMoveDataTypes.Common;
this.X_abs = 0;
this.Y_abs = 0;
......@@ -2460,6 +2473,14 @@
CMouseMoveData.prototype.get_LockedObjectType = function () {
return this.LockedObjectType;
};
CMouseMoveData.prototype.get_FootnoteText = function()
{
return this.Text;
};
CMouseMoveData.prototype.get_FootnoteNumber = function()
{
return this.Number;
};
function asc_CUserInfo(obj) {
if (obj) {
......
......@@ -745,7 +745,8 @@
var c_oAscMouseMoveDataTypes = {
Common : 0,
Hyperlink : 1,
LockedObject : 2
LockedObject : 2,
Footnote : 3
};
// selection type
......
......@@ -45,6 +45,17 @@ function CFootEndnote(DocumentController)
this.Number = 1;
this.SectPr = null;
this.CurtomMarkFollows = false;
this.NeedUpdateHint = true;
this.Hint = "";
this.PositionInfo = {
Paragraph : null,
Run : null,
Line : 0,
Range : 0,
X : 0,
W : 0
};
}
AscCommon.extendClass(CFootEndnote, CDocumentContent);
......@@ -128,6 +139,40 @@ CFootEndnote.prototype.AddDefaultFootnoteContent = function(sText)
this.Cursor_MoveToEndPos(false);
};
CFootEndnote.prototype.Recalculate_Page = function(PageIndex, bStart)
{
CFootEndnote.superclass.Recalculate_Page.call(this, PageIndex, bStart);
this.NeedUpdateHint = true;
};
CFootEndnote.prototype.GetHint = function()
{
if (true === this.NeedUpdateHint)
{
var arrParagraphs = this.Get_AllParagraphs({All : true});
this.Hint = "";
for (var nIndex = 0, nCount = arrParagraphs.length; nIndex < nCount; ++nIndex)
{
this.Hint += arrParagraphs[nIndex].GetText();
}
this.NeedUpdateHint = false;
}
return this.Hint;
};
CFootEndnote.prototype.UpdatePositionInfo = function(Paragraph, Run, Line, Range, X, W)
{
this.PositionInfo.Paragraph = Paragraph;
this.PositionInfo.Run = Run;
this.PositionInfo.Line = Line;
this.PositionInfo.Range = Range;
this.PositionInfo.X = X;
this.PositionInfo.W = W;
};
CFootEndnote.prototype.GetPositionInfo = function()
{
return this.PositionInfo;
};
//--------------------------------------------------------export----------------------------------------------------
window['AscCommonWord'] = window['AscCommonWord'] || {};
......
......@@ -9288,12 +9288,19 @@ Paragraph.prototype =
MMData.Y_abs = Coords.Y;
var Hyperlink = this.Check_Hyperlink(X, Y, CurPage);
var Footnote = this.CheckFootnote(X, Y, CurPage);
if (null != Hyperlink && (Y <= this.Pages[CurPage].Bounds.Bottom && Y >= this.Pages[CurPage].Bounds.Top))
{
MMData.Type = AscCommon.c_oAscMouseMoveDataTypes.Hyperlink;
MMData.Hyperlink = new Asc.CHyperlinkProperty( Hyperlink );
}
else if (null !== Footnote)
{
MMData.Type = AscCommon.c_oAscMouseMoveDataTypes.Footnote;
MMData.Text = Footnote.GetHint();
MMData.Number = Footnote.GetNumber();
}
else
MMData.Type = AscCommon.c_oAscMouseMoveDataTypes.Common;
......@@ -12119,6 +12126,73 @@ Paragraph.prototype.GotoFootnoteRef = function(isNext, isCurrent)
return false;
};
Paragraph.prototype.GetText = function(oPr)
{
var oText = new CParagraphGetText();
oText.SetBreakOnNonText(false);
oText.SetParaEndToSpace(true);
for (var nIndex = 0, nCount = this.Content.length; nIndex < nCount; ++nIndex)
{
if (this.Content[nIndex].Get_Text)
this.Content[nIndex].Get_Text(oText);
}
return oText.Text;
};
Paragraph.prototype.CheckFootnote = function(X, Y, CurPage)
{
var SearchPosXY = this.Get_ParaContentPosByXY(X, Y, CurPage, false, false);
var CurLine = SearchPosXY.Line;
if (true !== SearchPosXY.InText)
return null;
if (!this.Lines[CurLine])
{
return null;
}
else if (this.Lines[CurLine].Info & paralineinfo_Notes)
{
var arrFootnoteRefs = this.private_GetFootnoteRefsInLine(CurLine);
var nMinDiff = 1000000000;
var oNote = null;
for (var nIndex = 0, nCount = arrFootnoteRefs.length; nIndex < nCount; ++nIndex)
{
var oFootnoteRef = arrFootnoteRefs[nIndex];
var oFootnote = oFootnoteRef.Get_Footnote();
var oPosInfo = oFootnote.GetPositionInfo();
if (Math.abs(X - oPosInfo.X) < nMinDiff || Math.abs(X - (oPosInfo.X + oPosInfo.W)) < nMinDiff)
{
nMinDiff = Math.min(Math.abs(X - oPosInfo.X), Math.abs(X - (oPosInfo.X + oPosInfo.W)));
oNote = oFootnote;
}
}
if (nMinDiff > 10)
oNote = null;
return oNote;
}
return null;
};
Paragraph.prototype.private_GetFootnoteRefsInLine = function(CurLine)
{
var arrFootnotes = [];
var oLine = this.Lines[CurLine];
for (var CurRange = 0, RangesCount = oLine.Ranges.length; CurRange < RangesCount; ++CurRange)
{
var oRange = oLine.Ranges[CurRange];
for (var CurPos = oRange.StartPos; CurPos <= oRange.EndPos; ++CurPos)
{
if (this.Content[CurPos].GetFootnoteRefsInRange)
this.Content[CurPos].GetFootnoteRefsInRange(arrFootnotes, CurLine, CurRange);
}
}
return arrFootnotes;
};
var pararecalc_0_All = 0;
var pararecalc_0_None = 1;
......@@ -12928,7 +13002,18 @@ function CParagraphCheckPageBreakEnd(PageBreak)
function CParagraphGetText()
{
this.Text = "";
this.BreakOnNonText = true;
this.ParaEndToSpace = false;
}
CParagraphGetText.prototype.SetBreakOnNonText = function(bValue)
{
this.BreakOnNonText = bValue;
};
CParagraphGetText.prototype.SetParaEndToSpace = function(bValue)
{
this.ParaEndToSpace = bValue;
};
function CParagraphNearPos()
{
......
......@@ -2634,6 +2634,20 @@ CParagraphContentWithParagraphLikeContent.prototype.GotoFootnoteRef = function(i
return false;
};
CParagraphContentWithParagraphLikeContent.prototype.GetFootnoteRefsInRange = function(arrFootnotes, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
for (var CurPos = StartPos; CurPos <= EndPos; CurPos++)
{
if (this.Content[CurPos].GetFootnoteRefsInRange)
this.Content[CurPos].GetFootnoteRefsInRange(arrFootnotes, _CurLine, _CurRange);
}
};
//----------------------------------------------------------------------------------------------------------------------
// Функции, которые должны быть реализованы в классах наследниках
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -1108,6 +1108,9 @@ Paragraph.prototype.private_RecalculateLineInfo = function(CurLine, CurPa
if (true === PRS.BadLeftTab)
this.Lines[CurLine].Info |= paralineinfo_BadLeftTab;
if (PRS.GetFootnoteReferencesCount() > 0)
this.Lines[CurLine].Info |= paralineinfo_Notes;
};
Paragraph.prototype.private_RecalculateLineMetrics = function(CurLine, CurPage, PRS, ParaPr)
......@@ -2179,6 +2182,7 @@ var paralineinfo_End = 0x0004; // Последняя строка па
var paralineinfo_RangeY = 0x0008; // Строка начинается после какого-либо объекта с обтеканием
var paralineinfo_BreakRealPage = 0x0010; // В строке есть PageBreak
var paralineinfo_BadLeftTab = 0x0020; // В строке есть левый таб, который правее правой границы
var paralineinfo_Notes = 0x0040; // В строке есть сноски
function CParaLine()
{
......
......@@ -275,12 +275,28 @@ ParaRun.prototype.Get_Text = function(Text)
switch ( ItemType )
{
case para_Drawing:
case para_End:
case para_PageNum:
case para_PageCount:
{
if (true === Text.BreakOnNonText)
{
Text.Text = null;
bBreak = true;
}
break;
}
case para_End:
{
if (true === Text.BreakOnNonText)
{
Text.Text = null;
bBreak = true;
}
if (true === Text.ParaEndToSpace)
Text.Text += " ";
break;
}
......@@ -3572,6 +3588,12 @@ ParaRun.prototype.Recalculate_Range_Spaces = function(PRSA, _CurLine, _CurRange,
Item.WidthVisible = (WidthVisible * TEXTWIDTH_DIVIDER) | 0;//Item.Set_WidthVisible(WidthVisible);
if (para_FootnoteReference === ItemType)
{
var oFootnote = Item.Get_Footnote();
oFootnote.UpdatePositionInfo(this.Paragraph, this, _CurLine, _CurRange, PRSA.X, WidthVisible);
}
PRSA.X += WidthVisible;
PRSA.LastW = WidthVisible;
......@@ -9069,6 +9091,20 @@ ParaRun.prototype.GotoFootnoteRef = function(isNext, isCurrent, isStepOver)
return nResult;
};
ParaRun.prototype.GetFootnoteRefsInRange = function(arrFootnotes, _CurLine, _CurRange)
{
var CurLine = _CurLine - this.StartLine;
var CurRange = (0 === CurLine ? _CurRange - this.StartRange : _CurRange);
var StartPos = this.protected_GetRangeStartPos(CurLine, CurRange);
var EndPos = this.protected_GetRangeEndPos(CurLine, CurRange);
for (var CurPos = StartPos; CurPos < EndPos; CurPos++)
{
if (para_FootnoteReference === this.Content[CurPos].Type)
arrFootnotes.push(this.Content[CurPos]);
}
};
function CParaRunStartState(Run)
{
......
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