From 5aef89f4491889a9568aecf60b28145a929292b1 Mon Sep 17 00:00:00 2001 From: Fedor Kobyakov Date: Tue, 22 Jul 2025 15:22:29 +0300 Subject: [PATCH] [ve] Move color theme index calculation to function --- visio/model/ooxmlApi/ooxmlApiIndex.js | 27 +++++++++++++++++++++++++++ visio/model/visioFunctionsApi.js | 19 +------------------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/visio/model/ooxmlApi/ooxmlApiIndex.js b/visio/model/ooxmlApi/ooxmlApiIndex.js index 1747e8d9b3..15dd208186 100644 --- a/visio/model/ooxmlApi/ooxmlApiIndex.js +++ b/visio/model/ooxmlApi/ooxmlApiIndex.js @@ -1819,6 +1819,33 @@ // }); } + /** + * @memberof Shape_Type + * returns index of color shape theme + */ + Shape_Type.prototype.calculateColorThemeIndex = function calculateColorThemeIndex(pageInfo) { + let themeIndex = 0; // zero index means no theme - use default values + let themeScopeCellName = this.isConnectorStyleIherited ? "ConnectorSchemeIndex" : "ColorSchemeIndex"; + let shapeColorSchemeThemeIndex = this.getCellNumberValue(themeScopeCellName); + if (isNaN(shapeColorSchemeThemeIndex)) { + // if not found or smth + // shapeColorSchemeThemeIndex = 0; // zero index means no theme + themeIndex = 0; // zero index means no theme + } else if (shapeColorSchemeThemeIndex === 65534) { + let pageThemeIndex = pageInfo.pageSheet.getCellNumberValue(themeScopeCellName); + if (!isNaN(pageThemeIndex)) { + themeIndex = pageThemeIndex; + } else { + // it's ok sometimes + // AscCommon.consoleLog("pageThemeIndexCell not found"); + themeIndex = 0; + } + } else { + themeIndex = shapeColorSchemeThemeIndex; + } + return themeIndex; + } + /** * get deep copy of object with prototypes * @param object diff --git a/visio/model/visioFunctionsApi.js b/visio/model/visioFunctionsApi.js index 5e552e44d5..082d587956 100644 --- a/visio/model/visioFunctionsApi.js +++ b/visio/model/visioFunctionsApi.js @@ -239,24 +239,7 @@ // and pick ColorSchemeIndex instead of ThemeIndex cell // upd: if connector styles are used lets use ConnectorSchemeIndex cell and // ext uri="{D75FF423-9257-4291-A4FE-1B2448832E17} - themeSchemeSchemeEnum to find theme - let themeIndex = 0; // zero index means no theme - use default values - let themeScopeCellName = isConnectorShape ? "ConnectorSchemeIndex" : "ColorSchemeIndex"; - let shapeColorSchemeThemeIndex = shape.getCellNumberValue(themeScopeCellName); - if (isNaN(shapeColorSchemeThemeIndex)) { - shapeColorSchemeThemeIndex = 0; // zero index means no theme - } - if (shapeColorSchemeThemeIndex === 65534) { - let pageThemeIndex = pageInfo.pageSheet.getCellNumberValue(themeScopeCellName); - if (!isNaN(pageThemeIndex)) { - themeIndex = pageThemeIndex; - } else { - // it's ok sometimes - // AscCommon.consoleLog("pageThemeIndexCell not found"); - themeIndex = 0; - } - } else { - themeIndex = shapeColorSchemeThemeIndex; - } + let themeIndex = shape.calculateColorThemeIndex(pageInfo); // if THEMEVAL was called with themeValue (argument like "FillColor") even if themeIndex is 0 we should