include/svtools/colorcfg.hxx | 14 ++++++- svtools/source/config/colorcfg.cxx | 70 ++++++++++++++++++++++--------------- 2 files changed, 56 insertions(+), 28 deletions(-)
New commits: commit 0c9fee8a2c81e1bb3de28a852435a4cdbdca22e3 Author: Sahil Gautam <[email protected]> AuthorDate: Thu Jan 29 17:01:07 2026 +0530 Commit: Sahil Gautam <[email protected]> CommitDate: Mon Feb 2 12:11:56 2026 +0100 chore: create a static copy of ColorConfig::GetColorValue function `ColorConfig::GetColorValue` is used over 300 times in the codebase, some times inside wrappers, sometimes stand alone. It doesn't make sense to spend time changing it in all those places as we are moving to 26-2 soon. In some places where it's called inside wrappers, the wrappers are doing more than just `GetColorValue`, things like `ColorConfig` instance initialization/reset, so changing it across the codebase might introduce subtle bugs here and there. This seems to be the most straight forward solution to tdf#169839 on 25-04. We create `ColorConfig::static_GetColorValue` so that we can make `LoadThemeColorsFromRegistry` static, which we will use outside `ColorConfig` in the following patches. Change-Id: Id0406525fb340f2136b03116f08e9b50f6c27ed3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198388 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/include/svtools/colorcfg.hxx b/include/svtools/colorcfg.hxx index 40417e507a0c..70cd70a62353 100644 --- a/include/svtools/colorcfg.hxx +++ b/include/svtools/colorcfg.hxx @@ -296,13 +296,25 @@ public: // get the configured value - if bSmart is set the default color setting is provided // instead of the automatic color ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart = true) const; + + /* + * The above function is used over 300 times in the codebase, some times inside + * wrappers, sometimes stand alone. it doesn't make sense to spend time changing + * it in all those places as we are moving to 26-2 soon. In some places where + * it's called inside wrappers, the wrappers are doing more than just GetColorValue, + * things like ColorConfig instance initialization/reset, so changing it across the + * codebase might introduce subtle bugs here and there. this seems to be the most + * straight forward solution to tdf#169839 on 25-04. + */ + static ColorConfigValue static_GetColorValue(ColorConfigEntry eEntry, bool bSmart = true); + // -1 gets the default color on current mod. // 0 gets the default color on light mod. // 1 gets the default color on dark mod. static Color GetDefaultColor(ColorConfigEntry eEntry, int nMod = -1); static const OUString& GetCurrentSchemeName(); - void LoadThemeColorsFromRegistry(); + static void LoadThemeColorsFromRegistry(); void SetupTheme(); DECL_LINK(DataChangedHdl, VclSimpleEvent&, void); diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index c3cd4a936983..33246f73bf56 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -436,33 +436,36 @@ void ColorConfig::LoadThemeColorsFromRegistry() { ThemeColors& rThemeColors = ThemeColors::GetThemeColors(); - rThemeColors.SetWindowColor(GetColorValue(svtools::WINDOWCOLOR).nColor); - rThemeColors.SetWindowTextColor(GetColorValue(svtools::WINDOWTEXTCOLOR).nColor); - rThemeColors.SetBaseColor(GetColorValue(svtools::BASECOLOR).nColor); - rThemeColors.SetButtonColor(GetColorValue(svtools::BUTTONCOLOR).nColor); - rThemeColors.SetButtonTextColor(GetColorValue(svtools::BUTTONTEXTCOLOR).nColor); - rThemeColors.SetAccentColor(GetColorValue(svtools::ACCENTCOLOR).nColor); - rThemeColors.SetDisabledColor(GetColorValue(svtools::DISABLEDCOLOR).nColor); - rThemeColors.SetDisabledTextColor(GetColorValue(svtools::DISABLEDTEXTCOLOR).nColor); - rThemeColors.SetShadeColor(GetColorValue(svtools::SHADECOLOR).nColor); - rThemeColors.SetSeparatorColor(GetColorValue(svtools::SEPARATORCOLOR).nColor); - rThemeColors.SetFaceColor(GetColorValue(svtools::FACECOLOR).nColor); - rThemeColors.SetActiveColor(GetColorValue(svtools::ACTIVECOLOR).nColor); - rThemeColors.SetActiveTextColor(GetColorValue(svtools::ACTIVETEXTCOLOR).nColor); - rThemeColors.SetActiveBorderColor(GetColorValue(svtools::ACTIVEBORDERCOLOR).nColor); - rThemeColors.SetFieldColor(GetColorValue(svtools::FIELDCOLOR).nColor); - rThemeColors.SetMenuBarColor(GetColorValue(svtools::MENUBARCOLOR).nColor); - rThemeColors.SetMenuBarTextColor(GetColorValue(svtools::MENUBARTEXTCOLOR).nColor); - rThemeColors.SetMenuBarHighlightColor(GetColorValue(svtools::MENUBARHIGHLIGHTCOLOR).nColor); - rThemeColors.SetMenuBarHighlightTextColor(GetColorValue(svtools::MENUBARHIGHLIGHTTEXTCOLOR).nColor); - rThemeColors.SetMenuColor(GetColorValue(svtools::MENUCOLOR).nColor); - rThemeColors.SetMenuTextColor(GetColorValue(svtools::MENUTEXTCOLOR).nColor); - rThemeColors.SetMenuHighlightColor(GetColorValue(svtools::MENUHIGHLIGHTCOLOR).nColor); - rThemeColors.SetMenuHighlightTextColor(GetColorValue(svtools::MENUHIGHLIGHTTEXTCOLOR).nColor); - rThemeColors.SetMenuBorderColor(GetColorValue(svtools::MENUBORDERCOLOR).nColor); - rThemeColors.SetInactiveColor(GetColorValue(svtools::INACTIVECOLOR).nColor); - rThemeColors.SetInactiveTextColor(GetColorValue(svtools::INACTIVETEXTCOLOR).nColor); - rThemeColors.SetInactiveBorderColor(GetColorValue(svtools::INACTIVEBORDERCOLOR).nColor); + rThemeColors.SetWindowColor(static_GetColorValue(svtools::WINDOWCOLOR).nColor); + rThemeColors.SetWindowTextColor(static_GetColorValue(svtools::WINDOWTEXTCOLOR).nColor); + rThemeColors.SetBaseColor(static_GetColorValue(svtools::BASECOLOR).nColor); + rThemeColors.SetButtonColor(static_GetColorValue(svtools::BUTTONCOLOR).nColor); + rThemeColors.SetButtonTextColor(static_GetColorValue(svtools::BUTTONTEXTCOLOR).nColor); + rThemeColors.SetAccentColor(static_GetColorValue(svtools::ACCENTCOLOR).nColor); + rThemeColors.SetDisabledColor(static_GetColorValue(svtools::DISABLEDCOLOR).nColor); + rThemeColors.SetDisabledTextColor(static_GetColorValue(svtools::DISABLEDTEXTCOLOR).nColor); + rThemeColors.SetShadeColor(static_GetColorValue(svtools::SHADECOLOR).nColor); + rThemeColors.SetSeparatorColor(static_GetColorValue(svtools::SEPARATORCOLOR).nColor); + rThemeColors.SetFaceColor(static_GetColorValue(svtools::FACECOLOR).nColor); + rThemeColors.SetActiveColor(static_GetColorValue(svtools::ACTIVECOLOR).nColor); + rThemeColors.SetActiveTextColor(static_GetColorValue(svtools::ACTIVETEXTCOLOR).nColor); + rThemeColors.SetActiveBorderColor(static_GetColorValue(svtools::ACTIVEBORDERCOLOR).nColor); + rThemeColors.SetFieldColor(static_GetColorValue(svtools::FIELDCOLOR).nColor); + rThemeColors.SetMenuBarColor(static_GetColorValue(svtools::MENUBARCOLOR).nColor); + rThemeColors.SetMenuBarTextColor(static_GetColorValue(svtools::MENUBARTEXTCOLOR).nColor); + rThemeColors.SetMenuBarHighlightColor( + static_GetColorValue(svtools::MENUBARHIGHLIGHTCOLOR).nColor); + rThemeColors.SetMenuBarHighlightTextColor( + static_GetColorValue(svtools::MENUBARHIGHLIGHTTEXTCOLOR).nColor); + rThemeColors.SetMenuColor(static_GetColorValue(svtools::MENUCOLOR).nColor); + rThemeColors.SetMenuTextColor(static_GetColorValue(svtools::MENUTEXTCOLOR).nColor); + rThemeColors.SetMenuHighlightColor(static_GetColorValue(svtools::MENUHIGHLIGHTCOLOR).nColor); + rThemeColors.SetMenuHighlightTextColor( + static_GetColorValue(svtools::MENUHIGHLIGHTTEXTCOLOR).nColor); + rThemeColors.SetMenuBorderColor(static_GetColorValue(svtools::MENUBORDERCOLOR).nColor); + rThemeColors.SetInactiveColor(static_GetColorValue(svtools::INACTIVECOLOR).nColor); + rThemeColors.SetInactiveTextColor(static_GetColorValue(svtools::INACTIVETEXTCOLOR).nColor); + rThemeColors.SetInactiveBorderColor(static_GetColorValue(svtools::INACTIVEBORDERCOLOR).nColor); rThemeColors.SetThemeName(GetCurrentSchemeName()); // as more controls support it, we might want to have ColorConfigValue entries in ThemeColors @@ -744,6 +747,19 @@ ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, bool bSmart return aRet; } +ColorConfigValue ColorConfig::static_GetColorValue(ColorConfigEntry eEntry, bool bSmart) +{ + ColorConfigValue aRet; + + if (m_pImpl) + aRet = m_pImpl->GetColorConfigValue(eEntry); + + if (bSmart && aRet.nColor == COL_AUTO) + aRet.nColor = ColorConfig::GetDefaultColor(eEntry); + + return aRet; +} + const OUString& ColorConfig::GetCurrentSchemeName() { uno::Sequence<OUString> aNames = m_pImpl->GetSchemeNames();
