Commit d7108701 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Поправил баг http://bugzserver/show_bug.cgi?id=26345 (при выставлении другого...

Поправил баг http://bugzserver/show_bug.cgi?id=26345 (при выставлении другого цвета и ширины одновременно 2 раза делался stroke).
Объединил отрисовку всех бордеров в одну функцию.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58321 954022d7-b5bf-4e40-9824-e11837661b57
parent 7939588e
...@@ -395,6 +395,11 @@ var c_oAscBorderStyles = { ...@@ -395,6 +395,11 @@ var c_oAscBorderStyles = {
Medium : 12, Medium : 12,
Thick : 13 Thick : 13
}; };
var c_oAscBorderType = {
Hor : 1,
Ver : 2,
Diag : 3
};
// PageOrientation // PageOrientation
var c_oAscPageOrientation = { var c_oAscPageOrientation = {
PagePortrait : 1, PagePortrait : 1,
......
...@@ -2646,93 +2646,41 @@ ...@@ -2646,93 +2646,41 @@
} }
} }
var bc = null, bw = -1, isNotFirst = false, isStroke = false; // cached border color var bc = null, bw = -1, isNotFirst = false; // cached border color
// ToDo в одну функцию function drawBorder(type, border, x1, y1, x2, y2) {
function drawBorderHor(border, x1, y, x2) { var isStroke = false,
if (border.s !== c_oAscBorderStyles.None) { isNewColor = !g_oColorManager.isEqual(bc, border.c),
if (!g_oColorManager.isEqual(bc, border.c)) { isNewWidth = bw !== border.w;
if (isNotFirst) if (isNotFirst && (isNewColor || isNewWidth)) {
ctx.stroke(); ctx.stroke();
isStroke = true;
bc = border.c;
ctx.setStrokeStyle(bc);
isStroke = true;
}
if (bw !== border.w) {
if (isNotFirst)
ctx.stroke();
bw = border.w;
ctx.setLineWidth(border.w);
isStroke = true;
}
if (isStroke || !isNotFirst) {
isNotFirst = true;
ctx.beginPath();
}
ctx.lineHor(x1, y, x2);
isStroke = false;
} }
}
function drawBorderVer(border, x1, y1, y2) {
if (border.s !== c_oAscBorderStyles.None) {
if (!g_oColorManager.isEqual(bc, border.c)) {
if (isNotFirst)
ctx.stroke();
bc = border.c;
ctx.setStrokeStyle(bc);
isStroke = true;
}
if (bw !== border.w) {
if (isNotFirst)
ctx.stroke();
bw = border.w; if (isNewColor) {
ctx.setLineWidth(border.w); bc = border.c;
isStroke = true; ctx.setStrokeStyle(bc);
} }
if (isNewWidth) {
if (isStroke || !isNotFirst) { bw = border.w;
isNotFirst = true; ctx.setLineWidth(border.w);
ctx.beginPath();
}
ctx.lineVer(x1, y1, y2);
isStroke = false;
} }
}
function drawDiagonal(border, x1, y1, x2, y2) {
if (border.s !== c_oAscBorderStyles.None) {
if (!g_oColorManager.isEqual(bc, border.c)) {
if (isNotFirst)
ctx.stroke();
bc = border.c;
ctx.setStrokeStyle(bc);
isStroke = true;
}
if (bw !== border.w) {
if (isNotFirst)
ctx.stroke();
bw = border.w;
ctx.setLineWidth(border.w);
isStroke = true;
}
if (isStroke || !isNotFirst) { if (isStroke || false === isNotFirst) {
isNotFirst = true; isNotFirst = true;
ctx.beginPath(); ctx.beginPath();
} }
ctx.lineDiag(x1, y1, x2, y2); switch (type) {
isStroke = false; case c_oAscBorderType.Hor:
ctx.lineHor(x1, y1, x2);
break;
case c_oAscBorderType.Ver:
ctx.lineVer(x1, y1, y2);
break;
case c_oAscBorderType.Diag:
ctx.lineDiag(x1, y1, x2, y2);
break;
} }
} }
...@@ -2754,7 +2702,7 @@ ...@@ -2754,7 +2702,7 @@
var dy1 = tbw > border.w ? tbw - 1 : (tbw > 1 ? -1 : 0); var dy1 = tbw > border.w ? tbw - 1 : (tbw > 1 ? -1 : 0);
var dy2 = bbw > border.w ? -2 : (bbw > 2 ? 1 : 0); var dy2 = bbw > border.w ? -2 : (bbw > 2 ? 1 : 0);
drawBorderVer(border, x, y1 + (-1 + dy1) * t.height_1px, y2 + (1 + dy2) * t.height_1px); drawBorder(c_oAscBorderType.Ver, border, x, y1 + (-1 + dy1) * t.height_1px, x, y2 + (1 + dy2) * t.height_1px);
} }
function drawHorizontalBorder(borderTopObject, borderBottomObject, x1, y, x2) { function drawHorizontalBorder(borderTopObject, borderBottomObject, x1, y, x2) {
...@@ -2774,7 +2722,7 @@ ...@@ -2774,7 +2722,7 @@
borderTopObject && borderTopObject.getRightBorder()); borderTopObject && borderTopObject.getRightBorder());
var dx1 = border.w > lbw ? (lbw > 1 ? -1 : 0) : (lbw > 2 ? 2 : 1); var dx1 = border.w > lbw ? (lbw > 1 ? -1 : 0) : (lbw > 2 ? 2 : 1);
var dx2 = border.w > rbw ? (rbw > 2 ? 1 : 0) : (rbw > 1 ? -2 : -1); var dx2 = border.w > rbw ? (rbw > 2 ? 1 : 0) : (rbw > 1 ? -2 : -1);
drawBorderHor(border, x1 + (-1 + dx1) * t.width_1px, y, x2 + (1 + dx2) * t.width_1px); drawBorder(c_oAscBorderType.Hor, border, x1 + (-1 + dx1) * t.width_1px, y, x2 + (1 + dx2) * t.width_1px, y);
} }
} }
...@@ -2909,11 +2857,11 @@ ...@@ -2909,11 +2857,11 @@
*/ */
if (bCur.borders.dd) { if (bCur.borders.dd) {
// draw diagonal line l,t - r,b // draw diagonal line l,t - r,b
drawDiagonal(bCur.borders.d, x1 - t.width_1px, y1 - t.height_1px, x2Diagonal, y2Diagonal); drawBorder(c_oAscBorderType.Diag, bCur.borders.d, x1 - t.width_1px, y1 - t.height_1px, x2Diagonal, y2Diagonal);
} }
if (bCur.borders.du) { if (bCur.borders.du) {
// draw diagonal line l,b - r,t // draw diagonal line l,b - r,t
drawDiagonal(bCur.borders.d, x1 - t.width_1px, y2Diagonal, x2Diagonal, y1 - t.height_1px); drawBorder(c_oAscBorderType.Diag, bCur.borders.d, x1 - t.width_1px, y2Diagonal, x2Diagonal, y1 - t.height_1px);
} }
// ToDo Clip diagonal borders // ToDo Clip diagonal borders
//ctx.restore(); //ctx.restore();
......
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