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 126378132cf7b22bf050b11173abff9d719c9d71 Author: Sahil Gautam <[email protected]> AuthorDate: Wed May 21 16:46:25 2025 +0530 Commit: Sahil Gautam <[email protected]> CommitDate: Mon Jan 26 10:05:15 2026 +0100 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 <[email protected]> (cherry picked from commit f7f1538dd8d04a51733af3c5c5457fd65e591f22) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198097 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Sahil Gautam <[email protected]> diff --git a/cui/source/options/appearance.cxx b/cui/source/options/appearance.cxx index 6d3fe3edf732..3bcd7b6960c5 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(); }))) @@ -224,6 +225,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 @@ -426,6 +433,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 d4c7aeb7af30..d131a07e63b5 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 acb14beb459a..e96aa2892039 100644 --- a/cui/uiconfig/ui/appearance.ui +++ b/cui/uiconfig/ui/appearance.ui @@ -93,6 +93,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"> @@ -112,6 +131,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 777c59a6ce5a..62a27b352bde 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -5225,6 +5225,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 3a7545db4f60..c70eaa5c623a 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -513,8 +513,12 @@ static OString getTabViewRenderState(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 3153b61c0b67..1e2a33fd7b35 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -3974,8 +3974,12 @@ OString SdXImpressDocument::getViewRenderState(SfxViewShell* pViewShell) const SdViewOptions& pVOpt = pView->GetViewOptions(); if (mpDoc && 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 a1b3e00ad56c..457bc2422d7b 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -734,6 +734,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 35a84bdb3d7f..9527a22887b2 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -45,6 +45,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::getCurrentView(); diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 4ce2e4d87a3b..7c4d6af10b8b 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3629,9 +3629,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: */
