diff options
author | Paris Oplopoios <paris.oplopoios@collabora.com> | 2023-03-16 03:58:18 +0200 |
---|---|---|
committer | Paris Oplopoios <parisoplop@gmail.com> | 2023-03-17 16:22:39 +0000 |
commit | 2f08fac476b150a9c9850df7b1c6823e35ddae7d (patch) | |
tree | 87f6a637478f329caa99773c9eea572f7667bde1 | |
parent | 63f77fc7c52ed01d3f9a27a05c8952cc4ee2d20e (diff) |
Update view options string based on theme
Update the view options string based on the theme when tiled rendering,
and make sure only the currently active view is updated
Change-Id: Ib24111848f2926fe7ae858ca2e18e946d980e83f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148943
Tested-by: Paris Oplopoios <parisoplop@gmail.com>
Reviewed-by: Paris Oplopoios <parisoplop@gmail.com>
(cherry picked from commit 9f0cf00d29298ed55737928ec4dddc50ac850cd8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149024
-rw-r--r-- | include/svtools/colorcfg.hxx | 1 | ||||
-rw-r--r-- | svtools/source/config/colorcfg.cxx | 5 | ||||
-rw-r--r-- | sw/inc/viewopt.hxx | 11 | ||||
-rw-r--r-- | sw/qa/extras/tiledrendering/tiledrendering.cxx | 20 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 1 | ||||
-rw-r--r-- | sw/source/uibase/app/apphdl.cxx | 9 | ||||
-rw-r--r-- | sw/source/uibase/config/viewopt.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/uno/unotxdoc.cxx | 2 |
8 files changed, 48 insertions, 3 deletions
diff --git a/include/svtools/colorcfg.hxx b/include/svtools/colorcfg.hxx index 300625cf14a7..08f5d3000bed 100644 --- a/include/svtools/colorcfg.hxx +++ b/include/svtools/colorcfg.hxx @@ -109,6 +109,7 @@ public: // instead of the automatic color ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart = true) const; static Color GetDefaultColor(ColorConfigEntry eEntry); + const OUString& GetCurrentSchemeName() const; }; class SVT_DLLPUBLIC EditableColorConfig diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index ad3170b430ab..93cd989dc64e 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -466,6 +466,11 @@ ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, bool bSmart return aRet; } +const OUString& ColorConfig::GetCurrentSchemeName() const +{ + return m_pImpl->GetLoadedScheme(); +} + EditableColorConfig::EditableColorConfig() : m_pImpl(new ColorConfig_Impl), m_bModified(false) diff --git a/sw/inc/viewopt.hxx b/sw/inc/viewopt.hxx index 4c9dcf8e071b..a6fd5eea8a57 100644 --- a/sw/inc/viewopt.hxx +++ b/sw/inc/viewopt.hxx @@ -248,6 +248,7 @@ class SW_DLLPUBLIC SwViewOption { SwViewColors m_aColorConfig; static SwViewColors s_aInitialColorConfig; + OUString m_sThemeName; static sal_uInt16 s_nPixelTwips;// 1 Pixel == ? Twips @@ -314,6 +315,16 @@ public: return m_aColorConfig; } + void SetThemeName(const OUString& rThemeName) + { + m_sThemeName = rThemeName; + } + + OUString GetThemeName() const + { + return m_sThemeName; + } + static void SetInitialColorConfig(const SwViewColors& rColorConfig) { s_aInitialColorConfig = rColorConfig; diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 20159c6aa6dc..7fcdeb0644d4 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1684,6 +1684,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testGetViewRenderState) // Create a second view SfxLokHelper::createView(); + int nSecondViewId = SfxLokHelper::getView(); ViewCallback aView2; { // Give the second view different options @@ -1697,6 +1698,25 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testGetViewRenderState) // 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()); + + // 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("COLOR_SCHEME_LIBREOFFICE_DARK")) }, + } + ); + comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); + } + CPPUNIT_ASSERT_EQUAL(OString("SD"), 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_TEST_FIXTURE(SwTiledRenderingTest, testSetViewGraphicSelection) diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 24dd90921a00..8a99aa5de310 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -2215,7 +2215,6 @@ void SwViewShell::ApplyViewOptions( const SwViewOption &rOpt ) if(&rSh == this) continue; SwViewOption aOpt( *rSh.GetViewOptions() ); - aOpt.SetColorConfig( rOpt.GetColorConfig() ); aOpt.SetFieldName( rOpt.IsFieldName() ); aOpt.SetShowHiddenField( rOpt.IsShowHiddenField() ); aOpt.SetShowHiddenPara( rOpt.IsShowHiddenPara() ); diff --git a/sw/source/uibase/app/apphdl.cxx b/sw/source/uibase/app/apphdl.cxx index a2ab13636d96..ed1c5ee792d4 100644 --- a/sw/source/uibase/app/apphdl.cxx +++ b/sw/source/uibase/app/apphdl.cxx @@ -79,6 +79,7 @@ #include <swabstdlg.hxx> #include <comphelper/dispatchcommand.hxx> #include <comphelper/processfactory.hxx> +#include <comphelper/lok.hxx> #include <salhelper/simplereferenceobject.hxx> #include <rtl/ref.hxx> @@ -969,8 +970,9 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con } else if ( pBrdCst == m_pColorConfig.get() ) { - //invalidate all edit windows - SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + //invalidate only the current view in tiled rendering mode, or all views otherwise + bool bOnlyInvalidateCurrentView = comphelper::LibreOfficeKit::isActive(); + SfxViewShell* pViewShell = bOnlyInvalidateCurrentView ? SfxViewShell::Current() : SfxViewShell::GetFirst(); while(pViewShell) { if(pViewShell->GetWindow()) @@ -981,11 +983,14 @@ void SwModule::ConfigurationChanged( utl::ConfigurationBroadcaster* pBrdCst, Con dynamic_cast< const SwSrcView *>( pViewShell ) != nullptr) { SwViewOption aNewOptions = *pSwView->GetWrtShell().GetViewOptions(); + aNewOptions.SetThemeName(m_pColorConfig->GetCurrentSchemeName()); aNewOptions.SetColorConfig(*m_pColorConfig); pSwView->GetWrtShell().ApplyViewOptions(aNewOptions); pViewShell->GetWindow()->Invalidate(); } } + if (bOnlyInvalidateCurrentView) + break; pViewShell = SfxViewShell::GetNext( *pViewShell ); } } diff --git a/sw/source/uibase/config/viewopt.cxx b/sw/source/uibase/config/viewopt.cxx index 04dfa0dd12f2..668256fb5c42 100644 --- a/sw/source/uibase/config/viewopt.cxx +++ b/sw/source/uibase/config/viewopt.cxx @@ -300,6 +300,7 @@ SwViewOption::SwViewOption(const SwViewOption& rVOpt) m_bReadonly = false; m_bSelectionInReadonly = false; // #114856# Form view + m_sThemeName = rVOpt.m_sThemeName; mbFormView = rVOpt.mbFormView; m_nZoom = rVOpt.m_nZoom ; m_aSnapSize = rVOpt.m_aSnapSize ; @@ -343,6 +344,7 @@ SwViewOption::SwViewOption(const SwViewOption& rVOpt) SwViewOption& SwViewOption::operator=( const SwViewOption &rVOpt ) { // #114856# Form view + m_sThemeName = rVOpt.m_sThemeName; mbFormView = rVOpt.mbFormView ; m_nZoom = rVOpt.m_nZoom ; m_aSnapSize = rVOpt.m_aSnapSize ; diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 5c9239c737e5..74326311f193 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3417,6 +3417,8 @@ OString SwXTextDocument::getViewRenderState() aState.append('P'); if (pVOpt->IsOnlineSpell()) aState.append('S'); + if (pVOpt->GetThemeName() == u"COLOR_SCHEME_LIBREOFFICE_DARK") + aState.append('D'); } } return aState.makeStringAndClear(); |