sfx2/sdi/sfx.sdi | 2 +- sfx2/source/appl/appserv.cxx | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-)
New commits: commit 9f47fe2bfd791bdce28c0b9e7226d329a2b9537e Author: Skyler Grey <[email protected]> AuthorDate: Thu Jul 25 12:34:34 2024 +0000 Commit: Miklos Vajna <[email protected]> CommitDate: Thu Aug 15 11:50:33 2024 +0200 feat(invert): Allow specifying a theme In Online, we previously weren't able to specify what we wanted the theme to be after an invert. This led to the theme being "whatever the *last* person toggled it to" rather than "whatever isn't our current theme" This commit also lays the groundwork for loading the same invert theme after a reload/rejoin/new doc in Online There is a change to online to support this here: https://github.com/CollaboraOnline/online/pull/9652 Change-Id: I05486860c5f562c3cfa59b4a7fc492d48913a181 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171889 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 5aedc10c828f..6b45698d563b 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -5930,7 +5930,7 @@ SfxVoidItem ChangeTheme FN_CHANGE_THEME ] SfxVoidItem InvertBackground FN_INVERT_BACKGROUND -() +(SfxStringItem NewTheme FN_PARAM_NEW_THEME) [ AutoUpdate = FALSE, FastCall = FALSE, diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 23358e7f8cfe..603b1b90648f 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -734,15 +734,29 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) } case FN_INVERT_BACKGROUND: { + const SfxStringItem* pNewThemeArg = rReq.GetArg<SfxStringItem>(FN_PARAM_NEW_THEME); + svtools::EditableColorConfig aColorConfig; - ::Color aCurrentColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; ::Color aDefLightColor = svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 0); ::Color aDefDarkColor = svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1); + OUString aNewTheme; + if (!pNewThemeArg) { + ::Color aCurrentColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; + + if (aCurrentColor == aDefLightColor) { + aNewTheme = OUString("Dark"); + } else { + aNewTheme = OUString("Light"); + } + } else { + aNewTheme = pNewThemeArg->GetValue(); + } + svtools::ColorConfigValue aValue; aValue.bIsVisible = true; - if(aCurrentColor == aDefLightColor) + if(aNewTheme == "Dark") aValue.nColor = aDefDarkColor; else aValue.nColor = aDefLightColor;
