cui/source/options/appearance.cxx | 11 ++++++ cui/source/options/appearance.hxx | 2 + cui/uiconfig/ui/appearance.ui | 22 +++++++++++++ include/vcl/themecolors.hxx | 3 + officecfg/registry/schema/org/openoffice/Office/Common.xcs | 8 ++++ sc/source/ui/unoobj/docuno.cxx | 8 +++- sd/source/ui/unoidl/unomodel.cxx | 8 +++- svtools/source/config/colorcfg.cxx | 4 ++ sw/qa/extras/tiledrendering/tiledrendering.cxx | 3 + sw/source/uibase/uno/unotxdoc.cxx | 9 +++-- vcl/source/app/themecolors.cxx | 12 +++++++ 11 files changed, 83 insertions(+), 7 deletions(-)
New commits: commit f7f1538dd8d04a51733af3c5c5457fd65e591f22 Author: Sahil Gautam <sahil.gautam.ext...@allotropia.de> AuthorDate: Wed May 21 16:46:25 2025 +0530 Commit: Sahil Gautam <sahil.gautam.ext...@allotropia.de> CommitDate: Fri May 23 11:53:27 2025 +0200 tdf#164970 add checkbox for toggling document color customization after themes was released in 25.2, there were quite a few bug reports on bugszilla like [broken dark mode], and some on social platforms like one [bug reported on X]. this also [broke old presentations], and in that case it was more problematic than writer or calc as in case of impress it is assumed that "what you see is what you get". this happened because the documents didn't have the backgroung color attribute set and the document canvas color is dark in dark mode. the solution for this is to not override the document canvas colors by default and provide users with a choice to enable it if they want. [broken dark mode]: https://bugs.documentfoundation.org/show_bug.cgi?id=164838 [bug reported on X]: https://x.com/pritamckn25/status/1915068541801210201 [broke old presenatations]: https://bugs.documentfoundation.org/show_bug.cgi?id=165803 Change-Id: I613b5f0b6e4e1f8f2b8f9fddb50f98286dbdc481 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185388 Tested-by: Jenkins Reviewed-by: Sahil Gautam <sahil.gautam.ext...@allotropia.de> diff --git a/cui/source/options/appearance.cxx b/cui/source/options/appearance.cxx index 12383791aaf4..648b07d07363 100644 --- a/cui/source/options/appearance.cxx +++ b/cui/source/options/appearance.cxx @@ -103,6 +103,7 @@ SvxAppearanceTabPage::SvxAppearanceTabPage(weld::Container* pPage, , m_xSchemeList(m_xBuilder->weld_combo_box(u"scheme"_ustr)) , m_xMoreThemesBtn(m_xBuilder->weld_button(u"morethemesbtn"_ustr)) , m_xEnableAppTheming(m_xBuilder->weld_check_button(u"enableapptheming"_ustr)) + , m_xUseOnlyWhiteDocBackground(m_xBuilder->weld_check_button(u"useonlywhitedocbackground"_ustr)) , m_xColorEntryBtn(m_xBuilder->weld_combo_box(u"registrydropdown"_ustr)) , m_xColorChangeBtn((new ColorListBox(m_xBuilder->weld_menu_button(u"colorsdropdownbtn"_ustr), [this] { return GetFrameWeld(); }))) @@ -223,6 +224,12 @@ IMPL_LINK_NOARG(SvxAppearanceTabPage, EnableAppThemingHdl, weld::Toggleable&, vo m_bRestartRequired = true; } +IMPL_LINK_NOARG(SvxAppearanceTabPage, UseOnlyWhiteDocBackgroundHdl, weld::Toggleable&, void) +{ + ThemeColors::SetUseOnlyWhiteDocBackground(m_xUseOnlyWhiteDocBackground->get_active()); + m_bRestartRequired = true; +} + IMPL_LINK_NOARG(SvxAppearanceTabPage, ColorEntryChgHdl, weld::ComboBox&, void) { // get selected entry index and ColorConfigValue @@ -434,6 +441,10 @@ void SvxAppearanceTabPage::InitThemes() m_xEnableAppTheming->connect_toggled(LINK(this, SvxAppearanceTabPage, EnableAppThemingHdl)); m_xEnableAppTheming->set_active(ThemeColors::IsThemeEnabled()); + + m_xUseOnlyWhiteDocBackground->connect_toggled( + LINK(this, SvxAppearanceTabPage, UseOnlyWhiteDocBackgroundHdl)); + m_xUseOnlyWhiteDocBackground->set_active(ThemeColors::UseOnlyWhiteDocBackground()); } void SvxAppearanceTabPage::InitCustomization() diff --git a/cui/source/options/appearance.hxx b/cui/source/options/appearance.hxx index cc62c28460c0..2646d568db52 100644 --- a/cui/source/options/appearance.hxx +++ b/cui/source/options/appearance.hxx @@ -39,6 +39,7 @@ private: std::unique_ptr<weld::ComboBox> m_xSchemeList; std::unique_ptr<weld::Button> m_xMoreThemesBtn; std::unique_ptr<weld::CheckButton> m_xEnableAppTheming; + std::unique_ptr<weld::CheckButton> m_xUseOnlyWhiteDocBackground; std::unique_ptr<weld::ComboBox> m_xColorEntryBtn; std::unique_ptr<ColorListBox> m_xColorChangeBtn; std::unique_ptr<weld::CheckButton> m_xShowInDocumentChkBtn; @@ -55,6 +56,7 @@ private: DECL_LINK(ColorValueChgHdl, ColorListBox&, void); DECL_LINK(ShowInDocumentHdl, weld::Toggleable&, void); DECL_LINK(EnableAppThemingHdl, weld::Toggleable&, void); + DECL_LINK(UseOnlyWhiteDocBackgroundHdl, weld::Toggleable&, void); DECL_LINK(SchemeChangeHdl, weld::ComboBox&, void); DECL_LINK(SchemeListToggleHdl, weld::ComboBox&, void); DECL_STATIC_LINK(SvxAppearanceTabPage, MoreThemesHdl, weld::Button&, void); diff --git a/cui/uiconfig/ui/appearance.ui b/cui/uiconfig/ui/appearance.ui index 2833647e776d..d3232a58dde8 100644 --- a/cui/uiconfig/ui/appearance.ui +++ b/cui/uiconfig/ui/appearance.ui @@ -103,6 +103,25 @@ <property name="position">1</property> </packing> </child> + <child> + <object class="GtkCheckButton" id="useonlywhitedocbackground"> + <property name="label" translatable="yes" context="appearance|enableapptheming">Use white document background</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">False</property> + <property name="draw-indicator">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="useonlywhitedocbackground-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="appearance|extended_tip|useonlywhitedocbackground">Check to disable document color customizations and only use white document colors.</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> </object> </child> <child type="label"> @@ -122,6 +141,9 @@ <property name="position">0</property> </packing> </child> + <child> + <placeholder/> + </child> </object> <packing> <property name="expand">True</property> diff --git a/include/vcl/themecolors.hxx b/include/vcl/themecolors.hxx index c2498e9cd479..9e04f40a5f54 100644 --- a/include/vcl/themecolors.hxx +++ b/include/vcl/themecolors.hxx @@ -76,6 +76,9 @@ public: static bool IsThemeReset() { return GetThemeState() == ThemeState::RESET; } static void ResetTheme() { SetThemeState(ThemeState::RESET); } + static bool UseOnlyWhiteDocBackground(); + static void SetUseOnlyWhiteDocBackground(bool bFlag); + // !IsThemeCached means that the ThemeColors object doesn't have the colors from the registry yet. // IsThemeReset means that the user pressed the Reset All button and the UI colors in the registry // are not valid anymore => read from the system again diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 663d70a909b6..f520774a65f4 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -5245,6 +5245,14 @@ </constraints> <value>0</value> </prop> + <prop oor:name="UseOnlyWhiteDocBackground" oor:type="xs:boolean" oor:nillable="false"> + <info> + <desc>Use only white colors for document background and don't let + the theme change it.</desc> + <label>Use white document background</label> + </info> + <value>true</value> + </prop> </group> <group oor:name="Misc"> <info> diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 3b8927d84d11..2afb3f12f0a7 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -510,8 +510,12 @@ static OString getTabViewRenderState(const ScTabViewShell& rTabViewShell) if (rTabViewShell.IsAutoSpell()) aState.append('S'); - if (rViewRenderingOptions.GetDocColor() == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1)) - aState.append('D'); + if (!ThemeColors::UseOnlyWhiteDocBackground()) + { + if (rViewRenderingOptions.GetDocColor() + == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1)) + aState.append('D'); + } aState.append(';'); diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 31e459c07f37..9dcae67d86ea 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -3966,8 +3966,12 @@ 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'); + if (!ThemeColors::UseOnlyWhiteDocBackground()) + { + if (pVOpt.mnDocBackgroundColor + == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR)) + aState.append('D'); + } aState.append(';'); OString aThemeName = OUStringToOString(pVOpt.msColorSchemeName, RTL_TEXTENCODING_UTF8); diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index c0e3e16feea7..1e7dfd0ea082 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -725,6 +725,10 @@ Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry, int nMod) break; } } + + if (ThemeColors::UseOnlyWhiteDocBackground()) + nAppMod = clLight; + aRet = cAutoColors[eEntry][nAppMod]; } // fdo#71511: if in a11y HC mode, do pull background color from theme diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 080ae12f1ed8..ae373612e59e 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -46,6 +46,7 @@ #include <vcl/vclevent.hxx> #include <vcl/BitmapReadAccess.hxx> #include <vcl/ITiledRenderable.hxx> +#include <vcl/themecolors.hxx> #include <tools/json_writer.hxx> #include <unotools/mediadescriptor.hxx> #include <comphelper/processfactory.hxx> @@ -1395,6 +1396,8 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testInvertBackgroundViewSeparation) { Color aDarkColor(0x1c, 0x1c, 0x1c); + if (ThemeColors::UseOnlyWhiteDocBackground()) + aDarkColor = COL_WHITE; addDarkLightThemes(aDarkColor, COL_WHITE); SwXTextDocument* pXTextDocument = createDoc(); int nFirstViewId = SfxLokHelper::getView(); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index bccb5b4a7968..f0f4b882a15e 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3647,9 +3647,12 @@ 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'); - + if (!ThemeColors::UseOnlyWhiteDocBackground()) + { + if (pVOpt->GetDocColor() + == svtools::ColorConfig::GetDefaultColor(svtools::DOCCOLOR, 1)) + aState.append('D'); + } if (pView->IsSpotlightParaStyles() || pView->IsSpotlightCharStyles()) { aState.append('H'); diff --git a/vcl/source/app/themecolors.cxx b/vcl/source/app/themecolors.cxx index 33f4601f89bc..f5197bbad8e9 100644 --- a/vcl/source/app/themecolors.cxx +++ b/vcl/source/app/themecolors.cxx @@ -24,4 +24,16 @@ ThemeState ThemeColors::GetThemeState() return static_cast<ThemeState>(officecfg::Office::Common::Appearance::LibreOfficeTheme::get()); } +bool ThemeColors::UseOnlyWhiteDocBackground() +{ + return officecfg::Office::Common::Appearance::UseOnlyWhiteDocBackground::get(); +} + +void ThemeColors::SetUseOnlyWhiteDocBackground(bool bFlag) +{ + auto pChange(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Appearance::UseOnlyWhiteDocBackground::set(bFlag, pChange); + pChange->commit(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */