From e9c081b7404d66fc8e1105eb72b69e525c32a66e Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Mon, 28 Jul 2025 10:33:47 +0300 Subject: [PATCH 01/10] [ve] Create GenerateDefaultTheme() override with same version as before --- visio/model/overrides.js | 149 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) diff --git a/visio/model/overrides.js b/visio/model/overrides.js index a1427626a0..a5b13ee3fe 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -815,6 +815,155 @@ AscCommonWord.CPresentationField.prototype.private_GetString = function() return sStr; }; +AscFormat.GenerateDefaultTheme = function GenerateDefaultTheme(presentation, opt_fontName) { + let phClr = 14; + return AscFormat.ExecuteNoHistory(function () { + if (!opt_fontName) { + opt_fontName = "Arial"; + } + var theme = new AscFormat.CTheme(); + theme.presentation = presentation; + theme.setFontScheme(new AscFormat.FontScheme()); + theme.themeElements.fontScheme.setMajorFont(new AscFormat.FontCollection(theme.themeElements.fontScheme)); + theme.themeElements.fontScheme.setMinorFont(new AscFormat.FontCollection(theme.themeElements.fontScheme)); + theme.themeElements.fontScheme.majorFont.setLatin(opt_fontName); + theme.themeElements.fontScheme.minorFont.setLatin(opt_fontName); + + + var scheme = theme.themeElements.clrScheme; + + scheme.colors[8] = AscFormat.CreateUniColorRGB(0, 0, 0); + scheme.colors[12] = AscFormat.CreateUniColorRGB(255, 255, 255); + scheme.colors[9] = AscFormat.CreateUniColorRGB(0x1F, 0x49, 0x7D); + scheme.colors[13] = AscFormat.CreateUniColorRGB(0xEE, 0xEC, 0xE1); + scheme.colors[0] = AscFormat.CreateUniColorRGB(0x4F, 0x81, 0xBD); //CreateUniColorRGB(0xFF, 0x81, 0xBD);// + scheme.colors[1] = AscFormat.CreateUniColorRGB(0xC0, 0x50, 0x4D); + scheme.colors[2] = AscFormat.CreateUniColorRGB(0x9B, 0xBB, 0x59); + scheme.colors[3] = AscFormat.CreateUniColorRGB(0x80, 0x64, 0xA2); + scheme.colors[4] = AscFormat.CreateUniColorRGB(0x4B, 0xAC, 0xC6); + scheme.colors[5] = AscFormat.CreateUniColorRGB(0xF7, 0x96, 0x46); + scheme.colors[11] = AscFormat.CreateUniColorRGB(0x00, 0x00, 0xFF); + scheme.colors[10] = AscFormat.CreateUniColorRGB(0x80, 0x00, 0x80); + + // -------------- fill styles ------------------------- + var brush = new AscFormat.CUniFill(); + brush.setFill(new AscFormat.CSolidFill()); + brush.fill.setColor(new AscFormat.CUniColor()); + brush.fill.color.setColor(new AscFormat.CSchemeColor()); + brush.fill.color.color.setId(phClr); + theme.themeElements.fmtScheme.fillStyleLst.push(brush); + + brush = new AscFormat.CUniFill(); + + let oFill = new AscFormat.CGradFill(); + oFill.rotateWithShape = true; + brush.setFill(oFill); + let oLin = new AscFormat.GradLin(); + oFill.setLin(oLin); + oLin.setAngle(16200000); + oLin.setScale(true); + let oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(0); + + let oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 50000}, {name: "satMod", val: 300000}]); + oGs.setColor(oColor); + + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(35000); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 37000}, {name: "satMod", val: 300000}]); + oGs.setColor(oColor); + + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(100000); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 15000}, {name: "satMod", val: 350000}]); + oGs.setColor(oColor); + + theme.themeElements.fmtScheme.fillStyleLst.push(brush); + + brush = new AscFormat.CUniFill(); + + oFill = new AscFormat.CGradFill(); + brush.setFill(oFill); + oFill.rotateWithShape = true; + oLin = new AscFormat.GradLin(); + oFill.setLin(oLin); + oLin.setAngle(16200000); + oLin.setScale(false); + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(0); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 51000}, {name: "satMod", val: 130000}]); + oGs.setColor(oColor); + + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(80000); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 93000}, {name: "satMod", val: 130000}]); + oGs.setColor(oColor); + + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(100000); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 94000}, {name: "satMod", val: 135000}]); + oGs.setColor(oColor); + + theme.themeElements.fmtScheme.fillStyleLst.push(brush); + // ---------------------------------------------------- + + // -------------- back styles ------------------------- + brush = new AscFormat.CUniFill(); + brush.setFill(new AscFormat.CSolidFill()); + brush.fill.setColor(new AscFormat.CUniColor()); + brush.fill.color.setColor(new AscFormat.CSchemeColor()); + brush.fill.color.color.setId(phClr); + theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); + + brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0)); + theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); + + brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0)); + theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); + // ---------------------------------------------------- + + var pen = new AscFormat.CLn(); + pen.setW(9525); + pen.setFill(new AscFormat.CUniFill()); + pen.Fill.setFill(new AscFormat.CSolidFill()); + pen.Fill.fill.setColor(new AscFormat.CUniColor()); + pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); + pen.Fill.fill.color.color.setId(phClr); + pen.Fill.fill.color.setMods(new AscFormat.CColorModifiers()); + + pen.Fill.fill.color.Mods.addMod("shade", 95000); + pen.Fill.fill.color.Mods.addMod("satMod", 105000); + theme.themeElements.fmtScheme.lnStyleLst.push(pen); + + pen = new AscFormat.CLn(); + pen.setW(25400); + pen.setFill(new AscFormat.CUniFill()); + pen.Fill.setFill(new AscFormat.CSolidFill()); + + pen.Fill.fill.setColor(new AscFormat.CUniColor()); + pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); + pen.Fill.fill.color.color.setId(phClr); + theme.themeElements.fmtScheme.lnStyleLst.push(pen); + + pen = new AscFormat.CLn(); + pen.setW(38100); + pen.setFill(new AscFormat.CUniFill()); + pen.Fill.setFill(new AscFormat.CSolidFill()); + pen.Fill.fill.setColor(new AscFormat.CUniColor()); + pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); + pen.Fill.fill.color.color.setId(phClr); + theme.themeElements.fmtScheme.lnStyleLst.push(pen); + theme.extraClrSchemeLst = []; + return theme; + }, this, []); +} + //todo CMobileDelegateEditorDiagram AscCommon.CMobileDelegateEditorPresentation.prototype.GetObjectTrack = function(x, y, page, bSelected, bText) { return false; } AscCommon.CMobileDelegateEditorPresentation.prototype.GetSelectionRectsBounds = function () { return null; } From 88c2a9eda9c5fab9b5c424bb2b28e8442bc5c8a8 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Mon, 28 Jul 2025 17:21:32 +0300 Subject: [PATCH 02/10] [ve] Add more checks for theme values --- visio/model/overrides.js | 28 +++++++++++++++------------- visio/model/visioFunctionsApi.js | 3 ++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/visio/model/overrides.js b/visio/model/overrides.js index a5b13ee3fe..556ae2fcd8 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -156,20 +156,22 @@ AscFormat.CTheme.prototype.getFillStyle = function (idx, unicolor, isConnectorSh let fmtScheme = (isConnectorShape && this.themeElements.themeExt) ? this.themeElements.themeExt.fmtConnectorScheme : this.themeElements.fmtScheme; - if (idx >= 1 && idx <= 999) { - if (fmtScheme.fillStyleLst[idx - 1]) { - ret = fmtScheme.fillStyleLst[idx - 1].createDuplicate(); - if (ret) { - ret.checkPhColor(unicolor, false); - return ret; + if (fmtScheme) { + if (idx >= 1 && idx <= 999) { + if (fmtScheme.fillStyleLst[idx - 1]) { + ret = fmtScheme.fillStyleLst[idx - 1].createDuplicate(); + if (ret) { + ret.checkPhColor(unicolor, false); + return ret; + } } - } - } else if (idx >= 1001) { - if (fmtScheme.bgFillStyleLst[idx - 1001]) { - ret = fmtScheme.bgFillStyleLst[idx - 1001].createDuplicate(); - if (ret) { - ret.checkPhColor(unicolor, false); - return ret; + } else if (idx >= 1001) { + if (fmtScheme.bgFillStyleLst[idx - 1001]) { + ret = fmtScheme.bgFillStyleLst[idx - 1001].createDuplicate(); + if (ret) { + ret.checkPhColor(unicolor, false); + return ret; + } } } } diff --git a/visio/model/visioFunctionsApi.js b/visio/model/visioFunctionsApi.js index a92f586174..7393d3dca1 100644 --- a/visio/model/visioFunctionsApi.js +++ b/visio/model/visioFunctionsApi.js @@ -446,7 +446,8 @@ result = getMedifiersResult && getMedifiersResult.fontPropsObject.color; } else if (cellName === "FillForegnd" || cellName === "FillBkgnd") { //leave result because it is fill - if (getMedifiersResult.fill.type === Asc.c_oAscFill.FILL_TYPE_PATT) { + if (getMedifiersResult && getMedifiersResult.fill && + getMedifiersResult.fill.type === Asc.c_oAscFill.FILL_TYPE_PATT) { let uniColor; if (cellName === "FillForegnd") { uniColor = getMedifiersResult.fill.fgClr; From 66b2684876828fa507c29306ff927458275781e0 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Mon, 28 Jul 2025 17:22:12 +0300 Subject: [PATCH 03/10] [ve] Change some theme values --- visio/model/overrides.js | 145 +++++++++------------------------------ 1 file changed, 31 insertions(+), 114 deletions(-) diff --git a/visio/model/overrides.js b/visio/model/overrides.js index 556ae2fcd8..5c133bd1a5 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -821,7 +821,7 @@ AscFormat.GenerateDefaultTheme = function GenerateDefaultTheme(presentation, opt let phClr = 14; return AscFormat.ExecuteNoHistory(function () { if (!opt_fontName) { - opt_fontName = "Arial"; + opt_fontName = "Calibri"; } var theme = new AscFormat.CTheme(); theme.presentation = presentation; @@ -834,134 +834,51 @@ AscFormat.GenerateDefaultTheme = function GenerateDefaultTheme(presentation, opt var scheme = theme.themeElements.clrScheme; + // TODO where are link colors? scheme.colors[8] = AscFormat.CreateUniColorRGB(0, 0, 0); scheme.colors[12] = AscFormat.CreateUniColorRGB(255, 255, 255); - scheme.colors[9] = AscFormat.CreateUniColorRGB(0x1F, 0x49, 0x7D); - scheme.colors[13] = AscFormat.CreateUniColorRGB(0xEE, 0xEC, 0xE1); - scheme.colors[0] = AscFormat.CreateUniColorRGB(0x4F, 0x81, 0xBD); //CreateUniColorRGB(0xFF, 0x81, 0xBD);// - scheme.colors[1] = AscFormat.CreateUniColorRGB(0xC0, 0x50, 0x4D); - scheme.colors[2] = AscFormat.CreateUniColorRGB(0x9B, 0xBB, 0x59); - scheme.colors[3] = AscFormat.CreateUniColorRGB(0x80, 0x64, 0xA2); - scheme.colors[4] = AscFormat.CreateUniColorRGB(0x4B, 0xAC, 0xC6); - scheme.colors[5] = AscFormat.CreateUniColorRGB(0xF7, 0x96, 0x46); - scheme.colors[11] = AscFormat.CreateUniColorRGB(0x00, 0x00, 0xFF); + scheme.colors[9] = AscFormat.CreateUniColorRGB(0, 0, 0); + scheme.colors[13] = AscFormat.CreateUniColorRGB(255, 255, 255); + scheme.colors[0] = AscFormat.CreateUniColorRGB(0, 0, 0); //CreateUniColorRGB(0xFF, 0x81, 0xBD);// + scheme.colors[1] = AscFormat.CreateUniColorRGB(0, 0, 0); + scheme.colors[2] = AscFormat.CreateUniColorRGB(0, 0, 0); + scheme.colors[3] = AscFormat.CreateUniColorRGB(0, 0, 0); + scheme.colors[4] = AscFormat.CreateUniColorRGB(0, 0, 0); + scheme.colors[5] = AscFormat.CreateUniColorRGB(0, 0, 0); + scheme.colors[11] = AscFormat.CreateUniColorRGB(0x05, 0x63, 0xC1); scheme.colors[10] = AscFormat.CreateUniColorRGB(0x80, 0x00, 0x80); - // -------------- fill styles ------------------------- - var brush = new AscFormat.CUniFill(); - brush.setFill(new AscFormat.CSolidFill()); - brush.fill.setColor(new AscFormat.CUniColor()); - brush.fill.color.setColor(new AscFormat.CSchemeColor()); - brush.fill.color.color.setId(phClr); - theme.themeElements.fmtScheme.fillStyleLst.push(brush); - - brush = new AscFormat.CUniFill(); - - let oFill = new AscFormat.CGradFill(); - oFill.rotateWithShape = true; - brush.setFill(oFill); - let oLin = new AscFormat.GradLin(); - oFill.setLin(oLin); - oLin.setAngle(16200000); - oLin.setScale(true); - let oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(0); - - let oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 50000}, {name: "satMod", val: 300000}]); - oGs.setColor(oColor); - - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(35000); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 37000}, {name: "satMod", val: 300000}]); - oGs.setColor(oColor); - - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(100000); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 15000}, {name: "satMod", val: 350000}]); - oGs.setColor(oColor); - - theme.themeElements.fmtScheme.fillStyleLst.push(brush); - - brush = new AscFormat.CUniFill(); - - oFill = new AscFormat.CGradFill(); - brush.setFill(oFill); - oFill.rotateWithShape = true; - oLin = new AscFormat.GradLin(); - oFill.setLin(oLin); - oLin.setAngle(16200000); - oLin.setScale(false); - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(0); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 51000}, {name: "satMod", val: 130000}]); - oGs.setColor(oColor); - - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(80000); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 93000}, {name: "satMod", val: 130000}]); - oGs.setColor(oColor); - - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(100000); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 94000}, {name: "satMod", val: 135000}]); - oGs.setColor(oColor); - - theme.themeElements.fmtScheme.fillStyleLst.push(brush); + var brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(255, 255, 255)); + for (let i = 0; i < 6; i++) { + theme.themeElements.fmtScheme.fillStyleLst.push(brush); + } // ---------------------------------------------------- // -------------- back styles ------------------------- - brush = new AscFormat.CUniFill(); - brush.setFill(new AscFormat.CSolidFill()); - brush.fill.setColor(new AscFormat.CUniColor()); - brush.fill.color.setColor(new AscFormat.CSchemeColor()); - brush.fill.color.color.setId(phClr); - theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); - - brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0)); - theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); - - brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0)); - theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); + var brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(255, 255, 255)); + for (let i = 0; i < 6; i++) { + theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); + } // ---------------------------------------------------- var pen = new AscFormat.CLn(); pen.setW(9525); - pen.setFill(new AscFormat.CUniFill()); - pen.Fill.setFill(new AscFormat.CSolidFill()); - pen.Fill.fill.setColor(new AscFormat.CUniColor()); - pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); - pen.Fill.fill.color.color.setId(phClr); + pen.setFill(AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0))); pen.Fill.fill.color.setMods(new AscFormat.CColorModifiers()); - pen.Fill.fill.color.Mods.addMod("shade", 95000); - pen.Fill.fill.color.Mods.addMod("satMod", 105000); - theme.themeElements.fmtScheme.lnStyleLst.push(pen); + for (let i = 0; i < 6; i++) { + theme.themeElements.fmtScheme.lnStyleLst.push(pen); + } - pen = new AscFormat.CLn(); - pen.setW(25400); - pen.setFill(new AscFormat.CUniFill()); - pen.Fill.setFill(new AscFormat.CSolidFill()); - - pen.Fill.fill.setColor(new AscFormat.CUniColor()); - pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); - pen.Fill.fill.color.color.setId(phClr); - theme.themeElements.fmtScheme.lnStyleLst.push(pen); - - pen = new AscFormat.CLn(); - pen.setW(38100); - pen.setFill(new AscFormat.CUniFill()); - pen.Fill.setFill(new AscFormat.CSolidFill()); - pen.Fill.fill.setColor(new AscFormat.CUniColor()); - pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); - pen.Fill.fill.color.color.setId(phClr); - theme.themeElements.fmtScheme.lnStyleLst.push(pen); theme.extraClrSchemeLst = []; + + theme.themeElements.themeExt = new AscFormat.CThemeExt(); + theme.themeElements.themeExt.themeSchemeSchemeEnum = "0"; + + theme.themeElements.clrScheme.clrSchemeExtLst = new AscFormat.CClrSchemeExtLst(); + theme.themeElements.clrScheme.clrSchemeExtLst.schemeEnum = "0"; + + return theme; }, this, []); } From 5b05241f3fab4c397f0d35c4ceaefd06a7eafd88 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Mon, 28 Jul 2025 17:35:09 +0300 Subject: [PATCH 04/10] [ve] Fix themes toZip in CVisioDocument.prototype.toZip --- visio/model/VisioDocument.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/visio/model/VisioDocument.js b/visio/model/VisioDocument.js index 67fb04b5e1..b34012a599 100644 --- a/visio/model/VisioDocument.js +++ b/visio/model/VisioDocument.js @@ -268,7 +268,6 @@ AscDFH.historyitem_type_VisioWindow = 328; let thumbNailPart = filePart.addPart(AscCommon.openXml.Types.thumbnail); let windowsPart = docPart.part.addPart(AscCommon.openXml.Types.visioDocumentWindows); let mastersPart = docPart.part.addPart(AscCommon.openXml.Types.masters); - let themesPart = docPart.part.addPart(AscCommon.openXml.Types.theme); let commentsPart = docPart.part.addPart(AscCommon.openXml.Types.visioComments); let extensionsPart = docPart.part.addPart(AscCommon.openXml.Types.visioExtensions); let dataConnectionsPart = docPart.part.addPart(AscCommon.openXml.Types.visioDataConnections); @@ -306,6 +305,11 @@ AscDFH.historyitem_type_VisioWindow = 328; } } + for (let i = 0; i < this.themes.length; i++) { + let themeContent = docPart.part.addPart(AscCommon.openXml.Types.theme); + themeContent.part.setDataXml(this.themes[i], memory); + } + // Not realized, file defines schema and data of that schema for (let i = 0; i < this.solutionXMLs.length; i++) { let solutionContent = solutionsPart.part.addPart(AscCommon.openXml.Types.solution); @@ -330,10 +334,6 @@ AscDFH.historyitem_type_VisioWindow = 328; mastersPart.part.setDataXml(this.masters, memory); } pagesPart.part.setDataXml(this.pages, memory); - for (let i = 0; i < this.themes.length; i++) { - let themeContent = themesPart.part.addPart(AscCommon.openXml.Types.theme); - themeContent.part.setDataXml(this.themes[i], memory); - } if (this.commentsPart) { commentsPart.part.setDataXml(this.commentsPart, memory); } From 81ab5114206d1862195b3997f1db307fc52f7fe0 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Wed, 6 Aug 2025 17:51:19 +0300 Subject: [PATCH 05/10] [ve] Fix theme save for non binary --- visio/model/VisioDocument.js | 7 +- visio/model/overrides.js | 139 +++++++++++++++++++++++++++++------ 2 files changed, 121 insertions(+), 25 deletions(-) diff --git a/visio/model/VisioDocument.js b/visio/model/VisioDocument.js index b34012a599..ef0a0048ee 100644 --- a/visio/model/VisioDocument.js +++ b/visio/model/VisioDocument.js @@ -306,8 +306,11 @@ AscDFH.historyitem_type_VisioWindow = 328; } for (let i = 0; i < this.themes.length; i++) { - let themeContent = docPart.part.addPart(AscCommon.openXml.Types.theme); - themeContent.part.setDataXml(this.themes[i], memory); + let theme = this.themes[i]; + if (theme.themeElements.themeExt.themeSchemeSchemeEnum !== "0") { + let themeContent = docPart.part.addPart(AscCommon.openXml.Types.theme); + themeContent.part.setDataXml(theme, memory); + } } // Not realized, file defines schema and data of that schema diff --git a/visio/model/overrides.js b/visio/model/overrides.js index 5c133bd1a5..5916f5f4bb 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -834,42 +834,134 @@ AscFormat.GenerateDefaultTheme = function GenerateDefaultTheme(presentation, opt var scheme = theme.themeElements.clrScheme; - // TODO where are link colors? + // TODO change colors scheme.colors[8] = AscFormat.CreateUniColorRGB(0, 0, 0); scheme.colors[12] = AscFormat.CreateUniColorRGB(255, 255, 255); - scheme.colors[9] = AscFormat.CreateUniColorRGB(0, 0, 0); - scheme.colors[13] = AscFormat.CreateUniColorRGB(255, 255, 255); - scheme.colors[0] = AscFormat.CreateUniColorRGB(0, 0, 0); //CreateUniColorRGB(0xFF, 0x81, 0xBD);// - scheme.colors[1] = AscFormat.CreateUniColorRGB(0, 0, 0); - scheme.colors[2] = AscFormat.CreateUniColorRGB(0, 0, 0); - scheme.colors[3] = AscFormat.CreateUniColorRGB(0, 0, 0); - scheme.colors[4] = AscFormat.CreateUniColorRGB(0, 0, 0); - scheme.colors[5] = AscFormat.CreateUniColorRGB(0, 0, 0); - scheme.colors[11] = AscFormat.CreateUniColorRGB(0x05, 0x63, 0xC1); - scheme.colors[10] = AscFormat.CreateUniColorRGB(0x80, 0x00, 0x80); + scheme.colors[9] = AscFormat.CreateUniColorRGB(0x1F, 0x49, 0x7D); + scheme.colors[13] = AscFormat.CreateUniColorRGB(0xEE, 0xEC, 0xE1); + scheme.colors[0] = AscFormat.CreateUniColorRGB(0x4F, 0x81, 0xBD); //CreateUniColorRGB(0xFF, 0x81, 0xBD);// + scheme.colors[1] = AscFormat.CreateUniColorRGB(0xC0, 0x50, 0x4D); + scheme.colors[2] = AscFormat.CreateUniColorRGB(0x9B, 0xBB, 0x59); + scheme.colors[3] = AscFormat.CreateUniColorRGB(0x80, 0x64, 0xA2); + scheme.colors[4] = AscFormat.CreateUniColorRGB(0x4B, 0xAC, 0xC6); + scheme.colors[5] = AscFormat.CreateUniColorRGB(0xF7, 0x96, 0x46); + scheme.colors[11] = AscFormat.CreateUniColorRGB(0x05, 0x63, 0xC1); // link + scheme.colors[10] = AscFormat.CreateUniColorRGB(0x80, 0x00, 0x80); // followed link + // -------------- fill styles ------------------------- - var brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(255, 255, 255)); - for (let i = 0; i < 6; i++) { - theme.themeElements.fmtScheme.fillStyleLst.push(brush); - } + var brush = new AscFormat.CUniFill(); + brush.setFill(new AscFormat.CSolidFill()); + brush.fill.setColor(new AscFormat.CUniColor()); + brush.fill.color.setColor(new AscFormat.CSchemeColor()); + brush.fill.color.color.setId(phClr); + theme.themeElements.fmtScheme.fillStyleLst.push(brush); + + brush = new AscFormat.CUniFill(); + + let oFill = new AscFormat.CGradFill(); + oFill.rotateWithShape = true; + brush.setFill(oFill); + let oLin = new AscFormat.GradLin(); + oFill.setLin(oLin); + oLin.setAngle(16200000); + oLin.setScale(true); + let oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(0); + + let oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 50000}, {name: "satMod", val: 300000}]); + oGs.setColor(oColor); + + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(35000); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 37000}, {name: "satMod", val: 300000}]); + oGs.setColor(oColor); + + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(100000); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 15000}, {name: "satMod", val: 350000}]); + oGs.setColor(oColor); + + theme.themeElements.fmtScheme.fillStyleLst.push(brush); + + brush = new AscFormat.CUniFill(); + + oFill = new AscFormat.CGradFill(); + brush.setFill(oFill); + oFill.rotateWithShape = true; + oLin = new AscFormat.GradLin(); + oFill.setLin(oLin); + oLin.setAngle(16200000); + oLin.setScale(false); + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(0); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 51000}, {name: "satMod", val: 130000}]); + oGs.setColor(oColor); + + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(80000); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 93000}, {name: "satMod", val: 130000}]); + oGs.setColor(oColor); + + oGs = new AscFormat.CGs(); + oFill.addColor(oGs); + oGs.setPos(100000); + oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 94000}, {name: "satMod", val: 135000}]); + oGs.setColor(oColor); + + theme.themeElements.fmtScheme.fillStyleLst.push(brush); // ---------------------------------------------------- // -------------- back styles ------------------------- - var brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(255, 255, 255)); - for (let i = 0; i < 6; i++) { - theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); - } + brush = new AscFormat.CUniFill(); + brush.setFill(new AscFormat.CSolidFill()); + brush.fill.setColor(new AscFormat.CUniColor()); + brush.fill.color.setColor(new AscFormat.CSchemeColor()); + brush.fill.color.color.setId(phClr); + theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); + + brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0)); + theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); + + brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0)); + theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); // ---------------------------------------------------- var pen = new AscFormat.CLn(); pen.setW(9525); - pen.setFill(AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0))); + pen.setFill(new AscFormat.CUniFill()); + pen.Fill.setFill(new AscFormat.CSolidFill()); + pen.Fill.fill.setColor(new AscFormat.CUniColor()); + pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); + pen.Fill.fill.color.color.setId(phClr); pen.Fill.fill.color.setMods(new AscFormat.CColorModifiers()); - for (let i = 0; i < 6; i++) { - theme.themeElements.fmtScheme.lnStyleLst.push(pen); - } + pen.Fill.fill.color.Mods.addMod("shade", 95000); + pen.Fill.fill.color.Mods.addMod("satMod", 105000); + theme.themeElements.fmtScheme.lnStyleLst.push(pen); + pen = new AscFormat.CLn(); + pen.setW(25400); + pen.setFill(new AscFormat.CUniFill()); + pen.Fill.setFill(new AscFormat.CSolidFill()); + + pen.Fill.fill.setColor(new AscFormat.CUniColor()); + pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); + pen.Fill.fill.color.color.setId(phClr); + theme.themeElements.fmtScheme.lnStyleLst.push(pen); + + pen = new AscFormat.CLn(); + pen.setW(38100); + pen.setFill(new AscFormat.CUniFill()); + pen.Fill.setFill(new AscFormat.CSolidFill()); + pen.Fill.fill.setColor(new AscFormat.CUniColor()); + pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); + pen.Fill.fill.color.color.setId(phClr); + theme.themeElements.fmtScheme.lnStyleLst.push(pen); theme.extraClrSchemeLst = []; theme.themeElements.themeExt = new AscFormat.CThemeExt(); @@ -878,6 +970,7 @@ AscFormat.GenerateDefaultTheme = function GenerateDefaultTheme(presentation, opt theme.themeElements.clrScheme.clrSchemeExtLst = new AscFormat.CClrSchemeExtLst(); theme.themeElements.clrScheme.clrSchemeExtLst.schemeEnum = "0"; + theme.themeElements.themeExt.fmtConnectorScheme = new AscFormat.FmtScheme(); return theme; }, this, []); From bddb93ccff8c48c5783ef4fe4dbc9f41994b5c93 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Mon, 11 Aug 2025 17:07:02 +0300 Subject: [PATCH 06/10] [ve] Get error when create default theme and don't save it --- visio/model/SerializeWriter.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/visio/model/SerializeWriter.js b/visio/model/SerializeWriter.js index ebb85e4e76..4a8767ae59 100644 --- a/visio/model/SerializeWriter.js +++ b/visio/model/SerializeWriter.js @@ -228,9 +228,13 @@ if (this.themes) { for (let i = 0; i < this.themes.length; i++) { - pWriter.StartRecord(15); - pWriter.WriteTheme(this.themes[i]); - pWriter.EndRecord(); + let theme = this.themes[i]; + // theme with id 0 is default theme (no theme in visio) - this theme should not be saved + if (theme.themeElements.themeExt.themeSchemeSchemeEnum !== "0") { + pWriter.StartRecord(15); + pWriter.WriteTheme(theme); + pWriter.EndRecord(); + } } } //todo VbaProject From 8666102dff5e8f0dbf1324b87e8ce94fc8ef562e Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Wed, 13 Aug 2025 17:46:16 +0300 Subject: [PATCH 07/10] [ve] Use GetDefaultTheme istead of GenerateDefaultTheme --- visio/model/VisioDocument.js | 2 +- visio/model/overrides.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/visio/model/VisioDocument.js b/visio/model/VisioDocument.js index ef0a0048ee..ab11c36cc4 100644 --- a/visio/model/VisioDocument.js +++ b/visio/model/VisioDocument.js @@ -361,7 +361,7 @@ AscDFH.historyitem_type_VisioWindow = 328; CVisioDocument.prototype.AfterOpenDocument = function(zip, context) { if (!this.themes.length) { AscCommon.consoleLog("No themes found by filenames. Creating default theme"); - this.themes.push(AscFormat.GenerateDefaultTheme(null, null)); + this.themes.push(AscFormat.GetDefaultTheme()); } }; diff --git a/visio/model/overrides.js b/visio/model/overrides.js index 5916f5f4bb..e5a83269fe 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -51,8 +51,8 @@ AscFormat.CShape.prototype.getParentObjects = function () if (this.parent) { oTheme = this.parent.themes[0]; } else { - AscCommon.consoleLog("Parent was not set for shape/group. GenerateDefaultTheme is used. shape/group:", this); - oTheme = AscFormat.GenerateDefaultTheme(null, null); + AscCommon.consoleLog("Parent was not set for shape/group. GetDefaultTheme will be used. shape/group:", this); + oTheme = AscFormat.GetDefaultTheme(); } return {slide: null, layout: null, master: null, theme: oTheme}; }; From 7dc7b34e6a6cb5ef0bab26bce3804fb52ba3db0a Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Wed, 13 Aug 2025 17:47:46 +0300 Subject: [PATCH 08/10] [ve] Don't override GenerateDefaultTheme but override GetDefaultTheme --- common/Drawings/Format/Format.js | 25 +++++ visio/model/overrides.js | 162 +------------------------------ 2 files changed, 30 insertions(+), 157 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 1911f1ed17..6c470a2724 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -16158,6 +16158,29 @@ }, this, []); } + /** + * Don't use this method. Use GetDefaultTheme + * @return {CTheme} + */ + function generateDefaultVisioTheme() { + let theme = GenerateDefaultTheme(null, "Calibri"); + let scheme = theme.themeElements.clrScheme; + // TODO change other colors + scheme.colors[11] = AscFormat.CreateUniColorRGB(0x05, 0x63, 0xC1); // link + scheme.colors[10] = AscFormat.CreateUniColorRGB(0x80, 0x00, 0x80); // followed link + + + theme.themeElements.themeExt = new AscFormat.CThemeExt(); + theme.themeElements.themeExt.themeSchemeSchemeEnum = "0"; + + theme.themeElements.clrScheme.clrSchemeExtLst = new AscFormat.CClrSchemeExtLst(); + theme.themeElements.clrScheme.clrSchemeExtLst.schemeEnum = "0"; + + theme.themeElements.themeExt.fmtConnectorScheme = new AscFormat.FmtScheme(); + + return theme; + } + function GetDefaultTheme() { if(!AscFormat.DEFAULT_THEME) { AscFormat.DEFAULT_THEME = GenerateDefaultTheme(null); @@ -20528,6 +20551,8 @@ window['AscFormat'].CFontProps = CFontProps; window['AscFormat'].CLineStyle = CLineStyle; + window['AscFormat'].generateDefaultVisioTheme = generateDefaultVisioTheme; + window["AscFormat"].RECT_ALIGN_B = RECT_ALIGN_B; window["AscFormat"].RECT_ALIGN_BL = RECT_ALIGN_BL; window["AscFormat"].RECT_ALIGN_BR = RECT_ALIGN_BR; diff --git a/visio/model/overrides.js b/visio/model/overrides.js index e5a83269fe..1d580f422b 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -817,163 +817,11 @@ AscCommonWord.CPresentationField.prototype.private_GetString = function() return sStr; }; -AscFormat.GenerateDefaultTheme = function GenerateDefaultTheme(presentation, opt_fontName) { - let phClr = 14; - return AscFormat.ExecuteNoHistory(function () { - if (!opt_fontName) { - opt_fontName = "Calibri"; - } - var theme = new AscFormat.CTheme(); - theme.presentation = presentation; - theme.setFontScheme(new AscFormat.FontScheme()); - theme.themeElements.fontScheme.setMajorFont(new AscFormat.FontCollection(theme.themeElements.fontScheme)); - theme.themeElements.fontScheme.setMinorFont(new AscFormat.FontCollection(theme.themeElements.fontScheme)); - theme.themeElements.fontScheme.majorFont.setLatin(opt_fontName); - theme.themeElements.fontScheme.minorFont.setLatin(opt_fontName); - - - var scheme = theme.themeElements.clrScheme; - - // TODO change colors - scheme.colors[8] = AscFormat.CreateUniColorRGB(0, 0, 0); - scheme.colors[12] = AscFormat.CreateUniColorRGB(255, 255, 255); - scheme.colors[9] = AscFormat.CreateUniColorRGB(0x1F, 0x49, 0x7D); - scheme.colors[13] = AscFormat.CreateUniColorRGB(0xEE, 0xEC, 0xE1); - scheme.colors[0] = AscFormat.CreateUniColorRGB(0x4F, 0x81, 0xBD); //CreateUniColorRGB(0xFF, 0x81, 0xBD);// - scheme.colors[1] = AscFormat.CreateUniColorRGB(0xC0, 0x50, 0x4D); - scheme.colors[2] = AscFormat.CreateUniColorRGB(0x9B, 0xBB, 0x59); - scheme.colors[3] = AscFormat.CreateUniColorRGB(0x80, 0x64, 0xA2); - scheme.colors[4] = AscFormat.CreateUniColorRGB(0x4B, 0xAC, 0xC6); - scheme.colors[5] = AscFormat.CreateUniColorRGB(0xF7, 0x96, 0x46); - scheme.colors[11] = AscFormat.CreateUniColorRGB(0x05, 0x63, 0xC1); // link - scheme.colors[10] = AscFormat.CreateUniColorRGB(0x80, 0x00, 0x80); // followed link - - // -------------- fill styles ------------------------- - var brush = new AscFormat.CUniFill(); - brush.setFill(new AscFormat.CSolidFill()); - brush.fill.setColor(new AscFormat.CUniColor()); - brush.fill.color.setColor(new AscFormat.CSchemeColor()); - brush.fill.color.color.setId(phClr); - theme.themeElements.fmtScheme.fillStyleLst.push(brush); - - brush = new AscFormat.CUniFill(); - - let oFill = new AscFormat.CGradFill(); - oFill.rotateWithShape = true; - brush.setFill(oFill); - let oLin = new AscFormat.GradLin(); - oFill.setLin(oLin); - oLin.setAngle(16200000); - oLin.setScale(true); - let oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(0); - - let oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 50000}, {name: "satMod", val: 300000}]); - oGs.setColor(oColor); - - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(35000); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 37000}, {name: "satMod", val: 300000}]); - oGs.setColor(oColor); - - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(100000); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "tint", val: 15000}, {name: "satMod", val: 350000}]); - oGs.setColor(oColor); - - theme.themeElements.fmtScheme.fillStyleLst.push(brush); - - brush = new AscFormat.CUniFill(); - - oFill = new AscFormat.CGradFill(); - brush.setFill(oFill); - oFill.rotateWithShape = true; - oLin = new AscFormat.GradLin(); - oFill.setLin(oLin); - oLin.setAngle(16200000); - oLin.setScale(false); - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(0); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 51000}, {name: "satMod", val: 130000}]); - oGs.setColor(oColor); - - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(80000); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 93000}, {name: "satMod", val: 130000}]); - oGs.setColor(oColor); - - oGs = new AscFormat.CGs(); - oFill.addColor(oGs); - oGs.setPos(100000); - oColor = AscFormat.CreateSchemeUnicolorWithMods(14, [{name: "shade", val: 94000}, {name: "satMod", val: 135000}]); - oGs.setColor(oColor); - - theme.themeElements.fmtScheme.fillStyleLst.push(brush); - // ---------------------------------------------------- - - // -------------- back styles ------------------------- - brush = new AscFormat.CUniFill(); - brush.setFill(new AscFormat.CSolidFill()); - brush.fill.setColor(new AscFormat.CUniColor()); - brush.fill.color.setColor(new AscFormat.CSchemeColor()); - brush.fill.color.color.setId(phClr); - theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); - - brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0)); - theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); - - brush = AscFormat.CreateUniFillByUniColor(AscFormat.CreateUniColorRGB(0, 0, 0)); - theme.themeElements.fmtScheme.bgFillStyleLst.push(brush); - // ---------------------------------------------------- - - var pen = new AscFormat.CLn(); - pen.setW(9525); - pen.setFill(new AscFormat.CUniFill()); - pen.Fill.setFill(new AscFormat.CSolidFill()); - pen.Fill.fill.setColor(new AscFormat.CUniColor()); - pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); - pen.Fill.fill.color.color.setId(phClr); - pen.Fill.fill.color.setMods(new AscFormat.CColorModifiers()); - - pen.Fill.fill.color.Mods.addMod("shade", 95000); - pen.Fill.fill.color.Mods.addMod("satMod", 105000); - theme.themeElements.fmtScheme.lnStyleLst.push(pen); - - pen = new AscFormat.CLn(); - pen.setW(25400); - pen.setFill(new AscFormat.CUniFill()); - pen.Fill.setFill(new AscFormat.CSolidFill()); - - pen.Fill.fill.setColor(new AscFormat.CUniColor()); - pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); - pen.Fill.fill.color.color.setId(phClr); - theme.themeElements.fmtScheme.lnStyleLst.push(pen); - - pen = new AscFormat.CLn(); - pen.setW(38100); - pen.setFill(new AscFormat.CUniFill()); - pen.Fill.setFill(new AscFormat.CSolidFill()); - pen.Fill.fill.setColor(new AscFormat.CUniColor()); - pen.Fill.fill.color.setColor(new AscFormat.CSchemeColor()); - pen.Fill.fill.color.color.setId(phClr); - theme.themeElements.fmtScheme.lnStyleLst.push(pen); - theme.extraClrSchemeLst = []; - - theme.themeElements.themeExt = new AscFormat.CThemeExt(); - theme.themeElements.themeExt.themeSchemeSchemeEnum = "0"; - - theme.themeElements.clrScheme.clrSchemeExtLst = new AscFormat.CClrSchemeExtLst(); - theme.themeElements.clrScheme.clrSchemeExtLst.schemeEnum = "0"; - - theme.themeElements.themeExt.fmtConnectorScheme = new AscFormat.FmtScheme(); - - return theme; - }, this, []); +AscFormat.GetDefaultTheme = function GetDefaultTheme() { + if(!AscFormat.DEFAULT_THEME) { + AscFormat.DEFAULT_THEME = AscFormat.generateDefaultVisioTheme(); + } + return AscFormat.DEFAULT_THEME; } //todo CMobileDelegateEditorDiagram From 9b7e1721d2385c6b4c4318f8bbf1a7eaa56f0c55 Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Fri, 15 Aug 2025 14:44:56 +0300 Subject: [PATCH 09/10] [ve] Fix crash on vsdx saving (snapAngles) --- visio/model/SerializeReader.js | 88 +++++++++++++++++++++++++++++++--- visio/model/SerializeWriter.js | 43 ++++++++++++++++- 2 files changed, 123 insertions(+), 8 deletions(-) diff --git a/visio/model/SerializeReader.js b/visio/model/SerializeReader.js index eeb5b7f81a..a074ca32f3 100644 --- a/visio/model/SerializeReader.js +++ b/visio/model/SerializeReader.js @@ -496,9 +496,6 @@ case 7: this.snapExtensions = stream.GetLong(); break; - case 8: - this.snapAngles = stream.GetLong(); - break; case 9: this.dynamicGridEnabled = stream.GetBool(); break; @@ -530,6 +527,38 @@ return true; }; + /** + * Read children from stream for DocumentSettings_Type + * + * @param {number} attrType - The type of attribute + * @param {BinaryVSDYLoader} pReader - The binary reader + * @returns {boolean} - True if attribute was handled, false otherwise + */ + AscVisio.DocumentSettings_Type.prototype.readChild = function(elementType, pReader) { + const t = this; + switch (elementType) { + case 0: + // Read Shape_Type + AscFormat.CBaseFormatNoIdObject.prototype.fromPPTY.call({ + readChildren: AscFormat.CBaseFormatNoIdObject.prototype.readChildren, + readChild: function(elementType, pReader) { + if (elementType === 0) { + const snapAngle = new AscVisio.SnapAngle_Type(); + snapAngle.fromPPTY(pReader); + t.snapAngles.push(snapAngle); + return true; + } + return false; + } + }, pReader); + break; + default: + return false; + } + + return true; + }; + /** * Read attributes from stream for ColorEntry_Type * @@ -1564,9 +1593,6 @@ case 24: this.snapExtensions = stream.GetULong(); return true; - case 25: - this.snapAngles = stream.GetBool(); - return true; case 26: this.dynamicGridEnabled = stream.GetBool(); return true; @@ -1584,6 +1610,56 @@ return false; }; + /** + * Read children from stream for DocumentSettings_Type + * + * @param {number} attrType - The type of attribute + * @param {BinaryVSDYLoader} pReader - The binary reader + * @returns {boolean} - True if attribute was handled, false otherwise + */ + AscVisio.Window_Type.prototype.readChild = function(elementType, pReader) { + const t = this; + switch (elementType) { + case 0: + // Read Shape_Type + AscFormat.CBaseFormatNoIdObject.prototype.fromPPTY.call({ + readChildren: AscFormat.CBaseFormatNoIdObject.prototype.readChildren, + readChild: function(elementType, pReader) { + if (elementType === 0) { + const snapAngle = new AscVisio.SnapAngle_Type(); + snapAngle.fromPPTY(pReader); + t.snapAngles.push(snapAngle); + return true; + } + return false; + } + }, pReader); + break; + default: + return false; + } + + return true; + }; + + /** + * Read attributes from stream for Window_Type + * + * @param {number} attrType - The type of attribute + * @param {BinaryVSDYLoader} pReader - The binary reader + * @returns {boolean} - True if attribute was handled, false otherwise + */ + AscVisio.SnapAngle_Type.prototype.readAttribute = function(attrType, pReader) { + const stream = pReader.stream; + switch (attrType) { + case 0: + this.value = stream.GetDouble(); + return true; + } + + return false; + }; + /** * Read attributes from stream for DocumentSheet_Type * diff --git a/visio/model/SerializeWriter.js b/visio/model/SerializeWriter.js index 4a8767ae59..c402132efe 100644 --- a/visio/model/SerializeWriter.js +++ b/visio/model/SerializeWriter.js @@ -981,13 +981,28 @@ pWriter._WriteUInt2(22, this.glueSettings); pWriter._WriteUInt2(23, this.snapSettings); pWriter._WriteUInt2(24, this.snapExtensions); - pWriter._WriteBool2(25, this.snapAngles); pWriter._WriteBool2(26, this.dynamicGridEnabled); pWriter._WriteDoubleReal2(27, this.tabSplitterPos); pWriter._WriteUInt2(28, this.stencilGroup); pWriter._WriteUInt2(29, this.stencilGroupPos); }; + /** + * Write children to stream for Window_Type + * + * @param {CBinaryFileWriter} pWriter - The binary writer + */ + AscVisio.Window_Type.prototype.writeChildren = function (pWriter) { + // Write content if present + if (this.snapAngles && this.snapAngles.length > 0) { + pWriter.StartRecord(0); + for (let i = 0; i < this.snapAngles.length; i++) { + pWriter.WriteRecordPPTY(0, this.snapAngles[i]); + } + pWriter.EndRecord(); + } + }; + /** * Write attributes to stream for Page_Type * @@ -1243,7 +1258,6 @@ pWriter._WriteInt2(5, this.glueSettings); pWriter._WriteInt2(6, this.snapSettings); pWriter._WriteInt2(7, this.snapExtensions); - pWriter._WriteInt2(8, this.snapAngles); pWriter._WriteBool2(9, this.dynamicGridEnabled); pWriter._WriteBool2(10, this.protectStyles); pWriter._WriteBool2(11, this.protectShapes); @@ -1254,6 +1268,31 @@ pWriter._WriteString2(16, this.attachedToolbars); }; + /** + * Write children to stream for DocumentSettings_Type + * + * @param {CBinaryFileWriter} pWriter - The binary writer + */ + AscVisio.DocumentSettings_Type.prototype.writeChildren = function (pWriter) { + // Write content if present + if (this.snapAngles && this.snapAngles.length > 0) { + pWriter.StartRecord(0); + for (let i = 0; i < this.snapAngles.length; i++) { + pWriter.WriteRecordPPTY(0, this.snapAngles[i]); + } + pWriter.EndRecord(); + } + }; + + /** + * Write attributes to stream for SnapAngle_Type + * + * @param {CBinaryFileWriter} pWriter - The binary writer + */ + AscVisio.SnapAngle_Type.prototype.privateWriteAttributes = function (pWriter) { + pWriter._WriteDoubleReal2(0, this.value); + }; + /** * Write attributes to stream for Section_Type * From fbcfaf4d2a44d6eddba1864afce08f50c8beb9ec Mon Sep 17 00:00:00 2001 From: Sergey Konovalov Date: Fri, 15 Aug 2025 15:45:38 +0300 Subject: [PATCH 10/10] [ve] Refactor GenerateDefaultVisioTheme --- common/Drawings/Format/Format.js | 12 +++++++----- visio/model/overrides.js | 7 +------ 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/common/Drawings/Format/Format.js b/common/Drawings/Format/Format.js index 6c470a2724..c6b0238c7a 100644 --- a/common/Drawings/Format/Format.js +++ b/common/Drawings/Format/Format.js @@ -16162,8 +16162,11 @@ * Don't use this method. Use GetDefaultTheme * @return {CTheme} */ - function generateDefaultVisioTheme() { - let theme = GenerateDefaultTheme(null, "Calibri"); + function GenerateDefaultVisioTheme(presentation, opt_fontName) { + if (!opt_fontName) { + opt_fontName = "Calibri"; + } + let theme = GenerateDefaultTheme(presentation, opt_fontName); let scheme = theme.themeElements.clrScheme; // TODO change other colors scheme.colors[11] = AscFormat.CreateUniColorRGB(0x05, 0x63, 0xC1); // link @@ -16183,7 +16186,7 @@ function GetDefaultTheme() { if(!AscFormat.DEFAULT_THEME) { - AscFormat.DEFAULT_THEME = GenerateDefaultTheme(null); + AscFormat.DEFAULT_THEME = AscFormat.GenerateDefaultTheme(null); } return AscFormat.DEFAULT_THEME; } @@ -20268,6 +20271,7 @@ window['AscFormat'].CBulletType = CBulletType; window['AscFormat'].TextListStyle = TextListStyle; window['AscFormat'].GenerateDefaultTheme = GenerateDefaultTheme; + window['AscFormat'].GenerateDefaultVisioTheme = GenerateDefaultVisioTheme; window['AscFormat'].GenerateDefaultMasterSlide = GenerateDefaultMasterSlide; window['AscFormat'].GenerateDefaultSlideLayout = GenerateDefaultSlideLayout; window['AscFormat'].GenerateDefaultSlide = GenerateDefaultSlide; @@ -20551,8 +20555,6 @@ window['AscFormat'].CFontProps = CFontProps; window['AscFormat'].CLineStyle = CLineStyle; - window['AscFormat'].generateDefaultVisioTheme = generateDefaultVisioTheme; - window["AscFormat"].RECT_ALIGN_B = RECT_ALIGN_B; window["AscFormat"].RECT_ALIGN_BL = RECT_ALIGN_BL; window["AscFormat"].RECT_ALIGN_BR = RECT_ALIGN_BR; diff --git a/visio/model/overrides.js b/visio/model/overrides.js index 1d580f422b..3eddc42d3d 100644 --- a/visio/model/overrides.js +++ b/visio/model/overrides.js @@ -817,12 +817,7 @@ AscCommonWord.CPresentationField.prototype.private_GetString = function() return sStr; }; -AscFormat.GetDefaultTheme = function GetDefaultTheme() { - if(!AscFormat.DEFAULT_THEME) { - AscFormat.DEFAULT_THEME = AscFormat.generateDefaultVisioTheme(); - } - return AscFormat.DEFAULT_THEME; -} +AscFormat.GenerateDefaultTheme = AscFormat.GenerateDefaultVisioTheme; //todo CMobileDelegateEditorDiagram AscCommon.CMobileDelegateEditorPresentation.prototype.GetObjectTrack = function(x, y, page, bSelected, bText) { return false; }