Commit 3209f8a5 authored by Alexander.Trofimov's avatar Alexander.Trofimov

Добавил у DrawingContext метод setCanvas

Добавил у WorksheetView метод getDrawingContextCharts
Добавил у WorkbookView объект в класс drawingCtxCharts (для отрисовки chart объектов)
Добавил у WorksheetView тригер (getDCForCharts) на получение из WorkbookView drawingCtxCharts
Поправил отрисовку текста chart-ов (она теперь через drawingCtxCharts)
Добавил изменение zoom для chart-ов

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47403 954022d7-b5bf-4e40-9824-e11837661b57
parent abe9b176
...@@ -2030,5 +2030,8 @@ function setFontChart(chart) ...@@ -2030,5 +2030,8 @@ function setFontChart(chart)
bar._otherProps._text_underline = false; bar._otherProps._text_underline = false;
bar._otherProps._text_font = defaultFont; bar._otherProps._text_font = defaultFont;
bar._otherProps._text_size = defaultSize; bar._otherProps._text_size = defaultSize;
} }
if (chart.worksheet)//выставление контекста для отрисовки
bar.drawingCtxCharts = chart.worksheet.getDrawingContextCharts();
} }
if (typeof(OfficeExcel) == 'undefined') OfficeExcel = {isOfficeExcel:true,type:'common'};  if (typeof(OfficeExcel) == 'undefined') OfficeExcel = {isOfficeExcel:true,type:'common'};
OfficeExcel.Registry = {}; OfficeExcel.Registry = {};
OfficeExcel.Registry.store = []; OfficeExcel.Registry.store = [];
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
var newMin = min; var newMin = min;
var newMax = max; var newMax = max;
// //находим максимум после преобразования
if('bar' != mainObj.type) if('bar' != mainObj.type)
{ {
if(typeof(arrNew[0]) == 'object') if(typeof(arrNew[0]) == 'object')
...@@ -117,21 +117,21 @@ ...@@ -117,21 +117,21 @@
} }
var massRes = []; var massRes = [];
// //шаг нужно высчитывать
var step = 10; var step = 10;
if(((newMax - newMin)/10) > 11 ) if(((newMax - newMin)/10) > 11 )
step = 20; step = 20;
if('bar' == mainObj.type && max > 0 && min < 0) if('bar' == mainObj.type && max > 0 && min < 0)
step = 20; step = 20;
var maxValue = 100; var maxValue = 100;
// //находим максимум
for (var i=0; i < 11; i++) { for (var i=0; i < 11; i++) {
if(newMax < 100 - step*i && newMax > 100 - step*(i+1)) if(newMax < 100 - step*i && newMax > 100 - step*(i+1))
maxValue = 100 - step*i; maxValue = 100 - step*i;
} }
if(maxValue > 100) if(maxValue > 100)
maxValue = 100; maxValue = 100;
// //получаем массив
if(max <= 0 && min < 0) if(max <= 0 && min < 0)
{ {
if('bar' == mainObj.type) if('bar' == mainObj.type)
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
var max1; var max1;
var arr = []; var arr = [];
// //находим минимальное значение
var min; var min;
var trueOX = false; var trueOX = false;
if('hbar' == mainObj.type) if('hbar' == mainObj.type)
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
} }
if('scatter' == mainObj.type) if('scatter' == mainObj.type)
{ {
// OX(max == true) //в этом случае определяем значения для оси OX(max == true)
if(mainObj._otherProps._type == 'burse2') if(mainObj._otherProps._type == 'burse2')
{ {
var arrTemp = [] var arrTemp = []
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
return [0.2,0.4,0.6,0.8,1,1.2]; return [0.2,0.4,0.6,0.8,1,1.2];
} }
// //подготовительная работы для дальнейшего вычисления шага
if(max >= 0 && min >= 0) if(max >= 0 && min >= 0)
{ {
if(max == min) if(max == min)
...@@ -436,7 +436,7 @@ ...@@ -436,7 +436,7 @@
// //приводим к первому порядку для дальнейших вычислений
var secPart = max.toString().split('.'); var secPart = max.toString().split('.');
var numPow = 1; var numPow = 1;
if(0 != secPart[0]) if(0 != secPart[0])
...@@ -479,7 +479,7 @@ ...@@ -479,7 +479,7 @@
} }
// //поиск шага
if(undefined != greaterNull) if(undefined != greaterNull)
{ {
var greaterNullTemp = greaterNull.toString().split('.'); var greaterNullTemp = greaterNull.toString().split('.');
...@@ -517,11 +517,11 @@ ...@@ -517,11 +517,11 @@
} }
arr[0] = 0;arr[1] = 1;arr[2] = 2;arr[3] = 5;arr[4] = 10; arr[0] = 0;arr[1] = 1;arr[2] = 2;arr[3] = 5;arr[4] = 10;
// , OY //если максимальное значение больше числа из данного массива, меняем диапазон по оси OY
var arrMaxVal = [0,0.952380952,1.904761904,4.76190476,9.523809523] var arrMaxVal = [0,0.952380952,1.904761904,4.76190476,9.523809523]
// //массив диапазонов
var arrDiffVal1 = [0,0.2,0.5,1,2] var arrDiffVal1 = [0,0.2,0.5,1,2]
if(axisXMin == 0 && undefined == greaterNull)// min max , if(axisXMin == 0 && undefined == greaterNull)//если разница между min и max такая, что не нужно масштабировать
{ {
for (var i=0; i<arr.length; i++) { for (var i=0; i<arr.length; i++) {
if( max >= arr[i] && max <= arr[i+1]) if( max >= arr[i] && max <= arr[i+1])
...@@ -531,7 +531,7 @@ ...@@ -531,7 +531,7 @@
var diff = max1/10; var diff = max1/10;
var trueDiff = diff; var trueDiff = diff;
var maxVal; var maxVal;
// //проверяем есть ли переход в следующий диапазон
if(max > arrMaxVal[i+1]) if(max > arrMaxVal[i+1])
{ {
trueDiff = arrDiffVal1[i+1] trueDiff = arrDiffVal1[i+1]
...@@ -559,7 +559,7 @@ ...@@ -559,7 +559,7 @@
} }
} }
// min max //находим истинные min и max
var testDiff; var testDiff;
var axisXMinTest; var axisXMinTest;
if(axisXMin == 0) if(axisXMin == 0)
...@@ -599,7 +599,7 @@ ...@@ -599,7 +599,7 @@
// //возвращаем массив
var varMin = axisXMinTest*numPowOY; var varMin = axisXMinTest*numPowOY;
var massRes = []; var massRes = [];
var tempKoff = 100000000000; var tempKoff = 100000000000;
...@@ -765,14 +765,14 @@ ...@@ -765,14 +765,14 @@
{ {
var max1; var max1;
var arr = []; var arr = [];
// //находим минимальное значение
var min; var min;
var max; var max;
if('bar' == mainObj.type || 'hbar' == mainObj.type || 'radar' == mainObj.type) if('bar' == mainObj.type || 'hbar' == mainObj.type || 'radar' == mainObj.type)
{ {
if(mainObj._otherProps._type == 'accumulative') if(mainObj._otherProps._type == 'accumulative')
{ {
// //суммируем отрицательные и положительные значения
if(typeof(mainObj.data[0]) == 'object') if(typeof(mainObj.data[0]) == 'object')
{ {
var arrMin = []; var arrMin = [];
...@@ -932,7 +932,7 @@ ...@@ -932,7 +932,7 @@
// //приведение к первому порядку для дальнейших вычислений
var secPart = max.toString().split('.'); var secPart = max.toString().split('.');
var numPow = 1; var numPow = 1;
if(0 != secPart[0]) if(0 != secPart[0])
...@@ -977,7 +977,7 @@ ...@@ -977,7 +977,7 @@
} }
// //поиск шага
if(undefined != greaterNull) if(undefined != greaterNull)
{ {
var greaterNullTemp = greaterNull.toString().split('.'); var greaterNullTemp = greaterNull.toString().split('.');
...@@ -1010,11 +1010,11 @@ ...@@ -1010,11 +1010,11 @@
} }
arr[0] = 0;arr[1] = 1;arr[2] = 2;arr[3] = 5;arr[4] = 10; arr[0] = 0;arr[1] = 1;arr[2] = 2;arr[3] = 5;arr[4] = 10;
// , OY //если максимальное значение больше числа из данного массива, меняем диапазон по оси OY
var arrMaxVal = [0,0.952380952,1.904761904,4.76190476,9.523809523] var arrMaxVal = [0,0.952380952,1.904761904,4.76190476,9.523809523]
// //массив диапазонов
var arrDiffVal1 = [0,0.2,0.5,1,2] var arrDiffVal1 = [0,0.2,0.5,1,2]
if(axisXMin == 0)// min max , if(axisXMin == 0)//если разница между min и max такая, что не нужно масштабировать
{ {
for (var i=0; i<arr.length; i++) { for (var i=0; i<arr.length; i++) {
if( max >= arr[i] && max <= arr[i+1]) if( max >= arr[i] && max <= arr[i+1])
...@@ -1024,7 +1024,7 @@ ...@@ -1024,7 +1024,7 @@
var diff = max1/10; var diff = max1/10;
var trueDiff = diff; var trueDiff = diff;
var maxVal; var maxVal;
// //проверяем есть ли переход в следующий диапазон
if(max > arrMaxVal[i+1]) if(max > arrMaxVal[i+1])
{ {
trueDiff = arrDiffVal1[i+1] trueDiff = arrDiffVal1[i+1]
...@@ -1038,7 +1038,7 @@ ...@@ -1038,7 +1038,7 @@
// min max //находим истинные min и max
var testDiff; var testDiff;
var axisXMinTest; var axisXMinTest;
if(axisXMin == 0) if(axisXMin == 0)
...@@ -1106,7 +1106,7 @@ ...@@ -1106,7 +1106,7 @@
// //возвращаем массив
var varMin = axisXMinTest*numPowOY; var varMin = axisXMinTest*numPowOY;
var massRes = []; var massRes = [];
...@@ -1496,44 +1496,13 @@ ...@@ -1496,44 +1496,13 @@
* @param bool Whether the text is bold or not * @param bool Whether the text is bold or not
* @param bool Whether the bounding box has a placement indicator * @param bool Whether the bounding box has a placement indicator
*/ */
OfficeExcel.getFmgrGraphics = function()
{
if(!this.fmgrGraphics)
{
if(!OfficeExcel.fontManager)
OfficeExcel.fontManager = new CFontManager();
this.fmgrGraphics = [];
this.fmgrGraphics.push(OfficeExcel.fontManager);
this.fmgrGraphics.push(OfficeExcel.fontManager);
this.fmgrGraphics[0].Initialize(true);
this.fmgrGraphics[1].Initialize(true);
}
}
OfficeExcel.getDrwContext = function(canvas)
{
if(!this.fmgrGraphics && Asc.DrawingContext)
{
this.getFmgrGraphics();
this.drwContext = Asc.DrawingContext({canvas: canvas, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics});
}
else if(!this.drwContext && Asc.DrawingContext)
this.drwContext = Asc.DrawingContext({canvas: canvas, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics});
else if(Asc.DrawingContext)// canvas(setCanvas)
this.drwContext = Asc.DrawingContext({canvas: canvas, units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics});
else
return false;
return this.drwContext;
}
OfficeExcel.Text = function (context, font, size, x, y, text) OfficeExcel.Text = function (context, font, size, x, y, text)
{ {
var drwContext = OfficeExcel.getDrwContext(bar.canvas); var drwContext = bar.drawingCtxCharts;
if(drwContext) if(drwContext)
{ {
drwContext.setCanvas(bar.canvas);
context = drwContext; context = drwContext;
// Need these now the angle can be specified, ie defaults for the former two args // Need these now the angle can be specified, ie defaults for the former two args
if (typeof(arguments[6]) == null) arguments[6] = 'bottom'; // Vertical alignment. Default to bottom/baseline if (typeof(arguments[6]) == null) arguments[6] = 'bottom'; // Vertical alignment. Default to bottom/baseline
......
...@@ -501,13 +501,8 @@ function DrawingContext(settings) { ...@@ -501,13 +501,8 @@ function DrawingContext(settings) {
return new DrawingContext(settings); return new DrawingContext(settings);
} }
var c = settings !== undefined && settings.canvas !== undefined ? settings.canvas : null; if (undefined !== settings)
if (c === null) {return null;} this.setCanvas(settings.canvas);
this.canvas = $(c);
this.ctx = c.getContext("2d");
if (this.ctx.mozImageSmoothingEnabled) {
this.ctx.mozImageSmoothingEnabled = false;
}
var ppiTest = var ppiTest =
$('<div style="position: absolute; width: 10in; height:10in; visibility:hidden; padding:0;"/>') $('<div style="position: absolute; width: 10in; height:10in; visibility:hidden; padding:0;"/>')
...@@ -573,6 +568,20 @@ DrawingContext.prototype = { ...@@ -573,6 +568,20 @@ DrawingContext.prototype = {
return this.canvas[0]; return this.canvas[0];
}, },
/**
*
* @param canvas
*/
setCanvas: function (canvas) {
var c = canvas !== undefined ? canvas : null;
if (c === null) {return;}
this.canvas = $(c);
this.ctx = c.getContext("2d");
if (this.ctx.mozImageSmoothingEnabled) {
this.ctx.mozImageSmoothingEnabled = false;
}
},
/** /**
* Returns pixels per inch ratio * Returns pixels per inch ratio
* @type {Number} * @type {Number}
......
...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
this.drawingCtx = undefined; this.drawingCtx = undefined;
this.overlayCtx = undefined; this.overlayCtx = undefined;
this.stringRender = undefined; this.stringRender = undefined;
this.drawingCtxCharts = undefined;
this.emSize = 0; this.emSize = 0;
this.defaultFont = new asc_FP(this.model.getDefaultFont(), this.model.getDefaultSize()); this.defaultFont = new asc_FP(this.model.getDefaultFont(), this.model.getDefaultSize());
...@@ -129,6 +130,8 @@ ...@@ -129,6 +130,8 @@
this.drawingCtx = this.buffers.main; this.drawingCtx = this.buffers.main;
this.overlayCtx = this.buffers.overlay; this.overlayCtx = this.buffers.overlay;
this.drawingCtxCharts = asc_DC({units: 1/*pt*/, fmgrGraphics: this.fmgrGraphics});
this.stringRender = asc_SR(this.buffers.main); this.stringRender = asc_SR(this.buffers.main);
this.stringRender.setDefaultFont(this.defaultFont); this.stringRender.setDefaultFont(this.defaultFont);
...@@ -326,7 +329,8 @@ ...@@ -326,7 +329,8 @@
"slowOperation" : function (isStart) {self.handlers.trigger((isStart ? "asc_onStartAction" : "asc_onEndAction"), c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.SlowOperation);}, "slowOperation" : function (isStart) {self.handlers.trigger((isStart ? "asc_onStartAction" : "asc_onEndAction"), c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.SlowOperation);},
"setFocusDrawingObject" : function (isFocusDrawingObject) { self.controller.setFocusDrawingObject(isFocusDrawingObject); }, "setFocusDrawingObject" : function (isFocusDrawingObject) { self.controller.setFocusDrawingObject(isFocusDrawingObject); },
"setAutoFiltersDialog" : function (arrVal) {self.handlers.trigger("asc_onSetAFDialog", arrVal);}, "setAutoFiltersDialog" : function (arrVal) {self.handlers.trigger("asc_onSetAFDialog", arrVal);},
"selectionRangeChanged" : function (val) {self.handlers.trigger("asc_onSelectionRangeChanged", val);} "selectionRangeChanged" : function (val) {self.handlers.trigger("asc_onSelectionRangeChanged", val);},
"getDCForCharts" : function () { return self.drawingCtxCharts; }
}); });
return new asc_WSV(wsModel, this.buffers, this.stringRender, this.emSize, this.collaborativeEditing, opt); return new asc_WSV(wsModel, this.buffers, this.stringRender, this.emSize, this.collaborativeEditing, opt);
}, },
...@@ -998,6 +1002,8 @@ ...@@ -998,6 +1002,8 @@
this.buffers.main.changeZoom(factor); this.buffers.main.changeZoom(factor);
this.buffers.overlay.changeZoom(factor); this.buffers.overlay.changeZoom(factor);
this.drawingCtxCharts.changeZoom(factor);
var item; var item;
var activeIndex = this.model.getActive(); var activeIndex = this.model.getActive();
for(var i in this.wsViews) { for(var i in this.wsViews) {
......
...@@ -1024,6 +1024,11 @@ ...@@ -1024,6 +1024,11 @@
} }
}, },
// ToDo переделать на полную отрисовку на нашем контексте
getDrawingContextCharts: function () {
return this._trigger("getDCForCharts");
},
// ----- Initialization ----- // ----- Initialization -----
......
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