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,6 +1409,12 @@ CDocumentContent.prototype.GetContentBounds = function(CurPage) ...@@ -1412,6 +1409,12 @@ CDocumentContent.prototype.GetContentBounds = function(CurPage)
var oElementBounds = oElement.GetContentBounds(nElementPageIndex); var oElementBounds = oElement.GetContentBounds(nElementPageIndex);
if (null === oBounds)
{
oBounds = oElementBounds.Copy();
}
else
{
if (oElementBounds.Bottom > oBounds.Bottom) if (oElementBounds.Bottom > oBounds.Bottom)
oBounds.Bottom = oElementBounds.Bottom; oBounds.Bottom = oElementBounds.Bottom;
...@@ -1424,6 +1427,7 @@ CDocumentContent.prototype.GetContentBounds = function(CurPage) ...@@ -1424,6 +1427,7 @@ CDocumentContent.prototype.GetContentBounds = function(CurPage)
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;
var Bottom = oLine.Bottom + oPage.Y;
var Left = null, Right = null;
for (var CurRange = 0, RangesCount = oLine.Ranges.length; CurRange < RangesCount; ++CurRange)
{
var oRange = oLine.Ranges[CurRange];
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) if (oBounds.Top > Top)
oBounds.Top = Top; oBounds.Top = Top;
var Bottom = oLine.Bottom + oPage.Y;
if (oBounds.Bottom < Bottom) if (oBounds.Bottom < Bottom)
oBounds.Bottom = Bottom; oBounds.Bottom = Bottom;
for (var CurRange = 0, RangesCount = oLine.Ranges.length; CurRange < RangesCount; ++CurRange) if (oBounds.Left > Left)
{ oBounds.Left = Left;
var oRange = oLine.Ranges[CurRange];
if (oBounds.Left > oRange.X)
oBounds.Left = oRange.X;
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