summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorParis Oplopoios <paris.oplopoios@collabora.com>2023-03-16 03:58:18 +0200
committerParis Oplopoios <parisoplop@gmail.com>2023-03-16 23:48:10 +0000
commit9f0cf00d29298ed55737928ec4dddc50ac850cd8 (patch)
treea4f69bb28a004e533306f31baf4a37d816c80f7d /sw
parent9310192a4a0af4e7e3e9ac6124cdd2a706dfedcb (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>
Diffstat (limited to 'sw')
-rw-r--r--sw/inc/viewopt.hxx11
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx20
-rw-r--r--sw/source/core/view/viewsh.cxx1
-rw-r--r--sw/source/uibase/app/apphdl.cxx9
-rw-r--r--sw/source/uibase/config/viewopt.cxx2
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx2
6 files changed, 42 insertions, 3 deletions
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();