Commit 68afeb34 authored by Ilya Kirillov's avatar Ilya Kirillov

Improved of drawing of a bounds around block-level content control.

parent e4c3ee23
......@@ -1397,14 +1397,11 @@ CDocumentContent.prototype.Get_PageBounds = function(CurPage, Height, bForceChec
};
CDocumentContent.prototype.GetContentBounds = function(CurPage)
{
var oBounds = this.Get_PageBounds(CurPage);
var oPage = this.Pages[CurPage];
if (!oPage)
return oBounds;
if (!oPage || oPage.Pos > oPage.EndPos)
return this.Get_PageBounds(CurPage);
this.Pos = 0;
this.EndPos = -1;
var oBounds = null;
for (var nIndex = oPage.Pos; nIndex <= oPage.EndPos; ++nIndex)
{
var oElement = this.Content[nIndex];
......@@ -1412,17 +1409,24 @@ CDocumentContent.prototype.GetContentBounds = function(CurPage)
var oElementBounds = oElement.GetContentBounds(nElementPageIndex);
if (oElementBounds.Bottom > oBounds.Bottom)
oBounds.Bottom = oElementBounds.Bottom;
if (null === oBounds)
{
oBounds = oElementBounds.Copy();
}
else
{
if (oElementBounds.Bottom > oBounds.Bottom)
oBounds.Bottom = oElementBounds.Bottom;
if (oElementBounds.Top < oBounds.Top)
oBounds.Top = oElementBounds.Top;
if (oElementBounds.Top < oBounds.Top)
oBounds.Top = oElementBounds.Top;
if (oElementBounds.Right > oBounds.Right)
oBounds.Right = oElementBounds.Right;
if (oElementBounds.Right > oBounds.Right)
oBounds.Right = oElementBounds.Right;
if (oElementBounds.Left < oBounds.Left)
oBounds.Left = oElementBounds.Left;
if (oElementBounds.Left < oBounds.Left)
oBounds.Left = oElementBounds.Left;
}
}
return oBounds;
......
......@@ -416,32 +416,48 @@ Paragraph.prototype.Get_PageBounds = function(CurPage)
};
Paragraph.prototype.GetContentBounds = function(CurPage)
{
var oBounds = this.Get_PageBounds(CurPage).Copy();
var oPage = this.Pages[CurPage];
if (!oPage)
return oBounds;
if (!oPage || oPage.StartLine > oPage.EndLine)
return this.Get_PageBounds(CurPage).Copy();
var oBounds = null;
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 Top = oLine.Top + oPage.Y;
var Bottom = oLine.Bottom + oPage.Y;
if (oBounds.Bottom < Bottom)
oBounds.Bottom = Bottom;
var Left = null, Right = null;
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 (null === Left || Left > oRange.XVisible)
Left = oRange.XVisible;
if (null === Right || Right < oRange.XVisible + oRange.W)
Right = oRange.XVisible + oRange.W;
}
if (!oBounds)
{
oBounds = new CDocumentBounds(Left, Top, Right, Bottom);
}
else
{
if (oBounds.Top > Top)
oBounds.Top = Top;
if (oBounds.Bottom < Bottom)
oBounds.Bottom = Bottom;
if (oBounds.Left > Left)
oBounds.Left = Left;
if (oBounds.Right < oRange.XEnd)
oBounds.Right = oRange.XEnd;
if (oBounds.Right < Right)
oBounds.Right = Right;
}
}
......
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