Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v7.2.0 #2781

Merged
merged 6 commits into from
May 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ module.exports = function(grunt) {
'libfont/js/fonts.*',
'libfont/wasm/fonts.*',
'spell/spell/*',
'hash/hash/*'
'hash/hash/*',
'zlib/engine/*'
],
dest: path.join(deploy, 'common')
},
Expand Down
14 changes: 1 addition & 13 deletions common/Charts/DrawingObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -1861,19 +1861,7 @@ CSparklineView.prototype.setMinMaxValAx = function(minVal, maxVal, oSparklineGro
switch (this.graphicObject.getObjectType()) {
case AscDFH.historyitem_type_ChartSpace:
case AscDFH.historyitem_type_SlicerView:
let Graphic = new AscFormat.CT_GraphicalObject();
Graphic.Namespace = ' xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"';
Graphic.GraphicData = new AscFormat.CT_GraphicalObjectData();
if(this.graphicObject.getObjectType() === AscDFH.historyitem_type_ChartSpace)
Graphic.GraphicData.Uri = "http://schemas.openxmlformats.org/drawingml/2006/chart";
else
Graphic.GraphicData.Uri = "http://schemas.microsoft.com/office/drawing/2010/slicer";
Graphic.GraphicData.graphicObject = graphicObject;

let newGraphicObject = new AscFormat.CGraphicFrame();
newGraphicObject.spPr = graphicObject.spPr;
newGraphicObject.graphicObject = Graphic;
graphicObject = newGraphicObject;
graphicObject = AscFormat.CGraphicFrame.prototype.static_CreateGraphicFrameFromDrawing(graphicObject);
break;
}
writer.WriteXmlNodeStart(name);
Expand Down
20 changes: 20 additions & 0 deletions common/Drawings/Format/CnxShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,26 @@
}
}
};
CConnectionShape.prototype.toXml = function(writer, sNamespace) {
let namespace_ = sNamespace || "a";

if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DOCX ||
writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) namespace_ = "wps";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_XLSX) namespace_ = "xdr";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = "a";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = "cdr";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = "dgm";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DSP_DRAWING) namespace_ = "dsp";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_PPTX) namespace_ = "p";

writer.WriteXmlNodeStart(namespace_ + ":cxnSp");
writer.WriteXmlNullableAttributeString("macro", this.macro);
writer.WriteXmlAttributesEnd();
this.nvSpPr.toXmlCxn(writer);
this.spPr.toXml(writer);
writer.WriteXmlNullable(this.style);
writer.WriteXmlNodeEnd(namespace_ + ":cxnSp");
};

window['AscFormat'] = window['AscFormat'] || {};
window['AscFormat'].fCalculateSpPr = fCalculateSpPr;
Expand Down
97 changes: 59 additions & 38 deletions common/Drawings/Format/Format.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,52 +73,49 @@
var CChangesDrawingsContent = AscDFH.CChangesDrawingsContent;


