include/svtools/colorcfg.hxx | 1 + svtools/source/config/colorcfg.cxx | 5 +++++ sw/inc/viewopt.hxx | 11 +++++++++++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 20 ++++++++++++++++++++ sw/source/core/view/viewsh.cxx | 1 - sw/source/uibase/app/apphdl.cxx | 9 +++++++-- sw/source/uibase/config/viewopt.cxx | 2 ++ sw/source/uibase/uno/unotxdoc.cxx | 2 ++ 8 files changed, 48 insertions(+), 3 deletions(-)
New commits: commit 9f0cf00d29298ed55737928ec4dddc50ac850cd8 Author: Paris Oplopoios <paris.oplopo...@collabora.com> AuthorDate: Thu Mar 16 03:58:18 2023 +0200 Commit: Paris Oplopoios <parisop...@gmail.com> CommitDate: Thu Mar 16 23:48:10 2023 +0000 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 <parisop...@gmail.com> Reviewed-by: Paris Oplopoios <parisop...@gmail.com> diff --git a/include/svtools/colorcfg.hxx b/include/svtools/colorcfg.hxx index f0c0fea5393d..8cf02dec72f8 100644 --- a/include/svtools/colorcfg.hxx +++ b/include/svtools/colorcfg.hxx @@ -110,6 +110,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 452104361729..359f55df45e1 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -468,6 +468,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 fd5c469c4f3b..230c3588026b 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1643,6 +1643,7 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testGetViewRenderState) // Create a second view SfxLokHelper::createView(); + int nSecondViewId = SfxLokHelper::getView(); ViewCallback aView2; { // Give the second view different options @@ -1656,6 +1657,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 e59c80afdc68..73fa17fd3c55 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -2214,7 +2214,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 a78ba9416e19..bbc2ada8e165 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 57ed9d0879c6..6fee616c2823 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3415,6 +3415,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();