[ve] Move color theme index calculation to function

This commit is contained in:
Fedor Kobyakov
2025-07-22 15:22:29 +03:00
parent 4f29678757
commit 5aef89f449
2 changed files with 28 additions and 18 deletions

View File

@ -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

View File

@ -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