sc/source/ui/unoobj/docuno.cxx | 4 - sd/source/ui/unoidl/unomodel.cxx | 2 sfx2/sdi/sfx.sdi | 2 sfx2/source/appl/appserv.cxx | 18 ++++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 100 +++++++++++++++++++++++++ sw/source/uibase/uno/unotxdoc.cxx | 3 6 files changed, 125 insertions(+), 4 deletions(-)
New commits: commit ee467e85efbdd7b18ccecc76894b9a7613bb44e9 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Thu Jul 25 12:34:34 2024 +0000 Commit: Skyler Grey <skyler.g...@collabora.com> CommitDate: Thu Aug 1 09:21:21 2024 +0200 test(invert): ensure background-invert separation I0aed702185e642f631854b1f8234355c9e69ff6e made inverted backgrounds separated by view. This change adds a test to make sure that it really works, based on the work in I05486860c5f562c3cfa59b4a7fc492d48913a181 to allow a specific theme to be stated on a per-view basis Change-Id: I3d0c4814cde5cafe069f984fe7904080660f10d7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171207 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index a01622eae018..29489e7835f1 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1885,6 +1885,106 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); } +// Test that changing the theme in one view doesn't change it in the other view +CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testInvertBackgroundViewSeparation) +{ + Color aDarkColor(0x1c, 0x1c, 0x1c); + addDarkLightThemes(aDarkColor, COL_WHITE); + SwXTextDocument* pXTextDocument = createDoc(); + int nFirstViewId = SfxLokHelper::getView(); + ViewCallback aView1; + // Set view to dark scheme + { + 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); + } + // First view is in dark scheme + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); + // Create second view + SfxLokHelper::createView(); + int nSecondViewId = SfxLokHelper::getView(); + ViewCallback aView2; + // Set second view to dark scheme + { + 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(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); + + // Set view 1 to invert document background + SfxLokHelper::setView(nFirstViewId); + { + 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("Light")) }, + } + ); + comphelper::dispatchCommand(".uno:InvertBackground", xFrame, aPropertyValues); + } + // First view has inverted background + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); + + SfxLokHelper::setView(nSecondViewId); + // Second view still has regular background + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); + + // Set view 2 to invert document background + { + 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("Light")) }, + } + ); + comphelper::dispatchCommand(".uno:InvertBackground", xFrame, aPropertyValues); + } + // Second view has inverted background + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); + + SfxLokHelper::setView(nFirstViewId); + // First view still has inverted background + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); + + SfxLokHelper::setView(nSecondViewId); + // Set view 2 to regular document background + { + 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:InvertBackground", xFrame, aPropertyValues); + } + // Second view has regular background + CPPUNIT_ASSERT_EQUAL(aDarkColor, getTilePixelColor(pXTextDocument, 255, 255)); + + SfxLokHelper::setView(nFirstViewId); + // First view still has inverted background + CPPUNIT_ASSERT_EQUAL(COL_WHITE, getTilePixelColor(pXTextDocument, 255, 255)); +} + // Test that changing the theme sends the document background color as LOK_CALLBACK_DOCUMENT_BACKGROUND_COLOR CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeChangeBackgroundCallback) { commit 9ebe3780594a7f2f115432b53d4d4d492e9b6c07 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Thu Jul 25 12:34:34 2024 +0000 Commit: Skyler Grey <skyler.g...@collabora.com> CommitDate: Thu Aug 1 09:21:15 2024 +0200 feat(invert): Allow specifying a theme In Online, we previously weren't able to specify what we wanted the theme to be after an invert. This led to the theme being "whatever the *last* person toggled it to" rather than "whatever isn't our current theme" This commit also lays the groundwork for loading the same invert theme after a reload/rejoin/new doc in Online There is a change to online to support this here: https://github.com/CollaboraOnline/online/pull/9652 Change-Id: I05486860c5f562c3cfa59b4a7fc492d48913a181 Refs: https://github.com/CollaboraOnline/online/pull/9652 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171206 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sfx2/sdi/sfx.sdi b/sfx2/sdi/sfx.sdi index b8e116a7a042..28ce62e6db32 100644 --- a/sfx2/sdi/sfx.sdi +++ b/sfx2/sdi/sfx.sdi @@ -5914,7 +5914,7 @@ SfxVoidItem ChangeTheme FN_CHANGE_THEME ] SfxVoidItem InvertBackground FN_INVERT_BACKGROUND -() +(SfxStringItem NewTheme FN_PARAM_NEW_THEME) [ AutoUpdate = FALSE, FastCall = FALSE, diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 8407e0248594..0db9fe31be24 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -656,15 +656,29 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) } case FN_INVERT_BACKGROUND: { + const SfxStringItem* pNewThemeArg = rReq.GetArg<SfxStringItem>(FN_PARAM_NEW_THEME); + svtools::EditableColorConfig aColorConfig; - ::Color aCurrentColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; ::Color aDefLightColor = svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 0); ::Color aDefDarkColor = svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1); + OUString aNewTheme; + if (!pNewThemeArg) { + ::Color aCurrentColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; + + if (aCurrentColor == aDefLightColor) { + aNewTheme = OUString("Dark"); + } else { + aNewTheme = OUString("Light"); + } + } else { + aNewTheme = pNewThemeArg->GetValue(); + } + svtools::ColorConfigValue aValue; aValue.bIsVisible = true; - if(aCurrentColor == aDefLightColor) + if(aNewTheme == "Dark") aValue.nColor = aDefDarkColor; else aValue.nColor = aDefLightColor; commit 64f915b0f794d763bfd967ba29c050bbfd432b41 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Thu Jul 25 12:34:34 2024 +0000 Commit: Skyler Grey <skyler.g...@collabora.com> CommitDate: Thu Aug 1 09:21:09 2024 +0200 fix(invert): Use separate view IDs when inverted Previously in Online the document background inversion was tied together such that if someone inverted the background, everyone in dark theme would end up with an inverted background. By adding whether the document background is dark to the view render state, we can create a new view when the background is inverted, and avoid everyone getting an inverted view. Change-Id: I0aed702185e642f631854b1f8234355c9e69ff6e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171045 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 7d962641178a..1cc6dc3182d1 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -505,13 +505,15 @@ void ScModelObj::RepaintRange( const ScRangeList& rRange ) static OString getTabViewRenderState(ScTabViewShell& rTabViewShell) { OStringBuffer aState; + const ScViewRenderingOptions& rViewRenderingOptions = rTabViewShell.GetViewRenderingData(); if (rTabViewShell.IsAutoSpell()) aState.append('S'); + if (rViewRenderingOptions.GetDocColor() == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1)) + aState.append('D'); aState.append(';'); - const ScViewRenderingOptions& rViewRenderingOptions = rTabViewShell.GetViewRenderingData(); OString aThemeName = OUStringToOString(rViewRenderingOptions.GetColorSchemeName(), RTL_TEXTENCODING_UTF8); aState.append(aThemeName); diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index d0d62880c747..1e3600fb53f9 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -3223,6 +3223,8 @@ OString SdXImpressDocument::getViewRenderState(SfxViewShell* pViewShell) const SdViewOptions& pVOpt = pView->GetViewOptions(); if (mpDoc->GetOnlineSpell()) aState.append('S'); + if (pVOpt.mnDocBackgroundColor == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1)) + aState.append('D'); aState.append(';'); OString aThemeName = OUStringToOString(pVOpt.msColorSchemeName, RTL_TEXTENCODING_UTF8); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 3ac436056d22..070e40c8d8b0 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3454,6 +3454,9 @@ OString SwXTextDocument::getViewRenderState(SfxViewShell* pViewShell) aState.append('P'); if (pVOpt->IsOnlineSpell()) aState.append('S'); + if (pVOpt->GetDocColor() == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1)) + aState.append('D'); + aState.append(';'); OString aThemeName = OUStringToOString(pVOpt->GetThemeName(), RTL_TEXTENCODING_UTF8);