Commit 22b88576 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

При генерации превью-стилей смотрим на custom, если есть BuiltinId

Баг http://bugzserver/show_bug.cgi?id=26006

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57830 954022d7-b5bf-4e40-9824-e11837661b57
parent c57f3d11
......@@ -1371,6 +1371,15 @@ CCellStyles.prototype.getDefaultStyleNameByBuiltinId = function (oBuiltinId) {
}
return null;
};
CCellStyles.prototype.getCustomStyleByBuiltinId = function (oBuiltinId) {
var style = null;
for (var i = 0, length = this.CustomStyles.length; i < length; ++i) {
style = this.CustomStyles[i];
if (style.BuiltinId === oBuiltinId)
return style;
}
return null;
};
CCellStyles.prototype._prepareCellStyle = function (name) {
var defaultStyle = null;
var style = null;
......
......@@ -1271,14 +1271,17 @@
var oGraphics = new asc.DrawingContext({canvas: oCanvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics, font: oFont});
var oStyle = null;
var oStyle, oCustomStyle;
this.defaultStyles = [];
for (var i = 0, styleIndex = 0; i < nLength; ++i) {
oStyle = cellStyles[i];
if (oStyle.Hidden)
continue;
// ToDo Возможно стоит переписать немного, чтобы не пробегать каждый раз по массиву custom-стилей (нужно генерировать AllStyles)
oCustomStyle = cellStylesAll.getCustomStyleByBuiltinId(oStyle.BuiltinId);
this.defaultStyles[i] = new asc_CStyleImage(oStyle.Name, styleIndex, c_oAscStyleImage.Default);
this.drawStyle(oGraphics, stringRenderer, oStyle, styleIndex);
this.drawStyle(oGraphics, stringRenderer, oCustomStyle || oStyle, oStyle.Name, styleIndex);
++styleIndex;
}
......@@ -1297,20 +1300,20 @@
var oGraphics = new asc.DrawingContext({canvas: oCanvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics, font: oFont});
var oStyle = null;
var oStyle;
this.docStyles = [];
for (var i = 0, styleIndex = 0; i < nLength; ++i) {
oStyle = cellStyles[i];
if (oStyle.Hidden || null != oStyle.BuiltinId)
continue;
this.docStyles[styleIndex] = new asc_CStyleImage(oStyle.Name, styleIndex, c_oAscStyleImage.Document);
this.drawStyle(oGraphics, stringRenderer, oStyle, styleIndex);
this.drawStyle(oGraphics, stringRenderer, oStyle, oStyle.Name, styleIndex);
++styleIndex;
}
this.docStylesImage = (0 === styleIndex) ? "" : oCanvas.toDataURL("image/png");
},
drawStyle: function (oGraphics, stringRenderer, oStyle, nIndex) {
drawStyle: function (oGraphics, stringRenderer, oStyle, sStyleName, nIndex) {
var nOffsetY = nIndex * this.styleThumbnailHeightPt;
// Fill cell
......@@ -1347,12 +1350,12 @@
var width_padding = 3; // 4 * 72 / 96
var tm = stringRenderer.measureString(oStyle.Name);
var tm = stringRenderer.measureString(sStyleName);
// Текст будем рисовать по центру (в Excel чуть по другому реализовано, у них постоянный отступ снизу)
var textY = 0.5 * (nOffsetY + (nOffsetY + this.styleThumbnailHeightPt) - tm.height);
oGraphics.setFont(oFont);
oGraphics.setFillStyle(oFontColor);
oGraphics.fillText(oStyle.Name, width_padding, textY + tm.baseline);
oGraphics.fillText(sStyleName, width_padding, textY + tm.baseline);
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