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 e0daa8a142387494d8f8b331d0802da552622073
Author:     Gülşah Köse <[email protected]>
AuthorDate: Fri May 24 14:34:15 2024 +0300
Commit:     Miklos Vajna <[email protected]>
CommitDate: Thu Aug 8 16:43:43 2024 +0200

    ONLINE: Add Invert document background color command.
    
    Change-Id: Ia8868a80e4eba9a9a1c0b31077d9eca0c5b00466
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171633
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 4356ede80ef3..a4aad72cf96a 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -302,6 +302,7 @@ class SvxZoomItem;
 #define FN_PARAM_NEW_THEME                  
TypedWhichId<SfxStringItem>(SID_SFX_START + 1746)
 #define SID_OPTIONS_PAGEID                  
TypedWhichId<SfxUInt16Item>(SID_SFX_START + 1747)
 #define SID_GPGSIGN                         
TypedWhichId<SfxBoolItem>(SID_SFX_START + 1748)
+#define FN_INVERT_BACKGROUND                (SID_SFX_START + 1749)
 //      SID_SFX_free_END                    (SID_SFX_START + 3999)
 
 #define SID_OPEN_NEW_VIEW                   
TypedWhichId<SfxBoolItem>(SID_SFX_START + 520)
diff --git a/include/svtools/colorcfg.hxx b/include/svtools/colorcfg.hxx
index c3e4af09885d..89074ec03887 100644
--- a/include/svtools/colorcfg.hxx
+++ b/include/svtools/colorcfg.hxx
@@ -112,7 +112,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 14f89dbabf63..45166d3376f6 100644
--- a/sfx2/sdi/appslots.sdi
+++ b/sfx2/sdi/appslots.sdi
@@ -69,6 +69,10 @@ interface Application
         ExecMethod = MiscExec_Impl ;
         StateMethod = MiscState_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 9a341064c970..5aedc10c828f 100644
--- a/sfx2/sdi/sfx.sdi
+++ b/sfx2/sdi/sfx.sdi
@@ -5928,3 +5928,17 @@ SfxVoidItem ChangeTheme FN_CHANGE_THEME
     ToolBoxConfig = TRUE,
     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 1505e3944d55..23358e7f8cfe 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -732,7 +732,24 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
             Invalidate(FN_CHANGE_THEME);
             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 60488ef5f3fb..9ba8004f752a 100644
--- a/svtools/source/config/colorcfg.cxx
+++ b/svtools/source/config/colorcfg.cxx
@@ -383,7 +383,7 @@ ColorConfig::~ColorConfig()
     }
 }
 
-Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry)
+Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry, int nMod)
 {
     enum ColorType { clLight = 0,
                      clDark,
@@ -469,20 +469,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)
         {

Reply via email to