include/sfx2/sfxsids.hrc | 1 + include/svtools/colorcfg.hxx | 5 ++++- sfx2/sdi/appslots.sdi | 4 ++++ sfx2/sdi/sfx.sdi | 14 ++++++++++++++ sfx2/source/appl/appserv.cxx | 17 +++++++++++++++++ svtools/source/config/colorcfg.cxx | 30 +++++++++++++++++++----------- 6 files changed, 59 insertions(+), 12 deletions(-)
New commits: commit d43562e03d5e70ef77e4fdf6cf71650dab504f1a Author: Gülşah Köse <[email protected]> AuthorDate: Fri May 24 14:34:15 2024 +0300 Commit: Szymon Kłos <[email protected]> CommitDate: Sat Jun 1 10:24:51 2024 +0200 ONLINE: Add Invert document background color command. Signed-off-by: Gülşah Köse <[email protected]> Change-Id: Ia8868a80e4eba9a9a1c0b31077d9eca0c5b00466 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168019 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index 4aa9424e13bb..788f2ef26467 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -301,6 +301,7 @@ class SvxZoomItem; #define FN_CHANGE_THEME (SID_SFX_START + 1745) #define FN_PARAM_NEW_THEME TypedWhichId<SfxStringItem>(SID_SFX_START + 1746) #define SID_OPTIONS_PAGEID TypedWhichId<SfxUInt16Item>(SID_SFX_START + 1747) +#define FN_INVERT_BACKGROUND (SID_SFX_START + 1748) // SID_SFX_free_END (SID_SFX_START + 3999) diff --git a/include/svtools/colorcfg.hxx b/include/svtools/colorcfg.hxx index 9e9d5bca7da8..7b8cef5d2f85 100644 --- a/include/svtools/colorcfg.hxx +++ b/include/svtools/colorcfg.hxx @@ -111,7 +111,10 @@ 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; - static Color GetDefaultColor(ColorConfigEntry eEntry); + // -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(); }; diff --git a/sfx2/sdi/appslots.sdi b/sfx2/sdi/appslots.sdi index b8d75480fef5..2ea5dd7a7580 100644 --- a/sfx2/sdi/appslots.sdi +++ b/sfx2/sdi/appslots.sdi @@ -68,6 +68,10 @@ interface Application [ ExecMethod = MiscExec_Impl ; ] + FN_INVERT_BACKGROUND // ole(no) api(final/play/rec) + [ + ExecMethod = MiscExec_Impl ; + ] SID_CONFIG // ole(no) api(final/play/rec) [ ExecMethod = MiscExec_Impl ; diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index 4dca362cea49..23e97115b737 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -5909,3 +5909,17 @@ SfxVoidItem ChangeTheme FN_CHANGE_THEME GroupId = SfxGroupId::Application; ] + +SfxVoidItem InvertBackground FN_INVERT_BACKGROUND +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = FALSE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + GroupId = SfxGroupId::Application; +] diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index a2fb56be0066..8da1edce2c1f 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -617,7 +617,24 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) aEditableConfig.LoadScheme(rSchemeName); break; } + case FN_INVERT_BACKGROUND: + { + 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); + + svtools::ColorConfigValue aValue; + aValue.bIsVisible = true; + + if(aCurrentColor == aDefLightColor) + aValue.nColor = aDefDarkColor; + else + aValue.nColor = aDefLightColor; + aColorConfig.SetColorValue(svtools::DOCCOLOR, aValue); + break; + } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - case SID_HELPINDEX: { diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index 167dfa3337ad..a2f8aeddf96d 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -382,7 +382,7 @@ ColorConfig::~ColorConfig() } } -Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry) +Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry, int nMod) { enum ColorType { clLight = 0, clDark, @@ -463,20 +463,28 @@ Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry) default: int nAppMod; - switch (MiscSettings::GetAppColorMode()) { - default: - if (MiscSettings::GetUseDarkMode()) - nAppMod = clDark; - else - nAppMod = clLight; - break; - case 1: nAppMod = clLight; break; - case 2: nAppMod = clDark; break; + + if(nMod == 0) + nAppMod = clLight; + else if(nMod == 1) + nAppMod = clDark; + else + { + switch (MiscSettings::GetAppColorMode()) { + default: + if (MiscSettings::GetUseDarkMode()) + nAppMod = clDark; + else + nAppMod = clLight; + break; + case 1: nAppMod = clLight; break; + case 2: nAppMod = clDark; break; + } } aRet = cAutoColors[eEntry][nAppMod]; } // fdo#71511: if in a11y HC mode, do pull background color from theme - if (Application::GetSettings().GetStyleSettings().GetHighContrastMode()) + if (Application::GetSettings().GetStyleSettings().GetHighContrastMode() && nMod == -1) { switch(eEntry) {
