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

delete chartStyleManager

delete c_oAscLegendMarkerType
delete OutlineColor
delete _generateColors, _generateColor, _generateColorPart
delete getLegendInfo, generateUniColors, getReverseSeries
delete _round_val, _array_exp, _array_reverse

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57074 954022d7-b5bf-4e40-9824-e11837661b57
parent 0a643cf2
This diff is collapsed.
......@@ -255,7 +255,6 @@ asc_CChart.prototype = {
ser.asc_setMarkerSize(object.series[i].Marker.Size);
ser.asc_setMarkerSymbol(object.series[i].Marker.Symbol);
}
ser.asc_setOutlineColor(object.series[i].OutlineColor);
ser.asc_setFormatCode(object.series[i].FormatCode);
this.series.push(ser);
......@@ -320,39 +319,7 @@ asc_CChart.prototype = {
asc_setSeria: function(seriaObj) { if (seriaObj) this.series.push(seriaObj); },
asc_removeSeries: function() { this.series = []; },
_generateColorPart: function (val, percent) {
// Negative outputs are shades, and positive outputs are tints.
if ( percent >= 0 )
return Math.min( 255, ((255 - val) * percent + val) >> 0 );
else
return Math.max( 0, (val * (1 + percent)) >> 0 );
},
_generateColor: function (oColor, percent) {
return new CColor(this._generateColorPart(oColor.r, percent),
this._generateColorPart(oColor.g, percent), this._generateColorPart(oColor.b, percent));
},
_generateColors: function (countColors, arrayBaseColors) {
var arrayColors = [];
var countBase = arrayBaseColors.length;
var needCreate = parseInt(countColors / countBase) + 1;
for (var i = 0; i < needCreate; i++) {
for (var j = 0; j < countBase; j++) {
// Для равномерного затухания: percent = i / needCreate
var percent = (-70 + 140 * ( (i + 1) / (needCreate + 1) )) / 100.0; // ECMA-376 Part 1
var color = this._generateColor(arrayBaseColors[j], percent);
arrayColors.push( color );
}
}
arrayColors.splice(countColors, arrayColors.length - countColors);
return arrayColors;
},
initDefault: function() {
// Обновлены тестовые данные для новой диаграммы
function createItem(value) {
return { numFormatStr: "General", isDateTimeFormat: false, val: value, isHidden: false };
......@@ -367,12 +334,10 @@ asc_CChart.prototype = {
this.yAxis.title = "Medals";
this.series = [];
var uniColors = this.generateUniColors(3);
var seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!B2:B7";
seria.Val.NumCache = [ createItem(46), createItem(38), createItem(24), createItem(29), createItem(11), createItem(7) ];
seria.OutlineColor = uniColors[0];
seria.TxCache.Formula = "Sheet1!B1";
seria.TxCache.Tx = "Gold";
if ( this.type != c_oAscChartType.scatter )
......@@ -384,7 +349,6 @@ asc_CChart.prototype = {
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!C2:C7";
seria.Val.NumCache = [ createItem(29), createItem(27), createItem(26), createItem(17), createItem(19), createItem(14) ];
seria.OutlineColor = uniColors[1];
seria.TxCache.Formula = "Sheet1!C1";
seria.TxCache.Tx = "Silver";
if ( this.type != c_oAscChartType.scatter )
......@@ -396,7 +360,6 @@ asc_CChart.prototype = {
seria = new asc_CChartSeria();
seria.Val.Formula = "Sheet1!D2:D7";
seria.Val.NumCache = [ createItem(29), createItem(23), createItem(32), createItem(19), createItem(14), createItem(17) ];
seria.OutlineColor = uniColors[2];
seria.TxCache.Formula = "Sheet1!D1";
seria.TxCache.Tx = "Bronze";
if ( this.type != c_oAscChartType.scatter )
......@@ -452,11 +415,7 @@ asc_CChart.prototype = {
var ws = _t.range.intervalObject.worksheet;
// Save old series colors
var i, oldSeriaData = [];
for (i = 0; !isIgnoreColors && (i < _t.series.length); ++i) {
if ( _t.series[i].OutlineColor && !_t.series[i].OutlineColor.isCustom )
oldSeriaData[i] = _t.series[i].OutlineColor;
}
var i;
_t.series = [];
function getNumCache(c1, c2, r1, r2) {
......@@ -639,114 +598,6 @@ asc_CChart.prototype = {
nameIndex++;
}
}
// Colors
var seriaUniColors = _t.generateUniColors(_t.series.length);
if ( _t.type == c_oAscChartType.hbar )
seriaUniColors = OfficeExcel.array_reverse(seriaUniColors);
// Restore old series colors
for (i = 0; i < _t.series.length; ++i) {
if ( oldSeriaData[i] )
_t.series[i].OutlineColor = oldSeriaData[i];
else
_t.series[i].OutlineColor = seriaUniColors[i];
}
},
getReverseSeries: function() {
var revSeries = [];
var serLen = this.series.length;
var i, j, aData = [];
for (j = 0; j < this.series.length; j++) {
aData.push(this.series[j].Val.NumCache.length);
aData.push(this.series[j].xVal.NumCache.length);
aData.push(this.series[j].Cat.NumCache.length);
}
var maxDataLen = Math.max.apply(Math, aData);
var emptyItem = { numFormatStr: "General", isDateTimeFormat: false, val: "", isHidden: false };
for (j = 0; j < this.series.length; j++) {
if ( this.series[j].Val.NumCache.length ) {
while ( this.series[j].Val.NumCache.length < maxDataLen )
this.series[j].Val.NumCache.push(emptyItem);
}
if ( this.series[j].xVal.NumCache.length ) {
while ( this.series[j].xVal.NumCache.length < maxDataLen )
this.series[j].xVal.NumCache.push(emptyItem);
}
if ( this.series[j].Cat.NumCache.length ) {
while ( this.series[j].Cat.NumCache.length < maxDataLen )
this.series[j].Cat.NumCache.push(emptyItem);
}
}
if ( serLen ) {
for (i = 0; i < this.series[0].Val.NumCache.length; i++) {
var seria = new asc_CChartSeria();
for (j = 0; j < this.series.length; j++) {
seria.Val.NumCache.push(this.series[j].Val.NumCache[i]);
if ( this.series[j].TxCache.Formula && this.series[j].TxCache.Tx )
seria.Cat.NumCache.push( {val: this.series[j].TxCache.Tx} );
if ( this.series[j].Cat.Formula && this.series[j].Cat.NumCache.length )
seria.TxCache.Tx = this.series[j].Cat.NumCache[i].val;
else
seria.TxCache.Tx = (i + 1);
}
revSeries.push(seria);
}
}
// Colors
var seriaUniColors = this.generateUniColors(revSeries.length);
for (i = 0; i < revSeries.length; i++) {
revSeries[i].OutlineColor = seriaUniColors[i];
}
return revSeries;
},
generateUniColors: function(count) {
var uniColors = [];
var api_doc = window["editor"];
var api_sheet = window["Asc"]["editor"];
var api = api_sheet ? api_sheet : api_doc;
if ( count > 0 ) {
if ( !api.chartStyleManager.isReady() )
api.chartStyleManager.init();
var baseColors = api.chartStyleManager.getBaseColors( parseInt(this.styleId) );
var colors = this._generateColors(count, baseColors);
for ( var i = 0; i < colors.length; i++ ) {
var uniColor = CreateUniColorRGB(colors[i].r, colors[i].g, colors[i].b);
uniColor.isCustom = true;
uniColors.push(uniColor);
}
}
return uniColors;
},
getLegendInfo: function() {
var aInfo = [];
function legendInfo() { return { text: null, color: null, marker: null } }
for ( var i = 0; i < this.series.length; i++ ) {
var info = new legendInfo();
info.text = this.series[i].asc_getTitle();
info.color = this.series[i].asc_getOutlineColor();
info.marker = c_oAscLegendMarkerType.Line;
aInfo.push(info);
}
return aInfo;
},
Get_Id: function() {
......@@ -1436,7 +1287,6 @@ function asc_CChartSeria() {
this.Cat = { Formula: "", NumCache: [] };
this.TxCache = { Formula: "", Tx: "" };
this.Marker = { Size: 0, Symbol: "" };
this.OutlineColor = null;
this.FormatCode = "";
this.isHidden = false;
this.bShowValue = false;
......@@ -1465,14 +1315,6 @@ asc_CChartSeria.prototype = {
asc_getMarkerSymbol: function() { return this.Marker.Symbol; },
asc_setMarkerSymbol: function(symbol) { this.Marker.Symbol = symbol; },
asc_getOutlineColor: function() { return this.OutlineColor; },
asc_setOutlineColor: function(color) {
if ( color instanceof CUniColor ) {
this.OutlineColor = color.createDuplicate();
this.OutlineColor.isCustom = color.isCustom;
}
},
asc_getFormatCode: function() { return this.FormatCode; },
asc_setFormatCode: function(format) { this.FormatCode = format; }
};
......@@ -1503,9 +1345,6 @@ prot["asc_setMarkerSize"] = prot.asc_setMarkerSize;
prot["asc_getMarkerSymbol"] = prot.asc_getMarkerSymbol;
prot["asc_setMarkerSymbol"] = prot.asc_setMarkerSymbol;
prot["asc_getOutlineColor"] = prot.asc_getOutlineColor;
prot["asc_setOutlineColor"] = prot.asc_setOutlineColor;
prot["asc_getFormatCode"] = prot.asc_getFormatCode;
prot["asc_setFormatCode"] = prot.asc_setFormatCode;
//}
......
"use strict";
function ChartStyleManager() {
var _this = this;
var bReady = false;
_this.colorMap = [];
_this.baseColors = [];
//-----------------------------------------------------------------------------------
// Methods
//-----------------------------------------------------------------------------------
_this.init = function(options) {
/** proprietary begin **/
_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};
// bg1,tx1,bg2,tx2,accent1 - accent6
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] = [ new CColor(85, 85, 85), new CColor(158, 158, 158), new CColor(114, 114, 114), new CColor(70, 70, 70), new CColor(131, 131, 131), new CColor(193, 193, 193) ];
_this.colorMap[2] = [ themeColors[4], themeColors[5], themeColors[6], themeColors[7], themeColors[8], themeColors[9] ];
_this.colorMap[3] = [ themeColors[4] ];
_this.colorMap[4] = [ themeColors[5] ];
_this.colorMap[5] = [ themeColors[6] ];
_this.colorMap[6] = [ themeColors[7] ];
_this.colorMap[7] = [ themeColors[8] ];
_this.colorMap[8] = [ themeColors[9] ];
for (var i = 0; i < themeColors.length; i++) {
_this.baseColors.push(themeColors[i]);
}
bReady = true;
/** proprietary end **/
}
_this.isReady = function() {
return bReady;
}
_this.getBaseColors = function(styleId) {
if ( styleId && (typeof(styleId) == 'number') ) {
if ( styleId % 8 === 0 )
return _this.colorMap[8];
else
return _this.colorMap[styleId % 8];
}
else
return _this.colorMap[2];
}
}
function ChartPreviewManager() {
var _this = this;
......
......@@ -109,8 +109,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Режим вставки диаграмм в редакторе документов
this.isChartEditor = false;
if(typeof ChartStyleManager !== "undefined")
this.chartStyleManager = new ChartStyleManager();
if(typeof ChartPreviewManager !== "undefined")
this.chartPreviewManager = new ChartPreviewManager();
......
......@@ -195,11 +195,6 @@ var c_oAscGraphicOption = {
ChangePosition : 4
};
var c_oAscLegendMarkerType = {
Line : 0,
Square : 1
};
var c_oAscHyperlinkType = {
WebLink : 1,
RangeLink : 2
......
......@@ -1876,12 +1876,6 @@ CGraphicObjects.prototype = {
History.TurnOff();
var ret = new CChartAsGroup();
ret.setAscChart(new asc_CChart());
var options = {};
options.slide = this.slide;
options.layout = this.slide.Layout;
options.master = this.slide.Layout.Master;
options.theme = this.slide.Layout.Master.Theme;
editor.chartStyleManager.init(options);
var presentation = editor.WordControl.m_oLogicDocument;
var chart_width = 0.264583*c_oAscChartDefines.defaultChartWidth;
......
......@@ -126,10 +126,6 @@ function asc_docs_api(name)
this.canSave = true; //Флаг нужен чтобы не происходило сохранение пока не завершится предыдущее сохранение
if(typeof ChartStyleManager !== "undefined")
this.chartStyleManager = new ChartStyleManager();
else
this.chartStyleManager = null;
if(typeof ChartPreviewManager !== "undefined")
this.chartPreviewManager = new ChartPreviewManager();
else
......@@ -671,15 +667,15 @@ asc_docs_api.prototype.sync_BeginCatchSelectedElements = function()
}
asc_docs_api.prototype.sync_EndCatchSelectedElements = function(options)
{
if ( this.chartStyleManager && this.chartPreviewManager && ( !this.chartStyleManager.isReady() ))
// ToDo chartStyleManager уже нет, когда будут правиться презентации - поправить!!!
if ( /*this.chartStyleManager && */ this.chartPreviewManager /*&& ( !this.chartStyleManager.isReady() )*/)
{
for ( var i = 0; i < this.SelectedObjectsStack.length; i++ )
{
if ( this.SelectedObjectsStack[i].Value.ChartProperties )
{
this.chartStyleManager.init(options);
this.chartPreviewManager.init(options); // ToDo этой функции уже нет, когда будут правиться презентации - поправить!!!
//this.chartStyleManager.init(options);
//this.chartPreviewManager.init(options); // ToDo этой функции уже нет, когда будут правиться презентации - поправить!!!
this.asc_fireCallback("asc_onUpdateChartStyles");
break;
}
......
......@@ -630,11 +630,7 @@ function asc_docs_api(name)
this.DocumentReaderMode = null;
this.isChartEditor = false;
if(typeof ChartStyleManager != "undefined")
this.chartStyleManager = new ChartStyleManager();
else
this.chartStyleManager = null;
if(typeof ChartPreviewManager != "undefined")
this.chartPreviewManager = new ChartPreviewManager();
else
......
......@@ -10,8 +10,7 @@
this.WordControl = new CEditorPage(this);
this.WordControl.m_oLogicDocument = new CDocument(this.WordControl.m_oDrawingDocument);
this.WordControl.m_oDrawingDocument.m_oLogicDocument = this.WordControl.m_oLogicDocument;
this.chartStyleManager = new ChartStyleManager();
this.chartPreviewManager = new ChartPreviewManager();
}
......
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