Commit 3d0912d6 authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

Исправлена проблема с отрисовкой объектов при первом открытии таблицы

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47286 954022d7-b5bf-4e40-9824-e11837661b57
parent 46e41827
......@@ -5,22 +5,22 @@
* Date: 13/08/2012
*/
//-----------------------------------------------------------------------------------
// Chart interface
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
// Global drawing pointers
//-----------------------------------------------------------------------------------
var DrawingObject = null;
var DrawingObjectLayer = null;
// Global drawing pointers
var DrawingObject = null;
var DrawingObjectLayer = null;
if ( !window["Asc"] ) { // Для вставки диаграмм в Word
if ( !window["Asc"] ) { // Для вставки диаграмм в Word
window["Asc"] = {};
}
}
function isObject(what) {
function isObject(what) {
return ( what && (typeof(what) == "object") );
}
}
function convertFormula(formula, ws) {
function convertFormula(formula, ws) {
var range = null;
if (formula && ws) {
......@@ -37,10 +37,13 @@
}
}
return range;
}
}
// Интерфейс < Excel - Word >
function CChartData(bWordContext, chart) {
//-----------------------------------------------------------------------------------
// Интерфейс < Excel - Word >
//-----------------------------------------------------------------------------------
function CChartData(bWordContext, chart) {
var _this = this;
......@@ -467,32 +470,42 @@
if ( bWordContext )
g_oTableId.Add( _this, _this.Id );
}
}
//-----------------------------------------------------------------------------------
// Chart style
//-----------------------------------------------------------------------------------
function asc_CChartStyle() {
function asc_CChartStyle() {
this.style = null;
this.imageUrl = null;
}
}
asc_CChartStyle.prototype = {
asc_CChartStyle.prototype = {
asc_getStyle: function() { return this.style; },
asc_setStyle: function(style) { this.style = style; },
asc_getImageUrl: function() { return this.imageUrl; },
asc_setImageUrl: function(imageUrl) { this.imageUrl = imageUrl; }
}
}
window["Asc"].asc_CChartStyle = asc_CChartStyle;
window["Asc"]["asc_CChartStyle"] = asc_CChartStyle;
prot = asc_CChartStyle.prototype;
//{ asc_CChartStyle export
window["Asc"].asc_CChartStyle = asc_CChartStyle;
window["Asc"]["asc_CChartStyle"] = asc_CChartStyle;
prot = asc_CChartStyle.prototype;
prot["asc_getStyle"] = prot.asc_getStyle;
prot["asc_setStyle"] = prot.asc_setStyle;
prot["asc_getStyle"] = prot.asc_getStyle;
prot["asc_setStyle"] = prot.asc_setStyle;
prot["asc_getImageUrl"] = prot.asc_getImageUrl;
prot["asc_setImageUrl"] = prot.asc_setImageUrl;
prot["asc_getImageUrl"] = prot.asc_getImageUrl;
prot["asc_setImageUrl"] = prot.asc_setImageUrl;
//}
function asc_CChart(object) {
//-----------------------------------------------------------------------------------
// Chart
//-----------------------------------------------------------------------------------
function asc_CChart(object) {
var bCopy = isObject(object);
......@@ -546,9 +559,9 @@
legend: 10,
series: 11
};
}
}
asc_CChart.prototype = {
asc_CChart.prototype = {
asc_getType: function() { return this.type; },
asc_setType: function(type) { this.type = type; },
......@@ -676,51 +689,56 @@
case this.Properties.series: this.series = value; break;
}
}
}
}
//{ asc_CChart export
window["Asc"].asc_CChart = asc_CChart;
window["Asc"]["asc_CChart"] = asc_CChart;
prot = asc_CChart.prototype;
window["Asc"].asc_CChart = asc_CChart;
window["Asc"]["asc_CChart"] = asc_CChart;
prot = asc_CChart.prototype;
prot["asc_getType"] = prot.asc_getType;
prot["asc_setType"] = prot.asc_setType;
prot["asc_getType"] = prot.asc_getType;
prot["asc_setType"] = prot.asc_setType;
prot["asc_getSubType"] = prot.asc_getSubType;
prot["asc_setSubType"] = prot.asc_setSubType;
prot["asc_getSubType"] = prot.asc_getSubType;
prot["asc_setSubType"] = prot.asc_setSubType;
prot["asc_getStyleId"] = prot.asc_getStyleId;
prot["asc_setStyleId"] = prot.asc_setStyleId;
prot["asc_getStyleId"] = prot.asc_getStyleId;
prot["asc_setStyleId"] = prot.asc_setStyleId;
prot["asc_getShowValueFlag"] = prot.asc_getShowValueFlag;
prot["asc_setShowValueFlag"] = prot.asc_setShowValueFlag;
prot["asc_getShowValueFlag"] = prot.asc_getShowValueFlag;
prot["asc_setShowValueFlag"] = prot.asc_setShowValueFlag;
prot["asc_getShowBorderFlag"] = prot.asc_getShowBorderFlag;
prot["asc_setShowBorderFlag"] = prot.asc_setShowBorderFlag;
prot["asc_getShowBorderFlag"] = prot.asc_getShowBorderFlag;
prot["asc_setShowBorderFlag"] = prot.asc_setShowBorderFlag;
prot["asc_getHeader"] = prot.asc_getHeader;
prot["asc_setHeader"] = prot.asc_setHeader;
prot["asc_getHeader"] = prot.asc_getHeader;
prot["asc_setHeader"] = prot.asc_setHeader;
prot["asc_getRange"] = prot.asc_getRange;
prot["asc_setRange"] = prot.asc_setRange;
prot["asc_getRange"] = prot.asc_getRange;
prot["asc_setRange"] = prot.asc_setRange;
prot["asc_getXAxis"] = prot.asc_getXAxis;
prot["asc_setXAxis"] = prot.asc_setXAxis;
prot["asc_getXAxis"] = prot.asc_getXAxis;
prot["asc_setXAxis"] = prot.asc_setXAxis;
prot["asc_getYAxis"] = prot.asc_getYAxis;
prot["asc_setYAxis"] = prot.asc_setYAxis;
prot["asc_getYAxis"] = prot.asc_getYAxis;
prot["asc_setYAxis"] = prot.asc_setYAxis;
prot["asc_getLegend"] = prot.asc_getLegend;
prot["asc_setLegend"] = prot.asc_setLegend;
prot["asc_getLegend"] = prot.asc_getLegend;
prot["asc_setLegend"] = prot.asc_setLegend;
prot["asc_getSeria"] = prot.asc_getSeria;
prot["asc_setSeria"] = prot.asc_setSeria;
prot["asc_removeSeries"] = prot.asc_removeSeries;
prot["asc_getSeria"] = prot.asc_getSeria;
prot["asc_setSeria"] = prot.asc_setSeria;
prot["asc_removeSeries"] = prot.asc_removeSeries;
prot["asc_getChartEditorFlag"] = prot.asc_getChartEditorFlag;
prot["asc_setChartEditorFlag"] = prot.asc_setChartEditorFlag;
//}
prot["asc_getChartEditorFlag"] = prot.asc_getChartEditorFlag;
prot["asc_setChartEditorFlag"] = prot.asc_setChartEditorFlag;
//-----------------------------------------------------------------------------------
// Chart range
//-----------------------------------------------------------------------------------
// Chart range
function asc_CChartRange(object) {
function asc_CChartRange(object) {
var bCopy = isObject(object);
......@@ -734,9 +752,9 @@
rows: 1,
columns: 2
};
}
}
asc_CChartRange.prototype = {
asc_CChartRange.prototype = {
asc_getInterval: function() { return this.interval; },
asc_setInterval: function(interval) { this.interval = interval; },
......@@ -777,23 +795,28 @@
case this.Properties.columns: this.columns = value; break;
}
}
}
}
window["Asc"].asc_CChartRange = asc_CChartRange;
window["Asc"]["asc_CChartRange"] = asc_CChartRange;
prot = asc_CChartRange.prototype;
//{ asc_CChartRange export
window["Asc"].asc_CChartRange = asc_CChartRange;
window["Asc"]["asc_CChartRange"] = asc_CChartRange;
prot = asc_CChartRange.prototype;
prot["asc_getInterval"] = prot.asc_getInterval;
prot["asc_setInterval"] = prot.asc_setInterval;
prot["asc_getInterval"] = prot.asc_getInterval;
prot["asc_setInterval"] = prot.asc_setInterval;
prot["asc_getRowsFlag"] = prot.asc_getRowsFlag;
prot["asc_setRowsFlag"] = prot.asc_setRowsFlag;
prot["asc_getRowsFlag"] = prot.asc_getRowsFlag;
prot["asc_setRowsFlag"] = prot.asc_setRowsFlag;
prot["asc_getColumnsFlag"] = prot.asc_getColumnsFlag;
prot["asc_setColumnsFlag"] = prot.asc_setColumnsFlag;
prot["asc_getColumnsFlag"] = prot.asc_getColumnsFlag;
prot["asc_setColumnsFlag"] = prot.asc_setColumnsFlag;
//}
// Chart title
function asc_CChartHeader(object) {
//-----------------------------------------------------------------------------------
// Chart title
//-----------------------------------------------------------------------------------
function asc_CChartHeader(object) {
var bCopy = isObject(object);
......@@ -808,9 +831,9 @@
bDefaultTitle: 2,
font: 3
};
}
}
asc_CChartHeader.prototype = {
asc_CChartHeader.prototype = {
asc_getTitle: function() { return this.title; },
asc_setTitle: function(title) { this.title = title; },
......@@ -846,23 +869,28 @@
case this.Properties.font: this.font = value; break;
}
}
}
}
//{ asc_CChartHeader export
window["Asc"].asc_CChartHeader = asc_CChartHeader;
window["Asc"]["asc_CChartHeader"] = asc_CChartHeader;
prot = asc_CChartHeader.prototype;
window["Asc"].asc_CChartHeader = asc_CChartHeader;
window["Asc"]["asc_CChartHeader"] = asc_CChartHeader;
prot = asc_CChartHeader.prototype;
prot["asc_getTitle"] = prot.asc_getTitle;
prot["asc_setTitle"] = prot.asc_setTitle;
prot["asc_getTitle"] = prot.asc_getTitle;
prot["asc_setTitle"] = prot.asc_setTitle;
prot["asc_getSubTitle"] = prot.asc_getSubTitle;
prot["asc_setSubTitle"] = prot.asc_setSubTitle;
prot["asc_getSubTitle"] = prot.asc_getSubTitle;
prot["asc_setSubTitle"] = prot.asc_setSubTitle;
prot["asc_getDefaultTitleFlag"] = prot.asc_getDefaultTitleFlag;
prot["asc_setDefaultTitleFlag"] = prot.asc_setDefaultTitleFlag;
//}
prot["asc_getDefaultTitleFlag"] = prot.asc_getDefaultTitleFlag;
prot["asc_setDefaultTitleFlag"] = prot.asc_setDefaultTitleFlag;
//-----------------------------------------------------------------------------------
// Chart axis X
//-----------------------------------------------------------------------------------
// Chart axis X
function asc_CChartAxisX(object) {
function asc_CChartAxisX(object) {
var bCopy = isObject(object);
......@@ -879,9 +907,9 @@
bGrid: 3,
font: 4
};
}
}
asc_CChartAxisX.prototype = {
asc_CChartAxisX.prototype = {
asc_getTitle: function() { return this.title; },
asc_setTitle: function(title) { this.title = title; },
......@@ -922,26 +950,31 @@
case this.Properties.font: this.font = value; break;
}
}
}
}
window["Asc"].asc_CChartAxisX = asc_CChartAxisX;
window["Asc"]["asc_CChartAxisX"] = asc_CChartAxisX;
prot = asc_CChartAxisX.prototype;
//{ asc_CChartAxisX export
window["Asc"].asc_CChartAxisX = asc_CChartAxisX;
window["Asc"]["asc_CChartAxisX"] = asc_CChartAxisX;
prot = asc_CChartAxisX.prototype;
prot["asc_getTitle"] = prot.asc_getTitle;
prot["asc_setTitle"] = prot.asc_setTitle;
prot["asc_getTitle"] = prot.asc_getTitle;
prot["asc_setTitle"] = prot.asc_setTitle;
prot["asc_getDefaultTitleFlag"] = prot.asc_getDefaultTitleFlag;
prot["asc_setDefaultTitleFlag"] = prot.asc_setDefaultTitleFlag;
prot["asc_getDefaultTitleFlag"] = prot.asc_getDefaultTitleFlag;
prot["asc_setDefaultTitleFlag"] = prot.asc_setDefaultTitleFlag;
prot["asc_getShowFlag"] = prot.asc_getShowFlag;
prot["asc_setShowFlag"] = prot.asc_setShowFlag;
prot["asc_getShowFlag"] = prot.asc_getShowFlag;
prot["asc_setShowFlag"] = prot.asc_setShowFlag;
prot["asc_getGridFlag"] = prot.asc_getGridFlag;
prot["asc_setGridFlag"] = prot.asc_setGridFlag;
prot["asc_getGridFlag"] = prot.asc_getGridFlag;
prot["asc_setGridFlag"] = prot.asc_setGridFlag;
//}
// Chart axis Y
function asc_CChartAxisY(object) {
//-----------------------------------------------------------------------------------
// Chart axis Y
//-----------------------------------------------------------------------------------
function asc_CChartAxisY(object) {
var bCopy = isObject(object);
......@@ -958,9 +991,9 @@
bGrid: 3,
font: 4
};
}
}
asc_CChartAxisY.prototype = {
asc_CChartAxisY.prototype = {
asc_getTitle: function() { return this.title; },
asc_setTitle: function(title) { this.title = title; },
......@@ -1001,26 +1034,31 @@
case this.Properties.font: this.font = value; break;
}
}
}
}
//{ asc_CChartAxisY export
window["Asc"].asc_CChartAxisY = asc_CChartAxisY;
window["Asc"]["asc_CChartAxisY"] = asc_CChartAxisY;
prot = asc_CChartAxisY.prototype;
window["Asc"].asc_CChartAxisY = asc_CChartAxisY;
window["Asc"]["asc_CChartAxisY"] = asc_CChartAxisY;
prot = asc_CChartAxisY.prototype;
prot["asc_getTitle"] = prot.asc_getTitle;
prot["asc_setTitle"] = prot.asc_setTitle;
prot["asc_getTitle"] = prot.asc_getTitle;
prot["asc_setTitle"] = prot.asc_setTitle;
prot["asc_getDefaultTitleFlag"] = prot.asc_getDefaultTitleFlag;
prot["asc_setDefaultTitleFlag"] = prot.asc_setDefaultTitleFlag;
prot["asc_getDefaultTitleFlag"] = prot.asc_getDefaultTitleFlag;
prot["asc_setDefaultTitleFlag"] = prot.asc_setDefaultTitleFlag;
prot["asc_getShowFlag"] = prot.asc_getShowFlag;
prot["asc_setShowFlag"] = prot.asc_setShowFlag;
prot["asc_getShowFlag"] = prot.asc_getShowFlag;
prot["asc_setShowFlag"] = prot.asc_setShowFlag;
prot["asc_getGridFlag"] = prot.asc_getGridFlag;
prot["asc_setGridFlag"] = prot.asc_setGridFlag;
//}
prot["asc_getGridFlag"] = prot.asc_getGridFlag;
prot["asc_setGridFlag"] = prot.asc_setGridFlag;
//-----------------------------------------------------------------------------------
// Chart legend
//-----------------------------------------------------------------------------------
// Chart legend
function asc_CChartLegend(object) {
function asc_CChartLegend(object) {
var bCopy = isObject(object);
......@@ -1035,9 +1073,9 @@
bOverlay: 2,
font: 3
};
}
}
asc_CChartLegend.prototype = {
asc_CChartLegend.prototype = {
asc_getPosition: function() { return this.position; },
asc_setPosition: function(pos) { this.position = pos; },
......@@ -1073,23 +1111,28 @@
case this.Properties.font: this.font = value; break;
}
}
}
}
window["Asc"].asc_CChartLegend = asc_CChartLegend;
window["Asc"]["asc_CChartLegend"] = asc_CChartLegend;
prot = asc_CChartLegend.prototype;
//{ asc_CChartLegend export
window["Asc"].asc_CChartLegend = asc_CChartLegend;
window["Asc"]["asc_CChartLegend"] = asc_CChartLegend;
prot = asc_CChartLegend.prototype;
prot["asc_getPosition"] = prot.asc_getPosition;
prot["asc_setPosition"] = prot.asc_setPosition;
prot["asc_getPosition"] = prot.asc_getPosition;
prot["asc_setPosition"] = prot.asc_setPosition;
prot["asc_getShowFlag"] = prot.asc_getShowFlag;
prot["asc_setShowFlag"] = prot.asc_setShowFlag;
prot["asc_getShowFlag"] = prot.asc_getShowFlag;
prot["asc_setShowFlag"] = prot.asc_setShowFlag;
prot["asc_getOverlayFlag"] = prot.asc_getOverlayFlag;
prot["asc_setOverlayFlag"] = prot.asc_setOverlayFlag;
prot["asc_getOverlayFlag"] = prot.asc_getOverlayFlag;
prot["asc_setOverlayFlag"] = prot.asc_setOverlayFlag;
//}
// Chart series
function asc_CChartSeria() {
//-----------------------------------------------------------------------------------
// Chart series
//-----------------------------------------------------------------------------------
function asc_CChartSeria() {
this.Val = { Formula: null, NumCache: [] };
this.xVal = { Formula: null, NumCache: [] };
this.Tx = null;
......@@ -1106,9 +1149,9 @@
MarkerSymbol: 6,
OutlineColor: 7
};
}
}
asc_CChartSeria.prototype = {
asc_CChartSeria.prototype = {
asc_getValFormula: function() { return this.Val.Formula; },
asc_setValFormula: function(formula) { this.Val.Formula = formula; },
......@@ -1162,32 +1205,37 @@
case this.Properties.OutlineColor: this.OutlineColor = value; break;
}
}
}
}
//{ asc_CChartSeria export
window["Asc"].asc_CChartSeria = asc_CChartSeria;
window["Asc"]["asc_CChartSeria"] = asc_CChartSeria;
prot = asc_CChartSeria.prototype;
window["Asc"].asc_CChartSeria = asc_CChartSeria;
window["Asc"]["asc_CChartSeria"] = asc_CChartSeria;
prot = asc_CChartSeria.prototype;
prot["asc_getValFormula"] = prot.asc_getValFormula;
prot["asc_setValFormula"] = prot.asc_setValFormula;
prot["asc_getValFormula"] = prot.asc_getValFormula;
prot["asc_setValFormula"] = prot.asc_setValFormula;
prot["asc_getxValFormula"] = prot.asc_getxValFormula;
prot["asc_setxValFormula"] = prot.asc_setxValFormula;
prot["asc_getxValFormula"] = prot.asc_getxValFormula;
prot["asc_setxValFormula"] = prot.asc_setxValFormula;
prot["asc_getTitle"] = prot.asc_getTitle;
prot["asc_setTitle"] = prot.asc_setTitle;
prot["asc_getTitle"] = prot.asc_getTitle;
prot["asc_setTitle"] = prot.asc_setTitle;
prot["asc_getMarkerSize"] = prot.asc_getMarkerSize;
prot["asc_setMarkerSize"] = prot.asc_setMarkerSize;
prot["asc_getMarkerSize"] = prot.asc_getMarkerSize;
prot["asc_setMarkerSize"] = prot.asc_setMarkerSize;
prot["asc_getMarkerSymbol"] = prot.asc_getMarkerSymbol;
prot["asc_setMarkerSymbol"] = prot.asc_setMarkerSymbol;
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_getOutlineColor"] = prot.asc_getOutlineColor;
prot["asc_setOutlineColor"] = prot.asc_setOutlineColor;
//-----------------------------------------------------------------------------------
// Chart font
//-----------------------------------------------------------------------------------
// Chart font
function asc_CChartFont(object) {
function asc_CChartFont(object) {
var bCopy = isObject(object);
......@@ -1207,9 +1255,9 @@
italic: 4,
underline: 5
}
}
}
asc_CChartFont.prototype = {
asc_CChartFont.prototype = {
asc_getName: function() { return this.name; },
asc_setName: function(val) { this.name = val; },
......@@ -1260,8 +1308,9 @@
case this.Properties.underline: this.underline = value; break;
}
}
}
}
//{ asc_CChartFont export
window["Asc"].asc_CChartFont = asc_CChartFont;
window["Asc"]["asc_CChartFont"] = asc_CChartFont;
prot = asc_CChartFont.prototype;
......@@ -1283,8 +1332,12 @@
prot["asc_getUnderline"] = prot.asc_getUnderline;
prot["asc_setUnderline"] = prot.asc_setUnderline;
//}
//-----------------------------------------------------------------------------------
// Undo/Redo
//-----------------------------------------------------------------------------------
// Undo / Redo
DrawingObjects.prototype = {
Undo: function(type, data) {
......@@ -1315,7 +1368,7 @@ DrawingObjects.prototype = {
aStorage.push(obj);
}
this.changeObjectStorage(aStorage);
this.showDrawingObjects(true, null, false, false);
this.showDrawingObjects(true, null, false);
}
break;
}
......@@ -1349,7 +1402,7 @@ DrawingObjects.prototype = {
aStorage.push(obj);
}
this.changeObjectStorage(aStorage);
this.showDrawingObjects(true, null, false, false);
this.showDrawingObjects(true, null, false);
}
break;
}
......@@ -1380,6 +1433,9 @@ function DrawingObjects() {
var documentId = null;
var lastObjectIndex = null;
// Все изменения, связанные с image.src прогоняем через этот класс
var imageLoader = new ImageLoader();
//-----------------------------------------------------------------------------------
// Public methods
//-----------------------------------------------------------------------------------
......@@ -1400,10 +1456,12 @@ function DrawingObjects() {
currentSheet.model.Drawings[i].worksheet = worksheet;
aObjects[i] = _this.cloneDrawingObject(currentSheet.model.Drawings[i]);
aObjects[i].flags.loaded = currentSheet.model.Drawings[i].flags.loaded;
if (aObjects[i].isChart())
_this.calcChartInterval(aObjects[i].chart);
if (aObjects[i].isImage())
imageLoader.addImage(aObjects[i].image.src);
}
lastObjectIndex = aObjects.length;
......@@ -1526,7 +1584,7 @@ function DrawingObjects() {
_this.showOverlayDrawingObject = function(index) {
if (_this.checkDrawingObjectIndex(index)) {
var obj = aObjects[index];
if (!obj.flags.loaded || !obj.image.complete) // complete - дополнительная проверка в случае base64
if ( !obj.image.complete ) // complete - дополнительная проверка в случае base64
return;
if (obj.image.width && obj.image.height) {
......@@ -1550,7 +1608,7 @@ function DrawingObjects() {
}
}
_this.showDrawingObjects = function(clearCanvas, printOptions, bMouseUp, bUpdateCharts) {
_this.showDrawingObjects = function(clearCanvas, printOptions, bUpdateCharts) {
/*********** Print Options ***************
printOptions : {
......@@ -1575,6 +1633,15 @@ function DrawingObjects() {
if (clearCanvas)
_this.clearDrawingObjects();
if ( !imageLoader.isReady() ) {
//console.log("imageLoader - False");
imageLoader.setReadyCallback(_this.showDrawingObjects);
}
else {
//console.log("imageLoader - Ok");
imageLoader.removeReadyCallback();
}
for (var i = 0; i < _this.countDrawingObjects(); i++) {
var index = i;
......@@ -1586,6 +1653,7 @@ function DrawingObjects() {
if (!obj.flags.anchorUpdated)
obj.updateAnchorPosition();
// History
if (obj.move.inAction && undoRedoObject && (undoRedoObject.id == obj.id)) {
History.Create_NewPoint();
......@@ -1605,7 +1673,7 @@ function DrawingObjects() {
var srcForPrint;
// выход за границы
// Выход за границы
while (worksheet.nColsCount < obj.to.col + 1) {
worksheet.expandColsOnScroll(true);
}
......@@ -1613,7 +1681,6 @@ function DrawingObjects() {
worksheet.expandRowsOnScroll(true);
}
var bOnload = false;
if ( obj.isChart() && bUpdateCharts ) {
if ( !obj.chart.range.intervalObject )
_this.intervalToIntervalObject(obj.chart);
......@@ -1622,53 +1689,25 @@ function DrawingObjects() {
if ( !chartBase64 )
continue;
imageLoader.addImage(chartBase64);
imageLoader.setReadyCallback(_this.showDrawingObjects);
obj.image.onload = function() {
obj.flags.loaded = true;
obj.flags.currentCursor = null;
_this.showDrawingObjects(true, printOptions, true, false);
}
obj.image.src = chartBase64;
obj.flags.loaded = false;
bOnload = true;
continue;
}
if ( !obj.canDraw() )
continue;
if ( !bOnload ) {
obj.image.onload = function() {
// Пересчёт нужен при смене src(ресайз диаграммы)
var sWidth = obj.image.width - obj.getInnerOffsetLeft();
var sHeight = obj.image.height - obj.getInnerOffsetTop();
// Проверка для IE
var dWidth = obj.getVisibleWidth();
var dHeight = obj.getVisibleHeight();
if ((dWidth <= 0) || (dHeight <= 0))
return;
drawingCtx.drawImage(obj.image,
// обрезаем
pxToPt(obj.getInnerOffsetLeft()), pxToPt(obj.getInnerOffsetTop()),
pxToPt(sWidth), pxToPt(sHeight),
// вставляем
pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(dWidth), pxToPt(dHeight));
if (obj.flags.selected && !printOptions)
_this.selectDrawingObject(index);
obj.flags.loaded = true;
}
}
var sWidth = obj.image.width - obj.getInnerOffsetLeft();
var sHeight = obj.image.height - obj.getInnerOffsetTop();
if (printOptions) {
if (obj.isChart()) {
if ( printOptions ) {
if ( obj.isChart() ) {
srcForPrint = obj.image.src; // base64
}
else {
......@@ -1689,12 +1728,9 @@ function DrawingObjects() {
pxToPt(obj.image.width), pxToPt(obj.image.height));
}
else {
if (!obj.image.width || !obj.image.height)
//return;
if ( !obj.image.width || !obj.image.height )
continue;
if (!obj.move.inAction || bMouseUp) {
// Проверка для IE
var dWidth = obj.getVisibleWidth();
var dHeight = obj.getVisibleHeight();
......@@ -1709,11 +1745,10 @@ function DrawingObjects() {
pxToPt(obj.getVisibleLeftOffset(true)), pxToPt(obj.getVisibleTopOffset(true)),
pxToPt(dWidth), pxToPt(dHeight));
}
}
if (obj.flags.selected && !printOptions)
if ( obj.flags.selected && !printOptions )
_this.selectDrawingObject(index);
if (obj.flags.lockState != c_oAscObjectLockState.No)
if ( obj.flags.lockState != c_oAscObjectLockState.No )
_this.selectLockedDrawingObject(obj.id, obj.flags.lockState);
obj.move.inAction = false;
......@@ -1849,7 +1884,6 @@ function DrawingObjects() {
_t.chart = new asc_CChart();
_t.flags = {
loaded: false,
selected: false,
anchorUpdated: false,
lockState: c_oAscObjectLockState.No,
......@@ -2325,6 +2359,8 @@ function DrawingObjects() {
if (imageUrl && !isViewerMode()) {
imageLoader.addImage(imageUrl);
var obj = _this.createDrawingObject();
obj.id = generateId();
obj.worksheet = worksheet;
......@@ -2408,7 +2444,6 @@ function DrawingObjects() {
// Теперь знаем реальную высоту и ширину
obj.image.onload = function() {
obj.flags.loaded = true;
calculateObjectMetrics(obj, obj.image.width, obj.image.height);
aObjects.push(obj);
......@@ -2538,6 +2573,8 @@ function DrawingObjects() {
if ( !chartBase64 )
return false;
imageLoader.addImage(chartBase64);
// draw
var obj = _this.createDrawingObject();
obj.id = generateId();
......@@ -2555,8 +2592,6 @@ function DrawingObjects() {
obj.image.onload = function() {
obj.flags.loaded = true;
var objWidth = options && options.width ? options.width : obj.image.width;
var objHeight = options && options.height ? options.height : obj.image.height;
......@@ -2590,7 +2625,7 @@ function DrawingObjects() {
}
if(options)
_this.showDrawingObjects(true, null/*printOptions*/, false/*bMouseUp*/, true/*bUpdateCharts*/);
_this.showDrawingObjects(true, null/*printOptions*/, true/*bUpdateCharts*/);
else
_this.showDrawingObjects(true);
......@@ -2662,7 +2697,7 @@ function DrawingObjects() {
_this.selectDrawingObject(index);
_this.selectDrawingObjectRange(index);
_this.showDrawingObjects(false, null/*printOptions*/, false/*bMouseUp*/, true/*bUpdateCharts*/);
_this.showDrawingObjects(false, null/*printOptions*/, true/*bUpdateCharts*/);
}
}
......@@ -2672,14 +2707,6 @@ function DrawingObjects() {
}
}
_this.reloadChartDrawingObjects = function(chart) {
for (var i = 0; i < _this.countDrawingObjects(); i++) {
var obj = aObjects[i];
if (obj.isChart())
obj.flags.loaded = false;
}
}
_this.deleteSelectedDrawingObject = function() {
var bResult = false;
......@@ -4108,12 +4135,12 @@ function DrawingObjects() {
}
// выход за границу слева
if (realLeftOffset <= worksheet.getCellLeft(0, 0))
if ( realLeftOffset <= worksheet.getCellLeft(0, 0) )
realLeftOffset = worksheet.getCellLeft(0, 0);
// выход за границу справа
var foundCol = worksheet._findColUnderCursor(pxToPt(realLeftOffset + widthFromTo), true);
while (foundCol == null) {
while ( foundCol == null ) {
worksheet.expandColsOnScroll(true);
worksheet._trigger("reinitializeScrollX");
foundCol = worksheet._findColUnderCursor(pxToPt(realLeftOffset + widthFromTo), true);
......@@ -4129,7 +4156,7 @@ function DrawingObjects() {
if ( heightFromTo < 0 )
heightFromTo = 0;
var foundRow = worksheet._findRowUnderCursor(pxToPt(realTopOffset + heightFromTo), true);
while (foundRow == null) {
while ( foundRow == null ) {
worksheet.expandRowsOnScroll(true);
worksheet._trigger("reinitializeScrollY");
foundRow = worksheet._findRowUnderCursor(pxToPt(realTopOffset + heightFromTo), true);
......@@ -4244,3 +4271,52 @@ function DrawingObjects() {
return tmp;
}
}
//-----------------------------------------------------------------------------------
// Image loader
//-----------------------------------------------------------------------------------
function ImageLoader() {
var _this = this;
var readyCallback = null;
var ImageObject = function() {
var _t = this;
_t.bReady = false;
_t.image = new Image();
_t.image.onload = function() {
_t.bReady = true;
if ( _this.isReady() && readyCallback )
readyCallback(false, null, false);
}
};
var container = []; // array of ImageObject
_this.isReady = function() {
for (var i = 0; i < container.length; i++) {
if ( !container[i].bReady )
return false;
}
container = []; // remove cache
return true;
}
_this.addImage = function(imageSrc) {
if ( imageSrc ) {
var imageObject = new ImageObject();
imageObject.image.src = imageSrc;
container.push(imageObject);
}
}
_this.setReadyCallback = function(callback) {
if ( callback && (typeof(callback) == "function") )
readyCallback = callback;
}
_this.removeReadyCallback = function(callback) {
readyCallback = null;
}
}
\ No newline at end of file
......@@ -1382,7 +1382,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
_onShowDrawingObjects: function () {
if (this.wb) {
this.wb.getWorksheet().objectRender.showDrawingObjects(true, /*printOptions*/null, /*bMouseUp*/false, /*bUpdateCharts*/false);
this.wb.getWorksheet().objectRender.showDrawingObjects(true, /*printOptions*/null, /*bUpdateCharts*/false);
}
},
......
......@@ -1866,7 +1866,7 @@
bottom: printPagesData.bottomFieldInPt
}
};
this.objectRender.showDrawingObjects(false, drawingPrintOptions, false, true);
this.objectRender.showDrawingObjects(false, drawingPrintOptions, false);
this.visibleRange = tmpVisibleRange.clone(true);
if (isAppBridge) {window['appBridge']['dummyCommandUpdate'] ();}
......@@ -1894,7 +1894,7 @@
}
//draw auto filters
this.autoFilters.drawAutoF(this);
this.objectRender.showDrawingObjects(true, null/*printOptions*/, false/*bMouseUp*/, true/*bUpdateCharts*/);
this.objectRender.showDrawingObjects(true, null/*printOptions*/, true/*bUpdateCharts*/);
this.cellCommentator.drawCommentCells(false);
return this;
......@@ -3456,7 +3456,7 @@
t.overlayCtx.ctx.globalAlpha = 1;
if (res) {
// Все хорошо, мы залочили, теперь применяем
t.objectRender.showDrawingObjects(true, null, true, true);
t.objectRender.showDrawingObjects(true, null, true);
}
else {
// Не удалось, восстанавливаем состояние
......@@ -8017,7 +8017,7 @@
if (isUpdateCols) { t._updateVisibleColsCount(); }
if (isUpdateRows) { t._updateVisibleRowsCount(); }
t.objectRender.showDrawingObjects(true, null, false, true);
t.objectRender.showDrawingObjects(true, null, true);
};
switch (prop) {
......@@ -8304,7 +8304,7 @@
if (isUpdateRows) { t._updateVisibleRowsCount(); }
if (false === lockDraw) {
t.objectRender.showDrawingObjects(true, null, false, true);
t.objectRender.showDrawingObjects(true, null, true);
t.autoFilters.drawAutoF(t);
}
},
......@@ -9034,7 +9034,6 @@
t._trigger("selectionChanged", t.getSelectionInfo());
}
t.objectRender.reloadChartDrawingObjects();
t.cellCommentator.updateCommentPosition();
t.draw(lockDraw);
},
......
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