Security update

This commit is contained in:
ONLYOFFICE
2014-07-22 18:10:05 +04:00
parent e0923e7aa4
commit 654bd6fbf9
10 changed files with 30 additions and 1668 deletions

View File

@@ -67,60 +67,7 @@ function ChartStyleManager() {
var bReady = false;
_this.colorMap = [];
_this.baseColors = [];
_this.init = function (options) {
_this.colorMap = [];
var api_doc = window["editor"];
var api_sheet = window["Asc"]["editor"];
var themeColors = [];
if (api_sheet) {
themeColors = api_sheet.GuiControlColorsMap;
} else {
themeColors = getDocColors(api_doc, options);
}
function getDocColors(api, options) {
var _theme = api.WordControl.m_oLogicDocument.theme;
var _clrMap = api.WordControl.m_oLogicDocument.clrSchemeMap ? api.WordControl.m_oLogicDocument.clrSchemeMap.color_map : undefined;
var arr_colors = new Array(10);
var rgba = {
R: 0,
G: 0,
B: 0,
A: 255
};
var array_colors_types = [6, 15, 7, 16, 0, 1, 2, 3, 4, 5];
var _count = array_colors_types.length;
var color = new CUniColor();
color.color = new CSchemeColor();
for (var i = 0; i < _count; ++i) {
color.color.id = array_colors_types[i];
if (!options) {
color.Calculate(_theme, _clrMap, rgba);
} else {
color.Calculate(options.theme, options.slide, options.layout, options.master, {
R: 0,
G: 0,
B: 0,
A: 255
});
}
var _rgba = color.RGBA;
arr_colors[i] = new CColor(_rgba.R, _rgba.G, _rgba.B);
}
return arr_colors;
}
_this.colorMap[1] = ["#555555", "#9E9E9E", "#727272", "#464646", "#838383", "#C1C1C1"];
_this.colorMap[2] = [themeColors[4].get_hex(), themeColors[5].get_hex(), themeColors[6].get_hex(), themeColors[7].get_hex(), themeColors[8].get_hex(), themeColors[9].get_hex()];
_this.colorMap[3] = [themeColors[4].get_hex()];
_this.colorMap[4] = [themeColors[5].get_hex()];
_this.colorMap[5] = [themeColors[6].get_hex()];
_this.colorMap[6] = [themeColors[7].get_hex()];
_this.colorMap[7] = [themeColors[8].get_hex()];
_this.colorMap[8] = [themeColors[9].get_hex()];
for (var i = 0; i < themeColors.length; i++) {
_this.baseColors.push(themeColors[i].get_hex());
}
bReady = true;
};
_this.init = function (options) {};
_this.isReady = function () {
return bReady;
};
@@ -162,263 +109,7 @@ function ChartPreviewManager() {
previewGroups[c_oAscChartType.scatter][c_oAscChartSubType.normal] = [];
previewGroups[c_oAscChartType.stock] = [];
previewGroups[c_oAscChartType.stock][c_oAscChartSubType.normal] = [];
_this.init = function (options) {
var startTime = new Date();
var api_doc = window["editor"];
var api_sheet = window["Asc"]["editor"];
var styleManager = api_doc ? api_doc.chartStyleManager : api_sheet.chartStyleManager;
var chartRender = new ChartRender(options);
var preview_w = 50,
preview_h = 50;
function createItem(value) {
return {
numFormatStr: "General",
isDateTimeFormat: false,
val: value,
isHidden: false
};
}
function fillChartData(chart) {
chart.data = [];
chart.series = [];
var uniColors = chart.generateUniColors(4);
switch (chart.type) {
case c_oAscChartType.line:
switch (chart.subType) {
case c_oAscChartSubType.normal:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(2), createItem(3), createItem(2), createItem(3)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(1), createItem(2), createItem(3), createItem(2)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
case c_oAscChartSubType.stacked:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(1), createItem(6), createItem(2), createItem(8)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(4), createItem(4), createItem(4), createItem(5)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
case c_oAscChartSubType.stackedPer:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(2), createItem(4), createItem(2), createItem(4)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(2), createItem(2), createItem(2), createItem(2)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
}
break;
case c_oAscChartType.hbar:
var uniColorsReverse = OfficeExcel.array_reverse(uniColors);
switch (chart.subType) {
case c_oAscChartSubType.normal:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(4)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(3)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(2)];
ser.OutlineColor = uniColors[2];
chart.series.push(ser);
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(1)];
ser.OutlineColor = uniColors[3];
chart.series.push(ser);
break;
case c_oAscChartSubType.stacked:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(4), createItem(3), createItem(2), createItem(1)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(5), createItem(4), createItem(3), createItem(2)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
case c_oAscChartSubType.stackedPer:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(7), createItem(5), createItem(3), createItem(1)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(7), createItem(6), createItem(5), createItem(4)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
}
break;
case c_oAscChartType.bar:
switch (chart.subType) {
case c_oAscChartSubType.normal:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(1)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(2)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(3)];
ser.OutlineColor = uniColors[2];
chart.series.push(ser);
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(4)];
ser.OutlineColor = uniColors[3];
chart.series.push(ser);
break;
case c_oAscChartSubType.stacked:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(1), createItem(2), createItem(3), createItem(4)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(2), createItem(3), createItem(4), createItem(5)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
case c_oAscChartSubType.stackedPer:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(1), createItem(3), createItem(5), createItem(7)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(4), createItem(5), createItem(6), createItem(7)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
}
break;
case c_oAscChartType.pie:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(3), createItem(1)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
break;
case c_oAscChartType.area:
switch (chart.subType) {
case c_oAscChartSubType.normal:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(0), createItem(8), createItem(5), createItem(6)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(0), createItem(4), createItem(2), createItem(9)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
case c_oAscChartSubType.stacked:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(0), createItem(8), createItem(5), createItem(11)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(4), createItem(4), createItem(4), createItem(4)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
case c_oAscChartSubType.stackedPer:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(0), createItem(4), createItem(1), createItem(16)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(4), createItem(4), createItem(4), createItem(4)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
}
break;
case c_oAscChartType.scatter:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(1), createItem(5)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(2), createItem(6)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
break;
default:
var ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(3), createItem(5), createItem(7)];
ser.OutlineColor = uniColors[0];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(10), createItem(12), createItem(14)];
ser.OutlineColor = uniColors[1];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(1), createItem(3), createItem(5)];
ser.OutlineColor = uniColors[2];
chart.series.push(ser);
ser = new asc_CChartSeria();
ser.Val.NumCache = [createItem(8), createItem(10), createItem(12)];
ser.OutlineColor = uniColors[3];
chart.series.push(ser);
break;
}
}
for (var chartType in previewGroups) {
var group = [];
var maxCol = 2,
maxRow = 2;
if (chartType == c_oAscChartType.stock) {
maxCol = 4;
maxRow = 3;
}
for (var style in styleManager.colorMap) {
var chart = new asc_CChart();
chart.range.interval = "Sheet1!A1:C3";
chart.xAxis.bShow = chart.xAxis.bGrid = false;
chart.yAxis.bShow = chart.yAxis.bGrid = false;
chart.legend.bShow = false;
chart.type = chartType;
chart.styleId = parseInt(style);
switch (chartType) {
case c_oAscChartType.line:
case c_oAscChartType.bar:
case c_oAscChartType.hbar:
case c_oAscChartType.area:
chart.subType = c_oAscChartSubType.normal;
fillChartData(chart);
var chartBase64 = chartRender.insertChart(chart, null, preview_w, preview_h, false, true).toDataURL();
previewGroups[chartType][c_oAscChartSubType.normal][style] = chartBase64;
chart.subType = c_oAscChartSubType.stacked;
fillChartData(chart);
var chartBase64 = chartRender.insertChart(chart, null, preview_w, preview_h, false, true).toDataURL();
previewGroups[chartType][c_oAscChartSubType.stacked][style] = chartBase64;
chart.subType = c_oAscChartSubType.stackedPer;
fillChartData(chart);
var chartBase64 = chartRender.insertChart(chart, null, preview_w, preview_h, false, true).toDataURL();
previewGroups[chartType][c_oAscChartSubType.stackedPer][style] = chartBase64;
break;
case c_oAscChartType.pie:
case c_oAscChartType.scatter:
case c_oAscChartType.stock:
chart.subType = c_oAscChartSubType.normal;
fillChartData(chart);
var chartBase64 = chartRender.insertChart(chart, null, preview_w, preview_h, false, true).toDataURL();
previewGroups[chartType][c_oAscChartSubType.normal][style] = chartBase64;
break;
}
}
}
bReady = true;
};
_this.init = function (options) {};
_this.isReady = function () {
return bReady;
};