diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc index e911e1d0d65d..4fb5892ba84b 100644 --- a/include/sfx2/sfxsids.hrc +++ b/include/sfx2/sfxsids.hrc @@ -469,6 +469,7 @@ class SvxZoomItem; #define SID_ACCESSIBILITY_CHECK (SID_SFX_START + 812) #define SID_ASYNCHRON (SID_SFX_START + 813) #define SID_ACCESSIBILITY_CHECK_ONLINE (SID_SFX_START + 814) +#define SID_THEME_DIALOG (SID_SFX_START + 815) // default-ids for configuration #define SID_CONFIG (SID_SFX_START + 904) diff --git a/include/svx/dialog/ThemeDialog.hxx b/include/svx/dialog/ThemeDialog.hxx new file mode 100644 index 000000000000..968c54af9e98 --- /dev/null +++ b/include/svx/dialog/ThemeDialog.hxx @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace svx +{ +class SVX_DLLPUBLIC ThemeDialog final : public weld::GenericDialogController +{ +private: + svx::Theme* mpTheme; + svx::ColorSets maColorSets; + std::shared_ptr mpChanger; + + std::unique_ptr mxValueSetThemeColors; + std::unique_ptr mxValueSetThemeColorsWindow; + +public: + ThemeDialog(weld::Window* pParent, svx::Theme* pTheme, + std::shared_ptr const& pChanger); + virtual ~ThemeDialog() override; + + DECL_LINK(DoubleClickValueSetHdl, ValueSet*, void); + void DoubleClickHdl(); +}; + +} // end svx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/theme/IThemeColorChanger.hxx b/include/svx/theme/IThemeColorChanger.hxx new file mode 100644 index 000000000000..5f90f273ee37 --- /dev/null +++ b/include/svx/theme/IThemeColorChanger.hxx @@ -0,0 +1,26 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include + +namespace svx +{ +class SVX_DLLPUBLIC IThemeColorChanger +{ +public: + virtual ~IThemeColorChanger() = default; + virtual void apply(svx::ColorSet const& rColorSet) = 0; +}; + +} // end svx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu index 9fa3b776f790..250d641f3b25 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/GenericCommands.xcu @@ -7465,6 +7465,14 @@ bit 3 (0x8): #define UICOMMANDDESCRIPTION_PROPERTIES_TOGGLEBUTTON 8 1 + + + Theme... + + + 1 + + Open the Properties Deck diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 9021b46d7f1b..f4b2befd5394 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -175,6 +175,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/dialog/swframeexample \ svx/source/dialog/swframeposstrings \ svx/source/dialog/ThemeColorValueSet \ + svx/source/dialog/ThemeDialog \ svx/source/dialog/txencbox \ svx/source/dialog/txenctab \ svx/source/dialog/weldeditview \ diff --git a/svx/UIConfig_svx.mk b/svx/UIConfig_svx.mk index 33bc1797f20f..9f12a4819b53 100644 --- a/svx/UIConfig_svx.mk +++ b/svx/UIConfig_svx.mk @@ -142,6 +142,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svx,\ svx/uiconfig/ui/textcontrolchardialog \ svx/uiconfig/ui/textcontrolparadialog \ svx/uiconfig/ui/textunderlinecontrol \ + svx/uiconfig/ui/themedialog \ svx/uiconfig/ui/toolbarpopover \ svx/uiconfig/ui/xmlsecstatmenu \ svx/uiconfig/ui/xformspage \ diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index 82c5700db86b..6710fdf145a7 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -12529,6 +12529,23 @@ SfxVoidItem GraphicSizeCheck SID_GRAPHIC_SIZE_CHECK GroupId = SfxGroupId::Modify; ] +SfxVoidItem ThemeDialog SID_THEME_DIALOG +() +[ + AutoUpdate = FALSE, + FastCall = FALSE, + ReadOnlyDoc = TRUE, + Toggle = FALSE, + Container = FALSE, + RecordAbsolute = FALSE, + RecordPerSet; + + AccelConfig = FALSE, + MenuConfig = FALSE, + ToolBoxConfig = FALSE, + GroupId = SfxGroupId::Modify; +] + SfxVoidItem AccessibilityCheck SID_ACCESSIBILITY_CHECK () [ diff --git a/svx/source/dialog/ThemeDialog.cxx b/svx/source/dialog/ThemeDialog.cxx new file mode 100644 index 000000000000..449a466e88e4 --- /dev/null +++ b/svx/source/dialog/ThemeDialog.cxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include +#include +#include + +namespace svx +{ +ThemeDialog::ThemeDialog(weld::Window* pParent, svx::Theme* pTheme, + std::shared_ptr const& pChanger) + : GenericDialogController(pParent, "svx/ui/themedialog.ui", "ThemeDialog") + , mpTheme(pTheme) + , mpChanger(pChanger) + , mxValueSetThemeColors(new svx::ThemeColorValueSet) + , mxValueSetThemeColorsWindow( + new weld::CustomWeld(*m_xBuilder, "valueset_theme_colors", *mxValueSetThemeColors)) +{ + mxValueSetThemeColors->SetColCount(2); + mxValueSetThemeColors->SetLineCount(6); + mxValueSetThemeColors->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor()); + mxValueSetThemeColors->SetDoubleClickHdl(LINK(this, ThemeDialog, DoubleClickValueSetHdl)); + + maColorSets.init(); + maColorSets.insert(*mpTheme->GetColorSet()); + + for (auto const& rColorSet : maColorSets.getColorSets()) + { + mxValueSetThemeColors->insert(rColorSet); + } + + mxValueSetThemeColors->SetOptimalSize(); + + if (!maColorSets.getColorSets().empty()) + mxValueSetThemeColors->SelectItem(1); // ItemId 1, position 0 +} + +ThemeDialog::~ThemeDialog() = default; + +IMPL_LINK_NOARG(ThemeDialog, DoubleClickValueSetHdl, ValueSet*, void) { DoubleClickHdl(); } + +void ThemeDialog::DoubleClickHdl() +{ + sal_uInt32 nItemId = mxValueSetThemeColors->GetSelectedItemId(); + if (!nItemId) + return; + + sal_uInt32 nIndex = nItemId - 1; + + svx::ColorSet const& rColorSet = maColorSets.getColorSet(nIndex); + + mpChanger->apply(rColorSet); +} + +} // end svx namespace + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/uiconfig/ui/themedialog.ui b/svx/uiconfig/ui/themedialog.ui new file mode 100644 index 000000000000..90aecc8ad1c9 --- /dev/null +++ b/svx/uiconfig/ui/themedialog.ui @@ -0,0 +1,145 @@ + + + + + + 640 + 480 + False + True + True + 6 + Theme + dialog + + + False + True + True + vertical + 12 + + + False + end + + + _Help + True + True + True + True + + + False + True + 0 + + + + + _OK + True + True + True + True + True + True + + + False + True + 1 + + + + + _Cancel + True + True + True + True + + + False + True + 2 + + + + + False + True + end + 0 + + + + + True + True + False + True + + + + True + False + + + True + True + False + False + never + never + in + + + True + False + + + True + False + GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_STRUCTURE_MASK + True + True + + + + + + + 0 + 0 + + + + + + + True + False + Colors + + + False + + + + + False + True + 1 + + + + + + help + ok + cancel + + + diff --git a/sw/sdi/_basesh.sdi b/sw/sdi/_basesh.sdi index 5ac4cb001eb3..a1468ffac8b1 100644 --- a/sw/sdi/_basesh.sdi +++ b/sw/sdi/_basesh.sdi @@ -617,4 +617,11 @@ interface BaseTextSelection StateMethod = GetState; DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; ] + + SID_THEME_DIALOG + [ + ExecMethod = ExecDlg; + StateMethod = GetState; + DisableFlags="SfxDisableFlags::SwOnProtectedCursor"; + ] } diff --git a/sw/source/core/inc/ThemeColorChanger.hxx b/sw/source/core/inc/ThemeColorChanger.hxx index 0698126da3e9..d4ba7a9fcad5 100644 --- a/sw/source/core/inc/ThemeColorChanger.hxx +++ b/sw/source/core/inc/ThemeColorChanger.hxx @@ -11,10 +11,11 @@ #include #include +#include namespace sw { -class ThemeColorChanger +class ThemeColorChanger : public svx::IThemeColorChanger { private: SwDocShell* mpDocSh; @@ -25,7 +26,9 @@ public: { } - void apply(svx::ColorSet const& rColorSet); + virtual ~ThemeColorChanger() override; + + void apply(svx::ColorSet const& rColorSet) override; }; } // end sw namespace diff --git a/sw/source/core/model/ThemeColorChanger.cxx b/sw/source/core/model/ThemeColorChanger.cxx index ff59c474748b..4c739547685b 100644 --- a/sw/source/core/model/ThemeColorChanger.cxx +++ b/sw/source/core/model/ThemeColorChanger.cxx @@ -229,6 +229,8 @@ void changeColor(SwFormat* pFormat, svx::ColorSet const& rColorSet, SwDoc* pDocu } // end anonymous namespace +ThemeColorChanger::~ThemeColorChanger() {} + void ThemeColorChanger::apply(svx::ColorSet const& rColorSet) { SwDoc* pDocument = mpDocSh->GetDoc(); diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx index 2e7489fda6de..44759890e695 100644 --- a/sw/source/uibase/shells/basesh.cxx +++ b/sw/source/uibase/shells/basesh.cxx @@ -80,8 +80,11 @@ #include #include #include +#include #include +#include #include +#include #include #include #include @@ -94,6 +97,7 @@ #include #include +#include #include #include #include @@ -2203,6 +2207,10 @@ void SwBaseShell::GetState( SfxItemSet &rSet ) rSet.DisableItem(nWhich); } break; + case SID_THEME_DIALOG: + { + } + break; } nWhich = aIter.NextWhich(); } @@ -3028,6 +3036,24 @@ void SwBaseShell::ExecDlg(SfxRequest &rReq) } break; + case SID_THEME_DIALOG: + { + auto* pDocument = rSh.GetDoc(); + auto* pDocumentShell = pDocument->GetDocShell(); + if (pDocumentShell) + { + SdrPage* pPage = pDocument->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + svx::Theme* pTheme = pPage->getSdrPageProperties().GetTheme(); + if (pTheme) + { + std::shared_ptr pChanger(new sw::ThemeColorChanger(pDocumentShell)); + auto pDialog = std::make_shared(pMDI, pTheme, pChanger); + weld::DialogController::runAsync(pDialog, [](int) {}); + } + } + } + break; + default:OSL_FAIL("wrong Dispatcher (basesh.cxx)"); } if(!bDone) diff --git a/sw/uiconfig/sglobal/menubar/menubar.xml b/sw/uiconfig/sglobal/menubar/menubar.xml index b933889b88f2..9b9d37689f10 100644 --- a/sw/uiconfig/sglobal/menubar/menubar.xml +++ b/sw/uiconfig/sglobal/menubar/menubar.xml @@ -443,6 +443,7 @@ + diff --git a/sw/uiconfig/swriter/menubar/menubar.xml b/sw/uiconfig/swriter/menubar/menubar.xml index 3b48071edb82..295dfe7280c6 100644 --- a/sw/uiconfig/swriter/menubar/menubar.xml +++ b/sw/uiconfig/swriter/menubar/menubar.xml @@ -454,6 +454,7 @@ +