diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 03b9c21123..17c81ddc19 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -637,7 +637,7 @@ pWriter._WriteUInt2(2, this.lineEx.startSize); pWriter._WriteUInt2(3, this.lineEx.end); pWriter._WriteUInt2(4, this.lineEx.endSize); - // pWriter._WriteUInt2(5, this.lineEx.pattern); + pWriter._WriteUInt2(5, this.lineEx.pattern); pWriter.WriteUChar(AscCommon.g_nodeAttributeEnd); pWriter.EndRecord(); if (Object.keys(this.sketch).length > 0) { @@ -651,8 +651,9 @@ pWriter.EndRecord(); } }; + function CVariationClrScheme() { - CBaseNoIdObject.call(this); + CBaseFormatNoIdObject.call(this); /** * * @type {*} @@ -664,7 +665,40 @@ */ this.varColor = []; } - InitClass(CVariationClrScheme, CBaseNoIdObject, 0); + InitClass(CVariationClrScheme, CBaseFormatNoIdObject, 0); + CVariationClrScheme.prototype.readAttribute = undefined; + /** + * Read children from stream for CVariationClrScheme + * + * @param {number} elementType - The type of the element to read + * @param {CBinaryFileReader} pReader - The binary reader + * @return {boolean} True if the element was read, false otherwise + */ + CVariationClrScheme.prototype.readChild = function(elementType, pReader) { + let handled = true; + if (0 <= elementType && elementType < 7) { + let varColor = new CVarColor(); + varColor.unicolor = pReader.ReadUniColor(); + this.varColor[elementType] = varColor; + } else { + handled = false; + } + return handled; + } + CVariationClrScheme.prototype.privateWriteAttributes = undefined; + /** + * Write children to stream for CLineStyle + * + * @param {CBinaryFileWriter} pWriter - The binary writer + */ + CVariationClrScheme.prototype.writeChildren = function(pWriter) { + for (let i = 0; i < this.varColor.length; i++) { + if (!this.varColor[i] || !this.varColor[i].unicolor) { + continue; + } + pWriter.WriteRecord1(i, this.varColor[i].unicolor, pWriter.WriteUniColor); + } + }; function CVarColor() { CBaseNoIdObject.call(this); diff --git a/common/Shapes/Serialize.js b/common/Shapes/Serialize.js index 4cb45aa071..daf550aeb7 100644 --- a/common/Shapes/Serialize.js +++ b/common/Shapes/Serialize.js @@ -3634,6 +3634,7 @@ function BinaryPPTYLoader() this.ReadClrScheme = function(clrscheme) { + const t = this; var s = this.stream; var _e = s.cur + s.GetULong() + 4; @@ -3652,8 +3653,45 @@ function BinaryPPTYLoader() while (s.cur < _e) { var _rec = s.GetUChar(); - - clrscheme.addColor(_rec,this.ReadUniColor()); + if (_rec === 20) + { + AscFormat.CBaseFormatNoIdObject.prototype.fromPPTY.call({ + readChildren: AscFormat.CBaseFormatNoIdObject.prototype.readChildren, + readChild: function(elementType, pReader) { + if (elementType === 0) { + if (!clrscheme.clrSchemeExtLst) { + clrscheme.clrSchemeExtLst = new AscFormat.CClrSchemeExtLst(); + } + clrscheme.clrSchemeExtLst.background = new AscFormat.CVarColor(); + clrscheme.clrSchemeExtLst.background.unicolor = t.ReadUniColor(); + return true; + } + return false; + } + }, this); + } + else if (_rec === 21) + { + AscFormat.CBaseFormatNoIdObject.prototype.fromPPTY.call({ + readChildren: AscFormat.CBaseFormatNoIdObject.prototype.readChildren, + readChild: function(elementType, pReader) { + if (elementType === 0) { + if (!clrscheme.clrSchemeExtLst) { + clrscheme.clrSchemeExtLst = new AscFormat.CClrSchemeExtLst(); + } + let variationClrScheme = new AscFormat.CVariationClrScheme(); + variationClrScheme.fromPPTY(pReader); + clrscheme.clrSchemeExtLst.variationClrSchemeLst.push(variationClrScheme); + return true; + } + return false; + } + }, this); + } + else + { + clrscheme.addColor(_rec,this.ReadUniColor()); + } } s.Seek2(_e); diff --git a/common/Shapes/SerializeWriter.js b/common/Shapes/SerializeWriter.js index 8e06ca7425..9deed9349b 100644 --- a/common/Shapes/SerializeWriter.js +++ b/common/Shapes/SerializeWriter.js @@ -1752,6 +1752,24 @@ function CBinaryFileWriter() oThis.WriteRecord1(i, scheme.colors[i], oThis.WriteUniColor); } } + if (scheme.clrSchemeExtLst) + { + if (scheme.clrSchemeExtLst.background && scheme.clrSchemeExtLst.background.unicolor) + { + oThis.StartRecord(20); + oThis.WriteRecord1(0, scheme.clrSchemeExtLst.background.unicolor, oThis.WriteUniColor); + oThis.EndRecord(); + } + if (scheme.clrSchemeExtLst.variationClrSchemeLst.length > 0) + { + oThis.StartRecord(21); + for (let i = 0; i < scheme.clrSchemeExtLst.variationClrSchemeLst.length; i++) + { + oThis.WriteRecordPPTY(0, scheme.clrSchemeExtLst.variationClrSchemeLst[i]); + } + oThis.EndRecord(); + } + } }; this.WriteClrMapOvr = function(clrmapovr) {