function CBaseObject() {
this.Id = null;
if (AscCommon.g_oIdCounter.m_bLoad || History.CanAddChanges() || this.notAllowedWithoutId()) {
this.Id = AscCommon.g_oIdCounter.Get_NewId();
AscCommon.g_oTableId.Add(this, this.Id);
}

function CBaseNoIdObject() {
}

CBaseObject.prototype.classType = AscDFH.historyitem_type_Unknown;
CBaseObject.prototype.notAllowedWithoutId = function () {

CBaseNoIdObject.prototype.classType = AscDFH.historyitem_type_Unknown;
CBaseNoIdObject.prototype.notAllowedWithoutId = function () {
return false;
};
CBaseObject.prototype.getObjectType = function () {
CBaseNoIdObject.prototype.getObjectType = function () {
return this.classType;
};
CBaseObject.prototype.Get_Id = function () {
CBaseNoIdObject.prototype.Get_Id = function () {
return this.Id;
};
CBaseObject.prototype.Write_ToBinary2 = function (oWriter) {
CBaseNoIdObject.prototype.Write_ToBinary2 = function (oWriter) {
oWriter.WriteLong(this.getObjectType());
oWriter.WriteString2(this.Get_Id());
};
CBaseObject.prototype.Read_FromBinary2 = function (oReader) {
CBaseNoIdObject.prototype.Read_FromBinary2 = function (oReader) {
this.Id = oReader.GetString2();
};
CBaseObject.prototype.Refresh_RecalcData = function (oChange) {
CBaseNoIdObject.prototype.Refresh_RecalcData = function (oChange) {
};
//open/save from/to xml
CBaseObject.prototype.readAttr = function (reader) {
CBaseNoIdObject.prototype.readAttr = function (reader) {
while (reader.MoveToNextAttribute()) {
this.readAttrXml(reader.GetNameNoNS(), reader);
}
};
CBaseObject.prototype.readAttrXml = function (name, reader) {
CBaseNoIdObject.prototype.readAttrXml = function (name, reader) {
//TODO:Implement in children
};
CBaseObject.prototype.readChildXml = function (name, reader) {
CBaseNoIdObject.prototype.readChildXml = function (name, reader) {
//TODO:Implement in children
};
CBaseObject.prototype.writeAttrXmlImpl = function (writer) {
CBaseNoIdObject.prototype.writeAttrXmlImpl = function (writer) {
//TODO:Implement in children
};
CBaseObject.prototype.writeChildren = function (writer) {
CBaseNoIdObject.prototype.writeChildren = function (writer) {
//TODO:Implement in children
};
CBaseObject.prototype.fromXml = function (reader, bSkipFirstNode) {
CBaseNoIdObject.prototype.fromXml = function (reader, bSkipFirstNode) {
if (bSkipFirstNode) {
if (!reader.ReadNextNode()) {
return;
Expand All @@ -131,17 +128,28 @@
this.readChildXml(name, reader);
}
};
CBaseObject.prototype.toXml = function (writer, name) {
CBaseNoIdObject.prototype.toXml = function (writer, name) {
writer.WriteXmlNodeStart(name);
this.writeAttrXml(writer);
this.writeChildren(writer);
writer.WriteXmlNodeEnd(name);
};
CBaseObject.prototype.writeAttrXml = function (writer) {
CBaseNoIdObject.prototype.writeAttrXml = function (writer) {
this.writeAttrXmlImpl(writer);
writer.WriteXmlAttributesEnd();
};


function CBaseObject() {
CBaseNoIdObject.call(this);
this.Id = null;
if (AscCommon.g_oIdCounter.m_bLoad || History.CanAddChanges() || this.notAllowedWithoutId()) {
this.Id = AscCommon.g_oIdCounter.Get_NewId();
AscCommon.g_oTableId.Add(this, this.Id);
}
}
InitClass(CBaseObject, CBaseNoIdObject, AscDFH.historyitem_type_Unknown);

function InitClassWithoutType(fClass, fBase) {
fClass.prototype = Object.create(fBase.prototype);
fClass.prototype.superclass = fBase;
Expand All @@ -154,14 +162,6 @@
}


function CBaseNoIdObject() {
AscFormat.ExecuteNoHistory(function () {
CBaseObject.call(this);
}, this, []);
}

InitClass(CBaseNoIdObject, CBaseObject, AscDFH.historyitem_type_Unknown);

function CBaseFormatObject() {
CBaseObject.call(this);
this.parent = null;
Expand Down Expand Up @@ -8076,7 +8076,9 @@
writer.WriteXmlNullableAttributeString(sAttrNamespace + "algn", this.GetAlgnByCode(this.algn));
writer.WriteXmlAttributesEnd();

this.Fill.toXml(writer);
if(this.Fill) {
this.Fill.toXml(writer);
}

let nDashCode = this.GetDashByCode(this.prstDash);
if(nDashCode !== null) {
Expand Down Expand Up @@ -8976,6 +8978,7 @@
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_XLSX) namespace_ = "xdr";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = "a";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = "cdr";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_PPTX) namespace_ = "p";

writer.WriteXmlNodeStart(namespace_ + ":cNvCxnSpPr");

Expand Down Expand Up @@ -9024,18 +9027,15 @@

writer.WriteXmlNodeEnd(namespace_ + ":cNvCxnSpPr");
};

CNvUniSpPr.prototype.toXmlGrFrame = function (writer) {

let namespace_ = "a";
let namespaceLock_ = "a";
let namespaceLockLink_ = "xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"";

if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_XLSX) namespace_ = "xdr";
if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DOCX ||
writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DOCX_GLOSSARY) {
namespaceLock_ = "a";
namespaceLockLink_ = "xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\"";
namespace_ = "wp";
} else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = "a";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = "cdr";
Expand All @@ -9049,8 +9049,7 @@

writer.WriteXmlNodeStart(namespaceLock_ + ":graphicFrameLocks");


writer.WriteXmlNullableAttributeString("xmlns:" + namespaceLock_, namespaceLockLink_);
writer.WriteXmlAttributeString("xmlns:a", "http://schemas.openxmlformats.org/drawingml/2006/main");
writer.WriteXmlNullableAttributeBool("noChangeAspect", fGetLockValue(this.locks, AscFormat.LOCKS_MASKS.noChangeAspect));
writer.WriteXmlNullableAttributeBool("noDrilldown", fGetLockValue(this.locks, AscFormat.LOCKS_MASKS.noDrilldown));
writer.WriteXmlNullableAttributeBool("noGrp", fGetLockValue(this.locks, AscFormat.LOCKS_MASKS.noGrp));
Expand Down Expand Up @@ -9278,6 +9277,10 @@
this.cNvPr.fromXml(reader);
break;
}
case "cNvCxnSpPr":
case "cNvGraphicFramePr":
case "cNvGrpSpPr":
case "cNvPicPr":
case "cNvSpPr": {
this.nvUniSpPr.fromXml(reader);
break;
Expand All @@ -9288,6 +9291,12 @@
}
}
};
UniNvPr.prototype.getLocks = function() {
if(this.nvUniSpPr) {
return this.nvUniSpPr.locks;
}
return 0;
};
UniNvPr.prototype.toXmlGrFrame = function (writer) {
let namespace_ = "a";
if ((writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DOCX ||
Expand Down Expand Up @@ -9330,6 +9339,7 @@
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_GRAPHICS) namespace_ = "a";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_CHART_DRAWING) namespace_ = "cdr";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DIAGRAM) namespace_ = "dgm";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_PPTX) namespace_ = "p";

writer.WriteXmlNodeStart(namespace_ + ":nvCxnSpPr");
writer.WriteXmlAttributesEnd();
Expand Down Expand Up @@ -10548,6 +10558,9 @@
CSpPr.prototype.setXfrm = function (pr) {
History.Add(new CChangesDrawingsObject(this, AscDFH.historyitem_SpPr_SetXfrm, this.xfrm, pr));
this.xfrm = pr;
if(pr) {
pr.setParent(this);
}
};
CSpPr.prototype.setGeometry = function (pr) {
History.Add(new CChangesDrawingsObject(this, AscDFH.historyitem_SpPr_SetGeometry, this.geometry, pr));
Expand Down Expand Up @@ -10665,6 +10678,7 @@
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_DSP_DRAWING) name_ = "dsp:spPr";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_CHART) name_ = "c:spPr";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_GRAPHICS) name_ = "a:spPr";
else if (writer.context.docType === AscFormat.XMLWRITER_DOC_TYPE_CHART_STYLE) name_ = "cs:spPr";
else {//theme
if (0 !== (writer.context.flag & 0x04)) name_ = "a:spPr";
else name_ = "p:spPr";
Expand Down Expand Up @@ -12448,8 +12462,15 @@

writer.context.groupIndex++;

for (let i = 0; i < this.spTree.length; ++i)
this.spTree[i].toXml(writer);
for (let i = 0; i < this.spTree.length; ++i) {
let oSp = this.spTree[i];
let nType = oSp.getObjectType();
let oElement = oSp;
if(nType === AscDFH.historyitem_type_ChartSpace || nType === AscDFH.historyitem_type_SmartArt) {
oElement = AscFormat.CGraphicFrame.prototype.static_CreateGraphicFrameFromDrawing(oSp);
}
oElement.toXml(writer);
}

writer.context.groupIndex--;

Expand Down Expand Up @@ -13964,7 +13985,7 @@
writer.WriteXmlNullableAttributeBool("compatLnSpc", this.compatLnSpc);
writer.WriteXmlAttributesEnd();

writer.WriteXmlNullable(this.prstTxWarp, "prstTxWarp");
writer.WriteXmlNullable(this.prstTxWarp, sNamespace_ + ":prstTxWarp");
writer.WriteXmlNullable(this.textFit);
//writer.WriteXmlNullable(this.scene3d);
//writer.WriteXmlNullable(this.sp3d);
Expand Down
39 changes: 18 additions & 21 deletions common/Drawings/Format/Geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -1671,20 +1671,19 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
break;
}
}
if(bEmptyLst) {
if (bEmptyLst)
writer.WriteXmlString("<" + name + "/>");
else {
writer.WriteXmlNodeStart(name);
writer.WriteXmlAttributesEnd();
for(let nGd = 0; nGd < this.gdLstInfo.length; ++nGd) {
let oGd = this.gdLstInfo[nGd];
if(!this.avLst[oGd.name]) {
CGuide.prototype.toXml(writer, oGd);
}

if (bEmptyLst)
writer.WriteXmlString("<" + name + "/>");
else {
writer.WriteXmlNodeStart(name);
writer.WriteXmlAttributesEnd();
for(let nGd = 0; nGd < this.gdLstInfo.length; ++nGd) {
let oGd = this.gdLstInfo[nGd];
if(!this.avLst[oGd.name]) {
CGuide.prototype.toXml(writer, oGd);
}
writer.WriteXmlNodeEnd(name);
}
writer.WriteXmlNodeEnd(name);
}
};
Geometry.prototype.writeAhLst = function(writer) {
Expand All @@ -1709,7 +1708,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
};
Geometry.prototype.writeCxnLst = function(writer) {
let name = "a:cxnLst";
if(this.rectS) {
if(this.cnxLstInfo.length === 0) {
writer.WriteXmlString("<" + name + "/>");
}
else {
Expand All @@ -1723,10 +1722,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
}
};
Geometry.prototype.writeRect = function(writer) {
let bEmptyLst = true;
let name = "a:rect";
bEmptyLst = this.cnxLstInfo.length === 0 ;
if(bEmptyLst) {
if(!this.rectS) {
writer.WriteXmlString("<a:rect l=\"0\" t=\"0\" r=\"r\" b=\"b\"/>");
}
else {
Expand All @@ -1751,14 +1747,15 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
writer.WriteXmlNodeEnd(name);
}
};
Geometry.prototype.toXml = function (writer) {
Geometry.prototype.toXml = function (writer, sName) {
if(this.preset !== null && this.preset !== "") {
writer.WriteXmlNodeStart("a:prstGeom");
let sName_ = sName || "a:prstGeom";
writer.WriteXmlNodeStart(sName_);

writer.WriteXmlNullableAttributeString("prst", this.preset);
writer.WriteXmlAttributesEnd();
this.writeAvLst(writer);
writer.WriteXmlNodeEnd("a:prstGeom");
writer.WriteXmlNodeEnd(sName_);
}
else {
writer.WriteXmlNodeStart("a:custGeom");
Expand Down Expand Up @@ -2085,7 +2082,7 @@ function CChangesGeometryAddAdj(Class, Name, OldValue, NewValue, OldAvValue, bRe
}
};
CGuide.prototype.toXml = function(writer, oGd) {
let sFmla = MAP_TYPE_TO_FMLA[oGd.fmla];
let sFmla = MAP_TYPE_TO_FMLA[oGd.formula];
if(sFmla) {
writer.WriteXmlNodeStart("a:gd");
writer.WriteXmlNullableAttributeString("name", oGd.name);
Expand Down
Loading