Commit 9f321333 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил генерацию guiStyles

Добавил загрузку шрифтов из стилей
Добавил классы для отрисовки стилей и отдачи из контрола

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47857 954022d7-b5bf-4e40-9824-e11837661b57
parent 8413badd
......@@ -1023,9 +1023,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.asyncMethodCallback();
this.asyncMethodCallback = undefined;
} else {
this.asc_CheckGuiControlColors();
this.asc_SendThemeColorScheme();
this.asc_ApplyColorScheme(false);
// Шрифты загрузились, возможно стоит подождать совместное редактирование
this.FontLoadWaitComplete = true;
if (this.ServerIdWaitComplete)
......@@ -1427,6 +1424,11 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this._applyFirstLoadChanges();
// Меняем тип состояния (на никакое)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
this.asc_CheckGuiControlColors();
this.asc_SendThemeColorScheme();
this.asc_ApplyColorScheme(false);
//this.asc_Resize(); // Убрал, т.к. сверху приходит resize (http://bugzserver/show_bug.cgi?id=14680)
if( this.wbModel.startActionOn == false ){
this.wbModel.startActionOn = true;
......@@ -2385,15 +2387,16 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
asc_ApplyColorScheme : function(bRedraw) {
this.chartStyleManager.init();
this.chartPreviewManager.init();
var asc_AF = asc.AutoFilters;
var autoFilters = new asc_AF();
var autoFilters = new asc.AutoFilters();
var tablePictures = autoFilters.getTablePictures(this.wbModel);
var bResult = this.handlers.trigger("asc_onInitTablePictures", tablePictures);
if (false === bResult)
this.tablePictures = tablePictures;
else
this.tablePictures = null;
this.tablePictures = (false === bResult) ? tablePictures : null;
// Отправка стилей ячеек
var guiStyles = this.wb.getCellStyles();
bResult = this.handlers.trigger("asc_onInitEditorStyles", guiStyles);
this.guiStyles = (false === bResult) ? guiStyles : null;
if (bRedraw) {
var ws = this.wb.getWorksheet();
......
......@@ -316,6 +316,11 @@ var c_oAscFontRenderingModeType = {
hinting : 2,
hintingAndSubpixeling : 3
};
var c_oAscStyleImage = {
Default : 0,
Document : 1
};
var c_oAscCoAuthoringMeBorderColor = "rgba(22,156,0,1)";
var c_oAscCoAuthoringOtherBorderColor = "rgba(238,53,37,1)";
......
......@@ -1878,6 +1878,7 @@ Workbook.prototype.generateFontMap=function(){
for(var i = 0, length = this.aWorksheets.length; i < length; ++i)
this.aWorksheets[i].generateFontMap(oFontMap);
this.CellStyles.generateFontMap(oFontMap);
var aRes = new Array();
for(var i in oFontMap)
......
......@@ -1217,6 +1217,20 @@ function CCellStyles() {
this.DefaultStyles = [];
this.AllStyles = {};
}
CCellStyles.prototype = {
generateFontMap: function (oFontMap) {
this._generateFontMap(oFontMap, this.DefaultStyles);
this._generateFontMap(oFontMap, this.CustomStyles);
},
_generateFontMap: function (oFontMap, aStyles) {
var i, length, oStyle;
for (i = 0, length = aStyles.length; i < length; ++i) {
oStyle = aStyles[i];
if (null != oStyle.xfs && null != oStyle.xfs.font && null != oStyle.xfs.font.fn)
oFontMap[oStyle.xfs.font.fn] = 1;
}
}
};
/** @constructor */
function CCellStyle() {
this.BuiltinId = null;
......@@ -1228,6 +1242,25 @@ function CCellStyle() {
this.xfs = null;
}
CCellStyle.prototype = {
getFill: function () {
if (null != this.xfs && null != this.xfs.fill)
return this.xfs.fill.bg;
return g_oDefaultFill.bg;
},
getFontColor: function () {
if (null != this.xfs && null != this.xfs.font)
return this.xfs.font.c;
return g_oDefaultFont.c;
},
getFont: function () {
if (null != this.xfs && null != this.xfs.font)
return this.xfs.font;
return null;
}
};
/** @constructor */
function StyleManager(){
//содержат все свойства по умолчанию
......
......@@ -696,6 +696,101 @@
this.bIsReInit = false;
}
/** @constructor */
function asc_CStyleImage(name, thumbnailOffset, type) {
this.name = name;
this.thumbnailOffset = thumbnailOffset;
this.type = type;
}
asc_CStyleImage.prototype = {
constructor: asc_CStyleImage,
asc_getName: function () { return this.name; },
asc_getThumbnailOffset: function () { return this.thumbnailOffset; },
asc_getType: function () { return this.type; }
};
/** @constructor */
function asc_CStylesPainter() {
// base64 defaultStyles image
this.defaultStylesImage = "";
this.defaultStyles = null;
// base64 docStyles image
this.docStylesImage = "";
this.docStyles = null;
this.styleThumbnailWidth = 100;
this.styleThumbnailHeight = 22;
this.styleThumbnailWidthPt = this.styleThumbnailWidth * 72 / 96;
this.styleThumbnailHeightPt = this.styleThumbnailHeight * 72 / 96;
}
asc_CStylesPainter.prototype = {
constructor: asc_CStylesPainter,
asc_getStyleThumbnailWidth: function () { return this.styleThumbnailWidth; },
asc_getStyleThumbnailHeight: function () { return this.styleThumbnailHeight; },
asc_getDefaultStylesImage: function () { return this.defaultStylesImage; },
asc_getDocStylesImage: function () { return this.docStylesImage; },
generateStylesAll: function (cellStylesAll, fmgrGraphics) {
this.generateStyles(cellStylesAll.DefaultStyles, fmgrGraphics);
},
generateStyles: function (cellStyles, fmgrGraphics) {
var nStylesCount = cellStyles.length;
var oCanvas = document.createElement('canvas');
oCanvas.width = this.styleThumbnailWidth;
oCanvas.height = nStylesCount * this.styleThumbnailHeight;
var ctx = oCanvas.getContext('2d');
ctx.fillStyle = "#FFFFFF";
ctx.fillRect(0, 0, oCanvas.width, oCanvas.height);
var oGraphics = asc.DrawingContext({canvas: oCanvas, units: 1/*pt*/, fmgrGraphics: fmgrGraphics});
var oStyle = null;
this.defaultStyles = [];
for (var i = 0; i < nStylesCount; ++i) {
oStyle = cellStyles[i];
this.defaultStyles[i] = new asc_CStyleImage(oStyle.Name, i, c_oAscStyleImage.Default);
this.drawStyle(oGraphics, oStyle, i);
}
this.defaultStylesImage = oCanvas.toDataURL("image/png");
var test = document.createElement('img');
test.src = this.defaultStylesImage;
document.body.appendChild(test);
},
generateDocumentStyles: function () {
},
drawStyle: function (oGraphics, oStyle, nIndex) {
var nOffsetY = nIndex * this.styleThumbnailHeightPt;
var bg = oStyle.getFill();
if(null != bg)
bg = bg.getRgb();
var oColor = bg !== null ? asc.numberToCSSColor(bg) : "#FFFFFF";
oGraphics.save().setFillStyle(oColor);
oGraphics.rect(0, nOffsetY, this.styleThumbnailWidthPt, nOffsetY + this.styleThumbnailHeightPt);
oGraphics.fill().clip();
var fc = oStyle.getFontColor();
if(null != fc)
fc = fc.getRgb();
var oFontColor = fc !== null ? asc.numberToCSSColor(fc) : "#000000";
var format = oStyle.getFont();
var oFont = new asc.FontProperties(format.fn, format.fs, format.b, format.i, format.u, format.s);
oGraphics.setFont(oFont);
oGraphics.setFillStyle(oFontColor);
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();
}
};
/*
* Export
......@@ -819,5 +914,18 @@
prot["asc_setShowGridLines"] = prot.asc_setShowGridLines;
prot["asc_setShowRowColHeaders"] = prot.asc_setShowRowColHeaders;
}
window["Asc"]["asc_CStyleImage"] = window["Asc"].asc_CStyleImage = asc_CStyleImage;
prot = asc_CStyleImage.prototype;
prot["asc_getName"] = prot.asc_getName;
prot["asc_getThumbnailOffset"] = prot.asc_getThumbnailOffset;
prot["asc_getType"] = prot.asc_getType;
window["Asc"]["asc_CStylesPainter"] = window["Asc"].asc_CStylesPainter = asc_CStylesPainter;
prot = asc_CStylesPainter.prototype;
prot["asc_getStyleThumbnailWidth"] = prot.asc_getStyleThumbnailWidth;
prot["asc_getStyleThumbnailHeight"] = prot.asc_getStyleThumbnailHeight;
prot["asc_getDefaultStylesImage"] = prot.asc_getDefaultStylesImage;
prot["asc_getDocStylesImage"] = prot.asc_getDocStylesImage;
}
)(jQuery, window);
......@@ -27,6 +27,7 @@
var asc_DC = asc.DrawingContext;
var asc_SR = asc.StringRender;
var asc_getcvt = asc.getCvtRatio;
var asc_CSP = asc.asc_CStylesPainter;
/**
......@@ -906,6 +907,11 @@
}
},
getCellStyles: function () {
var oStylesPainter = new asc_CSP();
oStylesPainter.generateStylesAll(this.model.CellStyles, this.fmgrGraphics);
},
getWorksheetById: function (id) {
var wsModel = this.model.getWorksheetById(id);
if (wsModel)
......
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