sfx2/source/appl/appserv.cxx                   |   21 +++++++++++++++++----
 sw/qa/extras/tiledrendering/tiledrendering.cxx |    8 ++------
 2 files changed, 19 insertions(+), 10 deletions(-)

New commits:
commit 08aa152a3602bdfd41498acb927154f5cf788576
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Fri Feb 14 17:08:37 2025 +0100
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Wed Feb 19 21:22:47 2025 +0100

    lok: switch dark mode faster
    
    We don't need to load the color scheme every time
    we switch the dark mode on/off. Let's load it once
    then reuse.
    
    - preloading
    - reuse instance
    
    Change-Id: I72478327124dad7142af826232f483e4033764e2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181812
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx
index cae76cbeeb48..3076a689ce29 100644
--- a/sfx2/source/appl/appserv.cxx
+++ b/sfx2/source/appl/appserv.cxx
@@ -345,6 +345,17 @@ weld::Window* SfxRequest::GetFrameWeld() const
 
 void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
 {
+    const bool bIsLOK = comphelper::LibreOfficeKit::isActive();
+    static svtools::EditableColorConfig aEditableConfig;
+    static bool aColorConfigInitialized = false;
+    if (!aColorConfigInitialized && bIsLOK)
+    {
+        // preload color schemes
+        aEditableConfig.LoadScheme("Light");
+        aEditableConfig.LoadScheme("Dark");
+        aColorConfigInitialized = true;
+    }
+
     bool bDone = false;
     switch ( rReq.GetSlot() )
     {
@@ -640,16 +651,18 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq )
                 }
                 MiscSettings::SetAppColorMode(nUseMode);
             }
-            svtools::EditableColorConfig aEditableConfig;
+
             // kit explicitly ignores changes to the global color scheme, 
except for the current ViewShell,
             // so an attempted change to the same global color scheme when the 
now current ViewShell ignored
             // the last change requires re-sending the change. In which case 
individual shells will have to
             // decide if this color-scheme change is a change from their 
perspective to avoid unnecessary
             // invalidations.
-            if (!pNewThemeArg || comphelper::LibreOfficeKit::isActive()
-                || aEditableConfig.GetCurrentSchemeName() != sSchemeName)
+            if (!pNewThemeArg || bIsLOK || 
aEditableConfig.GetCurrentSchemeName() != sSchemeName)
             {
-                aEditableConfig.LoadScheme(sSchemeName);
+                if (bIsLOK)
+                    aEditableConfig.SetCurrentSchemeName(sSchemeName);
+                else
+                    aEditableConfig.LoadScheme(sSchemeName);
             }
 
             Invalidate(FN_CHANGE_THEME);
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 4148d8eb8799..9de9f6706dc4 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1774,14 +1774,10 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testGetViewRenderState)
         SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
         SwView* pView = pDoc->GetDocShell()->GetView();
         uno::Reference<frame::XFrame> xFrame = 
pView->GetViewFrame().GetFrame().GetFrameInterface();
-        uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence(
-            {
-                { "NewTheme", uno::Any(OUString("Dark")) },
-            }
-        );
+        uno::Sequence<beans::PropertyValue> aPropertyValues = 
comphelper::InitPropertySequence({});
         comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, 
aPropertyValues);
     }
-    CPPUNIT_ASSERT_EQUAL("S;Dark"_ostr, pXTextDocument->getViewRenderState());
+    CPPUNIT_ASSERT_EQUAL("SD;Dark"_ostr, pXTextDocument->getViewRenderState());
     // Switch back to the first view, and check that the options string is the 
same
     SfxLokHelper::setView(nFirstViewId);
     CPPUNIT_ASSERT_EQUAL("PS;Default"_ostr, 
pXTextDocument->getViewRenderState());

Reply via email to