Commit 1d941eae authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Отрисовка border-ов для стилей ячеек

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47895 954022d7-b5bf-4e40-9824-e11837661b57
parent 610f34a7
...@@ -1259,6 +1259,11 @@ CCellStyle.prototype = { ...@@ -1259,6 +1259,11 @@ CCellStyle.prototype = {
if (null != this.xfs && null != this.xfs.font) if (null != this.xfs && null != this.xfs.font)
return this.xfs.font; return this.xfs.font;
return null; return null;
},
getBorder: function () {
if (null != this.xfs && null != this.xfs.border)
return this.xfs.border;
return g_oDefaultBorder;
} }
}; };
/** @constructor */ /** @constructor */
......
...@@ -781,10 +781,6 @@ ...@@ -781,10 +781,6 @@
} }
this.defaultStylesImage = oCanvas.toDataURL("image/png"); this.defaultStylesImage = oCanvas.toDataURL("image/png");
var test = document.createElement('img');
test.src = this.defaultStylesImage;
document.body.appendChild(test);
}, },
generateDocumentStyles: function () { generateDocumentStyles: function () {
...@@ -792,14 +788,79 @@ ...@@ -792,14 +788,79 @@
drawStyle: function (oGraphics, oStyle, nIndex) { drawStyle: function (oGraphics, oStyle, nIndex) {
var nOffsetY = nIndex * this.styleThumbnailHeightPt; var nOffsetY = nIndex * this.styleThumbnailHeightPt;
// Fill cell
var bg = oStyle.getFill(); var bg = oStyle.getFill();
if(null != bg) if(null != bg)
bg = bg.getRgb(); bg = bg.getRgb();
var oColor = bg !== null ? asc.numberToCSSColor(bg) : "#FFFFFF"; var oColor = bg !== null ? asc.numberToCSSColor(bg) : "#FFFFFF";
oGraphics.save().setFillStyle(oColor); oGraphics.save().beginPath().setFillStyle(oColor);
oGraphics.rect(0, nOffsetY, this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt); oGraphics.rect(0, nOffsetY, this.styleThumbnailWidthPt, this.styleThumbnailHeightPt).clip();
oGraphics.fill().clip(); oGraphics.fill();
var bc, bw;
/**
* cell border styles
* @const
*/
var kcbNone = "none";
var kcbThick = "thick";
var kcbThin = "thin";
var kcbMedium = "medium";
var kcbDashDot = "dashDot";
var kcbDashDotDot = "dashDotDot";
var kcbDashed = "dashed";
var kcbDotted = "dotted";
var kcbDouble = "double";
var kcbHair = "hair";
var kcbMediumDashDot = "mediumDashDot";
var kcbMediumDashDotDot = "mediumDashDotDot";
var kcbMediumDashed = "mediumDashed";
var kcbSlantDashDot = "slantDashDot";
var kcbThinBorders = [kcbThin, kcbDashDot, kcbDashDotDot, kcbDashed, kcbDotted, kcbHair];
var kcbMediumBorders = [kcbMedium, kcbMediumDashDot, kcbMediumDashDotDot, kcbMediumDashed, kcbSlantDashDot];
var kcbThickBorders = [kcbThick, kcbDouble];
var isThinBorder = function (bs) {
return $.inArray(bs, kcbThinBorders) >= 0;
};
var isMediumBorder = function (bs) {
return $.inArray(bs, kcbMediumBorders) >= 0;
};
var isThickBorder = function (bs) {
return $.inArray(bs, kcbThickBorders) >= 0;
};
var calcBorderWidth = function (b) {
var s = b.s;
return b == null ? 0 : (
isThinBorder(s) ? 1 : (
isMediumBorder(s) ? 2 : (
isThickBorder(s) ? 3 : 0)));
};
var drawBorder = function (b, x1, y1, x2, y2) {
if (null != b && "none" != b.s) {
bc = asc.numberToCSSColor(b.c.getRgb());
oGraphics.setStrokeStyle(bc);
bw = calcBorderWidth(b);
if (0 < bw) {
oGraphics.setLineWidth(bw).beginPath().moveTo(x1, y1).lineTo(x2, y2).stroke();
}
}
};
// borders
var oBorders = oStyle.getBorder();
drawBorder(oBorders.l, 0, nOffsetY,
0, nOffsetY + this.styleThumbnailHeightPt);
drawBorder(oBorders.r, this.styleThumbnailWidthPt, nOffsetY,
this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt);
drawBorder(oBorders.t, 0, nOffsetY,
this.styleThumbnailWidthPt, nOffsetY);
drawBorder(oBorders.t, 0, nOffsetY + this.styleThumbnailHeightPt,
this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt);
// Draw text
var fc = oStyle.getFontColor(); var fc = oStyle.getFontColor();
if(null != fc) if(null != fc)
fc = fc.getRgb(); fc = fc.getRgb();
...@@ -811,9 +872,6 @@ ...@@ -811,9 +872,6 @@
oGraphics.setFillStyle(oFontColor); oGraphics.setFillStyle(oFontColor);
oGraphics.fillText(oStyle.Name, 0, nOffsetY + this.styleThumbnailHeightPt / 2); oGraphics.fillText(oStyle.Name, 0, nOffsetY + this.styleThumbnailHeightPt / 2);
oGraphics.beginPath().setLineWidth(1).setStrokeStyle(oFontColor).moveTo(0, nOffsetY + this.styleThumbnailHeightPt);
oGraphics.lineTo(this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt).stroke();
oGraphics.restore(); oGraphics.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