Skip to content

Commit

Permalink
fix crash on copy chart ex with gridlines
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyLuzyanin committed Dec 3, 2024
1 parent ece5bbe commit 78350fa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 37 deletions.
26 changes: 0 additions & 26 deletions common/Drawings/Format/ChartEx.js
Original file line number Diff line number Diff line change
Expand Up @@ -2328,31 +2328,6 @@ function (window, undefined) {
AscDFH.changesFactory[AscDFH.historyitem_Gridlines_SetSpPr] = window['AscDFH'].CChangesDrawingsObject;
AscDFH.changesFactory[AscDFH.historyitem_Gridlines_SetName] = window['AscDFH'].CChangesDrawingsString;

function CGridlines() {
CBaseChartObject.call(this);
this.spPr = null;
this.name = null;
}

InitClass(CGridlines, CBaseChartObject, AscDFH.historyitem_type_Gridlines);

CGridlines.prototype.fillObject = function (oCopy) {
CBaseChartObject.prototype.fillObject.call(this, oCopy);
if (this.spPr) {
oCopy.setSpPr(this.spPr.createDuplicate());
}
oCopy.setName(this.name);
}

CGridlines.prototype.setSpPr = function (pr) {
History.CanAddChanges() && History.Add(new CChangesDrawingsObject(this, AscDFH.historyitem_Gridlines_SetSpPr, this.spPr, pr));
this.spPr = pr;
this.setParentToChild(pr);
};
CGridlines.prototype.setName = function (pr) {
History.CanAddChanges() && History.Add(new CChangesDrawingsString(this, AscDFH.historyitem_Gridlines_SetName, this.name, pr));
this.name = pr;
};


// // HeaderFooter (contains in ChartFormat.js)
Expand Down Expand Up @@ -4520,7 +4495,6 @@ function (window, undefined) {
window['AscFormat'].CGeoLocations = CGeoLocations;
window['AscFormat'].CGeoPolygon = CGeoPolygon;
window['AscFormat'].CGeoPolygons = CGeoPolygons;
window['AscFormat'].CGridlines = CGridlines;
// window['AscFormat'].CHeaderFooter = CHeaderFooter;
// window['AscFormat'].CChartExLegend = CChartExLegend;
// window['AscFormat'].CNumberColorPosition = CNumberColorPosition;
Expand Down
20 changes: 10 additions & 10 deletions common/SerializeChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -6752,9 +6752,9 @@ BinaryChartWriter.prototype.WriteCT_TickMarks = function (oVal) {
};
BinaryChartWriter.prototype.WriteCT_Gridlines = function (oVal) {
var oThis = this;
if(oVal.spPr !== null) {
if(oVal !== null) {
this.bs.WriteItem(c_oserct_chartExGridlinesSPPR, function() {
oThis.WriteSpPr(oVal.spPr);
oThis.WriteSpPr(oVal);
});
}
};
Expand Down Expand Up @@ -13396,19 +13396,19 @@ BinaryChartReader.prototype.ReadCT_Axis = function (type, length, val) {
}
else if (c_oserct_chartExAxisMAJORGRID === type)
{
var oNewVal = new AscFormat.CGridlines();
let oNewVal = { spPr: null };
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadCT_Gridlines(t, l, oNewVal);
});
val.setMajorGridlines(oNewVal);
val.setMajorGridlines(oNewVal.spPr || new AscFormat.CSpPr());
}
else if (c_oserct_chartExAxisMINORGRID === type)
{
var oNewVal = new AscFormat.CGridlines();
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadCT_Gridlines(t, l, oNewVal);
});
val.setMinorGridlines(oNewVal);
let oNewVal = { spPr: null };
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadCT_Gridlines(t, l, oNewVal);
});
val.setMinorGridlines(oNewVal.spPr || new AscFormat.CSpPr());
}
else if (c_oserct_chartExAxisTICKLABELS === type)
{
Expand Down Expand Up @@ -14369,7 +14369,7 @@ BinaryChartReader.prototype.ReadCT_Gridlines = function (type, length, val) {
var oNewVal;
if (c_oserct_chartExGridlinesSPPR === type)
{
val.setSpPr(this.ReadSpPr(length));
val.spPr = this.ReadSpPr(length);
}
else
{
Expand Down
1 change: 0 additions & 1 deletion common/TableId.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@
this.m_oFactoryClass[AscDFH.historyitem_type_GeoLocations] = AscFormat.CGeoLocations;
this.m_oFactoryClass[AscDFH.historyitem_type_GeoPolygon] = AscFormat.CGeoPolygon;
this.m_oFactoryClass[AscDFH.historyitem_type_GeoPolygons] = AscFormat.CGeoPolygons;
this.m_oFactoryClass[AscDFH.historyitem_type_Gridlines] = AscFormat.CGridlines;
this.m_oFactoryClass[AscDFH.historyitem_type_Dimension] = AscFormat.CDimension;
this.m_oFactoryClass[AscDFH.historyitem_type_NumericDimension] = AscFormat.CNumericDimension;
this.m_oFactoryClass[AscDFH.historyitem_type_PercentageColorPosition] = AscFormat.CPercentageColorPosition;
Expand Down

0 comments on commit 78350fa

Please sign in to comment.