Commit 999a8361 authored by Ilya Kirillov's avatar Ilya Kirillov

Implemented "\p" switch for the PAGEREF field.

parent 9908f722
......@@ -52,6 +52,9 @@ function CParagraphBookmark(isStart, sBookmarkId, sBookmarkName)
this.BookmarkId = sBookmarkId;
this.BookmarkName = sBookmarkName;
this.Use = true;
this.PageAbs = 1;
this.X = 0;
this.Y = 0;
AscCommon.g_oTableId.Add(this, this.Id);
}
......@@ -67,6 +70,10 @@ CParagraphBookmark.prototype.GetId = function()
{
return this.Id;
};
CParagraphBookmark.prototype.Copy = function()
{
return new CParagraphBookmark(this.Start, this.BookmarkId, this.BookmarkName);
};
CParagraphBookmark.prototype.GetBookmarkId = function()
{
return this.BookmarkId;
......@@ -91,6 +98,21 @@ CParagraphBookmark.prototype.IsStart = function()
{
return this.Start;
};
CParagraphBookmark.prototype.Recalculate_Range = function(PRS, ParaPr)
{
this.PageAbs = PRS.Paragraph.Get_AbsolutePage(PRS.Page);
this.X = PRS.X;
this.Y = PRS.Y;
};
CParagraphBookmark.prototype.GetPage = function()
{
return this.PageAbs;
};
CParagraphBookmark.prototype.GetXY = function()
{
return {X : this.X, Y : this.Y};
};
//----------------------------------------------------------------------------------------------------------------------
// Функции совместного редактирования
//----------------------------------------------------------------------------------------------------------------------
......
......@@ -50,6 +50,9 @@ function ParaFieldChar(Type, LogicDocument)
this.CharType = undefined === Type ? fldchartype_Begin : Type;
this.ComplexField = (this.CharType === fldchartype_Begin) ? new CComplexField(LogicDocument) : null;
this.Run = null;
this.X = 0;
this.Y = 0;
this.PageAbs = 0;
}
ParaFieldChar.prototype = Object.create(CRunElementBase.prototype);
ParaFieldChar.prototype.constructor = ParaFieldChar;
......@@ -111,6 +114,23 @@ ParaFieldChar.prototype.GetRun = function()
{
return this.Run;
};
ParaFieldChar.prototype.SetXY = function(X, Y)
{
this.X = X;
this.Y = Y;
};
ParaFieldChar.prototype.GetXY = function()
{
return {X : this.X, Y : this.Y};
};
ParaFieldChar.prototype.SetPage = function(nPage)
{
this.PageAbs = nPage;
};
ParaFieldChar.prototype.GetPage = function()
{
return this.PageAbs;
};
function ParaInstrText(value)
{
......@@ -273,7 +293,43 @@ CComplexField.prototype.Update = function()
{
this.LogicDocument.Create_NewHistoryPoint();
this.LogicDocument.GetBookmarksManager();
var oBookmarksManager = this.LogicDocument.GetBookmarksManager();
var oBookmark = oBookmarksManager.GetBookmarkByName(this.Instruction.GetBookmarkName());
var sValue = "Error! Bookmark not defined.";
if (oBookmark)
{
var oStartBookmark = oBookmark[0];
var nBookmarkPage = oStartBookmark.GetPage() + 1;
if (this.Instruction.IsPositionRelative())
{
if (oStartBookmark.GetPage() === this.SeparateChar.GetPage())
{
var oBookmarkXY = oStartBookmark.GetXY();
var oFieldXY = this.SeparateChar.GetXY();
if (Math.abs(oBookmarkXY.Y - oFieldXY.Y) < 0.001)
sValue = oBookmarkXY.X < oFieldXY.X ? "above" : "below";
else if (oBookmarkXY.Y < oFieldXY.Y)
sValue = "above";
else
sValue = "below";
}
else
{
sValue = "on page " + nBookmarkPage;
}
}
else
{
sValue = (oStartBookmark.GetPage() + 1) + "";
}
}
for (var nIndex = 0, nLen = sValue.length; nIndex < nLen; ++nIndex)
{
this.LogicDocument.AddToParagraph(new ParaText(sValue.charAt(nIndex)));
}
this.LogicDocument.Recalculate();
}
......
......@@ -37,6 +37,9 @@ function CParagraphContentBase()
this.StartLine = -1;
this.StartRange = -1;
this.Lines = [];
this.LinesLength = 0;
}
CParagraphContentBase.prototype.CanSplit = function()
{
......
......@@ -3244,6 +3244,9 @@ ParaRun.prototype.Recalculate_Range = function(PRS, ParaPr, Depth)
if (PRS.IsFastRecalculate())
break;
Item.SetXY(X + SpaceLen + WordLen, PRS.Y);
Item.SetPage(Para.Get_AbsolutePage(CurPage));
Item.SetRun(this);
if (Item.IsBegin())
{
......
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