sc/source/ui/unoobj/docuno.cxx | 11 +++++++ sd/source/ui/unoidl/unomodel.cxx | 11 +++++++ sfx2/source/appl/appserv.cxx | 1 svtools/source/config/colorcfg.cxx | 51 ++++++++++++++++++++++++++++++------- sw/source/uibase/uno/unotxdoc.cxx | 11 +++++++ 5 files changed, 75 insertions(+), 10 deletions(-)
New commits: commit f805a645b9d358938b73f0522dfcdfe8cc6036d1 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Tue Jul 30 10:17:31 2024 +0000 Commit: Skyler Grey <skyler.g...@collabora.com> CommitDate: Thu Aug 1 09:21:33 2024 +0200 fix(invert): Avoid spurious LOK invalidations Using the same mechanism as with theme changes, we can avoid LOK getting invalidations if we have an invert-background change that doesn't apply. The trouble is that this method of inverting the background causes *lots of* properties to change, so there's no single "If we inverted the background" to check... To get there, I've checked if all of the following are true - We didn't change the color scheme - We didn't have any new colors after this change - All of the properties we were changing should have been within this color scheme While they don't necessarily mean "there was a background inversion", they do mean "something changed in your theme but no action is needed from you" - which should only be a background inversion - and if we added anything else that could fit in that category, it should also avoid LOK invalidations Change-Id: Idb680d5241db7879d9be834268ab616848c1f165 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171283 Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> diff --git a/sfx2/source/appl/appserv.cxx b/sfx2/source/appl/appserv.cxx index 0db9fe31be24..f53570f78a8c 100644 --- a/sfx2/source/appl/appserv.cxx +++ b/sfx2/source/appl/appserv.cxx @@ -676,7 +676,6 @@ void SfxApplication::MiscExec_Impl( SfxRequest& rReq ) } svtools::ColorConfigValue aValue; - aValue.bIsVisible = true; if(aNewTheme == "Dark") aValue.nColor = aDefDarkColor; diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index a2f8aeddf96d..3e7e84a273fd 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -244,25 +244,58 @@ void ColorConfig_Impl::Load(const OUString& rScheme) void ColorConfig_Impl::Notify(const uno::Sequence<OUString>& rProperties) { - const bool bOnlyChangingCurrentColorScheme = rProperties.getLength() == 1 && rProperties[0] == "CurrentColorScheme"; const OUString sOldLoadedScheme = m_sLoadedScheme; - //loading via notification always uses the default setting + ColorConfigValue aOldConfigValues[ColorConfigEntryCount]; + std::copy( m_aConfigValues, m_aConfigValues + ColorConfigEntryCount, aOldConfigValues ); + + // loading via notification always uses the default setting Load(OUString()); + const bool bNoColorSchemeChange = sOldLoadedScheme == m_sLoadedScheme; + // If the name of the scheme hasn't changed, then there is no change to the // global color scheme name, but Kit deliberately only changed the then // current document when it last changed, so there are typically a mixture // of documents with the original 'light' color scheme and the last changed // color scheme 'dark'. Kit then tries to set the color scheme again to the // last changed color scheme 'dark' to try and update a 'light' document - // that had opted out of the last change to 'dark'. So tag such an apparent - // null change attempt with 'OnlyCurrentDocumentColorScheme' to allow it to - // go through, but identify what that change is for, so the other color - // config listeners for whom it doesn't matter, can ignore it as an - // optimization. - const bool bOnlyCurrentDocumentColorScheme = bOnlyChangingCurrentColorScheme && sOldLoadedScheme == m_sLoadedScheme && - comphelper::LibreOfficeKit::isActive(); + // that had opted out of the last change to 'dark'... + const bool bEmptyColorSchemeNotify = + rProperties.getLength() == 1 + && rProperties[0] == "CurrentColorScheme" + && bNoColorSchemeChange; + + // ...We can get into a similar situation with inverted backgrounds, for + // similar reasons, so even if we are only changing the current color scheme + // we need to make sure that something actually changed... + bool bNoConfigChange = true; + for (int i = 0; i < ColorConfigEntryCount; ++i) { + if (aOldConfigValues[i] != m_aConfigValues[i]) { + bNoConfigChange = false; + break; + } + } + + // ...and if something from a different color scheme changes, our config + // values wouldn't change anyway, so we need to make sure that if something + // changed it was this color scheme... + const OUString sCurrentSchemePropertyPrefix = "ColorSchemes/org.openoffice.Office.UI:ColorScheme['" + m_sLoadedScheme + "']/"; + bool bOnlyCurrentSchemeChanges = true; + for (int i = 0; i < rProperties.getLength(); ++i) { + if (!rProperties[i].startsWith(sCurrentSchemePropertyPrefix)) { + bOnlyCurrentSchemeChanges = false; + break; + } + } + + bool bEmptyCurrentSchemeNotify = bNoColorSchemeChange && bNoConfigChange && bOnlyCurrentSchemeChanges; + + // ...We can tag apparent null change attempts with + // 'OnlyCurrentDocumentColorScheme' to allow them to go through, but + // identify what that change is for, so the other color config listeners for + // whom it doesn't matter, can ignore it as an optimization. + const bool bOnlyCurrentDocumentColorScheme = (bEmptyColorSchemeNotify || bEmptyCurrentSchemeNotify) && comphelper::LibreOfficeKit::isActive(); NotifyListeners(bOnlyCurrentDocumentColorScheme ? ConfigurationHints::OnlyCurrentDocumentColorScheme : ConfigurationHints::NONE); } commit 5cc22e205287d76cae6cc24453cd1b5e7ac39344 Author: Skyler Grey <skyler.g...@collabora.com> AuthorDate: Mon Jul 29 09:52:18 2024 +0000 Commit: Skyler Grey <skyler.g...@collabora.com> CommitDate: Thu Aug 1 09:21:27 2024 +0200 feat(invert): Allow inverted background on init Previously for Online there was no way to save the background invert state and reload it. Worse, when someone changed the state it would become the default for new document loads. This patch allows Online to specify whether it wants the background to be inverted, which should allow smooth tab refreshes while also avoiding mingling state from different people. There is a change to online to support this here: https://github.com/CollaboraOnline/online/pull/9652 Change-Id: I8c22c03d3b4589736d48509004f7789dd5166389 Refs: https://github.com/CollaboraOnline/online/pull/9652 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171208 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 1cc6dc3182d1..2efedd61b856 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1316,6 +1316,7 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans SC_MOD()->SetAppOptions(aAppOptions); OUString sThemeName; + OUString sBackgroundThemeName; for (const beans::PropertyValue& rValue : rArguments) { @@ -1327,6 +1328,8 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans } else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>()) sThemeName = rValue.Value.get<OUString>(); + else if (rValue.Name == ".uno:InvertBackground" && rValue.Value.has<OUString>()) + sBackgroundThemeName = rValue.Value.get<OUString>(); } // show us the text exactly @@ -1353,6 +1356,14 @@ void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans })); comphelper::dispatchCommand(".uno:ChangeTheme", aPropertyValues); } + if (!sBackgroundThemeName.isEmpty()) + { + css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(sBackgroundThemeName) } + })); + comphelper::dispatchCommand(".uno:InvertBackground", aPropertyValues); + } } uno::Any SAL_CALL ScModelObj::queryInterface( const uno::Type& rType ) diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 1e3600fb53f9..991cf2a037bf 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -3460,6 +3460,7 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs SolarMutexGuard aGuard; OUString sThemeName; + OUString sBackgroundThemeName; if (DrawViewShell* pViewShell = GetViewShell()) { @@ -3474,6 +3475,8 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs mpDoc->SetOnlineSpell(rValue.Value.get<bool>()); else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>()) sThemeName = rValue.Value.get<OUString>(); + else if (rValue.Name == ".uno:InvertBackground" && rValue.Value.has<OUString>()) + sBackgroundThemeName = rValue.Value.get<OUString>(); } // Disable comments if requested @@ -3525,6 +3528,14 @@ void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<cs })); comphelper::dispatchCommand(".uno:ChangeTheme", aPropertyValues); } + if (!sBackgroundThemeName.isEmpty()) + { + css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(sBackgroundThemeName) } + })); + comphelper::dispatchCommand(".uno:InvertBackground", aPropertyValues); + } } void SdXImpressDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode) diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 070e40c8d8b0..2cffa5af217f 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3651,6 +3651,7 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css:: aViewOption.SetUseHeaderFooterMenu(false); OUString sThemeName; + OUString sBackgroundThemeName; OUString sOrigAuthor = SW_MOD()->GetRedlineAuthor(SW_MOD()->GetRedlineAuthor()); OUString sAuthor; @@ -3674,6 +3675,8 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css:: aViewOption.SetOnlineSpell(rValue.Value.get<bool>()); else if (rValue.Name == ".uno:ChangeTheme" && rValue.Value.has<OUString>()) sThemeName = rValue.Value.get<OUString>(); + else if (rValue.Name == ".uno:InvertBackground" && rValue.Value.has<OUString>()) + sBackgroundThemeName = rValue.Value.get<OUString>(); } if (!sAuthor.isEmpty() && sAuthor != sOrigAuthor) @@ -3732,6 +3735,14 @@ void SwXTextDocument::initializeForTiledRendering(const css::uno::Sequence<css:: })); comphelper::dispatchCommand(".uno:ChangeTheme", aPropertyValues); } + if (!sBackgroundThemeName.isEmpty()) + { + css::uno::Sequence<css::beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(sBackgroundThemeName) } + })); + comphelper::dispatchCommand(".uno:InvertBackground", aPropertyValues); + } } void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)