sw/qa/extras/tiledrendering/tiledrendering.cxx |   25 ++++++++++++++++++++++---
 sw/source/uibase/config/viewopt.cxx            |    1 +
 sw/source/uibase/uno/unotxdoc.cxx              |    4 ++++
 3 files changed, 27 insertions(+), 3 deletions(-)

New commits:
commit 292f422c421336c43bafe5ee048832137d617436
Author:     Paris Oplopoios <paris.oplopo...@collabora.com>
AuthorDate: Wed Apr 26 12:17:33 2023 +0300
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Apr 27 08:23:40 2023 +0200

    Extend tiled rendering test to account for dark mode
    
    Made testGetViewRenderState test for change from light mode to dark mode
    
    Change-Id: Ia02e7a462e595671492405733f25c0bbb3c24080
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151046
    Tested-by: Jenkins
    Reviewed-by: Paris Oplopoios <parisop...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx 
b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 19bd70fa78e4..06b9ee25a64c 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1639,10 +1639,11 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testGetViewRenderState)
         aViewOptions.SetOnlineSpell(true);
         
pXTextDocument->GetDocShell()->GetWrtShell()->ApplyViewOptions(aViewOptions);
     }
-    CPPUNIT_ASSERT_EQUAL(OString("PS"), pXTextDocument->getViewRenderState());
+    CPPUNIT_ASSERT_EQUAL(OString("PS;Default"), 
pXTextDocument->getViewRenderState());
 
     // Create a second view
     SfxLokHelper::createView();
+    int nSecondViewId = SfxLokHelper::getView();
     ViewCallback aView2;
     {
         // Give the second view different options
@@ -1651,11 +1652,29 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, 
testGetViewRenderState)
         aViewOptions.SetOnlineSpell(true);
         
pXTextDocument->GetDocShell()->GetWrtShell()->ApplyViewOptions(aViewOptions);
     }
-    CPPUNIT_ASSERT_EQUAL(OString("S"), pXTextDocument->getViewRenderState());
+    CPPUNIT_ASSERT_EQUAL(OString("S;Default"), 
pXTextDocument->getViewRenderState());
 
     // Switch back to the first view, and check that the options string is the 
same
     SfxLokHelper::setView(nFirstViewId);
-    CPPUNIT_ASSERT_EQUAL(OString("PS"), pXTextDocument->getViewRenderState());
+    CPPUNIT_ASSERT_EQUAL(OString("PS;Default"), 
pXTextDocument->getViewRenderState());
+
+    // Switch back to the second view, and change to dark mode
+    SfxLokHelper::setView(nSecondViewId);
+    {
+        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")) },
+            }
+        );
+        comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, 
aPropertyValues);
+    }
+    CPPUNIT_ASSERT_EQUAL(OString("S;Dark"), 
pXTextDocument->getViewRenderState());
+    // Switch back to the first view, and check that the options string is the 
same
+    SfxLokHelper::setView(nFirstViewId);
+    CPPUNIT_ASSERT_EQUAL(OString("PS;Default"), 
pXTextDocument->getViewRenderState());
 }
 
 CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testSetViewGraphicSelection)
diff --git a/sw/source/uibase/config/viewopt.cxx 
b/sw/source/uibase/config/viewopt.cxx
index 6b9ca4967c36..2f456a317e92 100644
--- a/sw/source/uibase/config/viewopt.cxx
+++ b/sw/source/uibase/config/viewopt.cxx
@@ -237,6 +237,7 @@ void SwViewOption::PaintPostIts( OutputDevice *pOut, const 
SwRect &rRect, bool b
 }
 
 SwViewOption::SwViewOption() :
+    m_sThemeName( "Default" ),
     m_sSymbolFont( "symbol" ),
     m_aRetouchColor( COL_TRANSPARENT ),
     mnViewLayoutColumns( 0 ),
diff --git a/sw/source/uibase/uno/unotxdoc.cxx 
b/sw/source/uibase/uno/unotxdoc.cxx
index e7eb52e81a21..f107586c1a29 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3414,6 +3414,10 @@ OString SwXTextDocument::getViewRenderState()
                 aState.append('P');
             if (pVOpt->IsOnlineSpell())
                 aState.append('S');
+            aState.append(';');
+
+            OString aThemeName = OUStringToOString(pVOpt->GetThemeName(), 
RTL_TEXTENCODING_UTF8);
+            aState.append(aThemeName);
         }
     }
     return aState.makeStringAndClear();

Reply via email to