Commit fe07d8b5 authored by Ilya Kirillov's avatar Ilya Kirillov

Fixed problem with bounding rectangle around a block level content control.

parent 09f46ed7
......@@ -1395,6 +1395,38 @@ CDocumentContent.prototype.Get_PageBounds = function(CurPage, Height, bForceChec
return Bounds;
};
CDocumentContent.prototype.GetContentBounds = function(CurPage)
{
var oBounds = this.Get_PageBounds(CurPage);
var oPage = this.Pages[CurPage];
if (!oPage)
return oBounds;
this.Pos = 0;
this.EndPos = -1;
for (var nIndex = oPage.Pos; nIndex <= oPage.EndPos; ++nIndex)
{
var oElement = this.Content[nIndex];
var nElementPageIndex = this.private_GetElementPageIndex(nIndex, CurPage, 0, 1);
var oElementBounds = oElement.GetContentBounds(nElementPageIndex);
if (oElementBounds.Bottom > oBounds.Bottom)
oBounds.Bottom = oElementBounds.Bottom;
if (oElementBounds.Top < oBounds.Top)
oBounds.Top = oElementBounds.Top;
if (oElementBounds.Right > oBounds.Right)
oBounds.Right = oElementBounds.Right;
if (oElementBounds.Left < oBounds.Left)
oBounds.Left = oElementBounds.Left;
}
return oBounds;
};
CDocumentContent.prototype.Get_PagesCount = function()
{
return this.Pages.length;
......
......@@ -128,6 +128,10 @@ CDocumentContentElementBase.prototype.Get_PageBounds = function(CurPage)
{
return new CDocumentBounds(this.X, this.Y, this.XLimit, this.YLimit);
};
CDocumentContentElementBase.prototype.GetContentBounds = function(CurPage)
{
return new CDocumentBounds(this.X, this.Y, this.XLimit, this.YLimit);
};
CDocumentContentElementBase.prototype.Is_EmptyPage = function(CurPage)
{
return false;
......
......@@ -414,6 +414,39 @@ Paragraph.prototype.Get_PageBounds = function(CurPage)
{
return this.Pages[CurPage].Bounds;
};
Paragraph.prototype.GetContentBounds = function(CurPage)
{
var oBounds = this.Get_PageBounds(CurPage).Copy();
var oPage = this.Pages[CurPage];
if (!oPage)
return oBounds;
for (var CurLine = oPage.StartLine; CurLine <= oPage.EndLine; ++CurLine)
{
var oLine = this.Lines[CurLine];
var Top = oLine.Top + oPage.Y;
if (oBounds.Top > Top)
oBounds.Top = Top;
var Bottom = oLine.Bottom + oPage.Y;
if (oBounds.Bottom < Bottom)
oBounds.Bottom = Bottom;
for (var CurRange = 0, RangesCount = oLine.Ranges.length; CurRange < RangesCount; ++CurRange)
{
var oRange = oLine.Ranges[CurRange];
if (oBounds.Left > oRange.X)
oBounds.Left = oRange.X;
if (oBounds.Right < oRange.XEnd)
oBounds.Right = oRange.XEnd;
}
}
return oBounds;
};
Paragraph.prototype.Get_EmptyHeight = function()
{
var Pr = this.Get_CompiledPr();
......@@ -12137,6 +12170,10 @@ CDocumentBounds.prototype.Reset = function()
this.Right = 0;
this.Top = 0;
};
CDocumentBounds.prototype.Copy = function()
{
return new CDocumentBounds(this.Left, this.Top, this.Right, this.Bottom);
};
function CParagraphPageEndInfo()
{
......
......@@ -105,6 +105,10 @@ CBlockLevelSdt.prototype.Get_PageBounds = function(CurPage)
{
return this.Content.Get_PageBounds(CurPage);
};
CBlockLevelSdt.prototype.GetContentBounds = function(CurPage)
{
return this.Content.GetContentBounds(CurPage);
};
CBlockLevelSdt.prototype.Is_EmptyPage = function(CurPage)
{
// TODO: Реализовать
......@@ -596,7 +600,7 @@ CBlockLevelSdt.prototype.DrawContentControlsTrack = function(isHover)
for (var nCurPage = 0, nPagesCount = this.GetPagesCount(); nCurPage < nPagesCount; ++nCurPage)
{
var nPageAbs = this.Get_AbsolutePage(nCurPage);
var oBounds = this.GetPageBounds(nCurPage);
var oBounds = this.Content.GetContentBounds(nCurPage);
arrRects.push({X : oBounds.Left, Y : oBounds.Top, R : oBounds.Right, B : oBounds.Bottom, Page : nPageAbs});
}
......
......@@ -2061,6 +2061,10 @@ CTable.prototype.Get_PageBounds = function(CurPage)
{
return this.Pages[CurPage].Bounds;
};
CTable.prototype.GetContentBounds = function(CurPage)
{
return this.Get_PageBounds(CurPage);
};
CTable.prototype.Get_PagesCount = function()
{
return this.Pages.length;
......
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