Commit fd14c473 authored by Alexander.Trofimov's avatar Alexander.Trofimov

add method insertSparkline

add method setWorksheet
parent 30a7fd0c
...@@ -5605,7 +5605,7 @@ ...@@ -5605,7 +5605,7 @@
}); });
} else if (c_oSerWorksheetsTypes.SparklineGroups === type) { } else if (c_oSerWorksheetsTypes.SparklineGroups === type) {
res = this.bcr.Read1(length, function (t, l) { res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadSparklineGroups(t, l, oWorksheet.aSparklineGroups); return oThis.ReadSparklineGroups(t, l, oWorksheet);
}); });
} else } else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
...@@ -6620,15 +6620,16 @@ ...@@ -6620,15 +6620,16 @@
return res; return res;
}; };
this.ReadSparklineGroups = function (type, length, aSparklineGroups) { this.ReadSparklineGroups = function (type, length, oWorksheet) {
var oThis = this; var oThis = this;
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
if (c_oSer_Sparkline.SparklineGroup === type) { if (c_oSer_Sparkline.SparklineGroup === type) {
var newSparklineGroup = new AscCommonExcel.sparklineGroup(true); var newSparklineGroup = new AscCommonExcel.sparklineGroup(true);
newSparklineGroup.setWorksheet(oWorksheet);
res = this.bcr.Read1(length, function (t, l) { res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadSparklineGroup(t, l, newSparklineGroup); return oThis.ReadSparklineGroup(t, l, newSparklineGroup);
}); });
aSparklineGroups.push(newSparklineGroup); oWorksheet.aSparklineGroups.push(newSparklineGroup);
} else } else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
......
...@@ -3479,9 +3479,6 @@ Woorksheet.prototype.clone=function(sNewId, sName, tableNames){ ...@@ -3479,9 +3479,6 @@ Woorksheet.prototype.clone=function(sNewId, sName, tableNames){
for (i = 0; i < this.aConditionalFormatting.length; ++i) { for (i = 0; i < this.aConditionalFormatting.length; ++i) {
oNewWs.aConditionalFormatting.push(this.aConditionalFormatting[i].clone()); oNewWs.aConditionalFormatting.push(this.aConditionalFormatting[i].clone());
} }
for (i = 0; i < this.aSparklineGroups.length; ++i) {
oNewWs.aSparklineGroups.push(this.aSparklineGroups[i].clone());
}
if (this.sheetPr) if (this.sheetPr)
oNewWs.sheetPr = this.sheetPr.clone(); oNewWs.sheetPr = this.sheetPr.clone();
...@@ -3489,28 +3486,37 @@ Woorksheet.prototype.clone=function(sNewId, sName, tableNames){ ...@@ -3489,28 +3486,37 @@ Woorksheet.prototype.clone=function(sNewId, sName, tableNames){
return oNewWs; return oNewWs;
}; };
Woorksheet.prototype.copyDrawingObjects=function(oNewWs, wsFrom) Woorksheet.prototype.copyDrawingObjects = function (oNewWs, wsFrom) {
{ var i;
if(null != this.Drawings && this.Drawings.length > 0) if (null != this.Drawings && this.Drawings.length > 0) {
{ var drawingObjects = new AscFormat.DrawingObjects();
var drawingObjects = new AscFormat.DrawingObjects(); oNewWs.Drawings = [];
oNewWs.Drawings = []; AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT = oNewWs.DrawingDocument;
AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT = oNewWs.DrawingDocument; for (i = 0; i < this.Drawings.length; ++i) {
for(var i = 0; i < this.Drawings.length; ++i) var drawingObject = drawingObjects.cloneDrawingObject(this.Drawings[i]);
{ drawingObject.graphicObject = this.Drawings[i].graphicObject.copy();
var drawingObject = drawingObjects.cloneDrawingObject(this.Drawings[i]); drawingObject.graphicObject.setWorksheet(oNewWs);
drawingObject.graphicObject = this.Drawings[i].graphicObject.copy(); drawingObject.graphicObject.addToDrawingObjects();
drawingObject.graphicObject.setWorksheet(oNewWs); var drawingBase = this.Drawings[i];
drawingObject.graphicObject.addToDrawingObjects(); drawingObject.graphicObject.setDrawingBaseCoords(drawingBase.from.col, drawingBase.from.colOff,
var drawingBase = this.Drawings[i]; drawingBase.from.row, drawingBase.from.rowOff, drawingBase.to.col, drawingBase.to.colOff,
drawingObject.graphicObject.setDrawingBaseCoords(drawingBase.from.col, drawingBase.from.colOff, drawingBase.from.row, drawingBase.from.rowOff, drawingBase.to.col, drawingBase.to.colOff, drawingBase.to.row, drawingBase.to.rowOff, drawingBase.Pos.X, drawingBase.Pos.Y, drawingBase.ext.cx, drawingBase.ext.cy); drawingBase.to.row, drawingBase.to.rowOff, drawingBase.Pos.X, drawingBase.Pos.Y, drawingBase.ext.cx,
oNewWs.Drawings[oNewWs.Drawings.length - 1] = drawingObject; drawingBase.ext.cy);
} oNewWs.Drawings[oNewWs.Drawings.length - 1] = drawingObject;
AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT = null; }
drawingObjects.pushToAObjects(oNewWs.Drawings); AscFormat.NEW_WORKSHEET_DRAWING_DOCUMENT = null;
drawingObjects.updateChartReferences2(parserHelp.getEscapeSheetName(wsFrom.sName), parserHelp.getEscapeSheetName(oNewWs.sName)); drawingObjects.pushToAObjects(oNewWs.Drawings);
} drawingObjects.updateChartReferences2(parserHelp.getEscapeSheetName(wsFrom.sName),
}; parserHelp.getEscapeSheetName(oNewWs.sName));
}
var newSparkline;
for (i = 0; i < this.aSparklineGroups.length; ++i) {
newSparkline = this.aSparklineGroups[i].clone();
newSparkline.setWorksheet(oNewWs);
oNewWs.aSparklineGroups.push(newSparkline);
}
};
Woorksheet.prototype.initPostOpen = function (handlers) { Woorksheet.prototype.initPostOpen = function (handlers) {
var cwf = this.workbook.cwf[this.Id] = {}; var cwf = this.workbook.cwf[this.Id] = {};
if (this.aFormulaExt) { if (this.aFormulaExt) {
...@@ -5693,11 +5699,14 @@ Woorksheet.prototype.updateSparklineCache = function(sheet, ranges) { ...@@ -5693,11 +5699,14 @@ Woorksheet.prototype.updateSparklineCache = function(sheet, ranges) {
Woorksheet.prototype.getSparklineGroup = function(c, r) { Woorksheet.prototype.getSparklineGroup = function(c, r) {
for (var i = 0; i < this.aSparklineGroups.length; ++i) { for (var i = 0; i < this.aSparklineGroups.length; ++i) {
if (-1 !== this.aSparklineGroups[i].contains(c, r)) { if (-1 !== this.aSparklineGroups[i].contains(c, r)) {
return this.aSparklineGroups[i].clone(true); return this.aSparklineGroups[i];
} }
} }
return null; return null;
}; };
Woorksheet.prototype.insertSparkline = function (sparkline) {
this.aSparklineGroups.push(sparkline);
};
//------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------
/** /**
* @constructor * @constructor
......
...@@ -4721,6 +4721,7 @@ CellArea.prototype = { ...@@ -4721,6 +4721,7 @@ CellArea.prototype = {
//for drawing preview //for drawing preview
this.canvas = null; this.canvas = null;
this.worksheet = null;
this.Id = null; this.Id = null;
if (addId) { if (addId) {
this.Id = AscCommon.g_oIdCounter.Get_NewId(); this.Id = AscCommon.g_oIdCounter.Get_NewId();
...@@ -5077,6 +5078,9 @@ CellArea.prototype = { ...@@ -5077,6 +5078,9 @@ CellArea.prototype = {
this.colorHigh = new RgbColor(defaultOtherColor); this.colorHigh = new RgbColor(defaultOtherColor);
this.colorLow = new RgbColor(defaultOtherColor); this.colorLow = new RgbColor(defaultOtherColor);
}; };
sparklineGroup.prototype.setWorksheet = function (worksheet) {
this.worksheet = worksheet;
};
sparklineGroup.prototype.set = function (val) { sparklineGroup.prototype.set = function (val) {
var t = this; var t = this;
var checkProperty = function(propOld, propNew, type) { var checkProperty = function(propOld, propNew, type) {
......
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