Commit 25be584a authored by Ilya.Kirillov's avatar Ilya.Kirillov

Сделана отрисовка рамок и выделений контента для многострочных формуд.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62214 954022d7-b5bf-4e40-9824-e11837661b57
parent a4dbd7bd
...@@ -1682,7 +1682,7 @@ function CDrawingDocument() ...@@ -1682,7 +1682,7 @@ function CDrawingDocument()
this.FrameRect = { IsActive : false, Rect : { X : 0, Y : 0, R : 0, B : 0 }, Frame : null, this.FrameRect = { IsActive : false, Rect : { X : 0, Y : 0, R : 0, B : 0 }, Frame : null,
Track : { X : 0, Y : 0, L : 0, T : 0, R : 0, B : 0, PageIndex : 0, Type : -1 }, IsTracked : false, PageIndex : 0 }; Track : { X : 0, Y : 0, L : 0, T : 0, R : 0, B : 0, PageIndex : 0, Type : -1 }, IsTracked : false, PageIndex : 0 };
this.MathRect = { IsActive : false, Rect : { X : 0, Y : 0, R : 0, B : 0, PageIndex : 0 }, ContentSelection : null }; this.MathRect = { IsActive : false, Bounds : [], ContentSelection : null };
this.FieldTrack = {IsActive : false, Rects : []}; this.FieldTrack = {IsActive : false, Rects : []};
this.m_oCacheManager = new CCacheManager(); this.m_oCacheManager = new CCacheManager();
...@@ -3321,52 +3321,21 @@ function CDrawingDocument() ...@@ -3321,52 +3321,21 @@ function CDrawingDocument()
overlay.Show(); overlay.Show();
var _page = this.m_arrPages[this.MathRect.Rect.PageIndex];
var drPage = _page.drawingPage;
var dKoefX = (drPage.right - drPage.left) / _page.width_mm;
var dKoefY = (drPage.bottom - drPage.top) / _page.height_mm;
if (null == this.TextMatrix || global_MatrixTransformer.IsIdentity(this.TextMatrix)) if (null == this.TextMatrix || global_MatrixTransformer.IsIdentity(this.TextMatrix))
{ {
var _x = (drPage.left + dKoefX * this.MathRect.Rect.X); for (var nIndex = 0, nCount = this.MathRect.Bounds.length; nIndex < nCount; nIndex++)
var _y = (drPage.top + dKoefY * this.MathRect.Rect.Y); {
var _r = (drPage.left + dKoefX * this.MathRect.Rect.R); var oBounds = this.MathRect.Bounds[nIndex];
var _b = (drPage.top + dKoefY * this.MathRect.Rect.B); var _page = this.m_arrPages[oBounds.Page];
var drPage = _page.drawingPage;
if (_x < overlay.min_x)
overlay.min_x = _x;
if (_r > overlay.max_x)
overlay.max_x = _r;
if (_y < overlay.min_y)
overlay.min_y = _y;
if (_b > overlay.max_y)
overlay.max_y = _b;
var ctx = overlay.m_oContext;
ctx.strokeStyle = "#939393";
ctx.lineWidth = 1;
ctx.beginPath(); var dKoefX = (drPage.right - drPage.left) / _page.width_mm;
this.AutoShapesTrack.AddRect(ctx, _x >> 0, _y >> 0, _r >> 0, _b >> 0, true); var dKoefY = (drPage.bottom - drPage.top) / _page.height_mm;
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = "#FFFFFF"; var _x = (drPage.left + dKoefX * oBounds.X);
ctx.lineWidth = 1; var _y = (drPage.top + dKoefY * oBounds.Y);
var _r = (drPage.left + dKoefX * oBounds.R);
ctx.beginPath(); var _b = (drPage.top + dKoefY * oBounds.B);
this.AutoShapesTrack.AddRect(ctx, (_x - 1) >> 0, (_y - 1) >> 0, (_r + 1) >> 0, (_b + 1) >> 0, true);
ctx.stroke();
ctx.beginPath();
if (null !== this.MathRect.ContentSelection)
{
_x = (drPage.left + dKoefX * this.MathRect.ContentSelection.X);
_y = (drPage.top + dKoefY * this.MathRect.ContentSelection.Y);
_r = (drPage.left + dKoefX * (this.MathRect.ContentSelection.X + this.MathRect.ContentSelection.W));
_b = (drPage.top + dKoefY * (this.MathRect.ContentSelection.Y + this.MathRect.ContentSelection.H));
if (_x < overlay.min_x) if (_x < overlay.min_x)
overlay.min_x = _x; overlay.min_x = _x;
...@@ -3379,94 +3348,157 @@ function CDrawingDocument() ...@@ -3379,94 +3348,157 @@ function CDrawingDocument()
overlay.max_y = _b; overlay.max_y = _b;
var ctx = overlay.m_oContext; var ctx = overlay.m_oContext;
ctx.fillStyle = "#375082"; ctx.strokeStyle = "#939393";
ctx.lineWidth = 1;
ctx.beginPath(); ctx.beginPath();
this.AutoShapesTrack.AddRect(ctx, _x >> 0, _y >> 0, _r >> 0, _b >> 0); this.AutoShapesTrack.AddRect(ctx, _x >> 0, _y >> 0, _r >> 0, _b >> 0, true);
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = "#FFFFFF";
ctx.lineWidth = 1;
ctx.globalAlpha = 0.2; ctx.beginPath();
ctx.fill(); this.AutoShapesTrack.AddRect(ctx, (_x - 1) >> 0, (_y - 1) >> 0, (_r + 1) >> 0, (_b + 1) >> 0, true);
ctx.globalAlpha = 1; ctx.stroke();
ctx.beginPath(); ctx.beginPath();
} }
}
else
{
var _arrBorderBlack = TransformRectByMatrix(this.TextMatrix,
[this.MathRect.Rect.X, this.MathRect.Rect.Y, this.MathRect.Rect.R, this.MathRect.Rect.B],
drPage.left, drPage.top, dKoefX, dKoefY);
var _1px_mm_x = 1 / Math.max(dKoefX, 0.001); if (null !== this.MathRect.ContentSelection)
var _1px_mm_y = 1 / Math.max(dKoefY, 0.001); {
var _arrBorderWhite = TransformRectByMatrix(this.TextMatrix, for (var nIndex = 0, nCount = this.MathRect.ContentSelection.length; nIndex < nCount; nIndex++)
[this.MathRect.Rect.X - _1px_mm_x, this.MathRect.Rect.Y - _1px_mm_y, this.MathRect.Rect.R - _1px_mm_x, this.MathRect.Rect.B - _1px_mm_y], {
drPage.left, drPage.top, dKoefX, dKoefY); var oContentSelection = this.MathRect.ContentSelection[nIndex];
var _page = this.m_arrPages[oContentSelection.Page];
var drPage = _page.drawingPage;
overlay.CheckPoint(_arrBorderWhite[0], _arrBorderWhite[1]); var dKoefX = (drPage.right - drPage.left) / _page.width_mm;
overlay.CheckPoint(_arrBorderWhite[2], _arrBorderWhite[3]); var dKoefY = (drPage.bottom - drPage.top) / _page.height_mm;
overlay.CheckPoint(_arrBorderWhite[4], _arrBorderWhite[5]);
overlay.CheckPoint(_arrBorderWhite[6], _arrBorderWhite[7]);
var ctx = overlay.m_oContext; _x = (drPage.left + dKoefX * oContentSelection.X);
ctx.strokeStyle = "#FFFFFF"; _y = (drPage.top + dKoefY * oContentSelection.Y);
ctx.lineWidth = 1; _r = (drPage.left + dKoefX * (oContentSelection.X + oContentSelection.W));
_b = (drPage.top + dKoefY * (oContentSelection.Y + oContentSelection.H));
ctx.beginPath(); if (_x < overlay.min_x)
overlay.min_x = _x;
if (_r > overlay.max_x)
overlay.max_x = _r;
ctx.moveTo(_arrBorderWhite[0], _arrBorderWhite[1]); if (_y < overlay.min_y)
ctx.lineTo(_arrBorderWhite[2], _arrBorderWhite[3]); overlay.min_y = _y;
ctx.lineTo(_arrBorderWhite[4], _arrBorderWhite[5]); if (_b > overlay.max_y)
ctx.lineTo(_arrBorderWhite[6], _arrBorderWhite[7]); overlay.max_y = _b;
ctx.closePath();
ctx.stroke(); var ctx = overlay.m_oContext;
ctx.beginPath(); ctx.fillStyle = "#375082";
ctx.strokeStyle = "#939393"; ctx.beginPath();
ctx.lineWidth = 1; this.AutoShapesTrack.AddRect(ctx, _x >> 0, _y >> 0, _r >> 0, _b >> 0);
ctx.beginPath(); ctx.globalAlpha = 0.2;
ctx.fill();
ctx.globalAlpha = 1;
ctx.beginPath();
}
}
}
else
{
for (var nIndex = 0, nCount = this.MathRect.Bounds.length; nIndex < nCount; nIndex++)
{
var oBounds = this.MathRect.Bounds[nIndex];
var _page = this.m_arrPages[oBounds.Page];
var drPage = _page.drawingPage;
ctx.moveTo(_arrBorderBlack[0], _arrBorderBlack[1]); var dKoefX = (drPage.right - drPage.left) / _page.width_mm;
ctx.lineTo(_arrBorderBlack[2], _arrBorderBlack[3]); var dKoefY = (drPage.bottom - drPage.top) / _page.height_mm;
ctx.lineTo(_arrBorderBlack[4], _arrBorderBlack[5]);
ctx.lineTo(_arrBorderBlack[6], _arrBorderBlack[7]);
ctx.closePath();
ctx.stroke(); var _arrBorderBlack = TransformRectByMatrix(this.TextMatrix,
ctx.beginPath(); [oBounds.X, oBounds.Y, oBounds.R, oBounds.B],
drPage.left, drPage.top, dKoefX, dKoefY);
if (null !== this.MathRect.ContentSelection) var _1px_mm_x = 1 / Math.max(dKoefX, 0.001);
{ var _1px_mm_y = 1 / Math.max(dKoefY, 0.001);
var _arrSelect = TransformRectByMatrix(this.TextMatrix, var _arrBorderWhite = TransformRectByMatrix(this.TextMatrix,
[this.MathRect.ContentSelection.X, this.MathRect.ContentSelection.Y, [oBounds.X - _1px_mm_x, oBounds.Y - _1px_mm_y, oBounds.R - _1px_mm_x, oBounds.B - _1px_mm_y],
this.MathRect.ContentSelection.X + this.MathRect.ContentSelection.W,
this.MathRect.ContentSelection.Y + this.MathRect.ContentSelection.H],
drPage.left, drPage.top, dKoefX, dKoefY); drPage.left, drPage.top, dKoefX, dKoefY);
overlay.CheckPoint(_arrSelect[0], _arrSelect[1]); overlay.CheckPoint(_arrBorderWhite[0], _arrBorderWhite[1]);
overlay.CheckPoint(_arrSelect[2], _arrSelect[3]); overlay.CheckPoint(_arrBorderWhite[2], _arrBorderWhite[3]);
overlay.CheckPoint(_arrSelect[4], _arrSelect[5]); overlay.CheckPoint(_arrBorderWhite[4], _arrBorderWhite[5]);
overlay.CheckPoint(_arrSelect[6], _arrSelect[7]); overlay.CheckPoint(_arrBorderWhite[6], _arrBorderWhite[7]);
var ctx = overlay.m_oContext; var ctx = overlay.m_oContext;
ctx.fillStyle = "#375082"; ctx.strokeStyle = "#FFFFFF";
ctx.lineWidth = 1;
ctx.beginPath(); ctx.beginPath();
ctx.moveTo(_arrSelect[0], _arrSelect[1]); ctx.moveTo(_arrBorderWhite[0], _arrBorderWhite[1]);
ctx.lineTo(_arrSelect[2], _arrSelect[3]); ctx.lineTo(_arrBorderWhite[2], _arrBorderWhite[3]);
ctx.lineTo(_arrSelect[4], _arrSelect[5]); ctx.lineTo(_arrBorderWhite[4], _arrBorderWhite[5]);
ctx.lineTo(_arrSelect[6], _arrSelect[7]); ctx.lineTo(_arrBorderWhite[6], _arrBorderWhite[7]);
ctx.closePath(); ctx.closePath();
ctx.globalAlpha = 0.2; ctx.stroke();
ctx.fill();
ctx.globalAlpha = 1;
ctx.beginPath(); ctx.beginPath();
}
ctx.strokeStyle = "#939393";
ctx.lineWidth = 1;
ctx.beginPath();
ctx.moveTo(_arrBorderBlack[0], _arrBorderBlack[1]);
ctx.lineTo(_arrBorderBlack[2], _arrBorderBlack[3]);
ctx.lineTo(_arrBorderBlack[4], _arrBorderBlack[5]);
ctx.lineTo(_arrBorderBlack[6], _arrBorderBlack[7]);
ctx.closePath();
ctx.stroke();
ctx.beginPath();
}
if (null !== this.MathRect.ContentSelection)
{
for (var nIndex = 0, nCount = this.MathRect.ContentSelection.length; nIndex < nCount; nIndex++)
{
var oContentSelection = this.MathRect.ContentSelection[nIndex];
var _page = this.m_arrPages[oContentSelection.Page];
var drPage = _page.drawingPage;
var dKoefX = (drPage.right - drPage.left) / _page.width_mm;
var dKoefY = (drPage.bottom - drPage.top) / _page.height_mm;
var _arrSelect = TransformRectByMatrix(this.TextMatrix,
[oContentSelection.X, oContentSelection.Y,
oContentSelection.X + oContentSelection.W,
oContentSelection.Y + oContentSelection.H],
drPage.left, drPage.top, dKoefX, dKoefY);
overlay.CheckPoint(_arrSelect[0], _arrSelect[1]);
overlay.CheckPoint(_arrSelect[2], _arrSelect[3]);
overlay.CheckPoint(_arrSelect[4], _arrSelect[5]);
overlay.CheckPoint(_arrSelect[6], _arrSelect[7]);
var ctx = overlay.m_oContext;
ctx.fillStyle = "#375082";
ctx.beginPath();
ctx.moveTo(_arrSelect[0], _arrSelect[1]);
ctx.lineTo(_arrSelect[2], _arrSelect[3]);
ctx.lineTo(_arrSelect[4], _arrSelect[5]);
ctx.lineTo(_arrSelect[6], _arrSelect[7]);
ctx.closePath();
ctx.globalAlpha = 0.2;
ctx.fill();
ctx.globalAlpha = 1;
ctx.beginPath();
}
}
} }
} }
...@@ -4556,24 +4588,34 @@ function CDrawingDocument() ...@@ -4556,24 +4588,34 @@ function CDrawingDocument()
this.m_oWordControl.UpdateVerRuler(); this.m_oWordControl.UpdateVerRuler();
} }
this.Update_MathTrack = function(IsActive, IsContentActive, Math, X, Y, W, H, PageIndex) this.Update_MathTrack = function(IsActive, IsContentActive, Math)
{ {
this.MathRect.IsActive = IsActive; this.MathRect.IsActive = IsActive;
if (true === IsActive) if (true === IsActive && null !== Math)
{ {
if (null !== Math && true === IsContentActive) if (true === IsContentActive)
this.MathRect.ContentSelection = Math.Get_ContentSelection(); this.MathRect.ContentSelection = Math.Get_ContentSelection();
else else
this.MathRect.ContentSelection = null; this.MathRect.ContentSelection = null;
var PixelError = this.GetMMPerDot(1) * 3; var PixelError = this.GetMMPerDot(1) * 3;
this.MathRect.Rect.X = X - PixelError; var arrBounds = Math.Get_Bounds();
this.MathRect.Rect.Y = Y - PixelError; this.MathRect.Bounds = [];
this.MathRect.Rect.R = X + W + PixelError; for (var nIndex = 0, nCount = arrBounds.length; nIndex < nCount; nIndex++)
this.MathRect.Rect.B = Y + H + PixelError; {
this.MathRect.Rect.PageIndex = PageIndex; var oBounds = arrBounds[nIndex];
this.MathRect.Bounds[nIndex] =
{
X : oBounds.X - PixelError,
Y : oBounds.Y - PixelError,
R : oBounds.X + oBounds.W + PixelError,
B : oBounds.Y + oBounds.H + PixelError,
Page : oBounds.Page
};
}
} }
} }
......
...@@ -12042,10 +12042,7 @@ CDocument.prototype = ...@@ -12042,10 +12042,7 @@ CDocument.prototype =
var oSelectedInfo = this.Get_SelectedElementsInfo(); var oSelectedInfo = this.Get_SelectedElementsInfo();
var Math = oSelectedInfo.Get_Math(); var Math = oSelectedInfo.Get_Math();
if (null !== Math) if (null !== Math)
{ this.DrawingDocument.Update_MathTrack(true, (false === bSelection || true === bEmptySelection ? true : false), Math);
var Bounds = Math.Get_Bounds();
this.DrawingDocument.Update_MathTrack(true, (false === bSelection || true === bEmptySelection ? true : false), Math, Bounds.X, Bounds.Y, Bounds.W, Bounds.H, Bounds.Page);
}
else else
this.DrawingDocument.Update_MathTrack(false); this.DrawingDocument.Update_MathTrack(false);
......
...@@ -1824,10 +1824,7 @@ ParaMath.prototype.Get_ContentSelection = function() ...@@ -1824,10 +1824,7 @@ ParaMath.prototype.Get_ContentSelection = function()
return null; return null;
var Bounds = oContent.Get_Bounds(); var Bounds = oContent.Get_Bounds();
return Bounds;
var LinesCount = oContent.protected_GetLinesCount();
return Bounds[0];
}; };
ParaMath.prototype.Recalc_RunsCompiledPr = function() ParaMath.prototype.Recalc_RunsCompiledPr = function()
...@@ -1969,14 +1966,9 @@ ParaMath.prototype.Make_AutoCorrect = function() ...@@ -1969,14 +1966,9 @@ ParaMath.prototype.Make_AutoCorrect = function()
ParaMath.prototype.Get_Bounds = function() ParaMath.prototype.Get_Bounds = function()
{ {
if (undefined === this.Paragraph || null === this.Paragraph) if (undefined === this.Paragraph || null === this.Paragraph)
return {X : 0, Y : 0, W : 0, H : 0, Page : 0}; return [{X : 0, Y : 0, W : 0, H : 0, Page : 0}];
else else
{ return this.Root.Get_Bounds();
var LinesCount = this.Root.protected_GetLinesCount();
return this.Root.Get_Bounds()[LinesCount - 1];
}
}; };
ParaMath.prototype.getPropsForWrite = function() ParaMath.prototype.getPropsForWrite = function()
......
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