cui/inc/strings.hrc | 1 cui/source/options/optcolor.cxx | 36 + cui/source/options/optcolor.hxx | 3 cui/uiconfig/ui/optappearancepage.ui | 220 +++++---- include/vcl/settings.hxx | 3 officecfg/registry/data/org/openoffice/Office/UI.xcu | 298 ------------- officecfg/registry/schema/org/openoffice/Office/Common.xcs | 25 + sc/inc/viewopti.hxx | 2 sc/source/ui/view/gridwin4.cxx | 2 sd/inc/viewopt.hxx | 2 sd/qa/unit/tiledrendering/tiledrendering.cxx | 88 +++ sd/source/ui/unoidl/unomodel.cxx | 6 sd/source/ui/view/drviewsk.cxx | 1 svtools/source/config/colorcfg.cxx | 121 ++--- sw/qa/extras/tiledrendering/tiledrendering.cxx | 54 +- vcl/source/app/settings.cxx | 12 16 files changed, 380 insertions(+), 494 deletions(-)
New commits: commit c1bc450f395dbebcf3481fdcdf3f63c8867cab5f Author: Paris Oplopoios <[email protected]> AuthorDate: Wed May 3 14:46:37 2023 +0300 Commit: Paris Oplopoios <[email protected]> CommitDate: Fri May 5 11:34:18 2023 +0200 Application color should follow system color patch backport Patch https://gerrit.libreoffice.org/c/core/+/149059 removed dark mode and made application color follow system color. This patch backports that patch to co-23.05 and changes the tests to account for the new ways to change to dark mode. Change-Id: I49a99a73bce6cb26f8e8e2ab2f642483c9ee195b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151320 Tested-by: Paris Oplopoios <[email protected]> Reviewed-by: Paris Oplopoios <[email protected]> diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc index cb90ffe6d7df..b665204dc7a9 100644 --- a/cui/inc/strings.hrc +++ b/cui/inc/strings.hrc @@ -406,6 +406,5 @@ // Translatable names of color schemes #define RID_COLOR_SCHEME_LIBREOFFICE_AUTOMATIC NC_("RID_COLOR_SCHEME_LIBREOFFICE_AUTOMATIC", "Automatic") -#define RID_COLOR_SCHEME_LIBREOFFICE_DARK NC_("RID_COLOR_SCHEME_LIBREOFFICE_DARK", "Dark") /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/options/optcolor.cxx b/cui/source/options/optcolor.cxx index 112be3ea215c..7a37e1187b53 100644 --- a/cui/source/options/optcolor.cxx +++ b/cui/source/options/optcolor.cxx @@ -34,7 +34,8 @@ #include <dialmgr.hxx> #include "optcolor.hxx" #include <strings.hrc> - +#include <svtools/miscopt.hxx> +#include <officecfg/Office/Common.hxx> using namespace ::com::sun::star; using namespace ::svtools; @@ -164,7 +165,6 @@ const std::map<OUString, OUString> &getColorSchemes() { static std::map<OUString, OUString> const vColorSchemes = { {"COLOR_SCHEME_LIBREOFFICE_AUTOMATIC", CuiResId(RID_COLOR_SCHEME_LIBREOFFICE_AUTOMATIC)}, - {"COLOR_SCHEME_LIBREOFFICE_DARK", CuiResId(RID_COLOR_SCHEME_LIBREOFFICE_DARK)} }; return vColorSchemes; }; @@ -203,6 +203,7 @@ public: Link<weld::Widget&,void> const&, weld::ScrolledWindow& rScroll); void Update(EditableColorConfig const*, EditableExtendedColorConfig const*); + void UpdateEntries(); void ClickHdl(EditableColorConfig*, const weld::Toggleable&); void ColorHdl(EditableColorConfig*, EditableExtendedColorConfig*, const ColorListBox*); @@ -527,6 +528,16 @@ void ColorConfigWindow_Impl::Update ( } } +void ColorConfigWindow_Impl::UpdateEntries() +{ + for (unsigned i = 0; i != ColorConfigEntryCount; ++i) + { + ColorConfigEntry const aEntry = static_cast<ColorConfigEntry>(i); + Color aColor = ColorConfig::GetDefaultColor(aEntry); + vEntries[i]->m_xColorList->SetAutoDisplayColor(aColor); + } +} + // ClickHdl() void ColorConfigWindow_Impl::ClickHdl(EditableColorConfig* pConfig, const weld::Toggleable& rBox) { @@ -626,6 +637,7 @@ public: void SetConfig (EditableColorConfig& rConfig) { pColorConfig = &rConfig; } void SetExtendedConfig (EditableExtendedColorConfig& rConfig) { pExtColorConfig = &rConfig; } void Update(); + void UpdateEntries(); tools::Long GetScrollPosition() const { return m_xVScroll->vadjustment_get_value(); @@ -669,6 +681,11 @@ void ColorConfigCtrl_Impl::Update () m_xScrollWindow->Update(pColorConfig, pExtColorConfig); } +void ColorConfigCtrl_Impl::UpdateEntries() +{ + m_xScrollWindow->UpdateEntries(); +} + IMPL_LINK(ColorConfigCtrl_Impl, ClickHdl, weld::Toggleable&, rBox, void) { DBG_ASSERT(pColorConfig, "Configuration not set"); @@ -725,6 +742,7 @@ SvxColorOptionsTabPage::SvxColorOptionsTabPage(weld::Container* pPage, weld::Dia : SfxTabPage(pPage, pController, "cui/ui/optappearancepage.ui", "OptAppearancePage", &rCoreSet) , bFillItemSetCalled(false) , m_nSizeAllocEventId(nullptr) + , m_xAutoColorLB(m_xBuilder->weld_combo_box("autocolorlb")) , m_xColorSchemeLB(m_xBuilder->weld_combo_box("colorschemelb")) , m_xSaveSchemePB(m_xBuilder->weld_button("save")) , m_xDeleteSchemePB(m_xBuilder->weld_button("delete")) @@ -737,6 +755,7 @@ SvxColorOptionsTabPage::SvxColorOptionsTabPage(weld::Container* pPage, weld::Dia { m_xColorSchemeLB->make_sorted(); m_xColorSchemeLB->connect_changed(LINK(this, SvxColorOptionsTabPage, SchemeChangedHdl_Impl)); + m_xAutoColorLB->connect_changed(LINK(this, SvxColorOptionsTabPage, onAutoColorChanged)); Link<weld::Button&,void> aLk = LINK(this, SvxColorOptionsTabPage, SaveDeleteHdl_Impl ); m_xSaveSchemePB->connect_clicked(aLk); m_xDeleteSchemePB->connect_clicked(aLk); @@ -811,6 +830,8 @@ void SvxColorOptionsTabPage::Reset( const SfxItemSet* ) pExtColorConfig.reset(new EditableExtendedColorConfig); m_xColorConfigCT->SetExtendedConfig(*pExtColorConfig); + m_xAutoColorLB->set_active( MiscSettings::GetAppColorMode() ); + OUString sUser = GetUserData(); //has to be called always to speed up accessibility tools m_xColorConfigCT->SetScrollPosition(sUser.toInt32()); @@ -837,6 +858,17 @@ void SvxColorOptionsTabPage::UpdateColorConfig() m_xColorConfigCT->Update(); } +IMPL_LINK_NOARG(SvxColorOptionsTabPage, onAutoColorChanged, weld::ComboBox&, void) +{ + MiscSettings::SetAppColorMode( m_xAutoColorLB->get_active() ); + + m_xColorConfigCT->UpdateEntries(); + + pColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(m_xColorSchemeLB->get_active_text())); + pExtColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(m_xColorSchemeLB->get_active_text())); + UpdateColorConfig(); +} + IMPL_LINK(SvxColorOptionsTabPage, SchemeChangedHdl_Impl, weld::ComboBox&, rBox, void) { pColorConfig->LoadScheme(lcl_TranslatedNameToSchemeId(rBox.get_active_text())); diff --git a/cui/source/options/optcolor.hxx b/cui/source/options/optcolor.hxx index 0fa8cf2c46ea..096ed93b256d 100644 --- a/cui/source/options/optcolor.hxx +++ b/cui/source/options/optcolor.hxx @@ -31,6 +31,7 @@ class SvxColorOptionsTabPage : public SfxTabPage ImplSVEvent* m_nSizeAllocEventId; + std::unique_ptr<weld::ComboBox> m_xAutoColorLB; std::unique_ptr<weld::ComboBox> m_xColorSchemeLB; std::unique_ptr<weld::Button> m_xSaveSchemePB; std::unique_ptr<weld::Button> m_xDeleteSchemePB; @@ -38,6 +39,7 @@ class SvxColorOptionsTabPage : public SfxTabPage std::unique_ptr<weld::Widget> m_xTable; std::unique_ptr<weld::Label> m_xOnFT; std::unique_ptr<weld::Label> m_xColorFT; + weld::Widget& m_rWidget1; weld::Widget& m_rWidget2; @@ -45,6 +47,7 @@ class SvxColorOptionsTabPage : public SfxTabPage std::unique_ptr<svtools::EditableExtendedColorConfig> pExtColorConfig; DECL_LINK(SchemeChangedHdl_Impl, weld::ComboBox&, void); + DECL_LINK(onAutoColorChanged, weld::ComboBox&, void); DECL_LINK(SaveDeleteHdl_Impl, weld::Button&, void); DECL_LINK(CheckNameHdl_Impl, AbstractSvxNameDialog&, bool); DECL_LINK(AdjustHeaderBar, const Size&, void); diff --git a/cui/uiconfig/ui/optappearancepage.ui b/cui/uiconfig/ui/optappearancepage.ui index 64c338ba978f..63916d36543f 100644 --- a/cui/uiconfig/ui/optappearancepage.ui +++ b/cui/uiconfig/ui/optappearancepage.ui @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.38.2 --> +<!-- Generated with glade 3.40.0 --> <interface domain="cui"> <requires lib="gtk+" version="3.20"/> <object class="GtkBox" id="OptAppearancePage"> @@ -10,106 +10,6 @@ <property name="border-width">6</property> <property name="orientation">vertical</property> <property name="spacing">12</property> - <child> - <object class="GtkFrame" id="frame1"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="hexpand">True</property> - <property name="label-xalign">0</property> - <property name="shadow-type">none</property> - <child> - <!-- n-columns=4 n-rows=1 --> - <object class="GtkGrid" id="grid1"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="margin-start">12</property> - <property name="margin-top">6</property> - <property name="hexpand">True</property> - <property name="column-spacing">12</property> - <child> - <object class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes" context="optappearancepage|label3">_Scheme:</property> - <property name="use-underline">True</property> - <property name="mnemonic-widget">colorschemelb</property> - </object> - <packing> - <property name="left-attach">0</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="save"> - <property name="label" translatable="yes" context="optappearancepage|save">_Save</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="use-underline">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="save-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|save">Saves the current settings as a color scheme that you can reload later.</property> - </object> - </child> - </object> - <packing> - <property name="left-attach">2</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="delete"> - <property name="label" translatable="yes" context="stock">_Delete</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">True</property> - <property name="use-underline">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="delete-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|delete">Deletes the color scheme shown in the Scheme box. You cannot delete the Default scheme.</property> - </object> - </child> - </object> - <packing> - <property name="left-attach">3</property> - <property name="top-attach">0</property> - </packing> - </child> - <child> - <object class="GtkComboBoxText" id="colorschemelb"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="hexpand">True</property> - <child internal-child="accessible"> - <object class="AtkObject" id="colorschemelb-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|colorschemelb">Selects the color scheme you want to use.</property> - </object> - </child> - </object> - <packing> - <property name="left-attach">1</property> - <property name="top-attach">0</property> - </packing> - </child> - </object> - </child> - <child type="label"> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="can-focus">False</property> - <property name="label" translatable="yes" context="optappearancepage|label1">Color Scheme</property> - <attributes> - <attribute name="weight" value="bold"/> - </attributes> - </object> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> <child> <object class="GtkFrame" id="frame2"> <property name="visible">True</property> @@ -119,9 +19,10 @@ <property name="label-xalign">0</property> <property name="shadow-type">none</property> <child> - <!-- n-columns=1 n-rows=2 --> + <!-- n-columns=1 n-rows=3 --> <object class="GtkGrid" id="table"> <property name="visible">True</property> + <property name="sensitive">False</property> <property name="can-focus">False</property> <property name="margin-start">12</property> <property name="margin-top">6</property> @@ -179,7 +80,7 @@ </object> <packing> <property name="left-attach">0</property> - <property name="top-attach">1</property> + <property name="top-attach">2</property> </packing> </child> <child> @@ -187,6 +88,7 @@ <object class="GtkGrid" id="grid3"> <property name="visible">True</property> <property name="can-focus">False</property> + <property name="margin-top">6</property> <property name="hexpand">True</property> <property name="column-spacing">6</property> <child> @@ -228,6 +130,116 @@ </packing> </child> </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">1</property> + </packing> + </child> + <child> + <!-- n-columns=6 n-rows=1 --> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">12</property> + <property name="margin-top">6</property> + <property name="hexpand">True</property> + <property name="column-spacing">6</property> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="label" translatable="yes" context="optappearancepage|label3">_Scheme:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">colorschemelb</property> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="save"> + <property name="label" translatable="yes" context="optappearancepage|save">_Save</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="save-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|save">Saves the current settings as a color scheme that you can reload later.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">2</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="delete"> + <property name="label" translatable="yes" context="stock">_Delete</property> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="receives-default">True</property> + <property name="use-underline">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="delete-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|delete">Deletes the color scheme shown in the Scheme box. You cannot delete the Default scheme.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">3</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="colorschemelb"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="hexpand">True</property> + <child internal-child="accessible"> + <object class="AtkObject" id="colorschemelb-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="extended_tip|colorschemelb">Selects the color scheme you want to use.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="autocolor"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="margin-start">12</property> + <property name="label" translatable="yes" context="optappearancepage|autocolor">_Automatic:</property> + <property name="use-underline">True</property> + <property name="mnemonic-widget">autocolorlb</property> + </object> + <packing> + <property name="left-attach">4</property> + <property name="top-attach">0</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="autocolorlb"> + <property name="visible">True</property> + <property name="can-focus">False</property> + <property name="active">1</property> + <items> + <item id="0" translatable="yes" context="optappearancepage|cbSchemeEntry1">System Theme</item> + <item id="1" translatable="yes" context="optappearancepage|cbSchemeEntry2">Light</item> + <item id="2" translatable="yes" context="optappearancepage|cbSchemeEntry3">Dark</item> + </items> + </object> + <packing> + <property name="left-attach">5</property> + <property name="top-attach">0</property> + </packing> + </child> + </object> <packing> <property name="left-attach">0</property> <property name="top-attach">0</property> @@ -249,7 +261,7 @@ <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">1</property> + <property name="position">0</property> </packing> </child> <child internal-child="accessible"> diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx index de6a4b903c07..9292e10e45cf 100644 --- a/include/vcl/settings.hxx +++ b/include/vcl/settings.hxx @@ -648,7 +648,8 @@ public: // 0 auto, 1 light, 2, dark static void SetDarkMode(int nMode); static int GetDarkMode(); - + static void SetAppColorMode(int nMode); + static int GetAppColorMode(); bool operator ==( const MiscSettings& rSet ) const; bool operator !=( const MiscSettings& rSet ) const; }; diff --git a/officecfg/registry/data/org/openoffice/Office/UI.xcu b/officecfg/registry/data/org/openoffice/Office/UI.xcu index 93e95f0c5c65..e299a81dae76 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI.xcu @@ -435,304 +435,6 @@ </prop> </node> </node> - <node oor:name="COLOR_SCHEME_LIBREOFFICE_DARK" oor:op="replace"> - <node oor:name="DocColor"> - <prop oor:name="Color"> - <value>1842204</value> - </prop> - </node> - <node oor:name="DocBoundaries"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value>8421504</value> - </prop> - </node> - <node oor:name="AppBackground"> - <prop oor:name="Color"> - <value>3355443</value> - </prop> - </node> - <node oor:name="ObjectBoundaries"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value>8421504</value> - </prop> - </node> - <node oor:name="TableBoundaries"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value>1842204</value> - </prop> - </node> - <node oor:name="FontColor"> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="Links"> - <prop oor:name="IsVisible"> - <value>false</value> - </prop> - <prop oor:name="Color"> - <value>1939955</value> - </prop> - </node> - <node oor:name="LinksVisited"> - <prop oor:name="IsVisible"> - <value>false</value> - </prop> - <prop oor:name="Color"> - <value>10181046</value> - </prop> - </node> - <node oor:name="Spell"> - <prop oor:name="Color"> - <value>13181214</value> - </prop> - </node> - <node oor:name="Grammar"> - <prop oor:name="Color"> - <value>7512015</value> - </prop> - </node> - <node oor:name="SmartTags"> - <prop oor:name="Color"> - <value>7865203</value> - </prop> - </node> - <node oor:name="Shadow"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value>1842204</value> - </prop> - </node> - <node oor:name="WriterTextGrid"> - <prop oor:name="Color"> - <value>8421504</value> - </prop> - </node> - <node oor:name="WriterFieldShadings"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="WriterIdxShadings"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value>1842204</value> - </prop> - </node> - <node oor:name="WriterDirectCursor"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="WriterScriptIndicator"> - <prop oor:name="Color"> - <value>1993273</value> - </prop> - </node> - <node oor:name="WriterSectionBoundaries"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value>6710886</value> - </prop> - </node> - <node oor:name="WriterHeaderFooterMark"> - <prop oor:name="Color"> - <value>11847644</value> - </prop> - </node> - <node oor:name="WriterPageBreaks"> - <prop oor:name="Color"> - <value>7512015</value> - </prop> - </node> - <node oor:name="HTMLSGML"> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="HTMLComment"> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="HTMLKeyword"> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="HTMLUnknown"> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="CalcGrid"> - <prop oor:name="Color"> - <value>6710886</value> - </prop> - </node> - <node oor:name="CalcPageBreak"> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="CalcPageBreakManual"> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="CalcPageBreakAutomatic"> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="CalcHiddenColRow"> - <prop oor:name="IsVisible"> - <value>false</value> - </prop> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="CalcDetective"> - <prop oor:name="Color"> - <value>3494505</value> - </prop> - </node> - <node oor:name="CalcDetectiveError"> - <prop oor:name="Color"> - <value>13181214</value> - </prop> - </node> - <node oor:name="CalcReference"> - <prop oor:name="Color"> - <value>861141</value> - </prop> - </node> - <node oor:name="CalcNotesBackground"> - <prop oor:name="Color"> - <value>15245826</value> - </prop> - </node> - <node oor:name="CalcValue"> - <prop oor:name="Color"> - <value>7512015</value> - </prop> - </node> - <node oor:name="CalcFormula"> - <prop oor:name="Color"> - <value>7847013</value> - </prop> - </node> - <node oor:name="CalcText"> - <prop oor:name="Color"> - <value>15658734</value> - </prop> - </node> - <node oor:name="CalcProtectedBackground"> - <prop oor:name="Color"> - <value>1842204</value> - </prop> - </node> - <node oor:name="DrawGrid"> - <prop oor:name="IsVisible"> - <value>true</value> - </prop> - <prop oor:name="Color"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="BASICIdentifier"> - <prop oor:name="Color" oor:type="xs:int"> - <value>14543051</value> - </prop> - </node> - <node oor:name="BASICComment"> - <prop oor:name="Color" oor:type="xs:int"> - <value>15658734</value> - </prop> - </node> - <node oor:name="BASICNumber"> - <prop oor:name="Color" oor:type="xs:int"> - <value>16754342</value> - </prop> - </node> - <node oor:name="BASICString"> - <prop oor:name="Color" oor:type="xs:int"> - <value>16754342</value> - </prop> - </node> - <node oor:name="BASICOperator"> - <prop oor:name="Color" oor:type="xs:int"> - <value>11847644</value> - </prop> - </node> - <node oor:name="BASICKeyword"> - <prop oor:name="Color" oor:type="xs:int"> - <value>11847644</value> - </prop> - </node> - <node oor:name="BASICError"> - <prop oor:name="Color" oor:type="xs:int"> - <value>16726072</value> - </prop> - </node> - <node oor:name="SQLIdentifier"> - <prop oor:name="Color" oor:type="xs:int"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="SQLNumber"> - <prop oor:name="Color" oor:type="xs:int"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="SQLString"> - <prop oor:name="Color" oor:type="xs:int"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="SQLOperator"> - <prop oor:name="Color" oor:type="xs:int"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="SQLKeyword"> - <prop oor:name="Color" oor:type="xs:int"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="SQLParameter"> - <prop oor:name="Color" oor:type="xs:int"> - <value xsi:nil="true"/> - </prop> - </node> - <node oor:name="SQLComment"> - <prop oor:name="Color" oor:type="xs:int"> - <value xsi:nil="true"/> - </prop> - </node> - </node> </node> </node> </oor:component-data> diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs index 3fea66eb5b1e..110a8595f9f7 100644 --- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs +++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs @@ -5446,6 +5446,31 @@ </constraints> <value>0</value> </prop> + <prop oor:name="ApplicationAppearance" oor:type="xs:short" oor:nillable="false"> + <!-- UIHints: Tools Options - General View [Section] Appearance --> + <info> + <desc>Specifies the application colors.</desc> + <label>Application Colors</label> + </info> + <constraints> + <enumeration oor:value="0"> + <info> + <desc>Automatic, following the system settings</desc> + </info> + </enumeration> + <enumeration oor:value="1"> + <info> + <desc>Light</desc> + </info> + </enumeration> + <enumeration oor:value="2"> + <info> + <desc>Dark</desc> + </info> + </enumeration> + </constraints> + <value>1</value> + </prop> <prop oor:name="MaxOpenDocuments" oor:type="xs:int"> <info> <desc>Determines the maximum count of documents, which are allowed to diff --git a/sc/inc/viewopti.hxx b/sc/inc/viewopti.hxx index 79819e7ca324..9887ca3903fb 100644 --- a/sc/inc/viewopti.hxx +++ b/sc/inc/viewopti.hxx @@ -58,6 +58,8 @@ enum ScVObjType #define MAX_OPT sal_uInt16(VOPT_CLIPMARKS)+1 #define MAX_TYPE sal_uInt16(VOBJ_TYPE_DRAW)+1 +// SC_STD_GRIDCOLOR is obsolete since tdf#152184 since GridColor == COL_AUTO +// converts now to either light or dark but still used on options > view > visual aids #define SC_STD_GRIDCOLOR COL_LIGHTGRAY // SvxGrid options with standard operators diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index d798ca8cce93..b6590530d44a 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -691,7 +691,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI tools::Long nScrY = aOutputData.nScrY; const svtools::ColorConfig& rColorCfg = pScMod->GetColorConfig(); - Color aGridColor( rColorCfg.GetColorValue( svtools::CALCGRID, false ).nColor ); + Color aGridColor( rColorCfg.GetColorValue( svtools::CALCGRID ).nColor ); if ( aGridColor == COL_TRANSPARENT ) { // use view options' grid color only if color config has "automatic" color diff --git a/sd/inc/viewopt.hxx b/sd/inc/viewopt.hxx index 0e12dc067427..03ebd2ada659 100644 --- a/sd/inc/viewopt.hxx +++ b/sd/inc/viewopt.hxx @@ -28,7 +28,7 @@ struct SdViewOptions // The color of the document background Color mnDocBackgroundColor; // The name of the color scheme - OUString msColorSchemeName; + OUString msColorSchemeName = "Default"; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 5c3325ad42f0..0552193eaf30 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -132,6 +132,7 @@ public: void testDeleteTable(); void testPasteUndo(); void testShapeEditInMultipleViews(); + void testGetViewRenderState(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testCreateDestroy); @@ -192,6 +193,7 @@ public: CPPUNIT_TEST(testDeleteTable); CPPUNIT_TEST(testPasteUndo); CPPUNIT_TEST(testShapeEditInMultipleViews); + CPPUNIT_TEST(testGetViewRenderState); CPPUNIT_TEST_SUITE_END(); private: @@ -2538,8 +2540,34 @@ void SdTiledRenderingTest::testCutSelectionChange() CPPUNIT_ASSERT_EQUAL(static_cast<std::size_t>(0), m_aSelection.size()); } +void SdTiledRenderingTest::testGetViewRenderState() +{ + SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); + int nFirstViewId = SfxLokHelper::getView(); + ViewCallback aView1; + CPPUNIT_ASSERT_EQUAL(OString(";Default"), pXImpressDocument->getViewRenderState()); + // Create a second view + SfxLokHelper::createView(); + int nSecondViewId = SfxLokHelper::getView(); + ViewCallback aView2; + CPPUNIT_ASSERT_EQUAL(OString(";Default"), pXImpressDocument->getViewRenderState()); + // Set to dark scheme + { + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(OUString("Dark")) }, + } + ); + dispatchCommand(mxComponent, ".uno:ChangeTheme", aPropertyValues); + } + CPPUNIT_ASSERT_EQUAL(OString(";Dark"), pXImpressDocument->getViewRenderState()); + // Switch back to the first view, and check that the options string is the same + SfxLokHelper::setView(nFirstViewId); + CPPUNIT_ASSERT_EQUAL(OString(";Default"), pXImpressDocument->getViewRenderState()); +} + // Helper function to get a tile to a bitmap and check the pixel color -static void assertTilePixelColor(SdXImpressDocument* pXTextDocument, int nPixelX, int nPixelY, Color aColor) +static void assertTilePixelColor(SdXImpressDocument* pXImpressDocument, int nPixelX, int nPixelY, Color aColor) { size_t nCanvasSize = 1024; size_t nTileSize = 256; @@ -2548,7 +2576,7 @@ static void assertTilePixelColor(SdXImpressDocument* pXTextDocument, int nPixelX pDevice->SetBackground(Wallpaper(COL_TRANSPARENT)); pDevice->SetOutputSizePixelScaleOffsetAndLOKBuffer(Size(nCanvasSize, nCanvasSize), Fraction(1.0), Point(), aPixmap.data()); - pXTextDocument->paintTile(*pDevice, nCanvasSize, nCanvasSize, 0, 0, 15360, 7680); + pXImpressDocument->paintTile(*pDevice, nCanvasSize, nCanvasSize, 0, 0, 15360, 7680); pDevice->EnableMapMode(false); Bitmap aBitmap = pDevice->GetBitmap(Point(0, 0), Size(nTileSize, nTileSize)); Bitmap::ScopedReadAccess pAccess(aBitmap); @@ -2559,42 +2587,70 @@ static void assertTilePixelColor(SdXImpressDocument* pXTextDocument, int nPixelX // Test that changing the theme in one view doesn't change it in the other view void SdTiledRenderingTest::testThemeViewSeparation() { - SdXImpressDocument* pXTextDocument = createDoc("dummy.odp"); + Color aDarkColor(0x1c, 0x1c, 0x1c); + // Add a minimal dark scheme + { + svtools::EditableColorConfig aColorConfig; + svtools::ColorConfigValue aValue; + aValue.bIsVisible = true; + aValue.nColor = aDarkColor; + aColorConfig.SetColorValue(svtools::DOCCOLOR, aValue); + aColorConfig.AddScheme(u"Dark"); + } + // Add a minimal light scheme + { + svtools::EditableColorConfig aColorConfig; + svtools::ColorConfigValue aValue; + aValue.bIsVisible = true; + aValue.nColor = COL_WHITE; + aColorConfig.SetColorValue(svtools::DOCCOLOR, aValue); + aColorConfig.AddScheme(u"Light"); + } + SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp"); int nFirstViewId = SfxLokHelper::getView(); ViewCallback aView1; - // First view is at light mode - assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); + // Switch first view to light scheme + { + uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( + { + { "NewTheme", uno::Any(OUString("Light")) }, + } + ); + dispatchCommand(mxComponent, ".uno:ChangeTheme", aPropertyValues); + } + // First view is at light scheme + assertTilePixelColor(pXImpressDocument, 255, 255, COL_WHITE); // Create second view SfxLokHelper::createView(); int nSecondViewId = SfxLokHelper::getView(); ViewCallback aView2; - // Set second view to dark mode + // Set second view to dark scheme { uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( { - { "NewTheme", uno::Any(OUString("COLOR_SCHEME_LIBREOFFICE_DARK")) }, + { "NewTheme", uno::Any(OUString("Dark")) }, } ); dispatchCommand(mxComponent, ".uno:ChangeTheme", aPropertyValues); } - assertTilePixelColor(pXTextDocument, 255, 255, Color(0x1c, 0x1c, 0x1c)); - // First view still in light mode + assertTilePixelColor(pXImpressDocument, 255, 255, aDarkColor); + // First view still in light scheme SfxLokHelper::setView(nFirstViewId); - assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); - // Second view still in dark mode + assertTilePixelColor(pXImpressDocument, 255, 255, COL_WHITE); + // Second view still in dark scheme SfxLokHelper::setView(nSecondViewId); - assertTilePixelColor(pXTextDocument, 255, 255, Color(0x1c, 0x1c, 0x1c)); - // Switch second view back to light mode + assertTilePixelColor(pXImpressDocument, 255, 255, aDarkColor); + // Switch second view back to light scheme { uno::Sequence<beans::PropertyValue> aPropertyValues = comphelper::InitPropertySequence( { - { "NewTheme", uno::Any(OUString("COLOR_SCHEME_LIBREOFFICE_AUTOMATIC")) }, + { "NewTheme", uno::Any(OUString("Light")) }, } ); dispatchCommand(mxComponent, ".uno:ChangeTheme", aPropertyValues); } - // Now in light mode - assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); + // Now in light scheme + assertTilePixelColor(pXImpressDocument, 255, 255, COL_WHITE); } void SdTiledRenderingTest::testRegenerateDiagram() diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 4653de535761..b0c45ea1913b 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2308,8 +2308,10 @@ OString SdXImpressDocument::getViewRenderState() if (pView) { const SdViewOptions& pVOpt = pView->GetViewOptions(); - if (pVOpt.msColorSchemeName == u"COLOR_SCHEME_LIBREOFFICE_DARK") - aState.append('D'); + aState.append(';'); + + OString aThemeName = OUStringToOString(pVOpt.msColorSchemeName, RTL_TEXTENCODING_UTF8); + aState.append(aThemeName); } return aState.makeStringAndClear(); } diff --git a/sd/source/ui/view/drviewsk.cxx b/sd/source/ui/view/drviewsk.cxx index 541b69534123..3a20691afa54 100644 --- a/sd/source/ui/view/drviewsk.cxx +++ b/sd/source/ui/view/drviewsk.cxx @@ -31,6 +31,7 @@ void DrawViewShell::ConfigurationChanged( utl::ConfigurationBroadcaster* pCb, Co if(pShellBase) pCurrentDrawShell = dynamic_cast<DrawViewShell*>(pShellBase->GetMainViewShell().get()); pCurrentDrawShell->maViewOptions.mnDocBackgroundColor = pColorConfig->GetColorValue(svtools::DOCCOLOR).nColor; + pCurrentDrawShell->maViewOptions.msColorSchemeName = pColorConfig->GetCurrentSchemeName(); SdXImpressDocument* pDoc = comphelper::getFromUnoTunnel<SdXImpressDocument>(pCurrentShell->GetCurrentDocument()); SfxLokHelper::notifyViewRenderState(pCurrentShell, pDoc); Color aFillColor(pColorConfig->GetColorValue(svtools::APPBACKGROUND).nColor); diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index 93cd989dc64e..d382116d2a2d 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -362,60 +362,64 @@ ColorConfig::~ColorConfig() Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry) { - static const Color aAutoColors[] = - { - COL_WHITE, // DOCCOLOR - COL_LIGHTGRAY, // DOCBOUNDARIES - Color(0xDFDFDE), // APPBACKGROUND - COL_LIGHTGRAY, // OBJECTBOUNDARIES - COL_LIGHTGRAY, // TABLEBOUNDARIES - COL_BLACK, // FONTCOLOR - COL_BLUE, // LINKS - Color(0x0000cc), // LINKSVISITED - COL_LIGHTRED, // SPELL - COL_LIGHTBLUE, // GRAMMAR - COL_LIGHTMAGENTA, // SMARTTAGS - COL_GRAY, // SHADOWCOLOR - COL_LIGHTGRAY, // WRITERTEXTGRID - COL_LIGHTGRAY, // WRITERFIELDSHADIN - COL_LIGHTGRAY, // WRITERIDXSHADINGS - COL_BLACK, // WRITERDIRECTCURSOR - COL_GREEN, //WRITERSCRIPTINDICATOR - COL_LIGHTGRAY, //WRITERSECTIONBOUNDARIES - Color(0x0369a3), //WRITERHEADERFOOTERMARK, - COL_BLUE, //WRITERPAGEBREAKS, - COL_LIGHTBLUE, // HTMLSGML - COL_LIGHTGREEN, // HTMLCOMMENT - COL_LIGHTRED, // HTMLKEYWORD - COL_GRAY, // HTMLUNKNOWN - COL_GRAY3, // CALCGRID - COL_BLUE, //CALCPAGEBREAK - Color(0x2300dc), //CALCPAGEBREAKMANUAL - COL_GRAY7, //CALCPAGEBREAKAUTOMATIC - Color(0x2300dc), //CALCHIDDENCOLROW - COL_LIGHTBLUE, // CALCDETECTIVE - COL_LIGHTRED, // CALCDETECTIVEERROR - Color(0xef0fff), // CALCREFERENCE - Color(0xffffc0), // CALCNOTESBACKGROUND - COL_LIGHTBLUE, // CALCVALUE - COL_GREEN, // CALCFORMULA - COL_BLACK, // CALCTEXT - COL_LIGHTGRAY, // CALCPROTECTEDBACKGROUND - COL_GRAY7, // DRAWGRID - COL_GREEN, // BASICIDENTIFIER, - COL_GRAY, // BASICCOMMENT, - COL_LIGHTRED, // BASICNUMBER, - COL_LIGHTRED, // BASICSTRING, - COL_BLUE, // BASICOPERATOR, - COL_BLUE, // BASICKEYWORD, - COL_RED, //BASICERROR - Color(0x009900), // SQLIDENTIFIER - COL_BLACK, // SQLNUMBER - Color(0xCE7B00), // SQLSTRING - COL_BLACK, // SQLOPERATOR - Color(0x0000E6), // SQLKEYWORD - Color(0x259D9D), // SQLPARAMETER - COL_GRAY, // SQLCOMMENT + enum ColorType { clLight = 0, + clDark, + nColorTypes }; + + static const Color cAutoColors[][nColorTypes] = { + { COL_WHITE, Color(0x1C1C1C) }, // DOCCOLOR + { COL_LIGHTGRAY, Color(0x808080) }, // DOCBOUNDARIES + { Color(0xDFDFDE), Color(0x333333) }, // APPBACKGROUND + { COL_LIGHTGRAY, Color(0x808080) }, // OBJECTBOUNDARIES + { COL_LIGHTGRAY, Color(0x1C1C1C) }, // TABLEBOUNDARIES + { COL_BLACK, COL_BLACK }, // FONTCOLOR + { COL_BLUE, Color(0x1D99F3) }, // LINKS + { Color(0x0000cc), Color(0x9B59B6) }, // LINKSVISITED + { COL_LIGHTRED, Color(0xC9211E) }, // SPELL + { COL_LIGHTBLUE, Color(0x729FCF) }, // GRAMMAR + { COL_LIGHTMAGENTA, Color(0x780373) }, // SMARTTAGS + { COL_GRAY, Color(0x1C1C1C) }, // SHADOWCOLOR + { COL_LIGHTGRAY, Color(0x808080) }, // WRITERTEXTGRID + { COL_LIGHTGRAY, COL_LIGHTGRAY }, // WRITERFIELDSHADING + { COL_LIGHTGRAY, Color(0x1C1C1C) }, // WRITERIDXSHADINGS + { COL_BLACK, COL_BLACK }, // WRITERDIRECTCURSOR + { COL_GREEN, Color(0x1E6A39) }, // WRITERSCRIPTINDICATOR + { COL_LIGHTGRAY, Color(0x666666) }, // WRITERSECTIONBOUNDARIES + { Color(0x0369a3), Color(0xB4C7DC) }, // WRITERHEADERFOOTERMARK + { COL_BLUE, Color(0x729FCF) }, // WRITERPAGEBREAKS + { COL_LIGHTBLUE, COL_LIGHTBLUE }, // HTMLSGML + { COL_LIGHTGREEN, COL_LIGHTGREEN }, // HTMLCOMMENT + { COL_LIGHTRED, COL_LIGHTRED }, // HTMLKEYWORD + { COL_GRAY, COL_GRAY }, // HTMLUNKNOWN + { COL_GRAY3, COL_GRAY7 }, // CALCGRID + { COL_BLUE, COL_BLUE }, // CALCPAGEBREAK + { Color(0x2300dc), Color(0x2300DC) }, // CALCPAGEBREAKMANUAL + { COL_GRAY7, COL_GRAY7 }, // CALCPAGEBREAKAUTOMATIC + { Color(0x2300dc), Color(0x2300DC) }, // CALCHIDDENCOLROW + { COL_LIGHTBLUE, Color(0x355269) }, // CALCDETECTIVE + { COL_LIGHTRED, Color(0xC9211E) }, // CALCDETECTIVEERROR + { Color(0xef0fff), Color(0x0D23D5) }, // CALCREFERENCE + { Color(0xffffc0), Color(0xE8A202) }, // CALCNOTESBACKGROUND + { COL_LIGHTBLUE, Color(0x729FCF) }, // CALCVALUE + { COL_GREEN, Color(0x77BC65) }, // CALCFORMULA + { COL_BLACK, Color(0xEEEEEE) }, // CALCTEXT + { COL_LIGHTGRAY, Color(0x1C1C1C) }, // CALCPROTECTEDBACKGROUND + { COL_GRAY7, COL_GRAY7 }, // DRAWGRID + { COL_WHITE, Color(0x1C1C1C) }, // BASICEDITOR + { COL_GREEN, Color(0xDDE8CB) }, // BASICIDENTIFIER + { COL_GRAY, Color(0xEEEEEE) }, // BASICCOMMENT + { COL_LIGHTRED, Color(0xFFA6A6) }, // BASICNUMBER + { COL_LIGHTRED, Color(0xFFA6A6) }, // BASICSTRING + { COL_BLUE, Color(0xB4C7DC) }, // BASICOPERATOR + { COL_BLUE, Color(0xB4C7DC) }, // BASICKEYWORD + { COL_RED, Color(0xFF3838) }, // BASICERROR + { Color(0x009900), Color(0x009900) }, // SQLIDENTIFIER + { COL_BLACK, COL_BLACK }, // SQLNUMBER + { Color(0xCE7B00), Color(0xCE7B00) }, // SQLSTRING + { COL_BLACK, COL_BLACK }, // SQLOPERATOR + { Color(0x0000E6), Color(0x0000E6) }, // SQLKEYWORD + { Color(0x259D9D), Color(0x259D9D) }, // SQLPARAMETER + { COL_GRAY, COL_GRAY }, // SQLCOMMENT }; Color aRet; switch(eEntry) @@ -433,7 +437,14 @@ Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry) break; default: - aRet = aAutoColors[eEntry]; + int nAppMod; + switch (MiscSettings::GetAppColorMode()) { + case 0: nAppMod = clLight; break; // UseDarkMode() ? clDark : clLight; break; + case 1: nAppMod = clLight; break; + case 2: nAppMod = clDark; break; + default: nAppMod = clLight; + } + aRet = cAutoColors[eEntry][nAppMod]; } // fdo#71511: if in a11y HC mode, do pull background color from theme if (Application::GetSettings().GetStyleSettings().GetHighContrastMode()) diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 8e4ff3ea4077..15854f194f2a 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -1685,7 +1685,6 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testGetViewRenderState) pXTextDocument->GetDocShell()->GetWrtShell()->ApplyViewOptions(aViewOptions); } CPPUNIT_ASSERT_EQUAL(OString("PS;Default"), pXTextDocument->getViewRenderState()); - // Create a second view SfxLokHelper::createView(); int nSecondViewId = SfxLokHelper::getView(); @@ -1698,11 +1697,9 @@ CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testGetViewRenderState) pXTextDocument->GetDocShell()->GetWrtShell()->ApplyViewOptions(aViewOptions); } CPPUNIT_ASSERT_EQUAL(OString("S;Default"), 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;Default"), pXTextDocument->getViewRenderState()); - // Switch back to the second view, and change to dark mode SfxLokHelper::setView(nSecondViewId); { @@ -1743,47 +1740,78 @@ static void assertTilePixelColor(SwXTextDocument* pXTextDocument, int nPixelX, i // Test that changing the theme in one view doesn't change it in the other view CPPUNIT_TEST_FIXTURE(SwTiledRenderingTest, testThemeViewSeparation) { + Color aDarkColor(0x1c, 0x1c, 0x1c); + // Add a minimal dark scheme + { + svtools::EditableColorConfig aColorConfig; + svtools::ColorConfigValue aValue; + aValue.bIsVisible = true; + aValue.nColor = aDarkColor; + aColorConfig.SetColorValue(svtools::DOCCOLOR, aValue); + aColorConfig.AddScheme(u"Dark"); + } + // Add a minimal light scheme + { + svtools::EditableColorConfig aColorConfig; + svtools::ColorConfigValue aValue; + aValue.bIsVisible = true; + aValue.nColor = COL_WHITE; + aColorConfig.SetColorValue(svtools::DOCCOLOR, aValue); + aColorConfig.AddScheme(u"Light"); + } SwXTextDocument* pXTextDocument = createDoc(); int nFirstViewId = SfxLokHelper::getView(); ViewCallback aView1; - // First view is at light mode + // Set first view to light 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("Light")) }, + } + ); + comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); + } + // First view is in light scheme assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); // Create second view SfxLokHelper::createView(); int nSecondViewId = SfxLokHelper::getView(); ViewCallback aView2; - // Set second view to dark mode + // 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("COLOR_SCHEME_LIBREOFFICE_DARK")) }, + { "NewTheme", uno::Any(OUString("Dark")) }, } ); comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); } - assertTilePixelColor(pXTextDocument, 255, 255, Color(0x1c, 0x1c, 0x1c)); - // First view still in light mode + assertTilePixelColor(pXTextDocument, 255, 255, aDarkColor); + // First view still in light scheme SfxLokHelper::setView(nFirstViewId); assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); - // Second view still in dark mode + // Second view still in dark scheme SfxLokHelper::setView(nSecondViewId); - assertTilePixelColor(pXTextDocument, 255, 255, Color(0x1c, 0x1c, 0x1c)); - // Switch second view back to light mode + assertTilePixelColor(pXTextDocument, 255, 255, aDarkColor); + // Switch second view back to light 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("COLOR_SCHEME_LIBREOFFICE_AUTOMATIC")) }, + { "NewTheme", uno::Any(OUString("Light")) }, } ); comphelper::dispatchCommand(".uno:ChangeTheme", xFrame, aPropertyValues); } - // Now in light mode + // Now in light scheme assertTilePixelColor(pXTextDocument, 255, 255, COL_WHITE); } diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx index 71d58a4aa5a8..9e7f13cc256d 100644 --- a/vcl/source/app/settings.cxx +++ b/vcl/source/app/settings.cxx @@ -2786,6 +2786,18 @@ void MiscSettings::SetDarkMode(int nMode) } } +int MiscSettings::GetAppColorMode() +{ + return officecfg::Office::Common::Misc::ApplicationAppearance::get(); +} + +void MiscSettings::SetAppColorMode(int nMode) +{ + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Common::Misc::ApplicationAppearance::set(nMode, batch); + batch->commit(); +} + HelpSettings::HelpSettings() : mxData(std::make_shared<ImplHelpData>()) {
