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